@@ -1174,16 +1174,33 @@ class NamedOperandBit_1<string Name, AsmOperandClass MatchClass> :
1174
1174
let ParserMatchClass = MatchClass;
1175
1175
}
1176
1176
1177
- class NamedOperandU8<string Name, AsmOperandClass MatchClass> : Operand<i8> {
1178
- let PrintMethod = "print"#Name;
1179
- let ParserMatchClass = MatchClass;
1177
+ class CustomOperandClass<string CName, bit Optional> : AsmOperandClass {
1178
+ let Name = CName;
1179
+ let PredicateMethod = "is"#CName;
1180
+ let ParserMethod = "parse"#CName;
1181
+ let RenderMethod = "addImmOperands";
1182
+ let IsOptional = Optional;
1183
+ let DefaultMethod = "default"#CName;
1180
1184
}
1181
1185
1182
- class NamedOperandU16<string Name, AsmOperandClass MatchClass> : Operand<i16> {
1186
+ class CustomOperand<ValueType Type, bit Optional = 0, string Name = NAME,
1187
+ AsmOperandClass Class = CustomOperandClass<Name, Optional>>
1188
+ : Operand<Type> {
1183
1189
let PrintMethod = "print"#Name;
1184
- let ParserMatchClass = MatchClass;
1190
+ let ParserMatchClass = Class;
1191
+ }
1192
+
1193
+ class NamedIntOperandClass<string Prefix, string Name>
1194
+ : CustomOperandClass<Name, 1> {
1195
+ string ImmTy = "AMDGPUOperand::ImmTy"#Name;
1196
+ let ParserMethod =
1197
+ "[this](OperandVector &Operands) -> OperandMatchResultTy { "#
1198
+ "return parseIntWithPrefix(\""#Prefix#"\", Operands, "#ImmTy#"); }";
1185
1199
}
1186
1200
1201
+ class NamedIntOperand<ValueType Type, string Prefix, string Name = NAME>
1202
+ : CustomOperand<Type, 1, Name, NamedIntOperandClass<Prefix, Name>>;
1203
+
1187
1204
class NamedOperandU32<string Name, AsmOperandClass MatchClass> : Operand<i32> {
1188
1205
let PrintMethod = "print"#Name;
1189
1206
let ParserMatchClass = MatchClass;
@@ -1209,10 +1226,10 @@ class NamedOperandU32Default1<string Name, AsmOperandClass MatchClass> :
1209
1226
1210
1227
let OperandType = "OPERAND_IMMEDIATE" in {
1211
1228
1212
- def flat_offset : NamedOperandU16<"FlatOffset", NamedMatchClass< "FlatOffset"> >;
1213
- def offset : NamedOperandU16<"Offset ", NamedMatchClass< "Offset"> >;
1214
- def offset0 : NamedOperandU8<"Offset0 ", NamedMatchClass< "Offset0"> >;
1215
- def offset1 : NamedOperandU8<"Offset1 ", NamedMatchClass< "Offset1"> >;
1229
+ def flat_offset : CustomOperand<i16, 1, "FlatOffset">;
1230
+ def offset : NamedIntOperand<i16, "offset ", "Offset">;
1231
+ def offset0 : NamedIntOperand<i8, "offset0 ", "Offset0">;
1232
+ def offset1 : NamedIntOperand<i8, "offset1 ", "Offset1">;
1216
1233
1217
1234
def gds : NamedOperandBit<"GDS", NamedMatchClass<"GDS">>;
1218
1235
@@ -1242,10 +1259,10 @@ def LWE : NamedOperandBit<"LWE", NamedMatchClass<"LWE">>;
1242
1259
def exp_compr : NamedOperandBit<"ExpCompr", NamedMatchClass<"ExpCompr">>;
1243
1260
def exp_vm : NamedOperandBit<"ExpVM", NamedMatchClass<"ExpVM">>;
1244
1261
1245
- def FORMAT : NamedOperandU8<"FORMAT", NamedMatchClass<"FORMAT", 0> >;
1262
+ def FORMAT : CustomOperand<i8 >;
1246
1263
1247
- def DMask : NamedOperandU16<"DMask", NamedMatchClass<"DMask"> >;
1248
- def Dim : NamedOperandU8<"Dim", NamedMatchClass<"Dim", 0> >;
1264
+ def DMask : NamedIntOperand<i16, "dmask" >;
1265
+ def Dim : CustomOperand<i8 >;
1249
1266
1250
1267
def dst_sel : NamedOperandU32<"SDWADstSel", NamedMatchClass<"SDWADstSel">>;
1251
1268
def src0_sel : NamedOperandU32<"SDWASrc0Sel", NamedMatchClass<"SDWASrc0Sel">>;
@@ -1275,8 +1292,8 @@ def exp_tgt : NamedOperandU32<"ExpTgt", NamedMatchClass<"ExpTgt", 0>> {
1275
1292
1276
1293
}
1277
1294
1278
- def wait_vdst : NamedOperandU8<"WaitVDST ", NamedMatchClass< "WaitVDST"> >;
1279
- def wait_exp : NamedOperandU8<"WaitEXP ", NamedMatchClass< "WaitEXP"> >;
1295
+ def wait_vdst : NamedIntOperand<i8, "wait_vdst ", "WaitVDST">;
1296
+ def wait_exp : NamedIntOperand<i8, "wait_exp ", "WaitEXP">;
1280
1297
1281
1298
} // End OperandType = "OPERAND_IMMEDIATE"
1282
1299
0 commit comments