xref: /freebsd/contrib/llvm-project/clang/lib/Sema/SemaLoongArch.cpp (revision 5036d9652a5701d00e9e40ea942c278e9f77d33d)
1 //===------ SemaLoongArch.cpp ---- LoongArch target-specific routines -----===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 //  This file implements semantic analysis functions specific to LoongArch.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "clang/Sema/SemaLoongArch.h"
14 #include "clang/Basic/TargetBuiltins.h"
15 #include "clang/Sema/Sema.h"
16 #include "llvm/Support/MathExtras.h"
17 
18 namespace clang {
19 
20 SemaLoongArch::SemaLoongArch(Sema &S) : SemaBase(S) {}
21 
22 bool SemaLoongArch::CheckLoongArchBuiltinFunctionCall(const TargetInfo &TI,
23                                                       unsigned BuiltinID,
24                                                       CallExpr *TheCall) {
25   switch (BuiltinID) {
26   default:
27     break;
28   // Basic intrinsics.
29   case LoongArch::BI__builtin_loongarch_cacop_d:
30   case LoongArch::BI__builtin_loongarch_cacop_w: {
31     SemaRef.BuiltinConstantArgRange(TheCall, 0, 0, llvm::maxUIntN(5));
32     SemaRef.BuiltinConstantArgRange(TheCall, 2, llvm::minIntN(12),
33                                     llvm::maxIntN(12));
34     break;
35   }
36   case LoongArch::BI__builtin_loongarch_break:
37   case LoongArch::BI__builtin_loongarch_dbar:
38   case LoongArch::BI__builtin_loongarch_ibar:
39   case LoongArch::BI__builtin_loongarch_syscall:
40     // Check if immediate is in [0, 32767].
41     return SemaRef.BuiltinConstantArgRange(TheCall, 0, 0, 32767);
42   case LoongArch::BI__builtin_loongarch_csrrd_w:
43   case LoongArch::BI__builtin_loongarch_csrrd_d:
44     return SemaRef.BuiltinConstantArgRange(TheCall, 0, 0, 16383);
45   case LoongArch::BI__builtin_loongarch_csrwr_w:
46   case LoongArch::BI__builtin_loongarch_csrwr_d:
47     return SemaRef.BuiltinConstantArgRange(TheCall, 1, 0, 16383);
48   case LoongArch::BI__builtin_loongarch_csrxchg_w:
49   case LoongArch::BI__builtin_loongarch_csrxchg_d:
50     return SemaRef.BuiltinConstantArgRange(TheCall, 2, 0, 16383);
51   case LoongArch::BI__builtin_loongarch_lddir_d:
52   case LoongArch::BI__builtin_loongarch_ldpte_d:
53     return SemaRef.BuiltinConstantArgRange(TheCall, 1, 0, 31);
54   case LoongArch::BI__builtin_loongarch_movfcsr2gr:
55   case LoongArch::BI__builtin_loongarch_movgr2fcsr:
56     return SemaRef.BuiltinConstantArgRange(TheCall, 0, 0, llvm::maxUIntN(2));
57 
58   // LSX intrinsics.
59   case LoongArch::BI__builtin_lsx_vbitclri_b:
60   case LoongArch::BI__builtin_lsx_vbitrevi_b:
61   case LoongArch::BI__builtin_lsx_vbitseti_b:
62   case LoongArch::BI__builtin_lsx_vsat_b:
63   case LoongArch::BI__builtin_lsx_vsat_bu:
64   case LoongArch::BI__builtin_lsx_vslli_b:
65   case LoongArch::BI__builtin_lsx_vsrai_b:
66   case LoongArch::BI__builtin_lsx_vsrari_b:
67   case LoongArch::BI__builtin_lsx_vsrli_b:
68   case LoongArch::BI__builtin_lsx_vsllwil_h_b:
69   case LoongArch::BI__builtin_lsx_vsllwil_hu_bu:
70   case LoongArch::BI__builtin_lsx_vrotri_b:
71   case LoongArch::BI__builtin_lsx_vsrlri_b:
72     return SemaRef.BuiltinConstantArgRange(TheCall, 1, 0, 7);
73   case LoongArch::BI__builtin_lsx_vbitclri_h:
74   case LoongArch::BI__builtin_lsx_vbitrevi_h:
75   case LoongArch::BI__builtin_lsx_vbitseti_h:
76   case LoongArch::BI__builtin_lsx_vsat_h:
77   case LoongArch::BI__builtin_lsx_vsat_hu:
78   case LoongArch::BI__builtin_lsx_vslli_h:
79   case LoongArch::BI__builtin_lsx_vsrai_h:
80   case LoongArch::BI__builtin_lsx_vsrari_h:
81   case LoongArch::BI__builtin_lsx_vsrli_h:
82   case LoongArch::BI__builtin_lsx_vsllwil_w_h:
83   case LoongArch::BI__builtin_lsx_vsllwil_wu_hu:
84   case LoongArch::BI__builtin_lsx_vrotri_h:
85   case LoongArch::BI__builtin_lsx_vsrlri_h:
86     return SemaRef.BuiltinConstantArgRange(TheCall, 1, 0, 15);
87   case LoongArch::BI__builtin_lsx_vssrarni_b_h:
88   case LoongArch::BI__builtin_lsx_vssrarni_bu_h:
89   case LoongArch::BI__builtin_lsx_vssrani_b_h:
90   case LoongArch::BI__builtin_lsx_vssrani_bu_h:
91   case LoongArch::BI__builtin_lsx_vsrarni_b_h:
92   case LoongArch::BI__builtin_lsx_vsrlni_b_h:
93   case LoongArch::BI__builtin_lsx_vsrlrni_b_h:
94   case LoongArch::BI__builtin_lsx_vssrlni_b_h:
95   case LoongArch::BI__builtin_lsx_vssrlni_bu_h:
96   case LoongArch::BI__builtin_lsx_vssrlrni_b_h:
97   case LoongArch::BI__builtin_lsx_vssrlrni_bu_h:
98   case LoongArch::BI__builtin_lsx_vsrani_b_h:
99     return SemaRef.BuiltinConstantArgRange(TheCall, 2, 0, 15);
100   case LoongArch::BI__builtin_lsx_vslei_bu:
101   case LoongArch::BI__builtin_lsx_vslei_hu:
102   case LoongArch::BI__builtin_lsx_vslei_wu:
103   case LoongArch::BI__builtin_lsx_vslei_du:
104   case LoongArch::BI__builtin_lsx_vslti_bu:
105   case LoongArch::BI__builtin_lsx_vslti_hu:
106   case LoongArch::BI__builtin_lsx_vslti_wu:
107   case LoongArch::BI__builtin_lsx_vslti_du:
108   case LoongArch::BI__builtin_lsx_vmaxi_bu:
109   case LoongArch::BI__builtin_lsx_vmaxi_hu:
110   case LoongArch::BI__builtin_lsx_vmaxi_wu:
111   case LoongArch::BI__builtin_lsx_vmaxi_du:
112   case LoongArch::BI__builtin_lsx_vmini_bu:
113   case LoongArch::BI__builtin_lsx_vmini_hu:
114   case LoongArch::BI__builtin_lsx_vmini_wu:
115   case LoongArch::BI__builtin_lsx_vmini_du:
116   case LoongArch::BI__builtin_lsx_vaddi_bu:
117   case LoongArch::BI__builtin_lsx_vaddi_hu:
118   case LoongArch::BI__builtin_lsx_vaddi_wu:
119   case LoongArch::BI__builtin_lsx_vaddi_du:
120   case LoongArch::BI__builtin_lsx_vbitclri_w:
121   case LoongArch::BI__builtin_lsx_vbitrevi_w:
122   case LoongArch::BI__builtin_lsx_vbitseti_w:
123   case LoongArch::BI__builtin_lsx_vsat_w:
124   case LoongArch::BI__builtin_lsx_vsat_wu:
125   case LoongArch::BI__builtin_lsx_vslli_w:
126   case LoongArch::BI__builtin_lsx_vsrai_w:
127   case LoongArch::BI__builtin_lsx_vsrari_w:
128   case LoongArch::BI__builtin_lsx_vsrli_w:
129   case LoongArch::BI__builtin_lsx_vsllwil_d_w:
130   case LoongArch::BI__builtin_lsx_vsllwil_du_wu:
131   case LoongArch::BI__builtin_lsx_vsrlri_w:
132   case LoongArch::BI__builtin_lsx_vrotri_w:
133   case LoongArch::BI__builtin_lsx_vsubi_bu:
134   case LoongArch::BI__builtin_lsx_vsubi_hu:
135   case LoongArch::BI__builtin_lsx_vbsrl_v:
136   case LoongArch::BI__builtin_lsx_vbsll_v:
137   case LoongArch::BI__builtin_lsx_vsubi_wu:
138   case LoongArch::BI__builtin_lsx_vsubi_du:
139     return SemaRef.BuiltinConstantArgRange(TheCall, 1, 0, 31);
140   case LoongArch::BI__builtin_lsx_vssrarni_h_w:
141   case LoongArch::BI__builtin_lsx_vssrarni_hu_w:
142   case LoongArch::BI__builtin_lsx_vssrani_h_w:
143   case LoongArch::BI__builtin_lsx_vssrani_hu_w:
144   case LoongArch::BI__builtin_lsx_vsrarni_h_w:
145   case LoongArch::BI__builtin_lsx_vsrani_h_w:
146   case LoongArch::BI__builtin_lsx_vfrstpi_b:
147   case LoongArch::BI__builtin_lsx_vfrstpi_h:
148   case LoongArch::BI__builtin_lsx_vsrlni_h_w:
149   case LoongArch::BI__builtin_lsx_vsrlrni_h_w:
150   case LoongArch::BI__builtin_lsx_vssrlni_h_w:
151   case LoongArch::BI__builtin_lsx_vssrlni_hu_w:
152   case LoongArch::BI__builtin_lsx_vssrlrni_h_w:
153   case LoongArch::BI__builtin_lsx_vssrlrni_hu_w:
154     return SemaRef.BuiltinConstantArgRange(TheCall, 2, 0, 31);
155   case LoongArch::BI__builtin_lsx_vbitclri_d:
156   case LoongArch::BI__builtin_lsx_vbitrevi_d:
157   case LoongArch::BI__builtin_lsx_vbitseti_d:
158   case LoongArch::BI__builtin_lsx_vsat_d:
159   case LoongArch::BI__builtin_lsx_vsat_du:
160   case LoongArch::BI__builtin_lsx_vslli_d:
161   case LoongArch::BI__builtin_lsx_vsrai_d:
162   case LoongArch::BI__builtin_lsx_vsrli_d:
163   case LoongArch::BI__builtin_lsx_vsrari_d:
164   case LoongArch::BI__builtin_lsx_vrotri_d:
165   case LoongArch::BI__builtin_lsx_vsrlri_d:
166     return SemaRef.BuiltinConstantArgRange(TheCall, 1, 0, 63);
167   case LoongArch::BI__builtin_lsx_vssrarni_w_d:
168   case LoongArch::BI__builtin_lsx_vssrarni_wu_d:
169   case LoongArch::BI__builtin_lsx_vssrani_w_d:
170   case LoongArch::BI__builtin_lsx_vssrani_wu_d:
171   case LoongArch::BI__builtin_lsx_vsrarni_w_d:
172   case LoongArch::BI__builtin_lsx_vsrlni_w_d:
173   case LoongArch::BI__builtin_lsx_vsrlrni_w_d:
174   case LoongArch::BI__builtin_lsx_vssrlni_w_d:
175   case LoongArch::BI__builtin_lsx_vssrlni_wu_d:
176   case LoongArch::BI__builtin_lsx_vssrlrni_w_d:
177   case LoongArch::BI__builtin_lsx_vssrlrni_wu_d:
178   case LoongArch::BI__builtin_lsx_vsrani_w_d:
179     return SemaRef.BuiltinConstantArgRange(TheCall, 2, 0, 63);
180   case LoongArch::BI__builtin_lsx_vssrarni_d_q:
181   case LoongArch::BI__builtin_lsx_vssrarni_du_q:
182   case LoongArch::BI__builtin_lsx_vssrani_d_q:
183   case LoongArch::BI__builtin_lsx_vssrani_du_q:
184   case LoongArch::BI__builtin_lsx_vsrarni_d_q:
185   case LoongArch::BI__builtin_lsx_vssrlni_d_q:
186   case LoongArch::BI__builtin_lsx_vssrlni_du_q:
187   case LoongArch::BI__builtin_lsx_vssrlrni_d_q:
188   case LoongArch::BI__builtin_lsx_vssrlrni_du_q:
189   case LoongArch::BI__builtin_lsx_vsrani_d_q:
190   case LoongArch::BI__builtin_lsx_vsrlrni_d_q:
191   case LoongArch::BI__builtin_lsx_vsrlni_d_q:
192     return SemaRef.BuiltinConstantArgRange(TheCall, 2, 0, 127);
193   case LoongArch::BI__builtin_lsx_vseqi_b:
194   case LoongArch::BI__builtin_lsx_vseqi_h:
195   case LoongArch::BI__builtin_lsx_vseqi_w:
196   case LoongArch::BI__builtin_lsx_vseqi_d:
197   case LoongArch::BI__builtin_lsx_vslti_b:
198   case LoongArch::BI__builtin_lsx_vslti_h:
199   case LoongArch::BI__builtin_lsx_vslti_w:
200   case LoongArch::BI__builtin_lsx_vslti_d:
201   case LoongArch::BI__builtin_lsx_vslei_b:
202   case LoongArch::BI__builtin_lsx_vslei_h:
203   case LoongArch::BI__builtin_lsx_vslei_w:
204   case LoongArch::BI__builtin_lsx_vslei_d:
205   case LoongArch::BI__builtin_lsx_vmaxi_b:
206   case LoongArch::BI__builtin_lsx_vmaxi_h:
207   case LoongArch::BI__builtin_lsx_vmaxi_w:
208   case LoongArch::BI__builtin_lsx_vmaxi_d:
209   case LoongArch::BI__builtin_lsx_vmini_b:
210   case LoongArch::BI__builtin_lsx_vmini_h:
211   case LoongArch::BI__builtin_lsx_vmini_w:
212   case LoongArch::BI__builtin_lsx_vmini_d:
213     return SemaRef.BuiltinConstantArgRange(TheCall, 1, -16, 15);
214   case LoongArch::BI__builtin_lsx_vandi_b:
215   case LoongArch::BI__builtin_lsx_vnori_b:
216   case LoongArch::BI__builtin_lsx_vori_b:
217   case LoongArch::BI__builtin_lsx_vshuf4i_b:
218   case LoongArch::BI__builtin_lsx_vshuf4i_h:
219   case LoongArch::BI__builtin_lsx_vshuf4i_w:
220   case LoongArch::BI__builtin_lsx_vxori_b:
221     return SemaRef.BuiltinConstantArgRange(TheCall, 1, 0, 255);
222   case LoongArch::BI__builtin_lsx_vbitseli_b:
223   case LoongArch::BI__builtin_lsx_vshuf4i_d:
224   case LoongArch::BI__builtin_lsx_vextrins_b:
225   case LoongArch::BI__builtin_lsx_vextrins_h:
226   case LoongArch::BI__builtin_lsx_vextrins_w:
227   case LoongArch::BI__builtin_lsx_vextrins_d:
228   case LoongArch::BI__builtin_lsx_vpermi_w:
229     return SemaRef.BuiltinConstantArgRange(TheCall, 2, 0, 255);
230   case LoongArch::BI__builtin_lsx_vpickve2gr_b:
231   case LoongArch::BI__builtin_lsx_vpickve2gr_bu:
232   case LoongArch::BI__builtin_lsx_vreplvei_b:
233     return SemaRef.BuiltinConstantArgRange(TheCall, 1, 0, 15);
234   case LoongArch::BI__builtin_lsx_vinsgr2vr_b:
235     return SemaRef.BuiltinConstantArgRange(TheCall, 2, 0, 15);
236   case LoongArch::BI__builtin_lsx_vpickve2gr_h:
237   case LoongArch::BI__builtin_lsx_vpickve2gr_hu:
238   case LoongArch::BI__builtin_lsx_vreplvei_h:
239     return SemaRef.BuiltinConstantArgRange(TheCall, 1, 0, 7);
240   case LoongArch::BI__builtin_lsx_vinsgr2vr_h:
241     return SemaRef.BuiltinConstantArgRange(TheCall, 2, 0, 7);
242   case LoongArch::BI__builtin_lsx_vpickve2gr_w:
243   case LoongArch::BI__builtin_lsx_vpickve2gr_wu:
244   case LoongArch::BI__builtin_lsx_vreplvei_w:
245     return SemaRef.BuiltinConstantArgRange(TheCall, 1, 0, 3);
246   case LoongArch::BI__builtin_lsx_vinsgr2vr_w:
247     return SemaRef.BuiltinConstantArgRange(TheCall, 2, 0, 3);
248   case LoongArch::BI__builtin_lsx_vpickve2gr_d:
249   case LoongArch::BI__builtin_lsx_vpickve2gr_du:
250   case LoongArch::BI__builtin_lsx_vreplvei_d:
251     return SemaRef.BuiltinConstantArgRange(TheCall, 1, 0, 1);
252   case LoongArch::BI__builtin_lsx_vinsgr2vr_d:
253     return SemaRef.BuiltinConstantArgRange(TheCall, 2, 0, 1);
254   case LoongArch::BI__builtin_lsx_vstelm_b:
255     return SemaRef.BuiltinConstantArgRange(TheCall, 2, -128, 127) ||
256            SemaRef.BuiltinConstantArgRange(TheCall, 3, 0, 15);
257   case LoongArch::BI__builtin_lsx_vstelm_h:
258     return SemaRef.BuiltinConstantArgRange(TheCall, 2, -256, 254) ||
259            SemaRef.BuiltinConstantArgRange(TheCall, 3, 0, 7);
260   case LoongArch::BI__builtin_lsx_vstelm_w:
261     return SemaRef.BuiltinConstantArgRange(TheCall, 2, -512, 508) ||
262            SemaRef.BuiltinConstantArgRange(TheCall, 3, 0, 3);
263   case LoongArch::BI__builtin_lsx_vstelm_d:
264     return SemaRef.BuiltinConstantArgRange(TheCall, 2, -1024, 1016) ||
265            SemaRef.BuiltinConstantArgRange(TheCall, 3, 0, 1);
266   case LoongArch::BI__builtin_lsx_vldrepl_b:
267   case LoongArch::BI__builtin_lsx_vld:
268     return SemaRef.BuiltinConstantArgRange(TheCall, 1, -2048, 2047);
269   case LoongArch::BI__builtin_lsx_vldrepl_h:
270     return SemaRef.BuiltinConstantArgRange(TheCall, 1, -2048, 2046);
271   case LoongArch::BI__builtin_lsx_vldrepl_w:
272     return SemaRef.BuiltinConstantArgRange(TheCall, 1, -2048, 2044);
273   case LoongArch::BI__builtin_lsx_vldrepl_d:
274     return SemaRef.BuiltinConstantArgRange(TheCall, 1, -2048, 2040);
275   case LoongArch::BI__builtin_lsx_vst:
276     return SemaRef.BuiltinConstantArgRange(TheCall, 2, -2048, 2047);
277   case LoongArch::BI__builtin_lsx_vldi:
278     return SemaRef.BuiltinConstantArgRange(TheCall, 0, -4096, 4095);
279   case LoongArch::BI__builtin_lsx_vrepli_b:
280   case LoongArch::BI__builtin_lsx_vrepli_h:
281   case LoongArch::BI__builtin_lsx_vrepli_w:
282   case LoongArch::BI__builtin_lsx_vrepli_d:
283     return SemaRef.BuiltinConstantArgRange(TheCall, 0, -512, 511);
284 
285   // LASX intrinsics.
286   case LoongArch::BI__builtin_lasx_xvbitclri_b:
287   case LoongArch::BI__builtin_lasx_xvbitrevi_b:
288   case LoongArch::BI__builtin_lasx_xvbitseti_b:
289   case LoongArch::BI__builtin_lasx_xvsat_b:
290   case LoongArch::BI__builtin_lasx_xvsat_bu:
291   case LoongArch::BI__builtin_lasx_xvslli_b:
292   case LoongArch::BI__builtin_lasx_xvsrai_b:
293   case LoongArch::BI__builtin_lasx_xvsrari_b:
294   case LoongArch::BI__builtin_lasx_xvsrli_b:
295   case LoongArch::BI__builtin_lasx_xvsllwil_h_b:
296   case LoongArch::BI__builtin_lasx_xvsllwil_hu_bu:
297   case LoongArch::BI__builtin_lasx_xvrotri_b:
298   case LoongArch::BI__builtin_lasx_xvsrlri_b:
299     return SemaRef.BuiltinConstantArgRange(TheCall, 1, 0, 7);
300   case LoongArch::BI__builtin_lasx_xvbitclri_h:
301   case LoongArch::BI__builtin_lasx_xvbitrevi_h:
302   case LoongArch::BI__builtin_lasx_xvbitseti_h:
303   case LoongArch::BI__builtin_lasx_xvsat_h:
304   case LoongArch::BI__builtin_lasx_xvsat_hu:
305   case LoongArch::BI__builtin_lasx_xvslli_h:
306   case LoongArch::BI__builtin_lasx_xvsrai_h:
307   case LoongArch::BI__builtin_lasx_xvsrari_h:
308   case LoongArch::BI__builtin_lasx_xvsrli_h:
309   case LoongArch::BI__builtin_lasx_xvsllwil_w_h:
310   case LoongArch::BI__builtin_lasx_xvsllwil_wu_hu:
311   case LoongArch::BI__builtin_lasx_xvrotri_h:
312   case LoongArch::BI__builtin_lasx_xvsrlri_h:
313     return SemaRef.BuiltinConstantArgRange(TheCall, 1, 0, 15);
314   case LoongArch::BI__builtin_lasx_xvssrarni_b_h:
315   case LoongArch::BI__builtin_lasx_xvssrarni_bu_h:
316   case LoongArch::BI__builtin_lasx_xvssrani_b_h:
317   case LoongArch::BI__builtin_lasx_xvssrani_bu_h:
318   case LoongArch::BI__builtin_lasx_xvsrarni_b_h:
319   case LoongArch::BI__builtin_lasx_xvsrlni_b_h:
320   case LoongArch::BI__builtin_lasx_xvsrlrni_b_h:
321   case LoongArch::BI__builtin_lasx_xvssrlni_b_h:
322   case LoongArch::BI__builtin_lasx_xvssrlni_bu_h:
323   case LoongArch::BI__builtin_lasx_xvssrlrni_b_h:
324   case LoongArch::BI__builtin_lasx_xvssrlrni_bu_h:
325   case LoongArch::BI__builtin_lasx_xvsrani_b_h:
326     return SemaRef.BuiltinConstantArgRange(TheCall, 2, 0, 15);
327   case LoongArch::BI__builtin_lasx_xvslei_bu:
328   case LoongArch::BI__builtin_lasx_xvslei_hu:
329   case LoongArch::BI__builtin_lasx_xvslei_wu:
330   case LoongArch::BI__builtin_lasx_xvslei_du:
331   case LoongArch::BI__builtin_lasx_xvslti_bu:
332   case LoongArch::BI__builtin_lasx_xvslti_hu:
333   case LoongArch::BI__builtin_lasx_xvslti_wu:
334   case LoongArch::BI__builtin_lasx_xvslti_du:
335   case LoongArch::BI__builtin_lasx_xvmaxi_bu:
336   case LoongArch::BI__builtin_lasx_xvmaxi_hu:
337   case LoongArch::BI__builtin_lasx_xvmaxi_wu:
338   case LoongArch::BI__builtin_lasx_xvmaxi_du:
339   case LoongArch::BI__builtin_lasx_xvmini_bu:
340   case LoongArch::BI__builtin_lasx_xvmini_hu:
341   case LoongArch::BI__builtin_lasx_xvmini_wu:
342   case LoongArch::BI__builtin_lasx_xvmini_du:
343   case LoongArch::BI__builtin_lasx_xvaddi_bu:
344   case LoongArch::BI__builtin_lasx_xvaddi_hu:
345   case LoongArch::BI__builtin_lasx_xvaddi_wu:
346   case LoongArch::BI__builtin_lasx_xvaddi_du:
347   case LoongArch::BI__builtin_lasx_xvbitclri_w:
348   case LoongArch::BI__builtin_lasx_xvbitrevi_w:
349   case LoongArch::BI__builtin_lasx_xvbitseti_w:
350   case LoongArch::BI__builtin_lasx_xvsat_w:
351   case LoongArch::BI__builtin_lasx_xvsat_wu:
352   case LoongArch::BI__builtin_lasx_xvslli_w:
353   case LoongArch::BI__builtin_lasx_xvsrai_w:
354   case LoongArch::BI__builtin_lasx_xvsrari_w:
355   case LoongArch::BI__builtin_lasx_xvsrli_w:
356   case LoongArch::BI__builtin_lasx_xvsllwil_d_w:
357   case LoongArch::BI__builtin_lasx_xvsllwil_du_wu:
358   case LoongArch::BI__builtin_lasx_xvsrlri_w:
359   case LoongArch::BI__builtin_lasx_xvrotri_w:
360   case LoongArch::BI__builtin_lasx_xvsubi_bu:
361   case LoongArch::BI__builtin_lasx_xvsubi_hu:
362   case LoongArch::BI__builtin_lasx_xvsubi_wu:
363   case LoongArch::BI__builtin_lasx_xvsubi_du:
364   case LoongArch::BI__builtin_lasx_xvbsrl_v:
365   case LoongArch::BI__builtin_lasx_xvbsll_v:
366     return SemaRef.BuiltinConstantArgRange(TheCall, 1, 0, 31);
367   case LoongArch::BI__builtin_lasx_xvssrarni_h_w:
368   case LoongArch::BI__builtin_lasx_xvssrarni_hu_w:
369   case LoongArch::BI__builtin_lasx_xvssrani_h_w:
370   case LoongArch::BI__builtin_lasx_xvssrani_hu_w:
371   case LoongArch::BI__builtin_lasx_xvsrarni_h_w:
372   case LoongArch::BI__builtin_lasx_xvsrani_h_w:
373   case LoongArch::BI__builtin_lasx_xvfrstpi_b:
374   case LoongArch::BI__builtin_lasx_xvfrstpi_h:
375   case LoongArch::BI__builtin_lasx_xvsrlni_h_w:
376   case LoongArch::BI__builtin_lasx_xvsrlrni_h_w:
377   case LoongArch::BI__builtin_lasx_xvssrlni_h_w:
378   case LoongArch::BI__builtin_lasx_xvssrlni_hu_w:
379   case LoongArch::BI__builtin_lasx_xvssrlrni_h_w:
380   case LoongArch::BI__builtin_lasx_xvssrlrni_hu_w:
381     return SemaRef.BuiltinConstantArgRange(TheCall, 2, 0, 31);
382   case LoongArch::BI__builtin_lasx_xvbitclri_d:
383   case LoongArch::BI__builtin_lasx_xvbitrevi_d:
384   case LoongArch::BI__builtin_lasx_xvbitseti_d:
385   case LoongArch::BI__builtin_lasx_xvsat_d:
386   case LoongArch::BI__builtin_lasx_xvsat_du:
387   case LoongArch::BI__builtin_lasx_xvslli_d:
388   case LoongArch::BI__builtin_lasx_xvsrai_d:
389   case LoongArch::BI__builtin_lasx_xvsrli_d:
390   case LoongArch::BI__builtin_lasx_xvsrari_d:
391   case LoongArch::BI__builtin_lasx_xvrotri_d:
392   case LoongArch::BI__builtin_lasx_xvsrlri_d:
393     return SemaRef.BuiltinConstantArgRange(TheCall, 1, 0, 63);
394   case LoongArch::BI__builtin_lasx_xvssrarni_w_d:
395   case LoongArch::BI__builtin_lasx_xvssrarni_wu_d:
396   case LoongArch::BI__builtin_lasx_xvssrani_w_d:
397   case LoongArch::BI__builtin_lasx_xvssrani_wu_d:
398   case LoongArch::BI__builtin_lasx_xvsrarni_w_d:
399   case LoongArch::BI__builtin_lasx_xvsrlni_w_d:
400   case LoongArch::BI__builtin_lasx_xvsrlrni_w_d:
401   case LoongArch::BI__builtin_lasx_xvssrlni_w_d:
402   case LoongArch::BI__builtin_lasx_xvssrlni_wu_d:
403   case LoongArch::BI__builtin_lasx_xvssrlrni_w_d:
404   case LoongArch::BI__builtin_lasx_xvssrlrni_wu_d:
405   case LoongArch::BI__builtin_lasx_xvsrani_w_d:
406     return SemaRef.BuiltinConstantArgRange(TheCall, 2, 0, 63);
407   case LoongArch::BI__builtin_lasx_xvssrarni_d_q:
408   case LoongArch::BI__builtin_lasx_xvssrarni_du_q:
409   case LoongArch::BI__builtin_lasx_xvssrani_d_q:
410   case LoongArch::BI__builtin_lasx_xvssrani_du_q:
411   case LoongArch::BI__builtin_lasx_xvsrarni_d_q:
412   case LoongArch::BI__builtin_lasx_xvssrlni_d_q:
413   case LoongArch::BI__builtin_lasx_xvssrlni_du_q:
414   case LoongArch::BI__builtin_lasx_xvssrlrni_d_q:
415   case LoongArch::BI__builtin_lasx_xvssrlrni_du_q:
416   case LoongArch::BI__builtin_lasx_xvsrani_d_q:
417   case LoongArch::BI__builtin_lasx_xvsrlni_d_q:
418   case LoongArch::BI__builtin_lasx_xvsrlrni_d_q:
419     return SemaRef.BuiltinConstantArgRange(TheCall, 2, 0, 127);
420   case LoongArch::BI__builtin_lasx_xvseqi_b:
421   case LoongArch::BI__builtin_lasx_xvseqi_h:
422   case LoongArch::BI__builtin_lasx_xvseqi_w:
423   case LoongArch::BI__builtin_lasx_xvseqi_d:
424   case LoongArch::BI__builtin_lasx_xvslti_b:
425   case LoongArch::BI__builtin_lasx_xvslti_h:
426   case LoongArch::BI__builtin_lasx_xvslti_w:
427   case LoongArch::BI__builtin_lasx_xvslti_d:
428   case LoongArch::BI__builtin_lasx_xvslei_b:
429   case LoongArch::BI__builtin_lasx_xvslei_h:
430   case LoongArch::BI__builtin_lasx_xvslei_w:
431   case LoongArch::BI__builtin_lasx_xvslei_d:
432   case LoongArch::BI__builtin_lasx_xvmaxi_b:
433   case LoongArch::BI__builtin_lasx_xvmaxi_h:
434   case LoongArch::BI__builtin_lasx_xvmaxi_w:
435   case LoongArch::BI__builtin_lasx_xvmaxi_d:
436   case LoongArch::BI__builtin_lasx_xvmini_b:
437   case LoongArch::BI__builtin_lasx_xvmini_h:
438   case LoongArch::BI__builtin_lasx_xvmini_w:
439   case LoongArch::BI__builtin_lasx_xvmini_d:
440     return SemaRef.BuiltinConstantArgRange(TheCall, 1, -16, 15);
441   case LoongArch::BI__builtin_lasx_xvandi_b:
442   case LoongArch::BI__builtin_lasx_xvnori_b:
443   case LoongArch::BI__builtin_lasx_xvori_b:
444   case LoongArch::BI__builtin_lasx_xvshuf4i_b:
445   case LoongArch::BI__builtin_lasx_xvshuf4i_h:
446   case LoongArch::BI__builtin_lasx_xvshuf4i_w:
447   case LoongArch::BI__builtin_lasx_xvxori_b:
448   case LoongArch::BI__builtin_lasx_xvpermi_d:
449     return SemaRef.BuiltinConstantArgRange(TheCall, 1, 0, 255);
450   case LoongArch::BI__builtin_lasx_xvbitseli_b:
451   case LoongArch::BI__builtin_lasx_xvshuf4i_d:
452   case LoongArch::BI__builtin_lasx_xvextrins_b:
453   case LoongArch::BI__builtin_lasx_xvextrins_h:
454   case LoongArch::BI__builtin_lasx_xvextrins_w:
455   case LoongArch::BI__builtin_lasx_xvextrins_d:
456   case LoongArch::BI__builtin_lasx_xvpermi_q:
457   case LoongArch::BI__builtin_lasx_xvpermi_w:
458     return SemaRef.BuiltinConstantArgRange(TheCall, 2, 0, 255);
459   case LoongArch::BI__builtin_lasx_xvrepl128vei_b:
460     return SemaRef.BuiltinConstantArgRange(TheCall, 1, 0, 15);
461   case LoongArch::BI__builtin_lasx_xvrepl128vei_h:
462   case LoongArch::BI__builtin_lasx_xvpickve2gr_w:
463   case LoongArch::BI__builtin_lasx_xvpickve2gr_wu:
464   case LoongArch::BI__builtin_lasx_xvpickve_w_f:
465   case LoongArch::BI__builtin_lasx_xvpickve_w:
466     return SemaRef.BuiltinConstantArgRange(TheCall, 1, 0, 7);
467   case LoongArch::BI__builtin_lasx_xvinsgr2vr_w:
468   case LoongArch::BI__builtin_lasx_xvinsve0_w:
469     return SemaRef.BuiltinConstantArgRange(TheCall, 2, 0, 7);
470   case LoongArch::BI__builtin_lasx_xvrepl128vei_w:
471   case LoongArch::BI__builtin_lasx_xvpickve2gr_d:
472   case LoongArch::BI__builtin_lasx_xvpickve2gr_du:
473   case LoongArch::BI__builtin_lasx_xvpickve_d_f:
474   case LoongArch::BI__builtin_lasx_xvpickve_d:
475     return SemaRef.BuiltinConstantArgRange(TheCall, 1, 0, 3);
476   case LoongArch::BI__builtin_lasx_xvinsve0_d:
477   case LoongArch::BI__builtin_lasx_xvinsgr2vr_d:
478     return SemaRef.BuiltinConstantArgRange(TheCall, 2, 0, 3);
479   case LoongArch::BI__builtin_lasx_xvstelm_b:
480     return SemaRef.BuiltinConstantArgRange(TheCall, 2, -128, 127) ||
481            SemaRef.BuiltinConstantArgRange(TheCall, 3, 0, 31);
482   case LoongArch::BI__builtin_lasx_xvstelm_h:
483     return SemaRef.BuiltinConstantArgRange(TheCall, 2, -256, 254) ||
484            SemaRef.BuiltinConstantArgRange(TheCall, 3, 0, 15);
485   case LoongArch::BI__builtin_lasx_xvstelm_w:
486     return SemaRef.BuiltinConstantArgRange(TheCall, 2, -512, 508) ||
487            SemaRef.BuiltinConstantArgRange(TheCall, 3, 0, 7);
488   case LoongArch::BI__builtin_lasx_xvstelm_d:
489     return SemaRef.BuiltinConstantArgRange(TheCall, 2, -1024, 1016) ||
490            SemaRef.BuiltinConstantArgRange(TheCall, 3, 0, 3);
491   case LoongArch::BI__builtin_lasx_xvrepl128vei_d:
492     return SemaRef.BuiltinConstantArgRange(TheCall, 1, 0, 1);
493   case LoongArch::BI__builtin_lasx_xvldrepl_b:
494   case LoongArch::BI__builtin_lasx_xvld:
495     return SemaRef.BuiltinConstantArgRange(TheCall, 1, -2048, 2047);
496   case LoongArch::BI__builtin_lasx_xvldrepl_h:
497     return SemaRef.BuiltinConstantArgRange(TheCall, 1, -2048, 2046);
498   case LoongArch::BI__builtin_lasx_xvldrepl_w:
499     return SemaRef.BuiltinConstantArgRange(TheCall, 1, -2048, 2044);
500   case LoongArch::BI__builtin_lasx_xvldrepl_d:
501     return SemaRef.BuiltinConstantArgRange(TheCall, 1, -2048, 2040);
502   case LoongArch::BI__builtin_lasx_xvst:
503     return SemaRef.BuiltinConstantArgRange(TheCall, 2, -2048, 2047);
504   case LoongArch::BI__builtin_lasx_xvldi:
505     return SemaRef.BuiltinConstantArgRange(TheCall, 0, -4096, 4095);
506   case LoongArch::BI__builtin_lasx_xvrepli_b:
507   case LoongArch::BI__builtin_lasx_xvrepli_h:
508   case LoongArch::BI__builtin_lasx_xvrepli_w:
509   case LoongArch::BI__builtin_lasx_xvrepli_d:
510     return SemaRef.BuiltinConstantArgRange(TheCall, 0, -512, 511);
511   }
512   return false;
513 }
514 
515 } // namespace clang
516