mirror of
https://github.com/intel/llvm.git
synced 2026-01-16 05:32:28 +08:00
[BOLT] Add createCondBranch() and createLongUncondBranch() (#85315)
Add MCPlusBuilder interface for creating two new branch types.
This commit is contained in:
@@ -1558,6 +1558,13 @@ public:
|
||||
llvm_unreachable("not implemented");
|
||||
}
|
||||
|
||||
/// Create a version of unconditional jump that has the largest span for a
|
||||
/// single instruction with direct target.
|
||||
virtual void createLongUncondBranch(MCInst &Inst, const MCSymbol *Target,
|
||||
MCContext *Ctx) const {
|
||||
llvm_unreachable("not implemented");
|
||||
}
|
||||
|
||||
/// Creates a new call instruction in Inst and sets its operand to
|
||||
/// Target.
|
||||
virtual void createCall(MCInst &Inst, const MCSymbol *Target,
|
||||
@@ -1675,6 +1682,12 @@ public:
|
||||
return Inst.getOpcode() == TargetOpcode::CFI_INSTRUCTION;
|
||||
}
|
||||
|
||||
/// Create a conditional branch with a target-specific conditional code \p CC.
|
||||
virtual void createCondBranch(MCInst &Inst, const MCSymbol *Target,
|
||||
unsigned CC, MCContext *Ctx) const {
|
||||
llvm_unreachable("not implemented");
|
||||
}
|
||||
|
||||
/// Reverses the branch condition in Inst and update its taken target to TBB.
|
||||
///
|
||||
/// Returns true on success.
|
||||
|
||||
@@ -2734,6 +2734,14 @@ public:
|
||||
MCSymbolRefExpr::create(TBB, MCSymbolRefExpr::VK_None, *Ctx)));
|
||||
}
|
||||
|
||||
void createLongUncondBranch(MCInst &Inst, const MCSymbol *Target,
|
||||
MCContext *Ctx) const override {
|
||||
Inst.setOpcode(X86::JMP_4);
|
||||
Inst.clear();
|
||||
Inst.addOperand(MCOperand::createExpr(
|
||||
MCSymbolRefExpr::create(Target, MCSymbolRefExpr::VK_None, *Ctx)));
|
||||
}
|
||||
|
||||
void createCall(MCInst &Inst, const MCSymbol *Target,
|
||||
MCContext *Ctx) override {
|
||||
Inst.setOpcode(X86::CALL64pcrel32);
|
||||
@@ -2759,6 +2767,15 @@ public:
|
||||
Inst.setOpcode(X86::TRAP);
|
||||
}
|
||||
|
||||
void createCondBranch(MCInst &Inst, const MCSymbol *Target, unsigned CC,
|
||||
MCContext *Ctx) const override {
|
||||
Inst.setOpcode(X86::JCC_1);
|
||||
Inst.clear();
|
||||
Inst.addOperand(MCOperand::createExpr(
|
||||
MCSymbolRefExpr::create(Target, MCSymbolRefExpr::VK_None, *Ctx)));
|
||||
Inst.addOperand(MCOperand::createImm(CC));
|
||||
}
|
||||
|
||||
bool reverseBranchCondition(MCInst &Inst, const MCSymbol *TBB,
|
||||
MCContext *Ctx) const override {
|
||||
unsigned InvCC = getInvertedCondCode(getCondCode(Inst));
|
||||
|
||||
Reference in New Issue
Block a user