Subversion Repositories QNX 8.QNX8 LLVM/Clang compiler suite

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
14 pmbaty 1
case RISCVVector::BI__builtin_rvv_vget_v:
2
  PolicyAttrs = 3;
3
IsMasked = false;
4
 
5
      {
6
        ID = Intrinsic::vector_extract;
7
        auto *VecTy = cast<ScalableVectorType>(ResultType);
8
        auto *OpVecTy = cast<ScalableVectorType>(Ops[0]->getType());
9
        // Mask to only valid indices.
10
        unsigned MaxIndex = OpVecTy->getMinNumElements() / VecTy->getMinNumElements();
11
        assert(isPowerOf2_32(MaxIndex));
12
        Ops[1] = Builder.CreateZExt(Ops[1], Builder.getInt64Ty());
13
        Ops[1] = Builder.CreateAnd(Ops[1], MaxIndex - 1);
14
        Ops[1] = Builder.CreateMul(Ops[1],
15
                                   ConstantInt::get(Ops[1]->getType(),
16
                                                    VecTy->getMinNumElements()));
17
        IntrinsicTypes = {ResultType, Ops[0]->getType()};
18
        return Builder.CreateCall(CGM.getIntrinsic(ID, IntrinsicTypes), Ops, "");
19
      }
20
      break;
21
case RISCVVector::BI__builtin_rvv_vset_v:
22
  PolicyAttrs = 3;
23
IsMasked = false;
24
 
25
      {
26
        ID = Intrinsic::vector_insert;
27
        IntrinsicTypes = {ResultType, Ops[2]->getType()};
28
        auto *ResVecTy = cast<ScalableVectorType>(ResultType);
29
        auto *VecTy = cast<ScalableVectorType>(Ops[2]->getType());
30
        // Mask to only valid indices.
31
        unsigned MaxIndex = ResVecTy->getMinNumElements() / VecTy->getMinNumElements();
32
        assert(isPowerOf2_32(MaxIndex));
33
        Ops[1] = Builder.CreateZExt(Ops[1], Builder.getInt64Ty());
34
        Ops[1] = Builder.CreateAnd(Ops[1], MaxIndex - 1);
35
        Ops[1] = Builder.CreateMul(Ops[1],
36
                                   ConstantInt::get(Ops[1]->getType(),
37
                                                    VecTy->getMinNumElements()));
38
        std::swap(Ops[1], Ops[2]);
39
        return Builder.CreateCall(CGM.getIntrinsic(ID, IntrinsicTypes), Ops, "");
40
      }
41
      break;
42
case RISCVVector::BI__builtin_rvv_vlenb:
43
  PolicyAttrs = 3;
44
IsMasked = false;
45
 
46
    {
47
      LLVMContext &Context = CGM.getLLVMContext();
48
      llvm::MDBuilder MDHelper(Context);
49
 
50
      llvm::Metadata *Ops[] = {llvm::MDString::get(Context, "vlenb")};
51
      llvm::MDNode *RegName = llvm::MDNode::get(Context, Ops);
52
      llvm::Value *Metadata = llvm::MetadataAsValue::get(Context, RegName);
53
      llvm::Function *F =
54
        CGM.getIntrinsic(llvm::Intrinsic::read_register, {SizeTy});
55
      return Builder.CreateCall(F, Metadata);
56
    }
57
    break;
58
case RISCVVector::BI__builtin_rvv_vlmul_ext_v:
59
  PolicyAttrs = 3;
60
IsMasked = false;
61
 
62
        ID = Intrinsic::vector_insert;
63
        IntrinsicTypes = {ResultType, Ops[0]->getType()};
64
        Ops.push_back(llvm::PoisonValue::get(ResultType));
65
        std::swap(Ops[0], Ops[1]);
66
        Ops.push_back(ConstantInt::get(Int64Ty, 0));
67
        return Builder.CreateCall(CGM.getIntrinsic(ID, IntrinsicTypes), Ops, "");
68
      break;
69
case RISCVVector::BI__builtin_rvv_vlmul_trunc_v:
70
  PolicyAttrs = 3;
71
IsMasked = false;
72
 {
73
        ID = Intrinsic::vector_extract;
74
        IntrinsicTypes = {ResultType, Ops[0]->getType()};
75
        Ops.push_back(ConstantInt::get(Int64Ty, 0));
76
        return Builder.CreateCall(CGM.getIntrinsic(ID, IntrinsicTypes), Ops, "");
77
      } break;
78
case RISCVVector::BI__builtin_rvv_vreinterpret_v:
79
  PolicyAttrs = 3;
80
IsMasked = false;
81
 
82
        return Builder.CreateBitCast(Ops[0], ResultType);
83
      break;
84
case RISCVVector::BI__builtin_rvv_vundefined:
85
  PolicyAttrs = 3;
86
IsMasked = false;
87
 
88
        return llvm::PoisonValue::get(ResultType);
89
      break;
90
case RISCVVector::BI__builtin_rvv_vaadd_vv_tu:
91
case RISCVVector::BI__builtin_rvv_vaadd_vx_tu:
92
  ID = Intrinsic::riscv_vaadd;
93
  PolicyAttrs = 2;
94
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
95
  break;
96
case RISCVVector::BI__builtin_rvv_vaadd_vv_ta:
97
case RISCVVector::BI__builtin_rvv_vaadd_vx_ta:
98
  ID = Intrinsic::riscv_vaadd;
99
  PolicyAttrs = 3;
100
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
101
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
102
  break;
103
case RISCVVector::BI__builtin_rvv_vaadd_vv_tum:
104
case RISCVVector::BI__builtin_rvv_vaadd_vx_tum:
105
  ID = Intrinsic::riscv_vaadd_mask;
106
  PolicyAttrs = 2;
107
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
108
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
109
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
110
  break;
111
case RISCVVector::BI__builtin_rvv_vaadd_vv_tama:
112
case RISCVVector::BI__builtin_rvv_vaadd_vx_tama:
113
  ID = Intrinsic::riscv_vaadd_mask;
114
  PolicyAttrs = 3;
115
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
116
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
117
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
118
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
119
  break;
120
case RISCVVector::BI__builtin_rvv_vaadd_vv_tumu:
121
case RISCVVector::BI__builtin_rvv_vaadd_vx_tumu:
122
  ID = Intrinsic::riscv_vaadd_mask;
123
  PolicyAttrs = 0;
124
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
125
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
126
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
127
  break;
128
case RISCVVector::BI__builtin_rvv_vaadd_vv_mu:
129
case RISCVVector::BI__builtin_rvv_vaadd_vx_mu:
130
  ID = Intrinsic::riscv_vaadd_mask;
131
  PolicyAttrs = 1;
132
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
133
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
134
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
135
  break;
136
case RISCVVector::BI__builtin_rvv_vaaddu_vv_tu:
137
case RISCVVector::BI__builtin_rvv_vaaddu_vx_tu:
138
  ID = Intrinsic::riscv_vaaddu;
139
  PolicyAttrs = 2;
140
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
141
  break;
142
case RISCVVector::BI__builtin_rvv_vaaddu_vv_ta:
143
case RISCVVector::BI__builtin_rvv_vaaddu_vx_ta:
144
  ID = Intrinsic::riscv_vaaddu;
145
  PolicyAttrs = 3;
146
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
147
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
148
  break;
149
case RISCVVector::BI__builtin_rvv_vaaddu_vv_tum:
150
case RISCVVector::BI__builtin_rvv_vaaddu_vx_tum:
151
  ID = Intrinsic::riscv_vaaddu_mask;
152
  PolicyAttrs = 2;
153
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
154
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
155
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
156
  break;
157
case RISCVVector::BI__builtin_rvv_vaaddu_vv_tama:
158
case RISCVVector::BI__builtin_rvv_vaaddu_vx_tama:
159
  ID = Intrinsic::riscv_vaaddu_mask;
160
  PolicyAttrs = 3;
161
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
162
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
163
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
164
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
165
  break;
166
case RISCVVector::BI__builtin_rvv_vaaddu_vv_tumu:
167
case RISCVVector::BI__builtin_rvv_vaaddu_vx_tumu:
168
  ID = Intrinsic::riscv_vaaddu_mask;
169
  PolicyAttrs = 0;
170
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
171
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
172
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
173
  break;
174
case RISCVVector::BI__builtin_rvv_vaaddu_vv_mu:
175
case RISCVVector::BI__builtin_rvv_vaaddu_vx_mu:
176
  ID = Intrinsic::riscv_vaaddu_mask;
177
  PolicyAttrs = 1;
178
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
179
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
180
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
181
  break;
182
case RISCVVector::BI__builtin_rvv_vadc_vvm_tu:
183
case RISCVVector::BI__builtin_rvv_vadc_vxm_tu:
184
  ID = Intrinsic::riscv_vadc;
185
  PolicyAttrs = 2;
186
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
187
  break;
188
case RISCVVector::BI__builtin_rvv_vadc_vvm_ta:
189
case RISCVVector::BI__builtin_rvv_vadc_vxm_ta:
190
  ID = Intrinsic::riscv_vadc;
191
  PolicyAttrs = 3;
192
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
193
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
194
  break;
195
case RISCVVector::BI__builtin_rvv_vadd_vv_tu:
196
case RISCVVector::BI__builtin_rvv_vadd_vx_tu:
197
  ID = Intrinsic::riscv_vadd;
198
  PolicyAttrs = 2;
199
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
200
  break;
201
case RISCVVector::BI__builtin_rvv_vadd_vv_ta:
202
case RISCVVector::BI__builtin_rvv_vadd_vx_ta:
203
  ID = Intrinsic::riscv_vadd;
204
  PolicyAttrs = 3;
205
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
206
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
207
  break;
208
case RISCVVector::BI__builtin_rvv_vadd_vv_tum:
209
case RISCVVector::BI__builtin_rvv_vadd_vx_tum:
210
  ID = Intrinsic::riscv_vadd_mask;
211
  PolicyAttrs = 2;
212
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
213
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
214
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
215
  break;
216
case RISCVVector::BI__builtin_rvv_vadd_vv_tama:
217
case RISCVVector::BI__builtin_rvv_vadd_vx_tama:
218
  ID = Intrinsic::riscv_vadd_mask;
219
  PolicyAttrs = 3;
220
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
221
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
222
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
223
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
224
  break;
225
case RISCVVector::BI__builtin_rvv_vadd_vv_tumu:
226
case RISCVVector::BI__builtin_rvv_vadd_vx_tumu:
227
  ID = Intrinsic::riscv_vadd_mask;
228
  PolicyAttrs = 0;
229
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
230
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
231
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
232
  break;
233
case RISCVVector::BI__builtin_rvv_vadd_vv_mu:
234
case RISCVVector::BI__builtin_rvv_vadd_vx_mu:
235
  ID = Intrinsic::riscv_vadd_mask;
236
  PolicyAttrs = 1;
237
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
238
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
239
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
240
  break;
241
case RISCVVector::BI__builtin_rvv_vand_vv_tu:
242
case RISCVVector::BI__builtin_rvv_vand_vx_tu:
243
  ID = Intrinsic::riscv_vand;
244
  PolicyAttrs = 2;
245
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
246
  break;
247
case RISCVVector::BI__builtin_rvv_vand_vv_ta:
248
case RISCVVector::BI__builtin_rvv_vand_vx_ta:
249
  ID = Intrinsic::riscv_vand;
250
  PolicyAttrs = 3;
251
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
252
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
253
  break;
254
case RISCVVector::BI__builtin_rvv_vand_vv_tum:
255
case RISCVVector::BI__builtin_rvv_vand_vx_tum:
256
  ID = Intrinsic::riscv_vand_mask;
257
  PolicyAttrs = 2;
258
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
259
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
260
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
261
  break;
262
case RISCVVector::BI__builtin_rvv_vand_vv_tama:
263
case RISCVVector::BI__builtin_rvv_vand_vx_tama:
264
  ID = Intrinsic::riscv_vand_mask;
265
  PolicyAttrs = 3;
266
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
267
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
268
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
269
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
270
  break;
271
case RISCVVector::BI__builtin_rvv_vand_vv_tumu:
272
case RISCVVector::BI__builtin_rvv_vand_vx_tumu:
273
  ID = Intrinsic::riscv_vand_mask;
274
  PolicyAttrs = 0;
275
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
276
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
277
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
278
  break;
279
case RISCVVector::BI__builtin_rvv_vand_vv_mu:
280
case RISCVVector::BI__builtin_rvv_vand_vx_mu:
281
  ID = Intrinsic::riscv_vand_mask;
282
  PolicyAttrs = 1;
283
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
284
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
285
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
286
  break;
287
case RISCVVector::BI__builtin_rvv_vasub_vv_tu:
288
case RISCVVector::BI__builtin_rvv_vasub_vx_tu:
289
  ID = Intrinsic::riscv_vasub;
290
  PolicyAttrs = 2;
291
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
292
  break;
293
case RISCVVector::BI__builtin_rvv_vasub_vv_ta:
294
case RISCVVector::BI__builtin_rvv_vasub_vx_ta:
295
  ID = Intrinsic::riscv_vasub;
296
  PolicyAttrs = 3;
297
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
298
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
299
  break;
300
case RISCVVector::BI__builtin_rvv_vasub_vv_tum:
301
case RISCVVector::BI__builtin_rvv_vasub_vx_tum:
302
  ID = Intrinsic::riscv_vasub_mask;
303
  PolicyAttrs = 2;
304
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
305
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
306
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
307
  break;
308
case RISCVVector::BI__builtin_rvv_vasub_vv_tama:
309
case RISCVVector::BI__builtin_rvv_vasub_vx_tama:
310
  ID = Intrinsic::riscv_vasub_mask;
311
  PolicyAttrs = 3;
312
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
313
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
314
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
315
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
316
  break;
317
case RISCVVector::BI__builtin_rvv_vasub_vv_tumu:
318
case RISCVVector::BI__builtin_rvv_vasub_vx_tumu:
319
  ID = Intrinsic::riscv_vasub_mask;
320
  PolicyAttrs = 0;
321
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
322
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
323
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
324
  break;
325
case RISCVVector::BI__builtin_rvv_vasub_vv_mu:
326
case RISCVVector::BI__builtin_rvv_vasub_vx_mu:
327
  ID = Intrinsic::riscv_vasub_mask;
328
  PolicyAttrs = 1;
329
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
330
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
331
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
332
  break;
333
case RISCVVector::BI__builtin_rvv_vasubu_vv_tu:
334
case RISCVVector::BI__builtin_rvv_vasubu_vx_tu:
335
  ID = Intrinsic::riscv_vasubu;
336
  PolicyAttrs = 2;
337
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
338
  break;
339
case RISCVVector::BI__builtin_rvv_vasubu_vv_ta:
340
case RISCVVector::BI__builtin_rvv_vasubu_vx_ta:
341
  ID = Intrinsic::riscv_vasubu;
342
  PolicyAttrs = 3;
343
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
344
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
345
  break;
346
case RISCVVector::BI__builtin_rvv_vasubu_vv_tum:
347
case RISCVVector::BI__builtin_rvv_vasubu_vx_tum:
348
  ID = Intrinsic::riscv_vasubu_mask;
349
  PolicyAttrs = 2;
350
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
351
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
352
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
353
  break;
354
case RISCVVector::BI__builtin_rvv_vasubu_vv_tama:
355
case RISCVVector::BI__builtin_rvv_vasubu_vx_tama:
356
  ID = Intrinsic::riscv_vasubu_mask;
357
  PolicyAttrs = 3;
358
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
359
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
360
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
361
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
362
  break;
363
case RISCVVector::BI__builtin_rvv_vasubu_vv_tumu:
364
case RISCVVector::BI__builtin_rvv_vasubu_vx_tumu:
365
  ID = Intrinsic::riscv_vasubu_mask;
366
  PolicyAttrs = 0;
367
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
368
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
369
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
370
  break;
371
case RISCVVector::BI__builtin_rvv_vasubu_vv_mu:
372
case RISCVVector::BI__builtin_rvv_vasubu_vx_mu:
373
  ID = Intrinsic::riscv_vasubu_mask;
374
  PolicyAttrs = 1;
375
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
376
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
377
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
378
  break;
379
case RISCVVector::BI__builtin_rvv_vcompress_vm_tu:
380
  ID = Intrinsic::riscv_vcompress;
381
  PolicyAttrs = 2;
382
IsMasked = false;
383
 
384
      // insert poison passthru
385
      if (PolicyAttrs & RVV_VTA)
386
        Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
387
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
388
    break;
389
case RISCVVector::BI__builtin_rvv_vcompress_vm_ta:
390
  ID = Intrinsic::riscv_vcompress;
391
  PolicyAttrs = 3;
392
IsMasked = false;
393
 
394
      // insert poison passthru
395
      if (PolicyAttrs & RVV_VTA)
396
        Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
397
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
398
    break;
399
case RISCVVector::BI__builtin_rvv_vcpop_m:
400
  ID = Intrinsic::riscv_vcpop;
401
  PolicyAttrs = 3;
402
  IntrinsicTypes = {Ops[0]->getType(), Ops.back()->getType()};
403
  break;
404
case RISCVVector::BI__builtin_rvv_vcpop_m_m:
405
  ID = Intrinsic::riscv_vcpop_mask;
406
  PolicyAttrs = 3;
407
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
408
  IntrinsicTypes = {Ops[0]->getType(), Ops.back()->getType()};
409
  break;
410
case RISCVVector::BI__builtin_rvv_vdiv_vv_tu:
411
case RISCVVector::BI__builtin_rvv_vdiv_vx_tu:
412
  ID = Intrinsic::riscv_vdiv;
413
  PolicyAttrs = 2;
414
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
415
  break;
416
case RISCVVector::BI__builtin_rvv_vdiv_vv_ta:
417
case RISCVVector::BI__builtin_rvv_vdiv_vx_ta:
418
  ID = Intrinsic::riscv_vdiv;
419
  PolicyAttrs = 3;
420
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
421
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
422
  break;
423
case RISCVVector::BI__builtin_rvv_vdiv_vv_tum:
424
case RISCVVector::BI__builtin_rvv_vdiv_vx_tum:
425
  ID = Intrinsic::riscv_vdiv_mask;
426
  PolicyAttrs = 2;
427
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
428
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
429
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
430
  break;
431
case RISCVVector::BI__builtin_rvv_vdiv_vv_tama:
432
case RISCVVector::BI__builtin_rvv_vdiv_vx_tama:
433
  ID = Intrinsic::riscv_vdiv_mask;
434
  PolicyAttrs = 3;
435
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
436
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
437
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
438
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
439
  break;
440
case RISCVVector::BI__builtin_rvv_vdiv_vv_tumu:
441
case RISCVVector::BI__builtin_rvv_vdiv_vx_tumu:
442
  ID = Intrinsic::riscv_vdiv_mask;
443
  PolicyAttrs = 0;
444
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
445
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
446
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
447
  break;
448
case RISCVVector::BI__builtin_rvv_vdiv_vv_mu:
449
case RISCVVector::BI__builtin_rvv_vdiv_vx_mu:
450
  ID = Intrinsic::riscv_vdiv_mask;
451
  PolicyAttrs = 1;
452
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
453
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
454
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
455
  break;
456
case RISCVVector::BI__builtin_rvv_vdivu_vv_tu:
457
case RISCVVector::BI__builtin_rvv_vdivu_vx_tu:
458
  ID = Intrinsic::riscv_vdivu;
459
  PolicyAttrs = 2;
460
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
461
  break;
462
case RISCVVector::BI__builtin_rvv_vdivu_vv_ta:
463
case RISCVVector::BI__builtin_rvv_vdivu_vx_ta:
464
  ID = Intrinsic::riscv_vdivu;
465
  PolicyAttrs = 3;
466
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
467
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
468
  break;
469
case RISCVVector::BI__builtin_rvv_vdivu_vv_tum:
470
case RISCVVector::BI__builtin_rvv_vdivu_vx_tum:
471
  ID = Intrinsic::riscv_vdivu_mask;
472
  PolicyAttrs = 2;
473
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
474
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
475
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
476
  break;
477
case RISCVVector::BI__builtin_rvv_vdivu_vv_tama:
478
case RISCVVector::BI__builtin_rvv_vdivu_vx_tama:
479
  ID = Intrinsic::riscv_vdivu_mask;
480
  PolicyAttrs = 3;
481
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
482
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
483
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
484
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
485
  break;
486
case RISCVVector::BI__builtin_rvv_vdivu_vv_tumu:
487
case RISCVVector::BI__builtin_rvv_vdivu_vx_tumu:
488
  ID = Intrinsic::riscv_vdivu_mask;
489
  PolicyAttrs = 0;
490
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
491
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
492
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
493
  break;
494
case RISCVVector::BI__builtin_rvv_vdivu_vv_mu:
495
case RISCVVector::BI__builtin_rvv_vdivu_vx_mu:
496
  ID = Intrinsic::riscv_vdivu_mask;
497
  PolicyAttrs = 1;
498
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
499
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
500
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
501
  break;
502
case RISCVVector::BI__builtin_rvv_vfadd_vv_tu:
503
case RISCVVector::BI__builtin_rvv_vfadd_vf_tu:
504
  ID = Intrinsic::riscv_vfadd;
505
  PolicyAttrs = 2;
506
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
507
  break;
508
case RISCVVector::BI__builtin_rvv_vfadd_vv_ta:
509
case RISCVVector::BI__builtin_rvv_vfadd_vf_ta:
510
  ID = Intrinsic::riscv_vfadd;
511
  PolicyAttrs = 3;
512
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
513
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
514
  break;
515
case RISCVVector::BI__builtin_rvv_vfadd_vv_tum:
516
case RISCVVector::BI__builtin_rvv_vfadd_vf_tum:
517
  ID = Intrinsic::riscv_vfadd_mask;
518
  PolicyAttrs = 2;
519
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
520
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
521
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
522
  break;
523
case RISCVVector::BI__builtin_rvv_vfadd_vv_tama:
524
case RISCVVector::BI__builtin_rvv_vfadd_vf_tama:
525
  ID = Intrinsic::riscv_vfadd_mask;
526
  PolicyAttrs = 3;
527
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
528
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
529
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
530
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
531
  break;
532
case RISCVVector::BI__builtin_rvv_vfadd_vv_tumu:
533
case RISCVVector::BI__builtin_rvv_vfadd_vf_tumu:
534
  ID = Intrinsic::riscv_vfadd_mask;
535
  PolicyAttrs = 0;
536
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
537
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
538
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
539
  break;
540
case RISCVVector::BI__builtin_rvv_vfadd_vv_mu:
541
case RISCVVector::BI__builtin_rvv_vfadd_vf_mu:
542
  ID = Intrinsic::riscv_vfadd_mask;
543
  PolicyAttrs = 1;
544
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
545
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
546
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
547
  break;
548
case RISCVVector::BI__builtin_rvv_vfclass_v_tu:
549
  ID = Intrinsic::riscv_vfclass;
550
  PolicyAttrs = 2;
551
  IntrinsicTypes = {Ops[1]->getType(), Ops.back()->getType()};
552
  break;
553
case RISCVVector::BI__builtin_rvv_vfclass_v_ta:
554
  ID = Intrinsic::riscv_vfclass;
555
  PolicyAttrs = 3;
556
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
557
  IntrinsicTypes = {Ops[1]->getType(), Ops.back()->getType()};
558
  break;
559
case RISCVVector::BI__builtin_rvv_vfclass_v_tum:
560
  ID = Intrinsic::riscv_vfclass_mask;
561
  PolicyAttrs = 2;
562
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
563
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
564
  IntrinsicTypes = {Ops[1]->getType(), Ops.back()->getType()};
565
  break;
566
case RISCVVector::BI__builtin_rvv_vfclass_v_tama:
567
  ID = Intrinsic::riscv_vfclass_mask;
568
  PolicyAttrs = 3;
569
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
570
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
571
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
572
  IntrinsicTypes = {Ops[1]->getType(), Ops.back()->getType()};
573
  break;
574
case RISCVVector::BI__builtin_rvv_vfclass_v_tumu:
575
  ID = Intrinsic::riscv_vfclass_mask;
576
  PolicyAttrs = 0;
577
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
578
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
579
  IntrinsicTypes = {Ops[1]->getType(), Ops.back()->getType()};
580
  break;
581
case RISCVVector::BI__builtin_rvv_vfclass_v_mu:
582
  ID = Intrinsic::riscv_vfclass_mask;
583
  PolicyAttrs = 1;
584
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
585
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
586
  IntrinsicTypes = {Ops[1]->getType(), Ops.back()->getType()};
587
  break;
588
case RISCVVector::BI__builtin_rvv_vfcvt_f_x_v_tu:
589
  ID = Intrinsic::riscv_vfcvt_f_x_v;
590
  PolicyAttrs = 2;
591
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
592
  break;
593
case RISCVVector::BI__builtin_rvv_vfcvt_f_x_v_ta:
594
  ID = Intrinsic::riscv_vfcvt_f_x_v;
595
  PolicyAttrs = 3;
596
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
597
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
598
  break;
599
case RISCVVector::BI__builtin_rvv_vfcvt_f_x_v_tum:
600
  ID = Intrinsic::riscv_vfcvt_f_x_v_mask;
601
  PolicyAttrs = 2;
602
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
603
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
604
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
605
  break;
606
case RISCVVector::BI__builtin_rvv_vfcvt_f_x_v_tama:
607
  ID = Intrinsic::riscv_vfcvt_f_x_v_mask;
608
  PolicyAttrs = 3;
609
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
610
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
611
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
612
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
613
  break;
614
case RISCVVector::BI__builtin_rvv_vfcvt_f_x_v_tumu:
615
  ID = Intrinsic::riscv_vfcvt_f_x_v_mask;
616
  PolicyAttrs = 0;
617
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
618
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
619
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
620
  break;
621
case RISCVVector::BI__builtin_rvv_vfcvt_f_x_v_mu:
622
  ID = Intrinsic::riscv_vfcvt_f_x_v_mask;
623
  PolicyAttrs = 1;
624
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
625
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
626
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
627
  break;
628
case RISCVVector::BI__builtin_rvv_vfcvt_f_xu_v_tu:
629
  ID = Intrinsic::riscv_vfcvt_f_xu_v;
630
  PolicyAttrs = 2;
631
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
632
  break;
633
case RISCVVector::BI__builtin_rvv_vfcvt_f_xu_v_ta:
634
  ID = Intrinsic::riscv_vfcvt_f_xu_v;
635
  PolicyAttrs = 3;
636
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
637
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
638
  break;
639
case RISCVVector::BI__builtin_rvv_vfcvt_f_xu_v_tum:
640
  ID = Intrinsic::riscv_vfcvt_f_xu_v_mask;
641
  PolicyAttrs = 2;
642
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
643
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
644
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
645
  break;
646
case RISCVVector::BI__builtin_rvv_vfcvt_f_xu_v_tama:
647
  ID = Intrinsic::riscv_vfcvt_f_xu_v_mask;
648
  PolicyAttrs = 3;
649
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
650
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
651
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
652
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
653
  break;
654
case RISCVVector::BI__builtin_rvv_vfcvt_f_xu_v_tumu:
655
  ID = Intrinsic::riscv_vfcvt_f_xu_v_mask;
656
  PolicyAttrs = 0;
657
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
658
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
659
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
660
  break;
661
case RISCVVector::BI__builtin_rvv_vfcvt_f_xu_v_mu:
662
  ID = Intrinsic::riscv_vfcvt_f_xu_v_mask;
663
  PolicyAttrs = 1;
664
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
665
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
666
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
667
  break;
668
case RISCVVector::BI__builtin_rvv_vfcvt_rtz_x_f_v_tu:
669
  ID = Intrinsic::riscv_vfcvt_rtz_x_f_v;
670
  PolicyAttrs = 2;
671
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
672
  break;
673
case RISCVVector::BI__builtin_rvv_vfcvt_rtz_x_f_v_ta:
674
  ID = Intrinsic::riscv_vfcvt_rtz_x_f_v;
675
  PolicyAttrs = 3;
676
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
677
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
678
  break;
679
case RISCVVector::BI__builtin_rvv_vfcvt_rtz_x_f_v_tum:
680
  ID = Intrinsic::riscv_vfcvt_rtz_x_f_v_mask;
681
  PolicyAttrs = 2;
682
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
683
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
684
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
685
  break;
686
case RISCVVector::BI__builtin_rvv_vfcvt_rtz_x_f_v_tama:
687
  ID = Intrinsic::riscv_vfcvt_rtz_x_f_v_mask;
688
  PolicyAttrs = 3;
689
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
690
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
691
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
692
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
693
  break;
694
case RISCVVector::BI__builtin_rvv_vfcvt_rtz_x_f_v_tumu:
695
  ID = Intrinsic::riscv_vfcvt_rtz_x_f_v_mask;
696
  PolicyAttrs = 0;
697
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
698
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
699
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
700
  break;
701
case RISCVVector::BI__builtin_rvv_vfcvt_rtz_x_f_v_mu:
702
  ID = Intrinsic::riscv_vfcvt_rtz_x_f_v_mask;
703
  PolicyAttrs = 1;
704
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
705
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
706
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
707
  break;
708
case RISCVVector::BI__builtin_rvv_vfcvt_rtz_xu_f_v_tu:
709
  ID = Intrinsic::riscv_vfcvt_rtz_xu_f_v;
710
  PolicyAttrs = 2;
711
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
712
  break;
713
case RISCVVector::BI__builtin_rvv_vfcvt_rtz_xu_f_v_ta:
714
  ID = Intrinsic::riscv_vfcvt_rtz_xu_f_v;
715
  PolicyAttrs = 3;
716
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
717
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
718
  break;
719
case RISCVVector::BI__builtin_rvv_vfcvt_rtz_xu_f_v_tum:
720
  ID = Intrinsic::riscv_vfcvt_rtz_xu_f_v_mask;
721
  PolicyAttrs = 2;
722
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
723
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
724
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
725
  break;
726
case RISCVVector::BI__builtin_rvv_vfcvt_rtz_xu_f_v_tama:
727
  ID = Intrinsic::riscv_vfcvt_rtz_xu_f_v_mask;
728
  PolicyAttrs = 3;
729
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
730
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
731
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
732
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
733
  break;
734
case RISCVVector::BI__builtin_rvv_vfcvt_rtz_xu_f_v_tumu:
735
  ID = Intrinsic::riscv_vfcvt_rtz_xu_f_v_mask;
736
  PolicyAttrs = 0;
737
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
738
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
739
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
740
  break;
741
case RISCVVector::BI__builtin_rvv_vfcvt_rtz_xu_f_v_mu:
742
  ID = Intrinsic::riscv_vfcvt_rtz_xu_f_v_mask;
743
  PolicyAttrs = 1;
744
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
745
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
746
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
747
  break;
748
case RISCVVector::BI__builtin_rvv_vfcvt_x_f_v_tu:
749
  ID = Intrinsic::riscv_vfcvt_x_f_v;
750
  PolicyAttrs = 2;
751
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
752
  break;
753
case RISCVVector::BI__builtin_rvv_vfcvt_x_f_v_ta:
754
  ID = Intrinsic::riscv_vfcvt_x_f_v;
755
  PolicyAttrs = 3;
756
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
757
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
758
  break;
759
case RISCVVector::BI__builtin_rvv_vfcvt_x_f_v_tum:
760
  ID = Intrinsic::riscv_vfcvt_x_f_v_mask;
761
  PolicyAttrs = 2;
762
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
763
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
764
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
765
  break;
766
case RISCVVector::BI__builtin_rvv_vfcvt_x_f_v_tama:
767
  ID = Intrinsic::riscv_vfcvt_x_f_v_mask;
768
  PolicyAttrs = 3;
769
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
770
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
771
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
772
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
773
  break;
774
case RISCVVector::BI__builtin_rvv_vfcvt_x_f_v_tumu:
775
  ID = Intrinsic::riscv_vfcvt_x_f_v_mask;
776
  PolicyAttrs = 0;
777
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
778
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
779
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
780
  break;
781
case RISCVVector::BI__builtin_rvv_vfcvt_x_f_v_mu:
782
  ID = Intrinsic::riscv_vfcvt_x_f_v_mask;
783
  PolicyAttrs = 1;
784
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
785
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
786
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
787
  break;
788
case RISCVVector::BI__builtin_rvv_vfcvt_xu_f_v_tu:
789
  ID = Intrinsic::riscv_vfcvt_xu_f_v;
790
  PolicyAttrs = 2;
791
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
792
  break;
793
case RISCVVector::BI__builtin_rvv_vfcvt_xu_f_v_ta:
794
  ID = Intrinsic::riscv_vfcvt_xu_f_v;
795
  PolicyAttrs = 3;
796
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
797
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
798
  break;
799
case RISCVVector::BI__builtin_rvv_vfcvt_xu_f_v_tum:
800
  ID = Intrinsic::riscv_vfcvt_xu_f_v_mask;
801
  PolicyAttrs = 2;
802
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
803
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
804
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
805
  break;
806
case RISCVVector::BI__builtin_rvv_vfcvt_xu_f_v_tama:
807
  ID = Intrinsic::riscv_vfcvt_xu_f_v_mask;
808
  PolicyAttrs = 3;
809
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
810
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
811
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
812
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
813
  break;
814
case RISCVVector::BI__builtin_rvv_vfcvt_xu_f_v_tumu:
815
  ID = Intrinsic::riscv_vfcvt_xu_f_v_mask;
816
  PolicyAttrs = 0;
817
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
818
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
819
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
820
  break;
821
case RISCVVector::BI__builtin_rvv_vfcvt_xu_f_v_mu:
822
  ID = Intrinsic::riscv_vfcvt_xu_f_v_mask;
823
  PolicyAttrs = 1;
824
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
825
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
826
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
827
  break;
828
case RISCVVector::BI__builtin_rvv_vfdiv_vv_tu:
829
case RISCVVector::BI__builtin_rvv_vfdiv_vf_tu:
830
  ID = Intrinsic::riscv_vfdiv;
831
  PolicyAttrs = 2;
832
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
833
  break;
834
case RISCVVector::BI__builtin_rvv_vfdiv_vv_ta:
835
case RISCVVector::BI__builtin_rvv_vfdiv_vf_ta:
836
  ID = Intrinsic::riscv_vfdiv;
837
  PolicyAttrs = 3;
838
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
839
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
840
  break;
841
case RISCVVector::BI__builtin_rvv_vfdiv_vv_tum:
842
case RISCVVector::BI__builtin_rvv_vfdiv_vf_tum:
843
  ID = Intrinsic::riscv_vfdiv_mask;
844
  PolicyAttrs = 2;
845
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
846
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
847
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
848
  break;
849
case RISCVVector::BI__builtin_rvv_vfdiv_vv_tama:
850
case RISCVVector::BI__builtin_rvv_vfdiv_vf_tama:
851
  ID = Intrinsic::riscv_vfdiv_mask;
852
  PolicyAttrs = 3;
853
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
854
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
855
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
856
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
857
  break;
858
case RISCVVector::BI__builtin_rvv_vfdiv_vv_tumu:
859
case RISCVVector::BI__builtin_rvv_vfdiv_vf_tumu:
860
  ID = Intrinsic::riscv_vfdiv_mask;
861
  PolicyAttrs = 0;
862
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
863
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
864
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
865
  break;
866
case RISCVVector::BI__builtin_rvv_vfdiv_vv_mu:
867
case RISCVVector::BI__builtin_rvv_vfdiv_vf_mu:
868
  ID = Intrinsic::riscv_vfdiv_mask;
869
  PolicyAttrs = 1;
870
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
871
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
872
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
873
  break;
874
case RISCVVector::BI__builtin_rvv_vfirst_m:
875
  ID = Intrinsic::riscv_vfirst;
876
  PolicyAttrs = 3;
877
  IntrinsicTypes = {Ops[0]->getType(), Ops.back()->getType()};
878
  break;
879
case RISCVVector::BI__builtin_rvv_vfirst_m_m:
880
  ID = Intrinsic::riscv_vfirst_mask;
881
  PolicyAttrs = 3;
882
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
883
  IntrinsicTypes = {Ops[0]->getType(), Ops.back()->getType()};
884
  break;
885
case RISCVVector::BI__builtin_rvv_vfmacc_vv_tu:
886
case RISCVVector::BI__builtin_rvv_vfmacc_vf_tu:
887
  ID = Intrinsic::riscv_vfmacc;
888
  PolicyAttrs = 2;
889
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
890
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
891
  break;
892
case RISCVVector::BI__builtin_rvv_vfmacc_vv_ta:
893
case RISCVVector::BI__builtin_rvv_vfmacc_vf_ta:
894
  ID = Intrinsic::riscv_vfmacc;
895
  PolicyAttrs = 3;
896
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
897
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
898
  break;
899
case RISCVVector::BI__builtin_rvv_vfmacc_vv_tum:
900
case RISCVVector::BI__builtin_rvv_vfmacc_vf_tum:
901
  ID = Intrinsic::riscv_vfmacc_mask;
902
  PolicyAttrs = 2;
903
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
904
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
905
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
906
  break;
907
case RISCVVector::BI__builtin_rvv_vfmacc_vv_tama:
908
case RISCVVector::BI__builtin_rvv_vfmacc_vf_tama:
909
  ID = Intrinsic::riscv_vfmacc_mask;
910
  PolicyAttrs = 3;
911
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
912
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
913
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
914
  break;
915
case RISCVVector::BI__builtin_rvv_vfmacc_vv_tumu:
916
case RISCVVector::BI__builtin_rvv_vfmacc_vf_tumu:
917
  ID = Intrinsic::riscv_vfmacc_mask;
918
  PolicyAttrs = 0;
919
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
920
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
921
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
922
  break;
923
case RISCVVector::BI__builtin_rvv_vfmacc_vv_mu:
924
case RISCVVector::BI__builtin_rvv_vfmacc_vf_mu:
925
  ID = Intrinsic::riscv_vfmacc_mask;
926
  PolicyAttrs = 1;
927
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
928
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
929
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
930
  break;
931
case RISCVVector::BI__builtin_rvv_vfmadd_vv_tu:
932
case RISCVVector::BI__builtin_rvv_vfmadd_vf_tu:
933
  ID = Intrinsic::riscv_vfmadd;
934
  PolicyAttrs = 2;
935
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
936
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
937
  break;
938
case RISCVVector::BI__builtin_rvv_vfmadd_vv_ta:
939
case RISCVVector::BI__builtin_rvv_vfmadd_vf_ta:
940
  ID = Intrinsic::riscv_vfmadd;
941
  PolicyAttrs = 3;
942
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
943
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
944
  break;
945
case RISCVVector::BI__builtin_rvv_vfmadd_vv_tum:
946
case RISCVVector::BI__builtin_rvv_vfmadd_vf_tum:
947
  ID = Intrinsic::riscv_vfmadd_mask;
948
  PolicyAttrs = 2;
949
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
950
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
951
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
952
  break;
953
case RISCVVector::BI__builtin_rvv_vfmadd_vv_tama:
954
case RISCVVector::BI__builtin_rvv_vfmadd_vf_tama:
955
  ID = Intrinsic::riscv_vfmadd_mask;
956
  PolicyAttrs = 3;
957
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
958
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
959
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
960
  break;
961
case RISCVVector::BI__builtin_rvv_vfmadd_vv_tumu:
962
case RISCVVector::BI__builtin_rvv_vfmadd_vf_tumu:
963
  ID = Intrinsic::riscv_vfmadd_mask;
964
  PolicyAttrs = 0;
965
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
966
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
967
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
968
  break;
969
case RISCVVector::BI__builtin_rvv_vfmadd_vv_mu:
970
case RISCVVector::BI__builtin_rvv_vfmadd_vf_mu:
971
  ID = Intrinsic::riscv_vfmadd_mask;
972
  PolicyAttrs = 1;
973
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
974
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
975
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
976
  break;
977
case RISCVVector::BI__builtin_rvv_vfmax_vv_tu:
978
case RISCVVector::BI__builtin_rvv_vfmax_vf_tu:
979
  ID = Intrinsic::riscv_vfmax;
980
  PolicyAttrs = 2;
981
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
982
  break;
983
case RISCVVector::BI__builtin_rvv_vfmax_vv_ta:
984
case RISCVVector::BI__builtin_rvv_vfmax_vf_ta:
985
  ID = Intrinsic::riscv_vfmax;
986
  PolicyAttrs = 3;
987
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
988
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
989
  break;
990
case RISCVVector::BI__builtin_rvv_vfmax_vv_tum:
991
case RISCVVector::BI__builtin_rvv_vfmax_vf_tum:
992
  ID = Intrinsic::riscv_vfmax_mask;
993
  PolicyAttrs = 2;
994
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
995
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
996
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
997
  break;
998
case RISCVVector::BI__builtin_rvv_vfmax_vv_tama:
999
case RISCVVector::BI__builtin_rvv_vfmax_vf_tama:
1000
  ID = Intrinsic::riscv_vfmax_mask;
1001
  PolicyAttrs = 3;
1002
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1003
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1004
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1005
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
1006
  break;
1007
case RISCVVector::BI__builtin_rvv_vfmax_vv_tumu:
1008
case RISCVVector::BI__builtin_rvv_vfmax_vf_tumu:
1009
  ID = Intrinsic::riscv_vfmax_mask;
1010
  PolicyAttrs = 0;
1011
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1012
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1013
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
1014
  break;
1015
case RISCVVector::BI__builtin_rvv_vfmax_vv_mu:
1016
case RISCVVector::BI__builtin_rvv_vfmax_vf_mu:
1017
  ID = Intrinsic::riscv_vfmax_mask;
1018
  PolicyAttrs = 1;
1019
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1020
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1021
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
1022
  break;
1023
case RISCVVector::BI__builtin_rvv_vfmerge_vfm_tu:
1024
  ID = Intrinsic::riscv_vfmerge;
1025
  PolicyAttrs = 2;
1026
IsMasked = false;
1027
 
1028
      // insert poison passthru
1029
      if (PolicyAttrs & RVV_VTA)
1030
        Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1031
      IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
1032
    break;
1033
case RISCVVector::BI__builtin_rvv_vfmerge_vfm_ta:
1034
  ID = Intrinsic::riscv_vfmerge;
1035
  PolicyAttrs = 3;
1036
IsMasked = false;
1037
 
1038
      // insert poison passthru
1039
      if (PolicyAttrs & RVV_VTA)
1040
        Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1041
      IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
1042
    break;
1043
case RISCVVector::BI__builtin_rvv_vfmin_vv_tu:
1044
case RISCVVector::BI__builtin_rvv_vfmin_vf_tu:
1045
  ID = Intrinsic::riscv_vfmin;
1046
  PolicyAttrs = 2;
1047
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
1048
  break;
1049
case RISCVVector::BI__builtin_rvv_vfmin_vv_ta:
1050
case RISCVVector::BI__builtin_rvv_vfmin_vf_ta:
1051
  ID = Intrinsic::riscv_vfmin;
1052
  PolicyAttrs = 3;
1053
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1054
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
1055
  break;
1056
case RISCVVector::BI__builtin_rvv_vfmin_vv_tum:
1057
case RISCVVector::BI__builtin_rvv_vfmin_vf_tum:
1058
  ID = Intrinsic::riscv_vfmin_mask;
1059
  PolicyAttrs = 2;
1060
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1061
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1062
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
1063
  break;
1064
case RISCVVector::BI__builtin_rvv_vfmin_vv_tama:
1065
case RISCVVector::BI__builtin_rvv_vfmin_vf_tama:
1066
  ID = Intrinsic::riscv_vfmin_mask;
1067
  PolicyAttrs = 3;
1068
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1069
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1070
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1071
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
1072
  break;
1073
case RISCVVector::BI__builtin_rvv_vfmin_vv_tumu:
1074
case RISCVVector::BI__builtin_rvv_vfmin_vf_tumu:
1075
  ID = Intrinsic::riscv_vfmin_mask;
1076
  PolicyAttrs = 0;
1077
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1078
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1079
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
1080
  break;
1081
case RISCVVector::BI__builtin_rvv_vfmin_vv_mu:
1082
case RISCVVector::BI__builtin_rvv_vfmin_vf_mu:
1083
  ID = Intrinsic::riscv_vfmin_mask;
1084
  PolicyAttrs = 1;
1085
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1086
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1087
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
1088
  break;
1089
case RISCVVector::BI__builtin_rvv_vfmsac_vv_tu:
1090
case RISCVVector::BI__builtin_rvv_vfmsac_vf_tu:
1091
  ID = Intrinsic::riscv_vfmsac;
1092
  PolicyAttrs = 2;
1093
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1094
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1095
  break;
1096
case RISCVVector::BI__builtin_rvv_vfmsac_vv_ta:
1097
case RISCVVector::BI__builtin_rvv_vfmsac_vf_ta:
1098
  ID = Intrinsic::riscv_vfmsac;
1099
  PolicyAttrs = 3;
1100
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1101
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1102
  break;
1103
case RISCVVector::BI__builtin_rvv_vfmsac_vv_tum:
1104
case RISCVVector::BI__builtin_rvv_vfmsac_vf_tum:
1105
  ID = Intrinsic::riscv_vfmsac_mask;
1106
  PolicyAttrs = 2;
1107
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1108
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1109
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1110
  break;
1111
case RISCVVector::BI__builtin_rvv_vfmsac_vv_tama:
1112
case RISCVVector::BI__builtin_rvv_vfmsac_vf_tama:
1113
  ID = Intrinsic::riscv_vfmsac_mask;
1114
  PolicyAttrs = 3;
1115
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1116
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1117
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1118
  break;
1119
case RISCVVector::BI__builtin_rvv_vfmsac_vv_tumu:
1120
case RISCVVector::BI__builtin_rvv_vfmsac_vf_tumu:
1121
  ID = Intrinsic::riscv_vfmsac_mask;
1122
  PolicyAttrs = 0;
1123
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1124
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1125
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1126
  break;
1127
case RISCVVector::BI__builtin_rvv_vfmsac_vv_mu:
1128
case RISCVVector::BI__builtin_rvv_vfmsac_vf_mu:
1129
  ID = Intrinsic::riscv_vfmsac_mask;
1130
  PolicyAttrs = 1;
1131
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1132
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1133
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1134
  break;
1135
case RISCVVector::BI__builtin_rvv_vfmsub_vv_tu:
1136
case RISCVVector::BI__builtin_rvv_vfmsub_vf_tu:
1137
  ID = Intrinsic::riscv_vfmsub;
1138
  PolicyAttrs = 2;
1139
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1140
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1141
  break;
1142
case RISCVVector::BI__builtin_rvv_vfmsub_vv_ta:
1143
case RISCVVector::BI__builtin_rvv_vfmsub_vf_ta:
1144
  ID = Intrinsic::riscv_vfmsub;
1145
  PolicyAttrs = 3;
1146
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1147
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1148
  break;
1149
case RISCVVector::BI__builtin_rvv_vfmsub_vv_tum:
1150
case RISCVVector::BI__builtin_rvv_vfmsub_vf_tum:
1151
  ID = Intrinsic::riscv_vfmsub_mask;
1152
  PolicyAttrs = 2;
1153
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1154
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1155
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1156
  break;
1157
case RISCVVector::BI__builtin_rvv_vfmsub_vv_tama:
1158
case RISCVVector::BI__builtin_rvv_vfmsub_vf_tama:
1159
  ID = Intrinsic::riscv_vfmsub_mask;
1160
  PolicyAttrs = 3;
1161
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1162
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1163
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1164
  break;
1165
case RISCVVector::BI__builtin_rvv_vfmsub_vv_tumu:
1166
case RISCVVector::BI__builtin_rvv_vfmsub_vf_tumu:
1167
  ID = Intrinsic::riscv_vfmsub_mask;
1168
  PolicyAttrs = 0;
1169
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1170
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1171
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1172
  break;
1173
case RISCVVector::BI__builtin_rvv_vfmsub_vv_mu:
1174
case RISCVVector::BI__builtin_rvv_vfmsub_vf_mu:
1175
  ID = Intrinsic::riscv_vfmsub_mask;
1176
  PolicyAttrs = 1;
1177
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1178
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1179
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1180
  break;
1181
case RISCVVector::BI__builtin_rvv_vfmul_vv_tu:
1182
case RISCVVector::BI__builtin_rvv_vfmul_vf_tu:
1183
  ID = Intrinsic::riscv_vfmul;
1184
  PolicyAttrs = 2;
1185
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
1186
  break;
1187
case RISCVVector::BI__builtin_rvv_vfmul_vv_ta:
1188
case RISCVVector::BI__builtin_rvv_vfmul_vf_ta:
1189
  ID = Intrinsic::riscv_vfmul;
1190
  PolicyAttrs = 3;
1191
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1192
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
1193
  break;
1194
case RISCVVector::BI__builtin_rvv_vfmul_vv_tum:
1195
case RISCVVector::BI__builtin_rvv_vfmul_vf_tum:
1196
  ID = Intrinsic::riscv_vfmul_mask;
1197
  PolicyAttrs = 2;
1198
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1199
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1200
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
1201
  break;
1202
case RISCVVector::BI__builtin_rvv_vfmul_vv_tama:
1203
case RISCVVector::BI__builtin_rvv_vfmul_vf_tama:
1204
  ID = Intrinsic::riscv_vfmul_mask;
1205
  PolicyAttrs = 3;
1206
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1207
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1208
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1209
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
1210
  break;
1211
case RISCVVector::BI__builtin_rvv_vfmul_vv_tumu:
1212
case RISCVVector::BI__builtin_rvv_vfmul_vf_tumu:
1213
  ID = Intrinsic::riscv_vfmul_mask;
1214
  PolicyAttrs = 0;
1215
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1216
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1217
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
1218
  break;
1219
case RISCVVector::BI__builtin_rvv_vfmul_vv_mu:
1220
case RISCVVector::BI__builtin_rvv_vfmul_vf_mu:
1221
  ID = Intrinsic::riscv_vfmul_mask;
1222
  PolicyAttrs = 1;
1223
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1224
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1225
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
1226
  break;
1227
case RISCVVector::BI__builtin_rvv_vfmv_f_s:
1228
  ID = Intrinsic::riscv_vfmv_f_s;
1229
  PolicyAttrs = 3;
1230
  IntrinsicTypes = {Ops[0]->getType()};
1231
  break;
1232
case RISCVVector::BI__builtin_rvv_vfmv_s_f_tu:
1233
case RISCVVector::BI__builtin_rvv_vfmv_s_x_tu:
1234
  ID = Intrinsic::riscv_vfmv_s_f;
1235
  PolicyAttrs = 2;
1236
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
1237
  break;
1238
case RISCVVector::BI__builtin_rvv_vfmv_s_f_ta:
1239
case RISCVVector::BI__builtin_rvv_vfmv_s_x_ta:
1240
  ID = Intrinsic::riscv_vfmv_s_f;
1241
  PolicyAttrs = 3;
1242
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1243
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
1244
  break;
1245
case RISCVVector::BI__builtin_rvv_vfmv_v_f_tu:
1246
  ID = Intrinsic::riscv_vfmv_v_f;
1247
  PolicyAttrs = 2;
1248
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
1249
  break;
1250
case RISCVVector::BI__builtin_rvv_vfmv_v_f_ta:
1251
  ID = Intrinsic::riscv_vfmv_v_f;
1252
  PolicyAttrs = 3;
1253
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1254
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
1255
  break;
1256
case RISCVVector::BI__builtin_rvv_vfncvt_f_f_w_tu:
1257
  ID = Intrinsic::riscv_vfncvt_f_f_w;
1258
  PolicyAttrs = 2;
1259
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1260
  break;
1261
case RISCVVector::BI__builtin_rvv_vfncvt_f_f_w_ta:
1262
  ID = Intrinsic::riscv_vfncvt_f_f_w;
1263
  PolicyAttrs = 3;
1264
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1265
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1266
  break;
1267
case RISCVVector::BI__builtin_rvv_vfncvt_f_f_w_tum:
1268
  ID = Intrinsic::riscv_vfncvt_f_f_w_mask;
1269
  PolicyAttrs = 2;
1270
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1271
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1272
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1273
  break;
1274
case RISCVVector::BI__builtin_rvv_vfncvt_f_f_w_tama:
1275
  ID = Intrinsic::riscv_vfncvt_f_f_w_mask;
1276
  PolicyAttrs = 3;
1277
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1278
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1279
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1280
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1281
  break;
1282
case RISCVVector::BI__builtin_rvv_vfncvt_f_f_w_tumu:
1283
  ID = Intrinsic::riscv_vfncvt_f_f_w_mask;
1284
  PolicyAttrs = 0;
1285
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1286
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1287
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1288
  break;
1289
case RISCVVector::BI__builtin_rvv_vfncvt_f_f_w_mu:
1290
  ID = Intrinsic::riscv_vfncvt_f_f_w_mask;
1291
  PolicyAttrs = 1;
1292
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1293
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1294
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1295
  break;
1296
case RISCVVector::BI__builtin_rvv_vfncvt_f_x_w_tu:
1297
  ID = Intrinsic::riscv_vfncvt_f_x_w;
1298
  PolicyAttrs = 2;
1299
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1300
  break;
1301
case RISCVVector::BI__builtin_rvv_vfncvt_f_x_w_ta:
1302
  ID = Intrinsic::riscv_vfncvt_f_x_w;
1303
  PolicyAttrs = 3;
1304
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1305
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1306
  break;
1307
case RISCVVector::BI__builtin_rvv_vfncvt_f_x_w_tum:
1308
  ID = Intrinsic::riscv_vfncvt_f_x_w_mask;
1309
  PolicyAttrs = 2;
1310
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1311
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1312
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1313
  break;
1314
case RISCVVector::BI__builtin_rvv_vfncvt_f_x_w_tama:
1315
  ID = Intrinsic::riscv_vfncvt_f_x_w_mask;
1316
  PolicyAttrs = 3;
1317
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1318
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1319
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1320
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1321
  break;
1322
case RISCVVector::BI__builtin_rvv_vfncvt_f_x_w_tumu:
1323
  ID = Intrinsic::riscv_vfncvt_f_x_w_mask;
1324
  PolicyAttrs = 0;
1325
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1326
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1327
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1328
  break;
1329
case RISCVVector::BI__builtin_rvv_vfncvt_f_x_w_mu:
1330
  ID = Intrinsic::riscv_vfncvt_f_x_w_mask;
1331
  PolicyAttrs = 1;
1332
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1333
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1334
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1335
  break;
1336
case RISCVVector::BI__builtin_rvv_vfncvt_f_xu_w_tu:
1337
  ID = Intrinsic::riscv_vfncvt_f_xu_w;
1338
  PolicyAttrs = 2;
1339
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1340
  break;
1341
case RISCVVector::BI__builtin_rvv_vfncvt_f_xu_w_ta:
1342
  ID = Intrinsic::riscv_vfncvt_f_xu_w;
1343
  PolicyAttrs = 3;
1344
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1345
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1346
  break;
1347
case RISCVVector::BI__builtin_rvv_vfncvt_f_xu_w_tum:
1348
  ID = Intrinsic::riscv_vfncvt_f_xu_w_mask;
1349
  PolicyAttrs = 2;
1350
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1351
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1352
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1353
  break;
1354
case RISCVVector::BI__builtin_rvv_vfncvt_f_xu_w_tama:
1355
  ID = Intrinsic::riscv_vfncvt_f_xu_w_mask;
1356
  PolicyAttrs = 3;
1357
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1358
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1359
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1360
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1361
  break;
1362
case RISCVVector::BI__builtin_rvv_vfncvt_f_xu_w_tumu:
1363
  ID = Intrinsic::riscv_vfncvt_f_xu_w_mask;
1364
  PolicyAttrs = 0;
1365
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1366
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1367
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1368
  break;
1369
case RISCVVector::BI__builtin_rvv_vfncvt_f_xu_w_mu:
1370
  ID = Intrinsic::riscv_vfncvt_f_xu_w_mask;
1371
  PolicyAttrs = 1;
1372
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1373
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1374
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1375
  break;
1376
case RISCVVector::BI__builtin_rvv_vfncvt_rod_f_f_w_tu:
1377
  ID = Intrinsic::riscv_vfncvt_rod_f_f_w;
1378
  PolicyAttrs = 2;
1379
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1380
  break;
1381
case RISCVVector::BI__builtin_rvv_vfncvt_rod_f_f_w_ta:
1382
  ID = Intrinsic::riscv_vfncvt_rod_f_f_w;
1383
  PolicyAttrs = 3;
1384
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1385
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1386
  break;
1387
case RISCVVector::BI__builtin_rvv_vfncvt_rod_f_f_w_tum:
1388
  ID = Intrinsic::riscv_vfncvt_rod_f_f_w_mask;
1389
  PolicyAttrs = 2;
1390
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1391
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1392
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1393
  break;
1394
case RISCVVector::BI__builtin_rvv_vfncvt_rod_f_f_w_tama:
1395
  ID = Intrinsic::riscv_vfncvt_rod_f_f_w_mask;
1396
  PolicyAttrs = 3;
1397
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1398
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1399
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1400
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1401
  break;
1402
case RISCVVector::BI__builtin_rvv_vfncvt_rod_f_f_w_tumu:
1403
  ID = Intrinsic::riscv_vfncvt_rod_f_f_w_mask;
1404
  PolicyAttrs = 0;
1405
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1406
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1407
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1408
  break;
1409
case RISCVVector::BI__builtin_rvv_vfncvt_rod_f_f_w_mu:
1410
  ID = Intrinsic::riscv_vfncvt_rod_f_f_w_mask;
1411
  PolicyAttrs = 1;
1412
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1413
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1414
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1415
  break;
1416
case RISCVVector::BI__builtin_rvv_vfncvt_rtz_x_f_w_tu:
1417
  ID = Intrinsic::riscv_vfncvt_rtz_x_f_w;
1418
  PolicyAttrs = 2;
1419
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1420
  break;
1421
case RISCVVector::BI__builtin_rvv_vfncvt_rtz_x_f_w_ta:
1422
  ID = Intrinsic::riscv_vfncvt_rtz_x_f_w;
1423
  PolicyAttrs = 3;
1424
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1425
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1426
  break;
1427
case RISCVVector::BI__builtin_rvv_vfncvt_rtz_x_f_w_tum:
1428
  ID = Intrinsic::riscv_vfncvt_rtz_x_f_w_mask;
1429
  PolicyAttrs = 2;
1430
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1431
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1432
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1433
  break;
1434
case RISCVVector::BI__builtin_rvv_vfncvt_rtz_x_f_w_tama:
1435
  ID = Intrinsic::riscv_vfncvt_rtz_x_f_w_mask;
1436
  PolicyAttrs = 3;
1437
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1438
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1439
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1440
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1441
  break;
1442
case RISCVVector::BI__builtin_rvv_vfncvt_rtz_x_f_w_tumu:
1443
  ID = Intrinsic::riscv_vfncvt_rtz_x_f_w_mask;
1444
  PolicyAttrs = 0;
1445
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1446
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1447
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1448
  break;
1449
case RISCVVector::BI__builtin_rvv_vfncvt_rtz_x_f_w_mu:
1450
  ID = Intrinsic::riscv_vfncvt_rtz_x_f_w_mask;
1451
  PolicyAttrs = 1;
1452
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1453
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1454
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1455
  break;
1456
case RISCVVector::BI__builtin_rvv_vfncvt_rtz_xu_f_w_tu:
1457
  ID = Intrinsic::riscv_vfncvt_rtz_xu_f_w;
1458
  PolicyAttrs = 2;
1459
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1460
  break;
1461
case RISCVVector::BI__builtin_rvv_vfncvt_rtz_xu_f_w_ta:
1462
  ID = Intrinsic::riscv_vfncvt_rtz_xu_f_w;
1463
  PolicyAttrs = 3;
1464
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1465
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1466
  break;
1467
case RISCVVector::BI__builtin_rvv_vfncvt_rtz_xu_f_w_tum:
1468
  ID = Intrinsic::riscv_vfncvt_rtz_xu_f_w_mask;
1469
  PolicyAttrs = 2;
1470
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1471
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1472
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1473
  break;
1474
case RISCVVector::BI__builtin_rvv_vfncvt_rtz_xu_f_w_tama:
1475
  ID = Intrinsic::riscv_vfncvt_rtz_xu_f_w_mask;
1476
  PolicyAttrs = 3;
1477
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1478
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1479
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1480
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1481
  break;
1482
case RISCVVector::BI__builtin_rvv_vfncvt_rtz_xu_f_w_tumu:
1483
  ID = Intrinsic::riscv_vfncvt_rtz_xu_f_w_mask;
1484
  PolicyAttrs = 0;
1485
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1486
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1487
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1488
  break;
1489
case RISCVVector::BI__builtin_rvv_vfncvt_rtz_xu_f_w_mu:
1490
  ID = Intrinsic::riscv_vfncvt_rtz_xu_f_w_mask;
1491
  PolicyAttrs = 1;
1492
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1493
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1494
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1495
  break;
1496
case RISCVVector::BI__builtin_rvv_vfncvt_x_f_w_tu:
1497
  ID = Intrinsic::riscv_vfncvt_x_f_w;
1498
  PolicyAttrs = 2;
1499
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1500
  break;
1501
case RISCVVector::BI__builtin_rvv_vfncvt_x_f_w_ta:
1502
  ID = Intrinsic::riscv_vfncvt_x_f_w;
1503
  PolicyAttrs = 3;
1504
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1505
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1506
  break;
1507
case RISCVVector::BI__builtin_rvv_vfncvt_x_f_w_tum:
1508
  ID = Intrinsic::riscv_vfncvt_x_f_w_mask;
1509
  PolicyAttrs = 2;
1510
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1511
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1512
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1513
  break;
1514
case RISCVVector::BI__builtin_rvv_vfncvt_x_f_w_tama:
1515
  ID = Intrinsic::riscv_vfncvt_x_f_w_mask;
1516
  PolicyAttrs = 3;
1517
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1518
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1519
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1520
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1521
  break;
1522
case RISCVVector::BI__builtin_rvv_vfncvt_x_f_w_tumu:
1523
  ID = Intrinsic::riscv_vfncvt_x_f_w_mask;
1524
  PolicyAttrs = 0;
1525
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1526
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1527
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1528
  break;
1529
case RISCVVector::BI__builtin_rvv_vfncvt_x_f_w_mu:
1530
  ID = Intrinsic::riscv_vfncvt_x_f_w_mask;
1531
  PolicyAttrs = 1;
1532
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1533
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1534
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1535
  break;
1536
case RISCVVector::BI__builtin_rvv_vfncvt_xu_f_w_tu:
1537
  ID = Intrinsic::riscv_vfncvt_xu_f_w;
1538
  PolicyAttrs = 2;
1539
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1540
  break;
1541
case RISCVVector::BI__builtin_rvv_vfncvt_xu_f_w_ta:
1542
  ID = Intrinsic::riscv_vfncvt_xu_f_w;
1543
  PolicyAttrs = 3;
1544
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1545
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1546
  break;
1547
case RISCVVector::BI__builtin_rvv_vfncvt_xu_f_w_tum:
1548
  ID = Intrinsic::riscv_vfncvt_xu_f_w_mask;
1549
  PolicyAttrs = 2;
1550
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1551
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1552
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1553
  break;
1554
case RISCVVector::BI__builtin_rvv_vfncvt_xu_f_w_tama:
1555
  ID = Intrinsic::riscv_vfncvt_xu_f_w_mask;
1556
  PolicyAttrs = 3;
1557
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1558
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1559
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1560
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1561
  break;
1562
case RISCVVector::BI__builtin_rvv_vfncvt_xu_f_w_tumu:
1563
  ID = Intrinsic::riscv_vfncvt_xu_f_w_mask;
1564
  PolicyAttrs = 0;
1565
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1566
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1567
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1568
  break;
1569
case RISCVVector::BI__builtin_rvv_vfncvt_xu_f_w_mu:
1570
  ID = Intrinsic::riscv_vfncvt_xu_f_w_mask;
1571
  PolicyAttrs = 1;
1572
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1573
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1574
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1575
  break;
1576
case RISCVVector::BI__builtin_rvv_vfnmacc_vv_tu:
1577
case RISCVVector::BI__builtin_rvv_vfnmacc_vf_tu:
1578
  ID = Intrinsic::riscv_vfnmacc;
1579
  PolicyAttrs = 2;
1580
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1581
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1582
  break;
1583
case RISCVVector::BI__builtin_rvv_vfnmacc_vv_ta:
1584
case RISCVVector::BI__builtin_rvv_vfnmacc_vf_ta:
1585
  ID = Intrinsic::riscv_vfnmacc;
1586
  PolicyAttrs = 3;
1587
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1588
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1589
  break;
1590
case RISCVVector::BI__builtin_rvv_vfnmacc_vv_tum:
1591
case RISCVVector::BI__builtin_rvv_vfnmacc_vf_tum:
1592
  ID = Intrinsic::riscv_vfnmacc_mask;
1593
  PolicyAttrs = 2;
1594
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1595
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1596
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1597
  break;
1598
case RISCVVector::BI__builtin_rvv_vfnmacc_vv_tama:
1599
case RISCVVector::BI__builtin_rvv_vfnmacc_vf_tama:
1600
  ID = Intrinsic::riscv_vfnmacc_mask;
1601
  PolicyAttrs = 3;
1602
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1603
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1604
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1605
  break;
1606
case RISCVVector::BI__builtin_rvv_vfnmacc_vv_tumu:
1607
case RISCVVector::BI__builtin_rvv_vfnmacc_vf_tumu:
1608
  ID = Intrinsic::riscv_vfnmacc_mask;
1609
  PolicyAttrs = 0;
1610
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1611
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1612
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1613
  break;
1614
case RISCVVector::BI__builtin_rvv_vfnmacc_vv_mu:
1615
case RISCVVector::BI__builtin_rvv_vfnmacc_vf_mu:
1616
  ID = Intrinsic::riscv_vfnmacc_mask;
1617
  PolicyAttrs = 1;
1618
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1619
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1620
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1621
  break;
1622
case RISCVVector::BI__builtin_rvv_vfnmadd_vv_tu:
1623
case RISCVVector::BI__builtin_rvv_vfnmadd_vf_tu:
1624
  ID = Intrinsic::riscv_vfnmadd;
1625
  PolicyAttrs = 2;
1626
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1627
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1628
  break;
1629
case RISCVVector::BI__builtin_rvv_vfnmadd_vv_ta:
1630
case RISCVVector::BI__builtin_rvv_vfnmadd_vf_ta:
1631
  ID = Intrinsic::riscv_vfnmadd;
1632
  PolicyAttrs = 3;
1633
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1634
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1635
  break;
1636
case RISCVVector::BI__builtin_rvv_vfnmadd_vv_tum:
1637
case RISCVVector::BI__builtin_rvv_vfnmadd_vf_tum:
1638
  ID = Intrinsic::riscv_vfnmadd_mask;
1639
  PolicyAttrs = 2;
1640
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1641
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1642
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1643
  break;
1644
case RISCVVector::BI__builtin_rvv_vfnmadd_vv_tama:
1645
case RISCVVector::BI__builtin_rvv_vfnmadd_vf_tama:
1646
  ID = Intrinsic::riscv_vfnmadd_mask;
1647
  PolicyAttrs = 3;
1648
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1649
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1650
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1651
  break;
1652
case RISCVVector::BI__builtin_rvv_vfnmadd_vv_tumu:
1653
case RISCVVector::BI__builtin_rvv_vfnmadd_vf_tumu:
1654
  ID = Intrinsic::riscv_vfnmadd_mask;
1655
  PolicyAttrs = 0;
1656
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1657
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1658
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1659
  break;
1660
case RISCVVector::BI__builtin_rvv_vfnmadd_vv_mu:
1661
case RISCVVector::BI__builtin_rvv_vfnmadd_vf_mu:
1662
  ID = Intrinsic::riscv_vfnmadd_mask;
1663
  PolicyAttrs = 1;
1664
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1665
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1666
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1667
  break;
1668
case RISCVVector::BI__builtin_rvv_vfnmsac_vv_tu:
1669
case RISCVVector::BI__builtin_rvv_vfnmsac_vf_tu:
1670
  ID = Intrinsic::riscv_vfnmsac;
1671
  PolicyAttrs = 2;
1672
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1673
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1674
  break;
1675
case RISCVVector::BI__builtin_rvv_vfnmsac_vv_ta:
1676
case RISCVVector::BI__builtin_rvv_vfnmsac_vf_ta:
1677
  ID = Intrinsic::riscv_vfnmsac;
1678
  PolicyAttrs = 3;
1679
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1680
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1681
  break;
1682
case RISCVVector::BI__builtin_rvv_vfnmsac_vv_tum:
1683
case RISCVVector::BI__builtin_rvv_vfnmsac_vf_tum:
1684
  ID = Intrinsic::riscv_vfnmsac_mask;
1685
  PolicyAttrs = 2;
1686
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1687
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1688
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1689
  break;
1690
case RISCVVector::BI__builtin_rvv_vfnmsac_vv_tama:
1691
case RISCVVector::BI__builtin_rvv_vfnmsac_vf_tama:
1692
  ID = Intrinsic::riscv_vfnmsac_mask;
1693
  PolicyAttrs = 3;
1694
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1695
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1696
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1697
  break;
1698
case RISCVVector::BI__builtin_rvv_vfnmsac_vv_tumu:
1699
case RISCVVector::BI__builtin_rvv_vfnmsac_vf_tumu:
1700
  ID = Intrinsic::riscv_vfnmsac_mask;
1701
  PolicyAttrs = 0;
1702
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1703
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1704
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1705
  break;
1706
case RISCVVector::BI__builtin_rvv_vfnmsac_vv_mu:
1707
case RISCVVector::BI__builtin_rvv_vfnmsac_vf_mu:
1708
  ID = Intrinsic::riscv_vfnmsac_mask;
1709
  PolicyAttrs = 1;
1710
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1711
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1712
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1713
  break;
1714
case RISCVVector::BI__builtin_rvv_vfnmsub_vv_tu:
1715
case RISCVVector::BI__builtin_rvv_vfnmsub_vf_tu:
1716
  ID = Intrinsic::riscv_vfnmsub;
1717
  PolicyAttrs = 2;
1718
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1719
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1720
  break;
1721
case RISCVVector::BI__builtin_rvv_vfnmsub_vv_ta:
1722
case RISCVVector::BI__builtin_rvv_vfnmsub_vf_ta:
1723
  ID = Intrinsic::riscv_vfnmsub;
1724
  PolicyAttrs = 3;
1725
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1726
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1727
  break;
1728
case RISCVVector::BI__builtin_rvv_vfnmsub_vv_tum:
1729
case RISCVVector::BI__builtin_rvv_vfnmsub_vf_tum:
1730
  ID = Intrinsic::riscv_vfnmsub_mask;
1731
  PolicyAttrs = 2;
1732
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1733
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1734
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1735
  break;
1736
case RISCVVector::BI__builtin_rvv_vfnmsub_vv_tama:
1737
case RISCVVector::BI__builtin_rvv_vfnmsub_vf_tama:
1738
  ID = Intrinsic::riscv_vfnmsub_mask;
1739
  PolicyAttrs = 3;
1740
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1741
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1742
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1743
  break;
1744
case RISCVVector::BI__builtin_rvv_vfnmsub_vv_tumu:
1745
case RISCVVector::BI__builtin_rvv_vfnmsub_vf_tumu:
1746
  ID = Intrinsic::riscv_vfnmsub_mask;
1747
  PolicyAttrs = 0;
1748
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1749
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1750
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1751
  break;
1752
case RISCVVector::BI__builtin_rvv_vfnmsub_vv_mu:
1753
case RISCVVector::BI__builtin_rvv_vfnmsub_vf_mu:
1754
  ID = Intrinsic::riscv_vfnmsub_mask;
1755
  PolicyAttrs = 1;
1756
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1757
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1758
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1759
  break;
1760
case RISCVVector::BI__builtin_rvv_vfrdiv_vf_tu:
1761
  ID = Intrinsic::riscv_vfrdiv;
1762
  PolicyAttrs = 2;
1763
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
1764
  break;
1765
case RISCVVector::BI__builtin_rvv_vfrdiv_vf_ta:
1766
  ID = Intrinsic::riscv_vfrdiv;
1767
  PolicyAttrs = 3;
1768
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1769
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
1770
  break;
1771
case RISCVVector::BI__builtin_rvv_vfrdiv_vf_tum:
1772
  ID = Intrinsic::riscv_vfrdiv_mask;
1773
  PolicyAttrs = 2;
1774
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1775
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1776
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
1777
  break;
1778
case RISCVVector::BI__builtin_rvv_vfrdiv_vf_tama:
1779
  ID = Intrinsic::riscv_vfrdiv_mask;
1780
  PolicyAttrs = 3;
1781
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1782
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1783
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1784
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
1785
  break;
1786
case RISCVVector::BI__builtin_rvv_vfrdiv_vf_tumu:
1787
  ID = Intrinsic::riscv_vfrdiv_mask;
1788
  PolicyAttrs = 0;
1789
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1790
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1791
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
1792
  break;
1793
case RISCVVector::BI__builtin_rvv_vfrdiv_vf_mu:
1794
  ID = Intrinsic::riscv_vfrdiv_mask;
1795
  PolicyAttrs = 1;
1796
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1797
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1798
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
1799
  break;
1800
case RISCVVector::BI__builtin_rvv_vfrec7_v_tu:
1801
  ID = Intrinsic::riscv_vfrec7;
1802
  PolicyAttrs = 2;
1803
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
1804
  break;
1805
case RISCVVector::BI__builtin_rvv_vfrec7_v_ta:
1806
  ID = Intrinsic::riscv_vfrec7;
1807
  PolicyAttrs = 3;
1808
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1809
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
1810
  break;
1811
case RISCVVector::BI__builtin_rvv_vfrec7_v_tum:
1812
  ID = Intrinsic::riscv_vfrec7_mask;
1813
  PolicyAttrs = 2;
1814
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1815
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1816
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
1817
  break;
1818
case RISCVVector::BI__builtin_rvv_vfrec7_v_tama:
1819
  ID = Intrinsic::riscv_vfrec7_mask;
1820
  PolicyAttrs = 3;
1821
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1822
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1823
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1824
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
1825
  break;
1826
case RISCVVector::BI__builtin_rvv_vfrec7_v_tumu:
1827
  ID = Intrinsic::riscv_vfrec7_mask;
1828
  PolicyAttrs = 0;
1829
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1830
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1831
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
1832
  break;
1833
case RISCVVector::BI__builtin_rvv_vfrec7_v_mu:
1834
  ID = Intrinsic::riscv_vfrec7_mask;
1835
  PolicyAttrs = 1;
1836
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1837
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1838
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
1839
  break;
1840
case RISCVVector::BI__builtin_rvv_vfredmax_vs_tu:
1841
  ID = Intrinsic::riscv_vfredmax;
1842
  PolicyAttrs = 2;
1843
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1844
  break;
1845
case RISCVVector::BI__builtin_rvv_vfredmax_vs_ta:
1846
  ID = Intrinsic::riscv_vfredmax;
1847
  PolicyAttrs = 3;
1848
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1849
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1850
  break;
1851
case RISCVVector::BI__builtin_rvv_vfredmax_vs_tum:
1852
  ID = Intrinsic::riscv_vfredmax_mask;
1853
  PolicyAttrs = 2;
1854
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1855
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1856
  break;
1857
case RISCVVector::BI__builtin_rvv_vfredmax_vs_tama:
1858
  ID = Intrinsic::riscv_vfredmax_mask;
1859
  PolicyAttrs = 3;
1860
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1861
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1862
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1863
  break;
1864
case RISCVVector::BI__builtin_rvv_vfredmin_vs_tu:
1865
  ID = Intrinsic::riscv_vfredmin;
1866
  PolicyAttrs = 2;
1867
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1868
  break;
1869
case RISCVVector::BI__builtin_rvv_vfredmin_vs_ta:
1870
  ID = Intrinsic::riscv_vfredmin;
1871
  PolicyAttrs = 3;
1872
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1873
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1874
  break;
1875
case RISCVVector::BI__builtin_rvv_vfredmin_vs_tum:
1876
  ID = Intrinsic::riscv_vfredmin_mask;
1877
  PolicyAttrs = 2;
1878
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1879
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1880
  break;
1881
case RISCVVector::BI__builtin_rvv_vfredmin_vs_tama:
1882
  ID = Intrinsic::riscv_vfredmin_mask;
1883
  PolicyAttrs = 3;
1884
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1885
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1886
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1887
  break;
1888
case RISCVVector::BI__builtin_rvv_vfredosum_vs_tu:
1889
  ID = Intrinsic::riscv_vfredosum;
1890
  PolicyAttrs = 2;
1891
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1892
  break;
1893
case RISCVVector::BI__builtin_rvv_vfredosum_vs_ta:
1894
  ID = Intrinsic::riscv_vfredosum;
1895
  PolicyAttrs = 3;
1896
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1897
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1898
  break;
1899
case RISCVVector::BI__builtin_rvv_vfredosum_vs_tum:
1900
  ID = Intrinsic::riscv_vfredosum_mask;
1901
  PolicyAttrs = 2;
1902
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1903
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1904
  break;
1905
case RISCVVector::BI__builtin_rvv_vfredosum_vs_tama:
1906
  ID = Intrinsic::riscv_vfredosum_mask;
1907
  PolicyAttrs = 3;
1908
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1909
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1910
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1911
  break;
1912
case RISCVVector::BI__builtin_rvv_vfredusum_vs_tu:
1913
  ID = Intrinsic::riscv_vfredusum;
1914
  PolicyAttrs = 2;
1915
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1916
  break;
1917
case RISCVVector::BI__builtin_rvv_vfredusum_vs_ta:
1918
  ID = Intrinsic::riscv_vfredusum;
1919
  PolicyAttrs = 3;
1920
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1921
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1922
  break;
1923
case RISCVVector::BI__builtin_rvv_vfredusum_vs_tum:
1924
  ID = Intrinsic::riscv_vfredusum_mask;
1925
  PolicyAttrs = 2;
1926
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1927
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1928
  break;
1929
case RISCVVector::BI__builtin_rvv_vfredusum_vs_tama:
1930
  ID = Intrinsic::riscv_vfredusum_mask;
1931
  PolicyAttrs = 3;
1932
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1933
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1934
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
1935
  break;
1936
case RISCVVector::BI__builtin_rvv_vfrsqrt7_v_tu:
1937
  ID = Intrinsic::riscv_vfrsqrt7;
1938
  PolicyAttrs = 2;
1939
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
1940
  break;
1941
case RISCVVector::BI__builtin_rvv_vfrsqrt7_v_ta:
1942
  ID = Intrinsic::riscv_vfrsqrt7;
1943
  PolicyAttrs = 3;
1944
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1945
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
1946
  break;
1947
case RISCVVector::BI__builtin_rvv_vfrsqrt7_v_tum:
1948
  ID = Intrinsic::riscv_vfrsqrt7_mask;
1949
  PolicyAttrs = 2;
1950
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1951
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1952
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
1953
  break;
1954
case RISCVVector::BI__builtin_rvv_vfrsqrt7_v_tama:
1955
  ID = Intrinsic::riscv_vfrsqrt7_mask;
1956
  PolicyAttrs = 3;
1957
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1958
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1959
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1960
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
1961
  break;
1962
case RISCVVector::BI__builtin_rvv_vfrsqrt7_v_tumu:
1963
  ID = Intrinsic::riscv_vfrsqrt7_mask;
1964
  PolicyAttrs = 0;
1965
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1966
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1967
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
1968
  break;
1969
case RISCVVector::BI__builtin_rvv_vfrsqrt7_v_mu:
1970
  ID = Intrinsic::riscv_vfrsqrt7_mask;
1971
  PolicyAttrs = 1;
1972
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1973
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1974
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
1975
  break;
1976
case RISCVVector::BI__builtin_rvv_vfrsub_vf_tu:
1977
  ID = Intrinsic::riscv_vfrsub;
1978
  PolicyAttrs = 2;
1979
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
1980
  break;
1981
case RISCVVector::BI__builtin_rvv_vfrsub_vf_ta:
1982
  ID = Intrinsic::riscv_vfrsub;
1983
  PolicyAttrs = 3;
1984
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
1985
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
1986
  break;
1987
case RISCVVector::BI__builtin_rvv_vfrsub_vf_tum:
1988
  ID = Intrinsic::riscv_vfrsub_mask;
1989
  PolicyAttrs = 2;
1990
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1991
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1992
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
1993
  break;
1994
case RISCVVector::BI__builtin_rvv_vfrsub_vf_tama:
1995
  ID = Intrinsic::riscv_vfrsub_mask;
1996
  PolicyAttrs = 3;
1997
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
1998
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
1999
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2000
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2001
  break;
2002
case RISCVVector::BI__builtin_rvv_vfrsub_vf_tumu:
2003
  ID = Intrinsic::riscv_vfrsub_mask;
2004
  PolicyAttrs = 0;
2005
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2006
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2007
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2008
  break;
2009
case RISCVVector::BI__builtin_rvv_vfrsub_vf_mu:
2010
  ID = Intrinsic::riscv_vfrsub_mask;
2011
  PolicyAttrs = 1;
2012
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2013
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2014
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2015
  break;
2016
case RISCVVector::BI__builtin_rvv_vfsgnj_vv_tu:
2017
case RISCVVector::BI__builtin_rvv_vfsgnj_vf_tu:
2018
  ID = Intrinsic::riscv_vfsgnj;
2019
  PolicyAttrs = 2;
2020
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2021
  break;
2022
case RISCVVector::BI__builtin_rvv_vfsgnj_vv_ta:
2023
case RISCVVector::BI__builtin_rvv_vfsgnj_vf_ta:
2024
  ID = Intrinsic::riscv_vfsgnj;
2025
  PolicyAttrs = 3;
2026
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2027
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2028
  break;
2029
case RISCVVector::BI__builtin_rvv_vfsgnj_vv_tum:
2030
case RISCVVector::BI__builtin_rvv_vfsgnj_vf_tum:
2031
  ID = Intrinsic::riscv_vfsgnj_mask;
2032
  PolicyAttrs = 2;
2033
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2034
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2035
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2036
  break;
2037
case RISCVVector::BI__builtin_rvv_vfsgnj_vv_tama:
2038
case RISCVVector::BI__builtin_rvv_vfsgnj_vf_tama:
2039
  ID = Intrinsic::riscv_vfsgnj_mask;
2040
  PolicyAttrs = 3;
2041
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2042
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2043
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2044
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2045
  break;
2046
case RISCVVector::BI__builtin_rvv_vfsgnj_vv_tumu:
2047
case RISCVVector::BI__builtin_rvv_vfsgnj_vf_tumu:
2048
  ID = Intrinsic::riscv_vfsgnj_mask;
2049
  PolicyAttrs = 0;
2050
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2051
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2052
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2053
  break;
2054
case RISCVVector::BI__builtin_rvv_vfsgnj_vv_mu:
2055
case RISCVVector::BI__builtin_rvv_vfsgnj_vf_mu:
2056
  ID = Intrinsic::riscv_vfsgnj_mask;
2057
  PolicyAttrs = 1;
2058
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2059
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2060
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2061
  break;
2062
case RISCVVector::BI__builtin_rvv_vfsgnjn_vv_tu:
2063
case RISCVVector::BI__builtin_rvv_vfsgnjn_vf_tu:
2064
  ID = Intrinsic::riscv_vfsgnjn;
2065
  PolicyAttrs = 2;
2066
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2067
  break;
2068
case RISCVVector::BI__builtin_rvv_vfneg_v_tu:
2069
  ID = Intrinsic::riscv_vfsgnjn;
2070
  PolicyAttrs = 2;
2071
IsMasked = false;
2072
 
2073
      {
2074
        if (IsMasked) {
2075
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2076
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
2077
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2078
          Ops.insert(Ops.begin() + 2, Ops[1]);
2079
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2080
          // maskedoff, op1, op2, mask, vl
2081
          IntrinsicTypes = {ResultType,
2082
                            Ops[2]->getType(),
2083
                            Ops.back()->getType()};
2084
        } else {
2085
          if (PolicyAttrs & RVV_VTA)
2086
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2087
          // op1, po2, vl
2088
          IntrinsicTypes = {ResultType,
2089
                            Ops[1]->getType(), Ops[2]->getType()};
2090
          Ops.insert(Ops.begin() + 2, Ops[1]);
2091
          break;
2092
        }
2093
        break;
2094
      }
2095
      break;
2096
case RISCVVector::BI__builtin_rvv_vfsgnjn_vv_ta:
2097
case RISCVVector::BI__builtin_rvv_vfsgnjn_vf_ta:
2098
  ID = Intrinsic::riscv_vfsgnjn;
2099
  PolicyAttrs = 3;
2100
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2101
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2102
  break;
2103
case RISCVVector::BI__builtin_rvv_vfneg_v_ta:
2104
  ID = Intrinsic::riscv_vfsgnjn;
2105
  PolicyAttrs = 3;
2106
IsMasked = false;
2107
 
2108
      {
2109
        if (IsMasked) {
2110
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2111
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
2112
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2113
          Ops.insert(Ops.begin() + 2, Ops[1]);
2114
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2115
          // maskedoff, op1, op2, mask, vl
2116
          IntrinsicTypes = {ResultType,
2117
                            Ops[2]->getType(),
2118
                            Ops.back()->getType()};
2119
        } else {
2120
          if (PolicyAttrs & RVV_VTA)
2121
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2122
          // op1, po2, vl
2123
          IntrinsicTypes = {ResultType,
2124
                            Ops[1]->getType(), Ops[2]->getType()};
2125
          Ops.insert(Ops.begin() + 2, Ops[1]);
2126
          break;
2127
        }
2128
        break;
2129
      }
2130
      break;
2131
case RISCVVector::BI__builtin_rvv_vfsgnjn_vv_tum:
2132
case RISCVVector::BI__builtin_rvv_vfsgnjn_vf_tum:
2133
  ID = Intrinsic::riscv_vfsgnjn_mask;
2134
  PolicyAttrs = 2;
2135
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2136
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2137
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2138
  break;
2139
case RISCVVector::BI__builtin_rvv_vfneg_v_tum:
2140
  ID = Intrinsic::riscv_vfsgnjn_mask;
2141
  PolicyAttrs = 2;
2142
IsMasked = true;
2143
 
2144
      {
2145
        if (IsMasked) {
2146
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2147
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
2148
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2149
          Ops.insert(Ops.begin() + 2, Ops[1]);
2150
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2151
          // maskedoff, op1, op2, mask, vl
2152
          IntrinsicTypes = {ResultType,
2153
                            Ops[2]->getType(),
2154
                            Ops.back()->getType()};
2155
        } else {
2156
          if (PolicyAttrs & RVV_VTA)
2157
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2158
          // op1, po2, vl
2159
          IntrinsicTypes = {ResultType,
2160
                            Ops[1]->getType(), Ops[2]->getType()};
2161
          Ops.insert(Ops.begin() + 2, Ops[1]);
2162
          break;
2163
        }
2164
        break;
2165
      }
2166
      break;
2167
case RISCVVector::BI__builtin_rvv_vfsgnjn_vv_tama:
2168
case RISCVVector::BI__builtin_rvv_vfsgnjn_vf_tama:
2169
  ID = Intrinsic::riscv_vfsgnjn_mask;
2170
  PolicyAttrs = 3;
2171
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2172
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2173
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2174
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2175
  break;
2176
case RISCVVector::BI__builtin_rvv_vfneg_v_tama:
2177
  ID = Intrinsic::riscv_vfsgnjn_mask;
2178
  PolicyAttrs = 3;
2179
IsMasked = true;
2180
 
2181
      {
2182
        if (IsMasked) {
2183
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2184
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
2185
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2186
          Ops.insert(Ops.begin() + 2, Ops[1]);
2187
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2188
          // maskedoff, op1, op2, mask, vl
2189
          IntrinsicTypes = {ResultType,
2190
                            Ops[2]->getType(),
2191
                            Ops.back()->getType()};
2192
        } else {
2193
          if (PolicyAttrs & RVV_VTA)
2194
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2195
          // op1, po2, vl
2196
          IntrinsicTypes = {ResultType,
2197
                            Ops[1]->getType(), Ops[2]->getType()};
2198
          Ops.insert(Ops.begin() + 2, Ops[1]);
2199
          break;
2200
        }
2201
        break;
2202
      }
2203
      break;
2204
case RISCVVector::BI__builtin_rvv_vfsgnjn_vv_tumu:
2205
case RISCVVector::BI__builtin_rvv_vfsgnjn_vf_tumu:
2206
  ID = Intrinsic::riscv_vfsgnjn_mask;
2207
  PolicyAttrs = 0;
2208
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2209
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2210
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2211
  break;
2212
case RISCVVector::BI__builtin_rvv_vfneg_v_tumu:
2213
  ID = Intrinsic::riscv_vfsgnjn_mask;
2214
  PolicyAttrs = 0;
2215
IsMasked = true;
2216
 
2217
      {
2218
        if (IsMasked) {
2219
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2220
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
2221
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2222
          Ops.insert(Ops.begin() + 2, Ops[1]);
2223
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2224
          // maskedoff, op1, op2, mask, vl
2225
          IntrinsicTypes = {ResultType,
2226
                            Ops[2]->getType(),
2227
                            Ops.back()->getType()};
2228
        } else {
2229
          if (PolicyAttrs & RVV_VTA)
2230
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2231
          // op1, po2, vl
2232
          IntrinsicTypes = {ResultType,
2233
                            Ops[1]->getType(), Ops[2]->getType()};
2234
          Ops.insert(Ops.begin() + 2, Ops[1]);
2235
          break;
2236
        }
2237
        break;
2238
      }
2239
      break;
2240
case RISCVVector::BI__builtin_rvv_vfsgnjn_vv_mu:
2241
case RISCVVector::BI__builtin_rvv_vfsgnjn_vf_mu:
2242
  ID = Intrinsic::riscv_vfsgnjn_mask;
2243
  PolicyAttrs = 1;
2244
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2245
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2246
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2247
  break;
2248
case RISCVVector::BI__builtin_rvv_vfneg_v_mu:
2249
  ID = Intrinsic::riscv_vfsgnjn_mask;
2250
  PolicyAttrs = 1;
2251
IsMasked = true;
2252
 
2253
      {
2254
        if (IsMasked) {
2255
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2256
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
2257
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2258
          Ops.insert(Ops.begin() + 2, Ops[1]);
2259
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2260
          // maskedoff, op1, op2, mask, vl
2261
          IntrinsicTypes = {ResultType,
2262
                            Ops[2]->getType(),
2263
                            Ops.back()->getType()};
2264
        } else {
2265
          if (PolicyAttrs & RVV_VTA)
2266
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2267
          // op1, po2, vl
2268
          IntrinsicTypes = {ResultType,
2269
                            Ops[1]->getType(), Ops[2]->getType()};
2270
          Ops.insert(Ops.begin() + 2, Ops[1]);
2271
          break;
2272
        }
2273
        break;
2274
      }
2275
      break;
2276
case RISCVVector::BI__builtin_rvv_vfsgnjx_vv_tu:
2277
case RISCVVector::BI__builtin_rvv_vfsgnjx_vf_tu:
2278
  ID = Intrinsic::riscv_vfsgnjx;
2279
  PolicyAttrs = 2;
2280
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2281
  break;
2282
case RISCVVector::BI__builtin_rvv_vfabs_v_tu:
2283
  ID = Intrinsic::riscv_vfsgnjx;
2284
  PolicyAttrs = 2;
2285
IsMasked = false;
2286
 
2287
      {
2288
        if (IsMasked) {
2289
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2290
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
2291
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2292
          Ops.insert(Ops.begin() + 2, Ops[1]);
2293
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2294
          // maskedoff, op1, op2, mask, vl
2295
          IntrinsicTypes = {ResultType,
2296
                            Ops[2]->getType(),
2297
                            Ops.back()->getType()};
2298
        } else {
2299
          if (PolicyAttrs & RVV_VTA)
2300
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2301
          // op1, po2, vl
2302
          IntrinsicTypes = {ResultType,
2303
                            Ops[1]->getType(), Ops[2]->getType()};
2304
          Ops.insert(Ops.begin() + 2, Ops[1]);
2305
          break;
2306
        }
2307
        break;
2308
      }
2309
      break;
2310
case RISCVVector::BI__builtin_rvv_vfsgnjx_vv_ta:
2311
case RISCVVector::BI__builtin_rvv_vfsgnjx_vf_ta:
2312
  ID = Intrinsic::riscv_vfsgnjx;
2313
  PolicyAttrs = 3;
2314
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2315
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2316
  break;
2317
case RISCVVector::BI__builtin_rvv_vfabs_v_ta:
2318
  ID = Intrinsic::riscv_vfsgnjx;
2319
  PolicyAttrs = 3;
2320
IsMasked = false;
2321
 
2322
      {
2323
        if (IsMasked) {
2324
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2325
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
2326
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2327
          Ops.insert(Ops.begin() + 2, Ops[1]);
2328
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2329
          // maskedoff, op1, op2, mask, vl
2330
          IntrinsicTypes = {ResultType,
2331
                            Ops[2]->getType(),
2332
                            Ops.back()->getType()};
2333
        } else {
2334
          if (PolicyAttrs & RVV_VTA)
2335
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2336
          // op1, po2, vl
2337
          IntrinsicTypes = {ResultType,
2338
                            Ops[1]->getType(), Ops[2]->getType()};
2339
          Ops.insert(Ops.begin() + 2, Ops[1]);
2340
          break;
2341
        }
2342
        break;
2343
      }
2344
      break;
2345
case RISCVVector::BI__builtin_rvv_vfsgnjx_vv_tum:
2346
case RISCVVector::BI__builtin_rvv_vfsgnjx_vf_tum:
2347
  ID = Intrinsic::riscv_vfsgnjx_mask;
2348
  PolicyAttrs = 2;
2349
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2350
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2351
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2352
  break;
2353
case RISCVVector::BI__builtin_rvv_vfabs_v_tum:
2354
  ID = Intrinsic::riscv_vfsgnjx_mask;
2355
  PolicyAttrs = 2;
2356
IsMasked = true;
2357
 
2358
      {
2359
        if (IsMasked) {
2360
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2361
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
2362
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2363
          Ops.insert(Ops.begin() + 2, Ops[1]);
2364
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2365
          // maskedoff, op1, op2, mask, vl
2366
          IntrinsicTypes = {ResultType,
2367
                            Ops[2]->getType(),
2368
                            Ops.back()->getType()};
2369
        } else {
2370
          if (PolicyAttrs & RVV_VTA)
2371
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2372
          // op1, po2, vl
2373
          IntrinsicTypes = {ResultType,
2374
                            Ops[1]->getType(), Ops[2]->getType()};
2375
          Ops.insert(Ops.begin() + 2, Ops[1]);
2376
          break;
2377
        }
2378
        break;
2379
      }
2380
      break;
2381
case RISCVVector::BI__builtin_rvv_vfsgnjx_vv_tama:
2382
case RISCVVector::BI__builtin_rvv_vfsgnjx_vf_tama:
2383
  ID = Intrinsic::riscv_vfsgnjx_mask;
2384
  PolicyAttrs = 3;
2385
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2386
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2387
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2388
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2389
  break;
2390
case RISCVVector::BI__builtin_rvv_vfabs_v_tama:
2391
  ID = Intrinsic::riscv_vfsgnjx_mask;
2392
  PolicyAttrs = 3;
2393
IsMasked = true;
2394
 
2395
      {
2396
        if (IsMasked) {
2397
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2398
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
2399
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2400
          Ops.insert(Ops.begin() + 2, Ops[1]);
2401
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2402
          // maskedoff, op1, op2, mask, vl
2403
          IntrinsicTypes = {ResultType,
2404
                            Ops[2]->getType(),
2405
                            Ops.back()->getType()};
2406
        } else {
2407
          if (PolicyAttrs & RVV_VTA)
2408
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2409
          // op1, po2, vl
2410
          IntrinsicTypes = {ResultType,
2411
                            Ops[1]->getType(), Ops[2]->getType()};
2412
          Ops.insert(Ops.begin() + 2, Ops[1]);
2413
          break;
2414
        }
2415
        break;
2416
      }
2417
      break;
2418
case RISCVVector::BI__builtin_rvv_vfsgnjx_vv_tumu:
2419
case RISCVVector::BI__builtin_rvv_vfsgnjx_vf_tumu:
2420
  ID = Intrinsic::riscv_vfsgnjx_mask;
2421
  PolicyAttrs = 0;
2422
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2423
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2424
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2425
  break;
2426
case RISCVVector::BI__builtin_rvv_vfabs_v_tumu:
2427
  ID = Intrinsic::riscv_vfsgnjx_mask;
2428
  PolicyAttrs = 0;
2429
IsMasked = true;
2430
 
2431
      {
2432
        if (IsMasked) {
2433
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2434
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
2435
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2436
          Ops.insert(Ops.begin() + 2, Ops[1]);
2437
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2438
          // maskedoff, op1, op2, mask, vl
2439
          IntrinsicTypes = {ResultType,
2440
                            Ops[2]->getType(),
2441
                            Ops.back()->getType()};
2442
        } else {
2443
          if (PolicyAttrs & RVV_VTA)
2444
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2445
          // op1, po2, vl
2446
          IntrinsicTypes = {ResultType,
2447
                            Ops[1]->getType(), Ops[2]->getType()};
2448
          Ops.insert(Ops.begin() + 2, Ops[1]);
2449
          break;
2450
        }
2451
        break;
2452
      }
2453
      break;
2454
case RISCVVector::BI__builtin_rvv_vfsgnjx_vv_mu:
2455
case RISCVVector::BI__builtin_rvv_vfsgnjx_vf_mu:
2456
  ID = Intrinsic::riscv_vfsgnjx_mask;
2457
  PolicyAttrs = 1;
2458
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2459
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2460
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2461
  break;
2462
case RISCVVector::BI__builtin_rvv_vfabs_v_mu:
2463
  ID = Intrinsic::riscv_vfsgnjx_mask;
2464
  PolicyAttrs = 1;
2465
IsMasked = true;
2466
 
2467
      {
2468
        if (IsMasked) {
2469
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2470
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
2471
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2472
          Ops.insert(Ops.begin() + 2, Ops[1]);
2473
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2474
          // maskedoff, op1, op2, mask, vl
2475
          IntrinsicTypes = {ResultType,
2476
                            Ops[2]->getType(),
2477
                            Ops.back()->getType()};
2478
        } else {
2479
          if (PolicyAttrs & RVV_VTA)
2480
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2481
          // op1, po2, vl
2482
          IntrinsicTypes = {ResultType,
2483
                            Ops[1]->getType(), Ops[2]->getType()};
2484
          Ops.insert(Ops.begin() + 2, Ops[1]);
2485
          break;
2486
        }
2487
        break;
2488
      }
2489
      break;
2490
case RISCVVector::BI__builtin_rvv_vfslide1down_vf_tu:
2491
  ID = Intrinsic::riscv_vfslide1down;
2492
  PolicyAttrs = 2;
2493
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2494
  break;
2495
case RISCVVector::BI__builtin_rvv_vfslide1down_vf_ta:
2496
  ID = Intrinsic::riscv_vfslide1down;
2497
  PolicyAttrs = 3;
2498
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2499
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2500
  break;
2501
case RISCVVector::BI__builtin_rvv_vfslide1down_vf_tum:
2502
  ID = Intrinsic::riscv_vfslide1down_mask;
2503
  PolicyAttrs = 2;
2504
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2505
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2506
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2507
  break;
2508
case RISCVVector::BI__builtin_rvv_vfslide1down_vf_tama:
2509
  ID = Intrinsic::riscv_vfslide1down_mask;
2510
  PolicyAttrs = 3;
2511
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2512
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2513
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2514
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2515
  break;
2516
case RISCVVector::BI__builtin_rvv_vfslide1down_vf_tumu:
2517
  ID = Intrinsic::riscv_vfslide1down_mask;
2518
  PolicyAttrs = 0;
2519
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2520
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2521
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2522
  break;
2523
case RISCVVector::BI__builtin_rvv_vfslide1down_vf_mu:
2524
  ID = Intrinsic::riscv_vfslide1down_mask;
2525
  PolicyAttrs = 1;
2526
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2527
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2528
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2529
  break;
2530
case RISCVVector::BI__builtin_rvv_vfslide1up_vf_tu:
2531
  ID = Intrinsic::riscv_vfslide1up;
2532
  PolicyAttrs = 2;
2533
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2534
  break;
2535
case RISCVVector::BI__builtin_rvv_vfslide1up_vf_ta:
2536
  ID = Intrinsic::riscv_vfslide1up;
2537
  PolicyAttrs = 3;
2538
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2539
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2540
  break;
2541
case RISCVVector::BI__builtin_rvv_vfslide1up_vf_tum:
2542
  ID = Intrinsic::riscv_vfslide1up_mask;
2543
  PolicyAttrs = 2;
2544
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2545
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2546
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2547
  break;
2548
case RISCVVector::BI__builtin_rvv_vfslide1up_vf_tama:
2549
  ID = Intrinsic::riscv_vfslide1up_mask;
2550
  PolicyAttrs = 3;
2551
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2552
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2553
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2554
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2555
  break;
2556
case RISCVVector::BI__builtin_rvv_vfslide1up_vf_tumu:
2557
  ID = Intrinsic::riscv_vfslide1up_mask;
2558
  PolicyAttrs = 0;
2559
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2560
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2561
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2562
  break;
2563
case RISCVVector::BI__builtin_rvv_vfslide1up_vf_mu:
2564
  ID = Intrinsic::riscv_vfslide1up_mask;
2565
  PolicyAttrs = 1;
2566
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2567
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2568
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2569
  break;
2570
case RISCVVector::BI__builtin_rvv_vfsqrt_v_tu:
2571
  ID = Intrinsic::riscv_vfsqrt;
2572
  PolicyAttrs = 2;
2573
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
2574
  break;
2575
case RISCVVector::BI__builtin_rvv_vfsqrt_v_ta:
2576
  ID = Intrinsic::riscv_vfsqrt;
2577
  PolicyAttrs = 3;
2578
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2579
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
2580
  break;
2581
case RISCVVector::BI__builtin_rvv_vfsqrt_v_tum:
2582
  ID = Intrinsic::riscv_vfsqrt_mask;
2583
  PolicyAttrs = 2;
2584
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2585
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2586
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
2587
  break;
2588
case RISCVVector::BI__builtin_rvv_vfsqrt_v_tama:
2589
  ID = Intrinsic::riscv_vfsqrt_mask;
2590
  PolicyAttrs = 3;
2591
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2592
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2593
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2594
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
2595
  break;
2596
case RISCVVector::BI__builtin_rvv_vfsqrt_v_tumu:
2597
  ID = Intrinsic::riscv_vfsqrt_mask;
2598
  PolicyAttrs = 0;
2599
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2600
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2601
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
2602
  break;
2603
case RISCVVector::BI__builtin_rvv_vfsqrt_v_mu:
2604
  ID = Intrinsic::riscv_vfsqrt_mask;
2605
  PolicyAttrs = 1;
2606
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2607
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2608
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
2609
  break;
2610
case RISCVVector::BI__builtin_rvv_vfsub_vv_tu:
2611
case RISCVVector::BI__builtin_rvv_vfsub_vf_tu:
2612
  ID = Intrinsic::riscv_vfsub;
2613
  PolicyAttrs = 2;
2614
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2615
  break;
2616
case RISCVVector::BI__builtin_rvv_vfsub_vv_ta:
2617
case RISCVVector::BI__builtin_rvv_vfsub_vf_ta:
2618
  ID = Intrinsic::riscv_vfsub;
2619
  PolicyAttrs = 3;
2620
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2621
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2622
  break;
2623
case RISCVVector::BI__builtin_rvv_vfsub_vv_tum:
2624
case RISCVVector::BI__builtin_rvv_vfsub_vf_tum:
2625
  ID = Intrinsic::riscv_vfsub_mask;
2626
  PolicyAttrs = 2;
2627
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2628
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2629
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2630
  break;
2631
case RISCVVector::BI__builtin_rvv_vfsub_vv_tama:
2632
case RISCVVector::BI__builtin_rvv_vfsub_vf_tama:
2633
  ID = Intrinsic::riscv_vfsub_mask;
2634
  PolicyAttrs = 3;
2635
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2636
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2637
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2638
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2639
  break;
2640
case RISCVVector::BI__builtin_rvv_vfsub_vv_tumu:
2641
case RISCVVector::BI__builtin_rvv_vfsub_vf_tumu:
2642
  ID = Intrinsic::riscv_vfsub_mask;
2643
  PolicyAttrs = 0;
2644
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2645
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2646
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2647
  break;
2648
case RISCVVector::BI__builtin_rvv_vfsub_vv_mu:
2649
case RISCVVector::BI__builtin_rvv_vfsub_vf_mu:
2650
  ID = Intrinsic::riscv_vfsub_mask;
2651
  PolicyAttrs = 1;
2652
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2653
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2654
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2655
  break;
2656
case RISCVVector::BI__builtin_rvv_vfwadd_vv_tu:
2657
case RISCVVector::BI__builtin_rvv_vfwadd_vf_tu:
2658
  ID = Intrinsic::riscv_vfwadd;
2659
  PolicyAttrs = 2;
2660
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
2661
  break;
2662
case RISCVVector::BI__builtin_rvv_vfwadd_vv_ta:
2663
case RISCVVector::BI__builtin_rvv_vfwadd_vf_ta:
2664
  ID = Intrinsic::riscv_vfwadd;
2665
  PolicyAttrs = 3;
2666
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2667
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
2668
  break;
2669
case RISCVVector::BI__builtin_rvv_vfwadd_vv_tum:
2670
case RISCVVector::BI__builtin_rvv_vfwadd_vf_tum:
2671
  ID = Intrinsic::riscv_vfwadd_mask;
2672
  PolicyAttrs = 2;
2673
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2674
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2675
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
2676
  break;
2677
case RISCVVector::BI__builtin_rvv_vfwadd_vv_tama:
2678
case RISCVVector::BI__builtin_rvv_vfwadd_vf_tama:
2679
  ID = Intrinsic::riscv_vfwadd_mask;
2680
  PolicyAttrs = 3;
2681
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2682
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2683
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2684
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
2685
  break;
2686
case RISCVVector::BI__builtin_rvv_vfwadd_vv_tumu:
2687
case RISCVVector::BI__builtin_rvv_vfwadd_vf_tumu:
2688
  ID = Intrinsic::riscv_vfwadd_mask;
2689
  PolicyAttrs = 0;
2690
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2691
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2692
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
2693
  break;
2694
case RISCVVector::BI__builtin_rvv_vfwadd_vv_mu:
2695
case RISCVVector::BI__builtin_rvv_vfwadd_vf_mu:
2696
  ID = Intrinsic::riscv_vfwadd_mask;
2697
  PolicyAttrs = 1;
2698
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2699
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2700
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
2701
  break;
2702
case RISCVVector::BI__builtin_rvv_vfwadd_wv_tu:
2703
case RISCVVector::BI__builtin_rvv_vfwadd_wf_tu:
2704
  ID = Intrinsic::riscv_vfwadd_w;
2705
  PolicyAttrs = 2;
2706
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2707
  break;
2708
case RISCVVector::BI__builtin_rvv_vfwadd_wv_ta:
2709
case RISCVVector::BI__builtin_rvv_vfwadd_wf_ta:
2710
  ID = Intrinsic::riscv_vfwadd_w;
2711
  PolicyAttrs = 3;
2712
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2713
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2714
  break;
2715
case RISCVVector::BI__builtin_rvv_vfwadd_wv_tum:
2716
case RISCVVector::BI__builtin_rvv_vfwadd_wf_tum:
2717
  ID = Intrinsic::riscv_vfwadd_w_mask;
2718
  PolicyAttrs = 2;
2719
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2720
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2721
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2722
  break;
2723
case RISCVVector::BI__builtin_rvv_vfwadd_wv_tama:
2724
case RISCVVector::BI__builtin_rvv_vfwadd_wf_tama:
2725
  ID = Intrinsic::riscv_vfwadd_w_mask;
2726
  PolicyAttrs = 3;
2727
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2728
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2729
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2730
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2731
  break;
2732
case RISCVVector::BI__builtin_rvv_vfwadd_wv_tumu:
2733
case RISCVVector::BI__builtin_rvv_vfwadd_wf_tumu:
2734
  ID = Intrinsic::riscv_vfwadd_w_mask;
2735
  PolicyAttrs = 0;
2736
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2737
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2738
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2739
  break;
2740
case RISCVVector::BI__builtin_rvv_vfwadd_wv_mu:
2741
case RISCVVector::BI__builtin_rvv_vfwadd_wf_mu:
2742
  ID = Intrinsic::riscv_vfwadd_w_mask;
2743
  PolicyAttrs = 1;
2744
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2745
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2746
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
2747
  break;
2748
case RISCVVector::BI__builtin_rvv_vfwcvt_f_f_v_tu:
2749
  ID = Intrinsic::riscv_vfwcvt_f_f_v;
2750
  PolicyAttrs = 2;
2751
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
2752
  break;
2753
case RISCVVector::BI__builtin_rvv_vfwcvt_f_f_v_ta:
2754
  ID = Intrinsic::riscv_vfwcvt_f_f_v;
2755
  PolicyAttrs = 3;
2756
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2757
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
2758
  break;
2759
case RISCVVector::BI__builtin_rvv_vfwcvt_f_f_v_tum:
2760
  ID = Intrinsic::riscv_vfwcvt_f_f_v_mask;
2761
  PolicyAttrs = 2;
2762
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2763
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2764
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
2765
  break;
2766
case RISCVVector::BI__builtin_rvv_vfwcvt_f_f_v_tama:
2767
  ID = Intrinsic::riscv_vfwcvt_f_f_v_mask;
2768
  PolicyAttrs = 3;
2769
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2770
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2771
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2772
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
2773
  break;
2774
case RISCVVector::BI__builtin_rvv_vfwcvt_f_f_v_tumu:
2775
  ID = Intrinsic::riscv_vfwcvt_f_f_v_mask;
2776
  PolicyAttrs = 0;
2777
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2778
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2779
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
2780
  break;
2781
case RISCVVector::BI__builtin_rvv_vfwcvt_f_f_v_mu:
2782
  ID = Intrinsic::riscv_vfwcvt_f_f_v_mask;
2783
  PolicyAttrs = 1;
2784
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2785
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2786
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
2787
  break;
2788
case RISCVVector::BI__builtin_rvv_vfwcvt_f_x_v_tu:
2789
  ID = Intrinsic::riscv_vfwcvt_f_x_v;
2790
  PolicyAttrs = 2;
2791
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
2792
  break;
2793
case RISCVVector::BI__builtin_rvv_vfwcvt_f_x_v_ta:
2794
  ID = Intrinsic::riscv_vfwcvt_f_x_v;
2795
  PolicyAttrs = 3;
2796
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2797
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
2798
  break;
2799
case RISCVVector::BI__builtin_rvv_vfwcvt_f_x_v_tum:
2800
  ID = Intrinsic::riscv_vfwcvt_f_x_v_mask;
2801
  PolicyAttrs = 2;
2802
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2803
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2804
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
2805
  break;
2806
case RISCVVector::BI__builtin_rvv_vfwcvt_f_x_v_tama:
2807
  ID = Intrinsic::riscv_vfwcvt_f_x_v_mask;
2808
  PolicyAttrs = 3;
2809
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2810
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2811
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2812
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
2813
  break;
2814
case RISCVVector::BI__builtin_rvv_vfwcvt_f_x_v_tumu:
2815
  ID = Intrinsic::riscv_vfwcvt_f_x_v_mask;
2816
  PolicyAttrs = 0;
2817
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2818
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2819
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
2820
  break;
2821
case RISCVVector::BI__builtin_rvv_vfwcvt_f_x_v_mu:
2822
  ID = Intrinsic::riscv_vfwcvt_f_x_v_mask;
2823
  PolicyAttrs = 1;
2824
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2825
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2826
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
2827
  break;
2828
case RISCVVector::BI__builtin_rvv_vfwcvt_f_xu_v_tu:
2829
  ID = Intrinsic::riscv_vfwcvt_f_xu_v;
2830
  PolicyAttrs = 2;
2831
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
2832
  break;
2833
case RISCVVector::BI__builtin_rvv_vfwcvt_f_xu_v_ta:
2834
  ID = Intrinsic::riscv_vfwcvt_f_xu_v;
2835
  PolicyAttrs = 3;
2836
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2837
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
2838
  break;
2839
case RISCVVector::BI__builtin_rvv_vfwcvt_f_xu_v_tum:
2840
  ID = Intrinsic::riscv_vfwcvt_f_xu_v_mask;
2841
  PolicyAttrs = 2;
2842
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2843
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2844
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
2845
  break;
2846
case RISCVVector::BI__builtin_rvv_vfwcvt_f_xu_v_tama:
2847
  ID = Intrinsic::riscv_vfwcvt_f_xu_v_mask;
2848
  PolicyAttrs = 3;
2849
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2850
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2851
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2852
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
2853
  break;
2854
case RISCVVector::BI__builtin_rvv_vfwcvt_f_xu_v_tumu:
2855
  ID = Intrinsic::riscv_vfwcvt_f_xu_v_mask;
2856
  PolicyAttrs = 0;
2857
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2858
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2859
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
2860
  break;
2861
case RISCVVector::BI__builtin_rvv_vfwcvt_f_xu_v_mu:
2862
  ID = Intrinsic::riscv_vfwcvt_f_xu_v_mask;
2863
  PolicyAttrs = 1;
2864
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2865
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2866
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
2867
  break;
2868
case RISCVVector::BI__builtin_rvv_vfwcvt_rtz_x_f_v_tu:
2869
  ID = Intrinsic::riscv_vfwcvt_rtz_x_f_v;
2870
  PolicyAttrs = 2;
2871
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
2872
  break;
2873
case RISCVVector::BI__builtin_rvv_vfwcvt_rtz_x_f_v_ta:
2874
  ID = Intrinsic::riscv_vfwcvt_rtz_x_f_v;
2875
  PolicyAttrs = 3;
2876
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2877
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
2878
  break;
2879
case RISCVVector::BI__builtin_rvv_vfwcvt_rtz_x_f_v_tum:
2880
  ID = Intrinsic::riscv_vfwcvt_rtz_x_f_v_mask;
2881
  PolicyAttrs = 2;
2882
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2883
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2884
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
2885
  break;
2886
case RISCVVector::BI__builtin_rvv_vfwcvt_rtz_x_f_v_tama:
2887
  ID = Intrinsic::riscv_vfwcvt_rtz_x_f_v_mask;
2888
  PolicyAttrs = 3;
2889
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2890
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2891
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2892
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
2893
  break;
2894
case RISCVVector::BI__builtin_rvv_vfwcvt_rtz_x_f_v_tumu:
2895
  ID = Intrinsic::riscv_vfwcvt_rtz_x_f_v_mask;
2896
  PolicyAttrs = 0;
2897
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2898
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2899
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
2900
  break;
2901
case RISCVVector::BI__builtin_rvv_vfwcvt_rtz_x_f_v_mu:
2902
  ID = Intrinsic::riscv_vfwcvt_rtz_x_f_v_mask;
2903
  PolicyAttrs = 1;
2904
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2905
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2906
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
2907
  break;
2908
case RISCVVector::BI__builtin_rvv_vfwcvt_rtz_xu_f_v_tu:
2909
  ID = Intrinsic::riscv_vfwcvt_rtz_xu_f_v;
2910
  PolicyAttrs = 2;
2911
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
2912
  break;
2913
case RISCVVector::BI__builtin_rvv_vfwcvt_rtz_xu_f_v_ta:
2914
  ID = Intrinsic::riscv_vfwcvt_rtz_xu_f_v;
2915
  PolicyAttrs = 3;
2916
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2917
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
2918
  break;
2919
case RISCVVector::BI__builtin_rvv_vfwcvt_rtz_xu_f_v_tum:
2920
  ID = Intrinsic::riscv_vfwcvt_rtz_xu_f_v_mask;
2921
  PolicyAttrs = 2;
2922
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2923
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2924
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
2925
  break;
2926
case RISCVVector::BI__builtin_rvv_vfwcvt_rtz_xu_f_v_tama:
2927
  ID = Intrinsic::riscv_vfwcvt_rtz_xu_f_v_mask;
2928
  PolicyAttrs = 3;
2929
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2930
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2931
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2932
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
2933
  break;
2934
case RISCVVector::BI__builtin_rvv_vfwcvt_rtz_xu_f_v_tumu:
2935
  ID = Intrinsic::riscv_vfwcvt_rtz_xu_f_v_mask;
2936
  PolicyAttrs = 0;
2937
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2938
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2939
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
2940
  break;
2941
case RISCVVector::BI__builtin_rvv_vfwcvt_rtz_xu_f_v_mu:
2942
  ID = Intrinsic::riscv_vfwcvt_rtz_xu_f_v_mask;
2943
  PolicyAttrs = 1;
2944
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2945
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2946
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
2947
  break;
2948
case RISCVVector::BI__builtin_rvv_vfwcvt_x_f_v_tu:
2949
  ID = Intrinsic::riscv_vfwcvt_x_f_v;
2950
  PolicyAttrs = 2;
2951
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
2952
  break;
2953
case RISCVVector::BI__builtin_rvv_vfwcvt_x_f_v_ta:
2954
  ID = Intrinsic::riscv_vfwcvt_x_f_v;
2955
  PolicyAttrs = 3;
2956
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2957
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
2958
  break;
2959
case RISCVVector::BI__builtin_rvv_vfwcvt_x_f_v_tum:
2960
  ID = Intrinsic::riscv_vfwcvt_x_f_v_mask;
2961
  PolicyAttrs = 2;
2962
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2963
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2964
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
2965
  break;
2966
case RISCVVector::BI__builtin_rvv_vfwcvt_x_f_v_tama:
2967
  ID = Intrinsic::riscv_vfwcvt_x_f_v_mask;
2968
  PolicyAttrs = 3;
2969
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2970
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2971
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2972
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
2973
  break;
2974
case RISCVVector::BI__builtin_rvv_vfwcvt_x_f_v_tumu:
2975
  ID = Intrinsic::riscv_vfwcvt_x_f_v_mask;
2976
  PolicyAttrs = 0;
2977
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2978
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2979
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
2980
  break;
2981
case RISCVVector::BI__builtin_rvv_vfwcvt_x_f_v_mu:
2982
  ID = Intrinsic::riscv_vfwcvt_x_f_v_mask;
2983
  PolicyAttrs = 1;
2984
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
2985
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
2986
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
2987
  break;
2988
case RISCVVector::BI__builtin_rvv_vfwcvt_xu_f_v_tu:
2989
  ID = Intrinsic::riscv_vfwcvt_xu_f_v;
2990
  PolicyAttrs = 2;
2991
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
2992
  break;
2993
case RISCVVector::BI__builtin_rvv_vfwcvt_xu_f_v_ta:
2994
  ID = Intrinsic::riscv_vfwcvt_xu_f_v;
2995
  PolicyAttrs = 3;
2996
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
2997
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
2998
  break;
2999
case RISCVVector::BI__builtin_rvv_vfwcvt_xu_f_v_tum:
3000
  ID = Intrinsic::riscv_vfwcvt_xu_f_v_mask;
3001
  PolicyAttrs = 2;
3002
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3003
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3004
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
3005
  break;
3006
case RISCVVector::BI__builtin_rvv_vfwcvt_xu_f_v_tama:
3007
  ID = Intrinsic::riscv_vfwcvt_xu_f_v_mask;
3008
  PolicyAttrs = 3;
3009
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3010
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3011
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
3012
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
3013
  break;
3014
case RISCVVector::BI__builtin_rvv_vfwcvt_xu_f_v_tumu:
3015
  ID = Intrinsic::riscv_vfwcvt_xu_f_v_mask;
3016
  PolicyAttrs = 0;
3017
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3018
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3019
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
3020
  break;
3021
case RISCVVector::BI__builtin_rvv_vfwcvt_xu_f_v_mu:
3022
  ID = Intrinsic::riscv_vfwcvt_xu_f_v_mask;
3023
  PolicyAttrs = 1;
3024
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3025
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3026
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
3027
  break;
3028
case RISCVVector::BI__builtin_rvv_vfwmacc_vv_tu:
3029
case RISCVVector::BI__builtin_rvv_vfwmacc_vf_tu:
3030
  ID = Intrinsic::riscv_vfwmacc;
3031
  PolicyAttrs = 2;
3032
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3033
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
3034
  break;
3035
case RISCVVector::BI__builtin_rvv_vfwmacc_vv_ta:
3036
case RISCVVector::BI__builtin_rvv_vfwmacc_vf_ta:
3037
  ID = Intrinsic::riscv_vfwmacc;
3038
  PolicyAttrs = 3;
3039
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3040
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
3041
  break;
3042
case RISCVVector::BI__builtin_rvv_vfwmacc_vv_tum:
3043
case RISCVVector::BI__builtin_rvv_vfwmacc_vf_tum:
3044
  ID = Intrinsic::riscv_vfwmacc_mask;
3045
  PolicyAttrs = 2;
3046
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3047
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3048
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
3049
  break;
3050
case RISCVVector::BI__builtin_rvv_vfwmacc_vv_tama:
3051
case RISCVVector::BI__builtin_rvv_vfwmacc_vf_tama:
3052
  ID = Intrinsic::riscv_vfwmacc_mask;
3053
  PolicyAttrs = 3;
3054
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3055
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3056
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
3057
  break;
3058
case RISCVVector::BI__builtin_rvv_vfwmacc_vv_tumu:
3059
case RISCVVector::BI__builtin_rvv_vfwmacc_vf_tumu:
3060
  ID = Intrinsic::riscv_vfwmacc_mask;
3061
  PolicyAttrs = 0;
3062
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3063
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3064
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
3065
  break;
3066
case RISCVVector::BI__builtin_rvv_vfwmacc_vv_mu:
3067
case RISCVVector::BI__builtin_rvv_vfwmacc_vf_mu:
3068
  ID = Intrinsic::riscv_vfwmacc_mask;
3069
  PolicyAttrs = 1;
3070
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3071
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3072
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
3073
  break;
3074
case RISCVVector::BI__builtin_rvv_vfwmsac_vv_tu:
3075
case RISCVVector::BI__builtin_rvv_vfwmsac_vf_tu:
3076
  ID = Intrinsic::riscv_vfwmsac;
3077
  PolicyAttrs = 2;
3078
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3079
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
3080
  break;
3081
case RISCVVector::BI__builtin_rvv_vfwmsac_vv_ta:
3082
case RISCVVector::BI__builtin_rvv_vfwmsac_vf_ta:
3083
  ID = Intrinsic::riscv_vfwmsac;
3084
  PolicyAttrs = 3;
3085
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3086
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
3087
  break;
3088
case RISCVVector::BI__builtin_rvv_vfwmsac_vv_tum:
3089
case RISCVVector::BI__builtin_rvv_vfwmsac_vf_tum:
3090
  ID = Intrinsic::riscv_vfwmsac_mask;
3091
  PolicyAttrs = 2;
3092
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3093
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3094
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
3095
  break;
3096
case RISCVVector::BI__builtin_rvv_vfwmsac_vv_tama:
3097
case RISCVVector::BI__builtin_rvv_vfwmsac_vf_tama:
3098
  ID = Intrinsic::riscv_vfwmsac_mask;
3099
  PolicyAttrs = 3;
3100
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3101
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3102
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
3103
  break;
3104
case RISCVVector::BI__builtin_rvv_vfwmsac_vv_tumu:
3105
case RISCVVector::BI__builtin_rvv_vfwmsac_vf_tumu:
3106
  ID = Intrinsic::riscv_vfwmsac_mask;
3107
  PolicyAttrs = 0;
3108
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3109
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3110
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
3111
  break;
3112
case RISCVVector::BI__builtin_rvv_vfwmsac_vv_mu:
3113
case RISCVVector::BI__builtin_rvv_vfwmsac_vf_mu:
3114
  ID = Intrinsic::riscv_vfwmsac_mask;
3115
  PolicyAttrs = 1;
3116
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3117
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3118
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
3119
  break;
3120
case RISCVVector::BI__builtin_rvv_vfwmul_vv_tu:
3121
case RISCVVector::BI__builtin_rvv_vfwmul_vf_tu:
3122
  ID = Intrinsic::riscv_vfwmul;
3123
  PolicyAttrs = 2;
3124
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
3125
  break;
3126
case RISCVVector::BI__builtin_rvv_vfwmul_vv_ta:
3127
case RISCVVector::BI__builtin_rvv_vfwmul_vf_ta:
3128
  ID = Intrinsic::riscv_vfwmul;
3129
  PolicyAttrs = 3;
3130
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
3131
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
3132
  break;
3133
case RISCVVector::BI__builtin_rvv_vfwmul_vv_tum:
3134
case RISCVVector::BI__builtin_rvv_vfwmul_vf_tum:
3135
  ID = Intrinsic::riscv_vfwmul_mask;
3136
  PolicyAttrs = 2;
3137
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3138
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3139
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
3140
  break;
3141
case RISCVVector::BI__builtin_rvv_vfwmul_vv_tama:
3142
case RISCVVector::BI__builtin_rvv_vfwmul_vf_tama:
3143
  ID = Intrinsic::riscv_vfwmul_mask;
3144
  PolicyAttrs = 3;
3145
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3146
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3147
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
3148
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
3149
  break;
3150
case RISCVVector::BI__builtin_rvv_vfwmul_vv_tumu:
3151
case RISCVVector::BI__builtin_rvv_vfwmul_vf_tumu:
3152
  ID = Intrinsic::riscv_vfwmul_mask;
3153
  PolicyAttrs = 0;
3154
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3155
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3156
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
3157
  break;
3158
case RISCVVector::BI__builtin_rvv_vfwmul_vv_mu:
3159
case RISCVVector::BI__builtin_rvv_vfwmul_vf_mu:
3160
  ID = Intrinsic::riscv_vfwmul_mask;
3161
  PolicyAttrs = 1;
3162
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3163
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3164
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
3165
  break;
3166
case RISCVVector::BI__builtin_rvv_vfwnmacc_vv_tu:
3167
case RISCVVector::BI__builtin_rvv_vfwnmacc_vf_tu:
3168
  ID = Intrinsic::riscv_vfwnmacc;
3169
  PolicyAttrs = 2;
3170
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3171
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
3172
  break;
3173
case RISCVVector::BI__builtin_rvv_vfwnmacc_vv_ta:
3174
case RISCVVector::BI__builtin_rvv_vfwnmacc_vf_ta:
3175
  ID = Intrinsic::riscv_vfwnmacc;
3176
  PolicyAttrs = 3;
3177
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3178
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
3179
  break;
3180
case RISCVVector::BI__builtin_rvv_vfwnmacc_vv_tum:
3181
case RISCVVector::BI__builtin_rvv_vfwnmacc_vf_tum:
3182
  ID = Intrinsic::riscv_vfwnmacc_mask;
3183
  PolicyAttrs = 2;
3184
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3185
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3186
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
3187
  break;
3188
case RISCVVector::BI__builtin_rvv_vfwnmacc_vv_tama:
3189
case RISCVVector::BI__builtin_rvv_vfwnmacc_vf_tama:
3190
  ID = Intrinsic::riscv_vfwnmacc_mask;
3191
  PolicyAttrs = 3;
3192
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3193
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3194
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
3195
  break;
3196
case RISCVVector::BI__builtin_rvv_vfwnmacc_vv_tumu:
3197
case RISCVVector::BI__builtin_rvv_vfwnmacc_vf_tumu:
3198
  ID = Intrinsic::riscv_vfwnmacc_mask;
3199
  PolicyAttrs = 0;
3200
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3201
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3202
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
3203
  break;
3204
case RISCVVector::BI__builtin_rvv_vfwnmacc_vv_mu:
3205
case RISCVVector::BI__builtin_rvv_vfwnmacc_vf_mu:
3206
  ID = Intrinsic::riscv_vfwnmacc_mask;
3207
  PolicyAttrs = 1;
3208
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3209
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3210
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
3211
  break;
3212
case RISCVVector::BI__builtin_rvv_vfwnmsac_vv_tu:
3213
case RISCVVector::BI__builtin_rvv_vfwnmsac_vf_tu:
3214
  ID = Intrinsic::riscv_vfwnmsac;
3215
  PolicyAttrs = 2;
3216
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3217
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
3218
  break;
3219
case RISCVVector::BI__builtin_rvv_vfwnmsac_vv_ta:
3220
case RISCVVector::BI__builtin_rvv_vfwnmsac_vf_ta:
3221
  ID = Intrinsic::riscv_vfwnmsac;
3222
  PolicyAttrs = 3;
3223
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3224
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
3225
  break;
3226
case RISCVVector::BI__builtin_rvv_vfwnmsac_vv_tum:
3227
case RISCVVector::BI__builtin_rvv_vfwnmsac_vf_tum:
3228
  ID = Intrinsic::riscv_vfwnmsac_mask;
3229
  PolicyAttrs = 2;
3230
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3231
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3232
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
3233
  break;
3234
case RISCVVector::BI__builtin_rvv_vfwnmsac_vv_tama:
3235
case RISCVVector::BI__builtin_rvv_vfwnmsac_vf_tama:
3236
  ID = Intrinsic::riscv_vfwnmsac_mask;
3237
  PolicyAttrs = 3;
3238
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3239
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3240
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
3241
  break;
3242
case RISCVVector::BI__builtin_rvv_vfwnmsac_vv_tumu:
3243
case RISCVVector::BI__builtin_rvv_vfwnmsac_vf_tumu:
3244
  ID = Intrinsic::riscv_vfwnmsac_mask;
3245
  PolicyAttrs = 0;
3246
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3247
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3248
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
3249
  break;
3250
case RISCVVector::BI__builtin_rvv_vfwnmsac_vv_mu:
3251
case RISCVVector::BI__builtin_rvv_vfwnmsac_vf_mu:
3252
  ID = Intrinsic::riscv_vfwnmsac_mask;
3253
  PolicyAttrs = 1;
3254
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3255
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3256
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
3257
  break;
3258
case RISCVVector::BI__builtin_rvv_vfwredosum_vs_tu:
3259
  ID = Intrinsic::riscv_vfwredosum;
3260
  PolicyAttrs = 2;
3261
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
3262
  break;
3263
case RISCVVector::BI__builtin_rvv_vfwredosum_vs_ta:
3264
  ID = Intrinsic::riscv_vfwredosum;
3265
  PolicyAttrs = 3;
3266
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
3267
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
3268
  break;
3269
case RISCVVector::BI__builtin_rvv_vfwredosum_vs_tum:
3270
  ID = Intrinsic::riscv_vfwredosum_mask;
3271
  PolicyAttrs = 2;
3272
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3273
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
3274
  break;
3275
case RISCVVector::BI__builtin_rvv_vfwredosum_vs_tama:
3276
  ID = Intrinsic::riscv_vfwredosum_mask;
3277
  PolicyAttrs = 3;
3278
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3279
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
3280
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
3281
  break;
3282
case RISCVVector::BI__builtin_rvv_vfwredusum_vs_tu:
3283
  ID = Intrinsic::riscv_vfwredusum;
3284
  PolicyAttrs = 2;
3285
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
3286
  break;
3287
case RISCVVector::BI__builtin_rvv_vfwredusum_vs_ta:
3288
  ID = Intrinsic::riscv_vfwredusum;
3289
  PolicyAttrs = 3;
3290
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
3291
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
3292
  break;
3293
case RISCVVector::BI__builtin_rvv_vfwredusum_vs_tum:
3294
  ID = Intrinsic::riscv_vfwredusum_mask;
3295
  PolicyAttrs = 2;
3296
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3297
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
3298
  break;
3299
case RISCVVector::BI__builtin_rvv_vfwredusum_vs_tama:
3300
  ID = Intrinsic::riscv_vfwredusum_mask;
3301
  PolicyAttrs = 3;
3302
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3303
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
3304
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
3305
  break;
3306
case RISCVVector::BI__builtin_rvv_vfwsub_vv_tu:
3307
case RISCVVector::BI__builtin_rvv_vfwsub_vf_tu:
3308
  ID = Intrinsic::riscv_vfwsub;
3309
  PolicyAttrs = 2;
3310
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
3311
  break;
3312
case RISCVVector::BI__builtin_rvv_vfwsub_vv_ta:
3313
case RISCVVector::BI__builtin_rvv_vfwsub_vf_ta:
3314
  ID = Intrinsic::riscv_vfwsub;
3315
  PolicyAttrs = 3;
3316
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
3317
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
3318
  break;
3319
case RISCVVector::BI__builtin_rvv_vfwsub_vv_tum:
3320
case RISCVVector::BI__builtin_rvv_vfwsub_vf_tum:
3321
  ID = Intrinsic::riscv_vfwsub_mask;
3322
  PolicyAttrs = 2;
3323
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3324
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3325
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
3326
  break;
3327
case RISCVVector::BI__builtin_rvv_vfwsub_vv_tama:
3328
case RISCVVector::BI__builtin_rvv_vfwsub_vf_tama:
3329
  ID = Intrinsic::riscv_vfwsub_mask;
3330
  PolicyAttrs = 3;
3331
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3332
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3333
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
3334
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
3335
  break;
3336
case RISCVVector::BI__builtin_rvv_vfwsub_vv_tumu:
3337
case RISCVVector::BI__builtin_rvv_vfwsub_vf_tumu:
3338
  ID = Intrinsic::riscv_vfwsub_mask;
3339
  PolicyAttrs = 0;
3340
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3341
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3342
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
3343
  break;
3344
case RISCVVector::BI__builtin_rvv_vfwsub_vv_mu:
3345
case RISCVVector::BI__builtin_rvv_vfwsub_vf_mu:
3346
  ID = Intrinsic::riscv_vfwsub_mask;
3347
  PolicyAttrs = 1;
3348
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3349
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3350
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
3351
  break;
3352
case RISCVVector::BI__builtin_rvv_vfwsub_wv_tu:
3353
case RISCVVector::BI__builtin_rvv_vfwsub_wf_tu:
3354
  ID = Intrinsic::riscv_vfwsub_w;
3355
  PolicyAttrs = 2;
3356
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
3357
  break;
3358
case RISCVVector::BI__builtin_rvv_vfwsub_wv_ta:
3359
case RISCVVector::BI__builtin_rvv_vfwsub_wf_ta:
3360
  ID = Intrinsic::riscv_vfwsub_w;
3361
  PolicyAttrs = 3;
3362
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
3363
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
3364
  break;
3365
case RISCVVector::BI__builtin_rvv_vfwsub_wv_tum:
3366
case RISCVVector::BI__builtin_rvv_vfwsub_wf_tum:
3367
  ID = Intrinsic::riscv_vfwsub_w_mask;
3368
  PolicyAttrs = 2;
3369
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3370
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3371
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
3372
  break;
3373
case RISCVVector::BI__builtin_rvv_vfwsub_wv_tama:
3374
case RISCVVector::BI__builtin_rvv_vfwsub_wf_tama:
3375
  ID = Intrinsic::riscv_vfwsub_w_mask;
3376
  PolicyAttrs = 3;
3377
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3378
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3379
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
3380
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
3381
  break;
3382
case RISCVVector::BI__builtin_rvv_vfwsub_wv_tumu:
3383
case RISCVVector::BI__builtin_rvv_vfwsub_wf_tumu:
3384
  ID = Intrinsic::riscv_vfwsub_w_mask;
3385
  PolicyAttrs = 0;
3386
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3387
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3388
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
3389
  break;
3390
case RISCVVector::BI__builtin_rvv_vfwsub_wv_mu:
3391
case RISCVVector::BI__builtin_rvv_vfwsub_wf_mu:
3392
  ID = Intrinsic::riscv_vfwsub_w_mask;
3393
  PolicyAttrs = 1;
3394
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3395
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3396
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
3397
  break;
3398
case RISCVVector::BI__builtin_rvv_vid_v_tu:
3399
  ID = Intrinsic::riscv_vid;
3400
  PolicyAttrs = 2;
3401
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
3402
  break;
3403
case RISCVVector::BI__builtin_rvv_vid_v_ta:
3404
  ID = Intrinsic::riscv_vid;
3405
  PolicyAttrs = 3;
3406
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
3407
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
3408
  break;
3409
case RISCVVector::BI__builtin_rvv_vid_v_tum:
3410
  ID = Intrinsic::riscv_vid_mask;
3411
  PolicyAttrs = 2;
3412
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3413
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3414
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
3415
  break;
3416
case RISCVVector::BI__builtin_rvv_vid_v_tama:
3417
  ID = Intrinsic::riscv_vid_mask;
3418
  PolicyAttrs = 3;
3419
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3420
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3421
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
3422
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
3423
  break;
3424
case RISCVVector::BI__builtin_rvv_vid_v_tumu:
3425
  ID = Intrinsic::riscv_vid_mask;
3426
  PolicyAttrs = 0;
3427
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3428
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3429
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
3430
  break;
3431
case RISCVVector::BI__builtin_rvv_vid_v_mu:
3432
  ID = Intrinsic::riscv_vid_mask;
3433
  PolicyAttrs = 1;
3434
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3435
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3436
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
3437
  break;
3438
case RISCVVector::BI__builtin_rvv_viota_m_tu:
3439
  ID = Intrinsic::riscv_viota;
3440
  PolicyAttrs = 2;
3441
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
3442
  break;
3443
case RISCVVector::BI__builtin_rvv_viota_m_ta:
3444
  ID = Intrinsic::riscv_viota;
3445
  PolicyAttrs = 3;
3446
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
3447
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
3448
  break;
3449
case RISCVVector::BI__builtin_rvv_viota_m_tum:
3450
  ID = Intrinsic::riscv_viota_mask;
3451
  PolicyAttrs = 2;
3452
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3453
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3454
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
3455
  break;
3456
case RISCVVector::BI__builtin_rvv_viota_m_tama:
3457
  ID = Intrinsic::riscv_viota_mask;
3458
  PolicyAttrs = 3;
3459
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3460
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3461
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
3462
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
3463
  break;
3464
case RISCVVector::BI__builtin_rvv_viota_m_tumu:
3465
  ID = Intrinsic::riscv_viota_mask;
3466
  PolicyAttrs = 0;
3467
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3468
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3469
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
3470
  break;
3471
case RISCVVector::BI__builtin_rvv_viota_m_mu:
3472
  ID = Intrinsic::riscv_viota_mask;
3473
  PolicyAttrs = 1;
3474
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3475
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3476
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
3477
  break;
3478
case RISCVVector::BI__builtin_rvv_vle8_v_tu:
3479
case RISCVVector::BI__builtin_rvv_vle16_v_tu:
3480
case RISCVVector::BI__builtin_rvv_vle32_v_tu:
3481
case RISCVVector::BI__builtin_rvv_vle64_v_tu:
3482
  ID = Intrinsic::riscv_vle;
3483
  PolicyAttrs = 2;
3484
  Ops[1] = Builder.CreateBitCast(Ops[1], ResultType->getPointerTo());
3485
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
3486
  break;
3487
case RISCVVector::BI__builtin_rvv_vle8_v_ta:
3488
case RISCVVector::BI__builtin_rvv_vle16_v_ta:
3489
case RISCVVector::BI__builtin_rvv_vle32_v_ta:
3490
case RISCVVector::BI__builtin_rvv_vle64_v_ta:
3491
  ID = Intrinsic::riscv_vle;
3492
  PolicyAttrs = 3;
3493
  Ops[0] = Builder.CreateBitCast(Ops[0], ResultType->getPointerTo());
3494
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
3495
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
3496
  break;
3497
case RISCVVector::BI__builtin_rvv_vle8_v_tum:
3498
case RISCVVector::BI__builtin_rvv_vle16_v_tum:
3499
case RISCVVector::BI__builtin_rvv_vle32_v_tum:
3500
case RISCVVector::BI__builtin_rvv_vle64_v_tum:
3501
  ID = Intrinsic::riscv_vle_mask;
3502
  PolicyAttrs = 2;
3503
  Ops[2] = Builder.CreateBitCast(Ops[2], ResultType->getPointerTo());
3504
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3505
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3506
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
3507
  break;
3508
case RISCVVector::BI__builtin_rvv_vle8_v_tama:
3509
case RISCVVector::BI__builtin_rvv_vle16_v_tama:
3510
case RISCVVector::BI__builtin_rvv_vle32_v_tama:
3511
case RISCVVector::BI__builtin_rvv_vle64_v_tama:
3512
  ID = Intrinsic::riscv_vle_mask;
3513
  PolicyAttrs = 3;
3514
  Ops[1] = Builder.CreateBitCast(Ops[1], ResultType->getPointerTo());
3515
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3516
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3517
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
3518
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
3519
  break;
3520
case RISCVVector::BI__builtin_rvv_vle8_v_tumu:
3521
case RISCVVector::BI__builtin_rvv_vle16_v_tumu:
3522
case RISCVVector::BI__builtin_rvv_vle32_v_tumu:
3523
case RISCVVector::BI__builtin_rvv_vle64_v_tumu:
3524
  ID = Intrinsic::riscv_vle_mask;
3525
  PolicyAttrs = 0;
3526
  Ops[2] = Builder.CreateBitCast(Ops[2], ResultType->getPointerTo());
3527
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3528
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3529
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
3530
  break;
3531
case RISCVVector::BI__builtin_rvv_vle8_v_mu:
3532
case RISCVVector::BI__builtin_rvv_vle16_v_mu:
3533
case RISCVVector::BI__builtin_rvv_vle32_v_mu:
3534
case RISCVVector::BI__builtin_rvv_vle64_v_mu:
3535
  ID = Intrinsic::riscv_vle_mask;
3536
  PolicyAttrs = 1;
3537
  Ops[2] = Builder.CreateBitCast(Ops[2], ResultType->getPointerTo());
3538
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3539
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3540
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
3541
  break;
3542
case RISCVVector::BI__builtin_rvv_vle16ff_v_tu:
3543
case RISCVVector::BI__builtin_rvv_vle32ff_v_tu:
3544
case RISCVVector::BI__builtin_rvv_vle64ff_v_tu:
3545
case RISCVVector::BI__builtin_rvv_vle8ff_v_tu:
3546
  ID = Intrinsic::riscv_vleff;
3547
  PolicyAttrs = 2;
3548
IsMasked = false;
3549
 
3550
      {
3551
        if (IsMasked) {
3552
          // Move mask to right before vl.
3553
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3554
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
3555
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
3556
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3557
          IntrinsicTypes = {ResultType, Ops[4]->getType()};
3558
        } else {
3559
          if (PolicyAttrs & RVV_VTA)
3560
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
3561
          IntrinsicTypes = {ResultType, Ops[3]->getType()};
3562
        }
3563
        Ops[1] = Builder.CreateBitCast(Ops[1], ResultType->getPointerTo());
3564
        Value *NewVL = Ops[2];
3565
        Ops.erase(Ops.begin() + 2);
3566
        llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
3567
        llvm::Value *LoadValue = Builder.CreateCall(F, Ops, "");
3568
        llvm::Value *V = Builder.CreateExtractValue(LoadValue, {0});
3569
        // Store new_vl.
3570
        clang::CharUnits Align;
3571
        if (IsMasked)
3572
          Align = CGM.getNaturalPointeeTypeAlignment(E->getArg(E->getNumArgs()-2)->getType());
3573
        else
3574
          Align = CGM.getNaturalPointeeTypeAlignment(E->getArg(1)->getType());
3575
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {1});
3576
        Builder.CreateStore(Val, Address(NewVL, Val->getType(), Align));
3577
        return V;
3578
      }
3579
      break;
3580
case RISCVVector::BI__builtin_rvv_vle16ff_v_ta:
3581
case RISCVVector::BI__builtin_rvv_vle32ff_v_ta:
3582
case RISCVVector::BI__builtin_rvv_vle64ff_v_ta:
3583
case RISCVVector::BI__builtin_rvv_vle8ff_v_ta:
3584
  ID = Intrinsic::riscv_vleff;
3585
  PolicyAttrs = 3;
3586
IsMasked = false;
3587
 
3588
      {
3589
        if (IsMasked) {
3590
          // Move mask to right before vl.
3591
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3592
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
3593
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
3594
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3595
          IntrinsicTypes = {ResultType, Ops[4]->getType()};
3596
        } else {
3597
          if (PolicyAttrs & RVV_VTA)
3598
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
3599
          IntrinsicTypes = {ResultType, Ops[3]->getType()};
3600
        }
3601
        Ops[1] = Builder.CreateBitCast(Ops[1], ResultType->getPointerTo());
3602
        Value *NewVL = Ops[2];
3603
        Ops.erase(Ops.begin() + 2);
3604
        llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
3605
        llvm::Value *LoadValue = Builder.CreateCall(F, Ops, "");
3606
        llvm::Value *V = Builder.CreateExtractValue(LoadValue, {0});
3607
        // Store new_vl.
3608
        clang::CharUnits Align;
3609
        if (IsMasked)
3610
          Align = CGM.getNaturalPointeeTypeAlignment(E->getArg(E->getNumArgs()-2)->getType());
3611
        else
3612
          Align = CGM.getNaturalPointeeTypeAlignment(E->getArg(1)->getType());
3613
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {1});
3614
        Builder.CreateStore(Val, Address(NewVL, Val->getType(), Align));
3615
        return V;
3616
      }
3617
      break;
3618
case RISCVVector::BI__builtin_rvv_vle16ff_v_tum:
3619
case RISCVVector::BI__builtin_rvv_vle32ff_v_tum:
3620
case RISCVVector::BI__builtin_rvv_vle64ff_v_tum:
3621
case RISCVVector::BI__builtin_rvv_vle8ff_v_tum:
3622
  ID = Intrinsic::riscv_vleff_mask;
3623
  PolicyAttrs = 2;
3624
IsMasked = true;
3625
 
3626
      {
3627
        if (IsMasked) {
3628
          // Move mask to right before vl.
3629
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3630
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
3631
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
3632
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3633
          IntrinsicTypes = {ResultType, Ops[4]->getType()};
3634
        } else {
3635
          if (PolicyAttrs & RVV_VTA)
3636
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
3637
          IntrinsicTypes = {ResultType, Ops[3]->getType()};
3638
        }
3639
        Ops[1] = Builder.CreateBitCast(Ops[1], ResultType->getPointerTo());
3640
        Value *NewVL = Ops[2];
3641
        Ops.erase(Ops.begin() + 2);
3642
        llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
3643
        llvm::Value *LoadValue = Builder.CreateCall(F, Ops, "");
3644
        llvm::Value *V = Builder.CreateExtractValue(LoadValue, {0});
3645
        // Store new_vl.
3646
        clang::CharUnits Align;
3647
        if (IsMasked)
3648
          Align = CGM.getNaturalPointeeTypeAlignment(E->getArg(E->getNumArgs()-2)->getType());
3649
        else
3650
          Align = CGM.getNaturalPointeeTypeAlignment(E->getArg(1)->getType());
3651
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {1});
3652
        Builder.CreateStore(Val, Address(NewVL, Val->getType(), Align));
3653
        return V;
3654
      }
3655
      break;
3656
case RISCVVector::BI__builtin_rvv_vle16ff_v_tama:
3657
case RISCVVector::BI__builtin_rvv_vle32ff_v_tama:
3658
case RISCVVector::BI__builtin_rvv_vle64ff_v_tama:
3659
case RISCVVector::BI__builtin_rvv_vle8ff_v_tama:
3660
  ID = Intrinsic::riscv_vleff_mask;
3661
  PolicyAttrs = 3;
3662
IsMasked = true;
3663
 
3664
      {
3665
        if (IsMasked) {
3666
          // Move mask to right before vl.
3667
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3668
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
3669
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
3670
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3671
          IntrinsicTypes = {ResultType, Ops[4]->getType()};
3672
        } else {
3673
          if (PolicyAttrs & RVV_VTA)
3674
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
3675
          IntrinsicTypes = {ResultType, Ops[3]->getType()};
3676
        }
3677
        Ops[1] = Builder.CreateBitCast(Ops[1], ResultType->getPointerTo());
3678
        Value *NewVL = Ops[2];
3679
        Ops.erase(Ops.begin() + 2);
3680
        llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
3681
        llvm::Value *LoadValue = Builder.CreateCall(F, Ops, "");
3682
        llvm::Value *V = Builder.CreateExtractValue(LoadValue, {0});
3683
        // Store new_vl.
3684
        clang::CharUnits Align;
3685
        if (IsMasked)
3686
          Align = CGM.getNaturalPointeeTypeAlignment(E->getArg(E->getNumArgs()-2)->getType());
3687
        else
3688
          Align = CGM.getNaturalPointeeTypeAlignment(E->getArg(1)->getType());
3689
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {1});
3690
        Builder.CreateStore(Val, Address(NewVL, Val->getType(), Align));
3691
        return V;
3692
      }
3693
      break;
3694
case RISCVVector::BI__builtin_rvv_vle16ff_v_tumu:
3695
case RISCVVector::BI__builtin_rvv_vle32ff_v_tumu:
3696
case RISCVVector::BI__builtin_rvv_vle64ff_v_tumu:
3697
case RISCVVector::BI__builtin_rvv_vle8ff_v_tumu:
3698
  ID = Intrinsic::riscv_vleff_mask;
3699
  PolicyAttrs = 0;
3700
IsMasked = true;
3701
 
3702
      {
3703
        if (IsMasked) {
3704
          // Move mask to right before vl.
3705
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3706
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
3707
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
3708
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3709
          IntrinsicTypes = {ResultType, Ops[4]->getType()};
3710
        } else {
3711
          if (PolicyAttrs & RVV_VTA)
3712
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
3713
          IntrinsicTypes = {ResultType, Ops[3]->getType()};
3714
        }
3715
        Ops[1] = Builder.CreateBitCast(Ops[1], ResultType->getPointerTo());
3716
        Value *NewVL = Ops[2];
3717
        Ops.erase(Ops.begin() + 2);
3718
        llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
3719
        llvm::Value *LoadValue = Builder.CreateCall(F, Ops, "");
3720
        llvm::Value *V = Builder.CreateExtractValue(LoadValue, {0});
3721
        // Store new_vl.
3722
        clang::CharUnits Align;
3723
        if (IsMasked)
3724
          Align = CGM.getNaturalPointeeTypeAlignment(E->getArg(E->getNumArgs()-2)->getType());
3725
        else
3726
          Align = CGM.getNaturalPointeeTypeAlignment(E->getArg(1)->getType());
3727
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {1});
3728
        Builder.CreateStore(Val, Address(NewVL, Val->getType(), Align));
3729
        return V;
3730
      }
3731
      break;
3732
case RISCVVector::BI__builtin_rvv_vle16ff_v_mu:
3733
case RISCVVector::BI__builtin_rvv_vle32ff_v_mu:
3734
case RISCVVector::BI__builtin_rvv_vle64ff_v_mu:
3735
case RISCVVector::BI__builtin_rvv_vle8ff_v_mu:
3736
  ID = Intrinsic::riscv_vleff_mask;
3737
  PolicyAttrs = 1;
3738
IsMasked = true;
3739
 
3740
      {
3741
        if (IsMasked) {
3742
          // Move mask to right before vl.
3743
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3744
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
3745
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
3746
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3747
          IntrinsicTypes = {ResultType, Ops[4]->getType()};
3748
        } else {
3749
          if (PolicyAttrs & RVV_VTA)
3750
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
3751
          IntrinsicTypes = {ResultType, Ops[3]->getType()};
3752
        }
3753
        Ops[1] = Builder.CreateBitCast(Ops[1], ResultType->getPointerTo());
3754
        Value *NewVL = Ops[2];
3755
        Ops.erase(Ops.begin() + 2);
3756
        llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
3757
        llvm::Value *LoadValue = Builder.CreateCall(F, Ops, "");
3758
        llvm::Value *V = Builder.CreateExtractValue(LoadValue, {0});
3759
        // Store new_vl.
3760
        clang::CharUnits Align;
3761
        if (IsMasked)
3762
          Align = CGM.getNaturalPointeeTypeAlignment(E->getArg(E->getNumArgs()-2)->getType());
3763
        else
3764
          Align = CGM.getNaturalPointeeTypeAlignment(E->getArg(1)->getType());
3765
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {1});
3766
        Builder.CreateStore(Val, Address(NewVL, Val->getType(), Align));
3767
        return V;
3768
      }
3769
      break;
3770
case RISCVVector::BI__builtin_rvv_vlm_v:
3771
  ID = Intrinsic::riscv_vlm;
3772
  PolicyAttrs = 3;
3773
  Ops[0] = Builder.CreateBitCast(Ops[0], ResultType->getPointerTo());
3774
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
3775
  break;
3776
case RISCVVector::BI__builtin_rvv_vloxei8_v_tu:
3777
case RISCVVector::BI__builtin_rvv_vloxei16_v_tu:
3778
case RISCVVector::BI__builtin_rvv_vloxei32_v_tu:
3779
case RISCVVector::BI__builtin_rvv_vloxei64_v_tu:
3780
  ID = Intrinsic::riscv_vloxei;
3781
  PolicyAttrs = 2;
3782
  Ops[1] = Builder.CreateBitCast(Ops[1], ResultType->getPointerTo());
3783
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
3784
  break;
3785
case RISCVVector::BI__builtin_rvv_vloxei8_v_ta:
3786
case RISCVVector::BI__builtin_rvv_vloxei16_v_ta:
3787
case RISCVVector::BI__builtin_rvv_vloxei32_v_ta:
3788
case RISCVVector::BI__builtin_rvv_vloxei64_v_ta:
3789
  ID = Intrinsic::riscv_vloxei;
3790
  PolicyAttrs = 3;
3791
  Ops[0] = Builder.CreateBitCast(Ops[0], ResultType->getPointerTo());
3792
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
3793
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
3794
  break;
3795
case RISCVVector::BI__builtin_rvv_vloxei8_v_tum:
3796
case RISCVVector::BI__builtin_rvv_vloxei16_v_tum:
3797
case RISCVVector::BI__builtin_rvv_vloxei32_v_tum:
3798
case RISCVVector::BI__builtin_rvv_vloxei64_v_tum:
3799
  ID = Intrinsic::riscv_vloxei_mask;
3800
  PolicyAttrs = 2;
3801
  Ops[2] = Builder.CreateBitCast(Ops[2], ResultType->getPointerTo());
3802
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3803
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3804
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
3805
  break;
3806
case RISCVVector::BI__builtin_rvv_vloxei8_v_tama:
3807
case RISCVVector::BI__builtin_rvv_vloxei16_v_tama:
3808
case RISCVVector::BI__builtin_rvv_vloxei32_v_tama:
3809
case RISCVVector::BI__builtin_rvv_vloxei64_v_tama:
3810
  ID = Intrinsic::riscv_vloxei_mask;
3811
  PolicyAttrs = 3;
3812
  Ops[1] = Builder.CreateBitCast(Ops[1], ResultType->getPointerTo());
3813
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3814
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3815
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
3816
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
3817
  break;
3818
case RISCVVector::BI__builtin_rvv_vloxei8_v_tumu:
3819
case RISCVVector::BI__builtin_rvv_vloxei16_v_tumu:
3820
case RISCVVector::BI__builtin_rvv_vloxei32_v_tumu:
3821
case RISCVVector::BI__builtin_rvv_vloxei64_v_tumu:
3822
  ID = Intrinsic::riscv_vloxei_mask;
3823
  PolicyAttrs = 0;
3824
  Ops[2] = Builder.CreateBitCast(Ops[2], ResultType->getPointerTo());
3825
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3826
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3827
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
3828
  break;
3829
case RISCVVector::BI__builtin_rvv_vloxei8_v_mu:
3830
case RISCVVector::BI__builtin_rvv_vloxei16_v_mu:
3831
case RISCVVector::BI__builtin_rvv_vloxei32_v_mu:
3832
case RISCVVector::BI__builtin_rvv_vloxei64_v_mu:
3833
  ID = Intrinsic::riscv_vloxei_mask;
3834
  PolicyAttrs = 1;
3835
  Ops[2] = Builder.CreateBitCast(Ops[2], ResultType->getPointerTo());
3836
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
3837
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3838
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
3839
  break;
3840
case RISCVVector::BI__builtin_rvv_vloxseg2ei16_v_tu:
3841
case RISCVVector::BI__builtin_rvv_vloxseg2ei32_v_tu:
3842
case RISCVVector::BI__builtin_rvv_vloxseg2ei64_v_tu:
3843
case RISCVVector::BI__builtin_rvv_vloxseg2ei8_v_tu:
3844
  ID = Intrinsic::riscv_vloxseg2;
3845
  NF = 2;
3846
  PolicyAttrs = 2;
3847
IsMasked = false;
3848
 
3849
    {
3850
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
3851
      SmallVector<llvm::Value*, 12> Operands;
3852
 
3853
      // Please refer to comment under 'defvar NFList' in this file
3854
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
3855
          (!IsMasked && PolicyAttrs & RVV_VTA))
3856
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
3857
      else {
3858
        if (IsMasked)
3859
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
3860
        else // Unmasked
3861
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
3862
      }
3863
      unsigned PtrOperandIdx = IsMasked ?
3864
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
3865
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
3866
      Value *PtrOperand = Ops[PtrOperandIdx];
3867
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
3868
      Value *VLOperand = Ops[PtrOperandIdx + 2];
3869
      Operands.push_back(PtrOperand);
3870
      Operands.push_back(IndexOperand);
3871
      if (IsMasked)
3872
        Operands.push_back(Ops[NF]);
3873
      Operands.push_back(VLOperand);
3874
      if (IsMasked)
3875
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3876
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
3877
 
3878
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
3879
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
3880
      clang::CharUnits Align =
3881
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
3882
      llvm::Value *V;
3883
      for (unsigned I = 0; I < NF; ++I) {
3884
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
3885
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
3886
      }
3887
      return V;
3888
    }
3889
    break;
3890
case RISCVVector::BI__builtin_rvv_vloxseg2ei16_v_ta:
3891
case RISCVVector::BI__builtin_rvv_vloxseg2ei32_v_ta:
3892
case RISCVVector::BI__builtin_rvv_vloxseg2ei64_v_ta:
3893
case RISCVVector::BI__builtin_rvv_vloxseg2ei8_v_ta:
3894
  ID = Intrinsic::riscv_vloxseg2;
3895
  NF = 2;
3896
  PolicyAttrs = 3;
3897
IsMasked = false;
3898
 
3899
    {
3900
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
3901
      SmallVector<llvm::Value*, 12> Operands;
3902
 
3903
      // Please refer to comment under 'defvar NFList' in this file
3904
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
3905
          (!IsMasked && PolicyAttrs & RVV_VTA))
3906
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
3907
      else {
3908
        if (IsMasked)
3909
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
3910
        else // Unmasked
3911
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
3912
      }
3913
      unsigned PtrOperandIdx = IsMasked ?
3914
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
3915
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
3916
      Value *PtrOperand = Ops[PtrOperandIdx];
3917
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
3918
      Value *VLOperand = Ops[PtrOperandIdx + 2];
3919
      Operands.push_back(PtrOperand);
3920
      Operands.push_back(IndexOperand);
3921
      if (IsMasked)
3922
        Operands.push_back(Ops[NF]);
3923
      Operands.push_back(VLOperand);
3924
      if (IsMasked)
3925
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3926
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
3927
 
3928
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
3929
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
3930
      clang::CharUnits Align =
3931
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
3932
      llvm::Value *V;
3933
      for (unsigned I = 0; I < NF; ++I) {
3934
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
3935
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
3936
      }
3937
      return V;
3938
    }
3939
    break;
3940
case RISCVVector::BI__builtin_rvv_vloxseg2ei16_v_tum:
3941
case RISCVVector::BI__builtin_rvv_vloxseg2ei32_v_tum:
3942
case RISCVVector::BI__builtin_rvv_vloxseg2ei64_v_tum:
3943
case RISCVVector::BI__builtin_rvv_vloxseg2ei8_v_tum:
3944
  ID = Intrinsic::riscv_vloxseg2_mask;
3945
  NF = 2;
3946
  PolicyAttrs = 2;
3947
IsMasked = true;
3948
 
3949
    {
3950
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
3951
      SmallVector<llvm::Value*, 12> Operands;
3952
 
3953
      // Please refer to comment under 'defvar NFList' in this file
3954
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
3955
          (!IsMasked && PolicyAttrs & RVV_VTA))
3956
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
3957
      else {
3958
        if (IsMasked)
3959
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
3960
        else // Unmasked
3961
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
3962
      }
3963
      unsigned PtrOperandIdx = IsMasked ?
3964
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
3965
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
3966
      Value *PtrOperand = Ops[PtrOperandIdx];
3967
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
3968
      Value *VLOperand = Ops[PtrOperandIdx + 2];
3969
      Operands.push_back(PtrOperand);
3970
      Operands.push_back(IndexOperand);
3971
      if (IsMasked)
3972
        Operands.push_back(Ops[NF]);
3973
      Operands.push_back(VLOperand);
3974
      if (IsMasked)
3975
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
3976
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
3977
 
3978
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
3979
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
3980
      clang::CharUnits Align =
3981
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
3982
      llvm::Value *V;
3983
      for (unsigned I = 0; I < NF; ++I) {
3984
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
3985
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
3986
      }
3987
      return V;
3988
    }
3989
    break;
3990
case RISCVVector::BI__builtin_rvv_vloxseg2ei16_v_tama:
3991
case RISCVVector::BI__builtin_rvv_vloxseg2ei32_v_tama:
3992
case RISCVVector::BI__builtin_rvv_vloxseg2ei64_v_tama:
3993
case RISCVVector::BI__builtin_rvv_vloxseg2ei8_v_tama:
3994
  ID = Intrinsic::riscv_vloxseg2_mask;
3995
  NF = 2;
3996
  PolicyAttrs = 3;
3997
IsMasked = true;
3998
 
3999
    {
4000
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
4001
      SmallVector<llvm::Value*, 12> Operands;
4002
 
4003
      // Please refer to comment under 'defvar NFList' in this file
4004
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
4005
          (!IsMasked && PolicyAttrs & RVV_VTA))
4006
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
4007
      else {
4008
        if (IsMasked)
4009
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
4010
        else // Unmasked
4011
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
4012
      }
4013
      unsigned PtrOperandIdx = IsMasked ?
4014
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
4015
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
4016
      Value *PtrOperand = Ops[PtrOperandIdx];
4017
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
4018
      Value *VLOperand = Ops[PtrOperandIdx + 2];
4019
      Operands.push_back(PtrOperand);
4020
      Operands.push_back(IndexOperand);
4021
      if (IsMasked)
4022
        Operands.push_back(Ops[NF]);
4023
      Operands.push_back(VLOperand);
4024
      if (IsMasked)
4025
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
4026
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
4027
 
4028
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
4029
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
4030
      clang::CharUnits Align =
4031
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
4032
      llvm::Value *V;
4033
      for (unsigned I = 0; I < NF; ++I) {
4034
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
4035
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
4036
      }
4037
      return V;
4038
    }
4039
    break;
4040
case RISCVVector::BI__builtin_rvv_vloxseg2ei16_v_tumu:
4041
case RISCVVector::BI__builtin_rvv_vloxseg2ei32_v_tumu:
4042
case RISCVVector::BI__builtin_rvv_vloxseg2ei64_v_tumu:
4043
case RISCVVector::BI__builtin_rvv_vloxseg2ei8_v_tumu:
4044
  ID = Intrinsic::riscv_vloxseg2_mask;
4045
  NF = 2;
4046
  PolicyAttrs = 0;
4047
IsMasked = true;
4048
 
4049
    {
4050
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
4051
      SmallVector<llvm::Value*, 12> Operands;
4052
 
4053
      // Please refer to comment under 'defvar NFList' in this file
4054
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
4055
          (!IsMasked && PolicyAttrs & RVV_VTA))
4056
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
4057
      else {
4058
        if (IsMasked)
4059
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
4060
        else // Unmasked
4061
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
4062
      }
4063
      unsigned PtrOperandIdx = IsMasked ?
4064
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
4065
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
4066
      Value *PtrOperand = Ops[PtrOperandIdx];
4067
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
4068
      Value *VLOperand = Ops[PtrOperandIdx + 2];
4069
      Operands.push_back(PtrOperand);
4070
      Operands.push_back(IndexOperand);
4071
      if (IsMasked)
4072
        Operands.push_back(Ops[NF]);
4073
      Operands.push_back(VLOperand);
4074
      if (IsMasked)
4075
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
4076
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
4077
 
4078
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
4079
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
4080
      clang::CharUnits Align =
4081
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
4082
      llvm::Value *V;
4083
      for (unsigned I = 0; I < NF; ++I) {
4084
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
4085
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
4086
      }
4087
      return V;
4088
    }
4089
    break;
4090
case RISCVVector::BI__builtin_rvv_vloxseg2ei16_v_mu:
4091
case RISCVVector::BI__builtin_rvv_vloxseg2ei32_v_mu:
4092
case RISCVVector::BI__builtin_rvv_vloxseg2ei64_v_mu:
4093
case RISCVVector::BI__builtin_rvv_vloxseg2ei8_v_mu:
4094
  ID = Intrinsic::riscv_vloxseg2_mask;
4095
  NF = 2;
4096
  PolicyAttrs = 1;
4097
IsMasked = true;
4098
 
4099
    {
4100
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
4101
      SmallVector<llvm::Value*, 12> Operands;
4102
 
4103
      // Please refer to comment under 'defvar NFList' in this file
4104
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
4105
          (!IsMasked && PolicyAttrs & RVV_VTA))
4106
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
4107
      else {
4108
        if (IsMasked)
4109
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
4110
        else // Unmasked
4111
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
4112
      }
4113
      unsigned PtrOperandIdx = IsMasked ?
4114
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
4115
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
4116
      Value *PtrOperand = Ops[PtrOperandIdx];
4117
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
4118
      Value *VLOperand = Ops[PtrOperandIdx + 2];
4119
      Operands.push_back(PtrOperand);
4120
      Operands.push_back(IndexOperand);
4121
      if (IsMasked)
4122
        Operands.push_back(Ops[NF]);
4123
      Operands.push_back(VLOperand);
4124
      if (IsMasked)
4125
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
4126
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
4127
 
4128
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
4129
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
4130
      clang::CharUnits Align =
4131
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
4132
      llvm::Value *V;
4133
      for (unsigned I = 0; I < NF; ++I) {
4134
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
4135
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
4136
      }
4137
      return V;
4138
    }
4139
    break;
4140
case RISCVVector::BI__builtin_rvv_vloxseg3ei8_v_tu:
4141
case RISCVVector::BI__builtin_rvv_vloxseg3ei16_v_tu:
4142
case RISCVVector::BI__builtin_rvv_vloxseg3ei32_v_tu:
4143
case RISCVVector::BI__builtin_rvv_vloxseg3ei64_v_tu:
4144
  ID = Intrinsic::riscv_vloxseg3;
4145
  NF = 3;
4146
  PolicyAttrs = 2;
4147
IsMasked = false;
4148
 
4149
    {
4150
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
4151
      SmallVector<llvm::Value*, 12> Operands;
4152
 
4153
      // Please refer to comment under 'defvar NFList' in this file
4154
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
4155
          (!IsMasked && PolicyAttrs & RVV_VTA))
4156
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
4157
      else {
4158
        if (IsMasked)
4159
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
4160
        else // Unmasked
4161
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
4162
      }
4163
      unsigned PtrOperandIdx = IsMasked ?
4164
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
4165
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
4166
      Value *PtrOperand = Ops[PtrOperandIdx];
4167
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
4168
      Value *VLOperand = Ops[PtrOperandIdx + 2];
4169
      Operands.push_back(PtrOperand);
4170
      Operands.push_back(IndexOperand);
4171
      if (IsMasked)
4172
        Operands.push_back(Ops[NF]);
4173
      Operands.push_back(VLOperand);
4174
      if (IsMasked)
4175
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
4176
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
4177
 
4178
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
4179
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
4180
      clang::CharUnits Align =
4181
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
4182
      llvm::Value *V;
4183
      for (unsigned I = 0; I < NF; ++I) {
4184
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
4185
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
4186
      }
4187
      return V;
4188
    }
4189
    break;
4190
case RISCVVector::BI__builtin_rvv_vloxseg3ei8_v_ta:
4191
case RISCVVector::BI__builtin_rvv_vloxseg3ei16_v_ta:
4192
case RISCVVector::BI__builtin_rvv_vloxseg3ei32_v_ta:
4193
case RISCVVector::BI__builtin_rvv_vloxseg3ei64_v_ta:
4194
  ID = Intrinsic::riscv_vloxseg3;
4195
  NF = 3;
4196
  PolicyAttrs = 3;
4197
IsMasked = false;
4198
 
4199
    {
4200
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
4201
      SmallVector<llvm::Value*, 12> Operands;
4202
 
4203
      // Please refer to comment under 'defvar NFList' in this file
4204
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
4205
          (!IsMasked && PolicyAttrs & RVV_VTA))
4206
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
4207
      else {
4208
        if (IsMasked)
4209
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
4210
        else // Unmasked
4211
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
4212
      }
4213
      unsigned PtrOperandIdx = IsMasked ?
4214
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
4215
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
4216
      Value *PtrOperand = Ops[PtrOperandIdx];
4217
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
4218
      Value *VLOperand = Ops[PtrOperandIdx + 2];
4219
      Operands.push_back(PtrOperand);
4220
      Operands.push_back(IndexOperand);
4221
      if (IsMasked)
4222
        Operands.push_back(Ops[NF]);
4223
      Operands.push_back(VLOperand);
4224
      if (IsMasked)
4225
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
4226
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
4227
 
4228
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
4229
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
4230
      clang::CharUnits Align =
4231
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
4232
      llvm::Value *V;
4233
      for (unsigned I = 0; I < NF; ++I) {
4234
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
4235
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
4236
      }
4237
      return V;
4238
    }
4239
    break;
4240
case RISCVVector::BI__builtin_rvv_vloxseg3ei8_v_tum:
4241
case RISCVVector::BI__builtin_rvv_vloxseg3ei16_v_tum:
4242
case RISCVVector::BI__builtin_rvv_vloxseg3ei32_v_tum:
4243
case RISCVVector::BI__builtin_rvv_vloxseg3ei64_v_tum:
4244
  ID = Intrinsic::riscv_vloxseg3_mask;
4245
  NF = 3;
4246
  PolicyAttrs = 2;
4247
IsMasked = true;
4248
 
4249
    {
4250
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
4251
      SmallVector<llvm::Value*, 12> Operands;
4252
 
4253
      // Please refer to comment under 'defvar NFList' in this file
4254
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
4255
          (!IsMasked && PolicyAttrs & RVV_VTA))
4256
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
4257
      else {
4258
        if (IsMasked)
4259
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
4260
        else // Unmasked
4261
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
4262
      }
4263
      unsigned PtrOperandIdx = IsMasked ?
4264
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
4265
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
4266
      Value *PtrOperand = Ops[PtrOperandIdx];
4267
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
4268
      Value *VLOperand = Ops[PtrOperandIdx + 2];
4269
      Operands.push_back(PtrOperand);
4270
      Operands.push_back(IndexOperand);
4271
      if (IsMasked)
4272
        Operands.push_back(Ops[NF]);
4273
      Operands.push_back(VLOperand);
4274
      if (IsMasked)
4275
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
4276
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
4277
 
4278
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
4279
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
4280
      clang::CharUnits Align =
4281
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
4282
      llvm::Value *V;
4283
      for (unsigned I = 0; I < NF; ++I) {
4284
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
4285
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
4286
      }
4287
      return V;
4288
    }
4289
    break;
4290
case RISCVVector::BI__builtin_rvv_vloxseg3ei8_v_tama:
4291
case RISCVVector::BI__builtin_rvv_vloxseg3ei16_v_tama:
4292
case RISCVVector::BI__builtin_rvv_vloxseg3ei32_v_tama:
4293
case RISCVVector::BI__builtin_rvv_vloxseg3ei64_v_tama:
4294
  ID = Intrinsic::riscv_vloxseg3_mask;
4295
  NF = 3;
4296
  PolicyAttrs = 3;
4297
IsMasked = true;
4298
 
4299
    {
4300
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
4301
      SmallVector<llvm::Value*, 12> Operands;
4302
 
4303
      // Please refer to comment under 'defvar NFList' in this file
4304
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
4305
          (!IsMasked && PolicyAttrs & RVV_VTA))
4306
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
4307
      else {
4308
        if (IsMasked)
4309
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
4310
        else // Unmasked
4311
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
4312
      }
4313
      unsigned PtrOperandIdx = IsMasked ?
4314
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
4315
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
4316
      Value *PtrOperand = Ops[PtrOperandIdx];
4317
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
4318
      Value *VLOperand = Ops[PtrOperandIdx + 2];
4319
      Operands.push_back(PtrOperand);
4320
      Operands.push_back(IndexOperand);
4321
      if (IsMasked)
4322
        Operands.push_back(Ops[NF]);
4323
      Operands.push_back(VLOperand);
4324
      if (IsMasked)
4325
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
4326
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
4327
 
4328
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
4329
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
4330
      clang::CharUnits Align =
4331
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
4332
      llvm::Value *V;
4333
      for (unsigned I = 0; I < NF; ++I) {
4334
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
4335
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
4336
      }
4337
      return V;
4338
    }
4339
    break;
4340
case RISCVVector::BI__builtin_rvv_vloxseg3ei8_v_tumu:
4341
case RISCVVector::BI__builtin_rvv_vloxseg3ei16_v_tumu:
4342
case RISCVVector::BI__builtin_rvv_vloxseg3ei32_v_tumu:
4343
case RISCVVector::BI__builtin_rvv_vloxseg3ei64_v_tumu:
4344
  ID = Intrinsic::riscv_vloxseg3_mask;
4345
  NF = 3;
4346
  PolicyAttrs = 0;
4347
IsMasked = true;
4348
 
4349
    {
4350
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
4351
      SmallVector<llvm::Value*, 12> Operands;
4352
 
4353
      // Please refer to comment under 'defvar NFList' in this file
4354
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
4355
          (!IsMasked && PolicyAttrs & RVV_VTA))
4356
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
4357
      else {
4358
        if (IsMasked)
4359
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
4360
        else // Unmasked
4361
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
4362
      }
4363
      unsigned PtrOperandIdx = IsMasked ?
4364
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
4365
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
4366
      Value *PtrOperand = Ops[PtrOperandIdx];
4367
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
4368
      Value *VLOperand = Ops[PtrOperandIdx + 2];
4369
      Operands.push_back(PtrOperand);
4370
      Operands.push_back(IndexOperand);
4371
      if (IsMasked)
4372
        Operands.push_back(Ops[NF]);
4373
      Operands.push_back(VLOperand);
4374
      if (IsMasked)
4375
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
4376
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
4377
 
4378
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
4379
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
4380
      clang::CharUnits Align =
4381
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
4382
      llvm::Value *V;
4383
      for (unsigned I = 0; I < NF; ++I) {
4384
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
4385
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
4386
      }
4387
      return V;
4388
    }
4389
    break;
4390
case RISCVVector::BI__builtin_rvv_vloxseg3ei8_v_mu:
4391
case RISCVVector::BI__builtin_rvv_vloxseg3ei16_v_mu:
4392
case RISCVVector::BI__builtin_rvv_vloxseg3ei32_v_mu:
4393
case RISCVVector::BI__builtin_rvv_vloxseg3ei64_v_mu:
4394
  ID = Intrinsic::riscv_vloxseg3_mask;
4395
  NF = 3;
4396
  PolicyAttrs = 1;
4397
IsMasked = true;
4398
 
4399
    {
4400
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
4401
      SmallVector<llvm::Value*, 12> Operands;
4402
 
4403
      // Please refer to comment under 'defvar NFList' in this file
4404
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
4405
          (!IsMasked && PolicyAttrs & RVV_VTA))
4406
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
4407
      else {
4408
        if (IsMasked)
4409
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
4410
        else // Unmasked
4411
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
4412
      }
4413
      unsigned PtrOperandIdx = IsMasked ?
4414
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
4415
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
4416
      Value *PtrOperand = Ops[PtrOperandIdx];
4417
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
4418
      Value *VLOperand = Ops[PtrOperandIdx + 2];
4419
      Operands.push_back(PtrOperand);
4420
      Operands.push_back(IndexOperand);
4421
      if (IsMasked)
4422
        Operands.push_back(Ops[NF]);
4423
      Operands.push_back(VLOperand);
4424
      if (IsMasked)
4425
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
4426
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
4427
 
4428
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
4429
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
4430
      clang::CharUnits Align =
4431
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
4432
      llvm::Value *V;
4433
      for (unsigned I = 0; I < NF; ++I) {
4434
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
4435
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
4436
      }
4437
      return V;
4438
    }
4439
    break;
4440
case RISCVVector::BI__builtin_rvv_vloxseg4ei8_v_tu:
4441
case RISCVVector::BI__builtin_rvv_vloxseg4ei16_v_tu:
4442
case RISCVVector::BI__builtin_rvv_vloxseg4ei32_v_tu:
4443
case RISCVVector::BI__builtin_rvv_vloxseg4ei64_v_tu:
4444
  ID = Intrinsic::riscv_vloxseg4;
4445
  NF = 4;
4446
  PolicyAttrs = 2;
4447
IsMasked = false;
4448
 
4449
    {
4450
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
4451
      SmallVector<llvm::Value*, 12> Operands;
4452
 
4453
      // Please refer to comment under 'defvar NFList' in this file
4454
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
4455
          (!IsMasked && PolicyAttrs & RVV_VTA))
4456
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
4457
      else {
4458
        if (IsMasked)
4459
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
4460
        else // Unmasked
4461
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
4462
      }
4463
      unsigned PtrOperandIdx = IsMasked ?
4464
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
4465
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
4466
      Value *PtrOperand = Ops[PtrOperandIdx];
4467
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
4468
      Value *VLOperand = Ops[PtrOperandIdx + 2];
4469
      Operands.push_back(PtrOperand);
4470
      Operands.push_back(IndexOperand);
4471
      if (IsMasked)
4472
        Operands.push_back(Ops[NF]);
4473
      Operands.push_back(VLOperand);
4474
      if (IsMasked)
4475
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
4476
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
4477
 
4478
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
4479
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
4480
      clang::CharUnits Align =
4481
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
4482
      llvm::Value *V;
4483
      for (unsigned I = 0; I < NF; ++I) {
4484
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
4485
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
4486
      }
4487
      return V;
4488
    }
4489
    break;
4490
case RISCVVector::BI__builtin_rvv_vloxseg4ei8_v_ta:
4491
case RISCVVector::BI__builtin_rvv_vloxseg4ei16_v_ta:
4492
case RISCVVector::BI__builtin_rvv_vloxseg4ei32_v_ta:
4493
case RISCVVector::BI__builtin_rvv_vloxseg4ei64_v_ta:
4494
  ID = Intrinsic::riscv_vloxseg4;
4495
  NF = 4;
4496
  PolicyAttrs = 3;
4497
IsMasked = false;
4498
 
4499
    {
4500
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
4501
      SmallVector<llvm::Value*, 12> Operands;
4502
 
4503
      // Please refer to comment under 'defvar NFList' in this file
4504
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
4505
          (!IsMasked && PolicyAttrs & RVV_VTA))
4506
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
4507
      else {
4508
        if (IsMasked)
4509
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
4510
        else // Unmasked
4511
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
4512
      }
4513
      unsigned PtrOperandIdx = IsMasked ?
4514
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
4515
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
4516
      Value *PtrOperand = Ops[PtrOperandIdx];
4517
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
4518
      Value *VLOperand = Ops[PtrOperandIdx + 2];
4519
      Operands.push_back(PtrOperand);
4520
      Operands.push_back(IndexOperand);
4521
      if (IsMasked)
4522
        Operands.push_back(Ops[NF]);
4523
      Operands.push_back(VLOperand);
4524
      if (IsMasked)
4525
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
4526
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
4527
 
4528
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
4529
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
4530
      clang::CharUnits Align =
4531
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
4532
      llvm::Value *V;
4533
      for (unsigned I = 0; I < NF; ++I) {
4534
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
4535
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
4536
      }
4537
      return V;
4538
    }
4539
    break;
4540
case RISCVVector::BI__builtin_rvv_vloxseg4ei8_v_tum:
4541
case RISCVVector::BI__builtin_rvv_vloxseg4ei16_v_tum:
4542
case RISCVVector::BI__builtin_rvv_vloxseg4ei32_v_tum:
4543
case RISCVVector::BI__builtin_rvv_vloxseg4ei64_v_tum:
4544
  ID = Intrinsic::riscv_vloxseg4_mask;
4545
  NF = 4;
4546
  PolicyAttrs = 2;
4547
IsMasked = true;
4548
 
4549
    {
4550
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
4551
      SmallVector<llvm::Value*, 12> Operands;
4552
 
4553
      // Please refer to comment under 'defvar NFList' in this file
4554
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
4555
          (!IsMasked && PolicyAttrs & RVV_VTA))
4556
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
4557
      else {
4558
        if (IsMasked)
4559
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
4560
        else // Unmasked
4561
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
4562
      }
4563
      unsigned PtrOperandIdx = IsMasked ?
4564
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
4565
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
4566
      Value *PtrOperand = Ops[PtrOperandIdx];
4567
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
4568
      Value *VLOperand = Ops[PtrOperandIdx + 2];
4569
      Operands.push_back(PtrOperand);
4570
      Operands.push_back(IndexOperand);
4571
      if (IsMasked)
4572
        Operands.push_back(Ops[NF]);
4573
      Operands.push_back(VLOperand);
4574
      if (IsMasked)
4575
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
4576
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
4577
 
4578
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
4579
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
4580
      clang::CharUnits Align =
4581
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
4582
      llvm::Value *V;
4583
      for (unsigned I = 0; I < NF; ++I) {
4584
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
4585
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
4586
      }
4587
      return V;
4588
    }
4589
    break;
4590
case RISCVVector::BI__builtin_rvv_vloxseg4ei8_v_tama:
4591
case RISCVVector::BI__builtin_rvv_vloxseg4ei16_v_tama:
4592
case RISCVVector::BI__builtin_rvv_vloxseg4ei32_v_tama:
4593
case RISCVVector::BI__builtin_rvv_vloxseg4ei64_v_tama:
4594
  ID = Intrinsic::riscv_vloxseg4_mask;
4595
  NF = 4;
4596
  PolicyAttrs = 3;
4597
IsMasked = true;
4598
 
4599
    {
4600
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
4601
      SmallVector<llvm::Value*, 12> Operands;
4602
 
4603
      // Please refer to comment under 'defvar NFList' in this file
4604
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
4605
          (!IsMasked && PolicyAttrs & RVV_VTA))
4606
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
4607
      else {
4608
        if (IsMasked)
4609
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
4610
        else // Unmasked
4611
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
4612
      }
4613
      unsigned PtrOperandIdx = IsMasked ?
4614
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
4615
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
4616
      Value *PtrOperand = Ops[PtrOperandIdx];
4617
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
4618
      Value *VLOperand = Ops[PtrOperandIdx + 2];
4619
      Operands.push_back(PtrOperand);
4620
      Operands.push_back(IndexOperand);
4621
      if (IsMasked)
4622
        Operands.push_back(Ops[NF]);
4623
      Operands.push_back(VLOperand);
4624
      if (IsMasked)
4625
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
4626
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
4627
 
4628
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
4629
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
4630
      clang::CharUnits Align =
4631
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
4632
      llvm::Value *V;
4633
      for (unsigned I = 0; I < NF; ++I) {
4634
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
4635
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
4636
      }
4637
      return V;
4638
    }
4639
    break;
4640
case RISCVVector::BI__builtin_rvv_vloxseg4ei8_v_tumu:
4641
case RISCVVector::BI__builtin_rvv_vloxseg4ei16_v_tumu:
4642
case RISCVVector::BI__builtin_rvv_vloxseg4ei32_v_tumu:
4643
case RISCVVector::BI__builtin_rvv_vloxseg4ei64_v_tumu:
4644
  ID = Intrinsic::riscv_vloxseg4_mask;
4645
  NF = 4;
4646
  PolicyAttrs = 0;
4647
IsMasked = true;
4648
 
4649
    {
4650
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
4651
      SmallVector<llvm::Value*, 12> Operands;
4652
 
4653
      // Please refer to comment under 'defvar NFList' in this file
4654
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
4655
          (!IsMasked && PolicyAttrs & RVV_VTA))
4656
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
4657
      else {
4658
        if (IsMasked)
4659
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
4660
        else // Unmasked
4661
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
4662
      }
4663
      unsigned PtrOperandIdx = IsMasked ?
4664
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
4665
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
4666
      Value *PtrOperand = Ops[PtrOperandIdx];
4667
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
4668
      Value *VLOperand = Ops[PtrOperandIdx + 2];
4669
      Operands.push_back(PtrOperand);
4670
      Operands.push_back(IndexOperand);
4671
      if (IsMasked)
4672
        Operands.push_back(Ops[NF]);
4673
      Operands.push_back(VLOperand);
4674
      if (IsMasked)
4675
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
4676
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
4677
 
4678
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
4679
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
4680
      clang::CharUnits Align =
4681
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
4682
      llvm::Value *V;
4683
      for (unsigned I = 0; I < NF; ++I) {
4684
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
4685
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
4686
      }
4687
      return V;
4688
    }
4689
    break;
4690
case RISCVVector::BI__builtin_rvv_vloxseg4ei8_v_mu:
4691
case RISCVVector::BI__builtin_rvv_vloxseg4ei16_v_mu:
4692
case RISCVVector::BI__builtin_rvv_vloxseg4ei32_v_mu:
4693
case RISCVVector::BI__builtin_rvv_vloxseg4ei64_v_mu:
4694
  ID = Intrinsic::riscv_vloxseg4_mask;
4695
  NF = 4;
4696
  PolicyAttrs = 1;
4697
IsMasked = true;
4698
 
4699
    {
4700
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
4701
      SmallVector<llvm::Value*, 12> Operands;
4702
 
4703
      // Please refer to comment under 'defvar NFList' in this file
4704
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
4705
          (!IsMasked && PolicyAttrs & RVV_VTA))
4706
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
4707
      else {
4708
        if (IsMasked)
4709
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
4710
        else // Unmasked
4711
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
4712
      }
4713
      unsigned PtrOperandIdx = IsMasked ?
4714
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
4715
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
4716
      Value *PtrOperand = Ops[PtrOperandIdx];
4717
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
4718
      Value *VLOperand = Ops[PtrOperandIdx + 2];
4719
      Operands.push_back(PtrOperand);
4720
      Operands.push_back(IndexOperand);
4721
      if (IsMasked)
4722
        Operands.push_back(Ops[NF]);
4723
      Operands.push_back(VLOperand);
4724
      if (IsMasked)
4725
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
4726
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
4727
 
4728
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
4729
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
4730
      clang::CharUnits Align =
4731
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
4732
      llvm::Value *V;
4733
      for (unsigned I = 0; I < NF; ++I) {
4734
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
4735
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
4736
      }
4737
      return V;
4738
    }
4739
    break;
4740
case RISCVVector::BI__builtin_rvv_vloxseg5ei8_v_tu:
4741
case RISCVVector::BI__builtin_rvv_vloxseg5ei16_v_tu:
4742
case RISCVVector::BI__builtin_rvv_vloxseg5ei32_v_tu:
4743
case RISCVVector::BI__builtin_rvv_vloxseg5ei64_v_tu:
4744
  ID = Intrinsic::riscv_vloxseg5;
4745
  NF = 5;
4746
  PolicyAttrs = 2;
4747
IsMasked = false;
4748
 
4749
    {
4750
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
4751
      SmallVector<llvm::Value*, 12> Operands;
4752
 
4753
      // Please refer to comment under 'defvar NFList' in this file
4754
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
4755
          (!IsMasked && PolicyAttrs & RVV_VTA))
4756
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
4757
      else {
4758
        if (IsMasked)
4759
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
4760
        else // Unmasked
4761
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
4762
      }
4763
      unsigned PtrOperandIdx = IsMasked ?
4764
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
4765
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
4766
      Value *PtrOperand = Ops[PtrOperandIdx];
4767
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
4768
      Value *VLOperand = Ops[PtrOperandIdx + 2];
4769
      Operands.push_back(PtrOperand);
4770
      Operands.push_back(IndexOperand);
4771
      if (IsMasked)
4772
        Operands.push_back(Ops[NF]);
4773
      Operands.push_back(VLOperand);
4774
      if (IsMasked)
4775
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
4776
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
4777
 
4778
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
4779
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
4780
      clang::CharUnits Align =
4781
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
4782
      llvm::Value *V;
4783
      for (unsigned I = 0; I < NF; ++I) {
4784
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
4785
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
4786
      }
4787
      return V;
4788
    }
4789
    break;
4790
case RISCVVector::BI__builtin_rvv_vloxseg5ei8_v_ta:
4791
case RISCVVector::BI__builtin_rvv_vloxseg5ei16_v_ta:
4792
case RISCVVector::BI__builtin_rvv_vloxseg5ei32_v_ta:
4793
case RISCVVector::BI__builtin_rvv_vloxseg5ei64_v_ta:
4794
  ID = Intrinsic::riscv_vloxseg5;
4795
  NF = 5;
4796
  PolicyAttrs = 3;
4797
IsMasked = false;
4798
 
4799
    {
4800
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
4801
      SmallVector<llvm::Value*, 12> Operands;
4802
 
4803
      // Please refer to comment under 'defvar NFList' in this file
4804
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
4805
          (!IsMasked && PolicyAttrs & RVV_VTA))
4806
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
4807
      else {
4808
        if (IsMasked)
4809
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
4810
        else // Unmasked
4811
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
4812
      }
4813
      unsigned PtrOperandIdx = IsMasked ?
4814
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
4815
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
4816
      Value *PtrOperand = Ops[PtrOperandIdx];
4817
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
4818
      Value *VLOperand = Ops[PtrOperandIdx + 2];
4819
      Operands.push_back(PtrOperand);
4820
      Operands.push_back(IndexOperand);
4821
      if (IsMasked)
4822
        Operands.push_back(Ops[NF]);
4823
      Operands.push_back(VLOperand);
4824
      if (IsMasked)
4825
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
4826
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
4827
 
4828
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
4829
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
4830
      clang::CharUnits Align =
4831
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
4832
      llvm::Value *V;
4833
      for (unsigned I = 0; I < NF; ++I) {
4834
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
4835
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
4836
      }
4837
      return V;
4838
    }
4839
    break;
4840
case RISCVVector::BI__builtin_rvv_vloxseg5ei8_v_tum:
4841
case RISCVVector::BI__builtin_rvv_vloxseg5ei16_v_tum:
4842
case RISCVVector::BI__builtin_rvv_vloxseg5ei32_v_tum:
4843
case RISCVVector::BI__builtin_rvv_vloxseg5ei64_v_tum:
4844
  ID = Intrinsic::riscv_vloxseg5_mask;
4845
  NF = 5;
4846
  PolicyAttrs = 2;
4847
IsMasked = true;
4848
 
4849
    {
4850
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
4851
      SmallVector<llvm::Value*, 12> Operands;
4852
 
4853
      // Please refer to comment under 'defvar NFList' in this file
4854
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
4855
          (!IsMasked && PolicyAttrs & RVV_VTA))
4856
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
4857
      else {
4858
        if (IsMasked)
4859
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
4860
        else // Unmasked
4861
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
4862
      }
4863
      unsigned PtrOperandIdx = IsMasked ?
4864
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
4865
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
4866
      Value *PtrOperand = Ops[PtrOperandIdx];
4867
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
4868
      Value *VLOperand = Ops[PtrOperandIdx + 2];
4869
      Operands.push_back(PtrOperand);
4870
      Operands.push_back(IndexOperand);
4871
      if (IsMasked)
4872
        Operands.push_back(Ops[NF]);
4873
      Operands.push_back(VLOperand);
4874
      if (IsMasked)
4875
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
4876
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
4877
 
4878
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
4879
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
4880
      clang::CharUnits Align =
4881
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
4882
      llvm::Value *V;
4883
      for (unsigned I = 0; I < NF; ++I) {
4884
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
4885
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
4886
      }
4887
      return V;
4888
    }
4889
    break;
4890
case RISCVVector::BI__builtin_rvv_vloxseg5ei8_v_tama:
4891
case RISCVVector::BI__builtin_rvv_vloxseg5ei16_v_tama:
4892
case RISCVVector::BI__builtin_rvv_vloxseg5ei32_v_tama:
4893
case RISCVVector::BI__builtin_rvv_vloxseg5ei64_v_tama:
4894
  ID = Intrinsic::riscv_vloxseg5_mask;
4895
  NF = 5;
4896
  PolicyAttrs = 3;
4897
IsMasked = true;
4898
 
4899
    {
4900
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
4901
      SmallVector<llvm::Value*, 12> Operands;
4902
 
4903
      // Please refer to comment under 'defvar NFList' in this file
4904
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
4905
          (!IsMasked && PolicyAttrs & RVV_VTA))
4906
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
4907
      else {
4908
        if (IsMasked)
4909
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
4910
        else // Unmasked
4911
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
4912
      }
4913
      unsigned PtrOperandIdx = IsMasked ?
4914
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
4915
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
4916
      Value *PtrOperand = Ops[PtrOperandIdx];
4917
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
4918
      Value *VLOperand = Ops[PtrOperandIdx + 2];
4919
      Operands.push_back(PtrOperand);
4920
      Operands.push_back(IndexOperand);
4921
      if (IsMasked)
4922
        Operands.push_back(Ops[NF]);
4923
      Operands.push_back(VLOperand);
4924
      if (IsMasked)
4925
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
4926
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
4927
 
4928
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
4929
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
4930
      clang::CharUnits Align =
4931
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
4932
      llvm::Value *V;
4933
      for (unsigned I = 0; I < NF; ++I) {
4934
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
4935
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
4936
      }
4937
      return V;
4938
    }
4939
    break;
4940
case RISCVVector::BI__builtin_rvv_vloxseg5ei8_v_tumu:
4941
case RISCVVector::BI__builtin_rvv_vloxseg5ei16_v_tumu:
4942
case RISCVVector::BI__builtin_rvv_vloxseg5ei32_v_tumu:
4943
case RISCVVector::BI__builtin_rvv_vloxseg5ei64_v_tumu:
4944
  ID = Intrinsic::riscv_vloxseg5_mask;
4945
  NF = 5;
4946
  PolicyAttrs = 0;
4947
IsMasked = true;
4948
 
4949
    {
4950
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
4951
      SmallVector<llvm::Value*, 12> Operands;
4952
 
4953
      // Please refer to comment under 'defvar NFList' in this file
4954
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
4955
          (!IsMasked && PolicyAttrs & RVV_VTA))
4956
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
4957
      else {
4958
        if (IsMasked)
4959
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
4960
        else // Unmasked
4961
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
4962
      }
4963
      unsigned PtrOperandIdx = IsMasked ?
4964
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
4965
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
4966
      Value *PtrOperand = Ops[PtrOperandIdx];
4967
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
4968
      Value *VLOperand = Ops[PtrOperandIdx + 2];
4969
      Operands.push_back(PtrOperand);
4970
      Operands.push_back(IndexOperand);
4971
      if (IsMasked)
4972
        Operands.push_back(Ops[NF]);
4973
      Operands.push_back(VLOperand);
4974
      if (IsMasked)
4975
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
4976
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
4977
 
4978
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
4979
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
4980
      clang::CharUnits Align =
4981
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
4982
      llvm::Value *V;
4983
      for (unsigned I = 0; I < NF; ++I) {
4984
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
4985
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
4986
      }
4987
      return V;
4988
    }
4989
    break;
4990
case RISCVVector::BI__builtin_rvv_vloxseg5ei8_v_mu:
4991
case RISCVVector::BI__builtin_rvv_vloxseg5ei16_v_mu:
4992
case RISCVVector::BI__builtin_rvv_vloxseg5ei32_v_mu:
4993
case RISCVVector::BI__builtin_rvv_vloxseg5ei64_v_mu:
4994
  ID = Intrinsic::riscv_vloxseg5_mask;
4995
  NF = 5;
4996
  PolicyAttrs = 1;
4997
IsMasked = true;
4998
 
4999
    {
5000
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
5001
      SmallVector<llvm::Value*, 12> Operands;
5002
 
5003
      // Please refer to comment under 'defvar NFList' in this file
5004
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
5005
          (!IsMasked && PolicyAttrs & RVV_VTA))
5006
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
5007
      else {
5008
        if (IsMasked)
5009
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
5010
        else // Unmasked
5011
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
5012
      }
5013
      unsigned PtrOperandIdx = IsMasked ?
5014
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
5015
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
5016
      Value *PtrOperand = Ops[PtrOperandIdx];
5017
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
5018
      Value *VLOperand = Ops[PtrOperandIdx + 2];
5019
      Operands.push_back(PtrOperand);
5020
      Operands.push_back(IndexOperand);
5021
      if (IsMasked)
5022
        Operands.push_back(Ops[NF]);
5023
      Operands.push_back(VLOperand);
5024
      if (IsMasked)
5025
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
5026
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
5027
 
5028
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
5029
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
5030
      clang::CharUnits Align =
5031
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
5032
      llvm::Value *V;
5033
      for (unsigned I = 0; I < NF; ++I) {
5034
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
5035
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
5036
      }
5037
      return V;
5038
    }
5039
    break;
5040
case RISCVVector::BI__builtin_rvv_vloxseg6ei8_v_tu:
5041
case RISCVVector::BI__builtin_rvv_vloxseg6ei16_v_tu:
5042
case RISCVVector::BI__builtin_rvv_vloxseg6ei32_v_tu:
5043
case RISCVVector::BI__builtin_rvv_vloxseg6ei64_v_tu:
5044
  ID = Intrinsic::riscv_vloxseg6;
5045
  NF = 6;
5046
  PolicyAttrs = 2;
5047
IsMasked = false;
5048
 
5049
    {
5050
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
5051
      SmallVector<llvm::Value*, 12> Operands;
5052
 
5053
      // Please refer to comment under 'defvar NFList' in this file
5054
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
5055
          (!IsMasked && PolicyAttrs & RVV_VTA))
5056
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
5057
      else {
5058
        if (IsMasked)
5059
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
5060
        else // Unmasked
5061
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
5062
      }
5063
      unsigned PtrOperandIdx = IsMasked ?
5064
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
5065
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
5066
      Value *PtrOperand = Ops[PtrOperandIdx];
5067
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
5068
      Value *VLOperand = Ops[PtrOperandIdx + 2];
5069
      Operands.push_back(PtrOperand);
5070
      Operands.push_back(IndexOperand);
5071
      if (IsMasked)
5072
        Operands.push_back(Ops[NF]);
5073
      Operands.push_back(VLOperand);
5074
      if (IsMasked)
5075
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
5076
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
5077
 
5078
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
5079
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
5080
      clang::CharUnits Align =
5081
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
5082
      llvm::Value *V;
5083
      for (unsigned I = 0; I < NF; ++I) {
5084
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
5085
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
5086
      }
5087
      return V;
5088
    }
5089
    break;
5090
case RISCVVector::BI__builtin_rvv_vloxseg6ei8_v_ta:
5091
case RISCVVector::BI__builtin_rvv_vloxseg6ei16_v_ta:
5092
case RISCVVector::BI__builtin_rvv_vloxseg6ei32_v_ta:
5093
case RISCVVector::BI__builtin_rvv_vloxseg6ei64_v_ta:
5094
  ID = Intrinsic::riscv_vloxseg6;
5095
  NF = 6;
5096
  PolicyAttrs = 3;
5097
IsMasked = false;
5098
 
5099
    {
5100
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
5101
      SmallVector<llvm::Value*, 12> Operands;
5102
 
5103
      // Please refer to comment under 'defvar NFList' in this file
5104
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
5105
          (!IsMasked && PolicyAttrs & RVV_VTA))
5106
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
5107
      else {
5108
        if (IsMasked)
5109
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
5110
        else // Unmasked
5111
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
5112
      }
5113
      unsigned PtrOperandIdx = IsMasked ?
5114
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
5115
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
5116
      Value *PtrOperand = Ops[PtrOperandIdx];
5117
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
5118
      Value *VLOperand = Ops[PtrOperandIdx + 2];
5119
      Operands.push_back(PtrOperand);
5120
      Operands.push_back(IndexOperand);
5121
      if (IsMasked)
5122
        Operands.push_back(Ops[NF]);
5123
      Operands.push_back(VLOperand);
5124
      if (IsMasked)
5125
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
5126
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
5127
 
5128
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
5129
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
5130
      clang::CharUnits Align =
5131
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
5132
      llvm::Value *V;
5133
      for (unsigned I = 0; I < NF; ++I) {
5134
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
5135
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
5136
      }
5137
      return V;
5138
    }
5139
    break;
5140
case RISCVVector::BI__builtin_rvv_vloxseg6ei8_v_tum:
5141
case RISCVVector::BI__builtin_rvv_vloxseg6ei16_v_tum:
5142
case RISCVVector::BI__builtin_rvv_vloxseg6ei32_v_tum:
5143
case RISCVVector::BI__builtin_rvv_vloxseg6ei64_v_tum:
5144
  ID = Intrinsic::riscv_vloxseg6_mask;
5145
  NF = 6;
5146
  PolicyAttrs = 2;
5147
IsMasked = true;
5148
 
5149
    {
5150
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
5151
      SmallVector<llvm::Value*, 12> Operands;
5152
 
5153
      // Please refer to comment under 'defvar NFList' in this file
5154
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
5155
          (!IsMasked && PolicyAttrs & RVV_VTA))
5156
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
5157
      else {
5158
        if (IsMasked)
5159
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
5160
        else // Unmasked
5161
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
5162
      }
5163
      unsigned PtrOperandIdx = IsMasked ?
5164
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
5165
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
5166
      Value *PtrOperand = Ops[PtrOperandIdx];
5167
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
5168
      Value *VLOperand = Ops[PtrOperandIdx + 2];
5169
      Operands.push_back(PtrOperand);
5170
      Operands.push_back(IndexOperand);
5171
      if (IsMasked)
5172
        Operands.push_back(Ops[NF]);
5173
      Operands.push_back(VLOperand);
5174
      if (IsMasked)
5175
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
5176
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
5177
 
5178
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
5179
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
5180
      clang::CharUnits Align =
5181
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
5182
      llvm::Value *V;
5183
      for (unsigned I = 0; I < NF; ++I) {
5184
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
5185
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
5186
      }
5187
      return V;
5188
    }
5189
    break;
5190
case RISCVVector::BI__builtin_rvv_vloxseg6ei8_v_tama:
5191
case RISCVVector::BI__builtin_rvv_vloxseg6ei16_v_tama:
5192
case RISCVVector::BI__builtin_rvv_vloxseg6ei32_v_tama:
5193
case RISCVVector::BI__builtin_rvv_vloxseg6ei64_v_tama:
5194
  ID = Intrinsic::riscv_vloxseg6_mask;
5195
  NF = 6;
5196
  PolicyAttrs = 3;
5197
IsMasked = true;
5198
 
5199
    {
5200
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
5201
      SmallVector<llvm::Value*, 12> Operands;
5202
 
5203
      // Please refer to comment under 'defvar NFList' in this file
5204
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
5205
          (!IsMasked && PolicyAttrs & RVV_VTA))
5206
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
5207
      else {
5208
        if (IsMasked)
5209
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
5210
        else // Unmasked
5211
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
5212
      }
5213
      unsigned PtrOperandIdx = IsMasked ?
5214
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
5215
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
5216
      Value *PtrOperand = Ops[PtrOperandIdx];
5217
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
5218
      Value *VLOperand = Ops[PtrOperandIdx + 2];
5219
      Operands.push_back(PtrOperand);
5220
      Operands.push_back(IndexOperand);
5221
      if (IsMasked)
5222
        Operands.push_back(Ops[NF]);
5223
      Operands.push_back(VLOperand);
5224
      if (IsMasked)
5225
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
5226
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
5227
 
5228
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
5229
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
5230
      clang::CharUnits Align =
5231
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
5232
      llvm::Value *V;
5233
      for (unsigned I = 0; I < NF; ++I) {
5234
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
5235
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
5236
      }
5237
      return V;
5238
    }
5239
    break;
5240
case RISCVVector::BI__builtin_rvv_vloxseg6ei8_v_tumu:
5241
case RISCVVector::BI__builtin_rvv_vloxseg6ei16_v_tumu:
5242
case RISCVVector::BI__builtin_rvv_vloxseg6ei32_v_tumu:
5243
case RISCVVector::BI__builtin_rvv_vloxseg6ei64_v_tumu:
5244
  ID = Intrinsic::riscv_vloxseg6_mask;
5245
  NF = 6;
5246
  PolicyAttrs = 0;
5247
IsMasked = true;
5248
 
5249
    {
5250
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
5251
      SmallVector<llvm::Value*, 12> Operands;
5252
 
5253
      // Please refer to comment under 'defvar NFList' in this file
5254
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
5255
          (!IsMasked && PolicyAttrs & RVV_VTA))
5256
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
5257
      else {
5258
        if (IsMasked)
5259
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
5260
        else // Unmasked
5261
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
5262
      }
5263
      unsigned PtrOperandIdx = IsMasked ?
5264
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
5265
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
5266
      Value *PtrOperand = Ops[PtrOperandIdx];
5267
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
5268
      Value *VLOperand = Ops[PtrOperandIdx + 2];
5269
      Operands.push_back(PtrOperand);
5270
      Operands.push_back(IndexOperand);
5271
      if (IsMasked)
5272
        Operands.push_back(Ops[NF]);
5273
      Operands.push_back(VLOperand);
5274
      if (IsMasked)
5275
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
5276
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
5277
 
5278
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
5279
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
5280
      clang::CharUnits Align =
5281
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
5282
      llvm::Value *V;
5283
      for (unsigned I = 0; I < NF; ++I) {
5284
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
5285
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
5286
      }
5287
      return V;
5288
    }
5289
    break;
5290
case RISCVVector::BI__builtin_rvv_vloxseg6ei8_v_mu:
5291
case RISCVVector::BI__builtin_rvv_vloxseg6ei16_v_mu:
5292
case RISCVVector::BI__builtin_rvv_vloxseg6ei32_v_mu:
5293
case RISCVVector::BI__builtin_rvv_vloxseg6ei64_v_mu:
5294
  ID = Intrinsic::riscv_vloxseg6_mask;
5295
  NF = 6;
5296
  PolicyAttrs = 1;
5297
IsMasked = true;
5298
 
5299
    {
5300
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
5301
      SmallVector<llvm::Value*, 12> Operands;
5302
 
5303
      // Please refer to comment under 'defvar NFList' in this file
5304
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
5305
          (!IsMasked && PolicyAttrs & RVV_VTA))
5306
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
5307
      else {
5308
        if (IsMasked)
5309
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
5310
        else // Unmasked
5311
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
5312
      }
5313
      unsigned PtrOperandIdx = IsMasked ?
5314
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
5315
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
5316
      Value *PtrOperand = Ops[PtrOperandIdx];
5317
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
5318
      Value *VLOperand = Ops[PtrOperandIdx + 2];
5319
      Operands.push_back(PtrOperand);
5320
      Operands.push_back(IndexOperand);
5321
      if (IsMasked)
5322
        Operands.push_back(Ops[NF]);
5323
      Operands.push_back(VLOperand);
5324
      if (IsMasked)
5325
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
5326
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
5327
 
5328
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
5329
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
5330
      clang::CharUnits Align =
5331
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
5332
      llvm::Value *V;
5333
      for (unsigned I = 0; I < NF; ++I) {
5334
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
5335
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
5336
      }
5337
      return V;
5338
    }
5339
    break;
5340
case RISCVVector::BI__builtin_rvv_vloxseg7ei8_v_tu:
5341
case RISCVVector::BI__builtin_rvv_vloxseg7ei16_v_tu:
5342
case RISCVVector::BI__builtin_rvv_vloxseg7ei32_v_tu:
5343
case RISCVVector::BI__builtin_rvv_vloxseg7ei64_v_tu:
5344
  ID = Intrinsic::riscv_vloxseg7;
5345
  NF = 7;
5346
  PolicyAttrs = 2;
5347
IsMasked = false;
5348
 
5349
    {
5350
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
5351
      SmallVector<llvm::Value*, 12> Operands;
5352
 
5353
      // Please refer to comment under 'defvar NFList' in this file
5354
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
5355
          (!IsMasked && PolicyAttrs & RVV_VTA))
5356
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
5357
      else {
5358
        if (IsMasked)
5359
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
5360
        else // Unmasked
5361
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
5362
      }
5363
      unsigned PtrOperandIdx = IsMasked ?
5364
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
5365
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
5366
      Value *PtrOperand = Ops[PtrOperandIdx];
5367
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
5368
      Value *VLOperand = Ops[PtrOperandIdx + 2];
5369
      Operands.push_back(PtrOperand);
5370
      Operands.push_back(IndexOperand);
5371
      if (IsMasked)
5372
        Operands.push_back(Ops[NF]);
5373
      Operands.push_back(VLOperand);
5374
      if (IsMasked)
5375
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
5376
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
5377
 
5378
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
5379
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
5380
      clang::CharUnits Align =
5381
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
5382
      llvm::Value *V;
5383
      for (unsigned I = 0; I < NF; ++I) {
5384
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
5385
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
5386
      }
5387
      return V;
5388
    }
5389
    break;
5390
case RISCVVector::BI__builtin_rvv_vloxseg7ei8_v_ta:
5391
case RISCVVector::BI__builtin_rvv_vloxseg7ei16_v_ta:
5392
case RISCVVector::BI__builtin_rvv_vloxseg7ei32_v_ta:
5393
case RISCVVector::BI__builtin_rvv_vloxseg7ei64_v_ta:
5394
  ID = Intrinsic::riscv_vloxseg7;
5395
  NF = 7;
5396
  PolicyAttrs = 3;
5397
IsMasked = false;
5398
 
5399
    {
5400
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
5401
      SmallVector<llvm::Value*, 12> Operands;
5402
 
5403
      // Please refer to comment under 'defvar NFList' in this file
5404
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
5405
          (!IsMasked && PolicyAttrs & RVV_VTA))
5406
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
5407
      else {
5408
        if (IsMasked)
5409
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
5410
        else // Unmasked
5411
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
5412
      }
5413
      unsigned PtrOperandIdx = IsMasked ?
5414
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
5415
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
5416
      Value *PtrOperand = Ops[PtrOperandIdx];
5417
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
5418
      Value *VLOperand = Ops[PtrOperandIdx + 2];
5419
      Operands.push_back(PtrOperand);
5420
      Operands.push_back(IndexOperand);
5421
      if (IsMasked)
5422
        Operands.push_back(Ops[NF]);
5423
      Operands.push_back(VLOperand);
5424
      if (IsMasked)
5425
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
5426
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
5427
 
5428
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
5429
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
5430
      clang::CharUnits Align =
5431
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
5432
      llvm::Value *V;
5433
      for (unsigned I = 0; I < NF; ++I) {
5434
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
5435
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
5436
      }
5437
      return V;
5438
    }
5439
    break;
5440
case RISCVVector::BI__builtin_rvv_vloxseg7ei8_v_tum:
5441
case RISCVVector::BI__builtin_rvv_vloxseg7ei16_v_tum:
5442
case RISCVVector::BI__builtin_rvv_vloxseg7ei32_v_tum:
5443
case RISCVVector::BI__builtin_rvv_vloxseg7ei64_v_tum:
5444
  ID = Intrinsic::riscv_vloxseg7_mask;
5445
  NF = 7;
5446
  PolicyAttrs = 2;
5447
IsMasked = true;
5448
 
5449
    {
5450
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
5451
      SmallVector<llvm::Value*, 12> Operands;
5452
 
5453
      // Please refer to comment under 'defvar NFList' in this file
5454
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
5455
          (!IsMasked && PolicyAttrs & RVV_VTA))
5456
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
5457
      else {
5458
        if (IsMasked)
5459
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
5460
        else // Unmasked
5461
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
5462
      }
5463
      unsigned PtrOperandIdx = IsMasked ?
5464
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
5465
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
5466
      Value *PtrOperand = Ops[PtrOperandIdx];
5467
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
5468
      Value *VLOperand = Ops[PtrOperandIdx + 2];
5469
      Operands.push_back(PtrOperand);
5470
      Operands.push_back(IndexOperand);
5471
      if (IsMasked)
5472
        Operands.push_back(Ops[NF]);
5473
      Operands.push_back(VLOperand);
5474
      if (IsMasked)
5475
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
5476
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
5477
 
5478
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
5479
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
5480
      clang::CharUnits Align =
5481
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
5482
      llvm::Value *V;
5483
      for (unsigned I = 0; I < NF; ++I) {
5484
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
5485
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
5486
      }
5487
      return V;
5488
    }
5489
    break;
5490
case RISCVVector::BI__builtin_rvv_vloxseg7ei8_v_tama:
5491
case RISCVVector::BI__builtin_rvv_vloxseg7ei16_v_tama:
5492
case RISCVVector::BI__builtin_rvv_vloxseg7ei32_v_tama:
5493
case RISCVVector::BI__builtin_rvv_vloxseg7ei64_v_tama:
5494
  ID = Intrinsic::riscv_vloxseg7_mask;
5495
  NF = 7;
5496
  PolicyAttrs = 3;
5497
IsMasked = true;
5498
 
5499
    {
5500
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
5501
      SmallVector<llvm::Value*, 12> Operands;
5502
 
5503
      // Please refer to comment under 'defvar NFList' in this file
5504
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
5505
          (!IsMasked && PolicyAttrs & RVV_VTA))
5506
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
5507
      else {
5508
        if (IsMasked)
5509
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
5510
        else // Unmasked
5511
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
5512
      }
5513
      unsigned PtrOperandIdx = IsMasked ?
5514
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
5515
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
5516
      Value *PtrOperand = Ops[PtrOperandIdx];
5517
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
5518
      Value *VLOperand = Ops[PtrOperandIdx + 2];
5519
      Operands.push_back(PtrOperand);
5520
      Operands.push_back(IndexOperand);
5521
      if (IsMasked)
5522
        Operands.push_back(Ops[NF]);
5523
      Operands.push_back(VLOperand);
5524
      if (IsMasked)
5525
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
5526
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
5527
 
5528
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
5529
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
5530
      clang::CharUnits Align =
5531
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
5532
      llvm::Value *V;
5533
      for (unsigned I = 0; I < NF; ++I) {
5534
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
5535
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
5536
      }
5537
      return V;
5538
    }
5539
    break;
5540
case RISCVVector::BI__builtin_rvv_vloxseg7ei8_v_tumu:
5541
case RISCVVector::BI__builtin_rvv_vloxseg7ei16_v_tumu:
5542
case RISCVVector::BI__builtin_rvv_vloxseg7ei32_v_tumu:
5543
case RISCVVector::BI__builtin_rvv_vloxseg7ei64_v_tumu:
5544
  ID = Intrinsic::riscv_vloxseg7_mask;
5545
  NF = 7;
5546
  PolicyAttrs = 0;
5547
IsMasked = true;
5548
 
5549
    {
5550
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
5551
      SmallVector<llvm::Value*, 12> Operands;
5552
 
5553
      // Please refer to comment under 'defvar NFList' in this file
5554
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
5555
          (!IsMasked && PolicyAttrs & RVV_VTA))
5556
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
5557
      else {
5558
        if (IsMasked)
5559
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
5560
        else // Unmasked
5561
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
5562
      }
5563
      unsigned PtrOperandIdx = IsMasked ?
5564
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
5565
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
5566
      Value *PtrOperand = Ops[PtrOperandIdx];
5567
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
5568
      Value *VLOperand = Ops[PtrOperandIdx + 2];
5569
      Operands.push_back(PtrOperand);
5570
      Operands.push_back(IndexOperand);
5571
      if (IsMasked)
5572
        Operands.push_back(Ops[NF]);
5573
      Operands.push_back(VLOperand);
5574
      if (IsMasked)
5575
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
5576
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
5577
 
5578
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
5579
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
5580
      clang::CharUnits Align =
5581
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
5582
      llvm::Value *V;
5583
      for (unsigned I = 0; I < NF; ++I) {
5584
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
5585
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
5586
      }
5587
      return V;
5588
    }
5589
    break;
5590
case RISCVVector::BI__builtin_rvv_vloxseg7ei8_v_mu:
5591
case RISCVVector::BI__builtin_rvv_vloxseg7ei16_v_mu:
5592
case RISCVVector::BI__builtin_rvv_vloxseg7ei32_v_mu:
5593
case RISCVVector::BI__builtin_rvv_vloxseg7ei64_v_mu:
5594
  ID = Intrinsic::riscv_vloxseg7_mask;
5595
  NF = 7;
5596
  PolicyAttrs = 1;
5597
IsMasked = true;
5598
 
5599
    {
5600
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
5601
      SmallVector<llvm::Value*, 12> Operands;
5602
 
5603
      // Please refer to comment under 'defvar NFList' in this file
5604
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
5605
          (!IsMasked && PolicyAttrs & RVV_VTA))
5606
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
5607
      else {
5608
        if (IsMasked)
5609
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
5610
        else // Unmasked
5611
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
5612
      }
5613
      unsigned PtrOperandIdx = IsMasked ?
5614
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
5615
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
5616
      Value *PtrOperand = Ops[PtrOperandIdx];
5617
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
5618
      Value *VLOperand = Ops[PtrOperandIdx + 2];
5619
      Operands.push_back(PtrOperand);
5620
      Operands.push_back(IndexOperand);
5621
      if (IsMasked)
5622
        Operands.push_back(Ops[NF]);
5623
      Operands.push_back(VLOperand);
5624
      if (IsMasked)
5625
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
5626
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
5627
 
5628
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
5629
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
5630
      clang::CharUnits Align =
5631
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
5632
      llvm::Value *V;
5633
      for (unsigned I = 0; I < NF; ++I) {
5634
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
5635
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
5636
      }
5637
      return V;
5638
    }
5639
    break;
5640
case RISCVVector::BI__builtin_rvv_vloxseg8ei8_v_tu:
5641
case RISCVVector::BI__builtin_rvv_vloxseg8ei16_v_tu:
5642
case RISCVVector::BI__builtin_rvv_vloxseg8ei32_v_tu:
5643
case RISCVVector::BI__builtin_rvv_vloxseg8ei64_v_tu:
5644
  ID = Intrinsic::riscv_vloxseg8;
5645
  NF = 8;
5646
  PolicyAttrs = 2;
5647
IsMasked = false;
5648
 
5649
    {
5650
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
5651
      SmallVector<llvm::Value*, 12> Operands;
5652
 
5653
      // Please refer to comment under 'defvar NFList' in this file
5654
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
5655
          (!IsMasked && PolicyAttrs & RVV_VTA))
5656
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
5657
      else {
5658
        if (IsMasked)
5659
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
5660
        else // Unmasked
5661
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
5662
      }
5663
      unsigned PtrOperandIdx = IsMasked ?
5664
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
5665
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
5666
      Value *PtrOperand = Ops[PtrOperandIdx];
5667
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
5668
      Value *VLOperand = Ops[PtrOperandIdx + 2];
5669
      Operands.push_back(PtrOperand);
5670
      Operands.push_back(IndexOperand);
5671
      if (IsMasked)
5672
        Operands.push_back(Ops[NF]);
5673
      Operands.push_back(VLOperand);
5674
      if (IsMasked)
5675
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
5676
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
5677
 
5678
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
5679
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
5680
      clang::CharUnits Align =
5681
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
5682
      llvm::Value *V;
5683
      for (unsigned I = 0; I < NF; ++I) {
5684
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
5685
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
5686
      }
5687
      return V;
5688
    }
5689
    break;
5690
case RISCVVector::BI__builtin_rvv_vloxseg8ei8_v_ta:
5691
case RISCVVector::BI__builtin_rvv_vloxseg8ei16_v_ta:
5692
case RISCVVector::BI__builtin_rvv_vloxseg8ei32_v_ta:
5693
case RISCVVector::BI__builtin_rvv_vloxseg8ei64_v_ta:
5694
  ID = Intrinsic::riscv_vloxseg8;
5695
  NF = 8;
5696
  PolicyAttrs = 3;
5697
IsMasked = false;
5698
 
5699
    {
5700
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
5701
      SmallVector<llvm::Value*, 12> Operands;
5702
 
5703
      // Please refer to comment under 'defvar NFList' in this file
5704
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
5705
          (!IsMasked && PolicyAttrs & RVV_VTA))
5706
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
5707
      else {
5708
        if (IsMasked)
5709
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
5710
        else // Unmasked
5711
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
5712
      }
5713
      unsigned PtrOperandIdx = IsMasked ?
5714
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
5715
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
5716
      Value *PtrOperand = Ops[PtrOperandIdx];
5717
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
5718
      Value *VLOperand = Ops[PtrOperandIdx + 2];
5719
      Operands.push_back(PtrOperand);
5720
      Operands.push_back(IndexOperand);
5721
      if (IsMasked)
5722
        Operands.push_back(Ops[NF]);
5723
      Operands.push_back(VLOperand);
5724
      if (IsMasked)
5725
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
5726
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
5727
 
5728
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
5729
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
5730
      clang::CharUnits Align =
5731
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
5732
      llvm::Value *V;
5733
      for (unsigned I = 0; I < NF; ++I) {
5734
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
5735
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
5736
      }
5737
      return V;
5738
    }
5739
    break;
5740
case RISCVVector::BI__builtin_rvv_vloxseg8ei8_v_tum:
5741
case RISCVVector::BI__builtin_rvv_vloxseg8ei16_v_tum:
5742
case RISCVVector::BI__builtin_rvv_vloxseg8ei32_v_tum:
5743
case RISCVVector::BI__builtin_rvv_vloxseg8ei64_v_tum:
5744
  ID = Intrinsic::riscv_vloxseg8_mask;
5745
  NF = 8;
5746
  PolicyAttrs = 2;
5747
IsMasked = true;
5748
 
5749
    {
5750
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
5751
      SmallVector<llvm::Value*, 12> Operands;
5752
 
5753
      // Please refer to comment under 'defvar NFList' in this file
5754
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
5755
          (!IsMasked && PolicyAttrs & RVV_VTA))
5756
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
5757
      else {
5758
        if (IsMasked)
5759
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
5760
        else // Unmasked
5761
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
5762
      }
5763
      unsigned PtrOperandIdx = IsMasked ?
5764
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
5765
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
5766
      Value *PtrOperand = Ops[PtrOperandIdx];
5767
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
5768
      Value *VLOperand = Ops[PtrOperandIdx + 2];
5769
      Operands.push_back(PtrOperand);
5770
      Operands.push_back(IndexOperand);
5771
      if (IsMasked)
5772
        Operands.push_back(Ops[NF]);
5773
      Operands.push_back(VLOperand);
5774
      if (IsMasked)
5775
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
5776
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
5777
 
5778
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
5779
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
5780
      clang::CharUnits Align =
5781
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
5782
      llvm::Value *V;
5783
      for (unsigned I = 0; I < NF; ++I) {
5784
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
5785
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
5786
      }
5787
      return V;
5788
    }
5789
    break;
5790
case RISCVVector::BI__builtin_rvv_vloxseg8ei8_v_tama:
5791
case RISCVVector::BI__builtin_rvv_vloxseg8ei16_v_tama:
5792
case RISCVVector::BI__builtin_rvv_vloxseg8ei32_v_tama:
5793
case RISCVVector::BI__builtin_rvv_vloxseg8ei64_v_tama:
5794
  ID = Intrinsic::riscv_vloxseg8_mask;
5795
  NF = 8;
5796
  PolicyAttrs = 3;
5797
IsMasked = true;
5798
 
5799
    {
5800
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
5801
      SmallVector<llvm::Value*, 12> Operands;
5802
 
5803
      // Please refer to comment under 'defvar NFList' in this file
5804
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
5805
          (!IsMasked && PolicyAttrs & RVV_VTA))
5806
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
5807
      else {
5808
        if (IsMasked)
5809
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
5810
        else // Unmasked
5811
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
5812
      }
5813
      unsigned PtrOperandIdx = IsMasked ?
5814
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
5815
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
5816
      Value *PtrOperand = Ops[PtrOperandIdx];
5817
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
5818
      Value *VLOperand = Ops[PtrOperandIdx + 2];
5819
      Operands.push_back(PtrOperand);
5820
      Operands.push_back(IndexOperand);
5821
      if (IsMasked)
5822
        Operands.push_back(Ops[NF]);
5823
      Operands.push_back(VLOperand);
5824
      if (IsMasked)
5825
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
5826
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
5827
 
5828
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
5829
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
5830
      clang::CharUnits Align =
5831
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
5832
      llvm::Value *V;
5833
      for (unsigned I = 0; I < NF; ++I) {
5834
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
5835
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
5836
      }
5837
      return V;
5838
    }
5839
    break;
5840
case RISCVVector::BI__builtin_rvv_vloxseg8ei8_v_tumu:
5841
case RISCVVector::BI__builtin_rvv_vloxseg8ei16_v_tumu:
5842
case RISCVVector::BI__builtin_rvv_vloxseg8ei32_v_tumu:
5843
case RISCVVector::BI__builtin_rvv_vloxseg8ei64_v_tumu:
5844
  ID = Intrinsic::riscv_vloxseg8_mask;
5845
  NF = 8;
5846
  PolicyAttrs = 0;
5847
IsMasked = true;
5848
 
5849
    {
5850
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
5851
      SmallVector<llvm::Value*, 12> Operands;
5852
 
5853
      // Please refer to comment under 'defvar NFList' in this file
5854
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
5855
          (!IsMasked && PolicyAttrs & RVV_VTA))
5856
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
5857
      else {
5858
        if (IsMasked)
5859
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
5860
        else // Unmasked
5861
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
5862
      }
5863
      unsigned PtrOperandIdx = IsMasked ?
5864
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
5865
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
5866
      Value *PtrOperand = Ops[PtrOperandIdx];
5867
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
5868
      Value *VLOperand = Ops[PtrOperandIdx + 2];
5869
      Operands.push_back(PtrOperand);
5870
      Operands.push_back(IndexOperand);
5871
      if (IsMasked)
5872
        Operands.push_back(Ops[NF]);
5873
      Operands.push_back(VLOperand);
5874
      if (IsMasked)
5875
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
5876
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
5877
 
5878
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
5879
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
5880
      clang::CharUnits Align =
5881
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
5882
      llvm::Value *V;
5883
      for (unsigned I = 0; I < NF; ++I) {
5884
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
5885
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
5886
      }
5887
      return V;
5888
    }
5889
    break;
5890
case RISCVVector::BI__builtin_rvv_vloxseg8ei8_v_mu:
5891
case RISCVVector::BI__builtin_rvv_vloxseg8ei16_v_mu:
5892
case RISCVVector::BI__builtin_rvv_vloxseg8ei32_v_mu:
5893
case RISCVVector::BI__builtin_rvv_vloxseg8ei64_v_mu:
5894
  ID = Intrinsic::riscv_vloxseg8_mask;
5895
  NF = 8;
5896
  PolicyAttrs = 1;
5897
IsMasked = true;
5898
 
5899
    {
5900
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
5901
      SmallVector<llvm::Value*, 12> Operands;
5902
 
5903
      // Please refer to comment under 'defvar NFList' in this file
5904
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
5905
          (!IsMasked && PolicyAttrs & RVV_VTA))
5906
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
5907
      else {
5908
        if (IsMasked)
5909
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
5910
        else // Unmasked
5911
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
5912
      }
5913
      unsigned PtrOperandIdx = IsMasked ?
5914
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
5915
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
5916
      Value *PtrOperand = Ops[PtrOperandIdx];
5917
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
5918
      Value *VLOperand = Ops[PtrOperandIdx + 2];
5919
      Operands.push_back(PtrOperand);
5920
      Operands.push_back(IndexOperand);
5921
      if (IsMasked)
5922
        Operands.push_back(Ops[NF]);
5923
      Operands.push_back(VLOperand);
5924
      if (IsMasked)
5925
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
5926
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
5927
 
5928
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
5929
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
5930
      clang::CharUnits Align =
5931
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
5932
      llvm::Value *V;
5933
      for (unsigned I = 0; I < NF; ++I) {
5934
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
5935
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
5936
      }
5937
      return V;
5938
    }
5939
    break;
5940
case RISCVVector::BI__builtin_rvv_vlse32_v_tu:
5941
case RISCVVector::BI__builtin_rvv_vlse64_v_tu:
5942
case RISCVVector::BI__builtin_rvv_vlse8_v_tu:
5943
case RISCVVector::BI__builtin_rvv_vlse16_v_tu:
5944
  ID = Intrinsic::riscv_vlse;
5945
  PolicyAttrs = 2;
5946
  Ops[1] = Builder.CreateBitCast(Ops[1], ResultType->getPointerTo());
5947
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
5948
  break;
5949
case RISCVVector::BI__builtin_rvv_vlse32_v_ta:
5950
case RISCVVector::BI__builtin_rvv_vlse64_v_ta:
5951
case RISCVVector::BI__builtin_rvv_vlse8_v_ta:
5952
case RISCVVector::BI__builtin_rvv_vlse16_v_ta:
5953
  ID = Intrinsic::riscv_vlse;
5954
  PolicyAttrs = 3;
5955
  Ops[0] = Builder.CreateBitCast(Ops[0], ResultType->getPointerTo());
5956
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
5957
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
5958
  break;
5959
case RISCVVector::BI__builtin_rvv_vlse32_v_tum:
5960
case RISCVVector::BI__builtin_rvv_vlse64_v_tum:
5961
case RISCVVector::BI__builtin_rvv_vlse8_v_tum:
5962
case RISCVVector::BI__builtin_rvv_vlse16_v_tum:
5963
  ID = Intrinsic::riscv_vlse_mask;
5964
  PolicyAttrs = 2;
5965
  Ops[2] = Builder.CreateBitCast(Ops[2], ResultType->getPointerTo());
5966
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
5967
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
5968
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
5969
  break;
5970
case RISCVVector::BI__builtin_rvv_vlse32_v_tama:
5971
case RISCVVector::BI__builtin_rvv_vlse64_v_tama:
5972
case RISCVVector::BI__builtin_rvv_vlse8_v_tama:
5973
case RISCVVector::BI__builtin_rvv_vlse16_v_tama:
5974
  ID = Intrinsic::riscv_vlse_mask;
5975
  PolicyAttrs = 3;
5976
  Ops[1] = Builder.CreateBitCast(Ops[1], ResultType->getPointerTo());
5977
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
5978
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
5979
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
5980
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
5981
  break;
5982
case RISCVVector::BI__builtin_rvv_vlse32_v_tumu:
5983
case RISCVVector::BI__builtin_rvv_vlse64_v_tumu:
5984
case RISCVVector::BI__builtin_rvv_vlse8_v_tumu:
5985
case RISCVVector::BI__builtin_rvv_vlse16_v_tumu:
5986
  ID = Intrinsic::riscv_vlse_mask;
5987
  PolicyAttrs = 0;
5988
  Ops[2] = Builder.CreateBitCast(Ops[2], ResultType->getPointerTo());
5989
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
5990
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
5991
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
5992
  break;
5993
case RISCVVector::BI__builtin_rvv_vlse32_v_mu:
5994
case RISCVVector::BI__builtin_rvv_vlse64_v_mu:
5995
case RISCVVector::BI__builtin_rvv_vlse8_v_mu:
5996
case RISCVVector::BI__builtin_rvv_vlse16_v_mu:
5997
  ID = Intrinsic::riscv_vlse_mask;
5998
  PolicyAttrs = 1;
5999
  Ops[2] = Builder.CreateBitCast(Ops[2], ResultType->getPointerTo());
6000
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
6001
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
6002
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
6003
  break;
6004
case RISCVVector::BI__builtin_rvv_vlseg2e8_v_tu:
6005
case RISCVVector::BI__builtin_rvv_vlseg2e16_v_tu:
6006
case RISCVVector::BI__builtin_rvv_vlseg2e32_v_tu:
6007
case RISCVVector::BI__builtin_rvv_vlseg2e64_v_tu:
6008
  ID = Intrinsic::riscv_vlseg2;
6009
  NF = 2;
6010
  PolicyAttrs = 2;
6011
IsMasked = false;
6012
 
6013
    {
6014
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
6015
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
6016
      SmallVector<llvm::Value*, 12> Operands;
6017
 
6018
      // Please refer to comment under 'defvar NFList' in this file
6019
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
6020
          (!IsMasked && PolicyAttrs & RVV_VTA))
6021
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
6022
      else {
6023
        if (IsMasked)
6024
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
6025
        else // Unmasked
6026
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
6027
      }
6028
      unsigned PtrOperandIdx = IsMasked ?
6029
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
6030
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
6031
      Value *PtrOperand = Ops[PtrOperandIdx];
6032
      Value *VLOperand = Ops[PtrOperandIdx + 1];
6033
      Operands.push_back(PtrOperand);
6034
      if (IsMasked)
6035
        Operands.push_back(Ops[NF]);
6036
      Operands.push_back(VLOperand);
6037
      if (IsMasked)
6038
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
6039
 
6040
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
6041
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
6042
      clang::CharUnits Align =
6043
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
6044
      llvm::Value *V;
6045
      for (unsigned I = 0; I < NF; ++I) {
6046
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
6047
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
6048
      }
6049
      return V;
6050
    }
6051
    break;
6052
case RISCVVector::BI__builtin_rvv_vlseg2e8_v_ta:
6053
case RISCVVector::BI__builtin_rvv_vlseg2e16_v_ta:
6054
case RISCVVector::BI__builtin_rvv_vlseg2e32_v_ta:
6055
case RISCVVector::BI__builtin_rvv_vlseg2e64_v_ta:
6056
  ID = Intrinsic::riscv_vlseg2;
6057
  NF = 2;
6058
  PolicyAttrs = 3;
6059
IsMasked = false;
6060
 
6061
    {
6062
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
6063
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
6064
      SmallVector<llvm::Value*, 12> Operands;
6065
 
6066
      // Please refer to comment under 'defvar NFList' in this file
6067
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
6068
          (!IsMasked && PolicyAttrs & RVV_VTA))
6069
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
6070
      else {
6071
        if (IsMasked)
6072
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
6073
        else // Unmasked
6074
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
6075
      }
6076
      unsigned PtrOperandIdx = IsMasked ?
6077
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
6078
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
6079
      Value *PtrOperand = Ops[PtrOperandIdx];
6080
      Value *VLOperand = Ops[PtrOperandIdx + 1];
6081
      Operands.push_back(PtrOperand);
6082
      if (IsMasked)
6083
        Operands.push_back(Ops[NF]);
6084
      Operands.push_back(VLOperand);
6085
      if (IsMasked)
6086
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
6087
 
6088
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
6089
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
6090
      clang::CharUnits Align =
6091
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
6092
      llvm::Value *V;
6093
      for (unsigned I = 0; I < NF; ++I) {
6094
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
6095
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
6096
      }
6097
      return V;
6098
    }
6099
    break;
6100
case RISCVVector::BI__builtin_rvv_vlseg2e8_v_tum:
6101
case RISCVVector::BI__builtin_rvv_vlseg2e16_v_tum:
6102
case RISCVVector::BI__builtin_rvv_vlseg2e32_v_tum:
6103
case RISCVVector::BI__builtin_rvv_vlseg2e64_v_tum:
6104
  ID = Intrinsic::riscv_vlseg2_mask;
6105
  NF = 2;
6106
  PolicyAttrs = 2;
6107
IsMasked = true;
6108
 
6109
    {
6110
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
6111
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
6112
      SmallVector<llvm::Value*, 12> Operands;
6113
 
6114
      // Please refer to comment under 'defvar NFList' in this file
6115
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
6116
          (!IsMasked && PolicyAttrs & RVV_VTA))
6117
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
6118
      else {
6119
        if (IsMasked)
6120
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
6121
        else // Unmasked
6122
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
6123
      }
6124
      unsigned PtrOperandIdx = IsMasked ?
6125
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
6126
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
6127
      Value *PtrOperand = Ops[PtrOperandIdx];
6128
      Value *VLOperand = Ops[PtrOperandIdx + 1];
6129
      Operands.push_back(PtrOperand);
6130
      if (IsMasked)
6131
        Operands.push_back(Ops[NF]);
6132
      Operands.push_back(VLOperand);
6133
      if (IsMasked)
6134
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
6135
 
6136
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
6137
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
6138
      clang::CharUnits Align =
6139
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
6140
      llvm::Value *V;
6141
      for (unsigned I = 0; I < NF; ++I) {
6142
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
6143
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
6144
      }
6145
      return V;
6146
    }
6147
    break;
6148
case RISCVVector::BI__builtin_rvv_vlseg2e8_v_tama:
6149
case RISCVVector::BI__builtin_rvv_vlseg2e16_v_tama:
6150
case RISCVVector::BI__builtin_rvv_vlseg2e32_v_tama:
6151
case RISCVVector::BI__builtin_rvv_vlseg2e64_v_tama:
6152
  ID = Intrinsic::riscv_vlseg2_mask;
6153
  NF = 2;
6154
  PolicyAttrs = 3;
6155
IsMasked = true;
6156
 
6157
    {
6158
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
6159
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
6160
      SmallVector<llvm::Value*, 12> Operands;
6161
 
6162
      // Please refer to comment under 'defvar NFList' in this file
6163
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
6164
          (!IsMasked && PolicyAttrs & RVV_VTA))
6165
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
6166
      else {
6167
        if (IsMasked)
6168
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
6169
        else // Unmasked
6170
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
6171
      }
6172
      unsigned PtrOperandIdx = IsMasked ?
6173
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
6174
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
6175
      Value *PtrOperand = Ops[PtrOperandIdx];
6176
      Value *VLOperand = Ops[PtrOperandIdx + 1];
6177
      Operands.push_back(PtrOperand);
6178
      if (IsMasked)
6179
        Operands.push_back(Ops[NF]);
6180
      Operands.push_back(VLOperand);
6181
      if (IsMasked)
6182
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
6183
 
6184
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
6185
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
6186
      clang::CharUnits Align =
6187
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
6188
      llvm::Value *V;
6189
      for (unsigned I = 0; I < NF; ++I) {
6190
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
6191
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
6192
      }
6193
      return V;
6194
    }
6195
    break;
6196
case RISCVVector::BI__builtin_rvv_vlseg2e8_v_tumu:
6197
case RISCVVector::BI__builtin_rvv_vlseg2e16_v_tumu:
6198
case RISCVVector::BI__builtin_rvv_vlseg2e32_v_tumu:
6199
case RISCVVector::BI__builtin_rvv_vlseg2e64_v_tumu:
6200
  ID = Intrinsic::riscv_vlseg2_mask;
6201
  NF = 2;
6202
  PolicyAttrs = 0;
6203
IsMasked = true;
6204
 
6205
    {
6206
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
6207
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
6208
      SmallVector<llvm::Value*, 12> Operands;
6209
 
6210
      // Please refer to comment under 'defvar NFList' in this file
6211
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
6212
          (!IsMasked && PolicyAttrs & RVV_VTA))
6213
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
6214
      else {
6215
        if (IsMasked)
6216
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
6217
        else // Unmasked
6218
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
6219
      }
6220
      unsigned PtrOperandIdx = IsMasked ?
6221
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
6222
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
6223
      Value *PtrOperand = Ops[PtrOperandIdx];
6224
      Value *VLOperand = Ops[PtrOperandIdx + 1];
6225
      Operands.push_back(PtrOperand);
6226
      if (IsMasked)
6227
        Operands.push_back(Ops[NF]);
6228
      Operands.push_back(VLOperand);
6229
      if (IsMasked)
6230
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
6231
 
6232
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
6233
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
6234
      clang::CharUnits Align =
6235
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
6236
      llvm::Value *V;
6237
      for (unsigned I = 0; I < NF; ++I) {
6238
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
6239
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
6240
      }
6241
      return V;
6242
    }
6243
    break;
6244
case RISCVVector::BI__builtin_rvv_vlseg2e8_v_mu:
6245
case RISCVVector::BI__builtin_rvv_vlseg2e16_v_mu:
6246
case RISCVVector::BI__builtin_rvv_vlseg2e32_v_mu:
6247
case RISCVVector::BI__builtin_rvv_vlseg2e64_v_mu:
6248
  ID = Intrinsic::riscv_vlseg2_mask;
6249
  NF = 2;
6250
  PolicyAttrs = 1;
6251
IsMasked = true;
6252
 
6253
    {
6254
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
6255
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
6256
      SmallVector<llvm::Value*, 12> Operands;
6257
 
6258
      // Please refer to comment under 'defvar NFList' in this file
6259
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
6260
          (!IsMasked && PolicyAttrs & RVV_VTA))
6261
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
6262
      else {
6263
        if (IsMasked)
6264
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
6265
        else // Unmasked
6266
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
6267
      }
6268
      unsigned PtrOperandIdx = IsMasked ?
6269
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
6270
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
6271
      Value *PtrOperand = Ops[PtrOperandIdx];
6272
      Value *VLOperand = Ops[PtrOperandIdx + 1];
6273
      Operands.push_back(PtrOperand);
6274
      if (IsMasked)
6275
        Operands.push_back(Ops[NF]);
6276
      Operands.push_back(VLOperand);
6277
      if (IsMasked)
6278
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
6279
 
6280
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
6281
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
6282
      clang::CharUnits Align =
6283
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
6284
      llvm::Value *V;
6285
      for (unsigned I = 0; I < NF; ++I) {
6286
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
6287
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
6288
      }
6289
      return V;
6290
    }
6291
    break;
6292
case RISCVVector::BI__builtin_rvv_vlseg2e16ff_v_tu:
6293
case RISCVVector::BI__builtin_rvv_vlseg2e32ff_v_tu:
6294
case RISCVVector::BI__builtin_rvv_vlseg2e64ff_v_tu:
6295
case RISCVVector::BI__builtin_rvv_vlseg2e8ff_v_tu:
6296
  ID = Intrinsic::riscv_vlseg2ff;
6297
  NF = 2;
6298
  PolicyAttrs = 2;
6299
IsMasked = false;
6300
 
6301
    {
6302
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
6303
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
6304
      SmallVector<llvm::Value*, 12> Operands;
6305
 
6306
      // Please refer to comment under 'defvar NFList' in this file
6307
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
6308
          (!IsMasked && PolicyAttrs & RVV_VTA))
6309
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
6310
      else {
6311
        if (IsMasked)
6312
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
6313
        else // Unmasked
6314
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
6315
      }
6316
      unsigned PtrOperandIdx = IsMasked ?
6317
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
6318
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
6319
      Value *PtrOperand = Ops[PtrOperandIdx];
6320
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
6321
      Value *VLOperand = Ops[PtrOperandIdx + 2];
6322
      Operands.push_back(PtrOperand);
6323
      if (IsMasked)
6324
        Operands.push_back(Ops[NF]);
6325
      Operands.push_back(VLOperand);
6326
      if (IsMasked)
6327
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
6328
 
6329
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
6330
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
6331
      clang::CharUnits Align =
6332
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
6333
      for (unsigned I = 0; I < NF; ++I) {
6334
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
6335
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
6336
      }
6337
      // Store new_vl.
6338
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
6339
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
6340
    }
6341
    break;
6342
case RISCVVector::BI__builtin_rvv_vlseg2e16ff_v_ta:
6343
case RISCVVector::BI__builtin_rvv_vlseg2e32ff_v_ta:
6344
case RISCVVector::BI__builtin_rvv_vlseg2e64ff_v_ta:
6345
case RISCVVector::BI__builtin_rvv_vlseg2e8ff_v_ta:
6346
  ID = Intrinsic::riscv_vlseg2ff;
6347
  NF = 2;
6348
  PolicyAttrs = 3;
6349
IsMasked = false;
6350
 
6351
    {
6352
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
6353
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
6354
      SmallVector<llvm::Value*, 12> Operands;
6355
 
6356
      // Please refer to comment under 'defvar NFList' in this file
6357
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
6358
          (!IsMasked && PolicyAttrs & RVV_VTA))
6359
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
6360
      else {
6361
        if (IsMasked)
6362
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
6363
        else // Unmasked
6364
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
6365
      }
6366
      unsigned PtrOperandIdx = IsMasked ?
6367
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
6368
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
6369
      Value *PtrOperand = Ops[PtrOperandIdx];
6370
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
6371
      Value *VLOperand = Ops[PtrOperandIdx + 2];
6372
      Operands.push_back(PtrOperand);
6373
      if (IsMasked)
6374
        Operands.push_back(Ops[NF]);
6375
      Operands.push_back(VLOperand);
6376
      if (IsMasked)
6377
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
6378
 
6379
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
6380
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
6381
      clang::CharUnits Align =
6382
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
6383
      for (unsigned I = 0; I < NF; ++I) {
6384
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
6385
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
6386
      }
6387
      // Store new_vl.
6388
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
6389
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
6390
    }
6391
    break;
6392
case RISCVVector::BI__builtin_rvv_vlseg2e16ff_v_tum:
6393
case RISCVVector::BI__builtin_rvv_vlseg2e32ff_v_tum:
6394
case RISCVVector::BI__builtin_rvv_vlseg2e64ff_v_tum:
6395
case RISCVVector::BI__builtin_rvv_vlseg2e8ff_v_tum:
6396
  ID = Intrinsic::riscv_vlseg2ff_mask;
6397
  NF = 2;
6398
  PolicyAttrs = 2;
6399
IsMasked = true;
6400
 
6401
    {
6402
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
6403
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
6404
      SmallVector<llvm::Value*, 12> Operands;
6405
 
6406
      // Please refer to comment under 'defvar NFList' in this file
6407
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
6408
          (!IsMasked && PolicyAttrs & RVV_VTA))
6409
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
6410
      else {
6411
        if (IsMasked)
6412
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
6413
        else // Unmasked
6414
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
6415
      }
6416
      unsigned PtrOperandIdx = IsMasked ?
6417
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
6418
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
6419
      Value *PtrOperand = Ops[PtrOperandIdx];
6420
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
6421
      Value *VLOperand = Ops[PtrOperandIdx + 2];
6422
      Operands.push_back(PtrOperand);
6423
      if (IsMasked)
6424
        Operands.push_back(Ops[NF]);
6425
      Operands.push_back(VLOperand);
6426
      if (IsMasked)
6427
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
6428
 
6429
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
6430
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
6431
      clang::CharUnits Align =
6432
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
6433
      for (unsigned I = 0; I < NF; ++I) {
6434
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
6435
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
6436
      }
6437
      // Store new_vl.
6438
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
6439
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
6440
    }
6441
    break;
6442
case RISCVVector::BI__builtin_rvv_vlseg2e16ff_v_tama:
6443
case RISCVVector::BI__builtin_rvv_vlseg2e32ff_v_tama:
6444
case RISCVVector::BI__builtin_rvv_vlseg2e64ff_v_tama:
6445
case RISCVVector::BI__builtin_rvv_vlseg2e8ff_v_tama:
6446
  ID = Intrinsic::riscv_vlseg2ff_mask;
6447
  NF = 2;
6448
  PolicyAttrs = 3;
6449
IsMasked = true;
6450
 
6451
    {
6452
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
6453
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
6454
      SmallVector<llvm::Value*, 12> Operands;
6455
 
6456
      // Please refer to comment under 'defvar NFList' in this file
6457
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
6458
          (!IsMasked && PolicyAttrs & RVV_VTA))
6459
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
6460
      else {
6461
        if (IsMasked)
6462
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
6463
        else // Unmasked
6464
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
6465
      }
6466
      unsigned PtrOperandIdx = IsMasked ?
6467
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
6468
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
6469
      Value *PtrOperand = Ops[PtrOperandIdx];
6470
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
6471
      Value *VLOperand = Ops[PtrOperandIdx + 2];
6472
      Operands.push_back(PtrOperand);
6473
      if (IsMasked)
6474
        Operands.push_back(Ops[NF]);
6475
      Operands.push_back(VLOperand);
6476
      if (IsMasked)
6477
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
6478
 
6479
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
6480
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
6481
      clang::CharUnits Align =
6482
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
6483
      for (unsigned I = 0; I < NF; ++I) {
6484
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
6485
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
6486
      }
6487
      // Store new_vl.
6488
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
6489
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
6490
    }
6491
    break;
6492
case RISCVVector::BI__builtin_rvv_vlseg2e16ff_v_tumu:
6493
case RISCVVector::BI__builtin_rvv_vlseg2e32ff_v_tumu:
6494
case RISCVVector::BI__builtin_rvv_vlseg2e64ff_v_tumu:
6495
case RISCVVector::BI__builtin_rvv_vlseg2e8ff_v_tumu:
6496
  ID = Intrinsic::riscv_vlseg2ff_mask;
6497
  NF = 2;
6498
  PolicyAttrs = 0;
6499
IsMasked = true;
6500
 
6501
    {
6502
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
6503
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
6504
      SmallVector<llvm::Value*, 12> Operands;
6505
 
6506
      // Please refer to comment under 'defvar NFList' in this file
6507
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
6508
          (!IsMasked && PolicyAttrs & RVV_VTA))
6509
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
6510
      else {
6511
        if (IsMasked)
6512
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
6513
        else // Unmasked
6514
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
6515
      }
6516
      unsigned PtrOperandIdx = IsMasked ?
6517
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
6518
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
6519
      Value *PtrOperand = Ops[PtrOperandIdx];
6520
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
6521
      Value *VLOperand = Ops[PtrOperandIdx + 2];
6522
      Operands.push_back(PtrOperand);
6523
      if (IsMasked)
6524
        Operands.push_back(Ops[NF]);
6525
      Operands.push_back(VLOperand);
6526
      if (IsMasked)
6527
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
6528
 
6529
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
6530
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
6531
      clang::CharUnits Align =
6532
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
6533
      for (unsigned I = 0; I < NF; ++I) {
6534
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
6535
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
6536
      }
6537
      // Store new_vl.
6538
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
6539
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
6540
    }
6541
    break;
6542
case RISCVVector::BI__builtin_rvv_vlseg2e16ff_v_mu:
6543
case RISCVVector::BI__builtin_rvv_vlseg2e32ff_v_mu:
6544
case RISCVVector::BI__builtin_rvv_vlseg2e64ff_v_mu:
6545
case RISCVVector::BI__builtin_rvv_vlseg2e8ff_v_mu:
6546
  ID = Intrinsic::riscv_vlseg2ff_mask;
6547
  NF = 2;
6548
  PolicyAttrs = 1;
6549
IsMasked = true;
6550
 
6551
    {
6552
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
6553
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
6554
      SmallVector<llvm::Value*, 12> Operands;
6555
 
6556
      // Please refer to comment under 'defvar NFList' in this file
6557
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
6558
          (!IsMasked && PolicyAttrs & RVV_VTA))
6559
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
6560
      else {
6561
        if (IsMasked)
6562
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
6563
        else // Unmasked
6564
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
6565
      }
6566
      unsigned PtrOperandIdx = IsMasked ?
6567
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
6568
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
6569
      Value *PtrOperand = Ops[PtrOperandIdx];
6570
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
6571
      Value *VLOperand = Ops[PtrOperandIdx + 2];
6572
      Operands.push_back(PtrOperand);
6573
      if (IsMasked)
6574
        Operands.push_back(Ops[NF]);
6575
      Operands.push_back(VLOperand);
6576
      if (IsMasked)
6577
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
6578
 
6579
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
6580
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
6581
      clang::CharUnits Align =
6582
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
6583
      for (unsigned I = 0; I < NF; ++I) {
6584
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
6585
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
6586
      }
6587
      // Store new_vl.
6588
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
6589
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
6590
    }
6591
    break;
6592
case RISCVVector::BI__builtin_rvv_vlseg3e8_v_tu:
6593
case RISCVVector::BI__builtin_rvv_vlseg3e16_v_tu:
6594
case RISCVVector::BI__builtin_rvv_vlseg3e32_v_tu:
6595
case RISCVVector::BI__builtin_rvv_vlseg3e64_v_tu:
6596
  ID = Intrinsic::riscv_vlseg3;
6597
  NF = 3;
6598
  PolicyAttrs = 2;
6599
IsMasked = false;
6600
 
6601
    {
6602
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
6603
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
6604
      SmallVector<llvm::Value*, 12> Operands;
6605
 
6606
      // Please refer to comment under 'defvar NFList' in this file
6607
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
6608
          (!IsMasked && PolicyAttrs & RVV_VTA))
6609
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
6610
      else {
6611
        if (IsMasked)
6612
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
6613
        else // Unmasked
6614
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
6615
      }
6616
      unsigned PtrOperandIdx = IsMasked ?
6617
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
6618
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
6619
      Value *PtrOperand = Ops[PtrOperandIdx];
6620
      Value *VLOperand = Ops[PtrOperandIdx + 1];
6621
      Operands.push_back(PtrOperand);
6622
      if (IsMasked)
6623
        Operands.push_back(Ops[NF]);
6624
      Operands.push_back(VLOperand);
6625
      if (IsMasked)
6626
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
6627
 
6628
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
6629
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
6630
      clang::CharUnits Align =
6631
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
6632
      llvm::Value *V;
6633
      for (unsigned I = 0; I < NF; ++I) {
6634
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
6635
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
6636
      }
6637
      return V;
6638
    }
6639
    break;
6640
case RISCVVector::BI__builtin_rvv_vlseg3e8_v_ta:
6641
case RISCVVector::BI__builtin_rvv_vlseg3e16_v_ta:
6642
case RISCVVector::BI__builtin_rvv_vlseg3e32_v_ta:
6643
case RISCVVector::BI__builtin_rvv_vlseg3e64_v_ta:
6644
  ID = Intrinsic::riscv_vlseg3;
6645
  NF = 3;
6646
  PolicyAttrs = 3;
6647
IsMasked = false;
6648
 
6649
    {
6650
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
6651
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
6652
      SmallVector<llvm::Value*, 12> Operands;
6653
 
6654
      // Please refer to comment under 'defvar NFList' in this file
6655
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
6656
          (!IsMasked && PolicyAttrs & RVV_VTA))
6657
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
6658
      else {
6659
        if (IsMasked)
6660
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
6661
        else // Unmasked
6662
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
6663
      }
6664
      unsigned PtrOperandIdx = IsMasked ?
6665
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
6666
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
6667
      Value *PtrOperand = Ops[PtrOperandIdx];
6668
      Value *VLOperand = Ops[PtrOperandIdx + 1];
6669
      Operands.push_back(PtrOperand);
6670
      if (IsMasked)
6671
        Operands.push_back(Ops[NF]);
6672
      Operands.push_back(VLOperand);
6673
      if (IsMasked)
6674
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
6675
 
6676
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
6677
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
6678
      clang::CharUnits Align =
6679
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
6680
      llvm::Value *V;
6681
      for (unsigned I = 0; I < NF; ++I) {
6682
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
6683
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
6684
      }
6685
      return V;
6686
    }
6687
    break;
6688
case RISCVVector::BI__builtin_rvv_vlseg3e8_v_tum:
6689
case RISCVVector::BI__builtin_rvv_vlseg3e16_v_tum:
6690
case RISCVVector::BI__builtin_rvv_vlseg3e32_v_tum:
6691
case RISCVVector::BI__builtin_rvv_vlseg3e64_v_tum:
6692
  ID = Intrinsic::riscv_vlseg3_mask;
6693
  NF = 3;
6694
  PolicyAttrs = 2;
6695
IsMasked = true;
6696
 
6697
    {
6698
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
6699
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
6700
      SmallVector<llvm::Value*, 12> Operands;
6701
 
6702
      // Please refer to comment under 'defvar NFList' in this file
6703
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
6704
          (!IsMasked && PolicyAttrs & RVV_VTA))
6705
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
6706
      else {
6707
        if (IsMasked)
6708
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
6709
        else // Unmasked
6710
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
6711
      }
6712
      unsigned PtrOperandIdx = IsMasked ?
6713
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
6714
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
6715
      Value *PtrOperand = Ops[PtrOperandIdx];
6716
      Value *VLOperand = Ops[PtrOperandIdx + 1];
6717
      Operands.push_back(PtrOperand);
6718
      if (IsMasked)
6719
        Operands.push_back(Ops[NF]);
6720
      Operands.push_back(VLOperand);
6721
      if (IsMasked)
6722
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
6723
 
6724
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
6725
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
6726
      clang::CharUnits Align =
6727
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
6728
      llvm::Value *V;
6729
      for (unsigned I = 0; I < NF; ++I) {
6730
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
6731
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
6732
      }
6733
      return V;
6734
    }
6735
    break;
6736
case RISCVVector::BI__builtin_rvv_vlseg3e8_v_tama:
6737
case RISCVVector::BI__builtin_rvv_vlseg3e16_v_tama:
6738
case RISCVVector::BI__builtin_rvv_vlseg3e32_v_tama:
6739
case RISCVVector::BI__builtin_rvv_vlseg3e64_v_tama:
6740
  ID = Intrinsic::riscv_vlseg3_mask;
6741
  NF = 3;
6742
  PolicyAttrs = 3;
6743
IsMasked = true;
6744
 
6745
    {
6746
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
6747
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
6748
      SmallVector<llvm::Value*, 12> Operands;
6749
 
6750
      // Please refer to comment under 'defvar NFList' in this file
6751
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
6752
          (!IsMasked && PolicyAttrs & RVV_VTA))
6753
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
6754
      else {
6755
        if (IsMasked)
6756
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
6757
        else // Unmasked
6758
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
6759
      }
6760
      unsigned PtrOperandIdx = IsMasked ?
6761
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
6762
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
6763
      Value *PtrOperand = Ops[PtrOperandIdx];
6764
      Value *VLOperand = Ops[PtrOperandIdx + 1];
6765
      Operands.push_back(PtrOperand);
6766
      if (IsMasked)
6767
        Operands.push_back(Ops[NF]);
6768
      Operands.push_back(VLOperand);
6769
      if (IsMasked)
6770
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
6771
 
6772
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
6773
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
6774
      clang::CharUnits Align =
6775
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
6776
      llvm::Value *V;
6777
      for (unsigned I = 0; I < NF; ++I) {
6778
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
6779
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
6780
      }
6781
      return V;
6782
    }
6783
    break;
6784
case RISCVVector::BI__builtin_rvv_vlseg3e8_v_tumu:
6785
case RISCVVector::BI__builtin_rvv_vlseg3e16_v_tumu:
6786
case RISCVVector::BI__builtin_rvv_vlseg3e32_v_tumu:
6787
case RISCVVector::BI__builtin_rvv_vlseg3e64_v_tumu:
6788
  ID = Intrinsic::riscv_vlseg3_mask;
6789
  NF = 3;
6790
  PolicyAttrs = 0;
6791
IsMasked = true;
6792
 
6793
    {
6794
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
6795
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
6796
      SmallVector<llvm::Value*, 12> Operands;
6797
 
6798
      // Please refer to comment under 'defvar NFList' in this file
6799
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
6800
          (!IsMasked && PolicyAttrs & RVV_VTA))
6801
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
6802
      else {
6803
        if (IsMasked)
6804
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
6805
        else // Unmasked
6806
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
6807
      }
6808
      unsigned PtrOperandIdx = IsMasked ?
6809
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
6810
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
6811
      Value *PtrOperand = Ops[PtrOperandIdx];
6812
      Value *VLOperand = Ops[PtrOperandIdx + 1];
6813
      Operands.push_back(PtrOperand);
6814
      if (IsMasked)
6815
        Operands.push_back(Ops[NF]);
6816
      Operands.push_back(VLOperand);
6817
      if (IsMasked)
6818
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
6819
 
6820
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
6821
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
6822
      clang::CharUnits Align =
6823
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
6824
      llvm::Value *V;
6825
      for (unsigned I = 0; I < NF; ++I) {
6826
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
6827
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
6828
      }
6829
      return V;
6830
    }
6831
    break;
6832
case RISCVVector::BI__builtin_rvv_vlseg3e8_v_mu:
6833
case RISCVVector::BI__builtin_rvv_vlseg3e16_v_mu:
6834
case RISCVVector::BI__builtin_rvv_vlseg3e32_v_mu:
6835
case RISCVVector::BI__builtin_rvv_vlseg3e64_v_mu:
6836
  ID = Intrinsic::riscv_vlseg3_mask;
6837
  NF = 3;
6838
  PolicyAttrs = 1;
6839
IsMasked = true;
6840
 
6841
    {
6842
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
6843
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
6844
      SmallVector<llvm::Value*, 12> Operands;
6845
 
6846
      // Please refer to comment under 'defvar NFList' in this file
6847
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
6848
          (!IsMasked && PolicyAttrs & RVV_VTA))
6849
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
6850
      else {
6851
        if (IsMasked)
6852
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
6853
        else // Unmasked
6854
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
6855
      }
6856
      unsigned PtrOperandIdx = IsMasked ?
6857
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
6858
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
6859
      Value *PtrOperand = Ops[PtrOperandIdx];
6860
      Value *VLOperand = Ops[PtrOperandIdx + 1];
6861
      Operands.push_back(PtrOperand);
6862
      if (IsMasked)
6863
        Operands.push_back(Ops[NF]);
6864
      Operands.push_back(VLOperand);
6865
      if (IsMasked)
6866
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
6867
 
6868
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
6869
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
6870
      clang::CharUnits Align =
6871
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
6872
      llvm::Value *V;
6873
      for (unsigned I = 0; I < NF; ++I) {
6874
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
6875
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
6876
      }
6877
      return V;
6878
    }
6879
    break;
6880
case RISCVVector::BI__builtin_rvv_vlseg3e8ff_v_tu:
6881
case RISCVVector::BI__builtin_rvv_vlseg3e16ff_v_tu:
6882
case RISCVVector::BI__builtin_rvv_vlseg3e32ff_v_tu:
6883
case RISCVVector::BI__builtin_rvv_vlseg3e64ff_v_tu:
6884
  ID = Intrinsic::riscv_vlseg3ff;
6885
  NF = 3;
6886
  PolicyAttrs = 2;
6887
IsMasked = false;
6888
 
6889
    {
6890
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
6891
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
6892
      SmallVector<llvm::Value*, 12> Operands;
6893
 
6894
      // Please refer to comment under 'defvar NFList' in this file
6895
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
6896
          (!IsMasked && PolicyAttrs & RVV_VTA))
6897
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
6898
      else {
6899
        if (IsMasked)
6900
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
6901
        else // Unmasked
6902
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
6903
      }
6904
      unsigned PtrOperandIdx = IsMasked ?
6905
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
6906
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
6907
      Value *PtrOperand = Ops[PtrOperandIdx];
6908
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
6909
      Value *VLOperand = Ops[PtrOperandIdx + 2];
6910
      Operands.push_back(PtrOperand);
6911
      if (IsMasked)
6912
        Operands.push_back(Ops[NF]);
6913
      Operands.push_back(VLOperand);
6914
      if (IsMasked)
6915
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
6916
 
6917
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
6918
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
6919
      clang::CharUnits Align =
6920
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
6921
      for (unsigned I = 0; I < NF; ++I) {
6922
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
6923
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
6924
      }
6925
      // Store new_vl.
6926
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
6927
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
6928
    }
6929
    break;
6930
case RISCVVector::BI__builtin_rvv_vlseg3e8ff_v_ta:
6931
case RISCVVector::BI__builtin_rvv_vlseg3e16ff_v_ta:
6932
case RISCVVector::BI__builtin_rvv_vlseg3e32ff_v_ta:
6933
case RISCVVector::BI__builtin_rvv_vlseg3e64ff_v_ta:
6934
  ID = Intrinsic::riscv_vlseg3ff;
6935
  NF = 3;
6936
  PolicyAttrs = 3;
6937
IsMasked = false;
6938
 
6939
    {
6940
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
6941
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
6942
      SmallVector<llvm::Value*, 12> Operands;
6943
 
6944
      // Please refer to comment under 'defvar NFList' in this file
6945
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
6946
          (!IsMasked && PolicyAttrs & RVV_VTA))
6947
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
6948
      else {
6949
        if (IsMasked)
6950
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
6951
        else // Unmasked
6952
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
6953
      }
6954
      unsigned PtrOperandIdx = IsMasked ?
6955
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
6956
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
6957
      Value *PtrOperand = Ops[PtrOperandIdx];
6958
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
6959
      Value *VLOperand = Ops[PtrOperandIdx + 2];
6960
      Operands.push_back(PtrOperand);
6961
      if (IsMasked)
6962
        Operands.push_back(Ops[NF]);
6963
      Operands.push_back(VLOperand);
6964
      if (IsMasked)
6965
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
6966
 
6967
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
6968
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
6969
      clang::CharUnits Align =
6970
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
6971
      for (unsigned I = 0; I < NF; ++I) {
6972
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
6973
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
6974
      }
6975
      // Store new_vl.
6976
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
6977
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
6978
    }
6979
    break;
6980
case RISCVVector::BI__builtin_rvv_vlseg3e8ff_v_tum:
6981
case RISCVVector::BI__builtin_rvv_vlseg3e16ff_v_tum:
6982
case RISCVVector::BI__builtin_rvv_vlseg3e32ff_v_tum:
6983
case RISCVVector::BI__builtin_rvv_vlseg3e64ff_v_tum:
6984
  ID = Intrinsic::riscv_vlseg3ff_mask;
6985
  NF = 3;
6986
  PolicyAttrs = 2;
6987
IsMasked = true;
6988
 
6989
    {
6990
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
6991
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
6992
      SmallVector<llvm::Value*, 12> Operands;
6993
 
6994
      // Please refer to comment under 'defvar NFList' in this file
6995
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
6996
          (!IsMasked && PolicyAttrs & RVV_VTA))
6997
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
6998
      else {
6999
        if (IsMasked)
7000
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
7001
        else // Unmasked
7002
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
7003
      }
7004
      unsigned PtrOperandIdx = IsMasked ?
7005
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
7006
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
7007
      Value *PtrOperand = Ops[PtrOperandIdx];
7008
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
7009
      Value *VLOperand = Ops[PtrOperandIdx + 2];
7010
      Operands.push_back(PtrOperand);
7011
      if (IsMasked)
7012
        Operands.push_back(Ops[NF]);
7013
      Operands.push_back(VLOperand);
7014
      if (IsMasked)
7015
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
7016
 
7017
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
7018
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
7019
      clang::CharUnits Align =
7020
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
7021
      for (unsigned I = 0; I < NF; ++I) {
7022
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
7023
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
7024
      }
7025
      // Store new_vl.
7026
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
7027
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
7028
    }
7029
    break;
7030
case RISCVVector::BI__builtin_rvv_vlseg3e8ff_v_tama:
7031
case RISCVVector::BI__builtin_rvv_vlseg3e16ff_v_tama:
7032
case RISCVVector::BI__builtin_rvv_vlseg3e32ff_v_tama:
7033
case RISCVVector::BI__builtin_rvv_vlseg3e64ff_v_tama:
7034
  ID = Intrinsic::riscv_vlseg3ff_mask;
7035
  NF = 3;
7036
  PolicyAttrs = 3;
7037
IsMasked = true;
7038
 
7039
    {
7040
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
7041
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
7042
      SmallVector<llvm::Value*, 12> Operands;
7043
 
7044
      // Please refer to comment under 'defvar NFList' in this file
7045
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
7046
          (!IsMasked && PolicyAttrs & RVV_VTA))
7047
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
7048
      else {
7049
        if (IsMasked)
7050
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
7051
        else // Unmasked
7052
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
7053
      }
7054
      unsigned PtrOperandIdx = IsMasked ?
7055
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
7056
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
7057
      Value *PtrOperand = Ops[PtrOperandIdx];
7058
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
7059
      Value *VLOperand = Ops[PtrOperandIdx + 2];
7060
      Operands.push_back(PtrOperand);
7061
      if (IsMasked)
7062
        Operands.push_back(Ops[NF]);
7063
      Operands.push_back(VLOperand);
7064
      if (IsMasked)
7065
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
7066
 
7067
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
7068
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
7069
      clang::CharUnits Align =
7070
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
7071
      for (unsigned I = 0; I < NF; ++I) {
7072
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
7073
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
7074
      }
7075
      // Store new_vl.
7076
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
7077
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
7078
    }
7079
    break;
7080
case RISCVVector::BI__builtin_rvv_vlseg3e8ff_v_tumu:
7081
case RISCVVector::BI__builtin_rvv_vlseg3e16ff_v_tumu:
7082
case RISCVVector::BI__builtin_rvv_vlseg3e32ff_v_tumu:
7083
case RISCVVector::BI__builtin_rvv_vlseg3e64ff_v_tumu:
7084
  ID = Intrinsic::riscv_vlseg3ff_mask;
7085
  NF = 3;
7086
  PolicyAttrs = 0;
7087
IsMasked = true;
7088
 
7089
    {
7090
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
7091
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
7092
      SmallVector<llvm::Value*, 12> Operands;
7093
 
7094
      // Please refer to comment under 'defvar NFList' in this file
7095
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
7096
          (!IsMasked && PolicyAttrs & RVV_VTA))
7097
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
7098
      else {
7099
        if (IsMasked)
7100
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
7101
        else // Unmasked
7102
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
7103
      }
7104
      unsigned PtrOperandIdx = IsMasked ?
7105
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
7106
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
7107
      Value *PtrOperand = Ops[PtrOperandIdx];
7108
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
7109
      Value *VLOperand = Ops[PtrOperandIdx + 2];
7110
      Operands.push_back(PtrOperand);
7111
      if (IsMasked)
7112
        Operands.push_back(Ops[NF]);
7113
      Operands.push_back(VLOperand);
7114
      if (IsMasked)
7115
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
7116
 
7117
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
7118
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
7119
      clang::CharUnits Align =
7120
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
7121
      for (unsigned I = 0; I < NF; ++I) {
7122
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
7123
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
7124
      }
7125
      // Store new_vl.
7126
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
7127
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
7128
    }
7129
    break;
7130
case RISCVVector::BI__builtin_rvv_vlseg3e8ff_v_mu:
7131
case RISCVVector::BI__builtin_rvv_vlseg3e16ff_v_mu:
7132
case RISCVVector::BI__builtin_rvv_vlseg3e32ff_v_mu:
7133
case RISCVVector::BI__builtin_rvv_vlseg3e64ff_v_mu:
7134
  ID = Intrinsic::riscv_vlseg3ff_mask;
7135
  NF = 3;
7136
  PolicyAttrs = 1;
7137
IsMasked = true;
7138
 
7139
    {
7140
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
7141
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
7142
      SmallVector<llvm::Value*, 12> Operands;
7143
 
7144
      // Please refer to comment under 'defvar NFList' in this file
7145
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
7146
          (!IsMasked && PolicyAttrs & RVV_VTA))
7147
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
7148
      else {
7149
        if (IsMasked)
7150
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
7151
        else // Unmasked
7152
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
7153
      }
7154
      unsigned PtrOperandIdx = IsMasked ?
7155
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
7156
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
7157
      Value *PtrOperand = Ops[PtrOperandIdx];
7158
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
7159
      Value *VLOperand = Ops[PtrOperandIdx + 2];
7160
      Operands.push_back(PtrOperand);
7161
      if (IsMasked)
7162
        Operands.push_back(Ops[NF]);
7163
      Operands.push_back(VLOperand);
7164
      if (IsMasked)
7165
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
7166
 
7167
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
7168
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
7169
      clang::CharUnits Align =
7170
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
7171
      for (unsigned I = 0; I < NF; ++I) {
7172
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
7173
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
7174
      }
7175
      // Store new_vl.
7176
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
7177
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
7178
    }
7179
    break;
7180
case RISCVVector::BI__builtin_rvv_vlseg4e8_v_tu:
7181
case RISCVVector::BI__builtin_rvv_vlseg4e16_v_tu:
7182
case RISCVVector::BI__builtin_rvv_vlseg4e32_v_tu:
7183
case RISCVVector::BI__builtin_rvv_vlseg4e64_v_tu:
7184
  ID = Intrinsic::riscv_vlseg4;
7185
  NF = 4;
7186
  PolicyAttrs = 2;
7187
IsMasked = false;
7188
 
7189
    {
7190
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
7191
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
7192
      SmallVector<llvm::Value*, 12> Operands;
7193
 
7194
      // Please refer to comment under 'defvar NFList' in this file
7195
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
7196
          (!IsMasked && PolicyAttrs & RVV_VTA))
7197
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
7198
      else {
7199
        if (IsMasked)
7200
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
7201
        else // Unmasked
7202
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
7203
      }
7204
      unsigned PtrOperandIdx = IsMasked ?
7205
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
7206
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
7207
      Value *PtrOperand = Ops[PtrOperandIdx];
7208
      Value *VLOperand = Ops[PtrOperandIdx + 1];
7209
      Operands.push_back(PtrOperand);
7210
      if (IsMasked)
7211
        Operands.push_back(Ops[NF]);
7212
      Operands.push_back(VLOperand);
7213
      if (IsMasked)
7214
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
7215
 
7216
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
7217
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
7218
      clang::CharUnits Align =
7219
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
7220
      llvm::Value *V;
7221
      for (unsigned I = 0; I < NF; ++I) {
7222
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
7223
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
7224
      }
7225
      return V;
7226
    }
7227
    break;
7228
case RISCVVector::BI__builtin_rvv_vlseg4e8_v_ta:
7229
case RISCVVector::BI__builtin_rvv_vlseg4e16_v_ta:
7230
case RISCVVector::BI__builtin_rvv_vlseg4e32_v_ta:
7231
case RISCVVector::BI__builtin_rvv_vlseg4e64_v_ta:
7232
  ID = Intrinsic::riscv_vlseg4;
7233
  NF = 4;
7234
  PolicyAttrs = 3;
7235
IsMasked = false;
7236
 
7237
    {
7238
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
7239
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
7240
      SmallVector<llvm::Value*, 12> Operands;
7241
 
7242
      // Please refer to comment under 'defvar NFList' in this file
7243
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
7244
          (!IsMasked && PolicyAttrs & RVV_VTA))
7245
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
7246
      else {
7247
        if (IsMasked)
7248
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
7249
        else // Unmasked
7250
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
7251
      }
7252
      unsigned PtrOperandIdx = IsMasked ?
7253
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
7254
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
7255
      Value *PtrOperand = Ops[PtrOperandIdx];
7256
      Value *VLOperand = Ops[PtrOperandIdx + 1];
7257
      Operands.push_back(PtrOperand);
7258
      if (IsMasked)
7259
        Operands.push_back(Ops[NF]);
7260
      Operands.push_back(VLOperand);
7261
      if (IsMasked)
7262
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
7263
 
7264
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
7265
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
7266
      clang::CharUnits Align =
7267
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
7268
      llvm::Value *V;
7269
      for (unsigned I = 0; I < NF; ++I) {
7270
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
7271
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
7272
      }
7273
      return V;
7274
    }
7275
    break;
7276
case RISCVVector::BI__builtin_rvv_vlseg4e8_v_tum:
7277
case RISCVVector::BI__builtin_rvv_vlseg4e16_v_tum:
7278
case RISCVVector::BI__builtin_rvv_vlseg4e32_v_tum:
7279
case RISCVVector::BI__builtin_rvv_vlseg4e64_v_tum:
7280
  ID = Intrinsic::riscv_vlseg4_mask;
7281
  NF = 4;
7282
  PolicyAttrs = 2;
7283
IsMasked = true;
7284
 
7285
    {
7286
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
7287
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
7288
      SmallVector<llvm::Value*, 12> Operands;
7289
 
7290
      // Please refer to comment under 'defvar NFList' in this file
7291
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
7292
          (!IsMasked && PolicyAttrs & RVV_VTA))
7293
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
7294
      else {
7295
        if (IsMasked)
7296
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
7297
        else // Unmasked
7298
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
7299
      }
7300
      unsigned PtrOperandIdx = IsMasked ?
7301
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
7302
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
7303
      Value *PtrOperand = Ops[PtrOperandIdx];
7304
      Value *VLOperand = Ops[PtrOperandIdx + 1];
7305
      Operands.push_back(PtrOperand);
7306
      if (IsMasked)
7307
        Operands.push_back(Ops[NF]);
7308
      Operands.push_back(VLOperand);
7309
      if (IsMasked)
7310
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
7311
 
7312
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
7313
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
7314
      clang::CharUnits Align =
7315
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
7316
      llvm::Value *V;
7317
      for (unsigned I = 0; I < NF; ++I) {
7318
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
7319
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
7320
      }
7321
      return V;
7322
    }
7323
    break;
7324
case RISCVVector::BI__builtin_rvv_vlseg4e8_v_tama:
7325
case RISCVVector::BI__builtin_rvv_vlseg4e16_v_tama:
7326
case RISCVVector::BI__builtin_rvv_vlseg4e32_v_tama:
7327
case RISCVVector::BI__builtin_rvv_vlseg4e64_v_tama:
7328
  ID = Intrinsic::riscv_vlseg4_mask;
7329
  NF = 4;
7330
  PolicyAttrs = 3;
7331
IsMasked = true;
7332
 
7333
    {
7334
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
7335
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
7336
      SmallVector<llvm::Value*, 12> Operands;
7337
 
7338
      // Please refer to comment under 'defvar NFList' in this file
7339
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
7340
          (!IsMasked && PolicyAttrs & RVV_VTA))
7341
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
7342
      else {
7343
        if (IsMasked)
7344
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
7345
        else // Unmasked
7346
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
7347
      }
7348
      unsigned PtrOperandIdx = IsMasked ?
7349
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
7350
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
7351
      Value *PtrOperand = Ops[PtrOperandIdx];
7352
      Value *VLOperand = Ops[PtrOperandIdx + 1];
7353
      Operands.push_back(PtrOperand);
7354
      if (IsMasked)
7355
        Operands.push_back(Ops[NF]);
7356
      Operands.push_back(VLOperand);
7357
      if (IsMasked)
7358
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
7359
 
7360
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
7361
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
7362
      clang::CharUnits Align =
7363
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
7364
      llvm::Value *V;
7365
      for (unsigned I = 0; I < NF; ++I) {
7366
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
7367
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
7368
      }
7369
      return V;
7370
    }
7371
    break;
7372
case RISCVVector::BI__builtin_rvv_vlseg4e8_v_tumu:
7373
case RISCVVector::BI__builtin_rvv_vlseg4e16_v_tumu:
7374
case RISCVVector::BI__builtin_rvv_vlseg4e32_v_tumu:
7375
case RISCVVector::BI__builtin_rvv_vlseg4e64_v_tumu:
7376
  ID = Intrinsic::riscv_vlseg4_mask;
7377
  NF = 4;
7378
  PolicyAttrs = 0;
7379
IsMasked = true;
7380
 
7381
    {
7382
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
7383
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
7384
      SmallVector<llvm::Value*, 12> Operands;
7385
 
7386
      // Please refer to comment under 'defvar NFList' in this file
7387
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
7388
          (!IsMasked && PolicyAttrs & RVV_VTA))
7389
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
7390
      else {
7391
        if (IsMasked)
7392
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
7393
        else // Unmasked
7394
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
7395
      }
7396
      unsigned PtrOperandIdx = IsMasked ?
7397
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
7398
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
7399
      Value *PtrOperand = Ops[PtrOperandIdx];
7400
      Value *VLOperand = Ops[PtrOperandIdx + 1];
7401
      Operands.push_back(PtrOperand);
7402
      if (IsMasked)
7403
        Operands.push_back(Ops[NF]);
7404
      Operands.push_back(VLOperand);
7405
      if (IsMasked)
7406
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
7407
 
7408
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
7409
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
7410
      clang::CharUnits Align =
7411
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
7412
      llvm::Value *V;
7413
      for (unsigned I = 0; I < NF; ++I) {
7414
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
7415
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
7416
      }
7417
      return V;
7418
    }
7419
    break;
7420
case RISCVVector::BI__builtin_rvv_vlseg4e8_v_mu:
7421
case RISCVVector::BI__builtin_rvv_vlseg4e16_v_mu:
7422
case RISCVVector::BI__builtin_rvv_vlseg4e32_v_mu:
7423
case RISCVVector::BI__builtin_rvv_vlseg4e64_v_mu:
7424
  ID = Intrinsic::riscv_vlseg4_mask;
7425
  NF = 4;
7426
  PolicyAttrs = 1;
7427
IsMasked = true;
7428
 
7429
    {
7430
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
7431
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
7432
      SmallVector<llvm::Value*, 12> Operands;
7433
 
7434
      // Please refer to comment under 'defvar NFList' in this file
7435
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
7436
          (!IsMasked && PolicyAttrs & RVV_VTA))
7437
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
7438
      else {
7439
        if (IsMasked)
7440
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
7441
        else // Unmasked
7442
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
7443
      }
7444
      unsigned PtrOperandIdx = IsMasked ?
7445
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
7446
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
7447
      Value *PtrOperand = Ops[PtrOperandIdx];
7448
      Value *VLOperand = Ops[PtrOperandIdx + 1];
7449
      Operands.push_back(PtrOperand);
7450
      if (IsMasked)
7451
        Operands.push_back(Ops[NF]);
7452
      Operands.push_back(VLOperand);
7453
      if (IsMasked)
7454
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
7455
 
7456
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
7457
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
7458
      clang::CharUnits Align =
7459
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
7460
      llvm::Value *V;
7461
      for (unsigned I = 0; I < NF; ++I) {
7462
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
7463
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
7464
      }
7465
      return V;
7466
    }
7467
    break;
7468
case RISCVVector::BI__builtin_rvv_vlseg4e8ff_v_tu:
7469
case RISCVVector::BI__builtin_rvv_vlseg4e16ff_v_tu:
7470
case RISCVVector::BI__builtin_rvv_vlseg4e32ff_v_tu:
7471
case RISCVVector::BI__builtin_rvv_vlseg4e64ff_v_tu:
7472
  ID = Intrinsic::riscv_vlseg4ff;
7473
  NF = 4;
7474
  PolicyAttrs = 2;
7475
IsMasked = false;
7476
 
7477
    {
7478
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
7479
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
7480
      SmallVector<llvm::Value*, 12> Operands;
7481
 
7482
      // Please refer to comment under 'defvar NFList' in this file
7483
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
7484
          (!IsMasked && PolicyAttrs & RVV_VTA))
7485
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
7486
      else {
7487
        if (IsMasked)
7488
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
7489
        else // Unmasked
7490
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
7491
      }
7492
      unsigned PtrOperandIdx = IsMasked ?
7493
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
7494
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
7495
      Value *PtrOperand = Ops[PtrOperandIdx];
7496
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
7497
      Value *VLOperand = Ops[PtrOperandIdx + 2];
7498
      Operands.push_back(PtrOperand);
7499
      if (IsMasked)
7500
        Operands.push_back(Ops[NF]);
7501
      Operands.push_back(VLOperand);
7502
      if (IsMasked)
7503
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
7504
 
7505
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
7506
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
7507
      clang::CharUnits Align =
7508
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
7509
      for (unsigned I = 0; I < NF; ++I) {
7510
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
7511
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
7512
      }
7513
      // Store new_vl.
7514
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
7515
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
7516
    }
7517
    break;
7518
case RISCVVector::BI__builtin_rvv_vlseg4e8ff_v_ta:
7519
case RISCVVector::BI__builtin_rvv_vlseg4e16ff_v_ta:
7520
case RISCVVector::BI__builtin_rvv_vlseg4e32ff_v_ta:
7521
case RISCVVector::BI__builtin_rvv_vlseg4e64ff_v_ta:
7522
  ID = Intrinsic::riscv_vlseg4ff;
7523
  NF = 4;
7524
  PolicyAttrs = 3;
7525
IsMasked = false;
7526
 
7527
    {
7528
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
7529
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
7530
      SmallVector<llvm::Value*, 12> Operands;
7531
 
7532
      // Please refer to comment under 'defvar NFList' in this file
7533
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
7534
          (!IsMasked && PolicyAttrs & RVV_VTA))
7535
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
7536
      else {
7537
        if (IsMasked)
7538
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
7539
        else // Unmasked
7540
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
7541
      }
7542
      unsigned PtrOperandIdx = IsMasked ?
7543
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
7544
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
7545
      Value *PtrOperand = Ops[PtrOperandIdx];
7546
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
7547
      Value *VLOperand = Ops[PtrOperandIdx + 2];
7548
      Operands.push_back(PtrOperand);
7549
      if (IsMasked)
7550
        Operands.push_back(Ops[NF]);
7551
      Operands.push_back(VLOperand);
7552
      if (IsMasked)
7553
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
7554
 
7555
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
7556
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
7557
      clang::CharUnits Align =
7558
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
7559
      for (unsigned I = 0; I < NF; ++I) {
7560
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
7561
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
7562
      }
7563
      // Store new_vl.
7564
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
7565
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
7566
    }
7567
    break;
7568
case RISCVVector::BI__builtin_rvv_vlseg4e8ff_v_tum:
7569
case RISCVVector::BI__builtin_rvv_vlseg4e16ff_v_tum:
7570
case RISCVVector::BI__builtin_rvv_vlseg4e32ff_v_tum:
7571
case RISCVVector::BI__builtin_rvv_vlseg4e64ff_v_tum:
7572
  ID = Intrinsic::riscv_vlseg4ff_mask;
7573
  NF = 4;
7574
  PolicyAttrs = 2;
7575
IsMasked = true;
7576
 
7577
    {
7578
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
7579
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
7580
      SmallVector<llvm::Value*, 12> Operands;
7581
 
7582
      // Please refer to comment under 'defvar NFList' in this file
7583
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
7584
          (!IsMasked && PolicyAttrs & RVV_VTA))
7585
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
7586
      else {
7587
        if (IsMasked)
7588
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
7589
        else // Unmasked
7590
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
7591
      }
7592
      unsigned PtrOperandIdx = IsMasked ?
7593
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
7594
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
7595
      Value *PtrOperand = Ops[PtrOperandIdx];
7596
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
7597
      Value *VLOperand = Ops[PtrOperandIdx + 2];
7598
      Operands.push_back(PtrOperand);
7599
      if (IsMasked)
7600
        Operands.push_back(Ops[NF]);
7601
      Operands.push_back(VLOperand);
7602
      if (IsMasked)
7603
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
7604
 
7605
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
7606
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
7607
      clang::CharUnits Align =
7608
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
7609
      for (unsigned I = 0; I < NF; ++I) {
7610
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
7611
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
7612
      }
7613
      // Store new_vl.
7614
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
7615
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
7616
    }
7617
    break;
7618
case RISCVVector::BI__builtin_rvv_vlseg4e8ff_v_tama:
7619
case RISCVVector::BI__builtin_rvv_vlseg4e16ff_v_tama:
7620
case RISCVVector::BI__builtin_rvv_vlseg4e32ff_v_tama:
7621
case RISCVVector::BI__builtin_rvv_vlseg4e64ff_v_tama:
7622
  ID = Intrinsic::riscv_vlseg4ff_mask;
7623
  NF = 4;
7624
  PolicyAttrs = 3;
7625
IsMasked = true;
7626
 
7627
    {
7628
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
7629
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
7630
      SmallVector<llvm::Value*, 12> Operands;
7631
 
7632
      // Please refer to comment under 'defvar NFList' in this file
7633
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
7634
          (!IsMasked && PolicyAttrs & RVV_VTA))
7635
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
7636
      else {
7637
        if (IsMasked)
7638
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
7639
        else // Unmasked
7640
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
7641
      }
7642
      unsigned PtrOperandIdx = IsMasked ?
7643
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
7644
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
7645
      Value *PtrOperand = Ops[PtrOperandIdx];
7646
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
7647
      Value *VLOperand = Ops[PtrOperandIdx + 2];
7648
      Operands.push_back(PtrOperand);
7649
      if (IsMasked)
7650
        Operands.push_back(Ops[NF]);
7651
      Operands.push_back(VLOperand);
7652
      if (IsMasked)
7653
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
7654
 
7655
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
7656
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
7657
      clang::CharUnits Align =
7658
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
7659
      for (unsigned I = 0; I < NF; ++I) {
7660
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
7661
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
7662
      }
7663
      // Store new_vl.
7664
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
7665
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
7666
    }
7667
    break;
7668
case RISCVVector::BI__builtin_rvv_vlseg4e8ff_v_tumu:
7669
case RISCVVector::BI__builtin_rvv_vlseg4e16ff_v_tumu:
7670
case RISCVVector::BI__builtin_rvv_vlseg4e32ff_v_tumu:
7671
case RISCVVector::BI__builtin_rvv_vlseg4e64ff_v_tumu:
7672
  ID = Intrinsic::riscv_vlseg4ff_mask;
7673
  NF = 4;
7674
  PolicyAttrs = 0;
7675
IsMasked = true;
7676
 
7677
    {
7678
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
7679
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
7680
      SmallVector<llvm::Value*, 12> Operands;
7681
 
7682
      // Please refer to comment under 'defvar NFList' in this file
7683
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
7684
          (!IsMasked && PolicyAttrs & RVV_VTA))
7685
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
7686
      else {
7687
        if (IsMasked)
7688
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
7689
        else // Unmasked
7690
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
7691
      }
7692
      unsigned PtrOperandIdx = IsMasked ?
7693
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
7694
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
7695
      Value *PtrOperand = Ops[PtrOperandIdx];
7696
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
7697
      Value *VLOperand = Ops[PtrOperandIdx + 2];
7698
      Operands.push_back(PtrOperand);
7699
      if (IsMasked)
7700
        Operands.push_back(Ops[NF]);
7701
      Operands.push_back(VLOperand);
7702
      if (IsMasked)
7703
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
7704
 
7705
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
7706
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
7707
      clang::CharUnits Align =
7708
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
7709
      for (unsigned I = 0; I < NF; ++I) {
7710
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
7711
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
7712
      }
7713
      // Store new_vl.
7714
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
7715
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
7716
    }
7717
    break;
7718
case RISCVVector::BI__builtin_rvv_vlseg4e8ff_v_mu:
7719
case RISCVVector::BI__builtin_rvv_vlseg4e16ff_v_mu:
7720
case RISCVVector::BI__builtin_rvv_vlseg4e32ff_v_mu:
7721
case RISCVVector::BI__builtin_rvv_vlseg4e64ff_v_mu:
7722
  ID = Intrinsic::riscv_vlseg4ff_mask;
7723
  NF = 4;
7724
  PolicyAttrs = 1;
7725
IsMasked = true;
7726
 
7727
    {
7728
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
7729
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
7730
      SmallVector<llvm::Value*, 12> Operands;
7731
 
7732
      // Please refer to comment under 'defvar NFList' in this file
7733
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
7734
          (!IsMasked && PolicyAttrs & RVV_VTA))
7735
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
7736
      else {
7737
        if (IsMasked)
7738
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
7739
        else // Unmasked
7740
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
7741
      }
7742
      unsigned PtrOperandIdx = IsMasked ?
7743
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
7744
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
7745
      Value *PtrOperand = Ops[PtrOperandIdx];
7746
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
7747
      Value *VLOperand = Ops[PtrOperandIdx + 2];
7748
      Operands.push_back(PtrOperand);
7749
      if (IsMasked)
7750
        Operands.push_back(Ops[NF]);
7751
      Operands.push_back(VLOperand);
7752
      if (IsMasked)
7753
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
7754
 
7755
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
7756
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
7757
      clang::CharUnits Align =
7758
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
7759
      for (unsigned I = 0; I < NF; ++I) {
7760
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
7761
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
7762
      }
7763
      // Store new_vl.
7764
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
7765
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
7766
    }
7767
    break;
7768
case RISCVVector::BI__builtin_rvv_vlseg5e8_v_tu:
7769
case RISCVVector::BI__builtin_rvv_vlseg5e16_v_tu:
7770
case RISCVVector::BI__builtin_rvv_vlseg5e32_v_tu:
7771
case RISCVVector::BI__builtin_rvv_vlseg5e64_v_tu:
7772
  ID = Intrinsic::riscv_vlseg5;
7773
  NF = 5;
7774
  PolicyAttrs = 2;
7775
IsMasked = false;
7776
 
7777
    {
7778
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
7779
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
7780
      SmallVector<llvm::Value*, 12> Operands;
7781
 
7782
      // Please refer to comment under 'defvar NFList' in this file
7783
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
7784
          (!IsMasked && PolicyAttrs & RVV_VTA))
7785
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
7786
      else {
7787
        if (IsMasked)
7788
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
7789
        else // Unmasked
7790
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
7791
      }
7792
      unsigned PtrOperandIdx = IsMasked ?
7793
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
7794
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
7795
      Value *PtrOperand = Ops[PtrOperandIdx];
7796
      Value *VLOperand = Ops[PtrOperandIdx + 1];
7797
      Operands.push_back(PtrOperand);
7798
      if (IsMasked)
7799
        Operands.push_back(Ops[NF]);
7800
      Operands.push_back(VLOperand);
7801
      if (IsMasked)
7802
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
7803
 
7804
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
7805
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
7806
      clang::CharUnits Align =
7807
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
7808
      llvm::Value *V;
7809
      for (unsigned I = 0; I < NF; ++I) {
7810
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
7811
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
7812
      }
7813
      return V;
7814
    }
7815
    break;
7816
case RISCVVector::BI__builtin_rvv_vlseg5e8_v_ta:
7817
case RISCVVector::BI__builtin_rvv_vlseg5e16_v_ta:
7818
case RISCVVector::BI__builtin_rvv_vlseg5e32_v_ta:
7819
case RISCVVector::BI__builtin_rvv_vlseg5e64_v_ta:
7820
  ID = Intrinsic::riscv_vlseg5;
7821
  NF = 5;
7822
  PolicyAttrs = 3;
7823
IsMasked = false;
7824
 
7825
    {
7826
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
7827
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
7828
      SmallVector<llvm::Value*, 12> Operands;
7829
 
7830
      // Please refer to comment under 'defvar NFList' in this file
7831
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
7832
          (!IsMasked && PolicyAttrs & RVV_VTA))
7833
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
7834
      else {
7835
        if (IsMasked)
7836
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
7837
        else // Unmasked
7838
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
7839
      }
7840
      unsigned PtrOperandIdx = IsMasked ?
7841
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
7842
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
7843
      Value *PtrOperand = Ops[PtrOperandIdx];
7844
      Value *VLOperand = Ops[PtrOperandIdx + 1];
7845
      Operands.push_back(PtrOperand);
7846
      if (IsMasked)
7847
        Operands.push_back(Ops[NF]);
7848
      Operands.push_back(VLOperand);
7849
      if (IsMasked)
7850
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
7851
 
7852
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
7853
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
7854
      clang::CharUnits Align =
7855
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
7856
      llvm::Value *V;
7857
      for (unsigned I = 0; I < NF; ++I) {
7858
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
7859
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
7860
      }
7861
      return V;
7862
    }
7863
    break;
7864
case RISCVVector::BI__builtin_rvv_vlseg5e8_v_tum:
7865
case RISCVVector::BI__builtin_rvv_vlseg5e16_v_tum:
7866
case RISCVVector::BI__builtin_rvv_vlseg5e32_v_tum:
7867
case RISCVVector::BI__builtin_rvv_vlseg5e64_v_tum:
7868
  ID = Intrinsic::riscv_vlseg5_mask;
7869
  NF = 5;
7870
  PolicyAttrs = 2;
7871
IsMasked = true;
7872
 
7873
    {
7874
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
7875
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
7876
      SmallVector<llvm::Value*, 12> Operands;
7877
 
7878
      // Please refer to comment under 'defvar NFList' in this file
7879
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
7880
          (!IsMasked && PolicyAttrs & RVV_VTA))
7881
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
7882
      else {
7883
        if (IsMasked)
7884
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
7885
        else // Unmasked
7886
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
7887
      }
7888
      unsigned PtrOperandIdx = IsMasked ?
7889
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
7890
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
7891
      Value *PtrOperand = Ops[PtrOperandIdx];
7892
      Value *VLOperand = Ops[PtrOperandIdx + 1];
7893
      Operands.push_back(PtrOperand);
7894
      if (IsMasked)
7895
        Operands.push_back(Ops[NF]);
7896
      Operands.push_back(VLOperand);
7897
      if (IsMasked)
7898
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
7899
 
7900
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
7901
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
7902
      clang::CharUnits Align =
7903
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
7904
      llvm::Value *V;
7905
      for (unsigned I = 0; I < NF; ++I) {
7906
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
7907
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
7908
      }
7909
      return V;
7910
    }
7911
    break;
7912
case RISCVVector::BI__builtin_rvv_vlseg5e8_v_tama:
7913
case RISCVVector::BI__builtin_rvv_vlseg5e16_v_tama:
7914
case RISCVVector::BI__builtin_rvv_vlseg5e32_v_tama:
7915
case RISCVVector::BI__builtin_rvv_vlseg5e64_v_tama:
7916
  ID = Intrinsic::riscv_vlseg5_mask;
7917
  NF = 5;
7918
  PolicyAttrs = 3;
7919
IsMasked = true;
7920
 
7921
    {
7922
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
7923
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
7924
      SmallVector<llvm::Value*, 12> Operands;
7925
 
7926
      // Please refer to comment under 'defvar NFList' in this file
7927
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
7928
          (!IsMasked && PolicyAttrs & RVV_VTA))
7929
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
7930
      else {
7931
        if (IsMasked)
7932
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
7933
        else // Unmasked
7934
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
7935
      }
7936
      unsigned PtrOperandIdx = IsMasked ?
7937
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
7938
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
7939
      Value *PtrOperand = Ops[PtrOperandIdx];
7940
      Value *VLOperand = Ops[PtrOperandIdx + 1];
7941
      Operands.push_back(PtrOperand);
7942
      if (IsMasked)
7943
        Operands.push_back(Ops[NF]);
7944
      Operands.push_back(VLOperand);
7945
      if (IsMasked)
7946
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
7947
 
7948
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
7949
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
7950
      clang::CharUnits Align =
7951
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
7952
      llvm::Value *V;
7953
      for (unsigned I = 0; I < NF; ++I) {
7954
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
7955
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
7956
      }
7957
      return V;
7958
    }
7959
    break;
7960
case RISCVVector::BI__builtin_rvv_vlseg5e8_v_tumu:
7961
case RISCVVector::BI__builtin_rvv_vlseg5e16_v_tumu:
7962
case RISCVVector::BI__builtin_rvv_vlseg5e32_v_tumu:
7963
case RISCVVector::BI__builtin_rvv_vlseg5e64_v_tumu:
7964
  ID = Intrinsic::riscv_vlseg5_mask;
7965
  NF = 5;
7966
  PolicyAttrs = 0;
7967
IsMasked = true;
7968
 
7969
    {
7970
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
7971
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
7972
      SmallVector<llvm::Value*, 12> Operands;
7973
 
7974
      // Please refer to comment under 'defvar NFList' in this file
7975
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
7976
          (!IsMasked && PolicyAttrs & RVV_VTA))
7977
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
7978
      else {
7979
        if (IsMasked)
7980
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
7981
        else // Unmasked
7982
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
7983
      }
7984
      unsigned PtrOperandIdx = IsMasked ?
7985
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
7986
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
7987
      Value *PtrOperand = Ops[PtrOperandIdx];
7988
      Value *VLOperand = Ops[PtrOperandIdx + 1];
7989
      Operands.push_back(PtrOperand);
7990
      if (IsMasked)
7991
        Operands.push_back(Ops[NF]);
7992
      Operands.push_back(VLOperand);
7993
      if (IsMasked)
7994
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
7995
 
7996
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
7997
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
7998
      clang::CharUnits Align =
7999
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
8000
      llvm::Value *V;
8001
      for (unsigned I = 0; I < NF; ++I) {
8002
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
8003
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
8004
      }
8005
      return V;
8006
    }
8007
    break;
8008
case RISCVVector::BI__builtin_rvv_vlseg5e8_v_mu:
8009
case RISCVVector::BI__builtin_rvv_vlseg5e16_v_mu:
8010
case RISCVVector::BI__builtin_rvv_vlseg5e32_v_mu:
8011
case RISCVVector::BI__builtin_rvv_vlseg5e64_v_mu:
8012
  ID = Intrinsic::riscv_vlseg5_mask;
8013
  NF = 5;
8014
  PolicyAttrs = 1;
8015
IsMasked = true;
8016
 
8017
    {
8018
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
8019
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
8020
      SmallVector<llvm::Value*, 12> Operands;
8021
 
8022
      // Please refer to comment under 'defvar NFList' in this file
8023
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
8024
          (!IsMasked && PolicyAttrs & RVV_VTA))
8025
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
8026
      else {
8027
        if (IsMasked)
8028
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
8029
        else // Unmasked
8030
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
8031
      }
8032
      unsigned PtrOperandIdx = IsMasked ?
8033
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
8034
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
8035
      Value *PtrOperand = Ops[PtrOperandIdx];
8036
      Value *VLOperand = Ops[PtrOperandIdx + 1];
8037
      Operands.push_back(PtrOperand);
8038
      if (IsMasked)
8039
        Operands.push_back(Ops[NF]);
8040
      Operands.push_back(VLOperand);
8041
      if (IsMasked)
8042
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
8043
 
8044
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
8045
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
8046
      clang::CharUnits Align =
8047
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
8048
      llvm::Value *V;
8049
      for (unsigned I = 0; I < NF; ++I) {
8050
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
8051
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
8052
      }
8053
      return V;
8054
    }
8055
    break;
8056
case RISCVVector::BI__builtin_rvv_vlseg5e8ff_v_tu:
8057
case RISCVVector::BI__builtin_rvv_vlseg5e16ff_v_tu:
8058
case RISCVVector::BI__builtin_rvv_vlseg5e32ff_v_tu:
8059
case RISCVVector::BI__builtin_rvv_vlseg5e64ff_v_tu:
8060
  ID = Intrinsic::riscv_vlseg5ff;
8061
  NF = 5;
8062
  PolicyAttrs = 2;
8063
IsMasked = false;
8064
 
8065
    {
8066
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
8067
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
8068
      SmallVector<llvm::Value*, 12> Operands;
8069
 
8070
      // Please refer to comment under 'defvar NFList' in this file
8071
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
8072
          (!IsMasked && PolicyAttrs & RVV_VTA))
8073
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
8074
      else {
8075
        if (IsMasked)
8076
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
8077
        else // Unmasked
8078
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
8079
      }
8080
      unsigned PtrOperandIdx = IsMasked ?
8081
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
8082
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
8083
      Value *PtrOperand = Ops[PtrOperandIdx];
8084
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
8085
      Value *VLOperand = Ops[PtrOperandIdx + 2];
8086
      Operands.push_back(PtrOperand);
8087
      if (IsMasked)
8088
        Operands.push_back(Ops[NF]);
8089
      Operands.push_back(VLOperand);
8090
      if (IsMasked)
8091
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
8092
 
8093
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
8094
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
8095
      clang::CharUnits Align =
8096
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
8097
      for (unsigned I = 0; I < NF; ++I) {
8098
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
8099
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
8100
      }
8101
      // Store new_vl.
8102
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
8103
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
8104
    }
8105
    break;
8106
case RISCVVector::BI__builtin_rvv_vlseg5e8ff_v_ta:
8107
case RISCVVector::BI__builtin_rvv_vlseg5e16ff_v_ta:
8108
case RISCVVector::BI__builtin_rvv_vlseg5e32ff_v_ta:
8109
case RISCVVector::BI__builtin_rvv_vlseg5e64ff_v_ta:
8110
  ID = Intrinsic::riscv_vlseg5ff;
8111
  NF = 5;
8112
  PolicyAttrs = 3;
8113
IsMasked = false;
8114
 
8115
    {
8116
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
8117
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
8118
      SmallVector<llvm::Value*, 12> Operands;
8119
 
8120
      // Please refer to comment under 'defvar NFList' in this file
8121
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
8122
          (!IsMasked && PolicyAttrs & RVV_VTA))
8123
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
8124
      else {
8125
        if (IsMasked)
8126
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
8127
        else // Unmasked
8128
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
8129
      }
8130
      unsigned PtrOperandIdx = IsMasked ?
8131
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
8132
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
8133
      Value *PtrOperand = Ops[PtrOperandIdx];
8134
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
8135
      Value *VLOperand = Ops[PtrOperandIdx + 2];
8136
      Operands.push_back(PtrOperand);
8137
      if (IsMasked)
8138
        Operands.push_back(Ops[NF]);
8139
      Operands.push_back(VLOperand);
8140
      if (IsMasked)
8141
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
8142
 
8143
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
8144
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
8145
      clang::CharUnits Align =
8146
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
8147
      for (unsigned I = 0; I < NF; ++I) {
8148
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
8149
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
8150
      }
8151
      // Store new_vl.
8152
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
8153
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
8154
    }
8155
    break;
8156
case RISCVVector::BI__builtin_rvv_vlseg5e8ff_v_tum:
8157
case RISCVVector::BI__builtin_rvv_vlseg5e16ff_v_tum:
8158
case RISCVVector::BI__builtin_rvv_vlseg5e32ff_v_tum:
8159
case RISCVVector::BI__builtin_rvv_vlseg5e64ff_v_tum:
8160
  ID = Intrinsic::riscv_vlseg5ff_mask;
8161
  NF = 5;
8162
  PolicyAttrs = 2;
8163
IsMasked = true;
8164
 
8165
    {
8166
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
8167
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
8168
      SmallVector<llvm::Value*, 12> Operands;
8169
 
8170
      // Please refer to comment under 'defvar NFList' in this file
8171
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
8172
          (!IsMasked && PolicyAttrs & RVV_VTA))
8173
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
8174
      else {
8175
        if (IsMasked)
8176
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
8177
        else // Unmasked
8178
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
8179
      }
8180
      unsigned PtrOperandIdx = IsMasked ?
8181
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
8182
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
8183
      Value *PtrOperand = Ops[PtrOperandIdx];
8184
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
8185
      Value *VLOperand = Ops[PtrOperandIdx + 2];
8186
      Operands.push_back(PtrOperand);
8187
      if (IsMasked)
8188
        Operands.push_back(Ops[NF]);
8189
      Operands.push_back(VLOperand);
8190
      if (IsMasked)
8191
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
8192
 
8193
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
8194
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
8195
      clang::CharUnits Align =
8196
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
8197
      for (unsigned I = 0; I < NF; ++I) {
8198
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
8199
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
8200
      }
8201
      // Store new_vl.
8202
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
8203
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
8204
    }
8205
    break;
8206
case RISCVVector::BI__builtin_rvv_vlseg5e8ff_v_tama:
8207
case RISCVVector::BI__builtin_rvv_vlseg5e16ff_v_tama:
8208
case RISCVVector::BI__builtin_rvv_vlseg5e32ff_v_tama:
8209
case RISCVVector::BI__builtin_rvv_vlseg5e64ff_v_tama:
8210
  ID = Intrinsic::riscv_vlseg5ff_mask;
8211
  NF = 5;
8212
  PolicyAttrs = 3;
8213
IsMasked = true;
8214
 
8215
    {
8216
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
8217
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
8218
      SmallVector<llvm::Value*, 12> Operands;
8219
 
8220
      // Please refer to comment under 'defvar NFList' in this file
8221
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
8222
          (!IsMasked && PolicyAttrs & RVV_VTA))
8223
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
8224
      else {
8225
        if (IsMasked)
8226
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
8227
        else // Unmasked
8228
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
8229
      }
8230
      unsigned PtrOperandIdx = IsMasked ?
8231
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
8232
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
8233
      Value *PtrOperand = Ops[PtrOperandIdx];
8234
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
8235
      Value *VLOperand = Ops[PtrOperandIdx + 2];
8236
      Operands.push_back(PtrOperand);
8237
      if (IsMasked)
8238
        Operands.push_back(Ops[NF]);
8239
      Operands.push_back(VLOperand);
8240
      if (IsMasked)
8241
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
8242
 
8243
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
8244
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
8245
      clang::CharUnits Align =
8246
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
8247
      for (unsigned I = 0; I < NF; ++I) {
8248
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
8249
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
8250
      }
8251
      // Store new_vl.
8252
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
8253
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
8254
    }
8255
    break;
8256
case RISCVVector::BI__builtin_rvv_vlseg5e8ff_v_tumu:
8257
case RISCVVector::BI__builtin_rvv_vlseg5e16ff_v_tumu:
8258
case RISCVVector::BI__builtin_rvv_vlseg5e32ff_v_tumu:
8259
case RISCVVector::BI__builtin_rvv_vlseg5e64ff_v_tumu:
8260
  ID = Intrinsic::riscv_vlseg5ff_mask;
8261
  NF = 5;
8262
  PolicyAttrs = 0;
8263
IsMasked = true;
8264
 
8265
    {
8266
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
8267
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
8268
      SmallVector<llvm::Value*, 12> Operands;
8269
 
8270
      // Please refer to comment under 'defvar NFList' in this file
8271
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
8272
          (!IsMasked && PolicyAttrs & RVV_VTA))
8273
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
8274
      else {
8275
        if (IsMasked)
8276
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
8277
        else // Unmasked
8278
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
8279
      }
8280
      unsigned PtrOperandIdx = IsMasked ?
8281
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
8282
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
8283
      Value *PtrOperand = Ops[PtrOperandIdx];
8284
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
8285
      Value *VLOperand = Ops[PtrOperandIdx + 2];
8286
      Operands.push_back(PtrOperand);
8287
      if (IsMasked)
8288
        Operands.push_back(Ops[NF]);
8289
      Operands.push_back(VLOperand);
8290
      if (IsMasked)
8291
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
8292
 
8293
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
8294
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
8295
      clang::CharUnits Align =
8296
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
8297
      for (unsigned I = 0; I < NF; ++I) {
8298
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
8299
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
8300
      }
8301
      // Store new_vl.
8302
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
8303
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
8304
    }
8305
    break;
8306
case RISCVVector::BI__builtin_rvv_vlseg5e8ff_v_mu:
8307
case RISCVVector::BI__builtin_rvv_vlseg5e16ff_v_mu:
8308
case RISCVVector::BI__builtin_rvv_vlseg5e32ff_v_mu:
8309
case RISCVVector::BI__builtin_rvv_vlseg5e64ff_v_mu:
8310
  ID = Intrinsic::riscv_vlseg5ff_mask;
8311
  NF = 5;
8312
  PolicyAttrs = 1;
8313
IsMasked = true;
8314
 
8315
    {
8316
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
8317
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
8318
      SmallVector<llvm::Value*, 12> Operands;
8319
 
8320
      // Please refer to comment under 'defvar NFList' in this file
8321
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
8322
          (!IsMasked && PolicyAttrs & RVV_VTA))
8323
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
8324
      else {
8325
        if (IsMasked)
8326
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
8327
        else // Unmasked
8328
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
8329
      }
8330
      unsigned PtrOperandIdx = IsMasked ?
8331
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
8332
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
8333
      Value *PtrOperand = Ops[PtrOperandIdx];
8334
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
8335
      Value *VLOperand = Ops[PtrOperandIdx + 2];
8336
      Operands.push_back(PtrOperand);
8337
      if (IsMasked)
8338
        Operands.push_back(Ops[NF]);
8339
      Operands.push_back(VLOperand);
8340
      if (IsMasked)
8341
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
8342
 
8343
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
8344
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
8345
      clang::CharUnits Align =
8346
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
8347
      for (unsigned I = 0; I < NF; ++I) {
8348
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
8349
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
8350
      }
8351
      // Store new_vl.
8352
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
8353
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
8354
    }
8355
    break;
8356
case RISCVVector::BI__builtin_rvv_vlseg6e8_v_tu:
8357
case RISCVVector::BI__builtin_rvv_vlseg6e16_v_tu:
8358
case RISCVVector::BI__builtin_rvv_vlseg6e32_v_tu:
8359
case RISCVVector::BI__builtin_rvv_vlseg6e64_v_tu:
8360
  ID = Intrinsic::riscv_vlseg6;
8361
  NF = 6;
8362
  PolicyAttrs = 2;
8363
IsMasked = false;
8364
 
8365
    {
8366
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
8367
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
8368
      SmallVector<llvm::Value*, 12> Operands;
8369
 
8370
      // Please refer to comment under 'defvar NFList' in this file
8371
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
8372
          (!IsMasked && PolicyAttrs & RVV_VTA))
8373
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
8374
      else {
8375
        if (IsMasked)
8376
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
8377
        else // Unmasked
8378
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
8379
      }
8380
      unsigned PtrOperandIdx = IsMasked ?
8381
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
8382
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
8383
      Value *PtrOperand = Ops[PtrOperandIdx];
8384
      Value *VLOperand = Ops[PtrOperandIdx + 1];
8385
      Operands.push_back(PtrOperand);
8386
      if (IsMasked)
8387
        Operands.push_back(Ops[NF]);
8388
      Operands.push_back(VLOperand);
8389
      if (IsMasked)
8390
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
8391
 
8392
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
8393
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
8394
      clang::CharUnits Align =
8395
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
8396
      llvm::Value *V;
8397
      for (unsigned I = 0; I < NF; ++I) {
8398
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
8399
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
8400
      }
8401
      return V;
8402
    }
8403
    break;
8404
case RISCVVector::BI__builtin_rvv_vlseg6e8_v_ta:
8405
case RISCVVector::BI__builtin_rvv_vlseg6e16_v_ta:
8406
case RISCVVector::BI__builtin_rvv_vlseg6e32_v_ta:
8407
case RISCVVector::BI__builtin_rvv_vlseg6e64_v_ta:
8408
  ID = Intrinsic::riscv_vlseg6;
8409
  NF = 6;
8410
  PolicyAttrs = 3;
8411
IsMasked = false;
8412
 
8413
    {
8414
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
8415
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
8416
      SmallVector<llvm::Value*, 12> Operands;
8417
 
8418
      // Please refer to comment under 'defvar NFList' in this file
8419
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
8420
          (!IsMasked && PolicyAttrs & RVV_VTA))
8421
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
8422
      else {
8423
        if (IsMasked)
8424
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
8425
        else // Unmasked
8426
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
8427
      }
8428
      unsigned PtrOperandIdx = IsMasked ?
8429
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
8430
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
8431
      Value *PtrOperand = Ops[PtrOperandIdx];
8432
      Value *VLOperand = Ops[PtrOperandIdx + 1];
8433
      Operands.push_back(PtrOperand);
8434
      if (IsMasked)
8435
        Operands.push_back(Ops[NF]);
8436
      Operands.push_back(VLOperand);
8437
      if (IsMasked)
8438
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
8439
 
8440
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
8441
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
8442
      clang::CharUnits Align =
8443
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
8444
      llvm::Value *V;
8445
      for (unsigned I = 0; I < NF; ++I) {
8446
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
8447
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
8448
      }
8449
      return V;
8450
    }
8451
    break;
8452
case RISCVVector::BI__builtin_rvv_vlseg6e8_v_tum:
8453
case RISCVVector::BI__builtin_rvv_vlseg6e16_v_tum:
8454
case RISCVVector::BI__builtin_rvv_vlseg6e32_v_tum:
8455
case RISCVVector::BI__builtin_rvv_vlseg6e64_v_tum:
8456
  ID = Intrinsic::riscv_vlseg6_mask;
8457
  NF = 6;
8458
  PolicyAttrs = 2;
8459
IsMasked = true;
8460
 
8461
    {
8462
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
8463
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
8464
      SmallVector<llvm::Value*, 12> Operands;
8465
 
8466
      // Please refer to comment under 'defvar NFList' in this file
8467
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
8468
          (!IsMasked && PolicyAttrs & RVV_VTA))
8469
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
8470
      else {
8471
        if (IsMasked)
8472
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
8473
        else // Unmasked
8474
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
8475
      }
8476
      unsigned PtrOperandIdx = IsMasked ?
8477
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
8478
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
8479
      Value *PtrOperand = Ops[PtrOperandIdx];
8480
      Value *VLOperand = Ops[PtrOperandIdx + 1];
8481
      Operands.push_back(PtrOperand);
8482
      if (IsMasked)
8483
        Operands.push_back(Ops[NF]);
8484
      Operands.push_back(VLOperand);
8485
      if (IsMasked)
8486
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
8487
 
8488
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
8489
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
8490
      clang::CharUnits Align =
8491
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
8492
      llvm::Value *V;
8493
      for (unsigned I = 0; I < NF; ++I) {
8494
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
8495
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
8496
      }
8497
      return V;
8498
    }
8499
    break;
8500
case RISCVVector::BI__builtin_rvv_vlseg6e8_v_tama:
8501
case RISCVVector::BI__builtin_rvv_vlseg6e16_v_tama:
8502
case RISCVVector::BI__builtin_rvv_vlseg6e32_v_tama:
8503
case RISCVVector::BI__builtin_rvv_vlseg6e64_v_tama:
8504
  ID = Intrinsic::riscv_vlseg6_mask;
8505
  NF = 6;
8506
  PolicyAttrs = 3;
8507
IsMasked = true;
8508
 
8509
    {
8510
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
8511
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
8512
      SmallVector<llvm::Value*, 12> Operands;
8513
 
8514
      // Please refer to comment under 'defvar NFList' in this file
8515
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
8516
          (!IsMasked && PolicyAttrs & RVV_VTA))
8517
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
8518
      else {
8519
        if (IsMasked)
8520
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
8521
        else // Unmasked
8522
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
8523
      }
8524
      unsigned PtrOperandIdx = IsMasked ?
8525
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
8526
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
8527
      Value *PtrOperand = Ops[PtrOperandIdx];
8528
      Value *VLOperand = Ops[PtrOperandIdx + 1];
8529
      Operands.push_back(PtrOperand);
8530
      if (IsMasked)
8531
        Operands.push_back(Ops[NF]);
8532
      Operands.push_back(VLOperand);
8533
      if (IsMasked)
8534
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
8535
 
8536
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
8537
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
8538
      clang::CharUnits Align =
8539
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
8540
      llvm::Value *V;
8541
      for (unsigned I = 0; I < NF; ++I) {
8542
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
8543
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
8544
      }
8545
      return V;
8546
    }
8547
    break;
8548
case RISCVVector::BI__builtin_rvv_vlseg6e8_v_tumu:
8549
case RISCVVector::BI__builtin_rvv_vlseg6e16_v_tumu:
8550
case RISCVVector::BI__builtin_rvv_vlseg6e32_v_tumu:
8551
case RISCVVector::BI__builtin_rvv_vlseg6e64_v_tumu:
8552
  ID = Intrinsic::riscv_vlseg6_mask;
8553
  NF = 6;
8554
  PolicyAttrs = 0;
8555
IsMasked = true;
8556
 
8557
    {
8558
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
8559
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
8560
      SmallVector<llvm::Value*, 12> Operands;
8561
 
8562
      // Please refer to comment under 'defvar NFList' in this file
8563
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
8564
          (!IsMasked && PolicyAttrs & RVV_VTA))
8565
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
8566
      else {
8567
        if (IsMasked)
8568
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
8569
        else // Unmasked
8570
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
8571
      }
8572
      unsigned PtrOperandIdx = IsMasked ?
8573
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
8574
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
8575
      Value *PtrOperand = Ops[PtrOperandIdx];
8576
      Value *VLOperand = Ops[PtrOperandIdx + 1];
8577
      Operands.push_back(PtrOperand);
8578
      if (IsMasked)
8579
        Operands.push_back(Ops[NF]);
8580
      Operands.push_back(VLOperand);
8581
      if (IsMasked)
8582
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
8583
 
8584
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
8585
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
8586
      clang::CharUnits Align =
8587
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
8588
      llvm::Value *V;
8589
      for (unsigned I = 0; I < NF; ++I) {
8590
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
8591
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
8592
      }
8593
      return V;
8594
    }
8595
    break;
8596
case RISCVVector::BI__builtin_rvv_vlseg6e8_v_mu:
8597
case RISCVVector::BI__builtin_rvv_vlseg6e16_v_mu:
8598
case RISCVVector::BI__builtin_rvv_vlseg6e32_v_mu:
8599
case RISCVVector::BI__builtin_rvv_vlseg6e64_v_mu:
8600
  ID = Intrinsic::riscv_vlseg6_mask;
8601
  NF = 6;
8602
  PolicyAttrs = 1;
8603
IsMasked = true;
8604
 
8605
    {
8606
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
8607
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
8608
      SmallVector<llvm::Value*, 12> Operands;
8609
 
8610
      // Please refer to comment under 'defvar NFList' in this file
8611
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
8612
          (!IsMasked && PolicyAttrs & RVV_VTA))
8613
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
8614
      else {
8615
        if (IsMasked)
8616
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
8617
        else // Unmasked
8618
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
8619
      }
8620
      unsigned PtrOperandIdx = IsMasked ?
8621
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
8622
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
8623
      Value *PtrOperand = Ops[PtrOperandIdx];
8624
      Value *VLOperand = Ops[PtrOperandIdx + 1];
8625
      Operands.push_back(PtrOperand);
8626
      if (IsMasked)
8627
        Operands.push_back(Ops[NF]);
8628
      Operands.push_back(VLOperand);
8629
      if (IsMasked)
8630
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
8631
 
8632
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
8633
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
8634
      clang::CharUnits Align =
8635
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
8636
      llvm::Value *V;
8637
      for (unsigned I = 0; I < NF; ++I) {
8638
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
8639
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
8640
      }
8641
      return V;
8642
    }
8643
    break;
8644
case RISCVVector::BI__builtin_rvv_vlseg6e8ff_v_tu:
8645
case RISCVVector::BI__builtin_rvv_vlseg6e16ff_v_tu:
8646
case RISCVVector::BI__builtin_rvv_vlseg6e32ff_v_tu:
8647
case RISCVVector::BI__builtin_rvv_vlseg6e64ff_v_tu:
8648
  ID = Intrinsic::riscv_vlseg6ff;
8649
  NF = 6;
8650
  PolicyAttrs = 2;
8651
IsMasked = false;
8652
 
8653
    {
8654
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
8655
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
8656
      SmallVector<llvm::Value*, 12> Operands;
8657
 
8658
      // Please refer to comment under 'defvar NFList' in this file
8659
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
8660
          (!IsMasked && PolicyAttrs & RVV_VTA))
8661
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
8662
      else {
8663
        if (IsMasked)
8664
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
8665
        else // Unmasked
8666
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
8667
      }
8668
      unsigned PtrOperandIdx = IsMasked ?
8669
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
8670
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
8671
      Value *PtrOperand = Ops[PtrOperandIdx];
8672
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
8673
      Value *VLOperand = Ops[PtrOperandIdx + 2];
8674
      Operands.push_back(PtrOperand);
8675
      if (IsMasked)
8676
        Operands.push_back(Ops[NF]);
8677
      Operands.push_back(VLOperand);
8678
      if (IsMasked)
8679
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
8680
 
8681
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
8682
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
8683
      clang::CharUnits Align =
8684
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
8685
      for (unsigned I = 0; I < NF; ++I) {
8686
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
8687
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
8688
      }
8689
      // Store new_vl.
8690
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
8691
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
8692
    }
8693
    break;
8694
case RISCVVector::BI__builtin_rvv_vlseg6e8ff_v_ta:
8695
case RISCVVector::BI__builtin_rvv_vlseg6e16ff_v_ta:
8696
case RISCVVector::BI__builtin_rvv_vlseg6e32ff_v_ta:
8697
case RISCVVector::BI__builtin_rvv_vlseg6e64ff_v_ta:
8698
  ID = Intrinsic::riscv_vlseg6ff;
8699
  NF = 6;
8700
  PolicyAttrs = 3;
8701
IsMasked = false;
8702
 
8703
    {
8704
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
8705
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
8706
      SmallVector<llvm::Value*, 12> Operands;
8707
 
8708
      // Please refer to comment under 'defvar NFList' in this file
8709
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
8710
          (!IsMasked && PolicyAttrs & RVV_VTA))
8711
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
8712
      else {
8713
        if (IsMasked)
8714
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
8715
        else // Unmasked
8716
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
8717
      }
8718
      unsigned PtrOperandIdx = IsMasked ?
8719
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
8720
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
8721
      Value *PtrOperand = Ops[PtrOperandIdx];
8722
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
8723
      Value *VLOperand = Ops[PtrOperandIdx + 2];
8724
      Operands.push_back(PtrOperand);
8725
      if (IsMasked)
8726
        Operands.push_back(Ops[NF]);
8727
      Operands.push_back(VLOperand);
8728
      if (IsMasked)
8729
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
8730
 
8731
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
8732
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
8733
      clang::CharUnits Align =
8734
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
8735
      for (unsigned I = 0; I < NF; ++I) {
8736
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
8737
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
8738
      }
8739
      // Store new_vl.
8740
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
8741
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
8742
    }
8743
    break;
8744
case RISCVVector::BI__builtin_rvv_vlseg6e8ff_v_tum:
8745
case RISCVVector::BI__builtin_rvv_vlseg6e16ff_v_tum:
8746
case RISCVVector::BI__builtin_rvv_vlseg6e32ff_v_tum:
8747
case RISCVVector::BI__builtin_rvv_vlseg6e64ff_v_tum:
8748
  ID = Intrinsic::riscv_vlseg6ff_mask;
8749
  NF = 6;
8750
  PolicyAttrs = 2;
8751
IsMasked = true;
8752
 
8753
    {
8754
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
8755
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
8756
      SmallVector<llvm::Value*, 12> Operands;
8757
 
8758
      // Please refer to comment under 'defvar NFList' in this file
8759
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
8760
          (!IsMasked && PolicyAttrs & RVV_VTA))
8761
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
8762
      else {
8763
        if (IsMasked)
8764
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
8765
        else // Unmasked
8766
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
8767
      }
8768
      unsigned PtrOperandIdx = IsMasked ?
8769
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
8770
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
8771
      Value *PtrOperand = Ops[PtrOperandIdx];
8772
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
8773
      Value *VLOperand = Ops[PtrOperandIdx + 2];
8774
      Operands.push_back(PtrOperand);
8775
      if (IsMasked)
8776
        Operands.push_back(Ops[NF]);
8777
      Operands.push_back(VLOperand);
8778
      if (IsMasked)
8779
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
8780
 
8781
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
8782
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
8783
      clang::CharUnits Align =
8784
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
8785
      for (unsigned I = 0; I < NF; ++I) {
8786
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
8787
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
8788
      }
8789
      // Store new_vl.
8790
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
8791
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
8792
    }
8793
    break;
8794
case RISCVVector::BI__builtin_rvv_vlseg6e8ff_v_tama:
8795
case RISCVVector::BI__builtin_rvv_vlseg6e16ff_v_tama:
8796
case RISCVVector::BI__builtin_rvv_vlseg6e32ff_v_tama:
8797
case RISCVVector::BI__builtin_rvv_vlseg6e64ff_v_tama:
8798
  ID = Intrinsic::riscv_vlseg6ff_mask;
8799
  NF = 6;
8800
  PolicyAttrs = 3;
8801
IsMasked = true;
8802
 
8803
    {
8804
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
8805
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
8806
      SmallVector<llvm::Value*, 12> Operands;
8807
 
8808
      // Please refer to comment under 'defvar NFList' in this file
8809
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
8810
          (!IsMasked && PolicyAttrs & RVV_VTA))
8811
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
8812
      else {
8813
        if (IsMasked)
8814
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
8815
        else // Unmasked
8816
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
8817
      }
8818
      unsigned PtrOperandIdx = IsMasked ?
8819
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
8820
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
8821
      Value *PtrOperand = Ops[PtrOperandIdx];
8822
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
8823
      Value *VLOperand = Ops[PtrOperandIdx + 2];
8824
      Operands.push_back(PtrOperand);
8825
      if (IsMasked)
8826
        Operands.push_back(Ops[NF]);
8827
      Operands.push_back(VLOperand);
8828
      if (IsMasked)
8829
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
8830
 
8831
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
8832
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
8833
      clang::CharUnits Align =
8834
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
8835
      for (unsigned I = 0; I < NF; ++I) {
8836
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
8837
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
8838
      }
8839
      // Store new_vl.
8840
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
8841
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
8842
    }
8843
    break;
8844
case RISCVVector::BI__builtin_rvv_vlseg6e8ff_v_tumu:
8845
case RISCVVector::BI__builtin_rvv_vlseg6e16ff_v_tumu:
8846
case RISCVVector::BI__builtin_rvv_vlseg6e32ff_v_tumu:
8847
case RISCVVector::BI__builtin_rvv_vlseg6e64ff_v_tumu:
8848
  ID = Intrinsic::riscv_vlseg6ff_mask;
8849
  NF = 6;
8850
  PolicyAttrs = 0;
8851
IsMasked = true;
8852
 
8853
    {
8854
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
8855
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
8856
      SmallVector<llvm::Value*, 12> Operands;
8857
 
8858
      // Please refer to comment under 'defvar NFList' in this file
8859
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
8860
          (!IsMasked && PolicyAttrs & RVV_VTA))
8861
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
8862
      else {
8863
        if (IsMasked)
8864
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
8865
        else // Unmasked
8866
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
8867
      }
8868
      unsigned PtrOperandIdx = IsMasked ?
8869
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
8870
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
8871
      Value *PtrOperand = Ops[PtrOperandIdx];
8872
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
8873
      Value *VLOperand = Ops[PtrOperandIdx + 2];
8874
      Operands.push_back(PtrOperand);
8875
      if (IsMasked)
8876
        Operands.push_back(Ops[NF]);
8877
      Operands.push_back(VLOperand);
8878
      if (IsMasked)
8879
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
8880
 
8881
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
8882
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
8883
      clang::CharUnits Align =
8884
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
8885
      for (unsigned I = 0; I < NF; ++I) {
8886
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
8887
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
8888
      }
8889
      // Store new_vl.
8890
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
8891
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
8892
    }
8893
    break;
8894
case RISCVVector::BI__builtin_rvv_vlseg6e8ff_v_mu:
8895
case RISCVVector::BI__builtin_rvv_vlseg6e16ff_v_mu:
8896
case RISCVVector::BI__builtin_rvv_vlseg6e32ff_v_mu:
8897
case RISCVVector::BI__builtin_rvv_vlseg6e64ff_v_mu:
8898
  ID = Intrinsic::riscv_vlseg6ff_mask;
8899
  NF = 6;
8900
  PolicyAttrs = 1;
8901
IsMasked = true;
8902
 
8903
    {
8904
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
8905
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
8906
      SmallVector<llvm::Value*, 12> Operands;
8907
 
8908
      // Please refer to comment under 'defvar NFList' in this file
8909
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
8910
          (!IsMasked && PolicyAttrs & RVV_VTA))
8911
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
8912
      else {
8913
        if (IsMasked)
8914
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
8915
        else // Unmasked
8916
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
8917
      }
8918
      unsigned PtrOperandIdx = IsMasked ?
8919
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
8920
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
8921
      Value *PtrOperand = Ops[PtrOperandIdx];
8922
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
8923
      Value *VLOperand = Ops[PtrOperandIdx + 2];
8924
      Operands.push_back(PtrOperand);
8925
      if (IsMasked)
8926
        Operands.push_back(Ops[NF]);
8927
      Operands.push_back(VLOperand);
8928
      if (IsMasked)
8929
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
8930
 
8931
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
8932
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
8933
      clang::CharUnits Align =
8934
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
8935
      for (unsigned I = 0; I < NF; ++I) {
8936
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
8937
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
8938
      }
8939
      // Store new_vl.
8940
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
8941
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
8942
    }
8943
    break;
8944
case RISCVVector::BI__builtin_rvv_vlseg7e8_v_tu:
8945
case RISCVVector::BI__builtin_rvv_vlseg7e16_v_tu:
8946
case RISCVVector::BI__builtin_rvv_vlseg7e32_v_tu:
8947
case RISCVVector::BI__builtin_rvv_vlseg7e64_v_tu:
8948
  ID = Intrinsic::riscv_vlseg7;
8949
  NF = 7;
8950
  PolicyAttrs = 2;
8951
IsMasked = false;
8952
 
8953
    {
8954
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
8955
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
8956
      SmallVector<llvm::Value*, 12> Operands;
8957
 
8958
      // Please refer to comment under 'defvar NFList' in this file
8959
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
8960
          (!IsMasked && PolicyAttrs & RVV_VTA))
8961
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
8962
      else {
8963
        if (IsMasked)
8964
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
8965
        else // Unmasked
8966
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
8967
      }
8968
      unsigned PtrOperandIdx = IsMasked ?
8969
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
8970
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
8971
      Value *PtrOperand = Ops[PtrOperandIdx];
8972
      Value *VLOperand = Ops[PtrOperandIdx + 1];
8973
      Operands.push_back(PtrOperand);
8974
      if (IsMasked)
8975
        Operands.push_back(Ops[NF]);
8976
      Operands.push_back(VLOperand);
8977
      if (IsMasked)
8978
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
8979
 
8980
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
8981
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
8982
      clang::CharUnits Align =
8983
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
8984
      llvm::Value *V;
8985
      for (unsigned I = 0; I < NF; ++I) {
8986
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
8987
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
8988
      }
8989
      return V;
8990
    }
8991
    break;
8992
case RISCVVector::BI__builtin_rvv_vlseg7e8_v_ta:
8993
case RISCVVector::BI__builtin_rvv_vlseg7e16_v_ta:
8994
case RISCVVector::BI__builtin_rvv_vlseg7e32_v_ta:
8995
case RISCVVector::BI__builtin_rvv_vlseg7e64_v_ta:
8996
  ID = Intrinsic::riscv_vlseg7;
8997
  NF = 7;
8998
  PolicyAttrs = 3;
8999
IsMasked = false;
9000
 
9001
    {
9002
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
9003
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
9004
      SmallVector<llvm::Value*, 12> Operands;
9005
 
9006
      // Please refer to comment under 'defvar NFList' in this file
9007
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
9008
          (!IsMasked && PolicyAttrs & RVV_VTA))
9009
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
9010
      else {
9011
        if (IsMasked)
9012
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
9013
        else // Unmasked
9014
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
9015
      }
9016
      unsigned PtrOperandIdx = IsMasked ?
9017
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
9018
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
9019
      Value *PtrOperand = Ops[PtrOperandIdx];
9020
      Value *VLOperand = Ops[PtrOperandIdx + 1];
9021
      Operands.push_back(PtrOperand);
9022
      if (IsMasked)
9023
        Operands.push_back(Ops[NF]);
9024
      Operands.push_back(VLOperand);
9025
      if (IsMasked)
9026
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
9027
 
9028
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
9029
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
9030
      clang::CharUnits Align =
9031
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
9032
      llvm::Value *V;
9033
      for (unsigned I = 0; I < NF; ++I) {
9034
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
9035
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
9036
      }
9037
      return V;
9038
    }
9039
    break;
9040
case RISCVVector::BI__builtin_rvv_vlseg7e8_v_tum:
9041
case RISCVVector::BI__builtin_rvv_vlseg7e16_v_tum:
9042
case RISCVVector::BI__builtin_rvv_vlseg7e32_v_tum:
9043
case RISCVVector::BI__builtin_rvv_vlseg7e64_v_tum:
9044
  ID = Intrinsic::riscv_vlseg7_mask;
9045
  NF = 7;
9046
  PolicyAttrs = 2;
9047
IsMasked = true;
9048
 
9049
    {
9050
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
9051
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
9052
      SmallVector<llvm::Value*, 12> Operands;
9053
 
9054
      // Please refer to comment under 'defvar NFList' in this file
9055
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
9056
          (!IsMasked && PolicyAttrs & RVV_VTA))
9057
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
9058
      else {
9059
        if (IsMasked)
9060
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
9061
        else // Unmasked
9062
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
9063
      }
9064
      unsigned PtrOperandIdx = IsMasked ?
9065
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
9066
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
9067
      Value *PtrOperand = Ops[PtrOperandIdx];
9068
      Value *VLOperand = Ops[PtrOperandIdx + 1];
9069
      Operands.push_back(PtrOperand);
9070
      if (IsMasked)
9071
        Operands.push_back(Ops[NF]);
9072
      Operands.push_back(VLOperand);
9073
      if (IsMasked)
9074
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
9075
 
9076
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
9077
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
9078
      clang::CharUnits Align =
9079
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
9080
      llvm::Value *V;
9081
      for (unsigned I = 0; I < NF; ++I) {
9082
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
9083
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
9084
      }
9085
      return V;
9086
    }
9087
    break;
9088
case RISCVVector::BI__builtin_rvv_vlseg7e8_v_tama:
9089
case RISCVVector::BI__builtin_rvv_vlseg7e16_v_tama:
9090
case RISCVVector::BI__builtin_rvv_vlseg7e32_v_tama:
9091
case RISCVVector::BI__builtin_rvv_vlseg7e64_v_tama:
9092
  ID = Intrinsic::riscv_vlseg7_mask;
9093
  NF = 7;
9094
  PolicyAttrs = 3;
9095
IsMasked = true;
9096
 
9097
    {
9098
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
9099
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
9100
      SmallVector<llvm::Value*, 12> Operands;
9101
 
9102
      // Please refer to comment under 'defvar NFList' in this file
9103
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
9104
          (!IsMasked && PolicyAttrs & RVV_VTA))
9105
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
9106
      else {
9107
        if (IsMasked)
9108
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
9109
        else // Unmasked
9110
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
9111
      }
9112
      unsigned PtrOperandIdx = IsMasked ?
9113
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
9114
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
9115
      Value *PtrOperand = Ops[PtrOperandIdx];
9116
      Value *VLOperand = Ops[PtrOperandIdx + 1];
9117
      Operands.push_back(PtrOperand);
9118
      if (IsMasked)
9119
        Operands.push_back(Ops[NF]);
9120
      Operands.push_back(VLOperand);
9121
      if (IsMasked)
9122
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
9123
 
9124
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
9125
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
9126
      clang::CharUnits Align =
9127
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
9128
      llvm::Value *V;
9129
      for (unsigned I = 0; I < NF; ++I) {
9130
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
9131
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
9132
      }
9133
      return V;
9134
    }
9135
    break;
9136
case RISCVVector::BI__builtin_rvv_vlseg7e8_v_tumu:
9137
case RISCVVector::BI__builtin_rvv_vlseg7e16_v_tumu:
9138
case RISCVVector::BI__builtin_rvv_vlseg7e32_v_tumu:
9139
case RISCVVector::BI__builtin_rvv_vlseg7e64_v_tumu:
9140
  ID = Intrinsic::riscv_vlseg7_mask;
9141
  NF = 7;
9142
  PolicyAttrs = 0;
9143
IsMasked = true;
9144
 
9145
    {
9146
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
9147
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
9148
      SmallVector<llvm::Value*, 12> Operands;
9149
 
9150
      // Please refer to comment under 'defvar NFList' in this file
9151
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
9152
          (!IsMasked && PolicyAttrs & RVV_VTA))
9153
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
9154
      else {
9155
        if (IsMasked)
9156
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
9157
        else // Unmasked
9158
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
9159
      }
9160
      unsigned PtrOperandIdx = IsMasked ?
9161
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
9162
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
9163
      Value *PtrOperand = Ops[PtrOperandIdx];
9164
      Value *VLOperand = Ops[PtrOperandIdx + 1];
9165
      Operands.push_back(PtrOperand);
9166
      if (IsMasked)
9167
        Operands.push_back(Ops[NF]);
9168
      Operands.push_back(VLOperand);
9169
      if (IsMasked)
9170
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
9171
 
9172
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
9173
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
9174
      clang::CharUnits Align =
9175
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
9176
      llvm::Value *V;
9177
      for (unsigned I = 0; I < NF; ++I) {
9178
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
9179
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
9180
      }
9181
      return V;
9182
    }
9183
    break;
9184
case RISCVVector::BI__builtin_rvv_vlseg7e8_v_mu:
9185
case RISCVVector::BI__builtin_rvv_vlseg7e16_v_mu:
9186
case RISCVVector::BI__builtin_rvv_vlseg7e32_v_mu:
9187
case RISCVVector::BI__builtin_rvv_vlseg7e64_v_mu:
9188
  ID = Intrinsic::riscv_vlseg7_mask;
9189
  NF = 7;
9190
  PolicyAttrs = 1;
9191
IsMasked = true;
9192
 
9193
    {
9194
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
9195
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
9196
      SmallVector<llvm::Value*, 12> Operands;
9197
 
9198
      // Please refer to comment under 'defvar NFList' in this file
9199
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
9200
          (!IsMasked && PolicyAttrs & RVV_VTA))
9201
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
9202
      else {
9203
        if (IsMasked)
9204
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
9205
        else // Unmasked
9206
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
9207
      }
9208
      unsigned PtrOperandIdx = IsMasked ?
9209
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
9210
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
9211
      Value *PtrOperand = Ops[PtrOperandIdx];
9212
      Value *VLOperand = Ops[PtrOperandIdx + 1];
9213
      Operands.push_back(PtrOperand);
9214
      if (IsMasked)
9215
        Operands.push_back(Ops[NF]);
9216
      Operands.push_back(VLOperand);
9217
      if (IsMasked)
9218
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
9219
 
9220
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
9221
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
9222
      clang::CharUnits Align =
9223
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
9224
      llvm::Value *V;
9225
      for (unsigned I = 0; I < NF; ++I) {
9226
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
9227
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
9228
      }
9229
      return V;
9230
    }
9231
    break;
9232
case RISCVVector::BI__builtin_rvv_vlseg7e8ff_v_tu:
9233
case RISCVVector::BI__builtin_rvv_vlseg7e16ff_v_tu:
9234
case RISCVVector::BI__builtin_rvv_vlseg7e32ff_v_tu:
9235
case RISCVVector::BI__builtin_rvv_vlseg7e64ff_v_tu:
9236
  ID = Intrinsic::riscv_vlseg7ff;
9237
  NF = 7;
9238
  PolicyAttrs = 2;
9239
IsMasked = false;
9240
 
9241
    {
9242
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
9243
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
9244
      SmallVector<llvm::Value*, 12> Operands;
9245
 
9246
      // Please refer to comment under 'defvar NFList' in this file
9247
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
9248
          (!IsMasked && PolicyAttrs & RVV_VTA))
9249
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
9250
      else {
9251
        if (IsMasked)
9252
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
9253
        else // Unmasked
9254
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
9255
      }
9256
      unsigned PtrOperandIdx = IsMasked ?
9257
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
9258
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
9259
      Value *PtrOperand = Ops[PtrOperandIdx];
9260
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
9261
      Value *VLOperand = Ops[PtrOperandIdx + 2];
9262
      Operands.push_back(PtrOperand);
9263
      if (IsMasked)
9264
        Operands.push_back(Ops[NF]);
9265
      Operands.push_back(VLOperand);
9266
      if (IsMasked)
9267
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
9268
 
9269
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
9270
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
9271
      clang::CharUnits Align =
9272
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
9273
      for (unsigned I = 0; I < NF; ++I) {
9274
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
9275
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
9276
      }
9277
      // Store new_vl.
9278
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
9279
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
9280
    }
9281
    break;
9282
case RISCVVector::BI__builtin_rvv_vlseg7e8ff_v_ta:
9283
case RISCVVector::BI__builtin_rvv_vlseg7e16ff_v_ta:
9284
case RISCVVector::BI__builtin_rvv_vlseg7e32ff_v_ta:
9285
case RISCVVector::BI__builtin_rvv_vlseg7e64ff_v_ta:
9286
  ID = Intrinsic::riscv_vlseg7ff;
9287
  NF = 7;
9288
  PolicyAttrs = 3;
9289
IsMasked = false;
9290
 
9291
    {
9292
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
9293
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
9294
      SmallVector<llvm::Value*, 12> Operands;
9295
 
9296
      // Please refer to comment under 'defvar NFList' in this file
9297
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
9298
          (!IsMasked && PolicyAttrs & RVV_VTA))
9299
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
9300
      else {
9301
        if (IsMasked)
9302
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
9303
        else // Unmasked
9304
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
9305
      }
9306
      unsigned PtrOperandIdx = IsMasked ?
9307
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
9308
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
9309
      Value *PtrOperand = Ops[PtrOperandIdx];
9310
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
9311
      Value *VLOperand = Ops[PtrOperandIdx + 2];
9312
      Operands.push_back(PtrOperand);
9313
      if (IsMasked)
9314
        Operands.push_back(Ops[NF]);
9315
      Operands.push_back(VLOperand);
9316
      if (IsMasked)
9317
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
9318
 
9319
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
9320
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
9321
      clang::CharUnits Align =
9322
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
9323
      for (unsigned I = 0; I < NF; ++I) {
9324
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
9325
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
9326
      }
9327
      // Store new_vl.
9328
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
9329
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
9330
    }
9331
    break;
9332
case RISCVVector::BI__builtin_rvv_vlseg7e8ff_v_tum:
9333
case RISCVVector::BI__builtin_rvv_vlseg7e16ff_v_tum:
9334
case RISCVVector::BI__builtin_rvv_vlseg7e32ff_v_tum:
9335
case RISCVVector::BI__builtin_rvv_vlseg7e64ff_v_tum:
9336
  ID = Intrinsic::riscv_vlseg7ff_mask;
9337
  NF = 7;
9338
  PolicyAttrs = 2;
9339
IsMasked = true;
9340
 
9341
    {
9342
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
9343
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
9344
      SmallVector<llvm::Value*, 12> Operands;
9345
 
9346
      // Please refer to comment under 'defvar NFList' in this file
9347
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
9348
          (!IsMasked && PolicyAttrs & RVV_VTA))
9349
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
9350
      else {
9351
        if (IsMasked)
9352
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
9353
        else // Unmasked
9354
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
9355
      }
9356
      unsigned PtrOperandIdx = IsMasked ?
9357
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
9358
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
9359
      Value *PtrOperand = Ops[PtrOperandIdx];
9360
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
9361
      Value *VLOperand = Ops[PtrOperandIdx + 2];
9362
      Operands.push_back(PtrOperand);
9363
      if (IsMasked)
9364
        Operands.push_back(Ops[NF]);
9365
      Operands.push_back(VLOperand);
9366
      if (IsMasked)
9367
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
9368
 
9369
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
9370
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
9371
      clang::CharUnits Align =
9372
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
9373
      for (unsigned I = 0; I < NF; ++I) {
9374
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
9375
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
9376
      }
9377
      // Store new_vl.
9378
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
9379
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
9380
    }
9381
    break;
9382
case RISCVVector::BI__builtin_rvv_vlseg7e8ff_v_tama:
9383
case RISCVVector::BI__builtin_rvv_vlseg7e16ff_v_tama:
9384
case RISCVVector::BI__builtin_rvv_vlseg7e32ff_v_tama:
9385
case RISCVVector::BI__builtin_rvv_vlseg7e64ff_v_tama:
9386
  ID = Intrinsic::riscv_vlseg7ff_mask;
9387
  NF = 7;
9388
  PolicyAttrs = 3;
9389
IsMasked = true;
9390
 
9391
    {
9392
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
9393
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
9394
      SmallVector<llvm::Value*, 12> Operands;
9395
 
9396
      // Please refer to comment under 'defvar NFList' in this file
9397
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
9398
          (!IsMasked && PolicyAttrs & RVV_VTA))
9399
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
9400
      else {
9401
        if (IsMasked)
9402
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
9403
        else // Unmasked
9404
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
9405
      }
9406
      unsigned PtrOperandIdx = IsMasked ?
9407
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
9408
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
9409
      Value *PtrOperand = Ops[PtrOperandIdx];
9410
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
9411
      Value *VLOperand = Ops[PtrOperandIdx + 2];
9412
      Operands.push_back(PtrOperand);
9413
      if (IsMasked)
9414
        Operands.push_back(Ops[NF]);
9415
      Operands.push_back(VLOperand);
9416
      if (IsMasked)
9417
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
9418
 
9419
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
9420
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
9421
      clang::CharUnits Align =
9422
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
9423
      for (unsigned I = 0; I < NF; ++I) {
9424
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
9425
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
9426
      }
9427
      // Store new_vl.
9428
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
9429
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
9430
    }
9431
    break;
9432
case RISCVVector::BI__builtin_rvv_vlseg7e8ff_v_tumu:
9433
case RISCVVector::BI__builtin_rvv_vlseg7e16ff_v_tumu:
9434
case RISCVVector::BI__builtin_rvv_vlseg7e32ff_v_tumu:
9435
case RISCVVector::BI__builtin_rvv_vlseg7e64ff_v_tumu:
9436
  ID = Intrinsic::riscv_vlseg7ff_mask;
9437
  NF = 7;
9438
  PolicyAttrs = 0;
9439
IsMasked = true;
9440
 
9441
    {
9442
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
9443
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
9444
      SmallVector<llvm::Value*, 12> Operands;
9445
 
9446
      // Please refer to comment under 'defvar NFList' in this file
9447
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
9448
          (!IsMasked && PolicyAttrs & RVV_VTA))
9449
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
9450
      else {
9451
        if (IsMasked)
9452
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
9453
        else // Unmasked
9454
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
9455
      }
9456
      unsigned PtrOperandIdx = IsMasked ?
9457
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
9458
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
9459
      Value *PtrOperand = Ops[PtrOperandIdx];
9460
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
9461
      Value *VLOperand = Ops[PtrOperandIdx + 2];
9462
      Operands.push_back(PtrOperand);
9463
      if (IsMasked)
9464
        Operands.push_back(Ops[NF]);
9465
      Operands.push_back(VLOperand);
9466
      if (IsMasked)
9467
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
9468
 
9469
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
9470
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
9471
      clang::CharUnits Align =
9472
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
9473
      for (unsigned I = 0; I < NF; ++I) {
9474
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
9475
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
9476
      }
9477
      // Store new_vl.
9478
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
9479
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
9480
    }
9481
    break;
9482
case RISCVVector::BI__builtin_rvv_vlseg7e8ff_v_mu:
9483
case RISCVVector::BI__builtin_rvv_vlseg7e16ff_v_mu:
9484
case RISCVVector::BI__builtin_rvv_vlseg7e32ff_v_mu:
9485
case RISCVVector::BI__builtin_rvv_vlseg7e64ff_v_mu:
9486
  ID = Intrinsic::riscv_vlseg7ff_mask;
9487
  NF = 7;
9488
  PolicyAttrs = 1;
9489
IsMasked = true;
9490
 
9491
    {
9492
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
9493
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
9494
      SmallVector<llvm::Value*, 12> Operands;
9495
 
9496
      // Please refer to comment under 'defvar NFList' in this file
9497
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
9498
          (!IsMasked && PolicyAttrs & RVV_VTA))
9499
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
9500
      else {
9501
        if (IsMasked)
9502
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
9503
        else // Unmasked
9504
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
9505
      }
9506
      unsigned PtrOperandIdx = IsMasked ?
9507
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
9508
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
9509
      Value *PtrOperand = Ops[PtrOperandIdx];
9510
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
9511
      Value *VLOperand = Ops[PtrOperandIdx + 2];
9512
      Operands.push_back(PtrOperand);
9513
      if (IsMasked)
9514
        Operands.push_back(Ops[NF]);
9515
      Operands.push_back(VLOperand);
9516
      if (IsMasked)
9517
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
9518
 
9519
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
9520
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
9521
      clang::CharUnits Align =
9522
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
9523
      for (unsigned I = 0; I < NF; ++I) {
9524
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
9525
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
9526
      }
9527
      // Store new_vl.
9528
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
9529
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
9530
    }
9531
    break;
9532
case RISCVVector::BI__builtin_rvv_vlseg8e8_v_tu:
9533
case RISCVVector::BI__builtin_rvv_vlseg8e16_v_tu:
9534
case RISCVVector::BI__builtin_rvv_vlseg8e32_v_tu:
9535
case RISCVVector::BI__builtin_rvv_vlseg8e64_v_tu:
9536
  ID = Intrinsic::riscv_vlseg8;
9537
  NF = 8;
9538
  PolicyAttrs = 2;
9539
IsMasked = false;
9540
 
9541
    {
9542
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
9543
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
9544
      SmallVector<llvm::Value*, 12> Operands;
9545
 
9546
      // Please refer to comment under 'defvar NFList' in this file
9547
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
9548
          (!IsMasked && PolicyAttrs & RVV_VTA))
9549
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
9550
      else {
9551
        if (IsMasked)
9552
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
9553
        else // Unmasked
9554
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
9555
      }
9556
      unsigned PtrOperandIdx = IsMasked ?
9557
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
9558
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
9559
      Value *PtrOperand = Ops[PtrOperandIdx];
9560
      Value *VLOperand = Ops[PtrOperandIdx + 1];
9561
      Operands.push_back(PtrOperand);
9562
      if (IsMasked)
9563
        Operands.push_back(Ops[NF]);
9564
      Operands.push_back(VLOperand);
9565
      if (IsMasked)
9566
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
9567
 
9568
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
9569
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
9570
      clang::CharUnits Align =
9571
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
9572
      llvm::Value *V;
9573
      for (unsigned I = 0; I < NF; ++I) {
9574
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
9575
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
9576
      }
9577
      return V;
9578
    }
9579
    break;
9580
case RISCVVector::BI__builtin_rvv_vlseg8e8_v_ta:
9581
case RISCVVector::BI__builtin_rvv_vlseg8e16_v_ta:
9582
case RISCVVector::BI__builtin_rvv_vlseg8e32_v_ta:
9583
case RISCVVector::BI__builtin_rvv_vlseg8e64_v_ta:
9584
  ID = Intrinsic::riscv_vlseg8;
9585
  NF = 8;
9586
  PolicyAttrs = 3;
9587
IsMasked = false;
9588
 
9589
    {
9590
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
9591
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
9592
      SmallVector<llvm::Value*, 12> Operands;
9593
 
9594
      // Please refer to comment under 'defvar NFList' in this file
9595
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
9596
          (!IsMasked && PolicyAttrs & RVV_VTA))
9597
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
9598
      else {
9599
        if (IsMasked)
9600
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
9601
        else // Unmasked
9602
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
9603
      }
9604
      unsigned PtrOperandIdx = IsMasked ?
9605
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
9606
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
9607
      Value *PtrOperand = Ops[PtrOperandIdx];
9608
      Value *VLOperand = Ops[PtrOperandIdx + 1];
9609
      Operands.push_back(PtrOperand);
9610
      if (IsMasked)
9611
        Operands.push_back(Ops[NF]);
9612
      Operands.push_back(VLOperand);
9613
      if (IsMasked)
9614
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
9615
 
9616
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
9617
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
9618
      clang::CharUnits Align =
9619
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
9620
      llvm::Value *V;
9621
      for (unsigned I = 0; I < NF; ++I) {
9622
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
9623
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
9624
      }
9625
      return V;
9626
    }
9627
    break;
9628
case RISCVVector::BI__builtin_rvv_vlseg8e8_v_tum:
9629
case RISCVVector::BI__builtin_rvv_vlseg8e16_v_tum:
9630
case RISCVVector::BI__builtin_rvv_vlseg8e32_v_tum:
9631
case RISCVVector::BI__builtin_rvv_vlseg8e64_v_tum:
9632
  ID = Intrinsic::riscv_vlseg8_mask;
9633
  NF = 8;
9634
  PolicyAttrs = 2;
9635
IsMasked = true;
9636
 
9637
    {
9638
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
9639
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
9640
      SmallVector<llvm::Value*, 12> Operands;
9641
 
9642
      // Please refer to comment under 'defvar NFList' in this file
9643
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
9644
          (!IsMasked && PolicyAttrs & RVV_VTA))
9645
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
9646
      else {
9647
        if (IsMasked)
9648
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
9649
        else // Unmasked
9650
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
9651
      }
9652
      unsigned PtrOperandIdx = IsMasked ?
9653
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
9654
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
9655
      Value *PtrOperand = Ops[PtrOperandIdx];
9656
      Value *VLOperand = Ops[PtrOperandIdx + 1];
9657
      Operands.push_back(PtrOperand);
9658
      if (IsMasked)
9659
        Operands.push_back(Ops[NF]);
9660
      Operands.push_back(VLOperand);
9661
      if (IsMasked)
9662
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
9663
 
9664
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
9665
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
9666
      clang::CharUnits Align =
9667
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
9668
      llvm::Value *V;
9669
      for (unsigned I = 0; I < NF; ++I) {
9670
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
9671
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
9672
      }
9673
      return V;
9674
    }
9675
    break;
9676
case RISCVVector::BI__builtin_rvv_vlseg8e8_v_tama:
9677
case RISCVVector::BI__builtin_rvv_vlseg8e16_v_tama:
9678
case RISCVVector::BI__builtin_rvv_vlseg8e32_v_tama:
9679
case RISCVVector::BI__builtin_rvv_vlseg8e64_v_tama:
9680
  ID = Intrinsic::riscv_vlseg8_mask;
9681
  NF = 8;
9682
  PolicyAttrs = 3;
9683
IsMasked = true;
9684
 
9685
    {
9686
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
9687
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
9688
      SmallVector<llvm::Value*, 12> Operands;
9689
 
9690
      // Please refer to comment under 'defvar NFList' in this file
9691
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
9692
          (!IsMasked && PolicyAttrs & RVV_VTA))
9693
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
9694
      else {
9695
        if (IsMasked)
9696
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
9697
        else // Unmasked
9698
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
9699
      }
9700
      unsigned PtrOperandIdx = IsMasked ?
9701
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
9702
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
9703
      Value *PtrOperand = Ops[PtrOperandIdx];
9704
      Value *VLOperand = Ops[PtrOperandIdx + 1];
9705
      Operands.push_back(PtrOperand);
9706
      if (IsMasked)
9707
        Operands.push_back(Ops[NF]);
9708
      Operands.push_back(VLOperand);
9709
      if (IsMasked)
9710
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
9711
 
9712
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
9713
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
9714
      clang::CharUnits Align =
9715
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
9716
      llvm::Value *V;
9717
      for (unsigned I = 0; I < NF; ++I) {
9718
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
9719
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
9720
      }
9721
      return V;
9722
    }
9723
    break;
9724
case RISCVVector::BI__builtin_rvv_vlseg8e8_v_tumu:
9725
case RISCVVector::BI__builtin_rvv_vlseg8e16_v_tumu:
9726
case RISCVVector::BI__builtin_rvv_vlseg8e32_v_tumu:
9727
case RISCVVector::BI__builtin_rvv_vlseg8e64_v_tumu:
9728
  ID = Intrinsic::riscv_vlseg8_mask;
9729
  NF = 8;
9730
  PolicyAttrs = 0;
9731
IsMasked = true;
9732
 
9733
    {
9734
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
9735
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
9736
      SmallVector<llvm::Value*, 12> Operands;
9737
 
9738
      // Please refer to comment under 'defvar NFList' in this file
9739
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
9740
          (!IsMasked && PolicyAttrs & RVV_VTA))
9741
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
9742
      else {
9743
        if (IsMasked)
9744
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
9745
        else // Unmasked
9746
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
9747
      }
9748
      unsigned PtrOperandIdx = IsMasked ?
9749
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
9750
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
9751
      Value *PtrOperand = Ops[PtrOperandIdx];
9752
      Value *VLOperand = Ops[PtrOperandIdx + 1];
9753
      Operands.push_back(PtrOperand);
9754
      if (IsMasked)
9755
        Operands.push_back(Ops[NF]);
9756
      Operands.push_back(VLOperand);
9757
      if (IsMasked)
9758
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
9759
 
9760
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
9761
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
9762
      clang::CharUnits Align =
9763
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
9764
      llvm::Value *V;
9765
      for (unsigned I = 0; I < NF; ++I) {
9766
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
9767
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
9768
      }
9769
      return V;
9770
    }
9771
    break;
9772
case RISCVVector::BI__builtin_rvv_vlseg8e8_v_mu:
9773
case RISCVVector::BI__builtin_rvv_vlseg8e16_v_mu:
9774
case RISCVVector::BI__builtin_rvv_vlseg8e32_v_mu:
9775
case RISCVVector::BI__builtin_rvv_vlseg8e64_v_mu:
9776
  ID = Intrinsic::riscv_vlseg8_mask;
9777
  NF = 8;
9778
  PolicyAttrs = 1;
9779
IsMasked = true;
9780
 
9781
    {
9782
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
9783
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
9784
      SmallVector<llvm::Value*, 12> Operands;
9785
 
9786
      // Please refer to comment under 'defvar NFList' in this file
9787
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
9788
          (!IsMasked && PolicyAttrs & RVV_VTA))
9789
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
9790
      else {
9791
        if (IsMasked)
9792
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
9793
        else // Unmasked
9794
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
9795
      }
9796
      unsigned PtrOperandIdx = IsMasked ?
9797
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
9798
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
9799
      Value *PtrOperand = Ops[PtrOperandIdx];
9800
      Value *VLOperand = Ops[PtrOperandIdx + 1];
9801
      Operands.push_back(PtrOperand);
9802
      if (IsMasked)
9803
        Operands.push_back(Ops[NF]);
9804
      Operands.push_back(VLOperand);
9805
      if (IsMasked)
9806
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
9807
 
9808
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
9809
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
9810
      clang::CharUnits Align =
9811
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
9812
      llvm::Value *V;
9813
      for (unsigned I = 0; I < NF; ++I) {
9814
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
9815
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
9816
      }
9817
      return V;
9818
    }
9819
    break;
9820
case RISCVVector::BI__builtin_rvv_vlseg8e8ff_v_tu:
9821
case RISCVVector::BI__builtin_rvv_vlseg8e16ff_v_tu:
9822
case RISCVVector::BI__builtin_rvv_vlseg8e32ff_v_tu:
9823
case RISCVVector::BI__builtin_rvv_vlseg8e64ff_v_tu:
9824
  ID = Intrinsic::riscv_vlseg8ff;
9825
  NF = 8;
9826
  PolicyAttrs = 2;
9827
IsMasked = false;
9828
 
9829
    {
9830
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
9831
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
9832
      SmallVector<llvm::Value*, 12> Operands;
9833
 
9834
      // Please refer to comment under 'defvar NFList' in this file
9835
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
9836
          (!IsMasked && PolicyAttrs & RVV_VTA))
9837
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
9838
      else {
9839
        if (IsMasked)
9840
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
9841
        else // Unmasked
9842
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
9843
      }
9844
      unsigned PtrOperandIdx = IsMasked ?
9845
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
9846
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
9847
      Value *PtrOperand = Ops[PtrOperandIdx];
9848
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
9849
      Value *VLOperand = Ops[PtrOperandIdx + 2];
9850
      Operands.push_back(PtrOperand);
9851
      if (IsMasked)
9852
        Operands.push_back(Ops[NF]);
9853
      Operands.push_back(VLOperand);
9854
      if (IsMasked)
9855
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
9856
 
9857
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
9858
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
9859
      clang::CharUnits Align =
9860
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
9861
      for (unsigned I = 0; I < NF; ++I) {
9862
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
9863
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
9864
      }
9865
      // Store new_vl.
9866
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
9867
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
9868
    }
9869
    break;
9870
case RISCVVector::BI__builtin_rvv_vlseg8e8ff_v_ta:
9871
case RISCVVector::BI__builtin_rvv_vlseg8e16ff_v_ta:
9872
case RISCVVector::BI__builtin_rvv_vlseg8e32ff_v_ta:
9873
case RISCVVector::BI__builtin_rvv_vlseg8e64ff_v_ta:
9874
  ID = Intrinsic::riscv_vlseg8ff;
9875
  NF = 8;
9876
  PolicyAttrs = 3;
9877
IsMasked = false;
9878
 
9879
    {
9880
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
9881
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
9882
      SmallVector<llvm::Value*, 12> Operands;
9883
 
9884
      // Please refer to comment under 'defvar NFList' in this file
9885
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
9886
          (!IsMasked && PolicyAttrs & RVV_VTA))
9887
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
9888
      else {
9889
        if (IsMasked)
9890
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
9891
        else // Unmasked
9892
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
9893
      }
9894
      unsigned PtrOperandIdx = IsMasked ?
9895
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
9896
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
9897
      Value *PtrOperand = Ops[PtrOperandIdx];
9898
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
9899
      Value *VLOperand = Ops[PtrOperandIdx + 2];
9900
      Operands.push_back(PtrOperand);
9901
      if (IsMasked)
9902
        Operands.push_back(Ops[NF]);
9903
      Operands.push_back(VLOperand);
9904
      if (IsMasked)
9905
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
9906
 
9907
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
9908
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
9909
      clang::CharUnits Align =
9910
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
9911
      for (unsigned I = 0; I < NF; ++I) {
9912
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
9913
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
9914
      }
9915
      // Store new_vl.
9916
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
9917
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
9918
    }
9919
    break;
9920
case RISCVVector::BI__builtin_rvv_vlseg8e8ff_v_tum:
9921
case RISCVVector::BI__builtin_rvv_vlseg8e16ff_v_tum:
9922
case RISCVVector::BI__builtin_rvv_vlseg8e32ff_v_tum:
9923
case RISCVVector::BI__builtin_rvv_vlseg8e64ff_v_tum:
9924
  ID = Intrinsic::riscv_vlseg8ff_mask;
9925
  NF = 8;
9926
  PolicyAttrs = 2;
9927
IsMasked = true;
9928
 
9929
    {
9930
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
9931
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
9932
      SmallVector<llvm::Value*, 12> Operands;
9933
 
9934
      // Please refer to comment under 'defvar NFList' in this file
9935
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
9936
          (!IsMasked && PolicyAttrs & RVV_VTA))
9937
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
9938
      else {
9939
        if (IsMasked)
9940
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
9941
        else // Unmasked
9942
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
9943
      }
9944
      unsigned PtrOperandIdx = IsMasked ?
9945
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
9946
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
9947
      Value *PtrOperand = Ops[PtrOperandIdx];
9948
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
9949
      Value *VLOperand = Ops[PtrOperandIdx + 2];
9950
      Operands.push_back(PtrOperand);
9951
      if (IsMasked)
9952
        Operands.push_back(Ops[NF]);
9953
      Operands.push_back(VLOperand);
9954
      if (IsMasked)
9955
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
9956
 
9957
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
9958
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
9959
      clang::CharUnits Align =
9960
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
9961
      for (unsigned I = 0; I < NF; ++I) {
9962
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
9963
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
9964
      }
9965
      // Store new_vl.
9966
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
9967
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
9968
    }
9969
    break;
9970
case RISCVVector::BI__builtin_rvv_vlseg8e8ff_v_tama:
9971
case RISCVVector::BI__builtin_rvv_vlseg8e16ff_v_tama:
9972
case RISCVVector::BI__builtin_rvv_vlseg8e32ff_v_tama:
9973
case RISCVVector::BI__builtin_rvv_vlseg8e64ff_v_tama:
9974
  ID = Intrinsic::riscv_vlseg8ff_mask;
9975
  NF = 8;
9976
  PolicyAttrs = 3;
9977
IsMasked = true;
9978
 
9979
    {
9980
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
9981
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
9982
      SmallVector<llvm::Value*, 12> Operands;
9983
 
9984
      // Please refer to comment under 'defvar NFList' in this file
9985
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
9986
          (!IsMasked && PolicyAttrs & RVV_VTA))
9987
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
9988
      else {
9989
        if (IsMasked)
9990
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
9991
        else // Unmasked
9992
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
9993
      }
9994
      unsigned PtrOperandIdx = IsMasked ?
9995
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
9996
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
9997
      Value *PtrOperand = Ops[PtrOperandIdx];
9998
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
9999
      Value *VLOperand = Ops[PtrOperandIdx + 2];
10000
      Operands.push_back(PtrOperand);
10001
      if (IsMasked)
10002
        Operands.push_back(Ops[NF]);
10003
      Operands.push_back(VLOperand);
10004
      if (IsMasked)
10005
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
10006
 
10007
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
10008
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
10009
      clang::CharUnits Align =
10010
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
10011
      for (unsigned I = 0; I < NF; ++I) {
10012
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
10013
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
10014
      }
10015
      // Store new_vl.
10016
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
10017
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
10018
    }
10019
    break;
10020
case RISCVVector::BI__builtin_rvv_vlseg8e8ff_v_tumu:
10021
case RISCVVector::BI__builtin_rvv_vlseg8e16ff_v_tumu:
10022
case RISCVVector::BI__builtin_rvv_vlseg8e32ff_v_tumu:
10023
case RISCVVector::BI__builtin_rvv_vlseg8e64ff_v_tumu:
10024
  ID = Intrinsic::riscv_vlseg8ff_mask;
10025
  NF = 8;
10026
  PolicyAttrs = 0;
10027
IsMasked = true;
10028
 
10029
    {
10030
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
10031
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
10032
      SmallVector<llvm::Value*, 12> Operands;
10033
 
10034
      // Please refer to comment under 'defvar NFList' in this file
10035
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
10036
          (!IsMasked && PolicyAttrs & RVV_VTA))
10037
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
10038
      else {
10039
        if (IsMasked)
10040
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
10041
        else // Unmasked
10042
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
10043
      }
10044
      unsigned PtrOperandIdx = IsMasked ?
10045
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
10046
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
10047
      Value *PtrOperand = Ops[PtrOperandIdx];
10048
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
10049
      Value *VLOperand = Ops[PtrOperandIdx + 2];
10050
      Operands.push_back(PtrOperand);
10051
      if (IsMasked)
10052
        Operands.push_back(Ops[NF]);
10053
      Operands.push_back(VLOperand);
10054
      if (IsMasked)
10055
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
10056
 
10057
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
10058
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
10059
      clang::CharUnits Align =
10060
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
10061
      for (unsigned I = 0; I < NF; ++I) {
10062
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
10063
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
10064
      }
10065
      // Store new_vl.
10066
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
10067
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
10068
    }
10069
    break;
10070
case RISCVVector::BI__builtin_rvv_vlseg8e8ff_v_mu:
10071
case RISCVVector::BI__builtin_rvv_vlseg8e16ff_v_mu:
10072
case RISCVVector::BI__builtin_rvv_vlseg8e32ff_v_mu:
10073
case RISCVVector::BI__builtin_rvv_vlseg8e64ff_v_mu:
10074
  ID = Intrinsic::riscv_vlseg8ff_mask;
10075
  NF = 8;
10076
  PolicyAttrs = 1;
10077
IsMasked = true;
10078
 
10079
    {
10080
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
10081
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
10082
      SmallVector<llvm::Value*, 12> Operands;
10083
 
10084
      // Please refer to comment under 'defvar NFList' in this file
10085
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
10086
          (!IsMasked && PolicyAttrs & RVV_VTA))
10087
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
10088
      else {
10089
        if (IsMasked)
10090
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
10091
        else // Unmasked
10092
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
10093
      }
10094
      unsigned PtrOperandIdx = IsMasked ?
10095
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
10096
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
10097
      Value *PtrOperand = Ops[PtrOperandIdx];
10098
      Value *NewVLOperand = Ops[PtrOperandIdx + 1];
10099
      Value *VLOperand = Ops[PtrOperandIdx + 2];
10100
      Operands.push_back(PtrOperand);
10101
      if (IsMasked)
10102
        Operands.push_back(Ops[NF]);
10103
      Operands.push_back(VLOperand);
10104
      if (IsMasked)
10105
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
10106
 
10107
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
10108
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
10109
      clang::CharUnits Align =
10110
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
10111
      for (unsigned I = 0; I < NF; ++I) {
10112
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
10113
        Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
10114
      }
10115
      // Store new_vl.
10116
      llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {NF});
10117
      return Builder.CreateStore(Val, Address(NewVLOperand, Val->getType(), Align));
10118
    }
10119
    break;
10120
case RISCVVector::BI__builtin_rvv_vlsseg2e16_v_tu:
10121
case RISCVVector::BI__builtin_rvv_vlsseg2e8_v_tu:
10122
case RISCVVector::BI__builtin_rvv_vlsseg2e32_v_tu:
10123
case RISCVVector::BI__builtin_rvv_vlsseg2e64_v_tu:
10124
  ID = Intrinsic::riscv_vlsseg2;
10125
  NF = 2;
10126
  PolicyAttrs = 2;
10127
IsMasked = false;
10128
 
10129
    {
10130
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
10131
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
10132
      SmallVector<llvm::Value*, 12> Operands;
10133
 
10134
      // Please refer to comment under 'defvar NFList' in this file
10135
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
10136
          (!IsMasked && PolicyAttrs & RVV_VTA))
10137
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
10138
      else {
10139
        if (IsMasked)
10140
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
10141
        else // Unmasked
10142
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
10143
      }
10144
      unsigned PtrOperandIdx = IsMasked ?
10145
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
10146
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
10147
      Value *PtrOperand = Ops[PtrOperandIdx];
10148
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
10149
      Value *VLOperand = Ops[PtrOperandIdx + 2];
10150
      Operands.push_back(PtrOperand);
10151
      Operands.push_back(StrideOperand);
10152
      if (IsMasked)
10153
        Operands.push_back(Ops[NF]);
10154
      Operands.push_back(VLOperand);
10155
      if (IsMasked)
10156
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
10157
 
10158
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
10159
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
10160
      clang::CharUnits Align =
10161
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
10162
      llvm::Value *V;
10163
      for (unsigned I = 0; I < NF; ++I) {
10164
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
10165
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
10166
      }
10167
      return V;
10168
    }
10169
    break;
10170
case RISCVVector::BI__builtin_rvv_vlsseg2e16_v_ta:
10171
case RISCVVector::BI__builtin_rvv_vlsseg2e8_v_ta:
10172
case RISCVVector::BI__builtin_rvv_vlsseg2e32_v_ta:
10173
case RISCVVector::BI__builtin_rvv_vlsseg2e64_v_ta:
10174
  ID = Intrinsic::riscv_vlsseg2;
10175
  NF = 2;
10176
  PolicyAttrs = 3;
10177
IsMasked = false;
10178
 
10179
    {
10180
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
10181
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
10182
      SmallVector<llvm::Value*, 12> Operands;
10183
 
10184
      // Please refer to comment under 'defvar NFList' in this file
10185
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
10186
          (!IsMasked && PolicyAttrs & RVV_VTA))
10187
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
10188
      else {
10189
        if (IsMasked)
10190
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
10191
        else // Unmasked
10192
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
10193
      }
10194
      unsigned PtrOperandIdx = IsMasked ?
10195
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
10196
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
10197
      Value *PtrOperand = Ops[PtrOperandIdx];
10198
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
10199
      Value *VLOperand = Ops[PtrOperandIdx + 2];
10200
      Operands.push_back(PtrOperand);
10201
      Operands.push_back(StrideOperand);
10202
      if (IsMasked)
10203
        Operands.push_back(Ops[NF]);
10204
      Operands.push_back(VLOperand);
10205
      if (IsMasked)
10206
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
10207
 
10208
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
10209
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
10210
      clang::CharUnits Align =
10211
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
10212
      llvm::Value *V;
10213
      for (unsigned I = 0; I < NF; ++I) {
10214
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
10215
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
10216
      }
10217
      return V;
10218
    }
10219
    break;
10220
case RISCVVector::BI__builtin_rvv_vlsseg2e16_v_tum:
10221
case RISCVVector::BI__builtin_rvv_vlsseg2e8_v_tum:
10222
case RISCVVector::BI__builtin_rvv_vlsseg2e32_v_tum:
10223
case RISCVVector::BI__builtin_rvv_vlsseg2e64_v_tum:
10224
  ID = Intrinsic::riscv_vlsseg2_mask;
10225
  NF = 2;
10226
  PolicyAttrs = 2;
10227
IsMasked = true;
10228
 
10229
    {
10230
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
10231
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
10232
      SmallVector<llvm::Value*, 12> Operands;
10233
 
10234
      // Please refer to comment under 'defvar NFList' in this file
10235
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
10236
          (!IsMasked && PolicyAttrs & RVV_VTA))
10237
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
10238
      else {
10239
        if (IsMasked)
10240
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
10241
        else // Unmasked
10242
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
10243
      }
10244
      unsigned PtrOperandIdx = IsMasked ?
10245
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
10246
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
10247
      Value *PtrOperand = Ops[PtrOperandIdx];
10248
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
10249
      Value *VLOperand = Ops[PtrOperandIdx + 2];
10250
      Operands.push_back(PtrOperand);
10251
      Operands.push_back(StrideOperand);
10252
      if (IsMasked)
10253
        Operands.push_back(Ops[NF]);
10254
      Operands.push_back(VLOperand);
10255
      if (IsMasked)
10256
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
10257
 
10258
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
10259
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
10260
      clang::CharUnits Align =
10261
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
10262
      llvm::Value *V;
10263
      for (unsigned I = 0; I < NF; ++I) {
10264
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
10265
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
10266
      }
10267
      return V;
10268
    }
10269
    break;
10270
case RISCVVector::BI__builtin_rvv_vlsseg2e16_v_tama:
10271
case RISCVVector::BI__builtin_rvv_vlsseg2e8_v_tama:
10272
case RISCVVector::BI__builtin_rvv_vlsseg2e32_v_tama:
10273
case RISCVVector::BI__builtin_rvv_vlsseg2e64_v_tama:
10274
  ID = Intrinsic::riscv_vlsseg2_mask;
10275
  NF = 2;
10276
  PolicyAttrs = 3;
10277
IsMasked = true;
10278
 
10279
    {
10280
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
10281
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
10282
      SmallVector<llvm::Value*, 12> Operands;
10283
 
10284
      // Please refer to comment under 'defvar NFList' in this file
10285
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
10286
          (!IsMasked && PolicyAttrs & RVV_VTA))
10287
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
10288
      else {
10289
        if (IsMasked)
10290
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
10291
        else // Unmasked
10292
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
10293
      }
10294
      unsigned PtrOperandIdx = IsMasked ?
10295
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
10296
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
10297
      Value *PtrOperand = Ops[PtrOperandIdx];
10298
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
10299
      Value *VLOperand = Ops[PtrOperandIdx + 2];
10300
      Operands.push_back(PtrOperand);
10301
      Operands.push_back(StrideOperand);
10302
      if (IsMasked)
10303
        Operands.push_back(Ops[NF]);
10304
      Operands.push_back(VLOperand);
10305
      if (IsMasked)
10306
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
10307
 
10308
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
10309
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
10310
      clang::CharUnits Align =
10311
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
10312
      llvm::Value *V;
10313
      for (unsigned I = 0; I < NF; ++I) {
10314
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
10315
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
10316
      }
10317
      return V;
10318
    }
10319
    break;
10320
case RISCVVector::BI__builtin_rvv_vlsseg2e16_v_tumu:
10321
case RISCVVector::BI__builtin_rvv_vlsseg2e8_v_tumu:
10322
case RISCVVector::BI__builtin_rvv_vlsseg2e32_v_tumu:
10323
case RISCVVector::BI__builtin_rvv_vlsseg2e64_v_tumu:
10324
  ID = Intrinsic::riscv_vlsseg2_mask;
10325
  NF = 2;
10326
  PolicyAttrs = 0;
10327
IsMasked = true;
10328
 
10329
    {
10330
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
10331
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
10332
      SmallVector<llvm::Value*, 12> Operands;
10333
 
10334
      // Please refer to comment under 'defvar NFList' in this file
10335
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
10336
          (!IsMasked && PolicyAttrs & RVV_VTA))
10337
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
10338
      else {
10339
        if (IsMasked)
10340
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
10341
        else // Unmasked
10342
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
10343
      }
10344
      unsigned PtrOperandIdx = IsMasked ?
10345
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
10346
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
10347
      Value *PtrOperand = Ops[PtrOperandIdx];
10348
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
10349
      Value *VLOperand = Ops[PtrOperandIdx + 2];
10350
      Operands.push_back(PtrOperand);
10351
      Operands.push_back(StrideOperand);
10352
      if (IsMasked)
10353
        Operands.push_back(Ops[NF]);
10354
      Operands.push_back(VLOperand);
10355
      if (IsMasked)
10356
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
10357
 
10358
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
10359
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
10360
      clang::CharUnits Align =
10361
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
10362
      llvm::Value *V;
10363
      for (unsigned I = 0; I < NF; ++I) {
10364
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
10365
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
10366
      }
10367
      return V;
10368
    }
10369
    break;
10370
case RISCVVector::BI__builtin_rvv_vlsseg2e16_v_mu:
10371
case RISCVVector::BI__builtin_rvv_vlsseg2e8_v_mu:
10372
case RISCVVector::BI__builtin_rvv_vlsseg2e32_v_mu:
10373
case RISCVVector::BI__builtin_rvv_vlsseg2e64_v_mu:
10374
  ID = Intrinsic::riscv_vlsseg2_mask;
10375
  NF = 2;
10376
  PolicyAttrs = 1;
10377
IsMasked = true;
10378
 
10379
    {
10380
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
10381
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
10382
      SmallVector<llvm::Value*, 12> Operands;
10383
 
10384
      // Please refer to comment under 'defvar NFList' in this file
10385
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
10386
          (!IsMasked && PolicyAttrs & RVV_VTA))
10387
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
10388
      else {
10389
        if (IsMasked)
10390
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
10391
        else // Unmasked
10392
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
10393
      }
10394
      unsigned PtrOperandIdx = IsMasked ?
10395
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
10396
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
10397
      Value *PtrOperand = Ops[PtrOperandIdx];
10398
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
10399
      Value *VLOperand = Ops[PtrOperandIdx + 2];
10400
      Operands.push_back(PtrOperand);
10401
      Operands.push_back(StrideOperand);
10402
      if (IsMasked)
10403
        Operands.push_back(Ops[NF]);
10404
      Operands.push_back(VLOperand);
10405
      if (IsMasked)
10406
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
10407
 
10408
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
10409
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
10410
      clang::CharUnits Align =
10411
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
10412
      llvm::Value *V;
10413
      for (unsigned I = 0; I < NF; ++I) {
10414
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
10415
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
10416
      }
10417
      return V;
10418
    }
10419
    break;
10420
case RISCVVector::BI__builtin_rvv_vlsseg3e8_v_tu:
10421
case RISCVVector::BI__builtin_rvv_vlsseg3e16_v_tu:
10422
case RISCVVector::BI__builtin_rvv_vlsseg3e32_v_tu:
10423
case RISCVVector::BI__builtin_rvv_vlsseg3e64_v_tu:
10424
  ID = Intrinsic::riscv_vlsseg3;
10425
  NF = 3;
10426
  PolicyAttrs = 2;
10427
IsMasked = false;
10428
 
10429
    {
10430
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
10431
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
10432
      SmallVector<llvm::Value*, 12> Operands;
10433
 
10434
      // Please refer to comment under 'defvar NFList' in this file
10435
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
10436
          (!IsMasked && PolicyAttrs & RVV_VTA))
10437
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
10438
      else {
10439
        if (IsMasked)
10440
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
10441
        else // Unmasked
10442
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
10443
      }
10444
      unsigned PtrOperandIdx = IsMasked ?
10445
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
10446
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
10447
      Value *PtrOperand = Ops[PtrOperandIdx];
10448
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
10449
      Value *VLOperand = Ops[PtrOperandIdx + 2];
10450
      Operands.push_back(PtrOperand);
10451
      Operands.push_back(StrideOperand);
10452
      if (IsMasked)
10453
        Operands.push_back(Ops[NF]);
10454
      Operands.push_back(VLOperand);
10455
      if (IsMasked)
10456
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
10457
 
10458
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
10459
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
10460
      clang::CharUnits Align =
10461
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
10462
      llvm::Value *V;
10463
      for (unsigned I = 0; I < NF; ++I) {
10464
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
10465
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
10466
      }
10467
      return V;
10468
    }
10469
    break;
10470
case RISCVVector::BI__builtin_rvv_vlsseg3e8_v_ta:
10471
case RISCVVector::BI__builtin_rvv_vlsseg3e16_v_ta:
10472
case RISCVVector::BI__builtin_rvv_vlsseg3e32_v_ta:
10473
case RISCVVector::BI__builtin_rvv_vlsseg3e64_v_ta:
10474
  ID = Intrinsic::riscv_vlsseg3;
10475
  NF = 3;
10476
  PolicyAttrs = 3;
10477
IsMasked = false;
10478
 
10479
    {
10480
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
10481
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
10482
      SmallVector<llvm::Value*, 12> Operands;
10483
 
10484
      // Please refer to comment under 'defvar NFList' in this file
10485
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
10486
          (!IsMasked && PolicyAttrs & RVV_VTA))
10487
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
10488
      else {
10489
        if (IsMasked)
10490
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
10491
        else // Unmasked
10492
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
10493
      }
10494
      unsigned PtrOperandIdx = IsMasked ?
10495
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
10496
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
10497
      Value *PtrOperand = Ops[PtrOperandIdx];
10498
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
10499
      Value *VLOperand = Ops[PtrOperandIdx + 2];
10500
      Operands.push_back(PtrOperand);
10501
      Operands.push_back(StrideOperand);
10502
      if (IsMasked)
10503
        Operands.push_back(Ops[NF]);
10504
      Operands.push_back(VLOperand);
10505
      if (IsMasked)
10506
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
10507
 
10508
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
10509
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
10510
      clang::CharUnits Align =
10511
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
10512
      llvm::Value *V;
10513
      for (unsigned I = 0; I < NF; ++I) {
10514
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
10515
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
10516
      }
10517
      return V;
10518
    }
10519
    break;
10520
case RISCVVector::BI__builtin_rvv_vlsseg3e8_v_tum:
10521
case RISCVVector::BI__builtin_rvv_vlsseg3e16_v_tum:
10522
case RISCVVector::BI__builtin_rvv_vlsseg3e32_v_tum:
10523
case RISCVVector::BI__builtin_rvv_vlsseg3e64_v_tum:
10524
  ID = Intrinsic::riscv_vlsseg3_mask;
10525
  NF = 3;
10526
  PolicyAttrs = 2;
10527
IsMasked = true;
10528
 
10529
    {
10530
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
10531
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
10532
      SmallVector<llvm::Value*, 12> Operands;
10533
 
10534
      // Please refer to comment under 'defvar NFList' in this file
10535
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
10536
          (!IsMasked && PolicyAttrs & RVV_VTA))
10537
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
10538
      else {
10539
        if (IsMasked)
10540
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
10541
        else // Unmasked
10542
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
10543
      }
10544
      unsigned PtrOperandIdx = IsMasked ?
10545
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
10546
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
10547
      Value *PtrOperand = Ops[PtrOperandIdx];
10548
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
10549
      Value *VLOperand = Ops[PtrOperandIdx + 2];
10550
      Operands.push_back(PtrOperand);
10551
      Operands.push_back(StrideOperand);
10552
      if (IsMasked)
10553
        Operands.push_back(Ops[NF]);
10554
      Operands.push_back(VLOperand);
10555
      if (IsMasked)
10556
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
10557
 
10558
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
10559
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
10560
      clang::CharUnits Align =
10561
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
10562
      llvm::Value *V;
10563
      for (unsigned I = 0; I < NF; ++I) {
10564
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
10565
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
10566
      }
10567
      return V;
10568
    }
10569
    break;
10570
case RISCVVector::BI__builtin_rvv_vlsseg3e8_v_tama:
10571
case RISCVVector::BI__builtin_rvv_vlsseg3e16_v_tama:
10572
case RISCVVector::BI__builtin_rvv_vlsseg3e32_v_tama:
10573
case RISCVVector::BI__builtin_rvv_vlsseg3e64_v_tama:
10574
  ID = Intrinsic::riscv_vlsseg3_mask;
10575
  NF = 3;
10576
  PolicyAttrs = 3;
10577
IsMasked = true;
10578
 
10579
    {
10580
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
10581
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
10582
      SmallVector<llvm::Value*, 12> Operands;
10583
 
10584
      // Please refer to comment under 'defvar NFList' in this file
10585
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
10586
          (!IsMasked && PolicyAttrs & RVV_VTA))
10587
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
10588
      else {
10589
        if (IsMasked)
10590
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
10591
        else // Unmasked
10592
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
10593
      }
10594
      unsigned PtrOperandIdx = IsMasked ?
10595
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
10596
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
10597
      Value *PtrOperand = Ops[PtrOperandIdx];
10598
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
10599
      Value *VLOperand = Ops[PtrOperandIdx + 2];
10600
      Operands.push_back(PtrOperand);
10601
      Operands.push_back(StrideOperand);
10602
      if (IsMasked)
10603
        Operands.push_back(Ops[NF]);
10604
      Operands.push_back(VLOperand);
10605
      if (IsMasked)
10606
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
10607
 
10608
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
10609
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
10610
      clang::CharUnits Align =
10611
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
10612
      llvm::Value *V;
10613
      for (unsigned I = 0; I < NF; ++I) {
10614
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
10615
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
10616
      }
10617
      return V;
10618
    }
10619
    break;
10620
case RISCVVector::BI__builtin_rvv_vlsseg3e8_v_tumu:
10621
case RISCVVector::BI__builtin_rvv_vlsseg3e16_v_tumu:
10622
case RISCVVector::BI__builtin_rvv_vlsseg3e32_v_tumu:
10623
case RISCVVector::BI__builtin_rvv_vlsseg3e64_v_tumu:
10624
  ID = Intrinsic::riscv_vlsseg3_mask;
10625
  NF = 3;
10626
  PolicyAttrs = 0;
10627
IsMasked = true;
10628
 
10629
    {
10630
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
10631
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
10632
      SmallVector<llvm::Value*, 12> Operands;
10633
 
10634
      // Please refer to comment under 'defvar NFList' in this file
10635
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
10636
          (!IsMasked && PolicyAttrs & RVV_VTA))
10637
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
10638
      else {
10639
        if (IsMasked)
10640
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
10641
        else // Unmasked
10642
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
10643
      }
10644
      unsigned PtrOperandIdx = IsMasked ?
10645
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
10646
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
10647
      Value *PtrOperand = Ops[PtrOperandIdx];
10648
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
10649
      Value *VLOperand = Ops[PtrOperandIdx + 2];
10650
      Operands.push_back(PtrOperand);
10651
      Operands.push_back(StrideOperand);
10652
      if (IsMasked)
10653
        Operands.push_back(Ops[NF]);
10654
      Operands.push_back(VLOperand);
10655
      if (IsMasked)
10656
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
10657
 
10658
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
10659
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
10660
      clang::CharUnits Align =
10661
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
10662
      llvm::Value *V;
10663
      for (unsigned I = 0; I < NF; ++I) {
10664
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
10665
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
10666
      }
10667
      return V;
10668
    }
10669
    break;
10670
case RISCVVector::BI__builtin_rvv_vlsseg3e8_v_mu:
10671
case RISCVVector::BI__builtin_rvv_vlsseg3e16_v_mu:
10672
case RISCVVector::BI__builtin_rvv_vlsseg3e32_v_mu:
10673
case RISCVVector::BI__builtin_rvv_vlsseg3e64_v_mu:
10674
  ID = Intrinsic::riscv_vlsseg3_mask;
10675
  NF = 3;
10676
  PolicyAttrs = 1;
10677
IsMasked = true;
10678
 
10679
    {
10680
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
10681
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
10682
      SmallVector<llvm::Value*, 12> Operands;
10683
 
10684
      // Please refer to comment under 'defvar NFList' in this file
10685
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
10686
          (!IsMasked && PolicyAttrs & RVV_VTA))
10687
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
10688
      else {
10689
        if (IsMasked)
10690
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
10691
        else // Unmasked
10692
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
10693
      }
10694
      unsigned PtrOperandIdx = IsMasked ?
10695
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
10696
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
10697
      Value *PtrOperand = Ops[PtrOperandIdx];
10698
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
10699
      Value *VLOperand = Ops[PtrOperandIdx + 2];
10700
      Operands.push_back(PtrOperand);
10701
      Operands.push_back(StrideOperand);
10702
      if (IsMasked)
10703
        Operands.push_back(Ops[NF]);
10704
      Operands.push_back(VLOperand);
10705
      if (IsMasked)
10706
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
10707
 
10708
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
10709
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
10710
      clang::CharUnits Align =
10711
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
10712
      llvm::Value *V;
10713
      for (unsigned I = 0; I < NF; ++I) {
10714
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
10715
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
10716
      }
10717
      return V;
10718
    }
10719
    break;
10720
case RISCVVector::BI__builtin_rvv_vlsseg4e8_v_tu:
10721
case RISCVVector::BI__builtin_rvv_vlsseg4e16_v_tu:
10722
case RISCVVector::BI__builtin_rvv_vlsseg4e32_v_tu:
10723
case RISCVVector::BI__builtin_rvv_vlsseg4e64_v_tu:
10724
  ID = Intrinsic::riscv_vlsseg4;
10725
  NF = 4;
10726
  PolicyAttrs = 2;
10727
IsMasked = false;
10728
 
10729
    {
10730
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
10731
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
10732
      SmallVector<llvm::Value*, 12> Operands;
10733
 
10734
      // Please refer to comment under 'defvar NFList' in this file
10735
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
10736
          (!IsMasked && PolicyAttrs & RVV_VTA))
10737
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
10738
      else {
10739
        if (IsMasked)
10740
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
10741
        else // Unmasked
10742
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
10743
      }
10744
      unsigned PtrOperandIdx = IsMasked ?
10745
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
10746
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
10747
      Value *PtrOperand = Ops[PtrOperandIdx];
10748
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
10749
      Value *VLOperand = Ops[PtrOperandIdx + 2];
10750
      Operands.push_back(PtrOperand);
10751
      Operands.push_back(StrideOperand);
10752
      if (IsMasked)
10753
        Operands.push_back(Ops[NF]);
10754
      Operands.push_back(VLOperand);
10755
      if (IsMasked)
10756
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
10757
 
10758
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
10759
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
10760
      clang::CharUnits Align =
10761
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
10762
      llvm::Value *V;
10763
      for (unsigned I = 0; I < NF; ++I) {
10764
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
10765
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
10766
      }
10767
      return V;
10768
    }
10769
    break;
10770
case RISCVVector::BI__builtin_rvv_vlsseg4e8_v_ta:
10771
case RISCVVector::BI__builtin_rvv_vlsseg4e16_v_ta:
10772
case RISCVVector::BI__builtin_rvv_vlsseg4e32_v_ta:
10773
case RISCVVector::BI__builtin_rvv_vlsseg4e64_v_ta:
10774
  ID = Intrinsic::riscv_vlsseg4;
10775
  NF = 4;
10776
  PolicyAttrs = 3;
10777
IsMasked = false;
10778
 
10779
    {
10780
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
10781
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
10782
      SmallVector<llvm::Value*, 12> Operands;
10783
 
10784
      // Please refer to comment under 'defvar NFList' in this file
10785
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
10786
          (!IsMasked && PolicyAttrs & RVV_VTA))
10787
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
10788
      else {
10789
        if (IsMasked)
10790
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
10791
        else // Unmasked
10792
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
10793
      }
10794
      unsigned PtrOperandIdx = IsMasked ?
10795
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
10796
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
10797
      Value *PtrOperand = Ops[PtrOperandIdx];
10798
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
10799
      Value *VLOperand = Ops[PtrOperandIdx + 2];
10800
      Operands.push_back(PtrOperand);
10801
      Operands.push_back(StrideOperand);
10802
      if (IsMasked)
10803
        Operands.push_back(Ops[NF]);
10804
      Operands.push_back(VLOperand);
10805
      if (IsMasked)
10806
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
10807
 
10808
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
10809
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
10810
      clang::CharUnits Align =
10811
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
10812
      llvm::Value *V;
10813
      for (unsigned I = 0; I < NF; ++I) {
10814
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
10815
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
10816
      }
10817
      return V;
10818
    }
10819
    break;
10820
case RISCVVector::BI__builtin_rvv_vlsseg4e8_v_tum:
10821
case RISCVVector::BI__builtin_rvv_vlsseg4e16_v_tum:
10822
case RISCVVector::BI__builtin_rvv_vlsseg4e32_v_tum:
10823
case RISCVVector::BI__builtin_rvv_vlsseg4e64_v_tum:
10824
  ID = Intrinsic::riscv_vlsseg4_mask;
10825
  NF = 4;
10826
  PolicyAttrs = 2;
10827
IsMasked = true;
10828
 
10829
    {
10830
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
10831
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
10832
      SmallVector<llvm::Value*, 12> Operands;
10833
 
10834
      // Please refer to comment under 'defvar NFList' in this file
10835
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
10836
          (!IsMasked && PolicyAttrs & RVV_VTA))
10837
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
10838
      else {
10839
        if (IsMasked)
10840
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
10841
        else // Unmasked
10842
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
10843
      }
10844
      unsigned PtrOperandIdx = IsMasked ?
10845
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
10846
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
10847
      Value *PtrOperand = Ops[PtrOperandIdx];
10848
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
10849
      Value *VLOperand = Ops[PtrOperandIdx + 2];
10850
      Operands.push_back(PtrOperand);
10851
      Operands.push_back(StrideOperand);
10852
      if (IsMasked)
10853
        Operands.push_back(Ops[NF]);
10854
      Operands.push_back(VLOperand);
10855
      if (IsMasked)
10856
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
10857
 
10858
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
10859
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
10860
      clang::CharUnits Align =
10861
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
10862
      llvm::Value *V;
10863
      for (unsigned I = 0; I < NF; ++I) {
10864
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
10865
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
10866
      }
10867
      return V;
10868
    }
10869
    break;
10870
case RISCVVector::BI__builtin_rvv_vlsseg4e8_v_tama:
10871
case RISCVVector::BI__builtin_rvv_vlsseg4e16_v_tama:
10872
case RISCVVector::BI__builtin_rvv_vlsseg4e32_v_tama:
10873
case RISCVVector::BI__builtin_rvv_vlsseg4e64_v_tama:
10874
  ID = Intrinsic::riscv_vlsseg4_mask;
10875
  NF = 4;
10876
  PolicyAttrs = 3;
10877
IsMasked = true;
10878
 
10879
    {
10880
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
10881
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
10882
      SmallVector<llvm::Value*, 12> Operands;
10883
 
10884
      // Please refer to comment under 'defvar NFList' in this file
10885
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
10886
          (!IsMasked && PolicyAttrs & RVV_VTA))
10887
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
10888
      else {
10889
        if (IsMasked)
10890
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
10891
        else // Unmasked
10892
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
10893
      }
10894
      unsigned PtrOperandIdx = IsMasked ?
10895
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
10896
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
10897
      Value *PtrOperand = Ops[PtrOperandIdx];
10898
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
10899
      Value *VLOperand = Ops[PtrOperandIdx + 2];
10900
      Operands.push_back(PtrOperand);
10901
      Operands.push_back(StrideOperand);
10902
      if (IsMasked)
10903
        Operands.push_back(Ops[NF]);
10904
      Operands.push_back(VLOperand);
10905
      if (IsMasked)
10906
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
10907
 
10908
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
10909
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
10910
      clang::CharUnits Align =
10911
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
10912
      llvm::Value *V;
10913
      for (unsigned I = 0; I < NF; ++I) {
10914
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
10915
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
10916
      }
10917
      return V;
10918
    }
10919
    break;
10920
case RISCVVector::BI__builtin_rvv_vlsseg4e8_v_tumu:
10921
case RISCVVector::BI__builtin_rvv_vlsseg4e16_v_tumu:
10922
case RISCVVector::BI__builtin_rvv_vlsseg4e32_v_tumu:
10923
case RISCVVector::BI__builtin_rvv_vlsseg4e64_v_tumu:
10924
  ID = Intrinsic::riscv_vlsseg4_mask;
10925
  NF = 4;
10926
  PolicyAttrs = 0;
10927
IsMasked = true;
10928
 
10929
    {
10930
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
10931
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
10932
      SmallVector<llvm::Value*, 12> Operands;
10933
 
10934
      // Please refer to comment under 'defvar NFList' in this file
10935
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
10936
          (!IsMasked && PolicyAttrs & RVV_VTA))
10937
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
10938
      else {
10939
        if (IsMasked)
10940
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
10941
        else // Unmasked
10942
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
10943
      }
10944
      unsigned PtrOperandIdx = IsMasked ?
10945
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
10946
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
10947
      Value *PtrOperand = Ops[PtrOperandIdx];
10948
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
10949
      Value *VLOperand = Ops[PtrOperandIdx + 2];
10950
      Operands.push_back(PtrOperand);
10951
      Operands.push_back(StrideOperand);
10952
      if (IsMasked)
10953
        Operands.push_back(Ops[NF]);
10954
      Operands.push_back(VLOperand);
10955
      if (IsMasked)
10956
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
10957
 
10958
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
10959
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
10960
      clang::CharUnits Align =
10961
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
10962
      llvm::Value *V;
10963
      for (unsigned I = 0; I < NF; ++I) {
10964
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
10965
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
10966
      }
10967
      return V;
10968
    }
10969
    break;
10970
case RISCVVector::BI__builtin_rvv_vlsseg4e8_v_mu:
10971
case RISCVVector::BI__builtin_rvv_vlsseg4e16_v_mu:
10972
case RISCVVector::BI__builtin_rvv_vlsseg4e32_v_mu:
10973
case RISCVVector::BI__builtin_rvv_vlsseg4e64_v_mu:
10974
  ID = Intrinsic::riscv_vlsseg4_mask;
10975
  NF = 4;
10976
  PolicyAttrs = 1;
10977
IsMasked = true;
10978
 
10979
    {
10980
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
10981
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
10982
      SmallVector<llvm::Value*, 12> Operands;
10983
 
10984
      // Please refer to comment under 'defvar NFList' in this file
10985
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
10986
          (!IsMasked && PolicyAttrs & RVV_VTA))
10987
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
10988
      else {
10989
        if (IsMasked)
10990
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
10991
        else // Unmasked
10992
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
10993
      }
10994
      unsigned PtrOperandIdx = IsMasked ?
10995
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
10996
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
10997
      Value *PtrOperand = Ops[PtrOperandIdx];
10998
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
10999
      Value *VLOperand = Ops[PtrOperandIdx + 2];
11000
      Operands.push_back(PtrOperand);
11001
      Operands.push_back(StrideOperand);
11002
      if (IsMasked)
11003
        Operands.push_back(Ops[NF]);
11004
      Operands.push_back(VLOperand);
11005
      if (IsMasked)
11006
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
11007
 
11008
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
11009
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
11010
      clang::CharUnits Align =
11011
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
11012
      llvm::Value *V;
11013
      for (unsigned I = 0; I < NF; ++I) {
11014
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
11015
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
11016
      }
11017
      return V;
11018
    }
11019
    break;
11020
case RISCVVector::BI__builtin_rvv_vlsseg5e8_v_tu:
11021
case RISCVVector::BI__builtin_rvv_vlsseg5e16_v_tu:
11022
case RISCVVector::BI__builtin_rvv_vlsseg5e32_v_tu:
11023
case RISCVVector::BI__builtin_rvv_vlsseg5e64_v_tu:
11024
  ID = Intrinsic::riscv_vlsseg5;
11025
  NF = 5;
11026
  PolicyAttrs = 2;
11027
IsMasked = false;
11028
 
11029
    {
11030
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
11031
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
11032
      SmallVector<llvm::Value*, 12> Operands;
11033
 
11034
      // Please refer to comment under 'defvar NFList' in this file
11035
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
11036
          (!IsMasked && PolicyAttrs & RVV_VTA))
11037
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
11038
      else {
11039
        if (IsMasked)
11040
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
11041
        else // Unmasked
11042
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
11043
      }
11044
      unsigned PtrOperandIdx = IsMasked ?
11045
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
11046
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
11047
      Value *PtrOperand = Ops[PtrOperandIdx];
11048
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
11049
      Value *VLOperand = Ops[PtrOperandIdx + 2];
11050
      Operands.push_back(PtrOperand);
11051
      Operands.push_back(StrideOperand);
11052
      if (IsMasked)
11053
        Operands.push_back(Ops[NF]);
11054
      Operands.push_back(VLOperand);
11055
      if (IsMasked)
11056
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
11057
 
11058
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
11059
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
11060
      clang::CharUnits Align =
11061
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
11062
      llvm::Value *V;
11063
      for (unsigned I = 0; I < NF; ++I) {
11064
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
11065
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
11066
      }
11067
      return V;
11068
    }
11069
    break;
11070
case RISCVVector::BI__builtin_rvv_vlsseg5e8_v_ta:
11071
case RISCVVector::BI__builtin_rvv_vlsseg5e16_v_ta:
11072
case RISCVVector::BI__builtin_rvv_vlsseg5e32_v_ta:
11073
case RISCVVector::BI__builtin_rvv_vlsseg5e64_v_ta:
11074
  ID = Intrinsic::riscv_vlsseg5;
11075
  NF = 5;
11076
  PolicyAttrs = 3;
11077
IsMasked = false;
11078
 
11079
    {
11080
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
11081
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
11082
      SmallVector<llvm::Value*, 12> Operands;
11083
 
11084
      // Please refer to comment under 'defvar NFList' in this file
11085
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
11086
          (!IsMasked && PolicyAttrs & RVV_VTA))
11087
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
11088
      else {
11089
        if (IsMasked)
11090
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
11091
        else // Unmasked
11092
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
11093
      }
11094
      unsigned PtrOperandIdx = IsMasked ?
11095
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
11096
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
11097
      Value *PtrOperand = Ops[PtrOperandIdx];
11098
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
11099
      Value *VLOperand = Ops[PtrOperandIdx + 2];
11100
      Operands.push_back(PtrOperand);
11101
      Operands.push_back(StrideOperand);
11102
      if (IsMasked)
11103
        Operands.push_back(Ops[NF]);
11104
      Operands.push_back(VLOperand);
11105
      if (IsMasked)
11106
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
11107
 
11108
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
11109
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
11110
      clang::CharUnits Align =
11111
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
11112
      llvm::Value *V;
11113
      for (unsigned I = 0; I < NF; ++I) {
11114
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
11115
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
11116
      }
11117
      return V;
11118
    }
11119
    break;
11120
case RISCVVector::BI__builtin_rvv_vlsseg5e8_v_tum:
11121
case RISCVVector::BI__builtin_rvv_vlsseg5e16_v_tum:
11122
case RISCVVector::BI__builtin_rvv_vlsseg5e32_v_tum:
11123
case RISCVVector::BI__builtin_rvv_vlsseg5e64_v_tum:
11124
  ID = Intrinsic::riscv_vlsseg5_mask;
11125
  NF = 5;
11126
  PolicyAttrs = 2;
11127
IsMasked = true;
11128
 
11129
    {
11130
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
11131
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
11132
      SmallVector<llvm::Value*, 12> Operands;
11133
 
11134
      // Please refer to comment under 'defvar NFList' in this file
11135
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
11136
          (!IsMasked && PolicyAttrs & RVV_VTA))
11137
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
11138
      else {
11139
        if (IsMasked)
11140
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
11141
        else // Unmasked
11142
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
11143
      }
11144
      unsigned PtrOperandIdx = IsMasked ?
11145
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
11146
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
11147
      Value *PtrOperand = Ops[PtrOperandIdx];
11148
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
11149
      Value *VLOperand = Ops[PtrOperandIdx + 2];
11150
      Operands.push_back(PtrOperand);
11151
      Operands.push_back(StrideOperand);
11152
      if (IsMasked)
11153
        Operands.push_back(Ops[NF]);
11154
      Operands.push_back(VLOperand);
11155
      if (IsMasked)
11156
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
11157
 
11158
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
11159
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
11160
      clang::CharUnits Align =
11161
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
11162
      llvm::Value *V;
11163
      for (unsigned I = 0; I < NF; ++I) {
11164
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
11165
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
11166
      }
11167
      return V;
11168
    }
11169
    break;
11170
case RISCVVector::BI__builtin_rvv_vlsseg5e8_v_tama:
11171
case RISCVVector::BI__builtin_rvv_vlsseg5e16_v_tama:
11172
case RISCVVector::BI__builtin_rvv_vlsseg5e32_v_tama:
11173
case RISCVVector::BI__builtin_rvv_vlsseg5e64_v_tama:
11174
  ID = Intrinsic::riscv_vlsseg5_mask;
11175
  NF = 5;
11176
  PolicyAttrs = 3;
11177
IsMasked = true;
11178
 
11179
    {
11180
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
11181
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
11182
      SmallVector<llvm::Value*, 12> Operands;
11183
 
11184
      // Please refer to comment under 'defvar NFList' in this file
11185
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
11186
          (!IsMasked && PolicyAttrs & RVV_VTA))
11187
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
11188
      else {
11189
        if (IsMasked)
11190
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
11191
        else // Unmasked
11192
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
11193
      }
11194
      unsigned PtrOperandIdx = IsMasked ?
11195
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
11196
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
11197
      Value *PtrOperand = Ops[PtrOperandIdx];
11198
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
11199
      Value *VLOperand = Ops[PtrOperandIdx + 2];
11200
      Operands.push_back(PtrOperand);
11201
      Operands.push_back(StrideOperand);
11202
      if (IsMasked)
11203
        Operands.push_back(Ops[NF]);
11204
      Operands.push_back(VLOperand);
11205
      if (IsMasked)
11206
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
11207
 
11208
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
11209
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
11210
      clang::CharUnits Align =
11211
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
11212
      llvm::Value *V;
11213
      for (unsigned I = 0; I < NF; ++I) {
11214
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
11215
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
11216
      }
11217
      return V;
11218
    }
11219
    break;
11220
case RISCVVector::BI__builtin_rvv_vlsseg5e8_v_tumu:
11221
case RISCVVector::BI__builtin_rvv_vlsseg5e16_v_tumu:
11222
case RISCVVector::BI__builtin_rvv_vlsseg5e32_v_tumu:
11223
case RISCVVector::BI__builtin_rvv_vlsseg5e64_v_tumu:
11224
  ID = Intrinsic::riscv_vlsseg5_mask;
11225
  NF = 5;
11226
  PolicyAttrs = 0;
11227
IsMasked = true;
11228
 
11229
    {
11230
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
11231
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
11232
      SmallVector<llvm::Value*, 12> Operands;
11233
 
11234
      // Please refer to comment under 'defvar NFList' in this file
11235
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
11236
          (!IsMasked && PolicyAttrs & RVV_VTA))
11237
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
11238
      else {
11239
        if (IsMasked)
11240
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
11241
        else // Unmasked
11242
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
11243
      }
11244
      unsigned PtrOperandIdx = IsMasked ?
11245
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
11246
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
11247
      Value *PtrOperand = Ops[PtrOperandIdx];
11248
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
11249
      Value *VLOperand = Ops[PtrOperandIdx + 2];
11250
      Operands.push_back(PtrOperand);
11251
      Operands.push_back(StrideOperand);
11252
      if (IsMasked)
11253
        Operands.push_back(Ops[NF]);
11254
      Operands.push_back(VLOperand);
11255
      if (IsMasked)
11256
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
11257
 
11258
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
11259
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
11260
      clang::CharUnits Align =
11261
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
11262
      llvm::Value *V;
11263
      for (unsigned I = 0; I < NF; ++I) {
11264
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
11265
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
11266
      }
11267
      return V;
11268
    }
11269
    break;
11270
case RISCVVector::BI__builtin_rvv_vlsseg5e8_v_mu:
11271
case RISCVVector::BI__builtin_rvv_vlsseg5e16_v_mu:
11272
case RISCVVector::BI__builtin_rvv_vlsseg5e32_v_mu:
11273
case RISCVVector::BI__builtin_rvv_vlsseg5e64_v_mu:
11274
  ID = Intrinsic::riscv_vlsseg5_mask;
11275
  NF = 5;
11276
  PolicyAttrs = 1;
11277
IsMasked = true;
11278
 
11279
    {
11280
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
11281
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
11282
      SmallVector<llvm::Value*, 12> Operands;
11283
 
11284
      // Please refer to comment under 'defvar NFList' in this file
11285
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
11286
          (!IsMasked && PolicyAttrs & RVV_VTA))
11287
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
11288
      else {
11289
        if (IsMasked)
11290
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
11291
        else // Unmasked
11292
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
11293
      }
11294
      unsigned PtrOperandIdx = IsMasked ?
11295
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
11296
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
11297
      Value *PtrOperand = Ops[PtrOperandIdx];
11298
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
11299
      Value *VLOperand = Ops[PtrOperandIdx + 2];
11300
      Operands.push_back(PtrOperand);
11301
      Operands.push_back(StrideOperand);
11302
      if (IsMasked)
11303
        Operands.push_back(Ops[NF]);
11304
      Operands.push_back(VLOperand);
11305
      if (IsMasked)
11306
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
11307
 
11308
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
11309
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
11310
      clang::CharUnits Align =
11311
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
11312
      llvm::Value *V;
11313
      for (unsigned I = 0; I < NF; ++I) {
11314
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
11315
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
11316
      }
11317
      return V;
11318
    }
11319
    break;
11320
case RISCVVector::BI__builtin_rvv_vlsseg6e8_v_tu:
11321
case RISCVVector::BI__builtin_rvv_vlsseg6e16_v_tu:
11322
case RISCVVector::BI__builtin_rvv_vlsseg6e32_v_tu:
11323
case RISCVVector::BI__builtin_rvv_vlsseg6e64_v_tu:
11324
  ID = Intrinsic::riscv_vlsseg6;
11325
  NF = 6;
11326
  PolicyAttrs = 2;
11327
IsMasked = false;
11328
 
11329
    {
11330
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
11331
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
11332
      SmallVector<llvm::Value*, 12> Operands;
11333
 
11334
      // Please refer to comment under 'defvar NFList' in this file
11335
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
11336
          (!IsMasked && PolicyAttrs & RVV_VTA))
11337
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
11338
      else {
11339
        if (IsMasked)
11340
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
11341
        else // Unmasked
11342
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
11343
      }
11344
      unsigned PtrOperandIdx = IsMasked ?
11345
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
11346
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
11347
      Value *PtrOperand = Ops[PtrOperandIdx];
11348
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
11349
      Value *VLOperand = Ops[PtrOperandIdx + 2];
11350
      Operands.push_back(PtrOperand);
11351
      Operands.push_back(StrideOperand);
11352
      if (IsMasked)
11353
        Operands.push_back(Ops[NF]);
11354
      Operands.push_back(VLOperand);
11355
      if (IsMasked)
11356
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
11357
 
11358
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
11359
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
11360
      clang::CharUnits Align =
11361
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
11362
      llvm::Value *V;
11363
      for (unsigned I = 0; I < NF; ++I) {
11364
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
11365
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
11366
      }
11367
      return V;
11368
    }
11369
    break;
11370
case RISCVVector::BI__builtin_rvv_vlsseg6e8_v_ta:
11371
case RISCVVector::BI__builtin_rvv_vlsseg6e16_v_ta:
11372
case RISCVVector::BI__builtin_rvv_vlsseg6e32_v_ta:
11373
case RISCVVector::BI__builtin_rvv_vlsseg6e64_v_ta:
11374
  ID = Intrinsic::riscv_vlsseg6;
11375
  NF = 6;
11376
  PolicyAttrs = 3;
11377
IsMasked = false;
11378
 
11379
    {
11380
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
11381
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
11382
      SmallVector<llvm::Value*, 12> Operands;
11383
 
11384
      // Please refer to comment under 'defvar NFList' in this file
11385
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
11386
          (!IsMasked && PolicyAttrs & RVV_VTA))
11387
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
11388
      else {
11389
        if (IsMasked)
11390
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
11391
        else // Unmasked
11392
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
11393
      }
11394
      unsigned PtrOperandIdx = IsMasked ?
11395
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
11396
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
11397
      Value *PtrOperand = Ops[PtrOperandIdx];
11398
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
11399
      Value *VLOperand = Ops[PtrOperandIdx + 2];
11400
      Operands.push_back(PtrOperand);
11401
      Operands.push_back(StrideOperand);
11402
      if (IsMasked)
11403
        Operands.push_back(Ops[NF]);
11404
      Operands.push_back(VLOperand);
11405
      if (IsMasked)
11406
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
11407
 
11408
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
11409
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
11410
      clang::CharUnits Align =
11411
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
11412
      llvm::Value *V;
11413
      for (unsigned I = 0; I < NF; ++I) {
11414
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
11415
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
11416
      }
11417
      return V;
11418
    }
11419
    break;
11420
case RISCVVector::BI__builtin_rvv_vlsseg6e8_v_tum:
11421
case RISCVVector::BI__builtin_rvv_vlsseg6e16_v_tum:
11422
case RISCVVector::BI__builtin_rvv_vlsseg6e32_v_tum:
11423
case RISCVVector::BI__builtin_rvv_vlsseg6e64_v_tum:
11424
  ID = Intrinsic::riscv_vlsseg6_mask;
11425
  NF = 6;
11426
  PolicyAttrs = 2;
11427
IsMasked = true;
11428
 
11429
    {
11430
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
11431
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
11432
      SmallVector<llvm::Value*, 12> Operands;
11433
 
11434
      // Please refer to comment under 'defvar NFList' in this file
11435
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
11436
          (!IsMasked && PolicyAttrs & RVV_VTA))
11437
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
11438
      else {
11439
        if (IsMasked)
11440
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
11441
        else // Unmasked
11442
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
11443
      }
11444
      unsigned PtrOperandIdx = IsMasked ?
11445
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
11446
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
11447
      Value *PtrOperand = Ops[PtrOperandIdx];
11448
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
11449
      Value *VLOperand = Ops[PtrOperandIdx + 2];
11450
      Operands.push_back(PtrOperand);
11451
      Operands.push_back(StrideOperand);
11452
      if (IsMasked)
11453
        Operands.push_back(Ops[NF]);
11454
      Operands.push_back(VLOperand);
11455
      if (IsMasked)
11456
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
11457
 
11458
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
11459
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
11460
      clang::CharUnits Align =
11461
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
11462
      llvm::Value *V;
11463
      for (unsigned I = 0; I < NF; ++I) {
11464
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
11465
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
11466
      }
11467
      return V;
11468
    }
11469
    break;
11470
case RISCVVector::BI__builtin_rvv_vlsseg6e8_v_tama:
11471
case RISCVVector::BI__builtin_rvv_vlsseg6e16_v_tama:
11472
case RISCVVector::BI__builtin_rvv_vlsseg6e32_v_tama:
11473
case RISCVVector::BI__builtin_rvv_vlsseg6e64_v_tama:
11474
  ID = Intrinsic::riscv_vlsseg6_mask;
11475
  NF = 6;
11476
  PolicyAttrs = 3;
11477
IsMasked = true;
11478
 
11479
    {
11480
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
11481
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
11482
      SmallVector<llvm::Value*, 12> Operands;
11483
 
11484
      // Please refer to comment under 'defvar NFList' in this file
11485
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
11486
          (!IsMasked && PolicyAttrs & RVV_VTA))
11487
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
11488
      else {
11489
        if (IsMasked)
11490
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
11491
        else // Unmasked
11492
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
11493
      }
11494
      unsigned PtrOperandIdx = IsMasked ?
11495
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
11496
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
11497
      Value *PtrOperand = Ops[PtrOperandIdx];
11498
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
11499
      Value *VLOperand = Ops[PtrOperandIdx + 2];
11500
      Operands.push_back(PtrOperand);
11501
      Operands.push_back(StrideOperand);
11502
      if (IsMasked)
11503
        Operands.push_back(Ops[NF]);
11504
      Operands.push_back(VLOperand);
11505
      if (IsMasked)
11506
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
11507
 
11508
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
11509
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
11510
      clang::CharUnits Align =
11511
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
11512
      llvm::Value *V;
11513
      for (unsigned I = 0; I < NF; ++I) {
11514
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
11515
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
11516
      }
11517
      return V;
11518
    }
11519
    break;
11520
case RISCVVector::BI__builtin_rvv_vlsseg6e8_v_tumu:
11521
case RISCVVector::BI__builtin_rvv_vlsseg6e16_v_tumu:
11522
case RISCVVector::BI__builtin_rvv_vlsseg6e32_v_tumu:
11523
case RISCVVector::BI__builtin_rvv_vlsseg6e64_v_tumu:
11524
  ID = Intrinsic::riscv_vlsseg6_mask;
11525
  NF = 6;
11526
  PolicyAttrs = 0;
11527
IsMasked = true;
11528
 
11529
    {
11530
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
11531
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
11532
      SmallVector<llvm::Value*, 12> Operands;
11533
 
11534
      // Please refer to comment under 'defvar NFList' in this file
11535
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
11536
          (!IsMasked && PolicyAttrs & RVV_VTA))
11537
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
11538
      else {
11539
        if (IsMasked)
11540
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
11541
        else // Unmasked
11542
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
11543
      }
11544
      unsigned PtrOperandIdx = IsMasked ?
11545
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
11546
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
11547
      Value *PtrOperand = Ops[PtrOperandIdx];
11548
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
11549
      Value *VLOperand = Ops[PtrOperandIdx + 2];
11550
      Operands.push_back(PtrOperand);
11551
      Operands.push_back(StrideOperand);
11552
      if (IsMasked)
11553
        Operands.push_back(Ops[NF]);
11554
      Operands.push_back(VLOperand);
11555
      if (IsMasked)
11556
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
11557
 
11558
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
11559
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
11560
      clang::CharUnits Align =
11561
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
11562
      llvm::Value *V;
11563
      for (unsigned I = 0; I < NF; ++I) {
11564
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
11565
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
11566
      }
11567
      return V;
11568
    }
11569
    break;
11570
case RISCVVector::BI__builtin_rvv_vlsseg6e8_v_mu:
11571
case RISCVVector::BI__builtin_rvv_vlsseg6e16_v_mu:
11572
case RISCVVector::BI__builtin_rvv_vlsseg6e32_v_mu:
11573
case RISCVVector::BI__builtin_rvv_vlsseg6e64_v_mu:
11574
  ID = Intrinsic::riscv_vlsseg6_mask;
11575
  NF = 6;
11576
  PolicyAttrs = 1;
11577
IsMasked = true;
11578
 
11579
    {
11580
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
11581
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
11582
      SmallVector<llvm::Value*, 12> Operands;
11583
 
11584
      // Please refer to comment under 'defvar NFList' in this file
11585
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
11586
          (!IsMasked && PolicyAttrs & RVV_VTA))
11587
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
11588
      else {
11589
        if (IsMasked)
11590
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
11591
        else // Unmasked
11592
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
11593
      }
11594
      unsigned PtrOperandIdx = IsMasked ?
11595
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
11596
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
11597
      Value *PtrOperand = Ops[PtrOperandIdx];
11598
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
11599
      Value *VLOperand = Ops[PtrOperandIdx + 2];
11600
      Operands.push_back(PtrOperand);
11601
      Operands.push_back(StrideOperand);
11602
      if (IsMasked)
11603
        Operands.push_back(Ops[NF]);
11604
      Operands.push_back(VLOperand);
11605
      if (IsMasked)
11606
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
11607
 
11608
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
11609
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
11610
      clang::CharUnits Align =
11611
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
11612
      llvm::Value *V;
11613
      for (unsigned I = 0; I < NF; ++I) {
11614
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
11615
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
11616
      }
11617
      return V;
11618
    }
11619
    break;
11620
case RISCVVector::BI__builtin_rvv_vlsseg7e8_v_tu:
11621
case RISCVVector::BI__builtin_rvv_vlsseg7e16_v_tu:
11622
case RISCVVector::BI__builtin_rvv_vlsseg7e32_v_tu:
11623
case RISCVVector::BI__builtin_rvv_vlsseg7e64_v_tu:
11624
  ID = Intrinsic::riscv_vlsseg7;
11625
  NF = 7;
11626
  PolicyAttrs = 2;
11627
IsMasked = false;
11628
 
11629
    {
11630
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
11631
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
11632
      SmallVector<llvm::Value*, 12> Operands;
11633
 
11634
      // Please refer to comment under 'defvar NFList' in this file
11635
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
11636
          (!IsMasked && PolicyAttrs & RVV_VTA))
11637
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
11638
      else {
11639
        if (IsMasked)
11640
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
11641
        else // Unmasked
11642
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
11643
      }
11644
      unsigned PtrOperandIdx = IsMasked ?
11645
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
11646
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
11647
      Value *PtrOperand = Ops[PtrOperandIdx];
11648
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
11649
      Value *VLOperand = Ops[PtrOperandIdx + 2];
11650
      Operands.push_back(PtrOperand);
11651
      Operands.push_back(StrideOperand);
11652
      if (IsMasked)
11653
        Operands.push_back(Ops[NF]);
11654
      Operands.push_back(VLOperand);
11655
      if (IsMasked)
11656
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
11657
 
11658
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
11659
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
11660
      clang::CharUnits Align =
11661
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
11662
      llvm::Value *V;
11663
      for (unsigned I = 0; I < NF; ++I) {
11664
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
11665
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
11666
      }
11667
      return V;
11668
    }
11669
    break;
11670
case RISCVVector::BI__builtin_rvv_vlsseg7e8_v_ta:
11671
case RISCVVector::BI__builtin_rvv_vlsseg7e16_v_ta:
11672
case RISCVVector::BI__builtin_rvv_vlsseg7e32_v_ta:
11673
case RISCVVector::BI__builtin_rvv_vlsseg7e64_v_ta:
11674
  ID = Intrinsic::riscv_vlsseg7;
11675
  NF = 7;
11676
  PolicyAttrs = 3;
11677
IsMasked = false;
11678
 
11679
    {
11680
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
11681
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
11682
      SmallVector<llvm::Value*, 12> Operands;
11683
 
11684
      // Please refer to comment under 'defvar NFList' in this file
11685
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
11686
          (!IsMasked && PolicyAttrs & RVV_VTA))
11687
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
11688
      else {
11689
        if (IsMasked)
11690
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
11691
        else // Unmasked
11692
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
11693
      }
11694
      unsigned PtrOperandIdx = IsMasked ?
11695
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
11696
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
11697
      Value *PtrOperand = Ops[PtrOperandIdx];
11698
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
11699
      Value *VLOperand = Ops[PtrOperandIdx + 2];
11700
      Operands.push_back(PtrOperand);
11701
      Operands.push_back(StrideOperand);
11702
      if (IsMasked)
11703
        Operands.push_back(Ops[NF]);
11704
      Operands.push_back(VLOperand);
11705
      if (IsMasked)
11706
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
11707
 
11708
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
11709
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
11710
      clang::CharUnits Align =
11711
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
11712
      llvm::Value *V;
11713
      for (unsigned I = 0; I < NF; ++I) {
11714
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
11715
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
11716
      }
11717
      return V;
11718
    }
11719
    break;
11720
case RISCVVector::BI__builtin_rvv_vlsseg7e8_v_tum:
11721
case RISCVVector::BI__builtin_rvv_vlsseg7e16_v_tum:
11722
case RISCVVector::BI__builtin_rvv_vlsseg7e32_v_tum:
11723
case RISCVVector::BI__builtin_rvv_vlsseg7e64_v_tum:
11724
  ID = Intrinsic::riscv_vlsseg7_mask;
11725
  NF = 7;
11726
  PolicyAttrs = 2;
11727
IsMasked = true;
11728
 
11729
    {
11730
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
11731
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
11732
      SmallVector<llvm::Value*, 12> Operands;
11733
 
11734
      // Please refer to comment under 'defvar NFList' in this file
11735
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
11736
          (!IsMasked && PolicyAttrs & RVV_VTA))
11737
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
11738
      else {
11739
        if (IsMasked)
11740
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
11741
        else // Unmasked
11742
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
11743
      }
11744
      unsigned PtrOperandIdx = IsMasked ?
11745
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
11746
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
11747
      Value *PtrOperand = Ops[PtrOperandIdx];
11748
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
11749
      Value *VLOperand = Ops[PtrOperandIdx + 2];
11750
      Operands.push_back(PtrOperand);
11751
      Operands.push_back(StrideOperand);
11752
      if (IsMasked)
11753
        Operands.push_back(Ops[NF]);
11754
      Operands.push_back(VLOperand);
11755
      if (IsMasked)
11756
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
11757
 
11758
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
11759
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
11760
      clang::CharUnits Align =
11761
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
11762
      llvm::Value *V;
11763
      for (unsigned I = 0; I < NF; ++I) {
11764
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
11765
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
11766
      }
11767
      return V;
11768
    }
11769
    break;
11770
case RISCVVector::BI__builtin_rvv_vlsseg7e8_v_tama:
11771
case RISCVVector::BI__builtin_rvv_vlsseg7e16_v_tama:
11772
case RISCVVector::BI__builtin_rvv_vlsseg7e32_v_tama:
11773
case RISCVVector::BI__builtin_rvv_vlsseg7e64_v_tama:
11774
  ID = Intrinsic::riscv_vlsseg7_mask;
11775
  NF = 7;
11776
  PolicyAttrs = 3;
11777
IsMasked = true;
11778
 
11779
    {
11780
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
11781
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
11782
      SmallVector<llvm::Value*, 12> Operands;
11783
 
11784
      // Please refer to comment under 'defvar NFList' in this file
11785
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
11786
          (!IsMasked && PolicyAttrs & RVV_VTA))
11787
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
11788
      else {
11789
        if (IsMasked)
11790
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
11791
        else // Unmasked
11792
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
11793
      }
11794
      unsigned PtrOperandIdx = IsMasked ?
11795
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
11796
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
11797
      Value *PtrOperand = Ops[PtrOperandIdx];
11798
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
11799
      Value *VLOperand = Ops[PtrOperandIdx + 2];
11800
      Operands.push_back(PtrOperand);
11801
      Operands.push_back(StrideOperand);
11802
      if (IsMasked)
11803
        Operands.push_back(Ops[NF]);
11804
      Operands.push_back(VLOperand);
11805
      if (IsMasked)
11806
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
11807
 
11808
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
11809
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
11810
      clang::CharUnits Align =
11811
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
11812
      llvm::Value *V;
11813
      for (unsigned I = 0; I < NF; ++I) {
11814
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
11815
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
11816
      }
11817
      return V;
11818
    }
11819
    break;
11820
case RISCVVector::BI__builtin_rvv_vlsseg7e8_v_tumu:
11821
case RISCVVector::BI__builtin_rvv_vlsseg7e16_v_tumu:
11822
case RISCVVector::BI__builtin_rvv_vlsseg7e32_v_tumu:
11823
case RISCVVector::BI__builtin_rvv_vlsseg7e64_v_tumu:
11824
  ID = Intrinsic::riscv_vlsseg7_mask;
11825
  NF = 7;
11826
  PolicyAttrs = 0;
11827
IsMasked = true;
11828
 
11829
    {
11830
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
11831
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
11832
      SmallVector<llvm::Value*, 12> Operands;
11833
 
11834
      // Please refer to comment under 'defvar NFList' in this file
11835
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
11836
          (!IsMasked && PolicyAttrs & RVV_VTA))
11837
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
11838
      else {
11839
        if (IsMasked)
11840
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
11841
        else // Unmasked
11842
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
11843
      }
11844
      unsigned PtrOperandIdx = IsMasked ?
11845
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
11846
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
11847
      Value *PtrOperand = Ops[PtrOperandIdx];
11848
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
11849
      Value *VLOperand = Ops[PtrOperandIdx + 2];
11850
      Operands.push_back(PtrOperand);
11851
      Operands.push_back(StrideOperand);
11852
      if (IsMasked)
11853
        Operands.push_back(Ops[NF]);
11854
      Operands.push_back(VLOperand);
11855
      if (IsMasked)
11856
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
11857
 
11858
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
11859
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
11860
      clang::CharUnits Align =
11861
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
11862
      llvm::Value *V;
11863
      for (unsigned I = 0; I < NF; ++I) {
11864
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
11865
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
11866
      }
11867
      return V;
11868
    }
11869
    break;
11870
case RISCVVector::BI__builtin_rvv_vlsseg7e8_v_mu:
11871
case RISCVVector::BI__builtin_rvv_vlsseg7e16_v_mu:
11872
case RISCVVector::BI__builtin_rvv_vlsseg7e32_v_mu:
11873
case RISCVVector::BI__builtin_rvv_vlsseg7e64_v_mu:
11874
  ID = Intrinsic::riscv_vlsseg7_mask;
11875
  NF = 7;
11876
  PolicyAttrs = 1;
11877
IsMasked = true;
11878
 
11879
    {
11880
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
11881
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
11882
      SmallVector<llvm::Value*, 12> Operands;
11883
 
11884
      // Please refer to comment under 'defvar NFList' in this file
11885
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
11886
          (!IsMasked && PolicyAttrs & RVV_VTA))
11887
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
11888
      else {
11889
        if (IsMasked)
11890
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
11891
        else // Unmasked
11892
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
11893
      }
11894
      unsigned PtrOperandIdx = IsMasked ?
11895
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
11896
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
11897
      Value *PtrOperand = Ops[PtrOperandIdx];
11898
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
11899
      Value *VLOperand = Ops[PtrOperandIdx + 2];
11900
      Operands.push_back(PtrOperand);
11901
      Operands.push_back(StrideOperand);
11902
      if (IsMasked)
11903
        Operands.push_back(Ops[NF]);
11904
      Operands.push_back(VLOperand);
11905
      if (IsMasked)
11906
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
11907
 
11908
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
11909
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
11910
      clang::CharUnits Align =
11911
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
11912
      llvm::Value *V;
11913
      for (unsigned I = 0; I < NF; ++I) {
11914
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
11915
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
11916
      }
11917
      return V;
11918
    }
11919
    break;
11920
case RISCVVector::BI__builtin_rvv_vlsseg8e8_v_tu:
11921
case RISCVVector::BI__builtin_rvv_vlsseg8e16_v_tu:
11922
case RISCVVector::BI__builtin_rvv_vlsseg8e32_v_tu:
11923
case RISCVVector::BI__builtin_rvv_vlsseg8e64_v_tu:
11924
  ID = Intrinsic::riscv_vlsseg8;
11925
  NF = 8;
11926
  PolicyAttrs = 2;
11927
IsMasked = false;
11928
 
11929
    {
11930
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
11931
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
11932
      SmallVector<llvm::Value*, 12> Operands;
11933
 
11934
      // Please refer to comment under 'defvar NFList' in this file
11935
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
11936
          (!IsMasked && PolicyAttrs & RVV_VTA))
11937
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
11938
      else {
11939
        if (IsMasked)
11940
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
11941
        else // Unmasked
11942
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
11943
      }
11944
      unsigned PtrOperandIdx = IsMasked ?
11945
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
11946
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
11947
      Value *PtrOperand = Ops[PtrOperandIdx];
11948
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
11949
      Value *VLOperand = Ops[PtrOperandIdx + 2];
11950
      Operands.push_back(PtrOperand);
11951
      Operands.push_back(StrideOperand);
11952
      if (IsMasked)
11953
        Operands.push_back(Ops[NF]);
11954
      Operands.push_back(VLOperand);
11955
      if (IsMasked)
11956
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
11957
 
11958
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
11959
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
11960
      clang::CharUnits Align =
11961
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
11962
      llvm::Value *V;
11963
      for (unsigned I = 0; I < NF; ++I) {
11964
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
11965
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
11966
      }
11967
      return V;
11968
    }
11969
    break;
11970
case RISCVVector::BI__builtin_rvv_vlsseg8e8_v_ta:
11971
case RISCVVector::BI__builtin_rvv_vlsseg8e16_v_ta:
11972
case RISCVVector::BI__builtin_rvv_vlsseg8e32_v_ta:
11973
case RISCVVector::BI__builtin_rvv_vlsseg8e64_v_ta:
11974
  ID = Intrinsic::riscv_vlsseg8;
11975
  NF = 8;
11976
  PolicyAttrs = 3;
11977
IsMasked = false;
11978
 
11979
    {
11980
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
11981
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
11982
      SmallVector<llvm::Value*, 12> Operands;
11983
 
11984
      // Please refer to comment under 'defvar NFList' in this file
11985
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
11986
          (!IsMasked && PolicyAttrs & RVV_VTA))
11987
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
11988
      else {
11989
        if (IsMasked)
11990
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
11991
        else // Unmasked
11992
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
11993
      }
11994
      unsigned PtrOperandIdx = IsMasked ?
11995
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
11996
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
11997
      Value *PtrOperand = Ops[PtrOperandIdx];
11998
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
11999
      Value *VLOperand = Ops[PtrOperandIdx + 2];
12000
      Operands.push_back(PtrOperand);
12001
      Operands.push_back(StrideOperand);
12002
      if (IsMasked)
12003
        Operands.push_back(Ops[NF]);
12004
      Operands.push_back(VLOperand);
12005
      if (IsMasked)
12006
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
12007
 
12008
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
12009
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
12010
      clang::CharUnits Align =
12011
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
12012
      llvm::Value *V;
12013
      for (unsigned I = 0; I < NF; ++I) {
12014
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
12015
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
12016
      }
12017
      return V;
12018
    }
12019
    break;
12020
case RISCVVector::BI__builtin_rvv_vlsseg8e8_v_tum:
12021
case RISCVVector::BI__builtin_rvv_vlsseg8e16_v_tum:
12022
case RISCVVector::BI__builtin_rvv_vlsseg8e32_v_tum:
12023
case RISCVVector::BI__builtin_rvv_vlsseg8e64_v_tum:
12024
  ID = Intrinsic::riscv_vlsseg8_mask;
12025
  NF = 8;
12026
  PolicyAttrs = 2;
12027
IsMasked = true;
12028
 
12029
    {
12030
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
12031
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
12032
      SmallVector<llvm::Value*, 12> Operands;
12033
 
12034
      // Please refer to comment under 'defvar NFList' in this file
12035
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
12036
          (!IsMasked && PolicyAttrs & RVV_VTA))
12037
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
12038
      else {
12039
        if (IsMasked)
12040
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
12041
        else // Unmasked
12042
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
12043
      }
12044
      unsigned PtrOperandIdx = IsMasked ?
12045
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
12046
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
12047
      Value *PtrOperand = Ops[PtrOperandIdx];
12048
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
12049
      Value *VLOperand = Ops[PtrOperandIdx + 2];
12050
      Operands.push_back(PtrOperand);
12051
      Operands.push_back(StrideOperand);
12052
      if (IsMasked)
12053
        Operands.push_back(Ops[NF]);
12054
      Operands.push_back(VLOperand);
12055
      if (IsMasked)
12056
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
12057
 
12058
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
12059
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
12060
      clang::CharUnits Align =
12061
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
12062
      llvm::Value *V;
12063
      for (unsigned I = 0; I < NF; ++I) {
12064
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
12065
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
12066
      }
12067
      return V;
12068
    }
12069
    break;
12070
case RISCVVector::BI__builtin_rvv_vlsseg8e8_v_tama:
12071
case RISCVVector::BI__builtin_rvv_vlsseg8e16_v_tama:
12072
case RISCVVector::BI__builtin_rvv_vlsseg8e32_v_tama:
12073
case RISCVVector::BI__builtin_rvv_vlsseg8e64_v_tama:
12074
  ID = Intrinsic::riscv_vlsseg8_mask;
12075
  NF = 8;
12076
  PolicyAttrs = 3;
12077
IsMasked = true;
12078
 
12079
    {
12080
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
12081
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
12082
      SmallVector<llvm::Value*, 12> Operands;
12083
 
12084
      // Please refer to comment under 'defvar NFList' in this file
12085
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
12086
          (!IsMasked && PolicyAttrs & RVV_VTA))
12087
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
12088
      else {
12089
        if (IsMasked)
12090
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
12091
        else // Unmasked
12092
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
12093
      }
12094
      unsigned PtrOperandIdx = IsMasked ?
12095
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
12096
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
12097
      Value *PtrOperand = Ops[PtrOperandIdx];
12098
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
12099
      Value *VLOperand = Ops[PtrOperandIdx + 2];
12100
      Operands.push_back(PtrOperand);
12101
      Operands.push_back(StrideOperand);
12102
      if (IsMasked)
12103
        Operands.push_back(Ops[NF]);
12104
      Operands.push_back(VLOperand);
12105
      if (IsMasked)
12106
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
12107
 
12108
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
12109
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
12110
      clang::CharUnits Align =
12111
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
12112
      llvm::Value *V;
12113
      for (unsigned I = 0; I < NF; ++I) {
12114
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
12115
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
12116
      }
12117
      return V;
12118
    }
12119
    break;
12120
case RISCVVector::BI__builtin_rvv_vlsseg8e8_v_tumu:
12121
case RISCVVector::BI__builtin_rvv_vlsseg8e16_v_tumu:
12122
case RISCVVector::BI__builtin_rvv_vlsseg8e32_v_tumu:
12123
case RISCVVector::BI__builtin_rvv_vlsseg8e64_v_tumu:
12124
  ID = Intrinsic::riscv_vlsseg8_mask;
12125
  NF = 8;
12126
  PolicyAttrs = 0;
12127
IsMasked = true;
12128
 
12129
    {
12130
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
12131
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
12132
      SmallVector<llvm::Value*, 12> Operands;
12133
 
12134
      // Please refer to comment under 'defvar NFList' in this file
12135
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
12136
          (!IsMasked && PolicyAttrs & RVV_VTA))
12137
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
12138
      else {
12139
        if (IsMasked)
12140
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
12141
        else // Unmasked
12142
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
12143
      }
12144
      unsigned PtrOperandIdx = IsMasked ?
12145
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
12146
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
12147
      Value *PtrOperand = Ops[PtrOperandIdx];
12148
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
12149
      Value *VLOperand = Ops[PtrOperandIdx + 2];
12150
      Operands.push_back(PtrOperand);
12151
      Operands.push_back(StrideOperand);
12152
      if (IsMasked)
12153
        Operands.push_back(Ops[NF]);
12154
      Operands.push_back(VLOperand);
12155
      if (IsMasked)
12156
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
12157
 
12158
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
12159
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
12160
      clang::CharUnits Align =
12161
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
12162
      llvm::Value *V;
12163
      for (unsigned I = 0; I < NF; ++I) {
12164
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
12165
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
12166
      }
12167
      return V;
12168
    }
12169
    break;
12170
case RISCVVector::BI__builtin_rvv_vlsseg8e8_v_mu:
12171
case RISCVVector::BI__builtin_rvv_vlsseg8e16_v_mu:
12172
case RISCVVector::BI__builtin_rvv_vlsseg8e32_v_mu:
12173
case RISCVVector::BI__builtin_rvv_vlsseg8e64_v_mu:
12174
  ID = Intrinsic::riscv_vlsseg8_mask;
12175
  NF = 8;
12176
  PolicyAttrs = 1;
12177
IsMasked = true;
12178
 
12179
    {
12180
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
12181
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
12182
      SmallVector<llvm::Value*, 12> Operands;
12183
 
12184
      // Please refer to comment under 'defvar NFList' in this file
12185
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
12186
          (!IsMasked && PolicyAttrs & RVV_VTA))
12187
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
12188
      else {
12189
        if (IsMasked)
12190
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
12191
        else // Unmasked
12192
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
12193
      }
12194
      unsigned PtrOperandIdx = IsMasked ?
12195
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
12196
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
12197
      Value *PtrOperand = Ops[PtrOperandIdx];
12198
      Value *StrideOperand = Ops[PtrOperandIdx + 1];
12199
      Value *VLOperand = Ops[PtrOperandIdx + 2];
12200
      Operands.push_back(PtrOperand);
12201
      Operands.push_back(StrideOperand);
12202
      if (IsMasked)
12203
        Operands.push_back(Ops[NF]);
12204
      Operands.push_back(VLOperand);
12205
      if (IsMasked)
12206
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
12207
 
12208
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
12209
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
12210
      clang::CharUnits Align =
12211
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
12212
      llvm::Value *V;
12213
      for (unsigned I = 0; I < NF; ++I) {
12214
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
12215
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
12216
      }
12217
      return V;
12218
    }
12219
    break;
12220
case RISCVVector::BI__builtin_rvv_vluxei8_v_tu:
12221
case RISCVVector::BI__builtin_rvv_vluxei64_v_tu:
12222
case RISCVVector::BI__builtin_rvv_vluxei16_v_tu:
12223
case RISCVVector::BI__builtin_rvv_vluxei32_v_tu:
12224
  ID = Intrinsic::riscv_vluxei;
12225
  PolicyAttrs = 2;
12226
  Ops[1] = Builder.CreateBitCast(Ops[1], ResultType->getPointerTo());
12227
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
12228
  break;
12229
case RISCVVector::BI__builtin_rvv_vluxei8_v_ta:
12230
case RISCVVector::BI__builtin_rvv_vluxei64_v_ta:
12231
case RISCVVector::BI__builtin_rvv_vluxei16_v_ta:
12232
case RISCVVector::BI__builtin_rvv_vluxei32_v_ta:
12233
  ID = Intrinsic::riscv_vluxei;
12234
  PolicyAttrs = 3;
12235
  Ops[0] = Builder.CreateBitCast(Ops[0], ResultType->getPointerTo());
12236
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
12237
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
12238
  break;
12239
case RISCVVector::BI__builtin_rvv_vluxei8_v_tum:
12240
case RISCVVector::BI__builtin_rvv_vluxei64_v_tum:
12241
case RISCVVector::BI__builtin_rvv_vluxei16_v_tum:
12242
case RISCVVector::BI__builtin_rvv_vluxei32_v_tum:
12243
  ID = Intrinsic::riscv_vluxei_mask;
12244
  PolicyAttrs = 2;
12245
  Ops[2] = Builder.CreateBitCast(Ops[2], ResultType->getPointerTo());
12246
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
12247
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
12248
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
12249
  break;
12250
case RISCVVector::BI__builtin_rvv_vluxei8_v_tama:
12251
case RISCVVector::BI__builtin_rvv_vluxei64_v_tama:
12252
case RISCVVector::BI__builtin_rvv_vluxei16_v_tama:
12253
case RISCVVector::BI__builtin_rvv_vluxei32_v_tama:
12254
  ID = Intrinsic::riscv_vluxei_mask;
12255
  PolicyAttrs = 3;
12256
  Ops[1] = Builder.CreateBitCast(Ops[1], ResultType->getPointerTo());
12257
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
12258
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
12259
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
12260
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
12261
  break;
12262
case RISCVVector::BI__builtin_rvv_vluxei8_v_tumu:
12263
case RISCVVector::BI__builtin_rvv_vluxei64_v_tumu:
12264
case RISCVVector::BI__builtin_rvv_vluxei16_v_tumu:
12265
case RISCVVector::BI__builtin_rvv_vluxei32_v_tumu:
12266
  ID = Intrinsic::riscv_vluxei_mask;
12267
  PolicyAttrs = 0;
12268
  Ops[2] = Builder.CreateBitCast(Ops[2], ResultType->getPointerTo());
12269
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
12270
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
12271
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
12272
  break;
12273
case RISCVVector::BI__builtin_rvv_vluxei8_v_mu:
12274
case RISCVVector::BI__builtin_rvv_vluxei64_v_mu:
12275
case RISCVVector::BI__builtin_rvv_vluxei16_v_mu:
12276
case RISCVVector::BI__builtin_rvv_vluxei32_v_mu:
12277
  ID = Intrinsic::riscv_vluxei_mask;
12278
  PolicyAttrs = 1;
12279
  Ops[2] = Builder.CreateBitCast(Ops[2], ResultType->getPointerTo());
12280
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
12281
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
12282
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
12283
  break;
12284
case RISCVVector::BI__builtin_rvv_vluxseg2ei8_v_tu:
12285
case RISCVVector::BI__builtin_rvv_vluxseg2ei16_v_tu:
12286
case RISCVVector::BI__builtin_rvv_vluxseg2ei32_v_tu:
12287
case RISCVVector::BI__builtin_rvv_vluxseg2ei64_v_tu:
12288
  ID = Intrinsic::riscv_vluxseg2;
12289
  NF = 2;
12290
  PolicyAttrs = 2;
12291
IsMasked = false;
12292
 
12293
    {
12294
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
12295
      SmallVector<llvm::Value*, 12> Operands;
12296
 
12297
      // Please refer to comment under 'defvar NFList' in this file
12298
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
12299
          (!IsMasked && PolicyAttrs & RVV_VTA))
12300
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
12301
      else {
12302
        if (IsMasked)
12303
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
12304
        else // Unmasked
12305
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
12306
      }
12307
      unsigned PtrOperandIdx = IsMasked ?
12308
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
12309
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
12310
      Value *PtrOperand = Ops[PtrOperandIdx];
12311
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
12312
      Value *VLOperand = Ops[PtrOperandIdx + 2];
12313
      Operands.push_back(PtrOperand);
12314
      Operands.push_back(IndexOperand);
12315
      if (IsMasked)
12316
        Operands.push_back(Ops[NF]);
12317
      Operands.push_back(VLOperand);
12318
      if (IsMasked)
12319
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
12320
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
12321
 
12322
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
12323
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
12324
      clang::CharUnits Align =
12325
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
12326
      llvm::Value *V;
12327
      for (unsigned I = 0; I < NF; ++I) {
12328
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
12329
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
12330
      }
12331
      return V;
12332
    }
12333
    break;
12334
case RISCVVector::BI__builtin_rvv_vluxseg2ei8_v_ta:
12335
case RISCVVector::BI__builtin_rvv_vluxseg2ei16_v_ta:
12336
case RISCVVector::BI__builtin_rvv_vluxseg2ei32_v_ta:
12337
case RISCVVector::BI__builtin_rvv_vluxseg2ei64_v_ta:
12338
  ID = Intrinsic::riscv_vluxseg2;
12339
  NF = 2;
12340
  PolicyAttrs = 3;
12341
IsMasked = false;
12342
 
12343
    {
12344
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
12345
      SmallVector<llvm::Value*, 12> Operands;
12346
 
12347
      // Please refer to comment under 'defvar NFList' in this file
12348
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
12349
          (!IsMasked && PolicyAttrs & RVV_VTA))
12350
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
12351
      else {
12352
        if (IsMasked)
12353
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
12354
        else // Unmasked
12355
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
12356
      }
12357
      unsigned PtrOperandIdx = IsMasked ?
12358
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
12359
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
12360
      Value *PtrOperand = Ops[PtrOperandIdx];
12361
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
12362
      Value *VLOperand = Ops[PtrOperandIdx + 2];
12363
      Operands.push_back(PtrOperand);
12364
      Operands.push_back(IndexOperand);
12365
      if (IsMasked)
12366
        Operands.push_back(Ops[NF]);
12367
      Operands.push_back(VLOperand);
12368
      if (IsMasked)
12369
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
12370
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
12371
 
12372
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
12373
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
12374
      clang::CharUnits Align =
12375
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
12376
      llvm::Value *V;
12377
      for (unsigned I = 0; I < NF; ++I) {
12378
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
12379
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
12380
      }
12381
      return V;
12382
    }
12383
    break;
12384
case RISCVVector::BI__builtin_rvv_vluxseg2ei8_v_tum:
12385
case RISCVVector::BI__builtin_rvv_vluxseg2ei16_v_tum:
12386
case RISCVVector::BI__builtin_rvv_vluxseg2ei32_v_tum:
12387
case RISCVVector::BI__builtin_rvv_vluxseg2ei64_v_tum:
12388
  ID = Intrinsic::riscv_vluxseg2_mask;
12389
  NF = 2;
12390
  PolicyAttrs = 2;
12391
IsMasked = true;
12392
 
12393
    {
12394
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
12395
      SmallVector<llvm::Value*, 12> Operands;
12396
 
12397
      // Please refer to comment under 'defvar NFList' in this file
12398
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
12399
          (!IsMasked && PolicyAttrs & RVV_VTA))
12400
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
12401
      else {
12402
        if (IsMasked)
12403
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
12404
        else // Unmasked
12405
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
12406
      }
12407
      unsigned PtrOperandIdx = IsMasked ?
12408
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
12409
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
12410
      Value *PtrOperand = Ops[PtrOperandIdx];
12411
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
12412
      Value *VLOperand = Ops[PtrOperandIdx + 2];
12413
      Operands.push_back(PtrOperand);
12414
      Operands.push_back(IndexOperand);
12415
      if (IsMasked)
12416
        Operands.push_back(Ops[NF]);
12417
      Operands.push_back(VLOperand);
12418
      if (IsMasked)
12419
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
12420
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
12421
 
12422
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
12423
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
12424
      clang::CharUnits Align =
12425
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
12426
      llvm::Value *V;
12427
      for (unsigned I = 0; I < NF; ++I) {
12428
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
12429
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
12430
      }
12431
      return V;
12432
    }
12433
    break;
12434
case RISCVVector::BI__builtin_rvv_vluxseg2ei8_v_tama:
12435
case RISCVVector::BI__builtin_rvv_vluxseg2ei16_v_tama:
12436
case RISCVVector::BI__builtin_rvv_vluxseg2ei32_v_tama:
12437
case RISCVVector::BI__builtin_rvv_vluxseg2ei64_v_tama:
12438
  ID = Intrinsic::riscv_vluxseg2_mask;
12439
  NF = 2;
12440
  PolicyAttrs = 3;
12441
IsMasked = true;
12442
 
12443
    {
12444
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
12445
      SmallVector<llvm::Value*, 12> Operands;
12446
 
12447
      // Please refer to comment under 'defvar NFList' in this file
12448
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
12449
          (!IsMasked && PolicyAttrs & RVV_VTA))
12450
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
12451
      else {
12452
        if (IsMasked)
12453
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
12454
        else // Unmasked
12455
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
12456
      }
12457
      unsigned PtrOperandIdx = IsMasked ?
12458
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
12459
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
12460
      Value *PtrOperand = Ops[PtrOperandIdx];
12461
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
12462
      Value *VLOperand = Ops[PtrOperandIdx + 2];
12463
      Operands.push_back(PtrOperand);
12464
      Operands.push_back(IndexOperand);
12465
      if (IsMasked)
12466
        Operands.push_back(Ops[NF]);
12467
      Operands.push_back(VLOperand);
12468
      if (IsMasked)
12469
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
12470
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
12471
 
12472
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
12473
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
12474
      clang::CharUnits Align =
12475
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
12476
      llvm::Value *V;
12477
      for (unsigned I = 0; I < NF; ++I) {
12478
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
12479
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
12480
      }
12481
      return V;
12482
    }
12483
    break;
12484
case RISCVVector::BI__builtin_rvv_vluxseg2ei8_v_tumu:
12485
case RISCVVector::BI__builtin_rvv_vluxseg2ei16_v_tumu:
12486
case RISCVVector::BI__builtin_rvv_vluxseg2ei32_v_tumu:
12487
case RISCVVector::BI__builtin_rvv_vluxseg2ei64_v_tumu:
12488
  ID = Intrinsic::riscv_vluxseg2_mask;
12489
  NF = 2;
12490
  PolicyAttrs = 0;
12491
IsMasked = true;
12492
 
12493
    {
12494
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
12495
      SmallVector<llvm::Value*, 12> Operands;
12496
 
12497
      // Please refer to comment under 'defvar NFList' in this file
12498
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
12499
          (!IsMasked && PolicyAttrs & RVV_VTA))
12500
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
12501
      else {
12502
        if (IsMasked)
12503
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
12504
        else // Unmasked
12505
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
12506
      }
12507
      unsigned PtrOperandIdx = IsMasked ?
12508
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
12509
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
12510
      Value *PtrOperand = Ops[PtrOperandIdx];
12511
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
12512
      Value *VLOperand = Ops[PtrOperandIdx + 2];
12513
      Operands.push_back(PtrOperand);
12514
      Operands.push_back(IndexOperand);
12515
      if (IsMasked)
12516
        Operands.push_back(Ops[NF]);
12517
      Operands.push_back(VLOperand);
12518
      if (IsMasked)
12519
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
12520
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
12521
 
12522
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
12523
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
12524
      clang::CharUnits Align =
12525
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
12526
      llvm::Value *V;
12527
      for (unsigned I = 0; I < NF; ++I) {
12528
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
12529
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
12530
      }
12531
      return V;
12532
    }
12533
    break;
12534
case RISCVVector::BI__builtin_rvv_vluxseg2ei8_v_mu:
12535
case RISCVVector::BI__builtin_rvv_vluxseg2ei16_v_mu:
12536
case RISCVVector::BI__builtin_rvv_vluxseg2ei32_v_mu:
12537
case RISCVVector::BI__builtin_rvv_vluxseg2ei64_v_mu:
12538
  ID = Intrinsic::riscv_vluxseg2_mask;
12539
  NF = 2;
12540
  PolicyAttrs = 1;
12541
IsMasked = true;
12542
 
12543
    {
12544
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
12545
      SmallVector<llvm::Value*, 12> Operands;
12546
 
12547
      // Please refer to comment under 'defvar NFList' in this file
12548
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
12549
          (!IsMasked && PolicyAttrs & RVV_VTA))
12550
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
12551
      else {
12552
        if (IsMasked)
12553
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
12554
        else // Unmasked
12555
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
12556
      }
12557
      unsigned PtrOperandIdx = IsMasked ?
12558
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
12559
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
12560
      Value *PtrOperand = Ops[PtrOperandIdx];
12561
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
12562
      Value *VLOperand = Ops[PtrOperandIdx + 2];
12563
      Operands.push_back(PtrOperand);
12564
      Operands.push_back(IndexOperand);
12565
      if (IsMasked)
12566
        Operands.push_back(Ops[NF]);
12567
      Operands.push_back(VLOperand);
12568
      if (IsMasked)
12569
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
12570
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
12571
 
12572
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
12573
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
12574
      clang::CharUnits Align =
12575
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
12576
      llvm::Value *V;
12577
      for (unsigned I = 0; I < NF; ++I) {
12578
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
12579
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
12580
      }
12581
      return V;
12582
    }
12583
    break;
12584
case RISCVVector::BI__builtin_rvv_vluxseg3ei8_v_tu:
12585
case RISCVVector::BI__builtin_rvv_vluxseg3ei16_v_tu:
12586
case RISCVVector::BI__builtin_rvv_vluxseg3ei32_v_tu:
12587
case RISCVVector::BI__builtin_rvv_vluxseg3ei64_v_tu:
12588
  ID = Intrinsic::riscv_vluxseg3;
12589
  NF = 3;
12590
  PolicyAttrs = 2;
12591
IsMasked = false;
12592
 
12593
    {
12594
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
12595
      SmallVector<llvm::Value*, 12> Operands;
12596
 
12597
      // Please refer to comment under 'defvar NFList' in this file
12598
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
12599
          (!IsMasked && PolicyAttrs & RVV_VTA))
12600
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
12601
      else {
12602
        if (IsMasked)
12603
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
12604
        else // Unmasked
12605
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
12606
      }
12607
      unsigned PtrOperandIdx = IsMasked ?
12608
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
12609
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
12610
      Value *PtrOperand = Ops[PtrOperandIdx];
12611
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
12612
      Value *VLOperand = Ops[PtrOperandIdx + 2];
12613
      Operands.push_back(PtrOperand);
12614
      Operands.push_back(IndexOperand);
12615
      if (IsMasked)
12616
        Operands.push_back(Ops[NF]);
12617
      Operands.push_back(VLOperand);
12618
      if (IsMasked)
12619
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
12620
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
12621
 
12622
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
12623
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
12624
      clang::CharUnits Align =
12625
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
12626
      llvm::Value *V;
12627
      for (unsigned I = 0; I < NF; ++I) {
12628
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
12629
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
12630
      }
12631
      return V;
12632
    }
12633
    break;
12634
case RISCVVector::BI__builtin_rvv_vluxseg3ei8_v_ta:
12635
case RISCVVector::BI__builtin_rvv_vluxseg3ei16_v_ta:
12636
case RISCVVector::BI__builtin_rvv_vluxseg3ei32_v_ta:
12637
case RISCVVector::BI__builtin_rvv_vluxseg3ei64_v_ta:
12638
  ID = Intrinsic::riscv_vluxseg3;
12639
  NF = 3;
12640
  PolicyAttrs = 3;
12641
IsMasked = false;
12642
 
12643
    {
12644
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
12645
      SmallVector<llvm::Value*, 12> Operands;
12646
 
12647
      // Please refer to comment under 'defvar NFList' in this file
12648
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
12649
          (!IsMasked && PolicyAttrs & RVV_VTA))
12650
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
12651
      else {
12652
        if (IsMasked)
12653
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
12654
        else // Unmasked
12655
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
12656
      }
12657
      unsigned PtrOperandIdx = IsMasked ?
12658
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
12659
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
12660
      Value *PtrOperand = Ops[PtrOperandIdx];
12661
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
12662
      Value *VLOperand = Ops[PtrOperandIdx + 2];
12663
      Operands.push_back(PtrOperand);
12664
      Operands.push_back(IndexOperand);
12665
      if (IsMasked)
12666
        Operands.push_back(Ops[NF]);
12667
      Operands.push_back(VLOperand);
12668
      if (IsMasked)
12669
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
12670
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
12671
 
12672
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
12673
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
12674
      clang::CharUnits Align =
12675
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
12676
      llvm::Value *V;
12677
      for (unsigned I = 0; I < NF; ++I) {
12678
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
12679
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
12680
      }
12681
      return V;
12682
    }
12683
    break;
12684
case RISCVVector::BI__builtin_rvv_vluxseg3ei8_v_tum:
12685
case RISCVVector::BI__builtin_rvv_vluxseg3ei16_v_tum:
12686
case RISCVVector::BI__builtin_rvv_vluxseg3ei32_v_tum:
12687
case RISCVVector::BI__builtin_rvv_vluxseg3ei64_v_tum:
12688
  ID = Intrinsic::riscv_vluxseg3_mask;
12689
  NF = 3;
12690
  PolicyAttrs = 2;
12691
IsMasked = true;
12692
 
12693
    {
12694
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
12695
      SmallVector<llvm::Value*, 12> Operands;
12696
 
12697
      // Please refer to comment under 'defvar NFList' in this file
12698
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
12699
          (!IsMasked && PolicyAttrs & RVV_VTA))
12700
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
12701
      else {
12702
        if (IsMasked)
12703
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
12704
        else // Unmasked
12705
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
12706
      }
12707
      unsigned PtrOperandIdx = IsMasked ?
12708
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
12709
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
12710
      Value *PtrOperand = Ops[PtrOperandIdx];
12711
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
12712
      Value *VLOperand = Ops[PtrOperandIdx + 2];
12713
      Operands.push_back(PtrOperand);
12714
      Operands.push_back(IndexOperand);
12715
      if (IsMasked)
12716
        Operands.push_back(Ops[NF]);
12717
      Operands.push_back(VLOperand);
12718
      if (IsMasked)
12719
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
12720
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
12721
 
12722
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
12723
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
12724
      clang::CharUnits Align =
12725
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
12726
      llvm::Value *V;
12727
      for (unsigned I = 0; I < NF; ++I) {
12728
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
12729
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
12730
      }
12731
      return V;
12732
    }
12733
    break;
12734
case RISCVVector::BI__builtin_rvv_vluxseg3ei8_v_tama:
12735
case RISCVVector::BI__builtin_rvv_vluxseg3ei16_v_tama:
12736
case RISCVVector::BI__builtin_rvv_vluxseg3ei32_v_tama:
12737
case RISCVVector::BI__builtin_rvv_vluxseg3ei64_v_tama:
12738
  ID = Intrinsic::riscv_vluxseg3_mask;
12739
  NF = 3;
12740
  PolicyAttrs = 3;
12741
IsMasked = true;
12742
 
12743
    {
12744
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
12745
      SmallVector<llvm::Value*, 12> Operands;
12746
 
12747
      // Please refer to comment under 'defvar NFList' in this file
12748
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
12749
          (!IsMasked && PolicyAttrs & RVV_VTA))
12750
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
12751
      else {
12752
        if (IsMasked)
12753
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
12754
        else // Unmasked
12755
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
12756
      }
12757
      unsigned PtrOperandIdx = IsMasked ?
12758
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
12759
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
12760
      Value *PtrOperand = Ops[PtrOperandIdx];
12761
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
12762
      Value *VLOperand = Ops[PtrOperandIdx + 2];
12763
      Operands.push_back(PtrOperand);
12764
      Operands.push_back(IndexOperand);
12765
      if (IsMasked)
12766
        Operands.push_back(Ops[NF]);
12767
      Operands.push_back(VLOperand);
12768
      if (IsMasked)
12769
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
12770
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
12771
 
12772
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
12773
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
12774
      clang::CharUnits Align =
12775
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
12776
      llvm::Value *V;
12777
      for (unsigned I = 0; I < NF; ++I) {
12778
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
12779
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
12780
      }
12781
      return V;
12782
    }
12783
    break;
12784
case RISCVVector::BI__builtin_rvv_vluxseg3ei8_v_tumu:
12785
case RISCVVector::BI__builtin_rvv_vluxseg3ei16_v_tumu:
12786
case RISCVVector::BI__builtin_rvv_vluxseg3ei32_v_tumu:
12787
case RISCVVector::BI__builtin_rvv_vluxseg3ei64_v_tumu:
12788
  ID = Intrinsic::riscv_vluxseg3_mask;
12789
  NF = 3;
12790
  PolicyAttrs = 0;
12791
IsMasked = true;
12792
 
12793
    {
12794
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
12795
      SmallVector<llvm::Value*, 12> Operands;
12796
 
12797
      // Please refer to comment under 'defvar NFList' in this file
12798
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
12799
          (!IsMasked && PolicyAttrs & RVV_VTA))
12800
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
12801
      else {
12802
        if (IsMasked)
12803
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
12804
        else // Unmasked
12805
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
12806
      }
12807
      unsigned PtrOperandIdx = IsMasked ?
12808
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
12809
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
12810
      Value *PtrOperand = Ops[PtrOperandIdx];
12811
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
12812
      Value *VLOperand = Ops[PtrOperandIdx + 2];
12813
      Operands.push_back(PtrOperand);
12814
      Operands.push_back(IndexOperand);
12815
      if (IsMasked)
12816
        Operands.push_back(Ops[NF]);
12817
      Operands.push_back(VLOperand);
12818
      if (IsMasked)
12819
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
12820
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
12821
 
12822
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
12823
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
12824
      clang::CharUnits Align =
12825
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
12826
      llvm::Value *V;
12827
      for (unsigned I = 0; I < NF; ++I) {
12828
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
12829
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
12830
      }
12831
      return V;
12832
    }
12833
    break;
12834
case RISCVVector::BI__builtin_rvv_vluxseg3ei8_v_mu:
12835
case RISCVVector::BI__builtin_rvv_vluxseg3ei16_v_mu:
12836
case RISCVVector::BI__builtin_rvv_vluxseg3ei32_v_mu:
12837
case RISCVVector::BI__builtin_rvv_vluxseg3ei64_v_mu:
12838
  ID = Intrinsic::riscv_vluxseg3_mask;
12839
  NF = 3;
12840
  PolicyAttrs = 1;
12841
IsMasked = true;
12842
 
12843
    {
12844
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
12845
      SmallVector<llvm::Value*, 12> Operands;
12846
 
12847
      // Please refer to comment under 'defvar NFList' in this file
12848
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
12849
          (!IsMasked && PolicyAttrs & RVV_VTA))
12850
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
12851
      else {
12852
        if (IsMasked)
12853
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
12854
        else // Unmasked
12855
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
12856
      }
12857
      unsigned PtrOperandIdx = IsMasked ?
12858
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
12859
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
12860
      Value *PtrOperand = Ops[PtrOperandIdx];
12861
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
12862
      Value *VLOperand = Ops[PtrOperandIdx + 2];
12863
      Operands.push_back(PtrOperand);
12864
      Operands.push_back(IndexOperand);
12865
      if (IsMasked)
12866
        Operands.push_back(Ops[NF]);
12867
      Operands.push_back(VLOperand);
12868
      if (IsMasked)
12869
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
12870
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
12871
 
12872
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
12873
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
12874
      clang::CharUnits Align =
12875
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
12876
      llvm::Value *V;
12877
      for (unsigned I = 0; I < NF; ++I) {
12878
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
12879
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
12880
      }
12881
      return V;
12882
    }
12883
    break;
12884
case RISCVVector::BI__builtin_rvv_vluxseg4ei8_v_tu:
12885
case RISCVVector::BI__builtin_rvv_vluxseg4ei16_v_tu:
12886
case RISCVVector::BI__builtin_rvv_vluxseg4ei32_v_tu:
12887
case RISCVVector::BI__builtin_rvv_vluxseg4ei64_v_tu:
12888
  ID = Intrinsic::riscv_vluxseg4;
12889
  NF = 4;
12890
  PolicyAttrs = 2;
12891
IsMasked = false;
12892
 
12893
    {
12894
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
12895
      SmallVector<llvm::Value*, 12> Operands;
12896
 
12897
      // Please refer to comment under 'defvar NFList' in this file
12898
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
12899
          (!IsMasked && PolicyAttrs & RVV_VTA))
12900
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
12901
      else {
12902
        if (IsMasked)
12903
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
12904
        else // Unmasked
12905
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
12906
      }
12907
      unsigned PtrOperandIdx = IsMasked ?
12908
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
12909
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
12910
      Value *PtrOperand = Ops[PtrOperandIdx];
12911
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
12912
      Value *VLOperand = Ops[PtrOperandIdx + 2];
12913
      Operands.push_back(PtrOperand);
12914
      Operands.push_back(IndexOperand);
12915
      if (IsMasked)
12916
        Operands.push_back(Ops[NF]);
12917
      Operands.push_back(VLOperand);
12918
      if (IsMasked)
12919
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
12920
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
12921
 
12922
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
12923
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
12924
      clang::CharUnits Align =
12925
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
12926
      llvm::Value *V;
12927
      for (unsigned I = 0; I < NF; ++I) {
12928
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
12929
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
12930
      }
12931
      return V;
12932
    }
12933
    break;
12934
case RISCVVector::BI__builtin_rvv_vluxseg4ei8_v_ta:
12935
case RISCVVector::BI__builtin_rvv_vluxseg4ei16_v_ta:
12936
case RISCVVector::BI__builtin_rvv_vluxseg4ei32_v_ta:
12937
case RISCVVector::BI__builtin_rvv_vluxseg4ei64_v_ta:
12938
  ID = Intrinsic::riscv_vluxseg4;
12939
  NF = 4;
12940
  PolicyAttrs = 3;
12941
IsMasked = false;
12942
 
12943
    {
12944
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
12945
      SmallVector<llvm::Value*, 12> Operands;
12946
 
12947
      // Please refer to comment under 'defvar NFList' in this file
12948
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
12949
          (!IsMasked && PolicyAttrs & RVV_VTA))
12950
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
12951
      else {
12952
        if (IsMasked)
12953
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
12954
        else // Unmasked
12955
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
12956
      }
12957
      unsigned PtrOperandIdx = IsMasked ?
12958
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
12959
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
12960
      Value *PtrOperand = Ops[PtrOperandIdx];
12961
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
12962
      Value *VLOperand = Ops[PtrOperandIdx + 2];
12963
      Operands.push_back(PtrOperand);
12964
      Operands.push_back(IndexOperand);
12965
      if (IsMasked)
12966
        Operands.push_back(Ops[NF]);
12967
      Operands.push_back(VLOperand);
12968
      if (IsMasked)
12969
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
12970
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
12971
 
12972
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
12973
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
12974
      clang::CharUnits Align =
12975
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
12976
      llvm::Value *V;
12977
      for (unsigned I = 0; I < NF; ++I) {
12978
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
12979
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
12980
      }
12981
      return V;
12982
    }
12983
    break;
12984
case RISCVVector::BI__builtin_rvv_vluxseg4ei8_v_tum:
12985
case RISCVVector::BI__builtin_rvv_vluxseg4ei16_v_tum:
12986
case RISCVVector::BI__builtin_rvv_vluxseg4ei32_v_tum:
12987
case RISCVVector::BI__builtin_rvv_vluxseg4ei64_v_tum:
12988
  ID = Intrinsic::riscv_vluxseg4_mask;
12989
  NF = 4;
12990
  PolicyAttrs = 2;
12991
IsMasked = true;
12992
 
12993
    {
12994
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
12995
      SmallVector<llvm::Value*, 12> Operands;
12996
 
12997
      // Please refer to comment under 'defvar NFList' in this file
12998
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
12999
          (!IsMasked && PolicyAttrs & RVV_VTA))
13000
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
13001
      else {
13002
        if (IsMasked)
13003
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
13004
        else // Unmasked
13005
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
13006
      }
13007
      unsigned PtrOperandIdx = IsMasked ?
13008
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
13009
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
13010
      Value *PtrOperand = Ops[PtrOperandIdx];
13011
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
13012
      Value *VLOperand = Ops[PtrOperandIdx + 2];
13013
      Operands.push_back(PtrOperand);
13014
      Operands.push_back(IndexOperand);
13015
      if (IsMasked)
13016
        Operands.push_back(Ops[NF]);
13017
      Operands.push_back(VLOperand);
13018
      if (IsMasked)
13019
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
13020
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
13021
 
13022
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
13023
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
13024
      clang::CharUnits Align =
13025
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
13026
      llvm::Value *V;
13027
      for (unsigned I = 0; I < NF; ++I) {
13028
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
13029
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
13030
      }
13031
      return V;
13032
    }
13033
    break;
13034
case RISCVVector::BI__builtin_rvv_vluxseg4ei8_v_tama:
13035
case RISCVVector::BI__builtin_rvv_vluxseg4ei16_v_tama:
13036
case RISCVVector::BI__builtin_rvv_vluxseg4ei32_v_tama:
13037
case RISCVVector::BI__builtin_rvv_vluxseg4ei64_v_tama:
13038
  ID = Intrinsic::riscv_vluxseg4_mask;
13039
  NF = 4;
13040
  PolicyAttrs = 3;
13041
IsMasked = true;
13042
 
13043
    {
13044
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
13045
      SmallVector<llvm::Value*, 12> Operands;
13046
 
13047
      // Please refer to comment under 'defvar NFList' in this file
13048
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
13049
          (!IsMasked && PolicyAttrs & RVV_VTA))
13050
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
13051
      else {
13052
        if (IsMasked)
13053
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
13054
        else // Unmasked
13055
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
13056
      }
13057
      unsigned PtrOperandIdx = IsMasked ?
13058
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
13059
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
13060
      Value *PtrOperand = Ops[PtrOperandIdx];
13061
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
13062
      Value *VLOperand = Ops[PtrOperandIdx + 2];
13063
      Operands.push_back(PtrOperand);
13064
      Operands.push_back(IndexOperand);
13065
      if (IsMasked)
13066
        Operands.push_back(Ops[NF]);
13067
      Operands.push_back(VLOperand);
13068
      if (IsMasked)
13069
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
13070
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
13071
 
13072
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
13073
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
13074
      clang::CharUnits Align =
13075
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
13076
      llvm::Value *V;
13077
      for (unsigned I = 0; I < NF; ++I) {
13078
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
13079
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
13080
      }
13081
      return V;
13082
    }
13083
    break;
13084
case RISCVVector::BI__builtin_rvv_vluxseg4ei8_v_tumu:
13085
case RISCVVector::BI__builtin_rvv_vluxseg4ei16_v_tumu:
13086
case RISCVVector::BI__builtin_rvv_vluxseg4ei32_v_tumu:
13087
case RISCVVector::BI__builtin_rvv_vluxseg4ei64_v_tumu:
13088
  ID = Intrinsic::riscv_vluxseg4_mask;
13089
  NF = 4;
13090
  PolicyAttrs = 0;
13091
IsMasked = true;
13092
 
13093
    {
13094
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
13095
      SmallVector<llvm::Value*, 12> Operands;
13096
 
13097
      // Please refer to comment under 'defvar NFList' in this file
13098
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
13099
          (!IsMasked && PolicyAttrs & RVV_VTA))
13100
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
13101
      else {
13102
        if (IsMasked)
13103
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
13104
        else // Unmasked
13105
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
13106
      }
13107
      unsigned PtrOperandIdx = IsMasked ?
13108
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
13109
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
13110
      Value *PtrOperand = Ops[PtrOperandIdx];
13111
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
13112
      Value *VLOperand = Ops[PtrOperandIdx + 2];
13113
      Operands.push_back(PtrOperand);
13114
      Operands.push_back(IndexOperand);
13115
      if (IsMasked)
13116
        Operands.push_back(Ops[NF]);
13117
      Operands.push_back(VLOperand);
13118
      if (IsMasked)
13119
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
13120
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
13121
 
13122
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
13123
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
13124
      clang::CharUnits Align =
13125
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
13126
      llvm::Value *V;
13127
      for (unsigned I = 0; I < NF; ++I) {
13128
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
13129
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
13130
      }
13131
      return V;
13132
    }
13133
    break;
13134
case RISCVVector::BI__builtin_rvv_vluxseg4ei8_v_mu:
13135
case RISCVVector::BI__builtin_rvv_vluxseg4ei16_v_mu:
13136
case RISCVVector::BI__builtin_rvv_vluxseg4ei32_v_mu:
13137
case RISCVVector::BI__builtin_rvv_vluxseg4ei64_v_mu:
13138
  ID = Intrinsic::riscv_vluxseg4_mask;
13139
  NF = 4;
13140
  PolicyAttrs = 1;
13141
IsMasked = true;
13142
 
13143
    {
13144
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
13145
      SmallVector<llvm::Value*, 12> Operands;
13146
 
13147
      // Please refer to comment under 'defvar NFList' in this file
13148
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
13149
          (!IsMasked && PolicyAttrs & RVV_VTA))
13150
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
13151
      else {
13152
        if (IsMasked)
13153
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
13154
        else // Unmasked
13155
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
13156
      }
13157
      unsigned PtrOperandIdx = IsMasked ?
13158
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
13159
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
13160
      Value *PtrOperand = Ops[PtrOperandIdx];
13161
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
13162
      Value *VLOperand = Ops[PtrOperandIdx + 2];
13163
      Operands.push_back(PtrOperand);
13164
      Operands.push_back(IndexOperand);
13165
      if (IsMasked)
13166
        Operands.push_back(Ops[NF]);
13167
      Operands.push_back(VLOperand);
13168
      if (IsMasked)
13169
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
13170
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
13171
 
13172
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
13173
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
13174
      clang::CharUnits Align =
13175
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
13176
      llvm::Value *V;
13177
      for (unsigned I = 0; I < NF; ++I) {
13178
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
13179
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
13180
      }
13181
      return V;
13182
    }
13183
    break;
13184
case RISCVVector::BI__builtin_rvv_vluxseg5ei8_v_tu:
13185
case RISCVVector::BI__builtin_rvv_vluxseg5ei16_v_tu:
13186
case RISCVVector::BI__builtin_rvv_vluxseg5ei32_v_tu:
13187
case RISCVVector::BI__builtin_rvv_vluxseg5ei64_v_tu:
13188
  ID = Intrinsic::riscv_vluxseg5;
13189
  NF = 5;
13190
  PolicyAttrs = 2;
13191
IsMasked = false;
13192
 
13193
    {
13194
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
13195
      SmallVector<llvm::Value*, 12> Operands;
13196
 
13197
      // Please refer to comment under 'defvar NFList' in this file
13198
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
13199
          (!IsMasked && PolicyAttrs & RVV_VTA))
13200
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
13201
      else {
13202
        if (IsMasked)
13203
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
13204
        else // Unmasked
13205
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
13206
      }
13207
      unsigned PtrOperandIdx = IsMasked ?
13208
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
13209
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
13210
      Value *PtrOperand = Ops[PtrOperandIdx];
13211
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
13212
      Value *VLOperand = Ops[PtrOperandIdx + 2];
13213
      Operands.push_back(PtrOperand);
13214
      Operands.push_back(IndexOperand);
13215
      if (IsMasked)
13216
        Operands.push_back(Ops[NF]);
13217
      Operands.push_back(VLOperand);
13218
      if (IsMasked)
13219
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
13220
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
13221
 
13222
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
13223
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
13224
      clang::CharUnits Align =
13225
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
13226
      llvm::Value *V;
13227
      for (unsigned I = 0; I < NF; ++I) {
13228
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
13229
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
13230
      }
13231
      return V;
13232
    }
13233
    break;
13234
case RISCVVector::BI__builtin_rvv_vluxseg5ei8_v_ta:
13235
case RISCVVector::BI__builtin_rvv_vluxseg5ei16_v_ta:
13236
case RISCVVector::BI__builtin_rvv_vluxseg5ei32_v_ta:
13237
case RISCVVector::BI__builtin_rvv_vluxseg5ei64_v_ta:
13238
  ID = Intrinsic::riscv_vluxseg5;
13239
  NF = 5;
13240
  PolicyAttrs = 3;
13241
IsMasked = false;
13242
 
13243
    {
13244
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
13245
      SmallVector<llvm::Value*, 12> Operands;
13246
 
13247
      // Please refer to comment under 'defvar NFList' in this file
13248
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
13249
          (!IsMasked && PolicyAttrs & RVV_VTA))
13250
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
13251
      else {
13252
        if (IsMasked)
13253
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
13254
        else // Unmasked
13255
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
13256
      }
13257
      unsigned PtrOperandIdx = IsMasked ?
13258
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
13259
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
13260
      Value *PtrOperand = Ops[PtrOperandIdx];
13261
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
13262
      Value *VLOperand = Ops[PtrOperandIdx + 2];
13263
      Operands.push_back(PtrOperand);
13264
      Operands.push_back(IndexOperand);
13265
      if (IsMasked)
13266
        Operands.push_back(Ops[NF]);
13267
      Operands.push_back(VLOperand);
13268
      if (IsMasked)
13269
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
13270
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
13271
 
13272
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
13273
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
13274
      clang::CharUnits Align =
13275
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
13276
      llvm::Value *V;
13277
      for (unsigned I = 0; I < NF; ++I) {
13278
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
13279
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
13280
      }
13281
      return V;
13282
    }
13283
    break;
13284
case RISCVVector::BI__builtin_rvv_vluxseg5ei8_v_tum:
13285
case RISCVVector::BI__builtin_rvv_vluxseg5ei16_v_tum:
13286
case RISCVVector::BI__builtin_rvv_vluxseg5ei32_v_tum:
13287
case RISCVVector::BI__builtin_rvv_vluxseg5ei64_v_tum:
13288
  ID = Intrinsic::riscv_vluxseg5_mask;
13289
  NF = 5;
13290
  PolicyAttrs = 2;
13291
IsMasked = true;
13292
 
13293
    {
13294
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
13295
      SmallVector<llvm::Value*, 12> Operands;
13296
 
13297
      // Please refer to comment under 'defvar NFList' in this file
13298
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
13299
          (!IsMasked && PolicyAttrs & RVV_VTA))
13300
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
13301
      else {
13302
        if (IsMasked)
13303
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
13304
        else // Unmasked
13305
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
13306
      }
13307
      unsigned PtrOperandIdx = IsMasked ?
13308
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
13309
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
13310
      Value *PtrOperand = Ops[PtrOperandIdx];
13311
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
13312
      Value *VLOperand = Ops[PtrOperandIdx + 2];
13313
      Operands.push_back(PtrOperand);
13314
      Operands.push_back(IndexOperand);
13315
      if (IsMasked)
13316
        Operands.push_back(Ops[NF]);
13317
      Operands.push_back(VLOperand);
13318
      if (IsMasked)
13319
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
13320
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
13321
 
13322
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
13323
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
13324
      clang::CharUnits Align =
13325
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
13326
      llvm::Value *V;
13327
      for (unsigned I = 0; I < NF; ++I) {
13328
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
13329
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
13330
      }
13331
      return V;
13332
    }
13333
    break;
13334
case RISCVVector::BI__builtin_rvv_vluxseg5ei8_v_tama:
13335
case RISCVVector::BI__builtin_rvv_vluxseg5ei16_v_tama:
13336
case RISCVVector::BI__builtin_rvv_vluxseg5ei32_v_tama:
13337
case RISCVVector::BI__builtin_rvv_vluxseg5ei64_v_tama:
13338
  ID = Intrinsic::riscv_vluxseg5_mask;
13339
  NF = 5;
13340
  PolicyAttrs = 3;
13341
IsMasked = true;
13342
 
13343
    {
13344
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
13345
      SmallVector<llvm::Value*, 12> Operands;
13346
 
13347
      // Please refer to comment under 'defvar NFList' in this file
13348
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
13349
          (!IsMasked && PolicyAttrs & RVV_VTA))
13350
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
13351
      else {
13352
        if (IsMasked)
13353
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
13354
        else // Unmasked
13355
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
13356
      }
13357
      unsigned PtrOperandIdx = IsMasked ?
13358
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
13359
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
13360
      Value *PtrOperand = Ops[PtrOperandIdx];
13361
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
13362
      Value *VLOperand = Ops[PtrOperandIdx + 2];
13363
      Operands.push_back(PtrOperand);
13364
      Operands.push_back(IndexOperand);
13365
      if (IsMasked)
13366
        Operands.push_back(Ops[NF]);
13367
      Operands.push_back(VLOperand);
13368
      if (IsMasked)
13369
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
13370
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
13371
 
13372
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
13373
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
13374
      clang::CharUnits Align =
13375
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
13376
      llvm::Value *V;
13377
      for (unsigned I = 0; I < NF; ++I) {
13378
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
13379
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
13380
      }
13381
      return V;
13382
    }
13383
    break;
13384
case RISCVVector::BI__builtin_rvv_vluxseg5ei8_v_tumu:
13385
case RISCVVector::BI__builtin_rvv_vluxseg5ei16_v_tumu:
13386
case RISCVVector::BI__builtin_rvv_vluxseg5ei32_v_tumu:
13387
case RISCVVector::BI__builtin_rvv_vluxseg5ei64_v_tumu:
13388
  ID = Intrinsic::riscv_vluxseg5_mask;
13389
  NF = 5;
13390
  PolicyAttrs = 0;
13391
IsMasked = true;
13392
 
13393
    {
13394
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
13395
      SmallVector<llvm::Value*, 12> Operands;
13396
 
13397
      // Please refer to comment under 'defvar NFList' in this file
13398
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
13399
          (!IsMasked && PolicyAttrs & RVV_VTA))
13400
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
13401
      else {
13402
        if (IsMasked)
13403
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
13404
        else // Unmasked
13405
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
13406
      }
13407
      unsigned PtrOperandIdx = IsMasked ?
13408
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
13409
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
13410
      Value *PtrOperand = Ops[PtrOperandIdx];
13411
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
13412
      Value *VLOperand = Ops[PtrOperandIdx + 2];
13413
      Operands.push_back(PtrOperand);
13414
      Operands.push_back(IndexOperand);
13415
      if (IsMasked)
13416
        Operands.push_back(Ops[NF]);
13417
      Operands.push_back(VLOperand);
13418
      if (IsMasked)
13419
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
13420
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
13421
 
13422
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
13423
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
13424
      clang::CharUnits Align =
13425
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
13426
      llvm::Value *V;
13427
      for (unsigned I = 0; I < NF; ++I) {
13428
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
13429
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
13430
      }
13431
      return V;
13432
    }
13433
    break;
13434
case RISCVVector::BI__builtin_rvv_vluxseg5ei8_v_mu:
13435
case RISCVVector::BI__builtin_rvv_vluxseg5ei16_v_mu:
13436
case RISCVVector::BI__builtin_rvv_vluxseg5ei32_v_mu:
13437
case RISCVVector::BI__builtin_rvv_vluxseg5ei64_v_mu:
13438
  ID = Intrinsic::riscv_vluxseg5_mask;
13439
  NF = 5;
13440
  PolicyAttrs = 1;
13441
IsMasked = true;
13442
 
13443
    {
13444
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
13445
      SmallVector<llvm::Value*, 12> Operands;
13446
 
13447
      // Please refer to comment under 'defvar NFList' in this file
13448
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
13449
          (!IsMasked && PolicyAttrs & RVV_VTA))
13450
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
13451
      else {
13452
        if (IsMasked)
13453
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
13454
        else // Unmasked
13455
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
13456
      }
13457
      unsigned PtrOperandIdx = IsMasked ?
13458
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
13459
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
13460
      Value *PtrOperand = Ops[PtrOperandIdx];
13461
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
13462
      Value *VLOperand = Ops[PtrOperandIdx + 2];
13463
      Operands.push_back(PtrOperand);
13464
      Operands.push_back(IndexOperand);
13465
      if (IsMasked)
13466
        Operands.push_back(Ops[NF]);
13467
      Operands.push_back(VLOperand);
13468
      if (IsMasked)
13469
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
13470
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
13471
 
13472
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
13473
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
13474
      clang::CharUnits Align =
13475
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
13476
      llvm::Value *V;
13477
      for (unsigned I = 0; I < NF; ++I) {
13478
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
13479
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
13480
      }
13481
      return V;
13482
    }
13483
    break;
13484
case RISCVVector::BI__builtin_rvv_vluxseg6ei8_v_tu:
13485
case RISCVVector::BI__builtin_rvv_vluxseg6ei16_v_tu:
13486
case RISCVVector::BI__builtin_rvv_vluxseg6ei32_v_tu:
13487
case RISCVVector::BI__builtin_rvv_vluxseg6ei64_v_tu:
13488
  ID = Intrinsic::riscv_vluxseg6;
13489
  NF = 6;
13490
  PolicyAttrs = 2;
13491
IsMasked = false;
13492
 
13493
    {
13494
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
13495
      SmallVector<llvm::Value*, 12> Operands;
13496
 
13497
      // Please refer to comment under 'defvar NFList' in this file
13498
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
13499
          (!IsMasked && PolicyAttrs & RVV_VTA))
13500
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
13501
      else {
13502
        if (IsMasked)
13503
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
13504
        else // Unmasked
13505
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
13506
      }
13507
      unsigned PtrOperandIdx = IsMasked ?
13508
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
13509
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
13510
      Value *PtrOperand = Ops[PtrOperandIdx];
13511
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
13512
      Value *VLOperand = Ops[PtrOperandIdx + 2];
13513
      Operands.push_back(PtrOperand);
13514
      Operands.push_back(IndexOperand);
13515
      if (IsMasked)
13516
        Operands.push_back(Ops[NF]);
13517
      Operands.push_back(VLOperand);
13518
      if (IsMasked)
13519
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
13520
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
13521
 
13522
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
13523
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
13524
      clang::CharUnits Align =
13525
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
13526
      llvm::Value *V;
13527
      for (unsigned I = 0; I < NF; ++I) {
13528
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
13529
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
13530
      }
13531
      return V;
13532
    }
13533
    break;
13534
case RISCVVector::BI__builtin_rvv_vluxseg6ei8_v_ta:
13535
case RISCVVector::BI__builtin_rvv_vluxseg6ei16_v_ta:
13536
case RISCVVector::BI__builtin_rvv_vluxseg6ei32_v_ta:
13537
case RISCVVector::BI__builtin_rvv_vluxseg6ei64_v_ta:
13538
  ID = Intrinsic::riscv_vluxseg6;
13539
  NF = 6;
13540
  PolicyAttrs = 3;
13541
IsMasked = false;
13542
 
13543
    {
13544
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
13545
      SmallVector<llvm::Value*, 12> Operands;
13546
 
13547
      // Please refer to comment under 'defvar NFList' in this file
13548
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
13549
          (!IsMasked && PolicyAttrs & RVV_VTA))
13550
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
13551
      else {
13552
        if (IsMasked)
13553
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
13554
        else // Unmasked
13555
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
13556
      }
13557
      unsigned PtrOperandIdx = IsMasked ?
13558
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
13559
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
13560
      Value *PtrOperand = Ops[PtrOperandIdx];
13561
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
13562
      Value *VLOperand = Ops[PtrOperandIdx + 2];
13563
      Operands.push_back(PtrOperand);
13564
      Operands.push_back(IndexOperand);
13565
      if (IsMasked)
13566
        Operands.push_back(Ops[NF]);
13567
      Operands.push_back(VLOperand);
13568
      if (IsMasked)
13569
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
13570
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
13571
 
13572
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
13573
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
13574
      clang::CharUnits Align =
13575
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
13576
      llvm::Value *V;
13577
      for (unsigned I = 0; I < NF; ++I) {
13578
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
13579
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
13580
      }
13581
      return V;
13582
    }
13583
    break;
13584
case RISCVVector::BI__builtin_rvv_vluxseg6ei8_v_tum:
13585
case RISCVVector::BI__builtin_rvv_vluxseg6ei16_v_tum:
13586
case RISCVVector::BI__builtin_rvv_vluxseg6ei32_v_tum:
13587
case RISCVVector::BI__builtin_rvv_vluxseg6ei64_v_tum:
13588
  ID = Intrinsic::riscv_vluxseg6_mask;
13589
  NF = 6;
13590
  PolicyAttrs = 2;
13591
IsMasked = true;
13592
 
13593
    {
13594
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
13595
      SmallVector<llvm::Value*, 12> Operands;
13596
 
13597
      // Please refer to comment under 'defvar NFList' in this file
13598
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
13599
          (!IsMasked && PolicyAttrs & RVV_VTA))
13600
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
13601
      else {
13602
        if (IsMasked)
13603
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
13604
        else // Unmasked
13605
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
13606
      }
13607
      unsigned PtrOperandIdx = IsMasked ?
13608
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
13609
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
13610
      Value *PtrOperand = Ops[PtrOperandIdx];
13611
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
13612
      Value *VLOperand = Ops[PtrOperandIdx + 2];
13613
      Operands.push_back(PtrOperand);
13614
      Operands.push_back(IndexOperand);
13615
      if (IsMasked)
13616
        Operands.push_back(Ops[NF]);
13617
      Operands.push_back(VLOperand);
13618
      if (IsMasked)
13619
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
13620
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
13621
 
13622
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
13623
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
13624
      clang::CharUnits Align =
13625
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
13626
      llvm::Value *V;
13627
      for (unsigned I = 0; I < NF; ++I) {
13628
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
13629
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
13630
      }
13631
      return V;
13632
    }
13633
    break;
13634
case RISCVVector::BI__builtin_rvv_vluxseg6ei8_v_tama:
13635
case RISCVVector::BI__builtin_rvv_vluxseg6ei16_v_tama:
13636
case RISCVVector::BI__builtin_rvv_vluxseg6ei32_v_tama:
13637
case RISCVVector::BI__builtin_rvv_vluxseg6ei64_v_tama:
13638
  ID = Intrinsic::riscv_vluxseg6_mask;
13639
  NF = 6;
13640
  PolicyAttrs = 3;
13641
IsMasked = true;
13642
 
13643
    {
13644
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
13645
      SmallVector<llvm::Value*, 12> Operands;
13646
 
13647
      // Please refer to comment under 'defvar NFList' in this file
13648
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
13649
          (!IsMasked && PolicyAttrs & RVV_VTA))
13650
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
13651
      else {
13652
        if (IsMasked)
13653
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
13654
        else // Unmasked
13655
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
13656
      }
13657
      unsigned PtrOperandIdx = IsMasked ?
13658
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
13659
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
13660
      Value *PtrOperand = Ops[PtrOperandIdx];
13661
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
13662
      Value *VLOperand = Ops[PtrOperandIdx + 2];
13663
      Operands.push_back(PtrOperand);
13664
      Operands.push_back(IndexOperand);
13665
      if (IsMasked)
13666
        Operands.push_back(Ops[NF]);
13667
      Operands.push_back(VLOperand);
13668
      if (IsMasked)
13669
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
13670
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
13671
 
13672
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
13673
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
13674
      clang::CharUnits Align =
13675
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
13676
      llvm::Value *V;
13677
      for (unsigned I = 0; I < NF; ++I) {
13678
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
13679
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
13680
      }
13681
      return V;
13682
    }
13683
    break;
13684
case RISCVVector::BI__builtin_rvv_vluxseg6ei8_v_tumu:
13685
case RISCVVector::BI__builtin_rvv_vluxseg6ei16_v_tumu:
13686
case RISCVVector::BI__builtin_rvv_vluxseg6ei32_v_tumu:
13687
case RISCVVector::BI__builtin_rvv_vluxseg6ei64_v_tumu:
13688
  ID = Intrinsic::riscv_vluxseg6_mask;
13689
  NF = 6;
13690
  PolicyAttrs = 0;
13691
IsMasked = true;
13692
 
13693
    {
13694
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
13695
      SmallVector<llvm::Value*, 12> Operands;
13696
 
13697
      // Please refer to comment under 'defvar NFList' in this file
13698
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
13699
          (!IsMasked && PolicyAttrs & RVV_VTA))
13700
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
13701
      else {
13702
        if (IsMasked)
13703
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
13704
        else // Unmasked
13705
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
13706
      }
13707
      unsigned PtrOperandIdx = IsMasked ?
13708
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
13709
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
13710
      Value *PtrOperand = Ops[PtrOperandIdx];
13711
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
13712
      Value *VLOperand = Ops[PtrOperandIdx + 2];
13713
      Operands.push_back(PtrOperand);
13714
      Operands.push_back(IndexOperand);
13715
      if (IsMasked)
13716
        Operands.push_back(Ops[NF]);
13717
      Operands.push_back(VLOperand);
13718
      if (IsMasked)
13719
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
13720
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
13721
 
13722
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
13723
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
13724
      clang::CharUnits Align =
13725
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
13726
      llvm::Value *V;
13727
      for (unsigned I = 0; I < NF; ++I) {
13728
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
13729
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
13730
      }
13731
      return V;
13732
    }
13733
    break;
13734
case RISCVVector::BI__builtin_rvv_vluxseg6ei8_v_mu:
13735
case RISCVVector::BI__builtin_rvv_vluxseg6ei16_v_mu:
13736
case RISCVVector::BI__builtin_rvv_vluxseg6ei32_v_mu:
13737
case RISCVVector::BI__builtin_rvv_vluxseg6ei64_v_mu:
13738
  ID = Intrinsic::riscv_vluxseg6_mask;
13739
  NF = 6;
13740
  PolicyAttrs = 1;
13741
IsMasked = true;
13742
 
13743
    {
13744
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
13745
      SmallVector<llvm::Value*, 12> Operands;
13746
 
13747
      // Please refer to comment under 'defvar NFList' in this file
13748
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
13749
          (!IsMasked && PolicyAttrs & RVV_VTA))
13750
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
13751
      else {
13752
        if (IsMasked)
13753
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
13754
        else // Unmasked
13755
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
13756
      }
13757
      unsigned PtrOperandIdx = IsMasked ?
13758
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
13759
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
13760
      Value *PtrOperand = Ops[PtrOperandIdx];
13761
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
13762
      Value *VLOperand = Ops[PtrOperandIdx + 2];
13763
      Operands.push_back(PtrOperand);
13764
      Operands.push_back(IndexOperand);
13765
      if (IsMasked)
13766
        Operands.push_back(Ops[NF]);
13767
      Operands.push_back(VLOperand);
13768
      if (IsMasked)
13769
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
13770
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
13771
 
13772
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
13773
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
13774
      clang::CharUnits Align =
13775
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
13776
      llvm::Value *V;
13777
      for (unsigned I = 0; I < NF; ++I) {
13778
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
13779
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
13780
      }
13781
      return V;
13782
    }
13783
    break;
13784
case RISCVVector::BI__builtin_rvv_vluxseg7ei8_v_tu:
13785
case RISCVVector::BI__builtin_rvv_vluxseg7ei16_v_tu:
13786
case RISCVVector::BI__builtin_rvv_vluxseg7ei32_v_tu:
13787
case RISCVVector::BI__builtin_rvv_vluxseg7ei64_v_tu:
13788
  ID = Intrinsic::riscv_vluxseg7;
13789
  NF = 7;
13790
  PolicyAttrs = 2;
13791
IsMasked = false;
13792
 
13793
    {
13794
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
13795
      SmallVector<llvm::Value*, 12> Operands;
13796
 
13797
      // Please refer to comment under 'defvar NFList' in this file
13798
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
13799
          (!IsMasked && PolicyAttrs & RVV_VTA))
13800
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
13801
      else {
13802
        if (IsMasked)
13803
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
13804
        else // Unmasked
13805
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
13806
      }
13807
      unsigned PtrOperandIdx = IsMasked ?
13808
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
13809
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
13810
      Value *PtrOperand = Ops[PtrOperandIdx];
13811
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
13812
      Value *VLOperand = Ops[PtrOperandIdx + 2];
13813
      Operands.push_back(PtrOperand);
13814
      Operands.push_back(IndexOperand);
13815
      if (IsMasked)
13816
        Operands.push_back(Ops[NF]);
13817
      Operands.push_back(VLOperand);
13818
      if (IsMasked)
13819
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
13820
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
13821
 
13822
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
13823
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
13824
      clang::CharUnits Align =
13825
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
13826
      llvm::Value *V;
13827
      for (unsigned I = 0; I < NF; ++I) {
13828
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
13829
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
13830
      }
13831
      return V;
13832
    }
13833
    break;
13834
case RISCVVector::BI__builtin_rvv_vluxseg7ei8_v_ta:
13835
case RISCVVector::BI__builtin_rvv_vluxseg7ei16_v_ta:
13836
case RISCVVector::BI__builtin_rvv_vluxseg7ei32_v_ta:
13837
case RISCVVector::BI__builtin_rvv_vluxseg7ei64_v_ta:
13838
  ID = Intrinsic::riscv_vluxseg7;
13839
  NF = 7;
13840
  PolicyAttrs = 3;
13841
IsMasked = false;
13842
 
13843
    {
13844
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
13845
      SmallVector<llvm::Value*, 12> Operands;
13846
 
13847
      // Please refer to comment under 'defvar NFList' in this file
13848
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
13849
          (!IsMasked && PolicyAttrs & RVV_VTA))
13850
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
13851
      else {
13852
        if (IsMasked)
13853
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
13854
        else // Unmasked
13855
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
13856
      }
13857
      unsigned PtrOperandIdx = IsMasked ?
13858
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
13859
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
13860
      Value *PtrOperand = Ops[PtrOperandIdx];
13861
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
13862
      Value *VLOperand = Ops[PtrOperandIdx + 2];
13863
      Operands.push_back(PtrOperand);
13864
      Operands.push_back(IndexOperand);
13865
      if (IsMasked)
13866
        Operands.push_back(Ops[NF]);
13867
      Operands.push_back(VLOperand);
13868
      if (IsMasked)
13869
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
13870
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
13871
 
13872
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
13873
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
13874
      clang::CharUnits Align =
13875
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
13876
      llvm::Value *V;
13877
      for (unsigned I = 0; I < NF; ++I) {
13878
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
13879
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
13880
      }
13881
      return V;
13882
    }
13883
    break;
13884
case RISCVVector::BI__builtin_rvv_vluxseg7ei8_v_tum:
13885
case RISCVVector::BI__builtin_rvv_vluxseg7ei16_v_tum:
13886
case RISCVVector::BI__builtin_rvv_vluxseg7ei32_v_tum:
13887
case RISCVVector::BI__builtin_rvv_vluxseg7ei64_v_tum:
13888
  ID = Intrinsic::riscv_vluxseg7_mask;
13889
  NF = 7;
13890
  PolicyAttrs = 2;
13891
IsMasked = true;
13892
 
13893
    {
13894
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
13895
      SmallVector<llvm::Value*, 12> Operands;
13896
 
13897
      // Please refer to comment under 'defvar NFList' in this file
13898
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
13899
          (!IsMasked && PolicyAttrs & RVV_VTA))
13900
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
13901
      else {
13902
        if (IsMasked)
13903
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
13904
        else // Unmasked
13905
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
13906
      }
13907
      unsigned PtrOperandIdx = IsMasked ?
13908
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
13909
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
13910
      Value *PtrOperand = Ops[PtrOperandIdx];
13911
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
13912
      Value *VLOperand = Ops[PtrOperandIdx + 2];
13913
      Operands.push_back(PtrOperand);
13914
      Operands.push_back(IndexOperand);
13915
      if (IsMasked)
13916
        Operands.push_back(Ops[NF]);
13917
      Operands.push_back(VLOperand);
13918
      if (IsMasked)
13919
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
13920
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
13921
 
13922
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
13923
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
13924
      clang::CharUnits Align =
13925
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
13926
      llvm::Value *V;
13927
      for (unsigned I = 0; I < NF; ++I) {
13928
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
13929
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
13930
      }
13931
      return V;
13932
    }
13933
    break;
13934
case RISCVVector::BI__builtin_rvv_vluxseg7ei8_v_tama:
13935
case RISCVVector::BI__builtin_rvv_vluxseg7ei16_v_tama:
13936
case RISCVVector::BI__builtin_rvv_vluxseg7ei32_v_tama:
13937
case RISCVVector::BI__builtin_rvv_vluxseg7ei64_v_tama:
13938
  ID = Intrinsic::riscv_vluxseg7_mask;
13939
  NF = 7;
13940
  PolicyAttrs = 3;
13941
IsMasked = true;
13942
 
13943
    {
13944
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
13945
      SmallVector<llvm::Value*, 12> Operands;
13946
 
13947
      // Please refer to comment under 'defvar NFList' in this file
13948
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
13949
          (!IsMasked && PolicyAttrs & RVV_VTA))
13950
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
13951
      else {
13952
        if (IsMasked)
13953
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
13954
        else // Unmasked
13955
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
13956
      }
13957
      unsigned PtrOperandIdx = IsMasked ?
13958
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
13959
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
13960
      Value *PtrOperand = Ops[PtrOperandIdx];
13961
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
13962
      Value *VLOperand = Ops[PtrOperandIdx + 2];
13963
      Operands.push_back(PtrOperand);
13964
      Operands.push_back(IndexOperand);
13965
      if (IsMasked)
13966
        Operands.push_back(Ops[NF]);
13967
      Operands.push_back(VLOperand);
13968
      if (IsMasked)
13969
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
13970
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
13971
 
13972
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
13973
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
13974
      clang::CharUnits Align =
13975
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
13976
      llvm::Value *V;
13977
      for (unsigned I = 0; I < NF; ++I) {
13978
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
13979
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
13980
      }
13981
      return V;
13982
    }
13983
    break;
13984
case RISCVVector::BI__builtin_rvv_vluxseg7ei8_v_tumu:
13985
case RISCVVector::BI__builtin_rvv_vluxseg7ei16_v_tumu:
13986
case RISCVVector::BI__builtin_rvv_vluxseg7ei32_v_tumu:
13987
case RISCVVector::BI__builtin_rvv_vluxseg7ei64_v_tumu:
13988
  ID = Intrinsic::riscv_vluxseg7_mask;
13989
  NF = 7;
13990
  PolicyAttrs = 0;
13991
IsMasked = true;
13992
 
13993
    {
13994
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
13995
      SmallVector<llvm::Value*, 12> Operands;
13996
 
13997
      // Please refer to comment under 'defvar NFList' in this file
13998
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
13999
          (!IsMasked && PolicyAttrs & RVV_VTA))
14000
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
14001
      else {
14002
        if (IsMasked)
14003
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
14004
        else // Unmasked
14005
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
14006
      }
14007
      unsigned PtrOperandIdx = IsMasked ?
14008
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
14009
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
14010
      Value *PtrOperand = Ops[PtrOperandIdx];
14011
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
14012
      Value *VLOperand = Ops[PtrOperandIdx + 2];
14013
      Operands.push_back(PtrOperand);
14014
      Operands.push_back(IndexOperand);
14015
      if (IsMasked)
14016
        Operands.push_back(Ops[NF]);
14017
      Operands.push_back(VLOperand);
14018
      if (IsMasked)
14019
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
14020
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
14021
 
14022
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
14023
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
14024
      clang::CharUnits Align =
14025
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
14026
      llvm::Value *V;
14027
      for (unsigned I = 0; I < NF; ++I) {
14028
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
14029
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
14030
      }
14031
      return V;
14032
    }
14033
    break;
14034
case RISCVVector::BI__builtin_rvv_vluxseg7ei8_v_mu:
14035
case RISCVVector::BI__builtin_rvv_vluxseg7ei16_v_mu:
14036
case RISCVVector::BI__builtin_rvv_vluxseg7ei32_v_mu:
14037
case RISCVVector::BI__builtin_rvv_vluxseg7ei64_v_mu:
14038
  ID = Intrinsic::riscv_vluxseg7_mask;
14039
  NF = 7;
14040
  PolicyAttrs = 1;
14041
IsMasked = true;
14042
 
14043
    {
14044
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
14045
      SmallVector<llvm::Value*, 12> Operands;
14046
 
14047
      // Please refer to comment under 'defvar NFList' in this file
14048
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
14049
          (!IsMasked && PolicyAttrs & RVV_VTA))
14050
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
14051
      else {
14052
        if (IsMasked)
14053
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
14054
        else // Unmasked
14055
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
14056
      }
14057
      unsigned PtrOperandIdx = IsMasked ?
14058
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
14059
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
14060
      Value *PtrOperand = Ops[PtrOperandIdx];
14061
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
14062
      Value *VLOperand = Ops[PtrOperandIdx + 2];
14063
      Operands.push_back(PtrOperand);
14064
      Operands.push_back(IndexOperand);
14065
      if (IsMasked)
14066
        Operands.push_back(Ops[NF]);
14067
      Operands.push_back(VLOperand);
14068
      if (IsMasked)
14069
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
14070
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
14071
 
14072
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
14073
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
14074
      clang::CharUnits Align =
14075
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
14076
      llvm::Value *V;
14077
      for (unsigned I = 0; I < NF; ++I) {
14078
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
14079
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
14080
      }
14081
      return V;
14082
    }
14083
    break;
14084
case RISCVVector::BI__builtin_rvv_vluxseg8ei8_v_tu:
14085
case RISCVVector::BI__builtin_rvv_vluxseg8ei16_v_tu:
14086
case RISCVVector::BI__builtin_rvv_vluxseg8ei32_v_tu:
14087
case RISCVVector::BI__builtin_rvv_vluxseg8ei64_v_tu:
14088
  ID = Intrinsic::riscv_vluxseg8;
14089
  NF = 8;
14090
  PolicyAttrs = 2;
14091
IsMasked = false;
14092
 
14093
    {
14094
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
14095
      SmallVector<llvm::Value*, 12> Operands;
14096
 
14097
      // Please refer to comment under 'defvar NFList' in this file
14098
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
14099
          (!IsMasked && PolicyAttrs & RVV_VTA))
14100
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
14101
      else {
14102
        if (IsMasked)
14103
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
14104
        else // Unmasked
14105
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
14106
      }
14107
      unsigned PtrOperandIdx = IsMasked ?
14108
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
14109
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
14110
      Value *PtrOperand = Ops[PtrOperandIdx];
14111
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
14112
      Value *VLOperand = Ops[PtrOperandIdx + 2];
14113
      Operands.push_back(PtrOperand);
14114
      Operands.push_back(IndexOperand);
14115
      if (IsMasked)
14116
        Operands.push_back(Ops[NF]);
14117
      Operands.push_back(VLOperand);
14118
      if (IsMasked)
14119
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
14120
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
14121
 
14122
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
14123
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
14124
      clang::CharUnits Align =
14125
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
14126
      llvm::Value *V;
14127
      for (unsigned I = 0; I < NF; ++I) {
14128
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
14129
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
14130
      }
14131
      return V;
14132
    }
14133
    break;
14134
case RISCVVector::BI__builtin_rvv_vluxseg8ei8_v_ta:
14135
case RISCVVector::BI__builtin_rvv_vluxseg8ei16_v_ta:
14136
case RISCVVector::BI__builtin_rvv_vluxseg8ei32_v_ta:
14137
case RISCVVector::BI__builtin_rvv_vluxseg8ei64_v_ta:
14138
  ID = Intrinsic::riscv_vluxseg8;
14139
  NF = 8;
14140
  PolicyAttrs = 3;
14141
IsMasked = false;
14142
 
14143
    {
14144
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
14145
      SmallVector<llvm::Value*, 12> Operands;
14146
 
14147
      // Please refer to comment under 'defvar NFList' in this file
14148
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
14149
          (!IsMasked && PolicyAttrs & RVV_VTA))
14150
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
14151
      else {
14152
        if (IsMasked)
14153
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
14154
        else // Unmasked
14155
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
14156
      }
14157
      unsigned PtrOperandIdx = IsMasked ?
14158
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
14159
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
14160
      Value *PtrOperand = Ops[PtrOperandIdx];
14161
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
14162
      Value *VLOperand = Ops[PtrOperandIdx + 2];
14163
      Operands.push_back(PtrOperand);
14164
      Operands.push_back(IndexOperand);
14165
      if (IsMasked)
14166
        Operands.push_back(Ops[NF]);
14167
      Operands.push_back(VLOperand);
14168
      if (IsMasked)
14169
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
14170
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
14171
 
14172
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
14173
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
14174
      clang::CharUnits Align =
14175
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
14176
      llvm::Value *V;
14177
      for (unsigned I = 0; I < NF; ++I) {
14178
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
14179
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
14180
      }
14181
      return V;
14182
    }
14183
    break;
14184
case RISCVVector::BI__builtin_rvv_vluxseg8ei8_v_tum:
14185
case RISCVVector::BI__builtin_rvv_vluxseg8ei16_v_tum:
14186
case RISCVVector::BI__builtin_rvv_vluxseg8ei32_v_tum:
14187
case RISCVVector::BI__builtin_rvv_vluxseg8ei64_v_tum:
14188
  ID = Intrinsic::riscv_vluxseg8_mask;
14189
  NF = 8;
14190
  PolicyAttrs = 2;
14191
IsMasked = true;
14192
 
14193
    {
14194
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
14195
      SmallVector<llvm::Value*, 12> Operands;
14196
 
14197
      // Please refer to comment under 'defvar NFList' in this file
14198
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
14199
          (!IsMasked && PolicyAttrs & RVV_VTA))
14200
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
14201
      else {
14202
        if (IsMasked)
14203
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
14204
        else // Unmasked
14205
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
14206
      }
14207
      unsigned PtrOperandIdx = IsMasked ?
14208
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
14209
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
14210
      Value *PtrOperand = Ops[PtrOperandIdx];
14211
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
14212
      Value *VLOperand = Ops[PtrOperandIdx + 2];
14213
      Operands.push_back(PtrOperand);
14214
      Operands.push_back(IndexOperand);
14215
      if (IsMasked)
14216
        Operands.push_back(Ops[NF]);
14217
      Operands.push_back(VLOperand);
14218
      if (IsMasked)
14219
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
14220
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
14221
 
14222
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
14223
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
14224
      clang::CharUnits Align =
14225
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
14226
      llvm::Value *V;
14227
      for (unsigned I = 0; I < NF; ++I) {
14228
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
14229
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
14230
      }
14231
      return V;
14232
    }
14233
    break;
14234
case RISCVVector::BI__builtin_rvv_vluxseg8ei8_v_tama:
14235
case RISCVVector::BI__builtin_rvv_vluxseg8ei16_v_tama:
14236
case RISCVVector::BI__builtin_rvv_vluxseg8ei32_v_tama:
14237
case RISCVVector::BI__builtin_rvv_vluxseg8ei64_v_tama:
14238
  ID = Intrinsic::riscv_vluxseg8_mask;
14239
  NF = 8;
14240
  PolicyAttrs = 3;
14241
IsMasked = true;
14242
 
14243
    {
14244
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
14245
      SmallVector<llvm::Value*, 12> Operands;
14246
 
14247
      // Please refer to comment under 'defvar NFList' in this file
14248
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
14249
          (!IsMasked && PolicyAttrs & RVV_VTA))
14250
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
14251
      else {
14252
        if (IsMasked)
14253
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
14254
        else // Unmasked
14255
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
14256
      }
14257
      unsigned PtrOperandIdx = IsMasked ?
14258
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
14259
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
14260
      Value *PtrOperand = Ops[PtrOperandIdx];
14261
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
14262
      Value *VLOperand = Ops[PtrOperandIdx + 2];
14263
      Operands.push_back(PtrOperand);
14264
      Operands.push_back(IndexOperand);
14265
      if (IsMasked)
14266
        Operands.push_back(Ops[NF]);
14267
      Operands.push_back(VLOperand);
14268
      if (IsMasked)
14269
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
14270
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
14271
 
14272
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
14273
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
14274
      clang::CharUnits Align =
14275
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
14276
      llvm::Value *V;
14277
      for (unsigned I = 0; I < NF; ++I) {
14278
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
14279
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
14280
      }
14281
      return V;
14282
    }
14283
    break;
14284
case RISCVVector::BI__builtin_rvv_vluxseg8ei8_v_tumu:
14285
case RISCVVector::BI__builtin_rvv_vluxseg8ei16_v_tumu:
14286
case RISCVVector::BI__builtin_rvv_vluxseg8ei32_v_tumu:
14287
case RISCVVector::BI__builtin_rvv_vluxseg8ei64_v_tumu:
14288
  ID = Intrinsic::riscv_vluxseg8_mask;
14289
  NF = 8;
14290
  PolicyAttrs = 0;
14291
IsMasked = true;
14292
 
14293
    {
14294
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
14295
      SmallVector<llvm::Value*, 12> Operands;
14296
 
14297
      // Please refer to comment under 'defvar NFList' in this file
14298
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
14299
          (!IsMasked && PolicyAttrs & RVV_VTA))
14300
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
14301
      else {
14302
        if (IsMasked)
14303
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
14304
        else // Unmasked
14305
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
14306
      }
14307
      unsigned PtrOperandIdx = IsMasked ?
14308
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
14309
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
14310
      Value *PtrOperand = Ops[PtrOperandIdx];
14311
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
14312
      Value *VLOperand = Ops[PtrOperandIdx + 2];
14313
      Operands.push_back(PtrOperand);
14314
      Operands.push_back(IndexOperand);
14315
      if (IsMasked)
14316
        Operands.push_back(Ops[NF]);
14317
      Operands.push_back(VLOperand);
14318
      if (IsMasked)
14319
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
14320
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
14321
 
14322
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
14323
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
14324
      clang::CharUnits Align =
14325
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
14326
      llvm::Value *V;
14327
      for (unsigned I = 0; I < NF; ++I) {
14328
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
14329
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
14330
      }
14331
      return V;
14332
    }
14333
    break;
14334
case RISCVVector::BI__builtin_rvv_vluxseg8ei8_v_mu:
14335
case RISCVVector::BI__builtin_rvv_vluxseg8ei16_v_mu:
14336
case RISCVVector::BI__builtin_rvv_vluxseg8ei32_v_mu:
14337
case RISCVVector::BI__builtin_rvv_vluxseg8ei64_v_mu:
14338
  ID = Intrinsic::riscv_vluxseg8_mask;
14339
  NF = 8;
14340
  PolicyAttrs = 1;
14341
IsMasked = true;
14342
 
14343
    {
14344
      ResultType = ConvertType(E->getArg(0)->getType()->getPointeeType());
14345
      SmallVector<llvm::Value*, 12> Operands;
14346
 
14347
      // Please refer to comment under 'defvar NFList' in this file
14348
      if ((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
14349
          (!IsMasked && PolicyAttrs & RVV_VTA))
14350
        Operands.append(NF, llvm::PoisonValue::get(ResultType));
14351
      else {
14352
        if (IsMasked)
14353
          Operands.append(Ops.begin() + NF + 1, Ops.begin() + 2 * NF + 1);
14354
        else // Unmasked
14355
          Operands.append(Ops.begin() + NF, Ops.begin() + 2 * NF);
14356
      }
14357
      unsigned PtrOperandIdx = IsMasked ?
14358
        ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ? NF + 1 : 2 * NF + 1 :
14359
        (PolicyAttrs & RVV_VTA) ? NF : 2 * NF;
14360
      Value *PtrOperand = Ops[PtrOperandIdx];
14361
      Value *IndexOperand = Ops[PtrOperandIdx + 1];
14362
      Value *VLOperand = Ops[PtrOperandIdx + 2];
14363
      Operands.push_back(PtrOperand);
14364
      Operands.push_back(IndexOperand);
14365
      if (IsMasked)
14366
        Operands.push_back(Ops[NF]);
14367
      Operands.push_back(VLOperand);
14368
      if (IsMasked)
14369
        Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
14370
      IntrinsicTypes = {ResultType, IndexOperand->getType(), Ops.back()->getType()};
14371
 
14372
      llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
14373
      llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
14374
      clang::CharUnits Align =
14375
          CGM.getNaturalPointeeTypeAlignment(E->getArg(0)->getType());
14376
      llvm::Value *V;
14377
      for (unsigned I = 0; I < NF; ++I) {
14378
        llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {I});
14379
        V = Builder.CreateStore(Val, Address(Ops[I], Val->getType(), Align));
14380
      }
14381
      return V;
14382
    }
14383
    break;
14384
case RISCVVector::BI__builtin_rvv_vmacc_vv_tu:
14385
case RISCVVector::BI__builtin_rvv_vmacc_vx_tu:
14386
  ID = Intrinsic::riscv_vmacc;
14387
  PolicyAttrs = 2;
14388
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
14389
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
14390
  break;
14391
case RISCVVector::BI__builtin_rvv_vmacc_vv_ta:
14392
case RISCVVector::BI__builtin_rvv_vmacc_vx_ta:
14393
  ID = Intrinsic::riscv_vmacc;
14394
  PolicyAttrs = 3;
14395
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
14396
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
14397
  break;
14398
case RISCVVector::BI__builtin_rvv_vmacc_vv_tum:
14399
case RISCVVector::BI__builtin_rvv_vmacc_vx_tum:
14400
  ID = Intrinsic::riscv_vmacc_mask;
14401
  PolicyAttrs = 2;
14402
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14403
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
14404
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
14405
  break;
14406
case RISCVVector::BI__builtin_rvv_vmacc_vv_tama:
14407
case RISCVVector::BI__builtin_rvv_vmacc_vx_tama:
14408
  ID = Intrinsic::riscv_vmacc_mask;
14409
  PolicyAttrs = 3;
14410
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14411
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
14412
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
14413
  break;
14414
case RISCVVector::BI__builtin_rvv_vmacc_vv_tumu:
14415
case RISCVVector::BI__builtin_rvv_vmacc_vx_tumu:
14416
  ID = Intrinsic::riscv_vmacc_mask;
14417
  PolicyAttrs = 0;
14418
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14419
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
14420
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
14421
  break;
14422
case RISCVVector::BI__builtin_rvv_vmacc_vv_mu:
14423
case RISCVVector::BI__builtin_rvv_vmacc_vx_mu:
14424
  ID = Intrinsic::riscv_vmacc_mask;
14425
  PolicyAttrs = 1;
14426
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14427
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
14428
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
14429
  break;
14430
case RISCVVector::BI__builtin_rvv_vmadc_vv:
14431
case RISCVVector::BI__builtin_rvv_vmadc_vx:
14432
  ID = Intrinsic::riscv_vmadc;
14433
  PolicyAttrs = 3;
14434
  IntrinsicTypes = {Ops[0]->getType(), Ops[1]->getType(), Ops.back()->getType()};
14435
  break;
14436
case RISCVVector::BI__builtin_rvv_vmadc_vvm:
14437
case RISCVVector::BI__builtin_rvv_vmadc_vxm:
14438
  ID = Intrinsic::riscv_vmadc_carry_in;
14439
  PolicyAttrs = 3;
14440
  IntrinsicTypes = {Ops[0]->getType(), Ops[1]->getType(), Ops.back()->getType()};
14441
  break;
14442
case RISCVVector::BI__builtin_rvv_vmadd_vv_tu:
14443
case RISCVVector::BI__builtin_rvv_vmadd_vx_tu:
14444
  ID = Intrinsic::riscv_vmadd;
14445
  PolicyAttrs = 2;
14446
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
14447
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
14448
  break;
14449
case RISCVVector::BI__builtin_rvv_vmadd_vv_ta:
14450
case RISCVVector::BI__builtin_rvv_vmadd_vx_ta:
14451
  ID = Intrinsic::riscv_vmadd;
14452
  PolicyAttrs = 3;
14453
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
14454
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
14455
  break;
14456
case RISCVVector::BI__builtin_rvv_vmadd_vv_tum:
14457
case RISCVVector::BI__builtin_rvv_vmadd_vx_tum:
14458
  ID = Intrinsic::riscv_vmadd_mask;
14459
  PolicyAttrs = 2;
14460
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14461
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
14462
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
14463
  break;
14464
case RISCVVector::BI__builtin_rvv_vmadd_vv_tama:
14465
case RISCVVector::BI__builtin_rvv_vmadd_vx_tama:
14466
  ID = Intrinsic::riscv_vmadd_mask;
14467
  PolicyAttrs = 3;
14468
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14469
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
14470
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
14471
  break;
14472
case RISCVVector::BI__builtin_rvv_vmadd_vv_tumu:
14473
case RISCVVector::BI__builtin_rvv_vmadd_vx_tumu:
14474
  ID = Intrinsic::riscv_vmadd_mask;
14475
  PolicyAttrs = 0;
14476
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14477
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
14478
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
14479
  break;
14480
case RISCVVector::BI__builtin_rvv_vmadd_vv_mu:
14481
case RISCVVector::BI__builtin_rvv_vmadd_vx_mu:
14482
  ID = Intrinsic::riscv_vmadd_mask;
14483
  PolicyAttrs = 1;
14484
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14485
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
14486
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
14487
  break;
14488
case RISCVVector::BI__builtin_rvv_vmmv_m:
14489
  ID = Intrinsic::riscv_vmand;
14490
  PolicyAttrs = 3;
14491
IsMasked = false;
14492
 
14493
      {
14494
        // op1, vl
14495
        IntrinsicTypes = {ResultType,
14496
                          Ops[1]->getType()};
14497
        Ops.insert(Ops.begin() + 1, Ops[0]);
14498
        break;
14499
      }
14500
      break;
14501
case RISCVVector::BI__builtin_rvv_vmand_mm:
14502
  ID = Intrinsic::riscv_vmand;
14503
  PolicyAttrs = 3;
14504
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
14505
  break;
14506
case RISCVVector::BI__builtin_rvv_vmandn_mm:
14507
  ID = Intrinsic::riscv_vmandn;
14508
  PolicyAttrs = 3;
14509
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
14510
  break;
14511
case RISCVVector::BI__builtin_rvv_vmax_vv_tu:
14512
case RISCVVector::BI__builtin_rvv_vmax_vx_tu:
14513
  ID = Intrinsic::riscv_vmax;
14514
  PolicyAttrs = 2;
14515
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
14516
  break;
14517
case RISCVVector::BI__builtin_rvv_vmax_vv_ta:
14518
case RISCVVector::BI__builtin_rvv_vmax_vx_ta:
14519
  ID = Intrinsic::riscv_vmax;
14520
  PolicyAttrs = 3;
14521
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
14522
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
14523
  break;
14524
case RISCVVector::BI__builtin_rvv_vmax_vv_tum:
14525
case RISCVVector::BI__builtin_rvv_vmax_vx_tum:
14526
  ID = Intrinsic::riscv_vmax_mask;
14527
  PolicyAttrs = 2;
14528
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14529
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
14530
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
14531
  break;
14532
case RISCVVector::BI__builtin_rvv_vmax_vv_tama:
14533
case RISCVVector::BI__builtin_rvv_vmax_vx_tama:
14534
  ID = Intrinsic::riscv_vmax_mask;
14535
  PolicyAttrs = 3;
14536
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14537
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
14538
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
14539
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
14540
  break;
14541
case RISCVVector::BI__builtin_rvv_vmax_vv_tumu:
14542
case RISCVVector::BI__builtin_rvv_vmax_vx_tumu:
14543
  ID = Intrinsic::riscv_vmax_mask;
14544
  PolicyAttrs = 0;
14545
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14546
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
14547
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
14548
  break;
14549
case RISCVVector::BI__builtin_rvv_vmax_vv_mu:
14550
case RISCVVector::BI__builtin_rvv_vmax_vx_mu:
14551
  ID = Intrinsic::riscv_vmax_mask;
14552
  PolicyAttrs = 1;
14553
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14554
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
14555
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
14556
  break;
14557
case RISCVVector::BI__builtin_rvv_vmaxu_vv_tu:
14558
case RISCVVector::BI__builtin_rvv_vmaxu_vx_tu:
14559
  ID = Intrinsic::riscv_vmaxu;
14560
  PolicyAttrs = 2;
14561
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
14562
  break;
14563
case RISCVVector::BI__builtin_rvv_vmaxu_vv_ta:
14564
case RISCVVector::BI__builtin_rvv_vmaxu_vx_ta:
14565
  ID = Intrinsic::riscv_vmaxu;
14566
  PolicyAttrs = 3;
14567
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
14568
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
14569
  break;
14570
case RISCVVector::BI__builtin_rvv_vmaxu_vv_tum:
14571
case RISCVVector::BI__builtin_rvv_vmaxu_vx_tum:
14572
  ID = Intrinsic::riscv_vmaxu_mask;
14573
  PolicyAttrs = 2;
14574
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14575
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
14576
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
14577
  break;
14578
case RISCVVector::BI__builtin_rvv_vmaxu_vv_tama:
14579
case RISCVVector::BI__builtin_rvv_vmaxu_vx_tama:
14580
  ID = Intrinsic::riscv_vmaxu_mask;
14581
  PolicyAttrs = 3;
14582
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14583
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
14584
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
14585
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
14586
  break;
14587
case RISCVVector::BI__builtin_rvv_vmaxu_vv_tumu:
14588
case RISCVVector::BI__builtin_rvv_vmaxu_vx_tumu:
14589
  ID = Intrinsic::riscv_vmaxu_mask;
14590
  PolicyAttrs = 0;
14591
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14592
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
14593
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
14594
  break;
14595
case RISCVVector::BI__builtin_rvv_vmaxu_vv_mu:
14596
case RISCVVector::BI__builtin_rvv_vmaxu_vx_mu:
14597
  ID = Intrinsic::riscv_vmaxu_mask;
14598
  PolicyAttrs = 1;
14599
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14600
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
14601
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
14602
  break;
14603
case RISCVVector::BI__builtin_rvv_vmclr_m:
14604
  ID = Intrinsic::riscv_vmclr;
14605
  PolicyAttrs = 3;
14606
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
14607
  break;
14608
case RISCVVector::BI__builtin_rvv_vmerge_vvm_tu:
14609
case RISCVVector::BI__builtin_rvv_vmerge_vxm_tu:
14610
  ID = Intrinsic::riscv_vmerge;
14611
  PolicyAttrs = 2;
14612
IsMasked = false;
14613
 
14614
      // insert poison passthru
14615
      if (PolicyAttrs & RVV_VTA)
14616
        Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
14617
      IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
14618
    break;
14619
case RISCVVector::BI__builtin_rvv_vmerge_vvm_ta:
14620
case RISCVVector::BI__builtin_rvv_vmerge_vxm_ta:
14621
  ID = Intrinsic::riscv_vmerge;
14622
  PolicyAttrs = 3;
14623
IsMasked = false;
14624
 
14625
      // insert poison passthru
14626
      if (PolicyAttrs & RVV_VTA)
14627
        Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
14628
      IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
14629
    break;
14630
case RISCVVector::BI__builtin_rvv_vmfeq_vv:
14631
case RISCVVector::BI__builtin_rvv_vmfeq_vf:
14632
  ID = Intrinsic::riscv_vmfeq;
14633
  PolicyAttrs = 3;
14634
  IntrinsicTypes = {Ops[0]->getType(), Ops[1]->getType(), Ops.back()->getType()};
14635
  break;
14636
case RISCVVector::BI__builtin_rvv_vmfeq_vv_tama:
14637
case RISCVVector::BI__builtin_rvv_vmfeq_vf_tama:
14638
  ID = Intrinsic::riscv_vmfeq_mask;
14639
  PolicyAttrs = 3;
14640
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14641
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
14642
  IntrinsicTypes = {Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
14643
  break;
14644
case RISCVVector::BI__builtin_rvv_vmfeq_vv_mu:
14645
case RISCVVector::BI__builtin_rvv_vmfeq_vf_mu:
14646
  ID = Intrinsic::riscv_vmfeq_mask;
14647
  PolicyAttrs = 1;
14648
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14649
  IntrinsicTypes = {Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
14650
  break;
14651
case RISCVVector::BI__builtin_rvv_vmfge_vv:
14652
case RISCVVector::BI__builtin_rvv_vmfge_vf:
14653
  ID = Intrinsic::riscv_vmfge;
14654
  PolicyAttrs = 3;
14655
  IntrinsicTypes = {Ops[0]->getType(), Ops[1]->getType(), Ops.back()->getType()};
14656
  break;
14657
case RISCVVector::BI__builtin_rvv_vmfge_vv_tama:
14658
case RISCVVector::BI__builtin_rvv_vmfge_vf_tama:
14659
  ID = Intrinsic::riscv_vmfge_mask;
14660
  PolicyAttrs = 3;
14661
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14662
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
14663
  IntrinsicTypes = {Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
14664
  break;
14665
case RISCVVector::BI__builtin_rvv_vmfge_vv_mu:
14666
case RISCVVector::BI__builtin_rvv_vmfge_vf_mu:
14667
  ID = Intrinsic::riscv_vmfge_mask;
14668
  PolicyAttrs = 1;
14669
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14670
  IntrinsicTypes = {Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
14671
  break;
14672
case RISCVVector::BI__builtin_rvv_vmfgt_vv:
14673
case RISCVVector::BI__builtin_rvv_vmfgt_vf:
14674
  ID = Intrinsic::riscv_vmfgt;
14675
  PolicyAttrs = 3;
14676
  IntrinsicTypes = {Ops[0]->getType(), Ops[1]->getType(), Ops.back()->getType()};
14677
  break;
14678
case RISCVVector::BI__builtin_rvv_vmfgt_vv_tama:
14679
case RISCVVector::BI__builtin_rvv_vmfgt_vf_tama:
14680
  ID = Intrinsic::riscv_vmfgt_mask;
14681
  PolicyAttrs = 3;
14682
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14683
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
14684
  IntrinsicTypes = {Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
14685
  break;
14686
case RISCVVector::BI__builtin_rvv_vmfgt_vv_mu:
14687
case RISCVVector::BI__builtin_rvv_vmfgt_vf_mu:
14688
  ID = Intrinsic::riscv_vmfgt_mask;
14689
  PolicyAttrs = 1;
14690
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14691
  IntrinsicTypes = {Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
14692
  break;
14693
case RISCVVector::BI__builtin_rvv_vmfle_vv:
14694
case RISCVVector::BI__builtin_rvv_vmfle_vf:
14695
  ID = Intrinsic::riscv_vmfle;
14696
  PolicyAttrs = 3;
14697
  IntrinsicTypes = {Ops[0]->getType(), Ops[1]->getType(), Ops.back()->getType()};
14698
  break;
14699
case RISCVVector::BI__builtin_rvv_vmfle_vv_tama:
14700
case RISCVVector::BI__builtin_rvv_vmfle_vf_tama:
14701
  ID = Intrinsic::riscv_vmfle_mask;
14702
  PolicyAttrs = 3;
14703
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14704
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
14705
  IntrinsicTypes = {Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
14706
  break;
14707
case RISCVVector::BI__builtin_rvv_vmfle_vv_mu:
14708
case RISCVVector::BI__builtin_rvv_vmfle_vf_mu:
14709
  ID = Intrinsic::riscv_vmfle_mask;
14710
  PolicyAttrs = 1;
14711
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14712
  IntrinsicTypes = {Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
14713
  break;
14714
case RISCVVector::BI__builtin_rvv_vmflt_vv:
14715
case RISCVVector::BI__builtin_rvv_vmflt_vf:
14716
  ID = Intrinsic::riscv_vmflt;
14717
  PolicyAttrs = 3;
14718
  IntrinsicTypes = {Ops[0]->getType(), Ops[1]->getType(), Ops.back()->getType()};
14719
  break;
14720
case RISCVVector::BI__builtin_rvv_vmflt_vv_tama:
14721
case RISCVVector::BI__builtin_rvv_vmflt_vf_tama:
14722
  ID = Intrinsic::riscv_vmflt_mask;
14723
  PolicyAttrs = 3;
14724
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14725
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
14726
  IntrinsicTypes = {Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
14727
  break;
14728
case RISCVVector::BI__builtin_rvv_vmflt_vv_mu:
14729
case RISCVVector::BI__builtin_rvv_vmflt_vf_mu:
14730
  ID = Intrinsic::riscv_vmflt_mask;
14731
  PolicyAttrs = 1;
14732
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14733
  IntrinsicTypes = {Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
14734
  break;
14735
case RISCVVector::BI__builtin_rvv_vmfne_vv:
14736
case RISCVVector::BI__builtin_rvv_vmfne_vf:
14737
  ID = Intrinsic::riscv_vmfne;
14738
  PolicyAttrs = 3;
14739
  IntrinsicTypes = {Ops[0]->getType(), Ops[1]->getType(), Ops.back()->getType()};
14740
  break;
14741
case RISCVVector::BI__builtin_rvv_vmfne_vv_tama:
14742
case RISCVVector::BI__builtin_rvv_vmfne_vf_tama:
14743
  ID = Intrinsic::riscv_vmfne_mask;
14744
  PolicyAttrs = 3;
14745
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14746
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
14747
  IntrinsicTypes = {Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
14748
  break;
14749
case RISCVVector::BI__builtin_rvv_vmfne_vv_mu:
14750
case RISCVVector::BI__builtin_rvv_vmfne_vf_mu:
14751
  ID = Intrinsic::riscv_vmfne_mask;
14752
  PolicyAttrs = 1;
14753
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14754
  IntrinsicTypes = {Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
14755
  break;
14756
case RISCVVector::BI__builtin_rvv_vmin_vv_tu:
14757
case RISCVVector::BI__builtin_rvv_vmin_vx_tu:
14758
  ID = Intrinsic::riscv_vmin;
14759
  PolicyAttrs = 2;
14760
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
14761
  break;
14762
case RISCVVector::BI__builtin_rvv_vmin_vv_ta:
14763
case RISCVVector::BI__builtin_rvv_vmin_vx_ta:
14764
  ID = Intrinsic::riscv_vmin;
14765
  PolicyAttrs = 3;
14766
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
14767
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
14768
  break;
14769
case RISCVVector::BI__builtin_rvv_vmin_vv_tum:
14770
case RISCVVector::BI__builtin_rvv_vmin_vx_tum:
14771
  ID = Intrinsic::riscv_vmin_mask;
14772
  PolicyAttrs = 2;
14773
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14774
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
14775
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
14776
  break;
14777
case RISCVVector::BI__builtin_rvv_vmin_vv_tama:
14778
case RISCVVector::BI__builtin_rvv_vmin_vx_tama:
14779
  ID = Intrinsic::riscv_vmin_mask;
14780
  PolicyAttrs = 3;
14781
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14782
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
14783
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
14784
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
14785
  break;
14786
case RISCVVector::BI__builtin_rvv_vmin_vv_tumu:
14787
case RISCVVector::BI__builtin_rvv_vmin_vx_tumu:
14788
  ID = Intrinsic::riscv_vmin_mask;
14789
  PolicyAttrs = 0;
14790
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14791
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
14792
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
14793
  break;
14794
case RISCVVector::BI__builtin_rvv_vmin_vv_mu:
14795
case RISCVVector::BI__builtin_rvv_vmin_vx_mu:
14796
  ID = Intrinsic::riscv_vmin_mask;
14797
  PolicyAttrs = 1;
14798
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14799
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
14800
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
14801
  break;
14802
case RISCVVector::BI__builtin_rvv_vminu_vv_tu:
14803
case RISCVVector::BI__builtin_rvv_vminu_vx_tu:
14804
  ID = Intrinsic::riscv_vminu;
14805
  PolicyAttrs = 2;
14806
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
14807
  break;
14808
case RISCVVector::BI__builtin_rvv_vminu_vv_ta:
14809
case RISCVVector::BI__builtin_rvv_vminu_vx_ta:
14810
  ID = Intrinsic::riscv_vminu;
14811
  PolicyAttrs = 3;
14812
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
14813
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
14814
  break;
14815
case RISCVVector::BI__builtin_rvv_vminu_vv_tum:
14816
case RISCVVector::BI__builtin_rvv_vminu_vx_tum:
14817
  ID = Intrinsic::riscv_vminu_mask;
14818
  PolicyAttrs = 2;
14819
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14820
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
14821
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
14822
  break;
14823
case RISCVVector::BI__builtin_rvv_vminu_vv_tama:
14824
case RISCVVector::BI__builtin_rvv_vminu_vx_tama:
14825
  ID = Intrinsic::riscv_vminu_mask;
14826
  PolicyAttrs = 3;
14827
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14828
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
14829
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
14830
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
14831
  break;
14832
case RISCVVector::BI__builtin_rvv_vminu_vv_tumu:
14833
case RISCVVector::BI__builtin_rvv_vminu_vx_tumu:
14834
  ID = Intrinsic::riscv_vminu_mask;
14835
  PolicyAttrs = 0;
14836
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14837
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
14838
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
14839
  break;
14840
case RISCVVector::BI__builtin_rvv_vminu_vv_mu:
14841
case RISCVVector::BI__builtin_rvv_vminu_vx_mu:
14842
  ID = Intrinsic::riscv_vminu_mask;
14843
  PolicyAttrs = 1;
14844
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14845
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
14846
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
14847
  break;
14848
case RISCVVector::BI__builtin_rvv_vmnot_m:
14849
  ID = Intrinsic::riscv_vmnand;
14850
  PolicyAttrs = 3;
14851
IsMasked = false;
14852
 
14853
      {
14854
        // op1, vl
14855
        IntrinsicTypes = {ResultType,
14856
                          Ops[1]->getType()};
14857
        Ops.insert(Ops.begin() + 1, Ops[0]);
14858
        break;
14859
      }
14860
      break;
14861
case RISCVVector::BI__builtin_rvv_vmnand_mm:
14862
  ID = Intrinsic::riscv_vmnand;
14863
  PolicyAttrs = 3;
14864
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
14865
  break;
14866
case RISCVVector::BI__builtin_rvv_vmnor_mm:
14867
  ID = Intrinsic::riscv_vmnor;
14868
  PolicyAttrs = 3;
14869
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
14870
  break;
14871
case RISCVVector::BI__builtin_rvv_vmor_mm:
14872
  ID = Intrinsic::riscv_vmor;
14873
  PolicyAttrs = 3;
14874
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
14875
  break;
14876
case RISCVVector::BI__builtin_rvv_vmorn_mm:
14877
  ID = Intrinsic::riscv_vmorn;
14878
  PolicyAttrs = 3;
14879
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
14880
  break;
14881
case RISCVVector::BI__builtin_rvv_vmsbc_vv:
14882
case RISCVVector::BI__builtin_rvv_vmsbc_vx:
14883
  ID = Intrinsic::riscv_vmsbc;
14884
  PolicyAttrs = 3;
14885
  IntrinsicTypes = {Ops[0]->getType(), Ops[1]->getType(), Ops.back()->getType()};
14886
  break;
14887
case RISCVVector::BI__builtin_rvv_vmsbc_vvm:
14888
case RISCVVector::BI__builtin_rvv_vmsbc_vxm:
14889
  ID = Intrinsic::riscv_vmsbc_borrow_in;
14890
  PolicyAttrs = 3;
14891
  IntrinsicTypes = {Ops[0]->getType(), Ops[1]->getType(), Ops.back()->getType()};
14892
  break;
14893
case RISCVVector::BI__builtin_rvv_vmsbf_m:
14894
  ID = Intrinsic::riscv_vmsbf;
14895
  PolicyAttrs = 3;
14896
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
14897
  break;
14898
case RISCVVector::BI__builtin_rvv_vmsbf_m_tama:
14899
  ID = Intrinsic::riscv_vmsbf_mask;
14900
  PolicyAttrs = 3;
14901
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14902
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
14903
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
14904
  break;
14905
case RISCVVector::BI__builtin_rvv_vmsbf_m_mu:
14906
  ID = Intrinsic::riscv_vmsbf_mask;
14907
  PolicyAttrs = 1;
14908
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14909
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
14910
  break;
14911
case RISCVVector::BI__builtin_rvv_vmseq_vv:
14912
case RISCVVector::BI__builtin_rvv_vmseq_vx:
14913
  ID = Intrinsic::riscv_vmseq;
14914
  PolicyAttrs = 3;
14915
  IntrinsicTypes = {Ops[0]->getType(), Ops[1]->getType(), Ops.back()->getType()};
14916
  break;
14917
case RISCVVector::BI__builtin_rvv_vmseq_vv_tama:
14918
case RISCVVector::BI__builtin_rvv_vmseq_vx_tama:
14919
  ID = Intrinsic::riscv_vmseq_mask;
14920
  PolicyAttrs = 3;
14921
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14922
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
14923
  IntrinsicTypes = {Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
14924
  break;
14925
case RISCVVector::BI__builtin_rvv_vmseq_vv_mu:
14926
case RISCVVector::BI__builtin_rvv_vmseq_vx_mu:
14927
  ID = Intrinsic::riscv_vmseq_mask;
14928
  PolicyAttrs = 1;
14929
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14930
  IntrinsicTypes = {Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
14931
  break;
14932
case RISCVVector::BI__builtin_rvv_vmset_m:
14933
  ID = Intrinsic::riscv_vmset;
14934
  PolicyAttrs = 3;
14935
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
14936
  break;
14937
case RISCVVector::BI__builtin_rvv_vmsge_vv:
14938
case RISCVVector::BI__builtin_rvv_vmsge_vx:
14939
  ID = Intrinsic::riscv_vmsge;
14940
  PolicyAttrs = 3;
14941
  IntrinsicTypes = {Ops[0]->getType(), Ops[1]->getType(), Ops.back()->getType()};
14942
  break;
14943
case RISCVVector::BI__builtin_rvv_vmsge_vv_tama:
14944
case RISCVVector::BI__builtin_rvv_vmsge_vx_tama:
14945
  ID = Intrinsic::riscv_vmsge_mask;
14946
  PolicyAttrs = 3;
14947
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14948
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
14949
  IntrinsicTypes = {Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
14950
  break;
14951
case RISCVVector::BI__builtin_rvv_vmsge_vv_mu:
14952
case RISCVVector::BI__builtin_rvv_vmsge_vx_mu:
14953
  ID = Intrinsic::riscv_vmsge_mask;
14954
  PolicyAttrs = 1;
14955
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14956
  IntrinsicTypes = {Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
14957
  break;
14958
case RISCVVector::BI__builtin_rvv_vmsgeu_vv:
14959
case RISCVVector::BI__builtin_rvv_vmsgeu_vx:
14960
  ID = Intrinsic::riscv_vmsgeu;
14961
  PolicyAttrs = 3;
14962
  IntrinsicTypes = {Ops[0]->getType(), Ops[1]->getType(), Ops.back()->getType()};
14963
  break;
14964
case RISCVVector::BI__builtin_rvv_vmsgeu_vv_tama:
14965
case RISCVVector::BI__builtin_rvv_vmsgeu_vx_tama:
14966
  ID = Intrinsic::riscv_vmsgeu_mask;
14967
  PolicyAttrs = 3;
14968
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14969
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
14970
  IntrinsicTypes = {Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
14971
  break;
14972
case RISCVVector::BI__builtin_rvv_vmsgeu_vv_mu:
14973
case RISCVVector::BI__builtin_rvv_vmsgeu_vx_mu:
14974
  ID = Intrinsic::riscv_vmsgeu_mask;
14975
  PolicyAttrs = 1;
14976
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14977
  IntrinsicTypes = {Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
14978
  break;
14979
case RISCVVector::BI__builtin_rvv_vmsgt_vv:
14980
case RISCVVector::BI__builtin_rvv_vmsgt_vx:
14981
  ID = Intrinsic::riscv_vmsgt;
14982
  PolicyAttrs = 3;
14983
  IntrinsicTypes = {Ops[0]->getType(), Ops[1]->getType(), Ops.back()->getType()};
14984
  break;
14985
case RISCVVector::BI__builtin_rvv_vmsgt_vv_tama:
14986
case RISCVVector::BI__builtin_rvv_vmsgt_vx_tama:
14987
  ID = Intrinsic::riscv_vmsgt_mask;
14988
  PolicyAttrs = 3;
14989
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14990
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
14991
  IntrinsicTypes = {Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
14992
  break;
14993
case RISCVVector::BI__builtin_rvv_vmsgt_vv_mu:
14994
case RISCVVector::BI__builtin_rvv_vmsgt_vx_mu:
14995
  ID = Intrinsic::riscv_vmsgt_mask;
14996
  PolicyAttrs = 1;
14997
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
14998
  IntrinsicTypes = {Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
14999
  break;
15000
case RISCVVector::BI__builtin_rvv_vmsgtu_vv:
15001
case RISCVVector::BI__builtin_rvv_vmsgtu_vx:
15002
  ID = Intrinsic::riscv_vmsgtu;
15003
  PolicyAttrs = 3;
15004
  IntrinsicTypes = {Ops[0]->getType(), Ops[1]->getType(), Ops.back()->getType()};
15005
  break;
15006
case RISCVVector::BI__builtin_rvv_vmsgtu_vv_tama:
15007
case RISCVVector::BI__builtin_rvv_vmsgtu_vx_tama:
15008
  ID = Intrinsic::riscv_vmsgtu_mask;
15009
  PolicyAttrs = 3;
15010
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15011
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15012
  IntrinsicTypes = {Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
15013
  break;
15014
case RISCVVector::BI__builtin_rvv_vmsgtu_vv_mu:
15015
case RISCVVector::BI__builtin_rvv_vmsgtu_vx_mu:
15016
  ID = Intrinsic::riscv_vmsgtu_mask;
15017
  PolicyAttrs = 1;
15018
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15019
  IntrinsicTypes = {Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
15020
  break;
15021
case RISCVVector::BI__builtin_rvv_vmsif_m:
15022
  ID = Intrinsic::riscv_vmsif;
15023
  PolicyAttrs = 3;
15024
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
15025
  break;
15026
case RISCVVector::BI__builtin_rvv_vmsif_m_tama:
15027
  ID = Intrinsic::riscv_vmsif_mask;
15028
  PolicyAttrs = 3;
15029
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15030
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15031
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
15032
  break;
15033
case RISCVVector::BI__builtin_rvv_vmsif_m_mu:
15034
  ID = Intrinsic::riscv_vmsif_mask;
15035
  PolicyAttrs = 1;
15036
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15037
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
15038
  break;
15039
case RISCVVector::BI__builtin_rvv_vmsle_vv:
15040
case RISCVVector::BI__builtin_rvv_vmsle_vx:
15041
  ID = Intrinsic::riscv_vmsle;
15042
  PolicyAttrs = 3;
15043
  IntrinsicTypes = {Ops[0]->getType(), Ops[1]->getType(), Ops.back()->getType()};
15044
  break;
15045
case RISCVVector::BI__builtin_rvv_vmsle_vv_tama:
15046
case RISCVVector::BI__builtin_rvv_vmsle_vx_tama:
15047
  ID = Intrinsic::riscv_vmsle_mask;
15048
  PolicyAttrs = 3;
15049
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15050
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15051
  IntrinsicTypes = {Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
15052
  break;
15053
case RISCVVector::BI__builtin_rvv_vmsle_vv_mu:
15054
case RISCVVector::BI__builtin_rvv_vmsle_vx_mu:
15055
  ID = Intrinsic::riscv_vmsle_mask;
15056
  PolicyAttrs = 1;
15057
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15058
  IntrinsicTypes = {Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
15059
  break;
15060
case RISCVVector::BI__builtin_rvv_vmsleu_vv:
15061
case RISCVVector::BI__builtin_rvv_vmsleu_vx:
15062
  ID = Intrinsic::riscv_vmsleu;
15063
  PolicyAttrs = 3;
15064
  IntrinsicTypes = {Ops[0]->getType(), Ops[1]->getType(), Ops.back()->getType()};
15065
  break;
15066
case RISCVVector::BI__builtin_rvv_vmsleu_vv_tama:
15067
case RISCVVector::BI__builtin_rvv_vmsleu_vx_tama:
15068
  ID = Intrinsic::riscv_vmsleu_mask;
15069
  PolicyAttrs = 3;
15070
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15071
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15072
  IntrinsicTypes = {Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
15073
  break;
15074
case RISCVVector::BI__builtin_rvv_vmsleu_vv_mu:
15075
case RISCVVector::BI__builtin_rvv_vmsleu_vx_mu:
15076
  ID = Intrinsic::riscv_vmsleu_mask;
15077
  PolicyAttrs = 1;
15078
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15079
  IntrinsicTypes = {Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
15080
  break;
15081
case RISCVVector::BI__builtin_rvv_vmslt_vv:
15082
case RISCVVector::BI__builtin_rvv_vmslt_vx:
15083
  ID = Intrinsic::riscv_vmslt;
15084
  PolicyAttrs = 3;
15085
  IntrinsicTypes = {Ops[0]->getType(), Ops[1]->getType(), Ops.back()->getType()};
15086
  break;
15087
case RISCVVector::BI__builtin_rvv_vmslt_vv_tama:
15088
case RISCVVector::BI__builtin_rvv_vmslt_vx_tama:
15089
  ID = Intrinsic::riscv_vmslt_mask;
15090
  PolicyAttrs = 3;
15091
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15092
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15093
  IntrinsicTypes = {Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
15094
  break;
15095
case RISCVVector::BI__builtin_rvv_vmslt_vv_mu:
15096
case RISCVVector::BI__builtin_rvv_vmslt_vx_mu:
15097
  ID = Intrinsic::riscv_vmslt_mask;
15098
  PolicyAttrs = 1;
15099
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15100
  IntrinsicTypes = {Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
15101
  break;
15102
case RISCVVector::BI__builtin_rvv_vmsltu_vv:
15103
case RISCVVector::BI__builtin_rvv_vmsltu_vx:
15104
  ID = Intrinsic::riscv_vmsltu;
15105
  PolicyAttrs = 3;
15106
  IntrinsicTypes = {Ops[0]->getType(), Ops[1]->getType(), Ops.back()->getType()};
15107
  break;
15108
case RISCVVector::BI__builtin_rvv_vmsltu_vv_tama:
15109
case RISCVVector::BI__builtin_rvv_vmsltu_vx_tama:
15110
  ID = Intrinsic::riscv_vmsltu_mask;
15111
  PolicyAttrs = 3;
15112
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15113
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15114
  IntrinsicTypes = {Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
15115
  break;
15116
case RISCVVector::BI__builtin_rvv_vmsltu_vv_mu:
15117
case RISCVVector::BI__builtin_rvv_vmsltu_vx_mu:
15118
  ID = Intrinsic::riscv_vmsltu_mask;
15119
  PolicyAttrs = 1;
15120
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15121
  IntrinsicTypes = {Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
15122
  break;
15123
case RISCVVector::BI__builtin_rvv_vmsne_vv:
15124
case RISCVVector::BI__builtin_rvv_vmsne_vx:
15125
  ID = Intrinsic::riscv_vmsne;
15126
  PolicyAttrs = 3;
15127
  IntrinsicTypes = {Ops[0]->getType(), Ops[1]->getType(), Ops.back()->getType()};
15128
  break;
15129
case RISCVVector::BI__builtin_rvv_vmsne_vv_tama:
15130
case RISCVVector::BI__builtin_rvv_vmsne_vx_tama:
15131
  ID = Intrinsic::riscv_vmsne_mask;
15132
  PolicyAttrs = 3;
15133
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15134
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15135
  IntrinsicTypes = {Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
15136
  break;
15137
case RISCVVector::BI__builtin_rvv_vmsne_vv_mu:
15138
case RISCVVector::BI__builtin_rvv_vmsne_vx_mu:
15139
  ID = Intrinsic::riscv_vmsne_mask;
15140
  PolicyAttrs = 1;
15141
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15142
  IntrinsicTypes = {Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
15143
  break;
15144
case RISCVVector::BI__builtin_rvv_vmsof_m:
15145
  ID = Intrinsic::riscv_vmsof;
15146
  PolicyAttrs = 3;
15147
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
15148
  break;
15149
case RISCVVector::BI__builtin_rvv_vmsof_m_tama:
15150
  ID = Intrinsic::riscv_vmsof_mask;
15151
  PolicyAttrs = 3;
15152
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15153
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15154
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
15155
  break;
15156
case RISCVVector::BI__builtin_rvv_vmsof_m_mu:
15157
  ID = Intrinsic::riscv_vmsof_mask;
15158
  PolicyAttrs = 1;
15159
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15160
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
15161
  break;
15162
case RISCVVector::BI__builtin_rvv_vmul_vv_tu:
15163
case RISCVVector::BI__builtin_rvv_vmul_vx_tu:
15164
  ID = Intrinsic::riscv_vmul;
15165
  PolicyAttrs = 2;
15166
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
15167
  break;
15168
case RISCVVector::BI__builtin_rvv_vmul_vv_ta:
15169
case RISCVVector::BI__builtin_rvv_vmul_vx_ta:
15170
  ID = Intrinsic::riscv_vmul;
15171
  PolicyAttrs = 3;
15172
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15173
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
15174
  break;
15175
case RISCVVector::BI__builtin_rvv_vmul_vv_tum:
15176
case RISCVVector::BI__builtin_rvv_vmul_vx_tum:
15177
  ID = Intrinsic::riscv_vmul_mask;
15178
  PolicyAttrs = 2;
15179
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15180
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15181
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
15182
  break;
15183
case RISCVVector::BI__builtin_rvv_vmul_vv_tama:
15184
case RISCVVector::BI__builtin_rvv_vmul_vx_tama:
15185
  ID = Intrinsic::riscv_vmul_mask;
15186
  PolicyAttrs = 3;
15187
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15188
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15189
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15190
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
15191
  break;
15192
case RISCVVector::BI__builtin_rvv_vmul_vv_tumu:
15193
case RISCVVector::BI__builtin_rvv_vmul_vx_tumu:
15194
  ID = Intrinsic::riscv_vmul_mask;
15195
  PolicyAttrs = 0;
15196
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15197
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15198
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
15199
  break;
15200
case RISCVVector::BI__builtin_rvv_vmul_vv_mu:
15201
case RISCVVector::BI__builtin_rvv_vmul_vx_mu:
15202
  ID = Intrinsic::riscv_vmul_mask;
15203
  PolicyAttrs = 1;
15204
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15205
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15206
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
15207
  break;
15208
case RISCVVector::BI__builtin_rvv_vmulh_vv_tu:
15209
case RISCVVector::BI__builtin_rvv_vmulh_vx_tu:
15210
  ID = Intrinsic::riscv_vmulh;
15211
  PolicyAttrs = 2;
15212
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
15213
  break;
15214
case RISCVVector::BI__builtin_rvv_vmulh_vv_ta:
15215
case RISCVVector::BI__builtin_rvv_vmulh_vx_ta:
15216
  ID = Intrinsic::riscv_vmulh;
15217
  PolicyAttrs = 3;
15218
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15219
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
15220
  break;
15221
case RISCVVector::BI__builtin_rvv_vmulh_vv_tum:
15222
case RISCVVector::BI__builtin_rvv_vmulh_vx_tum:
15223
  ID = Intrinsic::riscv_vmulh_mask;
15224
  PolicyAttrs = 2;
15225
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15226
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15227
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
15228
  break;
15229
case RISCVVector::BI__builtin_rvv_vmulh_vv_tama:
15230
case RISCVVector::BI__builtin_rvv_vmulh_vx_tama:
15231
  ID = Intrinsic::riscv_vmulh_mask;
15232
  PolicyAttrs = 3;
15233
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15234
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15235
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15236
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
15237
  break;
15238
case RISCVVector::BI__builtin_rvv_vmulh_vv_tumu:
15239
case RISCVVector::BI__builtin_rvv_vmulh_vx_tumu:
15240
  ID = Intrinsic::riscv_vmulh_mask;
15241
  PolicyAttrs = 0;
15242
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15243
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15244
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
15245
  break;
15246
case RISCVVector::BI__builtin_rvv_vmulh_vv_mu:
15247
case RISCVVector::BI__builtin_rvv_vmulh_vx_mu:
15248
  ID = Intrinsic::riscv_vmulh_mask;
15249
  PolicyAttrs = 1;
15250
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15251
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15252
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
15253
  break;
15254
case RISCVVector::BI__builtin_rvv_vmulhsu_vv_tu:
15255
case RISCVVector::BI__builtin_rvv_vmulhsu_vx_tu:
15256
  ID = Intrinsic::riscv_vmulhsu;
15257
  PolicyAttrs = 2;
15258
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
15259
  break;
15260
case RISCVVector::BI__builtin_rvv_vmulhsu_vv_ta:
15261
case RISCVVector::BI__builtin_rvv_vmulhsu_vx_ta:
15262
  ID = Intrinsic::riscv_vmulhsu;
15263
  PolicyAttrs = 3;
15264
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15265
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
15266
  break;
15267
case RISCVVector::BI__builtin_rvv_vmulhsu_vv_tum:
15268
case RISCVVector::BI__builtin_rvv_vmulhsu_vx_tum:
15269
  ID = Intrinsic::riscv_vmulhsu_mask;
15270
  PolicyAttrs = 2;
15271
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15272
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15273
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
15274
  break;
15275
case RISCVVector::BI__builtin_rvv_vmulhsu_vv_tama:
15276
case RISCVVector::BI__builtin_rvv_vmulhsu_vx_tama:
15277
  ID = Intrinsic::riscv_vmulhsu_mask;
15278
  PolicyAttrs = 3;
15279
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15280
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15281
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15282
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
15283
  break;
15284
case RISCVVector::BI__builtin_rvv_vmulhsu_vv_tumu:
15285
case RISCVVector::BI__builtin_rvv_vmulhsu_vx_tumu:
15286
  ID = Intrinsic::riscv_vmulhsu_mask;
15287
  PolicyAttrs = 0;
15288
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15289
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15290
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
15291
  break;
15292
case RISCVVector::BI__builtin_rvv_vmulhsu_vv_mu:
15293
case RISCVVector::BI__builtin_rvv_vmulhsu_vx_mu:
15294
  ID = Intrinsic::riscv_vmulhsu_mask;
15295
  PolicyAttrs = 1;
15296
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15297
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15298
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
15299
  break;
15300
case RISCVVector::BI__builtin_rvv_vmulhu_vv_tu:
15301
case RISCVVector::BI__builtin_rvv_vmulhu_vx_tu:
15302
  ID = Intrinsic::riscv_vmulhu;
15303
  PolicyAttrs = 2;
15304
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
15305
  break;
15306
case RISCVVector::BI__builtin_rvv_vmulhu_vv_ta:
15307
case RISCVVector::BI__builtin_rvv_vmulhu_vx_ta:
15308
  ID = Intrinsic::riscv_vmulhu;
15309
  PolicyAttrs = 3;
15310
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15311
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
15312
  break;
15313
case RISCVVector::BI__builtin_rvv_vmulhu_vv_tum:
15314
case RISCVVector::BI__builtin_rvv_vmulhu_vx_tum:
15315
  ID = Intrinsic::riscv_vmulhu_mask;
15316
  PolicyAttrs = 2;
15317
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15318
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15319
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
15320
  break;
15321
case RISCVVector::BI__builtin_rvv_vmulhu_vv_tama:
15322
case RISCVVector::BI__builtin_rvv_vmulhu_vx_tama:
15323
  ID = Intrinsic::riscv_vmulhu_mask;
15324
  PolicyAttrs = 3;
15325
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15326
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15327
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15328
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
15329
  break;
15330
case RISCVVector::BI__builtin_rvv_vmulhu_vv_tumu:
15331
case RISCVVector::BI__builtin_rvv_vmulhu_vx_tumu:
15332
  ID = Intrinsic::riscv_vmulhu_mask;
15333
  PolicyAttrs = 0;
15334
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15335
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15336
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
15337
  break;
15338
case RISCVVector::BI__builtin_rvv_vmulhu_vv_mu:
15339
case RISCVVector::BI__builtin_rvv_vmulhu_vx_mu:
15340
  ID = Intrinsic::riscv_vmulhu_mask;
15341
  PolicyAttrs = 1;
15342
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15343
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15344
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
15345
  break;
15346
case RISCVVector::BI__builtin_rvv_vmv_s_x_tu:
15347
  ID = Intrinsic::riscv_vmv_s_x;
15348
  PolicyAttrs = 2;
15349
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
15350
  break;
15351
case RISCVVector::BI__builtin_rvv_vmv_s_x_ta:
15352
  ID = Intrinsic::riscv_vmv_s_x;
15353
  PolicyAttrs = 3;
15354
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15355
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
15356
  break;
15357
case RISCVVector::BI__builtin_rvv_vmv_v_v_tu:
15358
  ID = Intrinsic::riscv_vmv_v_v;
15359
  PolicyAttrs = 2;
15360
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
15361
  break;
15362
case RISCVVector::BI__builtin_rvv_vmv_v_v_ta:
15363
  ID = Intrinsic::riscv_vmv_v_v;
15364
  PolicyAttrs = 3;
15365
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15366
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
15367
  break;
15368
case RISCVVector::BI__builtin_rvv_vmv_v_x_tu:
15369
  ID = Intrinsic::riscv_vmv_v_x;
15370
  PolicyAttrs = 2;
15371
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
15372
  break;
15373
case RISCVVector::BI__builtin_rvv_vmv_v_x_ta:
15374
  ID = Intrinsic::riscv_vmv_v_x;
15375
  PolicyAttrs = 3;
15376
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15377
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
15378
  break;
15379
case RISCVVector::BI__builtin_rvv_vmv_x_s:
15380
  ID = Intrinsic::riscv_vmv_x_s;
15381
  PolicyAttrs = 3;
15382
  IntrinsicTypes = {Ops[0]->getType()};
15383
  break;
15384
case RISCVVector::BI__builtin_rvv_vmxnor_mm:
15385
  ID = Intrinsic::riscv_vmxnor;
15386
  PolicyAttrs = 3;
15387
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
15388
  break;
15389
case RISCVVector::BI__builtin_rvv_vmxor_mm:
15390
  ID = Intrinsic::riscv_vmxor;
15391
  PolicyAttrs = 3;
15392
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
15393
  break;
15394
case RISCVVector::BI__builtin_rvv_vnclip_wv_tu:
15395
case RISCVVector::BI__builtin_rvv_vnclip_wx_tu:
15396
  ID = Intrinsic::riscv_vnclip;
15397
  PolicyAttrs = 2;
15398
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
15399
  break;
15400
case RISCVVector::BI__builtin_rvv_vnclip_wv_ta:
15401
case RISCVVector::BI__builtin_rvv_vnclip_wx_ta:
15402
  ID = Intrinsic::riscv_vnclip;
15403
  PolicyAttrs = 3;
15404
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15405
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
15406
  break;
15407
case RISCVVector::BI__builtin_rvv_vnclip_wv_tum:
15408
case RISCVVector::BI__builtin_rvv_vnclip_wx_tum:
15409
  ID = Intrinsic::riscv_vnclip_mask;
15410
  PolicyAttrs = 2;
15411
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15412
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15413
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
15414
  break;
15415
case RISCVVector::BI__builtin_rvv_vnclip_wv_tama:
15416
case RISCVVector::BI__builtin_rvv_vnclip_wx_tama:
15417
  ID = Intrinsic::riscv_vnclip_mask;
15418
  PolicyAttrs = 3;
15419
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15420
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15421
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15422
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
15423
  break;
15424
case RISCVVector::BI__builtin_rvv_vnclip_wv_tumu:
15425
case RISCVVector::BI__builtin_rvv_vnclip_wx_tumu:
15426
  ID = Intrinsic::riscv_vnclip_mask;
15427
  PolicyAttrs = 0;
15428
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15429
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15430
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
15431
  break;
15432
case RISCVVector::BI__builtin_rvv_vnclip_wv_mu:
15433
case RISCVVector::BI__builtin_rvv_vnclip_wx_mu:
15434
  ID = Intrinsic::riscv_vnclip_mask;
15435
  PolicyAttrs = 1;
15436
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15437
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15438
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
15439
  break;
15440
case RISCVVector::BI__builtin_rvv_vnclipu_wv_tu:
15441
case RISCVVector::BI__builtin_rvv_vnclipu_wx_tu:
15442
  ID = Intrinsic::riscv_vnclipu;
15443
  PolicyAttrs = 2;
15444
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
15445
  break;
15446
case RISCVVector::BI__builtin_rvv_vnclipu_wv_ta:
15447
case RISCVVector::BI__builtin_rvv_vnclipu_wx_ta:
15448
  ID = Intrinsic::riscv_vnclipu;
15449
  PolicyAttrs = 3;
15450
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15451
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
15452
  break;
15453
case RISCVVector::BI__builtin_rvv_vnclipu_wv_tum:
15454
case RISCVVector::BI__builtin_rvv_vnclipu_wx_tum:
15455
  ID = Intrinsic::riscv_vnclipu_mask;
15456
  PolicyAttrs = 2;
15457
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15458
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15459
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
15460
  break;
15461
case RISCVVector::BI__builtin_rvv_vnclipu_wv_tama:
15462
case RISCVVector::BI__builtin_rvv_vnclipu_wx_tama:
15463
  ID = Intrinsic::riscv_vnclipu_mask;
15464
  PolicyAttrs = 3;
15465
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15466
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15467
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15468
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
15469
  break;
15470
case RISCVVector::BI__builtin_rvv_vnclipu_wv_tumu:
15471
case RISCVVector::BI__builtin_rvv_vnclipu_wx_tumu:
15472
  ID = Intrinsic::riscv_vnclipu_mask;
15473
  PolicyAttrs = 0;
15474
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15475
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15476
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
15477
  break;
15478
case RISCVVector::BI__builtin_rvv_vnclipu_wv_mu:
15479
case RISCVVector::BI__builtin_rvv_vnclipu_wx_mu:
15480
  ID = Intrinsic::riscv_vnclipu_mask;
15481
  PolicyAttrs = 1;
15482
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15483
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15484
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
15485
  break;
15486
case RISCVVector::BI__builtin_rvv_vnmsac_vv_tu:
15487
case RISCVVector::BI__builtin_rvv_vnmsac_vx_tu:
15488
  ID = Intrinsic::riscv_vnmsac;
15489
  PolicyAttrs = 2;
15490
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15491
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
15492
  break;
15493
case RISCVVector::BI__builtin_rvv_vnmsac_vv_ta:
15494
case RISCVVector::BI__builtin_rvv_vnmsac_vx_ta:
15495
  ID = Intrinsic::riscv_vnmsac;
15496
  PolicyAttrs = 3;
15497
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15498
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
15499
  break;
15500
case RISCVVector::BI__builtin_rvv_vnmsac_vv_tum:
15501
case RISCVVector::BI__builtin_rvv_vnmsac_vx_tum:
15502
  ID = Intrinsic::riscv_vnmsac_mask;
15503
  PolicyAttrs = 2;
15504
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15505
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15506
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
15507
  break;
15508
case RISCVVector::BI__builtin_rvv_vnmsac_vv_tama:
15509
case RISCVVector::BI__builtin_rvv_vnmsac_vx_tama:
15510
  ID = Intrinsic::riscv_vnmsac_mask;
15511
  PolicyAttrs = 3;
15512
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15513
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15514
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
15515
  break;
15516
case RISCVVector::BI__builtin_rvv_vnmsac_vv_tumu:
15517
case RISCVVector::BI__builtin_rvv_vnmsac_vx_tumu:
15518
  ID = Intrinsic::riscv_vnmsac_mask;
15519
  PolicyAttrs = 0;
15520
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15521
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15522
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
15523
  break;
15524
case RISCVVector::BI__builtin_rvv_vnmsac_vv_mu:
15525
case RISCVVector::BI__builtin_rvv_vnmsac_vx_mu:
15526
  ID = Intrinsic::riscv_vnmsac_mask;
15527
  PolicyAttrs = 1;
15528
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15529
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15530
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
15531
  break;
15532
case RISCVVector::BI__builtin_rvv_vnmsub_vv_tu:
15533
case RISCVVector::BI__builtin_rvv_vnmsub_vx_tu:
15534
  ID = Intrinsic::riscv_vnmsub;
15535
  PolicyAttrs = 2;
15536
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15537
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
15538
  break;
15539
case RISCVVector::BI__builtin_rvv_vnmsub_vv_ta:
15540
case RISCVVector::BI__builtin_rvv_vnmsub_vx_ta:
15541
  ID = Intrinsic::riscv_vnmsub;
15542
  PolicyAttrs = 3;
15543
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15544
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
15545
  break;
15546
case RISCVVector::BI__builtin_rvv_vnmsub_vv_tum:
15547
case RISCVVector::BI__builtin_rvv_vnmsub_vx_tum:
15548
  ID = Intrinsic::riscv_vnmsub_mask;
15549
  PolicyAttrs = 2;
15550
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15551
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15552
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
15553
  break;
15554
case RISCVVector::BI__builtin_rvv_vnmsub_vv_tama:
15555
case RISCVVector::BI__builtin_rvv_vnmsub_vx_tama:
15556
  ID = Intrinsic::riscv_vnmsub_mask;
15557
  PolicyAttrs = 3;
15558
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15559
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15560
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
15561
  break;
15562
case RISCVVector::BI__builtin_rvv_vnmsub_vv_tumu:
15563
case RISCVVector::BI__builtin_rvv_vnmsub_vx_tumu:
15564
  ID = Intrinsic::riscv_vnmsub_mask;
15565
  PolicyAttrs = 0;
15566
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15567
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15568
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
15569
  break;
15570
case RISCVVector::BI__builtin_rvv_vnmsub_vv_mu:
15571
case RISCVVector::BI__builtin_rvv_vnmsub_vx_mu:
15572
  ID = Intrinsic::riscv_vnmsub_mask;
15573
  PolicyAttrs = 1;
15574
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15575
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15576
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
15577
  break;
15578
case RISCVVector::BI__builtin_rvv_vnsra_wv_tu:
15579
case RISCVVector::BI__builtin_rvv_vnsra_wx_tu:
15580
  ID = Intrinsic::riscv_vnsra;
15581
  PolicyAttrs = 2;
15582
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
15583
  break;
15584
case RISCVVector::BI__builtin_rvv_vnsra_wv_ta:
15585
case RISCVVector::BI__builtin_rvv_vnsra_wx_ta:
15586
  ID = Intrinsic::riscv_vnsra;
15587
  PolicyAttrs = 3;
15588
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15589
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
15590
  break;
15591
case RISCVVector::BI__builtin_rvv_vnsra_wv_tum:
15592
case RISCVVector::BI__builtin_rvv_vnsra_wx_tum:
15593
  ID = Intrinsic::riscv_vnsra_mask;
15594
  PolicyAttrs = 2;
15595
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15596
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15597
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
15598
  break;
15599
case RISCVVector::BI__builtin_rvv_vnsra_wv_tama:
15600
case RISCVVector::BI__builtin_rvv_vnsra_wx_tama:
15601
  ID = Intrinsic::riscv_vnsra_mask;
15602
  PolicyAttrs = 3;
15603
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15604
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15605
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15606
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
15607
  break;
15608
case RISCVVector::BI__builtin_rvv_vnsra_wv_tumu:
15609
case RISCVVector::BI__builtin_rvv_vnsra_wx_tumu:
15610
  ID = Intrinsic::riscv_vnsra_mask;
15611
  PolicyAttrs = 0;
15612
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15613
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15614
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
15615
  break;
15616
case RISCVVector::BI__builtin_rvv_vnsra_wv_mu:
15617
case RISCVVector::BI__builtin_rvv_vnsra_wx_mu:
15618
  ID = Intrinsic::riscv_vnsra_mask;
15619
  PolicyAttrs = 1;
15620
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15621
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15622
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
15623
  break;
15624
case RISCVVector::BI__builtin_rvv_vnsrl_wv_tu:
15625
case RISCVVector::BI__builtin_rvv_vnsrl_wx_tu:
15626
  ID = Intrinsic::riscv_vnsrl;
15627
  PolicyAttrs = 2;
15628
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
15629
  break;
15630
case RISCVVector::BI__builtin_rvv_vncvt_x_x_w_tu:
15631
  ID = Intrinsic::riscv_vnsrl;
15632
  PolicyAttrs = 2;
15633
IsMasked = false;
15634
 
15635
      {
15636
        if (IsMasked) {
15637
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15638
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
15639
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15640
        } else {
15641
          if (PolicyAttrs & RVV_VTA)
15642
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15643
        }
15644
        Ops.insert(Ops.begin() + 2, llvm::Constant::getNullValue(Ops.back()->getType())); 
15645
        if (IsMasked) {
15646
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15647
          // maskedoff, op1, xlen, mask, vl
15648
          IntrinsicTypes = {ResultType,
15649
                            Ops[1]->getType(),
15650
                            Ops[4]->getType(),
15651
                            Ops[4]->getType()};
15652
        } else {
15653
          // passthru, op1, xlen, vl
15654
          IntrinsicTypes = {ResultType,
15655
                  Ops[1]->getType(),
15656
                  Ops[3]->getType(),
15657
                  Ops[3]->getType()};
15658
        }
15659
        break;
15660
      }
15661
      break;
15662
case RISCVVector::BI__builtin_rvv_vnsrl_wv_ta:
15663
case RISCVVector::BI__builtin_rvv_vnsrl_wx_ta:
15664
  ID = Intrinsic::riscv_vnsrl;
15665
  PolicyAttrs = 3;
15666
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15667
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
15668
  break;
15669
case RISCVVector::BI__builtin_rvv_vncvt_x_x_w_ta:
15670
  ID = Intrinsic::riscv_vnsrl;
15671
  PolicyAttrs = 3;
15672
IsMasked = false;
15673
 
15674
      {
15675
        if (IsMasked) {
15676
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15677
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
15678
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15679
        } else {
15680
          if (PolicyAttrs & RVV_VTA)
15681
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15682
        }
15683
        Ops.insert(Ops.begin() + 2, llvm::Constant::getNullValue(Ops.back()->getType())); 
15684
        if (IsMasked) {
15685
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15686
          // maskedoff, op1, xlen, mask, vl
15687
          IntrinsicTypes = {ResultType,
15688
                            Ops[1]->getType(),
15689
                            Ops[4]->getType(),
15690
                            Ops[4]->getType()};
15691
        } else {
15692
          // passthru, op1, xlen, vl
15693
          IntrinsicTypes = {ResultType,
15694
                  Ops[1]->getType(),
15695
                  Ops[3]->getType(),
15696
                  Ops[3]->getType()};
15697
        }
15698
        break;
15699
      }
15700
      break;
15701
case RISCVVector::BI__builtin_rvv_vnsrl_wv_tum:
15702
case RISCVVector::BI__builtin_rvv_vnsrl_wx_tum:
15703
  ID = Intrinsic::riscv_vnsrl_mask;
15704
  PolicyAttrs = 2;
15705
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15706
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15707
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
15708
  break;
15709
case RISCVVector::BI__builtin_rvv_vncvt_x_x_w_tum:
15710
  ID = Intrinsic::riscv_vnsrl_mask;
15711
  PolicyAttrs = 2;
15712
IsMasked = true;
15713
 
15714
      {
15715
        if (IsMasked) {
15716
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15717
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
15718
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15719
        } else {
15720
          if (PolicyAttrs & RVV_VTA)
15721
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15722
        }
15723
        Ops.insert(Ops.begin() + 2, llvm::Constant::getNullValue(Ops.back()->getType())); 
15724
        if (IsMasked) {
15725
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15726
          // maskedoff, op1, xlen, mask, vl
15727
          IntrinsicTypes = {ResultType,
15728
                            Ops[1]->getType(),
15729
                            Ops[4]->getType(),
15730
                            Ops[4]->getType()};
15731
        } else {
15732
          // passthru, op1, xlen, vl
15733
          IntrinsicTypes = {ResultType,
15734
                  Ops[1]->getType(),
15735
                  Ops[3]->getType(),
15736
                  Ops[3]->getType()};
15737
        }
15738
        break;
15739
      }
15740
      break;
15741
case RISCVVector::BI__builtin_rvv_vnsrl_wv_tama:
15742
case RISCVVector::BI__builtin_rvv_vnsrl_wx_tama:
15743
  ID = Intrinsic::riscv_vnsrl_mask;
15744
  PolicyAttrs = 3;
15745
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15746
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15747
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15748
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
15749
  break;
15750
case RISCVVector::BI__builtin_rvv_vncvt_x_x_w_tama:
15751
  ID = Intrinsic::riscv_vnsrl_mask;
15752
  PolicyAttrs = 3;
15753
IsMasked = true;
15754
 
15755
      {
15756
        if (IsMasked) {
15757
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15758
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
15759
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15760
        } else {
15761
          if (PolicyAttrs & RVV_VTA)
15762
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15763
        }
15764
        Ops.insert(Ops.begin() + 2, llvm::Constant::getNullValue(Ops.back()->getType())); 
15765
        if (IsMasked) {
15766
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15767
          // maskedoff, op1, xlen, mask, vl
15768
          IntrinsicTypes = {ResultType,
15769
                            Ops[1]->getType(),
15770
                            Ops[4]->getType(),
15771
                            Ops[4]->getType()};
15772
        } else {
15773
          // passthru, op1, xlen, vl
15774
          IntrinsicTypes = {ResultType,
15775
                  Ops[1]->getType(),
15776
                  Ops[3]->getType(),
15777
                  Ops[3]->getType()};
15778
        }
15779
        break;
15780
      }
15781
      break;
15782
case RISCVVector::BI__builtin_rvv_vnsrl_wv_tumu:
15783
case RISCVVector::BI__builtin_rvv_vnsrl_wx_tumu:
15784
  ID = Intrinsic::riscv_vnsrl_mask;
15785
  PolicyAttrs = 0;
15786
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15787
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15788
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
15789
  break;
15790
case RISCVVector::BI__builtin_rvv_vncvt_x_x_w_tumu:
15791
  ID = Intrinsic::riscv_vnsrl_mask;
15792
  PolicyAttrs = 0;
15793
IsMasked = true;
15794
 
15795
      {
15796
        if (IsMasked) {
15797
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15798
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
15799
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15800
        } else {
15801
          if (PolicyAttrs & RVV_VTA)
15802
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15803
        }
15804
        Ops.insert(Ops.begin() + 2, llvm::Constant::getNullValue(Ops.back()->getType())); 
15805
        if (IsMasked) {
15806
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15807
          // maskedoff, op1, xlen, mask, vl
15808
          IntrinsicTypes = {ResultType,
15809
                            Ops[1]->getType(),
15810
                            Ops[4]->getType(),
15811
                            Ops[4]->getType()};
15812
        } else {
15813
          // passthru, op1, xlen, vl
15814
          IntrinsicTypes = {ResultType,
15815
                  Ops[1]->getType(),
15816
                  Ops[3]->getType(),
15817
                  Ops[3]->getType()};
15818
        }
15819
        break;
15820
      }
15821
      break;
15822
case RISCVVector::BI__builtin_rvv_vnsrl_wv_mu:
15823
case RISCVVector::BI__builtin_rvv_vnsrl_wx_mu:
15824
  ID = Intrinsic::riscv_vnsrl_mask;
15825
  PolicyAttrs = 1;
15826
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15827
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15828
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
15829
  break;
15830
case RISCVVector::BI__builtin_rvv_vncvt_x_x_w_mu:
15831
  ID = Intrinsic::riscv_vnsrl_mask;
15832
  PolicyAttrs = 1;
15833
IsMasked = true;
15834
 
15835
      {
15836
        if (IsMasked) {
15837
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15838
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
15839
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15840
        } else {
15841
          if (PolicyAttrs & RVV_VTA)
15842
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15843
        }
15844
        Ops.insert(Ops.begin() + 2, llvm::Constant::getNullValue(Ops.back()->getType())); 
15845
        if (IsMasked) {
15846
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15847
          // maskedoff, op1, xlen, mask, vl
15848
          IntrinsicTypes = {ResultType,
15849
                            Ops[1]->getType(),
15850
                            Ops[4]->getType(),
15851
                            Ops[4]->getType()};
15852
        } else {
15853
          // passthru, op1, xlen, vl
15854
          IntrinsicTypes = {ResultType,
15855
                  Ops[1]->getType(),
15856
                  Ops[3]->getType(),
15857
                  Ops[3]->getType()};
15858
        }
15859
        break;
15860
      }
15861
      break;
15862
case RISCVVector::BI__builtin_rvv_vor_vv_tu:
15863
case RISCVVector::BI__builtin_rvv_vor_vx_tu:
15864
  ID = Intrinsic::riscv_vor;
15865
  PolicyAttrs = 2;
15866
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
15867
  break;
15868
case RISCVVector::BI__builtin_rvv_vor_vv_ta:
15869
case RISCVVector::BI__builtin_rvv_vor_vx_ta:
15870
  ID = Intrinsic::riscv_vor;
15871
  PolicyAttrs = 3;
15872
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15873
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
15874
  break;
15875
case RISCVVector::BI__builtin_rvv_vor_vv_tum:
15876
case RISCVVector::BI__builtin_rvv_vor_vx_tum:
15877
  ID = Intrinsic::riscv_vor_mask;
15878
  PolicyAttrs = 2;
15879
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15880
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15881
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
15882
  break;
15883
case RISCVVector::BI__builtin_rvv_vor_vv_tama:
15884
case RISCVVector::BI__builtin_rvv_vor_vx_tama:
15885
  ID = Intrinsic::riscv_vor_mask;
15886
  PolicyAttrs = 3;
15887
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15888
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15889
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15890
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
15891
  break;
15892
case RISCVVector::BI__builtin_rvv_vor_vv_tumu:
15893
case RISCVVector::BI__builtin_rvv_vor_vx_tumu:
15894
  ID = Intrinsic::riscv_vor_mask;
15895
  PolicyAttrs = 0;
15896
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15897
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15898
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
15899
  break;
15900
case RISCVVector::BI__builtin_rvv_vor_vv_mu:
15901
case RISCVVector::BI__builtin_rvv_vor_vx_mu:
15902
  ID = Intrinsic::riscv_vor_mask;
15903
  PolicyAttrs = 1;
15904
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15905
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
15906
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
15907
  break;
15908
case RISCVVector::BI__builtin_rvv_vredand_vs_tu:
15909
  ID = Intrinsic::riscv_vredand;
15910
  PolicyAttrs = 2;
15911
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
15912
  break;
15913
case RISCVVector::BI__builtin_rvv_vredand_vs_ta:
15914
  ID = Intrinsic::riscv_vredand;
15915
  PolicyAttrs = 3;
15916
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15917
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
15918
  break;
15919
case RISCVVector::BI__builtin_rvv_vredand_vs_tum:
15920
  ID = Intrinsic::riscv_vredand_mask;
15921
  PolicyAttrs = 2;
15922
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15923
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
15924
  break;
15925
case RISCVVector::BI__builtin_rvv_vredand_vs_tama:
15926
  ID = Intrinsic::riscv_vredand_mask;
15927
  PolicyAttrs = 3;
15928
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15929
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15930
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
15931
  break;
15932
case RISCVVector::BI__builtin_rvv_vredmax_vs_tu:
15933
  ID = Intrinsic::riscv_vredmax;
15934
  PolicyAttrs = 2;
15935
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
15936
  break;
15937
case RISCVVector::BI__builtin_rvv_vredmax_vs_ta:
15938
  ID = Intrinsic::riscv_vredmax;
15939
  PolicyAttrs = 3;
15940
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15941
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
15942
  break;
15943
case RISCVVector::BI__builtin_rvv_vredmax_vs_tum:
15944
  ID = Intrinsic::riscv_vredmax_mask;
15945
  PolicyAttrs = 2;
15946
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15947
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
15948
  break;
15949
case RISCVVector::BI__builtin_rvv_vredmax_vs_tama:
15950
  ID = Intrinsic::riscv_vredmax_mask;
15951
  PolicyAttrs = 3;
15952
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15953
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15954
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
15955
  break;
15956
case RISCVVector::BI__builtin_rvv_vredmaxu_vs_tu:
15957
  ID = Intrinsic::riscv_vredmaxu;
15958
  PolicyAttrs = 2;
15959
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
15960
  break;
15961
case RISCVVector::BI__builtin_rvv_vredmaxu_vs_ta:
15962
  ID = Intrinsic::riscv_vredmaxu;
15963
  PolicyAttrs = 3;
15964
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15965
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
15966
  break;
15967
case RISCVVector::BI__builtin_rvv_vredmaxu_vs_tum:
15968
  ID = Intrinsic::riscv_vredmaxu_mask;
15969
  PolicyAttrs = 2;
15970
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15971
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
15972
  break;
15973
case RISCVVector::BI__builtin_rvv_vredmaxu_vs_tama:
15974
  ID = Intrinsic::riscv_vredmaxu_mask;
15975
  PolicyAttrs = 3;
15976
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15977
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15978
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
15979
  break;
15980
case RISCVVector::BI__builtin_rvv_vredmin_vs_tu:
15981
  ID = Intrinsic::riscv_vredmin;
15982
  PolicyAttrs = 2;
15983
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
15984
  break;
15985
case RISCVVector::BI__builtin_rvv_vredmin_vs_ta:
15986
  ID = Intrinsic::riscv_vredmin;
15987
  PolicyAttrs = 3;
15988
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
15989
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
15990
  break;
15991
case RISCVVector::BI__builtin_rvv_vredmin_vs_tum:
15992
  ID = Intrinsic::riscv_vredmin_mask;
15993
  PolicyAttrs = 2;
15994
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
15995
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
15996
  break;
15997
case RISCVVector::BI__builtin_rvv_vredmin_vs_tama:
15998
  ID = Intrinsic::riscv_vredmin_mask;
15999
  PolicyAttrs = 3;
16000
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16001
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16002
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
16003
  break;
16004
case RISCVVector::BI__builtin_rvv_vredminu_vs_tu:
16005
  ID = Intrinsic::riscv_vredminu;
16006
  PolicyAttrs = 2;
16007
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
16008
  break;
16009
case RISCVVector::BI__builtin_rvv_vredminu_vs_ta:
16010
  ID = Intrinsic::riscv_vredminu;
16011
  PolicyAttrs = 3;
16012
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16013
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
16014
  break;
16015
case RISCVVector::BI__builtin_rvv_vredminu_vs_tum:
16016
  ID = Intrinsic::riscv_vredminu_mask;
16017
  PolicyAttrs = 2;
16018
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16019
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
16020
  break;
16021
case RISCVVector::BI__builtin_rvv_vredminu_vs_tama:
16022
  ID = Intrinsic::riscv_vredminu_mask;
16023
  PolicyAttrs = 3;
16024
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16025
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16026
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
16027
  break;
16028
case RISCVVector::BI__builtin_rvv_vredor_vs_tu:
16029
  ID = Intrinsic::riscv_vredor;
16030
  PolicyAttrs = 2;
16031
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
16032
  break;
16033
case RISCVVector::BI__builtin_rvv_vredor_vs_ta:
16034
  ID = Intrinsic::riscv_vredor;
16035
  PolicyAttrs = 3;
16036
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16037
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
16038
  break;
16039
case RISCVVector::BI__builtin_rvv_vredor_vs_tum:
16040
  ID = Intrinsic::riscv_vredor_mask;
16041
  PolicyAttrs = 2;
16042
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16043
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
16044
  break;
16045
case RISCVVector::BI__builtin_rvv_vredor_vs_tama:
16046
  ID = Intrinsic::riscv_vredor_mask;
16047
  PolicyAttrs = 3;
16048
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16049
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16050
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
16051
  break;
16052
case RISCVVector::BI__builtin_rvv_vredsum_vs_tu:
16053
  ID = Intrinsic::riscv_vredsum;
16054
  PolicyAttrs = 2;
16055
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
16056
  break;
16057
case RISCVVector::BI__builtin_rvv_vredsum_vs_ta:
16058
  ID = Intrinsic::riscv_vredsum;
16059
  PolicyAttrs = 3;
16060
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16061
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
16062
  break;
16063
case RISCVVector::BI__builtin_rvv_vredsum_vs_tum:
16064
  ID = Intrinsic::riscv_vredsum_mask;
16065
  PolicyAttrs = 2;
16066
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16067
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
16068
  break;
16069
case RISCVVector::BI__builtin_rvv_vredsum_vs_tama:
16070
  ID = Intrinsic::riscv_vredsum_mask;
16071
  PolicyAttrs = 3;
16072
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16073
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16074
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
16075
  break;
16076
case RISCVVector::BI__builtin_rvv_vredxor_vs_tu:
16077
  ID = Intrinsic::riscv_vredxor;
16078
  PolicyAttrs = 2;
16079
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
16080
  break;
16081
case RISCVVector::BI__builtin_rvv_vredxor_vs_ta:
16082
  ID = Intrinsic::riscv_vredxor;
16083
  PolicyAttrs = 3;
16084
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16085
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
16086
  break;
16087
case RISCVVector::BI__builtin_rvv_vredxor_vs_tum:
16088
  ID = Intrinsic::riscv_vredxor_mask;
16089
  PolicyAttrs = 2;
16090
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16091
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
16092
  break;
16093
case RISCVVector::BI__builtin_rvv_vredxor_vs_tama:
16094
  ID = Intrinsic::riscv_vredxor_mask;
16095
  PolicyAttrs = 3;
16096
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16097
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16098
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
16099
  break;
16100
case RISCVVector::BI__builtin_rvv_vrem_vv_tu:
16101
case RISCVVector::BI__builtin_rvv_vrem_vx_tu:
16102
  ID = Intrinsic::riscv_vrem;
16103
  PolicyAttrs = 2;
16104
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16105
  break;
16106
case RISCVVector::BI__builtin_rvv_vrem_vv_ta:
16107
case RISCVVector::BI__builtin_rvv_vrem_vx_ta:
16108
  ID = Intrinsic::riscv_vrem;
16109
  PolicyAttrs = 3;
16110
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16111
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16112
  break;
16113
case RISCVVector::BI__builtin_rvv_vrem_vv_tum:
16114
case RISCVVector::BI__builtin_rvv_vrem_vx_tum:
16115
  ID = Intrinsic::riscv_vrem_mask;
16116
  PolicyAttrs = 2;
16117
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16118
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16119
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16120
  break;
16121
case RISCVVector::BI__builtin_rvv_vrem_vv_tama:
16122
case RISCVVector::BI__builtin_rvv_vrem_vx_tama:
16123
  ID = Intrinsic::riscv_vrem_mask;
16124
  PolicyAttrs = 3;
16125
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16126
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16127
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16128
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16129
  break;
16130
case RISCVVector::BI__builtin_rvv_vrem_vv_tumu:
16131
case RISCVVector::BI__builtin_rvv_vrem_vx_tumu:
16132
  ID = Intrinsic::riscv_vrem_mask;
16133
  PolicyAttrs = 0;
16134
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16135
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16136
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16137
  break;
16138
case RISCVVector::BI__builtin_rvv_vrem_vv_mu:
16139
case RISCVVector::BI__builtin_rvv_vrem_vx_mu:
16140
  ID = Intrinsic::riscv_vrem_mask;
16141
  PolicyAttrs = 1;
16142
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16143
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16144
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16145
  break;
16146
case RISCVVector::BI__builtin_rvv_vremu_vv_tu:
16147
case RISCVVector::BI__builtin_rvv_vremu_vx_tu:
16148
  ID = Intrinsic::riscv_vremu;
16149
  PolicyAttrs = 2;
16150
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16151
  break;
16152
case RISCVVector::BI__builtin_rvv_vremu_vv_ta:
16153
case RISCVVector::BI__builtin_rvv_vremu_vx_ta:
16154
  ID = Intrinsic::riscv_vremu;
16155
  PolicyAttrs = 3;
16156
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16157
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16158
  break;
16159
case RISCVVector::BI__builtin_rvv_vremu_vv_tum:
16160
case RISCVVector::BI__builtin_rvv_vremu_vx_tum:
16161
  ID = Intrinsic::riscv_vremu_mask;
16162
  PolicyAttrs = 2;
16163
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16164
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16165
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16166
  break;
16167
case RISCVVector::BI__builtin_rvv_vremu_vv_tama:
16168
case RISCVVector::BI__builtin_rvv_vremu_vx_tama:
16169
  ID = Intrinsic::riscv_vremu_mask;
16170
  PolicyAttrs = 3;
16171
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16172
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16173
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16174
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16175
  break;
16176
case RISCVVector::BI__builtin_rvv_vremu_vv_tumu:
16177
case RISCVVector::BI__builtin_rvv_vremu_vx_tumu:
16178
  ID = Intrinsic::riscv_vremu_mask;
16179
  PolicyAttrs = 0;
16180
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16181
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16182
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16183
  break;
16184
case RISCVVector::BI__builtin_rvv_vremu_vv_mu:
16185
case RISCVVector::BI__builtin_rvv_vremu_vx_mu:
16186
  ID = Intrinsic::riscv_vremu_mask;
16187
  PolicyAttrs = 1;
16188
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16189
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16190
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16191
  break;
16192
case RISCVVector::BI__builtin_rvv_vrgather_vv_tu:
16193
  ID = Intrinsic::riscv_vrgather_vv;
16194
  PolicyAttrs = 2;
16195
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
16196
  break;
16197
case RISCVVector::BI__builtin_rvv_vrgather_vv_ta:
16198
  ID = Intrinsic::riscv_vrgather_vv;
16199
  PolicyAttrs = 3;
16200
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16201
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
16202
  break;
16203
case RISCVVector::BI__builtin_rvv_vrgather_vv_tum:
16204
  ID = Intrinsic::riscv_vrgather_vv_mask;
16205
  PolicyAttrs = 2;
16206
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16207
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16208
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
16209
  break;
16210
case RISCVVector::BI__builtin_rvv_vrgather_vv_tama:
16211
  ID = Intrinsic::riscv_vrgather_vv_mask;
16212
  PolicyAttrs = 3;
16213
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16214
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16215
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16216
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
16217
  break;
16218
case RISCVVector::BI__builtin_rvv_vrgather_vv_tumu:
16219
  ID = Intrinsic::riscv_vrgather_vv_mask;
16220
  PolicyAttrs = 0;
16221
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16222
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16223
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
16224
  break;
16225
case RISCVVector::BI__builtin_rvv_vrgather_vv_mu:
16226
  ID = Intrinsic::riscv_vrgather_vv_mask;
16227
  PolicyAttrs = 1;
16228
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16229
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16230
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
16231
  break;
16232
case RISCVVector::BI__builtin_rvv_vrgather_vx_tu:
16233
  ID = Intrinsic::riscv_vrgather_vx;
16234
  PolicyAttrs = 2;
16235
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
16236
  break;
16237
case RISCVVector::BI__builtin_rvv_vrgather_vx_ta:
16238
  ID = Intrinsic::riscv_vrgather_vx;
16239
  PolicyAttrs = 3;
16240
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16241
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
16242
  break;
16243
case RISCVVector::BI__builtin_rvv_vrgather_vx_tum:
16244
  ID = Intrinsic::riscv_vrgather_vx_mask;
16245
  PolicyAttrs = 2;
16246
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16247
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16248
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
16249
  break;
16250
case RISCVVector::BI__builtin_rvv_vrgather_vx_tama:
16251
  ID = Intrinsic::riscv_vrgather_vx_mask;
16252
  PolicyAttrs = 3;
16253
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16254
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16255
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16256
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
16257
  break;
16258
case RISCVVector::BI__builtin_rvv_vrgather_vx_tumu:
16259
  ID = Intrinsic::riscv_vrgather_vx_mask;
16260
  PolicyAttrs = 0;
16261
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16262
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16263
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
16264
  break;
16265
case RISCVVector::BI__builtin_rvv_vrgather_vx_mu:
16266
  ID = Intrinsic::riscv_vrgather_vx_mask;
16267
  PolicyAttrs = 1;
16268
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16269
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16270
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
16271
  break;
16272
case RISCVVector::BI__builtin_rvv_vrgatherei16_vv_tu:
16273
  ID = Intrinsic::riscv_vrgatherei16_vv;
16274
  PolicyAttrs = 2;
16275
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
16276
  break;
16277
case RISCVVector::BI__builtin_rvv_vrgatherei16_vv_ta:
16278
  ID = Intrinsic::riscv_vrgatherei16_vv;
16279
  PolicyAttrs = 3;
16280
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16281
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
16282
  break;
16283
case RISCVVector::BI__builtin_rvv_vrgatherei16_vv_tum:
16284
  ID = Intrinsic::riscv_vrgatherei16_vv_mask;
16285
  PolicyAttrs = 2;
16286
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16287
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16288
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
16289
  break;
16290
case RISCVVector::BI__builtin_rvv_vrgatherei16_vv_tama:
16291
  ID = Intrinsic::riscv_vrgatherei16_vv_mask;
16292
  PolicyAttrs = 3;
16293
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16294
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16295
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16296
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
16297
  break;
16298
case RISCVVector::BI__builtin_rvv_vrgatherei16_vv_tumu:
16299
  ID = Intrinsic::riscv_vrgatherei16_vv_mask;
16300
  PolicyAttrs = 0;
16301
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16302
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16303
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
16304
  break;
16305
case RISCVVector::BI__builtin_rvv_vrgatherei16_vv_mu:
16306
  ID = Intrinsic::riscv_vrgatherei16_vv_mask;
16307
  PolicyAttrs = 1;
16308
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16309
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16310
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
16311
  break;
16312
case RISCVVector::BI__builtin_rvv_vrsub_vx_tu:
16313
  ID = Intrinsic::riscv_vrsub;
16314
  PolicyAttrs = 2;
16315
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16316
  break;
16317
case RISCVVector::BI__builtin_rvv_vneg_v_tu:
16318
  ID = Intrinsic::riscv_vrsub;
16319
  PolicyAttrs = 2;
16320
IsMasked = false;
16321
 
16322
      {
16323
        if (IsMasked) {
16324
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16325
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
16326
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16327
        } else {
16328
          if (PolicyAttrs & RVV_VTA)
16329
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16330
        }
16331
        auto ElemTy = cast<llvm::VectorType>(ResultType)->getElementType();
16332
        Ops.insert(Ops.begin() + 2, llvm::Constant::getNullValue(ElemTy));
16333
 
16334
        if (IsMasked) {
16335
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16336
          // maskedoff, op1, op2, mask, vl, policy
16337
          IntrinsicTypes = {ResultType, ElemTy, Ops[4]->getType()};
16338
        } else {
16339
          // passthru, op1, op2, vl
16340
          IntrinsicTypes = {ResultType, ElemTy, Ops[3]->getType()};
16341
        }
16342
        break;
16343
      }
16344
      break;
16345
case RISCVVector::BI__builtin_rvv_vrsub_vx_ta:
16346
  ID = Intrinsic::riscv_vrsub;
16347
  PolicyAttrs = 3;
16348
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16349
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16350
  break;
16351
case RISCVVector::BI__builtin_rvv_vneg_v_ta:
16352
  ID = Intrinsic::riscv_vrsub;
16353
  PolicyAttrs = 3;
16354
IsMasked = false;
16355
 
16356
      {
16357
        if (IsMasked) {
16358
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16359
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
16360
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16361
        } else {
16362
          if (PolicyAttrs & RVV_VTA)
16363
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16364
        }
16365
        auto ElemTy = cast<llvm::VectorType>(ResultType)->getElementType();
16366
        Ops.insert(Ops.begin() + 2, llvm::Constant::getNullValue(ElemTy));
16367
 
16368
        if (IsMasked) {
16369
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16370
          // maskedoff, op1, op2, mask, vl, policy
16371
          IntrinsicTypes = {ResultType, ElemTy, Ops[4]->getType()};
16372
        } else {
16373
          // passthru, op1, op2, vl
16374
          IntrinsicTypes = {ResultType, ElemTy, Ops[3]->getType()};
16375
        }
16376
        break;
16377
      }
16378
      break;
16379
case RISCVVector::BI__builtin_rvv_vrsub_vx_tum:
16380
  ID = Intrinsic::riscv_vrsub_mask;
16381
  PolicyAttrs = 2;
16382
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16383
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16384
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16385
  break;
16386
case RISCVVector::BI__builtin_rvv_vneg_v_tum:
16387
  ID = Intrinsic::riscv_vrsub_mask;
16388
  PolicyAttrs = 2;
16389
IsMasked = true;
16390
 
16391
      {
16392
        if (IsMasked) {
16393
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16394
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
16395
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16396
        } else {
16397
          if (PolicyAttrs & RVV_VTA)
16398
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16399
        }
16400
        auto ElemTy = cast<llvm::VectorType>(ResultType)->getElementType();
16401
        Ops.insert(Ops.begin() + 2, llvm::Constant::getNullValue(ElemTy));
16402
 
16403
        if (IsMasked) {
16404
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16405
          // maskedoff, op1, op2, mask, vl, policy
16406
          IntrinsicTypes = {ResultType, ElemTy, Ops[4]->getType()};
16407
        } else {
16408
          // passthru, op1, op2, vl
16409
          IntrinsicTypes = {ResultType, ElemTy, Ops[3]->getType()};
16410
        }
16411
        break;
16412
      }
16413
      break;
16414
case RISCVVector::BI__builtin_rvv_vrsub_vx_tama:
16415
  ID = Intrinsic::riscv_vrsub_mask;
16416
  PolicyAttrs = 3;
16417
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16418
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16419
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16420
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16421
  break;
16422
case RISCVVector::BI__builtin_rvv_vneg_v_tama:
16423
  ID = Intrinsic::riscv_vrsub_mask;
16424
  PolicyAttrs = 3;
16425
IsMasked = true;
16426
 
16427
      {
16428
        if (IsMasked) {
16429
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16430
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
16431
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16432
        } else {
16433
          if (PolicyAttrs & RVV_VTA)
16434
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16435
        }
16436
        auto ElemTy = cast<llvm::VectorType>(ResultType)->getElementType();
16437
        Ops.insert(Ops.begin() + 2, llvm::Constant::getNullValue(ElemTy));
16438
 
16439
        if (IsMasked) {
16440
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16441
          // maskedoff, op1, op2, mask, vl, policy
16442
          IntrinsicTypes = {ResultType, ElemTy, Ops[4]->getType()};
16443
        } else {
16444
          // passthru, op1, op2, vl
16445
          IntrinsicTypes = {ResultType, ElemTy, Ops[3]->getType()};
16446
        }
16447
        break;
16448
      }
16449
      break;
16450
case RISCVVector::BI__builtin_rvv_vrsub_vx_tumu:
16451
  ID = Intrinsic::riscv_vrsub_mask;
16452
  PolicyAttrs = 0;
16453
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16454
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16455
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16456
  break;
16457
case RISCVVector::BI__builtin_rvv_vneg_v_tumu:
16458
  ID = Intrinsic::riscv_vrsub_mask;
16459
  PolicyAttrs = 0;
16460
IsMasked = true;
16461
 
16462
      {
16463
        if (IsMasked) {
16464
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16465
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
16466
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16467
        } else {
16468
          if (PolicyAttrs & RVV_VTA)
16469
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16470
        }
16471
        auto ElemTy = cast<llvm::VectorType>(ResultType)->getElementType();
16472
        Ops.insert(Ops.begin() + 2, llvm::Constant::getNullValue(ElemTy));
16473
 
16474
        if (IsMasked) {
16475
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16476
          // maskedoff, op1, op2, mask, vl, policy
16477
          IntrinsicTypes = {ResultType, ElemTy, Ops[4]->getType()};
16478
        } else {
16479
          // passthru, op1, op2, vl
16480
          IntrinsicTypes = {ResultType, ElemTy, Ops[3]->getType()};
16481
        }
16482
        break;
16483
      }
16484
      break;
16485
case RISCVVector::BI__builtin_rvv_vrsub_vx_mu:
16486
  ID = Intrinsic::riscv_vrsub_mask;
16487
  PolicyAttrs = 1;
16488
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16489
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16490
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16491
  break;
16492
case RISCVVector::BI__builtin_rvv_vneg_v_mu:
16493
  ID = Intrinsic::riscv_vrsub_mask;
16494
  PolicyAttrs = 1;
16495
IsMasked = true;
16496
 
16497
      {
16498
        if (IsMasked) {
16499
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16500
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
16501
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16502
        } else {
16503
          if (PolicyAttrs & RVV_VTA)
16504
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16505
        }
16506
        auto ElemTy = cast<llvm::VectorType>(ResultType)->getElementType();
16507
        Ops.insert(Ops.begin() + 2, llvm::Constant::getNullValue(ElemTy));
16508
 
16509
        if (IsMasked) {
16510
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16511
          // maskedoff, op1, op2, mask, vl, policy
16512
          IntrinsicTypes = {ResultType, ElemTy, Ops[4]->getType()};
16513
        } else {
16514
          // passthru, op1, op2, vl
16515
          IntrinsicTypes = {ResultType, ElemTy, Ops[3]->getType()};
16516
        }
16517
        break;
16518
      }
16519
      break;
16520
case RISCVVector::BI__builtin_rvv_vsadd_vv_tu:
16521
case RISCVVector::BI__builtin_rvv_vsadd_vx_tu:
16522
  ID = Intrinsic::riscv_vsadd;
16523
  PolicyAttrs = 2;
16524
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16525
  break;
16526
case RISCVVector::BI__builtin_rvv_vsadd_vv_ta:
16527
case RISCVVector::BI__builtin_rvv_vsadd_vx_ta:
16528
  ID = Intrinsic::riscv_vsadd;
16529
  PolicyAttrs = 3;
16530
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16531
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16532
  break;
16533
case RISCVVector::BI__builtin_rvv_vsadd_vv_tum:
16534
case RISCVVector::BI__builtin_rvv_vsadd_vx_tum:
16535
  ID = Intrinsic::riscv_vsadd_mask;
16536
  PolicyAttrs = 2;
16537
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16538
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16539
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16540
  break;
16541
case RISCVVector::BI__builtin_rvv_vsadd_vv_tama:
16542
case RISCVVector::BI__builtin_rvv_vsadd_vx_tama:
16543
  ID = Intrinsic::riscv_vsadd_mask;
16544
  PolicyAttrs = 3;
16545
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16546
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16547
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16548
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16549
  break;
16550
case RISCVVector::BI__builtin_rvv_vsadd_vv_tumu:
16551
case RISCVVector::BI__builtin_rvv_vsadd_vx_tumu:
16552
  ID = Intrinsic::riscv_vsadd_mask;
16553
  PolicyAttrs = 0;
16554
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16555
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16556
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16557
  break;
16558
case RISCVVector::BI__builtin_rvv_vsadd_vv_mu:
16559
case RISCVVector::BI__builtin_rvv_vsadd_vx_mu:
16560
  ID = Intrinsic::riscv_vsadd_mask;
16561
  PolicyAttrs = 1;
16562
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16563
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16564
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16565
  break;
16566
case RISCVVector::BI__builtin_rvv_vsaddu_vv_tu:
16567
case RISCVVector::BI__builtin_rvv_vsaddu_vx_tu:
16568
  ID = Intrinsic::riscv_vsaddu;
16569
  PolicyAttrs = 2;
16570
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16571
  break;
16572
case RISCVVector::BI__builtin_rvv_vsaddu_vv_ta:
16573
case RISCVVector::BI__builtin_rvv_vsaddu_vx_ta:
16574
  ID = Intrinsic::riscv_vsaddu;
16575
  PolicyAttrs = 3;
16576
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16577
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16578
  break;
16579
case RISCVVector::BI__builtin_rvv_vsaddu_vv_tum:
16580
case RISCVVector::BI__builtin_rvv_vsaddu_vx_tum:
16581
  ID = Intrinsic::riscv_vsaddu_mask;
16582
  PolicyAttrs = 2;
16583
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16584
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16585
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16586
  break;
16587
case RISCVVector::BI__builtin_rvv_vsaddu_vv_tama:
16588
case RISCVVector::BI__builtin_rvv_vsaddu_vx_tama:
16589
  ID = Intrinsic::riscv_vsaddu_mask;
16590
  PolicyAttrs = 3;
16591
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16592
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16593
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16594
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16595
  break;
16596
case RISCVVector::BI__builtin_rvv_vsaddu_vv_tumu:
16597
case RISCVVector::BI__builtin_rvv_vsaddu_vx_tumu:
16598
  ID = Intrinsic::riscv_vsaddu_mask;
16599
  PolicyAttrs = 0;
16600
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16601
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16602
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16603
  break;
16604
case RISCVVector::BI__builtin_rvv_vsaddu_vv_mu:
16605
case RISCVVector::BI__builtin_rvv_vsaddu_vx_mu:
16606
  ID = Intrinsic::riscv_vsaddu_mask;
16607
  PolicyAttrs = 1;
16608
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16609
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16610
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16611
  break;
16612
case RISCVVector::BI__builtin_rvv_vsbc_vvm_tu:
16613
case RISCVVector::BI__builtin_rvv_vsbc_vxm_tu:
16614
  ID = Intrinsic::riscv_vsbc;
16615
  PolicyAttrs = 2;
16616
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16617
  break;
16618
case RISCVVector::BI__builtin_rvv_vsbc_vvm_ta:
16619
case RISCVVector::BI__builtin_rvv_vsbc_vxm_ta:
16620
  ID = Intrinsic::riscv_vsbc;
16621
  PolicyAttrs = 3;
16622
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16623
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16624
  break;
16625
case RISCVVector::BI__builtin_rvv_vse8_v:
16626
case RISCVVector::BI__builtin_rvv_vse16_v:
16627
case RISCVVector::BI__builtin_rvv_vse32_v:
16628
case RISCVVector::BI__builtin_rvv_vse64_v:
16629
  ID = Intrinsic::riscv_vse;
16630
  PolicyAttrs = 3;
16631
IsMasked = false;
16632
 
16633
      if (IsMasked) {
16634
        // Builtin: (mask, ptr, value, vl). Intrinsic: (value, ptr, mask, vl)
16635
        std::swap(Ops[0], Ops[2]);
16636
      } else {
16637
        // Builtin: (ptr, value, vl). Intrinsic: (value, ptr, vl)
16638
        std::swap(Ops[0], Ops[1]);
16639
      }
16640
      Ops[1] = Builder.CreateBitCast(Ops[1], Ops[0]->getType()->getPointerTo());
16641
      if (IsMasked)
16642
        IntrinsicTypes = {Ops[0]->getType(), Ops[3]->getType()};
16643
      else
16644
        IntrinsicTypes = {Ops[0]->getType(), Ops[2]->getType()};
16645
    break;
16646
case RISCVVector::BI__builtin_rvv_vse8_v_m:
16647
case RISCVVector::BI__builtin_rvv_vse16_v_m:
16648
case RISCVVector::BI__builtin_rvv_vse32_v_m:
16649
case RISCVVector::BI__builtin_rvv_vse64_v_m:
16650
  ID = Intrinsic::riscv_vse_mask;
16651
  PolicyAttrs = 3;
16652
IsMasked = true;
16653
 
16654
      if (IsMasked) {
16655
        // Builtin: (mask, ptr, value, vl). Intrinsic: (value, ptr, mask, vl)
16656
        std::swap(Ops[0], Ops[2]);
16657
      } else {
16658
        // Builtin: (ptr, value, vl). Intrinsic: (value, ptr, vl)
16659
        std::swap(Ops[0], Ops[1]);
16660
      }
16661
      Ops[1] = Builder.CreateBitCast(Ops[1], Ops[0]->getType()->getPointerTo());
16662
      if (IsMasked)
16663
        IntrinsicTypes = {Ops[0]->getType(), Ops[3]->getType()};
16664
      else
16665
        IntrinsicTypes = {Ops[0]->getType(), Ops[2]->getType()};
16666
    break;
16667
case RISCVVector::BI__builtin_rvv_vsetvli:
16668
  ID = Intrinsic::riscv_vsetvli;
16669
  PolicyAttrs = 3;
16670
IsMasked = false;
16671
IntrinsicTypes = {ResultType};break;
16672
case RISCVVector::BI__builtin_rvv_vsetvlimax:
16673
  ID = Intrinsic::riscv_vsetvlimax;
16674
  PolicyAttrs = 3;
16675
IsMasked = false;
16676
IntrinsicTypes = {ResultType};break;
16677
case RISCVVector::BI__builtin_rvv_vsext_vf2_tu:
16678
case RISCVVector::BI__builtin_rvv_vsext_vf4_tu:
16679
case RISCVVector::BI__builtin_rvv_vsext_vf8_tu:
16680
  ID = Intrinsic::riscv_vsext;
16681
  PolicyAttrs = 2;
16682
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
16683
  break;
16684
case RISCVVector::BI__builtin_rvv_vsext_vf2_ta:
16685
case RISCVVector::BI__builtin_rvv_vsext_vf4_ta:
16686
case RISCVVector::BI__builtin_rvv_vsext_vf8_ta:
16687
  ID = Intrinsic::riscv_vsext;
16688
  PolicyAttrs = 3;
16689
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16690
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
16691
  break;
16692
case RISCVVector::BI__builtin_rvv_vsext_vf2_tum:
16693
case RISCVVector::BI__builtin_rvv_vsext_vf4_tum:
16694
case RISCVVector::BI__builtin_rvv_vsext_vf8_tum:
16695
  ID = Intrinsic::riscv_vsext_mask;
16696
  PolicyAttrs = 2;
16697
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16698
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16699
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
16700
  break;
16701
case RISCVVector::BI__builtin_rvv_vsext_vf2_tama:
16702
case RISCVVector::BI__builtin_rvv_vsext_vf4_tama:
16703
case RISCVVector::BI__builtin_rvv_vsext_vf8_tama:
16704
  ID = Intrinsic::riscv_vsext_mask;
16705
  PolicyAttrs = 3;
16706
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16707
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16708
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16709
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
16710
  break;
16711
case RISCVVector::BI__builtin_rvv_vsext_vf2_tumu:
16712
case RISCVVector::BI__builtin_rvv_vsext_vf4_tumu:
16713
case RISCVVector::BI__builtin_rvv_vsext_vf8_tumu:
16714
  ID = Intrinsic::riscv_vsext_mask;
16715
  PolicyAttrs = 0;
16716
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16717
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16718
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
16719
  break;
16720
case RISCVVector::BI__builtin_rvv_vsext_vf2_mu:
16721
case RISCVVector::BI__builtin_rvv_vsext_vf4_mu:
16722
case RISCVVector::BI__builtin_rvv_vsext_vf8_mu:
16723
  ID = Intrinsic::riscv_vsext_mask;
16724
  PolicyAttrs = 1;
16725
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16726
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16727
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
16728
  break;
16729
case RISCVVector::BI__builtin_rvv_vslide1down_vx_tu:
16730
  ID = Intrinsic::riscv_vslide1down;
16731
  PolicyAttrs = 2;
16732
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16733
  break;
16734
case RISCVVector::BI__builtin_rvv_vslide1down_vx_ta:
16735
  ID = Intrinsic::riscv_vslide1down;
16736
  PolicyAttrs = 3;
16737
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16738
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16739
  break;
16740
case RISCVVector::BI__builtin_rvv_vslide1down_vx_tum:
16741
  ID = Intrinsic::riscv_vslide1down_mask;
16742
  PolicyAttrs = 2;
16743
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16744
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16745
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16746
  break;
16747
case RISCVVector::BI__builtin_rvv_vslide1down_vx_tama:
16748
  ID = Intrinsic::riscv_vslide1down_mask;
16749
  PolicyAttrs = 3;
16750
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16751
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16752
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16753
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16754
  break;
16755
case RISCVVector::BI__builtin_rvv_vslide1down_vx_tumu:
16756
  ID = Intrinsic::riscv_vslide1down_mask;
16757
  PolicyAttrs = 0;
16758
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16759
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16760
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16761
  break;
16762
case RISCVVector::BI__builtin_rvv_vslide1down_vx_mu:
16763
  ID = Intrinsic::riscv_vslide1down_mask;
16764
  PolicyAttrs = 1;
16765
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16766
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16767
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16768
  break;
16769
case RISCVVector::BI__builtin_rvv_vslide1up_vx_tu:
16770
  ID = Intrinsic::riscv_vslide1up;
16771
  PolicyAttrs = 2;
16772
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16773
  break;
16774
case RISCVVector::BI__builtin_rvv_vslide1up_vx_ta:
16775
  ID = Intrinsic::riscv_vslide1up;
16776
  PolicyAttrs = 3;
16777
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16778
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16779
  break;
16780
case RISCVVector::BI__builtin_rvv_vslide1up_vx_tum:
16781
  ID = Intrinsic::riscv_vslide1up_mask;
16782
  PolicyAttrs = 2;
16783
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16784
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16785
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16786
  break;
16787
case RISCVVector::BI__builtin_rvv_vslide1up_vx_tama:
16788
  ID = Intrinsic::riscv_vslide1up_mask;
16789
  PolicyAttrs = 3;
16790
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16791
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16792
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16793
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16794
  break;
16795
case RISCVVector::BI__builtin_rvv_vslide1up_vx_tumu:
16796
  ID = Intrinsic::riscv_vslide1up_mask;
16797
  PolicyAttrs = 0;
16798
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16799
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16800
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16801
  break;
16802
case RISCVVector::BI__builtin_rvv_vslide1up_vx_mu:
16803
  ID = Intrinsic::riscv_vslide1up_mask;
16804
  PolicyAttrs = 1;
16805
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16806
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16807
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16808
  break;
16809
case RISCVVector::BI__builtin_rvv_vslidedown_vx_tu:
16810
  ID = Intrinsic::riscv_vslidedown;
16811
  PolicyAttrs = 2;
16812
IsMasked = false;
16813
 
16814
      if (IsMasked) {
16815
        std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16816
        if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
16817
          Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16818
      } else {
16819
        if (PolicyAttrs & RVV_VTA)
16820
          Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16821
      }
16822
 
16823
      Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16824
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
16825
    break;
16826
case RISCVVector::BI__builtin_rvv_vslidedown_vx_ta:
16827
  ID = Intrinsic::riscv_vslidedown;
16828
  PolicyAttrs = 3;
16829
IsMasked = false;
16830
 
16831
      if (IsMasked) {
16832
        std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16833
        if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
16834
          Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16835
      } else {
16836
        if (PolicyAttrs & RVV_VTA)
16837
          Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16838
      }
16839
 
16840
      Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16841
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
16842
    break;
16843
case RISCVVector::BI__builtin_rvv_vslidedown_vx_tum:
16844
  ID = Intrinsic::riscv_vslidedown_mask;
16845
  PolicyAttrs = 2;
16846
IsMasked = true;
16847
 
16848
      if (IsMasked) {
16849
        std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16850
        if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
16851
          Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16852
      } else {
16853
        if (PolicyAttrs & RVV_VTA)
16854
          Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16855
      }
16856
 
16857
      Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16858
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
16859
    break;
16860
case RISCVVector::BI__builtin_rvv_vslidedown_vx_tama:
16861
  ID = Intrinsic::riscv_vslidedown_mask;
16862
  PolicyAttrs = 3;
16863
IsMasked = true;
16864
 
16865
      if (IsMasked) {
16866
        std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16867
        if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
16868
          Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16869
      } else {
16870
        if (PolicyAttrs & RVV_VTA)
16871
          Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16872
      }
16873
 
16874
      Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16875
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
16876
    break;
16877
case RISCVVector::BI__builtin_rvv_vslidedown_vx_tumu:
16878
  ID = Intrinsic::riscv_vslidedown_mask;
16879
  PolicyAttrs = 0;
16880
IsMasked = true;
16881
 
16882
      if (IsMasked) {
16883
        std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16884
        if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
16885
          Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16886
      } else {
16887
        if (PolicyAttrs & RVV_VTA)
16888
          Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16889
      }
16890
 
16891
      Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16892
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
16893
    break;
16894
case RISCVVector::BI__builtin_rvv_vslidedown_vx_mu:
16895
  ID = Intrinsic::riscv_vslidedown_mask;
16896
  PolicyAttrs = 1;
16897
IsMasked = true;
16898
 
16899
      if (IsMasked) {
16900
        std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16901
        if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
16902
          Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16903
      } else {
16904
        if (PolicyAttrs & RVV_VTA)
16905
          Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16906
      }
16907
 
16908
      Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16909
      IntrinsicTypes = {ResultType, Ops.back()->getType()};
16910
    break;
16911
case RISCVVector::BI__builtin_rvv_vslideup_vx_tu:
16912
  ID = Intrinsic::riscv_vslideup;
16913
  PolicyAttrs = 2;
16914
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16915
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
16916
  break;
16917
case RISCVVector::BI__builtin_rvv_vslideup_vx_ta:
16918
  ID = Intrinsic::riscv_vslideup;
16919
  PolicyAttrs = 3;
16920
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16921
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
16922
  break;
16923
case RISCVVector::BI__builtin_rvv_vslideup_vx_tum:
16924
  ID = Intrinsic::riscv_vslideup_mask;
16925
  PolicyAttrs = 2;
16926
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16927
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16928
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
16929
  break;
16930
case RISCVVector::BI__builtin_rvv_vslideup_vx_tama:
16931
  ID = Intrinsic::riscv_vslideup_mask;
16932
  PolicyAttrs = 3;
16933
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16934
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16935
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
16936
  break;
16937
case RISCVVector::BI__builtin_rvv_vslideup_vx_tumu:
16938
  ID = Intrinsic::riscv_vslideup_mask;
16939
  PolicyAttrs = 0;
16940
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16941
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16942
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
16943
  break;
16944
case RISCVVector::BI__builtin_rvv_vslideup_vx_mu:
16945
  ID = Intrinsic::riscv_vslideup_mask;
16946
  PolicyAttrs = 1;
16947
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16948
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16949
  IntrinsicTypes = {ResultType, Ops.back()->getType()};
16950
  break;
16951
case RISCVVector::BI__builtin_rvv_vsll_vv_tu:
16952
case RISCVVector::BI__builtin_rvv_vsll_vx_tu:
16953
  ID = Intrinsic::riscv_vsll;
16954
  PolicyAttrs = 2;
16955
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16956
  break;
16957
case RISCVVector::BI__builtin_rvv_vsll_vv_ta:
16958
case RISCVVector::BI__builtin_rvv_vsll_vx_ta:
16959
  ID = Intrinsic::riscv_vsll;
16960
  PolicyAttrs = 3;
16961
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16962
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16963
  break;
16964
case RISCVVector::BI__builtin_rvv_vsll_vv_tum:
16965
case RISCVVector::BI__builtin_rvv_vsll_vx_tum:
16966
  ID = Intrinsic::riscv_vsll_mask;
16967
  PolicyAttrs = 2;
16968
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16969
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16970
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16971
  break;
16972
case RISCVVector::BI__builtin_rvv_vsll_vv_tama:
16973
case RISCVVector::BI__builtin_rvv_vsll_vx_tama:
16974
  ID = Intrinsic::riscv_vsll_mask;
16975
  PolicyAttrs = 3;
16976
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16977
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16978
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
16979
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16980
  break;
16981
case RISCVVector::BI__builtin_rvv_vsll_vv_tumu:
16982
case RISCVVector::BI__builtin_rvv_vsll_vx_tumu:
16983
  ID = Intrinsic::riscv_vsll_mask;
16984
  PolicyAttrs = 0;
16985
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16986
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16987
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16988
  break;
16989
case RISCVVector::BI__builtin_rvv_vsll_vv_mu:
16990
case RISCVVector::BI__builtin_rvv_vsll_vx_mu:
16991
  ID = Intrinsic::riscv_vsll_mask;
16992
  PolicyAttrs = 1;
16993
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
16994
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
16995
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
16996
  break;
16997
case RISCVVector::BI__builtin_rvv_vsm_v:
16998
  ID = Intrinsic::riscv_vsm;
16999
  PolicyAttrs = 3;
17000
IsMasked = false;
17001
 
17002
      if (IsMasked) {
17003
        // Builtin: (mask, ptr, value, vl). Intrinsic: (value, ptr, mask, vl)
17004
        std::swap(Ops[0], Ops[2]);
17005
      } else {
17006
        // Builtin: (ptr, value, vl). Intrinsic: (value, ptr, vl)
17007
        std::swap(Ops[0], Ops[1]);
17008
      }
17009
      Ops[1] = Builder.CreateBitCast(Ops[1], Ops[0]->getType()->getPointerTo());
17010
      if (IsMasked)
17011
        IntrinsicTypes = {Ops[0]->getType(), Ops[3]->getType()};
17012
      else
17013
        IntrinsicTypes = {Ops[0]->getType(), Ops[2]->getType()};
17014
    break;
17015
case RISCVVector::BI__builtin_rvv_vsmul_vv_tu:
17016
case RISCVVector::BI__builtin_rvv_vsmul_vx_tu:
17017
  ID = Intrinsic::riscv_vsmul;
17018
  PolicyAttrs = 2;
17019
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
17020
  break;
17021
case RISCVVector::BI__builtin_rvv_vsmul_vv_ta:
17022
case RISCVVector::BI__builtin_rvv_vsmul_vx_ta:
17023
  ID = Intrinsic::riscv_vsmul;
17024
  PolicyAttrs = 3;
17025
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
17026
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
17027
  break;
17028
case RISCVVector::BI__builtin_rvv_vsmul_vv_tum:
17029
case RISCVVector::BI__builtin_rvv_vsmul_vx_tum:
17030
  ID = Intrinsic::riscv_vsmul_mask;
17031
  PolicyAttrs = 2;
17032
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
17033
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
17034
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
17035
  break;
17036
case RISCVVector::BI__builtin_rvv_vsmul_vv_tama:
17037
case RISCVVector::BI__builtin_rvv_vsmul_vx_tama:
17038
  ID = Intrinsic::riscv_vsmul_mask;
17039
  PolicyAttrs = 3;
17040
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
17041
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
17042
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
17043
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
17044
  break;
17045
case RISCVVector::BI__builtin_rvv_vsmul_vv_tumu:
17046
case RISCVVector::BI__builtin_rvv_vsmul_vx_tumu:
17047
  ID = Intrinsic::riscv_vsmul_mask;
17048
  PolicyAttrs = 0;
17049
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
17050
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
17051
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
17052
  break;
17053
case RISCVVector::BI__builtin_rvv_vsmul_vv_mu:
17054
case RISCVVector::BI__builtin_rvv_vsmul_vx_mu:
17055
  ID = Intrinsic::riscv_vsmul_mask;
17056
  PolicyAttrs = 1;
17057
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
17058
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
17059
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
17060
  break;
17061
case RISCVVector::BI__builtin_rvv_vsoxei8_v:
17062
case RISCVVector::BI__builtin_rvv_vsoxei16_v:
17063
case RISCVVector::BI__builtin_rvv_vsoxei32_v:
17064
case RISCVVector::BI__builtin_rvv_vsoxei64_v:
17065
  ID = Intrinsic::riscv_vsoxei;
17066
  PolicyAttrs = 3;
17067
IsMasked = false;
17068
 
17069
        if (IsMasked) {
17070
          // Builtin: (mask, ptr, index, value, vl). Intrinsic: (value, ptr, index, mask, vl)
17071
          std::swap(Ops[0], Ops[3]);
17072
        } else {
17073
          // Builtin: (ptr, index, value, vl). Intrinsic: (value, ptr, index, vl)
17074
          std::rotate(Ops.begin(), Ops.begin() + 2, Ops.begin() + 3);
17075
        }
17076
        Ops[1] = Builder.CreateBitCast(Ops[1], Ops[0]->getType()->getPointerTo());
17077
        if (IsMasked)
17078
          IntrinsicTypes = {Ops[0]->getType(), Ops[2]->getType(), Ops[4]->getType()};
17079
        else
17080
          IntrinsicTypes = {Ops[0]->getType(), Ops[2]->getType(), Ops[3]->getType()};
17081
      break;
17082
case RISCVVector::BI__builtin_rvv_vsoxei8_v_m:
17083
case RISCVVector::BI__builtin_rvv_vsoxei16_v_m:
17084
case RISCVVector::BI__builtin_rvv_vsoxei32_v_m:
17085
case RISCVVector::BI__builtin_rvv_vsoxei64_v_m:
17086
  ID = Intrinsic::riscv_vsoxei_mask;
17087
  PolicyAttrs = 3;
17088
IsMasked = true;
17089
 
17090
        if (IsMasked) {
17091
          // Builtin: (mask, ptr, index, value, vl). Intrinsic: (value, ptr, index, mask, vl)
17092
          std::swap(Ops[0], Ops[3]);
17093
        } else {
17094
          // Builtin: (ptr, index, value, vl). Intrinsic: (value, ptr, index, vl)
17095
          std::rotate(Ops.begin(), Ops.begin() + 2, Ops.begin() + 3);
17096
        }
17097
        Ops[1] = Builder.CreateBitCast(Ops[1], Ops[0]->getType()->getPointerTo());
17098
        if (IsMasked)
17099
          IntrinsicTypes = {Ops[0]->getType(), Ops[2]->getType(), Ops[4]->getType()};
17100
        else
17101
          IntrinsicTypes = {Ops[0]->getType(), Ops[2]->getType(), Ops[3]->getType()};
17102
      break;
17103
case RISCVVector::BI__builtin_rvv_vsoxseg2ei8_v:
17104
case RISCVVector::BI__builtin_rvv_vsoxseg2ei16_v:
17105
case RISCVVector::BI__builtin_rvv_vsoxseg2ei32_v:
17106
case RISCVVector::BI__builtin_rvv_vsoxseg2ei64_v:
17107
  ID = Intrinsic::riscv_vsoxseg2;
17108
  NF = 2;
17109
  PolicyAttrs = 3;
17110
IsMasked = false;
17111
 
17112
    {
17113
      if (IsMasked) {
17114
        // Builtin: (mask, ptr, index, val0, val1, ..., vl)
17115
        // Intrinsic: (val0, val1, ..., ptr, index, mask, vl)
17116
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
17117
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
17118
        IntrinsicTypes = {Ops[0]->getType(),
17119
                          Ops[NF + 1]->getType(), Ops[NF + 3]->getType()};
17120
        assert(Ops.size() == NF + 4);
17121
      } else {
17122
        // Builtin: (ptr, index, val0, val1, ..., vl)
17123
        // Intrinsic: (val0, val1, ..., ptr, index, vl)
17124
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
17125
        IntrinsicTypes = {Ops[0]->getType(),
17126
                          Ops[NF + 1]->getType(), Ops[NF + 2]->getType()};
17127
        assert(Ops.size() == NF + 3);
17128
      }
17129
    }
17130
            break;
17131
case RISCVVector::BI__builtin_rvv_vsoxseg2ei8_v_m:
17132
case RISCVVector::BI__builtin_rvv_vsoxseg2ei16_v_m:
17133
case RISCVVector::BI__builtin_rvv_vsoxseg2ei32_v_m:
17134
case RISCVVector::BI__builtin_rvv_vsoxseg2ei64_v_m:
17135
  ID = Intrinsic::riscv_vsoxseg2_mask;
17136
  NF = 2;
17137
  PolicyAttrs = 3;
17138
IsMasked = true;
17139
 
17140
    {
17141
      if (IsMasked) {
17142
        // Builtin: (mask, ptr, index, val0, val1, ..., vl)
17143
        // Intrinsic: (val0, val1, ..., ptr, index, mask, vl)
17144
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
17145
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
17146
        IntrinsicTypes = {Ops[0]->getType(),
17147
                          Ops[NF + 1]->getType(), Ops[NF + 3]->getType()};
17148
        assert(Ops.size() == NF + 4);
17149
      } else {
17150
        // Builtin: (ptr, index, val0, val1, ..., vl)
17151
        // Intrinsic: (val0, val1, ..., ptr, index, vl)
17152
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
17153
        IntrinsicTypes = {Ops[0]->getType(),
17154
                          Ops[NF + 1]->getType(), Ops[NF + 2]->getType()};
17155
        assert(Ops.size() == NF + 3);
17156
      }
17157
    }
17158
            break;
17159
case RISCVVector::BI__builtin_rvv_vsoxseg3ei8_v:
17160
case RISCVVector::BI__builtin_rvv_vsoxseg3ei16_v:
17161
case RISCVVector::BI__builtin_rvv_vsoxseg3ei32_v:
17162
case RISCVVector::BI__builtin_rvv_vsoxseg3ei64_v:
17163
  ID = Intrinsic::riscv_vsoxseg3;
17164
  NF = 3;
17165
  PolicyAttrs = 3;
17166
IsMasked = false;
17167
 
17168
    {
17169
      if (IsMasked) {
17170
        // Builtin: (mask, ptr, index, val0, val1, ..., vl)
17171
        // Intrinsic: (val0, val1, ..., ptr, index, mask, vl)
17172
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
17173
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
17174
        IntrinsicTypes = {Ops[0]->getType(),
17175
                          Ops[NF + 1]->getType(), Ops[NF + 3]->getType()};
17176
        assert(Ops.size() == NF + 4);
17177
      } else {
17178
        // Builtin: (ptr, index, val0, val1, ..., vl)
17179
        // Intrinsic: (val0, val1, ..., ptr, index, vl)
17180
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
17181
        IntrinsicTypes = {Ops[0]->getType(),
17182
                          Ops[NF + 1]->getType(), Ops[NF + 2]->getType()};
17183
        assert(Ops.size() == NF + 3);
17184
      }
17185
    }
17186
            break;
17187
case RISCVVector::BI__builtin_rvv_vsoxseg3ei8_v_m:
17188
case RISCVVector::BI__builtin_rvv_vsoxseg3ei16_v_m:
17189
case RISCVVector::BI__builtin_rvv_vsoxseg3ei32_v_m:
17190
case RISCVVector::BI__builtin_rvv_vsoxseg3ei64_v_m:
17191
  ID = Intrinsic::riscv_vsoxseg3_mask;
17192
  NF = 3;
17193
  PolicyAttrs = 3;
17194
IsMasked = true;
17195
 
17196
    {
17197
      if (IsMasked) {
17198
        // Builtin: (mask, ptr, index, val0, val1, ..., vl)
17199
        // Intrinsic: (val0, val1, ..., ptr, index, mask, vl)
17200
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
17201
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
17202
        IntrinsicTypes = {Ops[0]->getType(),
17203
                          Ops[NF + 1]->getType(), Ops[NF + 3]->getType()};
17204
        assert(Ops.size() == NF + 4);
17205
      } else {
17206
        // Builtin: (ptr, index, val0, val1, ..., vl)
17207
        // Intrinsic: (val0, val1, ..., ptr, index, vl)
17208
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
17209
        IntrinsicTypes = {Ops[0]->getType(),
17210
                          Ops[NF + 1]->getType(), Ops[NF + 2]->getType()};
17211
        assert(Ops.size() == NF + 3);
17212
      }
17213
    }
17214
            break;
17215
case RISCVVector::BI__builtin_rvv_vsoxseg4ei8_v:
17216
case RISCVVector::BI__builtin_rvv_vsoxseg4ei16_v:
17217
case RISCVVector::BI__builtin_rvv_vsoxseg4ei32_v:
17218
case RISCVVector::BI__builtin_rvv_vsoxseg4ei64_v:
17219
  ID = Intrinsic::riscv_vsoxseg4;
17220
  NF = 4;
17221
  PolicyAttrs = 3;
17222
IsMasked = false;
17223
 
17224
    {
17225
      if (IsMasked) {
17226
        // Builtin: (mask, ptr, index, val0, val1, ..., vl)
17227
        // Intrinsic: (val0, val1, ..., ptr, index, mask, vl)
17228
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
17229
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
17230
        IntrinsicTypes = {Ops[0]->getType(),
17231
                          Ops[NF + 1]->getType(), Ops[NF + 3]->getType()};
17232
        assert(Ops.size() == NF + 4);
17233
      } else {
17234
        // Builtin: (ptr, index, val0, val1, ..., vl)
17235
        // Intrinsic: (val0, val1, ..., ptr, index, vl)
17236
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
17237
        IntrinsicTypes = {Ops[0]->getType(),
17238
                          Ops[NF + 1]->getType(), Ops[NF + 2]->getType()};
17239
        assert(Ops.size() == NF + 3);
17240
      }
17241
    }
17242
            break;
17243
case RISCVVector::BI__builtin_rvv_vsoxseg4ei8_v_m:
17244
case RISCVVector::BI__builtin_rvv_vsoxseg4ei16_v_m:
17245
case RISCVVector::BI__builtin_rvv_vsoxseg4ei32_v_m:
17246
case RISCVVector::BI__builtin_rvv_vsoxseg4ei64_v_m:
17247
  ID = Intrinsic::riscv_vsoxseg4_mask;
17248
  NF = 4;
17249
  PolicyAttrs = 3;
17250
IsMasked = true;
17251
 
17252
    {
17253
      if (IsMasked) {
17254
        // Builtin: (mask, ptr, index, val0, val1, ..., vl)
17255
        // Intrinsic: (val0, val1, ..., ptr, index, mask, vl)
17256
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
17257
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
17258
        IntrinsicTypes = {Ops[0]->getType(),
17259
                          Ops[NF + 1]->getType(), Ops[NF + 3]->getType()};
17260
        assert(Ops.size() == NF + 4);
17261
      } else {
17262
        // Builtin: (ptr, index, val0, val1, ..., vl)
17263
        // Intrinsic: (val0, val1, ..., ptr, index, vl)
17264
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
17265
        IntrinsicTypes = {Ops[0]->getType(),
17266
                          Ops[NF + 1]->getType(), Ops[NF + 2]->getType()};
17267
        assert(Ops.size() == NF + 3);
17268
      }
17269
    }
17270
            break;
17271
case RISCVVector::BI__builtin_rvv_vsoxseg5ei8_v:
17272
case RISCVVector::BI__builtin_rvv_vsoxseg5ei16_v:
17273
case RISCVVector::BI__builtin_rvv_vsoxseg5ei32_v:
17274
case RISCVVector::BI__builtin_rvv_vsoxseg5ei64_v:
17275
  ID = Intrinsic::riscv_vsoxseg5;
17276
  NF = 5;
17277
  PolicyAttrs = 3;
17278
IsMasked = false;
17279
 
17280
    {
17281
      if (IsMasked) {
17282
        // Builtin: (mask, ptr, index, val0, val1, ..., vl)
17283
        // Intrinsic: (val0, val1, ..., ptr, index, mask, vl)
17284
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
17285
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
17286
        IntrinsicTypes = {Ops[0]->getType(),
17287
                          Ops[NF + 1]->getType(), Ops[NF + 3]->getType()};
17288
        assert(Ops.size() == NF + 4);
17289
      } else {
17290
        // Builtin: (ptr, index, val0, val1, ..., vl)
17291
        // Intrinsic: (val0, val1, ..., ptr, index, vl)
17292
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
17293
        IntrinsicTypes = {Ops[0]->getType(),
17294
                          Ops[NF + 1]->getType(), Ops[NF + 2]->getType()};
17295
        assert(Ops.size() == NF + 3);
17296
      }
17297
    }
17298
            break;
17299
case RISCVVector::BI__builtin_rvv_vsoxseg5ei8_v_m:
17300
case RISCVVector::BI__builtin_rvv_vsoxseg5ei16_v_m:
17301
case RISCVVector::BI__builtin_rvv_vsoxseg5ei32_v_m:
17302
case RISCVVector::BI__builtin_rvv_vsoxseg5ei64_v_m:
17303
  ID = Intrinsic::riscv_vsoxseg5_mask;
17304
  NF = 5;
17305
  PolicyAttrs = 3;
17306
IsMasked = true;
17307
 
17308
    {
17309
      if (IsMasked) {
17310
        // Builtin: (mask, ptr, index, val0, val1, ..., vl)
17311
        // Intrinsic: (val0, val1, ..., ptr, index, mask, vl)
17312
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
17313
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
17314
        IntrinsicTypes = {Ops[0]->getType(),
17315
                          Ops[NF + 1]->getType(), Ops[NF + 3]->getType()};
17316
        assert(Ops.size() == NF + 4);
17317
      } else {
17318
        // Builtin: (ptr, index, val0, val1, ..., vl)
17319
        // Intrinsic: (val0, val1, ..., ptr, index, vl)
17320
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
17321
        IntrinsicTypes = {Ops[0]->getType(),
17322
                          Ops[NF + 1]->getType(), Ops[NF + 2]->getType()};
17323
        assert(Ops.size() == NF + 3);
17324
      }
17325
    }
17326
            break;
17327
case RISCVVector::BI__builtin_rvv_vsoxseg6ei8_v:
17328
case RISCVVector::BI__builtin_rvv_vsoxseg6ei16_v:
17329
case RISCVVector::BI__builtin_rvv_vsoxseg6ei32_v:
17330
case RISCVVector::BI__builtin_rvv_vsoxseg6ei64_v:
17331
  ID = Intrinsic::riscv_vsoxseg6;
17332
  NF = 6;
17333
  PolicyAttrs = 3;
17334
IsMasked = false;
17335
 
17336
    {
17337
      if (IsMasked) {
17338
        // Builtin: (mask, ptr, index, val0, val1, ..., vl)
17339
        // Intrinsic: (val0, val1, ..., ptr, index, mask, vl)
17340
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
17341
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
17342
        IntrinsicTypes = {Ops[0]->getType(),
17343
                          Ops[NF + 1]->getType(), Ops[NF + 3]->getType()};
17344
        assert(Ops.size() == NF + 4);
17345
      } else {
17346
        // Builtin: (ptr, index, val0, val1, ..., vl)
17347
        // Intrinsic: (val0, val1, ..., ptr, index, vl)
17348
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
17349
        IntrinsicTypes = {Ops[0]->getType(),
17350
                          Ops[NF + 1]->getType(), Ops[NF + 2]->getType()};
17351
        assert(Ops.size() == NF + 3);
17352
      }
17353
    }
17354
            break;
17355
case RISCVVector::BI__builtin_rvv_vsoxseg6ei8_v_m:
17356
case RISCVVector::BI__builtin_rvv_vsoxseg6ei16_v_m:
17357
case RISCVVector::BI__builtin_rvv_vsoxseg6ei32_v_m:
17358
case RISCVVector::BI__builtin_rvv_vsoxseg6ei64_v_m:
17359
  ID = Intrinsic::riscv_vsoxseg6_mask;
17360
  NF = 6;
17361
  PolicyAttrs = 3;
17362
IsMasked = true;
17363
 
17364
    {
17365
      if (IsMasked) {
17366
        // Builtin: (mask, ptr, index, val0, val1, ..., vl)
17367
        // Intrinsic: (val0, val1, ..., ptr, index, mask, vl)
17368
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
17369
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
17370
        IntrinsicTypes = {Ops[0]->getType(),
17371
                          Ops[NF + 1]->getType(), Ops[NF + 3]->getType()};
17372
        assert(Ops.size() == NF + 4);
17373
      } else {
17374
        // Builtin: (ptr, index, val0, val1, ..., vl)
17375
        // Intrinsic: (val0, val1, ..., ptr, index, vl)
17376
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
17377
        IntrinsicTypes = {Ops[0]->getType(),
17378
                          Ops[NF + 1]->getType(), Ops[NF + 2]->getType()};
17379
        assert(Ops.size() == NF + 3);
17380
      }
17381
    }
17382
            break;
17383
case RISCVVector::BI__builtin_rvv_vsoxseg7ei8_v:
17384
case RISCVVector::BI__builtin_rvv_vsoxseg7ei16_v:
17385
case RISCVVector::BI__builtin_rvv_vsoxseg7ei32_v:
17386
case RISCVVector::BI__builtin_rvv_vsoxseg7ei64_v:
17387
  ID = Intrinsic::riscv_vsoxseg7;
17388
  NF = 7;
17389
  PolicyAttrs = 3;
17390
IsMasked = false;
17391
 
17392
    {
17393
      if (IsMasked) {
17394
        // Builtin: (mask, ptr, index, val0, val1, ..., vl)
17395
        // Intrinsic: (val0, val1, ..., ptr, index, mask, vl)
17396
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
17397
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
17398
        IntrinsicTypes = {Ops[0]->getType(),
17399
                          Ops[NF + 1]->getType(), Ops[NF + 3]->getType()};
17400
        assert(Ops.size() == NF + 4);
17401
      } else {
17402
        // Builtin: (ptr, index, val0, val1, ..., vl)
17403
        // Intrinsic: (val0, val1, ..., ptr, index, vl)
17404
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
17405
        IntrinsicTypes = {Ops[0]->getType(),
17406
                          Ops[NF + 1]->getType(), Ops[NF + 2]->getType()};
17407
        assert(Ops.size() == NF + 3);
17408
      }
17409
    }
17410
            break;
17411
case RISCVVector::BI__builtin_rvv_vsoxseg7ei8_v_m:
17412
case RISCVVector::BI__builtin_rvv_vsoxseg7ei16_v_m:
17413
case RISCVVector::BI__builtin_rvv_vsoxseg7ei32_v_m:
17414
case RISCVVector::BI__builtin_rvv_vsoxseg7ei64_v_m:
17415
  ID = Intrinsic::riscv_vsoxseg7_mask;
17416
  NF = 7;
17417
  PolicyAttrs = 3;
17418
IsMasked = true;
17419
 
17420
    {
17421
      if (IsMasked) {
17422
        // Builtin: (mask, ptr, index, val0, val1, ..., vl)
17423
        // Intrinsic: (val0, val1, ..., ptr, index, mask, vl)
17424
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
17425
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
17426
        IntrinsicTypes = {Ops[0]->getType(),
17427
                          Ops[NF + 1]->getType(), Ops[NF + 3]->getType()};
17428
        assert(Ops.size() == NF + 4);
17429
      } else {
17430
        // Builtin: (ptr, index, val0, val1, ..., vl)
17431
        // Intrinsic: (val0, val1, ..., ptr, index, vl)
17432
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
17433
        IntrinsicTypes = {Ops[0]->getType(),
17434
                          Ops[NF + 1]->getType(), Ops[NF + 2]->getType()};
17435
        assert(Ops.size() == NF + 3);
17436
      }
17437
    }
17438
            break;
17439
case RISCVVector::BI__builtin_rvv_vsoxseg8ei8_v:
17440
case RISCVVector::BI__builtin_rvv_vsoxseg8ei16_v:
17441
case RISCVVector::BI__builtin_rvv_vsoxseg8ei32_v:
17442
case RISCVVector::BI__builtin_rvv_vsoxseg8ei64_v:
17443
  ID = Intrinsic::riscv_vsoxseg8;
17444
  NF = 8;
17445
  PolicyAttrs = 3;
17446
IsMasked = false;
17447
 
17448
    {
17449
      if (IsMasked) {
17450
        // Builtin: (mask, ptr, index, val0, val1, ..., vl)
17451
        // Intrinsic: (val0, val1, ..., ptr, index, mask, vl)
17452
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
17453
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
17454
        IntrinsicTypes = {Ops[0]->getType(),
17455
                          Ops[NF + 1]->getType(), Ops[NF + 3]->getType()};
17456
        assert(Ops.size() == NF + 4);
17457
      } else {
17458
        // Builtin: (ptr, index, val0, val1, ..., vl)
17459
        // Intrinsic: (val0, val1, ..., ptr, index, vl)
17460
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
17461
        IntrinsicTypes = {Ops[0]->getType(),
17462
                          Ops[NF + 1]->getType(), Ops[NF + 2]->getType()};
17463
        assert(Ops.size() == NF + 3);
17464
      }
17465
    }
17466
            break;
17467
case RISCVVector::BI__builtin_rvv_vsoxseg8ei8_v_m:
17468
case RISCVVector::BI__builtin_rvv_vsoxseg8ei16_v_m:
17469
case RISCVVector::BI__builtin_rvv_vsoxseg8ei32_v_m:
17470
case RISCVVector::BI__builtin_rvv_vsoxseg8ei64_v_m:
17471
  ID = Intrinsic::riscv_vsoxseg8_mask;
17472
  NF = 8;
17473
  PolicyAttrs = 3;
17474
IsMasked = true;
17475
 
17476
    {
17477
      if (IsMasked) {
17478
        // Builtin: (mask, ptr, index, val0, val1, ..., vl)
17479
        // Intrinsic: (val0, val1, ..., ptr, index, mask, vl)
17480
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
17481
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
17482
        IntrinsicTypes = {Ops[0]->getType(),
17483
                          Ops[NF + 1]->getType(), Ops[NF + 3]->getType()};
17484
        assert(Ops.size() == NF + 4);
17485
      } else {
17486
        // Builtin: (ptr, index, val0, val1, ..., vl)
17487
        // Intrinsic: (val0, val1, ..., ptr, index, vl)
17488
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
17489
        IntrinsicTypes = {Ops[0]->getType(),
17490
                          Ops[NF + 1]->getType(), Ops[NF + 2]->getType()};
17491
        assert(Ops.size() == NF + 3);
17492
      }
17493
    }
17494
            break;
17495
case RISCVVector::BI__builtin_rvv_vsra_vv_tu:
17496
case RISCVVector::BI__builtin_rvv_vsra_vx_tu:
17497
  ID = Intrinsic::riscv_vsra;
17498
  PolicyAttrs = 2;
17499
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
17500
  break;
17501
case RISCVVector::BI__builtin_rvv_vsra_vv_ta:
17502
case RISCVVector::BI__builtin_rvv_vsra_vx_ta:
17503
  ID = Intrinsic::riscv_vsra;
17504
  PolicyAttrs = 3;
17505
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
17506
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
17507
  break;
17508
case RISCVVector::BI__builtin_rvv_vsra_vv_tum:
17509
case RISCVVector::BI__builtin_rvv_vsra_vx_tum:
17510
  ID = Intrinsic::riscv_vsra_mask;
17511
  PolicyAttrs = 2;
17512
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
17513
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
17514
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
17515
  break;
17516
case RISCVVector::BI__builtin_rvv_vsra_vv_tama:
17517
case RISCVVector::BI__builtin_rvv_vsra_vx_tama:
17518
  ID = Intrinsic::riscv_vsra_mask;
17519
  PolicyAttrs = 3;
17520
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
17521
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
17522
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
17523
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
17524
  break;
17525
case RISCVVector::BI__builtin_rvv_vsra_vv_tumu:
17526
case RISCVVector::BI__builtin_rvv_vsra_vx_tumu:
17527
  ID = Intrinsic::riscv_vsra_mask;
17528
  PolicyAttrs = 0;
17529
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
17530
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
17531
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
17532
  break;
17533
case RISCVVector::BI__builtin_rvv_vsra_vv_mu:
17534
case RISCVVector::BI__builtin_rvv_vsra_vx_mu:
17535
  ID = Intrinsic::riscv_vsra_mask;
17536
  PolicyAttrs = 1;
17537
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
17538
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
17539
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
17540
  break;
17541
case RISCVVector::BI__builtin_rvv_vsrl_vv_tu:
17542
case RISCVVector::BI__builtin_rvv_vsrl_vx_tu:
17543
  ID = Intrinsic::riscv_vsrl;
17544
  PolicyAttrs = 2;
17545
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
17546
  break;
17547
case RISCVVector::BI__builtin_rvv_vsrl_vv_ta:
17548
case RISCVVector::BI__builtin_rvv_vsrl_vx_ta:
17549
  ID = Intrinsic::riscv_vsrl;
17550
  PolicyAttrs = 3;
17551
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
17552
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
17553
  break;
17554
case RISCVVector::BI__builtin_rvv_vsrl_vv_tum:
17555
case RISCVVector::BI__builtin_rvv_vsrl_vx_tum:
17556
  ID = Intrinsic::riscv_vsrl_mask;
17557
  PolicyAttrs = 2;
17558
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
17559
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
17560
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
17561
  break;
17562
case RISCVVector::BI__builtin_rvv_vsrl_vv_tama:
17563
case RISCVVector::BI__builtin_rvv_vsrl_vx_tama:
17564
  ID = Intrinsic::riscv_vsrl_mask;
17565
  PolicyAttrs = 3;
17566
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
17567
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
17568
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
17569
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
17570
  break;
17571
case RISCVVector::BI__builtin_rvv_vsrl_vv_tumu:
17572
case RISCVVector::BI__builtin_rvv_vsrl_vx_tumu:
17573
  ID = Intrinsic::riscv_vsrl_mask;
17574
  PolicyAttrs = 0;
17575
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
17576
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
17577
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
17578
  break;
17579
case RISCVVector::BI__builtin_rvv_vsrl_vv_mu:
17580
case RISCVVector::BI__builtin_rvv_vsrl_vx_mu:
17581
  ID = Intrinsic::riscv_vsrl_mask;
17582
  PolicyAttrs = 1;
17583
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
17584
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
17585
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
17586
  break;
17587
case RISCVVector::BI__builtin_rvv_vsse16_v:
17588
case RISCVVector::BI__builtin_rvv_vsse32_v:
17589
case RISCVVector::BI__builtin_rvv_vsse64_v:
17590
case RISCVVector::BI__builtin_rvv_vsse8_v:
17591
  ID = Intrinsic::riscv_vsse;
17592
  PolicyAttrs = 3;
17593
IsMasked = false;
17594
 
17595
        if (IsMasked) {
17596
          // Builtin: (mask, ptr, stride, value, vl). Intrinsic: (value, ptr, stride, mask, vl)
17597
          std::swap(Ops[0], Ops[3]);
17598
        } else {
17599
          // Builtin: (ptr, stride, value, vl). Intrinsic: (value, ptr, stride, vl)
17600
          std::rotate(Ops.begin(), Ops.begin() + 2, Ops.begin() + 3);
17601
        }
17602
        Ops[1] = Builder.CreateBitCast(Ops[1], Ops[0]->getType()->getPointerTo());
17603
        if (IsMasked)
17604
          IntrinsicTypes = {Ops[0]->getType(), Ops[4]->getType()};
17605
        else
17606
          IntrinsicTypes = {Ops[0]->getType(), Ops[3]->getType()};
17607
      break;
17608
case RISCVVector::BI__builtin_rvv_vsse16_v_m:
17609
case RISCVVector::BI__builtin_rvv_vsse32_v_m:
17610
case RISCVVector::BI__builtin_rvv_vsse64_v_m:
17611
case RISCVVector::BI__builtin_rvv_vsse8_v_m:
17612
  ID = Intrinsic::riscv_vsse_mask;
17613
  PolicyAttrs = 3;
17614
IsMasked = true;
17615
 
17616
        if (IsMasked) {
17617
          // Builtin: (mask, ptr, stride, value, vl). Intrinsic: (value, ptr, stride, mask, vl)
17618
          std::swap(Ops[0], Ops[3]);
17619
        } else {
17620
          // Builtin: (ptr, stride, value, vl). Intrinsic: (value, ptr, stride, vl)
17621
          std::rotate(Ops.begin(), Ops.begin() + 2, Ops.begin() + 3);
17622
        }
17623
        Ops[1] = Builder.CreateBitCast(Ops[1], Ops[0]->getType()->getPointerTo());
17624
        if (IsMasked)
17625
          IntrinsicTypes = {Ops[0]->getType(), Ops[4]->getType()};
17626
        else
17627
          IntrinsicTypes = {Ops[0]->getType(), Ops[3]->getType()};
17628
      break;
17629
case RISCVVector::BI__builtin_rvv_vsseg2e16_v:
17630
case RISCVVector::BI__builtin_rvv_vsseg2e32_v:
17631
case RISCVVector::BI__builtin_rvv_vsseg2e64_v:
17632
case RISCVVector::BI__builtin_rvv_vsseg2e8_v:
17633
  ID = Intrinsic::riscv_vsseg2;
17634
  NF = 2;
17635
  PolicyAttrs = 3;
17636
IsMasked = false;
17637
 
17638
    {
17639
      if (IsMasked) {
17640
        // Builtin: (mask, ptr, val0, val1, ..., vl)
17641
        // Intrinsic: (val0, val1, ..., ptr, mask, vl)
17642
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
17643
        std::swap(Ops[NF], Ops[NF + 1]);
17644
        IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 2]->getType()};
17645
        assert(Ops.size() == NF + 3);
17646
      } else {
17647
        // Builtin: (ptr, val0, val1, ..., vl)
17648
        // Intrinsic: (val0, val1, ..., ptr, vl)
17649
        std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
17650
        IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 1]->getType()};
17651
        assert(Ops.size() == NF + 2);
17652
      }
17653
    }
17654
            break;
17655
case RISCVVector::BI__builtin_rvv_vsseg2e16_v_m:
17656
case RISCVVector::BI__builtin_rvv_vsseg2e32_v_m:
17657
case RISCVVector::BI__builtin_rvv_vsseg2e64_v_m:
17658
case RISCVVector::BI__builtin_rvv_vsseg2e8_v_m:
17659
  ID = Intrinsic::riscv_vsseg2_mask;
17660
  NF = 2;
17661
  PolicyAttrs = 3;
17662
IsMasked = true;
17663
 
17664
    {
17665
      if (IsMasked) {
17666
        // Builtin: (mask, ptr, val0, val1, ..., vl)
17667
        // Intrinsic: (val0, val1, ..., ptr, mask, vl)
17668
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
17669
        std::swap(Ops[NF], Ops[NF + 1]);
17670
        IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 2]->getType()};
17671
        assert(Ops.size() == NF + 3);
17672
      } else {
17673
        // Builtin: (ptr, val0, val1, ..., vl)
17674
        // Intrinsic: (val0, val1, ..., ptr, vl)
17675
        std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
17676
        IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 1]->getType()};
17677
        assert(Ops.size() == NF + 2);
17678
      }
17679
    }
17680
            break;
17681
case RISCVVector::BI__builtin_rvv_vsseg3e8_v:
17682
case RISCVVector::BI__builtin_rvv_vsseg3e16_v:
17683
case RISCVVector::BI__builtin_rvv_vsseg3e32_v:
17684
case RISCVVector::BI__builtin_rvv_vsseg3e64_v:
17685
  ID = Intrinsic::riscv_vsseg3;
17686
  NF = 3;
17687
  PolicyAttrs = 3;
17688
IsMasked = false;
17689
 
17690
    {
17691
      if (IsMasked) {
17692
        // Builtin: (mask, ptr, val0, val1, ..., vl)
17693
        // Intrinsic: (val0, val1, ..., ptr, mask, vl)
17694
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
17695
        std::swap(Ops[NF], Ops[NF + 1]);
17696
        IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 2]->getType()};
17697
        assert(Ops.size() == NF + 3);
17698
      } else {
17699
        // Builtin: (ptr, val0, val1, ..., vl)
17700
        // Intrinsic: (val0, val1, ..., ptr, vl)
17701
        std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
17702
        IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 1]->getType()};
17703
        assert(Ops.size() == NF + 2);
17704
      }
17705
    }
17706
            break;
17707
case RISCVVector::BI__builtin_rvv_vsseg3e8_v_m:
17708
case RISCVVector::BI__builtin_rvv_vsseg3e16_v_m:
17709
case RISCVVector::BI__builtin_rvv_vsseg3e32_v_m:
17710
case RISCVVector::BI__builtin_rvv_vsseg3e64_v_m:
17711
  ID = Intrinsic::riscv_vsseg3_mask;
17712
  NF = 3;
17713
  PolicyAttrs = 3;
17714
IsMasked = true;
17715
 
17716
    {
17717
      if (IsMasked) {
17718
        // Builtin: (mask, ptr, val0, val1, ..., vl)
17719
        // Intrinsic: (val0, val1, ..., ptr, mask, vl)
17720
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
17721
        std::swap(Ops[NF], Ops[NF + 1]);
17722
        IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 2]->getType()};
17723
        assert(Ops.size() == NF + 3);
17724
      } else {
17725
        // Builtin: (ptr, val0, val1, ..., vl)
17726
        // Intrinsic: (val0, val1, ..., ptr, vl)
17727
        std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
17728
        IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 1]->getType()};
17729
        assert(Ops.size() == NF + 2);
17730
      }
17731
    }
17732
            break;
17733
case RISCVVector::BI__builtin_rvv_vsseg4e8_v:
17734
case RISCVVector::BI__builtin_rvv_vsseg4e16_v:
17735
case RISCVVector::BI__builtin_rvv_vsseg4e32_v:
17736
case RISCVVector::BI__builtin_rvv_vsseg4e64_v:
17737
  ID = Intrinsic::riscv_vsseg4;
17738
  NF = 4;
17739
  PolicyAttrs = 3;
17740
IsMasked = false;
17741
 
17742
    {
17743
      if (IsMasked) {
17744
        // Builtin: (mask, ptr, val0, val1, ..., vl)
17745
        // Intrinsic: (val0, val1, ..., ptr, mask, vl)
17746
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
17747
        std::swap(Ops[NF], Ops[NF + 1]);
17748
        IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 2]->getType()};
17749
        assert(Ops.size() == NF + 3);
17750
      } else {
17751
        // Builtin: (ptr, val0, val1, ..., vl)
17752
        // Intrinsic: (val0, val1, ..., ptr, vl)
17753
        std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
17754
        IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 1]->getType()};
17755
        assert(Ops.size() == NF + 2);
17756
      }
17757
    }
17758
            break;
17759
case RISCVVector::BI__builtin_rvv_vsseg4e8_v_m:
17760
case RISCVVector::BI__builtin_rvv_vsseg4e16_v_m:
17761
case RISCVVector::BI__builtin_rvv_vsseg4e32_v_m:
17762
case RISCVVector::BI__builtin_rvv_vsseg4e64_v_m:
17763
  ID = Intrinsic::riscv_vsseg4_mask;
17764
  NF = 4;
17765
  PolicyAttrs = 3;
17766
IsMasked = true;
17767
 
17768
    {
17769
      if (IsMasked) {
17770
        // Builtin: (mask, ptr, val0, val1, ..., vl)
17771
        // Intrinsic: (val0, val1, ..., ptr, mask, vl)
17772
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
17773
        std::swap(Ops[NF], Ops[NF + 1]);
17774
        IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 2]->getType()};
17775
        assert(Ops.size() == NF + 3);
17776
      } else {
17777
        // Builtin: (ptr, val0, val1, ..., vl)
17778
        // Intrinsic: (val0, val1, ..., ptr, vl)
17779
        std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
17780
        IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 1]->getType()};
17781
        assert(Ops.size() == NF + 2);
17782
      }
17783
    }
17784
            break;
17785
case RISCVVector::BI__builtin_rvv_vsseg5e8_v:
17786
case RISCVVector::BI__builtin_rvv_vsseg5e16_v:
17787
case RISCVVector::BI__builtin_rvv_vsseg5e32_v:
17788
case RISCVVector::BI__builtin_rvv_vsseg5e64_v:
17789
  ID = Intrinsic::riscv_vsseg5;
17790
  NF = 5;
17791
  PolicyAttrs = 3;
17792
IsMasked = false;
17793
 
17794
    {
17795
      if (IsMasked) {
17796
        // Builtin: (mask, ptr, val0, val1, ..., vl)
17797
        // Intrinsic: (val0, val1, ..., ptr, mask, vl)
17798
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
17799
        std::swap(Ops[NF], Ops[NF + 1]);
17800
        IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 2]->getType()};
17801
        assert(Ops.size() == NF + 3);
17802
      } else {
17803
        // Builtin: (ptr, val0, val1, ..., vl)
17804
        // Intrinsic: (val0, val1, ..., ptr, vl)
17805
        std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
17806
        IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 1]->getType()};
17807
        assert(Ops.size() == NF + 2);
17808
      }
17809
    }
17810
            break;
17811
case RISCVVector::BI__builtin_rvv_vsseg5e8_v_m:
17812
case RISCVVector::BI__builtin_rvv_vsseg5e16_v_m:
17813
case RISCVVector::BI__builtin_rvv_vsseg5e32_v_m:
17814
case RISCVVector::BI__builtin_rvv_vsseg5e64_v_m:
17815
  ID = Intrinsic::riscv_vsseg5_mask;
17816
  NF = 5;
17817
  PolicyAttrs = 3;
17818
IsMasked = true;
17819
 
17820
    {
17821
      if (IsMasked) {
17822
        // Builtin: (mask, ptr, val0, val1, ..., vl)
17823
        // Intrinsic: (val0, val1, ..., ptr, mask, vl)
17824
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
17825
        std::swap(Ops[NF], Ops[NF + 1]);
17826
        IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 2]->getType()};
17827
        assert(Ops.size() == NF + 3);
17828
      } else {
17829
        // Builtin: (ptr, val0, val1, ..., vl)
17830
        // Intrinsic: (val0, val1, ..., ptr, vl)
17831
        std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
17832
        IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 1]->getType()};
17833
        assert(Ops.size() == NF + 2);
17834
      }
17835
    }
17836
            break;
17837
case RISCVVector::BI__builtin_rvv_vsseg6e8_v:
17838
case RISCVVector::BI__builtin_rvv_vsseg6e16_v:
17839
case RISCVVector::BI__builtin_rvv_vsseg6e32_v:
17840
case RISCVVector::BI__builtin_rvv_vsseg6e64_v:
17841
  ID = Intrinsic::riscv_vsseg6;
17842
  NF = 6;
17843
  PolicyAttrs = 3;
17844
IsMasked = false;
17845
 
17846
    {
17847
      if (IsMasked) {
17848
        // Builtin: (mask, ptr, val0, val1, ..., vl)
17849
        // Intrinsic: (val0, val1, ..., ptr, mask, vl)
17850
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
17851
        std::swap(Ops[NF], Ops[NF + 1]);
17852
        IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 2]->getType()};
17853
        assert(Ops.size() == NF + 3);
17854
      } else {
17855
        // Builtin: (ptr, val0, val1, ..., vl)
17856
        // Intrinsic: (val0, val1, ..., ptr, vl)
17857
        std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
17858
        IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 1]->getType()};
17859
        assert(Ops.size() == NF + 2);
17860
      }
17861
    }
17862
            break;
17863
case RISCVVector::BI__builtin_rvv_vsseg6e8_v_m:
17864
case RISCVVector::BI__builtin_rvv_vsseg6e16_v_m:
17865
case RISCVVector::BI__builtin_rvv_vsseg6e32_v_m:
17866
case RISCVVector::BI__builtin_rvv_vsseg6e64_v_m:
17867
  ID = Intrinsic::riscv_vsseg6_mask;
17868
  NF = 6;
17869
  PolicyAttrs = 3;
17870
IsMasked = true;
17871
 
17872
    {
17873
      if (IsMasked) {
17874
        // Builtin: (mask, ptr, val0, val1, ..., vl)
17875
        // Intrinsic: (val0, val1, ..., ptr, mask, vl)
17876
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
17877
        std::swap(Ops[NF], Ops[NF + 1]);
17878
        IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 2]->getType()};
17879
        assert(Ops.size() == NF + 3);
17880
      } else {
17881
        // Builtin: (ptr, val0, val1, ..., vl)
17882
        // Intrinsic: (val0, val1, ..., ptr, vl)
17883
        std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
17884
        IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 1]->getType()};
17885
        assert(Ops.size() == NF + 2);
17886
      }
17887
    }
17888
            break;
17889
case RISCVVector::BI__builtin_rvv_vsseg7e8_v:
17890
case RISCVVector::BI__builtin_rvv_vsseg7e16_v:
17891
case RISCVVector::BI__builtin_rvv_vsseg7e32_v:
17892
case RISCVVector::BI__builtin_rvv_vsseg7e64_v:
17893
  ID = Intrinsic::riscv_vsseg7;
17894
  NF = 7;
17895
  PolicyAttrs = 3;
17896
IsMasked = false;
17897
 
17898
    {
17899
      if (IsMasked) {
17900
        // Builtin: (mask, ptr, val0, val1, ..., vl)
17901
        // Intrinsic: (val0, val1, ..., ptr, mask, vl)
17902
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
17903
        std::swap(Ops[NF], Ops[NF + 1]);
17904
        IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 2]->getType()};
17905
        assert(Ops.size() == NF + 3);
17906
      } else {
17907
        // Builtin: (ptr, val0, val1, ..., vl)
17908
        // Intrinsic: (val0, val1, ..., ptr, vl)
17909
        std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
17910
        IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 1]->getType()};
17911
        assert(Ops.size() == NF + 2);
17912
      }
17913
    }
17914
            break;
17915
case RISCVVector::BI__builtin_rvv_vsseg7e8_v_m:
17916
case RISCVVector::BI__builtin_rvv_vsseg7e16_v_m:
17917
case RISCVVector::BI__builtin_rvv_vsseg7e32_v_m:
17918
case RISCVVector::BI__builtin_rvv_vsseg7e64_v_m:
17919
  ID = Intrinsic::riscv_vsseg7_mask;
17920
  NF = 7;
17921
  PolicyAttrs = 3;
17922
IsMasked = true;
17923
 
17924
    {
17925
      if (IsMasked) {
17926
        // Builtin: (mask, ptr, val0, val1, ..., vl)
17927
        // Intrinsic: (val0, val1, ..., ptr, mask, vl)
17928
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
17929
        std::swap(Ops[NF], Ops[NF + 1]);
17930
        IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 2]->getType()};
17931
        assert(Ops.size() == NF + 3);
17932
      } else {
17933
        // Builtin: (ptr, val0, val1, ..., vl)
17934
        // Intrinsic: (val0, val1, ..., ptr, vl)
17935
        std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
17936
        IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 1]->getType()};
17937
        assert(Ops.size() == NF + 2);
17938
      }
17939
    }
17940
            break;
17941
case RISCVVector::BI__builtin_rvv_vsseg8e8_v:
17942
case RISCVVector::BI__builtin_rvv_vsseg8e16_v:
17943
case RISCVVector::BI__builtin_rvv_vsseg8e32_v:
17944
case RISCVVector::BI__builtin_rvv_vsseg8e64_v:
17945
  ID = Intrinsic::riscv_vsseg8;
17946
  NF = 8;
17947
  PolicyAttrs = 3;
17948
IsMasked = false;
17949
 
17950
    {
17951
      if (IsMasked) {
17952
        // Builtin: (mask, ptr, val0, val1, ..., vl)
17953
        // Intrinsic: (val0, val1, ..., ptr, mask, vl)
17954
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
17955
        std::swap(Ops[NF], Ops[NF + 1]);
17956
        IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 2]->getType()};
17957
        assert(Ops.size() == NF + 3);
17958
      } else {
17959
        // Builtin: (ptr, val0, val1, ..., vl)
17960
        // Intrinsic: (val0, val1, ..., ptr, vl)
17961
        std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
17962
        IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 1]->getType()};
17963
        assert(Ops.size() == NF + 2);
17964
      }
17965
    }
17966
            break;
17967
case RISCVVector::BI__builtin_rvv_vsseg8e8_v_m:
17968
case RISCVVector::BI__builtin_rvv_vsseg8e16_v_m:
17969
case RISCVVector::BI__builtin_rvv_vsseg8e32_v_m:
17970
case RISCVVector::BI__builtin_rvv_vsseg8e64_v_m:
17971
  ID = Intrinsic::riscv_vsseg8_mask;
17972
  NF = 8;
17973
  PolicyAttrs = 3;
17974
IsMasked = true;
17975
 
17976
    {
17977
      if (IsMasked) {
17978
        // Builtin: (mask, ptr, val0, val1, ..., vl)
17979
        // Intrinsic: (val0, val1, ..., ptr, mask, vl)
17980
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
17981
        std::swap(Ops[NF], Ops[NF + 1]);
17982
        IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 2]->getType()};
17983
        assert(Ops.size() == NF + 3);
17984
      } else {
17985
        // Builtin: (ptr, val0, val1, ..., vl)
17986
        // Intrinsic: (val0, val1, ..., ptr, vl)
17987
        std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
17988
        IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 1]->getType()};
17989
        assert(Ops.size() == NF + 2);
17990
      }
17991
    }
17992
            break;
17993
case RISCVVector::BI__builtin_rvv_vssra_vv_tu:
17994
case RISCVVector::BI__builtin_rvv_vssra_vx_tu:
17995
  ID = Intrinsic::riscv_vssra;
17996
  PolicyAttrs = 2;
17997
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
17998
  break;
17999
case RISCVVector::BI__builtin_rvv_vssra_vv_ta:
18000
case RISCVVector::BI__builtin_rvv_vssra_vx_ta:
18001
  ID = Intrinsic::riscv_vssra;
18002
  PolicyAttrs = 3;
18003
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
18004
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
18005
  break;
18006
case RISCVVector::BI__builtin_rvv_vssra_vv_tum:
18007
case RISCVVector::BI__builtin_rvv_vssra_vx_tum:
18008
  ID = Intrinsic::riscv_vssra_mask;
18009
  PolicyAttrs = 2;
18010
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
18011
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
18012
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
18013
  break;
18014
case RISCVVector::BI__builtin_rvv_vssra_vv_tama:
18015
case RISCVVector::BI__builtin_rvv_vssra_vx_tama:
18016
  ID = Intrinsic::riscv_vssra_mask;
18017
  PolicyAttrs = 3;
18018
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
18019
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
18020
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
18021
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
18022
  break;
18023
case RISCVVector::BI__builtin_rvv_vssra_vv_tumu:
18024
case RISCVVector::BI__builtin_rvv_vssra_vx_tumu:
18025
  ID = Intrinsic::riscv_vssra_mask;
18026
  PolicyAttrs = 0;
18027
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
18028
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
18029
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
18030
  break;
18031
case RISCVVector::BI__builtin_rvv_vssra_vv_mu:
18032
case RISCVVector::BI__builtin_rvv_vssra_vx_mu:
18033
  ID = Intrinsic::riscv_vssra_mask;
18034
  PolicyAttrs = 1;
18035
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
18036
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
18037
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
18038
  break;
18039
case RISCVVector::BI__builtin_rvv_vssrl_vv_tu:
18040
case RISCVVector::BI__builtin_rvv_vssrl_vx_tu:
18041
  ID = Intrinsic::riscv_vssrl;
18042
  PolicyAttrs = 2;
18043
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
18044
  break;
18045
case RISCVVector::BI__builtin_rvv_vssrl_vv_ta:
18046
case RISCVVector::BI__builtin_rvv_vssrl_vx_ta:
18047
  ID = Intrinsic::riscv_vssrl;
18048
  PolicyAttrs = 3;
18049
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
18050
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
18051
  break;
18052
case RISCVVector::BI__builtin_rvv_vssrl_vv_tum:
18053
case RISCVVector::BI__builtin_rvv_vssrl_vx_tum:
18054
  ID = Intrinsic::riscv_vssrl_mask;
18055
  PolicyAttrs = 2;
18056
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
18057
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
18058
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
18059
  break;
18060
case RISCVVector::BI__builtin_rvv_vssrl_vv_tama:
18061
case RISCVVector::BI__builtin_rvv_vssrl_vx_tama:
18062
  ID = Intrinsic::riscv_vssrl_mask;
18063
  PolicyAttrs = 3;
18064
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
18065
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
18066
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
18067
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
18068
  break;
18069
case RISCVVector::BI__builtin_rvv_vssrl_vv_tumu:
18070
case RISCVVector::BI__builtin_rvv_vssrl_vx_tumu:
18071
  ID = Intrinsic::riscv_vssrl_mask;
18072
  PolicyAttrs = 0;
18073
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
18074
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
18075
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
18076
  break;
18077
case RISCVVector::BI__builtin_rvv_vssrl_vv_mu:
18078
case RISCVVector::BI__builtin_rvv_vssrl_vx_mu:
18079
  ID = Intrinsic::riscv_vssrl_mask;
18080
  PolicyAttrs = 1;
18081
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
18082
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
18083
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
18084
  break;
18085
case RISCVVector::BI__builtin_rvv_vssseg2e16_v:
18086
case RISCVVector::BI__builtin_rvv_vssseg2e32_v:
18087
case RISCVVector::BI__builtin_rvv_vssseg2e64_v:
18088
case RISCVVector::BI__builtin_rvv_vssseg2e8_v:
18089
  ID = Intrinsic::riscv_vssseg2;
18090
  NF = 2;
18091
  PolicyAttrs = 3;
18092
IsMasked = false;
18093
 
18094
    {
18095
      if (IsMasked) {
18096
        // Builtin: (mask, ptr, stride, val0, val1, ..., vl).
18097
        // Intrinsic: (val0, val1, ..., ptr, stride, mask, vl)
18098
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
18099
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
18100
        assert(Ops.size() == NF + 4);
18101
      } else {
18102
        // Builtin: (ptr, stride, val0, val1, ..., vl).
18103
        // Intrinsic: (val0, val1, ..., ptr, stride, vl)
18104
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
18105
        assert(Ops.size() == NF + 3);
18106
      }
18107
      IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 1]->getType()};
18108
    }
18109
            break;
18110
case RISCVVector::BI__builtin_rvv_vssseg2e16_v_m:
18111
case RISCVVector::BI__builtin_rvv_vssseg2e32_v_m:
18112
case RISCVVector::BI__builtin_rvv_vssseg2e64_v_m:
18113
case RISCVVector::BI__builtin_rvv_vssseg2e8_v_m:
18114
  ID = Intrinsic::riscv_vssseg2_mask;
18115
  NF = 2;
18116
  PolicyAttrs = 3;
18117
IsMasked = true;
18118
 
18119
    {
18120
      if (IsMasked) {
18121
        // Builtin: (mask, ptr, stride, val0, val1, ..., vl).
18122
        // Intrinsic: (val0, val1, ..., ptr, stride, mask, vl)
18123
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
18124
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
18125
        assert(Ops.size() == NF + 4);
18126
      } else {
18127
        // Builtin: (ptr, stride, val0, val1, ..., vl).
18128
        // Intrinsic: (val0, val1, ..., ptr, stride, vl)
18129
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
18130
        assert(Ops.size() == NF + 3);
18131
      }
18132
      IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 1]->getType()};
18133
    }
18134
            break;
18135
case RISCVVector::BI__builtin_rvv_vssseg3e8_v:
18136
case RISCVVector::BI__builtin_rvv_vssseg3e16_v:
18137
case RISCVVector::BI__builtin_rvv_vssseg3e32_v:
18138
case RISCVVector::BI__builtin_rvv_vssseg3e64_v:
18139
  ID = Intrinsic::riscv_vssseg3;
18140
  NF = 3;
18141
  PolicyAttrs = 3;
18142
IsMasked = false;
18143
 
18144
    {
18145
      if (IsMasked) {
18146
        // Builtin: (mask, ptr, stride, val0, val1, ..., vl).
18147
        // Intrinsic: (val0, val1, ..., ptr, stride, mask, vl)
18148
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
18149
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
18150
        assert(Ops.size() == NF + 4);
18151
      } else {
18152
        // Builtin: (ptr, stride, val0, val1, ..., vl).
18153
        // Intrinsic: (val0, val1, ..., ptr, stride, vl)
18154
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
18155
        assert(Ops.size() == NF + 3);
18156
      }
18157
      IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 1]->getType()};
18158
    }
18159
            break;
18160
case RISCVVector::BI__builtin_rvv_vssseg3e8_v_m:
18161
case RISCVVector::BI__builtin_rvv_vssseg3e16_v_m:
18162
case RISCVVector::BI__builtin_rvv_vssseg3e32_v_m:
18163
case RISCVVector::BI__builtin_rvv_vssseg3e64_v_m:
18164
  ID = Intrinsic::riscv_vssseg3_mask;
18165
  NF = 3;
18166
  PolicyAttrs = 3;
18167
IsMasked = true;
18168
 
18169
    {
18170
      if (IsMasked) {
18171
        // Builtin: (mask, ptr, stride, val0, val1, ..., vl).
18172
        // Intrinsic: (val0, val1, ..., ptr, stride, mask, vl)
18173
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
18174
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
18175
        assert(Ops.size() == NF + 4);
18176
      } else {
18177
        // Builtin: (ptr, stride, val0, val1, ..., vl).
18178
        // Intrinsic: (val0, val1, ..., ptr, stride, vl)
18179
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
18180
        assert(Ops.size() == NF + 3);
18181
      }
18182
      IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 1]->getType()};
18183
    }
18184
            break;
18185
case RISCVVector::BI__builtin_rvv_vssseg4e8_v:
18186
case RISCVVector::BI__builtin_rvv_vssseg4e16_v:
18187
case RISCVVector::BI__builtin_rvv_vssseg4e32_v:
18188
case RISCVVector::BI__builtin_rvv_vssseg4e64_v:
18189
  ID = Intrinsic::riscv_vssseg4;
18190
  NF = 4;
18191
  PolicyAttrs = 3;
18192
IsMasked = false;
18193
 
18194
    {
18195
      if (IsMasked) {
18196
        // Builtin: (mask, ptr, stride, val0, val1, ..., vl).
18197
        // Intrinsic: (val0, val1, ..., ptr, stride, mask, vl)
18198
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
18199
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
18200
        assert(Ops.size() == NF + 4);
18201
      } else {
18202
        // Builtin: (ptr, stride, val0, val1, ..., vl).
18203
        // Intrinsic: (val0, val1, ..., ptr, stride, vl)
18204
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
18205
        assert(Ops.size() == NF + 3);
18206
      }
18207
      IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 1]->getType()};
18208
    }
18209
            break;
18210
case RISCVVector::BI__builtin_rvv_vssseg4e8_v_m:
18211
case RISCVVector::BI__builtin_rvv_vssseg4e16_v_m:
18212
case RISCVVector::BI__builtin_rvv_vssseg4e32_v_m:
18213
case RISCVVector::BI__builtin_rvv_vssseg4e64_v_m:
18214
  ID = Intrinsic::riscv_vssseg4_mask;
18215
  NF = 4;
18216
  PolicyAttrs = 3;
18217
IsMasked = true;
18218
 
18219
    {
18220
      if (IsMasked) {
18221
        // Builtin: (mask, ptr, stride, val0, val1, ..., vl).
18222
        // Intrinsic: (val0, val1, ..., ptr, stride, mask, vl)
18223
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
18224
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
18225
        assert(Ops.size() == NF + 4);
18226
      } else {
18227
        // Builtin: (ptr, stride, val0, val1, ..., vl).
18228
        // Intrinsic: (val0, val1, ..., ptr, stride, vl)
18229
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
18230
        assert(Ops.size() == NF + 3);
18231
      }
18232
      IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 1]->getType()};
18233
    }
18234
            break;
18235
case RISCVVector::BI__builtin_rvv_vssseg5e8_v:
18236
case RISCVVector::BI__builtin_rvv_vssseg5e16_v:
18237
case RISCVVector::BI__builtin_rvv_vssseg5e32_v:
18238
case RISCVVector::BI__builtin_rvv_vssseg5e64_v:
18239
  ID = Intrinsic::riscv_vssseg5;
18240
  NF = 5;
18241
  PolicyAttrs = 3;
18242
IsMasked = false;
18243
 
18244
    {
18245
      if (IsMasked) {
18246
        // Builtin: (mask, ptr, stride, val0, val1, ..., vl).
18247
        // Intrinsic: (val0, val1, ..., ptr, stride, mask, vl)
18248
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
18249
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
18250
        assert(Ops.size() == NF + 4);
18251
      } else {
18252
        // Builtin: (ptr, stride, val0, val1, ..., vl).
18253
        // Intrinsic: (val0, val1, ..., ptr, stride, vl)
18254
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
18255
        assert(Ops.size() == NF + 3);
18256
      }
18257
      IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 1]->getType()};
18258
    }
18259
            break;
18260
case RISCVVector::BI__builtin_rvv_vssseg5e8_v_m:
18261
case RISCVVector::BI__builtin_rvv_vssseg5e16_v_m:
18262
case RISCVVector::BI__builtin_rvv_vssseg5e32_v_m:
18263
case RISCVVector::BI__builtin_rvv_vssseg5e64_v_m:
18264
  ID = Intrinsic::riscv_vssseg5_mask;
18265
  NF = 5;
18266
  PolicyAttrs = 3;
18267
IsMasked = true;
18268
 
18269
    {
18270
      if (IsMasked) {
18271
        // Builtin: (mask, ptr, stride, val0, val1, ..., vl).
18272
        // Intrinsic: (val0, val1, ..., ptr, stride, mask, vl)
18273
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
18274
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
18275
        assert(Ops.size() == NF + 4);
18276
      } else {
18277
        // Builtin: (ptr, stride, val0, val1, ..., vl).
18278
        // Intrinsic: (val0, val1, ..., ptr, stride, vl)
18279
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
18280
        assert(Ops.size() == NF + 3);
18281
      }
18282
      IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 1]->getType()};
18283
    }
18284
            break;
18285
case RISCVVector::BI__builtin_rvv_vssseg6e8_v:
18286
case RISCVVector::BI__builtin_rvv_vssseg6e16_v:
18287
case RISCVVector::BI__builtin_rvv_vssseg6e32_v:
18288
case RISCVVector::BI__builtin_rvv_vssseg6e64_v:
18289
  ID = Intrinsic::riscv_vssseg6;
18290
  NF = 6;
18291
  PolicyAttrs = 3;
18292
IsMasked = false;
18293
 
18294
    {
18295
      if (IsMasked) {
18296
        // Builtin: (mask, ptr, stride, val0, val1, ..., vl).
18297
        // Intrinsic: (val0, val1, ..., ptr, stride, mask, vl)
18298
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
18299
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
18300
        assert(Ops.size() == NF + 4);
18301
      } else {
18302
        // Builtin: (ptr, stride, val0, val1, ..., vl).
18303
        // Intrinsic: (val0, val1, ..., ptr, stride, vl)
18304
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
18305
        assert(Ops.size() == NF + 3);
18306
      }
18307
      IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 1]->getType()};
18308
    }
18309
            break;
18310
case RISCVVector::BI__builtin_rvv_vssseg6e8_v_m:
18311
case RISCVVector::BI__builtin_rvv_vssseg6e16_v_m:
18312
case RISCVVector::BI__builtin_rvv_vssseg6e32_v_m:
18313
case RISCVVector::BI__builtin_rvv_vssseg6e64_v_m:
18314
  ID = Intrinsic::riscv_vssseg6_mask;
18315
  NF = 6;
18316
  PolicyAttrs = 3;
18317
IsMasked = true;
18318
 
18319
    {
18320
      if (IsMasked) {
18321
        // Builtin: (mask, ptr, stride, val0, val1, ..., vl).
18322
        // Intrinsic: (val0, val1, ..., ptr, stride, mask, vl)
18323
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
18324
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
18325
        assert(Ops.size() == NF + 4);
18326
      } else {
18327
        // Builtin: (ptr, stride, val0, val1, ..., vl).
18328
        // Intrinsic: (val0, val1, ..., ptr, stride, vl)
18329
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
18330
        assert(Ops.size() == NF + 3);
18331
      }
18332
      IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 1]->getType()};
18333
    }
18334
            break;
18335
case RISCVVector::BI__builtin_rvv_vssseg7e8_v:
18336
case RISCVVector::BI__builtin_rvv_vssseg7e16_v:
18337
case RISCVVector::BI__builtin_rvv_vssseg7e32_v:
18338
case RISCVVector::BI__builtin_rvv_vssseg7e64_v:
18339
  ID = Intrinsic::riscv_vssseg7;
18340
  NF = 7;
18341
  PolicyAttrs = 3;
18342
IsMasked = false;
18343
 
18344
    {
18345
      if (IsMasked) {
18346
        // Builtin: (mask, ptr, stride, val0, val1, ..., vl).
18347
        // Intrinsic: (val0, val1, ..., ptr, stride, mask, vl)
18348
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
18349
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
18350
        assert(Ops.size() == NF + 4);
18351
      } else {
18352
        // Builtin: (ptr, stride, val0, val1, ..., vl).
18353
        // Intrinsic: (val0, val1, ..., ptr, stride, vl)
18354
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
18355
        assert(Ops.size() == NF + 3);
18356
      }
18357
      IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 1]->getType()};
18358
    }
18359
            break;
18360
case RISCVVector::BI__builtin_rvv_vssseg7e8_v_m:
18361
case RISCVVector::BI__builtin_rvv_vssseg7e16_v_m:
18362
case RISCVVector::BI__builtin_rvv_vssseg7e32_v_m:
18363
case RISCVVector::BI__builtin_rvv_vssseg7e64_v_m:
18364
  ID = Intrinsic::riscv_vssseg7_mask;
18365
  NF = 7;
18366
  PolicyAttrs = 3;
18367
IsMasked = true;
18368
 
18369
    {
18370
      if (IsMasked) {
18371
        // Builtin: (mask, ptr, stride, val0, val1, ..., vl).
18372
        // Intrinsic: (val0, val1, ..., ptr, stride, mask, vl)
18373
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
18374
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
18375
        assert(Ops.size() == NF + 4);
18376
      } else {
18377
        // Builtin: (ptr, stride, val0, val1, ..., vl).
18378
        // Intrinsic: (val0, val1, ..., ptr, stride, vl)
18379
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
18380
        assert(Ops.size() == NF + 3);
18381
      }
18382
      IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 1]->getType()};
18383
    }
18384
            break;
18385
case RISCVVector::BI__builtin_rvv_vssseg8e8_v:
18386
case RISCVVector::BI__builtin_rvv_vssseg8e16_v:
18387
case RISCVVector::BI__builtin_rvv_vssseg8e32_v:
18388
case RISCVVector::BI__builtin_rvv_vssseg8e64_v:
18389
  ID = Intrinsic::riscv_vssseg8;
18390
  NF = 8;
18391
  PolicyAttrs = 3;
18392
IsMasked = false;
18393
 
18394
    {
18395
      if (IsMasked) {
18396
        // Builtin: (mask, ptr, stride, val0, val1, ..., vl).
18397
        // Intrinsic: (val0, val1, ..., ptr, stride, mask, vl)
18398
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
18399
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
18400
        assert(Ops.size() == NF + 4);
18401
      } else {
18402
        // Builtin: (ptr, stride, val0, val1, ..., vl).
18403
        // Intrinsic: (val0, val1, ..., ptr, stride, vl)
18404
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
18405
        assert(Ops.size() == NF + 3);
18406
      }
18407
      IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 1]->getType()};
18408
    }
18409
            break;
18410
case RISCVVector::BI__builtin_rvv_vssseg8e8_v_m:
18411
case RISCVVector::BI__builtin_rvv_vssseg8e16_v_m:
18412
case RISCVVector::BI__builtin_rvv_vssseg8e32_v_m:
18413
case RISCVVector::BI__builtin_rvv_vssseg8e64_v_m:
18414
  ID = Intrinsic::riscv_vssseg8_mask;
18415
  NF = 8;
18416
  PolicyAttrs = 3;
18417
IsMasked = true;
18418
 
18419
    {
18420
      if (IsMasked) {
18421
        // Builtin: (mask, ptr, stride, val0, val1, ..., vl).
18422
        // Intrinsic: (val0, val1, ..., ptr, stride, mask, vl)
18423
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
18424
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
18425
        assert(Ops.size() == NF + 4);
18426
      } else {
18427
        // Builtin: (ptr, stride, val0, val1, ..., vl).
18428
        // Intrinsic: (val0, val1, ..., ptr, stride, vl)
18429
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
18430
        assert(Ops.size() == NF + 3);
18431
      }
18432
      IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 1]->getType()};
18433
    }
18434
            break;
18435
case RISCVVector::BI__builtin_rvv_vssub_vv_tu:
18436
case RISCVVector::BI__builtin_rvv_vssub_vx_tu:
18437
  ID = Intrinsic::riscv_vssub;
18438
  PolicyAttrs = 2;
18439
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
18440
  break;
18441
case RISCVVector::BI__builtin_rvv_vssub_vv_ta:
18442
case RISCVVector::BI__builtin_rvv_vssub_vx_ta:
18443
  ID = Intrinsic::riscv_vssub;
18444
  PolicyAttrs = 3;
18445
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
18446
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
18447
  break;
18448
case RISCVVector::BI__builtin_rvv_vssub_vv_tum:
18449
case RISCVVector::BI__builtin_rvv_vssub_vx_tum:
18450
  ID = Intrinsic::riscv_vssub_mask;
18451
  PolicyAttrs = 2;
18452
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
18453
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
18454
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
18455
  break;
18456
case RISCVVector::BI__builtin_rvv_vssub_vv_tama:
18457
case RISCVVector::BI__builtin_rvv_vssub_vx_tama:
18458
  ID = Intrinsic::riscv_vssub_mask;
18459
  PolicyAttrs = 3;
18460
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
18461
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
18462
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
18463
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
18464
  break;
18465
case RISCVVector::BI__builtin_rvv_vssub_vv_tumu:
18466
case RISCVVector::BI__builtin_rvv_vssub_vx_tumu:
18467
  ID = Intrinsic::riscv_vssub_mask;
18468
  PolicyAttrs = 0;
18469
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
18470
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
18471
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
18472
  break;
18473
case RISCVVector::BI__builtin_rvv_vssub_vv_mu:
18474
case RISCVVector::BI__builtin_rvv_vssub_vx_mu:
18475
  ID = Intrinsic::riscv_vssub_mask;
18476
  PolicyAttrs = 1;
18477
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
18478
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
18479
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
18480
  break;
18481
case RISCVVector::BI__builtin_rvv_vssubu_vv_tu:
18482
case RISCVVector::BI__builtin_rvv_vssubu_vx_tu:
18483
  ID = Intrinsic::riscv_vssubu;
18484
  PolicyAttrs = 2;
18485
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
18486
  break;
18487
case RISCVVector::BI__builtin_rvv_vssubu_vv_ta:
18488
case RISCVVector::BI__builtin_rvv_vssubu_vx_ta:
18489
  ID = Intrinsic::riscv_vssubu;
18490
  PolicyAttrs = 3;
18491
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
18492
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
18493
  break;
18494
case RISCVVector::BI__builtin_rvv_vssubu_vv_tum:
18495
case RISCVVector::BI__builtin_rvv_vssubu_vx_tum:
18496
  ID = Intrinsic::riscv_vssubu_mask;
18497
  PolicyAttrs = 2;
18498
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
18499
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
18500
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
18501
  break;
18502
case RISCVVector::BI__builtin_rvv_vssubu_vv_tama:
18503
case RISCVVector::BI__builtin_rvv_vssubu_vx_tama:
18504
  ID = Intrinsic::riscv_vssubu_mask;
18505
  PolicyAttrs = 3;
18506
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
18507
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
18508
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
18509
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
18510
  break;
18511
case RISCVVector::BI__builtin_rvv_vssubu_vv_tumu:
18512
case RISCVVector::BI__builtin_rvv_vssubu_vx_tumu:
18513
  ID = Intrinsic::riscv_vssubu_mask;
18514
  PolicyAttrs = 0;
18515
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
18516
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
18517
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
18518
  break;
18519
case RISCVVector::BI__builtin_rvv_vssubu_vv_mu:
18520
case RISCVVector::BI__builtin_rvv_vssubu_vx_mu:
18521
  ID = Intrinsic::riscv_vssubu_mask;
18522
  PolicyAttrs = 1;
18523
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
18524
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
18525
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
18526
  break;
18527
case RISCVVector::BI__builtin_rvv_vsub_vv_tu:
18528
case RISCVVector::BI__builtin_rvv_vsub_vx_tu:
18529
  ID = Intrinsic::riscv_vsub;
18530
  PolicyAttrs = 2;
18531
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
18532
  break;
18533
case RISCVVector::BI__builtin_rvv_vsub_vv_ta:
18534
case RISCVVector::BI__builtin_rvv_vsub_vx_ta:
18535
  ID = Intrinsic::riscv_vsub;
18536
  PolicyAttrs = 3;
18537
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
18538
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
18539
  break;
18540
case RISCVVector::BI__builtin_rvv_vsub_vv_tum:
18541
case RISCVVector::BI__builtin_rvv_vsub_vx_tum:
18542
  ID = Intrinsic::riscv_vsub_mask;
18543
  PolicyAttrs = 2;
18544
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
18545
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
18546
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
18547
  break;
18548
case RISCVVector::BI__builtin_rvv_vsub_vv_tama:
18549
case RISCVVector::BI__builtin_rvv_vsub_vx_tama:
18550
  ID = Intrinsic::riscv_vsub_mask;
18551
  PolicyAttrs = 3;
18552
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
18553
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
18554
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
18555
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
18556
  break;
18557
case RISCVVector::BI__builtin_rvv_vsub_vv_tumu:
18558
case RISCVVector::BI__builtin_rvv_vsub_vx_tumu:
18559
  ID = Intrinsic::riscv_vsub_mask;
18560
  PolicyAttrs = 0;
18561
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
18562
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
18563
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
18564
  break;
18565
case RISCVVector::BI__builtin_rvv_vsub_vv_mu:
18566
case RISCVVector::BI__builtin_rvv_vsub_vx_mu:
18567
  ID = Intrinsic::riscv_vsub_mask;
18568
  PolicyAttrs = 1;
18569
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
18570
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
18571
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
18572
  break;
18573
case RISCVVector::BI__builtin_rvv_vsuxei16_v:
18574
case RISCVVector::BI__builtin_rvv_vsuxei32_v:
18575
case RISCVVector::BI__builtin_rvv_vsuxei8_v:
18576
case RISCVVector::BI__builtin_rvv_vsuxei64_v:
18577
  ID = Intrinsic::riscv_vsuxei;
18578
  PolicyAttrs = 3;
18579
IsMasked = false;
18580
 
18581
        if (IsMasked) {
18582
          // Builtin: (mask, ptr, index, value, vl). Intrinsic: (value, ptr, index, mask, vl)
18583
          std::swap(Ops[0], Ops[3]);
18584
        } else {
18585
          // Builtin: (ptr, index, value, vl). Intrinsic: (value, ptr, index, vl)
18586
          std::rotate(Ops.begin(), Ops.begin() + 2, Ops.begin() + 3);
18587
        }
18588
        Ops[1] = Builder.CreateBitCast(Ops[1], Ops[0]->getType()->getPointerTo());
18589
        if (IsMasked)
18590
          IntrinsicTypes = {Ops[0]->getType(), Ops[2]->getType(), Ops[4]->getType()};
18591
        else
18592
          IntrinsicTypes = {Ops[0]->getType(), Ops[2]->getType(), Ops[3]->getType()};
18593
      break;
18594
case RISCVVector::BI__builtin_rvv_vsuxei16_v_m:
18595
case RISCVVector::BI__builtin_rvv_vsuxei32_v_m:
18596
case RISCVVector::BI__builtin_rvv_vsuxei8_v_m:
18597
case RISCVVector::BI__builtin_rvv_vsuxei64_v_m:
18598
  ID = Intrinsic::riscv_vsuxei_mask;
18599
  PolicyAttrs = 3;
18600
IsMasked = true;
18601
 
18602
        if (IsMasked) {
18603
          // Builtin: (mask, ptr, index, value, vl). Intrinsic: (value, ptr, index, mask, vl)
18604
          std::swap(Ops[0], Ops[3]);
18605
        } else {
18606
          // Builtin: (ptr, index, value, vl). Intrinsic: (value, ptr, index, vl)
18607
          std::rotate(Ops.begin(), Ops.begin() + 2, Ops.begin() + 3);
18608
        }
18609
        Ops[1] = Builder.CreateBitCast(Ops[1], Ops[0]->getType()->getPointerTo());
18610
        if (IsMasked)
18611
          IntrinsicTypes = {Ops[0]->getType(), Ops[2]->getType(), Ops[4]->getType()};
18612
        else
18613
          IntrinsicTypes = {Ops[0]->getType(), Ops[2]->getType(), Ops[3]->getType()};
18614
      break;
18615
case RISCVVector::BI__builtin_rvv_vsuxseg2ei16_v:
18616
case RISCVVector::BI__builtin_rvv_vsuxseg2ei32_v:
18617
case RISCVVector::BI__builtin_rvv_vsuxseg2ei64_v:
18618
case RISCVVector::BI__builtin_rvv_vsuxseg2ei8_v:
18619
  ID = Intrinsic::riscv_vsuxseg2;
18620
  NF = 2;
18621
  PolicyAttrs = 3;
18622
IsMasked = false;
18623
 
18624
    {
18625
      if (IsMasked) {
18626
        // Builtin: (mask, ptr, index, val0, val1, ..., vl)
18627
        // Intrinsic: (val0, val1, ..., ptr, index, mask, vl)
18628
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
18629
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
18630
        IntrinsicTypes = {Ops[0]->getType(),
18631
                          Ops[NF + 1]->getType(), Ops[NF + 3]->getType()};
18632
        assert(Ops.size() == NF + 4);
18633
      } else {
18634
        // Builtin: (ptr, index, val0, val1, ..., vl)
18635
        // Intrinsic: (val0, val1, ..., ptr, index, vl)
18636
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
18637
        IntrinsicTypes = {Ops[0]->getType(),
18638
                          Ops[NF + 1]->getType(), Ops[NF + 2]->getType()};
18639
        assert(Ops.size() == NF + 3);
18640
      }
18641
    }
18642
            break;
18643
case RISCVVector::BI__builtin_rvv_vsuxseg2ei16_v_m:
18644
case RISCVVector::BI__builtin_rvv_vsuxseg2ei32_v_m:
18645
case RISCVVector::BI__builtin_rvv_vsuxseg2ei64_v_m:
18646
case RISCVVector::BI__builtin_rvv_vsuxseg2ei8_v_m:
18647
  ID = Intrinsic::riscv_vsuxseg2_mask;
18648
  NF = 2;
18649
  PolicyAttrs = 3;
18650
IsMasked = true;
18651
 
18652
    {
18653
      if (IsMasked) {
18654
        // Builtin: (mask, ptr, index, val0, val1, ..., vl)
18655
        // Intrinsic: (val0, val1, ..., ptr, index, mask, vl)
18656
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
18657
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
18658
        IntrinsicTypes = {Ops[0]->getType(),
18659
                          Ops[NF + 1]->getType(), Ops[NF + 3]->getType()};
18660
        assert(Ops.size() == NF + 4);
18661
      } else {
18662
        // Builtin: (ptr, index, val0, val1, ..., vl)
18663
        // Intrinsic: (val0, val1, ..., ptr, index, vl)
18664
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
18665
        IntrinsicTypes = {Ops[0]->getType(),
18666
                          Ops[NF + 1]->getType(), Ops[NF + 2]->getType()};
18667
        assert(Ops.size() == NF + 3);
18668
      }
18669
    }
18670
            break;
18671
case RISCVVector::BI__builtin_rvv_vsuxseg3ei8_v:
18672
case RISCVVector::BI__builtin_rvv_vsuxseg3ei16_v:
18673
case RISCVVector::BI__builtin_rvv_vsuxseg3ei32_v:
18674
case RISCVVector::BI__builtin_rvv_vsuxseg3ei64_v:
18675
  ID = Intrinsic::riscv_vsuxseg3;
18676
  NF = 3;
18677
  PolicyAttrs = 3;
18678
IsMasked = false;
18679
 
18680
    {
18681
      if (IsMasked) {
18682
        // Builtin: (mask, ptr, index, val0, val1, ..., vl)
18683
        // Intrinsic: (val0, val1, ..., ptr, index, mask, vl)
18684
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
18685
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
18686
        IntrinsicTypes = {Ops[0]->getType(),
18687
                          Ops[NF + 1]->getType(), Ops[NF + 3]->getType()};
18688
        assert(Ops.size() == NF + 4);
18689
      } else {
18690
        // Builtin: (ptr, index, val0, val1, ..., vl)
18691
        // Intrinsic: (val0, val1, ..., ptr, index, vl)
18692
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
18693
        IntrinsicTypes = {Ops[0]->getType(),
18694
                          Ops[NF + 1]->getType(), Ops[NF + 2]->getType()};
18695
        assert(Ops.size() == NF + 3);
18696
      }
18697
    }
18698
            break;
18699
case RISCVVector::BI__builtin_rvv_vsuxseg3ei8_v_m:
18700
case RISCVVector::BI__builtin_rvv_vsuxseg3ei16_v_m:
18701
case RISCVVector::BI__builtin_rvv_vsuxseg3ei32_v_m:
18702
case RISCVVector::BI__builtin_rvv_vsuxseg3ei64_v_m:
18703
  ID = Intrinsic::riscv_vsuxseg3_mask;
18704
  NF = 3;
18705
  PolicyAttrs = 3;
18706
IsMasked = true;
18707
 
18708
    {
18709
      if (IsMasked) {
18710
        // Builtin: (mask, ptr, index, val0, val1, ..., vl)
18711
        // Intrinsic: (val0, val1, ..., ptr, index, mask, vl)
18712
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
18713
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
18714
        IntrinsicTypes = {Ops[0]->getType(),
18715
                          Ops[NF + 1]->getType(), Ops[NF + 3]->getType()};
18716
        assert(Ops.size() == NF + 4);
18717
      } else {
18718
        // Builtin: (ptr, index, val0, val1, ..., vl)
18719
        // Intrinsic: (val0, val1, ..., ptr, index, vl)
18720
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
18721
        IntrinsicTypes = {Ops[0]->getType(),
18722
                          Ops[NF + 1]->getType(), Ops[NF + 2]->getType()};
18723
        assert(Ops.size() == NF + 3);
18724
      }
18725
    }
18726
            break;
18727
case RISCVVector::BI__builtin_rvv_vsuxseg4ei8_v:
18728
case RISCVVector::BI__builtin_rvv_vsuxseg4ei16_v:
18729
case RISCVVector::BI__builtin_rvv_vsuxseg4ei32_v:
18730
case RISCVVector::BI__builtin_rvv_vsuxseg4ei64_v:
18731
  ID = Intrinsic::riscv_vsuxseg4;
18732
  NF = 4;
18733
  PolicyAttrs = 3;
18734
IsMasked = false;
18735
 
18736
    {
18737
      if (IsMasked) {
18738
        // Builtin: (mask, ptr, index, val0, val1, ..., vl)
18739
        // Intrinsic: (val0, val1, ..., ptr, index, mask, vl)
18740
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
18741
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
18742
        IntrinsicTypes = {Ops[0]->getType(),
18743
                          Ops[NF + 1]->getType(), Ops[NF + 3]->getType()};
18744
        assert(Ops.size() == NF + 4);
18745
      } else {
18746
        // Builtin: (ptr, index, val0, val1, ..., vl)
18747
        // Intrinsic: (val0, val1, ..., ptr, index, vl)
18748
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
18749
        IntrinsicTypes = {Ops[0]->getType(),
18750
                          Ops[NF + 1]->getType(), Ops[NF + 2]->getType()};
18751
        assert(Ops.size() == NF + 3);
18752
      }
18753
    }
18754
            break;
18755
case RISCVVector::BI__builtin_rvv_vsuxseg4ei8_v_m:
18756
case RISCVVector::BI__builtin_rvv_vsuxseg4ei16_v_m:
18757
case RISCVVector::BI__builtin_rvv_vsuxseg4ei32_v_m:
18758
case RISCVVector::BI__builtin_rvv_vsuxseg4ei64_v_m:
18759
  ID = Intrinsic::riscv_vsuxseg4_mask;
18760
  NF = 4;
18761
  PolicyAttrs = 3;
18762
IsMasked = true;
18763
 
18764
    {
18765
      if (IsMasked) {
18766
        // Builtin: (mask, ptr, index, val0, val1, ..., vl)
18767
        // Intrinsic: (val0, val1, ..., ptr, index, mask, vl)
18768
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
18769
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
18770
        IntrinsicTypes = {Ops[0]->getType(),
18771
                          Ops[NF + 1]->getType(), Ops[NF + 3]->getType()};
18772
        assert(Ops.size() == NF + 4);
18773
      } else {
18774
        // Builtin: (ptr, index, val0, val1, ..., vl)
18775
        // Intrinsic: (val0, val1, ..., ptr, index, vl)
18776
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
18777
        IntrinsicTypes = {Ops[0]->getType(),
18778
                          Ops[NF + 1]->getType(), Ops[NF + 2]->getType()};
18779
        assert(Ops.size() == NF + 3);
18780
      }
18781
    }
18782
            break;
18783
case RISCVVector::BI__builtin_rvv_vsuxseg5ei8_v:
18784
case RISCVVector::BI__builtin_rvv_vsuxseg5ei16_v:
18785
case RISCVVector::BI__builtin_rvv_vsuxseg5ei32_v:
18786
case RISCVVector::BI__builtin_rvv_vsuxseg5ei64_v:
18787
  ID = Intrinsic::riscv_vsuxseg5;
18788
  NF = 5;
18789
  PolicyAttrs = 3;
18790
IsMasked = false;
18791
 
18792
    {
18793
      if (IsMasked) {
18794
        // Builtin: (mask, ptr, index, val0, val1, ..., vl)
18795
        // Intrinsic: (val0, val1, ..., ptr, index, mask, vl)
18796
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
18797
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
18798
        IntrinsicTypes = {Ops[0]->getType(),
18799
                          Ops[NF + 1]->getType(), Ops[NF + 3]->getType()};
18800
        assert(Ops.size() == NF + 4);
18801
      } else {
18802
        // Builtin: (ptr, index, val0, val1, ..., vl)
18803
        // Intrinsic: (val0, val1, ..., ptr, index, vl)
18804
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
18805
        IntrinsicTypes = {Ops[0]->getType(),
18806
                          Ops[NF + 1]->getType(), Ops[NF + 2]->getType()};
18807
        assert(Ops.size() == NF + 3);
18808
      }
18809
    }
18810
            break;
18811
case RISCVVector::BI__builtin_rvv_vsuxseg5ei8_v_m:
18812
case RISCVVector::BI__builtin_rvv_vsuxseg5ei16_v_m:
18813
case RISCVVector::BI__builtin_rvv_vsuxseg5ei32_v_m:
18814
case RISCVVector::BI__builtin_rvv_vsuxseg5ei64_v_m:
18815
  ID = Intrinsic::riscv_vsuxseg5_mask;
18816
  NF = 5;
18817
  PolicyAttrs = 3;
18818
IsMasked = true;
18819
 
18820
    {
18821
      if (IsMasked) {
18822
        // Builtin: (mask, ptr, index, val0, val1, ..., vl)
18823
        // Intrinsic: (val0, val1, ..., ptr, index, mask, vl)
18824
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
18825
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
18826
        IntrinsicTypes = {Ops[0]->getType(),
18827
                          Ops[NF + 1]->getType(), Ops[NF + 3]->getType()};
18828
        assert(Ops.size() == NF + 4);
18829
      } else {
18830
        // Builtin: (ptr, index, val0, val1, ..., vl)
18831
        // Intrinsic: (val0, val1, ..., ptr, index, vl)
18832
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
18833
        IntrinsicTypes = {Ops[0]->getType(),
18834
                          Ops[NF + 1]->getType(), Ops[NF + 2]->getType()};
18835
        assert(Ops.size() == NF + 3);
18836
      }
18837
    }
18838
            break;
18839
case RISCVVector::BI__builtin_rvv_vsuxseg6ei8_v:
18840
case RISCVVector::BI__builtin_rvv_vsuxseg6ei16_v:
18841
case RISCVVector::BI__builtin_rvv_vsuxseg6ei32_v:
18842
case RISCVVector::BI__builtin_rvv_vsuxseg6ei64_v:
18843
  ID = Intrinsic::riscv_vsuxseg6;
18844
  NF = 6;
18845
  PolicyAttrs = 3;
18846
IsMasked = false;
18847
 
18848
    {
18849
      if (IsMasked) {
18850
        // Builtin: (mask, ptr, index, val0, val1, ..., vl)
18851
        // Intrinsic: (val0, val1, ..., ptr, index, mask, vl)
18852
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
18853
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
18854
        IntrinsicTypes = {Ops[0]->getType(),
18855
                          Ops[NF + 1]->getType(), Ops[NF + 3]->getType()};
18856
        assert(Ops.size() == NF + 4);
18857
      } else {
18858
        // Builtin: (ptr, index, val0, val1, ..., vl)
18859
        // Intrinsic: (val0, val1, ..., ptr, index, vl)
18860
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
18861
        IntrinsicTypes = {Ops[0]->getType(),
18862
                          Ops[NF + 1]->getType(), Ops[NF + 2]->getType()};
18863
        assert(Ops.size() == NF + 3);
18864
      }
18865
    }
18866
            break;
18867
case RISCVVector::BI__builtin_rvv_vsuxseg6ei8_v_m:
18868
case RISCVVector::BI__builtin_rvv_vsuxseg6ei16_v_m:
18869
case RISCVVector::BI__builtin_rvv_vsuxseg6ei32_v_m:
18870
case RISCVVector::BI__builtin_rvv_vsuxseg6ei64_v_m:
18871
  ID = Intrinsic::riscv_vsuxseg6_mask;
18872
  NF = 6;
18873
  PolicyAttrs = 3;
18874
IsMasked = true;
18875
 
18876
    {
18877
      if (IsMasked) {
18878
        // Builtin: (mask, ptr, index, val0, val1, ..., vl)
18879
        // Intrinsic: (val0, val1, ..., ptr, index, mask, vl)
18880
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
18881
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
18882
        IntrinsicTypes = {Ops[0]->getType(),
18883
                          Ops[NF + 1]->getType(), Ops[NF + 3]->getType()};
18884
        assert(Ops.size() == NF + 4);
18885
      } else {
18886
        // Builtin: (ptr, index, val0, val1, ..., vl)
18887
        // Intrinsic: (val0, val1, ..., ptr, index, vl)
18888
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
18889
        IntrinsicTypes = {Ops[0]->getType(),
18890
                          Ops[NF + 1]->getType(), Ops[NF + 2]->getType()};
18891
        assert(Ops.size() == NF + 3);
18892
      }
18893
    }
18894
            break;
18895
case RISCVVector::BI__builtin_rvv_vsuxseg7ei8_v:
18896
case RISCVVector::BI__builtin_rvv_vsuxseg7ei16_v:
18897
case RISCVVector::BI__builtin_rvv_vsuxseg7ei32_v:
18898
case RISCVVector::BI__builtin_rvv_vsuxseg7ei64_v:
18899
  ID = Intrinsic::riscv_vsuxseg7;
18900
  NF = 7;
18901
  PolicyAttrs = 3;
18902
IsMasked = false;
18903
 
18904
    {
18905
      if (IsMasked) {
18906
        // Builtin: (mask, ptr, index, val0, val1, ..., vl)
18907
        // Intrinsic: (val0, val1, ..., ptr, index, mask, vl)
18908
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
18909
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
18910
        IntrinsicTypes = {Ops[0]->getType(),
18911
                          Ops[NF + 1]->getType(), Ops[NF + 3]->getType()};
18912
        assert(Ops.size() == NF + 4);
18913
      } else {
18914
        // Builtin: (ptr, index, val0, val1, ..., vl)
18915
        // Intrinsic: (val0, val1, ..., ptr, index, vl)
18916
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
18917
        IntrinsicTypes = {Ops[0]->getType(),
18918
                          Ops[NF + 1]->getType(), Ops[NF + 2]->getType()};
18919
        assert(Ops.size() == NF + 3);
18920
      }
18921
    }
18922
            break;
18923
case RISCVVector::BI__builtin_rvv_vsuxseg7ei8_v_m:
18924
case RISCVVector::BI__builtin_rvv_vsuxseg7ei16_v_m:
18925
case RISCVVector::BI__builtin_rvv_vsuxseg7ei32_v_m:
18926
case RISCVVector::BI__builtin_rvv_vsuxseg7ei64_v_m:
18927
  ID = Intrinsic::riscv_vsuxseg7_mask;
18928
  NF = 7;
18929
  PolicyAttrs = 3;
18930
IsMasked = true;
18931
 
18932
    {
18933
      if (IsMasked) {
18934
        // Builtin: (mask, ptr, index, val0, val1, ..., vl)
18935
        // Intrinsic: (val0, val1, ..., ptr, index, mask, vl)
18936
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
18937
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
18938
        IntrinsicTypes = {Ops[0]->getType(),
18939
                          Ops[NF + 1]->getType(), Ops[NF + 3]->getType()};
18940
        assert(Ops.size() == NF + 4);
18941
      } else {
18942
        // Builtin: (ptr, index, val0, val1, ..., vl)
18943
        // Intrinsic: (val0, val1, ..., ptr, index, vl)
18944
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
18945
        IntrinsicTypes = {Ops[0]->getType(),
18946
                          Ops[NF + 1]->getType(), Ops[NF + 2]->getType()};
18947
        assert(Ops.size() == NF + 3);
18948
      }
18949
    }
18950
            break;
18951
case RISCVVector::BI__builtin_rvv_vsuxseg8ei8_v:
18952
case RISCVVector::BI__builtin_rvv_vsuxseg8ei16_v:
18953
case RISCVVector::BI__builtin_rvv_vsuxseg8ei32_v:
18954
case RISCVVector::BI__builtin_rvv_vsuxseg8ei64_v:
18955
  ID = Intrinsic::riscv_vsuxseg8;
18956
  NF = 8;
18957
  PolicyAttrs = 3;
18958
IsMasked = false;
18959
 
18960
    {
18961
      if (IsMasked) {
18962
        // Builtin: (mask, ptr, index, val0, val1, ..., vl)
18963
        // Intrinsic: (val0, val1, ..., ptr, index, mask, vl)
18964
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
18965
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
18966
        IntrinsicTypes = {Ops[0]->getType(),
18967
                          Ops[NF + 1]->getType(), Ops[NF + 3]->getType()};
18968
        assert(Ops.size() == NF + 4);
18969
      } else {
18970
        // Builtin: (ptr, index, val0, val1, ..., vl)
18971
        // Intrinsic: (val0, val1, ..., ptr, index, vl)
18972
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
18973
        IntrinsicTypes = {Ops[0]->getType(),
18974
                          Ops[NF + 1]->getType(), Ops[NF + 2]->getType()};
18975
        assert(Ops.size() == NF + 3);
18976
      }
18977
    }
18978
            break;
18979
case RISCVVector::BI__builtin_rvv_vsuxseg8ei8_v_m:
18980
case RISCVVector::BI__builtin_rvv_vsuxseg8ei16_v_m:
18981
case RISCVVector::BI__builtin_rvv_vsuxseg8ei32_v_m:
18982
case RISCVVector::BI__builtin_rvv_vsuxseg8ei64_v_m:
18983
  ID = Intrinsic::riscv_vsuxseg8_mask;
18984
  NF = 8;
18985
  PolicyAttrs = 3;
18986
IsMasked = true;
18987
 
18988
    {
18989
      if (IsMasked) {
18990
        // Builtin: (mask, ptr, index, val0, val1, ..., vl)
18991
        // Intrinsic: (val0, val1, ..., ptr, index, mask, vl)
18992
        std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
18993
        std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 3);
18994
        IntrinsicTypes = {Ops[0]->getType(),
18995
                          Ops[NF + 1]->getType(), Ops[NF + 3]->getType()};
18996
        assert(Ops.size() == NF + 4);
18997
      } else {
18998
        // Builtin: (ptr, index, val0, val1, ..., vl)
18999
        // Intrinsic: (val0, val1, ..., ptr, index, vl)
19000
        std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
19001
        IntrinsicTypes = {Ops[0]->getType(),
19002
                          Ops[NF + 1]->getType(), Ops[NF + 2]->getType()};
19003
        assert(Ops.size() == NF + 3);
19004
      }
19005
    }
19006
            break;
19007
case RISCVVector::BI__builtin_rvv_vwadd_vv_tu:
19008
case RISCVVector::BI__builtin_rvv_vwadd_vx_tu:
19009
  ID = Intrinsic::riscv_vwadd;
19010
  PolicyAttrs = 2;
19011
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19012
  break;
19013
case RISCVVector::BI__builtin_rvv_vwcvt_x_x_v_tu:
19014
  ID = Intrinsic::riscv_vwadd;
19015
  PolicyAttrs = 2;
19016
IsMasked = false;
19017
 
19018
      {
19019
        if (IsMasked) {
19020
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19021
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
19022
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19023
        } else {
19024
          if (PolicyAttrs & RVV_VTA)
19025
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19026
        }
19027
        auto ElemTy = cast<llvm::VectorType>(ResultType)->getElementType();
19028
        Ops.insert(Ops.begin() + 2, llvm::Constant::getNullValue(ElemTy));
19029
        if (IsMasked) {
19030
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19031
          // maskedoff, op1, op2, mask, vl, policy
19032
          IntrinsicTypes = {ResultType,
19033
                            Ops[1]->getType(),
19034
                            ElemTy,
19035
                            Ops[4]->getType()};
19036
        } else {
19037
          // passtru, op1, op2, vl
19038
          IntrinsicTypes = {ResultType,
19039
                            Ops[1]->getType(),
19040
                            ElemTy,
19041
                            Ops[3]->getType()};
19042
        }
19043
        break;
19044
      }
19045
      break;
19046
case RISCVVector::BI__builtin_rvv_vwadd_vv_ta:
19047
case RISCVVector::BI__builtin_rvv_vwadd_vx_ta:
19048
  ID = Intrinsic::riscv_vwadd;
19049
  PolicyAttrs = 3;
19050
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19051
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19052
  break;
19053
case RISCVVector::BI__builtin_rvv_vwcvt_x_x_v_ta:
19054
  ID = Intrinsic::riscv_vwadd;
19055
  PolicyAttrs = 3;
19056
IsMasked = false;
19057
 
19058
      {
19059
        if (IsMasked) {
19060
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19061
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
19062
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19063
        } else {
19064
          if (PolicyAttrs & RVV_VTA)
19065
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19066
        }
19067
        auto ElemTy = cast<llvm::VectorType>(ResultType)->getElementType();
19068
        Ops.insert(Ops.begin() + 2, llvm::Constant::getNullValue(ElemTy));
19069
        if (IsMasked) {
19070
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19071
          // maskedoff, op1, op2, mask, vl, policy
19072
          IntrinsicTypes = {ResultType,
19073
                            Ops[1]->getType(),
19074
                            ElemTy,
19075
                            Ops[4]->getType()};
19076
        } else {
19077
          // passtru, op1, op2, vl
19078
          IntrinsicTypes = {ResultType,
19079
                            Ops[1]->getType(),
19080
                            ElemTy,
19081
                            Ops[3]->getType()};
19082
        }
19083
        break;
19084
      }
19085
      break;
19086
case RISCVVector::BI__builtin_rvv_vwadd_vv_tum:
19087
case RISCVVector::BI__builtin_rvv_vwadd_vx_tum:
19088
  ID = Intrinsic::riscv_vwadd_mask;
19089
  PolicyAttrs = 2;
19090
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19091
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19092
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19093
  break;
19094
case RISCVVector::BI__builtin_rvv_vwcvt_x_x_v_tum:
19095
  ID = Intrinsic::riscv_vwadd_mask;
19096
  PolicyAttrs = 2;
19097
IsMasked = true;
19098
 
19099
      {
19100
        if (IsMasked) {
19101
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19102
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
19103
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19104
        } else {
19105
          if (PolicyAttrs & RVV_VTA)
19106
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19107
        }
19108
        auto ElemTy = cast<llvm::VectorType>(ResultType)->getElementType();
19109
        Ops.insert(Ops.begin() + 2, llvm::Constant::getNullValue(ElemTy));
19110
        if (IsMasked) {
19111
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19112
          // maskedoff, op1, op2, mask, vl, policy
19113
          IntrinsicTypes = {ResultType,
19114
                            Ops[1]->getType(),
19115
                            ElemTy,
19116
                            Ops[4]->getType()};
19117
        } else {
19118
          // passtru, op1, op2, vl
19119
          IntrinsicTypes = {ResultType,
19120
                            Ops[1]->getType(),
19121
                            ElemTy,
19122
                            Ops[3]->getType()};
19123
        }
19124
        break;
19125
      }
19126
      break;
19127
case RISCVVector::BI__builtin_rvv_vwadd_vv_tama:
19128
case RISCVVector::BI__builtin_rvv_vwadd_vx_tama:
19129
  ID = Intrinsic::riscv_vwadd_mask;
19130
  PolicyAttrs = 3;
19131
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19132
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19133
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19134
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19135
  break;
19136
case RISCVVector::BI__builtin_rvv_vwcvt_x_x_v_tama:
19137
  ID = Intrinsic::riscv_vwadd_mask;
19138
  PolicyAttrs = 3;
19139
IsMasked = true;
19140
 
19141
      {
19142
        if (IsMasked) {
19143
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19144
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
19145
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19146
        } else {
19147
          if (PolicyAttrs & RVV_VTA)
19148
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19149
        }
19150
        auto ElemTy = cast<llvm::VectorType>(ResultType)->getElementType();
19151
        Ops.insert(Ops.begin() + 2, llvm::Constant::getNullValue(ElemTy));
19152
        if (IsMasked) {
19153
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19154
          // maskedoff, op1, op2, mask, vl, policy
19155
          IntrinsicTypes = {ResultType,
19156
                            Ops[1]->getType(),
19157
                            ElemTy,
19158
                            Ops[4]->getType()};
19159
        } else {
19160
          // passtru, op1, op2, vl
19161
          IntrinsicTypes = {ResultType,
19162
                            Ops[1]->getType(),
19163
                            ElemTy,
19164
                            Ops[3]->getType()};
19165
        }
19166
        break;
19167
      }
19168
      break;
19169
case RISCVVector::BI__builtin_rvv_vwadd_vv_tumu:
19170
case RISCVVector::BI__builtin_rvv_vwadd_vx_tumu:
19171
  ID = Intrinsic::riscv_vwadd_mask;
19172
  PolicyAttrs = 0;
19173
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19174
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19175
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19176
  break;
19177
case RISCVVector::BI__builtin_rvv_vwcvt_x_x_v_tumu:
19178
  ID = Intrinsic::riscv_vwadd_mask;
19179
  PolicyAttrs = 0;
19180
IsMasked = true;
19181
 
19182
      {
19183
        if (IsMasked) {
19184
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19185
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
19186
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19187
        } else {
19188
          if (PolicyAttrs & RVV_VTA)
19189
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19190
        }
19191
        auto ElemTy = cast<llvm::VectorType>(ResultType)->getElementType();
19192
        Ops.insert(Ops.begin() + 2, llvm::Constant::getNullValue(ElemTy));
19193
        if (IsMasked) {
19194
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19195
          // maskedoff, op1, op2, mask, vl, policy
19196
          IntrinsicTypes = {ResultType,
19197
                            Ops[1]->getType(),
19198
                            ElemTy,
19199
                            Ops[4]->getType()};
19200
        } else {
19201
          // passtru, op1, op2, vl
19202
          IntrinsicTypes = {ResultType,
19203
                            Ops[1]->getType(),
19204
                            ElemTy,
19205
                            Ops[3]->getType()};
19206
        }
19207
        break;
19208
      }
19209
      break;
19210
case RISCVVector::BI__builtin_rvv_vwadd_vv_mu:
19211
case RISCVVector::BI__builtin_rvv_vwadd_vx_mu:
19212
  ID = Intrinsic::riscv_vwadd_mask;
19213
  PolicyAttrs = 1;
19214
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19215
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19216
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19217
  break;
19218
case RISCVVector::BI__builtin_rvv_vwcvt_x_x_v_mu:
19219
  ID = Intrinsic::riscv_vwadd_mask;
19220
  PolicyAttrs = 1;
19221
IsMasked = true;
19222
 
19223
      {
19224
        if (IsMasked) {
19225
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19226
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
19227
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19228
        } else {
19229
          if (PolicyAttrs & RVV_VTA)
19230
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19231
        }
19232
        auto ElemTy = cast<llvm::VectorType>(ResultType)->getElementType();
19233
        Ops.insert(Ops.begin() + 2, llvm::Constant::getNullValue(ElemTy));
19234
        if (IsMasked) {
19235
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19236
          // maskedoff, op1, op2, mask, vl, policy
19237
          IntrinsicTypes = {ResultType,
19238
                            Ops[1]->getType(),
19239
                            ElemTy,
19240
                            Ops[4]->getType()};
19241
        } else {
19242
          // passtru, op1, op2, vl
19243
          IntrinsicTypes = {ResultType,
19244
                            Ops[1]->getType(),
19245
                            ElemTy,
19246
                            Ops[3]->getType()};
19247
        }
19248
        break;
19249
      }
19250
      break;
19251
case RISCVVector::BI__builtin_rvv_vwadd_wv_tu:
19252
case RISCVVector::BI__builtin_rvv_vwadd_wx_tu:
19253
  ID = Intrinsic::riscv_vwadd_w;
19254
  PolicyAttrs = 2;
19255
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
19256
  break;
19257
case RISCVVector::BI__builtin_rvv_vwadd_wv_ta:
19258
case RISCVVector::BI__builtin_rvv_vwadd_wx_ta:
19259
  ID = Intrinsic::riscv_vwadd_w;
19260
  PolicyAttrs = 3;
19261
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19262
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
19263
  break;
19264
case RISCVVector::BI__builtin_rvv_vwadd_wv_tum:
19265
case RISCVVector::BI__builtin_rvv_vwadd_wx_tum:
19266
  ID = Intrinsic::riscv_vwadd_w_mask;
19267
  PolicyAttrs = 2;
19268
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19269
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19270
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
19271
  break;
19272
case RISCVVector::BI__builtin_rvv_vwadd_wv_tama:
19273
case RISCVVector::BI__builtin_rvv_vwadd_wx_tama:
19274
  ID = Intrinsic::riscv_vwadd_w_mask;
19275
  PolicyAttrs = 3;
19276
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19277
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19278
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19279
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
19280
  break;
19281
case RISCVVector::BI__builtin_rvv_vwadd_wv_tumu:
19282
case RISCVVector::BI__builtin_rvv_vwadd_wx_tumu:
19283
  ID = Intrinsic::riscv_vwadd_w_mask;
19284
  PolicyAttrs = 0;
19285
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19286
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19287
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
19288
  break;
19289
case RISCVVector::BI__builtin_rvv_vwadd_wv_mu:
19290
case RISCVVector::BI__builtin_rvv_vwadd_wx_mu:
19291
  ID = Intrinsic::riscv_vwadd_w_mask;
19292
  PolicyAttrs = 1;
19293
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19294
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19295
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
19296
  break;
19297
case RISCVVector::BI__builtin_rvv_vwaddu_vv_tu:
19298
case RISCVVector::BI__builtin_rvv_vwaddu_vx_tu:
19299
  ID = Intrinsic::riscv_vwaddu;
19300
  PolicyAttrs = 2;
19301
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19302
  break;
19303
case RISCVVector::BI__builtin_rvv_vwcvtu_x_x_v_tu:
19304
  ID = Intrinsic::riscv_vwaddu;
19305
  PolicyAttrs = 2;
19306
IsMasked = false;
19307
 
19308
      {
19309
        if (IsMasked) {
19310
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19311
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
19312
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19313
        } else {
19314
          if (PolicyAttrs & RVV_VTA)
19315
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19316
        }
19317
        auto ElemTy = cast<llvm::VectorType>(ResultType)->getElementType();
19318
        Ops.insert(Ops.begin() + 2, llvm::Constant::getNullValue(ElemTy));
19319
        if (IsMasked) {
19320
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19321
          // maskedoff, op1, op2, mask, vl, policy
19322
          IntrinsicTypes = {ResultType,
19323
                            Ops[1]->getType(),
19324
                            ElemTy,
19325
                            Ops[4]->getType()};
19326
        } else {
19327
          // passtru, op1, op2, vl
19328
          IntrinsicTypes = {ResultType,
19329
                            Ops[1]->getType(),
19330
                            ElemTy,
19331
                            Ops[3]->getType()};
19332
        }
19333
        break;
19334
      }
19335
      break;
19336
case RISCVVector::BI__builtin_rvv_vwaddu_vv_ta:
19337
case RISCVVector::BI__builtin_rvv_vwaddu_vx_ta:
19338
  ID = Intrinsic::riscv_vwaddu;
19339
  PolicyAttrs = 3;
19340
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19341
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19342
  break;
19343
case RISCVVector::BI__builtin_rvv_vwcvtu_x_x_v_ta:
19344
  ID = Intrinsic::riscv_vwaddu;
19345
  PolicyAttrs = 3;
19346
IsMasked = false;
19347
 
19348
      {
19349
        if (IsMasked) {
19350
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19351
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
19352
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19353
        } else {
19354
          if (PolicyAttrs & RVV_VTA)
19355
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19356
        }
19357
        auto ElemTy = cast<llvm::VectorType>(ResultType)->getElementType();
19358
        Ops.insert(Ops.begin() + 2, llvm::Constant::getNullValue(ElemTy));
19359
        if (IsMasked) {
19360
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19361
          // maskedoff, op1, op2, mask, vl, policy
19362
          IntrinsicTypes = {ResultType,
19363
                            Ops[1]->getType(),
19364
                            ElemTy,
19365
                            Ops[4]->getType()};
19366
        } else {
19367
          // passtru, op1, op2, vl
19368
          IntrinsicTypes = {ResultType,
19369
                            Ops[1]->getType(),
19370
                            ElemTy,
19371
                            Ops[3]->getType()};
19372
        }
19373
        break;
19374
      }
19375
      break;
19376
case RISCVVector::BI__builtin_rvv_vwaddu_vv_tum:
19377
case RISCVVector::BI__builtin_rvv_vwaddu_vx_tum:
19378
  ID = Intrinsic::riscv_vwaddu_mask;
19379
  PolicyAttrs = 2;
19380
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19381
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19382
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19383
  break;
19384
case RISCVVector::BI__builtin_rvv_vwcvtu_x_x_v_tum:
19385
  ID = Intrinsic::riscv_vwaddu_mask;
19386
  PolicyAttrs = 2;
19387
IsMasked = true;
19388
 
19389
      {
19390
        if (IsMasked) {
19391
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19392
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
19393
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19394
        } else {
19395
          if (PolicyAttrs & RVV_VTA)
19396
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19397
        }
19398
        auto ElemTy = cast<llvm::VectorType>(ResultType)->getElementType();
19399
        Ops.insert(Ops.begin() + 2, llvm::Constant::getNullValue(ElemTy));
19400
        if (IsMasked) {
19401
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19402
          // maskedoff, op1, op2, mask, vl, policy
19403
          IntrinsicTypes = {ResultType,
19404
                            Ops[1]->getType(),
19405
                            ElemTy,
19406
                            Ops[4]->getType()};
19407
        } else {
19408
          // passtru, op1, op2, vl
19409
          IntrinsicTypes = {ResultType,
19410
                            Ops[1]->getType(),
19411
                            ElemTy,
19412
                            Ops[3]->getType()};
19413
        }
19414
        break;
19415
      }
19416
      break;
19417
case RISCVVector::BI__builtin_rvv_vwaddu_vv_tama:
19418
case RISCVVector::BI__builtin_rvv_vwaddu_vx_tama:
19419
  ID = Intrinsic::riscv_vwaddu_mask;
19420
  PolicyAttrs = 3;
19421
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19422
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19423
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19424
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19425
  break;
19426
case RISCVVector::BI__builtin_rvv_vwcvtu_x_x_v_tama:
19427
  ID = Intrinsic::riscv_vwaddu_mask;
19428
  PolicyAttrs = 3;
19429
IsMasked = true;
19430
 
19431
      {
19432
        if (IsMasked) {
19433
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19434
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
19435
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19436
        } else {
19437
          if (PolicyAttrs & RVV_VTA)
19438
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19439
        }
19440
        auto ElemTy = cast<llvm::VectorType>(ResultType)->getElementType();
19441
        Ops.insert(Ops.begin() + 2, llvm::Constant::getNullValue(ElemTy));
19442
        if (IsMasked) {
19443
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19444
          // maskedoff, op1, op2, mask, vl, policy
19445
          IntrinsicTypes = {ResultType,
19446
                            Ops[1]->getType(),
19447
                            ElemTy,
19448
                            Ops[4]->getType()};
19449
        } else {
19450
          // passtru, op1, op2, vl
19451
          IntrinsicTypes = {ResultType,
19452
                            Ops[1]->getType(),
19453
                            ElemTy,
19454
                            Ops[3]->getType()};
19455
        }
19456
        break;
19457
      }
19458
      break;
19459
case RISCVVector::BI__builtin_rvv_vwaddu_vv_tumu:
19460
case RISCVVector::BI__builtin_rvv_vwaddu_vx_tumu:
19461
  ID = Intrinsic::riscv_vwaddu_mask;
19462
  PolicyAttrs = 0;
19463
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19464
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19465
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19466
  break;
19467
case RISCVVector::BI__builtin_rvv_vwcvtu_x_x_v_tumu:
19468
  ID = Intrinsic::riscv_vwaddu_mask;
19469
  PolicyAttrs = 0;
19470
IsMasked = true;
19471
 
19472
      {
19473
        if (IsMasked) {
19474
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19475
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
19476
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19477
        } else {
19478
          if (PolicyAttrs & RVV_VTA)
19479
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19480
        }
19481
        auto ElemTy = cast<llvm::VectorType>(ResultType)->getElementType();
19482
        Ops.insert(Ops.begin() + 2, llvm::Constant::getNullValue(ElemTy));
19483
        if (IsMasked) {
19484
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19485
          // maskedoff, op1, op2, mask, vl, policy
19486
          IntrinsicTypes = {ResultType,
19487
                            Ops[1]->getType(),
19488
                            ElemTy,
19489
                            Ops[4]->getType()};
19490
        } else {
19491
          // passtru, op1, op2, vl
19492
          IntrinsicTypes = {ResultType,
19493
                            Ops[1]->getType(),
19494
                            ElemTy,
19495
                            Ops[3]->getType()};
19496
        }
19497
        break;
19498
      }
19499
      break;
19500
case RISCVVector::BI__builtin_rvv_vwaddu_vv_mu:
19501
case RISCVVector::BI__builtin_rvv_vwaddu_vx_mu:
19502
  ID = Intrinsic::riscv_vwaddu_mask;
19503
  PolicyAttrs = 1;
19504
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19505
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19506
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19507
  break;
19508
case RISCVVector::BI__builtin_rvv_vwcvtu_x_x_v_mu:
19509
  ID = Intrinsic::riscv_vwaddu_mask;
19510
  PolicyAttrs = 1;
19511
IsMasked = true;
19512
 
19513
      {
19514
        if (IsMasked) {
19515
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19516
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
19517
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19518
        } else {
19519
          if (PolicyAttrs & RVV_VTA)
19520
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19521
        }
19522
        auto ElemTy = cast<llvm::VectorType>(ResultType)->getElementType();
19523
        Ops.insert(Ops.begin() + 2, llvm::Constant::getNullValue(ElemTy));
19524
        if (IsMasked) {
19525
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19526
          // maskedoff, op1, op2, mask, vl, policy
19527
          IntrinsicTypes = {ResultType,
19528
                            Ops[1]->getType(),
19529
                            ElemTy,
19530
                            Ops[4]->getType()};
19531
        } else {
19532
          // passtru, op1, op2, vl
19533
          IntrinsicTypes = {ResultType,
19534
                            Ops[1]->getType(),
19535
                            ElemTy,
19536
                            Ops[3]->getType()};
19537
        }
19538
        break;
19539
      }
19540
      break;
19541
case RISCVVector::BI__builtin_rvv_vwaddu_wx_tu:
19542
case RISCVVector::BI__builtin_rvv_vwaddu_wv_tu:
19543
  ID = Intrinsic::riscv_vwaddu_w;
19544
  PolicyAttrs = 2;
19545
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
19546
  break;
19547
case RISCVVector::BI__builtin_rvv_vwaddu_wx_ta:
19548
case RISCVVector::BI__builtin_rvv_vwaddu_wv_ta:
19549
  ID = Intrinsic::riscv_vwaddu_w;
19550
  PolicyAttrs = 3;
19551
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19552
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
19553
  break;
19554
case RISCVVector::BI__builtin_rvv_vwaddu_wx_tum:
19555
case RISCVVector::BI__builtin_rvv_vwaddu_wv_tum:
19556
  ID = Intrinsic::riscv_vwaddu_w_mask;
19557
  PolicyAttrs = 2;
19558
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19559
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19560
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
19561
  break;
19562
case RISCVVector::BI__builtin_rvv_vwaddu_wx_tama:
19563
case RISCVVector::BI__builtin_rvv_vwaddu_wv_tama:
19564
  ID = Intrinsic::riscv_vwaddu_w_mask;
19565
  PolicyAttrs = 3;
19566
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19567
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19568
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19569
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
19570
  break;
19571
case RISCVVector::BI__builtin_rvv_vwaddu_wx_tumu:
19572
case RISCVVector::BI__builtin_rvv_vwaddu_wv_tumu:
19573
  ID = Intrinsic::riscv_vwaddu_w_mask;
19574
  PolicyAttrs = 0;
19575
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19576
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19577
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
19578
  break;
19579
case RISCVVector::BI__builtin_rvv_vwaddu_wx_mu:
19580
case RISCVVector::BI__builtin_rvv_vwaddu_wv_mu:
19581
  ID = Intrinsic::riscv_vwaddu_w_mask;
19582
  PolicyAttrs = 1;
19583
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19584
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19585
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
19586
  break;
19587
case RISCVVector::BI__builtin_rvv_vwmacc_vv_tu:
19588
case RISCVVector::BI__builtin_rvv_vwmacc_vx_tu:
19589
  ID = Intrinsic::riscv_vwmacc;
19590
  PolicyAttrs = 2;
19591
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19592
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19593
  break;
19594
case RISCVVector::BI__builtin_rvv_vwmacc_vv_ta:
19595
case RISCVVector::BI__builtin_rvv_vwmacc_vx_ta:
19596
  ID = Intrinsic::riscv_vwmacc;
19597
  PolicyAttrs = 3;
19598
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19599
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19600
  break;
19601
case RISCVVector::BI__builtin_rvv_vwmacc_vv_tum:
19602
case RISCVVector::BI__builtin_rvv_vwmacc_vx_tum:
19603
  ID = Intrinsic::riscv_vwmacc_mask;
19604
  PolicyAttrs = 2;
19605
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19606
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19607
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19608
  break;
19609
case RISCVVector::BI__builtin_rvv_vwmacc_vv_tama:
19610
case RISCVVector::BI__builtin_rvv_vwmacc_vx_tama:
19611
  ID = Intrinsic::riscv_vwmacc_mask;
19612
  PolicyAttrs = 3;
19613
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19614
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19615
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19616
  break;
19617
case RISCVVector::BI__builtin_rvv_vwmacc_vv_tumu:
19618
case RISCVVector::BI__builtin_rvv_vwmacc_vx_tumu:
19619
  ID = Intrinsic::riscv_vwmacc_mask;
19620
  PolicyAttrs = 0;
19621
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19622
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19623
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19624
  break;
19625
case RISCVVector::BI__builtin_rvv_vwmacc_vv_mu:
19626
case RISCVVector::BI__builtin_rvv_vwmacc_vx_mu:
19627
  ID = Intrinsic::riscv_vwmacc_mask;
19628
  PolicyAttrs = 1;
19629
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19630
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19631
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19632
  break;
19633
case RISCVVector::BI__builtin_rvv_vwmaccsu_vv_tu:
19634
case RISCVVector::BI__builtin_rvv_vwmaccsu_vx_tu:
19635
  ID = Intrinsic::riscv_vwmaccsu;
19636
  PolicyAttrs = 2;
19637
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19638
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19639
  break;
19640
case RISCVVector::BI__builtin_rvv_vwmaccsu_vv_ta:
19641
case RISCVVector::BI__builtin_rvv_vwmaccsu_vx_ta:
19642
  ID = Intrinsic::riscv_vwmaccsu;
19643
  PolicyAttrs = 3;
19644
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19645
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19646
  break;
19647
case RISCVVector::BI__builtin_rvv_vwmaccsu_vv_tum:
19648
case RISCVVector::BI__builtin_rvv_vwmaccsu_vx_tum:
19649
  ID = Intrinsic::riscv_vwmaccsu_mask;
19650
  PolicyAttrs = 2;
19651
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19652
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19653
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19654
  break;
19655
case RISCVVector::BI__builtin_rvv_vwmaccsu_vv_tama:
19656
case RISCVVector::BI__builtin_rvv_vwmaccsu_vx_tama:
19657
  ID = Intrinsic::riscv_vwmaccsu_mask;
19658
  PolicyAttrs = 3;
19659
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19660
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19661
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19662
  break;
19663
case RISCVVector::BI__builtin_rvv_vwmaccsu_vv_tumu:
19664
case RISCVVector::BI__builtin_rvv_vwmaccsu_vx_tumu:
19665
  ID = Intrinsic::riscv_vwmaccsu_mask;
19666
  PolicyAttrs = 0;
19667
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19668
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19669
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19670
  break;
19671
case RISCVVector::BI__builtin_rvv_vwmaccsu_vv_mu:
19672
case RISCVVector::BI__builtin_rvv_vwmaccsu_vx_mu:
19673
  ID = Intrinsic::riscv_vwmaccsu_mask;
19674
  PolicyAttrs = 1;
19675
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19676
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19677
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19678
  break;
19679
case RISCVVector::BI__builtin_rvv_vwmaccu_vv_tu:
19680
case RISCVVector::BI__builtin_rvv_vwmaccu_vx_tu:
19681
  ID = Intrinsic::riscv_vwmaccu;
19682
  PolicyAttrs = 2;
19683
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19684
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19685
  break;
19686
case RISCVVector::BI__builtin_rvv_vwmaccu_vv_ta:
19687
case RISCVVector::BI__builtin_rvv_vwmaccu_vx_ta:
19688
  ID = Intrinsic::riscv_vwmaccu;
19689
  PolicyAttrs = 3;
19690
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19691
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19692
  break;
19693
case RISCVVector::BI__builtin_rvv_vwmaccu_vv_tum:
19694
case RISCVVector::BI__builtin_rvv_vwmaccu_vx_tum:
19695
  ID = Intrinsic::riscv_vwmaccu_mask;
19696
  PolicyAttrs = 2;
19697
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19698
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19699
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19700
  break;
19701
case RISCVVector::BI__builtin_rvv_vwmaccu_vv_tama:
19702
case RISCVVector::BI__builtin_rvv_vwmaccu_vx_tama:
19703
  ID = Intrinsic::riscv_vwmaccu_mask;
19704
  PolicyAttrs = 3;
19705
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19706
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19707
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19708
  break;
19709
case RISCVVector::BI__builtin_rvv_vwmaccu_vv_tumu:
19710
case RISCVVector::BI__builtin_rvv_vwmaccu_vx_tumu:
19711
  ID = Intrinsic::riscv_vwmaccu_mask;
19712
  PolicyAttrs = 0;
19713
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19714
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19715
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19716
  break;
19717
case RISCVVector::BI__builtin_rvv_vwmaccu_vv_mu:
19718
case RISCVVector::BI__builtin_rvv_vwmaccu_vx_mu:
19719
  ID = Intrinsic::riscv_vwmaccu_mask;
19720
  PolicyAttrs = 1;
19721
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19722
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19723
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19724
  break;
19725
case RISCVVector::BI__builtin_rvv_vwmaccus_vx_tu:
19726
  ID = Intrinsic::riscv_vwmaccus;
19727
  PolicyAttrs = 2;
19728
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19729
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19730
  break;
19731
case RISCVVector::BI__builtin_rvv_vwmaccus_vx_ta:
19732
  ID = Intrinsic::riscv_vwmaccus;
19733
  PolicyAttrs = 3;
19734
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19735
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19736
  break;
19737
case RISCVVector::BI__builtin_rvv_vwmaccus_vx_tum:
19738
  ID = Intrinsic::riscv_vwmaccus_mask;
19739
  PolicyAttrs = 2;
19740
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19741
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19742
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19743
  break;
19744
case RISCVVector::BI__builtin_rvv_vwmaccus_vx_tama:
19745
  ID = Intrinsic::riscv_vwmaccus_mask;
19746
  PolicyAttrs = 3;
19747
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19748
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19749
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19750
  break;
19751
case RISCVVector::BI__builtin_rvv_vwmaccus_vx_tumu:
19752
  ID = Intrinsic::riscv_vwmaccus_mask;
19753
  PolicyAttrs = 0;
19754
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19755
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19756
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19757
  break;
19758
case RISCVVector::BI__builtin_rvv_vwmaccus_vx_mu:
19759
  ID = Intrinsic::riscv_vwmaccus_mask;
19760
  PolicyAttrs = 1;
19761
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19762
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19763
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19764
  break;
19765
case RISCVVector::BI__builtin_rvv_vwmul_vv_tu:
19766
case RISCVVector::BI__builtin_rvv_vwmul_vx_tu:
19767
  ID = Intrinsic::riscv_vwmul;
19768
  PolicyAttrs = 2;
19769
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19770
  break;
19771
case RISCVVector::BI__builtin_rvv_vwmul_vv_ta:
19772
case RISCVVector::BI__builtin_rvv_vwmul_vx_ta:
19773
  ID = Intrinsic::riscv_vwmul;
19774
  PolicyAttrs = 3;
19775
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19776
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19777
  break;
19778
case RISCVVector::BI__builtin_rvv_vwmul_vv_tum:
19779
case RISCVVector::BI__builtin_rvv_vwmul_vx_tum:
19780
  ID = Intrinsic::riscv_vwmul_mask;
19781
  PolicyAttrs = 2;
19782
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19783
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19784
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19785
  break;
19786
case RISCVVector::BI__builtin_rvv_vwmul_vv_tama:
19787
case RISCVVector::BI__builtin_rvv_vwmul_vx_tama:
19788
  ID = Intrinsic::riscv_vwmul_mask;
19789
  PolicyAttrs = 3;
19790
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19791
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19792
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19793
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19794
  break;
19795
case RISCVVector::BI__builtin_rvv_vwmul_vv_tumu:
19796
case RISCVVector::BI__builtin_rvv_vwmul_vx_tumu:
19797
  ID = Intrinsic::riscv_vwmul_mask;
19798
  PolicyAttrs = 0;
19799
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19800
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19801
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19802
  break;
19803
case RISCVVector::BI__builtin_rvv_vwmul_vv_mu:
19804
case RISCVVector::BI__builtin_rvv_vwmul_vx_mu:
19805
  ID = Intrinsic::riscv_vwmul_mask;
19806
  PolicyAttrs = 1;
19807
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19808
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19809
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19810
  break;
19811
case RISCVVector::BI__builtin_rvv_vwmulsu_vv_tu:
19812
case RISCVVector::BI__builtin_rvv_vwmulsu_vx_tu:
19813
  ID = Intrinsic::riscv_vwmulsu;
19814
  PolicyAttrs = 2;
19815
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19816
  break;
19817
case RISCVVector::BI__builtin_rvv_vwmulsu_vv_ta:
19818
case RISCVVector::BI__builtin_rvv_vwmulsu_vx_ta:
19819
  ID = Intrinsic::riscv_vwmulsu;
19820
  PolicyAttrs = 3;
19821
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19822
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19823
  break;
19824
case RISCVVector::BI__builtin_rvv_vwmulsu_vv_tum:
19825
case RISCVVector::BI__builtin_rvv_vwmulsu_vx_tum:
19826
  ID = Intrinsic::riscv_vwmulsu_mask;
19827
  PolicyAttrs = 2;
19828
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19829
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19830
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19831
  break;
19832
case RISCVVector::BI__builtin_rvv_vwmulsu_vv_tama:
19833
case RISCVVector::BI__builtin_rvv_vwmulsu_vx_tama:
19834
  ID = Intrinsic::riscv_vwmulsu_mask;
19835
  PolicyAttrs = 3;
19836
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19837
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19838
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19839
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19840
  break;
19841
case RISCVVector::BI__builtin_rvv_vwmulsu_vv_tumu:
19842
case RISCVVector::BI__builtin_rvv_vwmulsu_vx_tumu:
19843
  ID = Intrinsic::riscv_vwmulsu_mask;
19844
  PolicyAttrs = 0;
19845
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19846
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19847
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19848
  break;
19849
case RISCVVector::BI__builtin_rvv_vwmulsu_vv_mu:
19850
case RISCVVector::BI__builtin_rvv_vwmulsu_vx_mu:
19851
  ID = Intrinsic::riscv_vwmulsu_mask;
19852
  PolicyAttrs = 1;
19853
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19854
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19855
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19856
  break;
19857
case RISCVVector::BI__builtin_rvv_vwmulu_vv_tu:
19858
case RISCVVector::BI__builtin_rvv_vwmulu_vx_tu:
19859
  ID = Intrinsic::riscv_vwmulu;
19860
  PolicyAttrs = 2;
19861
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19862
  break;
19863
case RISCVVector::BI__builtin_rvv_vwmulu_vv_ta:
19864
case RISCVVector::BI__builtin_rvv_vwmulu_vx_ta:
19865
  ID = Intrinsic::riscv_vwmulu;
19866
  PolicyAttrs = 3;
19867
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19868
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19869
  break;
19870
case RISCVVector::BI__builtin_rvv_vwmulu_vv_tum:
19871
case RISCVVector::BI__builtin_rvv_vwmulu_vx_tum:
19872
  ID = Intrinsic::riscv_vwmulu_mask;
19873
  PolicyAttrs = 2;
19874
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19875
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19876
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19877
  break;
19878
case RISCVVector::BI__builtin_rvv_vwmulu_vv_tama:
19879
case RISCVVector::BI__builtin_rvv_vwmulu_vx_tama:
19880
  ID = Intrinsic::riscv_vwmulu_mask;
19881
  PolicyAttrs = 3;
19882
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19883
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19884
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19885
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19886
  break;
19887
case RISCVVector::BI__builtin_rvv_vwmulu_vv_tumu:
19888
case RISCVVector::BI__builtin_rvv_vwmulu_vx_tumu:
19889
  ID = Intrinsic::riscv_vwmulu_mask;
19890
  PolicyAttrs = 0;
19891
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19892
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19893
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19894
  break;
19895
case RISCVVector::BI__builtin_rvv_vwmulu_vv_mu:
19896
case RISCVVector::BI__builtin_rvv_vwmulu_vx_mu:
19897
  ID = Intrinsic::riscv_vwmulu_mask;
19898
  PolicyAttrs = 1;
19899
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19900
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19901
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19902
  break;
19903
case RISCVVector::BI__builtin_rvv_vwredsum_vs_tu:
19904
  ID = Intrinsic::riscv_vwredsum;
19905
  PolicyAttrs = 2;
19906
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
19907
  break;
19908
case RISCVVector::BI__builtin_rvv_vwredsum_vs_ta:
19909
  ID = Intrinsic::riscv_vwredsum;
19910
  PolicyAttrs = 3;
19911
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19912
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
19913
  break;
19914
case RISCVVector::BI__builtin_rvv_vwredsum_vs_tum:
19915
  ID = Intrinsic::riscv_vwredsum_mask;
19916
  PolicyAttrs = 2;
19917
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19918
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
19919
  break;
19920
case RISCVVector::BI__builtin_rvv_vwredsum_vs_tama:
19921
  ID = Intrinsic::riscv_vwredsum_mask;
19922
  PolicyAttrs = 3;
19923
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19924
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19925
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
19926
  break;
19927
case RISCVVector::BI__builtin_rvv_vwredsumu_vs_tu:
19928
  ID = Intrinsic::riscv_vwredsumu;
19929
  PolicyAttrs = 2;
19930
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
19931
  break;
19932
case RISCVVector::BI__builtin_rvv_vwredsumu_vs_ta:
19933
  ID = Intrinsic::riscv_vwredsumu;
19934
  PolicyAttrs = 3;
19935
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19936
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
19937
  break;
19938
case RISCVVector::BI__builtin_rvv_vwredsumu_vs_tum:
19939
  ID = Intrinsic::riscv_vwredsumu_mask;
19940
  PolicyAttrs = 2;
19941
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19942
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
19943
  break;
19944
case RISCVVector::BI__builtin_rvv_vwredsumu_vs_tama:
19945
  ID = Intrinsic::riscv_vwredsumu_mask;
19946
  PolicyAttrs = 3;
19947
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19948
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19949
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
19950
  break;
19951
case RISCVVector::BI__builtin_rvv_vwsub_vv_tu:
19952
case RISCVVector::BI__builtin_rvv_vwsub_vx_tu:
19953
  ID = Intrinsic::riscv_vwsub;
19954
  PolicyAttrs = 2;
19955
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19956
  break;
19957
case RISCVVector::BI__builtin_rvv_vwsub_vv_ta:
19958
case RISCVVector::BI__builtin_rvv_vwsub_vx_ta:
19959
  ID = Intrinsic::riscv_vwsub;
19960
  PolicyAttrs = 3;
19961
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19962
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19963
  break;
19964
case RISCVVector::BI__builtin_rvv_vwsub_vv_tum:
19965
case RISCVVector::BI__builtin_rvv_vwsub_vx_tum:
19966
  ID = Intrinsic::riscv_vwsub_mask;
19967
  PolicyAttrs = 2;
19968
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19969
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19970
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19971
  break;
19972
case RISCVVector::BI__builtin_rvv_vwsub_vv_tama:
19973
case RISCVVector::BI__builtin_rvv_vwsub_vx_tama:
19974
  ID = Intrinsic::riscv_vwsub_mask;
19975
  PolicyAttrs = 3;
19976
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19977
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19978
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
19979
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19980
  break;
19981
case RISCVVector::BI__builtin_rvv_vwsub_vv_tumu:
19982
case RISCVVector::BI__builtin_rvv_vwsub_vx_tumu:
19983
  ID = Intrinsic::riscv_vwsub_mask;
19984
  PolicyAttrs = 0;
19985
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19986
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19987
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19988
  break;
19989
case RISCVVector::BI__builtin_rvv_vwsub_vv_mu:
19990
case RISCVVector::BI__builtin_rvv_vwsub_vx_mu:
19991
  ID = Intrinsic::riscv_vwsub_mask;
19992
  PolicyAttrs = 1;
19993
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
19994
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
19995
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
19996
  break;
19997
case RISCVVector::BI__builtin_rvv_vwsub_wv_tu:
19998
case RISCVVector::BI__builtin_rvv_vwsub_wx_tu:
19999
  ID = Intrinsic::riscv_vwsub_w;
20000
  PolicyAttrs = 2;
20001
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
20002
  break;
20003
case RISCVVector::BI__builtin_rvv_vwsub_wv_ta:
20004
case RISCVVector::BI__builtin_rvv_vwsub_wx_ta:
20005
  ID = Intrinsic::riscv_vwsub_w;
20006
  PolicyAttrs = 3;
20007
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
20008
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
20009
  break;
20010
case RISCVVector::BI__builtin_rvv_vwsub_wv_tum:
20011
case RISCVVector::BI__builtin_rvv_vwsub_wx_tum:
20012
  ID = Intrinsic::riscv_vwsub_w_mask;
20013
  PolicyAttrs = 2;
20014
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
20015
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
20016
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
20017
  break;
20018
case RISCVVector::BI__builtin_rvv_vwsub_wv_tama:
20019
case RISCVVector::BI__builtin_rvv_vwsub_wx_tama:
20020
  ID = Intrinsic::riscv_vwsub_w_mask;
20021
  PolicyAttrs = 3;
20022
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
20023
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
20024
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
20025
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
20026
  break;
20027
case RISCVVector::BI__builtin_rvv_vwsub_wv_tumu:
20028
case RISCVVector::BI__builtin_rvv_vwsub_wx_tumu:
20029
  ID = Intrinsic::riscv_vwsub_w_mask;
20030
  PolicyAttrs = 0;
20031
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
20032
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
20033
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
20034
  break;
20035
case RISCVVector::BI__builtin_rvv_vwsub_wv_mu:
20036
case RISCVVector::BI__builtin_rvv_vwsub_wx_mu:
20037
  ID = Intrinsic::riscv_vwsub_w_mask;
20038
  PolicyAttrs = 1;
20039
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
20040
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
20041
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
20042
  break;
20043
case RISCVVector::BI__builtin_rvv_vwsubu_vv_tu:
20044
case RISCVVector::BI__builtin_rvv_vwsubu_vx_tu:
20045
  ID = Intrinsic::riscv_vwsubu;
20046
  PolicyAttrs = 2;
20047
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
20048
  break;
20049
case RISCVVector::BI__builtin_rvv_vwsubu_vv_ta:
20050
case RISCVVector::BI__builtin_rvv_vwsubu_vx_ta:
20051
  ID = Intrinsic::riscv_vwsubu;
20052
  PolicyAttrs = 3;
20053
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
20054
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
20055
  break;
20056
case RISCVVector::BI__builtin_rvv_vwsubu_vv_tum:
20057
case RISCVVector::BI__builtin_rvv_vwsubu_vx_tum:
20058
  ID = Intrinsic::riscv_vwsubu_mask;
20059
  PolicyAttrs = 2;
20060
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
20061
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
20062
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
20063
  break;
20064
case RISCVVector::BI__builtin_rvv_vwsubu_vv_tama:
20065
case RISCVVector::BI__builtin_rvv_vwsubu_vx_tama:
20066
  ID = Intrinsic::riscv_vwsubu_mask;
20067
  PolicyAttrs = 3;
20068
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
20069
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
20070
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
20071
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
20072
  break;
20073
case RISCVVector::BI__builtin_rvv_vwsubu_vv_tumu:
20074
case RISCVVector::BI__builtin_rvv_vwsubu_vx_tumu:
20075
  ID = Intrinsic::riscv_vwsubu_mask;
20076
  PolicyAttrs = 0;
20077
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
20078
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
20079
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
20080
  break;
20081
case RISCVVector::BI__builtin_rvv_vwsubu_vv_mu:
20082
case RISCVVector::BI__builtin_rvv_vwsubu_vx_mu:
20083
  ID = Intrinsic::riscv_vwsubu_mask;
20084
  PolicyAttrs = 1;
20085
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
20086
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
20087
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType(), Ops.back()->getType()};
20088
  break;
20089
case RISCVVector::BI__builtin_rvv_vwsubu_wv_tu:
20090
case RISCVVector::BI__builtin_rvv_vwsubu_wx_tu:
20091
  ID = Intrinsic::riscv_vwsubu_w;
20092
  PolicyAttrs = 2;
20093
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
20094
  break;
20095
case RISCVVector::BI__builtin_rvv_vwsubu_wv_ta:
20096
case RISCVVector::BI__builtin_rvv_vwsubu_wx_ta:
20097
  ID = Intrinsic::riscv_vwsubu_w;
20098
  PolicyAttrs = 3;
20099
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
20100
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
20101
  break;
20102
case RISCVVector::BI__builtin_rvv_vwsubu_wv_tum:
20103
case RISCVVector::BI__builtin_rvv_vwsubu_wx_tum:
20104
  ID = Intrinsic::riscv_vwsubu_w_mask;
20105
  PolicyAttrs = 2;
20106
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
20107
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
20108
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
20109
  break;
20110
case RISCVVector::BI__builtin_rvv_vwsubu_wv_tama:
20111
case RISCVVector::BI__builtin_rvv_vwsubu_wx_tama:
20112
  ID = Intrinsic::riscv_vwsubu_w_mask;
20113
  PolicyAttrs = 3;
20114
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
20115
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
20116
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
20117
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
20118
  break;
20119
case RISCVVector::BI__builtin_rvv_vwsubu_wv_tumu:
20120
case RISCVVector::BI__builtin_rvv_vwsubu_wx_tumu:
20121
  ID = Intrinsic::riscv_vwsubu_w_mask;
20122
  PolicyAttrs = 0;
20123
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
20124
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
20125
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
20126
  break;
20127
case RISCVVector::BI__builtin_rvv_vwsubu_wv_mu:
20128
case RISCVVector::BI__builtin_rvv_vwsubu_wx_mu:
20129
  ID = Intrinsic::riscv_vwsubu_w_mask;
20130
  PolicyAttrs = 1;
20131
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
20132
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
20133
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
20134
  break;
20135
case RISCVVector::BI__builtin_rvv_vxor_vv_tu:
20136
case RISCVVector::BI__builtin_rvv_vxor_vx_tu:
20137
  ID = Intrinsic::riscv_vxor;
20138
  PolicyAttrs = 2;
20139
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
20140
  break;
20141
case RISCVVector::BI__builtin_rvv_vnot_v_tu:
20142
  ID = Intrinsic::riscv_vxor;
20143
  PolicyAttrs = 2;
20144
IsMasked = false;
20145
 
20146
      {
20147
        if (IsMasked) {
20148
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
20149
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
20150
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
20151
        } else {
20152
          if (PolicyAttrs & RVV_VTA)
20153
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
20154
        }
20155
        auto ElemTy = cast<llvm::VectorType>(ResultType)->getElementType();
20156
        Ops.insert(Ops.begin() + 2,
20157
                   llvm::Constant::getAllOnesValue(ElemTy));
20158
        if (IsMasked) {
20159
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
20160
          // maskedoff, op1, po2, mask, vl, policy
20161
          IntrinsicTypes = {ResultType,
20162
                            ElemTy,
20163
                            Ops[4]->getType()};
20164
        } else {
20165
          // passthru, op1, op2, vl
20166
          IntrinsicTypes = {ResultType,
20167
                            ElemTy,
20168
                            Ops[3]->getType()};
20169
        }
20170
        break;
20171
      }
20172
      break;
20173
case RISCVVector::BI__builtin_rvv_vxor_vv_ta:
20174
case RISCVVector::BI__builtin_rvv_vxor_vx_ta:
20175
  ID = Intrinsic::riscv_vxor;
20176
  PolicyAttrs = 3;
20177
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
20178
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
20179
  break;
20180
case RISCVVector::BI__builtin_rvv_vnot_v_ta:
20181
  ID = Intrinsic::riscv_vxor;
20182
  PolicyAttrs = 3;
20183
IsMasked = false;
20184
 
20185
      {
20186
        if (IsMasked) {
20187
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
20188
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
20189
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
20190
        } else {
20191
          if (PolicyAttrs & RVV_VTA)
20192
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
20193
        }
20194
        auto ElemTy = cast<llvm::VectorType>(ResultType)->getElementType();
20195
        Ops.insert(Ops.begin() + 2,
20196
                   llvm::Constant::getAllOnesValue(ElemTy));
20197
        if (IsMasked) {
20198
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
20199
          // maskedoff, op1, po2, mask, vl, policy
20200
          IntrinsicTypes = {ResultType,
20201
                            ElemTy,
20202
                            Ops[4]->getType()};
20203
        } else {
20204
          // passthru, op1, op2, vl
20205
          IntrinsicTypes = {ResultType,
20206
                            ElemTy,
20207
                            Ops[3]->getType()};
20208
        }
20209
        break;
20210
      }
20211
      break;
20212
case RISCVVector::BI__builtin_rvv_vxor_vv_tum:
20213
case RISCVVector::BI__builtin_rvv_vxor_vx_tum:
20214
  ID = Intrinsic::riscv_vxor_mask;
20215
  PolicyAttrs = 2;
20216
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
20217
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
20218
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
20219
  break;
20220
case RISCVVector::BI__builtin_rvv_vnot_v_tum:
20221
  ID = Intrinsic::riscv_vxor_mask;
20222
  PolicyAttrs = 2;
20223
IsMasked = true;
20224
 
20225
      {
20226
        if (IsMasked) {
20227
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
20228
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
20229
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
20230
        } else {
20231
          if (PolicyAttrs & RVV_VTA)
20232
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
20233
        }
20234
        auto ElemTy = cast<llvm::VectorType>(ResultType)->getElementType();
20235
        Ops.insert(Ops.begin() + 2,
20236
                   llvm::Constant::getAllOnesValue(ElemTy));
20237
        if (IsMasked) {
20238
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
20239
          // maskedoff, op1, po2, mask, vl, policy
20240
          IntrinsicTypes = {ResultType,
20241
                            ElemTy,
20242
                            Ops[4]->getType()};
20243
        } else {
20244
          // passthru, op1, op2, vl
20245
          IntrinsicTypes = {ResultType,
20246
                            ElemTy,
20247
                            Ops[3]->getType()};
20248
        }
20249
        break;
20250
      }
20251
      break;
20252
case RISCVVector::BI__builtin_rvv_vxor_vv_tama:
20253
case RISCVVector::BI__builtin_rvv_vxor_vx_tama:
20254
  ID = Intrinsic::riscv_vxor_mask;
20255
  PolicyAttrs = 3;
20256
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
20257
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
20258
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
20259
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
20260
  break;
20261
case RISCVVector::BI__builtin_rvv_vnot_v_tama:
20262
  ID = Intrinsic::riscv_vxor_mask;
20263
  PolicyAttrs = 3;
20264
IsMasked = true;
20265
 
20266
      {
20267
        if (IsMasked) {
20268
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
20269
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
20270
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
20271
        } else {
20272
          if (PolicyAttrs & RVV_VTA)
20273
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
20274
        }
20275
        auto ElemTy = cast<llvm::VectorType>(ResultType)->getElementType();
20276
        Ops.insert(Ops.begin() + 2,
20277
                   llvm::Constant::getAllOnesValue(ElemTy));
20278
        if (IsMasked) {
20279
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
20280
          // maskedoff, op1, po2, mask, vl, policy
20281
          IntrinsicTypes = {ResultType,
20282
                            ElemTy,
20283
                            Ops[4]->getType()};
20284
        } else {
20285
          // passthru, op1, op2, vl
20286
          IntrinsicTypes = {ResultType,
20287
                            ElemTy,
20288
                            Ops[3]->getType()};
20289
        }
20290
        break;
20291
      }
20292
      break;
20293
case RISCVVector::BI__builtin_rvv_vxor_vv_tumu:
20294
case RISCVVector::BI__builtin_rvv_vxor_vx_tumu:
20295
  ID = Intrinsic::riscv_vxor_mask;
20296
  PolicyAttrs = 0;
20297
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
20298
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
20299
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
20300
  break;
20301
case RISCVVector::BI__builtin_rvv_vnot_v_tumu:
20302
  ID = Intrinsic::riscv_vxor_mask;
20303
  PolicyAttrs = 0;
20304
IsMasked = true;
20305
 
20306
      {
20307
        if (IsMasked) {
20308
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
20309
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
20310
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
20311
        } else {
20312
          if (PolicyAttrs & RVV_VTA)
20313
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
20314
        }
20315
        auto ElemTy = cast<llvm::VectorType>(ResultType)->getElementType();
20316
        Ops.insert(Ops.begin() + 2,
20317
                   llvm::Constant::getAllOnesValue(ElemTy));
20318
        if (IsMasked) {
20319
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
20320
          // maskedoff, op1, po2, mask, vl, policy
20321
          IntrinsicTypes = {ResultType,
20322
                            ElemTy,
20323
                            Ops[4]->getType()};
20324
        } else {
20325
          // passthru, op1, op2, vl
20326
          IntrinsicTypes = {ResultType,
20327
                            ElemTy,
20328
                            Ops[3]->getType()};
20329
        }
20330
        break;
20331
      }
20332
      break;
20333
case RISCVVector::BI__builtin_rvv_vxor_vv_mu:
20334
case RISCVVector::BI__builtin_rvv_vxor_vx_mu:
20335
  ID = Intrinsic::riscv_vxor_mask;
20336
  PolicyAttrs = 1;
20337
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
20338
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
20339
  IntrinsicTypes = {ResultType, Ops[2]->getType(), Ops.back()->getType()};
20340
  break;
20341
case RISCVVector::BI__builtin_rvv_vnot_v_mu:
20342
  ID = Intrinsic::riscv_vxor_mask;
20343
  PolicyAttrs = 1;
20344
IsMasked = true;
20345
 
20346
      {
20347
        if (IsMasked) {
20348
          std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
20349
          if ((PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA))
20350
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
20351
        } else {
20352
          if (PolicyAttrs & RVV_VTA)
20353
            Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
20354
        }
20355
        auto ElemTy = cast<llvm::VectorType>(ResultType)->getElementType();
20356
        Ops.insert(Ops.begin() + 2,
20357
                   llvm::Constant::getAllOnesValue(ElemTy));
20358
        if (IsMasked) {
20359
          Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
20360
          // maskedoff, op1, po2, mask, vl, policy
20361
          IntrinsicTypes = {ResultType,
20362
                            ElemTy,
20363
                            Ops[4]->getType()};
20364
        } else {
20365
          // passthru, op1, op2, vl
20366
          IntrinsicTypes = {ResultType,
20367
                            ElemTy,
20368
                            Ops[3]->getType()};
20369
        }
20370
        break;
20371
      }
20372
      break;
20373
case RISCVVector::BI__builtin_rvv_vzext_vf2_tu:
20374
case RISCVVector::BI__builtin_rvv_vzext_vf4_tu:
20375
case RISCVVector::BI__builtin_rvv_vzext_vf8_tu:
20376
  ID = Intrinsic::riscv_vzext;
20377
  PolicyAttrs = 2;
20378
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
20379
  break;
20380
case RISCVVector::BI__builtin_rvv_vzext_vf2_ta:
20381
case RISCVVector::BI__builtin_rvv_vzext_vf4_ta:
20382
case RISCVVector::BI__builtin_rvv_vzext_vf8_ta:
20383
  ID = Intrinsic::riscv_vzext;
20384
  PolicyAttrs = 3;
20385
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
20386
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
20387
  break;
20388
case RISCVVector::BI__builtin_rvv_vzext_vf2_tum:
20389
case RISCVVector::BI__builtin_rvv_vzext_vf4_tum:
20390
case RISCVVector::BI__builtin_rvv_vzext_vf8_tum:
20391
  ID = Intrinsic::riscv_vzext_mask;
20392
  PolicyAttrs = 2;
20393
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
20394
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
20395
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
20396
  break;
20397
case RISCVVector::BI__builtin_rvv_vzext_vf2_tama:
20398
case RISCVVector::BI__builtin_rvv_vzext_vf4_tama:
20399
case RISCVVector::BI__builtin_rvv_vzext_vf8_tama:
20400
  ID = Intrinsic::riscv_vzext_mask;
20401
  PolicyAttrs = 3;
20402
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
20403
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
20404
  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
20405
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
20406
  break;
20407
case RISCVVector::BI__builtin_rvv_vzext_vf2_tumu:
20408
case RISCVVector::BI__builtin_rvv_vzext_vf4_tumu:
20409
case RISCVVector::BI__builtin_rvv_vzext_vf8_tumu:
20410
  ID = Intrinsic::riscv_vzext_mask;
20411
  PolicyAttrs = 0;
20412
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
20413
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
20414
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
20415
  break;
20416
case RISCVVector::BI__builtin_rvv_vzext_vf2_mu:
20417
case RISCVVector::BI__builtin_rvv_vzext_vf4_mu:
20418
case RISCVVector::BI__builtin_rvv_vzext_vf8_mu:
20419
  ID = Intrinsic::riscv_vzext_mask;
20420
  PolicyAttrs = 1;
20421
  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
20422
  Ops.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
20423
  IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops.back()->getType()};
20424
  break;
20425