@@ -218,16 +218,76 @@ LoongArchTargetLowering::LoongArchTargetLowering(const TargetMachine &TM,
218
218
219
219
// Set operations for 'LSX' feature.
220
220
221
- if (Subtarget.hasExtLSX ())
222
- setOperationAction ({ISD::UMAX, ISD::UMIN, ISD::SMAX, ISD::SMIN},
223
- {MVT::v2i64, MVT::v4i32, MVT::v8i16, MVT::v16i8}, Legal);
221
+ if (Subtarget.hasExtLSX ()) {
222
+ for (MVT VT : MVT::fixedlen_vector_valuetypes ()) {
223
+ // Expand all truncating stores and extending loads.
224
+ for (MVT InnerVT : MVT::fixedlen_vector_valuetypes ()) {
225
+ setTruncStoreAction (VT, InnerVT, Expand);
226
+ setLoadExtAction (ISD::SEXTLOAD, VT, InnerVT, Expand);
227
+ setLoadExtAction (ISD::ZEXTLOAD, VT, InnerVT, Expand);
228
+ setLoadExtAction (ISD::EXTLOAD, VT, InnerVT, Expand);
229
+ }
230
+ // By default everything must be expanded. Then we will selectively turn
231
+ // on ones that can be effectively codegen'd.
232
+ for (unsigned Op = 0 ; Op < ISD::BUILTIN_OP_END; ++Op)
233
+ setOperationAction (Op, VT, Expand);
234
+ }
235
+
236
+ for (MVT VT : LSXVTs) {
237
+ setOperationAction ({ISD::LOAD, ISD::STORE}, VT, Legal);
238
+ setOperationAction (ISD::BITCAST, VT, Legal);
239
+ setOperationAction (ISD::UNDEF, VT, Legal);
240
+
241
+ // FIXME: For BUILD_VECTOR, it is temporarily set to `Legal` here, and it
242
+ // will be `Custom` handled in the future.
243
+ setOperationAction (ISD::BUILD_VECTOR, VT, Legal);
244
+ setOperationAction (ISD::INSERT_VECTOR_ELT, VT, Legal);
245
+ }
246
+ for (MVT VT : {MVT::v16i8, MVT::v8i16, MVT::v4i32, MVT::v2i64}) {
247
+ setOperationAction ({ISD::ADD, ISD::SUB}, VT, Legal);
248
+ setOperationAction ({ISD::UMAX, ISD::UMIN, ISD::SMAX, ISD::SMIN}, VT,
249
+ Legal);
250
+ setOperationAction ({ISD::MUL, ISD::SDIV, ISD::SREM, ISD::UDIV, ISD::UREM},
251
+ VT, Legal);
252
+ setOperationAction ({ISD::AND, ISD::OR, ISD::XOR}, VT, Legal);
253
+ setOperationAction ({ISD::SHL, ISD::SRA, ISD::SRL}, VT, Legal);
254
+ setOperationAction (ISD::CTPOP, VT, Legal);
255
+ }
256
+ for (MVT VT : {MVT::v4f32, MVT::v2f64}) {
257
+ setOperationAction ({ISD::FADD, ISD::FSUB}, VT, Legal);
258
+ setOperationAction ({ISD::FMUL, ISD::FDIV}, VT, Legal);
259
+ setOperationAction (ISD::FMA, VT, Legal);
260
+ }
261
+ }
224
262
225
263
// Set operations for 'LASX' feature.
226
264
227
- if (Subtarget.hasExtLASX ())
228
- setOperationAction ({ISD::UMAX, ISD::UMIN, ISD::SMAX, ISD::SMIN},
229
- {MVT::v4i64, MVT::v8i32, MVT::v16i16, MVT::v32i8},
230
- Legal);
265
+ if (Subtarget.hasExtLASX ()) {
266
+ for (MVT VT : LASXVTs) {
267
+ setOperationAction ({ISD::LOAD, ISD::STORE}, VT, Legal);
268
+ setOperationAction (ISD::BITCAST, VT, Legal);
269
+ setOperationAction (ISD::UNDEF, VT, Legal);
270
+
271
+ // FIXME: Same as above.
272
+ setOperationAction (ISD::BUILD_VECTOR, VT, Legal);
273
+ setOperationAction (ISD::INSERT_VECTOR_ELT, VT, Legal);
274
+ }
275
+ for (MVT VT : {MVT::v4i64, MVT::v8i32, MVT::v16i16, MVT::v32i8}) {
276
+ setOperationAction ({ISD::ADD, ISD::SUB}, VT, Legal);
277
+ setOperationAction ({ISD::UMAX, ISD::UMIN, ISD::SMAX, ISD::SMIN}, VT,
278
+ Legal);
279
+ setOperationAction ({ISD::MUL, ISD::SDIV, ISD::SREM, ISD::UDIV, ISD::UREM},
280
+ VT, Legal);
281
+ setOperationAction ({ISD::AND, ISD::OR, ISD::XOR}, VT, Legal);
282
+ setOperationAction ({ISD::SHL, ISD::SRA, ISD::SRL}, VT, Legal);
283
+ setOperationAction (ISD::CTPOP, VT, Legal);
284
+ }
285
+ for (MVT VT : {MVT::v8f32, MVT::v4f64}) {
286
+ setOperationAction ({ISD::FADD, ISD::FSUB}, VT, Legal);
287
+ setOperationAction ({ISD::FMUL, ISD::FDIV}, VT, Legal);
288
+ setOperationAction (ISD::FMA, VT, Legal);
289
+ }
290
+ }
231
291
232
292
// Set DAG combine for LA32 and LA64.
233
293
0 commit comments