@@ -40,6 +40,30 @@ static LegalityPredicate typeIsScalarFPArith(unsigned TypeIdx,
40
40
};
41
41
}
42
42
43
+ static LegalityPredicate
44
+ typeIsLegalIntOrFPVec (unsigned TypeIdx,
45
+ std::initializer_list<LLT> IntOrFPVecTys,
46
+ const RISCVSubtarget &ST) {
47
+ LegalityPredicate P = [=, &ST](const LegalityQuery &Query) {
48
+ return ST.hasVInstructions () &&
49
+ (Query.Types [TypeIdx].getScalarSizeInBits () != 64 ||
50
+ ST.hasVInstructionsI64 ()) &&
51
+ (Query.Types [TypeIdx].getElementCount ().getKnownMinValue () != 1 ||
52
+ ST.getELen () == 64 );
53
+ };
54
+
55
+ return all (typeInSet (TypeIdx, IntOrFPVecTys), P);
56
+ }
57
+
58
+ static LegalityPredicate
59
+ typeIsLegalBoolVec (unsigned TypeIdx, std::initializer_list<LLT> BoolVecTys,
60
+ const RISCVSubtarget &ST) {
61
+ LegalityPredicate HasV = [=, &ST](const LegalityQuery &Query) {
62
+ return ST.hasVInstructions ();
63
+ };
64
+ return all (typeInSet (TypeIdx, BoolVecTys), HasV);
65
+ }
66
+
43
67
RISCVLegalizerInfo::RISCVLegalizerInfo (const RISCVSubtarget &ST)
44
68
: STI(ST), XLen(STI.getXLen()), sXLen(LLT::scalar(XLen)) {
45
69
const LLT sDoubleXLen = LLT::scalar (2 * XLen);
@@ -50,6 +74,14 @@ RISCVLegalizerInfo::RISCVLegalizerInfo(const RISCVSubtarget &ST)
50
74
const LLT s32 = LLT::scalar (32 );
51
75
const LLT s64 = LLT::scalar (64 );
52
76
77
+ const LLT nxv1s1 = LLT::scalable_vector (1 , s1);
78
+ const LLT nxv2s1 = LLT::scalable_vector (2 , s1);
79
+ const LLT nxv4s1 = LLT::scalable_vector (4 , s1);
80
+ const LLT nxv8s1 = LLT::scalable_vector (8 , s1);
81
+ const LLT nxv16s1 = LLT::scalable_vector (16 , s1);
82
+ const LLT nxv32s1 = LLT::scalable_vector (32 , s1);
83
+ const LLT nxv64s1 = LLT::scalable_vector (64 , s1);
84
+
53
85
const LLT nxv1s8 = LLT::scalable_vector (1 , s8);
54
86
const LLT nxv2s8 = LLT::scalable_vector (2 , s8);
55
87
const LLT nxv4s8 = LLT::scalable_vector (4 , s8);
@@ -78,22 +110,16 @@ RISCVLegalizerInfo::RISCVLegalizerInfo(const RISCVSubtarget &ST)
78
110
79
111
using namespace TargetOpcode ;
80
112
81
- auto AllVecTys = {nxv1s8, nxv2s8, nxv4s8, nxv8s8, nxv16s8, nxv32s8,
82
- nxv64s8, nxv1s16, nxv2s16, nxv4s16, nxv8s16, nxv16s16,
83
- nxv32s16, nxv1s32, nxv2s32, nxv4s32, nxv8s32, nxv16s32,
84
- nxv1s64, nxv2s64, nxv4s64, nxv8s64};
113
+ auto BoolVecTys = {nxv1s1, nxv2s1, nxv4s1, nxv8s1, nxv16s1, nxv32s1, nxv64s1};
114
+
115
+ auto IntOrFPVecTys = {nxv1s8, nxv2s8, nxv4s8, nxv8s8, nxv16s8, nxv32s8,
116
+ nxv64s8, nxv1s16, nxv2s16, nxv4s16, nxv8s16, nxv16s16,
117
+ nxv32s16, nxv1s32, nxv2s32, nxv4s32, nxv8s32, nxv16s32,
118
+ nxv1s64, nxv2s64, nxv4s64, nxv8s64};
85
119
86
120
getActionDefinitionsBuilder ({G_ADD, G_SUB, G_AND, G_OR, G_XOR})
87
121
.legalFor ({s32, sXLen })
88
- .legalIf (all (
89
- typeInSet (0 , AllVecTys),
90
- LegalityPredicate ([=, &ST](const LegalityQuery &Query) {
91
- return ST.hasVInstructions () &&
92
- (Query.Types [0 ].getScalarSizeInBits () != 64 ||
93
- ST.hasVInstructionsI64 ()) &&
94
- (Query.Types [0 ].getElementCount ().getKnownMinValue () != 1 ||
95
- ST.getELen () == 64 );
96
- })))
122
+ .legalIf (typeIsLegalIntOrFPVec (0 , IntOrFPVecTys, ST))
97
123
.widenScalarToNextPow2 (0 )
98
124
.clampScalar (0 , s32, sXLen );
99
125
0 commit comments