mep.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793
  1. /* Definitions for Toshiba Media Processor
  2. Copyright (C) 2001-2015 Free Software Foundation, Inc.
  3. Contributed by Red Hat, Inc.
  4. This file is part of GCC.
  5. GCC is free software; you can redistribute it and/or modify it under
  6. the terms of the GNU General Public License as published by the Free
  7. Software Foundation; either version 3, or (at your option) any later
  8. version.
  9. GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  12. 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. #undef CPP_SPEC
  17. #define CPP_SPEC "\
  18. -D__MEP__ -D__MeP__ \
  19. -D__section(_x)=__attribute__((section(_x))) \
  20. -D__align(_x)=__attribute__((aligned(_x))) \
  21. -D__io(_x)=__attribute__((io(_x))) \
  22. -D__cb(_x)=__attribute__((cb(_x))) \
  23. -D__based=__attribute__((based)) \
  24. -D__tiny=__attribute__((tiny)) \
  25. -D__near=__attribute__((near)) \
  26. -D__far=__attribute__((far)) \
  27. -D__vliw=__attribute__((vliw)) \
  28. -D__interrupt=__attribute__((interrupt)) \
  29. -D__disinterrupt=__attribute__((disinterrupt)) \
  30. %{!meb:%{!mel:-D__BIG_ENDIAN__}} \
  31. %{meb:-U__LITTLE_ENDIAN__ -D__BIG_ENDIAN__} \
  32. %{mel:-U__BIG_ENDIAN__ -D__LITTLE_ENDIAN__} \
  33. %{mconfig=*:-D__MEP_CONFIG_%*} \
  34. %{mivc2:-D__MEP_CONFIG_CP_DATA_BUS_WIDTH=64} \
  35. "
  36. #undef CC1_SPEC
  37. #define CC1_SPEC "%{!mlibrary:%(config_cc_spec)} \
  38. %{!.cc:%{O2:%{!funroll*:--param max-completely-peeled-insns=6 \
  39. --param max-unrolled-insns=6 -funroll-loops}}}"
  40. #undef CC1PLUS_SPEC
  41. #define CC1PLUS_SPEC "%{!mlibrary:%(config_cc_spec)}"
  42. #undef ASM_SPEC
  43. #define ASM_SPEC "%{mconfig=*} %{meb:-EB} %{mel:-EL} \
  44. %{mno-satur} %{msatur} %{mno-clip} %{mclip} %{mno-minmax} %{mminmax} \
  45. %{mno-absdiff} %{mabsdiff} %{mno-leadz} %{mleadz} %{mno-bitops} %{mbitops} \
  46. %{mno-div} %{mdiv} %{mno-mult} %{mmult} %{mno-average} %{maverage} \
  47. %{mcop32} %{mno-debug} %{mdebug} %{mlibrary}"
  48. /* The MeP config tool will edit this spec. */
  49. #undef STARTFILE_SPEC
  50. #define STARTFILE_SPEC "%{msdram:%{msim:simsdram-crt0.o%s}} \
  51. %{mno-sdram:%{msim:sim-crt0.o%s}} \
  52. %{msdram:%{!msim*:sdram-crt0.o%s}} \
  53. %{mno-sdram:%{!msim*:crt0.o%s}} \
  54. %(config_start_spec) \
  55. %{msimnovec:simnovec-crt0.o%s} \
  56. crtbegin.o%s"
  57. #undef LIB_SPEC
  58. #define LIB_SPEC "-( -lc %{msim*:-lsim}%{!msim*:-lnosys} -) %(config_link_spec)"
  59. #undef LINK_SPEC
  60. #define LINK_SPEC "%{meb:-EB} %{mel:-EL}"
  61. #undef ENDFILE_SPEC
  62. #define ENDFILE_SPEC "crtend.o%s %{msim*:sim-crtn.o%s}%{!msim*:crtn.o%s}"
  63. /* The MeP config tool will edit this spec. */
  64. #define CONFIG_CC_SPEC "\
  65. %{mconfig=default: -mbitops -mleadz -mabsdiff -maverage -mminmax -mclip -msatur -mvl64 -mvliw -mcop64 -D__MEP_CONFIG_CP_DATA_BUS_WIDTH=64 -mivc2}\
  66. "
  67. /* end-config-cc-spec */
  68. /* The MeP config tool will edit this spec. */
  69. #define CONFIG_LINK_SPEC "\
  70. %{mconfig=default: %{!T*:-Tdefault.ld}}\
  71. "
  72. /* end-config-link-spec */
  73. /* The MeP config tool will edit this spec. */
  74. #define CONFIG_START_SPEC "\
  75. %{!msdram:%{!mno-sdram:%{!msim*:crt0.o%s}}} \
  76. %{!msdram:%{!mno-sdram:%{msim:sim-crt0.o%s}}} \
  77. "
  78. /* end-config-start-spec */
  79. #define EXTRA_SPECS \
  80. { "config_cc_spec", CONFIG_CC_SPEC }, \
  81. { "config_link_spec", CONFIG_LINK_SPEC }, \
  82. { "config_start_spec", CONFIG_START_SPEC },
  83. #define TARGET_CPU_CPP_BUILTINS() \
  84. do \
  85. { \
  86. builtin_define_std ("mep"); \
  87. builtin_assert ("machine=mep"); \
  88. } \
  89. while (0)
  90. /* Controlled by MeP-Integrator. */
  91. #define TARGET_H1 0
  92. #define MEP_ALL_OPTS (MASK_OPT_AVERAGE \
  93. | MASK_OPT_MULT \
  94. | MASK_OPT_DIV \
  95. | MASK_OPT_BITOPS \
  96. | MASK_OPT_LEADZ \
  97. | MASK_OPT_ABSDIFF \
  98. | MASK_OPT_MINMAX \
  99. | MASK_OPT_CLIP \
  100. | MASK_OPT_SATUR )
  101. #define TARGET_DEFAULT (MASK_IO_VOLATILE | MASK_OPT_REPEAT | MEP_ALL_OPTS | MASK_LITTLE_ENDIAN)
  102. #define TARGET_IO_NO_VOLATILE (! (target_flags & MASK_IO_VOLATILE))
  103. #define TARGET_OPT_NOREPEAT (! (target_flags & MASK_OPT_REPEAT))
  104. #define TARGET_32BIT_CR_REGS (! (target_flags & MASK_64BIT_CR_REGS))
  105. #define TARGET_BIG_ENDIAN (! (target_flags & MASK_LITTLE_ENDIAN))
  106. #define TARGET_COPRO_MULT 0
  107. /* The MeP config tool will replace this as appropriate. */
  108. #define DEFAULT_ENDIAN_SPEC "%{!meb: -mel}"
  109. /* The MeP config tool will replace this with an -mconfig= switch. */
  110. #define LIBRARY_CONFIG_SPEC "-mconfig=default"
  111. /* Don't add an endian option when building the libraries. */
  112. #define DRIVER_SELF_SPECS \
  113. "%{!mlibrary:" DEFAULT_ENDIAN_SPEC "}", \
  114. "%{mlibrary: " LIBRARY_CONFIG_SPEC " %{!mel:-meb}}", \
  115. "%{mall-opts:-maverage -mmult -mdiv -mbitops -mleadz \
  116. -mabsdiff -mminmax -mclip -msatur -mdebug} %<mall-opts", \
  117. "%{mno-opts:-mno-average -mno-mult -mno-div -mno-bitops -mno-leadz \
  118. -mno-absdiff -mno-minmax -mno-clip -mno-satur -mno-debug} %<mno-opts", \
  119. "%{mfar:-ml -mtf -mc=far} %<mfar", \
  120. "%{mconfig=default:-mmult -mdiv -D__MEP_CONFIG_ISA=1}"
  121. /* The MeP config tool will add COPROC_SELECTION_TABLE here. */
  122. /* start-coproc-selection-table */
  123. #define COPROC_SELECTION_TABLE \
  124. {"default", ISA_EXT1}
  125. /* end-coproc-selection-table */
  126. #define BITS_BIG_ENDIAN 0
  127. #define BYTES_BIG_ENDIAN (TARGET_LITTLE_ENDIAN ? 0 : 1)
  128. #define WORDS_BIG_ENDIAN (TARGET_LITTLE_ENDIAN ? 0 : 1)
  129. #define UNITS_PER_WORD 4
  130. #define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
  131. do \
  132. { \
  133. if (GET_MODE_CLASS (MODE) == MODE_INT \
  134. && GET_MODE_SIZE (MODE) < 4) \
  135. (MODE) = SImode; \
  136. } \
  137. while (0)
  138. #define PARM_BOUNDARY 32
  139. #define STACK_BOUNDARY 32
  140. #define PREFERRED_STACK_BOUNDARY 64
  141. #define FUNCTION_BOUNDARY 16
  142. #define BIGGEST_ALIGNMENT 64
  143. #define DATA_ALIGNMENT(TYPE, ALIGN) \
  144. (TREE_CODE (TYPE) == ARRAY_TYPE \
  145. && TYPE_MODE (TREE_TYPE (TYPE)) == QImode \
  146. && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
  147. #define CONSTANT_ALIGNMENT(EXP, ALIGN) \
  148. (TREE_CODE (EXP) == STRING_CST \
  149. && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
  150. #define STRICT_ALIGNMENT 1
  151. #define PCC_BITFIELD_TYPE_MATTERS 1
  152. #define DEFAULT_VTABLE_THUNKS 1
  153. #define INT_TYPE_SIZE 32
  154. #define SHORT_TYPE_SIZE 16
  155. #define LONG_TYPE_SIZE 32
  156. #define LONG_LONG_TYPE_SIZE 64
  157. #define CHAR_TYPE_SIZE 8
  158. #define FLOAT_TYPE_SIZE 32
  159. #define DOUBLE_TYPE_SIZE 64
  160. #define LONG_DOUBLE_TYPE_SIZE 64
  161. #define DEFAULT_SIGNED_CHAR 1
  162. #undef SIZE_TYPE
  163. #define SIZE_TYPE "unsigned int"
  164. #undef PTRDIFF_TYPE
  165. #define PTRDIFF_TYPE "int"
  166. #undef WCHAR_TYPE
  167. #define WCHAR_TYPE "long int"
  168. #undef WCHAR_TYPE_SIZE
  169. #define WCHAR_TYPE_SIZE BITS_PER_WORD
  170. /* Register numbers:
  171. 0..15 core registers
  172. 16..47 control registers
  173. 48..79 coprocessor registers
  174. 80..111 coprocessor control registers
  175. 112 virtual arg pointer register */
  176. #define FIRST_PSEUDO_REGISTER (LAST_SHADOW_REGISTER + 1)
  177. /* R12 is optionally FP. R13 is TP, R14 is GP, R15 is SP. */
  178. /* hi and lo can be used as general registers. Others have
  179. immutable bits. */
  180. /* A "1" here means the register is generally not available to gcc,
  181. and is assumed to remain unchanged or unused throughout. */
  182. #define FIXED_REGISTERS { \
  183. /* core registers */ \
  184. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, \
  185. /* control registers */ \
  186. 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, \
  187. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
  188. /* coprocessor registers */ \
  189. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
  190. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
  191. /* coprocessor control registers */ \
  192. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
  193. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
  194. /* virtual arg pointer */ \
  195. 1, FIXED_SHADOW_REGISTERS \
  196. }
  197. /* This is a call-clobbered reg not used for args or return value,
  198. that we use as a temp for saving control registers in the prolog
  199. and restoring them in the epilog. */
  200. #define REGSAVE_CONTROL_TEMP 11
  201. /* A "1" here means a register may be changed by a function without
  202. needing to preserve its previous value. */
  203. #define CALL_USED_REGISTERS { \
  204. /* core registers */ \
  205. 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, \
  206. /* control registers */ \
  207. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
  208. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
  209. /* coprocessor registers */ \
  210. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
  211. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
  212. /* coprocessor control registers */ \
  213. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
  214. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, \
  215. /* virtual arg pointer */ \
  216. 1, CALL_USED_SHADOW_REGISTERS \
  217. }
  218. #define REG_ALLOC_ORDER { \
  219. /* core registers */ \
  220. 3, 2, 1, 0, 9, 10, 11, 12, 4, 5, 6, 7, 8, 13, 14, 15, \
  221. /* control registers */ \
  222. 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, \
  223. 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, \
  224. /* coprocessor registers */ \
  225. /* Prefer to use the non-loadable registers when looking for a \
  226. member of CR_REGS (as opposed to LOADABLE_CR_REGS). */ \
  227. 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 48, 49, 50, 51, 52, 58, \
  228. 59, 60, 61, 62, 63, 53, 54, 55, 56, 57, 74, 75, 76, 77, 78, 79, \
  229. /* coprocessor control registers */ \
  230. 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, \
  231. 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, \
  232. /* virtual arg pointer */ \
  233. 112, SHADOW_REG_ALLOC_ORDER \
  234. }
  235. /* We must somehow disable register remapping for interrupt functions. */
  236. extern char mep_leaf_registers[];
  237. #define LEAF_REGISTERS mep_leaf_registers
  238. #define LEAF_REG_REMAP(REG) (REG)
  239. #define FIRST_GR_REGNO 0
  240. #define FIRST_CONTROL_REGNO (FIRST_GR_REGNO + 16)
  241. #define FIRST_CR_REGNO (FIRST_CONTROL_REGNO + 32)
  242. #define FIRST_CCR_REGNO (FIRST_CR_REGNO + 32)
  243. #define GR_REGNO_P(REGNO) \
  244. ((unsigned) ((REGNO) - FIRST_GR_REGNO) < 16)
  245. #define CONTROL_REGNO_P(REGNO) \
  246. ((unsigned) ((REGNO) - FIRST_CONTROL_REGNO) < 32)
  247. #define LOADABLE_CR_REGNO_P(REGNO) \
  248. ((unsigned) ((REGNO) - FIRST_CR_REGNO) < 16)
  249. #define CR_REGNO_P(REGNO) \
  250. ((unsigned) ((REGNO) - FIRST_CR_REGNO) < 32)
  251. #define CCR_REGNO_P(REGNO) \
  252. ((unsigned) ((REGNO) - FIRST_CCR_REGNO) < 32)
  253. #define ANY_CONTROL_REGNO_P(REGNO) \
  254. (CONTROL_REGNO_P (REGNO) || CCR_REGNO_P (REGNO))
  255. #define HARD_REGNO_NREGS(REGNO, MODE) \
  256. ((CR_REGNO_P (REGNO) && TARGET_64BIT_CR_REGS) \
  257. ? (GET_MODE_SIZE (MODE) + 8 - 1) / 8 \
  258. : (GET_MODE_SIZE (MODE) + 4 - 1) / 4)
  259. #define HARD_REGNO_MODE_OK(REGNO, MODE) 1
  260. #define MODES_TIEABLE_P(MODE1, MODE2) 1
  261. #define CANNOT_CHANGE_MODE_CLASS(FROM, TO, CLASS) \
  262. mep_cannot_change_mode_class (FROM, TO, CLASS)
  263. enum reg_class
  264. {
  265. NO_REGS,
  266. SP_REGS,
  267. TP_REGS,
  268. GP_REGS,
  269. R0_REGS,
  270. RPC_REGS,
  271. HI_REGS,
  272. LO_REGS,
  273. HILO_REGS,
  274. TPREL_REGS,
  275. GENERAL_NOT_R0_REGS,
  276. GENERAL_REGS,
  277. CONTROL_REGS,
  278. CONTROL_OR_GENERAL_REGS,
  279. USER0_REGS,
  280. USER1_REGS,
  281. USER2_REGS,
  282. USER3_REGS,
  283. LOADABLE_CR_REGS,
  284. CR_REGS,
  285. CCR_REGS,
  286. ALL_REGS,
  287. LIM_REG_CLASSES
  288. };
  289. #define N_REG_CLASSES ((int) LIM_REG_CLASSES)
  290. #define REG_CLASS_NAMES { \
  291. "NO_REGS", \
  292. "SP_REGS", \
  293. "TP_REGS", \
  294. "GP_REGS", \
  295. "R0_REGS", \
  296. "RPC_REGS", \
  297. "HI_REGS", \
  298. "LO_REGS", \
  299. "HILO_REGS", \
  300. "TPREL_REGS", \
  301. "GENERAL_NOT_R0_REGS", \
  302. "GENERAL_REGS", \
  303. "CONTROL_REGS", \
  304. "CONTROL_OR_GENERAL_REGS", \
  305. "USER0_REGS", \
  306. "USER1_REGS", \
  307. "USER2_REGS", \
  308. "USER3_REGS", \
  309. "LOADABLE_CR_REGS", \
  310. "CR_REGS", \
  311. "CCR_REGS", \
  312. "ALL_REGS" }
  313. #define REG_CLASS_CONTENTS { \
  314. { 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, /* NO_REGS */ \
  315. { 0x00008000, 0x00000000, 0x00000000, 0x00000000 }, /* SP_REGS */ \
  316. { 0x00002000, 0x00000000, 0x00000000, 0x00000000 }, /* TP_REGS */ \
  317. { 0x00004000, 0x00000000, 0x00000000, 0x00000000 }, /* GP_REGS */ \
  318. { 0x00000001, 0x00000000, 0x00000000, 0x00000000 }, /* R0_REGS */ \
  319. { 0x00400000, 0x00000000, 0x00000000, 0x00000000 }, /* RPC_REGS */ \
  320. { 0x00800000, 0x00000000, 0x00000000, 0x00000000 }, /* HI_REGS */ \
  321. { 0x01000000, 0x00000000, 0x00000000, 0x00000000 }, /* LO_REGS */ \
  322. { 0x01800000, 0x00000000, 0x00000000, 0x00000000 }, /* HILO_REGS */ \
  323. { 0x000000ff, 0x00000000, 0x00000000, 0x00000000 }, /* TPREL_REGS */ \
  324. { 0x0000fffe, 0x00000000, 0x00000000, 0x00000000 }, /* GENERAL_NOT_R0_REGS */ \
  325. { 0x0000ffff, 0x00000000, 0x00000000, 0x00010000 }, /* GENERAL_REGS */ \
  326. { 0xffff0000, 0x0000ffff, 0x00000000, 0x00000000 }, /* CONTROL_REGS */ \
  327. { 0xffffffff, 0x0000ffff, 0x00000000, 0x00000000 }, /* CONTROL_OR_GENERAL_REGS */ \
  328. { 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, /* USER0_REGS */ \
  329. { 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, /* USER1_REGS */ \
  330. { 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, /* USER2_REGS */ \
  331. { 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, /* USER3_REGS */ \
  332. { 0x00000000, 0xffff0000, 0x00000000, 0x00000000 }, /* LOADABLE_CR_REGS */ \
  333. { 0x00000000, 0xffff0000, 0x0000ffff, 0x00000000 }, /* CR_REGS */ \
  334. { 0x00000000, 0x00000000, 0xffff0000, 0x0000ffff }, /* CCR_REGS */ \
  335. { 0xffffffff, 0xffffffff, 0xffffffff, 0x0001ffff }, /* ALL_REGS */ \
  336. }
  337. #define REGNO_REG_CLASS(REGNO) (enum reg_class) mep_regno_reg_class (REGNO)
  338. #define BASE_REG_CLASS GENERAL_REGS
  339. #define INDEX_REG_CLASS GENERAL_REGS
  340. #define REGNO_OK_FOR_BASE_P(NUM) (GR_REGNO_P (NUM) \
  341. || (NUM) == ARG_POINTER_REGNUM \
  342. || (NUM) >= FIRST_PSEUDO_REGISTER)
  343. #define REGNO_OK_FOR_INDEX_P(NUM) REGNO_OK_FOR_BASE_P (NUM)
  344. #define PREFERRED_RELOAD_CLASS(X, CLASS) mep_preferred_reload_class (X, CLASS)
  345. #define SECONDARY_INPUT_RELOAD_CLASS(CLASS, MODE, X) \
  346. mep_secondary_input_reload_class (CLASS, MODE, X)
  347. #define SECONDARY_OUTPUT_RELOAD_CLASS(CLASS, MODE, X) \
  348. mep_secondary_output_reload_class (CLASS, MODE, X)
  349. #define SECONDARY_MEMORY_NEEDED(CLASS1, CLASS2, MODE) \
  350. mep_secondary_memory_needed (CLASS1, CLASS2, MODE)
  351. #define WANT_GCC_DECLARATIONS
  352. #include "mep-intrin.h"
  353. #undef WANT_GCC_DECLARATIONS
  354. extern int mep_intrinsic_insn[];
  355. extern unsigned int mep_selected_isa;
  356. /* True if intrinsic X is available. X is a mep_* value declared
  357. in mep-intrin.h. */
  358. #define MEP_INTRINSIC_AVAILABLE_P(X) (mep_intrinsic_insn[X] >= 0)
  359. /* Used to define CGEN_ENABLE_INTRINSIC_P in mep-intrin.h. */
  360. #define CGEN_CURRENT_ISAS mep_selected_isa
  361. #define CGEN_CURRENT_GROUP \
  362. (mep_vliw_function_p (cfun->decl) ? GROUP_VLIW : GROUP_NORMAL)
  363. #define STACK_GROWS_DOWNWARD 1
  364. #define FRAME_GROWS_DOWNWARD 1
  365. #define STARTING_FRAME_OFFSET 0
  366. #define FIRST_PARM_OFFSET(FUNDECL) 0
  367. #define INCOMING_FRAME_SP_OFFSET 0
  368. #define RETURN_ADDR_RTX(COUNT, FRAMEADDR) mep_return_addr_rtx (COUNT)
  369. #define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (SImode, LP_REGNO)
  370. #define DWARF_FRAME_RETURN_COLUMN LP_REGNO
  371. #define STACK_POINTER_REGNUM 15
  372. #define FRAME_POINTER_REGNUM 8
  373. #define ARG_POINTER_REGNUM 112
  374. #define RETURN_ADDRESS_POINTER_REGNUM 17
  375. #define STATIC_CHAIN_REGNUM 0
  376. #define ELIMINABLE_REGS \
  377. { \
  378. {ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
  379. {ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM}, \
  380. {FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM} \
  381. }
  382. #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
  383. (OFFSET) = mep_elimination_offset (FROM, TO)
  384. #define ACCUMULATE_OUTGOING_ARGS 1
  385. #define FUNCTION_ARG_CALLEE_COPIES(CUM, MODE, TYPE, NAMED) 1
  386. typedef struct
  387. {
  388. int nregs;
  389. int vliw;
  390. } CUMULATIVE_ARGS;
  391. #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, FNDECL, N_NAMED_ARGS) \
  392. mep_init_cumulative_args (& (CUM), FNTYPE, LIBNAME, FNDECL)
  393. #define FUNCTION_ARG_REGNO_P(REGNO) \
  394. (((REGNO) >= 1 && (REGNO) <= 4) \
  395. || ((REGNO) >= FIRST_CR_REGNO + 1 \
  396. && (REGNO) <= FIRST_CR_REGNO + 4 \
  397. && TARGET_COP))
  398. #define RETURN_VALUE_REGNUM 0
  399. #define FUNCTION_VALUE(VALTYPE, FUNC) mep_function_value (VALTYPE, FUNC)
  400. #define LIBCALL_VALUE(MODE) mep_libcall_value (MODE)
  401. #define FUNCTION_VALUE_REGNO_P(REGNO) \
  402. ((REGNO) == RETURN_VALUE_REGNUM)
  403. #define DEFAULT_PCC_STRUCT_RETURN 0
  404. #define STRUCT_VALUE 0
  405. #define FUNCTION_OK_FOR_SIBCALL(DECL) mep_function_ok_for_sibcall(DECL)
  406. /* Prologue and epilogues are all handled via RTL. */
  407. #define EXIT_IGNORE_STACK 1
  408. #define EPILOGUE_USES(REGNO) mep_epilogue_uses (REGNO)
  409. /* Profiling is supported. */
  410. #define FUNCTION_PROFILER(FILE, LABELNO) mep_function_profiler (FILE);
  411. #define NO_PROFILE_COUNTERS 1
  412. /* Trampolines are built at run-time. The cache is invalidated at
  413. run-time also. */
  414. #define TRAMPOLINE_SIZE 20
  415. #define MAX_REGS_PER_ADDRESS 1
  416. #ifdef REG_OK_STRICT
  417. #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, LABEL) \
  418. if (mep_legitimate_address ((MODE), (X), 1)) goto LABEL
  419. #else
  420. #define GO_IF_LEGITIMATE_ADDRESS(MODE, X, LABEL) \
  421. if (mep_legitimate_address ((MODE), (X), 0)) goto LABEL
  422. #endif
  423. #ifdef REG_OK_STRICT
  424. #define REG_OK_FOR_BASE_P(X) GR_REGNO_P (REGNO (X))
  425. #else
  426. #define REG_OK_FOR_BASE_P(X) (GR_REGNO_P (REGNO (X)) \
  427. || REGNO (X) == ARG_POINTER_REGNUM \
  428. || REGNO (X) >= FIRST_PSEUDO_REGISTER)
  429. #endif
  430. #define REG_OK_FOR_INDEX_P(X) REG_OK_FOR_BASE_P (X)
  431. #define LEGITIMIZE_RELOAD_ADDRESS(X, MODE, OPNUM, TYPE, IND_LEVELS, WIN) \
  432. if (mep_legitimize_reload_address (&(X), (MODE), (OPNUM), (TYPE), (IND_LEVELS))) \
  433. goto WIN
  434. #define SELECT_CC_MODE(OP, X, Y) CCmode
  435. /* Moves between control regs need a scratch. */
  436. #define REGISTER_MOVE_COST(MODE, FROM, TO) mep_register_move_cost (MODE, FROM, TO)
  437. #define SLOW_BYTE_ACCESS 1
  438. /* Define this macro if it is as good or better to call a constant function
  439. address than to call an address kept in a register. */
  440. #define NO_FUNCTION_CSE
  441. #define TEXT_SECTION_ASM_OP "\t.text\n\t.core"
  442. #define DATA_SECTION_ASM_OP "\t.data"
  443. #define BSS_SECTION_ASM_OP ".bss"
  444. #define USE_SELECT_SECTION_FOR_FUNCTIONS 1
  445. #define JUMP_TABLES_IN_TEXT_SECTION 1
  446. #define TARGET_ASM_FILE_END mep_file_cleanups
  447. #define ASM_APP_ON "#APP\n"
  448. #define ASM_APP_OFF "#NO_APP\n"
  449. #define ASM_OUTPUT_DOUBLE(FILE, VALUE) \
  450. do \
  451. { \
  452. long l[2]; \
  453. \
  454. REAL_VALUE_TO_TARGET_DOUBLE (VALUE, l); \
  455. fprintf (FILE, "\t.long\t0x%lx,0x%lx\n", l[0], l[1]); \
  456. } \
  457. while (0)
  458. #define ASM_OUTPUT_FLOAT(FILE, VALUE) \
  459. do \
  460. { \
  461. long l; \
  462. \
  463. REAL_VALUE_TO_TARGET_SINGLE (VALUE, l); \
  464. fprintf ((FILE), "\t.long\t0x%lx\n", l); \
  465. } \
  466. while (0)
  467. #define ASM_OUTPUT_CHAR(FILE, VALUE) \
  468. do \
  469. { \
  470. fprintf (FILE, "\t.byte\t"); \
  471. output_addr_const (FILE, (VALUE)); \
  472. fprintf (FILE, "\n"); \
  473. } \
  474. while (0)
  475. #define ASM_OUTPUT_SHORT(FILE, VALUE) \
  476. do \
  477. { \
  478. fprintf (FILE, "\t.hword\t"); \
  479. output_addr_const (FILE, (VALUE)); \
  480. fprintf (FILE, "\n"); \
  481. } \
  482. while (0)
  483. #define ASM_OUTPUT_INT(FILE, VALUE) \
  484. do \
  485. { \
  486. fprintf (FILE, "\t.word\t"); \
  487. output_addr_const (FILE, (VALUE)); \
  488. fprintf (FILE, "\n"); \
  489. } \
  490. while (0)
  491. /* Most of these are here to support based/tiny/far/io attributes. */
  492. #define ASM_OUTPUT_ALIGNED_DECL_COMMON(STREAM, DECL, NAME, SIZE, ALIGNMENT) \
  493. mep_output_aligned_common (STREAM, DECL, NAME, SIZE, ALIGNMENT, 1)
  494. #define ASM_OUTPUT_ALIGNED_DECL_LOCAL(STREAM, DECL, NAME, SIZE, ALIGNMENT) \
  495. mep_output_aligned_common (STREAM, DECL, NAME, SIZE, ALIGNMENT, 0)
  496. #define ASM_OUTPUT_LABEL(STREAM, NAME) \
  497. do \
  498. { \
  499. assemble_name (STREAM, NAME); \
  500. fputs (":\n", STREAM); \
  501. } \
  502. while (0)
  503. /* Globalizing directive for a label. */
  504. #define GLOBAL_ASM_OP "\t.globl "
  505. #define ASM_OUTPUT_LABELREF(STREAM, NAME) \
  506. asm_fprintf ((STREAM), "%U%s", mep_strip_name_encoding (NAME))
  507. #define ASM_FORMAT_PRIVATE_NAME(OUTVAR, NAME, NUMBER) \
  508. do \
  509. { \
  510. (OUTVAR) = (char *) alloca (strlen ((NAME)) + 12); \
  511. sprintf ((OUTVAR), "%s.%ld", (NAME), (long)(NUMBER)); \
  512. } \
  513. while (0)
  514. #define REGISTER_NAMES \
  515. { \
  516. /* Core registers. */ \
  517. "$0", "$1", "$2", "$3", "$4", "$5", "$6", "$7", \
  518. "$8", "$9", "$10", "$11", "$12", "$tp", "$gp", "$sp", \
  519. /* Control registers. */ \
  520. "$pc", "$lp", "$sar", "3", "$rpb", "$rpe", "$rpc", "$hi", \
  521. "$lo", "9", "10", "11", "$mb0", "$me0", "$mb1", "$me1", \
  522. "$psw", "$id", "$tmp", "$epc", "$exc", "$cfg", "22", "$npc", \
  523. "$dbg", "$depc", "$opt", "$rcfg", "$ccfg", "29", "30", "31", \
  524. /* Coprocessor registers. */ \
  525. "$c0", "$c1", "$c2", "$c3", "$c4", "$c5", "$c6", "$c7", \
  526. "$c8", "$c9", "$c10", "$c11", "$c12", "$c13", "$c14", "$c15", \
  527. "$c16", "$c17", "$c18", "$c19", "$c20", "$c21", "$c22", "$c23", \
  528. "$c24", "$c25", "$c26", "$c27", "$c28", "$c29", "$c30", "$c31", \
  529. /* Coprocessor control registers. */ \
  530. "$ccr0", "$ccr1", "$ccr2", "$ccr3", "$ccr4", "$ccr5", "$ccr6", \
  531. "$ccr7", "$ccr8", "$ccr9", "$ccr10", "$ccr11", "$ccr12", "$ccr13", \
  532. "$ccr14", "$ccr15", "$ccr16", "$ccr17", "$ccr18", "$ccr19", "$ccr20", \
  533. "$ccr21", "$ccr22", "$ccr23", "$ccr24", "$ccr25", "$ccr26", "$ccr27", \
  534. "$ccr28", "$ccr29", "$ccr30", "$ccr31", \
  535. /* Virtual arg pointer. */ \
  536. "$argp", SHADOW_REGISTER_NAMES \
  537. }
  538. /* We duplicate some of the above because we twiddle the above
  539. according to *how* the registers are used. Likewise, we include
  540. the standard names for coprocessor control registers so that
  541. coprocessor options can rename them in the default table. Note
  542. that these are compared to stripped names (see REGISTER_PREFIX
  543. below). */
  544. #define ADDITIONAL_REGISTER_NAMES \
  545. { \
  546. { "8", 8 }, { "fp", 8 }, \
  547. { "13", 13 }, { "tp", 13 }, \
  548. { "14", 14 }, { "gp", 14 }, \
  549. { "15", 15 }, { "sp", 15 }, \
  550. { "ccr0", FIRST_CCR_REGNO + 0 }, \
  551. { "ccr1", FIRST_CCR_REGNO + 1 }, \
  552. { "ccr2", FIRST_CCR_REGNO + 2 }, \
  553. { "ccr3", FIRST_CCR_REGNO + 3 }, \
  554. { "ccr4", FIRST_CCR_REGNO + 4 }, \
  555. { "ccr5", FIRST_CCR_REGNO + 5 }, \
  556. { "ccr6", FIRST_CCR_REGNO + 6 }, \
  557. { "ccr7", FIRST_CCR_REGNO + 7 }, \
  558. { "ccr8", FIRST_CCR_REGNO + 8 }, \
  559. { "ccr9", FIRST_CCR_REGNO + 9 }, \
  560. { "ccr10", FIRST_CCR_REGNO + 10 }, \
  561. { "ccr11", FIRST_CCR_REGNO + 11 }, \
  562. { "ccr12", FIRST_CCR_REGNO + 12 }, \
  563. { "ccr13", FIRST_CCR_REGNO + 13 }, \
  564. { "ccr14", FIRST_CCR_REGNO + 14 }, \
  565. { "ccr15", FIRST_CCR_REGNO + 15 }, \
  566. { "ccr16", FIRST_CCR_REGNO + 16 }, \
  567. { "ccr17", FIRST_CCR_REGNO + 17 }, \
  568. { "ccr18", FIRST_CCR_REGNO + 18 }, \
  569. { "ccr19", FIRST_CCR_REGNO + 19 }, \
  570. { "ccr20", FIRST_CCR_REGNO + 20 }, \
  571. { "ccr21", FIRST_CCR_REGNO + 21 }, \
  572. { "ccr22", FIRST_CCR_REGNO + 22 }, \
  573. { "ccr23", FIRST_CCR_REGNO + 23 }, \
  574. { "ccr24", FIRST_CCR_REGNO + 24 }, \
  575. { "ccr25", FIRST_CCR_REGNO + 25 }, \
  576. { "ccr26", FIRST_CCR_REGNO + 26 }, \
  577. { "ccr27", FIRST_CCR_REGNO + 27 }, \
  578. { "ccr28", FIRST_CCR_REGNO + 28 }, \
  579. { "ccr29", FIRST_CCR_REGNO + 29 }, \
  580. { "ccr30", FIRST_CCR_REGNO + 30 }, \
  581. { "ccr31", FIRST_CCR_REGNO + 31 } \
  582. }
  583. /* We watch for pipeline hazards with these */
  584. #define ASM_OUTPUT_OPCODE(STREAM, PTR) mep_asm_output_opcode (STREAM, PTR)
  585. #define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS) mep_final_prescan_insn (INSN, OPVEC, NOPERANDS)
  586. #define PRINT_OPERAND(STREAM, X, CODE) mep_print_operand (STREAM, X, CODE)
  587. #define PRINT_OPERAND_PUNCT_VALID_P(CODE) ((CODE) == '!' || (CODE) == '<')
  588. #define PRINT_OPERAND_ADDRESS(STREAM, X) mep_print_operand_address (STREAM, X)
  589. #define REGISTER_PREFIX "$"
  590. #define LOCAL_LABEL_PREFIX "."
  591. #define USER_LABEL_PREFIX ""
  592. #define IMMEDIATE_PREFIX ""
  593. #define ASM_OUTPUT_ADDR_VEC_ELT(STREAM, VALUE) \
  594. fprintf (STREAM, "\t.word .L%d\n", VALUE)
  595. #undef PREFERRED_DEBUGGING_TYPE
  596. #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
  597. #define DWARF2_DEBUGGING_INFO 1
  598. #define DWARF2_UNWIND_INFO 1
  599. #define EH_RETURN_DATA_REGNO(N) ((N) < 2 ? (N) + 10 : INVALID_REGNUM)
  600. #define EH_RETURN_STACKADJ_RTX mep_return_stackadj_rtx ()
  601. #define EH_RETURN_HANDLER_RTX mep_return_handler_rtx ()
  602. #define DBX_REGISTER_NUMBER(REGNO) (REGNO)
  603. #define ASM_OUTPUT_ALIGN(STREAM, POWER) \
  604. fprintf ((STREAM), "\t.p2align %d\n", (POWER))
  605. #define CASE_VECTOR_MODE SImode
  606. #define WORD_REGISTER_OPERATIONS
  607. #define LOAD_EXTEND_OP(MODE) SIGN_EXTEND
  608. #define SHORT_IMMEDIATES_SIGN_EXTEND
  609. #define MOVE_MAX 4
  610. #define SHIFT_COUNT_TRUNCATED 1
  611. #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
  612. #define STORE_FLAG_VALUE 1
  613. #define Pmode SImode
  614. #define FUNCTION_MODE SImode
  615. #define REGISTER_TARGET_PRAGMAS() mep_register_pragmas ()
  616. /* If defined, a C expression to determine the base term of address X.
  617. This macro is used in only one place: `find_base_term' in alias.c.
  618. It is always safe for this macro to not be defined. It exists so
  619. that alias analysis can understand machine-dependent addresses.
  620. The typical use of this macro is to handle addresses containing
  621. a label_ref or symbol_ref within an UNSPEC. */
  622. #define FIND_BASE_TERM(X) mep_find_base_term (X)