add another target hook for branch folding.

llvm-svn: 31262
This commit is contained in:
Chris Lattner 2006-10-28 17:29:57 +00:00
parent eef273a16f
commit 53ebf20c26
3 changed files with 21 additions and 0 deletions

View File

@ -318,6 +318,14 @@ public:
assert(0 && "Target didn't implement TargetInstrInfo::InsertBranch!");
}
/// BlockHasNoFallThrough - Return true if the specified block does not
/// fall-through into its successor block. This is primarily used when a
/// branch is unanalyzable. It is useful for things like unconditional
/// indirect branches (jump tables).
virtual bool BlockHasNoFallThrough(MachineBasicBlock &MBB) const {
return false;
}
/// ReverseBranchCondition - Reverses the branch condition of the specified
/// condition list, returning false on success and true if it cannot be
/// reversed.

View File

@ -420,6 +420,18 @@ void X86InstrInfo::InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
BuildMI(&MBB, X86::JMP, 1).addMBB(FBB);
}
bool X86InstrInfo::BlockHasNoFallThrough(MachineBasicBlock &MBB) const {
if (MBB.empty()) return false;
switch (MBB.back().getOpcode()) {
case X86::JMP: // Uncond branch.
case X86::JMP32r: // Indirect branch.
case X86::JMP32m: // Indirect branch through mem.
return true;
default: return false;
}
}
bool X86InstrInfo::
ReverseBranchCondition(std::vector<MachineOperand> &Cond) const {
assert(Cond.size() == 1 && "Invalid X86 branch condition!");

View File

@ -267,6 +267,7 @@ public:
virtual void InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
MachineBasicBlock *FBB,
const std::vector<MachineOperand> &Cond) const;
virtual bool BlockHasNoFallThrough(MachineBasicBlock &MBB) const;
virtual bool ReverseBranchCondition(std::vector<MachineOperand> &Cond) const;
const TargetRegisterClass *getPointerRegClass() const;