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