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