Encode pc-relative conditional branch offset as pc+(num of bytes / 4). The

asm printer will print it as offset*4. e.g. bne cr0, $+8.

The PPC code emitter was expecting the offset to be number of instructions, not
number of bytes. This fixes a whole bunch of JIT failures.

llvm-svn: 29885
This commit is contained in:
Evan Cheng 2006-08-25 21:54:44 +00:00
parent 50eac3b8ab
commit d7572fb234
2 changed files with 2 additions and 2 deletions

View File

@ -131,7 +131,7 @@ namespace {
// Branches can take an immediate operand. This is used by the branch
// selection pass to print $+8, an eight byte displacement from the PC.
if (MI->getOperand(OpNo).isImmediate()) {
O << "$+" << MI->getOperand(OpNo).getImmedValue();
O << "$+" << MI->getOperand(OpNo).getImmedValue()*4;
} else {
printOp(MI->getOperand(OpNo));
}

View File

@ -133,7 +133,7 @@ bool PPCBSel::runOnMachineFunction(MachineFunction &Fn) {
if (Displacement >= -32768 && Displacement <= 32767) {
BuildMI(*MBB, MBBJ, Opcode, 2).addReg(CRReg).addMBB(trueMBB);
} else {
BuildMI(*MBB, MBBJ, Inverted, 2).addReg(CRReg).addImm(8);
BuildMI(*MBB, MBBJ, Inverted, 2).addReg(CRReg).addImm(2);
BuildMI(*MBB, MBBJ, PPC::B, 1).addMBB(trueMBB);
}