aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/llvm/lib/Target/VE/VEInstrVec.td
blob: 4a8476f7288a36273343470b06d959c04f5ffc52 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
//===----------------------------------------------------------------------===//
// Vector Instructions
//===----------------------------------------------------------------------===//

//===----------------------------------------------------------------------===//
// Pseudo instructions for VM512 modifications
//===----------------------------------------------------------------------===//

// LVM/SVM instructions using VM512
let hasSideEffects = 0, isCodeGenOnly = 1 in {
  let Constraints = "$vx = $vd", DisableEncoding = "$vd" in {
    def LVMyir_y : Pseudo<(outs VM512:$vx), (ins uimm3:$sy, I64:$sz, VM512:$vd),
                          "# pseudo LVM $vx, $sy, $sz, $vd">;
    def LVMyim_y : Pseudo<(outs VM512:$vx),
                          (ins uimm3:$sy, mimm:$sz, VM512:$vd),
                          "# pseudo LVM $vx, $sy, $sz, $vd">;
  }
  def LVMyir : Pseudo<(outs VM512:$vx), (ins uimm3:$sy, I64:$sz),
                      "# pseudo LVM $vx, $sy, $sz">;
  def LVMyim : Pseudo<(outs VM512:$vx), (ins uimm3:$sy, mimm:$sz),
                      "# pseudo LVM $vx, $sy, $sz">;
  def SVMyi : Pseudo<(outs I64:$sx), (ins VM512:$vz, uimm3:$sy),
                     "# pseudo SVM $sx, $vz, $sy">;
}

// VFMK/VFMKW/VFMKS instructions using VM512
let hasSideEffects = 0, isCodeGenOnly = 1, DisableEncoding = "$vl" in {
  def VFMKyal : Pseudo<(outs VM512:$vmx), (ins I32:$vl),
                       "# pseudo-vfmk.at $vmx">;
  def VFMKynal : Pseudo<(outs VM512:$vmx), (ins I32:$vl),
                        "# pseudo-vfmk.af $vmx">;
  def VFMKWyvl  : Pseudo<(outs VM512:$vmx),
                         (ins CCOp:$cf, V64:$vz, I32:$vl),
                         "# pseudo-vfmk.w.$cf $vmx, $vz">;
  def VFMKWyvyl : Pseudo<(outs VM512:$vmx),
                         (ins CCOp:$cf, V64:$vz, VM512:$vm, I32:$vl),
                         "# pseudo-vfmk.w.$cf $vmx, $vz, $vm">;
  def VFMKSyvl  : Pseudo<(outs VM512:$vmx),
                         (ins CCOp:$cf, V64:$vz, I32:$vl),
                         "# pseudo-vfmk.s.$cf $vmx, $vz">;
  def VFMKSyvyl : Pseudo<(outs VM512:$vmx),
                         (ins CCOp:$cf, V64:$vz, VM512:$vm, I32:$vl),
                         "# pseudo-vfmk.s.$cf $vmx, $vz, $vm">;
}

// ANDM/ORM/XORM/EQVM/NNDM/NEGM instructions using VM512
let hasSideEffects = 0, isCodeGenOnly = 1 in {
  def ANDMyy : Pseudo<(outs VM512:$vmx), (ins VM512:$vmy, VM512:$vmz),
                      "# andm $vmx, $vmy, $vmz">;
  def ORMyy : Pseudo<(outs VM512:$vmx), (ins VM512:$vmy, VM512:$vmz),
                     "# orm $vmx, $vmy, $vmz">;
  def XORMyy : Pseudo<(outs VM512:$vmx), (ins VM512:$vmy, VM512:$vmz),
                      "# xorm $vmx, $vmy, $vmz">;
  def EQVMyy : Pseudo<(outs VM512:$vmx), (ins VM512:$vmy, VM512:$vmz),
                      "# eqvm $vmx, $vmy, $vmz">;
  def NNDMyy : Pseudo<(outs VM512:$vmx), (ins VM512:$vmy, VM512:$vmz),
                      "# nndm $vmx, $vmy, $vmz">;
  def NEGMy : Pseudo<(outs VM512:$vmx), (ins VM512:$vmy),
                     "# negm $vmx, $vmy">;
}

//===----------------------------------------------------------------------===//
// Instructions
//
// Define all vector instructions defined in SX-Aurora TSUBASA Architecture
// Guide here.  As those mnemonics, we use mnemonics defined in Vector Engine
// Assembly Language Reference Manual.
//
// Some instructions can update existing data by following instructions
// sequence.
//
//   lea %s0, 256
//   lea %s1, 128
//   lvl %s0
//   vbrd %v0, 2 # v0 = { 2, 2, 2, ..., 2, 2, 2 }
//   lvl %s1
//   vbrd %v0, 3 # v0 = { 3, 3, 3, ..., 3, 2, 2, 2, ..., 2, 2, 2 }
//
// In order to represent above with a virtual register, we defines instructions
// with an additional base register and `_v` suffiex in mnemonic.
//
//   lea t0, 256
//   lea t1, 128
//   lea t0
//   vbrd tv0, 2
//   lvl t1
//   vbrd_v tv1, 2, tv0
//
// We also have some instructions uses VL register with an pseudo VL value
// with following suffixes in mnemonic.
//
//   l: have an additional I32 register to represent the VL value.
//   L: have an additional VL register to represent the VL value.
//===----------------------------------------------------------------------===//

//-----------------------------------------------------------------------------
// Section 8.9 - Vector Load/Store and Move Instructions
//-----------------------------------------------------------------------------

// Multiclass for VLD instructions
let mayLoad = 1, hasSideEffects = 0, Uses = [VL] in
multiclass VLDbm<string opcStr, bits<8>opc, RegisterClass RC, dag dag_in,
                 string disEnc = ""> {
  let DisableEncoding = disEnc in
  def "" : RVM<opc, (outs RC:$vx), dag_in,
               !strconcat(opcStr, " $vx, $sy, $sz")>;
  let Constraints = "$vx = $base", DisableEncoding = disEnc#"$base",
      isCodeGenOnly = 1 in
  def _v : RVM<opc, (outs RC:$vx), !con(dag_in, (ins RC:$base)),
               !strconcat(opcStr, " $vx, $sy, $sz")>;
}
multiclass VLDlm<string opcStr, bits<8>opc, RegisterClass RC, dag dag_in> {
  defm "" : VLDbm<opcStr, opc, RC, dag_in>;
  let isCodeGenOnly = 1, VE_VLInUse = 1 in {
    defm l : VLDbm<opcStr, opc, RC, !con(dag_in, (ins I32:$vl)), "$vl,">;
    defm L : VLDbm<opcStr, opc, RC, !con(dag_in, (ins VLS:$vl)), "$vl,">;
  }
}
let VE_VLIndex = 3 in
multiclass VLDtgm<string opcStr, bits<8>opc, RegisterClass RC> {
  defm rr : VLDlm<opcStr, opc, RC, (ins I64:$sy, I64:$sz)>;
  let cy = 0 in
  defm ir : VLDlm<opcStr, opc, RC, (ins simm7:$sy, I64:$sz)>;
  let cz = 0 in
  defm rz : VLDlm<opcStr, opc, RC, (ins I64:$sy, zero:$sz)>;
  let cy = 0, cz = 0 in
  defm iz : VLDlm<opcStr, opc, RC, (ins simm7:$sy, zero:$sz)>;
}
multiclass VLDm<string opcStr, bits<8>opc, RegisterClass RC> {
  let vc = 1 in defm "" : VLDtgm<opcStr, opc, RC>;
  let vc = 0 in defm NC : VLDtgm<opcStr#".nc", opc, RC>;
}

// Section 8.9.1 - VLD (Vector Load)
defm VLD : VLDm<"vld", 0x81, V64>;

// Section 8.9.2 - VLDU (Vector Load Upper)
defm VLDU : VLDm<"vldu", 0x82, V64>;

// Section 8.9.3 - VLDL (Vector Load Lower)
defm VLDLSX : VLDm<"vldl.sx", 0x83, V64>;
let cx = 1 in defm VLDLZX : VLDm<"vldl.zx", 0x83, V64>;

// Section 8.9.4 - VLD2D (Vector Load 2D)
defm VLD2D : VLDm<"vld2d", 0xc1, V64>;

// Section 8.9.5 - VLDU2D (Vector Load Upper 2D)
defm VLDU2D : VLDm<"vldu2d", 0xc2, V64>;

// Section 8.9.6 - VLDL2D (Vector Load Lower 2D)
defm VLDL2DSX : VLDm<"vldl2d.sx", 0xc3, V64>;
let cx = 1 in defm VLDL2DZX : VLDm<"vldl2d.zx", 0xc3, V64>;

// Multiclass for VST instructions
let mayStore = 1, hasSideEffects = 0, Uses = [VL] in
multiclass VSTbm<string opcStr, string argStr, bits<8>opc, dag dag_in> {
  def "" : RVM<opc, (outs), dag_in, !strconcat(opcStr, argStr)>;
  let DisableEncoding = "$vl", isCodeGenOnly = 1, VE_VLInUse = 1 in {
    def l : RVM<opc, (outs), !con(dag_in, (ins I32:$vl)),
                !strconcat(opcStr, argStr)>;
    def L : RVM<opc, (outs), !con(dag_in, (ins VLS:$vl)),
                !strconcat(opcStr, argStr)>;
  }
}
multiclass VSTmm<string opcStr, bits<8>opc, dag dag_in> {
  defm "" : VSTbm<opcStr, " $vx, $sy, $sz", opc, dag_in>;
  let m = ?, VE_VLWithMask = 1 in
  defm m : VSTbm<opcStr, " $vx, $sy, $sz, $m", opc, !con(dag_in, (ins VM:$m))>;
}
let VE_VLIndex = 3 in
multiclass VSTtgm<string opcStr, bits<8>opc, RegisterClass RC> {
  defm rrv : VSTmm<opcStr, opc, (ins I64:$sy, I64:$sz, RC:$vx)>;
  let cy = 0 in
  defm irv : VSTmm<opcStr, opc, (ins simm7:$sy, I64:$sz, RC:$vx)>;
  let cz = 0 in
  defm rzv : VSTmm<opcStr, opc, (ins I64:$sy, zero:$sz, RC:$vx)>;
  let cy = 0, cz = 0 in
  defm izv : VSTmm<opcStr, opc, (ins simm7:$sy, zero:$sz, RC:$vx)>;
}
multiclass VSTm<string opcStr, bits<8>opc, RegisterClass RC> {
  let vc = 1, cx = 0 in defm "" : VSTtgm<opcStr, opc, RC>;
  let vc = 0, cx = 0 in defm NC : VSTtgm<opcStr#".nc", opc, RC>;
  let vc = 1, cx = 1 in defm OT : VSTtgm<opcStr#".ot", opc, RC>;
  let vc = 0, cx = 1 in defm NCOT : VSTtgm<opcStr#".nc.ot", opc, RC>;
}

// Section 8.9.7 - VST (Vector Store)
defm VST : VSTm<"vst", 0x91, V64>;

// Section 8.9.8 - VST (Vector Store Upper)
defm VSTU : VSTm<"vstu", 0x92, V64>;

// Section 8.9.9 - VSTL (Vector Store Lower)
defm VSTL : VSTm<"vstl", 0x93, V64>;

// Section 8.9.10 - VST2D (Vector Store 2D)
defm VST2D : VSTm<"vst2d", 0xd1, V64>;

// Section 8.9.11 - VSTU2D (Vector Store Upper 2D)
defm VSTU2D : VSTm<"vstu2d", 0xd2, V64>;

// Section 8.9.12 - VSTL2D (Vector Store Lower 2D)
defm VSTL2D : VSTm<"vstl2d", 0xd3, V64>;

