| 1 |
/* Description of builtins used by the ARM backend. |
| 2 |
Copyright (C) 2014-2025 Free Software Foundation, Inc. |
| 3 |
|
| 4 |
This file is part of GCC. |
| 5 |
|
| 6 |
GCC is free software; you can redistribute it and/or modify it |
| 7 |
under the terms of the GNU General Public License as published |
| 8 |
by the Free Software Foundation; either version 3, or (at your |
| 9 |
option) any later version. |
| 10 |
|
| 11 |
GCC is distributed in the hope that it will be useful, but WITHOUT |
| 12 |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 13 |
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public |
| 14 |
License for more details. |
| 15 |
|
| 16 |
You should have received a copy of the GNU General Public License |
| 17 |
along with GCC; see the file COPYING3. If not see |
| 18 |
<http://www.gnu.org/licenses/>. */ |
| 19 |
|
| 20 |
#define IN_TARGET_CODE 1 |
| 21 |
|
| 22 |
#include "config.h" |
| 23 |
#include "system.h" |
| 24 |
#include "coretypes.h" |
| 25 |
#include "target.h" |
| 26 |
#include "function.h" |
| 27 |
#include "rtl.h" |
| 28 |
#include "tree.h" |
| 29 |
#include "gimple-expr.h" |
| 30 |
#include "memmodel.h" |
| 31 |
#include "tm_p.h" |
| 32 |
#include "profile-count.h" |
| 33 |
#include "optabs.h" |
| 34 |
#include "emit-rtl.h" |
| 35 |
#include "recog.h" |
| 36 |
#include "diagnostic-core.h" |
| 37 |
#include "fold-const.h" |
| 38 |
#include "stor-layout.h" |
| 39 |
#include "explow.h" |
| 40 |
#include "expr.h" |
| 41 |
#include "langhooks.h" |
| 42 |
#include "case-cfn-macros.h" |
| 43 |
#include "sbitmap.h" |
| 44 |
#include "stringpool.h" |
| 45 |
#include "arm-builtins.h" |
| 46 |
#include "stringpool.h" |
| 47 |
#include "attribs.h" |
| 48 |
#include "basic-block.h" |
| 49 |
#include "gimple.h" |
| 50 |
#include "ssa.h" |
| 51 |
|
| 52 |
#define SIMD_MAX_BUILTIN_ARGS 7 |
| 53 |
|
| 54 |
/* The qualifier_internal allows generation of a unary builtin from |
| 55 |
a pattern with a third pseudo-operand such as a match_scratch. |
| 56 |
T (T). */ |
| 57 |
static enum arm_type_qualifiers |
| 58 |
arm_unop_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 59 |
= { qualifier_none, qualifier_none, qualifier_internal }; |
| 60 |
#define UNOP_QUALIFIERS (arm_unop_qualifiers) |
| 61 |
|
| 62 |
/* unsigned T (unsigned T). */ |
| 63 |
static enum arm_type_qualifiers |
| 64 |
arm_bswap_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 65 |
= { qualifier_unsigned, qualifier_unsigned }; |
| 66 |
#define BSWAP_QUALIFIERS (arm_bswap_qualifiers) |
| 67 |
|
| 68 |
/* T (T, T [maybe_immediate]). */ |
| 69 |
static enum arm_type_qualifiers |
| 70 |
arm_binop_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 71 |
= { qualifier_none, qualifier_none, qualifier_maybe_immediate }; |
| 72 |
#define BINOP_QUALIFIERS (arm_binop_qualifiers) |
| 73 |
|
| 74 |
/* T (T, T, T). */ |
| 75 |
static enum arm_type_qualifiers |
| 76 |
arm_ternop_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 77 |
= { qualifier_none, qualifier_none, qualifier_none, qualifier_none }; |
| 78 |
#define TERNOP_QUALIFIERS (arm_ternop_qualifiers) |
| 79 |
|
| 80 |
/* unsigned T (unsigned T, unsigned T, unsigned T). */ |
| 81 |
static enum arm_type_qualifiers |
| 82 |
arm_unsigned_uternop_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 83 |
= { qualifier_unsigned, qualifier_unsigned, qualifier_unsigned, |
| 84 |
qualifier_unsigned }; |
| 85 |
#define UTERNOP_QUALIFIERS (arm_unsigned_uternop_qualifiers) |
| 86 |
|
| 87 |
/* T (T, unsigned T, T). */ |
| 88 |
static enum arm_type_qualifiers |
| 89 |
arm_usternop_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 90 |
= { qualifier_none, qualifier_none, qualifier_unsigned, |
| 91 |
qualifier_none }; |
| 92 |
#define USTERNOP_QUALIFIERS (arm_usternop_qualifiers) |
| 93 |
|
| 94 |
/* T (T, immediate). */ |
| 95 |
static enum arm_type_qualifiers |
| 96 |
arm_binop_imm_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 97 |
= { qualifier_none, qualifier_none, qualifier_immediate }; |
| 98 |
#define BINOP_IMM_QUALIFIERS (arm_binop_imm_qualifiers) |
| 99 |
|
| 100 |
/* T (T, unsigned immediate). */ |
| 101 |
static enum arm_type_qualifiers |
| 102 |
arm_sat_binop_imm_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 103 |
= { qualifier_none, qualifier_none, qualifier_unsigned_immediate }; |
| 104 |
#define SAT_BINOP_UNSIGNED_IMM_QUALIFIERS \ |
| 105 |
(arm_sat_binop_imm_qualifiers) |
| 106 |
|
| 107 |
/* unsigned T (T, unsigned immediate). */ |
| 108 |
static enum arm_type_qualifiers |
| 109 |
arm_unsigned_sat_binop_unsigned_imm_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 110 |
= { qualifier_unsigned, qualifier_none, qualifier_unsigned_immediate }; |
| 111 |
#define UNSIGNED_SAT_BINOP_UNSIGNED_IMM_QUALIFIERS \ |
| 112 |
(arm_unsigned_sat_binop_unsigned_imm_qualifiers) |
| 113 |
|
| 114 |
/* T (T, lane index). */ |
| 115 |
static enum arm_type_qualifiers |
| 116 |
arm_getlane_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 117 |
= { qualifier_none, qualifier_none, qualifier_lane_index }; |
| 118 |
#define GETLANE_QUALIFIERS (arm_getlane_qualifiers) |
| 119 |
|
| 120 |
/* T (T, T, T, immediate). */ |
| 121 |
static enum arm_type_qualifiers |
| 122 |
arm_mac_n_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 123 |
= { qualifier_none, qualifier_none, qualifier_none, |
| 124 |
qualifier_none, qualifier_immediate }; |
| 125 |
#define MAC_N_QUALIFIERS (arm_mac_n_qualifiers) |
| 126 |
|
| 127 |
/* T (T, T, T, lane index). */ |
| 128 |
static enum arm_type_qualifiers |
| 129 |
arm_mac_lane_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 130 |
= { qualifier_none, qualifier_none, qualifier_none, |
| 131 |
qualifier_none, qualifier_lane_index }; |
| 132 |
#define MAC_LANE_QUALIFIERS (arm_mac_lane_qualifiers) |
| 133 |
|
| 134 |
/* T (T, T, T, lane pair index). */ |
| 135 |
static enum arm_type_qualifiers |
| 136 |
arm_mac_lane_pair_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 137 |
= { qualifier_none, qualifier_none, qualifier_none, |
| 138 |
qualifier_none, qualifier_lane_pair_index }; |
| 139 |
#define MAC_LANE_PAIR_QUALIFIERS (arm_mac_lane_pair_qualifiers) |
| 140 |
|
| 141 |
/* unsigned T (unsigned T, unsigned T, unsigend T, lane index). */ |
| 142 |
static enum arm_type_qualifiers |
| 143 |
arm_umac_lane_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 144 |
= { qualifier_unsigned, qualifier_unsigned, qualifier_unsigned, |
| 145 |
qualifier_unsigned, qualifier_lane_index }; |
| 146 |
#define UMAC_LANE_QUALIFIERS (arm_umac_lane_qualifiers) |
| 147 |
|
| 148 |
/* T (T, unsigned T, T, lane index). */ |
| 149 |
static enum arm_type_qualifiers |
| 150 |
arm_usmac_lane_quadtup_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 151 |
= { qualifier_none, qualifier_none, qualifier_unsigned, |
| 152 |
qualifier_none, qualifier_lane_quadtup_index }; |
| 153 |
#define USMAC_LANE_QUADTUP_QUALIFIERS (arm_usmac_lane_quadtup_qualifiers) |
| 154 |
|
| 155 |
/* T (T, T, unsigend T, lane index). */ |
| 156 |
static enum arm_type_qualifiers |
| 157 |
arm_sumac_lane_quadtup_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 158 |
= { qualifier_none, qualifier_none, qualifier_none, |
| 159 |
qualifier_unsigned, qualifier_lane_quadtup_index }; |
| 160 |
#define SUMAC_LANE_QUADTUP_QUALIFIERS (arm_sumac_lane_quadtup_qualifiers) |
| 161 |
|
| 162 |
/* T (T, T, immediate). */ |
| 163 |
static enum arm_type_qualifiers |
| 164 |
arm_ternop_imm_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 165 |
= { qualifier_none, qualifier_none, qualifier_none, qualifier_immediate }; |
| 166 |
#define TERNOP_IMM_QUALIFIERS (arm_ternop_imm_qualifiers) |
| 167 |
|
| 168 |
/* T (T, T, lane index). */ |
| 169 |
static enum arm_type_qualifiers |
| 170 |
arm_setlane_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 171 |
= { qualifier_none, qualifier_none, qualifier_none, qualifier_lane_index }; |
| 172 |
#define SETLANE_QUALIFIERS (arm_setlane_qualifiers) |
| 173 |
|
| 174 |
/* T (T, T). */ |
| 175 |
static enum arm_type_qualifiers |
| 176 |
arm_combine_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 177 |
= { qualifier_none, qualifier_none, qualifier_none }; |
| 178 |
#define COMBINE_QUALIFIERS (arm_combine_qualifiers) |
| 179 |
|
| 180 |
/* T ([T element type] *). */ |
| 181 |
static enum arm_type_qualifiers |
| 182 |
arm_load1_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 183 |
= { qualifier_none, qualifier_const_pointer_map_mode }; |
| 184 |
#define LOAD1_QUALIFIERS (arm_load1_qualifiers) |
| 185 |
|
| 186 |
/* T ([T element type] *, T, immediate). */ |
| 187 |
static enum arm_type_qualifiers |
| 188 |
arm_load1_lane_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 189 |
= { qualifier_none, qualifier_const_pointer_map_mode, |
| 190 |
qualifier_none, qualifier_struct_load_store_lane_index }; |
| 191 |
#define LOAD1LANE_QUALIFIERS (arm_load1_lane_qualifiers) |
| 192 |
|
| 193 |
/* unsigned T (unsigned T, unsigned T, unsigned T). */ |
| 194 |
static enum arm_type_qualifiers |
| 195 |
arm_unsigned_binop_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 196 |
= { qualifier_unsigned, qualifier_unsigned, qualifier_unsigned, |
| 197 |
qualifier_unsigned }; |
| 198 |
#define UBINOP_QUALIFIERS (arm_unsigned_binop_qualifiers) |
| 199 |
|
| 200 |
/* void (unsigned immediate, unsigned immediate, unsigned immediate, |
| 201 |
unsigned immediate, unsigned immediate, unsigned immediate). */ |
| 202 |
static enum arm_type_qualifiers |
| 203 |
arm_cdp_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 204 |
= { qualifier_void, qualifier_unsigned_immediate, |
| 205 |
qualifier_unsigned_immediate, |
| 206 |
qualifier_unsigned_immediate, |
| 207 |
qualifier_unsigned_immediate, |
| 208 |
qualifier_unsigned_immediate, |
| 209 |
qualifier_unsigned_immediate }; |
| 210 |
#define CDP_QUALIFIERS \ |
| 211 |
(arm_cdp_qualifiers) |
| 212 |
|
| 213 |
/* void (unsigned immediate, unsigned immediate, const void *). */ |
| 214 |
static enum arm_type_qualifiers |
| 215 |
arm_ldc_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 216 |
= { qualifier_void, qualifier_unsigned_immediate, |
| 217 |
qualifier_unsigned_immediate, qualifier_const_void_pointer }; |
| 218 |
#define LDC_QUALIFIERS \ |
| 219 |
(arm_ldc_qualifiers) |
| 220 |
|
| 221 |
/* void (unsigned immediate, unsigned immediate, void *). */ |
| 222 |
static enum arm_type_qualifiers |
| 223 |
arm_stc_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 224 |
= { qualifier_void, qualifier_unsigned_immediate, |
| 225 |
qualifier_unsigned_immediate, qualifier_void_pointer }; |
| 226 |
#define STC_QUALIFIERS \ |
| 227 |
(arm_stc_qualifiers) |
| 228 |
|
| 229 |
/* void (unsigned immediate, unsigned immediate, T, unsigned immediate, |
| 230 |
unsigned immediate, unsigned immediate). */ |
| 231 |
static enum arm_type_qualifiers |
| 232 |
arm_mcr_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 233 |
= { qualifier_void, qualifier_unsigned_immediate, |
| 234 |
qualifier_unsigned_immediate, qualifier_none, |
| 235 |
qualifier_unsigned_immediate, qualifier_unsigned_immediate, |
| 236 |
qualifier_unsigned_immediate }; |
| 237 |
#define MCR_QUALIFIERS \ |
| 238 |
(arm_mcr_qualifiers) |
| 239 |
|
| 240 |
/* T (unsigned immediate, unsigned immediate, unsigned immediate, |
| 241 |
unsigned immediate, unsigned immediate). */ |
| 242 |
static enum arm_type_qualifiers |
| 243 |
arm_mrc_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 244 |
= { qualifier_none, qualifier_unsigned_immediate, |
| 245 |
qualifier_unsigned_immediate, qualifier_unsigned_immediate, |
| 246 |
qualifier_unsigned_immediate, qualifier_unsigned_immediate }; |
| 247 |
#define MRC_QUALIFIERS \ |
| 248 |
(arm_mrc_qualifiers) |
| 249 |
|
| 250 |
/* void (unsigned immediate, unsigned immediate, T, unsigned immediate). */ |
| 251 |
static enum arm_type_qualifiers |
| 252 |
arm_mcrr_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 253 |
= { qualifier_void, qualifier_unsigned_immediate, |
| 254 |
qualifier_unsigned_immediate, qualifier_none, |
| 255 |
qualifier_unsigned_immediate }; |
| 256 |
#define MCRR_QUALIFIERS \ |
| 257 |
(arm_mcrr_qualifiers) |
| 258 |
|
| 259 |
/* T (unsigned immediate, unsigned immediate, unsigned immediate). */ |
| 260 |
static enum arm_type_qualifiers |
| 261 |
arm_mrrc_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 262 |
= { qualifier_none, qualifier_unsigned_immediate, |
| 263 |
qualifier_unsigned_immediate, qualifier_unsigned_immediate }; |
| 264 |
#define MRRC_QUALIFIERS \ |
| 265 |
(arm_mrrc_qualifiers) |
| 266 |
|
| 267 |
/* T (immediate, unsigned immediate). */ |
| 268 |
static enum arm_type_qualifiers |
| 269 |
arm_cx_imm_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 270 |
= { qualifier_none, qualifier_immediate, qualifier_unsigned_immediate }; |
| 271 |
#define CX_IMM_QUALIFIERS (arm_cx_imm_qualifiers) |
| 272 |
|
| 273 |
/* T (immediate, T, unsigned immediate). */ |
| 274 |
static enum arm_type_qualifiers |
| 275 |
arm_cx_unary_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 276 |
= { qualifier_none, qualifier_immediate, qualifier_none, |
| 277 |
qualifier_unsigned_immediate }; |
| 278 |
#define CX_UNARY_QUALIFIERS (arm_cx_unary_qualifiers) |
| 279 |
|
| 280 |
/* T (immediate, T, T, unsigned immediate). */ |
| 281 |
static enum arm_type_qualifiers |
| 282 |
arm_cx_binary_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 283 |
= { qualifier_none, qualifier_immediate, |
| 284 |
qualifier_none, qualifier_none, |
| 285 |
qualifier_unsigned_immediate }; |
| 286 |
#define CX_BINARY_QUALIFIERS (arm_cx_binary_qualifiers) |
| 287 |
|
| 288 |
/* T (immediate, T, T, T, unsigned immediate). */ |
| 289 |
static enum arm_type_qualifiers |
| 290 |
arm_cx_ternary_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 291 |
= { qualifier_none, qualifier_immediate, |
| 292 |
qualifier_none, qualifier_none, qualifier_none, |
| 293 |
qualifier_unsigned_immediate }; |
| 294 |
#define CX_TERNARY_QUALIFIERS (arm_cx_ternary_qualifiers) |
| 295 |
|
| 296 |
/* T (immediate, T, unsigned immediate). */ |
| 297 |
static enum arm_type_qualifiers |
| 298 |
arm_cx_unary_unone_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 299 |
= { qualifier_none, qualifier_immediate, qualifier_none, |
| 300 |
qualifier_unsigned_immediate, |
| 301 |
qualifier_predicate }; |
| 302 |
#define CX_UNARY_UNONE_QUALIFIERS (arm_cx_unary_unone_qualifiers) |
| 303 |
|
| 304 |
/* T (immediate, T, T, unsigned immediate). */ |
| 305 |
static enum arm_type_qualifiers |
| 306 |
arm_cx_binary_unone_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 307 |
= { qualifier_none, qualifier_immediate, |
| 308 |
qualifier_none, qualifier_none, |
| 309 |
qualifier_unsigned_immediate, |
| 310 |
qualifier_predicate }; |
| 311 |
#define CX_BINARY_UNONE_QUALIFIERS (arm_cx_binary_unone_qualifiers) |
| 312 |
|
| 313 |
/* T (immediate, T, T, T, unsigned immediate). */ |
| 314 |
static enum arm_type_qualifiers |
| 315 |
arm_cx_ternary_unone_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 316 |
= { qualifier_none, qualifier_immediate, |
| 317 |
qualifier_none, qualifier_none, qualifier_none, |
| 318 |
qualifier_unsigned_immediate, |
| 319 |
qualifier_predicate }; |
| 320 |
#define CX_TERNARY_UNONE_QUALIFIERS (arm_cx_ternary_unone_qualifiers) |
| 321 |
|
| 322 |
/* The first argument (return type) of a store should be void type, |
| 323 |
which we represent with qualifier_void. Their first operand will be |
| 324 |
a DImode pointer to the location to store to, so we must use |
| 325 |
qualifier_map_mode | qualifier_pointer to build a pointer to the |
| 326 |
element type of the vector. |
| 327 |
|
| 328 |
void ([T element type] *, T). */ |
| 329 |
static enum arm_type_qualifiers |
| 330 |
arm_store1_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 331 |
= { qualifier_void, qualifier_pointer_map_mode, qualifier_none }; |
| 332 |
#define STORE1_QUALIFIERS (arm_store1_qualifiers) |
| 333 |
|
| 334 |
/* Qualifiers for MVE builtins. */ |
| 335 |
|
| 336 |
static enum arm_type_qualifiers |
| 337 |
arm_unop_none_none_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 338 |
= { qualifier_none, qualifier_none }; |
| 339 |
#define UNOP_NONE_NONE_QUALIFIERS \ |
| 340 |
(arm_unop_none_none_qualifiers) |
| 341 |
|
| 342 |
static enum arm_type_qualifiers |
| 343 |
arm_unop_none_snone_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 344 |
= { qualifier_none, qualifier_none }; |
| 345 |
#define UNOP_NONE_SNONE_QUALIFIERS \ |
| 346 |
(arm_unop_none_snone_qualifiers) |
| 347 |
|
| 348 |
static enum arm_type_qualifiers |
| 349 |
arm_unop_none_unone_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 350 |
= { qualifier_none, qualifier_unsigned }; |
| 351 |
#define UNOP_NONE_UNONE_QUALIFIERS \ |
| 352 |
(arm_unop_none_unone_qualifiers) |
| 353 |
|
| 354 |
static enum arm_type_qualifiers |
| 355 |
arm_unop_snone_snone_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 356 |
= { qualifier_none, qualifier_none }; |
| 357 |
#define UNOP_SNONE_SNONE_QUALIFIERS \ |
| 358 |
(arm_unop_snone_snone_qualifiers) |
| 359 |
|
| 360 |
static enum arm_type_qualifiers |
| 361 |
arm_unop_snone_none_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 362 |
= { qualifier_none, qualifier_none }; |
| 363 |
#define UNOP_SNONE_NONE_QUALIFIERS \ |
| 364 |
(arm_unop_snone_none_qualifiers) |
| 365 |
|
| 366 |
static enum arm_type_qualifiers |
| 367 |
arm_unop_snone_imm_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 368 |
= { qualifier_none, qualifier_immediate }; |
| 369 |
#define UNOP_SNONE_IMM_QUALIFIERS \ |
| 370 |
(arm_unop_snone_imm_qualifiers) |
| 371 |
|
| 372 |
static enum arm_type_qualifiers |
| 373 |
arm_unop_unone_none_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 374 |
= { qualifier_unsigned, qualifier_none }; |
| 375 |
#define UNOP_UNONE_NONE_QUALIFIERS \ |
| 376 |
(arm_unop_unone_none_qualifiers) |
| 377 |
|
| 378 |
static enum arm_type_qualifiers |
| 379 |
arm_unop_unone_unone_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 380 |
= { qualifier_unsigned, qualifier_unsigned }; |
| 381 |
#define UNOP_UNONE_UNONE_QUALIFIERS \ |
| 382 |
(arm_unop_unone_unone_qualifiers) |
| 383 |
|
| 384 |
static enum arm_type_qualifiers |
| 385 |
arm_unop_unone_imm_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 386 |
= { qualifier_unsigned, qualifier_immediate }; |
| 387 |
#define UNOP_UNONE_IMM_QUALIFIERS \ |
| 388 |
(arm_unop_unone_imm_qualifiers) |
| 389 |
|
| 390 |
static enum arm_type_qualifiers |
| 391 |
arm_unop_pred_unone_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 392 |
= { qualifier_predicate, qualifier_unsigned }; |
| 393 |
#define UNOP_PRED_UNONE_QUALIFIERS \ |
| 394 |
(arm_unop_pred_unone_qualifiers) |
| 395 |
|
| 396 |
static enum arm_type_qualifiers |
| 397 |
arm_unop_pred_pred_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 398 |
= { qualifier_predicate, qualifier_predicate }; |
| 399 |
#define UNOP_PRED_PRED_QUALIFIERS \ |
| 400 |
(arm_unop_pred_pred_qualifiers) |
| 401 |
|
| 402 |
|
| 403 |
static enum arm_type_qualifiers |
| 404 |
arm_binop_none_none_none_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 405 |
= { qualifier_none, qualifier_none, qualifier_none }; |
| 406 |
#define BINOP_NONE_NONE_NONE_QUALIFIERS \ |
| 407 |
(arm_binop_none_none_none_qualifiers) |
| 408 |
|
| 409 |
static enum arm_type_qualifiers |
| 410 |
arm_binop_none_none_imm_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 411 |
= { qualifier_none, qualifier_none, qualifier_immediate }; |
| 412 |
#define BINOP_NONE_NONE_IMM_QUALIFIERS \ |
| 413 |
(arm_binop_none_none_imm_qualifiers) |
| 414 |
|
| 415 |
static enum arm_type_qualifiers |
| 416 |
arm_binop_none_unone_imm_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 417 |
= { qualifier_none, qualifier_unsigned, qualifier_immediate }; |
| 418 |
#define BINOP_NONE_UNONE_IMM_QUALIFIERS \ |
| 419 |
(arm_binop_none_unone_imm_qualifiers) |
| 420 |
|
| 421 |
static enum arm_type_qualifiers |
| 422 |
arm_binop_none_unone_unone_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 423 |
= { qualifier_none, qualifier_unsigned, qualifier_unsigned }; |
| 424 |
#define BINOP_NONE_UNONE_UNONE_QUALIFIERS \ |
| 425 |
(arm_binop_none_unone_unone_qualifiers) |
| 426 |
|
| 427 |
static enum arm_type_qualifiers |
| 428 |
arm_binop_unone_unone_imm_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 429 |
= { qualifier_unsigned, qualifier_unsigned, qualifier_immediate }; |
| 430 |
#define BINOP_UNONE_UNONE_IMM_QUALIFIERS \ |
| 431 |
(arm_binop_unone_unone_imm_qualifiers) |
| 432 |
|
| 433 |
static enum arm_type_qualifiers |
| 434 |
arm_binop_unone_unone_unone_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 435 |
= { qualifier_unsigned, qualifier_unsigned, qualifier_unsigned }; |
| 436 |
#define BINOP_UNONE_UNONE_UNONE_QUALIFIERS \ |
| 437 |
(arm_binop_unone_unone_unone_qualifiers) |
| 438 |
|
| 439 |
static enum arm_type_qualifiers |
| 440 |
arm_binop_pred_unone_unone_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 441 |
= { qualifier_predicate, qualifier_unsigned, qualifier_unsigned }; |
| 442 |
#define BINOP_PRED_UNONE_UNONE_QUALIFIERS \ |
| 443 |
(arm_binop_pred_unone_unone_qualifiers) |
| 444 |
|
| 445 |
static enum arm_type_qualifiers |
| 446 |
arm_binop_pred_unone_pred_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 447 |
= { qualifier_predicate, qualifier_unsigned, qualifier_predicate }; |
| 448 |
#define BINOP_PRED_UNONE_PRED_QUALIFIERS \ |
| 449 |
(arm_binop_pred_unone_pred_qualifiers) |
| 450 |
|
| 451 |
static enum arm_type_qualifiers |
| 452 |
arm_binop_unone_none_imm_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 453 |
= { qualifier_unsigned, qualifier_none, qualifier_immediate }; |
| 454 |
#define BINOP_UNONE_NONE_IMM_QUALIFIERS \ |
| 455 |
(arm_binop_unone_none_imm_qualifiers) |
| 456 |
|
| 457 |
static enum arm_type_qualifiers |
| 458 |
arm_binop_pred_none_none_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 459 |
= { qualifier_predicate, qualifier_none, qualifier_none }; |
| 460 |
#define BINOP_PRED_NONE_NONE_QUALIFIERS \ |
| 461 |
(arm_binop_pred_none_none_qualifiers) |
| 462 |
|
| 463 |
static enum arm_type_qualifiers |
| 464 |
arm_binop_unone_unone_none_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 465 |
= { qualifier_unsigned, qualifier_unsigned, qualifier_none }; |
| 466 |
#define BINOP_UNONE_UNONE_NONE_QUALIFIERS \ |
| 467 |
(arm_binop_unone_unone_none_qualifiers) |
| 468 |
|
| 469 |
static enum arm_type_qualifiers |
| 470 |
arm_ternop_unone_unone_unone_imm_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 471 |
= { qualifier_unsigned, qualifier_unsigned, qualifier_unsigned, |
| 472 |
qualifier_immediate }; |
| 473 |
#define TERNOP_UNONE_UNONE_UNONE_IMM_QUALIFIERS \ |
| 474 |
(arm_ternop_unone_unone_unone_imm_qualifiers) |
| 475 |
|
| 476 |
static enum arm_type_qualifiers |
| 477 |
arm_ternop_unone_unone_none_none_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 478 |
= { qualifier_unsigned, qualifier_unsigned, qualifier_none, qualifier_none }; |
| 479 |
#define TERNOP_UNONE_UNONE_NONE_NONE_QUALIFIERS \ |
| 480 |
(arm_ternop_unone_unone_none_none_qualifiers) |
| 481 |
|
| 482 |
static enum arm_type_qualifiers |
| 483 |
arm_ternop_unone_unone_none_imm_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 484 |
= { qualifier_unsigned, qualifier_unsigned, qualifier_none, |
| 485 |
qualifier_immediate }; |
| 486 |
#define TERNOP_UNONE_UNONE_NONE_IMM_QUALIFIERS \ |
| 487 |
(arm_ternop_unone_unone_none_imm_qualifiers) |
| 488 |
|
| 489 |
static enum arm_type_qualifiers |
| 490 |
arm_ternop_unone_unone_none_pred_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 491 |
= { qualifier_unsigned, qualifier_unsigned, qualifier_none, |
| 492 |
qualifier_predicate }; |
| 493 |
#define TERNOP_UNONE_UNONE_NONE_PRED_QUALIFIERS \ |
| 494 |
(arm_ternop_unone_unone_none_pred_qualifiers) |
| 495 |
|
| 496 |
static enum arm_type_qualifiers |
| 497 |
arm_ternop_unone_unone_imm_pred_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 498 |
= { qualifier_unsigned, qualifier_unsigned, qualifier_immediate, |
| 499 |
qualifier_predicate }; |
| 500 |
#define TERNOP_UNONE_UNONE_IMM_PRED_QUALIFIERS \ |
| 501 |
(arm_ternop_unone_unone_imm_pred_qualifiers) |
| 502 |
|
| 503 |
static enum arm_type_qualifiers |
| 504 |
arm_ternop_pred_none_none_pred_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 505 |
= { qualifier_predicate, qualifier_none, qualifier_none, qualifier_predicate }; |
| 506 |
#define TERNOP_PRED_NONE_NONE_PRED_QUALIFIERS \ |
| 507 |
(arm_ternop_pred_none_none_pred_qualifiers) |
| 508 |
|
| 509 |
static enum arm_type_qualifiers |
| 510 |
arm_ternop_none_none_none_imm_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 511 |
= { qualifier_none, qualifier_none, qualifier_none, qualifier_immediate }; |
| 512 |
#define TERNOP_NONE_NONE_NONE_IMM_QUALIFIERS \ |
| 513 |
(arm_ternop_none_none_none_imm_qualifiers) |
| 514 |
|
| 515 |
static enum arm_type_qualifiers |
| 516 |
arm_ternop_none_none_none_pred_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 517 |
= { qualifier_none, qualifier_none, qualifier_none, qualifier_predicate }; |
| 518 |
#define TERNOP_NONE_NONE_NONE_PRED_QUALIFIERS \ |
| 519 |
(arm_ternop_none_none_none_pred_qualifiers) |
| 520 |
|
| 521 |
static enum arm_type_qualifiers |
| 522 |
arm_ternop_none_none_imm_pred_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 523 |
= { qualifier_none, qualifier_none, qualifier_immediate, qualifier_predicate }; |
| 524 |
#define TERNOP_NONE_NONE_IMM_PRED_QUALIFIERS \ |
| 525 |
(arm_ternop_none_none_imm_pred_qualifiers) |
| 526 |
|
| 527 |
static enum arm_type_qualifiers |
| 528 |
arm_ternop_none_none_unone_pred_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 529 |
= { qualifier_none, qualifier_none, qualifier_unsigned, qualifier_predicate }; |
| 530 |
#define TERNOP_NONE_NONE_UNONE_PRED_QUALIFIERS \ |
| 531 |
(arm_ternop_none_none_unone_pred_qualifiers) |
| 532 |
|
| 533 |
static enum arm_type_qualifiers |
| 534 |
arm_ternop_unone_unone_unone_unone_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 535 |
= { qualifier_unsigned, qualifier_unsigned, qualifier_unsigned, |
| 536 |
qualifier_unsigned }; |
| 537 |
#define TERNOP_UNONE_UNONE_UNONE_UNONE_QUALIFIERS \ |
| 538 |
(arm_ternop_unone_unone_unone_unone_qualifiers) |
| 539 |
|
| 540 |
static enum arm_type_qualifiers |
| 541 |
arm_ternop_unone_unone_unone_pred_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 542 |
= { qualifier_unsigned, qualifier_unsigned, qualifier_unsigned, |
| 543 |
qualifier_predicate }; |
| 544 |
#define TERNOP_UNONE_UNONE_UNONE_PRED_QUALIFIERS \ |
| 545 |
(arm_ternop_unone_unone_unone_pred_qualifiers) |
| 546 |
|
| 547 |
static enum arm_type_qualifiers |
| 548 |
arm_ternop_pred_unone_unone_pred_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 549 |
= { qualifier_predicate, qualifier_unsigned, qualifier_unsigned, |
| 550 |
qualifier_predicate }; |
| 551 |
#define TERNOP_PRED_UNONE_UNONE_PRED_QUALIFIERS \ |
| 552 |
(arm_ternop_pred_unone_unone_pred_qualifiers) |
| 553 |
|
| 554 |
static enum arm_type_qualifiers |
| 555 |
arm_ternop_none_none_none_none_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 556 |
= { qualifier_none, qualifier_none, qualifier_none, qualifier_none }; |
| 557 |
#define TERNOP_NONE_NONE_NONE_NONE_QUALIFIERS \ |
| 558 |
(arm_ternop_none_none_none_none_qualifiers) |
| 559 |
|
| 560 |
static enum arm_type_qualifiers |
| 561 |
arm_quadop_unone_unone_none_none_pred_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 562 |
= { qualifier_unsigned, qualifier_unsigned, qualifier_none, qualifier_none, |
| 563 |
qualifier_predicate }; |
| 564 |
#define QUADOP_UNONE_UNONE_NONE_NONE_PRED_QUALIFIERS \ |
| 565 |
(arm_quadop_unone_unone_none_none_pred_qualifiers) |
| 566 |
|
| 567 |
static enum arm_type_qualifiers |
| 568 |
arm_quadop_none_none_none_none_pred_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 569 |
= { qualifier_none, qualifier_none, qualifier_none, qualifier_none, |
| 570 |
qualifier_predicate }; |
| 571 |
#define QUADOP_NONE_NONE_NONE_NONE_PRED_QUALIFIERS \ |
| 572 |
(arm_quadop_none_none_none_none_pred_qualifiers) |
| 573 |
|
| 574 |
static enum arm_type_qualifiers |
| 575 |
arm_quadop_none_none_none_imm_pred_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 576 |
= { qualifier_none, qualifier_none, qualifier_none, qualifier_immediate, |
| 577 |
qualifier_predicate }; |
| 578 |
#define QUADOP_NONE_NONE_NONE_IMM_PRED_QUALIFIERS \ |
| 579 |
(arm_quadop_none_none_none_imm_pred_qualifiers) |
| 580 |
|
| 581 |
static enum arm_type_qualifiers |
| 582 |
arm_quadop_unone_unone_unone_unone_pred_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 583 |
= { qualifier_unsigned, qualifier_unsigned, qualifier_unsigned, |
| 584 |
qualifier_unsigned, qualifier_predicate }; |
| 585 |
#define QUADOP_UNONE_UNONE_UNONE_UNONE_PRED_QUALIFIERS \ |
| 586 |
(arm_quadop_unone_unone_unone_unone_pred_qualifiers) |
| 587 |
|
| 588 |
static enum arm_type_qualifiers |
| 589 |
arm_quadop_unone_unone_none_imm_pred_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 590 |
= { qualifier_unsigned, qualifier_unsigned, qualifier_none, |
| 591 |
qualifier_immediate, qualifier_predicate }; |
| 592 |
#define QUADOP_UNONE_UNONE_NONE_IMM_PRED_QUALIFIERS \ |
| 593 |
(arm_quadop_unone_unone_none_imm_pred_qualifiers) |
| 594 |
|
| 595 |
static enum arm_type_qualifiers |
| 596 |
arm_quadop_none_none_unone_imm_pred_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 597 |
= { qualifier_none, qualifier_none, qualifier_unsigned, qualifier_immediate, |
| 598 |
qualifier_predicate }; |
| 599 |
#define QUADOP_NONE_NONE_UNONE_IMM_PRED_QUALIFIERS \ |
| 600 |
(arm_quadop_none_none_unone_imm_pred_qualifiers) |
| 601 |
|
| 602 |
static enum arm_type_qualifiers |
| 603 |
arm_quadop_unone_unone_unone_imm_pred_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 604 |
= { qualifier_unsigned, qualifier_unsigned, qualifier_unsigned, |
| 605 |
qualifier_immediate, qualifier_predicate }; |
| 606 |
#define QUADOP_UNONE_UNONE_UNONE_IMM_PRED_QUALIFIERS \ |
| 607 |
(arm_quadop_unone_unone_unone_imm_pred_qualifiers) |
| 608 |
|
| 609 |
static enum arm_type_qualifiers |
| 610 |
arm_quadop_unone_unone_unone_none_pred_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 611 |
= { qualifier_unsigned, qualifier_unsigned, qualifier_unsigned, |
| 612 |
qualifier_none, qualifier_predicate }; |
| 613 |
#define QUADOP_UNONE_UNONE_UNONE_NONE_PRED_QUALIFIERS \ |
| 614 |
(arm_quadop_unone_unone_unone_none_pred_qualifiers) |
| 615 |
|
| 616 |
static enum arm_type_qualifiers |
| 617 |
arm_lsll_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 618 |
= { qualifier_unsigned, qualifier_unsigned, qualifier_none}; |
| 619 |
#define LSLL_QUALIFIERS (arm_lsll_qualifiers) |
| 620 |
|
| 621 |
static enum arm_type_qualifiers |
| 622 |
arm_uqshl_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 623 |
= { qualifier_unsigned, qualifier_unsigned, qualifier_const}; |
| 624 |
#define UQSHL_QUALIFIERS (arm_uqshl_qualifiers) |
| 625 |
|
| 626 |
static enum arm_type_qualifiers |
| 627 |
arm_asrl_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 628 |
= { qualifier_none, qualifier_none, qualifier_none}; |
| 629 |
#define ASRL_QUALIFIERS (arm_asrl_qualifiers) |
| 630 |
|
| 631 |
static enum arm_type_qualifiers |
| 632 |
arm_sqshl_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 633 |
= { qualifier_unsigned, qualifier_unsigned, qualifier_const}; |
| 634 |
#define SQSHL_QUALIFIERS (arm_sqshl_qualifiers) |
| 635 |
|
| 636 |
static enum arm_type_qualifiers |
| 637 |
arm_binop_none_none_pred_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 638 |
= { qualifier_none, qualifier_none, qualifier_predicate }; |
| 639 |
#define BINOP_NONE_NONE_PRED_QUALIFIERS \ |
| 640 |
(arm_binop_none_none_pred_qualifiers) |
| 641 |
|
| 642 |
static enum arm_type_qualifiers |
| 643 |
arm_binop_unone_unone_pred_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 644 |
= { qualifier_unsigned, qualifier_unsigned, qualifier_predicate }; |
| 645 |
#define BINOP_UNONE_UNONE_PRED_QUALIFIERS \ |
| 646 |
(arm_binop_unone_unone_pred_qualifiers) |
| 647 |
|
| 648 |
/* End of Qualifier for MVE builtins. */ |
| 649 |
|
| 650 |
/* void ([T element type] *, T, immediate). */ |
| 651 |
static enum arm_type_qualifiers |
| 652 |
arm_storestruct_lane_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 653 |
= { qualifier_void, qualifier_pointer_map_mode, |
| 654 |
qualifier_none, qualifier_struct_load_store_lane_index }; |
| 655 |
#define STORE1LANE_QUALIFIERS (arm_storestruct_lane_qualifiers) |
| 656 |
|
| 657 |
/* int (void). */ |
| 658 |
static enum arm_type_qualifiers |
| 659 |
arm_sat_occurred_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 660 |
= { qualifier_none, qualifier_void }; |
| 661 |
#define SAT_OCCURRED_QUALIFIERS (arm_sat_occurred_qualifiers) |
| 662 |
|
| 663 |
/* void (int). */ |
| 664 |
static enum arm_type_qualifiers |
| 665 |
arm_set_sat_qualifiers[SIMD_MAX_BUILTIN_ARGS] |
| 666 |
= { qualifier_void, qualifier_none }; |
| 667 |
#define SET_SAT_QUALIFIERS (arm_set_sat_qualifiers) |
| 668 |
|
| 669 |
#define v2qi_UP E_V2QImode |
| 670 |
#define v4bi_UP E_V4BImode |
| 671 |
#define v8bi_UP E_V8BImode |
| 672 |
#define v16bi_UP E_V16BImode |
| 673 |
#define v8qi_UP E_V8QImode |
| 674 |
#define v4hi_UP E_V4HImode |
| 675 |
#define v4hf_UP E_V4HFmode |
| 676 |
#define v4bf_UP E_V4BFmode |
| 677 |
#define v2si_UP E_V2SImode |
| 678 |
#define v2sf_UP E_V2SFmode |
| 679 |
#define v2bf_UP E_V2BFmode |
| 680 |
#define di_UP E_DImode |
| 681 |
#define v16qi_UP E_V16QImode |
| 682 |
#define v8hi_UP E_V8HImode |
| 683 |
#define v8hf_UP E_V8HFmode |
| 684 |
#define v8bf_UP E_V8BFmode |
| 685 |
#define v4si_UP E_V4SImode |
| 686 |
#define v4sf_UP E_V4SFmode |
| 687 |
#define v2di_UP E_V2DImode |
| 688 |
#define ti_UP E_TImode |
| 689 |
#define ei_UP E_EImode |
| 690 |
#define oi_UP E_OImode |
| 691 |
#define hf_UP E_HFmode |
| 692 |
#define bf_UP E_BFmode |
| 693 |
#define si_UP E_SImode |
| 694 |
#define hi_UP E_HImode |
| 695 |
#define void_UP E_VOIDmode |
| 696 |
#define sf_UP E_SFmode |
| 697 |
#define UP(X) X##_UP |
| 698 |
|
| 699 |
typedef struct { |
| 700 |
const char *name; |
| 701 |
machine_mode mode; |
| 702 |
const enum insn_code code; |
| 703 |
unsigned int fcode; |
| 704 |
enum arm_type_qualifiers *qualifiers; |
| 705 |
} arm_builtin_datum; |
| 706 |
|
| 707 |
constexpr insn_code CODE_FOR_neon_sdotv8qi = CODE_FOR_neon_sdotv2siv8qi; |
| 708 |
constexpr insn_code CODE_FOR_neon_udotv8qi = CODE_FOR_neon_udotv2siv8qi; |
| 709 |
constexpr insn_code CODE_FOR_neon_usdotv8qi = CODE_FOR_neon_usdotv2siv8qi; |
| 710 |
constexpr insn_code CODE_FOR_neon_sdotv16qi = CODE_FOR_neon_sdotv4siv16qi; |
| 711 |
constexpr insn_code CODE_FOR_neon_udotv16qi = CODE_FOR_neon_udotv4siv16qi; |
| 712 |
constexpr insn_code CODE_FOR_neon_usdotv16qi = CODE_FOR_neon_usdotv4siv16qi; |
| 713 |
|
| 714 |
#define CF(N,X) CODE_FOR_neon_##N##X |
| 715 |
|
| 716 |
#define VAR1(T, N, A) \ |
| 717 |
{#N #A, UP (A), CF (N, A), 0, T##_QUALIFIERS}, |
| 718 |
#define VAR2(T, N, A, B) \ |
| 719 |
VAR1 (T, N, A) \ |
| 720 |
VAR1 (T, N, B) |
| 721 |
#define VAR3(T, N, A, B, C) \ |
| 722 |
VAR2 (T, N, A, B) \ |
| 723 |
VAR1 (T, N, C) |
| 724 |
#define VAR4(T, N, A, B, C, D) \ |
| 725 |
VAR3 (T, N, A, B, C) \ |
| 726 |
VAR1 (T, N, D) |
| 727 |
#define VAR5(T, N, A, B, C, D, E) \ |
| 728 |
VAR4 (T, N, A, B, C, D) \ |
| 729 |
VAR1 (T, N, E) |
| 730 |
#define VAR6(T, N, A, B, C, D, E, F) \ |
| 731 |
VAR5 (T, N, A, B, C, D, E) \ |
| 732 |
VAR1 (T, N, F) |
| 733 |
#define VAR7(T, N, A, B, C, D, E, F, G) \ |
| 734 |
VAR6 (T, N, A, B, C, D, E, F) \ |
| 735 |
VAR1 (T, N, G) |
| 736 |
#define VAR8(T, N, A, B, C, D, E, F, G, H) \ |
| 737 |
VAR7 (T, N, A, B, C, D, E, F, G) \ |
| 738 |
VAR1 (T, N, H) |
| 739 |
#define VAR9(T, N, A, B, C, D, E, F, G, H, I) \ |
| 740 |
VAR8 (T, N, A, B, C, D, E, F, G, H) \ |
| 741 |
VAR1 (T, N, I) |
| 742 |
#define VAR10(T, N, A, B, C, D, E, F, G, H, I, J) \ |
| 743 |
VAR9 (T, N, A, B, C, D, E, F, G, H, I) \ |
| 744 |
VAR1 (T, N, J) |
| 745 |
#define VAR11(T, N, A, B, C, D, E, F, G, H, I, J, K) \ |
| 746 |
VAR10 (T, N, A, B, C, D, E, F, G, H, I, J) \ |
| 747 |
VAR1 (T, N, K) |
| 748 |
#define VAR12(T, N, A, B, C, D, E, F, G, H, I, J, K, L) \ |
| 749 |
VAR11 (T, N, A, B, C, D, E, F, G, H, I, J, K) \ |
| 750 |
VAR1 (T, N, L) |
| 751 |
#define VAR13(T, N, A, B, C, D, E, F, G, H, I, J, K, L, M) \ |
| 752 |
VAR12 (T, N, A, B, C, D, E, F, G, H, I, J, K, L) \ |
| 753 |
VAR1 (T, N, M) |
| 754 |
#define VAR14(T, N, A, B, C, D, E, F, G, H, I, J, K, L, M, O) \ |
| 755 |
VAR13 (T, N, A, B, C, D, E, F, G, H, I, J, K, L, M) \ |
| 756 |
VAR1 (T, N, O) |
| 757 |
|
| 758 |
/* The builtin data can be found in arm_neon_builtins.def, arm_vfp_builtins.def |
| 759 |
and arm_acle_builtins.def. The entries in arm_neon_builtins.def require |
| 760 |
TARGET_NEON to be true. The feature tests are checked when the builtins are |
| 761 |
expanded. |
| 762 |
|
| 763 |
The mode entries in the following table correspond to the "key" type of the |
| 764 |
instruction variant, i.e. equivalent to that which would be specified after |
| 765 |
the assembler mnemonic for neon instructions, which usually refers to the |
| 766 |
last vector operand. The modes listed per instruction should be the same as |
| 767 |
those defined for that instruction's pattern, for instance in neon.md. */ |
| 768 |
|
| 769 |
static arm_builtin_datum vfp_builtin_data[] = |
| 770 |
{ |
| 771 |
#include "arm_vfp_builtins.def" |
| 772 |
}; |
| 773 |
|
| 774 |
static arm_builtin_datum neon_builtin_data[] = |
| 775 |
{ |
| 776 |
#include "arm_neon_builtins.def" |
| 777 |
}; |
| 778 |
|
| 779 |
#undef CF |
| 780 |
#define CF(N,X) CODE_FOR_mve_##N##X |
| 781 |
static arm_builtin_datum mve_builtin_data[] = |
| 782 |
{ |
| 783 |
#include "arm_mve_builtins.def" |
| 784 |
}; |
| 785 |
|
| 786 |
#undef CF |
| 787 |
#undef VAR1 |
| 788 |
#define VAR1(T, N, A) \ |
| 789 |
{#N, UP (A), CODE_FOR_arm_##N, 0, T##_QUALIFIERS}, |
| 790 |
|
| 791 |
static arm_builtin_datum acle_builtin_data[] = |
| 792 |
{ |
| 793 |
#include "arm_acle_builtins.def" |
| 794 |
}; |
| 795 |
|
| 796 |
#undef VAR1 |
| 797 |
/* IMM_MAX sets the maximum valid value of the CDE immediate operand. |
| 798 |
ECF_FLAG sets the flag used for set_call_expr_flags. */ |
| 799 |
#define VAR1(T, N, A, IMM_MAX, ECF_FLAG) \ |
| 800 |
{{#N #A, UP (A), CODE_FOR_arm_##N##A, 0, T##_QUALIFIERS}, IMM_MAX, ECF_FLAG}, |
| 801 |
|
| 802 |
typedef struct { |
| 803 |
arm_builtin_datum base; |
| 804 |
unsigned int imm_max; |
| 805 |
int ecf_flag; |
| 806 |
} arm_builtin_cde_datum; |
| 807 |
|
| 808 |
static arm_builtin_cde_datum cde_builtin_data[] = |
| 809 |
{ |
| 810 |
#include "arm_cde_builtins.def" |
| 811 |
}; |
| 812 |
|
| 813 |
#undef VAR1 |
| 814 |
#define VAR1(T, N, X) \ |
| 815 |
ARM_BUILTIN_NEON_##N##X, |
| 816 |
|
| 817 |
enum arm_builtins |
| 818 |
{ |
| 819 |
ARM_BUILTIN_GETWCGR0, |
| 820 |
ARM_BUILTIN_GETWCGR1, |
| 821 |
ARM_BUILTIN_GETWCGR2, |
| 822 |
ARM_BUILTIN_GETWCGR3, |
| 823 |
|
| 824 |
ARM_BUILTIN_SETWCGR0, |
| 825 |
ARM_BUILTIN_SETWCGR1, |
| 826 |
ARM_BUILTIN_SETWCGR2, |
| 827 |
ARM_BUILTIN_SETWCGR3, |
| 828 |
|
| 829 |
ARM_BUILTIN_WZERO, |
| 830 |
|
| 831 |
ARM_BUILTIN_WAVG2BR, |
| 832 |
ARM_BUILTIN_WAVG2HR, |
| 833 |
ARM_BUILTIN_WAVG2B, |
| 834 |
ARM_BUILTIN_WAVG2H, |
| 835 |
|
| 836 |
ARM_BUILTIN_WACCB, |
| 837 |
ARM_BUILTIN_WACCH, |
| 838 |
ARM_BUILTIN_WACCW, |
| 839 |
|
| 840 |
ARM_BUILTIN_WMACS, |
| 841 |
ARM_BUILTIN_WMACSZ, |
| 842 |
ARM_BUILTIN_WMACU, |
| 843 |
ARM_BUILTIN_WMACUZ, |
| 844 |
|
| 845 |
ARM_BUILTIN_WSADB, |
| 846 |
ARM_BUILTIN_WSADBZ, |
| 847 |
ARM_BUILTIN_WSADH, |
| 848 |
ARM_BUILTIN_WSADHZ, |
| 849 |
|
| 850 |
ARM_BUILTIN_WALIGNI, |
| 851 |
ARM_BUILTIN_WALIGNR0, |
| 852 |
ARM_BUILTIN_WALIGNR1, |
| 853 |
ARM_BUILTIN_WALIGNR2, |
| 854 |
ARM_BUILTIN_WALIGNR3, |
| 855 |
|
| 856 |
ARM_BUILTIN_TMIA, |
| 857 |
ARM_BUILTIN_TMIAPH, |
| 858 |
ARM_BUILTIN_TMIABB, |
| 859 |
ARM_BUILTIN_TMIABT, |
| 860 |
ARM_BUILTIN_TMIATB, |
| 861 |
ARM_BUILTIN_TMIATT, |
| 862 |
|
| 863 |
ARM_BUILTIN_TMOVMSKB, |
| 864 |
ARM_BUILTIN_TMOVMSKH, |
| 865 |
ARM_BUILTIN_TMOVMSKW, |
| 866 |
|
| 867 |
ARM_BUILTIN_TBCSTB, |
| 868 |
ARM_BUILTIN_TBCSTH, |
| 869 |
ARM_BUILTIN_TBCSTW, |
| 870 |
|
| 871 |
ARM_BUILTIN_WMADDS, |
| 872 |
ARM_BUILTIN_WMADDU, |
| 873 |
|
| 874 |
ARM_BUILTIN_WPACKHSS, |
| 875 |
ARM_BUILTIN_WPACKWSS, |
| 876 |
ARM_BUILTIN_WPACKDSS, |
| 877 |
ARM_BUILTIN_WPACKHUS, |
| 878 |
ARM_BUILTIN_WPACKWUS, |
| 879 |
ARM_BUILTIN_WPACKDUS, |
| 880 |
|
| 881 |
ARM_BUILTIN_WADDB, |
| 882 |
ARM_BUILTIN_WADDH, |
| 883 |
ARM_BUILTIN_WADDW, |
| 884 |
ARM_BUILTIN_WADDSSB, |
| 885 |
ARM_BUILTIN_WADDSSH, |
| 886 |
ARM_BUILTIN_WADDSSW, |
| 887 |
ARM_BUILTIN_WADDUSB, |
| 888 |
ARM_BUILTIN_WADDUSH, |
| 889 |
ARM_BUILTIN_WADDUSW, |
| 890 |
ARM_BUILTIN_WSUBB, |
| 891 |
ARM_BUILTIN_WSUBH, |
| 892 |
ARM_BUILTIN_WSUBW, |
| 893 |
ARM_BUILTIN_WSUBSSB, |
| 894 |
ARM_BUILTIN_WSUBSSH, |
| 895 |
ARM_BUILTIN_WSUBSSW, |
| 896 |
ARM_BUILTIN_WSUBUSB, |
| 897 |
ARM_BUILTIN_WSUBUSH, |
| 898 |
ARM_BUILTIN_WSUBUSW, |
| 899 |
|
| 900 |
ARM_BUILTIN_WAND, |
| 901 |
ARM_BUILTIN_WANDN, |
| 902 |
ARM_BUILTIN_WOR, |
| 903 |
ARM_BUILTIN_WXOR, |
| 904 |
|
| 905 |
ARM_BUILTIN_WCMPEQB, |
| 906 |
ARM_BUILTIN_WCMPEQH, |
| 907 |
ARM_BUILTIN_WCMPEQW, |
| 908 |
ARM_BUILTIN_WCMPGTUB, |
| 909 |
ARM_BUILTIN_WCMPGTUH, |
| 910 |
ARM_BUILTIN_WCMPGTUW, |
| 911 |
ARM_BUILTIN_WCMPGTSB, |
| 912 |
ARM_BUILTIN_WCMPGTSH, |
| 913 |
ARM_BUILTIN_WCMPGTSW, |
| 914 |
|
| 915 |
ARM_BUILTIN_TEXTRMSB, |
| 916 |
ARM_BUILTIN_TEXTRMSH, |
| 917 |
ARM_BUILTIN_TEXTRMSW, |
| 918 |
ARM_BUILTIN_TEXTRMUB, |
| 919 |
ARM_BUILTIN_TEXTRMUH, |
| 920 |
ARM_BUILTIN_TEXTRMUW, |
| 921 |
ARM_BUILTIN_TINSRB, |
| 922 |
ARM_BUILTIN_TINSRH, |
| 923 |
ARM_BUILTIN_TINSRW, |
| 924 |
|
| 925 |
ARM_BUILTIN_WMAXSW, |
| 926 |
ARM_BUILTIN_WMAXSH, |
| 927 |
ARM_BUILTIN_WMAXSB, |
| 928 |
ARM_BUILTIN_WMAXUW, |
| 929 |
ARM_BUILTIN_WMAXUH, |
| 930 |
ARM_BUILTIN_WMAXUB, |
| 931 |
ARM_BUILTIN_WMINSW, |
| 932 |
ARM_BUILTIN_WMINSH, |
| 933 |
ARM_BUILTIN_WMINSB, |
| 934 |
ARM_BUILTIN_WMINUW, |
| 935 |
ARM_BUILTIN_WMINUH, |
| 936 |
ARM_BUILTIN_WMINUB, |
| 937 |
|
| 938 |
ARM_BUILTIN_WMULUM, |
| 939 |
ARM_BUILTIN_WMULSM, |
| 940 |
ARM_BUILTIN_WMULUL, |
| 941 |
|
| 942 |
ARM_BUILTIN_PSADBH, |
| 943 |
ARM_BUILTIN_WSHUFH, |
| 944 |
|
| 945 |
ARM_BUILTIN_WSLLH, |
| 946 |
ARM_BUILTIN_WSLLW, |
| 947 |
ARM_BUILTIN_WSLLD, |
| 948 |
ARM_BUILTIN_WSRAH, |
| 949 |
ARM_BUILTIN_WSRAW, |
| 950 |
ARM_BUILTIN_WSRAD, |
| 951 |
ARM_BUILTIN_WSRLH, |
| 952 |
ARM_BUILTIN_WSRLW, |
| 953 |
ARM_BUILTIN_WSRLD, |
| 954 |
ARM_BUILTIN_WRORH, |
| 955 |
ARM_BUILTIN_WRORW, |
| 956 |
ARM_BUILTIN_WRORD, |
| 957 |
ARM_BUILTIN_WSLLHI, |
| 958 |
ARM_BUILTIN_WSLLWI, |
| 959 |
ARM_BUILTIN_WSLLDI, |
| 960 |
ARM_BUILTIN_WSRAHI, |
| 961 |
ARM_BUILTIN_WSRAWI, |
| 962 |
ARM_BUILTIN_WSRADI, |
| 963 |
ARM_BUILTIN_WSRLHI, |
| 964 |
ARM_BUILTIN_WSRLWI, |
| 965 |
ARM_BUILTIN_WSRLDI, |
| 966 |
ARM_BUILTIN_WRORHI, |
| 967 |
ARM_BUILTIN_WRORWI, |
| 968 |
ARM_BUILTIN_WRORDI, |
| 969 |
|
| 970 |
ARM_BUILTIN_WUNPCKIHB, |
| 971 |
ARM_BUILTIN_WUNPCKIHH, |
| 972 |
ARM_BUILTIN_WUNPCKIHW, |
| 973 |
ARM_BUILTIN_WUNPCKILB, |
| 974 |
ARM_BUILTIN_WUNPCKILH, |
| 975 |
ARM_BUILTIN_WUNPCKILW, |
| 976 |
|
| 977 |
ARM_BUILTIN_WUNPCKEHSB, |
| 978 |
ARM_BUILTIN_WUNPCKEHSH, |
| 979 |
ARM_BUILTIN_WUNPCKEHSW, |
| 980 |
ARM_BUILTIN_WUNPCKEHUB, |
| 981 |
ARM_BUILTIN_WUNPCKEHUH, |
| 982 |
ARM_BUILTIN_WUNPCKEHUW, |
| 983 |
ARM_BUILTIN_WUNPCKELSB, |
| 984 |
ARM_BUILTIN_WUNPCKELSH, |
| 985 |
ARM_BUILTIN_WUNPCKELSW, |
| 986 |
ARM_BUILTIN_WUNPCKELUB, |
| 987 |
ARM_BUILTIN_WUNPCKELUH, |
| 988 |
ARM_BUILTIN_WUNPCKELUW, |
| 989 |
|
| 990 |
ARM_BUILTIN_WABSB, |
| 991 |
ARM_BUILTIN_WABSH, |
| 992 |
ARM_BUILTIN_WABSW, |
| 993 |
|
| 994 |
ARM_BUILTIN_WADDSUBHX, |
| 995 |
ARM_BUILTIN_WSUBADDHX, |
| 996 |
|
| 997 |
ARM_BUILTIN_WABSDIFFB, |
| 998 |
ARM_BUILTIN_WABSDIFFH, |
| 999 |
ARM_BUILTIN_WABSDIFFW, |
| 1000 |
|
| 1001 |
ARM_BUILTIN_WADDCH, |
| 1002 |
ARM_BUILTIN_WADDCW, |
| 1003 |
|
| 1004 |
ARM_BUILTIN_WAVG4, |
| 1005 |
ARM_BUILTIN_WAVG4R, |
| 1006 |
|
| 1007 |
ARM_BUILTIN_WMADDSX, |
| 1008 |
ARM_BUILTIN_WMADDUX, |
| 1009 |
|
| 1010 |
ARM_BUILTIN_WMADDSN, |
| 1011 |
ARM_BUILTIN_WMADDUN, |
| 1012 |
|
| 1013 |
ARM_BUILTIN_WMULWSM, |
| 1014 |
ARM_BUILTIN_WMULWUM, |
| 1015 |
|
| 1016 |
ARM_BUILTIN_WMULWSMR, |
| 1017 |
ARM_BUILTIN_WMULWUMR, |
| 1018 |
|
| 1019 |
ARM_BUILTIN_WMULWL, |
| 1020 |
|
| 1021 |
ARM_BUILTIN_WMULSMR, |
| 1022 |
ARM_BUILTIN_WMULUMR, |
| 1023 |
|
| 1024 |
ARM_BUILTIN_WQMULM, |
| 1025 |
ARM_BUILTIN_WQMULMR, |
| 1026 |
|
| 1027 |
ARM_BUILTIN_WQMULWM, |
| 1028 |
ARM_BUILTIN_WQMULWMR, |
| 1029 |
|
| 1030 |
ARM_BUILTIN_WADDBHUSM, |
| 1031 |
ARM_BUILTIN_WADDBHUSL, |
| 1032 |
|
| 1033 |
ARM_BUILTIN_WQMIABB, |
| 1034 |
ARM_BUILTIN_WQMIABT, |
| 1035 |
ARM_BUILTIN_WQMIATB, |
| 1036 |
ARM_BUILTIN_WQMIATT, |
| 1037 |
|
| 1038 |
ARM_BUILTIN_WQMIABBN, |
| 1039 |
ARM_BUILTIN_WQMIABTN, |
| 1040 |
ARM_BUILTIN_WQMIATBN, |
| 1041 |
ARM_BUILTIN_WQMIATTN, |
| 1042 |
|
| 1043 |
ARM_BUILTIN_WMIABB, |
| 1044 |
ARM_BUILTIN_WMIABT, |
| 1045 |
ARM_BUILTIN_WMIATB, |
| 1046 |
ARM_BUILTIN_WMIATT, |
| 1047 |
|
| 1048 |
ARM_BUILTIN_WMIABBN, |
| 1049 |
ARM_BUILTIN_WMIABTN, |
| 1050 |
ARM_BUILTIN_WMIATBN, |
| 1051 |
ARM_BUILTIN_WMIATTN, |
| 1052 |
|
| 1053 |
ARM_BUILTIN_WMIAWBB, |
| 1054 |
ARM_BUILTIN_WMIAWBT, |
| 1055 |
ARM_BUILTIN_WMIAWTB, |
| 1056 |
ARM_BUILTIN_WMIAWTT, |
| 1057 |
|
| 1058 |
ARM_BUILTIN_WMIAWBBN, |
| 1059 |
ARM_BUILTIN_WMIAWBTN, |
| 1060 |
ARM_BUILTIN_WMIAWTBN, |
| 1061 |
ARM_BUILTIN_WMIAWTTN, |
| 1062 |
|
| 1063 |
ARM_BUILTIN_WMERGE, |
| 1064 |
|
| 1065 |
ARM_BUILTIN_GET_FPSCR, |
| 1066 |
ARM_BUILTIN_SET_FPSCR, |
| 1067 |
ARM_BUILTIN_GET_FPSCR_NZCVQC, |
| 1068 |
ARM_BUILTIN_SET_FPSCR_NZCVQC, |
| 1069 |
|
| 1070 |
ARM_BUILTIN_CMSE_NONSECURE_CALLER, |
| 1071 |
ARM_BUILTIN_SIMD_LANE_CHECK, |
| 1072 |
|
| 1073 |
#undef CRYPTO1 |
| 1074 |
#undef CRYPTO2 |
| 1075 |
#undef CRYPTO3 |
| 1076 |
|
| 1077 |
#define CRYPTO1(L, U, M1, M2) \ |
| 1078 |
ARM_BUILTIN_CRYPTO_##U, |
| 1079 |
#define CRYPTO2(L, U, M1, M2, M3) \ |
| 1080 |
ARM_BUILTIN_CRYPTO_##U, |
| 1081 |
#define CRYPTO3(L, U, M1, M2, M3, M4) \ |
| 1082 |
ARM_BUILTIN_CRYPTO_##U, |
| 1083 |
|
| 1084 |
ARM_BUILTIN_CRYPTO_BASE, |
| 1085 |
|
| 1086 |
#include "crypto.def" |
| 1087 |
|
| 1088 |
#undef CRYPTO1 |
| 1089 |
#undef CRYPTO2 |
| 1090 |
#undef CRYPTO3 |
| 1091 |
|
| 1092 |
ARM_BUILTIN_VFP_BASE, |
| 1093 |
|
| 1094 |
#include "arm_vfp_builtins.def" |
| 1095 |
|
| 1096 |
ARM_BUILTIN_NEON_BASE, |
| 1097 |
|
| 1098 |
#include "arm_neon_builtins.def" |
| 1099 |
|
| 1100 |
#undef VAR1 |
| 1101 |
#define VAR1(T, N, X) \ |
| 1102 |
ARM_BUILTIN_##N, |
| 1103 |
|
| 1104 |
ARM_BUILTIN_ACLE_BASE, |
| 1105 |
ARM_BUILTIN_SAT_IMM_CHECK = ARM_BUILTIN_ACLE_BASE, |
| 1106 |
|
| 1107 |
#include "arm_acle_builtins.def" |
| 1108 |
|
| 1109 |
#undef VAR1 |
| 1110 |
#define VAR1(T, N, X, ... ) \ |
| 1111 |
ARM_BUILTIN_##N##X, |
| 1112 |
|
| 1113 |
ARM_BUILTIN_CDE_BASE, |
| 1114 |
|
| 1115 |
#include "arm_cde_builtins.def" |
| 1116 |
|
| 1117 |
ARM_BUILTIN_MVE_BASE, |
| 1118 |
|
| 1119 |
#undef VAR1 |
| 1120 |
#define VAR1(T, N, X) \ |
| 1121 |
ARM_BUILTIN_MVE_##N##X, |
| 1122 |
#include "arm_mve_builtins.def" |
| 1123 |
|
| 1124 |
ARM_BUILTIN_MAX |
| 1125 |
}; |
| 1126 |
|
| 1127 |
#define ARM_BUILTIN_VFP_PATTERN_START \ |
| 1128 |
(ARM_BUILTIN_VFP_BASE + 1) |
| 1129 |
|
| 1130 |
#define ARM_BUILTIN_NEON_PATTERN_START \ |
| 1131 |
(ARM_BUILTIN_NEON_BASE + 1) |
| 1132 |
|
| 1133 |
#define ARM_BUILTIN_MVE_PATTERN_START \ |
| 1134 |
(ARM_BUILTIN_MVE_BASE + 1) |
| 1135 |
|
| 1136 |
#define ARM_BUILTIN_ACLE_PATTERN_START \ |
| 1137 |
(ARM_BUILTIN_ACLE_BASE + 1) |
| 1138 |
|
| 1139 |
#define ARM_BUILTIN_CDE_PATTERN_START \ |
| 1140 |
(ARM_BUILTIN_CDE_BASE + 1) |
| 1141 |
|
| 1142 |
#define ARM_BUILTIN_CDE_PATTERN_END \ |
| 1143 |
(ARM_BUILTIN_CDE_BASE + ARRAY_SIZE (cde_builtin_data)) |
| 1144 |
|
| 1145 |
#undef CF |
| 1146 |
#undef VAR1 |
| 1147 |
#undef VAR2 |
| 1148 |
#undef VAR3 |
| 1149 |
#undef VAR4 |
| 1150 |
#undef VAR5 |
| 1151 |
#undef VAR6 |
| 1152 |
#undef VAR7 |
| 1153 |
#undef VAR8 |
| 1154 |
#undef VAR9 |
| 1155 |
#undef VAR10 |
| 1156 |
|
| 1157 |
static GTY(()) tree arm_builtin_decls[ARM_BUILTIN_MAX]; |
| 1158 |
|
| 1159 |
#define NUM_DREG_TYPES 5 |
| 1160 |
#define NUM_QREG_TYPES 6 |
| 1161 |
|
| 1162 |
/* Internal scalar builtin types. These types are used to support |
| 1163 |
neon intrinsic builtins. They are _not_ user-visible types. Therefore |
| 1164 |
the mangling for these types are implementation defined. */ |
| 1165 |
const char *arm_scalar_builtin_types[] = { |
| 1166 |
"__builtin_neon_qi", |
| 1167 |
"__builtin_neon_hi", |
| 1168 |
"__builtin_neon_si", |
| 1169 |
"__builtin_neon_sf", |
| 1170 |
"__builtin_neon_di", |
| 1171 |
"__builtin_neon_df", |
| 1172 |
"__builtin_neon_ti", |
| 1173 |
"__builtin_neon_uqi", |
| 1174 |
"__builtin_neon_uhi", |
| 1175 |
"__builtin_neon_usi", |
| 1176 |
"__builtin_neon_udi", |
| 1177 |
"__builtin_neon_ei", |
| 1178 |
"__builtin_neon_oi", |
| 1179 |
"__builtin_neon_ci", |
| 1180 |
"__builtin_neon_xi", |
| 1181 |
"__builtin_neon_bf", |
| 1182 |
NULL |
| 1183 |
}; |
| 1184 |
|
| 1185 |
#define ENTRY(E, M, Q, S, T, G) \ |
| 1186 |
{E, \ |
| 1187 |
"__simd" #S "_" #T "_t", \ |
| 1188 |
#G "__simd" #S "_" #T "_t", \ |
| 1189 |
NULL_TREE, NULL_TREE, M##mode, qualifier_##Q}, |
| 1190 |
struct arm_simd_type_info arm_simd_types [] = { |
| 1191 |
#include "arm-simd-builtin-types.def" |
| 1192 |
}; |
| 1193 |
#undef ENTRY |
| 1194 |
|
| 1195 |
/* The user-visible __fp16 type. */ |
| 1196 |
tree arm_fp16_type_node = NULL_TREE; |
| 1197 |
|
| 1198 |
/* Back-end node type for brain float (bfloat) types. */ |
| 1199 |
tree arm_bf16_type_node = NULL_TREE; |
| 1200 |
tree arm_bf16_ptr_type_node = NULL_TREE; |
| 1201 |
|
| 1202 |
static tree arm_simd_intOI_type_node = NULL_TREE; |
| 1203 |
static tree arm_simd_intEI_type_node = NULL_TREE; |
| 1204 |
static tree arm_simd_intCI_type_node = NULL_TREE; |
| 1205 |
static tree arm_simd_intXI_type_node = NULL_TREE; |
| 1206 |
static tree arm_simd_polyQI_type_node = NULL_TREE; |
| 1207 |
static tree arm_simd_polyHI_type_node = NULL_TREE; |
| 1208 |
static tree arm_simd_polyDI_type_node = NULL_TREE; |
| 1209 |
static tree arm_simd_polyTI_type_node = NULL_TREE; |
| 1210 |
|
| 1211 |
/* Wrapper around add_builtin_function. NAME is the name of the built-in |
| 1212 |
function, TYPE is the function type, CODE is the function subcode |
| 1213 |
(relative to ARM_BUILTIN_GENERAL), and ATTRS is the function |
| 1214 |
attributes. */ |
| 1215 |
static tree |
| 1216 |
arm_general_add_builtin_function (const char* name, tree type, |
| 1217 |
unsigned int code, tree attrs = NULL_TREE) |
| 1218 |
{ |
| 1219 |
code = (code << ARM_BUILTIN_SHIFT) | ARM_BUILTIN_GENERAL; |
| 1220 |
return add_builtin_function (name, type, code, BUILT_IN_MD, NULL, attrs); |
| 1221 |
} |
| 1222 |
|
| 1223 |
static const char * |
| 1224 |
arm_mangle_builtin_scalar_type (const_tree type) |
| 1225 |
{ |
| 1226 |
int i = 0; |
| 1227 |
|
| 1228 |
while (arm_scalar_builtin_types[i] != NULL) |
| 1229 |
{ |
| 1230 |
const char *name = arm_scalar_builtin_types[i]; |
| 1231 |
|
| 1232 |
if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL |
| 1233 |
&& DECL_NAME (TYPE_NAME (type)) |
| 1234 |
&& !strcmp (IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))), name)) |
| 1235 |
return arm_scalar_builtin_types[i]; |
| 1236 |
i++; |
| 1237 |
} |
| 1238 |
return NULL; |
| 1239 |
} |
| 1240 |
|
| 1241 |
static const char * |
| 1242 |
arm_mangle_builtin_vector_type (const_tree type) |
| 1243 |
{ |
| 1244 |
tree attrs = TYPE_ATTRIBUTES (type); |
| 1245 |
if (tree attr = lookup_attribute ("Advanced SIMD type", attrs)) |
| 1246 |
{ |
| 1247 |
tree mangled_name = TREE_VALUE (TREE_VALUE (attr)); |
| 1248 |
return IDENTIFIER_POINTER (mangled_name); |
| 1249 |
} |
| 1250 |
|
| 1251 |
return NULL; |
| 1252 |
} |
| 1253 |
|
| 1254 |
const char * |
| 1255 |
arm_mangle_builtin_type (const_tree type) |
| 1256 |
{ |
| 1257 |
const char *mangle; |
| 1258 |
/* Walk through all the Arm builtins types tables to filter out the |
| 1259 |
incoming type. */ |
| 1260 |
if ((mangle = arm_mangle_builtin_vector_type (type)) |
| 1261 |
|| (mangle = arm_mangle_builtin_scalar_type (type))) |
| 1262 |
return mangle; |
| 1263 |
|
| 1264 |
return NULL; |
| 1265 |
} |
| 1266 |
|
| 1267 |
static tree |
| 1268 |
arm_simd_builtin_std_type (machine_mode mode, |
| 1269 |
enum arm_type_qualifiers q) |
| 1270 |
{ |
| 1271 |
#define QUAL_TYPE(M) \ |
| 1272 |
((q == qualifier_none) ? int##M##_type_node : unsigned_int##M##_type_node); |
| 1273 |
switch (mode) |
| 1274 |
{ |
| 1275 |
case E_QImode: |
| 1276 |
return QUAL_TYPE (QI); |
| 1277 |
case E_HImode: |
| 1278 |
return QUAL_TYPE (HI); |
| 1279 |
case E_SImode: |
| 1280 |
return QUAL_TYPE (SI); |
| 1281 |
case E_DImode: |
| 1282 |
return QUAL_TYPE (DI); |
| 1283 |
case E_TImode: |
| 1284 |
return QUAL_TYPE (TI); |
| 1285 |
case E_OImode: |
| 1286 |
return arm_simd_intOI_type_node; |
| 1287 |
case E_EImode: |
| 1288 |
return arm_simd_intEI_type_node; |
| 1289 |
case E_CImode: |
| 1290 |
return arm_simd_intCI_type_node; |
| 1291 |
case E_XImode: |
| 1292 |
return arm_simd_intXI_type_node; |
| 1293 |
case E_HFmode: |
| 1294 |
return arm_fp16_type_node; |
| 1295 |
case E_SFmode: |
| 1296 |
return float_type_node; |
| 1297 |
case E_DFmode: |
| 1298 |
return double_type_node; |
| 1299 |
case E_BFmode: |
| 1300 |
return arm_bf16_type_node; |
| 1301 |
default: |
| 1302 |
gcc_unreachable (); |
| 1303 |
} |
| 1304 |
#undef QUAL_TYPE |
| 1305 |
} |
| 1306 |
|
| 1307 |
static tree |
| 1308 |
arm_lookup_simd_builtin_type (machine_mode mode, |
| 1309 |
enum arm_type_qualifiers q) |
| 1310 |
{ |
| 1311 |
int i; |
| 1312 |
int nelts = ARRAY_SIZE (arm_simd_types); |
| 1313 |
|
| 1314 |
/* Non-poly scalar modes map to standard types not in the table. */ |
| 1315 |
if (q != qualifier_poly && !VECTOR_MODE_P (mode)) |
| 1316 |
return arm_simd_builtin_std_type (mode, q); |
| 1317 |
|
| 1318 |
for (i = 0; i < nelts; i++) |
| 1319 |
if (arm_simd_types[i].mode == mode |
| 1320 |
&& arm_simd_types[i].q == q) |
| 1321 |
return arm_simd_types[i].itype; |
| 1322 |
|
| 1323 |
/* Note that we won't have caught the underlying type for poly64x2_t |
| 1324 |
in the above table. This gets default mangling. */ |
| 1325 |
|
| 1326 |
return NULL_TREE; |
| 1327 |
} |
| 1328 |
|
| 1329 |
static tree |
| 1330 |
arm_simd_builtin_type (machine_mode mode, arm_type_qualifiers qualifiers) |
| 1331 |
{ |
| 1332 |
if ((qualifiers & qualifier_poly) != 0) |
| 1333 |
return arm_lookup_simd_builtin_type (mode, qualifier_poly); |
| 1334 |
else if ((qualifiers & qualifier_unsigned) != 0) |
| 1335 |
return arm_lookup_simd_builtin_type (mode, qualifier_unsigned); |
| 1336 |
else if ((qualifiers & qualifier_predicate) != 0) |
| 1337 |
return unsigned_intHI_type_node; |
| 1338 |
else |
| 1339 |
return arm_lookup_simd_builtin_type (mode, qualifier_none); |
| 1340 |
} |
| 1341 |
|
| 1342 |
static void |
| 1343 |
arm_init_simd_builtin_types (void) |
| 1344 |
{ |
| 1345 |
int i; |
| 1346 |
int nelts = ARRAY_SIZE (arm_simd_types); |
| 1347 |
tree tdecl; |
| 1348 |
|
| 1349 |
/* Poly types are a world of their own. In order to maintain legacy |
| 1350 |
ABI, they get initialized using the old interface, and don't get |
| 1351 |
an entry in our mangling table, consequently, they get default |
| 1352 |
mangling. As a further gotcha, poly8_t and poly16_t are signed |
| 1353 |
types, poly64_t and poly128_t are unsigned types. */ |
| 1354 |
if (!TARGET_HAVE_MVE) |
| 1355 |
{ |
| 1356 |
arm_simd_polyQI_type_node |
| 1357 |
= build_distinct_type_copy (intQI_type_node); |
| 1358 |
(*lang_hooks.types.register_builtin_type) (arm_simd_polyQI_type_node, |
| 1359 |
"__builtin_neon_poly8"); |
| 1360 |
arm_simd_polyHI_type_node |
| 1361 |
= build_distinct_type_copy (intHI_type_node); |
| 1362 |
(*lang_hooks.types.register_builtin_type) (arm_simd_polyHI_type_node, |
| 1363 |
"__builtin_neon_poly16"); |
| 1364 |
arm_simd_polyDI_type_node |
| 1365 |
= build_distinct_type_copy (unsigned_intDI_type_node); |
| 1366 |
(*lang_hooks.types.register_builtin_type) (arm_simd_polyDI_type_node, |
| 1367 |
"__builtin_neon_poly64"); |
| 1368 |
arm_simd_polyTI_type_node |
| 1369 |
= build_distinct_type_copy (unsigned_intTI_type_node); |
| 1370 |
(*lang_hooks.types.register_builtin_type) (arm_simd_polyTI_type_node, |
| 1371 |
"__builtin_neon_poly128"); |
| 1372 |
/* Init poly vector element types with scalar poly types. */ |
| 1373 |
arm_simd_types[Poly8x8_t].eltype = arm_simd_polyQI_type_node; |
| 1374 |
arm_simd_types[Poly8x16_t].eltype = arm_simd_polyQI_type_node; |
| 1375 |
arm_simd_types[Poly16x4_t].eltype = arm_simd_polyHI_type_node; |
| 1376 |
arm_simd_types[Poly16x8_t].eltype = arm_simd_polyHI_type_node; |
| 1377 |
/* Note: poly64x2_t is defined in arm_neon.h, to ensure it gets default |
| 1378 |
mangling. */ |
| 1379 |
|
| 1380 |
/* Prevent front-ends from transforming poly vectors into string |
| 1381 |
literals. */ |
| 1382 |
TYPE_STRING_FLAG (arm_simd_polyQI_type_node) = false; |
| 1383 |
TYPE_STRING_FLAG (arm_simd_polyHI_type_node) = false; |
| 1384 |
} |
| 1385 |
/* Init all the element types built by the front-end. */ |
| 1386 |
arm_simd_types[Int8x8_t].eltype = get_typenode_from_name (INT8_TYPE); |
| 1387 |
arm_simd_types[Int8x16_t].eltype = get_typenode_from_name (INT8_TYPE); |
| 1388 |
arm_simd_types[Int16x4_t].eltype = get_typenode_from_name (INT16_TYPE); |
| 1389 |
arm_simd_types[Int16x8_t].eltype = get_typenode_from_name (INT16_TYPE); |
| 1390 |
arm_simd_types[Int32x2_t].eltype = get_typenode_from_name (INT32_TYPE); |
| 1391 |
arm_simd_types[Int32x4_t].eltype = get_typenode_from_name (INT32_TYPE); |
| 1392 |
arm_simd_types[Int64x2_t].eltype = get_typenode_from_name (INT64_TYPE); |
| 1393 |
arm_simd_types[Uint8x8_t].eltype = get_typenode_from_name (UINT8_TYPE); |
| 1394 |
arm_simd_types[Uint8x16_t].eltype = get_typenode_from_name (UINT8_TYPE); |
| 1395 |
arm_simd_types[Uint16x4_t].eltype = get_typenode_from_name (UINT16_TYPE); |
| 1396 |
arm_simd_types[Uint16x8_t].eltype = get_typenode_from_name (UINT16_TYPE); |
| 1397 |
arm_simd_types[Uint32x2_t].eltype = get_typenode_from_name (UINT32_TYPE); |
| 1398 |
arm_simd_types[Uint32x4_t].eltype = get_typenode_from_name (UINT32_TYPE); |
| 1399 |
arm_simd_types[Uint64x2_t].eltype = get_typenode_from_name (UINT64_TYPE); |
| 1400 |
|
| 1401 |
/* Note: poly64x2_t is defined in arm_neon.h, to ensure it gets default |
| 1402 |
mangling. */ |
| 1403 |
|
| 1404 |
/* Continue with standard types. */ |
| 1405 |
/* The __builtin_simd{64,128}_float16 types are kept private unless |
| 1406 |
we have a scalar __fp16 type. */ |
| 1407 |
arm_simd_types[Float16x4_t].eltype = arm_fp16_type_node; |
| 1408 |
arm_simd_types[Float16x8_t].eltype = arm_fp16_type_node; |
| 1409 |
arm_simd_types[Float32x2_t].eltype = float_type_node; |
| 1410 |
arm_simd_types[Float32x4_t].eltype = float_type_node; |
| 1411 |
|
| 1412 |
/* Init Bfloat vector types with underlying __bf16 scalar type. */ |
| 1413 |
arm_simd_types[Bfloat16x2_t].eltype = arm_bf16_type_node; |
| 1414 |
arm_simd_types[Bfloat16x4_t].eltype = arm_bf16_type_node; |
| 1415 |
arm_simd_types[Bfloat16x8_t].eltype = arm_bf16_type_node; |
| 1416 |
|
| 1417 |
for (i = 0; i < nelts; i++) |
| 1418 |
{ |
| 1419 |
tree eltype = arm_simd_types[i].eltype; |
| 1420 |
machine_mode mode = arm_simd_types[i].mode; |
| 1421 |
|
| 1422 |
if (eltype == NULL |
| 1423 |
/* VECTOR_BOOL is not supported unless MVE is activated, |
| 1424 |
this would make build_truth_vector_type_for_mode |
| 1425 |
crash. */ |
| 1426 |
&& ((GET_MODE_CLASS (mode) != MODE_VECTOR_BOOL) |
| 1427 |
|| !TARGET_HAVE_MVE)) |
| 1428 |
continue; |
| 1429 |
if (arm_simd_types[i].itype == NULL) |
| 1430 |
{ |
| 1431 |
tree type; |
| 1432 |
if (GET_MODE_CLASS (mode) == MODE_VECTOR_BOOL) |
| 1433 |
{ |
| 1434 |
/* Handle MVE predicates: they are internally stored as |
| 1435 |
16 bits, but are used as vectors of 1, 2 or 4-bit |
| 1436 |
elements. */ |
| 1437 |
type = build_truth_vector_type_for_mode (GET_MODE_NUNITS (mode), |
| 1438 |
mode); |
| 1439 |
eltype = TREE_TYPE (type); |
| 1440 |
} |
| 1441 |
else |
| 1442 |
type = build_vector_type (eltype, GET_MODE_NUNITS (mode)); |
| 1443 |
|
| 1444 |
type = build_distinct_type_copy (type); |
| 1445 |
SET_TYPE_STRUCTURAL_EQUALITY (type); |
| 1446 |
|
| 1447 |
tree mangled_name = get_identifier (arm_simd_types[i].mangle); |
| 1448 |
tree value = tree_cons (NULL_TREE, mangled_name, NULL_TREE); |
| 1449 |
TYPE_ATTRIBUTES (type) |
| 1450 |
= tree_cons (get_identifier ("Advanced SIMD type"), value, |
| 1451 |
TYPE_ATTRIBUTES (type)); |
| 1452 |
arm_simd_types[i].itype = type; |
| 1453 |
} |
| 1454 |
|
| 1455 |
tdecl = add_builtin_type (arm_simd_types[i].name, |
| 1456 |
arm_simd_types[i].itype); |
| 1457 |
TYPE_NAME (arm_simd_types[i].itype) = tdecl; |
| 1458 |
SET_TYPE_STRUCTURAL_EQUALITY (arm_simd_types[i].itype); |
| 1459 |
} |
| 1460 |
|
| 1461 |
#define AARCH_BUILD_SIGNED_TYPE(mode) \ |
| 1462 |
make_signed_type (GET_MODE_PRECISION (mode)); |
| 1463 |
arm_simd_intOI_type_node = AARCH_BUILD_SIGNED_TYPE (OImode); |
| 1464 |
arm_simd_intEI_type_node = AARCH_BUILD_SIGNED_TYPE (EImode); |
| 1465 |
arm_simd_intCI_type_node = AARCH_BUILD_SIGNED_TYPE (CImode); |
| 1466 |
arm_simd_intXI_type_node = AARCH_BUILD_SIGNED_TYPE (XImode); |
| 1467 |
#undef AARCH_BUILD_SIGNED_TYPE |
| 1468 |
|
| 1469 |
tdecl = add_builtin_type |
| 1470 |
("__builtin_neon_ei" , arm_simd_intEI_type_node); |
| 1471 |
TYPE_NAME (arm_simd_intEI_type_node) = tdecl; |
| 1472 |
tdecl = add_builtin_type |
| 1473 |
("__builtin_neon_oi" , arm_simd_intOI_type_node); |
| 1474 |
TYPE_NAME (arm_simd_intOI_type_node) = tdecl; |
| 1475 |
tdecl = add_builtin_type |
| 1476 |
("__builtin_neon_ci" , arm_simd_intCI_type_node); |
| 1477 |
TYPE_NAME (arm_simd_intCI_type_node) = tdecl; |
| 1478 |
tdecl = add_builtin_type |
| 1479 |
("__builtin_neon_xi" , arm_simd_intXI_type_node); |
| 1480 |
TYPE_NAME (arm_simd_intXI_type_node) = tdecl; |
| 1481 |
} |
| 1482 |
|
| 1483 |
static void |
| 1484 |
arm_init_simd_builtin_scalar_types (void) |
| 1485 |
{ |
| 1486 |
/* Define typedefs for all the standard scalar types. */ |
| 1487 |
(*lang_hooks.types.register_builtin_type) (intQI_type_node, |
| 1488 |
"__builtin_neon_qi"); |
| 1489 |
(*lang_hooks.types.register_builtin_type) (intHI_type_node, |
| 1490 |
"__builtin_neon_hi"); |
| 1491 |
(*lang_hooks.types.register_builtin_type) (intSI_type_node, |
| 1492 |
"__builtin_neon_si"); |
| 1493 |
(*lang_hooks.types.register_builtin_type) (float_type_node, |
| 1494 |
"__builtin_neon_sf"); |
| 1495 |
(*lang_hooks.types.register_builtin_type) (intDI_type_node, |
| 1496 |
"__builtin_neon_di"); |
| 1497 |
(*lang_hooks.types.register_builtin_type) (double_type_node, |
| 1498 |
"__builtin_neon_df"); |
| 1499 |
(*lang_hooks.types.register_builtin_type) (intTI_type_node, |
| 1500 |
"__builtin_neon_ti"); |
| 1501 |
(*lang_hooks.types.register_builtin_type) (arm_bf16_type_node, |
| 1502 |
"__builtin_neon_bf"); |
| 1503 |
/* Unsigned integer types for various mode sizes. */ |
| 1504 |
(*lang_hooks.types.register_builtin_type) (unsigned_intQI_type_node, |
| 1505 |
"__builtin_neon_uqi"); |
| 1506 |
(*lang_hooks.types.register_builtin_type) (unsigned_intHI_type_node, |
| 1507 |
"__builtin_neon_uhi"); |
| 1508 |
(*lang_hooks.types.register_builtin_type) (unsigned_intSI_type_node, |
| 1509 |
"__builtin_neon_usi"); |
| 1510 |
(*lang_hooks.types.register_builtin_type) (unsigned_intDI_type_node, |
| 1511 |
"__builtin_neon_udi"); |
| 1512 |
(*lang_hooks.types.register_builtin_type) (unsigned_intTI_type_node, |
| 1513 |
"__builtin_neon_uti"); |
| 1514 |
} |
| 1515 |
|
| 1516 |
/* Set up a builtin. It will use information stored in the argument struct D to |
| 1517 |
derive the builtin's type signature and name. It will append the name in D |
| 1518 |
to the PREFIX passed and use these to create a builtin declaration that is |
| 1519 |
then stored in 'arm_builtin_decls' under index FCODE. This FCODE is also |
| 1520 |
written back to D for future use. */ |
| 1521 |
|
| 1522 |
static void |
| 1523 |
arm_init_builtin (unsigned int fcode, arm_builtin_datum *d, |
| 1524 |
const char * prefix) |
| 1525 |
{ |
| 1526 |
bool print_type_signature_p = false; |
| 1527 |
char type_signature[SIMD_MAX_BUILTIN_ARGS] = { 0 }; |
| 1528 |
char namebuf[60]; |
| 1529 |
tree ftype = NULL; |
| 1530 |
tree fndecl = NULL; |
| 1531 |
|
| 1532 |
d->fcode = fcode; |
| 1533 |
|
| 1534 |
/* We must track two variables here. op_num is |
| 1535 |
the operand number as in the RTL pattern. This is |
| 1536 |
required to access the mode (e.g. V4SF mode) of the |
| 1537 |
argument, from which the base type can be derived. |
| 1538 |
arg_num is an index in to the qualifiers data, which |
| 1539 |
gives qualifiers to the type (e.g. const unsigned). |
| 1540 |
The reason these two variables may differ by one is the |
| 1541 |
void return type. While all return types take the 0th entry |
| 1542 |
in the qualifiers array, there is no operand for them in the |
| 1543 |
RTL pattern. */ |
| 1544 |
int op_num = insn_data[d->code].n_operands - 1; |
| 1545 |
int arg_num = d->qualifiers[0] & qualifier_void |
| 1546 |
? op_num + 1 |
| 1547 |
: op_num; |
| 1548 |
tree return_type = void_type_node, args = void_list_node; |
| 1549 |
tree eltype; |
| 1550 |
|
| 1551 |
/* Build a function type directly from the insn_data for this |
| 1552 |
builtin. The build_function_type () function takes care of |
| 1553 |
removing duplicates for us. */ |
| 1554 |
for (; op_num >= 0; arg_num--, op_num--) |
| 1555 |
{ |
| 1556 |
machine_mode op_mode = insn_data[d->code].operand[op_num].mode; |
| 1557 |
enum arm_type_qualifiers qualifiers = d->qualifiers[arg_num]; |
| 1558 |
|
| 1559 |
if (qualifiers & qualifier_unsigned) |
| 1560 |
{ |
| 1561 |
type_signature[arg_num] = 'u'; |
| 1562 |
print_type_signature_p = true; |
| 1563 |
} |
| 1564 |
else if (qualifiers & qualifier_poly) |
| 1565 |
{ |
| 1566 |
type_signature[arg_num] = 'p'; |
| 1567 |
print_type_signature_p = true; |
| 1568 |
} |
| 1569 |
else |
| 1570 |
type_signature[arg_num] = 's'; |
| 1571 |
|
| 1572 |
/* Skip an internal operand for vget_{low, high}. */ |
| 1573 |
if (qualifiers & qualifier_internal) |
| 1574 |
continue; |
| 1575 |
|
| 1576 |
/* Some builtins have different user-facing types |
| 1577 |
for certain arguments, encoded in d->mode. */ |
| 1578 |
if (qualifiers & qualifier_map_mode) |
| 1579 |
op_mode = d->mode; |
| 1580 |
|
| 1581 |
/* MVE Predicates use HImode as mandated by the ABI: pred16_t is |
| 1582 |
unsigned short. */ |
| 1583 |
if (qualifiers & qualifier_predicate) |
| 1584 |
op_mode = HImode; |
| 1585 |
|
| 1586 |
/* For pointers, we want a pointer to the basic type |
| 1587 |
of the vector. */ |
| 1588 |
if (qualifiers & qualifier_pointer && VECTOR_MODE_P (op_mode)) |
| 1589 |
op_mode = GET_MODE_INNER (op_mode); |
| 1590 |
|
| 1591 |
/* For void pointers we already have nodes constructed by the midend. */ |
| 1592 |
if (qualifiers & qualifier_void_pointer) |
| 1593 |
eltype = qualifiers & qualifier_const |
| 1594 |
? const_ptr_type_node : ptr_type_node; |
| 1595 |
else |
| 1596 |
{ |
| 1597 |
eltype |
| 1598 |
= arm_simd_builtin_type (op_mode, qualifiers); |
| 1599 |
gcc_assert (eltype != NULL); |
| 1600 |
|
| 1601 |
/* Add qualifiers. */ |
| 1602 |
if (qualifiers & qualifier_const) |
| 1603 |
eltype = build_qualified_type (eltype, TYPE_QUAL_CONST); |
| 1604 |
|
| 1605 |
if (qualifiers & qualifier_pointer) |
| 1606 |
eltype = build_pointer_type (eltype); |
| 1607 |
} |
| 1608 |
/* If we have reached arg_num == 0, we are at a non-void |
| 1609 |
return type. Otherwise, we are still processing |
| 1610 |
arguments. */ |
| 1611 |
if (arg_num == 0) |
| 1612 |
return_type = eltype; |
| 1613 |
else |
| 1614 |
args = tree_cons (NULL_TREE, eltype, args); |
| 1615 |
} |
| 1616 |
|
| 1617 |
ftype = build_function_type (return_type, args); |
| 1618 |
|
| 1619 |
gcc_assert (ftype != NULL); |
| 1620 |
|
| 1621 |
if (print_type_signature_p |
| 1622 |
&& IN_RANGE (fcode, ARM_BUILTIN_VFP_BASE, ARM_BUILTIN_ACLE_BASE - 1)) |
| 1623 |
snprintf (namebuf, sizeof (namebuf), "%s_%s_%s", |
| 1624 |
prefix, d->name, type_signature); |
| 1625 |
else |
| 1626 |
snprintf (namebuf, sizeof (namebuf), "%s_%s", |
| 1627 |
prefix, d->name); |
| 1628 |
|
| 1629 |
fndecl = arm_general_add_builtin_function (namebuf, ftype, fcode); |
| 1630 |
arm_builtin_decls[fcode] = fndecl; |
| 1631 |
} |
| 1632 |
|
| 1633 |
/* Initialize the backend REAL_TYPE type supporting bfloat types. */ |
| 1634 |
static void |
| 1635 |
arm_init_bf16_types (void) |
| 1636 |
{ |
| 1637 |
arm_bf16_type_node = make_node (REAL_TYPE); |
| 1638 |
TYPE_PRECISION (arm_bf16_type_node) = 16; |
| 1639 |
SET_TYPE_MODE (arm_bf16_type_node, BFmode); |
| 1640 |
layout_type (arm_bf16_type_node); |
| 1641 |
|
| 1642 |
lang_hooks.types.register_builtin_type (arm_bf16_type_node, "__bf16"); |
| 1643 |
arm_bf16_ptr_type_node = build_pointer_type (arm_bf16_type_node); |
| 1644 |
} |
| 1645 |
|
| 1646 |
/* Set up ACLE builtins, even builtins for instructions that are not |
| 1647 |
in the current target ISA to allow the user to compile particular modules |
| 1648 |
with different target specific options that differ from the command line |
| 1649 |
options. Such builtins will be rejected in arm_general_expand_builtin. */ |
| 1650 |
|
| 1651 |
static void |
| 1652 |
arm_init_acle_builtins (void) |
| 1653 |
{ |
| 1654 |
unsigned int i, fcode = ARM_BUILTIN_ACLE_PATTERN_START; |
| 1655 |
|
| 1656 |
tree sat_check_fpr = build_function_type_list (void_type_node, |
| 1657 |
intSI_type_node, |
| 1658 |
intSI_type_node, |
| 1659 |
intSI_type_node, |
| 1660 |
NULL); |
| 1661 |
arm_builtin_decls[ARM_BUILTIN_SAT_IMM_CHECK] |
| 1662 |
= arm_general_add_builtin_function ("__builtin_sat_imm_check", |
| 1663 |
sat_check_fpr, |
| 1664 |
ARM_BUILTIN_SAT_IMM_CHECK); |
| 1665 |
|
| 1666 |
for (i = 0; i < ARRAY_SIZE (acle_builtin_data); i++, fcode++) |
| 1667 |
{ |
| 1668 |
arm_builtin_datum *d = &acle_builtin_data[i]; |
| 1669 |
arm_init_builtin (fcode, d, "__builtin_arm"); |
| 1670 |
} |
| 1671 |
} |
| 1672 |
|
| 1673 |
static void |
| 1674 |
arm_init_cde_builtins (void) |
| 1675 |
{ |
| 1676 |
unsigned int i, fcode = ARM_BUILTIN_CDE_PATTERN_START; |
| 1677 |
for (i = 0; i < ARRAY_SIZE (cde_builtin_data); i++, fcode++) |
| 1678 |
{ |
| 1679 |
/* Only define CDE floating point builtins if the target has floating |
| 1680 |
point registers. NOTE: without HARD_FLOAT we don't have MVE, so we |
| 1681 |
can break out of this loop directly here. */ |
| 1682 |
if (!TARGET_MAYBE_HARD_FLOAT && fcode >= ARM_BUILTIN_vcx1si) |
| 1683 |
break; |
| 1684 |
/* Only define CDE/MVE builtins if MVE is available. */ |
| 1685 |
if (!TARGET_HAVE_MVE && fcode >= ARM_BUILTIN_vcx1qv16qi) |
| 1686 |
break; |
| 1687 |
arm_builtin_cde_datum *cde = &cde_builtin_data[i]; |
| 1688 |
arm_builtin_datum *d = &cde->base; |
| 1689 |
arm_init_builtin (fcode, d, "__builtin_arm"); |
| 1690 |
set_call_expr_flags (arm_builtin_decls[fcode], cde->ecf_flag); |
| 1691 |
} |
| 1692 |
} |
| 1693 |
|
| 1694 |
/* Set up all the MVE builtins mentioned in arm_mve_builtins.def file. */ |
| 1695 |
static void |
| 1696 |
arm_init_mve_builtins (void) |
| 1697 |
{ |
| 1698 |
volatile unsigned int i, fcode = ARM_BUILTIN_MVE_PATTERN_START; |
| 1699 |
|
| 1700 |
arm_init_simd_builtin_scalar_types (); |
| 1701 |
arm_init_simd_builtin_types (); |
| 1702 |
|
| 1703 |
/* Add support for __builtin_{get,set}_fpscr_nzcvqc, used by MVE intrinsics |
| 1704 |
that read and/or write the carry bit. */ |
| 1705 |
tree get_fpscr_nzcvqc = build_function_type_list (intSI_type_node, |
| 1706 |
NULL); |
| 1707 |
tree set_fpscr_nzcvqc = build_function_type_list (void_type_node, |
| 1708 |
intSI_type_node, |
| 1709 |
NULL); |
| 1710 |
arm_builtin_decls[ARM_BUILTIN_GET_FPSCR_NZCVQC] |
| 1711 |
= arm_general_add_builtin_function ("__builtin_arm_get_fpscr_nzcvqc", |
| 1712 |
get_fpscr_nzcvqc, |
| 1713 |
ARM_BUILTIN_GET_FPSCR_NZCVQC); |
| 1714 |
arm_builtin_decls[ARM_BUILTIN_SET_FPSCR_NZCVQC] |
| 1715 |
= arm_general_add_builtin_function ("__builtin_arm_set_fpscr_nzcvqc", |
| 1716 |
set_fpscr_nzcvqc, |
| 1717 |
ARM_BUILTIN_SET_FPSCR_NZCVQC); |
| 1718 |
|
| 1719 |
for (i = 0; i < ARRAY_SIZE (mve_builtin_data); i++, fcode++) |
| 1720 |
{ |
| 1721 |
arm_builtin_datum *d = &mve_builtin_data[i]; |
| 1722 |
arm_init_builtin (fcode, d, "__builtin_mve"); |
| 1723 |
} |
| 1724 |
|
| 1725 |
if (in_lto_p) |
| 1726 |
{ |
| 1727 |
arm_mve::handle_arm_mve_types_h (); |
| 1728 |
/* Under LTO, we cannot know whether |
| 1729 |
__ARM_MVE_PRESERVE_USER_NAMESPACE was defined, so assume it |
| 1730 |
was not. */ |
| 1731 |
arm_mve::handle_arm_mve_h (false); |
| 1732 |
} |
| 1733 |
} |
| 1734 |
|
| 1735 |
/* Set up all the NEON builtins, even builtins for instructions that are not |
| 1736 |
in the current target ISA to allow the user to compile particular modules |
| 1737 |
with different target specific options that differ from the command line |
| 1738 |
options. Such builtins will be rejected in arm_general_expand_builtin. */ |
| 1739 |
|
| 1740 |
static void |
| 1741 |
arm_init_neon_builtins (void) |
| 1742 |
{ |
| 1743 |
unsigned int i, fcode = ARM_BUILTIN_NEON_PATTERN_START; |
| 1744 |
|
| 1745 |
arm_init_simd_builtin_types (); |
| 1746 |
|
| 1747 |
/* Strong-typing hasn't been implemented for all AdvSIMD builtin intrinsics. |
| 1748 |
Therefore we need to preserve the old __builtin scalar types. It can be |
| 1749 |
removed once all the intrinsics become strongly typed using the qualifier |
| 1750 |
system. */ |
| 1751 |
arm_init_simd_builtin_scalar_types (); |
| 1752 |
|
| 1753 |
for (i = 0; i < ARRAY_SIZE (neon_builtin_data); i++, fcode++) |
| 1754 |
{ |
| 1755 |
arm_builtin_datum *d = &neon_builtin_data[i]; |
| 1756 |
arm_init_builtin (fcode, d, "__builtin_neon"); |
| 1757 |
} |
| 1758 |
} |
| 1759 |
|
| 1760 |
/* Set up all the scalar floating point builtins. */ |
| 1761 |
|
| 1762 |
static void |
| 1763 |
arm_init_vfp_builtins (void) |
| 1764 |
{ |
| 1765 |
unsigned int i, fcode = ARM_BUILTIN_VFP_PATTERN_START; |
| 1766 |
|
| 1767 |
for (i = 0; i < ARRAY_SIZE (vfp_builtin_data); i++, fcode++) |
| 1768 |
{ |
| 1769 |
arm_builtin_datum *d = &vfp_builtin_data[i]; |
| 1770 |
arm_init_builtin (fcode, d, "__builtin_neon"); |
| 1771 |
} |
| 1772 |
} |
| 1773 |
|
| 1774 |
static void |
| 1775 |
arm_init_crypto_builtins (void) |
| 1776 |
{ |
| 1777 |
tree V16UQI_type_node |
| 1778 |
= arm_simd_builtin_type (V16QImode, qualifier_unsigned); |
| 1779 |
|
| 1780 |
tree V4USI_type_node |
| 1781 |
= arm_simd_builtin_type (V4SImode, qualifier_unsigned); |
| 1782 |
|
| 1783 |
tree v16uqi_ftype_v16uqi |
| 1784 |
= build_function_type_list (V16UQI_type_node, V16UQI_type_node, |
| 1785 |
NULL_TREE); |
| 1786 |
|
| 1787 |
tree v16uqi_ftype_v16uqi_v16uqi |
| 1788 |
= build_function_type_list (V16UQI_type_node, V16UQI_type_node, |
| 1789 |
V16UQI_type_node, NULL_TREE); |
| 1790 |
|
| 1791 |
tree v4usi_ftype_v4usi |
| 1792 |
= build_function_type_list (V4USI_type_node, V4USI_type_node, |
| 1793 |
NULL_TREE); |
| 1794 |
|
| 1795 |
tree v4usi_ftype_v4usi_v4usi |
| 1796 |
= build_function_type_list (V4USI_type_node, V4USI_type_node, |
| 1797 |
V4USI_type_node, NULL_TREE); |
| 1798 |
|
| 1799 |
tree v4usi_ftype_v4usi_v4usi_v4usi |
| 1800 |
= build_function_type_list (V4USI_type_node, V4USI_type_node, |
| 1801 |
V4USI_type_node, V4USI_type_node, |
| 1802 |
NULL_TREE); |
| 1803 |
|
| 1804 |
tree uti_ftype_udi_udi |
| 1805 |
= build_function_type_list (unsigned_intTI_type_node, |
| 1806 |
unsigned_intDI_type_node, |
| 1807 |
unsigned_intDI_type_node, |
| 1808 |
NULL_TREE); |
| 1809 |
|
| 1810 |
#undef CRYPTO1 |
| 1811 |
#undef CRYPTO2 |
| 1812 |
#undef CRYPTO3 |
| 1813 |
#undef C |
| 1814 |
#undef N |
| 1815 |
#undef CF |
| 1816 |
#undef FT1 |
| 1817 |
#undef FT2 |
| 1818 |
#undef FT3 |
| 1819 |
|
| 1820 |
#define C(U) \ |
| 1821 |
ARM_BUILTIN_CRYPTO_##U |
| 1822 |
#define N(L) \ |
| 1823 |
"__builtin_arm_crypto_"#L |
| 1824 |
#define FT1(R, A) \ |
| 1825 |
R##_ftype_##A |
| 1826 |
#define FT2(R, A1, A2) \ |
| 1827 |
R##_ftype_##A1##_##A2 |
| 1828 |
#define FT3(R, A1, A2, A3) \ |
| 1829 |
R##_ftype_##A1##_##A2##_##A3 |
| 1830 |
#define CRYPTO1(L, U, R, A) \ |
| 1831 |
arm_builtin_decls[C (U)] \ |
| 1832 |
= arm_general_add_builtin_function (N (L), FT1 (R, A), C (U)); |
| 1833 |
#define CRYPTO2(L, U, R, A1, A2) \ |
| 1834 |
arm_builtin_decls[C (U)] \ |
| 1835 |
= arm_general_add_builtin_function (N (L), FT2 (R, A1, A2), C (U)); |
| 1836 |
|
| 1837 |
#define CRYPTO3(L, U, R, A1, A2, A3) \ |
| 1838 |
arm_builtin_decls[C (U)] \ |
| 1839 |
= arm_general_add_builtin_function (N (L), FT3 (R, A1, A2, A3), C (U)); |
| 1840 |
#include "crypto.def" |
| 1841 |
|
| 1842 |
#undef CRYPTO1 |
| 1843 |
#undef CRYPTO2 |
| 1844 |
#undef CRYPTO3 |
| 1845 |
#undef C |
| 1846 |
#undef N |
| 1847 |
#undef FT1 |
| 1848 |
#undef FT2 |
| 1849 |
#undef FT3 |
| 1850 |
} |
| 1851 |
|
| 1852 |
#undef NUM_DREG_TYPES |
| 1853 |
#undef NUM_QREG_TYPES |
| 1854 |
|
| 1855 |
#define def_mbuiltin(FLAG, NAME, TYPE, CODE) \ |
| 1856 |
do \ |
| 1857 |
{ \ |
| 1858 |
if (FLAG == isa_nobit \ |
| 1859 |
|| bitmap_bit_p (arm_active_target.isa, FLAG)) \ |
| 1860 |
{ \ |
| 1861 |
tree bdecl; \ |
| 1862 |
bdecl = arm_general_add_builtin_function ((NAME), (TYPE), \ |
| 1863 |
(CODE)); \ |
| 1864 |
arm_builtin_decls[CODE] = bdecl; \ |
| 1865 |
} \ |
| 1866 |
} \ |
| 1867 |
while (0) |
| 1868 |
|
| 1869 |
struct builtin_description |
| 1870 |
{ |
| 1871 |
const enum isa_feature feature; |
| 1872 |
const enum insn_code icode; |
| 1873 |
const char * const name; |
| 1874 |
const enum arm_builtins code; |
| 1875 |
const enum rtx_code comparison; |
| 1876 |
const unsigned int flag; |
| 1877 |
}; |
| 1878 |
|
| 1879 |
static const struct builtin_description bdesc_2arg[] = |
| 1880 |
{ |
| 1881 |
#define IWMMXT_BUILTIN(code, string, builtin) \ |
| 1882 |
{ isa_bit_iwmmxt, CODE_FOR_##code, \ |
| 1883 |
"__builtin_arm_" string, \ |
| 1884 |
ARM_BUILTIN_##builtin, UNKNOWN, 0 }, |
| 1885 |
|
| 1886 |
#define IWMMXT2_BUILTIN(code, string, builtin) \ |
| 1887 |
{ isa_bit_iwmmxt2, CODE_FOR_##code, \ |
| 1888 |
"__builtin_arm_" string, \ |
| 1889 |
ARM_BUILTIN_##builtin, UNKNOWN, 0 }, |
| 1890 |
|
| 1891 |
IWMMXT_BUILTIN (addv8qi3, "waddb", WADDB) |
| 1892 |
IWMMXT_BUILTIN (addv4hi3, "waddh", WADDH) |
| 1893 |
IWMMXT_BUILTIN (addv2si3, "waddw", WADDW) |
| 1894 |
IWMMXT_BUILTIN (subv8qi3, "wsubb", WSUBB) |
| 1895 |
IWMMXT_BUILTIN (subv4hi3, "wsubh", WSUBH) |
| 1896 |
IWMMXT_BUILTIN (subv2si3, "wsubw", WSUBW) |
| 1897 |
IWMMXT_BUILTIN (ssaddv8qi3, "waddbss", WADDSSB) |
| 1898 |
IWMMXT_BUILTIN (ssaddv4hi3, "waddhss", WADDSSH) |
| 1899 |
IWMMXT_BUILTIN (ssaddv2si3, "waddwss", WADDSSW) |
| 1900 |
IWMMXT_BUILTIN (sssubv8qi3, "wsubbss", WSUBSSB) |
| 1901 |
IWMMXT_BUILTIN (sssubv4hi3, "wsubhss", WSUBSSH) |
| 1902 |
IWMMXT_BUILTIN (sssubv2si3, "wsubwss", WSUBSSW) |
| 1903 |
IWMMXT_BUILTIN (usaddv8qi3, "waddbus", WADDUSB) |
| 1904 |
IWMMXT_BUILTIN (usaddv4hi3, "waddhus", WADDUSH) |
| 1905 |
IWMMXT_BUILTIN (usaddv2si3, "waddwus", WADDUSW) |
| 1906 |
IWMMXT_BUILTIN (ussubv8qi3, "wsubbus", WSUBUSB) |
| 1907 |
IWMMXT_BUILTIN (ussubv4hi3, "wsubhus", WSUBUSH) |
| 1908 |
IWMMXT_BUILTIN (ussubv2si3, "wsubwus", WSUBUSW) |
| 1909 |
IWMMXT_BUILTIN (mulv4hi3, "wmulul", WMULUL) |
| 1910 |
IWMMXT_BUILTIN (smulv4hi3_highpart, "wmulsm", WMULSM) |
| 1911 |
IWMMXT_BUILTIN (umulv4hi3_highpart, "wmulum", WMULUM) |
| 1912 |
IWMMXT_BUILTIN (eqv8qi3, "wcmpeqb", WCMPEQB) |
| 1913 |
IWMMXT_BUILTIN (eqv4hi3, "wcmpeqh", WCMPEQH) |
| 1914 |
IWMMXT_BUILTIN (eqv2si3, "wcmpeqw", WCMPEQW) |
| 1915 |
IWMMXT_BUILTIN (gtuv8qi3, "wcmpgtub", WCMPGTUB) |
| 1916 |
IWMMXT_BUILTIN (gtuv4hi3, "wcmpgtuh", WCMPGTUH) |
| 1917 |
IWMMXT_BUILTIN (gtuv2si3, "wcmpgtuw", WCMPGTUW) |
| 1918 |
IWMMXT_BUILTIN (gtv8qi3, "wcmpgtsb", WCMPGTSB) |
| 1919 |
IWMMXT_BUILTIN (gtv4hi3, "wcmpgtsh", WCMPGTSH) |
| 1920 |
IWMMXT_BUILTIN (gtv2si3, "wcmpgtsw", WCMPGTSW) |
| 1921 |
IWMMXT_BUILTIN (umaxv8qi3, "wmaxub", WMAXUB) |
| 1922 |
IWMMXT_BUILTIN (smaxv8qi3, "wmaxsb", WMAXSB) |
| 1923 |
IWMMXT_BUILTIN (umaxv4hi3, "wmaxuh", WMAXUH) |
| 1924 |
IWMMXT_BUILTIN (smaxv4hi3, "wmaxsh", WMAXSH) |
| 1925 |
IWMMXT_BUILTIN (umaxv2si3, "wmaxuw", WMAXUW) |
| 1926 |
IWMMXT_BUILTIN (smaxv2si3, "wmaxsw", WMAXSW) |
| 1927 |
IWMMXT_BUILTIN (uminv8qi3, "wminub", WMINUB) |
| 1928 |
IWMMXT_BUILTIN (sminv8qi3, "wminsb", WMINSB) |
| 1929 |
IWMMXT_BUILTIN (uminv4hi3, "wminuh", WMINUH) |
| 1930 |
IWMMXT_BUILTIN (sminv4hi3, "wminsh", WMINSH) |
| 1931 |
IWMMXT_BUILTIN (uminv2si3, "wminuw", WMINUW) |
| 1932 |
IWMMXT_BUILTIN (sminv2si3, "wminsw", WMINSW) |
| 1933 |
IWMMXT_BUILTIN (iwmmxt_anddi3, "wand", WAND) |
| 1934 |
IWMMXT_BUILTIN (iwmmxt_nanddi3, "wandn", WANDN) |
| 1935 |
IWMMXT_BUILTIN (iwmmxt_iordi3, "wor", WOR) |
| 1936 |
IWMMXT_BUILTIN (iwmmxt_xordi3, "wxor", WXOR) |
| 1937 |
IWMMXT_BUILTIN (iwmmxt_uavgv8qi3, "wavg2b", WAVG2B) |
| 1938 |
IWMMXT_BUILTIN (iwmmxt_uavgv4hi3, "wavg2h", WAVG2H) |
| 1939 |
IWMMXT_BUILTIN (iwmmxt_uavgrndv8qi3, "wavg2br", WAVG2BR) |
| 1940 |
IWMMXT_BUILTIN (iwmmxt_uavgrndv4hi3, "wavg2hr", WAVG2HR) |
| 1941 |
IWMMXT_BUILTIN (iwmmxt_wunpckilb, "wunpckilb", WUNPCKILB) |
| 1942 |
IWMMXT_BUILTIN (iwmmxt_wunpckilh, "wunpckilh", WUNPCKILH) |
| 1943 |
IWMMXT_BUILTIN (iwmmxt_wunpckilw, "wunpckilw", WUNPCKILW) |
| 1944 |
IWMMXT_BUILTIN (iwmmxt_wunpckihb, "wunpckihb", WUNPCKIHB) |
| 1945 |
IWMMXT_BUILTIN (iwmmxt_wunpckihh, "wunpckihh", WUNPCKIHH) |
| 1946 |
IWMMXT_BUILTIN (iwmmxt_wunpckihw, "wunpckihw", WUNPCKIHW) |
| 1947 |
IWMMXT2_BUILTIN (iwmmxt_waddsubhx, "waddsubhx", WADDSUBHX) |
| 1948 |
IWMMXT2_BUILTIN (iwmmxt_wsubaddhx, "wsubaddhx", WSUBADDHX) |
| 1949 |
IWMMXT2_BUILTIN (iwmmxt_wabsdiffb, "wabsdiffb", WABSDIFFB) |
| 1950 |
IWMMXT2_BUILTIN (iwmmxt_wabsdiffh, "wabsdiffh", WABSDIFFH) |
| 1951 |
IWMMXT2_BUILTIN (iwmmxt_wabsdiffw, "wabsdiffw", WABSDIFFW) |
| 1952 |
IWMMXT2_BUILTIN (iwmmxt_avg4, "wavg4", WAVG4) |
| 1953 |
IWMMXT2_BUILTIN (iwmmxt_avg4r, "wavg4r", WAVG4R) |
| 1954 |
IWMMXT2_BUILTIN (iwmmxt_wmulwsm, "wmulwsm", WMULWSM) |
| 1955 |
IWMMXT2_BUILTIN (iwmmxt_wmulwum, "wmulwum", WMULWUM) |
| 1956 |
IWMMXT2_BUILTIN (iwmmxt_wmulwsmr, "wmulwsmr", WMULWSMR) |
| 1957 |
IWMMXT2_BUILTIN (iwmmxt_wmulwumr, "wmulwumr", WMULWUMR) |
| 1958 |
IWMMXT2_BUILTIN (iwmmxt_wmulwl, "wmulwl", WMULWL) |
| 1959 |
IWMMXT2_BUILTIN (iwmmxt_wmulsmr, "wmulsmr", WMULSMR) |
| 1960 |
IWMMXT2_BUILTIN (iwmmxt_wmulumr, "wmulumr", WMULUMR) |
| 1961 |
IWMMXT2_BUILTIN (iwmmxt_wqmulm, "wqmulm", WQMULM) |
| 1962 |
IWMMXT2_BUILTIN (iwmmxt_wqmulmr, "wqmulmr", WQMULMR) |
| 1963 |
IWMMXT2_BUILTIN (iwmmxt_wqmulwm, "wqmulwm", WQMULWM) |
| 1964 |
IWMMXT2_BUILTIN (iwmmxt_wqmulwmr, "wqmulwmr", WQMULWMR) |
| 1965 |
IWMMXT_BUILTIN (iwmmxt_walignr0, "walignr0", WALIGNR0) |
| 1966 |
IWMMXT_BUILTIN (iwmmxt_walignr1, "walignr1", WALIGNR1) |
| 1967 |
IWMMXT_BUILTIN (iwmmxt_walignr2, "walignr2", WALIGNR2) |
| 1968 |
IWMMXT_BUILTIN (iwmmxt_walignr3, "walignr3", WALIGNR3) |
| 1969 |
|
| 1970 |
#define IWMMXT_BUILTIN2(code, builtin) \ |
| 1971 |
{ isa_bit_iwmmxt, CODE_FOR_##code, NULL, \ |
| 1972 |
ARM_BUILTIN_##builtin, UNKNOWN, 0 }, |
| 1973 |
|
| 1974 |
#define IWMMXT2_BUILTIN2(code, builtin) \ |
| 1975 |
{ isa_bit_iwmmxt2, CODE_FOR_##code, NULL, \ |
| 1976 |
ARM_BUILTIN_##builtin, UNKNOWN, 0 }, |
| 1977 |
|
| 1978 |
IWMMXT2_BUILTIN2 (iwmmxt_waddbhusm, WADDBHUSM) |
| 1979 |
IWMMXT2_BUILTIN2 (iwmmxt_waddbhusl, WADDBHUSL) |
| 1980 |
IWMMXT_BUILTIN2 (iwmmxt_wpackhss, WPACKHSS) |
| 1981 |
IWMMXT_BUILTIN2 (iwmmxt_wpackwss, WPACKWSS) |
| 1982 |
IWMMXT_BUILTIN2 (iwmmxt_wpackdss, WPACKDSS) |
| 1983 |
IWMMXT_BUILTIN2 (iwmmxt_wpackhus, WPACKHUS) |
| 1984 |
IWMMXT_BUILTIN2 (iwmmxt_wpackwus, WPACKWUS) |
| 1985 |
IWMMXT_BUILTIN2 (iwmmxt_wpackdus, WPACKDUS) |
| 1986 |
IWMMXT_BUILTIN2 (iwmmxt_wmacuz, WMACUZ) |
| 1987 |
IWMMXT_BUILTIN2 (iwmmxt_wmacsz, WMACSZ) |
| 1988 |
|
| 1989 |
|
| 1990 |
#define FP_BUILTIN(L, U) \ |
| 1991 |
{isa_nobit, CODE_FOR_##L, "__builtin_arm_"#L, ARM_BUILTIN_##U, \ |
| 1992 |
UNKNOWN, 0}, |
| 1993 |
|
| 1994 |
FP_BUILTIN (get_fpscr, GET_FPSCR) |
| 1995 |
FP_BUILTIN (set_fpscr, SET_FPSCR) |
| 1996 |
#undef FP_BUILTIN |
| 1997 |
|
| 1998 |
#define CRYPTO_BUILTIN(L, U) \ |
| 1999 |
{isa_nobit, CODE_FOR_crypto_##L, "__builtin_arm_crypto_"#L, \ |
| 2000 |
ARM_BUILTIN_CRYPTO_##U, UNKNOWN, 0}, |
| 2001 |
#undef CRYPTO1 |
| 2002 |
#undef CRYPTO2 |
| 2003 |
#undef CRYPTO3 |
| 2004 |
#define CRYPTO2(L, U, R, A1, A2) CRYPTO_BUILTIN (L, U) |
| 2005 |
#define CRYPTO1(L, U, R, A) |
| 2006 |
#define CRYPTO3(L, U, R, A1, A2, A3) |
| 2007 |
#include "crypto.def" |
| 2008 |
#undef CRYPTO1 |
| 2009 |
#undef CRYPTO2 |
| 2010 |
#undef CRYPTO3 |
| 2011 |
|
| 2012 |
}; |
| 2013 |
|
| 2014 |
static const struct builtin_description bdesc_1arg[] = |
| 2015 |
{ |
| 2016 |
IWMMXT_BUILTIN (iwmmxt_tmovmskb, "tmovmskb", TMOVMSKB) |
| 2017 |
IWMMXT_BUILTIN (iwmmxt_tmovmskh, "tmovmskh", TMOVMSKH) |
| 2018 |
IWMMXT_BUILTIN (iwmmxt_tmovmskw, "tmovmskw", TMOVMSKW) |
| 2019 |
IWMMXT_BUILTIN (iwmmxt_waccb, "waccb", WACCB) |
| 2020 |
IWMMXT_BUILTIN (iwmmxt_wacch, "wacch", WACCH) |
| 2021 |
IWMMXT_BUILTIN (iwmmxt_waccw, "waccw", WACCW) |
| 2022 |
IWMMXT_BUILTIN (iwmmxt_wunpckehub, "wunpckehub", WUNPCKEHUB) |
| 2023 |
IWMMXT_BUILTIN (iwmmxt_wunpckehuh, "wunpckehuh", WUNPCKEHUH) |
| 2024 |
IWMMXT_BUILTIN (iwmmxt_wunpckehuw, "wunpckehuw", WUNPCKEHUW) |
| 2025 |
IWMMXT_BUILTIN (iwmmxt_wunpckehsb, "wunpckehsb", WUNPCKEHSB) |
| 2026 |
IWMMXT_BUILTIN (iwmmxt_wunpckehsh, "wunpckehsh", WUNPCKEHSH) |
| 2027 |
IWMMXT_BUILTIN (iwmmxt_wunpckehsw, "wunpckehsw", WUNPCKEHSW) |
| 2028 |
IWMMXT_BUILTIN (iwmmxt_wunpckelub, "wunpckelub", WUNPCKELUB) |
| 2029 |
IWMMXT_BUILTIN (iwmmxt_wunpckeluh, "wunpckeluh", WUNPCKELUH) |
| 2030 |
IWMMXT_BUILTIN (iwmmxt_wunpckeluw, "wunpckeluw", WUNPCKELUW) |
| 2031 |
IWMMXT_BUILTIN (iwmmxt_wunpckelsb, "wunpckelsb", WUNPCKELSB) |
| 2032 |
IWMMXT_BUILTIN (iwmmxt_wunpckelsh, "wunpckelsh", WUNPCKELSH) |
| 2033 |
IWMMXT_BUILTIN (iwmmxt_wunpckelsw, "wunpckelsw", WUNPCKELSW) |
| 2034 |
IWMMXT2_BUILTIN (iwmmxt_wabsv8qi3, "wabsb", WABSB) |
| 2035 |
IWMMXT2_BUILTIN (iwmmxt_wabsv4hi3, "wabsh", WABSH) |
| 2036 |
IWMMXT2_BUILTIN (iwmmxt_wabsv2si3, "wabsw", WABSW) |
| 2037 |
IWMMXT_BUILTIN (tbcstv8qi, "tbcstb", TBCSTB) |
| 2038 |
IWMMXT_BUILTIN (tbcstv4hi, "tbcsth", TBCSTH) |
| 2039 |
IWMMXT_BUILTIN (tbcstv2si, "tbcstw", TBCSTW) |
| 2040 |
|
| 2041 |
#define CRYPTO1(L, U, R, A) CRYPTO_BUILTIN (L, U) |
| 2042 |
#define CRYPTO2(L, U, R, A1, A2) |
| 2043 |
#define CRYPTO3(L, U, R, A1, A2, A3) |
| 2044 |
#include "crypto.def" |
| 2045 |
#undef CRYPTO1 |
| 2046 |
#undef CRYPTO2 |
| 2047 |
#undef CRYPTO3 |
| 2048 |
}; |
| 2049 |
|
| 2050 |
static const struct builtin_description bdesc_3arg[] = |
| 2051 |
{ |
| 2052 |
#define CRYPTO3(L, U, R, A1, A2, A3) CRYPTO_BUILTIN (L, U) |
| 2053 |
#define CRYPTO1(L, U, R, A) |
| 2054 |
#define CRYPTO2(L, U, R, A1, A2) |
| 2055 |
#include "crypto.def" |
| 2056 |
#undef CRYPTO1 |
| 2057 |
#undef CRYPTO2 |
| 2058 |
#undef CRYPTO3 |
| 2059 |
}; |
| 2060 |
#undef CRYPTO_BUILTIN |
| 2061 |
|
| 2062 |
/* Set up all the iWMMXt builtins. This is not called if |
| 2063 |
TARGET_IWMMXT is zero. */ |
| 2064 |
|
| 2065 |
static void |
| 2066 |
arm_init_iwmmxt_builtins (void) |
| 2067 |
{ |
| 2068 |
const struct builtin_description * d; |
| 2069 |
size_t i; |
| 2070 |
|
| 2071 |
tree V2SI_type_node = build_vector_type_for_mode (intSI_type_node, V2SImode); |
| 2072 |
tree V4HI_type_node = build_vector_type_for_mode (intHI_type_node, V4HImode); |
| 2073 |
tree V8QI_type_node = build_vector_type_for_mode (intQI_type_node, V8QImode); |
| 2074 |
|
| 2075 |
tree v8qi_ftype_v8qi_v8qi_int |
| 2076 |
= build_function_type_list (V8QI_type_node, |
| 2077 |
V8QI_type_node, V8QI_type_node, |
| 2078 |
integer_type_node, NULL_TREE); |
| 2079 |
tree v4hi_ftype_v4hi_int |
| 2080 |
= build_function_type_list (V4HI_type_node, |
| 2081 |
V4HI_type_node, integer_type_node, NULL_TREE); |
| 2082 |
tree v2si_ftype_v2si_int |
| 2083 |
= build_function_type_list (V2SI_type_node, |
| 2084 |
V2SI_type_node, integer_type_node, NULL_TREE); |
| 2085 |
tree v2si_ftype_di_di |
| 2086 |
= build_function_type_list (V2SI_type_node, |
| 2087 |
long_long_integer_type_node, |
| 2088 |
long_long_integer_type_node, |
| 2089 |
NULL_TREE); |
| 2090 |
tree di_ftype_di_int |
| 2091 |
= build_function_type_list (long_long_integer_type_node, |
| 2092 |
long_long_integer_type_node, |
| 2093 |
integer_type_node, NULL_TREE); |
| 2094 |
tree di_ftype_di_int_int |
| 2095 |
= build_function_type_list (long_long_integer_type_node, |
| 2096 |
long_long_integer_type_node, |
| 2097 |
integer_type_node, |
| 2098 |
integer_type_node, NULL_TREE); |
| 2099 |
tree int_ftype_v8qi |
| 2100 |
= build_function_type_list (integer_type_node, |
| 2101 |
V8QI_type_node, NULL_TREE); |
| 2102 |
tree int_ftype_v4hi |
| 2103 |
= build_function_type_list (integer_type_node, |
| 2104 |
V4HI_type_node, NULL_TREE); |
| 2105 |
tree int_ftype_v2si |
| 2106 |
= build_function_type_list (integer_type_node, |
| 2107 |
V2SI_type_node, NULL_TREE); |
| 2108 |
tree int_ftype_v8qi_int |
| 2109 |
= build_function_type_list (integer_type_node, |
| 2110 |
V8QI_type_node, integer_type_node, NULL_TREE); |
| 2111 |
tree int_ftype_v4hi_int |
| 2112 |
= build_function_type_list (integer_type_node, |
| 2113 |
V4HI_type_node, integer_type_node, NULL_TREE); |
| 2114 |
tree int_ftype_v2si_int |
| 2115 |
= build_function_type_list (integer_type_node, |
| 2116 |
V2SI_type_node, integer_type_node, NULL_TREE); |
| 2117 |
tree v8qi_ftype_v8qi_int_int |
| 2118 |
= build_function_type_list (V8QI_type_node, |
| 2119 |
V8QI_type_node, integer_type_node, |
| 2120 |
integer_type_node, NULL_TREE); |
| 2121 |
tree v4hi_ftype_v4hi_int_int |
| 2122 |
= build_function_type_list (V4HI_type_node, |
| 2123 |
V4HI_type_node, integer_type_node, |
| 2124 |
integer_type_node, NULL_TREE); |
| 2125 |
tree v2si_ftype_v2si_int_int |
| 2126 |
= build_function_type_list (V2SI_type_node, |
| 2127 |
V2SI_type_node, integer_type_node, |
| 2128 |
integer_type_node, NULL_TREE); |
| 2129 |
/* Miscellaneous. */ |
| 2130 |
tree v8qi_ftype_v4hi_v4hi |
| 2131 |
= build_function_type_list (V8QI_type_node, |
| 2132 |
V4HI_type_node, V4HI_type_node, NULL_TREE); |
| 2133 |
tree v4hi_ftype_v2si_v2si |
| 2134 |
= build_function_type_list (V4HI_type_node, |
| 2135 |
V2SI_type_node, V2SI_type_node, NULL_TREE); |
| 2136 |
tree v8qi_ftype_v4hi_v8qi |
| 2137 |
= build_function_type_list (V8QI_type_node, |
| 2138 |
V4HI_type_node, V8QI_type_node, NULL_TREE); |
| 2139 |
tree v2si_ftype_v4hi_v4hi |
| 2140 |
= build_function_type_list (V2SI_type_node, |
| 2141 |
V4HI_type_node, V4HI_type_node, NULL_TREE); |
| 2142 |
tree v2si_ftype_v8qi_v8qi |
| 2143 |
= build_function_type_list (V2SI_type_node, |
| 2144 |
V8QI_type_node, V8QI_type_node, NULL_TREE); |
| 2145 |
tree v4hi_ftype_v4hi_di |
| 2146 |
= build_function_type_list (V4HI_type_node, |
| 2147 |
V4HI_type_node, long_long_integer_type_node, |
| 2148 |
NULL_TREE); |
| 2149 |
tree v2si_ftype_v2si_di |
| 2150 |
= build_function_type_list (V2SI_type_node, |
| 2151 |
V2SI_type_node, long_long_integer_type_node, |
| 2152 |
NULL_TREE); |
| 2153 |
tree di_ftype_void |
| 2154 |
= build_function_type_list (long_long_unsigned_type_node, NULL_TREE); |
| 2155 |
tree int_ftype_void |
| 2156 |
= build_function_type_list (integer_type_node, NULL_TREE); |
| 2157 |
tree di_ftype_v8qi |
| 2158 |
= build_function_type_list (long_long_integer_type_node, |
| 2159 |
V8QI_type_node, NULL_TREE); |
| 2160 |
tree di_ftype_v4hi |
| 2161 |
= build_function_type_list (long_long_integer_type_node, |
| 2162 |
V4HI_type_node, NULL_TREE); |
| 2163 |
tree di_ftype_v2si |
| 2164 |
= build_function_type_list (long_long_integer_type_node, |
| 2165 |
V2SI_type_node, NULL_TREE); |
| 2166 |
tree v2si_ftype_v4hi |
| 2167 |
= build_function_type_list (V2SI_type_node, |
| 2168 |
V4HI_type_node, NULL_TREE); |
| 2169 |
tree v4hi_ftype_v8qi |
| 2170 |
= build_function_type_list (V4HI_type_node, |
| 2171 |
V8QI_type_node, NULL_TREE); |
| 2172 |
tree v8qi_ftype_v8qi |
| 2173 |
= build_function_type_list (V8QI_type_node, |
| 2174 |
V8QI_type_node, NULL_TREE); |
| 2175 |
tree v4hi_ftype_v4hi |
| 2176 |
= build_function_type_list (V4HI_type_node, |
| 2177 |
V4HI_type_node, NULL_TREE); |
| 2178 |
tree v2si_ftype_v2si |
| 2179 |
= build_function_type_list (V2SI_type_node, |
| 2180 |
V2SI_type_node, NULL_TREE); |
| 2181 |
|
| 2182 |
tree di_ftype_di_v4hi_v4hi |
| 2183 |
= build_function_type_list (long_long_unsigned_type_node, |
| 2184 |
long_long_unsigned_type_node, |
| 2185 |
V4HI_type_node, V4HI_type_node, |
| 2186 |
NULL_TREE); |
| 2187 |
|
| 2188 |
tree di_ftype_v4hi_v4hi |
| 2189 |
= build_function_type_list (long_long_unsigned_type_node, |
| 2190 |
V4HI_type_node,V4HI_type_node, |
| 2191 |
NULL_TREE); |
| 2192 |
|
| 2193 |
tree v2si_ftype_v2si_v4hi_v4hi |
| 2194 |
= build_function_type_list (V2SI_type_node, |
| 2195 |
V2SI_type_node, V4HI_type_node, |
| 2196 |
V4HI_type_node, NULL_TREE); |
| 2197 |
|
| 2198 |
tree v2si_ftype_v2si_v8qi_v8qi |
| 2199 |
= build_function_type_list (V2SI_type_node, |
| 2200 |
V2SI_type_node, V8QI_type_node, |
| 2201 |
V8QI_type_node, NULL_TREE); |
| 2202 |
|
| 2203 |
tree di_ftype_di_v2si_v2si |
| 2204 |
= build_function_type_list (long_long_unsigned_type_node, |
| 2205 |
long_long_unsigned_type_node, |
| 2206 |
V2SI_type_node, V2SI_type_node, |
| 2207 |
NULL_TREE); |
| 2208 |
|
| 2209 |
tree di_ftype_di_di_int |
| 2210 |
= build_function_type_list (long_long_unsigned_type_node, |
| 2211 |
long_long_unsigned_type_node, |
| 2212 |
long_long_unsigned_type_node, |
| 2213 |
integer_type_node, NULL_TREE); |
| 2214 |
|
| 2215 |
tree void_ftype_int |
| 2216 |
= build_function_type_list (void_type_node, |
| 2217 |
integer_type_node, NULL_TREE); |
| 2218 |
|
| 2219 |
tree v8qi_ftype_char |
| 2220 |
= build_function_type_list (V8QI_type_node, |
| 2221 |
signed_char_type_node, NULL_TREE); |
| 2222 |
|
| 2223 |
tree v4hi_ftype_short |
| 2224 |
= build_function_type_list (V4HI_type_node, |
| 2225 |
short_integer_type_node, NULL_TREE); |
| 2226 |
|
| 2227 |
tree v2si_ftype_int |
| 2228 |
= build_function_type_list (V2SI_type_node, |
| 2229 |
integer_type_node, NULL_TREE); |
| 2230 |
|
| 2231 |
/* Normal vector binops. */ |
| 2232 |
tree v8qi_ftype_v8qi_v8qi |
| 2233 |
= build_function_type_list (V8QI_type_node, |
| 2234 |
V8QI_type_node, V8QI_type_node, NULL_TREE); |
| 2235 |
tree v4hi_ftype_v4hi_v4hi |
| 2236 |
= build_function_type_list (V4HI_type_node, |
| 2237 |
V4HI_type_node,V4HI_type_node, NULL_TREE); |
| 2238 |
tree v2si_ftype_v2si_v2si |
| 2239 |
= build_function_type_list (V2SI_type_node, |
| 2240 |
V2SI_type_node, V2SI_type_node, NULL_TREE); |
| 2241 |
tree di_ftype_di_di |
| 2242 |
= build_function_type_list (long_long_unsigned_type_node, |
| 2243 |
long_long_unsigned_type_node, |
| 2244 |
long_long_unsigned_type_node, |
| 2245 |
NULL_TREE); |
| 2246 |
|
| 2247 |
/* Add all builtins that are more or less simple operations on two |
| 2248 |
operands. */ |
| 2249 |
for (i = 0, d = bdesc_2arg; i < ARRAY_SIZE (bdesc_2arg); i++, d++) |
| 2250 |
{ |
| 2251 |
/* Use one of the operands; the target can have a different mode for |
| 2252 |
mask-generating compares. */ |
| 2253 |
machine_mode mode; |
| 2254 |
tree type; |
| 2255 |
|
| 2256 |
if (d->name == 0 |
| 2257 |
|| !(d->feature == isa_bit_iwmmxt |
| 2258 |
|| d->feature == isa_bit_iwmmxt2)) |
| 2259 |
continue; |
| 2260 |
|
| 2261 |
mode = insn_data[d->icode].operand[1].mode; |
| 2262 |
|
| 2263 |
switch (mode) |
| 2264 |
{ |
| 2265 |
case E_V8QImode: |
| 2266 |
type = v8qi_ftype_v8qi_v8qi; |
| 2267 |
break; |
| 2268 |
case E_V4HImode: |
| 2269 |
type = v4hi_ftype_v4hi_v4hi; |
| 2270 |
break; |
| 2271 |
case E_V2SImode: |
| 2272 |
type = v2si_ftype_v2si_v2si; |
| 2273 |
break; |
| 2274 |
case E_DImode: |
| 2275 |
type = di_ftype_di_di; |
| 2276 |
break; |
| 2277 |
|
| 2278 |
default: |
| 2279 |
gcc_unreachable (); |
| 2280 |
} |
| 2281 |
|
| 2282 |
def_mbuiltin (d->feature, d->name, type, d->code); |
| 2283 |
} |
| 2284 |
|
| 2285 |
/* Add the remaining MMX insns with somewhat more complicated types. */ |
| 2286 |
#define iwmmx_mbuiltin(NAME, TYPE, CODE) \ |
| 2287 |
def_mbuiltin (isa_bit_iwmmxt, "__builtin_arm_" NAME, \ |
| 2288 |
(TYPE), ARM_BUILTIN_ ## CODE) |
| 2289 |
|
| 2290 |
#define iwmmx2_mbuiltin(NAME, TYPE, CODE) \ |
| 2291 |
def_mbuiltin (isa_bit_iwmmxt2, "__builtin_arm_" NAME, \ |
| 2292 |
(TYPE), ARM_BUILTIN_ ## CODE) |
| 2293 |
|
| 2294 |
iwmmx_mbuiltin ("wzero", di_ftype_void, WZERO); |
| 2295 |
iwmmx_mbuiltin ("setwcgr0", void_ftype_int, SETWCGR0); |
| 2296 |
iwmmx_mbuiltin ("setwcgr1", void_ftype_int, SETWCGR1); |
| 2297 |
iwmmx_mbuiltin ("setwcgr2", void_ftype_int, SETWCGR2); |
| 2298 |
iwmmx_mbuiltin ("setwcgr3", void_ftype_int, SETWCGR3); |
| 2299 |
iwmmx_mbuiltin ("getwcgr0", int_ftype_void, GETWCGR0); |
| 2300 |
iwmmx_mbuiltin ("getwcgr1", int_ftype_void, GETWCGR1); |
| 2301 |
iwmmx_mbuiltin ("getwcgr2", int_ftype_void, GETWCGR2); |
| 2302 |
iwmmx_mbuiltin ("getwcgr3", int_ftype_void, GETWCGR3); |
| 2303 |
|
| 2304 |
iwmmx_mbuiltin ("wsllh", v4hi_ftype_v4hi_di, WSLLH); |
| 2305 |
iwmmx_mbuiltin ("wsllw", v2si_ftype_v2si_di, WSLLW); |
| 2306 |
iwmmx_mbuiltin ("wslld", di_ftype_di_di, WSLLD); |
| 2307 |
iwmmx_mbuiltin ("wsllhi", v4hi_ftype_v4hi_int, WSLLHI); |
| 2308 |
iwmmx_mbuiltin ("wsllwi", v2si_ftype_v2si_int, WSLLWI); |
| 2309 |
iwmmx_mbuiltin ("wslldi", di_ftype_di_int, WSLLDI); |
| 2310 |
|
| 2311 |
iwmmx_mbuiltin ("wsrlh", v4hi_ftype_v4hi_di, WSRLH); |
| 2312 |
iwmmx_mbuiltin ("wsrlw", v2si_ftype_v2si_di, WSRLW); |
| 2313 |
iwmmx_mbuiltin ("wsrld", di_ftype_di_di, WSRLD); |
| 2314 |
iwmmx_mbuiltin ("wsrlhi", v4hi_ftype_v4hi_int, WSRLHI); |
| 2315 |
iwmmx_mbuiltin ("wsrlwi", v2si_ftype_v2si_int, WSRLWI); |
| 2316 |
iwmmx_mbuiltin ("wsrldi", di_ftype_di_int, WSRLDI); |
| 2317 |
|
| 2318 |
iwmmx_mbuiltin ("wsrah", v4hi_ftype_v4hi_di, WSRAH); |
| 2319 |
iwmmx_mbuiltin ("wsraw", v2si_ftype_v2si_di, WSRAW); |
| 2320 |
iwmmx_mbuiltin ("wsrad", di_ftype_di_di, WSRAD); |
| 2321 |
iwmmx_mbuiltin ("wsrahi", v4hi_ftype_v4hi_int, WSRAHI); |
| 2322 |
iwmmx_mbuiltin ("wsrawi", v2si_ftype_v2si_int, WSRAWI); |
| 2323 |
iwmmx_mbuiltin ("wsradi", di_ftype_di_int, WSRADI); |
| 2324 |
|
| 2325 |
iwmmx_mbuiltin ("wrorh", v4hi_ftype_v4hi_di, WRORH); |
| 2326 |
iwmmx_mbuiltin ("wrorw", v2si_ftype_v2si_di, WRORW); |
| 2327 |
iwmmx_mbuiltin ("wrord", di_ftype_di_di, WRORD); |
| 2328 |
iwmmx_mbuiltin ("wrorhi", v4hi_ftype_v4hi_int, WRORHI); |
| 2329 |
iwmmx_mbuiltin ("wrorwi", v2si_ftype_v2si_int, WRORWI); |
| 2330 |
iwmmx_mbuiltin ("wrordi", di_ftype_di_int, WRORDI); |
| 2331 |
|
| 2332 |
iwmmx_mbuiltin ("wshufh", v4hi_ftype_v4hi_int, WSHUFH); |
| 2333 |
|
| 2334 |
iwmmx_mbuiltin ("wsadb", v2si_ftype_v2si_v8qi_v8qi, WSADB); |
| 2335 |
iwmmx_mbuiltin ("wsadh", v2si_ftype_v2si_v4hi_v4hi, WSADH); |
| 2336 |
iwmmx_mbuiltin ("wmadds", v2si_ftype_v4hi_v4hi, WMADDS); |
| 2337 |
iwmmx2_mbuiltin ("wmaddsx", v2si_ftype_v4hi_v4hi, WMADDSX); |
| 2338 |
iwmmx2_mbuiltin ("wmaddsn", v2si_ftype_v4hi_v4hi, WMADDSN); |
| 2339 |
iwmmx_mbuiltin ("wmaddu", v2si_ftype_v4hi_v4hi, WMADDU); |
| 2340 |
iwmmx2_mbuiltin ("wmaddux", v2si_ftype_v4hi_v4hi, WMADDUX); |
| 2341 |
iwmmx2_mbuiltin ("wmaddun", v2si_ftype_v4hi_v4hi, WMADDUN); |
| 2342 |
iwmmx_mbuiltin ("wsadbz", v2si_ftype_v8qi_v8qi, WSADBZ); |
| 2343 |
iwmmx_mbuiltin ("wsadhz", v2si_ftype_v4hi_v4hi, WSADHZ); |
| 2344 |
|
| 2345 |
iwmmx_mbuiltin ("textrmsb", int_ftype_v8qi_int, TEXTRMSB); |
| 2346 |
iwmmx_mbuiltin ("textrmsh", int_ftype_v4hi_int, TEXTRMSH); |
| 2347 |
iwmmx_mbuiltin ("textrmsw", int_ftype_v2si_int, TEXTRMSW); |
| 2348 |
iwmmx_mbuiltin ("textrmub", int_ftype_v8qi_int, TEXTRMUB); |
| 2349 |
iwmmx_mbuiltin ("textrmuh", int_ftype_v4hi_int, TEXTRMUH); |
| 2350 |
iwmmx_mbuiltin ("textrmuw", int_ftype_v2si_int, TEXTRMUW); |
| 2351 |
iwmmx_mbuiltin ("tinsrb", v8qi_ftype_v8qi_int_int, TINSRB); |
| 2352 |
iwmmx_mbuiltin ("tinsrh", v4hi_ftype_v4hi_int_int, TINSRH); |
| 2353 |
iwmmx_mbuiltin ("tinsrw", v2si_ftype_v2si_int_int, TINSRW); |
| 2354 |
|
| 2355 |
iwmmx_mbuiltin ("waccb", di_ftype_v8qi, WACCB); |
| 2356 |
iwmmx_mbuiltin ("wacch", di_ftype_v4hi, WACCH); |
| 2357 |
iwmmx_mbuiltin ("waccw", di_ftype_v2si, WACCW); |
| 2358 |
|
| 2359 |
iwmmx_mbuiltin ("tmovmskb", int_ftype_v8qi, TMOVMSKB); |
| 2360 |
iwmmx_mbuiltin ("tmovmskh", int_ftype_v4hi, TMOVMSKH); |
| 2361 |
iwmmx_mbuiltin ("tmovmskw", int_ftype_v2si, TMOVMSKW); |
| 2362 |
|
| 2363 |
iwmmx2_mbuiltin ("waddbhusm", v8qi_ftype_v4hi_v8qi, WADDBHUSM); |
| 2364 |
iwmmx2_mbuiltin ("waddbhusl", v8qi_ftype_v4hi_v8qi, WADDBHUSL); |
| 2365 |
|
| 2366 |
iwmmx_mbuiltin ("wpackhss", v8qi_ftype_v4hi_v4hi, WPACKHSS); |
| 2367 |
iwmmx_mbuiltin ("wpackhus", v8qi_ftype_v4hi_v4hi, WPACKHUS); |
| 2368 |
iwmmx_mbuiltin ("wpackwus", v4hi_ftype_v2si_v2si, WPACKWUS); |
| 2369 |
iwmmx_mbuiltin ("wpackwss", v4hi_ftype_v2si_v2si, WPACKWSS); |
| 2370 |
iwmmx_mbuiltin ("wpackdus", v2si_ftype_di_di, WPACKDUS); |
| 2371 |
iwmmx_mbuiltin ("wpackdss", v2si_ftype_di_di, WPACKDSS); |
| 2372 |
|
| 2373 |
iwmmx_mbuiltin ("wunpckehub", v4hi_ftype_v8qi, WUNPCKEHUB); |
| 2374 |
iwmmx_mbuiltin ("wunpckehuh", v2si_ftype_v4hi, WUNPCKEHUH); |
| 2375 |
iwmmx_mbuiltin ("wunpckehuw", di_ftype_v2si, WUNPCKEHUW); |
| 2376 |
iwmmx_mbuiltin ("wunpckehsb", v4hi_ftype_v8qi, WUNPCKEHSB); |
| 2377 |
iwmmx_mbuiltin ("wunpckehsh", v2si_ftype_v4hi, WUNPCKEHSH); |
| 2378 |
iwmmx_mbuiltin ("wunpckehsw", di_ftype_v2si, WUNPCKEHSW); |
| 2379 |
iwmmx_mbuiltin ("wunpckelub", v4hi_ftype_v8qi, WUNPCKELUB); |
| 2380 |
iwmmx_mbuiltin ("wunpckeluh", v2si_ftype_v4hi, WUNPCKELUH); |
| 2381 |
iwmmx_mbuiltin ("wunpckeluw", di_ftype_v2si, WUNPCKELUW); |
| 2382 |
iwmmx_mbuiltin ("wunpckelsb", v4hi_ftype_v8qi, WUNPCKELSB); |
| 2383 |
iwmmx_mbuiltin ("wunpckelsh", v2si_ftype_v4hi, WUNPCKELSH); |
| 2384 |
iwmmx_mbuiltin ("wunpckelsw", di_ftype_v2si, WUNPCKELSW); |
| 2385 |
|
| 2386 |
iwmmx_mbuiltin ("wmacs", di_ftype_di_v4hi_v4hi, WMACS); |
| 2387 |
iwmmx_mbuiltin ("wmacsz", di_ftype_v4hi_v4hi, WMACSZ); |
| 2388 |
iwmmx_mbuiltin ("wmacu", di_ftype_di_v4hi_v4hi, WMACU); |
| 2389 |
iwmmx_mbuiltin ("wmacuz", di_ftype_v4hi_v4hi, WMACUZ); |
| 2390 |
|
| 2391 |
iwmmx_mbuiltin ("walign", v8qi_ftype_v8qi_v8qi_int, WALIGNI); |
| 2392 |
iwmmx_mbuiltin ("tmia", di_ftype_di_int_int, TMIA); |
| 2393 |
iwmmx_mbuiltin ("tmiaph", di_ftype_di_int_int, TMIAPH); |
| 2394 |
iwmmx_mbuiltin ("tmiabb", di_ftype_di_int_int, TMIABB); |
| 2395 |
iwmmx_mbuiltin ("tmiabt", di_ftype_di_int_int, TMIABT); |
| 2396 |
iwmmx_mbuiltin ("tmiatb", di_ftype_di_int_int, TMIATB); |
| 2397 |
iwmmx_mbuiltin ("tmiatt", di_ftype_di_int_int, TMIATT); |
| 2398 |
|
| 2399 |
iwmmx2_mbuiltin ("wabsb", v8qi_ftype_v8qi, WABSB); |
| 2400 |
iwmmx2_mbuiltin ("wabsh", v4hi_ftype_v4hi, WABSH); |
| 2401 |
iwmmx2_mbuiltin ("wabsw", v2si_ftype_v2si, WABSW); |
| 2402 |
|
| 2403 |
iwmmx2_mbuiltin ("wqmiabb", v2si_ftype_v2si_v4hi_v4hi, WQMIABB); |
| 2404 |
iwmmx2_mbuiltin ("wqmiabt", v2si_ftype_v2si_v4hi_v4hi, WQMIABT); |
| 2405 |
iwmmx2_mbuiltin ("wqmiatb", v2si_ftype_v2si_v4hi_v4hi, WQMIATB); |
| 2406 |
iwmmx2_mbuiltin ("wqmiatt", v2si_ftype_v2si_v4hi_v4hi, WQMIATT); |
| 2407 |
|
| 2408 |
iwmmx2_mbuiltin ("wqmiabbn", v2si_ftype_v2si_v4hi_v4hi, WQMIABBN); |
| 2409 |
iwmmx2_mbuiltin ("wqmiabtn", v2si_ftype_v2si_v4hi_v4hi, WQMIABTN); |
| 2410 |
iwmmx2_mbuiltin ("wqmiatbn", v2si_ftype_v2si_v4hi_v4hi, WQMIATBN); |
| 2411 |
iwmmx2_mbuiltin ("wqmiattn", v2si_ftype_v2si_v4hi_v4hi, WQMIATTN); |
| 2412 |
|
| 2413 |
iwmmx2_mbuiltin ("wmiabb", di_ftype_di_v4hi_v4hi, WMIABB); |
| 2414 |
iwmmx2_mbuiltin ("wmiabt", di_ftype_di_v4hi_v4hi, WMIABT); |
| 2415 |
iwmmx2_mbuiltin ("wmiatb", di_ftype_di_v4hi_v4hi, WMIATB); |
| 2416 |
iwmmx2_mbuiltin ("wmiatt", di_ftype_di_v4hi_v4hi, WMIATT); |
| 2417 |
|
| 2418 |
iwmmx2_mbuiltin ("wmiabbn", di_ftype_di_v4hi_v4hi, WMIABBN); |
| 2419 |
iwmmx2_mbuiltin ("wmiabtn", di_ftype_di_v4hi_v4hi, WMIABTN); |
| 2420 |
iwmmx2_mbuiltin ("wmiatbn", di_ftype_di_v4hi_v4hi, WMIATBN); |
| 2421 |
iwmmx2_mbuiltin ("wmiattn", di_ftype_di_v4hi_v4hi, WMIATTN); |
| 2422 |
|
| 2423 |
iwmmx2_mbuiltin ("wmiawbb", di_ftype_di_v2si_v2si, WMIAWBB); |
| 2424 |
iwmmx2_mbuiltin ("wmiawbt", di_ftype_di_v2si_v2si, WMIAWBT); |
| 2425 |
iwmmx2_mbuiltin ("wmiawtb", di_ftype_di_v2si_v2si, WMIAWTB); |
| 2426 |
iwmmx2_mbuiltin ("wmiawtt", di_ftype_di_v2si_v2si, WMIAWTT); |
| 2427 |
|
| 2428 |
iwmmx2_mbuiltin ("wmiawbbn", di_ftype_di_v2si_v2si, WMIAWBBN); |
| 2429 |
iwmmx2_mbuiltin ("wmiawbtn", di_ftype_di_v2si_v2si, WMIAWBTN); |
| 2430 |
iwmmx2_mbuiltin ("wmiawtbn", di_ftype_di_v2si_v2si, WMIAWTBN); |
| 2431 |
iwmmx2_mbuiltin ("wmiawttn", di_ftype_di_v2si_v2si, WMIAWTTN); |
| 2432 |
|
| 2433 |
iwmmx2_mbuiltin ("wmerge", di_ftype_di_di_int, WMERGE); |
| 2434 |
|
| 2435 |
iwmmx_mbuiltin ("tbcstb", v8qi_ftype_char, TBCSTB); |
| 2436 |
iwmmx_mbuiltin ("tbcsth", v4hi_ftype_short, TBCSTH); |
| 2437 |
iwmmx_mbuiltin ("tbcstw", v2si_ftype_int, TBCSTW); |
| 2438 |
|
| 2439 |
#undef iwmmx_mbuiltin |
| 2440 |
#undef iwmmx2_mbuiltin |
| 2441 |
} |
| 2442 |
|
| 2443 |
static void |
| 2444 |
arm_init_fp16_builtins (void) |
| 2445 |
{ |
| 2446 |
arm_fp16_type_node = make_node (REAL_TYPE); |
| 2447 |
TYPE_PRECISION (arm_fp16_type_node) = GET_MODE_PRECISION (HFmode); |
| 2448 |
layout_type (arm_fp16_type_node); |
| 2449 |
if (arm_fp16_format) |
| 2450 |
(*lang_hooks.types.register_builtin_type) (arm_fp16_type_node, |
| 2451 |
"__fp16"); |
| 2452 |
} |
| 2453 |
|
| 2454 |
void |
| 2455 |
arm_init_builtins (void) |
| 2456 |
{ |
| 2457 |
if (TARGET_REALLY_IWMMXT) |
| 2458 |
arm_init_iwmmxt_builtins (); |
| 2459 |
|
| 2460 |
/* This creates the arm_simd_floatHF_type_node so must come before |
| 2461 |
arm_init_neon_builtins which uses it. */ |
| 2462 |
arm_init_fp16_builtins (); |
| 2463 |
|
| 2464 |
arm_init_bf16_types (); |
| 2465 |
|
| 2466 |
if (TARGET_MAYBE_HARD_FLOAT) |
| 2467 |
{ |
| 2468 |
tree lane_check_fpr = build_function_type_list (void_type_node, |
| 2469 |
intSI_type_node, |
| 2470 |
intSI_type_node, |
| 2471 |
NULL); |
| 2472 |
arm_builtin_decls[ARM_BUILTIN_SIMD_LANE_CHECK] |
| 2473 |
= arm_general_add_builtin_function ("__builtin_arm_lane_check", |
| 2474 |
lane_check_fpr, |
| 2475 |
ARM_BUILTIN_SIMD_LANE_CHECK); |
| 2476 |
if (TARGET_HAVE_MVE) |
| 2477 |
arm_init_mve_builtins (); |
| 2478 |
else |
| 2479 |
arm_init_neon_builtins (); |
| 2480 |
arm_init_vfp_builtins (); |
| 2481 |
arm_init_crypto_builtins (); |
| 2482 |
} |
| 2483 |
|
| 2484 |
if (TARGET_CDE) |
| 2485 |
arm_init_cde_builtins (); |
| 2486 |
|
| 2487 |
arm_init_acle_builtins (); |
| 2488 |
|
| 2489 |
if (TARGET_MAYBE_HARD_FLOAT) |
| 2490 |
{ |
| 2491 |
tree ftype_set_fpscr |
| 2492 |
= build_function_type_list (void_type_node, unsigned_type_node, NULL); |
| 2493 |
tree ftype_get_fpscr |
| 2494 |
= build_function_type_list (unsigned_type_node, NULL); |
| 2495 |
|
| 2496 |
arm_builtin_decls[ARM_BUILTIN_GET_FPSCR] |
| 2497 |
= arm_general_add_builtin_function ("__builtin_arm_get_fpscr", |
| 2498 |
ftype_get_fpscr, |
| 2499 |
ARM_BUILTIN_GET_FPSCR); |
| 2500 |
arm_builtin_decls[ARM_BUILTIN_SET_FPSCR] |
| 2501 |
= arm_general_add_builtin_function ("__builtin_arm_set_fpscr", |
| 2502 |
ftype_set_fpscr, |
| 2503 |
ARM_BUILTIN_SET_FPSCR); |
| 2504 |
} |
| 2505 |
|
| 2506 |
if (use_cmse) |
| 2507 |
{ |
| 2508 |
tree ftype_cmse_nonsecure_caller |
| 2509 |
= build_function_type_list (unsigned_type_node, NULL); |
| 2510 |
arm_builtin_decls[ARM_BUILTIN_CMSE_NONSECURE_CALLER] |
| 2511 |
= arm_general_add_builtin_function ("__builtin_arm_cmse_nonsecure_caller", |
| 2512 |
ftype_cmse_nonsecure_caller, |
| 2513 |
ARM_BUILTIN_CMSE_NONSECURE_CALLER); |
| 2514 |
} |
| 2515 |
} |
| 2516 |
|
| 2517 |
/* Implement TARGET_BUILTIN_DECL for general builtins. */ |
| 2518 |
tree |
| 2519 |
arm_general_builtin_decl (unsigned code) |
| 2520 |
{ |
| 2521 |
if (code >= ARM_BUILTIN_MAX) |
| 2522 |
return error_mark_node; |
| 2523 |
|
| 2524 |
return arm_builtin_decls[code]; |
| 2525 |
} |
| 2526 |
|
| 2527 |
/* Implement TARGET_BUILTIN_DECL. */ |
| 2528 |
/* Return the ARM builtin for CODE. */ |
| 2529 |
tree |
| 2530 |
arm_builtin_decl (unsigned code, bool initialize_p ATTRIBUTE_UNUSED) |
| 2531 |
{ |
| 2532 |
unsigned subcode = code >> ARM_BUILTIN_SHIFT; |
| 2533 |
switch (code & ARM_BUILTIN_CLASS) |
| 2534 |
{ |
| 2535 |
case ARM_BUILTIN_GENERAL: |
| 2536 |
return arm_general_builtin_decl (subcode); |
| 2537 |
case ARM_BUILTIN_MVE: |
| 2538 |
return arm_mve::builtin_decl (subcode); |
| 2539 |
default: |
| 2540 |
gcc_unreachable (); |
| 2541 |
} |
| 2542 |
} |
| 2543 |
|
| 2544 |
/* Errors in the source file can cause expand_expr to return const0_rtx |
| 2545 |
where we expect a vector. To avoid crashing, use one of the vector |
| 2546 |
clear instructions. */ |
| 2547 |
|
| 2548 |
static rtx |
| 2549 |
safe_vector_operand (rtx x, machine_mode mode) |
| 2550 |
{ |
| 2551 |
if (x != const0_rtx) |
| 2552 |
return x; |
| 2553 |
x = gen_reg_rtx (mode); |
| 2554 |
|
| 2555 |
emit_insn (gen_iwmmxt_clrdi (mode == DImode ? x |
| 2556 |
: gen_rtx_SUBREG (DImode, x, 0))); |
| 2557 |
return x; |
| 2558 |
} |
| 2559 |
|
| 2560 |
/* Function to expand ternary builtins. */ |
| 2561 |
static rtx |
| 2562 |
arm_expand_ternop_builtin (enum insn_code icode, |
| 2563 |
tree exp, rtx target) |
| 2564 |
{ |
| 2565 |
rtx pat; |
| 2566 |
tree arg0 = CALL_EXPR_ARG (exp, 0); |
| 2567 |
tree arg1 = CALL_EXPR_ARG (exp, 1); |
| 2568 |
tree arg2 = CALL_EXPR_ARG (exp, 2); |
| 2569 |
|
| 2570 |
rtx op0 = expand_normal (arg0); |
| 2571 |
rtx op1 = expand_normal (arg1); |
| 2572 |
rtx op2 = expand_normal (arg2); |
| 2573 |
|
| 2574 |
machine_mode tmode = insn_data[icode].operand[0].mode; |
| 2575 |
machine_mode mode0 = insn_data[icode].operand[1].mode; |
| 2576 |
machine_mode mode1 = insn_data[icode].operand[2].mode; |
| 2577 |
machine_mode mode2 = insn_data[icode].operand[3].mode; |
| 2578 |
|
| 2579 |
if (VECTOR_MODE_P (mode0)) |
| 2580 |
op0 = safe_vector_operand (op0, mode0); |
| 2581 |
if (VECTOR_MODE_P (mode1)) |
| 2582 |
op1 = safe_vector_operand (op1, mode1); |
| 2583 |
if (VECTOR_MODE_P (mode2)) |
| 2584 |
op2 = safe_vector_operand (op2, mode2); |
| 2585 |
|
| 2586 |
if (! target |
| 2587 |
|| GET_MODE (target) != tmode |
| 2588 |
|| ! (*insn_data[icode].operand[0].predicate) (target, tmode)) |
| 2589 |
target = gen_reg_rtx (tmode); |
| 2590 |
|
| 2591 |
gcc_assert ((GET_MODE (op0) == mode0 || GET_MODE (op0) == VOIDmode) |
| 2592 |
&& (GET_MODE (op1) == mode1 || GET_MODE (op1) == VOIDmode) |
| 2593 |
&& (GET_MODE (op2) == mode2 || GET_MODE (op2) == VOIDmode)); |
| 2594 |
|
| 2595 |
if (! (*insn_data[icode].operand[1].predicate) (op0, mode0)) |
| 2596 |
op0 = copy_to_mode_reg (mode0, op0); |
| 2597 |
if (! (*insn_data[icode].operand[2].predicate) (op1, mode1)) |
| 2598 |
op1 = copy_to_mode_reg (mode1, op1); |
| 2599 |
if (! (*insn_data[icode].operand[3].predicate) (op2, mode2)) |
| 2600 |
op2 = copy_to_mode_reg (mode2, op2); |
| 2601 |
|
| 2602 |
pat = GEN_FCN (icode) (target, op0, op1, op2); |
| 2603 |
if (! pat) |
| 2604 |
return 0; |
| 2605 |
emit_insn (pat); |
| 2606 |
return target; |
| 2607 |
} |
| 2608 |
|
| 2609 |
/* Subroutine of arm_general_expand_builtin to take care of binop insns. */ |
| 2610 |
|
| 2611 |
static rtx |
| 2612 |
arm_expand_binop_builtin (enum insn_code icode, |
| 2613 |
tree exp, rtx target) |
| 2614 |
{ |
| 2615 |
rtx pat; |
| 2616 |
tree arg0 = CALL_EXPR_ARG (exp, 0); |
| 2617 |
tree arg1 = CALL_EXPR_ARG (exp, 1); |
| 2618 |
rtx op0 = expand_normal (arg0); |
| 2619 |
rtx op1 = expand_normal (arg1); |
| 2620 |
machine_mode tmode = insn_data[icode].operand[0].mode; |
| 2621 |
machine_mode mode0 = insn_data[icode].operand[1].mode; |
| 2622 |
machine_mode mode1 = insn_data[icode].operand[2].mode; |
| 2623 |
|
| 2624 |
if (VECTOR_MODE_P (mode0)) |
| 2625 |
op0 = safe_vector_operand (op0, mode0); |
| 2626 |
if (VECTOR_MODE_P (mode1)) |
| 2627 |
op1 = safe_vector_operand (op1, mode1); |
| 2628 |
|
| 2629 |
if (! target |
| 2630 |
|| GET_MODE (target) != tmode |
| 2631 |
|| ! (*insn_data[icode].operand[0].predicate) (target, tmode)) |
| 2632 |
target = gen_reg_rtx (tmode); |
| 2633 |
|
| 2634 |
gcc_assert ((GET_MODE (op0) == mode0 || GET_MODE (op0) == VOIDmode) |
| 2635 |
&& (GET_MODE (op1) == mode1 || GET_MODE (op1) == VOIDmode)); |
| 2636 |
|
| 2637 |
if (! (*insn_data[icode].operand[1].predicate) (op0, mode0)) |
| 2638 |
op0 = copy_to_mode_reg (mode0, op0); |
| 2639 |
if (! (*insn_data[icode].operand[2].predicate) (op1, mode1)) |
| 2640 |
op1 = copy_to_mode_reg (mode1, op1); |
| 2641 |
|
| 2642 |
pat = GEN_FCN (icode) (target, op0, op1); |
| 2643 |
if (! pat) |
| 2644 |
return 0; |
| 2645 |
emit_insn (pat); |
| 2646 |
return target; |
| 2647 |
} |
| 2648 |
|
| 2649 |
/* Subroutine of arm_general_expand_builtin to take care of unop insns. */ |
| 2650 |
|
| 2651 |
static rtx |
| 2652 |
arm_expand_unop_builtin (enum insn_code icode, |
| 2653 |
tree exp, rtx target, int do_load) |
| 2654 |
{ |
| 2655 |
rtx pat; |
| 2656 |
tree arg0 = CALL_EXPR_ARG (exp, 0); |
| 2657 |
rtx op0 = expand_normal (arg0); |
| 2658 |
machine_mode tmode = insn_data[icode].operand[0].mode; |
| 2659 |
machine_mode mode0 = insn_data[icode].operand[1].mode; |
| 2660 |
|
| 2661 |
if (! target |
| 2662 |
|| GET_MODE (target) != tmode |
| 2663 |
|| ! (*insn_data[icode].operand[0].predicate) (target, tmode)) |
| 2664 |
target = gen_reg_rtx (tmode); |
| 2665 |
if (do_load) |
| 2666 |
op0 = gen_rtx_MEM (mode0, copy_to_mode_reg (Pmode, op0)); |
| 2667 |
else |
| 2668 |
{ |
| 2669 |
if (VECTOR_MODE_P (mode0)) |
| 2670 |
op0 = safe_vector_operand (op0, mode0); |
| 2671 |
|
| 2672 |
if (! (*insn_data[icode].operand[1].predicate) (op0, mode0)) |
| 2673 |
op0 = copy_to_mode_reg (mode0, op0); |
| 2674 |
} |
| 2675 |
|
| 2676 |
pat = GEN_FCN (icode) (target, op0); |
| 2677 |
|
| 2678 |
if (! pat) |
| 2679 |
return 0; |
| 2680 |
emit_insn (pat); |
| 2681 |
return target; |
| 2682 |
} |
| 2683 |
|
| 2684 |
typedef enum { |
| 2685 |
ARG_BUILTIN_COPY_TO_REG, |
| 2686 |
ARG_BUILTIN_CONSTANT, |
| 2687 |
ARG_BUILTIN_LANE_INDEX, |
| 2688 |
ARG_BUILTIN_STRUCT_LOAD_STORE_LANE_INDEX, |
| 2689 |
ARG_BUILTIN_LANE_PAIR_INDEX, |
| 2690 |
ARG_BUILTIN_LANE_QUADTUP_INDEX, |
| 2691 |
ARG_BUILTIN_NEON_MEMORY, |
| 2692 |
ARG_BUILTIN_MEMORY, |
| 2693 |
ARG_BUILTIN_STOP |
| 2694 |
} builtin_arg; |
| 2695 |
|
| 2696 |
|
| 2697 |
/* EXP is a pointer argument to a Neon load or store intrinsic. Derive |
| 2698 |
and return an expression for the accessed memory. |
| 2699 |
|
| 2700 |
The intrinsic function operates on a block of registers that has |
| 2701 |
mode REG_MODE. This block contains vectors of type TYPE_MODE. The |
| 2702 |
function references the memory at EXP of type TYPE and in mode |
| 2703 |
MEM_MODE; this mode may be BLKmode if no more suitable mode is |
| 2704 |
available. */ |
| 2705 |
|
| 2706 |
static tree |
| 2707 |
neon_dereference_pointer (tree exp, tree type, machine_mode mem_mode, |
| 2708 |
machine_mode reg_mode, |
| 2709 |
machine_mode vector_mode) |
| 2710 |
{ |
| 2711 |
HOST_WIDE_INT reg_size, vector_size, nvectors, nelems; |
| 2712 |
tree elem_type, upper_bound, array_type; |
| 2713 |
|
| 2714 |
/* Work out the size of the register block in bytes. */ |
| 2715 |
reg_size = GET_MODE_SIZE (reg_mode); |
| 2716 |
|
| 2717 |
/* Work out the size of each vector in bytes. */ |
| 2718 |
vector_size = GET_MODE_SIZE (vector_mode); |
| 2719 |
|
| 2720 |
/* Work out how many vectors there are. */ |
| 2721 |
gcc_assert (reg_size % vector_size == 0); |
| 2722 |
nvectors = reg_size / vector_size; |
| 2723 |
|
| 2724 |
/* Work out the type of each element. */ |
| 2725 |
gcc_assert (POINTER_TYPE_P (type)); |
| 2726 |
elem_type = TREE_TYPE (type); |
| 2727 |
|
| 2728 |
/* Work out how many elements are being loaded or stored. |
| 2729 |
MEM_MODE == REG_MODE implies a one-to-one mapping between register |
| 2730 |
and memory elements; anything else implies a lane load or store. */ |
| 2731 |
if (mem_mode == reg_mode) |
| 2732 |
nelems = vector_size * nvectors / int_size_in_bytes (elem_type); |
| 2733 |
else |
| 2734 |
nelems = nvectors; |
| 2735 |
|
| 2736 |
/* Create a type that describes the full access. */ |
| 2737 |
upper_bound = build_int_cst (size_type_node, nelems - 1); |
| 2738 |
array_type = build_array_type (elem_type, build_index_type (upper_bound)); |
| 2739 |
|
| 2740 |
/* Dereference EXP using that type. */ |
| 2741 |
return fold_build2 (MEM_REF, array_type, exp, |
| 2742 |
build_int_cst (build_pointer_type (array_type), 0)); |
| 2743 |
} |
| 2744 |
|
| 2745 |
/* EXP is a pointer argument to a vector scatter store intrinsics. |
| 2746 |
|
| 2747 |
Consider the following example: |
| 2748 |
VSTRW<v>.<dt> Qd, [Qm{, #+/-<imm>}]! |
| 2749 |
When <Qm> used as the base register for the target address, |
| 2750 |
this function is used to derive and return an expression for the |
| 2751 |
accessed memory. |
| 2752 |
|
| 2753 |
The intrinsic function operates on a block of registers that has mode |
| 2754 |
REG_MODE. This block contains vectors of type TYPE_MODE. The function |
| 2755 |
references the memory at EXP of type TYPE and in mode MEM_MODE. This |
| 2756 |
mode may be BLKmode if no more suitable mode is available. */ |
| 2757 |
|
| 2758 |
static tree |
| 2759 |
mve_dereference_pointer (tree exp, tree type, machine_mode reg_mode, |
| 2760 |
machine_mode vector_mode) |
| 2761 |
{ |
| 2762 |
HOST_WIDE_INT reg_size, vector_size, nelems; |
| 2763 |
tree elem_type, upper_bound, array_type; |
| 2764 |
|
| 2765 |
/* Work out the size of each vector in bytes. */ |
| 2766 |
vector_size = GET_MODE_SIZE (vector_mode); |
| 2767 |
|
| 2768 |
/* Work out the size of the register block in bytes. */ |
| 2769 |
reg_size = GET_MODE_SIZE (reg_mode); |
| 2770 |
|
| 2771 |
/* Work out the type of each element. */ |
| 2772 |
gcc_assert (POINTER_TYPE_P (type)); |
| 2773 |
elem_type = TREE_TYPE (type); |
| 2774 |
|
| 2775 |
nelems = reg_size / vector_size; |
| 2776 |
|
| 2777 |
/* Create a type that describes the full access. */ |
| 2778 |
upper_bound = build_int_cst (size_type_node, nelems - 1); |
| 2779 |
array_type = build_array_type (elem_type, build_index_type (upper_bound)); |
| 2780 |
|
| 2781 |
/* Dereference EXP using that type. */ |
| 2782 |
return fold_build2 (MEM_REF, array_type, exp, |
| 2783 |
build_int_cst (build_pointer_type (array_type), 0)); |
| 2784 |
} |
| 2785 |
|
| 2786 |
/* Implement TARGET_EXPAND_BUILTIN for general builtins. */ |
| 2787 |
static rtx |
| 2788 |
arm_general_expand_builtin_args (rtx target, machine_mode map_mode, int fcode, |
| 2789 |
int icode, int have_retval, tree exp, |
| 2790 |
builtin_arg *args) |
| 2791 |
{ |
| 2792 |
rtx pat; |
| 2793 |
tree arg[SIMD_MAX_BUILTIN_ARGS]; |
| 2794 |
rtx op[SIMD_MAX_BUILTIN_ARGS]; |
| 2795 |
machine_mode tmode = insn_data[icode].operand[0].mode; |
| 2796 |
machine_mode mode[SIMD_MAX_BUILTIN_ARGS]; |
| 2797 |
tree formals; |
| 2798 |
int argc = 0; |
| 2799 |
rtx_insn * insn; |
| 2800 |
|
| 2801 |
if (have_retval |
| 2802 |
&& (!target |
| 2803 |
|| GET_MODE (target) != tmode |
| 2804 |
|| !(*insn_data[icode].operand[0].predicate) (target, tmode))) |
| 2805 |
target = gen_reg_rtx (tmode); |
| 2806 |
|
| 2807 |
formals = TYPE_ARG_TYPES (TREE_TYPE (arm_builtin_decls[fcode])); |
| 2808 |
|
| 2809 |
for (;;) |
| 2810 |
{ |
| 2811 |
builtin_arg thisarg = args[argc]; |
| 2812 |
|
| 2813 |
if (thisarg == ARG_BUILTIN_STOP) |
| 2814 |
break; |
| 2815 |
else |
| 2816 |
{ |
| 2817 |
int opno = argc + have_retval; |
| 2818 |
arg[argc] = CALL_EXPR_ARG (exp, argc); |
| 2819 |
mode[argc] = insn_data[icode].operand[opno].mode; |
| 2820 |
if (thisarg == ARG_BUILTIN_NEON_MEMORY) |
| 2821 |
{ |
| 2822 |
machine_mode other_mode |
| 2823 |
= insn_data[icode].operand[1 - opno].mode; |
| 2824 |
if (TARGET_HAVE_MVE && mode[argc] != other_mode) |
| 2825 |
{ |
| 2826 |
arg[argc] = mve_dereference_pointer (arg[argc], |
| 2827 |
TREE_VALUE (formals), |
| 2828 |
other_mode, map_mode); |
| 2829 |
} |
| 2830 |
else |
| 2831 |
arg[argc] = neon_dereference_pointer (arg[argc], |
| 2832 |
TREE_VALUE (formals), |
| 2833 |
mode[argc], other_mode, |
| 2834 |
map_mode); |
| 2835 |
} |
| 2836 |
|
| 2837 |
/* Use EXPAND_MEMORY for ARG_BUILTIN_MEMORY and |
| 2838 |
ARG_BUILTIN_NEON_MEMORY to ensure a MEM_P be returned. */ |
| 2839 |
op[argc] = expand_expr (arg[argc], NULL_RTX, VOIDmode, |
| 2840 |
((thisarg == ARG_BUILTIN_MEMORY |
| 2841 |
|| thisarg == ARG_BUILTIN_NEON_MEMORY) |
| 2842 |
? EXPAND_MEMORY : EXPAND_NORMAL)); |
| 2843 |
|
| 2844 |
switch (thisarg) |
| 2845 |
{ |
| 2846 |
case ARG_BUILTIN_MEMORY: |
| 2847 |
case ARG_BUILTIN_COPY_TO_REG: |
| 2848 |
if (POINTER_TYPE_P (TREE_TYPE (arg[argc]))) |
| 2849 |
op[argc] = convert_memory_address (Pmode, op[argc]); |
| 2850 |
|
| 2851 |
/* MVE uses mve_pred16_t (aka HImode) for vectors of |
| 2852 |
predicates, but internally we use V16BI/V8BI/V4BI/V2QI for |
| 2853 |
MVE predicate modes. */ |
| 2854 |
if (TARGET_HAVE_MVE && VALID_MVE_PRED_MODE (mode[argc])) |
| 2855 |
op[argc] = gen_lowpart (mode[argc], op[argc]); |
| 2856 |
|
| 2857 |
gcc_assert (GET_MODE (op[argc]) == mode[argc] |
| 2858 |
|| (GET_MODE(op[argc]) == E_VOIDmode |
| 2859 |
&& CONSTANT_P (op[argc]))); |
| 2860 |
if (!(*insn_data[icode].operand[opno].predicate) |
| 2861 |
(op[argc], mode[argc])) |
| 2862 |
op[argc] = copy_to_mode_reg (mode[argc], op[argc]); |
| 2863 |
break; |
| 2864 |
|
| 2865 |
case ARG_BUILTIN_STRUCT_LOAD_STORE_LANE_INDEX: |
| 2866 |
gcc_assert (argc > 1); |
| 2867 |
if (CONST_INT_P (op[argc])) |
| 2868 |
{ |
| 2869 |
neon_lane_bounds (op[argc], 0, |
| 2870 |
GET_MODE_NUNITS (map_mode), exp); |
| 2871 |
/* Keep to GCC-vector-extension lane indices in the RTL. */ |
| 2872 |
op[argc] = |
| 2873 |
GEN_INT (NEON_ENDIAN_LANE_N (map_mode, INTVAL (op[argc]))); |
| 2874 |
} |
| 2875 |
goto constant_arg; |
| 2876 |
|
| 2877 |
case ARG_BUILTIN_LANE_INDEX: |
| 2878 |
/* Previous argument must be a vector, which this indexes. */ |
| 2879 |
gcc_assert (argc > 0); |
| 2880 |
if (CONST_INT_P (op[argc])) |
| 2881 |
{ |
| 2882 |
machine_mode vmode = mode[argc - 1]; |
| 2883 |
neon_lane_bounds (op[argc], 0, GET_MODE_NUNITS (vmode), exp); |
| 2884 |
} |
| 2885 |
/* If the lane index isn't a constant then error out. */ |
| 2886 |
goto constant_arg; |
| 2887 |
|
| 2888 |
case ARG_BUILTIN_LANE_PAIR_INDEX: |
| 2889 |
/* Previous argument must be a vector, which this indexes. The |
| 2890 |
indexing will always select i and i+1 out of the vector, which |
| 2891 |
puts a limit on i. */ |
| 2892 |
gcc_assert (argc > 0); |
| 2893 |
if (CONST_INT_P (op[argc])) |
| 2894 |
{ |
| 2895 |
machine_mode vmode = mode[argc - 1]; |
| 2896 |
neon_lane_bounds (op[argc], 0, |
| 2897 |
GET_MODE_NUNITS (vmode) / 2, exp); |
| 2898 |
} |
| 2899 |
/* If the lane index isn't a constant then error out. */ |
| 2900 |
goto constant_arg; |
| 2901 |
|
| 2902 |
case ARG_BUILTIN_LANE_QUADTUP_INDEX: |
| 2903 |
/* Previous argument must be a vector, which this indexes. */ |
| 2904 |
gcc_assert (argc > 0); |
| 2905 |
if (CONST_INT_P (op[argc])) |
| 2906 |
{ |
| 2907 |
machine_mode vmode = mode[argc - 1]; |
| 2908 |
neon_lane_bounds (op[argc], 0, |
| 2909 |
GET_MODE_NUNITS (vmode) / 4, exp); |
| 2910 |
} |
| 2911 |
/* If the lane index isn't a constant then error out. */ |
| 2912 |
goto constant_arg; |
| 2913 |
|
| 2914 |
case ARG_BUILTIN_CONSTANT: |
| 2915 |
constant_arg: |
| 2916 |
if (!(*insn_data[icode].operand[opno].predicate) |
| 2917 |
(op[argc], mode[argc])) |
| 2918 |
{ |
| 2919 |
if (IN_RANGE (fcode, ARM_BUILTIN_CDE_PATTERN_START, |
| 2920 |
ARM_BUILTIN_CDE_PATTERN_END)) |
| 2921 |
{ |
| 2922 |
if (argc == 0) |
| 2923 |
{ |
| 2924 |
unsigned int cp_bit = (CONST_INT_P (op[argc]) |
| 2925 |
? UINTVAL (op[argc]) : -1); |
| 2926 |
if (IN_RANGE (cp_bit, 0, ARM_CDE_CONST_COPROC)) |
| 2927 |
error_at (EXPR_LOCATION (exp), |
| 2928 |
"coprocessor %d is not enabled " |
| 2929 |
"with +cdecp%d", cp_bit, cp_bit); |
| 2930 |
else |
| 2931 |
error_at (EXPR_LOCATION (exp), |
| 2932 |
"coproc must be a constant immediate in " |
| 2933 |
"range [0-%d] enabled with %<+cdecp<N>%>", |
| 2934 |
ARM_CDE_CONST_COPROC); |
| 2935 |
} |
| 2936 |
else |
| 2937 |
/* Here we mention the builtin name to follow the same |
| 2938 |
format that the C/C++ frontends use for referencing |
| 2939 |
a given argument index. */ |
| 2940 |
error_at (EXPR_LOCATION (exp), |
| 2941 |
"argument %d to %qE must be a constant " |
| 2942 |
"immediate in range [0-%d]", argc + 1, |
| 2943 |
arm_builtin_decls[fcode], |
| 2944 |
cde_builtin_data[fcode - |
| 2945 |
ARM_BUILTIN_CDE_PATTERN_START].imm_max); |
| 2946 |
} |
| 2947 |
else |
| 2948 |
error_at (EXPR_LOCATION (exp), |
| 2949 |
"argument %d must be a constant immediate", |
| 2950 |
argc + 1); |
| 2951 |
/* We have failed to expand the pattern, and are safely |
| 2952 |
in to invalid code. But the mid-end will still try to |
| 2953 |
build an assignment for this node while it expands, |
| 2954 |
before stopping for the error, just pass it back |
| 2955 |
TARGET to ensure a valid assignment. */ |
| 2956 |
return target; |
| 2957 |
} |
| 2958 |
break; |
| 2959 |
|
| 2960 |
case ARG_BUILTIN_NEON_MEMORY: |
| 2961 |
/* Check if expand failed. */ |
| 2962 |
if (op[argc] == const0_rtx) |
| 2963 |
return 0; |
| 2964 |
gcc_assert (MEM_P (op[argc])); |
| 2965 |
PUT_MODE (op[argc], mode[argc]); |
| 2966 |
/* ??? arm_neon.h uses the same built-in functions for signed |
| 2967 |
and unsigned accesses, casting where necessary. This isn't |
| 2968 |
alias safe. */ |
| 2969 |
set_mem_alias_set (op[argc], 0); |
| 2970 |
if (!(*insn_data[icode].operand[opno].predicate) |
| 2971 |
(op[argc], mode[argc])) |
| 2972 |
op[argc] = (replace_equiv_address |
| 2973 |
(op[argc], |
| 2974 |
copy_to_mode_reg (Pmode, XEXP (op[argc], 0)))); |
| 2975 |
break; |
| 2976 |
|
| 2977 |
case ARG_BUILTIN_STOP: |
| 2978 |
gcc_unreachable (); |
| 2979 |
} |
| 2980 |
|
| 2981 |
argc++; |
| 2982 |
} |
| 2983 |
} |
| 2984 |
|
| 2985 |
if (have_retval) |
| 2986 |
switch (argc) |
| 2987 |
{ |
| 2988 |
case 0: |
| 2989 |
pat = GEN_FCN (icode) (target); |
| 2990 |
break; |
| 2991 |
case 1: |
| 2992 |
pat = GEN_FCN (icode) (target, op[0]); |
| 2993 |
break; |
| 2994 |
|
| 2995 |
case 2: |
| 2996 |
pat = GEN_FCN (icode) (target, op[0], op[1]); |
| 2997 |
break; |
| 2998 |
|
| 2999 |
case 3: |
| 3000 |
pat = GEN_FCN (icode) (target, op[0], op[1], op[2]); |
| 3001 |
break; |
| 3002 |
|
| 3003 |
case 4: |
| 3004 |
pat = GEN_FCN (icode) (target, op[0], op[1], op[2], op[3]); |
| 3005 |
break; |
| 3006 |
|
| 3007 |
case 5: |
| 3008 |
pat = GEN_FCN (icode) (target, op[0], op[1], op[2], op[3], op[4]); |
| 3009 |
break; |
| 3010 |
|
| 3011 |
case 6: |
| 3012 |
pat = GEN_FCN (icode) (target, op[0], op[1], op[2], op[3], op[4], op[5]); |
| 3013 |
break; |
| 3014 |
|
| 3015 |
default: |
| 3016 |
gcc_unreachable (); |
| 3017 |
} |
| 3018 |
else |
| 3019 |
switch (argc) |
| 3020 |
{ |
| 3021 |
case 1: |
| 3022 |
pat = GEN_FCN (icode) (op[0]); |
| 3023 |
break; |
| 3024 |
|
| 3025 |
case 2: |
| 3026 |
pat = GEN_FCN (icode) (op[0], op[1]); |
| 3027 |
break; |
| 3028 |
|
| 3029 |
case 3: |
| 3030 |
pat = GEN_FCN (icode) (op[0], op[1], op[2]); |
| 3031 |
break; |
| 3032 |
|
| 3033 |
case 4: |
| 3034 |
pat = GEN_FCN (icode) (op[0], op[1], op[2], op[3]); |
| 3035 |
break; |
| 3036 |
|
| 3037 |
case 5: |
| 3038 |
pat = GEN_FCN (icode) (op[0], op[1], op[2], op[3], op[4]); |
| 3039 |
break; |
| 3040 |
|
| 3041 |
case 6: |
| 3042 |
pat = GEN_FCN (icode) (op[0], op[1], op[2], op[3], op[4], op[5]); |
| 3043 |
break; |
| 3044 |
|
| 3045 |
default: |
| 3046 |
gcc_unreachable (); |
| 3047 |
} |
| 3048 |
|
| 3049 |
if (!pat) |
| 3050 |
return 0; |
| 3051 |
|
| 3052 |
/* Check whether our current target implements the pattern chosen for this |
| 3053 |
builtin and error out if not. */ |
| 3054 |
start_sequence (); |
| 3055 |
emit_insn (pat); |
| 3056 |
insn = get_insns (); |
| 3057 |
end_sequence (); |
| 3058 |
|
| 3059 |
if (recog_memoized (insn) < 0) |
| 3060 |
error ("this builtin is not supported for this target"); |
| 3061 |
else |
| 3062 |
emit_insn (insn); |
| 3063 |
|
| 3064 |
if (TARGET_HAVE_MVE && VALID_MVE_PRED_MODE (tmode)) |
| 3065 |
{ |
| 3066 |
rtx HItarget = gen_reg_rtx (HImode); |
| 3067 |
emit_move_insn (HItarget, gen_lowpart (HImode, target)); |
| 3068 |
return HItarget; |
| 3069 |
} |
| 3070 |
|
| 3071 |
return target; |
| 3072 |
} |
| 3073 |
|
| 3074 |
/* Expand a general builtin. These builtins are "special" because they don't |
| 3075 |
have symbolic constants defined per-instruction or per instruction-variant. |
| 3076 |
Instead, the required info is looked up in the ARM_BUILTIN_DATA record that |
| 3077 |
is passed into the function. */ |
| 3078 |
|
| 3079 |
static rtx |
| 3080 |
arm_general_expand_builtin_1 (int fcode, tree exp, rtx target, |
| 3081 |
arm_builtin_datum *d) |
| 3082 |
{ |
| 3083 |
enum insn_code icode = d->code; |
| 3084 |
builtin_arg args[SIMD_MAX_BUILTIN_ARGS + 1]; |
| 3085 |
int num_args = insn_data[d->code].n_operands; |
| 3086 |
int is_void = 0; |
| 3087 |
int k; |
| 3088 |
bool neon = false; |
| 3089 |
bool mve = false; |
| 3090 |
|
| 3091 |
if (IN_RANGE (fcode, ARM_BUILTIN_VFP_BASE, ARM_BUILTIN_ACLE_BASE - 1)) |
| 3092 |
neon = true; |
| 3093 |
|
| 3094 |
if (IN_RANGE (fcode, ARM_BUILTIN_MVE_BASE, ARM_BUILTIN_MAX - 1)) |
| 3095 |
mve = true; |
| 3096 |
|
| 3097 |
is_void = !!(d->qualifiers[0] & qualifier_void); |
| 3098 |
|
| 3099 |
num_args += is_void; |
| 3100 |
|
| 3101 |
for (k = 1; k < num_args; k++) |
| 3102 |
{ |
| 3103 |
/* We have four arrays of data, each indexed in a different fashion. |
| 3104 |
qualifiers - element 0 always describes the function return type. |
| 3105 |
operands - element 0 is either the operand for return value (if |
| 3106 |
the function has a non-void return type) or the operand for the |
| 3107 |
first argument. |
| 3108 |
expr_args - element 0 always holds the first argument. |
| 3109 |
args - element 0 is always used for the return type. */ |
| 3110 |
int qualifiers_k = k; |
| 3111 |
int operands_k = k - is_void; |
| 3112 |
int expr_args_k = k - 1; |
| 3113 |
|
| 3114 |
if (d->qualifiers[qualifiers_k] & qualifier_lane_index) |
| 3115 |
args[k] = ARG_BUILTIN_LANE_INDEX; |
| 3116 |
else if (d->qualifiers[qualifiers_k] & qualifier_lane_pair_index) |
| 3117 |
args[k] = ARG_BUILTIN_LANE_PAIR_INDEX; |
| 3118 |
else if (d->qualifiers[qualifiers_k] & qualifier_lane_quadtup_index) |
| 3119 |
args[k] = ARG_BUILTIN_LANE_QUADTUP_INDEX; |
| 3120 |
else if (d->qualifiers[qualifiers_k] & qualifier_struct_load_store_lane_index) |
| 3121 |
args[k] = ARG_BUILTIN_STRUCT_LOAD_STORE_LANE_INDEX; |
| 3122 |
else if (d->qualifiers[qualifiers_k] & qualifier_immediate) |
| 3123 |
args[k] = ARG_BUILTIN_CONSTANT; |
| 3124 |
else if (d->qualifiers[qualifiers_k] & qualifier_maybe_immediate) |
| 3125 |
{ |
| 3126 |
rtx arg |
| 3127 |
= expand_normal (CALL_EXPR_ARG (exp, |
| 3128 |
(expr_args_k))); |
| 3129 |
/* Handle constants only if the predicate allows it. */ |
| 3130 |
bool op_const_int_p = |
| 3131 |
(CONST_INT_P (arg) |
| 3132 |
&& (*insn_data[icode].operand[operands_k].predicate) |
| 3133 |
(arg, insn_data[icode].operand[operands_k].mode)); |
| 3134 |
args[k] = op_const_int_p ? ARG_BUILTIN_CONSTANT : ARG_BUILTIN_COPY_TO_REG; |
| 3135 |
} |
| 3136 |
else if (d->qualifiers[qualifiers_k] & qualifier_pointer) |
| 3137 |
{ |
| 3138 |
if (neon || mve) |
| 3139 |
args[k] = ARG_BUILTIN_NEON_MEMORY; |
| 3140 |
else |
| 3141 |
args[k] = ARG_BUILTIN_MEMORY; |
| 3142 |
} |
| 3143 |
else |
| 3144 |
args[k] = ARG_BUILTIN_COPY_TO_REG; |
| 3145 |
} |
| 3146 |
args[k] = ARG_BUILTIN_STOP; |
| 3147 |
|
| 3148 |
/* The interface to arm_general_expand_builtin_args expects a 0 if |
| 3149 |
the function is void, and a 1 if it is not. */ |
| 3150 |
return arm_general_expand_builtin_args |
| 3151 |
(target, d->mode, fcode, icode, !is_void, exp, |
| 3152 |
&args[1]); |
| 3153 |
} |
| 3154 |
|
| 3155 |
/* Expand an ACLE builtin, i.e. those registered only if their respective |
| 3156 |
target constraints are met. This check happens within |
| 3157 |
arm_general_expand_builtin_args. */ |
| 3158 |
|
| 3159 |
static rtx |
| 3160 |
arm_expand_acle_builtin (int fcode, tree exp, rtx target) |
| 3161 |
{ |
| 3162 |
if (fcode == ARM_BUILTIN_SAT_IMM_CHECK) |
| 3163 |
{ |
| 3164 |
/* Check the saturation immediate bounds. */ |
| 3165 |
|
| 3166 |
rtx min_sat = expand_normal (CALL_EXPR_ARG (exp, 1)); |
| 3167 |
rtx max_sat = expand_normal (CALL_EXPR_ARG (exp, 2)); |
| 3168 |
gcc_assert (CONST_INT_P (min_sat)); |
| 3169 |
gcc_assert (CONST_INT_P (max_sat)); |
| 3170 |
rtx sat_imm = expand_normal (CALL_EXPR_ARG (exp, 0)); |
| 3171 |
if (CONST_INT_P (sat_imm)) |
| 3172 |
{ |
| 3173 |
if (!IN_RANGE (sat_imm, min_sat, max_sat)) |
| 3174 |
error_at (EXPR_LOCATION (exp), |
| 3175 |
"saturation bit range must be in the range [%wd, %wd]", |
| 3176 |
UINTVAL (min_sat), UINTVAL (max_sat)); |
| 3177 |
} |
| 3178 |
else |
| 3179 |
error_at (EXPR_LOCATION (exp), |
| 3180 |
"saturation bit range must be a constant immediate"); |
| 3181 |
/* Don't generate any RTL. */ |
| 3182 |
return const0_rtx; |
| 3183 |
} |
| 3184 |
|
| 3185 |
gcc_assert (fcode != ARM_BUILTIN_CDE_BASE); |
| 3186 |
arm_builtin_datum *d |
| 3187 |
= (fcode < ARM_BUILTIN_CDE_BASE) |
| 3188 |
? &acle_builtin_data[fcode - ARM_BUILTIN_ACLE_PATTERN_START] |
| 3189 |
: &cde_builtin_data[fcode - ARM_BUILTIN_CDE_PATTERN_START].base; |
| 3190 |
|
| 3191 |
return arm_general_expand_builtin_1 (fcode, exp, target, d); |
| 3192 |
} |
| 3193 |
|
| 3194 |
/* Expand an MVE builtin, i.e. those registered only if their respective |
| 3195 |
target constraints are met. This check happens within |
| 3196 |
arm_general_expand_builtin. */ |
| 3197 |
|
| 3198 |
static rtx |
| 3199 |
arm_expand_mve_builtin (int fcode, tree exp, rtx target) |
| 3200 |
{ |
| 3201 |
if (fcode >= ARM_BUILTIN_MVE_BASE && !TARGET_HAVE_MVE) |
| 3202 |
{ |
| 3203 |
fatal_error (input_location, |
| 3204 |
"You must enable MVE instructions" |
| 3205 |
" to use these intrinsics"); |
| 3206 |
return const0_rtx; |
| 3207 |
} |
| 3208 |
|
| 3209 |
arm_builtin_datum *d |
| 3210 |
= &mve_builtin_data[fcode - ARM_BUILTIN_MVE_PATTERN_START]; |
| 3211 |
|
| 3212 |
return arm_general_expand_builtin_1 (fcode, exp, target, d); |
| 3213 |
} |
| 3214 |
|
| 3215 |
/* Expand a Neon builtin, i.e. those registered only if TARGET_NEON holds. |
| 3216 |
Most of these are "special" because they don't have symbolic |
| 3217 |
constants defined per-instruction or per instruction-variant. Instead, the |
| 3218 |
required info is looked up in the table neon_builtin_data. */ |
| 3219 |
|
| 3220 |
static rtx |
| 3221 |
arm_expand_neon_builtin (int fcode, tree exp, rtx target) |
| 3222 |
{ |
| 3223 |
if (fcode >= ARM_BUILTIN_NEON_BASE && ! TARGET_NEON) |
| 3224 |
{ |
| 3225 |
fatal_error (input_location, |
| 3226 |
"You must enable NEON instructions" |
| 3227 |
" (e.g. %<-mfloat-abi=softfp%> %<-mfpu=neon%>)" |
| 3228 |
" to use these intrinsics."); |
| 3229 |
return const0_rtx; |
| 3230 |
} |
| 3231 |
|
| 3232 |
arm_builtin_datum *d |
| 3233 |
= &neon_builtin_data[fcode - ARM_BUILTIN_NEON_PATTERN_START]; |
| 3234 |
|
| 3235 |
return arm_general_expand_builtin_1 (fcode, exp, target, d); |
| 3236 |
} |
| 3237 |
|
| 3238 |
/* Expand a VFP builtin. These builtins are treated like |
| 3239 |
neon builtins except that the data is looked up in table |
| 3240 |
VFP_BUILTIN_DATA. */ |
| 3241 |
|
| 3242 |
static rtx |
| 3243 |
arm_expand_vfp_builtin (int fcode, tree exp, rtx target) |
| 3244 |
{ |
| 3245 |
if (fcode >= ARM_BUILTIN_VFP_BASE && ! TARGET_HARD_FLOAT) |
| 3246 |
{ |
| 3247 |
fatal_error (input_location, |
| 3248 |
"You must enable VFP instructions" |
| 3249 |
" to use these intrinsics."); |
| 3250 |
return const0_rtx; |
| 3251 |
} |
| 3252 |
|
| 3253 |
arm_builtin_datum *d |
| 3254 |
= &vfp_builtin_data[fcode - ARM_BUILTIN_VFP_PATTERN_START]; |
| 3255 |
|
| 3256 |
return arm_general_expand_builtin_1 (fcode, exp, target, d); |
| 3257 |
} |
| 3258 |
|
| 3259 |
/* Implement TARGET_EXPAND_BUILTIN for general builtins. */ |
| 3260 |
rtx |
| 3261 |
arm_general_expand_builtin (unsigned int fcode, |
| 3262 |
tree exp, |
| 3263 |
rtx target, |
| 3264 |
int ignore ATTRIBUTE_UNUSED) |
| 3265 |
{ |
| 3266 |
const struct builtin_description * d; |
| 3267 |
enum insn_code icode; |
| 3268 |
tree arg0; |
| 3269 |
tree arg1; |
| 3270 |
tree arg2; |
| 3271 |
rtx op0; |
| 3272 |
rtx op1; |
| 3273 |
rtx op2; |
| 3274 |
rtx pat; |
| 3275 |
size_t i; |
| 3276 |
machine_mode tmode; |
| 3277 |
machine_mode mode0; |
| 3278 |
machine_mode mode1; |
| 3279 |
machine_mode mode2; |
| 3280 |
int opint; |
| 3281 |
int selector; |
| 3282 |
int mask; |
| 3283 |
int imm; |
| 3284 |
|
| 3285 |
if (fcode == ARM_BUILTIN_SIMD_LANE_CHECK) |
| 3286 |
{ |
| 3287 |
/* Builtin is only to check bounds of the lane passed to some intrinsics |
| 3288 |
that are implemented with gcc vector extensions in arm_neon.h. */ |
| 3289 |
|
| 3290 |
tree nlanes = CALL_EXPR_ARG (exp, 0); |
| 3291 |
gcc_assert (TREE_CODE (nlanes) == INTEGER_CST); |
| 3292 |
rtx lane_idx = expand_normal (CALL_EXPR_ARG (exp, 1)); |
| 3293 |
if (CONST_INT_P (lane_idx)) |
| 3294 |
neon_lane_bounds (lane_idx, 0, TREE_INT_CST_LOW (nlanes), exp); |
| 3295 |
else |
| 3296 |
error_at (EXPR_LOCATION (exp), |
| 3297 |
"lane index must be a constant immediate"); |
| 3298 |
/* Don't generate any RTL. */ |
| 3299 |
return const0_rtx; |
| 3300 |
} |
| 3301 |
if (fcode >= ARM_BUILTIN_MVE_BASE) |
| 3302 |
return arm_expand_mve_builtin (fcode, exp, target); |
| 3303 |
|
| 3304 |
if (fcode >= ARM_BUILTIN_ACLE_BASE) |
| 3305 |
return arm_expand_acle_builtin (fcode, exp, target); |
| 3306 |
|
| 3307 |
if (fcode >= ARM_BUILTIN_NEON_BASE) |
| 3308 |
return arm_expand_neon_builtin (fcode, exp, target); |
| 3309 |
|
| 3310 |
if (fcode >= ARM_BUILTIN_VFP_BASE) |
| 3311 |
return arm_expand_vfp_builtin (fcode, exp, target); |
| 3312 |
|
| 3313 |
/* Check in the context of the function making the call whether the |
| 3314 |
builtin is supported. */ |
| 3315 |
if (fcode >= ARM_BUILTIN_CRYPTO_BASE |
| 3316 |
&& (!TARGET_CRYPTO || !TARGET_HARD_FLOAT)) |
| 3317 |
{ |
| 3318 |
fatal_error (input_location, |
| 3319 |
"You must enable crypto instructions" |
| 3320 |
" (e.g. include %<-mfloat-abi=softfp%> " |
| 3321 |
"%<-mfpu=crypto-neon%>)" |
| 3322 |
" to use these intrinsics."); |
| 3323 |
return const0_rtx; |
| 3324 |
} |
| 3325 |
|
| 3326 |
switch (fcode) |
| 3327 |
{ |
| 3328 |
case ARM_BUILTIN_GET_FPSCR_NZCVQC: |
| 3329 |
case ARM_BUILTIN_SET_FPSCR_NZCVQC: |
| 3330 |
if (fcode == ARM_BUILTIN_GET_FPSCR_NZCVQC) |
| 3331 |
{ |
| 3332 |
icode = CODE_FOR_get_fpscr_nzcvqc; |
| 3333 |
target = gen_reg_rtx (SImode); |
| 3334 |
emit_insn (GEN_FCN (icode) (target)); |
| 3335 |
return target; |
| 3336 |
} |
| 3337 |
else |
| 3338 |
{ |
| 3339 |
icode = CODE_FOR_set_fpscr_nzcvqc; |
| 3340 |
op0 = expand_normal (CALL_EXPR_ARG (exp, 0)); |
| 3341 |
emit_insn (GEN_FCN (icode) (force_reg (SImode, op0))); |
| 3342 |
return NULL_RTX; |
| 3343 |
} |
| 3344 |
|
| 3345 |
case ARM_BUILTIN_GET_FPSCR: |
| 3346 |
case ARM_BUILTIN_SET_FPSCR: |
| 3347 |
if (fcode == ARM_BUILTIN_GET_FPSCR) |
| 3348 |
{ |
| 3349 |
icode = CODE_FOR_get_fpscr; |
| 3350 |
target = gen_reg_rtx (SImode); |
| 3351 |
pat = GEN_FCN (icode) (target); |
| 3352 |
} |
| 3353 |
else |
| 3354 |
{ |
| 3355 |
target = NULL_RTX; |
| 3356 |
icode = CODE_FOR_set_fpscr; |
| 3357 |
arg0 = CALL_EXPR_ARG (exp, 0); |
| 3358 |
op0 = expand_normal (arg0); |
| 3359 |
pat = GEN_FCN (icode) (force_reg (SImode, op0)); |
| 3360 |
} |
| 3361 |
emit_insn (pat); |
| 3362 |
return target; |
| 3363 |
|
| 3364 |
case ARM_BUILTIN_CMSE_NONSECURE_CALLER: |
| 3365 |
target = gen_reg_rtx (SImode); |
| 3366 |
op0 = arm_return_addr (0, NULL_RTX); |
| 3367 |
emit_insn (gen_andsi3 (target, op0, const1_rtx)); |
| 3368 |
op1 = gen_rtx_EQ (SImode, target, const0_rtx); |
| 3369 |
emit_insn (gen_cstoresi4 (target, op1, target, const0_rtx)); |
| 3370 |
return target; |
| 3371 |
|
| 3372 |
case ARM_BUILTIN_TEXTRMSB: |
| 3373 |
case ARM_BUILTIN_TEXTRMUB: |
| 3374 |
case ARM_BUILTIN_TEXTRMSH: |
| 3375 |
case ARM_BUILTIN_TEXTRMUH: |
| 3376 |
case ARM_BUILTIN_TEXTRMSW: |
| 3377 |
case ARM_BUILTIN_TEXTRMUW: |
| 3378 |
icode = (fcode == ARM_BUILTIN_TEXTRMSB ? CODE_FOR_iwmmxt_textrmsb |
| 3379 |
: fcode == ARM_BUILTIN_TEXTRMUB ? CODE_FOR_iwmmxt_textrmub |
| 3380 |
: fcode == ARM_BUILTIN_TEXTRMSH ? CODE_FOR_iwmmxt_textrmsh |
| 3381 |
: fcode == ARM_BUILTIN_TEXTRMUH ? CODE_FOR_iwmmxt_textrmuh |
| 3382 |
: CODE_FOR_iwmmxt_textrmw); |
| 3383 |
|
| 3384 |
arg0 = CALL_EXPR_ARG (exp, 0); |
| 3385 |
arg1 = CALL_EXPR_ARG (exp, 1); |
| 3386 |
op0 = expand_normal (arg0); |
| 3387 |
op1 = expand_normal (arg1); |
| 3388 |
tmode = insn_data[icode].operand[0].mode; |
| 3389 |
mode0 = insn_data[icode].operand[1].mode; |
| 3390 |
mode1 = insn_data[icode].operand[2].mode; |
| 3391 |
|
| 3392 |
if (! (*insn_data[icode].operand[1].predicate) (op0, mode0)) |
| 3393 |
op0 = copy_to_mode_reg (mode0, op0); |
| 3394 |
if (! (*insn_data[icode].operand[2].predicate) (op1, mode1)) |
| 3395 |
{ |
| 3396 |
/* @@@ better error message */ |
| 3397 |
error ("selector must be an immediate"); |
| 3398 |
return gen_reg_rtx (tmode); |
| 3399 |
} |
| 3400 |
|
| 3401 |
opint = INTVAL (op1); |
| 3402 |
if (fcode == ARM_BUILTIN_TEXTRMSB || fcode == ARM_BUILTIN_TEXTRMUB) |
| 3403 |
{ |
| 3404 |
if (opint > 7 || opint < 0) |
| 3405 |
error ("the range of selector should be in 0 to 7"); |
| 3406 |
} |
| 3407 |
else if (fcode == ARM_BUILTIN_TEXTRMSH || fcode == ARM_BUILTIN_TEXTRMUH) |
| 3408 |
{ |
| 3409 |
if (opint > 3 || opint < 0) |
| 3410 |
error ("the range of selector should be in 0 to 3"); |
| 3411 |
} |
| 3412 |
else /* ARM_BUILTIN_TEXTRMSW || ARM_BUILTIN_TEXTRMUW. */ |
| 3413 |
{ |
| 3414 |
if (opint > 1 || opint < 0) |
| 3415 |
error ("the range of selector should be in 0 to 1"); |
| 3416 |
} |
| 3417 |
|
| 3418 |
if (target == 0 |
| 3419 |
|| GET_MODE (target) != tmode |
| 3420 |
|| ! (*insn_data[icode].operand[0].predicate) (target, tmode)) |
| 3421 |
target = gen_reg_rtx (tmode); |
| 3422 |
pat = GEN_FCN (icode) (target, op0, op1); |
| 3423 |
if (! pat) |
| 3424 |
return 0; |
| 3425 |
emit_insn (pat); |
| 3426 |
return target; |
| 3427 |
|
| 3428 |
case ARM_BUILTIN_WALIGNI: |
| 3429 |
/* If op2 is immediate, call walighi, else call walighr. */ |
| 3430 |
arg0 = CALL_EXPR_ARG (exp, 0); |
| 3431 |
arg1 = CALL_EXPR_ARG (exp, 1); |
| 3432 |
arg2 = CALL_EXPR_ARG (exp, 2); |
| 3433 |
op0 = expand_normal (arg0); |
| 3434 |
op1 = expand_normal (arg1); |
| 3435 |
op2 = expand_normal (arg2); |
| 3436 |
if (CONST_INT_P (op2)) |
| 3437 |
{ |
| 3438 |
icode = CODE_FOR_iwmmxt_waligni; |
| 3439 |
tmode = insn_data[icode].operand[0].mode; |
| 3440 |
mode0 = insn_data[icode].operand[1].mode; |
| 3441 |
mode1 = insn_data[icode].operand[2].mode; |
| 3442 |
mode2 = insn_data[icode].operand[3].mode; |
| 3443 |
if (!(*insn_data[icode].operand[1].predicate) (op0, mode0)) |
| 3444 |
op0 = copy_to_mode_reg (mode0, op0); |
| 3445 |
if (!(*insn_data[icode].operand[2].predicate) (op1, mode1)) |
| 3446 |
op1 = copy_to_mode_reg (mode1, op1); |
| 3447 |
gcc_assert ((*insn_data[icode].operand[3].predicate) (op2, mode2)); |
| 3448 |
selector = INTVAL (op2); |
| 3449 |
if (selector > 7 || selector < 0) |
| 3450 |
error ("the range of selector should be in 0 to 7"); |
| 3451 |
} |
| 3452 |
else |
| 3453 |
{ |
| 3454 |
icode = CODE_FOR_iwmmxt_walignr; |
| 3455 |
tmode = insn_data[icode].operand[0].mode; |
| 3456 |
mode0 = insn_data[icode].operand[1].mode; |
| 3457 |
mode1 = insn_data[icode].operand[2].mode; |
| 3458 |
mode2 = insn_data[icode].operand[3].mode; |
| 3459 |
if (!(*insn_data[icode].operand[1].predicate) (op0, mode0)) |
| 3460 |
op0 = copy_to_mode_reg (mode0, op0); |
| 3461 |
if (!(*insn_data[icode].operand[2].predicate) (op1, mode1)) |
| 3462 |
op1 = copy_to_mode_reg (mode1, op1); |
| 3463 |
if (!(*insn_data[icode].operand[3].predicate) (op2, mode2)) |
| 3464 |
op2 = copy_to_mode_reg (mode2, op2); |
| 3465 |
} |
| 3466 |
if (target == 0 |
| 3467 |
|| GET_MODE (target) != tmode |
| 3468 |
|| !(*insn_data[icode].operand[0].predicate) (target, tmode)) |
| 3469 |
target = gen_reg_rtx (tmode); |
| 3470 |
pat = GEN_FCN (icode) (target, op0, op1, op2); |
| 3471 |
if (!pat) |
| 3472 |
return 0; |
| 3473 |
emit_insn (pat); |
| 3474 |
return target; |
| 3475 |
|
| 3476 |
case ARM_BUILTIN_TINSRB: |
| 3477 |
case ARM_BUILTIN_TINSRH: |
| 3478 |
case ARM_BUILTIN_TINSRW: |
| 3479 |
case ARM_BUILTIN_WMERGE: |
| 3480 |
icode = (fcode == ARM_BUILTIN_TINSRB ? CODE_FOR_iwmmxt_tinsrb |
| 3481 |
: fcode == ARM_BUILTIN_TINSRH ? CODE_FOR_iwmmxt_tinsrh |
| 3482 |
: fcode == ARM_BUILTIN_WMERGE ? CODE_FOR_iwmmxt_wmerge |
| 3483 |
: CODE_FOR_iwmmxt_tinsrw); |
| 3484 |
arg0 = CALL_EXPR_ARG (exp, 0); |
| 3485 |
arg1 = CALL_EXPR_ARG (exp, 1); |
| 3486 |
arg2 = CALL_EXPR_ARG (exp, 2); |
| 3487 |
op0 = expand_normal (arg0); |
| 3488 |
op1 = expand_normal (arg1); |
| 3489 |
op2 = expand_normal (arg2); |
| 3490 |
tmode = insn_data[icode].operand[0].mode; |
| 3491 |
mode0 = insn_data[icode].operand[1].mode; |
| 3492 |
mode1 = insn_data[icode].operand[2].mode; |
| 3493 |
mode2 = insn_data[icode].operand[3].mode; |
| 3494 |
|
| 3495 |
if (! (*insn_data[icode].operand[1].predicate) (op0, mode0)) |
| 3496 |
op0 = copy_to_mode_reg (mode0, op0); |
| 3497 |
if (! (*insn_data[icode].operand[2].predicate) (op1, mode1)) |
| 3498 |
op1 = copy_to_mode_reg (mode1, op1); |
| 3499 |
if (! (*insn_data[icode].operand[3].predicate) (op2, mode2)) |
| 3500 |
{ |
| 3501 |
error ("selector must be an immediate"); |
| 3502 |
return const0_rtx; |
| 3503 |
} |
| 3504 |
if (icode == CODE_FOR_iwmmxt_wmerge) |
| 3505 |
{ |
| 3506 |
selector = INTVAL (op2); |
| 3507 |
if (selector > 7 || selector < 0) |
| 3508 |
error ("the range of selector should be in 0 to 7"); |
| 3509 |
} |
| 3510 |
if ((icode == CODE_FOR_iwmmxt_tinsrb) |
| 3511 |
|| (icode == CODE_FOR_iwmmxt_tinsrh) |
| 3512 |
|| (icode == CODE_FOR_iwmmxt_tinsrw)) |
| 3513 |
{ |
| 3514 |
mask = 0x01; |
| 3515 |
selector= INTVAL (op2); |
| 3516 |
if (icode == CODE_FOR_iwmmxt_tinsrb && (selector < 0 || selector > 7)) |
| 3517 |
error ("the range of selector should be in 0 to 7"); |
| 3518 |
else if (icode == CODE_FOR_iwmmxt_tinsrh && (selector < 0 ||selector > 3)) |
| 3519 |
error ("the range of selector should be in 0 to 3"); |
| 3520 |
else if (icode == CODE_FOR_iwmmxt_tinsrw && (selector < 0 ||selector > 1)) |
| 3521 |
error ("the range of selector should be in 0 to 1"); |
| 3522 |
mask <<= selector; |
| 3523 |
op2 = GEN_INT (mask); |
| 3524 |
} |
| 3525 |
if (target == 0 |
| 3526 |
|| GET_MODE (target) != tmode |
| 3527 |
|| ! (*insn_data[icode].operand[0].predicate) (target, tmode)) |
| 3528 |
target = gen_reg_rtx (tmode); |
| 3529 |
pat = GEN_FCN (icode) (target, op0, op1, op2); |
| 3530 |
if (! pat) |
| 3531 |
return 0; |
| 3532 |
emit_insn (pat); |
| 3533 |
return target; |
| 3534 |
|
| 3535 |
case ARM_BUILTIN_SETWCGR0: |
| 3536 |
case ARM_BUILTIN_SETWCGR1: |
| 3537 |
case ARM_BUILTIN_SETWCGR2: |
| 3538 |
case ARM_BUILTIN_SETWCGR3: |
| 3539 |
icode = (fcode == ARM_BUILTIN_SETWCGR0 ? CODE_FOR_iwmmxt_setwcgr0 |
| 3540 |
: fcode == ARM_BUILTIN_SETWCGR1 ? CODE_FOR_iwmmxt_setwcgr1 |
| 3541 |
: fcode == ARM_BUILTIN_SETWCGR2 ? CODE_FOR_iwmmxt_setwcgr2 |
| 3542 |
: CODE_FOR_iwmmxt_setwcgr3); |
| 3543 |
arg0 = CALL_EXPR_ARG (exp, 0); |
| 3544 |
op0 = expand_normal (arg0); |
| 3545 |
mode0 = insn_data[icode].operand[0].mode; |
| 3546 |
if (!(*insn_data[icode].operand[0].predicate) (op0, mode0)) |
| 3547 |
op0 = copy_to_mode_reg (mode0, op0); |
| 3548 |
pat = GEN_FCN (icode) (op0); |
| 3549 |
if (!pat) |
| 3550 |
return 0; |
| 3551 |
emit_insn (pat); |
| 3552 |
return 0; |
| 3553 |
|
| 3554 |
case ARM_BUILTIN_GETWCGR0: |
| 3555 |
case ARM_BUILTIN_GETWCGR1: |
| 3556 |
case ARM_BUILTIN_GETWCGR2: |
| 3557 |
case ARM_BUILTIN_GETWCGR3: |
| 3558 |
icode = (fcode == ARM_BUILTIN_GETWCGR0 ? CODE_FOR_iwmmxt_getwcgr0 |
| 3559 |
: fcode == ARM_BUILTIN_GETWCGR1 ? CODE_FOR_iwmmxt_getwcgr1 |
| 3560 |
: fcode == ARM_BUILTIN_GETWCGR2 ? CODE_FOR_iwmmxt_getwcgr2 |
| 3561 |
: CODE_FOR_iwmmxt_getwcgr3); |
| 3562 |
tmode = insn_data[icode].operand[0].mode; |
| 3563 |
if (target == 0 |
| 3564 |
|| GET_MODE (target) != tmode |
| 3565 |
|| !(*insn_data[icode].operand[0].predicate) (target, tmode)) |
| 3566 |
target = gen_reg_rtx (tmode); |
| 3567 |
pat = GEN_FCN (icode) (target); |
| 3568 |
if (!pat) |
| 3569 |
return 0; |
| 3570 |
emit_insn (pat); |
| 3571 |
return target; |
| 3572 |
|
| 3573 |
case ARM_BUILTIN_WSHUFH: |
| 3574 |
icode = CODE_FOR_iwmmxt_wshufh; |
| 3575 |
arg0 = CALL_EXPR_ARG (exp, 0); |
| 3576 |
arg1 = CALL_EXPR_ARG (exp, 1); |
| 3577 |
op0 = expand_normal (arg0); |
| 3578 |
op1 = expand_normal (arg1); |
| 3579 |
tmode = insn_data[icode].operand[0].mode; |
| 3580 |
mode1 = insn_data[icode].operand[1].mode; |
| 3581 |
mode2 = insn_data[icode].operand[2].mode; |
| 3582 |
|
| 3583 |
if (! (*insn_data[icode].operand[1].predicate) (op0, mode1)) |
| 3584 |
op0 = copy_to_mode_reg (mode1, op0); |
| 3585 |
if (! (*insn_data[icode].operand[2].predicate) (op1, mode2)) |
| 3586 |
{ |
| 3587 |
error ("mask must be an immediate"); |
| 3588 |
return const0_rtx; |
| 3589 |
} |
| 3590 |
selector = INTVAL (op1); |
| 3591 |
if (selector < 0 || selector > 255) |
| 3592 |
error ("the range of mask should be in 0 to 255"); |
| 3593 |
if (target == 0 |
| 3594 |
|| GET_MODE (target) != tmode |
| 3595 |
|| ! (*insn_data[icode].operand[0].predicate) (target, tmode)) |
| 3596 |
target = gen_reg_rtx (tmode); |
| 3597 |
pat = GEN_FCN (icode) (target, op0, op1); |
| 3598 |
if (! pat) |
| 3599 |
return 0; |
| 3600 |
emit_insn (pat); |
| 3601 |
return target; |
| 3602 |
|
| 3603 |
case ARM_BUILTIN_WMADDS: |
| 3604 |
return arm_expand_binop_builtin (CODE_FOR_iwmmxt_wmadds, exp, target); |
| 3605 |
case ARM_BUILTIN_WMADDSX: |
| 3606 |
return arm_expand_binop_builtin (CODE_FOR_iwmmxt_wmaddsx, exp, target); |
| 3607 |
case ARM_BUILTIN_WMADDSN: |
| 3608 |
return arm_expand_binop_builtin (CODE_FOR_iwmmxt_wmaddsn, exp, target); |
| 3609 |
case ARM_BUILTIN_WMADDU: |
| 3610 |
return arm_expand_binop_builtin (CODE_FOR_iwmmxt_wmaddu, exp, target); |
| 3611 |
case ARM_BUILTIN_WMADDUX: |
| 3612 |
return arm_expand_binop_builtin (CODE_FOR_iwmmxt_wmaddux, exp, target); |
| 3613 |
case ARM_BUILTIN_WMADDUN: |
| 3614 |
return arm_expand_binop_builtin (CODE_FOR_iwmmxt_wmaddun, exp, target); |
| 3615 |
case ARM_BUILTIN_WSADBZ: |
| 3616 |
return arm_expand_binop_builtin (CODE_FOR_iwmmxt_wsadbz, exp, target); |
| 3617 |
case ARM_BUILTIN_WSADHZ: |
| 3618 |
return arm_expand_binop_builtin (CODE_FOR_iwmmxt_wsadhz, exp, target); |
| 3619 |
|
| 3620 |
/* Several three-argument builtins. */ |
| 3621 |
case ARM_BUILTIN_WMACS: |
| 3622 |
case ARM_BUILTIN_WMACU: |
| 3623 |
case ARM_BUILTIN_TMIA: |
| 3624 |
case ARM_BUILTIN_TMIAPH: |
| 3625 |
case ARM_BUILTIN_TMIATT: |
| 3626 |
case ARM_BUILTIN_TMIATB: |
| 3627 |
case ARM_BUILTIN_TMIABT: |
| 3628 |
case ARM_BUILTIN_TMIABB: |
| 3629 |
case ARM_BUILTIN_WQMIABB: |
| 3630 |
case ARM_BUILTIN_WQMIABT: |
| 3631 |
case ARM_BUILTIN_WQMIATB: |
| 3632 |
case ARM_BUILTIN_WQMIATT: |
| 3633 |
case ARM_BUILTIN_WQMIABBN: |
| 3634 |
case ARM_BUILTIN_WQMIABTN: |
| 3635 |
case ARM_BUILTIN_WQMIATBN: |
| 3636 |
case ARM_BUILTIN_WQMIATTN: |
| 3637 |
case ARM_BUILTIN_WMIABB: |
| 3638 |
case ARM_BUILTIN_WMIABT: |
| 3639 |
case ARM_BUILTIN_WMIATB: |
| 3640 |
case ARM_BUILTIN_WMIATT: |
| 3641 |
case ARM_BUILTIN_WMIABBN: |
| 3642 |
case ARM_BUILTIN_WMIABTN: |
| 3643 |
case ARM_BUILTIN_WMIATBN: |
| 3644 |
case ARM_BUILTIN_WMIATTN: |
| 3645 |
case ARM_BUILTIN_WMIAWBB: |
| 3646 |
case ARM_BUILTIN_WMIAWBT: |
| 3647 |
case ARM_BUILTIN_WMIAWTB: |
| 3648 |
case ARM_BUILTIN_WMIAWTT: |
| 3649 |
case ARM_BUILTIN_WMIAWBBN: |
| 3650 |
case ARM_BUILTIN_WMIAWBTN: |
| 3651 |
case ARM_BUILTIN_WMIAWTBN: |
| 3652 |
case ARM_BUILTIN_WMIAWTTN: |
| 3653 |
case ARM_BUILTIN_WSADB: |
| 3654 |
case ARM_BUILTIN_WSADH: |
| 3655 |
icode = (fcode == ARM_BUILTIN_WMACS ? CODE_FOR_iwmmxt_wmacs |
| 3656 |
: fcode == ARM_BUILTIN_WMACU ? CODE_FOR_iwmmxt_wmacu |
| 3657 |
: fcode == ARM_BUILTIN_TMIA ? CODE_FOR_iwmmxt_tmia |
| 3658 |
: fcode == ARM_BUILTIN_TMIAPH ? CODE_FOR_iwmmxt_tmiaph |
| 3659 |
: fcode == ARM_BUILTIN_TMIABB ? CODE_FOR_iwmmxt_tmiabb |
| 3660 |
: fcode == ARM_BUILTIN_TMIABT ? CODE_FOR_iwmmxt_tmiabt |
| 3661 |
: fcode == ARM_BUILTIN_TMIATB ? CODE_FOR_iwmmxt_tmiatb |
| 3662 |
: fcode == ARM_BUILTIN_TMIATT ? CODE_FOR_iwmmxt_tmiatt |
| 3663 |
: fcode == ARM_BUILTIN_WQMIABB ? CODE_FOR_iwmmxt_wqmiabb |
| 3664 |
: fcode == ARM_BUILTIN_WQMIABT ? CODE_FOR_iwmmxt_wqmiabt |
| 3665 |
: fcode == ARM_BUILTIN_WQMIATB ? CODE_FOR_iwmmxt_wqmiatb |
| 3666 |
: fcode == ARM_BUILTIN_WQMIATT ? CODE_FOR_iwmmxt_wqmiatt |
| 3667 |
: fcode == ARM_BUILTIN_WQMIABBN ? CODE_FOR_iwmmxt_wqmiabbn |
| 3668 |
: fcode == ARM_BUILTIN_WQMIABTN ? CODE_FOR_iwmmxt_wqmiabtn |
| 3669 |
: fcode == ARM_BUILTIN_WQMIATBN ? CODE_FOR_iwmmxt_wqmiatbn |
| 3670 |
: fcode == ARM_BUILTIN_WQMIATTN ? CODE_FOR_iwmmxt_wqmiattn |
| 3671 |
: fcode == ARM_BUILTIN_WMIABB ? CODE_FOR_iwmmxt_wmiabb |
| 3672 |
: fcode == ARM_BUILTIN_WMIABT ? CODE_FOR_iwmmxt_wmiabt |
| 3673 |
: fcode == ARM_BUILTIN_WMIATB ? CODE_FOR_iwmmxt_wmiatb |
| 3674 |
: fcode == ARM_BUILTIN_WMIATT ? CODE_FOR_iwmmxt_wmiatt |
| 3675 |
: fcode == ARM_BUILTIN_WMIABBN ? CODE_FOR_iwmmxt_wmiabbn |
| 3676 |
: fcode == ARM_BUILTIN_WMIABTN ? CODE_FOR_iwmmxt_wmiabtn |
| 3677 |
: fcode == ARM_BUILTIN_WMIATBN ? CODE_FOR_iwmmxt_wmiatbn |
| 3678 |
: fcode == ARM_BUILTIN_WMIATTN ? CODE_FOR_iwmmxt_wmiattn |
| 3679 |
: fcode == ARM_BUILTIN_WMIAWBB ? CODE_FOR_iwmmxt_wmiawbb |
| 3680 |
: fcode == ARM_BUILTIN_WMIAWBT ? CODE_FOR_iwmmxt_wmiawbt |
| 3681 |
: fcode == ARM_BUILTIN_WMIAWTB ? CODE_FOR_iwmmxt_wmiawtb |
| 3682 |
: fcode == ARM_BUILTIN_WMIAWTT ? CODE_FOR_iwmmxt_wmiawtt |
| 3683 |
: fcode == ARM_BUILTIN_WMIAWBBN ? CODE_FOR_iwmmxt_wmiawbbn |
| 3684 |
: fcode == ARM_BUILTIN_WMIAWBTN ? CODE_FOR_iwmmxt_wmiawbtn |
| 3685 |
: fcode == ARM_BUILTIN_WMIAWTBN ? CODE_FOR_iwmmxt_wmiawtbn |
| 3686 |
: fcode == ARM_BUILTIN_WMIAWTTN ? CODE_FOR_iwmmxt_wmiawttn |
| 3687 |
: fcode == ARM_BUILTIN_WSADB ? CODE_FOR_iwmmxt_wsadb |
| 3688 |
: CODE_FOR_iwmmxt_wsadh); |
| 3689 |
arg0 = CALL_EXPR_ARG (exp, 0); |
| 3690 |
arg1 = CALL_EXPR_ARG (exp, 1); |
| 3691 |
arg2 = CALL_EXPR_ARG (exp, 2); |
| 3692 |
op0 = expand_normal (arg0); |
| 3693 |
op1 = expand_normal (arg1); |
| 3694 |
op2 = expand_normal (arg2); |
| 3695 |
tmode = insn_data[icode].operand[0].mode; |
| 3696 |
mode0 = insn_data[icode].operand[1].mode; |
| 3697 |
mode1 = insn_data[icode].operand[2].mode; |
| 3698 |
mode2 = insn_data[icode].operand[3].mode; |
| 3699 |
|
| 3700 |
if (! (*insn_data[icode].operand[1].predicate) (op0, mode0)) |
| 3701 |
op0 = copy_to_mode_reg (mode0, op0); |
| 3702 |
if (! (*insn_data[icode].operand[2].predicate) (op1, mode1)) |
| 3703 |
op1 = copy_to_mode_reg (mode1, op1); |
| 3704 |
if (! (*insn_data[icode].operand[3].predicate) (op2, mode2)) |
| 3705 |
op2 = copy_to_mode_reg (mode2, op2); |
| 3706 |
if (target == 0 |
| 3707 |
|| GET_MODE (target) != tmode |
| 3708 |
|| ! (*insn_data[icode].operand[0].predicate) (target, tmode)) |
| 3709 |
target = gen_reg_rtx (tmode); |
| 3710 |
pat = GEN_FCN (icode) (target, op0, op1, op2); |
| 3711 |
if (! pat) |
| 3712 |
return 0; |
| 3713 |
emit_insn (pat); |
| 3714 |
return target; |
| 3715 |
|
| 3716 |
case ARM_BUILTIN_WZERO: |
| 3717 |
target = gen_reg_rtx (DImode); |
| 3718 |
emit_insn (gen_iwmmxt_clrdi (target)); |
| 3719 |
return target; |
| 3720 |
|
| 3721 |
case ARM_BUILTIN_WSRLHI: |
| 3722 |
case ARM_BUILTIN_WSRLWI: |
| 3723 |
case ARM_BUILTIN_WSRLDI: |
| 3724 |
case ARM_BUILTIN_WSLLHI: |
| 3725 |
case ARM_BUILTIN_WSLLWI: |
| 3726 |
case ARM_BUILTIN_WSLLDI: |
| 3727 |
case ARM_BUILTIN_WSRAHI: |
| 3728 |
case ARM_BUILTIN_WSRAWI: |
| 3729 |
case ARM_BUILTIN_WSRADI: |
| 3730 |
case ARM_BUILTIN_WRORHI: |
| 3731 |
case ARM_BUILTIN_WRORWI: |
| 3732 |
case ARM_BUILTIN_WRORDI: |
| 3733 |
case ARM_BUILTIN_WSRLH: |
| 3734 |
case ARM_BUILTIN_WSRLW: |
| 3735 |
case ARM_BUILTIN_WSRLD: |
| 3736 |
case ARM_BUILTIN_WSLLH: |
| 3737 |
case ARM_BUILTIN_WSLLW: |
| 3738 |
case ARM_BUILTIN_WSLLD: |
| 3739 |
case ARM_BUILTIN_WSRAH: |
| 3740 |
case ARM_BUILTIN_WSRAW: |
| 3741 |
case ARM_BUILTIN_WSRAD: |
| 3742 |
case ARM_BUILTIN_WRORH: |
| 3743 |
case ARM_BUILTIN_WRORW: |
| 3744 |
case ARM_BUILTIN_WRORD: |
| 3745 |
icode = (fcode == ARM_BUILTIN_WSRLHI ? CODE_FOR_lshrv4hi3_iwmmxt |
| 3746 |
: fcode == ARM_BUILTIN_WSRLWI ? CODE_FOR_lshrv2si3_iwmmxt |
| 3747 |
: fcode == ARM_BUILTIN_WSRLDI ? CODE_FOR_lshrdi3_iwmmxt |
| 3748 |
: fcode == ARM_BUILTIN_WSLLHI ? CODE_FOR_ashlv4hi3_iwmmxt |
| 3749 |
: fcode == ARM_BUILTIN_WSLLWI ? CODE_FOR_ashlv2si3_iwmmxt |
| 3750 |
: fcode == ARM_BUILTIN_WSLLDI ? CODE_FOR_ashldi3_iwmmxt |
| 3751 |
: fcode == ARM_BUILTIN_WSRAHI ? CODE_FOR_ashrv4hi3_iwmmxt |
| 3752 |
: fcode == ARM_BUILTIN_WSRAWI ? CODE_FOR_ashrv2si3_iwmmxt |
| 3753 |
: fcode == ARM_BUILTIN_WSRADI ? CODE_FOR_ashrdi3_iwmmxt |
| 3754 |
: fcode == ARM_BUILTIN_WRORHI ? CODE_FOR_rorv4hi3 |
| 3755 |
: fcode == ARM_BUILTIN_WRORWI ? CODE_FOR_rorv2si3 |
| 3756 |
: fcode == ARM_BUILTIN_WRORDI ? CODE_FOR_rordi3 |
| 3757 |
: fcode == ARM_BUILTIN_WSRLH ? CODE_FOR_lshrv4hi3_di |
| 3758 |
: fcode == ARM_BUILTIN_WSRLW ? CODE_FOR_lshrv2si3_di |
| 3759 |
: fcode == ARM_BUILTIN_WSRLD ? CODE_FOR_lshrdi3_di |
| 3760 |
: fcode == ARM_BUILTIN_WSLLH ? CODE_FOR_ashlv4hi3_di |
| 3761 |
: fcode == ARM_BUILTIN_WSLLW ? CODE_FOR_ashlv2si3_di |
| 3762 |
: fcode == ARM_BUILTIN_WSLLD ? CODE_FOR_ashldi3_di |
| 3763 |
: fcode == ARM_BUILTIN_WSRAH ? CODE_FOR_ashrv4hi3_di |
| 3764 |
: fcode == ARM_BUILTIN_WSRAW ? CODE_FOR_ashrv2si3_di |
| 3765 |
: fcode == ARM_BUILTIN_WSRAD ? CODE_FOR_ashrdi3_di |
| 3766 |
: fcode == ARM_BUILTIN_WRORH ? CODE_FOR_rorv4hi3_di |
| 3767 |
: fcode == ARM_BUILTIN_WRORW ? CODE_FOR_rorv2si3_di |
| 3768 |
: fcode == ARM_BUILTIN_WRORD ? CODE_FOR_rordi3_di |
| 3769 |
: CODE_FOR_nothing); |
| 3770 |
arg1 = CALL_EXPR_ARG (exp, 1); |
| 3771 |
op1 = expand_normal (arg1); |
| 3772 |
if (GET_MODE (op1) == VOIDmode) |
| 3773 |
{ |
| 3774 |
imm = INTVAL (op1); |
| 3775 |
if ((fcode == ARM_BUILTIN_WRORWI || fcode == ARM_BUILTIN_WRORW) |
| 3776 |
&& (imm < 0 || imm > 32)) |
| 3777 |
{ |
| 3778 |
const char *builtin = (fcode == ARM_BUILTIN_WRORWI |
| 3779 |
? "_mm_rori_pi32" : "_mm_ror_pi32"); |
| 3780 |
error ("the range of count should be in 0 to 32; " |
| 3781 |
"please check the intrinsic %qs in code", builtin); |
| 3782 |
} |
| 3783 |
else if ((fcode == ARM_BUILTIN_WRORHI || fcode == ARM_BUILTIN_WRORH) |
| 3784 |
&& (imm < 0 || imm > 16)) |
| 3785 |
{ |
| 3786 |
const char *builtin = (fcode == ARM_BUILTIN_WRORHI |
| 3787 |
? "_mm_rori_pi16" : "_mm_ror_pi16"); |
| 3788 |
error ("the range of count should be in 0 to 16; " |
| 3789 |
"please check the intrinsic %qs in code", builtin); |
| 3790 |
} |
| 3791 |
else if ((fcode == ARM_BUILTIN_WRORDI || fcode == ARM_BUILTIN_WRORD) |
| 3792 |
&& (imm < 0 || imm > 64)) |
| 3793 |
{ |
| 3794 |
const char *builtin = (fcode == ARM_BUILTIN_WRORDI |
| 3795 |
? "_mm_rori_si64" : "_mm_ror_si64"); |
| 3796 |
error ("the range of count should be in 0 to 64; " |
| 3797 |
"please check the intrinsic %qs in code", builtin); |
| 3798 |
} |
| 3799 |
else if (imm < 0) |
| 3800 |
{ |
| 3801 |
const char *builtin; |
| 3802 |
switch (fcode) |
| 3803 |
{ |
| 3804 |
case ARM_BUILTIN_WSRLHI: |
| 3805 |
builtin = "_mm_srli_pi16"; |
| 3806 |
break; |
| 3807 |
case ARM_BUILTIN_WSRLWI: |
| 3808 |
builtin = "_mm_srli_pi32"; |
| 3809 |
break; |
| 3810 |
case ARM_BUILTIN_WSRLDI: |
| 3811 |
builtin = "_mm_srli_si64"; |
| 3812 |
break; |
| 3813 |
case ARM_BUILTIN_WSLLHI: |
| 3814 |
builtin = "_mm_slli_pi16"; |
| 3815 |
break; |
| 3816 |
case ARM_BUILTIN_WSLLWI: |
| 3817 |
builtin = "_mm_slli_pi32"; |
| 3818 |
break; |
| 3819 |
case ARM_BUILTIN_WSLLDI: |
| 3820 |
builtin = "_mm_slli_si64"; |
| 3821 |
break; |
| 3822 |
case ARM_BUILTIN_WSRAHI: |
| 3823 |
builtin = "_mm_srai_pi16"; |
| 3824 |
break; |
| 3825 |
case ARM_BUILTIN_WSRAWI: |
| 3826 |
builtin = "_mm_srai_pi32"; |
| 3827 |
break; |
| 3828 |
case ARM_BUILTIN_WSRADI: |
| 3829 |
builtin = "_mm_srai_si64"; |
| 3830 |
break; |
| 3831 |
case ARM_BUILTIN_WSRLH: |
| 3832 |
builtin = "_mm_srl_pi16"; |
| 3833 |
break; |
| 3834 |
case ARM_BUILTIN_WSRLW: |
| 3835 |
builtin = "_mm_srl_pi32"; |
| 3836 |
break; |
| 3837 |
case ARM_BUILTIN_WSRLD: |
| 3838 |
builtin = "_mm_srl_si64"; |
| 3839 |
break; |
| 3840 |
case ARM_BUILTIN_WSLLH: |
| 3841 |
builtin = "_mm_sll_pi16"; |
| 3842 |
break; |
| 3843 |
case ARM_BUILTIN_WSLLW: |
| 3844 |
builtin = "_mm_sll_pi32"; |
| 3845 |
break; |
| 3846 |
case ARM_BUILTIN_WSLLD: |
| 3847 |
builtin = "_mm_sll_si64"; |
| 3848 |
break; |
| 3849 |
case ARM_BUILTIN_WSRAH: |
| 3850 |
builtin = "_mm_sra_pi16"; |
| 3851 |
break; |
| 3852 |
case ARM_BUILTIN_WSRAW: |
| 3853 |
builtin = "_mm_sra_si64"; |
| 3854 |
break; |
| 3855 |
default: |
| 3856 |
builtin = "_mm_sra_si64"; |
| 3857 |
break; |
| 3858 |
} |
| 3859 |
error ("the count should be no less than 0; " |
| 3860 |
"please check the intrinsic %qs in code", builtin); |
| 3861 |
} |
| 3862 |
} |
| 3863 |
return arm_expand_binop_builtin (icode, exp, target); |
| 3864 |
|
| 3865 |
default: |
| 3866 |
break; |
| 3867 |
} |
| 3868 |
|
| 3869 |
for (i = 0, d = bdesc_2arg; i < ARRAY_SIZE (bdesc_2arg); i++, d++) |
| 3870 |
if (d->code == (enum arm_builtins) fcode) |
| 3871 |
return arm_expand_binop_builtin (d->icode, exp, target); |
| 3872 |
|
| 3873 |
for (i = 0, d = bdesc_1arg; i < ARRAY_SIZE (bdesc_1arg); i++, d++) |
| 3874 |
if (d->code == (enum arm_builtins) fcode) |
| 3875 |
return arm_expand_unop_builtin (d->icode, exp, target, 0); |
| 3876 |
|
| 3877 |
for (i = 0, d = bdesc_3arg; i < ARRAY_SIZE (bdesc_3arg); i++, d++) |
| 3878 |
if (d->code == (enum arm_builtins) fcode) |
| 3879 |
return arm_expand_ternop_builtin (d->icode, exp, target); |
| 3880 |
|
| 3881 |
/* @@@ Should really do something sensible here. */ |
| 3882 |
return NULL_RTX; |
| 3883 |
} |
| 3884 |
|
| 3885 |
/* Expand an expression EXP that calls a built-in function, |
| 3886 |
with result going to TARGET if that's convenient |
| 3887 |
(and in mode MODE if that's convenient). |
| 3888 |
SUBTARGET may be used as the target for computing one of EXP's operands. |
| 3889 |
IGNORE is nonzero if the value is to be ignored. */ |
| 3890 |
|
| 3891 |
rtx |
| 3892 |
arm_expand_builtin (tree exp, |
| 3893 |
rtx target, |
| 3894 |
rtx subtarget ATTRIBUTE_UNUSED, |
| 3895 |
machine_mode mode ATTRIBUTE_UNUSED, |
| 3896 |
int ignore ATTRIBUTE_UNUSED) |
| 3897 |
{ |
| 3898 |
tree fndecl = TREE_OPERAND (CALL_EXPR_FN (exp), 0); |
| 3899 |
unsigned int code = DECL_MD_FUNCTION_CODE (fndecl); |
| 3900 |
unsigned int subcode = code >> ARM_BUILTIN_SHIFT; |
| 3901 |
switch (code & ARM_BUILTIN_CLASS) |
| 3902 |
{ |
| 3903 |
case ARM_BUILTIN_GENERAL: |
| 3904 |
return arm_general_expand_builtin (subcode, exp, target, ignore); |
| 3905 |
case ARM_BUILTIN_MVE: |
| 3906 |
return arm_mve::expand_builtin (subcode, exp, target); |
| 3907 |
default: |
| 3908 |
gcc_unreachable (); |
| 3909 |
} |
| 3910 |
} |
| 3911 |
|
| 3912 |
void |
| 3913 |
arm_atomic_assign_expand_fenv (tree *hold, tree *clear, tree *update) |
| 3914 |
{ |
| 3915 |
const unsigned ARM_FE_INVALID = 1; |
| 3916 |
const unsigned ARM_FE_DIVBYZERO = 2; |
| 3917 |
const unsigned ARM_FE_OVERFLOW = 4; |
| 3918 |
const unsigned ARM_FE_UNDERFLOW = 8; |
| 3919 |
const unsigned ARM_FE_INEXACT = 16; |
| 3920 |
const unsigned HOST_WIDE_INT ARM_FE_ALL_EXCEPT = (ARM_FE_INVALID |
| 3921 |
| ARM_FE_DIVBYZERO |
| 3922 |
| ARM_FE_OVERFLOW |
| 3923 |
| ARM_FE_UNDERFLOW |
| 3924 |
| ARM_FE_INEXACT); |
| 3925 |
const unsigned HOST_WIDE_INT ARM_FE_EXCEPT_SHIFT = 8; |
| 3926 |
tree fenv_var, get_fpscr, set_fpscr, mask, ld_fenv, masked_fenv; |
| 3927 |
tree new_fenv_var, reload_fenv, restore_fnenv; |
| 3928 |
tree update_call, atomic_feraiseexcept, hold_fnclex; |
| 3929 |
|
| 3930 |
if (!TARGET_HARD_FLOAT) |
| 3931 |
return; |
| 3932 |
|
| 3933 |
/* Generate the equivalent of : |
| 3934 |
unsigned int fenv_var; |
| 3935 |
fenv_var = __builtin_arm_get_fpscr (); |
| 3936 |
|
| 3937 |
unsigned int masked_fenv; |
| 3938 |
masked_fenv = fenv_var & mask; |
| 3939 |
|
| 3940 |
__builtin_arm_set_fpscr (masked_fenv); */ |
| 3941 |
|
| 3942 |
fenv_var = create_tmp_var_raw (unsigned_type_node); |
| 3943 |
get_fpscr = arm_builtin_decls[ARM_BUILTIN_GET_FPSCR]; |
| 3944 |
set_fpscr = arm_builtin_decls[ARM_BUILTIN_SET_FPSCR]; |
| 3945 |
mask = build_int_cst (unsigned_type_node, |
| 3946 |
~((ARM_FE_ALL_EXCEPT << ARM_FE_EXCEPT_SHIFT) |
| 3947 |
| ARM_FE_ALL_EXCEPT)); |
| 3948 |
ld_fenv = build4 (TARGET_EXPR, unsigned_type_node, |
| 3949 |
fenv_var, build_call_expr (get_fpscr, 0), |
| 3950 |
NULL_TREE, NULL_TREE); |
| 3951 |
masked_fenv = build2 (BIT_AND_EXPR, unsigned_type_node, fenv_var, mask); |
| 3952 |
hold_fnclex = build_call_expr (set_fpscr, 1, masked_fenv); |
| 3953 |
*hold = build2 (COMPOUND_EXPR, void_type_node, |
| 3954 |
build2 (COMPOUND_EXPR, void_type_node, masked_fenv, ld_fenv), |
| 3955 |
hold_fnclex); |
| 3956 |
|
| 3957 |
/* Store the value of masked_fenv to clear the exceptions: |
| 3958 |
__builtin_arm_set_fpscr (masked_fenv); */ |
| 3959 |
|
| 3960 |
*clear = build_call_expr (set_fpscr, 1, masked_fenv); |
| 3961 |
|
| 3962 |
/* Generate the equivalent of : |
| 3963 |
unsigned int new_fenv_var; |
| 3964 |
new_fenv_var = __builtin_arm_get_fpscr (); |
| 3965 |
|
| 3966 |
__builtin_arm_set_fpscr (fenv_var); |
| 3967 |
|
| 3968 |
__atomic_feraiseexcept (new_fenv_var); */ |
| 3969 |
|
| 3970 |
new_fenv_var = create_tmp_var_raw (unsigned_type_node); |
| 3971 |
reload_fenv = build4 (TARGET_EXPR, unsigned_type_node, new_fenv_var, |
| 3972 |
build_call_expr (get_fpscr, 0), NULL_TREE, NULL_TREE); |
| 3973 |
restore_fnenv = build_call_expr (set_fpscr, 1, fenv_var); |
| 3974 |
atomic_feraiseexcept = builtin_decl_implicit (BUILT_IN_ATOMIC_FERAISEEXCEPT); |
| 3975 |
update_call = build_call_expr (atomic_feraiseexcept, 1, |
| 3976 |
fold_convert (integer_type_node, new_fenv_var)); |
| 3977 |
*update = build2 (COMPOUND_EXPR, void_type_node, |
| 3978 |
build2 (COMPOUND_EXPR, void_type_node, |
| 3979 |
reload_fenv, restore_fnenv), update_call); |
| 3980 |
} |
| 3981 |
|
| 3982 |
/* Implement TARGET_CHECK_BUILTIN_CALL for general builtins. Record a read of |
| 3983 |
the Q bit through intrinsics in the machine function for general built-in |
| 3984 |
functions. */ |
| 3985 |
bool |
| 3986 |
arm_general_check_builtin_call (unsigned int code) |
| 3987 |
{ |
| 3988 |
if (code == ARM_BUILTIN_saturation_occurred |
| 3989 |
|| code == ARM_BUILTIN_set_saturation) |
| 3990 |
{ |
| 3991 |
if (cfun && cfun->decl) |
| 3992 |
DECL_ATTRIBUTES (cfun->decl) |
| 3993 |
= tree_cons (get_identifier ("acle qbit"), NULL_TREE, |
| 3994 |
DECL_ATTRIBUTES (cfun->decl)); |
| 3995 |
} |
| 3996 |
else if (code == ARM_BUILTIN_sel) |
| 3997 |
{ |
| 3998 |
if (cfun && cfun->decl) |
| 3999 |
DECL_ATTRIBUTES (cfun->decl) |
| 4000 |
= tree_cons (get_identifier ("acle gebits"), NULL_TREE, |
| 4001 |
DECL_ATTRIBUTES (cfun->decl)); |
| 4002 |
} |
| 4003 |
return true; |
| 4004 |
} |
| 4005 |
|
| 4006 |
/* Implement TARGET_CHECK_BUILTIN_CALL. */ |
| 4007 |
bool |
| 4008 |
arm_check_builtin_call (location_t loc, vec<location_t> arg_loc, tree fndecl, |
| 4009 |
tree orig_fndecl, unsigned int nargs, tree *args, bool) |
| 4010 |
{ |
| 4011 |
unsigned int code = DECL_MD_FUNCTION_CODE (fndecl); |
| 4012 |
unsigned int subcode = code >> ARM_BUILTIN_SHIFT; |
| 4013 |
switch (code & ARM_BUILTIN_CLASS) |
| 4014 |
{ |
| 4015 |
case ARM_BUILTIN_GENERAL: |
| 4016 |
return arm_general_check_builtin_call (subcode); |
| 4017 |
case ARM_BUILTIN_MVE: |
| 4018 |
return arm_mve::check_builtin_call (loc, arg_loc, subcode, |
| 4019 |
orig_fndecl, nargs, args); |
| 4020 |
default: |
| 4021 |
gcc_unreachable (); |
| 4022 |
} |
| 4023 |
|
| 4024 |
} |
| 4025 |
|
| 4026 |
enum resolver_ident |
| 4027 |
arm_describe_resolver (tree fndecl) |
| 4028 |
{ |
| 4029 |
unsigned int code = DECL_MD_FUNCTION_CODE (fndecl); |
| 4030 |
unsigned int subcode = code >> ARM_BUILTIN_SHIFT; |
| 4031 |
switch (code & ARM_BUILTIN_CLASS) |
| 4032 |
{ |
| 4033 |
case ARM_BUILTIN_GENERAL: |
| 4034 |
if (subcode >= ARM_BUILTIN_vcx1qv16qi |
| 4035 |
&& subcode < ARM_BUILTIN_MVE_BASE) |
| 4036 |
return arm_cde_resolver; |
| 4037 |
return arm_no_resolver; |
| 4038 |
case ARM_BUILTIN_MVE: |
| 4039 |
return arm_mve_resolver; |
| 4040 |
default: |
| 4041 |
gcc_unreachable (); |
| 4042 |
} |
| 4043 |
} |
| 4044 |
|
| 4045 |
unsigned |
| 4046 |
arm_cde_end_args (tree fndecl) |
| 4047 |
{ |
| 4048 |
unsigned int code = DECL_MD_FUNCTION_CODE (fndecl); |
| 4049 |
unsigned int subcode = code >> ARM_BUILTIN_SHIFT; |
| 4050 |
switch (code & ARM_BUILTIN_CLASS) |
| 4051 |
{ |
| 4052 |
case ARM_BUILTIN_GENERAL: |
| 4053 |
return subcode >= ARM_BUILTIN_vcx1q_p_v16qi ? 2 : 1; |
| 4054 |
default: |
| 4055 |
gcc_unreachable (); |
| 4056 |
} |
| 4057 |
} |
| 4058 |
|
| 4059 |
/* Fold a call to vaeseq_u8 and vaesdq_u8. |
| 4060 |
That is `vaeseq_u8 (x ^ y, 0)` gets folded |
| 4061 |
into `vaeseq_u8 (x, y)`.*/ |
| 4062 |
static gimple * |
| 4063 |
arm_fold_aes_op (gcall *stmt) |
| 4064 |
{ |
| 4065 |
tree arg0 = gimple_call_arg (stmt, 0); |
| 4066 |
tree arg1 = gimple_call_arg (stmt, 1); |
| 4067 |
if (integer_zerop (arg0)) |
| 4068 |
arg0 = arg1; |
| 4069 |
else if (!integer_zerop (arg1)) |
| 4070 |
return nullptr; |
| 4071 |
if (TREE_CODE (arg0) != SSA_NAME) |
| 4072 |
return nullptr; |
| 4073 |
if (!has_single_use (arg0)) |
| 4074 |
return nullptr; |
| 4075 |
auto *s = dyn_cast<gassign *> (SSA_NAME_DEF_STMT (arg0)); |
| 4076 |
if (!s || gimple_assign_rhs_code (s) != BIT_XOR_EXPR) |
| 4077 |
return nullptr; |
| 4078 |
gimple_call_set_arg (stmt, 0, gimple_assign_rhs1 (s)); |
| 4079 |
gimple_call_set_arg (stmt, 1, gimple_assign_rhs2 (s)); |
| 4080 |
return stmt; |
| 4081 |
} |
| 4082 |
|
| 4083 |
/* Try to fold STMT, given that it's a call to the built-in function with |
| 4084 |
subcode FCODE. Return the new statement on success and null on |
| 4085 |
failure. */ |
| 4086 |
gimple * |
| 4087 |
arm_general_gimple_fold_builtin (unsigned int fcode, gcall *stmt) |
| 4088 |
{ |
| 4089 |
gimple *new_stmt = NULL; |
| 4090 |
|
| 4091 |
switch (fcode) |
| 4092 |
{ |
| 4093 |
case ARM_BUILTIN_CRYPTO_AESE: |
| 4094 |
case ARM_BUILTIN_CRYPTO_AESD: |
| 4095 |
new_stmt = arm_fold_aes_op (stmt); |
| 4096 |
break; |
| 4097 |
} |
| 4098 |
|
| 4099 |
/* GIMPLE assign statements (unlike calls) require a non-null lhs. If we |
| 4100 |
created an assign statement with a null lhs, then fix this by assigning |
| 4101 |
to a new (and subsequently unused) variable. */ |
| 4102 |
if (new_stmt && is_gimple_assign (new_stmt) && !gimple_assign_lhs (new_stmt)) |
| 4103 |
{ |
| 4104 |
tree new_lhs = make_ssa_name (gimple_call_return_type (stmt)); |
| 4105 |
gimple_assign_set_lhs (new_stmt, new_lhs); |
| 4106 |
} |
| 4107 |
|
| 4108 |
return new_stmt; |
| 4109 |
} |
| 4110 |
|
| 4111 |
#include "gt-arm-builtins.h" |