Thumb ADD(immediate) parsing support.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137788 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jim Grosbach 2011-08-16 23:57:34 +00:00
parent 16280308ac
commit 89e2aa6afd
3 changed files with 21 additions and 4 deletions

View File

@ -849,7 +849,7 @@ def tADC : // A8.6.2
// Add immediate
def tADDi3 : // A8.6.4 T1
T1sIGenEncodeImm<0b01110, (outs tGPR:$Rd), (ins tGPR:$Rm, i32imm:$imm3),
T1sIGenEncodeImm<0b01110, (outs tGPR:$Rd), (ins tGPR:$Rm, imm0_7:$imm3),
IIC_iALUi,
"add", "\t$Rd, $Rm, $imm3",
[(set tGPR:$Rd, (add tGPR:$Rm, imm0_7:$imm3))]> {
@ -858,8 +858,8 @@ def tADDi3 : // A8.6.4 T1
}
def tADDi8 : // A8.6.4 T2
T1sItGenEncodeImm<{1,1,0,?,?}, (outs tGPR:$Rdn), (ins tGPR:$Rn, i32imm:$imm8),
IIC_iALUi,
T1sItGenEncodeImm<{1,1,0,?,?}, (outs tGPR:$Rdn),
(ins tGPR:$Rn, imm0_255:$imm8), IIC_iALUi,
"add", "\t$Rdn, $imm8",
[(set tGPR:$Rdn, (add tGPR:$Rn, imm8_255:$imm8))]>;

View File

@ -3013,6 +3013,11 @@ processInstruction(MCInst &Inst,
Inst = TmpInst;
}
break;
case ARM::tADDi8:
// If the immediate is in the range 0-7, we really wanted tADDi3.
if (Inst.getOperand(3).getImm() < 8)
Inst.setOpcode(ARM::tADDi3);
break;
}
}

View File

@ -11,6 +11,18 @@
_func:
@ CHECK: _func
@------------------------------------------------------------------------------
@ ADD (immediate)
@------------------------------------------------------------------------------
adds r1, r2, #3
adds r2, #3
adds r2, #8
@ CHECK: adds r1, r2, #3 @ encoding: [0xd1,0x1c]
@ CHECK: adds r2, r2, #3 @ encoding: [0xd2,0x1c]
@ CHECK: adds r2, #8 @ encoding: [0x08,0x32]
@------------------------------------------------------------------------------
@ ADD (register)
@------------------------------------------------------------------------------
@ -18,4 +30,4 @@ _func:
add r2, r8
@ CHECK: adds r1, r2, r3 @ encoding: [0xd1,0x18]
@ CHECK: add r2, r8 @ encoding: [0x42,0x44]
CHECK: add r2, r8 @ encoding: [0x42,0x44]