Skip to content

Commit d0c8b1d

Browse files
committed
Full specialization
1 parent 2658855 commit d0c8b1d

File tree

7 files changed

+221
-134
lines changed

7 files changed

+221
-134
lines changed

llvm/include/llvm/Target/Target.td

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,6 +1137,15 @@ class OptionalDefOperand<ValueType ty, dag OpTypes, dag defaultops>
11371137
let MIOperandInfo = OpTypes;
11381138
}
11391139

1140+
// InstrDecoderOption - This class is used to provide some options to the
1141+
// TableGen DecoderEmitter backend.
1142+
class InstrDecoderOption<string ty, list<int> bws> {
1143+
string CPPType = ty; // C++ type for generating non-templated code.
1144+
list<int> Bitwidths = bws; // List of bitwidths supported by the above type.
1145+
1146+
assert !not(!empty(CPPType)), "CPP type cannot be empty";
1147+
assert !not(!empty(Bitwidths)), "Bitwidths cannot be empty";
1148+
}
11401149

11411150
// InstrInfo - This class should only be instantiated once to provide parameters
11421151
// which are global to the target machine.
@@ -1159,24 +1168,16 @@ class InstrInfo {
11591168
// This option is a temporary migration help. It will go away.
11601169
bit guessInstructionProperties = true;
11611170

1162-
// These properties, when set, opt into the non-templated variants of
1163-
// `decodeToMCInst` generated by TableGen DecoderEmitter backend. Using this
1164-
// option helps reduce the code size of the generated code as compared to the
1165-
// templated `decodeToMCInst` that is generated by default.
1166-
// For each index `I`, InsnCPPTypes[I] is a C++ type that will be used to
1167-
// generate a non-templated `decodeToMCInst`, and InstBitwidths[I] is a list
1168-
// instruction bitwidth(s) whose decoders will be included in the generated
1169-
// code.
1170-
list<string> InsnCPPTypes = [];
1171-
list<list<int>> InsnBitwidths = [];
1172-
assert !eq(!size(InsnCPPTypes), !size(InsnBitwidths)),
1173-
"The InsnCPPTypes and InsnBitwidths lists must be the same length";
1174-
1175-
// Make sure the InstCPPTypes, if not empty, does not contain empty strings.
1176-
assert !or(!empty(InsnCPPTypes), !empty(!filter(e, InsnCPPTypes, !empty(e)))),
1177-
"Entries in InstCPPTypes cannot be empty";
1178-
1179-
// Make sure that InsnBitwidths, if not empty, does not contain empty list.
1171+
// This is a list of instruction decoder options for this target. When non
1172+
// empty, it should list all the C++ types and associated bitwidths that this
1173+
// target intends to use to call the TableGen generated `decodeInstruction`
1174+
// function. If this list is empty, the decoder emitter will generate
1175+
// templated code. However, if a target intends to call this function with
1176+
// more than one `InsnType`, it may be beneficial to provide these decoder
1177+
// options to generate non-templated form of `decodeInstruction` and
1178+
// associated helper functions and avoid some code duplication in the
1179+
// `decodeToMCInst` function.
1180+
list<InstrDecoderOption> DecoderOptions = [];
11801181
}
11811182

11821183
// Standard Pseudo Instructions.

llvm/lib/Target/AArch64/AArch64.td

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,7 @@ include "AArch64SchedPredExynos.td"
4040
include "AArch64SchedPredNeoverse.td"
4141
include "AArch64Combine.td"
4242

43-
def AArch64InstrInfo : InstrInfo {
44-
// Opt-in into non-templated code for instruction decoder.
45-
let InsnCPPTypes = ["uint32_t"];
46-
let InsnBitwidths = [[32]];
47-
}
43+
def AArch64InstrInfo : InstrInfo;
4844

4945
//===----------------------------------------------------------------------===//
5046
// Named operands for MRS/MSR/TLBI/...

llvm/lib/Target/AMDGPU/AMDGPU.td

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1973,6 +1973,13 @@ def FeatureISAVersion12_Generic: FeatureSet<
19731973

19741974
def AMDGPUInstrInfo : InstrInfo {
19751975
let guessInstructionProperties = 1;
1976+
1977+
// Opt-in into non-templated code for instruction decoder.
1978+
let DecoderOptions = [
1979+
InstrDecoderOption<"uint32_t", [32]>,
1980+
InstrDecoderOption<"uint64_t", [64]>,
1981+
InstrDecoderOption<"DecoderUInt128", [96, 128]>,
1982+
];
19761983
}
19771984

19781985
def AMDGPUAsmParser : AsmParser {

llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ DecodeStatus AMDGPUDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
591591

592592
// Try to decode DPP and SDWA first to solve conflict with VOP1 and VOP2
593593
// encodings
594-
if (isGFX11Plus() && Bytes.size() >= 12 ) {
594+
if (isGFX11Plus() && Bytes.size() >= 12) {
595595
DecoderUInt128 DecW = eat12Bytes(Bytes);
596596

597597
if (isGFX11() &&

llvm/lib/Target/M68k/Disassembler/M68kDisassembler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,13 @@ static DecodeStatus DecodeFPCSCRegisterClass(MCInst &Inst, uint64_t RegNo,
111111
}
112112
#define DecodeFPICRegisterClass DecodeFPCSCRegisterClass
113113

114-
static DecodeStatus DecodeCCRCRegisterClass(MCInst &Inst, APInt &Insn,
114+
static DecodeStatus DecodeCCRCRegisterClass(MCInst &Inst, const APInt &Insn,
115115
uint64_t Address,
116116
const void *Decoder) {
117117
llvm_unreachable("unimplemented");
118118
}
119119

120-
static DecodeStatus DecodeSRCRegisterClass(MCInst &Inst, APInt &Insn,
120+
static DecodeStatus DecodeSRCRegisterClass(MCInst &Inst, const APInt &Insn,
121121
uint64_t Address,
122122
const void *Decoder) {
123123
llvm_unreachable("unimplemented");

llvm/lib/Target/RISCV/RISCV.td

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,6 @@ include "RISCVPfmCounters.td"
8585

8686
def RISCVInstrInfo : InstrInfo {
8787
let guessInstructionProperties = 0;
88-
89-
// Opt-in into non-templated code for instruction decoder.
90-
let InsnCPPTypes = ["uint64_t"];
91-
let InsnBitwidths = [[16, 32, 48]];
9288
}
9389

9490
def RISCVAsmParser : AsmParser {

0 commit comments

Comments
 (0)