1 | //===------ SemaHexagon.cpp ------ Hexagon 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 Hexagon. |
10 | // |
11 | //===----------------------------------------------------------------------===// |
12 | |
13 | #include "clang/Sema/SemaHexagon.h" |
14 | #include "clang/Basic/TargetBuiltins.h" |
15 | #include "clang/Sema/Sema.h" |
16 | #include "llvm/ADT/STLExtras.h" |
17 | #include <cstdint> |
18 | #include <iterator> |
19 | |
20 | namespace clang { |
21 | |
22 | SemaHexagon::SemaHexagon(Sema &S) : SemaBase(S) {} |
23 | |
24 | bool SemaHexagon::CheckHexagonBuiltinArgument(unsigned BuiltinID, |
25 | CallExpr *TheCall) { |
26 | struct ArgInfo { |
27 | uint8_t OpNum; |
28 | bool IsSigned; |
29 | uint8_t BitWidth; |
30 | uint8_t Align; |
31 | }; |
32 | struct BuiltinInfo { |
33 | unsigned BuiltinID; |
34 | ArgInfo Infos[2]; |
35 | }; |
36 | |
37 | static BuiltinInfo Infos[] = { |
38 | { .BuiltinID: Hexagon::BI__builtin_circ_ldd, .Infos: {{ .OpNum: 3, .IsSigned: true, .BitWidth: 4, .Align: 3 }} }, |
39 | { .BuiltinID: Hexagon::BI__builtin_circ_ldw, .Infos: {{ .OpNum: 3, .IsSigned: true, .BitWidth: 4, .Align: 2 }} }, |
40 | { .BuiltinID: Hexagon::BI__builtin_circ_ldh, .Infos: {{ .OpNum: 3, .IsSigned: true, .BitWidth: 4, .Align: 1 }} }, |
41 | { .BuiltinID: Hexagon::BI__builtin_circ_lduh, .Infos: {{ .OpNum: 3, .IsSigned: true, .BitWidth: 4, .Align: 1 }} }, |
42 | { .BuiltinID: Hexagon::BI__builtin_circ_ldb, .Infos: {{ .OpNum: 3, .IsSigned: true, .BitWidth: 4, .Align: 0 }} }, |
43 | { .BuiltinID: Hexagon::BI__builtin_circ_ldub, .Infos: {{ .OpNum: 3, .IsSigned: true, .BitWidth: 4, .Align: 0 }} }, |
44 | { .BuiltinID: Hexagon::BI__builtin_circ_std, .Infos: {{ .OpNum: 3, .IsSigned: true, .BitWidth: 4, .Align: 3 }} }, |
45 | { .BuiltinID: Hexagon::BI__builtin_circ_stw, .Infos: {{ .OpNum: 3, .IsSigned: true, .BitWidth: 4, .Align: 2 }} }, |
46 | { .BuiltinID: Hexagon::BI__builtin_circ_sth, .Infos: {{ .OpNum: 3, .IsSigned: true, .BitWidth: 4, .Align: 1 }} }, |
47 | { .BuiltinID: Hexagon::BI__builtin_circ_sthhi, .Infos: {{ .OpNum: 3, .IsSigned: true, .BitWidth: 4, .Align: 1 }} }, |
48 | { .BuiltinID: Hexagon::BI__builtin_circ_stb, .Infos: {{ .OpNum: 3, .IsSigned: true, .BitWidth: 4, .Align: 0 }} }, |
49 | |
50 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_L2_loadrub_pci, .Infos: {{ .OpNum: 1, .IsSigned: true, .BitWidth: 4, .Align: 0 }} }, |
51 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_L2_loadrb_pci, .Infos: {{ .OpNum: 1, .IsSigned: true, .BitWidth: 4, .Align: 0 }} }, |
52 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_L2_loadruh_pci, .Infos: {{ .OpNum: 1, .IsSigned: true, .BitWidth: 4, .Align: 1 }} }, |
53 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_L2_loadrh_pci, .Infos: {{ .OpNum: 1, .IsSigned: true, .BitWidth: 4, .Align: 1 }} }, |
54 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_L2_loadri_pci, .Infos: {{ .OpNum: 1, .IsSigned: true, .BitWidth: 4, .Align: 2 }} }, |
55 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_L2_loadrd_pci, .Infos: {{ .OpNum: 1, .IsSigned: true, .BitWidth: 4, .Align: 3 }} }, |
56 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_storerb_pci, .Infos: {{ .OpNum: 1, .IsSigned: true, .BitWidth: 4, .Align: 0 }} }, |
57 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_storerh_pci, .Infos: {{ .OpNum: 1, .IsSigned: true, .BitWidth: 4, .Align: 1 }} }, |
58 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_storerf_pci, .Infos: {{ .OpNum: 1, .IsSigned: true, .BitWidth: 4, .Align: 1 }} }, |
59 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_storeri_pci, .Infos: {{ .OpNum: 1, .IsSigned: true, .BitWidth: 4, .Align: 2 }} }, |
60 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_storerd_pci, .Infos: {{ .OpNum: 1, .IsSigned: true, .BitWidth: 4, .Align: 3 }} }, |
61 | |
62 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_A2_combineii, .Infos: {{ .OpNum: 1, .IsSigned: true, .BitWidth: 8, .Align: 0 }} }, |
63 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_A2_tfrih, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 16, .Align: 0 }} }, |
64 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_A2_tfril, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 16, .Align: 0 }} }, |
65 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_A2_tfrpi, .Infos: {{ .OpNum: 0, .IsSigned: true, .BitWidth: 8, .Align: 0 }} }, |
66 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_A4_bitspliti, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
67 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_A4_cmpbeqi, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 8, .Align: 0 }} }, |
68 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_A4_cmpbgti, .Infos: {{ .OpNum: 1, .IsSigned: true, .BitWidth: 8, .Align: 0 }} }, |
69 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_A4_cround_ri, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
70 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_A4_round_ri, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
71 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_A4_round_ri_sat, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
72 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_A4_vcmpbeqi, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 8, .Align: 0 }} }, |
73 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_A4_vcmpbgti, .Infos: {{ .OpNum: 1, .IsSigned: true, .BitWidth: 8, .Align: 0 }} }, |
74 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_A4_vcmpbgtui, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 7, .Align: 0 }} }, |
75 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_A4_vcmpheqi, .Infos: {{ .OpNum: 1, .IsSigned: true, .BitWidth: 8, .Align: 0 }} }, |
76 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_A4_vcmphgti, .Infos: {{ .OpNum: 1, .IsSigned: true, .BitWidth: 8, .Align: 0 }} }, |
77 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_A4_vcmphgtui, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 7, .Align: 0 }} }, |
78 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_A4_vcmpweqi, .Infos: {{ .OpNum: 1, .IsSigned: true, .BitWidth: 8, .Align: 0 }} }, |
79 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_A4_vcmpwgti, .Infos: {{ .OpNum: 1, .IsSigned: true, .BitWidth: 8, .Align: 0 }} }, |
80 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_A4_vcmpwgtui, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 7, .Align: 0 }} }, |
81 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_C2_bitsclri, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 6, .Align: 0 }} }, |
82 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_C2_muxii, .Infos: {{ .OpNum: 2, .IsSigned: true, .BitWidth: 8, .Align: 0 }} }, |
83 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_C4_nbitsclri, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 6, .Align: 0 }} }, |
84 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_F2_dfclass, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
85 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_F2_dfimm_n, .Infos: {{ .OpNum: 0, .IsSigned: false, .BitWidth: 10, .Align: 0 }} }, |
86 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_F2_dfimm_p, .Infos: {{ .OpNum: 0, .IsSigned: false, .BitWidth: 10, .Align: 0 }} }, |
87 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_F2_sfclass, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
88 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_F2_sfimm_n, .Infos: {{ .OpNum: 0, .IsSigned: false, .BitWidth: 10, .Align: 0 }} }, |
89 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_F2_sfimm_p, .Infos: {{ .OpNum: 0, .IsSigned: false, .BitWidth: 10, .Align: 0 }} }, |
90 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_M4_mpyri_addi, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 6, .Align: 0 }} }, |
91 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_M4_mpyri_addr_u2, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 6, .Align: 2 }} }, |
92 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_addasl_rrri, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 3, .Align: 0 }} }, |
93 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_acc, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 6, .Align: 0 }} }, |
94 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_and, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 6, .Align: 0 }} }, |
95 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_asl_i_p, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 6, .Align: 0 }} }, |
96 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_nac, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 6, .Align: 0 }} }, |
97 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_or, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 6, .Align: 0 }} }, |
98 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_asl_i_p_xacc, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 6, .Align: 0 }} }, |
99 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_acc, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
100 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_and, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
101 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_asl_i_r, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
102 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_nac, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
103 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_or, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
104 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_sat, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
105 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_asl_i_r_xacc, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
106 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_asl_i_vh, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 4, .Align: 0 }} }, |
107 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_asl_i_vw, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
108 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_acc, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 6, .Align: 0 }} }, |
109 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_and, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 6, .Align: 0 }} }, |
110 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_asr_i_p, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 6, .Align: 0 }} }, |
111 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_nac, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 6, .Align: 0 }} }, |
112 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_or, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 6, .Align: 0 }} }, |
113 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_rnd_goodsyntax, |
114 | .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 6, .Align: 0 }} }, |
115 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_asr_i_p_rnd, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 6, .Align: 0 }} }, |
116 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_acc, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
117 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_and, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
118 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_asr_i_r, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
119 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_nac, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
120 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_or, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
121 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_rnd_goodsyntax, |
122 | .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
123 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_asr_i_r_rnd, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
124 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_asr_i_svw_trun, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
125 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_asr_i_vh, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 4, .Align: 0 }} }, |
126 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_asr_i_vw, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
127 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_clrbit_i, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
128 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_extractu, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 5, .Align: 0 }, |
129 | { .OpNum: 2, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
130 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_extractup, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 6, .Align: 0 }, |
131 | { .OpNum: 2, .IsSigned: false, .BitWidth: 6, .Align: 0 }} }, |
132 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_insert, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 5, .Align: 0 }, |
133 | { .OpNum: 3, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
134 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_insertp, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 6, .Align: 0 }, |
135 | { .OpNum: 3, .IsSigned: false, .BitWidth: 6, .Align: 0 }} }, |
136 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_acc, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 6, .Align: 0 }} }, |
137 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_and, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 6, .Align: 0 }} }, |
138 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 6, .Align: 0 }} }, |
139 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_nac, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 6, .Align: 0 }} }, |
140 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_or, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 6, .Align: 0 }} }, |
141 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_lsr_i_p_xacc, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 6, .Align: 0 }} }, |
142 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_acc, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
143 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_and, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
144 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
145 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_nac, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
146 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_or, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
147 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_lsr_i_r_xacc, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
148 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_lsr_i_vh, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 4, .Align: 0 }} }, |
149 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_lsr_i_vw, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
150 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_setbit_i, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
151 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_tableidxb_goodsyntax, |
152 | .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 4, .Align: 0 }, |
153 | { .OpNum: 3, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
154 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_tableidxd_goodsyntax, |
155 | .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 4, .Align: 0 }, |
156 | { .OpNum: 3, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
157 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_tableidxh_goodsyntax, |
158 | .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 4, .Align: 0 }, |
159 | { .OpNum: 3, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
160 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_tableidxw_goodsyntax, |
161 | .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 4, .Align: 0 }, |
162 | { .OpNum: 3, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
163 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_togglebit_i, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
164 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_tstbit_i, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
165 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_valignib, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 3, .Align: 0 }} }, |
166 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S2_vspliceib, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 3, .Align: 0 }} }, |
167 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S4_addi_asl_ri, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
168 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S4_addi_lsr_ri, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
169 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S4_andi_asl_ri, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
170 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S4_andi_lsr_ri, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
171 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S4_clbaddi, .Infos: {{ .OpNum: 1, .IsSigned: true , .BitWidth: 6, .Align: 0 }} }, |
172 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S4_clbpaddi, .Infos: {{ .OpNum: 1, .IsSigned: true, .BitWidth: 6, .Align: 0 }} }, |
173 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S4_extract, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 5, .Align: 0 }, |
174 | { .OpNum: 2, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
175 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S4_extractp, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 6, .Align: 0 }, |
176 | { .OpNum: 2, .IsSigned: false, .BitWidth: 6, .Align: 0 }} }, |
177 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S4_lsli, .Infos: {{ .OpNum: 0, .IsSigned: true, .BitWidth: 6, .Align: 0 }} }, |
178 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S4_ntstbit_i, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
179 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S4_ori_asl_ri, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
180 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S4_ori_lsr_ri, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
181 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S4_subi_asl_ri, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
182 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S4_subi_lsr_ri, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
183 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S4_vrcrotate_acc, .Infos: {{ .OpNum: 3, .IsSigned: false, .BitWidth: 2, .Align: 0 }} }, |
184 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S4_vrcrotate, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 2, .Align: 0 }} }, |
185 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S5_asrhub_rnd_sat_goodsyntax, |
186 | .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 4, .Align: 0 }} }, |
187 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S5_asrhub_sat, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 4, .Align: 0 }} }, |
188 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S5_vasrhrnd_goodsyntax, |
189 | .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 4, .Align: 0 }} }, |
190 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S6_rol_i_p, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 6, .Align: 0 }} }, |
191 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_acc, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 6, .Align: 0 }} }, |
192 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_and, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 6, .Align: 0 }} }, |
193 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_nac, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 6, .Align: 0 }} }, |
194 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_or, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 6, .Align: 0 }} }, |
195 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S6_rol_i_p_xacc, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 6, .Align: 0 }} }, |
196 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S6_rol_i_r, .Infos: {{ .OpNum: 1, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
197 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_acc, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
198 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_and, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
199 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_nac, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
200 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_or, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
201 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_S6_rol_i_r_xacc, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 5, .Align: 0 }} }, |
202 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_V6_valignbi, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 3, .Align: 0 }} }, |
203 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_V6_valignbi_128B, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 3, .Align: 0 }} }, |
204 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_V6_vlalignbi, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 3, .Align: 0 }} }, |
205 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_V6_vlalignbi_128B, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 3, .Align: 0 }} }, |
206 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 1, .Align: 0 }} }, |
207 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_128B, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 1, .Align: 0 }} }, |
208 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_acc, .Infos: {{ .OpNum: 3, .IsSigned: false, .BitWidth: 1, .Align: 0 }} }, |
209 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_V6_vrmpybusi_acc_128B, |
210 | .Infos: {{ .OpNum: 3, .IsSigned: false, .BitWidth: 1, .Align: 0 }} }, |
211 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 1, .Align: 0 }} }, |
212 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_128B, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 1, .Align: 0 }} }, |
213 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_acc, .Infos: {{ .OpNum: 3, .IsSigned: false, .BitWidth: 1, .Align: 0 }} }, |
214 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_V6_vrmpyubi_acc_128B, |
215 | .Infos: {{ .OpNum: 3, .IsSigned: false, .BitWidth: 1, .Align: 0 }} }, |
216 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_V6_vrsadubi, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 1, .Align: 0 }} }, |
217 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_128B, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 1, .Align: 0 }} }, |
218 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_acc, .Infos: {{ .OpNum: 3, .IsSigned: false, .BitWidth: 1, .Align: 0 }} }, |
219 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_V6_vrsadubi_acc_128B, |
220 | .Infos: {{ .OpNum: 3, .IsSigned: false, .BitWidth: 1, .Align: 0 }} }, |
221 | |
222 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_V6_v6mpyhubs10, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 2, .Align: 0 }} }, |
223 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_V6_v6mpyhubs10_128B, |
224 | .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 2, .Align: 0 }} }, |
225 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_V6_v6mpyhubs10_vxx, |
226 | .Infos: {{ .OpNum: 3, .IsSigned: false, .BitWidth: 2, .Align: 0 }} }, |
227 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_V6_v6mpyhubs10_vxx_128B, |
228 | .Infos: {{ .OpNum: 3, .IsSigned: false, .BitWidth: 2, .Align: 0 }} }, |
229 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_V6_v6mpyvubs10, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 2, .Align: 0 }} }, |
230 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_V6_v6mpyvubs10_128B, |
231 | .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 2, .Align: 0 }} }, |
232 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_V6_v6mpyvubs10_vxx, |
233 | .Infos: {{ .OpNum: 3, .IsSigned: false, .BitWidth: 2, .Align: 0 }} }, |
234 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_V6_v6mpyvubs10_vxx_128B, |
235 | .Infos: {{ .OpNum: 3, .IsSigned: false, .BitWidth: 2, .Align: 0 }} }, |
236 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_V6_vlutvvbi, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 3, .Align: 0 }} }, |
237 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_V6_vlutvvbi_128B, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 3, .Align: 0 }} }, |
238 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_V6_vlutvvb_oracci, .Infos: {{ .OpNum: 3, .IsSigned: false, .BitWidth: 3, .Align: 0 }} }, |
239 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_V6_vlutvvb_oracci_128B, |
240 | .Infos: {{ .OpNum: 3, .IsSigned: false, .BitWidth: 3, .Align: 0 }} }, |
241 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_V6_vlutvwhi, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 3, .Align: 0 }} }, |
242 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_V6_vlutvwhi_128B, .Infos: {{ .OpNum: 2, .IsSigned: false, .BitWidth: 3, .Align: 0 }} }, |
243 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_V6_vlutvwh_oracci, .Infos: {{ .OpNum: 3, .IsSigned: false, .BitWidth: 3, .Align: 0 }} }, |
244 | { .BuiltinID: Hexagon::BI__builtin_HEXAGON_V6_vlutvwh_oracci_128B, |
245 | .Infos: {{ .OpNum: 3, .IsSigned: false, .BitWidth: 3, .Align: 0 }} }, |
246 | }; |
247 | |
248 | // Use a dynamically initialized static to sort the table exactly once on |
249 | // first run. |
250 | static const bool SortOnce = |
251 | (llvm::sort(C&: Infos, |
252 | Comp: [](const BuiltinInfo &LHS, const BuiltinInfo &RHS) { |
253 | return LHS.BuiltinID < RHS.BuiltinID; |
254 | }), |
255 | true); |
256 | (void)SortOnce; |
257 | |
258 | const BuiltinInfo *F = llvm::partition_point( |
259 | Range&: Infos, P: [=](const BuiltinInfo &BI) { return BI.BuiltinID < BuiltinID; }); |
260 | if (F == std::end(arr&: Infos) || F->BuiltinID != BuiltinID) |
261 | return false; |
262 | |
263 | bool Error = false; |
264 | |
265 | for (const ArgInfo &A : F->Infos) { |
266 | // Ignore empty ArgInfo elements. |
267 | if (A.BitWidth == 0) |
268 | continue; |
269 | |
270 | int32_t Min = A.IsSigned ? -(1 << (A.BitWidth - 1)) : 0; |
271 | int32_t Max = (1 << (A.IsSigned ? A.BitWidth - 1 : A.BitWidth)) - 1; |
272 | if (!A.Align) { |
273 | Error |= SemaRef.BuiltinConstantArgRange(TheCall, ArgNum: A.OpNum, Low: Min, High: Max); |
274 | } else { |
275 | unsigned M = 1 << A.Align; |
276 | Min *= M; |
277 | Max *= M; |
278 | Error |= SemaRef.BuiltinConstantArgRange(TheCall, ArgNum: A.OpNum, Low: Min, High: Max); |
279 | Error |= SemaRef.BuiltinConstantArgMultiple(TheCall, ArgNum: A.OpNum, Multiple: M); |
280 | } |
281 | } |
282 | return Error; |
283 | } |
284 | |
285 | bool SemaHexagon::CheckHexagonBuiltinFunctionCall(unsigned BuiltinID, |
286 | CallExpr *TheCall) { |
287 | return CheckHexagonBuiltinArgument(BuiltinID, TheCall); |
288 | } |
289 | |
290 | } // namespace clang |
291 | |