1 /* Definitions of target machine for GNU compiler for TILEPro. 2 Copyright (C) 2011-2021 Free Software Foundation, Inc. 3 Contributed by Walter Lee (walt@tilera.com) 4 5 This file is part of GCC. 6 7 GCC is free software; you can redistribute it and/or modify it 8 under the terms of the GNU General Public License as published 9 by the Free Software Foundation; either version 3, or (at your 10 option) any later version. 11 12 GCC is distributed in the hope that it will be useful, but WITHOUT 13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 15 License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with GCC; see the file COPYING3. If not see 19 <http://www.gnu.org/licenses/>. */ 20 21 /* This is used by tilepro_cpu_cpp_builtins to indicate the byte order 22 we're compiling for. */ 23 #define TILEPRO_CPU_CPP_ENDIAN_BUILTINS() \ 24 do \ 25 { \ 26 if (BYTES_BIG_ENDIAN) \ 27 builtin_define ("__BIG_ENDIAN__"); \ 28 else \ 29 builtin_define ("__LITTLE_ENDIAN__"); \ 30 } \ 31 while (0) 32 33 /* Target CPU builtins. */ 34 #define TARGET_CPU_CPP_BUILTINS() \ 35 tilepro_cpu_cpp_builtins (pfile) 36 37 #undef PTRDIFF_TYPE 38 #define PTRDIFF_TYPE "int" 39 40 #undef SIZE_TYPE 41 #define SIZE_TYPE "unsigned int" 42 43 44 /* Target machine storage layout */ 45 46 #define BITS_BIG_ENDIAN 0 47 #define BYTES_BIG_ENDIAN 0 48 #define WORDS_BIG_ENDIAN 0 49 50 #define UNITS_PER_WORD 4 51 #define PARM_BOUNDARY 32 52 #define STACK_BOUNDARY 64 53 #define FUNCTION_BOUNDARY 64 54 #define BIGGEST_ALIGNMENT 64 55 #define STRICT_ALIGNMENT 1 56 57 #define PCC_BITFIELD_TYPE_MATTERS 1 58 #define FASTEST_ALIGNMENT 32 59 #define BIGGEST_FIELD_ALIGNMENT 64 60 61 /* Make arrays of chars word-aligned for the same reasons. */ 62 #define DATA_ALIGNMENT(TYPE, ALIGN) \ 63 (TREE_CODE (TYPE) == ARRAY_TYPE \ 64 && TYPE_MODE (TREE_TYPE (TYPE)) == QImode \ 65 && (ALIGN) < FASTEST_ALIGNMENT ? FASTEST_ALIGNMENT : (ALIGN)) 66 67 /* Make local arrays of chars word-aligned for the same reasons. */ 68 #define LOCAL_ALIGNMENT(TYPE, ALIGN) DATA_ALIGNMENT (TYPE, ALIGN) 69 70 71 /* Standard register usage. */ 72 73 #define FIRST_PSEUDO_REGISTER (64 + 3) 74 75 #define FIXED_REGISTERS \ 76 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ 77 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ 78 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ 79 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, \ 80 1, 1, 1} 81 82 #define CALL_REALLY_USED_REGISTERS \ 83 {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ 84 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, \ 85 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ 86 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \ 87 1, 1, 1} 88 89 #define REG_ALLOC_ORDER { \ 90 10, 11, 12, 13, 14, /* call used */ \ 91 15, 16, 17, 18, 19, \ 92 20, 21, 22, 23, 24, \ 93 25, 26, 27, 28, 29, \ 94 \ 95 9, 8, 7, 6, 5, /* argument */ \ 96 4, 3, 2, 1, 0, \ 97 \ 98 55, /* return address */ \ 99 \ 100 30, 31, 32, 33, 34, /* call saved registers */ \ 101 35, 36, 37, 38, 39, \ 102 40, 41, 42, 43, 44, \ 103 45, 46, 47, 48, 49, \ 104 50, 51, \ 105 \ 106 52, /* hard frame pointer */ \ 107 53, 54, /* tp, sp */ \ 108 \ 109 56, 57, 58, 59, 60, /* special purpose */ \ 110 61, 62, 63, 64, 65, /* or fake registers */ \ 111 66 \ 112 } 113 114 /* Register that holds an address into the text segment that can be 115 used by pic code. */ 116 #define TILEPRO_PIC_TEXT_LABEL_REGNUM (flag_pic ? 50 : INVALID_REGNUM) 117 #define PIC_OFFSET_TABLE_REGNUM (flag_pic ? 51 : INVALID_REGNUM) 118 #define HARD_FRAME_POINTER_REGNUM 52 119 #define THREAD_POINTER_REGNUM 53 120 #define STACK_POINTER_REGNUM 54 121 #define TILEPRO_LINK_REGNUM 55 122 #define FRAME_POINTER_REGNUM 64 123 #define ARG_POINTER_REGNUM 65 124 /* Pseudo register used to enforce order between instructions that 125 touch the networks. */ 126 #define TILEPRO_NETORDER_REGNUM 66 127 #define STATIC_CHAIN_REGNUM 10 128 129 130 enum reg_class 131 { 132 NO_REGS, 133 R0_REGS, 134 R1_REGS, 135 R2_REGS, 136 R3_REGS, 137 R4_REGS, 138 R5_REGS, 139 R6_REGS, 140 R7_REGS, 141 R8_REGS, 142 R9_REGS, 143 R10_REGS, 144 ALL_REGS, 145 LIM_REG_CLASSES 146 }; 147 148 #define N_REG_CLASSES (int) LIM_REG_CLASSES 149 150 /* Since GENERAL_REGS is the same class as ALL_REGS, don't give it a 151 different class number; just make it an alias. */ 152 #define GENERAL_REGS ALL_REGS 153 154 #define REG_CLASS_NAMES \ 155 { \ 156 "NO_REGS", \ 157 "R0_REGS", \ 158 "R1_REGS", \ 159 "R2_REGS", \ 160 "R3_REGS", \ 161 "R4_REGS", \ 162 "R5_REGS", \ 163 "R6_REGS", \ 164 "R7_REGS", \ 165 "R8_REGS", \ 166 "R9_REGS", \ 167 "R10_REGS", \ 168 "ALL_REGS" \ 169 } 170 171 #define REG_CLASS_CONTENTS \ 172 { \ 173 { 0 }, \ 174 { 1 << 0 }, \ 175 { 1 << 1 }, \ 176 { 1 << 2 }, \ 177 { 1 << 3 }, \ 178 { 1 << 4 }, \ 179 { 1 << 5 }, \ 180 { 1 << 6 }, \ 181 { 1 << 7 }, \ 182 { 1 << 8 }, \ 183 { 1 << 9 }, \ 184 { 1 << 10 }, \ 185 { 0xffffffff, 0xffffffff } \ 186 } 187 188 #define REGNO_REG_CLASS(REGNO) \ 189 ((unsigned)(REGNO) <= 10 ? \ 190 (enum reg_class)(R0_REGS + (REGNO)) : ALL_REGS) 191 192 #define INDEX_REG_CLASS NO_REGS 193 #define BASE_REG_CLASS ALL_REGS 194 195 #define PREFERRED_RELOAD_CLASS(X,CLASS) (CLASS) 196 197 #define CLASS_MAX_NREGS(CLASS, MODE) \ 198 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD) 199 200 201 /* Stack layout; function entry, exit and calling. */ 202 203 #define STACK_GROWS_DOWNWARD 1 204 #define FRAME_GROWS_DOWNWARD 1 205 206 #define DYNAMIC_CHAIN_ADDRESS(FRAME) \ 207 plus_constant (Pmode, (FRAME), UNITS_PER_WORD) 208 209 #define FIRST_PARM_OFFSET(FNDECL) 0 210 211 #define ACCUMULATE_OUTGOING_ARGS 1 212 213 #define OUTGOING_REG_PARM_STACK_SPACE(FNTYPE) 1 214 215 #define INCOMING_FRAME_SP_OFFSET 0 216 217 #define STACK_POINTER_OFFSET (2 * UNITS_PER_WORD) 218 219 #define ARG_POINTER_CFA_OFFSET(FNDECL) (-STACK_POINTER_OFFSET) 220 221 #define DEFAULT_PCC_STRUCT_RETURN 0 222 223 /* The first 10 registers may hold return value. */ 224 #define TILEPRO_NUM_RETURN_REGS 10 225 226 /* The first 10 registers hold function arguments. */ 227 #define TILEPRO_NUM_ARG_REGS 10 228 229 #define FUNCTION_ARG_REGNO_P(N) ((N) < TILEPRO_NUM_ARG_REGS) 230 231 /* The type used to store the number of words of arguments scanned so 232 far during argument scanning. This includes any space that is 233 skipped. */ 234 #define CUMULATIVE_ARGS int 235 236 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT, N_NAMED_ARGS) \ 237 ((CUM) = 0) 238 239 240 #define ELIMINABLE_REGS \ 241 {{ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \ 242 {ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}, \ 243 {FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \ 244 {FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}} 245 246 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \ 247 ((OFFSET) = tilepro_initial_elimination_offset((FROM),(TO))) 248 249 #define PROFILE_BEFORE_PROLOGUE 1 250 251 #define FUNCTION_PROFILER(FILE, LABELNO) \ 252 tilepro_function_profiler (FILE, LABELNO) 253 254 #define TRAMPOLINE_SIZE 48 255 #define TRAMPOLINE_ALIGNMENT 64 256 #define TRAMPOLINE_SECTION text_section 257 258 259 /* Call frame debugging information. */ 260 261 #define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (Pmode, TILEPRO_LINK_REGNUM) 262 263 #define RETURN_ADDR_RTX tilepro_return_addr 264 265 #define DWARF_FRAME_RETURN_COLUMN DWARF_FRAME_REGNUM (TILEPRO_LINK_REGNUM) 266 267 #define DWARF_ZERO_REG 63 268 269 #define EH_RETURN_DATA_REGNO(N) ((N) < 4 ? (N + 12) : INVALID_REGNUM) 270 #define EH_RETURN_STACKADJ_RTX gen_rtx_REG (Pmode, 11) 271 #define EH_RETURN_HANDLER_RTX tilepro_eh_return_handler_rtx () 272 273 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL) \ 274 tilepro_asm_preferred_eh_data_format ((CODE), (GLOBAL)) 275 276 277 /* Addressing modes, and classification of registers for them. */ 278 279 #define HAVE_POST_INCREMENT 1 280 #define HAVE_POST_DECREMENT 1 281 #define HAVE_POST_MODIFY_DISP 1 282 283 #define REGNO_OK_FOR_INDEX_P(regno) 0 284 #define REGNO_OK_FOR_BASE_P(regno) \ 285 ((regno) < FIRST_PSEUDO_REGISTER || reg_renumber[regno] >= 0) 286 287 #define MAX_REGS_PER_ADDRESS 1 288 289 #define CONSTANT_ADDRESS_P(X) 0 290 291 #define LEGITIMATE_PIC_OPERAND_P(X) tilepro_legitimate_pic_operand_p (X) 292 293 294 #define CASE_VECTOR_MODE SImode 295 #define CASE_VECTOR_PC_RELATIVE 0 296 #define JUMP_TABLES_IN_TEXT_SECTION 0 297 298 #define DEFAULT_SIGNED_CHAR 1 299 300 #define MOVE_MAX UNITS_PER_WORD 301 302 /* Use a value of 11 for MOVE_RATIO and friends, because TILEPro 303 returns structs as large as 10 words in registers. Because of some 304 some code generation inefficiency, we never get smaller code for 305 turning that into a memcpy, so pick a value that guarantees this 306 doesn't happen. */ 307 #define TILEPRO_CALL_RATIO 11 308 #define MOVE_RATIO(speed) ((speed) ? 15 : TILEPRO_CALL_RATIO) 309 #define CLEAR_RATIO(speed) ((speed) ? 15 : TILEPRO_CALL_RATIO) 310 #define SET_RATIO(speed) ((speed) ? 15 : TILEPRO_CALL_RATIO) 311 312 #define WORD_REGISTER_OPERATIONS 1 313 314 #define LOAD_EXTEND_OP(MODE) ZERO_EXTEND 315 316 #define PROMOTE_MODE(MODE,UNSIGNEDP,TYPE) \ 317 if (GET_MODE_CLASS (MODE) == MODE_INT \ 318 && GET_MODE_SIZE (MODE) < UNITS_PER_WORD) \ 319 (MODE) = SImode; 320 321 /* Define SLOW_BYTE_ACCESS to avoid making a QI or HI mode 322 register. */ 323 #define SLOW_BYTE_ACCESS 1 324 325 #define SHIFT_COUNT_TRUNCATED 1 326 327 #define SHORT_IMMEDIATES_SIGN_EXTEND 1 328 329 #define CLZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) ((VALUE) = 32, 1) 330 #define CTZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) ((VALUE) = 32, 1) 331 332 #define Pmode SImode 333 334 #define STORE_FLAG_VALUE 1 335 336 #define FUNCTION_MODE SImode 337 338 #define NO_FUNCTION_CSE 1 339 340 #define ADJUST_INSN_LENGTH(INSN, LENGTH) \ 341 ((LENGTH) = tilepro_adjust_insn_length ((INSN), (LENGTH))) 342 343 #define TARGET_FLOAT_FORMAT IEEE_FLOAT_FORMAT 344 345 #define BRANCH_COST(speed_p, predictable_p) ((predictable_p) ? 2 : 6) 346 347 348 /* Control the assembler format that we output. */ 349 350 #undef NO_DOLLAR_IN_LABEL 351 352 #define ASM_COMMENT_START "##" 353 354 #define TEXT_SECTION_ASM_OP "\t.text" 355 356 #define DATA_SECTION_ASM_OP "\t.data" 357 358 #undef READONLY_DATA_SECTION_ASM_OP 359 #define READONLY_DATA_SECTION_ASM_OP "\t.section\t.rodata, \"a\"" 360 361 #undef BSS_SECTION_ASM_OP 362 #define BSS_SECTION_ASM_OP "\t.section\t.bss, \"wa\"" 363 364 #undef INIT_SECTION_ASM_OP 365 #define INIT_SECTION_ASM_OP "\t.section\t.init, \"ax\"" 366 367 #undef FINI_SECTION_ASM_OP 368 #define FINI_SECTION_ASM_OP "\t.section\t.fini, \"ax\"" 369 370 #define GLOBAL_ASM_OP ".global " 371 372 #define SUPPORTS_WEAK 1 373 374 #define USER_LABEL_PREFIX "" 375 376 #define REGISTER_PREFIX "" 377 #define REGISTER_NAMES \ 378 { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \ 379 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \ 380 "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", \ 381 "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31", \ 382 "r32", "r33", "r34", "r35", "r36", "r37", "r38", "r39", \ 383 "r40", "r41", "r42", "r43", "r44", "r45", "r46", "r47", \ 384 "r48", "r49", "r50", "r51", "r52", "tp", "sp", "lr", \ 385 "sn", "idn0", "idn1", "udn0", "udn1", "udn2", "udn3", "zero", \ 386 "?FRAME?", "?ARG?", "?NET?" } 387 388 /* This is used to help emit bundles. */ 389 #define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS) \ 390 tilepro_final_prescan_insn (insn) 391 392 /* This is used to help emit bundles. */ 393 #define ASM_OUTPUT_OPCODE(STREAM, PTR) \ 394 (PTR = tilepro_asm_output_opcode (STREAM, PTR)) 395 396 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \ 397 do \ 398 { \ 399 char label[256]; \ 400 ASM_GENERATE_INTERNAL_LABEL (label, "L", (VALUE));\ 401 fprintf (FILE, "\t.word "); \ 402 assemble_name (FILE, label); \ 403 fprintf (FILE, "\n"); \ 404 } \ 405 while (0) 406 407 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \ 408 do \ 409 { \ 410 char label[256]; \ 411 ASM_GENERATE_INTERNAL_LABEL (label, "L", (VALUE)); \ 412 fprintf (FILE, "\t.word "); \ 413 assemble_name (FILE, label); \ 414 ASM_GENERATE_INTERNAL_LABEL (label, "L", (REL)); \ 415 fprintf (FILE, "-"); \ 416 assemble_name (FILE, label); \ 417 fprintf (FILE, "\n"); \ 418 } \ 419 while (0) 420 421 #define ASM_OUTPUT_ALIGN(FILE,LOG) \ 422 do { if ((LOG) != 0) fprintf (FILE, "\t.align %d\n", 1 << (LOG)); } while (0) 423 424 #define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \ 425 ( fputs (".comm ", (FILE)), \ 426 assemble_name ((FILE), (NAME)), \ 427 fprintf ((FILE), ",%u\n", (unsigned int)(ROUNDED))) 428 429 #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \ 430 ( fputs (".lcomm ", (FILE)), \ 431 assemble_name ((FILE), (NAME)), \ 432 fprintf ((FILE), ",%u\n", (unsigned int)(ROUNDED))) 433 434 435 436 #define INIT_EXPANDERS tilepro_init_expanders () 437 438 /* A C structure for machine-specific, per-function data. This is 439 added to the cfun structure. */ 440 typedef struct GTY(()) machine_function 441 { 442 /* Symbol for the text label used for pic. */ 443 rtx text_label_symbol; 444 445 /* Register for the text label. */ 446 rtx text_label_rtx; 447 448 /* Register for the pic offset table. */ 449 rtx got_rtx; 450 451 /* The function calls tls_get_addr. */ 452 int calls_tls_get_addr; 453 } machine_function; 454 455 #ifndef HAVE_AS_TLS 456 #define HAVE_AS_TLS 0 457 #endif 458