Skip to content

Commit 48d64f5

Browse files
kaz7Simon Moll
authored andcommitted
[VE] Update logical operation instructions
Summary: Changing all mnemonic to match assembly instructions to simplify mnemonic naming rules. This time update all fixed-point arithmetic instructions. This also corrects bswp operand type. Reviewed By: simoll Differential Revision: https://reviews.llvm.org/D78177
1 parent d9c7fc6 commit 48d64f5

File tree

1 file changed

+103
-107
lines changed

1 file changed

+103
-107
lines changed

llvm/lib/Target/VE/VEInstrInfo.td

Lines changed: 103 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ include "VEInstrFormats.td"
2424
// Instruction Pattern Stuff
2525
//===----------------------------------------------------------------------===//
2626

27+
// uimm1 - Generic immediate value.
28+
def uimm1 : Operand<i32>, PatLeaf<(imm), [{
29+
return isUInt<1>(N->getZExtValue()); }]>;
30+
2731
// uimm6 - Generic immediate value.
2832
def uimm6 : Operand<i32>, PatLeaf<(imm), [{
2933
return isUInt<6>(N->getZExtValue()); }]>;
@@ -484,63 +488,55 @@ multiclass RRIm<string opcStr, bits<8>opc,
484488
}
485489
}
486490