// Multiclass for VGT instructions
let mayLoad = 1, hasSideEffects = 0, Uses = [VL] in
multiclass VGTbm<string opcStr, string argStr, bits<8>opc, RegisterClass RC,
                 dag dag_in, string disEnc = ""> {
  let DisableEncoding = disEnc in
  def "" : RVM<opc, (outs RC:$vx), dag_in,
               !strconcat(opcStr, " $vx, ", argStr)>;
  let Constraints = "$vx = $base", DisableEncoding = disEnc#"$base",
      isCodeGenOnly = 1 in
  def _v : RVM<opc, (outs RC:$vx), !con(dag_in, (ins RC:$base)),
               !strconcat(opcStr, " $vx, ", argStr)>;
}
multiclass VGTlm<string opcStr, string argStr, bits<8>opc, RegisterClass RC,
                 dag dag_in> {
  defm "" : VGTbm<opcStr, argStr, opc, RC, dag_in>;
  let isCodeGenOnly = 1, VE_VLInUse = 1 in {
    defm l : VGTbm<opcStr, argStr, opc, RC, !con(dag_in, (ins I32:$vl)),
                   "$vl,">;
    defm L : VGTbm<opcStr, argStr, opc, RC, !con(dag_in, (ins VLS:$vl)),
                   "$vl,">;
  }
}
multiclass VGTmm<string opcStr, string argStr, bits<8>opc, RegisterClass RC,
                 dag dag_in> {
  defm "" : VGTlm<opcStr, argStr, opc, RC, dag_in>;
  let m = ?, VE_VLWithMask = 1 in
  defm m : VGTlm<opcStr, argStr#", $m", opc, RC, !con(dag_in, (ins VM:$m))>;
}
let VE_VLIndex = 4 in
multiclass VGTlhm<string opcStr, string argStr, bits<8>opc, RegisterClass RC,
                  dag dag_in> {
  defm rr : VGTmm<opcStr, argStr#", $sy, $sz", opc, RC,
                  !con(dag_in, (ins I64:$sy, I64:$sz))>;
  let cy = 0 in
  defm ir : VGTmm<opcStr, argStr#", $sy, $sz", opc, RC,
                  !con(dag_in, (ins simm7:$sy, I64:$sz))>;
  let cz = 0 in
  defm rz : VGTmm<opcStr, argStr#", $sy, $sz", opc, RC,
                  !con(dag_in, (ins I64:$sy, zero:$sz))>;
  let cy = 0, cz = 0 in
  defm iz : VGTmm<opcStr, argStr#", $sy, $sz", opc, RC,
                  !con(dag_in, (ins simm7:$sy, zero:$sz))>;
}
multiclass VGTtgm<string opcStr, bits<8>opc, RegisterClass RC> {
  let vy = ? in defm v : VGTlhm<opcStr, "$vy", opc, RC, (ins V64:$vy)>;
  let cs = 1, sw = ? in defm s : VGTlhm<opcStr, "$sw", opc, RC, (ins I64:$sw)>;
}
multiclass VGTm<string opcStr, bits<8>opc, RegisterClass RC> {
  let vc = 1 in defm "" : VGTtgm<opcStr, opc, RC>;
  let vc = 0 in defm NC : VGTtgm<opcStr#".nc", opc, RC>;
}

// Section 8.9.13 - VGT (Vector Gather)
defm VGT : VGTm<"vgt", 0xa1, V64>;

// Section 8.9.14 - VGTU (Vector Gather Upper)
defm VGTU : VGTm<"vgtu", 0xa2, V64>;

// Section 8.9.15 - VGTL (Vector Gather Lower)
defm VGTLSX : VGTm<"vgtl.sx", 0xa3, V64>;
let cx = 1 in defm VGTLZX : VGTm<"vgtl.zx", 0xa3, V64>;
def : MnemonicAlias<"vgtl", "vgtl.zx">;
def : MnemonicAlias<"vgtl.nc", "vgtl.zx.nc">;

// Multiclass for VSC instructions
let mayStore = 1, hasSideEffects = 0, Uses = [VL] in
multiclass VSCbm<string opcStr, string argStr, bits<8>opc, dag dag_in> {
  def "" : RVM<opc, (outs), dag_in, !strconcat(opcStr, argStr)>;
  let DisableEncoding = "$vl", isCodeGenOnly = 1, VE_VLInUse = 1 in {
    def l : RVM<opc, (outs), !con(dag_in, (ins I32:$vl)),
                !strconcat(opcStr, argStr)>;
    def L : RVM<opc, (outs), !con(dag_in, (ins VLS:$vl)),
                !strconcat(opcStr, argStr)>;
  }
}
multiclass VSCmm<string opcStr, string argStr, bits<8>opc, dag dag_in> {
  defm "" : VSCbm<opcStr, argStr, opc, dag_in>;
  let m = ?, VE_VLWithMask = 1 in
  defm m : VSCbm<opcStr, argStr#", $m", opc, !con(dag_in, (ins VM:$m))>;
}
let VE_VLIndex = 4 in
multiclass VSClhm<string opcStr, string argStr, bits<8>opc, RegisterClass RC,
                  dag dag_in> {
  defm rrv : VSCmm<opcStr, " $vx, "#argStr#", $sy, $sz", opc,
                   !con(dag_in, (ins I64:$sy, I64:$sz, RC:$vx))>;
  let cy = 0 in
  defm irv : VSCmm<opcStr, " $vx, "#argStr#", $sy, $sz", opc,
                   !con(dag_in, (ins simm7:$sy, I64:$sz, RC:$vx))>;
  let cz = 0 in
  defm rzv : VSCmm<opcStr, " $vx, "#argStr#", $sy, $sz", opc,
                   !con(dag_in, (ins I64:$sy, zero:$sz, RC:$vx))>;
  let cy = 0, cz = 0 in
  defm izv : VSCmm<opcStr, " $vx, "#argStr#", $sy, $sz", opc,
                   !con(dag_in, (ins simm7:$sy, zero:$sz, RC:$vx))>;
}
multiclass VSCtgm<string opcStr, bits<8>opc, RegisterClass RC> {
  let vy = ? in defm v : VSClhm<opcStr, "$vy", opc, RC, (ins V64:$vy)>;
  let cs = 1, sw = ? in defm s : VSClhm<opcStr, "$sw", opc, RC, (ins I64:$sw)>;
}
multiclass VSCm<string opcStr, bits<8>opc, RegisterClass RC> {
  let vc = 1, cx = 0 in defm "" : VSCtgm<opcStr, opc, RC>;
  let vc = 0, cx = 0 in defm NC : VSCtgm<opcStr#".nc", opc, RC>;
  let vc = 1, cx = 1 in defm OT : VSCtgm<opcStr#".ot", opc, RC>;
  let vc = 0, cx = 1 in defm NCOT : VSCtgm<opcStr#".nc.ot", opc, RC>;
}

// Section 8.9.16 - VSC (Vector Scatter)
defm VSC : VSCm<"vsc", 0xb1, V64>;

// Section 8.9.17 - VSCU (Vector Scatter Upper)
defm VSCU : VSCm<"vscu", 0xb2, V64>;

// Section 8.9.18 - VSCL (Vector Scatter Lower)
defm VSCL : VSCm<"vscl", 0xb3, V64>;

// Section 8.9.19 - PFCHV (Prefetch Vector)
let Uses = [VL] in
multiclass PFCHVbm<string opcStr, string argStr, bits<8>opc, dag dag_in> {
  def "" : RVM<opc, (outs), dag_in, !strconcat(opcStr, argStr)>;
  let DisableEncoding = "$vl", isCodeGenOnly = 1, VE_VLInUse = 1 in {
    def l : RVM<opc, (outs), !con(dag_in, (ins I32:$vl)),
                !strconcat(opcStr, argStr)>;
    def L : RVM<opc, (outs), !con(dag_in, (ins VLS:$vl)),
                !strconcat(opcStr, argStr)>;
  }
}
let VE_VLIndex = 2 in
multiclass PFCHVm<string opcStr, bits<8>opc> {
  defm rr : PFCHVbm<opcStr, " $sy, $sz", opc, (ins I64:$sy, I64:$sz)>;
  let cy = 0 in
  defm ir : PFCHVbm<opcStr, " $sy, $sz", opc, (ins simm7:$sy, I64:$sz)>;
  let cz = 0 in
  defm rz : PFCHVbm<opcStr, " $sy, $sz", opc, (ins I64:$sy, zero:$sz)>;
  let cy = 0, cz = 0 in
  defm iz : PFCHVbm<opcStr, " $sy, $sz", opc, (ins simm7:$sy, zero:$sz)>;
}
let vc = 1, vx = 0 in defm PFCHV : PFCHVm<"pfchv", 0x80>;
let vc = 0, vx = 0 in defm PFCHVNC : PFCHVm<"pfchv.nc", 0x80>;

// Section 8.9.20 - LSV (Load S to V)
let sx = 0, vx = ?, hasSideEffects = 0 in
multiclass LSVbm<string opcStr, string argStr, bits<8>opc, RegisterClass RC,
                 dag dag_in> {
  def "" : RR<opc, (outs RC:$vx), dag_in, !strconcat(opcStr, " ${vx}", argStr)>;
  let Constraints = "$vx = $base", DisableEncoding = "$base",
      isCodeGenOnly = 1 in
  def _v : RR<opc, (outs RC:$vx), !con(dag_in, (ins RC:$base)),
               !strconcat(opcStr, " ${vx}", argStr)>;
}
multiclass LSVm<string opcStr, bits<8>opc, RegisterClass RC> {
  defm rr : LSVbm<opcStr, "(${sy}), $sz", opc, RC, (ins I64:$sy, I64:$sz)>;
  let cy = 0 in
  defm ir : LSVbm<opcStr, "(${sy}), $sz", opc, RC, (ins uimm7:$sy, I64:$sz)>;
  let cz = 0 in
  defm rm : LSVbm<opcStr, "(${sy}), $sz", opc, RC, (ins I64:$sy, mimm:$sz)>;
  let cy = 0, cz = 0 in
  defm im : LSVbm<opcStr, "(${sy}), $sz", opc, RC, (ins uimm7:$sy, mimm:$sz)>;
}
defm LSV : LSVm<"lsv", 0x8e, V64>;

// Section 8.9.21 - LVS (Load V to S)
let cz = 0, sz = 0, vx = ?, hasSideEffects = 0 in
multiclass LVSm<string opcStr, bits<8>opc, RegisterClass RC> {
  def vr : RR<opc, (outs I64:$sx), (ins RC:$vx, I64:$sy),
              opcStr#" $sx, ${vx}(${sy})">;
  let cy = 0 in
  def vi : RR<opc, (outs I64:$sx), (ins RC:$vx, uimm7:$sy),
              opcStr#" $sx, ${vx}(${sy})">;
}
defm LVS : LVSm<"lvs", 0x9e, V64>;

// Section 8.9.22 - LVM (Load VM)
let sx = 0, vx = ?, hasSideEffects = 0 in
multiclass LVMbm<string opcStr, string argStr, bits<8>opc, RegisterClass RCM,
                 dag dag_in> {
  def "" : RR<opc, (outs RCM:$vx), dag_in,
              !strconcat(opcStr, " $vx, ", argStr)>;
  let Constraints = "$vx = $base", DisableEncoding = "$base",
      isCodeGenOnly = 1 in {
    def _m : RR<opc, (outs RCM:$vx), !con(dag_in, (ins RCM:$base)),
                !strconcat(opcStr, " $vx, ", argStr)>;
  }
}
multiclass LVMom<string opcStr, bits<8>opc, RegisterClass RCM> {
  defm rr : LVMbm<opcStr, "$sy, $sz", opc, RCM, (ins I64:$sy, I64:$sz)>;
  let cy = 0 in
  defm ir : LVMbm<opcStr, "$sy, $sz", opc, RCM, (ins uimm2:$sy, I64:$sz)>;
  let cz = 0 in
  defm rm : LVMbm<opcStr, "$sy, $sz", opc, RCM, (ins I64:$sy, mimm:$sz)>;
  let cy = 0, cz = 0 in
  defm im : LVMbm<opcStr, "$sy, $sz", opc, RCM, (ins uimm2:$sy, mimm:$sz)>;
}
multiclass LVMm<string opcStr, bits<8>opc, RegisterClass RCM> {
  defm "" : LVMom<opcStr, opc, RCM>;
}
defm LVM : LVMm<"lvm", 0xb7, VM>;

