| 1 |
/* Definitions of target machine for GNU compiler. LoongArch version. |
| 2 |
Copyright (C) 2021-2025 Free Software Foundation, Inc. |
| 3 |
Contributed by Loongson Ltd. |
| 4 |
Based on MIPS and RISC-V target for GNU compiler. |
| 5 |
|
| 6 |
This file is part of GCC. |
| 7 |
|
| 8 |
GCC is free software; you can redistribute it and/or modify |
| 9 |
it under the terms of the GNU General Public License as published by |
| 10 |
the Free Software Foundation; either version 3, or (at your option) |
| 11 |
any later version. |
| 12 |
|
| 13 |
GCC is distributed in the hope that it will be useful, |
| 14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
GNU General Public License for more details. |
| 17 |
|
| 18 |
You should have received a copy of the GNU General Public License |
| 19 |
along with GCC; see the file COPYING3. If not see |
| 20 |
<http://www.gnu.org/licenses/>. */ |
| 21 |
|
| 22 |
/* LoongArch external variables defined in loongarch.cc. */ |
| 23 |
|
| 24 |
#include "config/loongarch/loongarch-opts.h" |
| 25 |
#include "config/loongarch/loongarch-evolution.h" |
| 26 |
|
| 27 |
#define SWITCHABLE_TARGET 1 |
| 28 |
|
| 29 |
#define REGISTER_TARGET_PRAGMAS() loongarch_register_pragmas () |
| 30 |
|
| 31 |
#define TARGET_SUPPORTS_WIDE_INT 1 |
| 32 |
|
| 33 |
/* Macros to silence warnings about numbers being signed in traditional |
| 34 |
C and unsigned in ISO C when compiled on 32-bit hosts. */ |
| 35 |
|
| 36 |
#define BITMASK_HIGH (((unsigned long) 1) << 31) /* 0x80000000 */ |
| 37 |
|
| 38 |
/* Run-time compilation parameters selecting different hardware subsets. */ |
| 39 |
|
| 40 |
/* Target CPU builtins. */ |
| 41 |
#define TARGET_CPU_CPP_BUILTINS() loongarch_cpu_cpp_builtins (pfile) |
| 42 |
|
| 43 |
/* Default target_flags if no switches are specified. */ |
| 44 |
|
| 45 |
#ifdef IN_LIBGCC2 |
| 46 |
#undef TARGET_64BIT |
| 47 |
/* Make this compile time constant for libgcc2. */ |
| 48 |
#ifdef __loongarch64 |
| 49 |
#define TARGET_64BIT 1 |
| 50 |
#else |
| 51 |
#define TARGET_64BIT 0 |
| 52 |
#endif |
| 53 |
#endif /* IN_LIBGCC2 */ |
| 54 |
|
| 55 |
#define TARGET_LIBGCC_SDATA_SECTION ".sdata" |
| 56 |
|
| 57 |
/* This definition replaces the formerly used 'm' constraint with a |
| 58 |
different constraint letter in order to avoid changing semantics of |
| 59 |
the 'm' constraint when accepting new address formats in |
| 60 |
TARGET_LEGITIMATE_ADDRESS_P. The constraint letter defined here |
| 61 |
must not be used in insn definitions or inline assemblies. */ |
| 62 |
#define TARGET_MEM_CONSTRAINT 'w' |
| 63 |
|
| 64 |
/* Tell collect what flags to pass to nm. */ |
| 65 |
#ifndef NM_FLAGS |
| 66 |
#define NM_FLAGS "-Bn" |
| 67 |
#endif |
| 68 |
|
| 69 |
/* Registers may have a prefix which can be ignored when matching |
| 70 |
user asm and register definitions. */ |
| 71 |
#ifndef REGISTER_PREFIX |
| 72 |
#define REGISTER_PREFIX "$" |
| 73 |
#endif |
| 74 |
|
| 75 |
/* Local compiler-generated symbols must have a prefix that the assembler |
| 76 |
understands. */ |
| 77 |
|
| 78 |
#define LOCAL_LABEL_PREFIX "." |
| 79 |
|
| 80 |
/* By default on the loongarch, external symbols do not have an underscore |
| 81 |
prepended. */ |
| 82 |
|
| 83 |
#define USER_LABEL_PREFIX "" |
| 84 |
|
| 85 |
#ifndef PREFERRED_DEBUGGING_TYPE |
| 86 |
#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG |
| 87 |
#endif |
| 88 |
|
| 89 |
/* The size of DWARF addresses should be the same as the size of symbols |
| 90 |
in the target file format. */ |
| 91 |
#define DWARF2_ADDR_SIZE (TARGET_64BIT ? 8 : 4) |
| 92 |
|
| 93 |
/* By default, turn on GDB extensions. */ |
| 94 |
#define DEFAULT_GDB_EXTENSIONS 1 |
| 95 |
|
| 96 |
/* By default, produce dwarf version 2 format debugging output in response |
| 97 |
to the ‘-g’ option. */ |
| 98 |
#define DWARF2_DEBUGGING_INFO 1 |
| 99 |
|
| 100 |
/* The mapping from gcc register number to DWARF 2 CFA column number. */ |
| 101 |
#define DWARF_FRAME_REGNUM(REGNO) loongarch_dwarf_regno[REGNO] |
| 102 |
|
| 103 |
/* The DWARF 2 CFA column which tracks the return address. */ |
| 104 |
#define DWARF_FRAME_RETURN_COLUMN RETURN_ADDR_REGNUM |
| 105 |
|
| 106 |
/* Before the prologue, RA lives in r1. */ |
| 107 |
#define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (Pmode, RETURN_ADDR_REGNUM) |
| 108 |
|
| 109 |
/* Describe how we implement __builtin_eh_return. */ |
| 110 |
#define EH_RETURN_DATA_REGNO(N) \ |
| 111 |
((N) < (4) ? (N) + GP_ARG_FIRST : INVALID_REGNUM) |
| 112 |
|
| 113 |
#define EH_RETURN_STACKADJ_RTX gen_rtx_REG (Pmode, GP_ARG_FIRST + 4) |
| 114 |
|
| 115 |
#define EH_USES(N) loongarch_eh_uses (N) |
| 116 |
|
| 117 |
/* Offsets recorded in opcodes are a multiple of this alignment factor. |
| 118 |
The default for this in 64-bit mode is 8, which causes problems with |
| 119 |
SFmode register saves. */ |
| 120 |
#define DWARF_CIE_DATA_ALIGNMENT -4 |
| 121 |
|
| 122 |
/* Target machine storage layout. */ |
| 123 |
|
| 124 |
#define BITS_BIG_ENDIAN 0 |
| 125 |
#define BYTES_BIG_ENDIAN 0 |
| 126 |
#define WORDS_BIG_ENDIAN 0 |
| 127 |
|
| 128 |
#define MAX_BITS_PER_WORD 64 |
| 129 |
|
| 130 |
/* Width of a word, in units (bytes). */ |
| 131 |
#define UNITS_PER_WORD (TARGET_64BIT ? 8 : 4) |
| 132 |
#ifndef IN_LIBGCC2 |
| 133 |
#define MIN_UNITS_PER_WORD 4 |
| 134 |
#endif |
| 135 |
|
| 136 |
/* Width of a LSX vector register in bytes. */ |
| 137 |
#define UNITS_PER_LSX_REG 16 |
| 138 |
/* Width of a LSX vector register in bits. */ |
| 139 |
#define BITS_PER_LSX_REG (UNITS_PER_LSX_REG * BITS_PER_UNIT) |
| 140 |
|
| 141 |
/* Width of a LASX vector register in bytes. */ |
| 142 |
#define UNITS_PER_LASX_REG 32 |
| 143 |
/* Width of a LASX vector register in bits. */ |
| 144 |
#define BITS_PER_LASX_REG (UNITS_PER_LASX_REG * BITS_PER_UNIT) |
| 145 |
|
| 146 |
/* The largest size of value that can be held in floating-point |
| 147 |
registers and moved with a single instruction. */ |
| 148 |
#define UNITS_PER_HWFPVALUE \ |
| 149 |
(TARGET_SOFT_FLOAT ? 0 : UNITS_PER_FP_REG) |
| 150 |
|
| 151 |
/* The number of bytes in a double. */ |
| 152 |
#define UNITS_PER_DOUBLE (TYPE_PRECISION (double_type_node) / BITS_PER_UNIT) |
| 153 |
|
| 154 |
/* Set the sizes of the core types. */ |
| 155 |
#define SHORT_TYPE_SIZE 16 |
| 156 |
#define INT_TYPE_SIZE 32 |
| 157 |
#define LONG_TYPE_SIZE (TARGET_64BIT ? 64 : 32) |
| 158 |
#define LONG_LONG_TYPE_SIZE 64 |
| 159 |
|
| 160 |
/* LONG_DOUBLE_TYPE_SIZE get poisoned, so add LA_ prefix. */ |
| 161 |
#define LA_LONG_DOUBLE_TYPE_SIZE (TARGET_64BIT ? 128 : 64) |
| 162 |
|
| 163 |
/* Define the sizes of fixed-point types. */ |
| 164 |
#define SHORT_FRACT_TYPE_SIZE 8 |
| 165 |
#define FRACT_TYPE_SIZE 16 |
| 166 |
#define LONG_FRACT_TYPE_SIZE 32 |
| 167 |
#define LONG_LONG_FRACT_TYPE_SIZE 64 |
| 168 |
|
| 169 |
#define SHORT_ACCUM_TYPE_SIZE 16 |
| 170 |
#define ACCUM_TYPE_SIZE 32 |
| 171 |
#define LONG_ACCUM_TYPE_SIZE 64 |
| 172 |
#define LONG_LONG_ACCUM_TYPE_SIZE (TARGET_64BIT ? 128 : 64) |
| 173 |
|
| 174 |
/* long double is not a fixed mode, but the idea is that, if we |
| 175 |
support long double, we also want a 128-bit integer type. */ |
| 176 |
#define MAX_FIXED_MODE_SIZE LA_LONG_DOUBLE_TYPE_SIZE |
| 177 |
|
| 178 |
/* Width in bits of a pointer. */ |
| 179 |
#ifndef POINTER_SIZE |
| 180 |
#define POINTER_SIZE (TARGET_64BIT ? 64 : 32) |
| 181 |
#endif |
| 182 |
|
| 183 |
/* Allocation boundary (in *bits*) for storing arguments in argument list. */ |
| 184 |
#define PARM_BOUNDARY BITS_PER_WORD |
| 185 |
|
| 186 |
/* Allocation boundary (in *bits*) for the code of a function. */ |
| 187 |
#define FUNCTION_BOUNDARY 32 |
| 188 |
|
| 189 |
/* Alignment of field after `int : 0' in a structure. */ |
| 190 |
#define EMPTY_FIELD_BOUNDARY 32 |
| 191 |
|
| 192 |
/* Number of bits which any structure or union's size must be a multiple of. |
| 193 |
Each structure or union's size is rounded up to a multiple of this. */ |
| 194 |
#define STRUCTURE_SIZE_BOUNDARY 8 |
| 195 |
|
| 196 |
/* There is no point aligning anything to a rounder boundary than |
| 197 |
LA_LONG_DOUBLE_TYPE_SIZE, unless under LSX/LASX the bigggest alignment is |
| 198 |
BITS_PER_LSX_REG/BITS_PER_LASX_REG/.. */ |
| 199 |
#define BIGGEST_ALIGNMENT \ |
| 200 |
(ISA_HAS_LASX? BITS_PER_LASX_REG \ |
| 201 |
: (ISA_HAS_LSX ? BITS_PER_LSX_REG : LA_LONG_DOUBLE_TYPE_SIZE)) |
| 202 |
|
| 203 |
/* All accesses must be aligned. */ |
| 204 |
#define STRICT_ALIGNMENT (TARGET_STRICT_ALIGN) |
| 205 |
|
| 206 |
/* Define this if you wish to imitate the way many other C compilers |
| 207 |
handle alignment of bitfields and the structures that contain |
| 208 |
them. |
| 209 |
|
| 210 |
The behavior is that the type written for a bit-field (`int', |
| 211 |
`short', or other integer type) imposes an alignment for the |
| 212 |
entire structure, as if the structure really did contain an |
| 213 |
ordinary field of that type. In addition, the bit-field is placed |
| 214 |
within the structure so that it would fit within such a field, |
| 215 |
not crossing a boundary for it. |
| 216 |
|
| 217 |
Thus, on most machines, a bit-field whose type is written as `int' |
| 218 |
would not cross a four-byte boundary, and would force four-byte |
| 219 |
alignment for the whole structure. (The alignment used may not |
| 220 |
be four bytes; it is controlled by the other alignment |
| 221 |
parameters.) |
| 222 |
|
| 223 |
If the macro is defined, its definition should be a C expression; |
| 224 |
a nonzero value for the expression enables this behavior. */ |
| 225 |
|
| 226 |
#define PCC_BITFIELD_TYPE_MATTERS 1 |
| 227 |
|
| 228 |
/* If defined, a C expression to compute the alignment for a static |
| 229 |
variable. TYPE is the data type, and ALIGN is the alignment that |
| 230 |
the object would ordinarily have. The value of this macro is used |
| 231 |
instead of that alignment to align the object. |
| 232 |
|
| 233 |
If this macro is not defined, then ALIGN is used. |
| 234 |
|
| 235 |
One use of this macro is to increase alignment of medium-size |
| 236 |
data to make it all fit in fewer cache lines. Another is to |
| 237 |
cause character arrays to be word-aligned so that `strcpy' calls |
| 238 |
that copy constants to character arrays can be done inline. */ |
| 239 |
|
| 240 |
#undef DATA_ALIGNMENT |
| 241 |
#define DATA_ALIGNMENT(TYPE, ALIGN) \ |
| 242 |
((((ALIGN) < BITS_PER_WORD) \ |
| 243 |
&& (TREE_CODE (TYPE) == ARRAY_TYPE \ |
| 244 |
|| TREE_CODE (TYPE) == UNION_TYPE \ |
| 245 |
|| TREE_CODE (TYPE) == RECORD_TYPE)) ? BITS_PER_WORD : (ALIGN)) |
| 246 |
|
| 247 |
/* We need this for the same reason as DATA_ALIGNMENT, namely to cause |
| 248 |
character arrays to be word-aligned so that `strcpy' calls that copy |
| 249 |
constants to character arrays can be done inline, and 'strcmp' can be |
| 250 |
optimised to use word loads. */ |
| 251 |
#define LOCAL_ALIGNMENT(TYPE, ALIGN) DATA_ALIGNMENT (TYPE, ALIGN) |
| 252 |
|
| 253 |
/* Define if operations between registers always perform the operation |
| 254 |
on the full register even if a narrower mode is specified. */ |
| 255 |
#define WORD_REGISTER_OPERATIONS 1 |
| 256 |
|
| 257 |
/* When in 64-bit mode, move insns will sign extend SImode and FCCmode |
| 258 |
moves. All other references are zero extended. */ |
| 259 |
#define LOAD_EXTEND_OP(MODE) \ |
| 260 |
(TARGET_64BIT && ((MODE) == SImode || (MODE) == FCCmode) ? SIGN_EXTEND \ |
| 261 |
: ZERO_EXTEND) |
| 262 |
|
| 263 |
/* Define this macro if it is advisable to hold scalars in registers |
| 264 |
in a wider mode than that declared by the program. In such cases, |
| 265 |
the value is constrained to be within the bounds of the declared |
| 266 |
type, but kept valid in the wider mode. The signedness of the |
| 267 |
extension may differ from that of the type. */ |
| 268 |
|
| 269 |
#define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \ |
| 270 |
if (GET_MODE_CLASS (MODE) == MODE_INT \ |
| 271 |
&& GET_MODE_SIZE (MODE) < UNITS_PER_WORD) \ |
| 272 |
{ \ |
| 273 |
if ((MODE) == SImode) \ |
| 274 |
(UNSIGNEDP) = 0; \ |
| 275 |
(MODE) = Pmode; \ |
| 276 |
} |
| 277 |
|
| 278 |
/* Pmode is always the same as ptr_mode, but not always the same as word_mode. |
| 279 |
Extensions of pointers to word_mode must be signed. */ |
| 280 |
#define POINTERS_EXTEND_UNSIGNED false |
| 281 |
|
| 282 |
/* Define if loading short immediate values into registers sign extends. */ |
| 283 |
#define SHORT_IMMEDIATES_SIGN_EXTEND 1 |
| 284 |
|
| 285 |
/* The clz.{w/d}, ctz.{w/d} instructions have the natural values at 0. */ |
| 286 |
|
| 287 |
#define CLZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) \ |
| 288 |
((VALUE) = GET_MODE_UNIT_BITSIZE (MODE), 2) |
| 289 |
#define CTZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) \ |
| 290 |
((VALUE) = GET_MODE_UNIT_BITSIZE (MODE), 2) |
| 291 |
|
| 292 |
/* Standard register usage. */ |
| 293 |
|
| 294 |
/* Number of hardware registers. We have: |
| 295 |
|
| 296 |
- 32 integer registers |
| 297 |
- 32 floating point registers |
| 298 |
- 8 condition code registers |
| 299 |
- 2 fake registers: |
| 300 |
- ARG_POINTER_REGNUM |
| 301 |
- FRAME_POINTER_REGNUM |
| 302 |
*/ |
| 303 |
|
| 304 |
#define FIRST_PSEUDO_REGISTER 74 |
| 305 |
|
| 306 |
/* zero, tp, sp and x are fixed. */ |
| 307 |
#define FIXED_REGISTERS \ |
| 308 |
{ /* General registers. */ \ |
| 309 |
1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ |
| 310 |
0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ |
| 311 |
/* Floating-point registers. */ \ |
| 312 |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ |
| 313 |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ |
| 314 |
/* Others. */ \ |
| 315 |
0, 0, 0, 0, 0, 0, 0, 0, 1, 1} |
| 316 |
|
| 317 |
/* The call RTLs themselves clobber ra. */ |
| 318 |
#define CALL_USED_REGISTERS \ |
| 319 |
{ /* General registers. */ \ |
| 320 |
1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ |
| 321 |
1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ |
| 322 |
/* Floating-point registers. */ \ |
| 323 |
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ |
| 324 |
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, \ |
| 325 |
/* Others. */ \ |
| 326 |
1, 1, 1, 1, 1, 1, 1, 1, 1, 1} |
| 327 |
|
| 328 |
/* Internal macros to classify a register number as to whether it's a |
| 329 |
general purpose register, a floating point register, or a status |
| 330 |
register. */ |
| 331 |
|
| 332 |
#define GP_REG_FIRST 0 |
| 333 |
#define GP_REG_LAST 31 |
| 334 |
#define GP_REG_NUM (GP_REG_LAST - GP_REG_FIRST + 1) |
| 335 |
|
| 336 |
#define FP_REG_FIRST 32 |
| 337 |
#define FP_REG_LAST 63 |
| 338 |
#define FP_REG_NUM (FP_REG_LAST - FP_REG_FIRST + 1) |
| 339 |
#define LSX_REG_FIRST FP_REG_FIRST |
| 340 |
#define LSX_REG_LAST FP_REG_LAST |
| 341 |
#define LSX_REG_NUM FP_REG_NUM |
| 342 |
|
| 343 |
#define LASX_REG_FIRST FP_REG_FIRST |
| 344 |
#define LASX_REG_LAST FP_REG_LAST |
| 345 |
#define LASX_REG_NUM FP_REG_NUM |
| 346 |
|
| 347 |
/* The DWARF 2 CFA column which tracks the return address from a |
| 348 |
signal handler context. This means that to maintain backwards |
| 349 |
compatibility, no hard register can be assigned this column if it |
| 350 |
would need to be handled by the DWARF unwinder. */ |
| 351 |
#define DWARF_ALT_FRAME_RETURN_COLUMN 72 |
| 352 |
|
| 353 |
#define FCC_REG_FIRST 64 |
| 354 |
#define FCC_REG_LAST 71 |
| 355 |
#define FCC_REG_NUM (FCC_REG_LAST - FCC_REG_FIRST + 1) |
| 356 |
|
| 357 |
#define GP_REG_P(REGNO) \ |
| 358 |
((unsigned int) ((int) (REGNO) - GP_REG_FIRST) < GP_REG_NUM) |
| 359 |
#define FP_REG_P(REGNO) \ |
| 360 |
((unsigned int) ((int) (REGNO) - FP_REG_FIRST) < FP_REG_NUM) |
| 361 |
#define FCC_REG_P(REGNO) \ |
| 362 |
((unsigned int) ((int) (REGNO) - FCC_REG_FIRST) < FCC_REG_NUM) |
| 363 |
#define LSX_REG_P(REGNO) \ |
| 364 |
((unsigned int) ((int) (REGNO) - LSX_REG_FIRST) < LSX_REG_NUM) |
| 365 |
#define LASX_REG_P(REGNO) \ |
| 366 |
((unsigned int) ((int) (REGNO) - LASX_REG_FIRST) < LASX_REG_NUM) |
| 367 |
|
| 368 |
#define FP_REG_RTX_P(X) (REG_P (X) && FP_REG_P (REGNO (X))) |
| 369 |
#define LSX_REG_RTX_P(X) (REG_P (X) && LSX_REG_P (REGNO (X))) |
| 370 |
#define LASX_REG_RTX_P(X) (REG_P (X) && LASX_REG_P (REGNO (X))) |
| 371 |
|
| 372 |
/* Select a register mode required for caller save of hard regno REGNO. */ |
| 373 |
#define HARD_REGNO_CALLER_SAVE_MODE(REGNO, NREGS, MODE) \ |
| 374 |
loongarch_hard_regno_caller_save_mode (REGNO, NREGS, MODE) |
| 375 |
|
| 376 |
/* Register to use for pushing function arguments. */ |
| 377 |
#define STACK_POINTER_REGNUM (GP_REG_FIRST + 3) |
| 378 |
|
| 379 |
/* These two registers don't really exist: they get eliminated to either |
| 380 |
the stack or hard frame pointer. */ |
| 381 |
#define ARG_POINTER_REGNUM 72 |
| 382 |
#define FRAME_POINTER_REGNUM 73 |
| 383 |
|
| 384 |
#define HARD_FRAME_POINTER_REGNUM (GP_REG_FIRST + 22) |
| 385 |
|
| 386 |
#define HARD_FRAME_POINTER_IS_FRAME_POINTER 0 |
| 387 |
#define HARD_FRAME_POINTER_IS_ARG_POINTER 0 |
| 388 |
|
| 389 |
/* Register in which static-chain is passed to a function. */ |
| 390 |
#define STATIC_CHAIN_REGNUM (GP_REG_FIRST + 20) /* $t8 */ |
| 391 |
|
| 392 |
#define GP_TEMP_FIRST (GP_REG_FIRST + 12) |
| 393 |
#define LARCH_PROLOGUE_TEMP_REGNUM (GP_TEMP_FIRST + 1) |
| 394 |
#define LARCH_PROLOGUE_TEMP2_REGNUM (GP_TEMP_FIRST) |
| 395 |
#define LARCH_PROLOGUE_TEMP3_REGNUM (GP_TEMP_FIRST + 2) |
| 396 |
#define LARCH_EPILOGUE_TEMP_REGNUM (GP_TEMP_FIRST) |
| 397 |
|
| 398 |
#define CALLEE_SAVED_REG_NUMBER(REGNO) \ |
| 399 |
((REGNO) >= 22 && (REGNO) <= 31 ? (REGNO) - 22 : -1) |
| 400 |
|
| 401 |
#define LARCH_PROLOGUE_TEMP(MODE) \ |
| 402 |
gen_rtx_REG (MODE, LARCH_PROLOGUE_TEMP_REGNUM) |
| 403 |
#define LARCH_PROLOGUE_TEMP2(MODE) \ |
| 404 |
gen_rtx_REG (MODE, LARCH_PROLOGUE_TEMP2_REGNUM) |
| 405 |
#define LARCH_PROLOGUE_TEMP3(MODE) \ |
| 406 |
gen_rtx_REG (MODE, LARCH_PROLOGUE_TEMP3_REGNUM) |
| 407 |
#define LARCH_EPILOGUE_TEMP(MODE) \ |
| 408 |
gen_rtx_REG (MODE, LARCH_EPILOGUE_TEMP_REGNUM) |
| 409 |
|
| 410 |
/* Define this macro if it is as good or better to call a constant |
| 411 |
function address than to call an address kept in a register. */ |
| 412 |
#define NO_FUNCTION_CSE 1 |
| 413 |
|
| 414 |
#define THREAD_POINTER_REGNUM (GP_REG_FIRST + 2) |
| 415 |
|
| 416 |
/* Define the classes of registers for register constraints in the |
| 417 |
machine description. Also define ranges of constants. |
| 418 |
|
| 419 |
One of the classes must always be named ALL_REGS and include all hard regs. |
| 420 |
If there is more than one class, another class must be named NO_REGS |
| 421 |
and contain no registers. |
| 422 |
|
| 423 |
The name GENERAL_REGS must be the name of a class (or an alias for |
| 424 |
another name such as ALL_REGS). This is the class of registers |
| 425 |
that is allowed by "r" in a register constraint. |
| 426 |
Also, registers outside this class are allocated only when |
| 427 |
instructions express preferences for them. |
| 428 |
|
| 429 |
The classes must be numbered in nondecreasing order; that is, |
| 430 |
a larger-numbered class must never be contained completely |
| 431 |
in a smaller-numbered class. |
| 432 |
|
| 433 |
For any two classes, it is very desirable that there be another |
| 434 |
class that represents their union. */ |
| 435 |
|
| 436 |
enum reg_class |
| 437 |
{ |
| 438 |
NO_REGS, /* no registers in set */ |
| 439 |
SIBCALL_REGS, /* registers used by indirect sibcalls */ |
| 440 |
JIRL_REGS, /* registers used by indirect calls */ |
| 441 |
CSR_REGS, /* integer registers except for $r0 and $r1 for lcsr. */ |
| 442 |
GR_REGS, /* integer registers */ |
| 443 |
FP_REGS, /* floating point registers */ |
| 444 |
FCC_REGS, /* status registers (fp status) */ |
| 445 |
FRAME_REGS, /* arg pointer and frame pointer */ |
| 446 |
ALL_REGS, /* all registers */ |
| 447 |
LIM_REG_CLASSES /* max value + 1 */ |
| 448 |
}; |
| 449 |
|
| 450 |
#define N_REG_CLASSES (int) LIM_REG_CLASSES |
| 451 |
|
| 452 |
#define GENERAL_REGS GR_REGS |
| 453 |
|
| 454 |
/* An initializer containing the names of the register classes as C |
| 455 |
string constants. These names are used in writing some of the |
| 456 |
debugging dumps. */ |
| 457 |
|
| 458 |
#define REG_CLASS_NAMES \ |
| 459 |
{ \ |
| 460 |
"NO_REGS", \ |
| 461 |
"SIBCALL_REGS", \ |
| 462 |
"JIRL_REGS", \ |
| 463 |
"CSR_REGS", \ |
| 464 |
"GR_REGS", \ |
| 465 |
"FP_REGS", \ |
| 466 |
"FCC_REGS", \ |
| 467 |
"FRAME_REGS", \ |
| 468 |
"ALL_REGS" \ |
| 469 |
} |
| 470 |
|
| 471 |
/* An initializer containing the contents of the register classes, |
| 472 |
as integers which are bit masks. The Nth integer specifies the |
| 473 |
contents of class N. The way the integer MASK is interpreted is |
| 474 |
that register R is in the class if `MASK & (1 << R)' is 1. |
| 475 |
|
| 476 |
When the machine has more than 32 registers, an integer does not |
| 477 |
suffice. Then the integers are replaced by sub-initializers, |
| 478 |
braced groupings containing several integers. Each |
| 479 |
sub-initializer must be suitable as an initializer for the type |
| 480 |
`HARD_REG_SET' which is defined in `hard-reg-set.h'. */ |
| 481 |
|
| 482 |
#define REG_CLASS_CONTENTS \ |
| 483 |
{ \ |
| 484 |
{ 0x00000000, 0x00000000, 0x00000000 }, /* NO_REGS */ \ |
| 485 |
{ 0x001fd000, 0x00000000, 0x00000000 }, /* SIBCALL_REGS */ \ |
| 486 |
{ 0xff9ffff0, 0x00000000, 0x00000000 }, /* JIRL_REGS */ \ |
| 487 |
{ 0xfffffffc, 0x00000000, 0x00000000 }, /* CSR_REGS */ \ |
| 488 |
{ 0xffffffff, 0x00000000, 0x00000000 }, /* GR_REGS */ \ |
| 489 |
{ 0x00000000, 0xffffffff, 0x00000000 }, /* FP_REGS */ \ |
| 490 |
{ 0x00000000, 0x00000000, 0x000000ff }, /* FCC_REGS */ \ |
| 491 |
{ 0x00000000, 0x00000000, 0x00000300 }, /* FRAME_REGS */ \ |
| 492 |
{ 0xffffffff, 0xffffffff, 0x000003ff } /* ALL_REGS */ \ |
| 493 |
} |
| 494 |
|
| 495 |
/* A C expression whose value is a register class containing hard |
| 496 |
register REGNO. In general there is more that one such class; |
| 497 |
choose a class which is "minimal", meaning that no smaller class |
| 498 |
also contains the register. */ |
| 499 |
|
| 500 |
#define REGNO_REG_CLASS(REGNO) loongarch_regno_to_class[(REGNO)] |
| 501 |
|
| 502 |
/* A macro whose definition is the name of the class to which a |
| 503 |
valid base register must belong. A base register is one used in |
| 504 |
an address which is the register value plus a displacement. */ |
| 505 |
|
| 506 |
#define BASE_REG_CLASS (GR_REGS) |
| 507 |
|
| 508 |
/* A macro whose definition is the name of the class to which a |
| 509 |
valid index register must belong. An index register is one used |
| 510 |
in an address where its value is either multiplied by a scale |
| 511 |
factor or added to another register (as well as added to a |
| 512 |
displacement). */ |
| 513 |
|
| 514 |
#define INDEX_REG_CLASS GR_REGS |
| 515 |
|
| 516 |
/* We generally want to put call-clobbered registers ahead of |
| 517 |
call-saved ones. (IRA expects this.) */ |
| 518 |
|
| 519 |
#define REG_ALLOC_ORDER \ |
| 520 |
{ /* Call-clobbered GPRs. */ \ |
| 521 |
12, 13, 14, 15, 16, 17, 18, 19, 20, 4, 5, 6, 7, 8, 9, 10, 11, 1, \ |
| 522 |
/* Call-saved GPRs. */ \ |
| 523 |
23, 24, 25, 26, 27, 28, 29, 30, 31, \ |
| 524 |
/* GPRs that can never be exposed to the register allocator. */ \ |
| 525 |
0, 2, 3, 21, 22, \ |
| 526 |
/* Call-clobbered FPRs. */ \ |
| 527 |
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, \ |
| 528 |
48, 49, 50, 51,52, 53, 54, 55, \ |
| 529 |
56, 57, 58, 59, 60, 61, 62, 63, \ |
| 530 |
/* None of the remaining classes have defined call-saved \ |
| 531 |
registers. */ \ |
| 532 |
64, 65, 66, 67, 68, 69, 70, 71, 72, 73} |
| 533 |
|
| 534 |
#define IMM_BITS 12 |
| 535 |
#define IMM_REACH (HOST_WIDE_INT_1 << IMM_BITS) |
| 536 |
#define HWIT_1U HOST_WIDE_INT_1U |
| 537 |
|
| 538 |
/* True if VALUE is an unsigned 6-bit number. */ |
| 539 |
|
| 540 |
#define UIMM6_OPERAND(VALUE) (((VALUE) & ~(unsigned HOST_WIDE_INT) 0x3f) == 0) |
| 541 |
|
| 542 |
/* True if VALUE is a signed 10-bit number. */ |
| 543 |
|
| 544 |
#define IMM10_OPERAND(VALUE) ((unsigned HOST_WIDE_INT) (VALUE) + 0x200 < 0x400) |
| 545 |
|
| 546 |
/* True if VALUE is a signed 12-bit number. */ |
| 547 |
|
| 548 |
#define IMM12_OPERAND(VALUE) \ |
| 549 |
((unsigned HOST_WIDE_INT) (VALUE) + IMM_REACH / 2 < IMM_REACH) |
| 550 |
|
| 551 |
/* True if VALUE is a signed 13-bit number. */ |
| 552 |
|
| 553 |
#define IMM13_OPERAND(VALUE) \ |
| 554 |
((unsigned HOST_WIDE_INT) (VALUE) + 0x1000 < 0x2000) |
| 555 |
|
| 556 |
/* True if VALUE is a signed 16-bit number. */ |
| 557 |
|
| 558 |
#define IMM16_OPERAND(VALUE) \ |
| 559 |
((unsigned HOST_WIDE_INT) (VALUE) + 0x8000 < 0x10000) |
| 560 |
|
| 561 |
/* True if VALUE is an unsigned 12-bit number. */ |
| 562 |
|
| 563 |
#define IMM12_OPERAND_UNSIGNED(VALUE) \ |
| 564 |
(((VALUE) & ~(unsigned HOST_WIDE_INT) (IMM_REACH - 1)) == 0) |
| 565 |
|
| 566 |
/* True if VALUE can be loaded into a register using LU12I. */ |
| 567 |
|
| 568 |
#define LU12I_OPERAND(VALUE) \ |
| 569 |
(((VALUE) | ((HWIT_1U << 31) - IMM_REACH)) == ((HWIT_1U << 31) - IMM_REACH) \ |
| 570 |
|| ((VALUE) | ((HWIT_1U << 31) - IMM_REACH)) + IMM_REACH == 0) |
| 571 |
|
| 572 |
/* True if VALUE can be loaded into a register using LU32I. */ |
| 573 |
|
| 574 |
#define LU32I_OPERAND(VALUE) \ |
| 575 |
(((VALUE) | (((HWIT_1U << 19) - 1) << 32)) == (((HWIT_1U << 19) - 1) << 32) \ |
| 576 |
|| ((VALUE) | (((HWIT_1U << 19) - 1) << 32)) + (HWIT_1U << 32) == 0) |
| 577 |
|
| 578 |
/* True if VALUE can be loaded into a register using LU52I. */ |
| 579 |
|
| 580 |
#define HWIT_UC_0xFFF HOST_WIDE_INT_UC(0xfff) |
| 581 |
#define LU52I_OPERAND(VALUE) \ |
| 582 |
(((VALUE) | (HWIT_UC_0xFFF << 52)) == (HWIT_UC_0xFFF << 52)) |
| 583 |
|
| 584 |
/* Return a value X with the low 12 bits clear, and such that |
| 585 |
VALUE - X is a signed 12-bit value. */ |
| 586 |
|
| 587 |
#define CONST_HIGH_PART(VALUE) (((VALUE) + (IMM_REACH / 2)) & ~(IMM_REACH - 1)) |
| 588 |
|
| 589 |
#define CONST_LOW_PART(VALUE) ((VALUE) - CONST_HIGH_PART (VALUE)) |
| 590 |
|
| 591 |
/* True if VALUE can be added onto a register with one addu16i.d |
| 592 |
instruction. */ |
| 593 |
|
| 594 |
#define ADDU16I_OPERAND(VALUE) \ |
| 595 |
(TARGET_64BIT && (((VALUE) & 0xffff) == 0 \ |
| 596 |
&& IMM16_OPERAND ((HOST_WIDE_INT) (VALUE) / 65536))) |
| 597 |
|
| 598 |
/* True if VALUE can be added onto a register with two addi.{d/w} |
| 599 |
instructions, but not one addi.{d/w} instruction. */ |
| 600 |
#define DUAL_IMM12_OPERAND(VALUE) \ |
| 601 |
(IN_RANGE ((VALUE), -4096, 4094) && !IMM12_OPERAND (VALUE)) |
| 602 |
|
| 603 |
/* True if VALUE can be added onto a register with two addu16i.d |
| 604 |
instruction, but not one addu16i.d instruction. */ |
| 605 |
#define DUAL_ADDU16I_OPERAND(VALUE) \ |
| 606 |
(TARGET_64BIT && (((VALUE) & 0xffff) == 0 \ |
| 607 |
&& !ADDU16I_OPERAND (VALUE) \ |
| 608 |
&& IN_RANGE ((VALUE) / 65536, -0x10000, 0xfffe))) |
| 609 |
|
| 610 |
#define IMM12_INT(X) IMM12_OPERAND (INTVAL (X)) |
| 611 |
#define IMM12_INT_UNSIGNED(X) IMM12_OPERAND_UNSIGNED (INTVAL (X)) |
| 612 |
#define LU12I_INT(X) LU12I_OPERAND (INTVAL (X)) |
| 613 |
#define LU32I_INT(X) LU32I_OPERAND (INTVAL (X)) |
| 614 |
#define LU52I_INT(X) LU52I_OPERAND (INTVAL (X)) |
| 615 |
#define LARCH_12BIT_OFFSET_P(OFFSET) (IN_RANGE (OFFSET, -2048, 2047)) |
| 616 |
#define LARCH_9BIT_OFFSET_P(OFFSET) (IN_RANGE (OFFSET, -256, 255)) |
| 617 |
#define LARCH_16BIT_OFFSET_P(OFFSET) (IN_RANGE (OFFSET, -32768, 32767)) |
| 618 |
#define LARCH_SHIFT_2_OFFSET_P(OFFSET) (((OFFSET) & 0x3) == 0) |
| 619 |
|
| 620 |
/* Return the maximum number of consecutive registers |
| 621 |
needed to represent mode MODE in a register of class CLASS. */ |
| 622 |
|
| 623 |
#define CLASS_MAX_NREGS(CLASS, MODE) loongarch_class_max_nregs (CLASS, MODE) |
| 624 |
|
| 625 |
/* Stack layout; function entry, exit and calling. */ |
| 626 |
|
| 627 |
#define STACK_GROWS_DOWNWARD 1 |
| 628 |
|
| 629 |
#define FRAME_GROWS_DOWNWARD 1 |
| 630 |
|
| 631 |
#define RETURN_ADDR_RTX loongarch_return_addr |
| 632 |
|
| 633 |
/* Similarly, don't use the least-significant bit to tell pointers to |
| 634 |
code from vtable index. */ |
| 635 |
|
| 636 |
#define TARGET_PTRMEMFUNC_VBIT_LOCATION ptrmemfunc_vbit_in_delta |
| 637 |
|
| 638 |
#define ELIMINABLE_REGS \ |
| 639 |
{ \ |
| 640 |
{ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \ |
| 641 |
{ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}, \ |
| 642 |
{FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \ |
| 643 |
{FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}, \ |
| 644 |
} |
| 645 |
|
| 646 |
#define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \ |
| 647 |
(OFFSET) = loongarch_initial_elimination_offset ((FROM), (TO)) |
| 648 |
|
| 649 |
/* Allocate stack space for arguments at the beginning of each function. */ |
| 650 |
#define ACCUMULATE_OUTGOING_ARGS 1 |
| 651 |
|
| 652 |
/* The argument pointer always points to the first argument. */ |
| 653 |
#define FIRST_PARM_OFFSET(FNDECL) 0 |
| 654 |
|
| 655 |
#define REG_PARM_STACK_SPACE(FNDECL) 0 |
| 656 |
|
| 657 |
/* Define this if it is the responsibility of the caller to |
| 658 |
allocate the area reserved for arguments passed in registers. |
| 659 |
If `ACCUMULATE_OUTGOING_ARGS' is also defined, the only effect |
| 660 |
of this macro is to determine whether the space is included in |
| 661 |
`crtl->outgoing_args_size'. */ |
| 662 |
#define OUTGOING_REG_PARM_STACK_SPACE(FNTYPE) 1 |
| 663 |
|
| 664 |
#define STACK_BOUNDARY (TARGET_ABI_LP64 ? 128 : 64) |
| 665 |
|
| 666 |
/* This value controls how many pages we manually unroll the loop for when |
| 667 |
generating stack clash probes. */ |
| 668 |
#define STACK_CLASH_MAX_UNROLL_PAGES 4 |
| 669 |
|
| 670 |
/* Symbolic macros for the registers used to return integer and floating |
| 671 |
point values. */ |
| 672 |
|
| 673 |
#define GP_RETURN (GP_REG_FIRST + 4) |
| 674 |
#define FP_RETURN ((TARGET_SOFT_FLOAT_ABI) ? GP_RETURN : (FP_REG_FIRST + 0)) |
| 675 |
|
| 676 |
#define MAX_ARGS_IN_REGISTERS 8 |
| 677 |
|
| 678 |
/* Symbolic macros for the first/last argument registers. */ |
| 679 |
|
| 680 |
#define GP_ARG_FIRST (GP_REG_FIRST + 4) |
| 681 |
#define GP_ARG_LAST (GP_ARG_FIRST + MAX_ARGS_IN_REGISTERS - 1) |
| 682 |
#define FP_ARG_FIRST (FP_REG_FIRST + 0) |
| 683 |
#define FP_ARG_LAST (FP_ARG_FIRST + MAX_ARGS_IN_REGISTERS - 1) |
| 684 |
|
| 685 |
/* True if MODE is vector and supported in a LSX vector register. */ |
| 686 |
#define LSX_SUPPORTED_MODE_P(MODE) \ |
| 687 |
(ISA_HAS_LSX \ |
| 688 |
&& GET_MODE_SIZE (MODE) == UNITS_PER_LSX_REG \ |
| 689 |
&& (GET_MODE_CLASS (MODE) == MODE_VECTOR_INT \ |
| 690 |
|| GET_MODE_CLASS (MODE) == MODE_VECTOR_FLOAT)) |
| 691 |
|
| 692 |
#define LASX_SUPPORTED_MODE_P(MODE) \ |
| 693 |
(ISA_HAS_LASX \ |
| 694 |
&& (GET_MODE_SIZE (MODE) == UNITS_PER_LSX_REG \ |
| 695 |
||GET_MODE_SIZE (MODE) == UNITS_PER_LASX_REG) \ |
| 696 |
&& (GET_MODE_CLASS (MODE) == MODE_VECTOR_INT \ |
| 697 |
|| GET_MODE_CLASS (MODE) == MODE_VECTOR_FLOAT)) |
| 698 |
|
| 699 |
#define RECIP_MASK_NONE 0x00 |
| 700 |
#define RECIP_MASK_DIV 0x01 |
| 701 |
#define RECIP_MASK_SQRT 0x02 |
| 702 |
#define RECIP_MASK_RSQRT 0x04 |
| 703 |
#define RECIP_MASK_VEC_DIV 0x08 |
| 704 |
#define RECIP_MASK_VEC_SQRT 0x10 |
| 705 |
#define RECIP_MASK_VEC_RSQRT 0x20 |
| 706 |
#define RECIP_MASK_ALL (RECIP_MASK_DIV | RECIP_MASK_SQRT \ |
| 707 |
| RECIP_MASK_RSQRT | RECIP_MASK_VEC_SQRT \ |
| 708 |
| RECIP_MASK_VEC_DIV | RECIP_MASK_VEC_RSQRT) |
| 709 |
|
| 710 |
#define TARGET_RECIP_DIV \ |
| 711 |
((recip_mask & RECIP_MASK_DIV) != 0 && ISA_HAS_FRECIPE) |
| 712 |
#define TARGET_RECIP_SQRT \ |
| 713 |
((recip_mask & RECIP_MASK_SQRT) != 0 && ISA_HAS_FRECIPE) |
| 714 |
#define TARGET_RECIP_RSQRT \ |
| 715 |
((recip_mask & RECIP_MASK_RSQRT) != 0 && ISA_HAS_FRECIPE) |
| 716 |
#define TARGET_RECIP_VEC_DIV \ |
| 717 |
((recip_mask & RECIP_MASK_VEC_DIV) != 0 && ISA_HAS_FRECIPE) |
| 718 |
#define TARGET_RECIP_VEC_SQRT \ |
| 719 |
((recip_mask & RECIP_MASK_VEC_SQRT) != 0 && ISA_HAS_FRECIPE) |
| 720 |
#define TARGET_RECIP_VEC_RSQRT \ |
| 721 |
((recip_mask & RECIP_MASK_VEC_RSQRT) != 0 && ISA_HAS_FRECIPE) |
| 722 |
|
| 723 |
/* 1 if N is a possible register number for function argument passing. |
| 724 |
We have no FP argument registers when soft-float. */ |
| 725 |
|
| 726 |
/* Accept arguments in a0-a7, and in fa0-fa7 if permitted by the ABI. */ |
| 727 |
#define FUNCTION_ARG_REGNO_P(N) \ |
| 728 |
(IN_RANGE ((N), GP_ARG_FIRST, GP_ARG_LAST) \ |
| 729 |
|| (UNITS_PER_FP_ARG && IN_RANGE ((N), FP_ARG_FIRST, FP_ARG_LAST))) |
| 730 |
|
| 731 |
typedef struct { |
| 732 |
/* Number of integer registers used so far, up to MAX_ARGS_IN_REGISTERS. */ |
| 733 |
unsigned int num_gprs; |
| 734 |
|
| 735 |
/* Number of floating-point registers used so far, likewise. */ |
| 736 |
unsigned int num_fprs; |
| 737 |
|
| 738 |
} CUMULATIVE_ARGS; |
| 739 |
|
| 740 |
/* Initialize a variable CUM of type CUMULATIVE_ARGS |
| 741 |
for a call to a function whose data type is FNTYPE. |
| 742 |
For a library call, FNTYPE is 0. */ |
| 743 |
|
| 744 |
#define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT, N_NAMED_ARGS) \ |
| 745 |
memset (&(CUM), 0, sizeof (CUM)) |
| 746 |
|
| 747 |
#define EPILOGUE_USES(REGNO) loongarch_epilogue_uses (REGNO) |
| 748 |
|
| 749 |
/* Treat LOC as a byte offset from the stack pointer and round it up |
| 750 |
to the next fully-aligned offset. */ |
| 751 |
#define LARCH_STACK_ALIGN(LOC) \ |
| 752 |
(TARGET_ABI_LP64 ? ROUND_UP ((LOC), 16) : ROUND_UP ((LOC), 8)) |
| 753 |
|
| 754 |
#define MCOUNT_NAME "_mcount" |
| 755 |
|
| 756 |
/* Emit rtl for profiling. Output assembler code to FILE |
| 757 |
to call "_mcount" for profiling a function entry. */ |
| 758 |
#define PROFILE_HOOK(LABEL) \ |
| 759 |
{ \ |
| 760 |
rtx fun, ra; \ |
| 761 |
ra = get_hard_reg_initial_val (Pmode, RETURN_ADDR_REGNUM); \ |
| 762 |
fun = gen_rtx_SYMBOL_REF (Pmode, MCOUNT_NAME); \ |
| 763 |
emit_library_call (fun, LCT_NORMAL, VOIDmode, ra, Pmode); \ |
| 764 |
} |
| 765 |
|
| 766 |
/* All the work done in PROFILE_HOOK, but still required. */ |
| 767 |
#define FUNCTION_PROFILER(STREAM, LABELNO) do { } while (0) |
| 768 |
|
| 769 |
#define NO_PROFILE_COUNTERS 1 |
| 770 |
|
| 771 |
/* EXIT_IGNORE_STACK should be nonzero if, when returning from a function, |
| 772 |
the stack pointer does not matter. The value is tested only in |
| 773 |
functions that have frame pointers. |
| 774 |
No definition is equivalent to always zero. */ |
| 775 |
|
| 776 |
#define EXIT_IGNORE_STACK 1 |
| 777 |
|
| 778 |
/* Trampolines are a block of code followed by two pointers. */ |
| 779 |
|
| 780 |
#define TRAMPOLINE_CODE_SIZE 16 |
| 781 |
#define TRAMPOLINE_SIZE \ |
| 782 |
((Pmode == SImode) ? TRAMPOLINE_CODE_SIZE \ |
| 783 |
: (TRAMPOLINE_CODE_SIZE + POINTER_SIZE * 2)) |
| 784 |
#define TRAMPOLINE_ALIGNMENT POINTER_SIZE |
| 785 |
|
| 786 |
/* loongarch_trampoline_init calls this library function to flush |
| 787 |
program and data caches. */ |
| 788 |
|
| 789 |
#ifndef CACHE_FLUSH_FUNC |
| 790 |
#define CACHE_FLUSH_FUNC "_flush_cache" |
| 791 |
#endif |
| 792 |
|
| 793 |
/* Addressing modes, and classification of registers for them. */ |
| 794 |
|
| 795 |
#define REGNO_OK_FOR_INDEX_P(REGNO) \ |
| 796 |
loongarch_regno_mode_ok_for_base_p (REGNO, VOIDmode, 1) |
| 797 |
|
| 798 |
#define REGNO_MODE_OK_FOR_BASE_P(REGNO, MODE) \ |
| 799 |
loongarch_regno_mode_ok_for_base_p (REGNO, MODE, 1) |
| 800 |
|
| 801 |
/* Maximum number of registers that can appear in a valid memory address. */ |
| 802 |
|
| 803 |
#define MAX_REGS_PER_ADDRESS 2 |
| 804 |
|
| 805 |
/* Check for constness inline but use loongarch_legitimate_address_p |
| 806 |
to check whether a constant really is an address. */ |
| 807 |
|
| 808 |
#define CONSTANT_ADDRESS_P(X) (CONSTANT_P (X) && memory_address_p (SImode, X)) |
| 809 |
|
| 810 |
/* This handles the magic '..CURRENT_FUNCTION' symbol, which means |
| 811 |
'the start of the function that this code is output in'. */ |
| 812 |
|
| 813 |
#define ASM_OUTPUT_LABELREF(FILE, NAME) \ |
| 814 |
do \ |
| 815 |
{ \ |
| 816 |
if (strcmp (NAME, "..CURRENT_FUNCTION") == 0) \ |
| 817 |
asm_fprintf ((FILE), "%U%s", \ |
| 818 |
XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0)); \ |
| 819 |
else \ |
| 820 |
asm_fprintf ((FILE), "%U%s", (NAME)); \ |
| 821 |
} \ |
| 822 |
while (0) |
| 823 |
|
| 824 |
#define CASE_VECTOR_MODE Pmode |
| 825 |
|
| 826 |
#define CASE_VECTOR_SHORTEN_MODE(MIN, MAX, BODY) Pmode |
| 827 |
|
| 828 |
/* Define this as 1 if `char' should by default be signed; else as 0. */ |
| 829 |
#ifndef DEFAULT_SIGNED_CHAR |
| 830 |
#define DEFAULT_SIGNED_CHAR 1 |
| 831 |
#endif |
| 832 |
|
| 833 |
/* The SPARC port says: |
| 834 |
The maximum number of bytes that a single instruction |
| 835 |
can move quickly between memory and registers or between |
| 836 |
two memory locations. */ |
| 837 |
#define MOVE_MAX UNITS_PER_WORD |
| 838 |
#define MAX_MOVE_MAX 8 |
| 839 |
|
| 840 |
/* The SPARC port says: |
| 841 |
Nonzero if access to memory by bytes is slow and undesirable. |
| 842 |
For RISC chips, it means that access to memory by bytes is no |
| 843 |
better than access by words when possible, so grab a whole word |
| 844 |
and maybe make use of that. */ |
| 845 |
#define SLOW_BYTE_ACCESS 1 |
| 846 |
|
| 847 |
/* Standard LoongArch integer shifts truncate the shift amount to the |
| 848 |
width of the shifted operand. */ |
| 849 |
#define SHIFT_COUNT_TRUNCATED 1 |
| 850 |
|
| 851 |
/* Specify the machine mode that pointers have. |
| 852 |
After generation of rtl, the compiler makes no further distinction |
| 853 |
between pointers and any other objects of this machine mode. */ |
| 854 |
|
| 855 |
#ifndef Pmode |
| 856 |
#define Pmode (TARGET_64BIT ? DImode : SImode) |
| 857 |
#endif |
| 858 |
|
| 859 |
/* Give call MEMs SImode since it is the "most permissive" mode |
| 860 |
for both 32-bit and 64-bit targets. */ |
| 861 |
|
| 862 |
#define FUNCTION_MODE SImode |
| 863 |
|
| 864 |
/* We allocate $fcc registers by hand and can't cope with moves of |
| 865 |
CCmode registers to and from pseudos (or memory). */ |
| 866 |
#define AVOID_CCMODE_COPIES |
| 867 |
|
| 868 |
/* A C expression for the cost of a branch instruction. A value of |
| 869 |
1 is the default; other values are interpreted relative to that. */ |
| 870 |
|
| 871 |
#define BRANCH_COST(speed_p, predictable_p) la_branch_cost |
| 872 |
#define LOGICAL_OP_NON_SHORT_CIRCUIT 0 |
| 873 |
|
| 874 |
/* Return the asm template for a conditional branch instruction. |
| 875 |
OPCODE is the opcode's mnemonic and OPERANDS is the asm template for |
| 876 |
its operands. */ |
| 877 |
#define LARCH_BRANCH(OPCODE, OPERANDS) OPCODE "\t" OPERANDS |
| 878 |
|
| 879 |
/* Control the assembler format that we output. */ |
| 880 |
|
| 881 |
/* Output to assembler file text saying following lines |
| 882 |
may contain character constants, extra white space, comments, etc. */ |
| 883 |
|
| 884 |
#ifndef ASM_APP_ON |
| 885 |
#define ASM_APP_ON " #APP\n" |
| 886 |
#endif |
| 887 |
|
| 888 |
/* Output to assembler file text saying following lines |
| 889 |
no longer contain unusual constructs. */ |
| 890 |
|
| 891 |
#ifndef ASM_APP_OFF |
| 892 |
#define ASM_APP_OFF " #NO_APP\n" |
| 893 |
#endif |
| 894 |
|
| 895 |
#define REGISTER_NAMES \ |
| 896 |
{ "$r0", "$r1", "$r2", "$r3", "$r4", "$r5", "$r6", "$r7", \ |
| 897 |
"$r8", "$r9", "$r10", "$r11", "$r12", "$r13", "$r14", "$r15", \ |
| 898 |
"$r16", "$r17", "$r18", "$r19", "$r20", "$r21", "$r22", "$r23", \ |
| 899 |
"$r24", "$r25", "$r26", "$r27", "$r28", "$r29", "$r30", "$r31", \ |
| 900 |
"$f0", "$f1", "$f2", "$f3", "$f4", "$f5", "$f6", "$f7", \ |
| 901 |
"$f8", "$f9", "$f10", "$f11", "$f12", "$f13", "$f14", "$f15", \ |
| 902 |
"$f16", "$f17", "$f18", "$f19", "$f20", "$f21", "$f22", "$f23", \ |
| 903 |
"$f24", "$f25", "$f26", "$f27", "$f28", "$f29", "$f30", "$f31", \ |
| 904 |
"$fcc0","$fcc1","$fcc2","$fcc3","$fcc4","$fcc5","$fcc6","$fcc7", \ |
| 905 |
"$arg", "$frame"} |
| 906 |
|
| 907 |
/* This macro defines additional names for hard registers. */ |
| 908 |
|
| 909 |
#define ADDITIONAL_REGISTER_NAMES \ |
| 910 |
{ \ |
| 911 |
{ "zero", 0 + GP_REG_FIRST }, \ |
| 912 |
{ "ra", 1 + GP_REG_FIRST }, \ |
| 913 |
{ "tp", 2 + GP_REG_FIRST }, \ |
| 914 |
{ "sp", 3 + GP_REG_FIRST }, \ |
| 915 |
{ "a0", 4 + GP_REG_FIRST }, \ |
| 916 |
{ "a1", 5 + GP_REG_FIRST }, \ |
| 917 |
{ "a2", 6 + GP_REG_FIRST }, \ |
| 918 |
{ "a3", 7 + GP_REG_FIRST }, \ |
| 919 |
{ "a4", 8 + GP_REG_FIRST }, \ |
| 920 |
{ "a5", 9 + GP_REG_FIRST }, \ |
| 921 |
{ "a6", 10 + GP_REG_FIRST }, \ |
| 922 |
{ "a7", 11 + GP_REG_FIRST }, \ |
| 923 |
{ "t0", 12 + GP_REG_FIRST }, \ |
| 924 |
{ "t1", 13 + GP_REG_FIRST }, \ |
| 925 |
{ "t2", 14 + GP_REG_FIRST }, \ |
| 926 |
{ "t3", 15 + GP_REG_FIRST }, \ |
| 927 |
{ "t4", 16 + GP_REG_FIRST }, \ |
| 928 |
{ "t5", 17 + GP_REG_FIRST }, \ |
| 929 |
{ "t6", 18 + GP_REG_FIRST }, \ |
| 930 |
{ "t7", 19 + GP_REG_FIRST }, \ |
| 931 |
{ "t8", 20 + GP_REG_FIRST }, \ |
| 932 |
{ "x", 21 + GP_REG_FIRST }, \ |
| 933 |
{ "fp", 22 + GP_REG_FIRST }, \ |
| 934 |
{ "s9", 22 + GP_REG_FIRST }, \ |
| 935 |
{ "s0", 23 + GP_REG_FIRST }, \ |
| 936 |
{ "s1", 24 + GP_REG_FIRST }, \ |
| 937 |
{ "s2", 25 + GP_REG_FIRST }, \ |
| 938 |
{ "s3", 26 + GP_REG_FIRST }, \ |
| 939 |
{ "s4", 27 + GP_REG_FIRST }, \ |
| 940 |
{ "s5", 28 + GP_REG_FIRST }, \ |
| 941 |
{ "s6", 29 + GP_REG_FIRST }, \ |
| 942 |
{ "s7", 30 + GP_REG_FIRST }, \ |
| 943 |
{ "s8", 31 + GP_REG_FIRST }, \ |
| 944 |
{ "fa0", 0 + FP_REG_FIRST }, \ |
| 945 |
{ "fa1", 1 + FP_REG_FIRST }, \ |
| 946 |
{ "fa2", 2 + FP_REG_FIRST }, \ |
| 947 |
{ "fa3", 3 + FP_REG_FIRST }, \ |
| 948 |
{ "fa4", 4 + FP_REG_FIRST }, \ |
| 949 |
{ "fa5", 5 + FP_REG_FIRST }, \ |
| 950 |
{ "fa6", 6 + FP_REG_FIRST }, \ |
| 951 |
{ "fa7", 7 + FP_REG_FIRST }, \ |
| 952 |
{ "ft0", 8 + FP_REG_FIRST }, \ |
| 953 |
{ "ft1", 9 + FP_REG_FIRST }, \ |
| 954 |
{ "ft2", 10 + FP_REG_FIRST }, \ |
| 955 |
{ "ft3", 11 + FP_REG_FIRST }, \ |
| 956 |
{ "ft4", 12 + FP_REG_FIRST }, \ |
| 957 |
{ "ft5", 13 + FP_REG_FIRST }, \ |
| 958 |
{ "ft6", 14 + FP_REG_FIRST }, \ |
| 959 |
{ "ft7", 15 + FP_REG_FIRST }, \ |
| 960 |
{ "ft8", 16 + FP_REG_FIRST }, \ |
| 961 |
{ "ft9", 17 + FP_REG_FIRST }, \ |
| 962 |
{ "ft10", 18 + FP_REG_FIRST }, \ |
| 963 |
{ "ft11", 19 + FP_REG_FIRST }, \ |
| 964 |
{ "ft12", 20 + FP_REG_FIRST }, \ |
| 965 |
{ "ft13", 21 + FP_REG_FIRST }, \ |
| 966 |
{ "ft14", 22 + FP_REG_FIRST }, \ |
| 967 |
{ "ft15", 23 + FP_REG_FIRST }, \ |
| 968 |
{ "fs0", 24 + FP_REG_FIRST }, \ |
| 969 |
{ "fs1", 25 + FP_REG_FIRST }, \ |
| 970 |
{ "fs2", 26 + FP_REG_FIRST }, \ |
| 971 |
{ "fs3", 27 + FP_REG_FIRST }, \ |
| 972 |
{ "fs4", 28 + FP_REG_FIRST }, \ |
| 973 |
{ "fs5", 29 + FP_REG_FIRST }, \ |
| 974 |
{ "fs6", 30 + FP_REG_FIRST }, \ |
| 975 |
{ "fs7", 31 + FP_REG_FIRST }, \ |
| 976 |
{ "v0", 4 + GP_REG_FIRST }, \ |
| 977 |
{ "v1", 5 + GP_REG_FIRST }, \ |
| 978 |
{ "vr0", 0 + FP_REG_FIRST }, \ |
| 979 |
{ "vr1", 1 + FP_REG_FIRST }, \ |
| 980 |
{ "vr2", 2 + FP_REG_FIRST }, \ |
| 981 |
{ "vr3", 3 + FP_REG_FIRST }, \ |
| 982 |
{ "vr4", 4 + FP_REG_FIRST }, \ |
| 983 |
{ "vr5", 5 + FP_REG_FIRST }, \ |
| 984 |
{ "vr6", 6 + FP_REG_FIRST }, \ |
| 985 |
{ "vr7", 7 + FP_REG_FIRST }, \ |
| 986 |
{ "vr8", 8 + FP_REG_FIRST }, \ |
| 987 |
{ "vr9", 9 + FP_REG_FIRST }, \ |
| 988 |
{ "vr10", 10 + FP_REG_FIRST }, \ |
| 989 |
{ "vr11", 11 + FP_REG_FIRST }, \ |
| 990 |
{ "vr12", 12 + FP_REG_FIRST }, \ |
| 991 |
{ "vr13", 13 + FP_REG_FIRST }, \ |
| 992 |
{ "vr14", 14 + FP_REG_FIRST }, \ |
| 993 |
{ "vr15", 15 + FP_REG_FIRST }, \ |
| 994 |
{ "vr16", 16 + FP_REG_FIRST }, \ |
| 995 |
{ "vr17", 17 + FP_REG_FIRST }, \ |
| 996 |
{ "vr18", 18 + FP_REG_FIRST }, \ |
| 997 |
{ "vr19", 19 + FP_REG_FIRST }, \ |
| 998 |
{ "vr20", 20 + FP_REG_FIRST }, \ |
| 999 |
{ "vr21", 21 + FP_REG_FIRST }, \ |
| 1000 |
{ "vr22", 22 + FP_REG_FIRST }, \ |
| 1001 |
{ "vr23", 23 + FP_REG_FIRST }, \ |
| 1002 |
{ "vr24", 24 + FP_REG_FIRST }, \ |
| 1003 |
{ "vr25", 25 + FP_REG_FIRST }, \ |
| 1004 |
{ "vr26", 26 + FP_REG_FIRST }, \ |
| 1005 |
{ "vr27", 27 + FP_REG_FIRST }, \ |
| 1006 |
{ "vr28", 28 + FP_REG_FIRST }, \ |
| 1007 |
{ "vr29", 29 + FP_REG_FIRST }, \ |
| 1008 |
{ "vr30", 30 + FP_REG_FIRST }, \ |
| 1009 |
{ "vr31", 31 + FP_REG_FIRST }, \ |
| 1010 |
{ "xr0", 0 + FP_REG_FIRST }, \ |
| 1011 |
{ "xr1", 1 + FP_REG_FIRST }, \ |
| 1012 |
{ "xr2", 2 + FP_REG_FIRST }, \ |
| 1013 |
{ "xr3", 3 + FP_REG_FIRST }, \ |
| 1014 |
{ "xr4", 4 + FP_REG_FIRST }, \ |
| 1015 |
{ "xr5", 5 + FP_REG_FIRST }, \ |
| 1016 |
{ "xr6", 6 + FP_REG_FIRST }, \ |
| 1017 |
{ "xr7", 7 + FP_REG_FIRST }, \ |
| 1018 |
{ "xr8", 8 + FP_REG_FIRST }, \ |
| 1019 |
{ "xr9", 9 + FP_REG_FIRST }, \ |
| 1020 |
{ "xr10", 10 + FP_REG_FIRST }, \ |
| 1021 |
{ "xr11", 11 + FP_REG_FIRST }, \ |
| 1022 |
{ "xr12", 12 + FP_REG_FIRST }, \ |
| 1023 |
{ "xr13", 13 + FP_REG_FIRST }, \ |
| 1024 |
{ "xr14", 14 + FP_REG_FIRST }, \ |
| 1025 |
{ "xr15", 15 + FP_REG_FIRST }, \ |
| 1026 |
{ "xr16", 16 + FP_REG_FIRST }, \ |
| 1027 |
{ "xr17", 17 + FP_REG_FIRST }, \ |
| 1028 |
{ "xr18", 18 + FP_REG_FIRST }, \ |
| 1029 |
{ "xr19", 19 + FP_REG_FIRST }, \ |
| 1030 |
{ "xr20", 20 + FP_REG_FIRST }, \ |
| 1031 |
{ "xr21", 21 + FP_REG_FIRST }, \ |
| 1032 |
{ "xr22", 22 + FP_REG_FIRST }, \ |
| 1033 |
{ "xr23", 23 + FP_REG_FIRST }, \ |
| 1034 |
{ "xr24", 24 + FP_REG_FIRST }, \ |
| 1035 |
{ "xr25", 25 + FP_REG_FIRST }, \ |
| 1036 |
{ "xr26", 26 + FP_REG_FIRST }, \ |
| 1037 |
{ "xr27", 27 + FP_REG_FIRST }, \ |
| 1038 |
{ "xr28", 28 + FP_REG_FIRST }, \ |
| 1039 |
{ "xr29", 29 + FP_REG_FIRST }, \ |
| 1040 |
{ "xr30", 30 + FP_REG_FIRST }, \ |
| 1041 |
{ "xr31", 31 + FP_REG_FIRST } \ |
| 1042 |
} |
| 1043 |
|
| 1044 |
/* Globalizing directive for a label. */ |
| 1045 |
#define GLOBAL_ASM_OP "\t.globl\t" |
| 1046 |
|
| 1047 |
/* This says how to output an external. It would be possible not to |
| 1048 |
output anything and let undefined symbol become external. However |
| 1049 |
the assembler uses length information on externals to allocate in |
| 1050 |
data/sdata bss/sbss, thereby saving exec time. */ |
| 1051 |
|
| 1052 |
#undef ASM_OUTPUT_EXTERNAL |
| 1053 |
#define ASM_OUTPUT_EXTERNAL(STREAM, DECL, NAME) \ |
| 1054 |
loongarch_output_external (STREAM, DECL, NAME) |
| 1055 |
|
| 1056 |
/* This is how to store into the string LABEL |
| 1057 |
the symbol_ref name of an internal numbered label where |
| 1058 |
PREFIX is the class of label and NUM is the number within the class. |
| 1059 |
This is suitable for output with `assemble_name'. */ |
| 1060 |
|
| 1061 |
#undef ASM_GENERATE_INTERNAL_LABEL |
| 1062 |
#define ASM_GENERATE_INTERNAL_LABEL(LABEL, PREFIX, NUM) \ |
| 1063 |
sprintf ((LABEL), "*%s%s%ld", (LOCAL_LABEL_PREFIX), (PREFIX), (long) (NUM)) |
| 1064 |
|
| 1065 |
/* Print debug labels as "foo = ." rather than "foo:" because they should |
| 1066 |
represent a byte pointer rather than an ISA-encoded address. This is |
| 1067 |
particularly important for code like: |
| 1068 |
|
| 1069 |
$LFBxxx = . |
| 1070 |
.cfi_startproc |
| 1071 |
... |
| 1072 |
.section .gcc_except_table,... |
| 1073 |
... |
| 1074 |
.uleb128 foo-$LFBxxx |
| 1075 |
|
| 1076 |
The .uleb128 requies $LFBxxx to match the FDE start address, which is |
| 1077 |
likewise a byte pointer rather than an ISA-encoded address. |
| 1078 |
|
| 1079 |
At the time of writing, this hook is not used for the function end |
| 1080 |
label: |
| 1081 |
|
| 1082 |
$LFExxx: |
| 1083 |
.end foo |
| 1084 |
|
| 1085 |
*/ |
| 1086 |
|
| 1087 |
#define ASM_OUTPUT_DEBUG_LABEL(FILE, PREFIX, NUM) \ |
| 1088 |
fprintf (FILE, "%s%s%d = .\n", LOCAL_LABEL_PREFIX, PREFIX, NUM) |
| 1089 |
|
| 1090 |
/* This is how to output an element of a case-vector that is absolute. */ |
| 1091 |
|
| 1092 |
#define ASM_OUTPUT_ADDR_VEC_ELT(STREAM, VALUE) \ |
| 1093 |
fprintf (STREAM, "\t%s\t%sL%d\n", ptr_mode == DImode ? ".dword" : ".word", \ |
| 1094 |
LOCAL_LABEL_PREFIX, VALUE) |
| 1095 |
|
| 1096 |
/* This is how to output an element of a case-vector. */ |
| 1097 |
|
| 1098 |
#define ASM_OUTPUT_ADDR_DIFF_ELT(STREAM, BODY, VALUE, REL) \ |
| 1099 |
do \ |
| 1100 |
{ \ |
| 1101 |
fprintf (STREAM, "\t%s\t%sL%d-%sL%d\n", \ |
| 1102 |
ptr_mode == DImode ? ".dword" : ".word", LOCAL_LABEL_PREFIX, \ |
| 1103 |
VALUE, LOCAL_LABEL_PREFIX, REL); \ |
| 1104 |
} \ |
| 1105 |
while (0) |
| 1106 |
|
| 1107 |
#define JUMP_TABLES_IN_TEXT_SECTION 0 |
| 1108 |
|
| 1109 |
/* This is how to output an assembler line |
| 1110 |
that says to advance the location counter |
| 1111 |
to a multiple of 2**LOG bytes. */ |
| 1112 |
|
| 1113 |
#define ASM_OUTPUT_ALIGN(STREAM, LOG) fprintf (STREAM, "\t.align\t%d\n", (LOG)) |
| 1114 |
|
| 1115 |
/* This is how to output an assembler line to advance the location |
| 1116 |
counter by SIZE bytes. */ |
| 1117 |
|
| 1118 |
#undef ASM_OUTPUT_SKIP |
| 1119 |
#define ASM_OUTPUT_SKIP(STREAM, SIZE) \ |
| 1120 |
fprintf (STREAM, "\t.space\t" HOST_WIDE_INT_PRINT_UNSIGNED "\n", (SIZE)) |
| 1121 |
|
| 1122 |
/* This is how to output a string. */ |
| 1123 |
#undef ASM_OUTPUT_ASCII |
| 1124 |
#define ASM_OUTPUT_ASCII loongarch_output_ascii |
| 1125 |
|
| 1126 |
/* Define the strings to put out for each section in the object file. */ |
| 1127 |
#define TEXT_SECTION_ASM_OP "\t.text" /* instructions */ |
| 1128 |
#define DATA_SECTION_ASM_OP "\t.data" /* large data */ |
| 1129 |
|
| 1130 |
#undef READONLY_DATA_SECTION_ASM_OP |
| 1131 |
#define READONLY_DATA_SECTION_ASM_OP "\t.section\t.rodata" /* read-only data */ |
| 1132 |
|
| 1133 |
#define ASM_OUTPUT_REG_PUSH(STREAM, REGNO) \ |
| 1134 |
do \ |
| 1135 |
{ \ |
| 1136 |
fprintf (STREAM, "\t%s\t%s,%s,-8\n\t%s\t%s,%s,0\n", \ |
| 1137 |
TARGET_64BIT ? "addi.d" : "addi.w", \ |
| 1138 |
reg_names[STACK_POINTER_REGNUM], \ |
| 1139 |
reg_names[STACK_POINTER_REGNUM], \ |
| 1140 |
TARGET_64BIT ? "st.d" : "st.w", reg_names[REGNO], \ |
| 1141 |
reg_names[STACK_POINTER_REGNUM]); \ |
| 1142 |
} \ |
| 1143 |
while (0) |
| 1144 |
|
| 1145 |
#define ASM_OUTPUT_REG_POP(STREAM, REGNO) \ |
| 1146 |
do \ |
| 1147 |
{ \ |
| 1148 |
fprintf (STREAM, "\t%s\t%s,%s,0\n\t%s\t%s,%s,8\n", \ |
| 1149 |
TARGET_64BIT ? "ld.d" : "ld.w", reg_names[REGNO], \ |
| 1150 |
reg_names[STACK_POINTER_REGNUM], \ |
| 1151 |
TARGET_64BIT ? "addi.d" : "addi.w", \ |
| 1152 |
reg_names[STACK_POINTER_REGNUM], \ |
| 1153 |
reg_names[STACK_POINTER_REGNUM]); \ |
| 1154 |
} \ |
| 1155 |
while (0) |
| 1156 |
|
| 1157 |
/* How to start an assembler comment. |
| 1158 |
The leading space is important (the loongarch native assembler requires it). |
| 1159 |
*/ |
| 1160 |
#ifndef ASM_COMMENT_START |
| 1161 |
#define ASM_COMMENT_START " #" |
| 1162 |
#endif |
| 1163 |
|
| 1164 |
#undef SIZE_TYPE |
| 1165 |
#define SIZE_TYPE (POINTER_SIZE == 64 ? "long unsigned int" : "unsigned int") |
| 1166 |
|
| 1167 |
#undef PTRDIFF_TYPE |
| 1168 |
#define PTRDIFF_TYPE (POINTER_SIZE == 64 ? "long int" : "int") |
| 1169 |
|
| 1170 |
/* The maximum number of bytes that can be copied by one iteration of |
| 1171 |
a cpymemsi loop; see loongarch_block_move_loop. */ |
| 1172 |
#define LARCH_MAX_MOVE_OPS_PER_LOOP_ITER 4 |
| 1173 |
|
| 1174 |
/* The maximum number of bytes that can be copied by a straight-line |
| 1175 |
implementation of cpymemsi; see loongarch_block_move_straight. We want |
| 1176 |
to make sure that any loop-based implementation will iterate at |
| 1177 |
least twice. */ |
| 1178 |
#define LARCH_MAX_MOVE_OPS_STRAIGHT (LARCH_MAX_MOVE_OPS_PER_LOOP_ITER * 2) |
| 1179 |
|
| 1180 |
#define LARCH_MAX_MOVE_PER_INSN \ |
| 1181 |
(ISA_HAS_LASX ? 32 : (ISA_HAS_LSX ? 16 : UNITS_PER_WORD)) |
| 1182 |
|
| 1183 |
/* The base cost of a memcpy call, for MOVE_RATIO and friends. These |
| 1184 |
values were determined experimentally by benchmarking with CSiBE. |
| 1185 |
*/ |
| 1186 |
#define LARCH_CALL_RATIO 6 |
| 1187 |
|
| 1188 |
/* Any loop-based implementation of cpymemsi will have at least |
| 1189 |
LARCH_MAX_MOVE_OPS_PER_LOOP_ITER memory-to-memory |
| 1190 |
moves, so allow individual copies of fewer elements. |
| 1191 |
|
| 1192 |
When cpymemsi is not available, use a value approximating |
| 1193 |
the length of a memcpy call sequence, so that move_by_pieces |
| 1194 |
will generate inline code if it is shorter than a function call. |
| 1195 |
Since move_by_pieces_ninsns counts memory-to-memory moves, but |
| 1196 |
we'll have to generate a load/store pair for each, halve the |
| 1197 |
value of LARCH_CALL_RATIO to take that into account. */ |
| 1198 |
|
| 1199 |
#define MOVE_RATIO(speed) \ |
| 1200 |
(HAVE_cpymemsi ? LARCH_MAX_MOVE_OPS_PER_LOOP_ITER : CLEAR_RATIO (speed) / 2) |
| 1201 |
|
| 1202 |
/* For CLEAR_RATIO, when optimizing for size, give a better estimate |
| 1203 |
of the length of a memset call, but use the default otherwise. */ |
| 1204 |
|
| 1205 |
#define CLEAR_RATIO(speed) ((speed) ? 15 : LARCH_CALL_RATIO) |
| 1206 |
|
| 1207 |
/* This is similar to CLEAR_RATIO, but for a non-zero constant, so when |
| 1208 |
optimizing for size adjust the ratio to account for the overhead of |
| 1209 |
loading the constant and replicating it across the word. */ |
| 1210 |
|
| 1211 |
#define SET_RATIO(speed) ((speed) ? 15 : LARCH_CALL_RATIO - 2) |
| 1212 |
|
| 1213 |
#ifndef USED_FOR_TARGET |
| 1214 |
extern const enum reg_class loongarch_regno_to_class[]; |
| 1215 |
extern int loongarch_dwarf_regno[]; |
| 1216 |
|
| 1217 |
/* Information about a function's frame layout. */ |
| 1218 |
struct GTY (()) loongarch_frame_info |
| 1219 |
{ |
| 1220 |
/* The size of the frame in bytes. */ |
| 1221 |
HOST_WIDE_INT total_size; |
| 1222 |
|
| 1223 |
/* Bit X is set if the function saves or restores GPR X. */ |
| 1224 |
unsigned int mask; |
| 1225 |
|
| 1226 |
/* Likewise FPR X. */ |
| 1227 |
unsigned int fmask; |
| 1228 |
|
| 1229 |
/* How much the GPR save/restore routines adjust sp (or 0 if unused). */ |
| 1230 |
unsigned save_libcall_adjustment; |
| 1231 |
|
| 1232 |
/* Offsets of fixed-point and floating-point save areas from frame |
| 1233 |
bottom. */ |
| 1234 |
HOST_WIDE_INT gp_sp_offset; |
| 1235 |
HOST_WIDE_INT fp_sp_offset; |
| 1236 |
|
| 1237 |
/* Offset of virtual frame pointer from stack pointer/frame bottom. */ |
| 1238 |
HOST_WIDE_INT frame_pointer_offset; |
| 1239 |
|
| 1240 |
/* Offset of hard frame pointer from stack pointer/frame bottom. */ |
| 1241 |
HOST_WIDE_INT hard_frame_pointer_offset; |
| 1242 |
|
| 1243 |
/* The offset of arg_pointer_rtx from the bottom of the frame. */ |
| 1244 |
HOST_WIDE_INT arg_pointer_offset; |
| 1245 |
}; |
| 1246 |
|
| 1247 |
struct GTY (()) machine_function |
| 1248 |
{ |
| 1249 |
/* The next floating-point condition-code register to allocate |
| 1250 |
for 8CC targets, relative to FCC_REG_FIRST. */ |
| 1251 |
unsigned int next_fcc; |
| 1252 |
|
| 1253 |
/* The number of extra stack bytes taken up by register varargs. |
| 1254 |
This area is allocated by the callee at the very top of the frame. */ |
| 1255 |
int varargs_size; |
| 1256 |
|
| 1257 |
/* The current frame information, calculated by loongarch_compute_frame_info. |
| 1258 |
*/ |
| 1259 |
struct loongarch_frame_info frame; |
| 1260 |
|
| 1261 |
bool reg_is_wrapped_separately[FIRST_PSEUDO_REGISTER]; |
| 1262 |
}; |
| 1263 |
#endif |
| 1264 |
|
| 1265 |
#ifdef HAVE_AS_EH_FRAME_PCREL_ENCODING_SUPPORT |
| 1266 |
#define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \ |
| 1267 |
(((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_sdata4) |
| 1268 |
#else |
| 1269 |
#define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \ |
| 1270 |
(((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_absptr) |
| 1271 |
#endif |
| 1272 |
|
| 1273 |
/* Do emit .note.GNU-stack by default. */ |
| 1274 |
#ifndef NEED_INDICATE_EXEC_STACK |
| 1275 |
#define NEED_INDICATE_EXEC_STACK 1 |
| 1276 |
#endif |
| 1277 |
|
| 1278 |
/* The `Q' extension is not yet supported. */ |
| 1279 |
/* TODO: according to march. */ |
| 1280 |
#define UNITS_PER_FP_REG (TARGET_DOUBLE_FLOAT ? 8 : 4) |
| 1281 |
|
| 1282 |
/* The largest type that can be passed in floating-point registers. */ |
| 1283 |
/* TODO: according to mabi. */ |
| 1284 |
#define UNITS_PER_FP_ARG \ |
| 1285 |
(TARGET_HARD_FLOAT_ABI ? (TARGET_DOUBLE_FLOAT_ABI ? 8 : 4) : 0) |
| 1286 |
|
| 1287 |
#define FUNCTION_VALUE_REGNO_P(N) ((N) == GP_RETURN || (N) == FP_RETURN) |
| 1288 |
|
| 1289 |
/* LoongArch maintains ICache/DCache coherency by hardware, |
| 1290 |
we just need "ibar" to avoid instruction hazard here. */ |
| 1291 |
#undef CLEAR_INSN_CACHE |
| 1292 |
#define CLEAR_INSN_CACHE(beg, end) __builtin_loongarch_ibar (0) |
| 1293 |
|
| 1294 |
#define TARGET_EXPLICIT_RELOCS \ |
| 1295 |
(la_opt_explicit_relocs == EXPLICIT_RELOCS_ALWAYS) |