mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
ARM assembly 'cmp lr, #0' should not encode using 'cmn'.
The CMP->CMN alias was matching for an immediate of zero when it should only match for negative values. rdar://11129224 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153689 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
182c34b121
commit
b22e70d835
@ -251,7 +251,8 @@ def imm16_31 : ImmLeaf<i32, [{
|
||||
|
||||
def so_imm_neg_asmoperand : AsmOperandClass { let Name = "ARMSOImmNeg"; }
|
||||
def so_imm_neg : Operand<i32>, PatLeaf<(imm), [{
|
||||
return ARM_AM::getSOImmVal(-(uint32_t)N->getZExtValue()) != -1;
|
||||
int64_t Value = -(int)N->getZExtValue();
|
||||
return Value && ARM_AM::getSOImmVal(Value) != -1;
|
||||
}], so_imm_neg_XFORM> {
|
||||
let ParserMatchClass = so_imm_neg_asmoperand;
|
||||
}
|
||||
|
@ -89,7 +89,8 @@ def t2_so_imm_not : Operand<i32>, PatLeaf<(imm), [{
|
||||
// t2_so_imm_neg - Match an immediate that is a negation of a t2_so_imm.
|
||||
def t2_so_imm_neg_asmoperand : AsmOperandClass { let Name = "T2SOImmNeg"; }
|
||||
def t2_so_imm_neg : Operand<i32>, PatLeaf<(imm), [{
|
||||
return ARM_AM::getT2SOImmVal(-((uint32_t)N->getZExtValue())) != -1;
|
||||
int64_t Value = -(int)N->getZExtValue();
|
||||
return Value && ARM_AM::getT2SOImmVal(Value) != -1;
|
||||
}], t2_so_imm_neg_XFORM> {
|
||||
let ParserMatchClass = t2_so_imm_neg_asmoperand;
|
||||
}
|
||||
|
@ -782,7 +782,8 @@ public:
|
||||
const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(getImm());
|
||||
if (!CE) return false;
|
||||
int64_t Value = CE->getValue();
|
||||
return ARM_AM::getSOImmVal(-Value) != -1;
|
||||
// Negation must be representable as an so_imm and be non-zero.
|
||||
return Value && ARM_AM::getSOImmVal(-Value) != -1;
|
||||
}
|
||||
bool isT2SOImm() const {
|
||||
if (!isImm()) return false;
|
||||
@ -803,7 +804,8 @@ public:
|
||||
const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(getImm());
|
||||
if (!CE) return false;
|
||||
int64_t Value = CE->getValue();
|
||||
return ARM_AM::getT2SOImmVal(-Value) != -1;
|
||||
// Negation must be representable as a t2_so_imm and be non-zero.
|
||||
return Value && ARM_AM::getT2SOImmVal(-Value) != -1;
|
||||
}
|
||||
bool isSetEndImm() const {
|
||||
if (!isImm()) return false;
|
||||
|
@ -494,6 +494,7 @@ Lforward:
|
||||
cmp r7, r8, ror r2
|
||||
cmp r1, r6, rrx
|
||||
cmp r0, #-2
|
||||
cmp lr, #0
|
||||
|
||||
@ CHECK: cmp r1, #15 @ encoding: [0x0f,0x00,0x51,0xe3]
|
||||
@ CHECK: cmp r1, r6 @ encoding: [0x06,0x00,0x51,0xe1]
|
||||
@ -508,6 +509,7 @@ Lforward:
|
||||
@ CHECK: cmp r7, r8, ror r2 @ encoding: [0x78,0x02,0x57,0xe1]
|
||||
@ CHECK: cmp r1, r6, rrx @ encoding: [0x66,0x00,0x51,0xe1]
|
||||
@ CHECK: cmn r0, #2 @ encoding: [0x02,0x00,0x70,0xe3]
|
||||
@ CHECK: cmp lr, #0 @ encoding: [0x00,0x00,0x5e,0xe3]
|
||||
|
||||
|
||||
@------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user