// Section 8.9.23 - SVM (Save VM)
let cz = 0, sz = 0, vz = ?, hasSideEffects = 0 in
multiclass SVMm<string opcStr, bits<8>opc, RegisterClass RCM> {
  def mr : RR<opc, (outs I64:$sx), (ins RCM:$vz, I64:$sy),
              opcStr#" $sx, $vz, $sy">;
  let cy = 0 in
  def mi : RR<opc, (outs I64:$sx), (ins RCM:$vz, uimm2:$sy),
              opcStr#" $sx, $vz, $sy">;
}
defm SVM : SVMm<"svm", 0xa7, VM>;

// Section 8.9.24 - VBRD (Vector Broadcast)
let vx = ?, hasSideEffects = 0, Uses = [VL] in
multiclass VBRDbm<string opcStr, string argStr, bits<8>opc, RegisterClass RC,
                  dag dag_in, string disEnc = ""> {
  let DisableEncoding = disEnc in
  def "" : RV<opc, (outs RC:$vx), dag_in,
              !strconcat(opcStr, " $vx, ", argStr)>;
  let Constraints = "$vx = $base", DisableEncoding = disEnc#"$base",
      isCodeGenOnly = 1 in
  def _v : RV<opc, (outs RC:$vx), !con(dag_in, (ins RC:$base)),
              !strconcat(opcStr, " $vx, ", argStr)>;
}
multiclass VBRDlm<string opcStr, string argStr, bits<8>opc, RegisterClass RC,
                  dag dag_in> {
  defm "" : VBRDbm<opcStr, argStr, opc, RC, dag_in>;
  let isCodeGenOnly = 1, VE_VLInUse = 1 in {
    defm l : VBRDbm<opcStr, argStr, opc, RC, !con(dag_in, (ins I32:$vl)),
                   "$vl,">;
    defm L : VBRDbm<opcStr, argStr, opc, RC, !con(dag_in, (ins VLS:$vl)),
                   "$vl,">;
  }
}
multiclass VBRDmm<string opcStr, string argStr, bits<8>opc, RegisterClass RC,
                  RegisterClass RCM, dag dag_in> {
  defm "" : VBRDlm<opcStr, argStr, opc, RC, dag_in>;
  let m = ?, VE_VLWithMask = 1 in
  defm m : VBRDlm<opcStr, argStr#", $m", opc, RC, !con(dag_in, (ins RCM:$m))>;
}
let VE_VLIndex = 2 in
multiclass VBRDm<string opcStr, bits<8>opc, RegisterClass VRC, RegisterClass RC,
                 RegisterClass RCM> {
  defm r : VBRDmm<opcStr, "$sy", opc, VRC, RCM, (ins RC:$sy)>;
  let cy = 0 in
  defm i : VBRDmm<opcStr, "$sy", opc, VRC, RCM, (ins simm7:$sy)>;
}
let cx = 0, cx2 = 0 in
defm VBRD : VBRDm<"vbrd", 0x8c, V64, I64, VM>;
let cx = 0, cx2 = 1 in
defm VBRDL : VBRDm<"vbrdl", 0x8c, V64, I32, VM>;
let cx = 1, cx2 = 0 in
defm VBRDU : VBRDm<"vbrdu", 0x8c, V64, F32, VM>;
let cx = 1, cx2 = 1 in
defm PVBRD : VBRDm<"pvbrd", 0x8c, V64, I64, VM512>;

// Section 8.9.25 - VMV (Vector Move)
let vx = ?, vz = ?, hasSideEffects = 0, Uses = [VL] in
multiclass VMVbm<string opcStr, string argStr, bits<8>opc, RegisterClass RC,
                 dag dag_in, string disEnc = ""> {
  let DisableEncoding = disEnc in
  def "" : RV<opc, (outs RC:$vx), dag_in,
              !strconcat(opcStr, " $vx, ", argStr)>;
  let Constraints = "$vx = $base", DisableEncoding = disEnc#"$base",
      isCodeGenOnly = 1 in
  def _v : RV<opc, (outs RC:$vx), !con(dag_in, (ins RC:$base)),
              !strconcat(opcStr, " $vx, ", argStr)>;
}
multiclass VMVlm<string opcStr, string argStr, bits<8>opc, RegisterClass RC,
                 dag dag_in> {
  defm "" : VMVbm<opcStr, argStr, opc, RC, dag_in>;
  let isCodeGenOnly = 1, VE_VLInUse = 1 in {
    defm l : VMVbm<opcStr, argStr, opc, RC, !con(dag_in, (ins I32:$vl)),
                   "$vl,">;
    defm L : VMVbm<opcStr, argStr, opc, RC, !con(dag_in, (ins VLS:$vl)),
                   "$vl,">;
  }
}
multiclass VMVmm<string opcStr, bits<8>opc, RegisterClass RC,
                 RegisterClass RCM, dag dag_in> {
  defm "" : VMVlm<opcStr, "$sy, $vz", opc, RC, dag_in>;
  let m = ?, VE_VLWithMask = 1 in
  defm m : VMVlm<opcStr, "$sy, $vz, $m", opc, RC, !con(dag_in, (ins RCM:$m))>;
}
let VE_VLIndex = 3 in
multiclass VMVm<string opcStr, bits<8>opc, RegisterClass RC,
                RegisterClass RCM> {
  defm rv : VMVmm<opcStr, opc, RC, RCM, (ins I64:$sy, RC:$vz)>;
  let cy = 0 in
  defm iv : VMVmm<opcStr, opc, RC, RCM, (ins uimm7:$sy, RC:$vz)>;
}
defm VMV : VMVm<"vmv", 0x9c, V64, VM>;

//-----------------------------------------------------------------------------
// Section 8.10 - Vector Fixed-Point Arithmetic Instructions
//-----------------------------------------------------------------------------

