X86: Allow expressions to appear as u8imm operands.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284688 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Peter Collingbourne 2016-10-20 01:58:34 +00:00
parent bae0043048
commit f43c9c6d35
4 changed files with 16 additions and 1 deletions

View File

@ -192,8 +192,10 @@ struct X86Operand : public MCParsedAsmOperand {
bool isImmUnsignedi8() const {
if (!isImm()) return false;
// If this isn't a constant expr, just assume it fits and let relaxation
// handle it.
const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(getImm());
if (!CE) return false;
if (!CE) return true;
return isImmUnsignedi8Value(CE->getValue());
}

View File

@ -291,6 +291,9 @@ void X86ATTInstPrinter::printMemOffset(const MCInst *MI, unsigned Op,
void X86ATTInstPrinter::printU8Imm(const MCInst *MI, unsigned Op,
raw_ostream &O) {
if (MI->getOperand(Op).isExpr())
return printOperand(MI, Op, O);
O << markup("<imm:") << '$' << formatImm(MI->getOperand(Op).getImm() & 0xff)
<< markup(">");
}

View File

@ -253,5 +253,8 @@ void X86IntelInstPrinter::printMemOffset(const MCInst *MI, unsigned Op,
void X86IntelInstPrinter::printU8Imm(const MCInst *MI, unsigned Op,
raw_ostream &O) {
if (MI->getOperand(Op).isExpr())
return MI->getOperand(Op).getExpr()->print(O, &MAI);
O << formatImm(MI->getOperand(Op).getImm() & 0xff);
}

View File

@ -1,4 +1,5 @@
// RUN: llvm-mc -triple i386-unknown-unknown %s --show-encoding | FileCheck %s
// RUN: llvm-mc -triple i386-unknown-unknown -output-asm-variant=1 %s | FileCheck --check-prefix=INTEL %s
// CHECK: flds (%edi)
// CHECK: encoding: [0xd9,0x07]
@ -1416,6 +1417,12 @@
// CHECK: encoding: [0xd1,0x0d,0x78,0x56,0x34,0x12]
rorl 0x12345678
// CHECK: rorl $foo, (%ebx)
// INTEL: ror dword ptr [ebx], foo
// CHECK: encoding: [0xc1,0x0b,A]
// CHECK: fixup A - offset: 2, value: foo, kind: FK_Data_1
rorl $foo, (%ebx)
// CHECK: shll $0, 3735928559(%ebx,%ecx,8)
// CHECK: encoding: [0xc1,0xa4,0xcb,0xef,0xbe,0xad,0xde,0x00]
sall $0,0xdeadbeef(%ebx,%ecx,8)