@@ -1121,15 +1121,6 @@ def SDWAVopcDst : BoolRC {
1121
1121
let PrintMethod = "printVOPDst";
1122
1122
}
1123
1123
1124
- class NamedMatchClass<string CName, bit Optional = 1> : AsmOperandClass {
1125
- let Name = "Imm"#CName;
1126
- let PredicateMethod = "is"#CName;
1127
- let ParserMethod = !if(Optional, "", "parse"#CName);
1128
- let RenderMethod = "addImmOperands";
1129
- let IsOptional = Optional;
1130
- let DefaultMethod = !if(Optional, "default"#CName, ?);
1131
- }
1132
-
1133
1124
class CustomOperandClass<string CName, bit Optional> : AsmOperandClass {
1134
1125
let Name = CName;
1135
1126
let PredicateMethod = "is"#CName;
@@ -1143,6 +1134,7 @@ class CustomOperandProps<bit Optional = 0, string Name = NAME,
1143
1134
AsmOperandClass Class = CustomOperandClass<Name, Optional>> {
1144
1135
string PrintMethod = "print"#Name;
1145
1136
AsmOperandClass ParserMatchClass = Class;
1137
+ string OperandType = "OPERAND_IMMEDIATE";
1146
1138
}
1147
1139
1148
1140
class CustomOperand<ValueType Type, bit Optional = 0, string Name = NAME,
@@ -1173,33 +1165,10 @@ class BitOperandClass<string Id, string Name>
1173
1165
class NamedBitOperand<string Id, string Name = NAME>
1174
1166
: CustomOperand<i1, 1, Name, BitOperandClass<Id, Name>>;
1175
1167
1176
- class DefaultOperand_0 <CustomOperand Op>
1177
- : OperandWithDefaultOps<Op.Type, (ops (Op.Type 0 ))>,
1168
+ class DefaultOperand <CustomOperand Op, int Value >
1169
+ : OperandWithDefaultOps<Op.Type, (ops (Op.Type Value ))>,
1178
1170
CustomOperandProps<1, Op.ParserMatchClass.Name, Op.ParserMatchClass>;
1179
1171
1180
- class NamedOperandU32<string Name, AsmOperandClass MatchClass> : Operand<i32> {
1181
- let PrintMethod = "print"#Name;
1182
- let ParserMatchClass = MatchClass;
1183
- }
1184
-
1185
- class NamedOperandU32_0<string Name, AsmOperandClass MatchClass> :
1186
- OperandWithDefaultOps<i32, (ops (i32 0))> {
1187
- let PrintMethod = "print"#Name;
1188
- let ParserMatchClass = MatchClass;
1189
- }
1190
-
1191
- class NamedOperandU32Default0<string Name, AsmOperandClass MatchClass> :
1192
- OperandWithDefaultOps<i32, (ops (i32 0))> {
1193
- let PrintMethod = "print"#Name;
1194
- let ParserMatchClass = MatchClass;
1195
- }
1196
-
1197
- class NamedOperandU32Default1<string Name, AsmOperandClass MatchClass> :
1198
- OperandWithDefaultOps<i32, (ops (i32 1))> {
1199
- let PrintMethod = "print"#Name;
1200
- let ParserMatchClass = MatchClass;
1201
- }
1202
-
1203
1172
class SDWAOperandClass<string Id, string Name>
1204
1173
: CustomOperandClass<Name, 1> {
1205
1174
string ImmTy = "AMDGPUOperand::ImmTy"#Name;
@@ -1211,7 +1180,17 @@ class SDWAOperandClass<string Id, string Name>
1211
1180
class SDWAOperand<string Id, string Name = NAME>
1212
1181
: CustomOperand<i32, 1, Name, SDWAOperandClass<Id, Name>>;
1213
1182
1214
- let OperandType = "OPERAND_IMMEDIATE" in {
1183
+ class ArrayOperandClass<string Id, string Name>
1184
+ : CustomOperandClass<Name, 1> {
1185
+ string ImmTy = "AMDGPUOperand::ImmTy"#Name;
1186
+ let ParserMethod =
1187
+ "[this](OperandVector &Operands) -> OperandMatchResultTy { "#
1188
+ "return parseOperandArrayWithPrefix(\""#Id#"\", Operands, "#ImmTy#"); }";
1189
+ }
1190
+
1191
+ class ArrayOperand0<string Id, string Name = NAME>
1192
+ : OperandWithDefaultOps<i32, (ops (i32 0))>,
1193
+ CustomOperandProps<1, Name, ArrayOperandClass<Id, Name>>;
1215
1194
1216
1195
def flat_offset : CustomOperand<i32, 1, "FlatOffset">;
1217
1196
def offset : NamedIntOperand<i32, "offset", "Offset">;
@@ -1220,23 +1199,23 @@ def offset1 : NamedIntOperand<i8, "offset1", "Offset1">;
1220
1199
1221
1200
def gds : NamedBitOperand<"gds", "GDS">;
1222
1201
1223
- def omod : NamedOperandU32<"OModSI", NamedMatchClass< "OModSI"> >;
1224
- def omod0 : NamedOperandU32_0<"OModSI", NamedMatchClass<"OModSI"> >;
1202
+ def omod : CustomOperand<i32, 1, "OModSI">;
1203
+ def omod0 : DefaultOperand<omod, 0 >;
1225
1204
1226
1205
// We need to make the cases with a default of 0 distinct from no
1227
1206
// default to help deal with some cases where the operand appears
1228
1207
// before a mandatory operand.
1229
1208
def clampmod : NamedBitOperand<"clamp", "ClampSI">;
1230
- def clampmod0 : DefaultOperand_0 <clampmod>;
1209
+ def clampmod0 : DefaultOperand <clampmod, 0 >;
1231
1210
def highmod : NamedBitOperand<"high", "High">;
1232
1211
1233
- def CPol : NamedOperandU32<"CPol", NamedMatchClass<"CPol"> >;
1234
- def CPol_0 : NamedOperandU32Default0<" CPol", NamedMatchClass<"CPol"> >;
1235
- def CPol_GLC1 : NamedOperandU32Default1<" CPol", NamedMatchClass<"CPol"> >;
1212
+ def CPol : CustomOperand<i32, 1 >;
1213
+ def CPol_0 : DefaultOperand< CPol, 0 >;
1214
+ def CPol_GLC1 : DefaultOperand< CPol, 1 >;
1236
1215
1237
1216
def TFE : NamedBitOperand<"tfe">;
1238
1217
def SWZ : NamedBitOperand<"swz">;
1239
- def SWZ_0 : DefaultOperand_0 <SWZ>;
1218
+ def SWZ_0 : DefaultOperand <SWZ, 0 >;
1240
1219
def UNorm : NamedBitOperand<"unorm">;
1241
1220
def DA : NamedBitOperand<"da">;
1242
1221
def R128A16 : CustomOperand<i1, 1>;
@@ -1256,10 +1235,10 @@ def src0_sel : SDWAOperand<"src0_sel", "SDWASrc0Sel">;
1256
1235
def src1_sel : SDWAOperand<"src1_sel", "SDWASrc1Sel">;
1257
1236
def dst_unused : CustomOperand<i32, 1, "SDWADstUnused">;
1258
1237
1259
- def op_sel0 : NamedOperandU32Default0<"OpSel ", NamedMatchClass< "OpSel"> >;
1260
- def op_sel_hi0 : NamedOperandU32Default0<"OpSelHi ", NamedMatchClass< "OpSelHi"> >;
1261
- def neg_lo0 : NamedOperandU32Default0<"NegLo ", NamedMatchClass< "NegLo"> >;
1262
- def neg_hi0 : NamedOperandU32Default0<"NegHi ", NamedMatchClass< "NegHi"> >;
1238
+ def op_sel0 : ArrayOperand0<"op_sel ", "OpSel">;
1239
+ def op_sel_hi0 : ArrayOperand0<"op_sel_hi ", "OpSelHi">;
1240
+ def neg_lo0 : ArrayOperand0<"neg_lo ", "NegLo">;
1241
+ def neg_hi0 : ArrayOperand0<"neg_hi ", "NegHi">;
1263
1242
1264
1243
def dpp8 : CustomOperand<i32, 0, "DPP8">;
1265
1244
def dpp_ctrl : CustomOperand<i32, 0, "DPPCtrl">;
@@ -1281,8 +1260,6 @@ def exp_tgt : CustomOperand<i32, 0, "ExpTgt">;
1281
1260
def wait_vdst : NamedIntOperand<i8, "wait_vdst", "WaitVDST">;
1282
1261
def wait_exp : NamedIntOperand<i8, "wait_exp", "WaitEXP">;
1283
1262
1284
- } // End OperandType = "OPERAND_IMMEDIATE"
1285
-
1286
1263
class KImmMatchClass<int size> : AsmOperandClass {
1287
1264
let Name = "KImmFP"#size;
1288
1265
let PredicateMethod = "isKImmFP"#size;
0 commit comments