// Multiclass for generic vector calculation
let vx = ?, hasSideEffects = 0, Uses = [VL] in
multiclass RVbm<string opcStr, string argStr, bits<8>opc, RegisterClass RC,
                dag dag_in, string disEnc = ""> {
  let DisableEncoding = disEnc in
  def "" : RV<opc, (outs RC:$vx), dag_in,
              !strconcat(opcStr, " $vx", argStr)>;
  let Constraints = "$vx = $base", DisableEncoding = disEnc#"$base",
      isCodeGenOnly = 1 in
  def _v : RV<opc, (outs RC:$vx), !con(dag_in, (ins RC:$base)),
              !strconcat(opcStr, " $vx", argStr)>;
}
multiclass RVlm<string opcStr, string argStr, bits<8>opc, RegisterClass RC,
                dag dag_in> {
  defm "" : RVbm<opcStr, argStr, opc, RC, dag_in>;
  let isCodeGenOnly = 1, VE_VLInUse = 1 in {
    defm l : RVbm<opcStr, argStr, opc, RC, !con(dag_in, (ins I32:$vl)),
                  "$vl,">;
    defm L : RVbm<opcStr, argStr, opc, RC, !con(dag_in, (ins VLS:$vl)),
                  "$vl,">;
  }
}
multiclass RVmm<string opcStr, string argStr, bits<8>opc, RegisterClass RC,
                RegisterClass RCM, dag dag_in> {
  defm "" : RVlm<opcStr, argStr, opc, RC, dag_in>;
  let m = ?, VE_VLWithMask = 1 in
  defm m : RVlm<opcStr, argStr#", $m", opc, RC, !con(dag_in, (ins RCM:$m))>;
}
// Generic RV multiclass with 2 arguments.
//   e.g. VADD, VSUB, VMPY, and etc.
let VE_VLIndex = 3 in
multiclass RVm<string opcStr, bits<8>opc, RegisterClass VRC, RegisterClass RC,
               RegisterClass RCM, Operand SIMM = simm7> {
  let cy = 0, sy = 0, vy = ?, vz = ? in
  defm vv : RVmm<opcStr, ", $vy, $vz", opc, VRC, RCM, (ins VRC:$vy, VRC:$vz)>;
  let cs = 1, vz = ? in
  defm rv : RVmm<opcStr, ", $sy, $vz", opc, VRC, RCM, (ins RC:$sy, VRC:$vz)>;
  let cs = 1, cy = 0, vz = ? in
  defm iv : RVmm<opcStr, ", $sy, $vz", opc, VRC, RCM, (ins SIMM:$sy, VRC:$vz)>;
}
// Special RV multiclass with 2 arguments using cs2.
//   e.g. VDIV, VDVS, and VDVX.
let VE_VLIndex = 3 in
multiclass RVDIVm<string opcStr, bits<8>opc, RegisterClass VRC,
                  RegisterClass RC, RegisterClass RCM, Operand SIMM = simm7> {
  let cy = 0, sy = 0, vy = ?, vz = ? in
  defm vv : RVmm<opcStr, ", $vy, $vz", opc, VRC, RCM, (ins VRC:$vy, VRC:$vz)>;
  let cs2 = 1, vy = ? in
  defm vr : RVmm<opcStr, ", $vy, $sy", opc, VRC, RCM, (ins VRC:$vy, RC:$sy)>;
  let cs2 = 1, cy = 0, vy = ? in
  defm vi : RVmm<opcStr, ", $vy, $sy", opc, VRC, RCM, (ins VRC:$vy, SIMM:$sy)>;
  let cs = 1, vz = ? in
  defm rv : RVmm<opcStr, ", $sy, $vz", opc, VRC, RCM, (ins RC:$sy, VRC:$vz)>;
  let cs = 1, cy = 0, vz = ? in
  defm iv : RVmm<opcStr, ", $sy, $vz", opc, VRC, RCM, (ins SIMM:$sy, VRC:$vz)>;
}
// Generic RV multiclass with 2 arguments for logical operations.
//   e.g. VAND, VOR, VXOR, and etc.
let VE_VLIndex = 3 in
multiclass RVLm<string opcStr, bits<8>opc, RegisterClass ScaRC,
                RegisterClass RC, RegisterClass RCM> {
  let cy = 0, sy = 0, vy = ?, vz = ? in
  defm vv : RVmm<opcStr, ", $vy, $vz", opc, RC, RCM, (ins RC:$vy, RC:$vz)>;
  let cs = 1, vz = ? in
  defm rv : RVmm<opcStr, ", $sy, $vz", opc, RC, RCM, (ins ScaRC:$sy, RC:$vz)>;
  let cs = 1, cy = 0, vz = ? in
  defm mv : RVmm<opcStr, ", $sy, $vz", opc, RC, RCM, (ins mimm:$sy, RC:$vz)>;
}
// Generic RV multiclass with 1 argument.
//   e.g. VLDZ, VPCNT, and VBRV.
let VE_VLIndex = 2 in
multiclass RV1m<string opcStr, bits<8>opc, RegisterClass RC,
                RegisterClass RCM> {
  let cy = 0, sy = 0, vz = ? in
  defm v : RVmm<opcStr, ", $vz", opc, RC, RCM, (ins RC:$vz)>;
}
// Generic RV multiclass with no argument.
//   e.g. VSEQ.
let VE_VLIndex = 1 in
multiclass RV0m<string opcStr, bits<8>opc, RegisterClass RC,
                RegisterClass RCM> {
  let cy = 0, sy = 0 in
  defm "" : RVmm<opcStr, "", opc, RC, RCM, (ins)>;
}
// Generic RV multiclass with 2 arguments for shift operations.
//   e.g. VSLL, VSRL, VSLA, and etc.
let VE_VLIndex = 3 in
multiclass RVSm<string opcStr, bits<8>opc, RegisterClass ScaRC,
                RegisterClass RC, RegisterClass RCM> {
  let cy = 0, sy = 0, vy = ?, vz = ? in
  defm vv : RVmm<opcStr, ", $vz, $vy", opc, RC, RCM, (ins RC:$vz, RC:$vy)>;
  let cs = 1, vz = ? in
  defm vr : RVmm<opcStr, ", $vz, $sy", opc, RC, RCM, (ins RC:$vz, ScaRC:$sy)>;
  let cs = 1, cy = 0, vz = ? in
  defm vi : RVmm<opcStr, ", $vz, $sy", opc, RC, RCM, (ins RC:$vz, uimm7:$sy)>;
}
// Generic RV multiclass with 3 arguments for shift operations.
//   e.g. VSLD and VSRD.
let VE_VLIndex = 4 in
multiclass RVSDm<string opcStr, bits<8>opc, RegisterClass RC,
                 RegisterClass RCM> {
  let vy = ?, vz = ? in
  defm vvr : RVmm<opcStr, ", ($vy, ${vz}), $sy", opc, RC, RCM,
                 (ins RC:$vy, RC:$vz, I64:$sy)>;
  let cy = 0, vy = ?, vz = ? in
  defm vvi : RVmm<opcStr, ", ($vy, ${vz}), $sy", opc, RC, RCM,
                 (ins RC:$vy, RC:$vz, uimm7:$sy)>;
}
// Special RV multiclass with 3 arguments.
//   e.g. VSFA
let VE_VLIndex = 4 in
multiclass RVSAm<string opcStr, bits<8>opc, RegisterClass RC,
                 RegisterClass RCM> {
  let cz = 1, sz = ?, vz = ? in
  defm vrr : RVmm<opcStr, ", $vz, $sy, $sz", opc, RC, RCM,
                  (ins RC:$vz, I64:$sy, I64:$sz)>;
  let cz = 0, sz = ?, vz = ? in
  defm vrm : RVmm<opcStr, ", $vz, $sy, $sz", opc, RC, RCM,
                  (ins RC:$vz, I64:$sy, mimm:$sz)>;
  let cy = 0, cz = 1, sz = ?, vz = ? in
  defm vir : RVmm<opcStr, ", $vz, $sy, $sz", opc, RC, RCM,
                  (ins RC:$vz, uimm3:$sy, I64:$sz)>;
  let cy = 0, cz = 0, sz = ?, vz = ? in
  defm vim : RVmm<opcStr, ", $vz, $sy, $sz", opc, RC, RCM,
                  (ins RC:$vz, uimm3:$sy, mimm:$sz)>;
}
// Generic RV multiclass with 1 argument using vy field.
//   e.g. VFSQRT, VRCP, and VRSQRT.
let VE_VLIndex = 2 in
multiclass RVF1m<string opcStr, bits<8>opc, RegisterClass RC,
                 RegisterClass RCM> {
  let cy = 0, sy = 0, vy = ? in
  defm v : RVmm<opcStr, ", $vy", opc, RC, RCM, (ins RC:$vy)>;
}
// Special RV multiclass with 3 arguments using cs2.
//   e.g. VFMAD, VFMSB, VFNMAD, and etc.
let VE_VLIndex = 4 in
multiclass RVMm<string opcStr, bits<8>opc, RegisterClass VRC, RegisterClass RC,
                RegisterClass RCM, Operand SIMM = simm7> {
  let cy = 0, sy = 0, vy = ?, vz = ?, vw = ? in
  defm vvv : RVmm<opcStr, ", $vy, $vz, $vw", opc, VRC, RCM,
                  (ins VRC:$vy, VRC:$vz, VRC:$vw)>;
  let cs2 = 1, vy = ?, vw = ? in
  defm vrv : RVmm<opcStr, ", $vy, $sy, $vw", opc, VRC, RCM,
                  (ins VRC:$vy, RC:$sy, VRC:$vw)>;
  let cs2 = 1, cy = 0, vy = ?, vw = ? in
  defm viv : RVmm<opcStr, ", $vy, $sy, $vw", opc, VRC, RCM,
                  (ins VRC:$vy, SIMM:$sy, VRC:$vw)>;
  let cs = 1, vz = ?, vw = ? in
  defm rvv : RVmm<opcStr, ", $sy, $vz, $vw", opc, VRC, RCM,
                  (ins RC:$sy, VRC:$vz, VRC:$vw)>;
  let cs = 1, cy = 0, vz = ?, vw = ? in
  defm ivv : RVmm<opcStr, ", $sy, $vz, $vw", opc, VRC, RCM,
                  (ins SIMM:$sy, VRC:$vz, VRC:$vw)>;
}
// Special RV multiclass with 2 arguments for floating point conversions.
//   e.g. VFIX and VFIXX
let hasSideEffects = 0, VE_VLIndex = 3 in
multiclass RVFIXm<string opcStr, bits<8> opc, RegisterClass RC,
                  RegisterClass RCM> {
  let cy = 0, sy = 0, vy = ?, vz = ? in
  defm v : RVmm<opcStr#"$vz", ", $vy", opc, RC, RCM, (ins RDOp:$vz, RC:$vy)>;
}
// Multiclass for generic iterative vector calculation
let vx = ?, hasSideEffects = 0, Uses = [VL] in
multiclass RVIbm<string opcStr, string argStr, bits<8>opc, RegisterClass RC,
                dag dag_in, string disEnc = ""> {
  let DisableEncoding = disEnc in
  def "" : RV<opc, (outs RC:$vx), dag_in,
              !strconcat(opcStr, " $vx", argStr)>;
  let isCodeGenOnly = 1, Constraints = "$vx = $base", DisableEncoding = disEnc#"$base" in
  def _v : RV<opc, (outs RC:$vx), !con(dag_in, (ins RC:$base)),
              !strconcat(opcStr, " $vx", argStr)>;
}
multiclass RVIlm<string opcStr, string argStr, bits<8>opc, RegisterClass RC,
                 dag dag_in> {
  defm "" : RVIbm<opcStr, argStr, opc, RC, dag_in>;
  let isCodeGenOnly = 1, VE_VLInUse = 1 in {
    defm l : RVIbm<opcStr, argStr, opc, RC, !con(dag_in, (ins I32:$vl)),
                   "$vl,">;
    defm L : RVIbm<opcStr, argStr, opc, RC, !con(dag_in, (ins VLS:$vl)),
                   "$vl,">;
  }
}
// Generic RV multiclass for iterative operation with 2 argument.
//   e.g. VFIA, VFIS, and VFIM
let VE_VLIndex = 3 in
multiclass RVI2m<string opcStr, bits<8>opc, RegisterClass VRC,
                 RegisterClass RC> {
  let vy = ? in
  defm vr : RVIlm<opcStr, ", $vy, $sy", opc, VRC, (ins VRC:$vy, RC:$sy)>;
  let cy = 0, vy = ? in
  defm vi : RVIlm<opcStr, ", $vy, $sy", opc, VRC, (ins VRC:$vy, simm7fp:$sy)>;
}
// Generic RV multiclass for iterative operation with 3 argument.
//   e.g. VFIAM, VFISM, VFIMA, and etc.
let VE_VLIndex = 4 in
multiclass RVI3m<string opcStr, bits<8>opc, RegisterClass VRC,
                 RegisterClass RC> {
  let vy = ?, vz = ? in
  defm vvr : RVIlm<opcStr, ", $vy, $vz, $sy", opc, VRC,
                   (ins VRC:$vy, VRC:$vz, RC:$sy)>;
  let cy = 0, vy = ?, vz = ? in
  defm vvi : RVIlm<opcStr, ", $vy, $vz, $sy", opc, VRC,
                   (ins VRC:$vy, VRC:$vz, simm7fp:$sy)>;
}
// special RV multiclass with 3 arguments for VSHF.
//   e.g. VSHF
let vy = ?, vz = ?, VE_VLIndex = 4 in
multiclass RVSHFm<string opcStr, bits<8>opc, RegisterClass RC,
                  Operand SIMM = uimm4> {
  defm vvr : RVlm<opcStr, ", $vy, $vz, $sy", opc, RC,
                  (ins RC:$vy, RC:$vz, I64:$sy)>;
  let cy = 0 in defm vvi : RVlm<opcStr, ", $vy, $vz, $sy", opc, RC,
                                (ins RC:$vy, RC:$vz, SIMM:$sy)>;
}
// Multiclass for generic mask calculation
let vx = ?, hasSideEffects = 0, Uses = [VL] in
multiclass RVMKbm<string opcStr, string argStr, bits<8>opc, dag dag_out,
                  dag dag_in> {
  def "" : RV<opc, dag_out, dag_in, !strconcat(opcStr, argStr)>;
  let DisableEncoding = "$vl", isCodeGenOnly = 1, VE_VLInUse = 1 in {
    def l : RV<opc, dag_out, !con(dag_in, (ins I32:$vl)),
               !strconcat(opcStr, argStr)>;
    def L : RV<opc, dag_out, !con(dag_in, (ins VLS:$vl)),
               !strconcat(opcStr, argStr)>;
  }
}
multiclass RVMKlm<string opcStr, string argStr, bits<8>opc, RegisterClass RCM,
                  dag dag_in> {
  defm "" : RVMKbm<opcStr, " $vx"#argStr, opc, (outs RCM:$vx), dag_in>;
  let m = ?, VE_VLWithMask = 1 in
  defm m : RVMKbm<opcStr, " $vx"#argStr#", $m", opc, (outs RCM:$vx),
                  !con(dag_in, (ins RCM:$m))>;
}
// Generic RV multiclass for mask calculation with a condition.
//   e.g. VFMK, VFMS, and VFMF
let cy = 0, sy = 0 in
multiclass RVMKom<string opcStr, bits<8> opc, RegisterClass RC,
                 RegisterClass RCM> {
  let vy = ?, vz = ?, VE_VLIndex = 3 in
  defm v : RVMKlm<opcStr#"$vy", ", $vz", opc, RCM, (ins CCOp:$vy, RC:$vz)>;
  let vy = 15 /* AT */, VE_VLIndex = 1 in
  defm a : RVMKlm<opcStr#"at", "", opc, RCM, (ins)>;
  let vy = 0 /* AF */, VE_VLIndex = 1 in
  defm na : RVMKlm<opcStr#"af", "", opc, RCM, (ins)>;
}
multiclass RVMKm<string opcStr, bits<8> opc, RegisterClass RC,
                 RegisterClass RCM> {
  defm "" : RVMKom<opcStr, opc, RC, RCM>;
}
// Generic RV multiclass for mask calculation with 2 arguments.
//   e.g. ANDM, ORM, XORM, and etc.
let cy = 0, sy = 0, vx = ?, vy = ?, vz = ?, hasSideEffects = 0 in
multiclass RVM2m<string opcStr, bits<8> opc, RegisterClass RCM> {
  def mm : RV<opc, (outs RCM:$vx), (ins RCM:$vy, RCM:$vz),
              !strconcat(opcStr, " $vx, $vy, $vz")>;
}
// Generic RV multiclass for mask calculation with 1 argument.
//   e.g. NEGM
let cy = 0, sy = 0, vx = ?, vy = ?, hasSideEffects = 0 in
multiclass RVM1m<string opcStr, bits<8> opc, RegisterClass RCM> {
  def m : RV<opc, (outs RCM:$vx), (ins RCM:$vy),
             !strconcat(opcStr, " $vx, $vy")>;
}
// Generic RV multiclass for mask calculation with 1 argument.
//   e.g. PCVM, LZVM, and TOVM
let cy = 0, sy = 0, vy = ?, hasSideEffects = 0, Uses = [VL] in
multiclass RVMSbm<string opcStr, string argStr, bits<8>opc, dag dag_in> {
  def "" : RV<opc, (outs I64:$sx), dag_in,
              !strconcat(opcStr, " $sx,", argStr)> {
    bits<7> sx;
    let Inst{54-48} = sx;
  }
  let DisableEncoding = "$vl", isCodeGenOnly = 1, VE_VLInUse = 1 in {
    def l : RV<opc, (outs I64:$sx), !con(dag_in, (ins I32:$vl)),
               !strconcat(opcStr, " $sx,", argStr)> {
      bits<7> sx;
      let Inst{54-48} = sx;
    }
    def L : RV<opc, (outs I64:$sx), !con(dag_in, (ins VLS:$vl)),
               !strconcat(opcStr, " $sx,", argStr)> {
      bits<7> sx;
      let Inst{54-48} = sx;
    }
  }
}
let VE_VLIndex = 2 in
multiclass RVMSm<string opcStr, bits<8> opc, RegisterClass RCM> {
  defm m : RVMSbm<opcStr, " $vy", opc, (ins RCM:$vy)>;
}