487-
// Multiclass for RR type instructions
488-
// Used by cmov instruction
489-
490-
let Constraints = "$sx = $sd", DisableEncoding = "$sd" in
491-
multiclass RRCMOVm<string opcStr, bits<8>opc,
492-
RegisterClass RC, ValueType Ty, Operand immOp, Operand immOp2> {
493-
def rr : RR<
494-
opc, (outs I64:$sx), (ins CCOp:$cf, RC:$sy, I64:$sz, I64:$sd),
495-
!strconcat(opcStr, " $sx, $sz, $sy")> {
496-
let cy = 1;
497-
let cz = 1;
498-
let hasSideEffects = 0;
499-
}
500-
def rm0 : RR<
501-
opc, (outs I64:$sx), (ins CCOp:$cf, RC:$sy, immOp2:$sz, I64:$sd),
502-
!strconcat(opcStr, " $sx, (${sz})0, $sy")> {
503-
let cy = 1;
504-
let cz = 0;
505-
let sz{6} = 1;
506-
let hasSideEffects = 0;
507-
}
491+
// Generic RR multiclass with an argument.
492+
// e.g. LDZ, PCNT, and BRV
493+
let cy = 0, sy = 0, hasSideEffects = 0 in
494+
multiclass RRI1m<string opcStr, bits<8>opc, RegisterClass RC, ValueType Ty,
495+
SDPatternOperator OpNode = null_frag> {
496+
def r : RR<opc, (outs RC:$sx), (ins RC:$sz), !strconcat(opcStr, " $sx, $sz"),
497+
[(set Ty:$sx, (OpNode Ty:$sz))]>;
498+
let cz = 0 in
499+
def m : RR<opc, (outs RC:$sx), (ins mimm:$sz),
500+
!strconcat(opcStr, " $sx, $sz"),
501+
[(set Ty:$sx, (OpNode (Ty mimm:$sz)))]>;
508502
}
509503

510-
// Multiclass for RR type instructions with only 2 operands
511-
// Used by pcnt, brv
504+
// Special RR multiclass for BSWP instruction.
505+
// e.g. BSWP
512506
let hasSideEffects = 0 in
513-
multiclass RRI2m<string opcStr, bits<8>opc, RegisterClass RC, ValueType Ty,
514-
Operand immOp2, SDPatternOperator OpNode=null_frag> {
515-
def r : RR<
516-
opc, (outs RC:$sx), (ins RC:$sz),
517-
!strconcat(opcStr, " $sx, $sz"),
518-
[(set Ty:$sx, (OpNode Ty:$sz))]> {
519-
let cy = 1;
520-
let cz = 1;
521-
}
522-
def i : RR<
523-
opc, (outs RC:$sx), (ins RC:$sz),
524-
!strconcat(opcStr, " $sx, $sz"),
525-
[(set Ty:$sx, (OpNode Ty:$sz))]> {
526-
let cy = 0;
527-
let cz = 1;
528-
}
529-
def m0 : RR<
530-
opc, (outs RC:$sx), (ins immOp2:$sz),
531-
!strconcat(opcStr, " $sx, (${sz})0")> {
532-
let cy = 1;
533-
let cz = 0;
534-
let sz{6} = 1;
535-
}
536-
def m1 : RR<
537-
opc, (outs RC:$sx), (ins immOp2:$sz),
538-
!strconcat(opcStr, " $sx, (${sz})1")> {
539-
let cy = 1;
540-
let cz = 0;
541-
}
507+
multiclass RRSWPm<string opcStr, bits<8>opc,
508+
RegisterClass RC, ValueType Ty,
509+
SDPatternOperator OpNode = null_frag> {
510+
let cy = 0 in
511+
def ri : RR<opc, (outs RC:$sx), (ins RC:$sz, uimm1:$sy),
512+
!strconcat(opcStr, " $sx, $sz, $sy"),
513+
[(set Ty:$sx, (OpNode Ty:$sz, (i32 uimm1:$sy)))]>;
514+
let cy = 0, cz = 0 in
515+
def mi : RR<opc, (outs RC:$sx), (ins mimm:$sz, uimm1:$sy),
516+
!strconcat(opcStr, " $sx, $sz, $sy"),
517+
[(set Ty:$sx, (OpNode (Ty mimm:$sz), (i32 uimm1:$sy)))]>;
542518
}
543519

520+
// Multiclass for CMOV instructions.
521+
// e.g. CMOVL, CMOVW, CMOVD, and etc.
522+
let Constraints = "$sx = $sd", DisableEncoding = "$sd", hasSideEffects = 0,
523+
cfw = ? in
524+
multiclass RRCMOVm<string opcStr, bits<8>opc, RegisterClass RC, ValueType Ty> {
525+
def rr : RR<opc, (outs I64:$sx), (ins CCOp:$cfw, RC:$sy, I64:$sz, I64:$sd),
526+
!strconcat(opcStr, " $sx, $sz, $sy")>;
527+
let cy = 0 in
528+
def ir : RR<opc, (outs I64:$sx),
529+
(ins CCOp:$cfw, simm7:$sy, I64:$sz, I64:$sd),
530+
!strconcat(opcStr, " $sx, $sz, $sy")>;
531+
let cz = 0 in
532+
def rm : RR<opc, (outs I64:$sx),
533+
(ins CCOp:$cfw, RC:$sy, mimm:$sz, I64:$sd),
534+
!strconcat(opcStr, " $sx, $sz, $sy")>;
535+
let cy = 0, cz = 0 in
536+
def im : RR<opc, (outs I64:$sx),
537+
(ins CCOp:$cfw, simm7:$sy, mimm:$sz, I64:$sd),
538+
!strconcat(opcStr, " $sx, $sz, $sy")>;
539+
}
544540

545541
// Branch multiclass
546542
let isBranch = 1, isTerminator = 1, hasDelaySlot = 1 in
@@ -792,19 +788,6 @@ defm ST1B : STOREm<"st1b", 0x15, I32, i32, truncstorei8>;
792788
// Section 8.3.1 - FENCE (Fence)
793789
// Section 8.3.2 - SVOB (Set Vector Out-of-order memory access Boundary)
794790

795-
// CMOV instructions
796-
let cx = 0, cw = 0, cw2 = 0 in
797-
defm CMOVL : RRCMOVm<"cmov.l.${cf}", 0x3B, I64, i64, simm7, uimm6>;
798-
799-
let cx = 0, cw = 1, cw2 = 0 in
800-
defm CMOVW : RRCMOVm<"cmov.w.${cf}", 0x3B, I32, i32, simm7, uimm6>;
801-
802-
let cx = 0, cw = 0, cw2 = 1 in
803-
defm CMOVD : RRCMOVm<"cmov.d.${cf}", 0x3B, I64, f64, simm7, uimm6>;
804-
805-
let cx = 0, cw = 1, cw2 = 1 in
806-
defm CMOVS : RRCMOVm<"cmov.s.${cf}", 0x3B, F32, f32, simm7, uimm6>;
807-
808791
//-----------------------------------------------------------------------------
809792
// Section 8.4 - Fixed-point Operation Instructions
810793
//-----------------------------------------------------------------------------
@@ -877,30 +860,43 @@ let cx = 1, cw = 1 in defm MINSWZX : RRm<"mins.w.zx", 0x78, I32, i32>;
877860
defm MAXSL : RRm<"maxs.l", 0x68, I64, i64>;
878861
let cw = 1 in defm MINSL : RRm<"mins.l", 0x68, I64, i64>;
879862

863+
//-----------------------------------------------------------------------------
864+
// Section 8.5 - Logical Operation Instructions
865+
//-----------------------------------------------------------------------------
866+
867+
// Section 8.5.1 - AND (AND)
868+
defm AND : RRm<"and", 0x44, I64, i64, and>;
869+
let isCodeGenOnly = 1 in defm AND32 : RRm<"and", 0x44, I32, i32, and>;
880870

881-
// 5.3.2.3. Logical Arithmetic Operation Instructions
871+
// Section 8.5.2 - OR (OR)
872+
defm OR : RRm<"or", 0x45, I64, i64, or>;
873+
let isCodeGenOnly = 1 in defm OR32 : RRm<"or", 0x45, I32, i32, or>;
882874

883-
let cx = 0 in {
884-
defm AND : RRm<"and", 0x44, I64, i64, and>;
885-
defm OR : RRm<"or", 0x45, I64, i64, or>;
886-
defm XOR : RRm<"xor", 0x46, I64, i64, xor>;
887-
let isCodeGenOnly = 1 in {
888-
defm AND32 : RRm<"and", 0x44, I32, i32, and>;
889-
defm OR32 : RRm<"or", 0x45, I32, i32, or>;
890-
defm XOR32 : RRm<"xor", 0x46, I32, i32, xor>;
891-
}
892-
}
875+
// Section 8.5.3 - XOR (Exclusive OR)
876+
defm XOR : RRm<"xor", 0x46, I64, i64, xor>;
877+
let isCodeGenOnly = 1 in defm XOR32 : RRm<"xor", 0x46, I32, i32, xor>;
893878

894-
// Bits operations
879+
// Section 8.5.4 - EQV (Equivalence)
880+
// Section 8.5.5 - NND (Negate AND)
881+
// Section 8.5.6 - MRG (Merge)
895882

896-
let cx = 0 in {
897-
defm PCNT : RRI2m<"pcnt", 0x38, I64, i64, uimm6, ctpop>;
898-
defm BRV : RRI2m<"brv", 0x39, I64, i64, uimm6, bitreverse>;
899-
defm LDZ : RRI2m<"ldz", 0x67, I64, i64, uimm6, ctlz>;
900-
defm BSWP : RRIm<"bswp", 0x2B, I64, i64, simm7, uimm6>;
901-
}
883+
// Section 8.5.7 - LDZ (Leading Zero Count)
884+
defm LDZ : RRI1m<"ldz", 0x67, I64, i64, ctlz>;
885+
886+
// Section 8.5.8 - PCNT (Population Count)
887+
defm PCNT : RRI1m<"pcnt", 0x38, I64, i64, ctpop>;
888+
889+
// Section 8.5.9 - BRV (Bit Reverse)
890+
defm BRV : RRI1m<"brv", 0x39, I64, i64, bitreverse>;
902891

892+
// Section 8.5.10 - BSWP (Byte Swap)
893+
defm BSWP : RRSWPm<"bswp", 0x2B, I64, i64>;
903894

895+
// Section 8.5.11 - CMOV (Conditional Move)
896+
let cw = 0, cw2 = 0 in defm CMOVL : RRCMOVm<"cmov.l.${cfw}", 0x3B, I64, i64>;
897+
let cw = 1, cw2 = 0 in defm CMOVW : RRCMOVm<"cmov.w.${cfw}", 0x3B, I32, i32>;
898+
let cw = 0, cw2 = 1 in defm CMOVD : RRCMOVm<"cmov.d.${cfw}", 0x3B, I64, f64>;
899+
let cw = 1, cw2 = 1 in defm CMOVS : RRCMOVm<"cmov.s.${cfw}", 0x3B, F32, f32>;
904900

905901
// 5.3.2.4 Shift Instructions
906902

@@ -1326,45 +1322,45 @@ def EXTEND_STACK_GUARD : Pseudo<(outs), (ins),
13261322

13271323
def : Pat<(i32 (setcc i64:$LHS, i64:$RHS, CCSIOp:$cond)),
13281324
(EXTRACT_SUBREG
1329-
(CMOVLrm0 (icond2cc $cond),
1330-
(CMPSLrr i64:$LHS, i64:$RHS),
1331-
63,
1332-
(ORim 0, 0)), sub_i32)>;
1325+
(CMOVLrm (icond2cc $cond),
1326+
(CMPSLrr i64:$LHS, i64:$RHS),
1327+
!add(63, 64),
1328+
(ORim 0, 0)), sub_i32)>;
13331329

13341330
def : Pat<(i32 (setcc i64:$LHS, i64:$RHS, CCUIOp:$cond)),
13351331
(EXTRACT_SUBREG
1336-
(CMOVLrm0 (icond2cc $cond),
1337-
(CMPULrr i64:$LHS, i64:$RHS),
1338-
63,
1339-
(ORim 0, 0)), sub_i32)>;
1332+
(CMOVLrm (icond2cc $cond),
1333+
(CMPULrr i64:$LHS, i64:$RHS),
1334+
!add(63, 64),
1335+
(ORim 0, 0)), sub_i32)>;
13401336

