diff --git a/llvm/test/TableGen/AsmWriterPCRelOp.td b/llvm/test/TableGen/AsmWriterPCRelOp.td new file mode 100644 --- /dev/null +++ b/llvm/test/TableGen/AsmWriterPCRelOp.td @@ -0,0 +1,38 @@ +// RUN: llvm-tblgen -gen-asm-writer -I %p/../../include %s | FileCheck %s + +include "llvm/Target/Target.td" + +def ArchInstrInfo : InstrInfo { } + +def Arch : Target { + let InstructionSet = ArchInstrInfo; +} + +def R0 : Register<"r0">; +def Reg : RegisterClass<"Reg", [i32], 0, (add R0)>; + +def IntOperand: Operand; + +def PCRelOperand : Operand { + let OperandType = "OPERAND_PCREL"; +} + +def foo : Instruction { + let OutOperandList = (outs); + let InOperandList = (ins Reg:$reg, IntOperand:$imm); + let AsmString = "foo $reg, $imm"; +} + +def bar : Instruction { + let OutOperandList = (outs); + let InOperandList = (ins Reg:$reg, PCRelOperand:$imm); + let AsmString = "bar $reg, $imm"; +} + +// CHECK: ArchInstPrinter::printInstruction( +// CHECK: // bar, foo +// CHECK-NEXT: printOperand(MI, 0, O); +// CHECK: // foo +// CHECK-NEXT: printOperand(MI, 1, O); +// CHECK: // bar +// CHECK-NEXT: printOperand(MI, Address, 1, O); diff --git a/llvm/utils/TableGen/AsmWriterInst.h b/llvm/utils/TableGen/AsmWriterInst.h --- a/llvm/utils/TableGen/AsmWriterInst.h +++ b/llvm/utils/TableGen/AsmWriterInst.h @@ -66,7 +66,8 @@ bool operator!=(const AsmWriterOperand &Other) const { if (OperandType != Other.OperandType || Str != Other.Str) return true; if (OperandType == isMachineInstrOperand) - return MIOpNo != Other.MIOpNo || MiModifier != Other.MiModifier; + return MIOpNo != Other.MIOpNo || MiModifier != Other.MiModifier || + PCRel != Other.PCRel; return false; } bool operator==(const AsmWriterOperand &Other) const {