mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-01 05:01:59 +01:00
[AVR] Insert JMP for long branches
Previously, on long branches (relative jumps of >4 kB), an assertion failure was hit, as AVRInstrInfo::insertIndirectBranch was not implemented. Despite its name, it is called by the branch relaxator for *all* unconditional jumps. Patch by Thomas Backman. llvm-svn: 314891
This commit is contained in:
parent
e4b79b6c71
commit
10d9b07b8a
@ -537,8 +537,7 @@ bool AVRInstrInfo::isBranchOffsetInRange(unsigned BranchOp,
|
||||
llvm_unreachable("unexpected opcode!");
|
||||
case AVR::JMPk:
|
||||
case AVR::CALLk:
|
||||
assert(BrOffset >= 0 && "offset must be absolute address");
|
||||
return isUIntN(16, BrOffset);
|
||||
return true;
|
||||
case AVR::RCALLk:
|
||||
case AVR::RJMPk:
|
||||
return isIntN(13, BrOffset);
|
||||
@ -556,5 +555,20 @@ bool AVRInstrInfo::isBranchOffsetInRange(unsigned BranchOp,
|
||||
}
|
||||
}
|
||||
|
||||
unsigned AVRInstrInfo::insertIndirectBranch(MachineBasicBlock &MBB,
|
||||
MachineBasicBlock &NewDestBB,
|
||||
const DebugLoc &DL,
|
||||
int64_t BrOffset,
|
||||
RegScavenger *RS) const {
|
||||
// This method inserts a *direct* branch (JMP), despite its name.
|
||||
// LLVM calls this method to fixup unconditional branches; it never calls
|
||||
// insertBranch or some hypothetical "insertDirectBranch".
|
||||
// See lib/CodeGen/RegisterRelaxation.cpp for details.
|
||||
// We end up here when a jump is too long for a RJMP instruction.
|
||||
auto &MI = *BuildMI(&MBB, DL, get(AVR::JMPk)).addMBB(&NewDestBB);
|
||||
|
||||
return getInstSizeInBytes(MI);
|
||||
}
|
||||
|
||||
} // end of namespace llvm
|
||||
|
||||
|
@ -107,6 +107,12 @@ public:
|
||||
|
||||
bool isBranchOffsetInRange(unsigned BranchOpc,
|
||||
int64_t BrOffset) const override;
|
||||
|
||||
unsigned insertIndirectBranch(MachineBasicBlock &MBB,
|
||||
MachineBasicBlock &NewDestBB,
|
||||
const DebugLoc &DL,
|
||||
int64_t BrOffset,
|
||||
RegScavenger *RS) const override;
|
||||
private:
|
||||
const AVRRegisterInfo RI;
|
||||
};
|
||||
|
4137
test/CodeGen/AVR/branch-relaxation-long.ll
Normal file
4137
test/CodeGen/AVR/branch-relaxation-long.ll
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user