mcore.h 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840
  1. /* Definitions of target machine for GNU compiler,
  2. for Motorola M*CORE Processor.
  3. Copyright (C) 1993-2015 Free Software Foundation, Inc.
  4. This file is part of GCC.
  5. GCC is free software; you can redistribute it and/or modify it
  6. under the terms of the GNU General Public License as published
  7. by the Free Software Foundation; either version 3, or (at your
  8. option) any later version.
  9. GCC is distributed in the hope that it will be useful, but WITHOUT
  10. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  11. or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  12. License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with GCC; see the file COPYING3. If not see
  15. <http://www.gnu.org/licenses/>. */
  16. #ifndef GCC_MCORE_H
  17. #define GCC_MCORE_H
  18. /* RBE: need to move these elsewhere. */
  19. #undef LIKE_PPC_ABI
  20. #define MCORE_STRUCT_ARGS
  21. /* RBE: end of "move elsewhere". */
  22. /* Run-time Target Specification. */
  23. #define TARGET_MCORE
  24. /* Get tree.c to declare a target-specific specialization of
  25. merge_decl_attributes. */
  26. #define TARGET_DLLIMPORT_DECL_ATTRIBUTES 1
  27. #define TARGET_CPU_CPP_BUILTINS() \
  28. do \
  29. { \
  30. builtin_define ("__mcore__"); \
  31. builtin_define ("__MCORE__"); \
  32. if (TARGET_LITTLE_END) \
  33. builtin_define ("__MCORELE__"); \
  34. else \
  35. builtin_define ("__MCOREBE__"); \
  36. if (TARGET_M340) \
  37. builtin_define ("__M340__"); \
  38. else \
  39. builtin_define ("__M210__"); \
  40. } \
  41. while (0)
  42. #undef CPP_SPEC
  43. #define CPP_SPEC "%{m210:%{mlittle-endian:%ethe m210 does not have little endian support}}"
  44. /* We don't have a -lg library, so don't put it in the list. */
  45. #undef LIB_SPEC
  46. #define LIB_SPEC "%{!shared: %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}}"
  47. #undef ASM_SPEC
  48. #define ASM_SPEC "%{mbig-endian:-EB} %{m210:-cpu=210 -EB}"
  49. #undef LINK_SPEC
  50. #define LINK_SPEC "%{mbig-endian:-EB} %{m210:-EB} -X"
  51. #define TARGET_DEFAULT \
  52. (MASK_HARDLIT \
  53. | MASK_DIV \
  54. | MASK_RELAX_IMM \
  55. | MASK_M340 \
  56. | MASK_LITTLE_END)
  57. #ifndef MULTILIB_DEFAULTS
  58. #define MULTILIB_DEFAULTS { "mlittle-endian", "m340" }
  59. #endif
  60. /* The ability to have 4 byte alignment is being suppressed for now.
  61. If this ability is reenabled, you must disable the definition below
  62. *and* edit t-mcore to enable multilibs for 4 byte alignment code. */
  63. #undef TARGET_8ALIGN
  64. #define TARGET_8ALIGN 1
  65. extern char * mcore_current_function_name;
  66. /* The MCore ABI says that bitfields are unsigned by default. */
  67. #define CC1_SPEC "-funsigned-bitfields"
  68. /* Target machine storage Layout. */
  69. #define PROMOTE_MODE(MODE,UNSIGNEDP,TYPE) \
  70. if (GET_MODE_CLASS (MODE) == MODE_INT \
  71. && GET_MODE_SIZE (MODE) < UNITS_PER_WORD) \
  72. { \
  73. (MODE) = SImode; \
  74. (UNSIGNEDP) = 1; \
  75. }
  76. /* Define this if most significant bit is lowest numbered
  77. in instructions that operate on numbered bit-fields. */
  78. #define BITS_BIG_ENDIAN 0
  79. /* Define this if most significant byte of a word is the lowest numbered. */
  80. #define BYTES_BIG_ENDIAN (! TARGET_LITTLE_END)
  81. /* Define this if most significant word of a multiword number is the lowest
  82. numbered. */
  83. #define WORDS_BIG_ENDIAN (! TARGET_LITTLE_END)
  84. #define MAX_BITS_PER_WORD 32
  85. /* Width of a word, in units (bytes). */
  86. #define UNITS_PER_WORD 4
  87. /* A C expression for the size in bits of the type `long long' on the
  88. target machine. If you don't define this, the default is two
  89. words. */
  90. #define LONG_LONG_TYPE_SIZE 64
  91. /* Allocation boundary (in *bits*) for storing arguments in argument list. */
  92. #define PARM_BOUNDARY 32
  93. /* Boundary (in *bits*) on which stack pointer should be aligned. */
  94. #define STACK_BOUNDARY (TARGET_8ALIGN ? 64 : 32)
  95. /* Largest increment in UNITS we allow the stack to grow in a single operation. */
  96. #define STACK_UNITS_MAXSTEP 4096
  97. /* Allocation boundary (in *bits*) for the code of a function. */
  98. #define FUNCTION_BOUNDARY ((TARGET_OVERALIGN_FUNC) ? 32 : 16)
  99. /* Alignment of field after `int : 0' in a structure. */
  100. #define EMPTY_FIELD_BOUNDARY 32
  101. /* No data type wants to be aligned rounder than this. */
  102. #define BIGGEST_ALIGNMENT (TARGET_8ALIGN ? 64 : 32)
  103. /* The best alignment to use in cases where we have a choice. */
  104. #define FASTEST_ALIGNMENT 32
  105. /* Every structures size must be a multiple of 8 bits. */
  106. #define STRUCTURE_SIZE_BOUNDARY 8
  107. /* Look at the fundamental type that is used for a bit-field and use
  108. that to impose alignment on the enclosing structure.
  109. struct s {int a:8}; should have same alignment as "int", not "char". */
  110. #define PCC_BITFIELD_TYPE_MATTERS 1
  111. /* Largest integer machine mode for structures. If undefined, the default
  112. is GET_MODE_SIZE(DImode). */
  113. #define MAX_FIXED_MODE_SIZE 32
  114. /* Make strings word-aligned so strcpy from constants will be faster. */
  115. #define CONSTANT_ALIGNMENT(EXP, ALIGN) \
  116. ((TREE_CODE (EXP) == STRING_CST \
  117. && (ALIGN) < FASTEST_ALIGNMENT) \
  118. ? FASTEST_ALIGNMENT : (ALIGN))
  119. /* Make arrays of chars word-aligned for the same reasons. */
  120. #define DATA_ALIGNMENT(TYPE, ALIGN) \
  121. (TREE_CODE (TYPE) == ARRAY_TYPE \
  122. && TYPE_MODE (TREE_TYPE (TYPE)) == QImode \
  123. && (ALIGN) < FASTEST_ALIGNMENT ? FASTEST_ALIGNMENT : (ALIGN))
  124. /* Set this nonzero if move instructions will actually fail to work
  125. when given unaligned data. */
  126. #define STRICT_ALIGNMENT 1
  127. /* Standard register usage. */
  128. /* Register allocation for our first guess
  129. r0 stack pointer
  130. r1 scratch, target reg for xtrb?
  131. r2-r7 arguments.
  132. r8-r14 call saved
  133. r15 link register
  134. ap arg pointer (doesn't really exist, always eliminated)
  135. c c bit
  136. fp frame pointer (doesn't really exist, always eliminated)
  137. x19 two control registers. */
  138. /* Number of actual hardware registers.
  139. The hardware registers are assigned numbers for the compiler
  140. from 0 to just below FIRST_PSEUDO_REGISTER.
  141. All registers that the compiler knows about must be given numbers,
  142. even those that are not normally considered general registers.
  143. MCore has 16 integer registers and 2 control registers + the arg
  144. pointer. */
  145. #define FIRST_PSEUDO_REGISTER 20
  146. #define R1_REG 1 /* Where literals are forced. */
  147. #define LK_REG 15 /* Overloaded on general register. */
  148. #define AP_REG 16 /* Fake arg pointer register. */
  149. /* RBE: mcore.md depends on CC_REG being set to 17. */
  150. #define CC_REG 17 /* Can't name it C_REG. */
  151. #define FP_REG 18 /* Fake frame pointer register. */
  152. /* Specify the registers used for certain standard purposes.
  153. The values of these macros are register numbers. */
  154. #undef PC_REGNUM /* Define this if the program counter is overloaded on a register. */
  155. #define STACK_POINTER_REGNUM 0 /* Register to use for pushing function arguments. */
  156. #define FRAME_POINTER_REGNUM 8 /* When we need FP, use r8. */
  157. /* The assembler's names for the registers. RFP need not always be used as
  158. the Real framepointer; it can also be used as a normal general register.
  159. Note that the name `fp' is horribly misleading since `fp' is in fact only
  160. the argument-and-return-context pointer. */
  161. #define REGISTER_NAMES \
  162. { \
  163. "sp", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
  164. "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \
  165. "apvirtual", "c", "fpvirtual", "x19" \
  166. }
  167. /* 1 for registers that have pervasive standard uses
  168. and are not available for the register allocator. */
  169. #define FIXED_REGISTERS \
  170. /* r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r13 r14 r15 ap c fp x19 */ \
  171. { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1}
  172. /* 1 for registers not available across function calls.
  173. These must include the FIXED_REGISTERS and also any
  174. registers that can be used without being saved.
  175. The latter must include the registers where values are returned
  176. and the register where structure-value addresses are passed.
  177. Aside from that, you can include as many other registers as you like. */
  178. /* RBE: r15 {link register} not available across calls,
  179. But we don't mark it that way here.... */
  180. #define CALL_USED_REGISTERS \
  181. /* r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r13 r14 r15 ap c fp x19 */ \
  182. { 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1}
  183. /* The order in which register should be allocated. */
  184. #define REG_ALLOC_ORDER \
  185. /* r7 r6 r5 r4 r3 r2 r15 r14 r13 r12 r11 r10 r9 r8 r1 r0 ap c fp x19*/ \
  186. { 7, 6, 5, 4, 3, 2, 15, 14, 13, 12, 11, 10, 9, 8, 1, 0, 16, 17, 18, 19}
  187. /* Return number of consecutive hard regs needed starting at reg REGNO
  188. to hold something of mode MODE.
  189. This is ordinarily the length in words of a value of mode MODE
  190. but can be less for certain modes in special long registers.
  191. On the MCore regs are UNITS_PER_WORD bits wide; */
  192. #define HARD_REGNO_NREGS(REGNO, MODE) \
  193. (((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
  194. /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE.
  195. We may keep double values in even registers. */
  196. #define HARD_REGNO_MODE_OK(REGNO, MODE) \
  197. ((TARGET_8ALIGN && GET_MODE_SIZE (MODE) > UNITS_PER_WORD) ? (((REGNO) & 1) == 0) : (REGNO < 18))
  198. /* Value is 1 if it is a good idea to tie two pseudo registers
  199. when one has mode MODE1 and one has mode MODE2.
  200. If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
  201. for any hard reg, then this must be 0 for correct output. */
  202. #define MODES_TIEABLE_P(MODE1, MODE2) \
  203. ((MODE1) == (MODE2) || GET_MODE_CLASS (MODE1) == GET_MODE_CLASS (MODE2))
  204. /* Definitions for register eliminations.
  205. We have two registers that can be eliminated on the MCore. First, the
  206. frame pointer register can often be eliminated in favor of the stack
  207. pointer register. Secondly, the argument pointer register can always be
  208. eliminated; it is replaced with either the stack or frame pointer. */
  209. /* Base register for access to arguments of the function. */
  210. #define ARG_POINTER_REGNUM 16
  211. /* Register in which the static-chain is passed to a function. */
  212. #define STATIC_CHAIN_REGNUM 1
  213. /* This is an array of structures. Each structure initializes one pair
  214. of eliminable registers. The "from" register number is given first,
  215. followed by "to". Eliminations of the same "from" register are listed
  216. in order of preference. */
  217. #define ELIMINABLE_REGS \
  218. {{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
  219. { ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
  220. { ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM},}
  221. /* Define the offset between two registers, one to be eliminated, and the other
  222. its replacement, at the start of a routine. */
  223. #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
  224. OFFSET = mcore_initial_elimination_offset (FROM, TO)
  225. /* Define the classes of registers for register constraints in the
  226. machine description. Also define ranges of constants.
  227. One of the classes must always be named ALL_REGS and include all hard regs.
  228. If there is more than one class, another class must be named NO_REGS
  229. and contain no registers.
  230. The name GENERAL_REGS must be the name of a class (or an alias for
  231. another name such as ALL_REGS). This is the class of registers
  232. that is allowed by "g" or "r" in a register constraint.
  233. Also, registers outside this class are allocated only when
  234. instructions express preferences for them.
  235. The classes must be numbered in nondecreasing order; that is,
  236. a larger-numbered class must never be contained completely
  237. in a smaller-numbered class.
  238. For any two classes, it is very desirable that there be another
  239. class that represents their union. */
  240. /* The MCore has only general registers. There are
  241. also some special purpose registers: the T bit register, the
  242. procedure Link and the Count Registers. */
  243. enum reg_class
  244. {
  245. NO_REGS,
  246. ONLYR1_REGS,
  247. LRW_REGS,
  248. GENERAL_REGS,
  249. C_REGS,
  250. ALL_REGS,
  251. LIM_REG_CLASSES
  252. };
  253. #define N_REG_CLASSES (int) LIM_REG_CLASSES
  254. /* Give names of register classes as strings for dump file. */
  255. #define REG_CLASS_NAMES \
  256. { \
  257. "NO_REGS", \
  258. "ONLYR1_REGS", \
  259. "LRW_REGS", \
  260. "GENERAL_REGS", \
  261. "C_REGS", \
  262. "ALL_REGS", \
  263. }
  264. /* Define which registers fit in which classes.
  265. This is an initializer for a vector of HARD_REG_SET
  266. of length N_REG_CLASSES. */
  267. /* ??? STACK_POINTER_REGNUM should be excluded from LRW_REGS. */
  268. #define REG_CLASS_CONTENTS \
  269. { \
  270. {0x000000}, /* NO_REGS */ \
  271. {0x000002}, /* ONLYR1_REGS */ \
  272. {0x007FFE}, /* LRW_REGS */ \
  273. {0x01FFFF}, /* GENERAL_REGS */ \
  274. {0x020000}, /* C_REGS */ \
  275. {0x0FFFFF} /* ALL_REGS */ \
  276. }
  277. /* The same information, inverted:
  278. Return the class number of the smallest class containing
  279. reg number REGNO. This could be a conditional expression
  280. or could index an array. */
  281. extern const enum reg_class regno_reg_class[FIRST_PSEUDO_REGISTER];
  282. #define REGNO_REG_CLASS(REGNO) ((REGNO) < FIRST_PSEUDO_REGISTER ? regno_reg_class[REGNO] : NO_REGS)
  283. /* When this hook returns true for MODE, the compiler allows
  284. registers explicitly used in the rtl to be used as spill registers
  285. but prevents the compiler from extending the lifetime of these
  286. registers. */
  287. #define TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P hook_bool_mode_true
  288. /* The class value for index registers, and the one for base regs. */
  289. #define INDEX_REG_CLASS NO_REGS
  290. #define BASE_REG_CLASS GENERAL_REGS
  291. /* Convenience wrappers around insn_const_int_ok_for_constraint. */
  292. #define CONST_OK_FOR_I(VALUE) \
  293. insn_const_int_ok_for_constraint (VALUE, CONSTRAINT_I)
  294. #define CONST_OK_FOR_J(VALUE) \
  295. insn_const_int_ok_for_constraint (VALUE, CONSTRAINT_J)
  296. #define CONST_OK_FOR_L(VALUE) \
  297. insn_const_int_ok_for_constraint (VALUE, CONSTRAINT_L)
  298. #define CONST_OK_FOR_K(VALUE) \
  299. insn_const_int_ok_for_constraint (VALUE, CONSTRAINT_K)
  300. #define CONST_OK_FOR_M(VALUE) \
  301. insn_const_int_ok_for_constraint (VALUE, CONSTRAINT_M)
  302. #define CONST_OK_FOR_N(VALUE) \
  303. insn_const_int_ok_for_constraint (VALUE, CONSTRAINT_N)
  304. #define CONST_OK_FOR_O(VALUE) \
  305. insn_const_int_ok_for_constraint (VALUE, CONSTRAINT_O)
  306. #define CONST_OK_FOR_P(VALUE) \
  307. insn_const_int_ok_for_constraint (VALUE, CONSTRAINT_P)
  308. /* Given an rtx X being reloaded into a reg required to be
  309. in class CLASS, return the class of reg to actually use.
  310. In general this is just CLASS; but on some machines
  311. in some cases it is preferable to use a more restrictive class. */
  312. #define PREFERRED_RELOAD_CLASS(X, CLASS) mcore_reload_class (X, CLASS)
  313. /* Return the register class of a scratch register needed to copy IN into
  314. or out of a register in CLASS in MODE. If it can be done directly,
  315. NO_REGS is returned. */
  316. #define SECONDARY_RELOAD_CLASS(CLASS, MODE, X) \
  317. mcore_secondary_reload_class (CLASS, MODE, X)
  318. /* Return the maximum number of consecutive registers
  319. needed to represent mode MODE in a register of class CLASS.
  320. On MCore this is the size of MODE in words. */
  321. #define CLASS_MAX_NREGS(CLASS, MODE) \
  322. (ROUND_ADVANCE (GET_MODE_SIZE (MODE)))
  323. /* Stack layout; function entry, exit and calling. */
  324. /* Define the number of register that can hold parameters.
  325. These two macros are used only in other macro definitions below. */
  326. #define NPARM_REGS 6
  327. #define FIRST_PARM_REG 2
  328. #define FIRST_RET_REG 2
  329. /* Define this if pushing a word on the stack
  330. makes the stack pointer a smaller address. */
  331. #define STACK_GROWS_DOWNWARD
  332. /* Offset within stack frame to start allocating local variables at.
  333. If FRAME_GROWS_DOWNWARD, this is the offset to the END of the
  334. first local allocated. Otherwise, it is the offset to the BEGINNING
  335. of the first local allocated. */
  336. #define STARTING_FRAME_OFFSET 0
  337. /* If defined, the maximum amount of space required for outgoing arguments
  338. will be computed and placed into the variable
  339. `crtl->outgoing_args_size'. No space will be pushed
  340. onto the stack for each call; instead, the function prologue should
  341. increase the stack frame size by this amount. */
  342. #define ACCUMULATE_OUTGOING_ARGS 1
  343. /* Offset of first parameter from the argument pointer register value. */
  344. #define FIRST_PARM_OFFSET(FNDECL) 0
  345. /* Define how to find the value returned by a function.
  346. VALTYPE is the data type of the value (as a tree).
  347. If the precise function being called is known, FUNC is its FUNCTION_DECL;
  348. otherwise, FUNC is 0. */
  349. #define FUNCTION_VALUE(VALTYPE, FUNC) mcore_function_value (VALTYPE, FUNC)
  350. /* Don't default to pcc-struct-return, because gcc is the only compiler, and
  351. we want to retain compatibility with older gcc versions. */
  352. #define DEFAULT_PCC_STRUCT_RETURN 0
  353. /* Define how to find the value returned by a library function
  354. assuming the value has mode MODE. */
  355. #define LIBCALL_VALUE(MODE) gen_rtx_REG (MODE, FIRST_RET_REG)
  356. /* 1 if N is a possible register number for a function value.
  357. On the MCore, only r4 can return results. */
  358. #define FUNCTION_VALUE_REGNO_P(REGNO) ((REGNO) == FIRST_RET_REG)
  359. /* 1 if N is a possible register number for function argument passing. */
  360. #define FUNCTION_ARG_REGNO_P(REGNO) \
  361. ((REGNO) >= FIRST_PARM_REG && (REGNO) < (NPARM_REGS + FIRST_PARM_REG))
  362. /* Define a data type for recording info about an argument list
  363. during the scan of that argument list. This data type should
  364. hold all necessary information about the function itself
  365. and about the args processed so far, enough to enable macros
  366. such as FUNCTION_ARG to determine where the next arg should go.
  367. On MCore, this is a single integer, which is a number of words
  368. of arguments scanned so far (including the invisible argument,
  369. if any, which holds the structure-value-address).
  370. Thus NARGREGS or more means all following args should go on the stack. */
  371. #define CUMULATIVE_ARGS int
  372. #define ROUND_ADVANCE(SIZE) \
  373. ((SIZE + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
  374. /* Round a register number up to a proper boundary for an arg of mode
  375. MODE.
  376. We round to an even reg for things larger than a word. */
  377. #define ROUND_REG(X, MODE) \
  378. ((TARGET_8ALIGN \
  379. && GET_MODE_UNIT_SIZE ((MODE)) > UNITS_PER_WORD) \
  380. ? ((X) + ((X) & 1)) : (X))
  381. /* Initialize a variable CUM of type CUMULATIVE_ARGS
  382. for a call to a function whose data type is FNTYPE.
  383. For a library call, FNTYPE is 0.
  384. On MCore, the offset always starts at 0: the first parm reg is always
  385. the same reg. */
  386. #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT, N_NAMED_ARGS) \
  387. ((CUM) = 0)
  388. /* Call the function profiler with a given profile label. */
  389. #define FUNCTION_PROFILER(STREAM,LABELNO) \
  390. { \
  391. fprintf (STREAM, " trap 1\n"); \
  392. fprintf (STREAM, " .align 2\n"); \
  393. fprintf (STREAM, " .long LP%d\n", (LABELNO)); \
  394. }
  395. /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
  396. the stack pointer does not matter. The value is tested only in
  397. functions that have frame pointers.
  398. No definition is equivalent to always zero. */
  399. #define EXIT_IGNORE_STACK 0
  400. /* Length in units of the trampoline for entering a nested function. */
  401. #define TRAMPOLINE_SIZE 12
  402. /* Alignment required for a trampoline in bits. */
  403. #define TRAMPOLINE_ALIGNMENT 32
  404. /* Macros to check register numbers against specific register classes. */
  405. /* These assume that REGNO is a hard or pseudo reg number.
  406. They give nonzero only if REGNO is a hard reg of the suitable class
  407. or a pseudo reg currently allocated to a suitable hard reg.
  408. Since they use reg_renumber, they are safe only once reg_renumber
  409. has been allocated, which happens in reginfo.c during register
  410. allocation. */
  411. #define REGNO_OK_FOR_BASE_P(REGNO) \
  412. ((REGNO) < AP_REG || (unsigned) reg_renumber[(REGNO)] < AP_REG)
  413. #define REGNO_OK_FOR_INDEX_P(REGNO) 0
  414. /* Maximum number of registers that can appear in a valid memory
  415. address. */
  416. #define MAX_REGS_PER_ADDRESS 1
  417. /* Recognize any constant value that is a valid address. */
  418. #define CONSTANT_ADDRESS_P(X) (GET_CODE (X) == LABEL_REF)
  419. /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
  420. and check its validity for a certain class.
  421. We have two alternate definitions for each of them.
  422. The usual definition accepts all pseudo regs; the other rejects
  423. them unless they have been allocated suitable hard regs.
  424. The symbol REG_OK_STRICT causes the latter definition to be used. */
  425. #ifndef REG_OK_STRICT
  426. /* Nonzero if X is a hard reg that can be used as a base reg
  427. or if it is a pseudo reg. */
  428. #define REG_OK_FOR_BASE_P(X) \
  429. (REGNO (X) <= 16 || REGNO (X) >= FIRST_PSEUDO_REGISTER)
  430. /* Nonzero if X is a hard reg that can be used as an index
  431. or if it is a pseudo reg. */
  432. #define REG_OK_FOR_INDEX_P(X) 0
  433. #else
  434. /* Nonzero if X is a hard reg that can be used as a base reg. */
  435. #define REG_OK_FOR_BASE_P(X) \
  436. REGNO_OK_FOR_BASE_P (REGNO (X))
  437. /* Nonzero if X is a hard reg that can be used as an index. */
  438. #define REG_OK_FOR_INDEX_P(X) 0
  439. #endif
  440. /* GO_IF_LEGITIMATE_ADDRESS recognizes an RTL expression
  441. that is a valid memory address for an instruction.
  442. The MODE argument is the machine mode for the MEM expression
  443. that wants to use this address.
  444. The other macros defined here are used only in GO_IF_LEGITIMATE_ADDRESS. */
  445. #define BASE_REGISTER_RTX_P(X) \
  446. (GET_CODE (X) == REG && REG_OK_FOR_BASE_P (X))
  447. #define INDEX_REGISTER_RTX_P(X) \
  448. (GET_CODE (X) == REG && REG_OK_FOR_INDEX_P (X))
  449. /* Jump to LABEL if X is a valid address RTX. This must also take
  450. REG_OK_STRICT into account when deciding about valid registers, but it uses
  451. the above macros so we are in luck.
  452. Allow REG
  453. REG+disp
  454. A legitimate index for a QI is 0..15, for HI is 0..30, for SI is 0..60,
  455. and for DI is 0..56 because we use two SI loads, etc. */
  456. #define GO_IF_LEGITIMATE_INDEX(MODE, REGNO, OP, LABEL) \
  457. do \
  458. { \
  459. if (GET_CODE (OP) == CONST_INT) \
  460. { \
  461. if (GET_MODE_SIZE (MODE) >= 4 \
  462. && (((unsigned HOST_WIDE_INT) INTVAL (OP)) % 4) == 0 \
  463. && ((unsigned HOST_WIDE_INT) INTVAL (OP)) \
  464. <= (unsigned HOST_WIDE_INT) 64 - GET_MODE_SIZE (MODE)) \
  465. goto LABEL; \
  466. if (GET_MODE_SIZE (MODE) == 2 \
  467. && (((unsigned HOST_WIDE_INT) INTVAL (OP)) % 2) == 0 \
  468. && ((unsigned HOST_WIDE_INT) INTVAL (OP)) <= 30) \
  469. goto LABEL; \
  470. if (GET_MODE_SIZE (MODE) == 1 \
  471. && ((unsigned HOST_WIDE_INT) INTVAL (OP)) <= 15) \
  472. goto LABEL; \
  473. } \
  474. } \
  475. while (0)
  476. #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, LABEL) \
  477. { \
  478. if (BASE_REGISTER_RTX_P (X)) \
  479. goto LABEL; \
  480. else if (GET_CODE (X) == PLUS || GET_CODE (X) == LO_SUM) \
  481. { \
  482. rtx xop0 = XEXP (X,0); \
  483. rtx xop1 = XEXP (X,1); \
  484. if (BASE_REGISTER_RTX_P (xop0)) \
  485. GO_IF_LEGITIMATE_INDEX (MODE, REGNO (xop0), xop1, LABEL); \
  486. if (BASE_REGISTER_RTX_P (xop1)) \
  487. GO_IF_LEGITIMATE_INDEX (MODE, REGNO (xop1), xop0, LABEL); \
  488. } \
  489. }
  490. /* Specify the machine mode that this machine uses
  491. for the index in the tablejump instruction. */
  492. #define CASE_VECTOR_MODE SImode
  493. /* 'char' is signed by default. */
  494. #define DEFAULT_SIGNED_CHAR 0
  495. #undef SIZE_TYPE
  496. #define SIZE_TYPE "unsigned int"
  497. #undef PTRDIFF_TYPE
  498. #define PTRDIFF_TYPE "int"
  499. #undef WCHAR_TYPE
  500. #define WCHAR_TYPE "long int"
  501. #undef WCHAR_TYPE_SIZE
  502. #define WCHAR_TYPE_SIZE BITS_PER_WORD
  503. /* Max number of bytes we can move from memory to memory
  504. in one reasonably fast instruction. */
  505. #define MOVE_MAX 4
  506. /* Define if operations between registers always perform the operation
  507. on the full register even if a narrower mode is specified. */
  508. #define WORD_REGISTER_OPERATIONS
  509. /* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD
  510. will either zero-extend or sign-extend. The value of this macro should
  511. be the code that says which one of the two operations is implicitly
  512. done, UNKNOWN if none. */
  513. #define LOAD_EXTEND_OP(MODE) ZERO_EXTEND
  514. /* Nonzero if access to memory by bytes is slow and undesirable. */
  515. #define SLOW_BYTE_ACCESS TARGET_SLOW_BYTES
  516. /* Shift counts are truncated to 6-bits (0 to 63) instead of the expected
  517. 5-bits, so we can not define SHIFT_COUNT_TRUNCATED to true for this
  518. target. */
  519. #define SHIFT_COUNT_TRUNCATED 0
  520. /* All integers have the same format so truncation is easy. */
  521. #define TRULY_NOOP_TRUNCATION(OUTPREC,INPREC) 1
  522. /* Define this if addresses of constant functions
  523. shouldn't be put through pseudo regs where they can be cse'd.
  524. Desirable on machines where ordinary constants are expensive
  525. but a CALL with constant address is cheap. */
  526. /* Why is this defined??? -- dac */
  527. #define NO_FUNCTION_CSE 1
  528. /* The machine modes of pointers and functions. */
  529. #define Pmode SImode
  530. #define FUNCTION_MODE Pmode
  531. /* Compute extra cost of moving data between one register class
  532. and another. All register moves are cheap. */
  533. #define REGISTER_MOVE_COST(MODE, SRCCLASS, DSTCLASS) 2
  534. #define WORD_REGISTER_OPERATIONS
  535. /* Assembler output control. */
  536. #define ASM_COMMENT_START "\t//"
  537. #define ASM_APP_ON "// inline asm begin\n"
  538. #define ASM_APP_OFF "// inline asm end\n"
  539. #define FILE_ASM_OP "\t.file\n"
  540. /* Switch to the text or data segment. */
  541. #define TEXT_SECTION_ASM_OP "\t.text"
  542. #define DATA_SECTION_ASM_OP "\t.data"
  543. /* Switch into a generic section. */
  544. #undef TARGET_ASM_NAMED_SECTION
  545. #define TARGET_ASM_NAMED_SECTION mcore_asm_named_section
  546. #define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (SImode, LK_REG)
  547. /* This is how to output an insn to push a register on the stack.
  548. It need not be very fast code. */
  549. #define ASM_OUTPUT_REG_PUSH(FILE,REGNO) \
  550. fprintf (FILE, "\tsubi\t %s,%d\n\tstw\t %s,(%s)\n", \
  551. reg_names[STACK_POINTER_REGNUM], \
  552. (STACK_BOUNDARY / BITS_PER_UNIT), \
  553. reg_names[REGNO], \
  554. reg_names[STACK_POINTER_REGNUM])
  555. /* Length in instructions of the code output by ASM_OUTPUT_REG_PUSH. */
  556. #define REG_PUSH_LENGTH 2
  557. /* This is how to output an insn to pop a register from the stack. */
  558. #define ASM_OUTPUT_REG_POP(FILE,REGNO) \
  559. fprintf (FILE, "\tldw\t %s,(%s)\n\taddi\t %s,%d\n", \
  560. reg_names[REGNO], \
  561. reg_names[STACK_POINTER_REGNUM], \
  562. reg_names[STACK_POINTER_REGNUM], \
  563. (STACK_BOUNDARY / BITS_PER_UNIT))
  564. /* Output a reference to a label. */
  565. #undef ASM_OUTPUT_LABELREF
  566. #define ASM_OUTPUT_LABELREF(STREAM, NAME) \
  567. fprintf (STREAM, "%s%s", USER_LABEL_PREFIX, \
  568. (* targetm.strip_name_encoding) (NAME))
  569. /* This is how to output an assembler line
  570. that says to advance the location counter
  571. to a multiple of 2**LOG bytes. */
  572. #define ASM_OUTPUT_ALIGN(FILE,LOG) \
  573. if ((LOG) != 0) \
  574. fprintf (FILE, "\t.align\t%d\n", LOG)
  575. #ifndef ASM_DECLARE_RESULT
  576. #define ASM_DECLARE_RESULT(FILE, RESULT)
  577. #endif
  578. #define MULTIPLE_SYMBOL_SPACES 1
  579. #define SUPPORTS_ONE_ONLY 1
  580. /* A pair of macros to output things for the callgraph data.
  581. VALUE means (to the tools that reads this info later):
  582. 0 a call from src to dst
  583. 1 the call is special (e.g. dst is "unknown" or "alloca")
  584. 2 the call is special (e.g., the src is a table instead of routine)
  585. Frame sizes are augmented with timestamps to help later tools
  586. differentiate between static entities with same names in different
  587. files. */
  588. extern long mcore_current_compilation_timestamp;
  589. #define ASM_OUTPUT_CG_NODE(FILE,SRCNAME,VALUE) \
  590. do \
  591. { \
  592. if (mcore_current_compilation_timestamp == 0) \
  593. mcore_current_compilation_timestamp = time (0); \
  594. fprintf ((FILE),"\t.equ\t__$frame$size$_%s_$_%08lx,%d\n", \
  595. (SRCNAME), mcore_current_compilation_timestamp, (VALUE)); \
  596. } \
  597. while (0)
  598. #define ASM_OUTPUT_CG_EDGE(FILE,SRCNAME,DSTNAME,VALUE) \
  599. do \
  600. { \
  601. fprintf ((FILE),"\t.equ\t__$function$call$_%s_$_%s,%d\n", \
  602. (SRCNAME), (DSTNAME), (VALUE)); \
  603. } \
  604. while (0)
  605. /* Globalizing directive for a label. */
  606. #define GLOBAL_ASM_OP "\t.export\t"
  607. /* The prefix to add to user-visible assembler symbols. */
  608. #undef USER_LABEL_PREFIX
  609. #define USER_LABEL_PREFIX ""
  610. /* Make an internal label into a string. */
  611. #undef ASM_GENERATE_INTERNAL_LABEL
  612. #define ASM_GENERATE_INTERNAL_LABEL(STRING, PREFIX, NUM) \
  613. sprintf (STRING, "*.%s%ld", PREFIX, (long) NUM)
  614. /* Jump tables must be 32 bit aligned. */
  615. #undef ASM_OUTPUT_CASE_LABEL
  616. #define ASM_OUTPUT_CASE_LABEL(STREAM,PREFIX,NUM,TABLE) \
  617. fprintf (STREAM, "\t.align 2\n.%s%d:\n", PREFIX, NUM);
  618. /* Output a relative address. Not needed since jump tables are absolute
  619. but we must define it anyway. */
  620. #define ASM_OUTPUT_ADDR_DIFF_ELT(STREAM,BODY,VALUE,REL) \
  621. fputs ("- - - ASM_OUTPUT_ADDR_DIFF_ELT called!\n", STREAM)
  622. /* Output an element of a dispatch table. */
  623. #define ASM_OUTPUT_ADDR_VEC_ELT(STREAM,VALUE) \
  624. fprintf (STREAM, "\t.long\t.L%d\n", VALUE)
  625. /* Output various types of constants. */
  626. /* This is how to output an assembler line
  627. that says to advance the location counter by SIZE bytes. */
  628. #undef ASM_OUTPUT_SKIP
  629. #define ASM_OUTPUT_SKIP(FILE,SIZE) \
  630. fprintf (FILE, "\t.fill %d, 1\n", (int)(SIZE))
  631. /* This says how to output an assembler line
  632. to define a global common symbol, with alignment information. */
  633. /* XXX - for now we ignore the alignment. */
  634. #undef ASM_OUTPUT_ALIGNED_COMMON
  635. #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
  636. do \
  637. { \
  638. if (mcore_dllexport_name_p (NAME)) \
  639. MCORE_EXPORT_NAME (FILE, NAME) \
  640. if (! mcore_dllimport_name_p (NAME)) \
  641. { \
  642. fputs ("\t.comm\t", FILE); \
  643. assemble_name (FILE, NAME); \
  644. fprintf (FILE, ",%lu\n", (unsigned long)(SIZE)); \
  645. } \
  646. } \
  647. while (0)
  648. /* This says how to output an assembler line
  649. to define a local common symbol.... */
  650. #undef ASM_OUTPUT_LOCAL
  651. #define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED) \
  652. (fputs ("\t.lcomm\t", FILE), \
  653. assemble_name (FILE, NAME), \
  654. fprintf (FILE, ",%d\n", (int)SIZE))
  655. /* ... and how to define a local common symbol whose alignment
  656. we wish to specify. ALIGN comes in as bits, we have to turn
  657. it into bytes. */
  658. #undef ASM_OUTPUT_ALIGNED_LOCAL
  659. #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
  660. do \
  661. { \
  662. fputs ("\t.bss\t", (FILE)); \
  663. assemble_name ((FILE), (NAME)); \
  664. fprintf ((FILE), ",%d,%d\n", (int)(SIZE), (ALIGN) / BITS_PER_UNIT);\
  665. } \
  666. while (0)
  667. #endif /* ! GCC_MCORE_H */