// Section 8.10.1 - VADD (Vector Add)
let cx = 0, cx2 = 0 in
defm VADDUL : RVm<"vaddu.l", 0xc8, V64, I64, VM>;
let cx = 0, cx2 = 1 in {
  defm PVADDULO : RVm<"pvaddu.lo", 0xc8, V64, I32, VM>;
  let isCodeGenOnly = 1 in
  defm VADDUW : RVm<"vaddu.w", 0xc8, V64, I32, VM>;
}
let cx = 1, cx2 = 0 in
defm PVADDUUP : RVm<"pvaddu.up", 0xc8, V64, I64, VM>;
let cx = 1, cx2 = 1 in
defm PVADDU : RVm<"pvaddu", 0xc8, V64, I64, VM512>;
def : MnemonicAlias<"vaddu.w", "pvaddu.lo">;

// Section 8.10.2 - VADS (Vector Add Single)
let cx = 0, cx2 = 0 in
defm VADDSWSX : RVm<"vadds.w.sx", 0xca, V64, I32, VM>;
let cx = 0, cx2 = 1 in {
  defm PVADDSLO : RVm<"pvadds.lo", 0xca, V64, I32, VM>;
  let isCodeGenOnly = 1 in
  defm VADDSWZX : RVm<"vadds.w.zx", 0xca, V64, I32, VM>;
}
let cx = 1, cx2 = 0 in
defm PVADDSUP : RVm<"pvadds.up", 0xca, V64, I64, VM>;
let cx = 1, cx2 = 1 in
defm PVADDS : RVm<"pvadds", 0xca, V64, I64, VM512>;
def : MnemonicAlias<"pvadds.lo.sx", "vadds.w.sx">;
def : MnemonicAlias<"vadds.w.zx", "pvadds.lo">;
def : MnemonicAlias<"vadds.w", "pvadds.lo">;
def : MnemonicAlias<"pvadds.lo.zx", "pvadds.lo">;

// Section 8.10.3 - VADX (Vector Add)
defm VADDSL : RVm<"vadds.l", 0x8b, V64, I64, VM>;

// Section 8.10.4 - VSUB (Vector Subtract)
let cx = 0, cx2 = 0 in
defm VSUBUL : RVm<"vsubu.l", 0xd8, V64, I64, VM>;
let cx = 0, cx2 = 1 in {
  defm PVSUBULO : RVm<"pvsubu.lo", 0xd8, V64, I32, VM>;
  let isCodeGenOnly = 1 in
  defm VSUBUW : RVm<"vsubu.w", 0xd8, V64, I32, VM>;
}
let cx = 1, cx2 = 0 in
defm PVSUBUUP : RVm<"pvsubu.up", 0xd8, V64, I64, VM>;
let cx = 1, cx2 = 1 in
defm PVSUBU : RVm<"pvsubu", 0xd8, V64, I64, VM512>;
def : MnemonicAlias<"vsubu.w", "pvsubu.lo">;

// Section 8.10.5 - VSBS (Vector Subtract Single)
let cx = 0, cx2 = 0 in
defm VSUBSWSX : RVm<"vsubs.w.sx", 0xda, V64, I32, VM>;
let cx = 0, cx2 = 1 in {
  defm PVSUBSLO : RVm<"pvsubs.lo", 0xda, V64, I32, VM>;
  let isCodeGenOnly = 1 in
  defm VSUBSWZX : RVm<"vsubs.w.zx", 0xda, V64, I32, VM>;
}
let cx = 1, cx2 = 0 in
defm PVSUBSUP : RVm<"pvsubs.up", 0xda, V64, I64, VM>;
let cx = 1, cx2 = 1 in
defm PVSUBS : RVm<"pvsubs", 0xda, V64, I64, VM512>;
def : MnemonicAlias<"pvsubs.lo.sx", "vsubs.w.sx">;
def : MnemonicAlias<"vsubs.w.zx", "pvsubs.lo">;
def : MnemonicAlias<"vsubs.w", "pvsubs.lo">;
def : MnemonicAlias<"pvsubs.lo.zx", "pvsubs.lo">;

// Section 8.10.6 - VSBX (Vector Subtract)
defm VSUBSL : RVm<"vsubs.l", 0x9b, V64, I64, VM>;

// Section 8.10.7 - VMPY (Vector Multiply)
let cx2 = 0 in
defm VMULUL : RVm<"vmulu.l", 0xc9, V64, I64, VM>;
let cx2 = 1 in
defm VMULUW : RVm<"vmulu.w", 0xc9, V64, I32, VM>;

// Section 8.10.8 - VMPS (Vector Multiply Single)
let cx2 = 0 in
defm VMULSWSX : RVm<"vmuls.w.sx", 0xcb, V64, I32, VM>;
let cx2 = 1 in
defm VMULSWZX : RVm<"vmuls.w.zx", 0xcb, V64, I32, VM>;
def : MnemonicAlias<"vmuls.w", "vmuls.w.zx">;

// Section 8.10.9 - VMPX (Vector Multiply)
defm VMULSL : RVm<"vmuls.l", 0xdb, V64, I64, VM>;

// Section 8.10.10 - VMPD (Vector Multiply)
defm VMULSLW : RVm<"vmuls.l.w", 0xd9, V64, I32, VM>;

// Section 8.10.11 - VDIV (Vector Divide)
let cx2 = 0 in
defm VDIVUL : RVDIVm<"vdivu.l", 0xe9, V64, I64, VM>;
let cx2 = 1 in
defm VDIVUW : RVDIVm<"vdivu.w", 0xe9, V64, I32, VM>;

// Section 8.10.12 - VDVS (Vector Divide Single)
let cx2 = 0 in
defm VDIVSWSX : RVDIVm<"vdivs.w.sx", 0xeb, V64, I32, VM>;
let cx2 = 1 in
defm VDIVSWZX : RVDIVm<"vdivs.w.zx", 0xeb, V64, I32, VM>;
def : MnemonicAlias<"vdivs.w", "vdivs.w.zx">;

// Section 8.10.13 - VDVX (Vector Divide)
defm VDIVSL : RVDIVm<"vdivs.l", 0xfb, V64, I64, VM>;

// Section 8.10.14 - VCMP (Vector Compare)
let cx = 0, cx2 = 0 in
defm VCMPUL : RVm<"vcmpu.l", 0xb9, V64, I64, VM>;
let cx = 0, cx2 = 1 in {
  defm PVCMPULO : RVm<"pvcmpu.lo", 0xb9, V64, I32, VM>;
  let isCodeGenOnly = 1 in
  defm VCMPUW : RVm<"vcmpu.w", 0xb9, V64, I32, VM>;
}
let cx = 1, cx2 = 0 in
defm PVCMPUUP : RVm<"pvcmpu.up", 0xb9, V64, I64, VM>;
let cx = 1, cx2 = 1 in
defm PVCMPU : RVm<"pvcmpu", 0xb9, V64, I64, VM512>;
def : MnemonicAlias<"vcmpu.w", "pvcmpu.lo">;

// Section 8.10.15 - VCPS (Vector Compare Single)
let cx = 0, cx2 = 0 in
defm VCMPSWSX : RVm<"vcmps.w.sx", 0xfa, V64, I32, VM>;
let cx = 0, cx2 = 1 in {
  defm PVCMPSLO : RVm<"pvcmps.lo", 0xfa, V64, I32, VM>;
  let isCodeGenOnly = 1 in
  defm VCMPSWZX : RVm<"vcmps.w.zx", 0xfa, V64, I32, VM>;
}
let cx = 1, cx2 = 0 in
defm PVCMPSUP : RVm<"pvcmps.up", 0xfa, V64, I64, VM>;
let cx = 1, cx2 = 1 in
defm PVCMPS : RVm<"pvcmps", 0xfa, V64, I64, VM512>;
def : MnemonicAlias<"pvcmps.lo.sx", "vcmps.w.sx">;
def : MnemonicAlias<"vcmps.w.zx", "pvcmps.lo">;
def : MnemonicAlias<"vcmps.w", "pvcmps.lo">;
def : MnemonicAlias<"pvcmps.lo.zx", "pvcmps.lo">;

// Section 8.10.16 - VCPX (Vector Compare)
defm VCMPSL : RVm<"vcmps.l", 0xba, V64, I64, VM>;

// Section 8.10.17 - VCMS (Vector Compare and Select Maximum/Minimum Single)
let cx = 0, cx2 = 0 in
defm VMAXSWSX : RVm<"vmaxs.w.sx", 0x8a, V64, I32, VM>;
let cx = 0, cx2 = 1 in {
  defm PVMAXSLO : RVm<"pvmaxs.lo", 0x8a, V64, I32, VM>;
  let isCodeGenOnly = 1 in
  defm VMAXSWZX : RVm<"vmaxs.w.zx", 0x8a, V64, I32, VM>;
}
let cx = 1, cx2 = 0 in
defm PVMAXSUP : RVm<"pvmaxs.up", 0x8a, V64, I64, VM>;
let cx = 1, cx2 = 1 in
defm PVMAXS : RVm<"pvmaxs", 0x8a, V64, I64, VM512>;
let cs2 = 1 in {
  let cx = 0, cx2 = 0 in
  defm VMINSWSX : RVm<"vmins.w.sx", 0x8a, V64, I32, VM>;
  let cx = 0, cx2 = 1 in {
    defm PVMINSLO : RVm<"pvmins.lo", 0x8a, V64, I32, VM>;
    let isCodeGenOnly = 1 in
    defm VMINSWZX : RVm<"vmins.w.zx", 0x8a, V64, I32, VM>;
  }
  let cx = 1, cx2 = 0 in
  defm PVMINSUP : RVm<"pvmins.up", 0x8a, V64, I64, VM>;
  let cx = 1, cx2 = 1 in
  defm PVMINS : RVm<"pvmins", 0x8a, V64, I64, VM512>;
}
def : MnemonicAlias<"pvmaxs.lo.sx", "vmaxs.w.sx">;
def : MnemonicAlias<"vmaxs.w.zx", "pvmaxs.lo">;
def : MnemonicAlias<"vmaxs.w", "pvmaxs.lo">;
def : MnemonicAlias<"pvmaxs.lo.zx", "pvmaxs.lo">;
def : MnemonicAlias<"pvmins.lo.sx", "vmins.w.sx">;
def : MnemonicAlias<"vmins.w.zx", "pvmins.lo">;
def : MnemonicAlias<"vmins.w", "pvmins.lo">;
def : MnemonicAlias<"pvmins.lo.zx", "pvmins.lo">;

// Section 8.10.18 - VCMX (Vector Compare and Select Maximum/Minimum)
defm VMAXSL : RVm<"vmaxs.l", 0x9a, V64, I64, VM>;
let cs2 = 1 in
defm VMINSL : RVm<"vmins.l", 0x9a, V64, I64, VM>;

//-----------------------------------------------------------------------------
// Section 8.11 - Vector Logical Operation Instructions
//-----------------------------------------------------------------------------

// Section 8.11.1 - VAND (Vector And)
let cx = 0, cx2 = 0 in defm VAND : RVLm<"vand", 0xc4, I64, V64, VM>;
let cx = 0, cx2 = 1 in defm PVANDLO : RVLm<"pvand.lo", 0xc4, I32, V64, VM>;
let cx = 1, cx2 = 0 in defm PVANDUP : RVLm<"pvand.up", 0xc4, F32, V64, VM>;
let cx = 1, cx2 = 1 in defm PVAND : RVLm<"pvand", 0xc4, I64, V64, VM512>;

// Section 8.11.2 - VOR (Vector Or)
let cx = 0, cx2 = 0 in defm VOR : RVLm<"vor", 0xc5, I64, V64, VM>;
let cx = 0, cx2 = 1 in defm PVORLO : RVLm<"pvor.lo", 0xc5, I32, V64, VM>;
let cx = 1, cx2 = 0 in defm PVORUP : RVLm<"pvor.up", 0xc5, F32, V64, VM>;
let cx = 1, cx2 = 1 in defm PVOR : RVLm<"pvor", 0xc5, I64, V64, VM512>;

