[TableGen][InstrInfoEmitter] Count sub-operands on def operands
- If a def operand includes multiple sub-operands, count them when generating instr info. - Found issues in x86 and sparc backends, where memory operands of store or store-like instructions are wrongly placed in the output list. Reviewers: jayfoad, arsenm, Pierre-vh Reviewed By: arsenm Pull Request: https://github.com/llvm/llvm-project/pull/88972
This commit is contained in:
37
llvm/test/TableGen/def-multiple-operands.td
Normal file
37
llvm/test/TableGen/def-multiple-operands.td
Normal file
@@ -0,0 +1,37 @@
|
||||
// RUN: llvm-tblgen -gen-instr-info -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 P0 : Register<"p0">;
|
||||
def R32 : RegisterClass<"MyNS", [i32], 0, (add R0)>;
|
||||
def P1 : RegisterClass<"MyNS", [i1], 0, (add P0)>;
|
||||
|
||||
def Reg3Opnd : Operand<OtherVT> {
|
||||
let MIOperandInfo = (ops R32, R32, P1);
|
||||
}
|
||||
|
||||
// The following checks verify that 'MCInstrDesc' entry for 'InstA' has the
|
||||
// expected 'NumOperands' and 'NumDefs', i.e. 'InstA' should have 3 defs out of
|
||||
// 4 operands.
|
||||
|
||||
// CHECK: archInstrTable {{.* = \{}}
|
||||
// CHECK: {{\{}}
|
||||
// CHECK: {{\{}} [[ID:[0-9]+]], 4, 3, 13, {{.+\}, \/\/}}
|
||||
// CHECK-SAME: Inst #[[ID]] = InstA
|
||||
def InstA : Instruction {
|
||||
let Namespace = "MyNS";
|
||||
let Size = 13;
|
||||
// InstA should have 3 defs out of 4 operands.
|
||||
let OutOperandList = (outs Reg3Opnd:$dst);
|
||||
let InOperandList = (ins i32imm:$c);
|
||||
field bits<8> Inst;
|
||||
field bits<8> SoftFail = 0;
|
||||
let hasSideEffects = false;
|
||||
}
|
||||
@@ -1181,9 +1181,15 @@ void InstrInfoEmitter::emitRecord(
|
||||
// Each logical operand can be multiple MI operands.
|
||||
MinOperands =
|
||||
Inst.Operands.back().MIOperandNo + Inst.Operands.back().MINumOperands;
|
||||
// Even the logical output operand may be multiple MI operands.
|
||||
int DefOperands = 0;
|
||||
if (Inst.Operands.NumDefs) {
|
||||
auto &Opnd = Inst.Operands[Inst.Operands.NumDefs - 1];
|
||||
DefOperands = Opnd.MIOperandNo + Opnd.MINumOperands;
|
||||
}
|
||||
|
||||
OS << " { ";
|
||||
OS << Num << ",\t" << MinOperands << ",\t" << Inst.Operands.NumDefs << ",\t"
|
||||
OS << Num << ",\t" << MinOperands << ",\t" << DefOperands << ",\t"
|
||||
<< Inst.TheDef->getValueAsInt("Size") << ",\t"
|
||||
<< SchedModels.getSchedClassIdx(Inst) << ",\t";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user