1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

[TableGen] Add EncoderMethod to RegisterOperand

Reviewers: stoklund, grosbach, vpykhtin

Differential Revision: https://reviews.llvm.org/D32493

llvm-svn: 303044
This commit is contained in:
Sam Kolton 2017-05-15 10:13:07 +00:00
parent 855ddefa6d
commit 396cd8fa77
4 changed files with 42 additions and 1 deletions

View File

@ -680,6 +680,11 @@ class RegisterOperand<RegisterClass regclass, string pm = "printOperand">
// 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.

View File

@ -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"

View File

@ -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: }

View File

@ -77,6 +77,7 @@ CGIOperandList::CGIOperandList(Record *R) : TheDef(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");