// Section 8.11.3 - VXOR (Vector Exclusive Or)
let cx = 0, cx2 = 0 in defm VXOR : RVLm<"vxor", 0xc6, I64, V64, VM>;
let cx = 0, cx2 = 1 in defm PVXORLO : RVLm<"pvxor.lo", 0xc6, I32, V64, VM>;
let cx = 1, cx2 = 0 in defm PVXORUP : RVLm<"pvxor.up", 0xc6, F32, V64, VM>;
let cx = 1, cx2 = 1 in defm PVXOR : RVLm<"pvxor", 0xc6, I64, V64, VM512>;

// Section 8.11.4 - VEQV (Vector Equivalence)
let cx = 0, cx2 = 0 in defm VEQV : RVLm<"veqv", 0xc7, I64, V64, VM>;
let cx = 0, cx2 = 1 in defm PVEQVLO : RVLm<"pveqv.lo", 0xc7, I32, V64, VM>;
let cx = 1, cx2 = 0 in defm PVEQVUP : RVLm<"pveqv.up", 0xc7, F32, V64, VM>;
let cx = 1, cx2 = 1 in defm PVEQV : RVLm<"pveqv", 0xc7, I64, V64, VM512>;

// Section 8.11.5 - VLDZ (Vector Leading Zero Count)
let cx = 0, cx2 = 0 in defm VLDZ : RV1m<"vldz", 0xe7, V64, VM>;
let cx = 0, cx2 = 1 in defm PVLDZLO : RV1m<"pvldz.lo", 0xe7, V64, VM>;
let cx = 1, cx2 = 0 in defm PVLDZUP : RV1m<"pvldz.up", 0xe7, V64, VM>;
let cx = 1, cx2 = 1 in defm PVLDZ : RV1m<"pvldz", 0xe7, V64, VM512>;

// Section 8.11.6 - VPCNT (Vector Population Count)
let cx = 0, cx2 = 0 in defm VPCNT : RV1m<"vpcnt", 0xac, V64, VM>;
let cx = 0, cx2 = 1 in defm PVPCNTLO : RV1m<"pvpcnt.lo", 0xac, V64, VM>;
let cx = 1, cx2 = 0 in defm PVPCNTUP : RV1m<"pvpcnt.up", 0xac, V64, VM>;
let cx = 1, cx2 = 1 in defm PVPCNT : RV1m<"pvpcnt", 0xac, V64, VM512>;

// Section 8.11.7 - VBRV (Vector Bit Reverse)
let cx = 0, cx2 = 0 in defm VBRV : RV1m<"vbrv", 0xf7, V64, VM>;
let cx = 0, cx2 = 1 in defm PVBRVLO : RV1m<"pvbrv.lo", 0xf7, V64, VM>;
let cx = 1, cx2 = 0 in defm PVBRVUP : RV1m<"pvbrv.up", 0xf7, V64, VM>;
let cx = 1, cx2 = 1 in defm PVBRV : RV1m<"pvbrv", 0xf7, V64, VM512>;

// Section 8.11.8 - VSEQ (Vector Sequential Number)
let cx = 0, cx2 = 0 in defm VSEQ : RV0m<"vseq", 0x99, V64, VM>;
let cx = 0, cx2 = 1 in defm PVSEQLO : RV0m<"pvseq.lo", 0x99, V64, VM>;
let cx = 1, cx2 = 0 in defm PVSEQUP : RV0m<"pvseq.up", 0x99, V64, VM>;
let cx = 1, cx2 = 1 in defm PVSEQ : RV0m<"pvseq", 0x99, V64, VM512>;

//-----------------------------------------------------------------------------
// Section 8.12 - Vector Shift Operation Instructions
//-----------------------------------------------------------------------------

// Section 8.12.1 - VSLL (Vector Shift Left Logical)
let cx = 0, cx2 = 0 in defm VSLL : RVSm<"vsll", 0xe5, I64, V64, VM>;
let cx = 0, cx2 = 1 in defm PVSLLLO : RVSm<"pvsll.lo", 0xe5, I32, V64, VM>;
let cx = 1, cx2 = 0 in defm PVSLLUP : RVSm<"pvsll.up", 0xe5, F32, V64, VM>;
let cx = 1, cx2 = 1 in defm PVSLL : RVSm<"pvsll", 0xe5, I64, V64, VM512>;

// Section 8.12.2 - VSLD (Vector Shift Left Double)
defm VSLD : RVSDm<"vsld", 0xe4, V64, VM>;

// Section 8.12.3 - VSRL (Vector Shift Right Logical)
let cx = 0, cx2 = 0 in defm VSRL : RVSm<"vsrl", 0xf5, I64, V64, VM>;
let cx = 0, cx2 = 1 in defm PVSRLLO : RVSm<"pvsrl.lo", 0xf5, I32, V64, VM>;
let cx = 1, cx2 = 0 in defm PVSRLUP : RVSm<"pvsrl.up", 0xf5, F32, V64, VM>;
let cx = 1, cx2 = 1 in defm PVSRL : RVSm<"pvsrl", 0xf5, I64, V64, VM512>;

// Section 8.12.4 - VSRD (Vector Shift Right Double)
defm VSRD : RVSDm<"vsrd", 0xf4, V64, VM>;

// Section 8.12.5 - VSLA (Vector Shift Left Arithmetic)
let cx = 0, cx2 = 0 in defm VSLAWSX : RVSm<"vsla.w.sx", 0xe6, I32, V64, VM>;
let cx = 0, cx2 = 1 in {
  defm PVSLALO : RVSm<"pvsla.lo", 0xe6, I32, V64, VM>;
  let isCodeGenOnly = 1 in defm VSLAWZX : RVSm<"vsla.w.zx", 0xe6, I32, V64, VM>;
}
let cx = 1, cx2 = 0 in defm PVSLAUP : RVSm<"pvsla.up", 0xe6, F32, V64, VM>;
let cx = 1, cx2 = 1 in defm PVSLA : RVSm<"pvsla", 0xe6, I64, V64, VM512>;
def : MnemonicAlias<"pvsla.lo.sx", "vsla.w.sx">;
def : MnemonicAlias<"vsla.w.zx", "pvsla.lo">;
def : MnemonicAlias<"vsla.w", "pvsla.lo">;
def : MnemonicAlias<"pvsla.lo.zx", "pvsla.lo">;

// Section 8.12.6 - VSLAX (Vector Shift Left Arithmetic)
defm VSLAL : RVSm<"vsla.l", 0xd4, I64, V64, VM>;

// Section 8.12.7 - VSRA (Vector Shift Right Arithmetic)
let cx = 0, cx2 = 0 in defm VSRAWSX : RVSm<"vsra.w.sx", 0xf6, I32, V64, VM>;
let cx = 0, cx2 = 1 in {
  defm PVSRALO : RVSm<"pvsra.lo", 0xf6, I32, V64, VM>;
  let isCodeGenOnly = 1 in defm VSRAWZX : RVSm<"vsra.w.zx", 0xf6, I32, V64, VM>;
}
let cx = 1, cx2 = 0 in defm PVSRAUP : RVSm<"pvsra.up", 0xf6, F32, V64, VM>;
let cx = 1, cx2 = 1 in defm PVSRA : RVSm<"pvsra", 0xf6, I64, V64, VM512>;
def : MnemonicAlias<"pvsra.lo.sx", "vsra.w.sx">;
def : MnemonicAlias<"vsra.w.zx", "pvsra.lo">;
def : MnemonicAlias<"vsra.w", "pvsra.lo">;
def : MnemonicAlias<"pvsra.lo.zx", "pvsra.lo">;

// Section 8.12.8 - VSRAX (Vector Shift Right Arithmetic)
defm VSRAL : RVSm<"vsra.l", 0xd5, I64, V64, VM>;

// Section 8.12.9 - VSFA (Vector Shift Left and Add)
defm VSFA : RVSAm<"vsfa", 0xd7, V64, VM>;

//-----------------------------------------------------------------------------
// Section 8.13 - Vector Floating-Point Arithmetic Instructions
//-----------------------------------------------------------------------------

// Section 8.13.1 - VFAD (Vector Floating Add)
let cx = 0, cx2 = 0 in
defm VFADDD : RVm<"vfadd.d", 0xcc, V64, I64, VM, simm7fp>;
let cx = 0, cx2 = 1 in
defm PVFADDLO : RVm<"pvfadd.lo", 0xcc, V64, I64, VM, simm7fp>;
let cx = 1, cx2 = 0 in {
  defm PVFADDUP : RVm<"pvfadd.up", 0xcc, V64, F32, VM, simm7fp>;
  let isCodeGenOnly = 1 in
  defm VFADDS : RVm<"vfadd.s", 0xcc, V64, F32, VM, simm7fp>;
}
let cx = 1, cx2 = 1 in
defm PVFADD : RVm<"pvfadd", 0xcc, V64, I64, VM512, simm7fp>;
def : MnemonicAlias<"vfadd.s", "pvfadd.up">;

// Section 8.13.2 - VFSB (Vector Floating Subtract)
let cx = 0, cx2 = 0 in
defm VFSUBD : RVm<"vfsub.d", 0xdc, V64, I64, VM, simm7fp>;
let cx = 0, cx2 = 1 in
defm PVFSUBLO : RVm<"pvfsub.lo", 0xdc, V64, I64, VM, simm7fp>;
let cx = 1, cx2 = 0 in {
  defm PVFSUBUP : RVm<"pvfsub.up", 0xdc, V64, F32, VM, simm7fp>;
  let isCodeGenOnly = 1 in
  defm VFSUBS : RVm<"vfsub.s", 0xdc, V64, F32, VM, simm7fp>;
}
let cx = 1, cx2 = 1 in
defm PVFSUB : RVm<"pvfsub", 0xdc, V64, I64, VM512, simm7fp>;
def : MnemonicAlias<"vfsub.s", "pvfsub.up">;

// Section 8.13.3 - VFMP (Vector Floating Multiply)
let cx = 0, cx2 = 0 in
defm VFMULD : RVm<"vfmul.d", 0xcd, V64, I64, VM, simm7fp>;
let cx = 0, cx2 = 1 in
defm PVFMULLO : RVm<"pvfmul.lo", 0xcd, V64, I64, VM, simm7fp>;
let cx = 1, cx2 = 0 in {
  defm PVFMULUP : RVm<"pvfmul.up", 0xcd, V64, F32, VM, simm7fp>;
  let isCodeGenOnly = 1 in
  defm VFMULS : RVm<"vfmul.s", 0xcd, V64, F32, VM, simm7fp>;
}
let cx = 1, cx2 = 1 in
defm PVFMUL : RVm<"pvfmul", 0xcd, V64, I64, VM512, simm7fp>;
def : MnemonicAlias<"vfmul.s", "pvfmul.up">;

// Section 8.13.4 - VFDV (Vector Floating Divide)
defm VFDIVD : RVDIVm<"vfdiv.d", 0xdd, V64, I64, VM, simm7fp>;
let cx = 1 in
defm VFDIVS : RVDIVm<"vfdiv.s", 0xdd, V64, F32, VM, simm7fp>;

// Section 8.13.5 - VFSQRT (Vector Floating Square Root)
defm VFSQRTD : RVF1m<"vfsqrt.d", 0xed, V64, VM>;
let cx = 1 in
defm VFSQRTS : RVF1m<"vfsqrt.s", 0xed, V64, VM>;

// Section 8.13.6 - VFCP (Vector Floating Compare)
let cx = 0, cx2 = 0 in
defm VFCMPD : RVm<"vfcmp.d", 0xfc, V64, I64, VM, simm7fp>;
let cx = 0, cx2 = 1 in
defm PVFCMPLO : RVm<"pvfcmp.lo", 0xfc, V64, I64, VM, simm7fp>;
let cx = 1, cx2 = 0 in {
  defm PVFCMPUP : RVm<"pvfcmp.up", 0xfc, V64, F32, VM, simm7fp>;
  let isCodeGenOnly = 1 in
  defm VFCMPS : RVm<"vfcmp.s", 0xfc, V64, F32, VM, simm7fp>;
}
let cx = 1, cx2 = 1 in
defm PVFCMP : RVm<"pvfcmp", 0xfc, V64, I64, VM512, simm7fp>;
def : MnemonicAlias<"vfcmp.s", "pvfcmp.up">;

