Index: llvm/trunk/include/llvm/Target/Target.td =================================================================== --- llvm/trunk/include/llvm/Target/Target.td +++ llvm/trunk/include/llvm/Target/Target.td @@ -680,6 +680,11 @@ // this type. The method normally will just use an alt-name index to look // up the name to print. Default to the generic printOperand(). string PrintMethod = pm; + + // EncoderMethod - The target method name to call to encode this register + // operand. + string EncoderMethod = ""; + // ParserMatchClass - The "match class" that operands of this type fit // in. Match classes are used to define the order in which instructions are // match, to ensure that which instructions gets matched is deterministic. Index: llvm/trunk/test/TableGen/AsmVariant.td =================================================================== --- llvm/trunk/test/TableGen/AsmVariant.td +++ llvm/trunk/test/TableGen/AsmVariant.td @@ -1,6 +1,6 @@ // RUN: llvm-tblgen -gen-asm-matcher -I %p/../../include %s | FileCheck %s -// Check that cpecifying AsmVariant works correctly +// Check that specifying AsmVariant works correctly include "llvm/Target/Target.td" Index: llvm/trunk/test/TableGen/RegisterEncoder.td =================================================================== --- llvm/trunk/test/TableGen/RegisterEncoder.td +++ llvm/trunk/test/TableGen/RegisterEncoder.td @@ -0,0 +1,35 @@ +// RUN: llvm-tblgen -gen-emitter -I %p/../../include %s | FileCheck %s + +// Check that EncoderMethod for RegisterOperand is working correctly + +include "llvm/Target/Target.td" + +def ArchInstrInfo : InstrInfo { } + +def Arch : Target { + let InstructionSet = ArchInstrInfo; +} + +def Reg : Register<"reg">; + +def RegClass : RegisterClass<"foo", [i32], 0, (add Reg)>; + +def RegOperand : RegisterOperand { + let EncoderMethod = "barEncoder"; +} + +def foo : Instruction { + let Size = 1; + + let OutOperandList = (outs); + let InOperandList = (ins RegOperand:$bar); + + bits<8> bar; + bits<8> Inst = bar; +} + +// CHECK: case ::foo: { +// CHECK: op = barEncoder +// CHECK: Value |= op & UINT64_C(255); +// CHECK: break; +// CHECK: } \ No newline at end of file Index: llvm/trunk/utils/TableGen/CodeGenInstruction.cpp =================================================================== --- llvm/trunk/utils/TableGen/CodeGenInstruction.cpp +++ llvm/trunk/utils/TableGen/CodeGenInstruction.cpp @@ -77,6 +77,7 @@ PrintMethod = Rec->getValueAsString("PrintMethod"); OperandType = Rec->getValueAsString("OperandType"); OperandNamespace = Rec->getValueAsString("OperandNamespace"); + EncoderMethod = Rec->getValueAsString("EncoderMethod"); } else if (Rec->isSubClassOf("Operand")) { PrintMethod = Rec->getValueAsString("PrintMethod"); OperandType = Rec->getValueAsString("OperandType");