13411337
def : Pat<(i32 (setcc i32:$LHS, i32:$RHS, CCSIOp:$cond)),
13421338
(EXTRACT_SUBREG
1343-
(CMOVWrm0 (icond2cc $cond),
1344-
(CMPSWSXrr i32:$LHS, i32:$RHS),
1345-
63,
1346-
(ORim 0, 0)), sub_i32)>;
1339+
(CMOVWrm (icond2cc $cond),
1340+
(CMPSWSXrr i32:$LHS, i32:$RHS),
1341+
!add(63, 64),
1342+
(ORim 0, 0)), sub_i32)>;
13471343

13481344
def : Pat<(i32 (setcc i32:$LHS, i32:$RHS, CCUIOp:$cond)),
13491345
(EXTRACT_SUBREG
1350-
(CMOVWrm0 (icond2cc $cond),
1351-
(CMPUWrr i32:$LHS, i32:$RHS),
1352-
63,
1353-
(ORim 0, 0)), sub_i32)>;
1346+
(CMOVWrm (icond2cc $cond),
1347+
(CMPUWrr i32:$LHS, i32:$RHS),
1348+
!add(63, 64),
1349+
(ORim 0, 0)), sub_i32)>;
13541350

13551351
def : Pat<(i32 (setcc f64:$LHS, f64:$RHS, cond:$cond)),
13561352
(EXTRACT_SUBREG
1357-
(CMOVDrm0 (fcond2cc $cond),
1358-
(FCPrr f64:$LHS, f64:$RHS),
1359-
63,
1360-
(ORim 0, 0)), sub_i32)>;
1353+
(CMOVDrm (fcond2cc $cond),
1354+
(FCPrr f64:$LHS, f64:$RHS),
1355+
!add(63, 64),
1356+
(ORim 0, 0)), sub_i32)>;
13611357

13621358
def : Pat<(i32 (setcc f32:$LHS, f32:$RHS, cond:$cond)),
13631359
(EXTRACT_SUBREG
1364-
(CMOVSrm0 (fcond2cc $cond),
1365-
(FCPSrr f32:$LHS, f32:$RHS),
1366-
63,
1367-
(ORim 0, 0)), sub_i32)>;
1360+
(CMOVSrm (fcond2cc $cond),
1361+
(FCPSrr f32:$LHS, f32:$RHS),
1362+
!add(63, 64),
1363+
(ORim 0, 0)), sub_i32)>;
13681364

13691365
// Special SELECTCC pattern matches
13701366
// Use min/max for better performance.

0 commit comments

Comments
 (0)