// Section 8.13.7 - VFCM (Vector Floating Compare and Select Maximum/Minimum)
let cx = 0, cx2 = 0 in
defm VFMAXD : RVm<"vfmax.d", 0xbd, V64, I64, VM, simm7fp>;
let cx = 0, cx2 = 1 in
defm PVFMAXLO : RVm<"pvfmax.lo", 0xbd, V64, I64, VM, simm7fp>;
let cx = 1, cx2 = 0 in {
  defm PVFMAXUP : RVm<"pvfmax.up", 0xbd, V64, F32, VM, simm7fp>;
  let isCodeGenOnly = 1 in
  defm VFMAXS : RVm<"vfmax.s", 0xbd, V64, F32, VM, simm7fp>;
}
let cx = 1, cx2 = 1 in
defm PVFMAX : RVm<"pvfmax", 0xbd, V64, I64, VM512, simm7fp>;
let cs2 = 1 in {
  let cx = 0, cx2 = 0 in
  defm VFMIND : RVm<"vfmin.d", 0xbd, V64, I64, VM, simm7fp>;
  let cx = 0, cx2 = 1 in
  defm PVFMINLO : RVm<"pvfmin.lo", 0xbd, V64, I64, VM, simm7fp>;
  let cx = 1, cx2 = 0 in {
    defm PVFMINUP : RVm<"pvfmin.up", 0xbd, V64, F32, VM, simm7fp>;
    let isCodeGenOnly = 1 in
    defm VFMINS : RVm<"vfmin.s", 0xbd, V64, F32, VM, simm7fp>;
  }
  let cx = 1, cx2 = 1 in
  defm PVFMIN : RVm<"pvfmin", 0xbd, V64, I64, VM512, simm7fp>;
}
def : MnemonicAlias<"vfmax.s", "pvfmax.up">;
def : MnemonicAlias<"vfmin.s", "pvfmin.up">;

// Section 8.13.8 - VFMAD (Vector Floating Fused Multiply Add)
let cx = 0, cx2 = 0 in
defm VFMADD : RVMm<"vfmad.d", 0xe2, V64, I64, VM, simm7fp>;
let cx = 0, cx2 = 1 in
defm PVFMADLO : RVMm<"pvfmad.lo", 0xe2, V64, I64, VM, simm7fp>;
let cx = 1, cx2 = 0 in {
  defm PVFMADUP : RVMm<"pvfmad.up", 0xe2, V64, F32, VM, simm7fp>;
  let isCodeGenOnly = 1 in
  defm VFMADS : RVMm<"vfmad.s", 0xe2, V64, F32, VM, simm7fp>;
}
let cx = 1, cx2 = 1 in
defm PVFMAD : RVMm<"pvfmad", 0xe2, V64, I64, VM512, simm7fp>;
def : MnemonicAlias<"vfmad.s", "pvfmad.up">;

// Section 8.13.9 - VFMSB (Vector Floating Fused Multiply Subtract)
let cx = 0, cx2 = 0 in
defm VFMSBD : RVMm<"vfmsb.d", 0xf2, V64, I64, VM, simm7fp>;
let cx = 0, cx2 = 1 in
defm PVFMSBLO : RVMm<"pvfmsb.lo", 0xf2, V64, I64, VM, simm7fp>;
let cx = 1, cx2 = 0 in {
  defm PVFMSBUP : RVMm<"pvfmsb.up", 0xf2, V64, F32, VM, simm7fp>;
  let isCodeGenOnly = 1 in
  defm VFMSBS : RVMm<"vfmsb.s", 0xf2, V64, F32, VM, simm7fp>;
}
let cx = 1, cx2 = 1 in
defm PVFMSB : RVMm<"pvfmsb", 0xf2, V64, I64, VM512, simm7fp>;
def : MnemonicAlias<"vfmsb.s", "pvfmsb.up">;

// Section 8.13.10 - VFNMAD (Vector Floating Fused Negative Multiply Add)
let cx = 0, cx2 = 0 in
defm VFNMADD : RVMm<"vfnmad.d", 0xe3, V64, I64, VM, simm7fp>;
let cx = 0, cx2 = 1 in
defm PVFNMADLO : RVMm<"pvfnmad.lo", 0xe3, V64, I64, VM, simm7fp>;
let cx = 1, cx2 = 0 in {
  defm PVFNMADUP : RVMm<"pvfnmad.up", 0xe3, V64, F32, VM, simm7fp>;
  let isCodeGenOnly = 1 in
  defm VFNMADS : RVMm<"vfnmad.s", 0xe3, V64, F32, VM, simm7fp>;
}
let cx = 1, cx2 = 1 in
defm PVFNMAD : RVMm<"pvfnmad", 0xe3, V64, I64, VM512, simm7fp>;
def : MnemonicAlias<"vfnmad.s", "pvfnmad.up">;

// Section 8.13.11 - VFNMSB (Vector Floating Fused Negative Multiply Subtract)
let cx = 0, cx2 = 0 in
defm VFNMSBD : RVMm<"vfnmsb.d", 0xf3, V64, I64, VM, simm7fp>;
let cx = 0, cx2 = 1 in
defm PVFNMSBLO : RVMm<"pvfnmsb.lo", 0xf3, V64, I64, VM, simm7fp>;
let cx = 1, cx2 = 0 in {
  defm PVFNMSBUP : RVMm<"pvfnmsb.up", 0xf3, V64, F32, VM, simm7fp>;
  let isCodeGenOnly = 1 in
  defm VFNMSBS : RVMm<"vfnmsb.s", 0xf3, V64, F32, VM, simm7fp>;
}
let cx = 1, cx2 = 1 in
defm PVFNMSB : RVMm<"pvfnmsb", 0xf3, V64, I64, VM512, simm7fp>;
def : MnemonicAlias<"vfnmsb.s", "pvfnmsb.up">;

// Section 8.13.12 - VRCP (Vector Floating Reciprocal)
let cx = 0, cx2 = 0 in defm VRCPD : RVF1m<"vrcp.d", 0xe1, V64, VM>;
let cx = 0, cx2 = 1 in defm PVRCPLO : RVF1m<"pvrcp.lo", 0xe1, V64, VM>;
let cx = 1, cx2 = 0 in {
  defm PVRCPUP : RVF1m<"pvrcp.up", 0xe1, V64, VM>;
  let isCodeGenOnly = 1 in defm VRCPS : RVF1m<"vrcp.s", 0xe1, V64, VM>;
}
let cx = 1, cx2 = 1 in defm PVRCP : RVF1m<"pvrcp", 0xe1, V64, VM512>;
def : MnemonicAlias<"vrcp.s", "pvrcp.up">;

// Section 8.13.13 - VRSQRT (Vector Floating Reciprocal Square Root)
let cx = 0, cx2 = 0 in defm VRSQRTD : RVF1m<"vrsqrt.d", 0xf1, V64, VM>;
let cx = 0, cx2 = 1 in defm PVRSQRTLO : RVF1m<"pvrsqrt.lo", 0xf1, V64, VM>;
let cx = 1, cx2 = 0 in {
  defm PVRSQRTUP : RVF1m<"pvrsqrt.up", 0xf1, V64, VM>;
  let isCodeGenOnly = 1 in
  defm VRSQRTS : RVF1m<"vrsqrt.s", 0xf1, V64, VM>;
}
let cx = 1, cx2 = 1 in
defm PVRSQRT : RVF1m<"pvrsqrt", 0xf1, V64, VM512>;
let cs2 = 1 in {
    let cx = 0, cx2 = 0 in
    defm VRSQRTDNEX : RVF1m<"vrsqrt.d.nex", 0xf1, V64, VM>;
    let cx = 0, cx2 = 1 in
    defm PVRSQRTLONEX : RVF1m<"pvrsqrt.lo.nex", 0xf1, V64, VM>;
    let cx = 1, cx2 = 0 in {
      defm PVRSQRTUPNEX : RVF1m<"pvrsqrt.up.nex", 0xf1, V64, VM>;
      let isCodeGenOnly = 1 in
      defm VRSQRTSNEX : RVF1m<"vrsqrt.s.nex", 0xf1, V64, VM>;
    }
    let cx = 1, cx2 = 1 in
    defm PVRSQRTNEX : RVF1m<"pvrsqrt.nex", 0xf1, V64, VM512>;
}
def : MnemonicAlias<"vrsqrt.s", "pvrsqrt.up">;
def : MnemonicAlias<"vrsqrt.s.nex", "pvrsqrt.up.nex">;

// Section 8.13.14 - VFIX (Vector Convert to Fixed Pointer)
let cx = 0, cx2 = 0, cs2 = 0 in
defm VCVTWDSX : RVFIXm<"vcvt.w.d.sx", 0xe8, V64, VM>;
let cx = 0, cx2 = 1, cs2 = 0 in
defm VCVTWDZX : RVFIXm<"vcvt.w.d.zx", 0xe8, V64, VM>;
let cx = 1, cx2 = 0, cs2 = 0 in
defm VCVTWSSX : RVFIXm<"vcvt.w.s.sx", 0xe8, V64, VM>;
let cx = 1, cx2 = 1, cs2 = 0 in
defm VCVTWSZX : RVFIXm<"vcvt.w.s.zx", 0xe8, V64, VM>;
let cx = 0, cx2 = 1, cs2 = 1 in
defm PVCVTWSLO : RVFIXm<"pvcvt.w.s.lo", 0xe8, V64, VM>;
let cx = 1, cx2 = 0, cs2 = 1 in
defm PVCVTWSUP : RVFIXm<"pvcvt.w.s.up", 0xe8, V64, VM>;
let cx = 1, cx2 = 1, cs2 = 1 in
defm PVCVTWS : RVFIXm<"pvcvt.w.s", 0xe8, V64, VM512>;

// Section 8.13.15 - VFIXX (Vector Convert to Fixed Pointer)
defm VCVTLD : RVFIXm<"vcvt.l.d", 0xa8, V64, VM>;

// Section 8.13.16 - VFLT (Vector Convert to Floating Pointer)
let cx = 0, cx2 = 0, cs2 = 0 in
defm VCVTDW : RVF1m<"vcvt.d.w", 0xf8, V64, VM>;
let cx = 1, cx2 = 0, cs2 = 0 in
defm VCVTSW : RVF1m<"vcvt.s.w", 0xf8, V64, VM>;
let cx = 0, cx2 = 1, cs2 = 1 in
defm PVCVTSWLO : RVF1m<"pvcvt.s.w.lo", 0xf8, V64, VM>;
let cx = 1, cx2 = 0, cs2 = 1 in
defm PVCVTSWUP : RVF1m<"pvcvt.s.w.up", 0xf8, V64, VM>;
let cx = 1, cx2 = 1, cs2 = 1 in
defm PVCVTSW : RVF1m<"pvcvt.s.w", 0xf8, V64, VM512>;

// Section 8.13.17 - VFLTX (Vector Convert to Floating Pointer)
defm VCVTDL : RVF1m<"vcvt.d.l", 0xb8, V64, VM>;

// Section 8.13.18 - VCVS (Vector Convert to Single-format)
defm VCVTSD : RVF1m<"vcvt.s.d", 0x9f, V64, VM>;

// Section 8.13.19 - VCVD (Vector Convert to Double-format)
defm VCVTDS : RVF1m<"vcvt.d.s", 0x8f, V64, VM>;

//-----------------------------------------------------------------------------
// Section 8.14 - Vector Reduction Instructions
//-----------------------------------------------------------------------------

// Section 8.14.1 - VSUMS (Vector Sum Single)
defm VSUMWSX : RVF1m<"vsum.w.sx", 0xea, V64, VM>;
let cx2 = 1 in defm VSUMWZX : RVF1m<"vsum.w.zx", 0xea, V64, VM>;

// Section 8.14.2 - VSUMX (Vector Sum)
defm VSUML : RVF1m<"vsum.l", 0xaa, V64, VM>;

