[llvm] r303044 - [TableGen] Add EncoderMethod to RegisterOperand
Sam Kolton via llvm-commits
llvm-commits at lists.llvm.org
Mon May 15 03:13:08 PDT 2017
Author: skolton
Date: Mon May 15 05:13:07 2017
New Revision: 303044
URL: http://llvm.org/viewvc/llvm-project?rev=303044&view=rev
Log:
[TableGen] Add EncoderMethod to RegisterOperand
Reviewers: stoklund, grosbach, vpykhtin
Differential Revision: https://reviews.llvm.org/D32493
Added:
llvm/trunk/test/TableGen/RegisterEncoder.td
Modified:
llvm/trunk/include/llvm/Target/Target.td
llvm/trunk/test/TableGen/AsmVariant.td
llvm/trunk/utils/TableGen/CodeGenInstruction.cpp
Modified: llvm/trunk/include/llvm/Target/Target.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/Target.td?rev=303044&r1=303043&r2=303044&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/Target.td (original)
+++ llvm/trunk/include/llvm/Target/Target.td Mon May 15 05:13:07 2017
@@ -680,6 +680,11 @@ class RegisterOperand<RegisterClass regc
// 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.
Modified: llvm/trunk/test/TableGen/AsmVariant.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/AsmVariant.td?rev=303044&r1=303043&r2=303044&view=diff
==============================================================================
--- llvm/trunk/test/TableGen/AsmVariant.td (original)
+++ llvm/trunk/test/TableGen/AsmVariant.td Mon May 15 05:13:07 2017
@@ -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"
Added: llvm/trunk/test/TableGen/RegisterEncoder.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/RegisterEncoder.td?rev=303044&view=auto
==============================================================================
--- llvm/trunk/test/TableGen/RegisterEncoder.td (added)
+++ llvm/trunk/test/TableGen/RegisterEncoder.td Mon May 15 05:13:07 2017
@@ -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<RegClass> {
+ 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
Modified: llvm/trunk/utils/TableGen/CodeGenInstruction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenInstruction.cpp?rev=303044&r1=303043&r2=303044&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CodeGenInstruction.cpp (original)
+++ llvm/trunk/utils/TableGen/CodeGenInstruction.cpp Mon May 15 05:13:07 2017
@@ -77,6 +77,7 @@ CGIOperandList::CGIOperandList(Record *R
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");
More information about the llvm-commits
mailing list