00001 /* Definitions of target machine for GNU compiler, Argonaut ARC cpu. 00002 Copyright (C) 1994, 1995, 1997, 1998, 1999, 2000, 2001, 2002 00003 Free Software Foundation, Inc. 00004 00005 This file is part of GNU CC. 00006 00007 GNU CC is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 2, or (at your option) 00010 any later version. 00011 00012 GNU CC is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with GNU CC; see the file COPYING. If not, write to 00019 the Free Software Foundation, 59 Temple Place - Suite 330, 00020 Boston, MA 02111-1307, USA. */ 00021 00022 /* ??? This is an old port, and is undoubtedly suffering from bit rot. */ 00023 00024 /* Things to do: 00025 00026 - PREDICATE_CODES 00027 - incscc, decscc? 00028 - print active compiler options in assembler output 00029 */ 00030 00031 00032 #undef ASM_SPEC 00033 #undef LINK_SPEC 00034 #undef STARTFILE_SPEC 00035 #undef ENDFILE_SPEC 00036 #undef SIZE_TYPE 00037 #undef PTRDIFF_TYPE 00038 #undef WCHAR_TYPE 00039 #undef WCHAR_TYPE_SIZE 00040 #undef ASM_OUTPUT_LABELREF 00041 00042 /* Print subsidiary information on the compiler version in use. */ 00043 #define TARGET_VERSION fprintf (stderr, " (arc)") 00044 00045 /* Names to predefine in the preprocessor for this target machine. */ 00046 #define CPP_PREDEFINES "-Acpu=arc -Amachine=arc -D__arc__" 00047 00048 /* Additional flags for the preprocessor. */ 00049 #define CPP_SPEC "\ 00050 %{!mcpu=*:-D__base__} %{mcpu=base:-D__base__} \ 00051 %{EB:-D__big_endian__} \ 00052 " 00053 00054 /* Pass -mmangle-cpu if we get -mcpu=*. 00055 Doing it this way lets one have it on as default with -mcpu=*, 00056 but also lets one turn it off with -mno-mangle-cpu. */ 00057 #define CC1_SPEC "\ 00058 %{mcpu=*:-mmangle-cpu} \ 00059 %{EB:%{EL:%emay not use both -EB and -EL}} \ 00060 %{EB:-mbig-endian} %{EL:-mlittle-endian} \ 00061 " 00062 00063 #define ASM_SPEC "%{v} %{EB} %{EL}" 00064 00065 #define LINK_SPEC "%{v} %{EB} %{EL}" 00066 00067 #define STARTFILE_SPEC "%{!shared:crt0.o%s} crtinit.o%s" 00068 00069 #define ENDFILE_SPEC "crtfini.o%s" 00070 00071 /* Run-time compilation parameters selecting different hardware subsets. */ 00072 00073 extern int target_flags; 00074 00075 /* Mangle all user symbols for the specified cpu. 00076 ARC's can be shipped in which a collection of cpus are coupled together. 00077 Each CPU may be different in some way, and thus we may need to distinguish 00078 code compiled for one to ensure it isn't linked with code compiled for 00079 another. */ 00080 #define TARGET_MASK_MANGLE_CPU 1 00081 #define TARGET_MANGLE_CPU (target_flags & TARGET_MASK_MANGLE_CPU) 00082 00083 #if 0 00084 /* Mangle libgcc symbols by adding a suffix for the specified cpu. */ 00085 #define TARGET_MASK_MANGLE_CPU_LIBGCC 2 00086 #define TARGET_MANGLE_CPU_LIBGCC (target_flags & TARGET_MASK_MANGLE_CPU_LIBGCC) 00087 #endif 00088 00089 /* Align loops to 32 byte boundaries (cache line size). */ 00090 #define TARGET_MASK_ALIGN_LOOPS 4 00091 #define TARGET_ALIGN_LOOPS (target_flags & TARGET_MASK_ALIGN_LOOPS) 00092 00093 /* Big Endian. */ 00094 #define TARGET_MASK_BIG_ENDIAN 8 00095 #define TARGET_BIG_ENDIAN (target_flags & TARGET_MASK_BIG_ENDIAN) 00096 00097 /* Turn off conditional execution optimization, 00098 so we can see how well it does, or in case it's buggy. */ 00099 #define TARGET_MASK_NO_COND_EXEC 0x10 00100 #define TARGET_NO_COND_EXEC (target_flags & TARGET_MASK_NO_COND_EXEC) 00101 00102 /* Macro to define tables used to set the flags. 00103 This is a list in braces of pairs in braces, 00104 each pair being { "NAME", VALUE } 00105 where VALUE is the bits to set or minus the bits to clear. 00106 An empty string NAME is used to identify the default VALUE. */ 00107 00108 #define TARGET_SWITCHES \ 00109 { \ 00110 { "mangle-cpu", TARGET_MASK_MANGLE_CPU }, \ 00111 { "no-mangle-cpu", -TARGET_MASK_MANGLE_CPU }, \ 00112 /* { "mangle-cpu-libgcc", TARGET_MASK_MANGLE_CPU_LIBGCC }, */ \ 00113 /* { "no-mangle-cpu-libgcc", -TARGET_MASK_MANGLE_CPU_LIBGCC }, */ \ 00114 { "align-loops", TARGET_MASK_ALIGN_LOOPS }, \ 00115 { "no-align-loops", -TARGET_MASK_ALIGN_LOOPS }, \ 00116 { "big-endian", TARGET_MASK_BIG_ENDIAN }, \ 00117 { "little-endian", -TARGET_MASK_BIG_ENDIAN }, \ 00118 { "no-cond-exec", TARGET_MASK_NO_COND_EXEC }, \ 00119 SUBTARGET_SWITCHES \ 00120 { "", TARGET_DEFAULT } \ 00121 } 00122 00123 #define TARGET_DEFAULT (0) 00124 00125 #define SUBTARGET_SWITCHES 00126 00127 /* Instruction set characteristics. 00128 These are internal macros, set by the appropriate -mcpu= option. */ 00129 00130 /* Non-zero means the cpu has a barrel shifter. */ 00131 #define TARGET_SHIFTER 0 00132 00133 extern const char *arc_cpu_string; 00134 extern const char *arc_text_string,*arc_data_string,*arc_rodata_string; 00135 00136 #define TARGET_OPTIONS \ 00137 { \ 00138 { "cpu=", &arc_cpu_string }, \ 00139 { "text=", &arc_text_string }, \ 00140 { "data=", &arc_data_string }, \ 00141 { "rodata=", &arc_rodata_string }, \ 00142 } 00143 00144 /* Which cpu we're compiling for. */ 00145 extern int arc_cpu_type; 00146 00147 /* Check if CPU is an extension and set `arc_cpu_type' and `arc_mangle_cpu' 00148 appropriately. The result should be non-zero if the cpu is recognized, 00149 otherwise zero. This is intended to be redefined in a cover file. 00150 This is used by arc_init. */ 00151 #define ARC_EXTENSION_CPU(cpu) 0 00152 00153 /* Sometimes certain combinations of command options do not make 00154 sense on a particular target machine. You can define a macro 00155 `OVERRIDE_OPTIONS' to take account of this. This macro, if 00156 defined, is executed once just after all the command options have 00157 been parsed. 00158 00159 Don't use this macro to turn on various extra optimizations for 00160 `-O'. That is what `OPTIMIZATION_OPTIONS' is for. */ 00161 00162 00163 #define OVERRIDE_OPTIONS \ 00164 do { \ 00165 /* These need to be done at start up. It's convenient to do them here. */ \ 00166 arc_init (); \ 00167 } while (0) 00168 00169 /* Target machine storage layout. */ 00170 00171 /* Define to use software floating point emulator for REAL_ARITHMETIC and 00172 decimal <-> binary conversion. */ 00173 #define REAL_ARITHMETIC 00174 00175 /* Define this if most significant bit is lowest numbered 00176 in instructions that operate on numbered bit-fields. */ 00177 #define BITS_BIG_ENDIAN 1 00178 00179 /* Define this if most significant byte of a word is the lowest numbered. */ 00180 #define BYTES_BIG_ENDIAN (TARGET_BIG_ENDIAN) 00181 00182 /* Define this if most significant word of a multiword number is the lowest 00183 numbered. */ 00184 #define WORDS_BIG_ENDIAN (TARGET_BIG_ENDIAN) 00185 00186 /* Define this to set the endianness to use in libgcc2.c, which can 00187 not depend on target_flags. */ 00188 #ifdef __big_endian__ 00189 #define LIBGCC2_WORDS_BIG_ENDIAN 1 00190 #else 00191 #define LIBGCC2_WORDS_BIG_ENDIAN 0 00192 #endif 00193 00194 /* Number of bits in an addressable storage unit. */ 00195 #define BITS_PER_UNIT 8 00196 00197 /* Width in bits of a "word", which is the contents of a machine register. 00198 Note that this is not necessarily the width of data type `int'; 00199 if using 16-bit ints on a 68000, this would still be 32. 00200 But on a machine with 16-bit registers, this would be 16. */ 00201 #define BITS_PER_WORD 32 00202 00203 /* Width of a word, in units (bytes). */ 00204 #define UNITS_PER_WORD 4 00205 00206 /* Define this macro if it is advisable to hold scalars in registers 00207 in a wider mode than that declared by the program. In such cases, 00208 the value is constrained to be within the bounds of the declared 00209 type, but kept valid in the wider mode. The signedness of the 00210 extension may differ from that of the type. */ 00211 #define PROMOTE_MODE(MODE,UNSIGNEDP,TYPE) \ 00212 if (GET_MODE_CLASS (MODE) == MODE_INT \ 00213 && GET_MODE_SIZE (MODE) < UNITS_PER_WORD) \ 00214 { \ 00215 (MODE) = SImode; \ 00216 } 00217 00218 /* Define this macro if the promotion described by `PROMOTE_MODE' 00219 should also be done for outgoing function arguments. */ 00220 #define PROMOTE_FUNCTION_ARGS 00221 00222 /* Likewise, if the function return value is promoted. */ 00223 #define PROMOTE_FUNCTION_RETURN 00224 00225 /* Width in bits of a pointer. 00226 See also the macro `Pmode' defined below. */ 00227 #define POINTER_SIZE 32 00228 00229 /* Allocation boundary (in *bits*) for storing arguments in argument list. */ 00230 #define PARM_BOUNDARY 32 00231 00232 /* Boundary (in *bits*) on which stack pointer should be aligned. */ 00233 #define STACK_BOUNDARY 64 00234 00235 /* ALIGN FRAMES on word boundaries */ 00236 #define ARC_STACK_ALIGN(LOC) (((LOC)+7) & ~7) 00237 00238 /* Allocation boundary (in *bits*) for the code of a function. */ 00239 #define FUNCTION_BOUNDARY 32 00240 00241 /* Alignment of field after `int : 0' in a structure. */ 00242 #define EMPTY_FIELD_BOUNDARY 32 00243 00244 /* Every structure's size must be a multiple of this. */ 00245 #define STRUCTURE_SIZE_BOUNDARY 8 00246 00247 /* A bitfield declared as `int' forces `int' alignment for the struct. */ 00248 #define PCC_BITFIELD_TYPE_MATTERS 1 00249 00250 /* No data type wants to be aligned rounder than this. */ 00251 /* This is bigger than currently necessary for the ARC. If 8 byte floats are 00252 ever added it's not clear whether they'll need such alignment or not. For 00253 now we assume they will. We can always relax it if necessary but the 00254 reverse isn't true. */ 00255 #define BIGGEST_ALIGNMENT 64 00256 00257 /* The best alignment to use in cases where we have a choice. */ 00258 #define FASTEST_ALIGNMENT 32 00259 00260 /* Make strings word-aligned so strcpy from constants will be faster. */ 00261 #define CONSTANT_ALIGNMENT(EXP, ALIGN) \ 00262 ((TREE_CODE (EXP) == STRING_CST \ 00263 && (ALIGN) < FASTEST_ALIGNMENT) \ 00264 ? FASTEST_ALIGNMENT : (ALIGN)) 00265 00266 /* Make arrays of chars word-aligned for the same reasons. */ 00267 #define DATA_ALIGNMENT(TYPE, ALIGN) \ 00268 (TREE_CODE (TYPE) == ARRAY_TYPE \ 00269 && TYPE_MODE (TREE_TYPE (TYPE)) == QImode \ 00270 && (ALIGN) < FASTEST_ALIGNMENT ? FASTEST_ALIGNMENT : (ALIGN)) 00271 00272 /* Set this nonzero if move instructions will actually fail to work 00273 when given unaligned data. */ 00274 /* On the ARC the lower address bits are masked to 0 as necessary. The chip 00275 won't croak when given an unaligned address, but the insn will still fail 00276 to produce the correct result. */ 00277 #define STRICT_ALIGNMENT 1 00278 00279 /* Layout of source language data types. */ 00280 00281 #define SHORT_TYPE_SIZE 16 00282 #define INT_TYPE_SIZE 32 00283 #define LONG_TYPE_SIZE 32 00284 #define LONG_LONG_TYPE_SIZE 64 00285 #define FLOAT_TYPE_SIZE 32 00286 #define DOUBLE_TYPE_SIZE 64 00287 #define LONG_DOUBLE_TYPE_SIZE 64 00288 00289 /* Define this as 1 if `char' should by default be signed; else as 0. */ 00290 #define DEFAULT_SIGNED_CHAR 1 00291 00292 #define SIZE_TYPE "long unsigned int" 00293 #define PTRDIFF_TYPE "long int" 00294 #define WCHAR_TYPE "short unsigned int" 00295 #define WCHAR_TYPE_SIZE 16 00296 00297 /* Standard register usage. */ 00298 00299 /* Number of actual hardware registers. 00300 The hardware registers are assigned numbers for the compiler 00301 from 0 to just below FIRST_PSEUDO_REGISTER. 00302 All registers that the compiler knows about must be given numbers, 00303 even those that are not normally considered general registers. */ 00304 /* Registers 61, 62, and 63 are not really registers and we needn't treat 00305 them as such. We still need a register for the condition code. */ 00306 #define FIRST_PSEUDO_REGISTER 62 00307 00308 /* 1 for registers that have pervasive standard uses 00309 and are not available for the register allocator. 00310 00311 0-28 - general purpose registers 00312 29 - ilink1 (interrupt link register) 00313 30 - ilink2 (interrupt link register) 00314 31 - blink (branch link register) 00315 32-59 - reserved for extensions 00316 60 - LP_COUNT 00317 61 - condition code 00318 00319 For doc purposes: 00320 61 - short immediate data indicator (setting flags) 00321 62 - long immediate data indicator 00322 63 - short immediate data indicator (not setting flags). 00323 00324 The general purpose registers are further broken down into: 00325 0-7 - arguments/results 00326 8-15 - call used 00327 16-23 - call saved 00328 24 - call used, static chain pointer 00329 25 - call used, gptmp 00330 26 - global pointer 00331 27 - frame pointer 00332 28 - stack pointer 00333 00334 By default, the extension registers are not available. */ 00335 00336 #define FIXED_REGISTERS \ 00337 { 0, 0, 0, 0, 0, 0, 0, 0, \ 00338 0, 0, 0, 0, 0, 0, 0, 0, \ 00339 0, 0, 0, 0, 0, 0, 0, 0, \ 00340 0, 0, 0, 1, 1, 1, 1, 0, \ 00341 \ 00342 1, 1, 1, 1, 1, 1, 1, 1, \ 00343 1, 1, 1, 1, 1, 1, 1, 1, \ 00344 1, 1, 1, 1, 1, 1, 1, 1, \ 00345 1, 1, 1, 1, 1, 1 } 00346 00347 /* 1 for registers not available across function calls. 00348 These must include the FIXED_REGISTERS and also any 00349 registers that can be used without being saved. 00350 The latter must include the registers where values are returned 00351 and the register where structure-value addresses are passed. 00352 Aside from that, you can include as many other registers as you like. */ 00353 00354 #define CALL_USED_REGISTERS \ 00355 { 1, 1, 1, 1, 1, 1, 1, 1, \ 00356 1, 1, 1, 1, 1, 1, 1, 1, \ 00357 0, 0, 0, 0, 0, 0, 0, 0, \ 00358 1, 1, 1, 1, 1, 1, 1, 1, \ 00359 \ 00360 1, 1, 1, 1, 1, 1, 1, 1, \ 00361 1, 1, 1, 1, 1, 1, 1, 1, \ 00362 1, 1, 1, 1, 1, 1, 1, 1, \ 00363 1, 1, 1, 1, 1, 1 } 00364 00365 /* If defined, an initializer for a vector of integers, containing the 00366 numbers of hard registers in the order in which GNU CC should 00367 prefer to use them (from most preferred to least). */ 00368 #define REG_ALLOC_ORDER \ 00369 { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, \ 00370 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 31, \ 00371 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, \ 00372 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, \ 00373 27, 28, 29, 30 } 00374 00375 /* Macro to conditionally modify fixed_regs/call_used_regs. */ 00376 #define CONDITIONAL_REGISTER_USAGE \ 00377 do { \ 00378 if (PIC_OFFSET_TABLE_REGNUM != INVALID_REGNUM) \ 00379 { \ 00380 fixed_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \ 00381 call_used_regs[PIC_OFFSET_TABLE_REGNUM] = 1; \ 00382 } \ 00383 } while (0) 00384 00385 /* Return number of consecutive hard regs needed starting at reg REGNO 00386 to hold something of mode MODE. 00387 This is ordinarily the length in words of a value of mode MODE 00388 but can be less for certain modes in special long registers. */ 00389 #define HARD_REGNO_NREGS(REGNO, MODE) \ 00390 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD) 00391 00392 /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE. */ 00393 extern const unsigned int arc_hard_regno_mode_ok[]; 00394 extern unsigned int arc_mode_class[]; 00395 #define HARD_REGNO_MODE_OK(REGNO, MODE) \ 00396 ((arc_hard_regno_mode_ok[REGNO] & arc_mode_class[MODE]) != 0) 00397 00398 /* A C expression that is nonzero if it is desirable to choose 00399 register allocation so as to avoid move instructions between a 00400 value of mode MODE1 and a value of mode MODE2. 00401 00402 If `HARD_REGNO_MODE_OK (R, MODE1)' and `HARD_REGNO_MODE_OK (R, 00403 MODE2)' are ever different for any R, then `MODES_TIEABLE_P (MODE1, 00404 MODE2)' must be zero. */ 00405 00406 /* Tie QI/HI/SI modes together. */ 00407 #define MODES_TIEABLE_P(MODE1, MODE2) \ 00408 (GET_MODE_CLASS (MODE1) == MODE_INT \ 00409 && GET_MODE_CLASS (MODE2) == MODE_INT \ 00410 && GET_MODE_SIZE (MODE1) <= UNITS_PER_WORD \ 00411 && GET_MODE_SIZE (MODE2) <= UNITS_PER_WORD) 00412 00413 /* Register classes and constants. */ 00414 00415 /* Define the classes of registers for register constraints in the 00416 machine description. Also define ranges of constants. 00417 00418 One of the classes must always be named ALL_REGS and include all hard regs. 00419 If there is more than one class, another class must be named NO_REGS 00420 and contain no registers. 00421 00422 The name GENERAL_REGS must be the name of a class (or an alias for 00423 another name such as ALL_REGS). This is the class of registers 00424 that is allowed by "g" or "r" in a register constraint. 00425 Also, registers outside this class are allocated only when 00426 instructions express preferences for them. 00427 00428 The classes must be numbered in nondecreasing order; that is, 00429 a larger-numbered class must never be contained completely 00430 in a smaller-numbered class. 00431 00432 For any two classes, it is very desirable that there be another 00433 class that represents their union. 00434 00435 It is important that any condition codes have class NO_REGS. 00436 See `register_operand'. */ 00437 00438 enum reg_class { 00439 NO_REGS, LPCOUNT_REG, GENERAL_REGS, ALL_REGS, LIM_REG_CLASSES 00440 }; 00441 00442 #define N_REG_CLASSES (int) LIM_REG_CLASSES 00443 00444 /* Give names of register classes as strings for dump file. */ 00445 #define REG_CLASS_NAMES \ 00446 { "NO_REGS", "LPCOUNT_REG", "GENERAL_REGS", "ALL_REGS" } 00447 00448 /* Define which registers fit in which classes. 00449 This is an initializer for a vector of HARD_REG_SET 00450 of length N_REG_CLASSES. */ 00451 00452 #define REG_CLASS_CONTENTS \ 00453 { {0, 0}, {0, 0x10000000}, {0xffffffff, 0xfffffff}, \ 00454 {0xffffffff, 0x1fffffff} } 00455 00456 /* The same information, inverted: 00457 Return the class number of the smallest class containing 00458 reg number REGNO. This could be a conditional expression 00459 or could index an array. */ 00460 extern enum reg_class arc_regno_reg_class[FIRST_PSEUDO_REGISTER]; 00461 #define REGNO_REG_CLASS(REGNO) \ 00462 (arc_regno_reg_class[REGNO]) 00463 00464 /* The class value for index registers, and the one for base regs. */ 00465 #define INDEX_REG_CLASS GENERAL_REGS 00466 #define BASE_REG_CLASS GENERAL_REGS 00467 00468 /* Get reg_class from a letter such as appears in the machine description. */ 00469 #define REG_CLASS_FROM_LETTER(C) \ 00470 ((C) == 'l' ? LPCOUNT_REG /* ??? needed? */ \ 00471 : NO_REGS) 00472 00473 /* These assume that REGNO is a hard or pseudo reg number. 00474 They give nonzero only if REGNO is a hard reg of the suitable class 00475 or a pseudo reg currently allocated to a suitable hard reg. 00476 Since they use reg_renumber, they are safe only once reg_renumber 00477 has been allocated, which happens in local-alloc.c. */ 00478 #define REGNO_OK_FOR_BASE_P(REGNO) \ 00479 ((REGNO) < 29 || (unsigned) reg_renumber[REGNO] < 29) 00480 #define REGNO_OK_FOR_INDEX_P(REGNO) \ 00481 ((REGNO) < 29 || (unsigned) reg_renumber[REGNO] < 29) 00482 00483 /* Given an rtx X being reloaded into a reg required to be 00484 in class CLASS, return the class of reg to actually use. 00485 In general this is just CLASS; but on some machines 00486 in some cases it is preferable to use a more restrictive class. */ 00487 #define PREFERRED_RELOAD_CLASS(X,CLASS) \ 00488 (CLASS) 00489 00490 /* Return the maximum number of consecutive registers 00491 needed to represent mode MODE in a register of class CLASS. */ 00492 #define CLASS_MAX_NREGS(CLASS, MODE) \ 00493 ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD) 00494 00495 /* The letters I, J, K, L, M, N, O, P in a register constraint string 00496 can be used to stand for particular ranges of immediate operands. 00497 This macro defines what the ranges are. 00498 C is the letter, and VALUE is a constant value. 00499 Return 1 if VALUE is in the range specified by C. */ 00500 /* 'I' is used for short immediates (always signed). 00501 'J' is used for long immediates. 00502 'K' is used for any constant up to 64 bits (for 64x32 situations?). */ 00503 00504 /* local to this file */ 00505 #define SMALL_INT(X) ((unsigned) ((X) + 0x100) < 0x200) 00506 /* local to this file */ 00507 #define LARGE_INT(X) \ 00508 ((X) >= (-(HOST_WIDE_INT) 0x7fffffff - 1) \ 00509 && (X) <= (unsigned HOST_WIDE_INT) 0xffffffff) 00510 00511 #define CONST_OK_FOR_LETTER_P(VALUE, C) \ 00512 ((C) == 'I' ? SMALL_INT (VALUE) \ 00513 : (C) == 'J' ? LARGE_INT (VALUE) \ 00514 : (C) == 'K' ? 1 \ 00515 : 0) 00516 00517 /* Similar, but for floating constants, and defining letters G and H. 00518 Here VALUE is the CONST_DOUBLE rtx itself. */ 00519 /* 'G' is used for integer values for the multiplication insns where the 00520 operands are extended from 4 bytes to 8 bytes. 00521 'H' is used when any 64 bit constant is allowed. */ 00522 #define CONST_DOUBLE_OK_FOR_LETTER_P(VALUE, C) \ 00523 ((C) == 'G' ? arc_double_limm_p (VALUE) \ 00524 : (C) == 'H' ? 1 \ 00525 : 0) 00526 00527 /* A C expression that defines the optional machine-dependent constraint 00528 letters that can be used to segregate specific types of operands, 00529 usually memory references, for the target machine. It should return 1 if 00530 VALUE corresponds to the operand type represented by the constraint letter 00531 C. If C is not defined as an extra constraint, the value returned should 00532 be 0 regardless of VALUE. */ 00533 /* ??? This currently isn't used. Waiting for PIC. */ 00534 #if 0 00535 #define EXTRA_CONSTRAINT(VALUE, C) \ 00536 ((C) == 'R' ? (SYMBOL_REF_FLAG (VALUE) || GET_CODE (VALUE) == LABEL_REF) \ 00537 : 0) 00538 #endif 00539 00540 /* Stack layout and stack pointer usage. */ 00541 00542 /* Define this macro if pushing a word onto the stack moves the stack 00543 pointer to a smaller address. */ 00544 #define STACK_GROWS_DOWNWARD 00545 00546 /* Define this if the nominal address of the stack frame 00547 is at the high-address end of the local variables; 00548 that is, each additional local variable allocated 00549 goes at a more negative offset in the frame. */ 00550 #define FRAME_GROWS_DOWNWARD 00551 00552 /* Offset within stack frame to start allocating local variables at. 00553 If FRAME_GROWS_DOWNWARD, this is the offset to the END of the 00554 first local allocated. Otherwise, it is the offset to the BEGINNING 00555 of the first local allocated. */ 00556 #define STARTING_FRAME_OFFSET 0 00557 00558 /* Offset from the stack pointer register to the first location at which 00559 outgoing arguments are placed. */ 00560 #define STACK_POINTER_OFFSET FIRST_PARM_OFFSET (0) 00561 00562 /* Offset of first parameter from the argument pointer register value. */ 00563 /* 4 bytes for each of previous fp, return address, and previous gp. 00564 4 byte reserved area for future considerations. */ 00565 #define FIRST_PARM_OFFSET(FNDECL) 16 00566 00567 /* A C expression whose value is RTL representing the address in a 00568 stack frame where the pointer to the caller's frame is stored. 00569 Assume that FRAMEADDR is an RTL expression for the address of the 00570 stack frame itself. 00571 00572 If you don't define this macro, the default is to return the value 00573 of FRAMEADDR--that is, the stack frame address is also the address 00574 of the stack word that points to the previous frame. */ 00575 /* ??? unfinished */ 00576 /*define DYNAMIC_CHAIN_ADDRESS (FRAMEADDR)*/ 00577 00578 /* A C expression whose value is RTL representing the value of the 00579 return address for the frame COUNT steps up from the current frame. 00580 FRAMEADDR is the frame pointer of the COUNT frame, or the frame 00581 pointer of the COUNT - 1 frame if `RETURN_ADDR_IN_PREVIOUS_FRAME' 00582 is defined. */ 00583 /* The current return address is in r31. The return address of anything 00584 farther back is at [%fp,4]. */ 00585 #if 0 /* The default value should work. */ 00586 #define RETURN_ADDR_RTX(COUNT, FRAME) \ 00587 (((COUNT) == -1) \ 00588 ? gen_rtx_REG (Pmode, 31) \ 00589 : copy_to_reg (gen_rtx_MEM (Pmode, \ 00590 memory_address (Pmode, \ 00591 plus_constant ((FRAME), \ 00592 UNITS_PER_WORD))))) 00593 #endif 00594 00595 /* Register to use for pushing function arguments. */ 00596 #define STACK_POINTER_REGNUM 28 00597 00598 /* Base register for access to local variables of the function. */ 00599 #define FRAME_POINTER_REGNUM 27 00600 00601 /* Base register for access to arguments of the function. */ 00602 #define ARG_POINTER_REGNUM FRAME_POINTER_REGNUM 00603 00604 /* Register in which static-chain is passed to a function. This must 00605 not be a register used by the prologue. */ 00606 #define STATIC_CHAIN_REGNUM 24 00607 00608 /* A C expression which is nonzero if a function must have and use a 00609 frame pointer. This expression is evaluated in the reload pass. 00610 If its value is nonzero the function will have a frame pointer. */ 00611 #define FRAME_POINTER_REQUIRED \ 00612 (current_function_calls_alloca) 00613 00614 /* C statement to store the difference between the frame pointer 00615 and the stack pointer values immediately after the function prologue. */ 00616 #define INITIAL_FRAME_POINTER_OFFSET(VAR) \ 00617 ((VAR) = arc_compute_frame_size (get_frame_size ())) 00618 00619 /* Function argument passing. */ 00620 00621 /* When a prototype says `char' or `short', really pass an `int'. */ 00622 #define PROMOTE_PROTOTYPES 1 00623 00624 /* If defined, the maximum amount of space required for outgoing 00625 arguments will be computed and placed into the variable 00626 `current_function_outgoing_args_size'. No space will be pushed 00627 onto the stack for each call; instead, the function prologue should 00628 increase the stack frame size by this amount. */ 00629 #define ACCUMULATE_OUTGOING_ARGS 1 00630 00631 /* Value is the number of bytes of arguments automatically 00632 popped when returning from a subroutine call. 00633 FUNDECL is the declaration node of the function (as a tree), 00634 FUNTYPE is the data type of the function (as a tree), 00635 or for a library call it is an identifier node for the subroutine name. 00636 SIZE is the number of bytes of arguments passed on the stack. */ 00637 #define RETURN_POPS_ARGS(DECL, FUNTYPE, SIZE) 0 00638 00639 /* Define a data type for recording info about an argument list 00640 during the scan of that argument list. This data type should 00641 hold all necessary information about the function itself 00642 and about the args processed so far, enough to enable macros 00643 such as FUNCTION_ARG to determine where the next arg should go. */ 00644 #define CUMULATIVE_ARGS int 00645 00646 /* Initialize a variable CUM of type CUMULATIVE_ARGS 00647 for a call to a function whose data type is FNTYPE. 00648 For a library call, FNTYPE is 0. */ 00649 #define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,INDIRECT) \ 00650 ((CUM) = 0) 00651 00652 /* The number of registers used for parameter passing. Local to this file. */ 00653 #define MAX_ARC_PARM_REGS 8 00654 00655 /* 1 if N is a possible register number for function argument passing. */ 00656 #define FUNCTION_ARG_REGNO_P(N) \ 00657 ((unsigned) (N) < MAX_ARC_PARM_REGS) 00658 00659 /* The ROUND_ADVANCE* macros are local to this file. */ 00660 /* Round SIZE up to a word boundary. */ 00661 #define ROUND_ADVANCE(SIZE) \ 00662 (((SIZE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD) 00663 00664 /* Round arg MODE/TYPE up to the next word boundary. */ 00665 #define ROUND_ADVANCE_ARG(MODE, TYPE) \ 00666 ((MODE) == BLKmode \ 00667 ? ROUND_ADVANCE (int_size_in_bytes (TYPE)) \ 00668 : ROUND_ADVANCE (GET_MODE_SIZE (MODE))) 00669 00670 /* Round CUM up to the necessary point for argument MODE/TYPE. */ 00671 #define ROUND_ADVANCE_CUM(CUM, MODE, TYPE) \ 00672 ((((MODE) == BLKmode ? TYPE_ALIGN (TYPE) : GET_MODE_BITSIZE (MODE)) \ 00673 > BITS_PER_WORD) \ 00674 ? (((CUM) + 1) & ~1) \ 00675 : (CUM)) 00676 00677 /* Return boolean indicating arg of type TYPE and mode MODE will be passed in 00678 a reg. This includes arguments that have to be passed by reference as the 00679 pointer to them is passed in a reg if one is available (and that is what 00680 we're given). 00681 When passing arguments NAMED is always 1. When receiving arguments NAMED 00682 is 1 for each argument except the last in a stdarg/varargs function. In 00683 a stdarg function we want to treat the last named arg as named. In a 00684 varargs function we want to treat the last named arg (which is 00685 `__builtin_va_alist') as unnamed. 00686 This macro is only used in this file. */ 00687 #define PASS_IN_REG_P(CUM, MODE, TYPE, NAMED) \ 00688 ((!current_function_varargs || (NAMED)) \ 00689 && (CUM) < MAX_ARC_PARM_REGS \ 00690 && ((ROUND_ADVANCE_CUM ((CUM), (MODE), (TYPE)) \ 00691 + ROUND_ADVANCE_ARG ((MODE), (TYPE)) \ 00692 <= MAX_ARC_PARM_REGS))) 00693 00694 /* Determine where to put an argument to a function. 00695 Value is zero to push the argument on the stack, 00696 or a hard register in which to store the argument. 00697 00698 MODE is the argument's machine mode. 00699 TYPE is the data type of the argument (as a tree). 00700 This is null for libcalls where that information may 00701 not be available. 00702 CUM is a variable of type CUMULATIVE_ARGS which gives info about 00703 the preceding args and about the function being called. 00704 NAMED is nonzero if this argument is a named parameter 00705 (otherwise it is an extra parameter matching an ellipsis). */ 00706 /* On the ARC the first MAX_ARC_PARM_REGS args are normally in registers 00707 and the rest are pushed. */ 00708 #define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \ 00709 (PASS_IN_REG_P ((CUM), (MODE), (TYPE), (NAMED)) \ 00710 ? gen_rtx_REG ((MODE), ROUND_ADVANCE_CUM ((CUM), (MODE), (TYPE))) \ 00711 : 0) 00712 00713 /* A C expression for the number of words, at the beginning of an 00714 argument, must be put in registers. The value must be zero for 00715 arguments that are passed entirely in registers or that are entirely 00716 pushed on the stack. 00717 00718 On some machines, certain arguments must be passed partially in 00719 registers and partially in memory. On these machines, typically the 00720 first @var{n} words of arguments are passed in registers, and the rest 00721 on the stack. If a multi-word argument (a @code{double} or a 00722 structure) crosses that boundary, its first few words must be passed 00723 in registers and the rest must be pushed. This macro tells the 00724 compiler when this occurs, and how many of the words should go in 00725 registers. */ 00726 #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) 0 00727 00728 /* A C expression that indicates when an argument must be passed by 00729 reference. If nonzero for an argument, a copy of that argument is 00730 made in memory and a pointer to the argument is passed instead of 00731 the argument itself. The pointer is passed in whatever way is 00732 appropriate for passing a pointer to that type. */ 00733 /* All aggregates and arguments greater than 8 bytes are passed this way. */ 00734 #define FUNCTION_ARG_PASS_BY_REFERENCE(CUM, MODE, TYPE, NAMED) \ 00735 (TYPE \ 00736 && (AGGREGATE_TYPE_P (TYPE) \ 00737 || int_size_in_bytes (TYPE) > 8)) 00738 00739 /* A C expression that indicates when it is the called function's 00740 responsibility to make copies of arguments passed by reference. 00741 If the callee can determine that the argument won't be modified, it can 00742 avoid the copy. */ 00743 /* ??? We'd love to be able to use NAMED here. Unfortunately, it doesn't 00744 include the last named argument so we keep track of the args ourselves. */ 00745 00746 #define FUNCTION_ARG_CALLEE_COPIES(CUM, MODE, TYPE, NAMED) \ 00747 FUNCTION_ARG_PASS_BY_REFERENCE ((CUM), (MODE), (TYPE), (NAMED)) 00748 00749 /* Update the data in CUM to advance over an argument 00750 of mode MODE and data type TYPE. 00751 (TYPE is null for libcalls where that information may not be available.) */ 00752 #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \ 00753 ((CUM) = (ROUND_ADVANCE_CUM ((CUM), (MODE), (TYPE)) \ 00754 + ROUND_ADVANCE_ARG ((MODE), (TYPE)))) 00755 00756 /* If defined, a C expression that gives the alignment boundary, in bits, 00757 of an argument with the specified mode and type. If it is not defined, 00758 PARM_BOUNDARY is used for all arguments. */ 00759 #define FUNCTION_ARG_BOUNDARY(MODE, TYPE) \ 00760 (((TYPE) ? TYPE_ALIGN (TYPE) : GET_MODE_BITSIZE (MODE)) <= PARM_BOUNDARY \ 00761 ? PARM_BOUNDARY \ 00762 : 2 * PARM_BOUNDARY) 00763 00764 /* This macro offers an alternative 00765 to using `__builtin_saveregs' and defining the macro 00766 `EXPAND_BUILTIN_SAVEREGS'. Use it to store the anonymous register 00767 arguments into the stack so that all the arguments appear to have 00768 been passed consecutively on the stack. Once this is done, you 00769 can use the standard implementation of varargs that works for 00770 machines that pass all their arguments on the stack. 00771 00772 The argument ARGS_SO_FAR is the `CUMULATIVE_ARGS' data structure, 00773 containing the values that obtain after processing of the named 00774 arguments. The arguments MODE and TYPE describe the last named 00775 argument--its machine mode and its data type as a tree node. 00776 00777 The macro implementation should do two things: first, push onto the 00778 stack all the argument registers *not* used for the named 00779 arguments, and second, store the size of the data thus pushed into 00780 the `int'-valued variable whose name is supplied as the argument 00781 PRETEND_SIZE. The value that you store here will serve as 00782 additional offset for setting up the stack frame. 00783 00784 If the argument NO_RTL is nonzero, it means that the 00785 arguments of the function are being analyzed for the second time. 00786 This happens for an inline function, which is not actually 00787 compiled until the end of the source file. The macro 00788 `SETUP_INCOMING_VARARGS' should not generate any instructions in 00789 this case. */ 00790 00791 #define SETUP_INCOMING_VARARGS(ARGS_SO_FAR, MODE, TYPE, PRETEND_SIZE, NO_RTL) \ 00792 arc_setup_incoming_varargs(&ARGS_SO_FAR, MODE, TYPE, &PRETEND_SIZE, NO_RTL) 00793 00794 /* Function results. */ 00795 00796 /* Define how to find the value returned by a function. 00797 VALTYPE is the data type of the value (as a tree). 00798 If the precise function being called is known, FUNC is its FUNCTION_DECL; 00799 otherwise, FUNC is 0. */ 00800 #define FUNCTION_VALUE(VALTYPE, FUNC) gen_rtx_REG (TYPE_MODE (VALTYPE), 0) 00801 00802 /* Define how to find the value returned by a library function 00803 assuming the value has mode MODE. */ 00804 #define LIBCALL_VALUE(MODE) gen_rtx_REG (MODE, 0) 00805 00806 /* 1 if N is a possible register number for a function value 00807 as seen by the caller. */ 00808 /* ??? What about r1 in DI/DF values. */ 00809 #define FUNCTION_VALUE_REGNO_P(N) ((N) == 0) 00810 00811 /* A C expression which can inhibit the returning of certain function 00812 values in registers, based on the type of value. A nonzero value says 00813 to return the function value in memory, just as large structures are 00814 always returned. Here TYPE will be a C expression of type `tree', 00815 representing the data type of the value. */ 00816 #define RETURN_IN_MEMORY(TYPE) \ 00817 (AGGREGATE_TYPE_P (TYPE) \ 00818 || int_size_in_bytes (TYPE) > 8 \ 00819 || TREE_ADDRESSABLE (TYPE)) 00820 00821 /* Tell GCC to use RETURN_IN_MEMORY. */ 00822 #define DEFAULT_PCC_STRUCT_RETURN 0 00823 00824 /* Register in which address to store a structure value 00825 is passed to a function, or 0 to use `invisible' first argument. */ 00826 #define STRUCT_VALUE 0 00827 00828 /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function, 00829 the stack pointer does not matter. The value is tested only in 00830 functions that have frame pointers. 00831 No definition is equivalent to always zero. */ 00832 #define EXIT_IGNORE_STACK 0 00833 00834 /* Epilogue delay slots. */ 00835 #define DELAY_SLOTS_FOR_EPILOGUE arc_delay_slots_for_epilogue () 00836 00837 #define ELIGIBLE_FOR_EPILOGUE_DELAY(TRIAL, SLOTS_FILLED) \ 00838 arc_eligible_for_epilogue_delay (TRIAL, SLOTS_FILLED) 00839 00840 /* Output assembler code to FILE to increment profiler label # LABELNO 00841 for profiling a function entry. */ 00842 #define FUNCTION_PROFILER(FILE, LABELNO) 00843 00844 /* Trampolines. */ 00845 /* ??? This doesn't work yet because GCC will use as the address of a nested 00846 function the address of the trampoline. We need to use that address 00847 right shifted by 2. It looks like we'll need PSImode after all. :-( */ 00848 00849 /* Output assembler code for a block containing the constant parts 00850 of a trampoline, leaving space for the variable parts. */ 00851 /* On the ARC, the trampoline is quite simple as we have 32 bit immediate 00852 constants. 00853 00854 mov r24,STATIC 00855 j.nd FUNCTION 00856 */ 00857 #define TRAMPOLINE_TEMPLATE(FILE) \ 00858 do { \ 00859 assemble_aligned_integer (UNITS_PER_WORD, GEN_INT (0x631f7c00)); \ 00860 assemble_aligned_integer (UNITS_PER_WORD, const0_rtx); \ 00861 assemble_aligned_integer (UNITS_PER_WORD, GEN_INT (0x381f0000)); \ 00862 assemble_aligned_integer (UNITS_PER_WORD, const0_rtx); \ 00863 } while (0) 00864 00865 /* Length in units of the trampoline for entering a nested function. */ 00866 #define TRAMPOLINE_SIZE 16 00867 00868 /* Emit RTL insns to initialize the variable parts of a trampoline. 00869 FNADDR is an RTX for the address of the function's pure code. 00870 CXT is an RTX for the static chain value for the function. */ 00871 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT) \ 00872 do { \ 00873 emit_move_insn (gen_rtx_MEM (SImode, plus_constant (TRAMP, 4)), CXT); \ 00874 emit_move_insn (gen_rtx_MEM (SImode, plus_constant (TRAMP, 12)), FNADDR); \ 00875 emit_insn (gen_flush_icache (validize_mem (gen_rtx_MEM (SImode, TRAMP)))); \ 00876 } while (0) 00877 00878 /* Library calls. */ 00879 00880 /* Generate calls to memcpy, memcmp and memset. */ 00881 #define TARGET_MEM_FUNCTIONS 00882 00883 /* Addressing modes, and classification of registers for them. */ 00884 00885 /* Maximum number of registers that can appear in a valid memory address. */ 00886 /* The `ld' insn allows 2, but the `st' insn only allows 1. */ 00887 #define MAX_REGS_PER_ADDRESS 1 00888 00889 /* We have pre inc/dec (load/store with update). */ 00890 #define HAVE_PRE_INCREMENT 1 00891 #define HAVE_PRE_DECREMENT 1 00892 00893 /* Recognize any constant value that is a valid address. */ 00894 #define CONSTANT_ADDRESS_P(X) \ 00895 (GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \ 00896 || GET_CODE (X) == CONST_INT || GET_CODE (X) == CONST) 00897 00898 /* Nonzero if the constant value X is a legitimate general operand. 00899 We can handle any 32 or 64 bit constant. */ 00900 /* "1" should work since the largest constant should be a 64 bit critter. */ 00901 /* ??? Not sure what to do for 64x32 compiler. */ 00902 #define LEGITIMATE_CONSTANT_P(X) 1 00903 00904 /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx 00905 and check its validity for a certain class. 00906 We have two alternate definitions for each of them. 00907 The usual definition accepts all pseudo regs; the other rejects 00908 them unless they have been allocated suitable hard regs. 00909 The symbol REG_OK_STRICT causes the latter definition to be used. 00910 00911 Most source files want to accept pseudo regs in the hope that 00912 they will get allocated to the class that the insn wants them to be in. 00913 Source files for reload pass need to be strict. 00914 After reload, it makes no difference, since pseudo regs have 00915 been eliminated by then. */ 00916 00917 #ifndef REG_OK_STRICT 00918 00919 /* Nonzero if X is a hard reg that can be used as an index 00920 or if it is a pseudo reg. */ 00921 #define REG_OK_FOR_INDEX_P(X) \ 00922 ((unsigned) REGNO (X) - 29 >= FIRST_PSEUDO_REGISTER - 29) 00923 /* Nonzero if X is a hard reg that can be used as a base reg 00924 or if it is a pseudo reg. */ 00925 #define REG_OK_FOR_BASE_P(X) \ 00926 ((unsigned) REGNO (X) - 29 >= FIRST_PSEUDO_REGISTER - 29) 00927 00928 #else 00929 00930 /* Nonzero if X is a hard reg that can be used as an index. */ 00931 #define REG_OK_FOR_INDEX_P(X) REGNO_OK_FOR_INDEX_P (REGNO (X)) 00932 /* Nonzero if X is a hard reg that can be used as a base reg. */ 00933 #define REG_OK_FOR_BASE_P(X) REGNO_OK_FOR_BASE_P (REGNO (X)) 00934 00935 #endif 00936 00937 /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression 00938 that is a valid memory address for an instruction. 00939 The MODE argument is the machine mode for the MEM expression 00940 that wants to use this address. */ 00941 /* The `ld' insn allows [reg],[reg+shimm],[reg+limm],[reg+reg],[limm] 00942 but the `st' insn only allows [reg],[reg+shimm],[limm]. 00943 The only thing we can do is only allow the most strict case `st' and hope 00944 other parts optimize out the restrictions for `ld'. */ 00945 00946 /* local to this file */ 00947 #define RTX_OK_FOR_BASE_P(X) \ 00948 (REG_P (X) && REG_OK_FOR_BASE_P (X)) 00949 00950 /* local to this file */ 00951 #define RTX_OK_FOR_INDEX_P(X) \ 00952 (0 && /*???*/ REG_P (X) && REG_OK_FOR_INDEX_P (X)) 00953 00954 /* local to this file */ 00955 /* ??? Loads can handle any constant, stores can only handle small ones. */ 00956 #define RTX_OK_FOR_OFFSET_P(X) \ 00957 (GET_CODE (X) == CONST_INT && SMALL_INT (INTVAL (X))) 00958 00959 #define LEGITIMATE_OFFSET_ADDRESS_P(MODE, X) \ 00960 (GET_CODE (X) == PLUS \ 00961 && RTX_OK_FOR_BASE_P (XEXP (X, 0)) \ 00962 && (RTX_OK_FOR_INDEX_P (XEXP (X, 1)) \ 00963 || RTX_OK_FOR_OFFSET_P (XEXP (X, 1)))) 00964 00965 #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, ADDR) \ 00966 { if (RTX_OK_FOR_BASE_P (X)) \ 00967 goto ADDR; \ 00968 if (LEGITIMATE_OFFSET_ADDRESS_P ((MODE), (X))) \ 00969 goto ADDR; \ 00970 if (GET_CODE (X) == CONST_INT && LARGE_INT (INTVAL (X))) \ 00971 goto ADDR; \ 00972 if (GET_CODE (X) == SYMBOL_REF \ 00973 || GET_CODE (X) == LABEL_REF \ 00974 || GET_CODE (X) == CONST) \ 00975 goto ADDR; \ 00976 if ((GET_CODE (X) == PRE_DEC || GET_CODE (X) == PRE_INC) \ 00977 /* We're restricted here by the `st' insn. */ \ 00978 && RTX_OK_FOR_BASE_P (XEXP ((X), 0))) \ 00979 goto ADDR; \ 00980 } 00981 00982 /* Try machine-dependent ways of modifying an illegitimate address 00983 to be legitimate. If we find one, return the new, valid address. 00984 This macro is used in only one place: `memory_address' in explow.c. 00985 00986 OLDX is the address as it was before break_out_memory_refs was called. 00987 In some cases it is useful to look at this to decide what needs to be done. 00988 00989 MODE and WIN are passed so that this macro can use 00990 GO_IF_LEGITIMATE_ADDRESS. 00991 00992 It is always safe for this macro to do nothing. It exists to recognize 00993 opportunities to optimize the output. */ 00994 00995 #define LEGITIMIZE_ADDRESS(X, OLDX, MODE, WIN) 00996 00997 /* Go to LABEL if ADDR (a legitimate address expression) 00998 has an effect that depends on the machine mode it is used for. */ 00999 #define GO_IF_MODE_DEPENDENT_ADDRESS(ADDR, LABEL) \ 01000 { if (GET_CODE (ADDR) == PRE_DEC) \ 01001 goto LABEL; \ 01002 if (GET_CODE (ADDR) == PRE_INC) \ 01003 goto LABEL; \ 01004 } 01005 01006 /* Condition code usage. */ 01007 01008 /* Some insns set all condition code flags, some only set the ZNC flags, and 01009 some only set the ZN flags. */ 01010 01011 #define EXTRA_CC_MODES \ 01012 CC(CCZNCmode, "CCZNC") \ 01013 CC(CCZNmode, "CCZN") 01014 01015 /* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE, 01016 return the mode to be used for the comparison. */ 01017 #define SELECT_CC_MODE(OP, X, Y) \ 01018 arc_select_cc_mode (OP, X, Y) 01019 01020 /* Return non-zero if SELECT_CC_MODE will never return MODE for a 01021 floating point inequality comparison. */ 01022 #define REVERSIBLE_CC_MODE(MODE) 1 /*???*/ 01023 01024 /* Costs. */ 01025 01026 /* An insn is define to cost 4 "units", and we work from there. 01027 COSTS_N_INSNS (N) is defined as (N) * 4 - 2 so that seems reasonable. 01028 Some values are supposed to be defined relative to each other and thus 01029 aren't necessarily related to COSTS_N_INSNS. */ 01030 01031 /* Compute the cost of computing a constant rtl expression RTX 01032 whose rtx-code is CODE. The body of this macro is a portion 01033 of a switch statement. If the code is computed here, 01034 return it with a return statement. Otherwise, break from the switch. */ 01035 /* Small integers are as cheap as registers. 4 byte values can be fetched 01036 as immediate constants - let's give that the cost of an extra insn. */ 01037 #define CONST_COSTS(X, CODE, OUTER_CODE) \ 01038 case CONST_INT : \ 01039 if (SMALL_INT (INTVAL (X))) \ 01040 return 0; \ 01041 /* fall through */ \ 01042 case CONST : \ 01043 case LABEL_REF : \ 01044 case SYMBOL_REF : \ 01045 return 4; \ 01046 case CONST_DOUBLE : \ 01047 { \ 01048 rtx high, low; \ 01049 split_double (X, &high, &low); \ 01050 return 4 * (!SMALL_INT (INTVAL (high)) \ 01051 + !SMALL_INT (INTVAL (low))); \ 01052 } 01053 01054 /* Compute the cost of an address. */ 01055 #define ADDRESS_COST(ADDR) (REG_P (ADDR) ? 1 : arc_address_cost (ADDR)) 01056 01057 /* Compute extra cost of moving data between one register class 01058 and another. */ 01059 #define REGISTER_MOVE_COST(MODE, CLASS1, CLASS2) 2 01060 01061 /* Compute the cost of moving data between registers and memory. */ 01062 /* Memory is 3 times as expensive as registers. 01063 ??? Is that the right way to look at it? */ 01064 #define MEMORY_MOVE_COST(MODE,CLASS,IN) \ 01065 (GET_MODE_SIZE (MODE) <= UNITS_PER_WORD ? 6 : 12) 01066 01067 /* The cost of a branch insn. */ 01068 /* ??? What's the right value here? Branches are certainly more 01069 expensive than reg->reg moves. */ 01070 #define BRANCH_COST 2 01071 01072 /* Provide the costs of a rtl expression. This is in the body of a 01073 switch on CODE. The purpose for the cost of MULT is to encourage 01074 `synth_mult' to find a synthetic multiply when reasonable. 01075 01076 If we need more than 12 insns to do a multiply, then go out-of-line, 01077 since the call overhead will be < 10% of the cost of the multiply. */ 01078 #define RTX_COSTS(X, CODE, OUTER_CODE) \ 01079 case ASHIFT : \ 01080 case ASHIFTRT : \ 01081 case LSHIFTRT : \ 01082 if (TARGET_SHIFTER) \ 01083 return COSTS_N_INSNS (1); \ 01084 if (GET_CODE (XEXP ((X), 1)) != CONST_INT) \ 01085 return COSTS_N_INSNS (16); \ 01086 return COSTS_N_INSNS (INTVAL (XEXP ((X), 1))); 01087 01088 /* Nonzero if access to memory by bytes is slow and undesirable. 01089 For RISC chips, it means that access to memory by bytes is no 01090 better than access by words when possible, so grab a whole word 01091 and maybe make use of that. */ 01092 #define SLOW_BYTE_ACCESS 1 01093 01094 /* Define this macro if it is as good or better to call a constant 01095 function address than to call an address kept in a register. */ 01096 /* On the ARC, calling through registers is slow. */ 01097 #define NO_FUNCTION_CSE 01098 01099 /* Define this macro if it is as good or better for a function to call 01100 itself with an explicit address than to call an address kept in a 01101 register. */ 01102 /* On the ARC, calling through registers is slow. */ 01103 #define NO_RECURSIVE_FUNCTION_CSE 01104 01105 /* Section selection. */ 01106 /* WARNING: These section names also appear in dwarfout.c. */ 01107 01108 /* The names of the text, data, and readonly-data sections are runtime 01109 selectable. */ 01110 01111 #define ARC_SECTION_FORMAT "\t.section %s" 01112 #define ARC_DEFAULT_TEXT_SECTION ".text" 01113 #define ARC_DEFAULT_DATA_SECTION ".data" 01114 #define ARC_DEFAULT_RODATA_SECTION ".rodata" 01115 01116 extern const char *arc_text_section, *arc_data_section, *arc_rodata_section; 01117 01118 /* initfini.c uses this in an asm. */ 01119 #if defined (CRT_INIT) || defined (CRT_FINI) 01120 #define TEXT_SECTION_ASM_OP "\t.section .text" 01121 #else 01122 #define TEXT_SECTION_ASM_OP arc_text_section /*"\t.section .text"*/ 01123 #endif 01124 #define DATA_SECTION_ASM_OP arc_data_section /*"\t.section .data"*/ 01125 01126 #undef CONST_SECTION_ASM_OP 01127 #define CONST_SECTION_ASM_OP arc_rodata_section /*"\t.section .rodata"*/ 01128 01129 #define BSS_SECTION_ASM_OP "\t.section .bss" 01130 01131 /* Define this macro if jump tables (for tablejump insns) should be 01132 output in the text section, along with the assembler instructions. 01133 Otherwise, the readonly data section is used. 01134 This macro is irrelevant if there is no separate readonly data section. */ 01135 /*#define JUMP_TABLES_IN_TEXT_SECTION*/ 01136 01137 /* Define this macro if references to a symbol must be treated 01138 differently depending on something about the variable or 01139 function named by the symbol (such as what section it is in). 01140 01141 The macro definition, if any, is executed immediately after the 01142 rtl for DECL or other node is created. 01143 The value of the rtl will be a `mem' whose address is a 01144 `symbol_ref'. 01145 01146 The usual thing for this macro to do is to store a flag in the 01147 `symbol_ref' (such as `SYMBOL_REF_FLAG') or to store a modified 01148 name string in the `symbol_ref' (if one bit is not enough 01149 information). */ 01150 01151 /* On the ARC, function addresses are not the same as normal addresses. 01152 Branch to absolute address insns take an address that is right-shifted 01153 by 2. We encode the fact that we have a function here, and then emit a 01154 special assembler op when outputting the address. */ 01155 #define ENCODE_SECTION_INFO(DECL) \ 01156 do { \ 01157 if (TREE_CODE (DECL) == FUNCTION_DECL) \ 01158 SYMBOL_REF_FLAG (XEXP (DECL_RTL (DECL), 0)) = 1; \ 01159 } while (0) 01160 01161 /* Decode SYM_NAME and store the real name part in VAR, sans 01162 the characters that encode section info. Define this macro if 01163 ENCODE_SECTION_INFO alters the symbol's name string. */ 01164 /*#define STRIP_NAME_ENCODING(VAR, SYM_NAME)*/ 01165 01166 /* For DWARF. Marginally different than default so output is "prettier" 01167 (and consistent with above). */ 01168 #define PUSHSECTION_ASM_OP "\t.section " 01169 01170 /* Tell crtstuff.c we're using ELF. */ 01171 #define OBJECT_FORMAT_ELF 01172 01173 /* PIC */ 01174 01175 /* The register number of the register used to address a table of static 01176 data addresses in memory. In some cases this register is defined by a 01177 processor's ``application binary interface'' (ABI). When this macro 01178 is defined, RTL is generated for this register once, as with the stack 01179 pointer and frame pointer registers. If this macro is not defined, it 01180 is up to the machine-dependent files to allocate such a register (if 01181 necessary). */ 01182 #define PIC_OFFSET_TABLE_REGNUM (flag_pic ? 26 : INVALID_REGNUM) 01183 01184 /* Define this macro if the register defined by PIC_OFFSET_TABLE_REGNUM is 01185 clobbered by calls. Do not define this macro if PIC_OFFSET_TABLE_REGNUM 01186 is not defined. */ 01187 /* This register is call-saved on the ARC. */ 01188 /*#define PIC_OFFSET_TABLE_REG_CALL_CLOBBERED*/ 01189 01190 /* By generating position-independent code, when two different programs (A 01191 and B) share a common library (libC.a), the text of the library can be 01192 shared whether or not the library is linked at the same address for both 01193 programs. In some of these environments, position-independent code 01194 requires not only the use of different addressing modes, but also 01195 special code to enable the use of these addressing modes. 01196 01197 The FINALIZE_PIC macro serves as a hook to emit these special 01198 codes once the function is being compiled into assembly code, but not 01199 before. (It is not done before, because in the case of compiling an 01200 inline function, it would lead to multiple PIC prologues being 01201 included in functions which used inline functions and were compiled to 01202 assembly language.) */ 01203 01204 #define FINALIZE_PIC arc_finalize_pic () 01205 01206 /* A C expression that is nonzero if X is a legitimate immediate 01207 operand on the target machine when generating position independent code. 01208 You can assume that X satisfies CONSTANT_P, so you need not 01209 check this. You can also assume `flag_pic' is true, so you need not 01210 check it either. You need not define this macro if all constants 01211 (including SYMBOL_REF) can be immediate operands when generating 01212 position independent code. */ 01213 /*#define LEGITIMATE_PIC_OPERAND_P(X)*/ 01214 01215 /* Control the assembler format that we output. */ 01216 01217 /* Output at beginning of assembler file. */ 01218 #undef ASM_FILE_START 01219 #define ASM_FILE_START(FILE) arc_asm_file_start (FILE) 01220 01221 /* A C string constant describing how to begin a comment in the target 01222 assembler language. The compiler assumes that the comment will 01223 end at the end of the line. */ 01224 #define ASM_COMMENT_START ";" 01225 01226 /* Output to assembler file text saying following lines 01227 may contain character constants, extra white space, comments, etc. */ 01228 #define ASM_APP_ON "" 01229 01230 /* Output to assembler file text saying following lines 01231 no longer contain unusual constructs. */ 01232 #define ASM_APP_OFF "" 01233 01234 /* This is how to output the definition of a user-level label named NAME, 01235 such as the label on a static function or variable NAME. */ 01236 #define ASM_OUTPUT_LABEL(FILE, NAME) \ 01237 do { assemble_name (FILE, NAME); fputs (":\n", FILE); } while (0) 01238 01239 /* This is how to output a command to make the user-level label named NAME 01240 defined for reference from other files. */ 01241 #define ASM_GLOBALIZE_LABEL(FILE, NAME) \ 01242 do { \ 01243 fputs ("\t.global\t", FILE); \ 01244 assemble_name (FILE, NAME); \ 01245 fputs ("\n", FILE); \ 01246 } while (0) 01247 01248 /* A C statement (sans semicolon) to output on FILE an assembler pseudo-op to 01249 declare a library function name external. The name of the library function 01250 is given by SYMREF, which has type RTX and is a SYMBOL_REF. */ 01251 #if 0 01252 /* On the ARC we want to have libgcc's for multiple cpus in one binary. 01253 We can't use `assemble_name' here as that will call ASM_OUTPUT_LABELREF 01254 and we'll get another suffix added on if -mmangle-cpu. */ 01255 extern const char *arc_mangle_cpu; 01256 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, SYMREF) \ 01257 do { \ 01258 if (TARGET_MANGLE_CPU_LIBGCC) \ 01259 { \ 01260 fprintf (FILE, "\t.rename\t_%s, _%s%s\n", \ 01261 XSTR (SYMREF, 0), XSTR (SYMREF, 0), \ 01262 arc_mangle_suffix); \ 01263 } \ 01264 } while (0) 01265 #endif 01266 01267 /* This is how to output a reference to a user-level label named NAME. 01268 `assemble_name' uses this. */ 01269 /* We mangle all user labels to provide protection from linking code 01270 compiled for different cpus. */ 01271 /* We work around a dwarfout.c deficiency by watching for labels from it and 01272 not adding the '_' prefix nor the cpu suffix. There is a comment in 01273 dwarfout.c that says it should be using ASM_OUTPUT_INTERNAL_LABEL. */ 01274 extern const char *arc_mangle_cpu; 01275 #define ASM_OUTPUT_LABELREF(FILE, NAME) \ 01276 do { \ 01277 if ((NAME)[0] == '.' && (NAME)[1] == 'L') \ 01278 fprintf (FILE, "%s", NAME); \ 01279 else \ 01280 { \ 01281 fputc ('_', FILE); \ 01282 if (TARGET_MANGLE_CPU && arc_mangle_cpu != NULL) \ 01283 fprintf (FILE, "%s_", arc_mangle_cpu); \ 01284 fprintf (FILE, "%s", NAME); \ 01285 } \ 01286 } while (0) 01287 01288 /* This is how to output a definition of an internal numbered label where 01289 PREFIX is the class of label and NUM is the number within the class. */ 01290 #undef ASM_OUTPUT_INTERNAL_LABEL 01291 #define ASM_OUTPUT_INTERNAL_LABEL(FILE, PREFIX, NUM) \ 01292 do { \ 01293 arc_ccfsm_at_label (PREFIX, NUM); \ 01294 fprintf (FILE, ".%s%d:\n", PREFIX, NUM); \ 01295 } while (0) 01296 01297 /* Store in OUTPUT a string (made with alloca) containing 01298 an assembler-name for a local static variable named NAME. 01299 LABELNO is an integer which is different for each call. */ 01300 #define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \ 01301 ( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10), \ 01302 sprintf ((OUTPUT), "%s.%d", (NAME), (LABELNO))) 01303 01304 /* Assembler pseudo-op to equate one value with another. */ 01305 /* ??? This is needed because dwarfout.c provides a default definition too 01306 late for defaults.h (which contains the default definition of ASM_OUTPUT_DEF 01307 that we use). */ 01308 #define SET_ASM_OP "\t.set\t" 01309 01310 /* How to refer to registers in assembler output. 01311 This sequence is indexed by compiler's hard-register-number (see above). */ 01312 #define REGISTER_NAMES \ 01313 {"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \ 01314 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \ 01315 "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", \ 01316 "r24", "r25", "r26", "fp", "sp", "ilink1", "ilink2", "blink", \ 01317 "r32", "r33", "r34", "r35", "r36", "r37", "r38", "r39", \ 01318 "r40", "r41", "r42", "r43", "r44", "r45", "r46", "r47", \ 01319 "r48", "r49", "r50", "r51", "r52", "r53", "r54", "r55", \ 01320 "r56", "r57", "r58", "r59", "lp_count", "cc"} 01321 01322 /* Entry to the insn conditionalizer. */ 01323 #define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS) \ 01324 arc_final_prescan_insn (INSN, OPVEC, NOPERANDS) 01325 01326 /* A C expression which evaluates to true if CODE is a valid 01327 punctuation character for use in the `PRINT_OPERAND' macro. */ 01328 extern char arc_punct_chars[256]; 01329 #define PRINT_OPERAND_PUNCT_VALID_P(CHAR) \ 01330 arc_punct_chars[(unsigned char) (CHAR)] 01331 01332 /* Print operand X (an rtx) in assembler syntax to file FILE. 01333 CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified. 01334 For `%' followed by punctuation, CODE is the punctuation and X is null. */ 01335 #define PRINT_OPERAND(FILE, X, CODE) \ 01336 arc_print_operand (FILE, X, CODE) 01337 01338 /* A C compound statement to output to stdio stream STREAM the 01339 assembler syntax for an instruction operand that is a memory 01340 reference whose address is ADDR. ADDR is an RTL expression. 01341 01342 On some machines, the syntax for a symbolic address depends on 01343 the section that the address refers to. On these machines, 01344 define the macro `ENCODE_SECTION_INFO' to store the information 01345 into the `symbol_ref', and then check for it here. */ 01346 #define PRINT_OPERAND_ADDRESS(FILE, ADDR) \ 01347 arc_print_operand_address (FILE, ADDR) 01348 01349 /* This is how to output an element of a case-vector that is absolute. */ 01350 #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \ 01351 do { \ 01352 char label[30]; \ 01353 ASM_GENERATE_INTERNAL_LABEL (label, "L", VALUE); \ 01354 fprintf (FILE, "\t.word %%st("); \ 01355 assemble_name (FILE, label); \ 01356 fprintf (FILE, ")\n"); \ 01357 } while (0) 01358 01359 /* This is how to output an element of a case-vector that is relative. */ 01360 #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \ 01361 do { \ 01362 char label[30]; \ 01363 ASM_GENERATE_INTERNAL_LABEL (label, "L", VALUE); \ 01364 fprintf (FILE, "\t.word %%st("); \ 01365 assemble_name (FILE, label); \ 01366 fprintf (FILE, "-"); \ 01367 ASM_GENERATE_INTERNAL_LABEL (label, "L", REL); \ 01368 assemble_name (FILE, label); \ 01369 fprintf (FILE, ")\n"); \ 01370 } while (0) 01371 01372 /* The desired alignment for the location counter at the beginning 01373 of a loop. */ 01374 /* On the ARC, align loops to 32 byte boundaries (cache line size) 01375 if -malign-loops. */ 01376 #define LOOP_ALIGN(LABEL) (TARGET_ALIGN_LOOPS ? 5 : 0) 01377 01378 /* This is how to output an assembler line 01379 that says to advance the location counter 01380 to a multiple of 2**LOG bytes. */ 01381 #define ASM_OUTPUT_ALIGN(FILE,LOG) \ 01382 do { if ((LOG) != 0) fprintf (FILE, "\t.align %d\n", 1 << (LOG)); } while (0) 01383 01384 /* Debugging information. */ 01385 01386 /* Generate DBX and DWARF debugging information. */ 01387 #ifndef DBX_DEBUGGING_INFO 01388 #define DBX_DEBUGGING_INFO 01389 #endif 01390 #ifndef DWARF_DEBUGGING_INFO 01391 #define DWARF_DEBUGGING_INFO 01392 #endif 01393 01394 /* Prefer STABS (for now). */ 01395 #undef PREFERRED_DEBUGGING_TYPE 01396 #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG 01397 01398 /* Turn off splitting of long stabs. */ 01399 #define DBX_CONTIN_LENGTH 0 01400 01401 /* Miscellaneous. */ 01402 01403 /* Specify the machine mode that this machine uses 01404 for the index in the tablejump instruction. */ 01405 #define CASE_VECTOR_MODE Pmode 01406 01407 /* Define as C expression which evaluates to nonzero if the tablejump 01408 instruction expects the table to contain offsets from the address of the 01409 table. 01410 Do not define this if the table should contain absolute addresses. */ 01411 /* It's not clear what PIC will look like or whether we want to use -fpic 01412 for the embedded form currently being talked about. For now require -fpic 01413 to get pc relative switch tables. */ 01414 /*#define CASE_VECTOR_PC_RELATIVE 1 */ 01415 01416 /* Define if operations between registers always perform the operation 01417 on the full register even if a narrower mode is specified. */ 01418 #define WORD_REGISTER_OPERATIONS 01419 01420 /* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD 01421 will either zero-extend or sign-extend. The value of this macro should 01422 be the code that says which one of the two operations is implicitly 01423 done, NIL if none. */ 01424 #define LOAD_EXTEND_OP(MODE) ZERO_EXTEND 01425 01426 /* Max number of bytes we can move from memory to memory 01427 in one reasonably fast instruction. */ 01428 #define MOVE_MAX 4 01429 01430 /* Define this to be nonzero if shift instructions ignore all but the low-order 01431 few bits. */ 01432 #define SHIFT_COUNT_TRUNCATED 1 01433 01434 /* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits 01435 is done just by pretending it is already truncated. */ 01436 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1 01437 01438 /* We assume that the store-condition-codes instructions store 0 for false 01439 and some other value for true. This is the value stored for true. */ 01440 #define STORE_FLAG_VALUE 1 01441 01442 /* Specify the machine mode that pointers have. 01443 After generation of rtl, the compiler makes no further distinction 01444 between pointers and any other objects of this machine mode. */ 01445 /* ??? The arc doesn't have full 32 bit pointers, but making this PSImode has 01446 its own problems (you have to add extendpsisi2 and trucnsipsi2 but how does 01447 one do it without getting excess code?). Try to avoid it. */ 01448 #define Pmode SImode 01449 01450 /* A function address in a call instruction. */ 01451 #define FUNCTION_MODE SImode 01452 01453 /* alloca should avoid clobbering the old register save area. */ 01454 /* ??? Not defined in tm.texi. */ 01455 #define SETJMP_VIA_SAVE_AREA 01456 01457 /* Define the information needed to generate branch and scc insns. This is 01458 stored from the compare operation. Note that we can't use "rtx" here 01459 since it hasn't been defined! */ 01460 extern struct rtx_def *arc_compare_op0, *arc_compare_op1; 01461 01462 /* ARC function types. */ 01463 enum arc_function_type { 01464 ARC_FUNCTION_UNKNOWN, ARC_FUNCTION_NORMAL, 01465 /* These are interrupt handlers. The name corresponds to the register 01466 name that contains the return address. */ 01467 ARC_FUNCTION_ILINK1, ARC_FUNCTION_ILINK2 01468 }; 01469 #define ARC_INTERRUPT_P(TYPE) \ 01470 ((TYPE) == ARC_FUNCTION_ILINK1 || (TYPE) == ARC_FUNCTION_ILINK2) 01471 /* Compute the type of a function from its DECL. */ 01472 01473 01474 /* Implement `va_start' for varargs and stdarg. */ 01475 #define EXPAND_BUILTIN_VA_START(stdarg, valist, nextarg) \ 01476 arc_va_start (stdarg, valist, nextarg) 01477 01478 /* Implement `va_arg'. */ 01479 #define EXPAND_BUILTIN_VA_ARG(valist, type) \ 01480 arc_va_arg (valist, type)
1.5.6