// Section 8.14.3 - VFSUM (Vector Floating Sum)
defm VFSUMD : RVF1m<"vfsum.d", 0xec, V64, VM>;
let cx = 1 in defm VFSUMS : RVF1m<"vfsum.s", 0xec, V64, VM>;

// Section 8.14.4 - VMAXS (Vector Maximum/Minimum Single)
let cx2 = 0 in defm VRMAXSWFSTSX : RVF1m<"vrmaxs.w.fst.sx", 0xbb, V64, VM>;
let cx2 = 1 in defm VRMAXSWFSTZX : RVF1m<"vrmaxs.w.fst.zx", 0xbb, V64, VM>;
let cs = 1 in {
  let cx2 = 0 in
  defm VRMAXSWLSTSX : RVF1m<"vrmaxs.w.lst.sx", 0xbb, V64, VM>;
  let cx2 = 1 in
  defm VRMAXSWLSTZX : RVF1m<"vrmaxs.w.lst.zx", 0xbb, V64, VM>;
}
let cs2 = 1 in {
  let cx2 = 0 in
  defm VRMINSWFSTSX : RVF1m<"vrmins.w.fst.sx", 0xbb, V64, VM>;
  let cx2 = 1 in
  defm VRMINSWFSTZX : RVF1m<"vrmins.w.fst.zx", 0xbb, V64, VM>;
  let cs = 1 in {
    let cx2 = 0 in
    defm VRMINSWLSTSX : RVF1m<"vrmins.w.lst.sx", 0xbb, V64, VM>;
    let cx2 = 1 in
    defm VRMINSWLSTZX : RVF1m<"vrmins.w.lst.zx", 0xbb, V64, VM>;
  }
}

// Section 8.14.5 - VMAXX (Vector Maximum/Minimum)
let cs = 0 in defm VRMAXSLFST : RVF1m<"vrmaxs.l.fst", 0xab, V64, VM>;
let cs = 1 in defm VRMAXSLLST : RVF1m<"vrmaxs.l.lst", 0xab, V64, VM>;
let cs2 = 1 in {
  let cs = 0 in defm VRMINSLFST : RVF1m<"vrmins.l.fst", 0xab, V64, VM>;
  let cs = 1 in defm VRMINSLLST : RVF1m<"vrmins.l.lst", 0xab, V64, VM>;
}

// Section 8.14.6 - VFMAX (Vector Floating Maximum/Minimum)
let cs = 0 in defm VFRMAXDFST : RVF1m<"vfrmax.d.fst", 0xad, V64, VM>;
let cs = 1 in defm VFRMAXDLST : RVF1m<"vfrmax.d.lst", 0xad, V64, VM>;
let cs2 = 1 in {
  let cs = 0 in defm VFRMINDFST : RVF1m<"vfrmin.d.fst", 0xad, V64, VM>;
  let cs = 1 in defm VFRMINDLST : RVF1m<"vfrmin.d.lst", 0xad, V64, VM>;
}
let cx = 1 in {
  let cs = 0 in defm VFRMAXSFST : RVF1m<"vfrmax.s.fst", 0xad, V64, VM>;
  let cs = 1 in defm VFRMAXSLST : RVF1m<"vfrmax.s.lst", 0xad, V64, VM>;
  let cs2 = 1 in {
    let cs = 0 in defm VFRMINSFST : RVF1m<"vfrmin.s.fst", 0xad, V64, VM>;
    let cs = 1 in defm VFRMINSLST : RVF1m<"vfrmin.s.lst", 0xad, V64, VM>;
  }
}

// Section 8.14.7 - VRAND (Vector Reduction And)
defm VRAND : RVF1m<"vrand", 0x88, V64, VM>;

// Section 8.14.8 - VROR (Vector Reduction Or)
defm VROR : RVF1m<"vror", 0x98, V64, VM>;

// Section 8.14.9 - VRXOR (Vector Reduction Exclusive Or)
defm VRXOR : RVF1m<"vrxor", 0x89, V64, VM>;

//-----------------------------------------------------------------------------
// Section 8.15 - Vector Iterative Operation Instructions
//-----------------------------------------------------------------------------

// Section 8.15.1 - VFIA (Vector Floating Iteration Add)
let cx = 0 in defm VFIAD : RVI2m<"vfia.d", 0xce, V64, I64>;
let cx = 1 in defm VFIAS : RVI2m<"vfia.s", 0xce, V64, F32>;

// Section 8.15.2 - VFIS (Vector Floating Iteration Subtract)
let cx = 0 in defm VFISD : RVI2m<"vfis.d", 0xde, V64, I64>;
let cx = 1 in defm VFISS : RVI2m<"vfis.s", 0xde, V64, F32>;

// Section 8.15.3 - VFIM (Vector Floating Iteration Multiply)
let cx = 0 in defm VFIMD : RVI2m<"vfim.d", 0xcf, V64, I64>;
let cx = 1 in defm VFIMS : RVI2m<"vfim.s", 0xcf, V64, F32>;

// Section 8.15.4 - VFIAM (Vector Floating Iteration Add and Multiply)
let cx = 0 in defm VFIAMD : RVI3m<"vfiam.d", 0xee, V64, I64>;
let cx = 1 in defm VFIAMS : RVI3m<"vfiam.s", 0xee, V64, F32>;

// Section 8.15.5 - VFISM (Vector Floating Iteration Subtract and Multiply)
let cx = 0 in defm VFISMD : RVI3m<"vfism.d", 0xfe, V64, I64>;
let cx = 1 in defm VFISMS : RVI3m<"vfism.s", 0xfe, V64, F32>;

// Section 8.15.6 - VFIMA (Vector Floating Iteration Multiply and Add)
let cx = 0 in defm VFIMAD : RVI3m<"vfima.d", 0xef, V64, I64>;
let cx = 1 in defm VFIMAS : RVI3m<"vfima.s", 0xef, V64, F32>;

// Section 8.15.7 - VFIMS (Vector Floating Iteration Multiply and Subtract)
let cx = 0 in defm VFIMSD : RVI3m<"vfims.d", 0xff, V64, I64>;
let cx = 1 in defm VFIMSS : RVI3m<"vfims.s", 0xff, V64, F32>;

//-----------------------------------------------------------------------------
// Section 8.16 - Vector Merger Operation Instructions
//-----------------------------------------------------------------------------

// Section 8.16.1 - VMRG (Vector Merge)
let cx = 0 in defm VMRG : RVm<"vmrg", 0xd6, V64, I64, VM>;
// FIXME: vmrg.w should be called as pvmrg, but following assembly manual.
let cx = 1 in defm VMRGW : RVm<"vmrg.w", 0xd6, V64, I64, VM512>;
def : MnemonicAlias<"vmrg.l", "vmrg">;

// Section 8.16.2 - VSHF (Vector Shuffle)
defm VSHF : RVSHFm<"vshf", 0xbc, V64>;

// Section 8.16.3 - VCP (Vector Compress)
defm VCP : RV1m<"vcp", 0x8d, V64, VM>;

// Section 8.16.4 - VEX (Vector Expand)
defm VEX : RV1m<"vex", 0x9d, V64, VM>;

//-----------------------------------------------------------------------------
// Section 8.17 - Vector Mask Operation Instructions
//-----------------------------------------------------------------------------

// Section 8.17.1 - VFMK (Vector Form Mask)
defm VFMKL : RVMKm<"vfmk.l.", 0xb4, V64, VM>;
def : MnemonicAlias<"vfmk.l", "vfmk.l.at">;

// Section 8.17.2 - VFMS (Vector Form Mask Single)
defm VFMKW : RVMKm<"vfmk.w.", 0xb5, V64, VM>;
let isCodeGenOnly = 1 in defm PVFMKWLO : RVMKm<"vfmk.w.", 0xb5, V64, VM>;
let cx = 1 in defm PVFMKWUP : RVMKm<"pvfmk.w.up.", 0xb5, V64, VM>;
def : MnemonicAlias<"vfmk.w", "vfmk.w.at">;
def : MnemonicAlias<"pvfmk.w.up", "pvfmk.w.up.at">;
def : MnemonicAlias<"pvfmk.w.lo", "vfmk.w.at">;
foreach CC = [ "af", "gt", "lt", "ne", "eq", "ge", "le", "at" ] in {
  def : MnemonicAlias<"pvfmk.w.lo."#CC, "vfmk.w."#CC>;
}

// Section 8.17.3 - VFMF (Vector Form Mask Floating Point)
defm VFMKD : RVMKm<"vfmk.d.", 0xb6, V64, VM>;
let cx2 = 1 in defm PVFMKSLO : RVMKm<"pvfmk.s.lo.", 0xb6, V64, VM>;
let cx = 1 in {
  defm PVFMKSUP : RVMKm<"pvfmk.s.up.", 0xb6, V64, VM>;
  let isCodeGenOnly = 1 in defm VFMKS : RVMKm<"vfmk.s.", 0xb6, V64, VM>;
}
def : MnemonicAlias<"vfmk.d", "vfmk.d.at">;
def : MnemonicAlias<"pvfmk.s.lo", "pvfmk.s.lo.at">;
def : MnemonicAlias<"pvfmk.s.up", "pvfmk.s.up.at">;
def : MnemonicAlias<"vfmk.s", "pvfmk.s.up.at">;
foreach CC = [ "af", "gt", "lt", "ne", "eq", "ge", "le", "at", "num", "nan",
               "gtnan", "ltnan", "nenan", "eqnan", "genan", "lenan" ] in {
  def : MnemonicAlias<"vfmk.s."#CC, "pvfmk.s.up."#CC>;
}

// Section 8.17.4 - ANDM (And VM)
defm ANDM : RVM2m<"andm", 0x84, VM>;

// Section 8.17.5 - ORM (Or VM)
defm ORM : RVM2m<"orm", 0x85, VM>;

// Section 8.17.6 - XORM (Exclusive Or VM)
defm XORM : RVM2m<"xorm", 0x86, VM>;

// Section 8.17.7 - EQVM (Equivalence VM)
defm EQVM : RVM2m<"eqvm", 0x87, VM>;

// Section 8.17.8 - NNDM (Negate And VM)
defm NNDM : RVM2m<"nndm", 0x94, VM>;

// Section 8.17.9 - NEGM (Negate VM)
defm NEGM : RVM1m<"negm", 0x95, VM>;

// Section 8.17.10 - PCVM (Population Count of VM)
defm PCVM : RVMSm<"pcvm", 0xa4, VM>;

// Section 8.17.11 - LZVM (Leading Zero of VM)
defm LZVM : RVMSm<"lzvm", 0xa5, VM>;

// Section 8.17.12 - TOVM (Trailing One of VM)
defm TOVM : RVMSm<"tovm", 0xa6, VM>;

//-----------------------------------------------------------------------------
// Section 8.18 - Vector Control Instructions
//-----------------------------------------------------------------------------

// Section 8.18.1 - LVL (Load VL)
let sx = 0, cz = 0, sz = 0, hasSideEffects = 0, Defs = [VL] in {
  def LVLr : RR<0xbf, (outs), (ins I64:$sy), "lvl $sy">;
  let cy = 0 in def LVLi : RR<0xbf, (outs), (ins simm7:$sy), "lvl $sy">;
}

// Section 8.18.2 - SVL (Save VL)
let cy = 0, sy = 0, cz = 0, sz = 0, hasSideEffects = 0, Uses = [VL] in
def SVL : RR<0x2f, (outs I64:$sx), (ins), "svl $sx">;

// Section 8.18.3 - SMVL (Save Maximum Vector Length)
let cy = 0, sy = 0, cz = 0, sz = 0, hasSideEffects = 0 in
def SMVL : RR<0x2e, (outs I64:$sx), (ins), "smvl $sx">;

// Section 8.18.4 - LVIX (Load Vector Data Index)
let sx = 0, cz = 0, sz = 0, hasSideEffects = 0, Defs = [VIX] in {
  def LVIXr : RR<0xaf, (outs), (ins I64:$sy), "lvix $sy">;
  let cy = 0 in def LVIXi : RR<0xaf, (outs), (ins uimm6:$sy), "lvix $sy">;
}