@@ -1253,44 +1253,56 @@ class getInsDPP <RegisterClass Src0RC, RegisterClass Src1RC, int NumSrcArgs,
1253
1253
}
1254
1254
1255
1255
class getInsSDWA <RegisterClass Src0RC, RegisterClass Src1RC, int NumSrcArgs,
1256
- bit HasFloatModifiers> {
1257
-
1258
- dag ret = !if (!eq(NumSrcArgs, 0),
1259
- // VOP1 without input operands (V_NOP)
1260
- (ins),
1261
- !if (!eq(NumSrcArgs, 1),
1262
- !if (HasFloatModifiers,
1263
- // VOP1_SDWA with float modifiers
1264
- (ins FPInputMods:$src0_fmodifiers, Src0RC:$src0,
1265
- clampmod:$clamp, dst_sel:$dst_sel, dst_unused:$dst_unused,
1266
- src0_sel:$src0_sel)
1267
- /* else */,
1268
- // VOP1_SDWA with sext modifier
1269
- (ins IntInputMods:$src0_imodifiers, Src0RC:$src0,
1270
- clampmod:$clamp, dst_sel:$dst_sel, dst_unused:$dst_unused,
1271
- src0_sel:$src0_sel)
1272
- /* endif */)
1256
+ bit HasFloatModifiers, ValueType DstVT > {
1257
+
1258
+ dag ret = !if(!eq(NumSrcArgs, 0),
1259
+ // VOP1 without input operands (V_NOP)
1260
+ (ins),
1261
+ !if(!eq(NumSrcArgs, 1),
1262
+ !if(HasFloatModifiers,
1263
+ // VOP1_SDWA with float modifiers
1264
+ (ins FPInputMods:$src0_fmodifiers, Src0RC:$src0,
1265
+ clampmod:$clamp, dst_sel:$dst_sel, dst_unused:$dst_unused,
1266
+ src0_sel:$src0_sel)
1267
+ /* else */,
1268
+ // VOP1_SDWA with sext modifier
1269
+ (ins IntInputMods:$src0_imodifiers, Src0RC:$src0,
1270
+ clampmod:$clamp, dst_sel:$dst_sel, dst_unused:$dst_unused,
1271
+ src0_sel:$src0_sel)
1272
+ /* endif */)
1273
1273
/* NumSrcArgs == 2 */,
1274
- !if (HasFloatModifiers,
1275
- // VOP2_SDWA with float modifiers
1276
- (ins FPInputMods:$src0_fmodifiers, Src0RC:$src0,
1277
- FPInputMods:$src1_fmodifiers, Src1RC:$src1,
1278
- clampmod:$clamp, dst_sel:$dst_sel, dst_unused:$dst_unused,
1279
- src0_sel:$src0_sel, src1_sel:$src1_sel)
1280
- /* else */,
1281
- // VOP2_DPP with sext modifier
1282
- (ins IntInputMods:$src0_imodifiers, Src0RC:$src0,
1283
- IntInputMods:$src1_imodifiers, Src1RC:$src1,
1284
- clampmod:$clamp, dst_sel:$dst_sel, dst_unused:$dst_unused,
1285
- src0_sel:$src0_sel, src1_sel:$src1_sel)
1274
+ !if(HasFloatModifiers,
1275
+ !if(!eq(DstVT.Size, 1),
1276
+ // VOPC_SDWA with float modifiers
1277
+ (ins FPInputMods:$src0_fmodifiers, Src0RC:$src0,
1278
+ FPInputMods:$src1_fmodifiers, Src1RC:$src1,
1279
+ clampmod:$clamp, src0_sel:$src0_sel, src1_sel:$src1_sel),
1280
+ // VOP2_SDWA or VOPC_SDWA with float modifiers
1281
+ (ins FPInputMods:$src0_fmodifiers, Src0RC:$src0,
1282
+ FPInputMods:$src1_fmodifiers, Src1RC:$src1,
1283
+ clampmod:$clamp, dst_sel:$dst_sel, dst_unused:$dst_unused,
1284
+ src0_sel:$src0_sel, src1_sel:$src1_sel)
1285
+ ),
1286
+ /* else */
1287
+ !if(!eq(DstVT.Size, 1),
1288
+ // VOPC_SDWA with sext modifiers
1289
+ (ins IntInputMods:$src0_imodifiers, Src0RC:$src0,
1290
+ IntInputMods:$src1_imodifiers, Src1RC:$src1,
1291
+ clampmod:$clamp, src0_sel:$src0_sel, src1_sel:$src1_sel),
1292
+ // VOP2_SDWA or VOPC_SDWA with sext modifier
1293
+ (ins IntInputMods:$src0_imodifiers, Src0RC:$src0,
1294
+ IntInputMods:$src1_imodifiers, Src1RC:$src1,
1295
+ clampmod:$clamp, dst_sel:$dst_sel, dst_unused:$dst_unused,
1296
+ src0_sel:$src0_sel, src1_sel:$src1_sel)
1297
+ )
1286
1298
/* endif */)));
1287
1299
}
1288
1300
1289
1301
// Outs for DPP and SDWA
1290
1302
class getOutsExt <bit HasDst, ValueType DstVT, RegisterOperand DstRCDPP> {
1291
1303
dag ret = !if(HasDst,
1292
1304
!if(!eq(DstVT.Size, 1),
1293
- (outs DstRCDPP:$sdst ), // sdst for VOPC
1305
+ (outs), // no dst for VOPC, we use "vcc"-token as dst in SDWA VOPC instructions
1294
1306
(outs DstRCDPP:$vdst)),
1295
1307
(outs)); // V_NOP
1296
1308
}
@@ -1344,7 +1356,7 @@ class getAsmSDWA <bit HasDst, int NumSrcArgs, bit HasFloatModifiers,
1344
1356
ValueType DstVT = i32> {
1345
1357
string dst = !if(HasDst,
1346
1358
!if(!eq(DstVT.Size, 1),
1347
- "$sdst ", // use $sdst for VOPC
1359
+ " vcc ", // use vcc token as dst for VOPC instructioins
1348
1360
"$vdst"),
1349
1361
"");
1350
1362
string src0 = !if(HasFloatModifiers, "$src0_fmodifiers", "$src0_imodifiers");
@@ -1360,7 +1372,10 @@ class getAsmSDWA <bit HasDst, int NumSrcArgs, bit HasFloatModifiers,
1360
1372
"",
1361
1373
!if(!eq(NumSrcArgs, 1),
1362
1374
" $dst_sel $dst_unused $src0_sel",
1363
- " $dst_sel $dst_unused $src0_sel $src1_sel"
1375
+ !if(!eq(DstVT.Size, 1),
1376
+ " $src0_sel $src1_sel", // No dst_sel and dst_unused for VOPC
1377
+ " $dst_sel $dst_unused $src0_sel $src1_sel"
1378
+ )
1364
1379
)
1365
1380
);
1366
1381
string ret = dst#args#sdwa;
@@ -1425,7 +1440,7 @@ class VOPProfile <list<ValueType> _ArgVT> {
1425
1440
field dag Ins64 = getIns64<Src0RC64, Src1RC64, Src2RC64, NumSrcArgs,
1426
1441
HasModifiers>.ret;
1427
1442
field dag InsDPP = getInsDPP<Src0DPP, Src1DPP, NumSrcArgs, HasModifiers>.ret;
1428
- field dag InsSDWA = getInsSDWA<Src0SDWA, Src1SDWA, NumSrcArgs, HasModifiers>.ret;
1443
+ field dag InsSDWA = getInsSDWA<Src0SDWA, Src1SDWA, NumSrcArgs, HasModifiers, DstVT >.ret;
1429
1444
1430
1445
field string Asm32 = getAsm32<HasDst, NumSrcArgs, DstVT>.ret;
1431
1446
field string Asm64 = getAsm64<HasDst, NumSrcArgs, HasModifiers, DstVT>.ret;
@@ -1538,6 +1553,11 @@ class VOPC_Profile<ValueType vt0, ValueType vt1 = vt0> : VOPProfile <[i1, vt0, v
1538
1553
class VOPC_Class_Profile<ValueType vt> : VOPC_Profile<vt, i32> {
1539
1554
let Ins64 = (ins FPInputMods:$src0_modifiers, Src0RC64:$src0, Src1RC64:$src1);
1540
1555
let Asm64 = "$sdst, $src0_modifiers, $src1";
1556
+ let InsSDWA = (ins FPInputMods:$src0_fmodifiers, Src0RC64:$src0,
1557
+ IntInputMods:$src1_imodifiers, Src1RC64:$src1,
1558
+ clampmod:$clamp, src0_sel:$src0_sel, src1_sel:$src1_sel);
1559
+ let AsmSDWA = " vcc, $src0_fmodifiers, $src1_imodifiers$clamp $src0_sel $src1_sel";
1560
+
1541
1561
}
1542
1562
1543
1563
def VOPC_I1_F32_F32 : VOPC_Profile<f32>;
@@ -2247,6 +2267,18 @@ class VOPC_Pseudo <dag ins, list<dag> pattern, string opName> :
2247
2267
let isCodeGenOnly = 1;
2248
2268
}
2249
2269
2270
+ class VOPC_SDWA <vopc op, string opName, bit DefExec, VOPProfile p> :
2271
+ VOPC_SDWAe <op.VI>,
2272
+ VOP_SDWA <p.OutsSDWA, p.InsSDWA, opName#p.AsmSDWA, [], p.HasModifiers>,
2273
+ SDWADisableFields <p> {
2274
+ let Defs = !if(DefExec, [VCC, EXEC], [VCC]);
2275
+ let hasSideEffects = DefExec;
2276
+ let AsmMatchConverter = "cvtSdwaVOPC";
2277
+ let AssemblerPredicates = !if(p.HasExt, [isVI], [DisableInst]);
2278
+ let DecoderNamespace = "SDWA";
2279
+ let DisableDecoder = DisableVIDecoder;
2280
+ }
2281
+
2250
2282
multiclass VOPC_m <vopc op, dag ins, string op_asm, list<dag> pattern,
2251
2283
string opName, bit DefExec, VOPProfile p,
2252
2284
list<SchedReadWrite> sched,
@@ -2293,6 +2325,8 @@ multiclass VOPC_Helper <vopc op, string opName, list<dag> pat32,
2293
2325
2294
2326
defm _e64 : VOP3_C_m <op, (outs VOPDstS64:$sdst), p.Ins64, opName#p.Asm64, pat64,
2295
2327
opName, p.HasModifiers, DefExec, revOp, sched>;
2328
+
2329
+ def _sdwa : VOPC_SDWA <op, opName, DefExec, p>;
2296
2330
}
2297
2331
2298
2332
// Special case for class instructions which only have modifiers on
@@ -2305,6 +2339,11 @@ multiclass VOPC_Class_Helper <vopc op, string opName, list<dag> pat32,
2305
2339
defm _e64 : VOP3_C_m <op, (outs VOPDstS64:$sdst), p.Ins64, opName#p.Asm64, pat64,
2306
2340
opName, p.HasModifiers, DefExec, revOp, sched>,
2307
2341
VOP3DisableModFields<1, 0, 0>;
2342
+
2343
+ def _sdwa : VOPC_SDWA <op, opName, DefExec, p> {
2344
+ let src1_fmodifiers = 0;
2345
+ let src1_imodifiers = ?;
2346
+ }
2308
2347
}
2309
2348
2310
2349
multiclass VOPCInst <vopc op, string opName,
@@ -2367,11 +2406,6 @@ multiclass VOPCX_I32 <vopc op, string opName, string revOp = opName> :
2367
2406
multiclass VOPCX_I64 <vopc op, string opName, string revOp = opName> :
2368
2407
VOPCX <op, opName, VOPC_I1_I64_I64, COND_NULL, [Write64Bit], revOp>;
2369
2408
2370
- multiclass VOP3_Helper <vop3 op, string opName, dag outs, dag ins, string asm,
2371
- list<dag> pat, int NumSrcArgs, bit HasMods,
2372
- bit VOP3Only = 0> : VOP3_m <
2373
- op, outs, ins, opName#" "#asm, pat, opName, NumSrcArgs, HasMods, VOP3Only
2374
- >;
2375
2409
2376
2410
multiclass VOPC_CLASS_F32 <vopc op, string opName> :
2377
2411
VOPCClassInst <op, opName, VOPC_I1_F32_I32, 0, [Write32Bit]>;
@@ -2385,6 +2419,13 @@ multiclass VOPC_CLASS_F64 <vopc op, string opName> :
2385
2419
multiclass VOPCX_CLASS_F64 <vopc op, string opName> :
2386
2420
VOPCClassInst <op, opName, VOPC_I1_F64_I32, 1, [WriteDoubleAdd]>;
2387
2421
2422
+
2423
+ multiclass VOP3_Helper <vop3 op, string opName, dag outs, dag ins, string asm,
2424
+ list<dag> pat, int NumSrcArgs, bit HasMods,
2425
+ bit VOP3Only = 0> : VOP3_m <
2426
+ op, outs, ins, opName#" "#asm, pat, opName, NumSrcArgs, HasMods, VOP3Only
2427
+ >;
2428
+
2388
2429
multiclass VOP3Inst <vop3 op, string opName, VOPProfile P,
2389
2430
SDPatternOperator node = null_frag, bit VOP3Only = 0> :
2390
2431
VOP3_Helper <
0 commit comments