@@ -40,6 +40,27 @@ 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
+ return [=, &ST](const LegalityQuery &Query) {
48
+ return typeInSet (TypeIdx, IntOrFPVecTys) && 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
+
56
+ static LegalityPredicate
57
+ typeIsLegalBoolVec (unsigned TypeIdx, std::initializer_list<LLT> BoolVecTys,
58
+ const RISCVSubtarget &ST) {
59
+ return [=, &ST](const LegalityQuery &Query) {
60
+ return typeInSet (TypeIdx, BoolVecTys) && ST.hasVInstructions ();
61
+ };
62
+ }
63
+
43
64
RISCVLegalizerInfo::RISCVLegalizerInfo (const RISCVSubtarget &ST)
44
65
: STI(ST), XLen(STI.getXLen()), sXLen(LLT::scalar(XLen)) {
45
66
const LLT sDoubleXLen = LLT::scalar (2 * XLen);
@@ -50,6 +71,14 @@ RISCVLegalizerInfo::RISCVLegalizerInfo(const RISCVSubtarget &ST)
50
71
const LLT s32 = LLT::scalar (32 );
51
72
const LLT s64 = LLT::scalar (64 );
52
73
74
+ const LLT nxv1s1 = LLT::scalable_vector (1 , s1);
75
+ const LLT nxv2s1 = LLT::scalable_vector (2 , s1);
76
+ const LLT nxv4s1 = LLT::scalable_vector (4 , s1);
77
+ const LLT nxv8s1 = LLT::scalable_vector (8 , s1);
78
+ const LLT nxv16s1 = LLT::scalable_vector (16 , s1);
79
+ const LLT nxv32s1 = LLT::scalable_vector (32 , s1);
80
+ const LLT nxv64s1 = LLT::scalable_vector (64 , s1);
81
+
53
82
const LLT nxv1s8 = LLT::scalable_vector (1 , s8);
54
83
const LLT nxv2s8 = LLT::scalable_vector (2 , s8);
55
84
const LLT nxv4s8 = LLT::scalable_vector (4 , s8);
@@ -78,22 +107,17 @@ RISCVLegalizerInfo::RISCVLegalizerInfo(const RISCVSubtarget &ST)
78
107
79
108
using namespace TargetOpcode ;
80
109
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};
110
+
111
+ auto BoolVecTys = {nxv1s1, nxv2s1, nxv4s1, nxv8s1, nxv16s1, nxv32s1, nxv64s1};
112
+
113
+ auto IntOrFPVecTys = {nxv1s8, nxv2s8, nxv4s8, nxv8s8, nxv16s8, nxv32s8,
114
+ nxv64s8, nxv1s16, nxv2s16, nxv4s16, nxv8s16, nxv16s16,
115
+ nxv32s16, nxv1s32, nxv2s32, nxv4s32, nxv8s32, nxv16s32,
116
+ nxv1s64, nxv2s64, nxv4s64, nxv8s64};
85
117
86
118
getActionDefinitionsBuilder ({G_ADD, G_SUB, G_AND, G_OR, G_XOR})
87
119
.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
- })))
120
+ .legalIf (typeIsLegalIntOrFPVec (0 , IntOrFPVecTys, ST))
97
121
.widenScalarToNextPow2 (0 )
98
122
.clampScalar (0 , s32, sXLen );
99
123
0 commit comments