sh.h 87 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292
  1. /* Definitions of target machine for GNU compiler for Renesas / SuperH SH.
  2. Copyright (C) 1993-2015 Free Software Foundation, Inc.
  3. Contributed by Steve Chamberlain (sac@cygnus.com).
  4. Improved by Jim Wilson (wilson@cygnus.com).
  5. This file is part of GCC.
  6. GCC is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 3, or (at your option)
  9. any later version.
  10. GCC is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with GCC; see the file COPYING3. If not see
  16. <http://www.gnu.org/licenses/>. */
  17. #ifndef GCC_SH_H
  18. #define GCC_SH_H
  19. #include "config/vxworks-dummy.h"
  20. /* Unfortunately, insn-attrtab.c doesn't include insn-codes.h. We can't
  21. include it here, because bconfig.h is also included by gencodes.c . */
  22. /* ??? No longer true. */
  23. extern int code_for_indirect_jump_scratch;
  24. #define TARGET_CPU_CPP_BUILTINS() sh_cpu_cpp_builtins (pfile)
  25. /* Value should be nonzero if functions must have frame pointers.
  26. Zero means the frame pointer need not be set up (and parms may be accessed
  27. via the stack pointer) in functions that seem suitable. */
  28. #ifndef SUBTARGET_FRAME_POINTER_REQUIRED
  29. #define SUBTARGET_FRAME_POINTER_REQUIRED 0
  30. #endif
  31. /* Nonzero if this is an ELF target - compile time only */
  32. #define TARGET_ELF 0
  33. /* Nonzero if we should generate code using type 2E insns. */
  34. #define TARGET_SH2E (TARGET_SH2 && TARGET_SH_E)
  35. /* Nonzero if we should generate code using type 2A insns. */
  36. #define TARGET_SH2A TARGET_HARD_SH2A
  37. /* Nonzero if we should generate code using type 2A SF insns. */
  38. #define TARGET_SH2A_SINGLE (TARGET_SH2A && TARGET_SH2E)
  39. /* Nonzero if we should generate code using type 2A DF insns. */
  40. #define TARGET_SH2A_DOUBLE (TARGET_HARD_SH2A_DOUBLE && TARGET_SH2A)
  41. /* Nonzero if we should generate code using type 3E insns. */
  42. #define TARGET_SH3E (TARGET_SH3 && TARGET_SH_E)
  43. /* Nonzero if we schedule for a superscalar implementation. */
  44. #define TARGET_SUPERSCALAR (TARGET_HARD_SH4 || TARGET_SH2A)
  45. /* Nonzero if a double-precision FPU is available. */
  46. #define TARGET_FPU_DOUBLE \
  47. ((target_flags & MASK_SH4) != 0 || TARGET_SH2A_DOUBLE)
  48. /* Nonzero if an FPU is available. */
  49. #define TARGET_FPU_ANY (TARGET_SH2E || TARGET_FPU_DOUBLE)
  50. /* Nonzero if we should generate code using type 4 insns. */
  51. #undef TARGET_SH4
  52. #define TARGET_SH4 ((target_flags & MASK_SH4) != 0 && TARGET_SH1)
  53. /* Nonzero if we're generating code for SH4a, unless the use of the
  54. FPU is disabled (which makes it compatible with SH4al-dsp). */
  55. #define TARGET_SH4A_FP (TARGET_SH4A && TARGET_FPU_ANY)
  56. /* Nonzero if we should generate code using the SHcompact instruction
  57. set and 32-bit ABI. */
  58. #define TARGET_SHCOMPACT (TARGET_SH5 && TARGET_SH1)
  59. /* Nonzero if we should generate code using the SHmedia instruction
  60. set and ABI. */
  61. #define TARGET_SHMEDIA (TARGET_SH5 && ! TARGET_SH1)
  62. /* Nonzero if we should generate code using the SHmedia ISA and 32-bit
  63. ABI. */
  64. #define TARGET_SHMEDIA32 (TARGET_SH5 && ! TARGET_SH1 && TARGET_SH_E)
  65. /* Nonzero if we should generate code using the SHmedia ISA and 64-bit
  66. ABI. */
  67. #define TARGET_SHMEDIA64 (TARGET_SH5 && ! TARGET_SH1 && ! TARGET_SH_E)
  68. /* Nonzero if we should generate code using SHmedia FPU instructions. */
  69. #define TARGET_SHMEDIA_FPU (TARGET_SHMEDIA && TARGET_FPU_DOUBLE)
  70. /* This is not used by the SH2E calling convention */
  71. #define TARGET_VARARGS_PRETEND_ARGS(FUN_DECL) \
  72. (TARGET_SH1 && ! TARGET_SH2E && ! TARGET_SH5 \
  73. && ! (TARGET_HITACHI || sh_attr_renesas_p (FUN_DECL)))
  74. #ifndef TARGET_CPU_DEFAULT
  75. #define TARGET_CPU_DEFAULT SELECT_SH1
  76. #define SUPPORT_SH1 1
  77. #define SUPPORT_SH2E 1
  78. #define SUPPORT_SH4 1
  79. #define SUPPORT_SH4_SINGLE 1
  80. #define SUPPORT_SH2A 1
  81. #define SUPPORT_SH2A_SINGLE 1
  82. #endif
  83. #define TARGET_DIVIDE_INV \
  84. (sh_div_strategy == SH_DIV_INV || sh_div_strategy == SH_DIV_INV_MINLAT \
  85. || sh_div_strategy == SH_DIV_INV20U || sh_div_strategy == SH_DIV_INV20L \
  86. || sh_div_strategy == SH_DIV_INV_CALL \
  87. || sh_div_strategy == SH_DIV_INV_CALL2 || sh_div_strategy == SH_DIV_INV_FP)
  88. #define TARGET_DIVIDE_FP (sh_div_strategy == SH_DIV_FP)
  89. #define TARGET_DIVIDE_INV_FP (sh_div_strategy == SH_DIV_INV_FP)
  90. #define TARGET_DIVIDE_CALL2 (sh_div_strategy == SH_DIV_CALL2)
  91. #define TARGET_DIVIDE_INV_MINLAT (sh_div_strategy == SH_DIV_INV_MINLAT)
  92. #define TARGET_DIVIDE_INV20U (sh_div_strategy == SH_DIV_INV20U)
  93. #define TARGET_DIVIDE_INV20L (sh_div_strategy == SH_DIV_INV20L)
  94. #define TARGET_DIVIDE_INV_CALL (sh_div_strategy == SH_DIV_INV_CALL)
  95. #define TARGET_DIVIDE_INV_CALL2 (sh_div_strategy == SH_DIV_INV_CALL2)
  96. #define TARGET_DIVIDE_CALL_DIV1 (sh_div_strategy == SH_DIV_CALL_DIV1)
  97. #define TARGET_DIVIDE_CALL_FP (sh_div_strategy == SH_DIV_CALL_FP)
  98. #define TARGET_DIVIDE_CALL_TABLE (sh_div_strategy == SH_DIV_CALL_TABLE)
  99. #define SELECT_SH1 (MASK_SH1)
  100. #define SELECT_SH2 (MASK_SH2 | SELECT_SH1)
  101. #define SELECT_SH2E (MASK_SH_E | MASK_SH2 | MASK_SH1 \
  102. | MASK_FPU_SINGLE)
  103. #define SELECT_SH2A (MASK_SH_E | MASK_HARD_SH2A \
  104. | MASK_HARD_SH2A_DOUBLE \
  105. | MASK_SH2 | MASK_SH1)
  106. #define SELECT_SH2A_NOFPU (MASK_HARD_SH2A | MASK_SH2 | MASK_SH1)
  107. #define SELECT_SH2A_SINGLE_ONLY (MASK_SH_E | MASK_HARD_SH2A | MASK_SH2 \
  108. | MASK_SH1 | MASK_FPU_SINGLE \
  109. | MASK_FPU_SINGLE_ONLY)
  110. #define SELECT_SH2A_SINGLE (MASK_SH_E | MASK_HARD_SH2A \
  111. | MASK_FPU_SINGLE | MASK_HARD_SH2A_DOUBLE \
  112. | MASK_SH2 | MASK_SH1)
  113. #define SELECT_SH3 (MASK_SH3 | SELECT_SH2)
  114. #define SELECT_SH3E (MASK_SH_E | MASK_FPU_SINGLE | SELECT_SH3)
  115. #define SELECT_SH4_NOFPU (MASK_HARD_SH4 | SELECT_SH3)
  116. #define SELECT_SH4_SINGLE_ONLY (MASK_HARD_SH4 | SELECT_SH3E \
  117. | MASK_FPU_SINGLE_ONLY)
  118. #define SELECT_SH4 (MASK_SH4 | MASK_SH_E | MASK_HARD_SH4 \
  119. | SELECT_SH3)
  120. #define SELECT_SH4_SINGLE (MASK_FPU_SINGLE | SELECT_SH4)
  121. #define SELECT_SH4A_NOFPU (MASK_SH4A | SELECT_SH4_NOFPU)
  122. #define SELECT_SH4A_SINGLE_ONLY (MASK_SH4A | SELECT_SH4_SINGLE_ONLY)
  123. #define SELECT_SH4A (MASK_SH4A | SELECT_SH4)
  124. #define SELECT_SH4A_SINGLE (MASK_SH4A | SELECT_SH4_SINGLE)
  125. #define SELECT_SH5_64MEDIA (MASK_SH5 | MASK_SH4)
  126. #define SELECT_SH5_64MEDIA_NOFPU (MASK_SH5)
  127. #define SELECT_SH5_32MEDIA (MASK_SH5 | MASK_SH4 | MASK_SH_E)
  128. #define SELECT_SH5_32MEDIA_NOFPU (MASK_SH5 | MASK_SH_E)
  129. #define SELECT_SH5_COMPACT (MASK_SH5 | MASK_SH4 | SELECT_SH3E)
  130. #define SELECT_SH5_COMPACT_NOFPU (MASK_SH5 | SELECT_SH3)
  131. #if SUPPORT_SH1
  132. #define SUPPORT_SH2 1
  133. #endif
  134. #if SUPPORT_SH2
  135. #define SUPPORT_SH3 1
  136. #define SUPPORT_SH2A_NOFPU 1
  137. #endif
  138. #if SUPPORT_SH3
  139. #define SUPPORT_SH4_NOFPU 1
  140. #endif
  141. #if SUPPORT_SH4_NOFPU
  142. #define SUPPORT_SH4A_NOFPU 1
  143. #define SUPPORT_SH4AL 1
  144. #endif
  145. #if SUPPORT_SH2E
  146. #define SUPPORT_SH3E 1
  147. #define SUPPORT_SH2A_SINGLE_ONLY 1
  148. #endif
  149. #if SUPPORT_SH3E
  150. #define SUPPORT_SH4_SINGLE_ONLY 1
  151. #endif
  152. #if SUPPORT_SH4_SINGLE_ONLY
  153. #define SUPPORT_SH4A_SINGLE_ONLY 1
  154. #endif
  155. #if SUPPORT_SH4
  156. #define SUPPORT_SH4A 1
  157. #endif
  158. #if SUPPORT_SH4_SINGLE
  159. #define SUPPORT_SH4A_SINGLE 1
  160. #endif
  161. #if SUPPORT_SH5_COMPAT
  162. #define SUPPORT_SH5_32MEDIA 1
  163. #endif
  164. #if SUPPORT_SH5_COMPACT_NOFPU
  165. #define SUPPORT_SH5_32MEDIA_NOFPU 1
  166. #endif
  167. #define SUPPORT_ANY_SH5_32MEDIA \
  168. (SUPPORT_SH5_32MEDIA || SUPPORT_SH5_32MEDIA_NOFPU)
  169. #define SUPPORT_ANY_SH5_64MEDIA \
  170. (SUPPORT_SH5_64MEDIA || SUPPORT_SH5_64MEDIA_NOFPU)
  171. #define SUPPORT_ANY_SH5 \
  172. (SUPPORT_ANY_SH5_32MEDIA || SUPPORT_ANY_SH5_64MEDIA)
  173. /* Reset all target-selection flags. */
  174. #define MASK_ARCH (MASK_SH1 | MASK_SH2 | MASK_SH3 | MASK_SH_E | MASK_SH4 \
  175. | MASK_HARD_SH2A | MASK_HARD_SH2A_DOUBLE | MASK_SH4A \
  176. | MASK_HARD_SH4 | MASK_FPU_SINGLE | MASK_SH5 \
  177. | MASK_FPU_SINGLE_ONLY)
  178. /* This defaults us to big-endian. */
  179. #ifndef TARGET_ENDIAN_DEFAULT
  180. #define TARGET_ENDIAN_DEFAULT 0
  181. #endif
  182. #ifndef TARGET_OPT_DEFAULT
  183. #define TARGET_OPT_DEFAULT 0
  184. #endif
  185. #define TARGET_DEFAULT \
  186. (TARGET_CPU_DEFAULT | TARGET_ENDIAN_DEFAULT | TARGET_OPT_DEFAULT)
  187. #ifndef SH_MULTILIB_CPU_DEFAULT
  188. #define SH_MULTILIB_CPU_DEFAULT "m1"
  189. #endif
  190. #if TARGET_ENDIAN_DEFAULT
  191. #define MULTILIB_DEFAULTS { "ml", SH_MULTILIB_CPU_DEFAULT }
  192. #else
  193. #define MULTILIB_DEFAULTS { "mb", SH_MULTILIB_CPU_DEFAULT }
  194. #endif
  195. #define CPP_SPEC " %(subtarget_cpp_spec) "
  196. #ifndef SUBTARGET_CPP_SPEC
  197. #define SUBTARGET_CPP_SPEC ""
  198. #endif
  199. #ifndef SUBTARGET_EXTRA_SPECS
  200. #define SUBTARGET_EXTRA_SPECS
  201. #endif
  202. #define EXTRA_SPECS \
  203. { "subtarget_cpp_spec", SUBTARGET_CPP_SPEC }, \
  204. { "link_emul_prefix", LINK_EMUL_PREFIX }, \
  205. { "link_default_cpu_emul", LINK_DEFAULT_CPU_EMUL }, \
  206. { "subtarget_link_emul_suffix", SUBTARGET_LINK_EMUL_SUFFIX }, \
  207. { "subtarget_link_spec", SUBTARGET_LINK_SPEC }, \
  208. { "subtarget_asm_endian_spec", SUBTARGET_ASM_ENDIAN_SPEC }, \
  209. { "subtarget_asm_relax_spec", SUBTARGET_ASM_RELAX_SPEC }, \
  210. { "subtarget_asm_isa_spec", SUBTARGET_ASM_ISA_SPEC }, \
  211. { "subtarget_asm_spec", SUBTARGET_ASM_SPEC }, \
  212. SUBTARGET_EXTRA_SPECS
  213. #if TARGET_CPU_DEFAULT & MASK_HARD_SH4
  214. #define SUBTARGET_ASM_RELAX_SPEC "%{!m1:%{!m2:%{!m3*:%{!m5*:-isa=sh4-up}}}}"
  215. #else
  216. #define SUBTARGET_ASM_RELAX_SPEC "%{m4*:-isa=sh4-up}"
  217. #endif
  218. /* Define which ISA type to pass to the assembler.
  219. For SH4 we pass SH4A to allow using some instructions that are available
  220. on some SH4 variants, but officially are part of the SH4A ISA. */
  221. #define SH_ASM_SPEC \
  222. "%(subtarget_asm_endian_spec) %{mrelax:-relax %(subtarget_asm_relax_spec)} \
  223. %(subtarget_asm_isa_spec) %(subtarget_asm_spec) \
  224. %{m1:--isa=sh} \
  225. %{m2:--isa=sh2} \
  226. %{m2e:--isa=sh2e} \
  227. %{m3:--isa=sh3} \
  228. %{m3e:--isa=sh3e} \
  229. %{m4:--isa=sh4a} \
  230. %{m4-single:--isa=sh4a} \
  231. %{m4-single-only:--isa=sh4a} \
  232. %{m4-nofpu:--isa=sh4a-nofpu} \
  233. %{m4a:--isa=sh4a} \
  234. %{m4a-single:--isa=sh4a} \
  235. %{m4a-single-only:--isa=sh4a} \
  236. %{m4a-nofpu:--isa=sh4a-nofpu} \
  237. %{m2a:--isa=sh2a} \
  238. %{m2a-single:--isa=sh2a} \
  239. %{m2a-single-only:--isa=sh2a} \
  240. %{m2a-nofpu:--isa=sh2a-nofpu} \
  241. %{m5-compact*:--isa=SHcompact} \
  242. %{m5-32media*:--isa=SHmedia --abi=32} \
  243. %{m5-64media*:--isa=SHmedia --abi=64} \
  244. %{m4al:-dsp} %{mcut2-workaround:-cut2-workaround}"
  245. #define ASM_SPEC SH_ASM_SPEC
  246. #ifndef SUBTARGET_ASM_ENDIAN_SPEC
  247. #if TARGET_ENDIAN_DEFAULT == MASK_LITTLE_ENDIAN
  248. #define SUBTARGET_ASM_ENDIAN_SPEC "%{mb:-big} %{!mb:-little}"
  249. #else
  250. #define SUBTARGET_ASM_ENDIAN_SPEC "%{ml:-little} %{!ml:-big}"
  251. #endif
  252. #endif
  253. #if STRICT_NOFPU == 1
  254. /* Strict nofpu means that the compiler should tell the assembler
  255. to reject FPU instructions. E.g. from ASM inserts. */
  256. #if TARGET_CPU_DEFAULT & MASK_HARD_SH4 && !(TARGET_CPU_DEFAULT & MASK_SH_E)
  257. #define SUBTARGET_ASM_ISA_SPEC "%{!m1:%{!m2:%{!m3*:%{m4-nofpu|!m4*:%{!m5:-isa=sh4-nofpu}}}}}"
  258. #else
  259. /* If there were an -isa option for sh5-nofpu then it would also go here. */
  260. #define SUBTARGET_ASM_ISA_SPEC \
  261. "%{m4-nofpu:-isa=sh4-nofpu} " ASM_ISA_DEFAULT_SPEC
  262. #endif
  263. #else /* ! STRICT_NOFPU */
  264. #define SUBTARGET_ASM_ISA_SPEC ASM_ISA_DEFAULT_SPEC
  265. #endif
  266. #ifndef SUBTARGET_ASM_SPEC
  267. #define SUBTARGET_ASM_SPEC ""
  268. #endif
  269. #if TARGET_ENDIAN_DEFAULT == MASK_LITTLE_ENDIAN
  270. #define LINK_EMUL_PREFIX "sh%{!mb:l}"
  271. #else
  272. #define LINK_EMUL_PREFIX "sh%{ml:l}"
  273. #endif
  274. #if TARGET_CPU_DEFAULT & MASK_SH5
  275. #if TARGET_CPU_DEFAULT & MASK_SH_E
  276. #define LINK_DEFAULT_CPU_EMUL "32"
  277. #if TARGET_CPU_DEFAULT & MASK_SH1
  278. #define ASM_ISA_SPEC_DEFAULT "--isa=SHcompact"
  279. #else
  280. #define ASM_ISA_SPEC_DEFAULT "--isa=SHmedia --abi=32"
  281. #endif /* MASK_SH1 */
  282. #else /* !MASK_SH_E */
  283. #define LINK_DEFAULT_CPU_EMUL "64"
  284. #define ASM_ISA_SPEC_DEFAULT "--isa=SHmedia --abi=64"
  285. #endif /* MASK_SH_E */
  286. #define ASM_ISA_DEFAULT_SPEC \
  287. " %{!m1:%{!m2*:%{!m3*:%{!m4*:%{!m5*:" ASM_ISA_SPEC_DEFAULT "}}}}}"
  288. #else /* !MASK_SH5 */
  289. #define LINK_DEFAULT_CPU_EMUL ""
  290. #define ASM_ISA_DEFAULT_SPEC ""
  291. #endif /* MASK_SH5 */
  292. #define SUBTARGET_LINK_EMUL_SUFFIX ""
  293. #define SUBTARGET_LINK_SPEC ""
  294. /* Go via SH_LINK_SPEC to avoid code replication. */
  295. #define LINK_SPEC SH_LINK_SPEC
  296. #define SH_LINK_SPEC "\
  297. -m %(link_emul_prefix)\
  298. %{m5-compact*|m5-32media*:32}\
  299. %{m5-64media*:64}\
  300. %{!m1:%{!m2:%{!m3*:%{!m4*:%{!m5*:%(link_default_cpu_emul)}}}}}\
  301. %(subtarget_link_emul_suffix) \
  302. %{mrelax:-relax} %(subtarget_link_spec)"
  303. #ifndef SH_DIV_STR_FOR_SIZE
  304. #define SH_DIV_STR_FOR_SIZE "call"
  305. #endif
  306. /* SH2A does not support little-endian. Catch such combinations
  307. taking into account the default configuration. */
  308. #if TARGET_ENDIAN_DEFAULT == MASK_BIG_ENDIAN
  309. #define IS_LITTLE_ENDIAN_OPTION "%{ml:"
  310. #else
  311. #define IS_LITTLE_ENDIAN_OPTION "%{!mb:"
  312. #endif
  313. #if TARGET_CPU_DEFAULT & MASK_HARD_SH2A
  314. #define UNSUPPORTED_SH2A IS_LITTLE_ENDIAN_OPTION \
  315. "%{m2a*|!m1:%{!m2*:%{!m3*:%{!m4*:{!m5*:%eSH2a does not support little-endian}}}}}}"
  316. #else
  317. #define UNSUPPORTED_SH2A IS_LITTLE_ENDIAN_OPTION \
  318. "%{m2a*:%eSH2a does not support little-endian}}"
  319. #endif
  320. #undef DRIVER_SELF_SPECS
  321. #define DRIVER_SELF_SPECS UNSUPPORTED_SH2A
  322. #define ASSEMBLER_DIALECT assembler_dialect
  323. extern int assembler_dialect;
  324. enum sh_divide_strategy_e {
  325. /* SH5 strategies. */
  326. SH_DIV_CALL,
  327. SH_DIV_CALL2,
  328. SH_DIV_FP, /* We could do this also for SH4. */
  329. SH_DIV_INV,
  330. SH_DIV_INV_MINLAT,
  331. SH_DIV_INV20U,
  332. SH_DIV_INV20L,
  333. SH_DIV_INV_CALL,
  334. SH_DIV_INV_CALL2,
  335. SH_DIV_INV_FP,
  336. /* SH1 .. SH4 strategies. Because of the small number of registers
  337. available, the compiler uses knowledge of the actual set of registers
  338. being clobbered by the different functions called. */
  339. SH_DIV_CALL_DIV1, /* No FPU, medium size, highest latency. */
  340. SH_DIV_CALL_FP, /* FPU needed, small size, high latency. */
  341. SH_DIV_CALL_TABLE, /* No FPU, large size, medium latency. */
  342. SH_DIV_INTRINSIC
  343. };
  344. extern enum sh_divide_strategy_e sh_div_strategy;
  345. #ifndef SH_DIV_STRATEGY_DEFAULT
  346. #define SH_DIV_STRATEGY_DEFAULT SH_DIV_CALL
  347. #endif
  348. #define SUBTARGET_OVERRIDE_OPTIONS (void) 0
  349. /* Target machine storage layout. */
  350. #define TARGET_BIG_ENDIAN (!TARGET_LITTLE_ENDIAN)
  351. #define SH_REG_MSW_OFFSET (TARGET_LITTLE_ENDIAN ? 1 : 0)
  352. #define SH_REG_LSW_OFFSET (TARGET_LITTLE_ENDIAN ? 0 : 1)
  353. /* Define this if most significant bit is lowest numbered
  354. in instructions that operate on numbered bit-fields. */
  355. #define BITS_BIG_ENDIAN 0
  356. /* Define this if most significant byte of a word is the lowest numbered. */
  357. #define BYTES_BIG_ENDIAN TARGET_BIG_ENDIAN
  358. /* Define this if most significant word of a multiword number is the lowest
  359. numbered. */
  360. #define WORDS_BIG_ENDIAN TARGET_BIG_ENDIAN
  361. #define MAX_BITS_PER_WORD 64
  362. /* Width in bits of an `int'. We want just 32-bits, even if words are
  363. longer. */
  364. #define INT_TYPE_SIZE 32
  365. /* Width in bits of a `long'. */
  366. #define LONG_TYPE_SIZE (TARGET_SHMEDIA64 ? 64 : 32)
  367. /* Width in bits of a `long long'. */
  368. #define LONG_LONG_TYPE_SIZE 64
  369. /* Width in bits of a `long double'. */
  370. #define LONG_DOUBLE_TYPE_SIZE 64
  371. /* Width of a word, in units (bytes). */
  372. #define UNITS_PER_WORD (TARGET_SHMEDIA ? 8 : 4)
  373. #define MIN_UNITS_PER_WORD 4
  374. /* Scaling factor for Dwarf data offsets for CFI information.
  375. The dwarf2out.c default would use -UNITS_PER_WORD, which is -8 for
  376. SHmedia; however, since we do partial register saves for the registers
  377. visible to SHcompact, and for target registers for SHMEDIA32, we have
  378. to allow saves that are only 4-byte aligned. */
  379. #define DWARF_CIE_DATA_ALIGNMENT -4
  380. /* Width in bits of a pointer.
  381. See also the macro `Pmode' defined below. */
  382. #define POINTER_SIZE (TARGET_SHMEDIA64 ? 64 : 32)
  383. /* Allocation boundary (in *bits*) for storing arguments in argument list. */
  384. #define PARM_BOUNDARY (TARGET_SH5 ? 64 : 32)
  385. /* Boundary (in *bits*) on which stack pointer should be aligned. */
  386. #define STACK_BOUNDARY BIGGEST_ALIGNMENT
  387. /* The log (base 2) of the cache line size, in bytes. Processors prior to
  388. SH2 have no actual cache, but they fetch code in chunks of 4 bytes.
  389. The SH2/3 have 16 byte cache lines, and the SH4 has a 32 byte cache line */
  390. #define CACHE_LOG ((TARGET_HARD_SH4 || TARGET_SH5) ? 5 : TARGET_SH2 ? 4 : 2)
  391. /* ABI given & required minimum allocation boundary (in *bits*) for the
  392. code of a function. */
  393. #define FUNCTION_BOUNDARY (16 << TARGET_SHMEDIA)
  394. /* On SH5, the lowest bit is used to indicate SHmedia functions, so
  395. the vbit must go into the delta field of
  396. pointers-to-member-functions. */
  397. #define TARGET_PTRMEMFUNC_VBIT_LOCATION \
  398. (TARGET_SH5 ? ptrmemfunc_vbit_in_delta : ptrmemfunc_vbit_in_pfn)
  399. /* Alignment of field after `int : 0' in a structure. */
  400. #define EMPTY_FIELD_BOUNDARY 32
  401. /* No data type wants to be aligned rounder than this. */
  402. #define BIGGEST_ALIGNMENT (TARGET_ALIGN_DOUBLE ? 64 : 32)
  403. /* The best alignment to use in cases where we have a choice. */
  404. #define FASTEST_ALIGNMENT (TARGET_SH5 ? 64 : 32)
  405. /* Make strings word-aligned so strcpy from constants will be faster. */
  406. #define CONSTANT_ALIGNMENT(EXP, ALIGN) \
  407. ((TREE_CODE (EXP) == STRING_CST \
  408. && (ALIGN) < FASTEST_ALIGNMENT) \
  409. ? FASTEST_ALIGNMENT : (ALIGN))
  410. /* get_mode_alignment assumes complex values are always held in multiple
  411. registers, but that is not the case on the SH; CQImode and CHImode are
  412. held in a single integer register. SH5 also holds CSImode and SCmode
  413. values in integer registers. This is relevant for argument passing on
  414. SHcompact as we use a stack temp in order to pass CSImode by reference. */
  415. #define LOCAL_ALIGNMENT(TYPE, ALIGN) \
  416. ((GET_MODE_CLASS (TYPE_MODE (TYPE)) == MODE_COMPLEX_INT \
  417. || GET_MODE_CLASS (TYPE_MODE (TYPE)) == MODE_COMPLEX_FLOAT) \
  418. ? (unsigned) MIN (BIGGEST_ALIGNMENT, GET_MODE_BITSIZE (TYPE_MODE (TYPE))) \
  419. : (unsigned) DATA_ALIGNMENT(TYPE, ALIGN))
  420. /* Make arrays of chars word-aligned for the same reasons. */
  421. #define DATA_ALIGNMENT(TYPE, ALIGN) \
  422. (TREE_CODE (TYPE) == ARRAY_TYPE \
  423. && TYPE_MODE (TREE_TYPE (TYPE)) == QImode \
  424. && (ALIGN) < FASTEST_ALIGNMENT ? FASTEST_ALIGNMENT : (ALIGN))
  425. /* Number of bits which any structure or union's size must be a
  426. multiple of. Each structure or union's size is rounded up to a
  427. multiple of this. */
  428. #define STRUCTURE_SIZE_BOUNDARY (TARGET_PADSTRUCT ? 32 : 8)
  429. /* Set this nonzero if move instructions will actually fail to work
  430. when given unaligned data. */
  431. #define STRICT_ALIGNMENT 1
  432. /* If LABEL_AFTER_BARRIER demands an alignment, return its base 2 logarithm. */
  433. #define LABEL_ALIGN_AFTER_BARRIER(LABEL_AFTER_BARRIER) \
  434. barrier_align (LABEL_AFTER_BARRIER)
  435. #define LOOP_ALIGN(A_LABEL) sh_loop_align (A_LABEL)
  436. #define LABEL_ALIGN(A_LABEL) \
  437. ( \
  438. (PREV_INSN (A_LABEL) \
  439. && NONJUMP_INSN_P (PREV_INSN (A_LABEL)) \
  440. && GET_CODE (PATTERN (PREV_INSN (A_LABEL))) == UNSPEC_VOLATILE \
  441. && XINT (PATTERN (PREV_INSN (A_LABEL)), 1) == UNSPECV_ALIGN) \
  442. /* explicit alignment insn in constant tables. */ \
  443. ? INTVAL (XVECEXP (PATTERN (PREV_INSN (A_LABEL)), 0, 0)) \
  444. : 0)
  445. /* Jump tables must be 32 bit aligned, no matter the size of the element. */
  446. #define ADDR_VEC_ALIGN(ADDR_VEC) 2
  447. /* The base two logarithm of the known minimum alignment of an insn length. */
  448. #define INSN_LENGTH_ALIGNMENT(A_INSN) \
  449. (NONJUMP_INSN_P (A_INSN) \
  450. ? 1 << TARGET_SHMEDIA \
  451. : JUMP_P (A_INSN) || CALL_P (A_INSN) \
  452. ? 1 << TARGET_SHMEDIA \
  453. : CACHE_LOG)
  454. /* Standard register usage. */
  455. /* Register allocation for the Renesas calling convention:
  456. r0 arg return
  457. r1..r3 scratch
  458. r4..r7 args in
  459. r8..r13 call saved
  460. r14 frame pointer/call saved
  461. r15 stack pointer
  462. ap arg pointer (doesn't really exist, always eliminated)
  463. pr subroutine return address
  464. t t bit
  465. mach multiply/accumulate result, high part
  466. macl multiply/accumulate result, low part.
  467. fpul fp/int communication register
  468. rap return address pointer register
  469. fr0 fp arg return
  470. fr1..fr3 scratch floating point registers
  471. fr4..fr11 fp args in
  472. fr12..fr15 call saved floating point registers */
  473. #define MAX_REGISTER_NAME_LENGTH 6
  474. extern char sh_register_names[][MAX_REGISTER_NAME_LENGTH + 1];
  475. #define SH_REGISTER_NAMES_INITIALIZER \
  476. { \
  477. "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \
  478. "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \
  479. "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", \
  480. "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31", \
  481. "r32", "r33", "r34", "r35", "r36", "r37", "r38", "r39", \
  482. "r40", "r41", "r42", "r43", "r44", "r45", "r46", "r47", \
  483. "r48", "r49", "r50", "r51", "r52", "r53", "r54", "r55", \
  484. "r56", "r57", "r58", "r59", "r60", "r61", "r62", "r63", \
  485. "fr0", "fr1", "fr2", "fr3", "fr4", "fr5", "fr6", "fr7", \
  486. "fr8", "fr9", "fr10", "fr11", "fr12", "fr13", "fr14", "fr15", \
  487. "fr16", "fr17", "fr18", "fr19", "fr20", "fr21", "fr22", "fr23", \
  488. "fr24", "fr25", "fr26", "fr27", "fr28", "fr29", "fr30", "fr31", \
  489. "fr32", "fr33", "fr34", "fr35", "fr36", "fr37", "fr38", "fr39", \
  490. "fr40", "fr41", "fr42", "fr43", "fr44", "fr45", "fr46", "fr47", \
  491. "fr48", "fr49", "fr50", "fr51", "fr52", "fr53", "fr54", "fr55", \
  492. "fr56", "fr57", "fr58", "fr59", "fr60", "fr61", "fr62", "fr63", \
  493. "tr0", "tr1", "tr2", "tr3", "tr4", "tr5", "tr6", "tr7", \
  494. "xd0", "xd2", "xd4", "xd6", "xd8", "xd10", "xd12", "xd14", \
  495. "gbr", "ap", "pr", "t", "mach", "macl", "fpul", "fpscr", \
  496. "rap", "sfp", "fpscr0", "fpscr1" \
  497. }
  498. #define REGNAMES_ARR_INDEX_1(index) \
  499. (sh_register_names[index])
  500. #define REGNAMES_ARR_INDEX_2(index) \
  501. REGNAMES_ARR_INDEX_1 ((index)), REGNAMES_ARR_INDEX_1 ((index)+1)
  502. #define REGNAMES_ARR_INDEX_4(index) \
  503. REGNAMES_ARR_INDEX_2 ((index)), REGNAMES_ARR_INDEX_2 ((index)+2)
  504. #define REGNAMES_ARR_INDEX_8(index) \
  505. REGNAMES_ARR_INDEX_4 ((index)), REGNAMES_ARR_INDEX_4 ((index)+4)
  506. #define REGNAMES_ARR_INDEX_16(index) \
  507. REGNAMES_ARR_INDEX_8 ((index)), REGNAMES_ARR_INDEX_8 ((index)+8)
  508. #define REGNAMES_ARR_INDEX_32(index) \
  509. REGNAMES_ARR_INDEX_16 ((index)), REGNAMES_ARR_INDEX_16 ((index)+16)
  510. #define REGNAMES_ARR_INDEX_64(index) \
  511. REGNAMES_ARR_INDEX_32 ((index)), REGNAMES_ARR_INDEX_32 ((index)+32)
  512. #define REGISTER_NAMES \
  513. { \
  514. REGNAMES_ARR_INDEX_64 (0), \
  515. REGNAMES_ARR_INDEX_64 (64), \
  516. REGNAMES_ARR_INDEX_8 (128), \
  517. REGNAMES_ARR_INDEX_8 (136), \
  518. REGNAMES_ARR_INDEX_8 (144), \
  519. REGNAMES_ARR_INDEX_4 (152) \
  520. }
  521. #define ADDREGNAMES_SIZE 32
  522. #define MAX_ADDITIONAL_REGISTER_NAME_LENGTH 4
  523. extern char sh_additional_register_names[ADDREGNAMES_SIZE] \
  524. [MAX_ADDITIONAL_REGISTER_NAME_LENGTH + 1];
  525. #define SH_ADDITIONAL_REGISTER_NAMES_INITIALIZER \
  526. { \
  527. "dr0", "dr2", "dr4", "dr6", "dr8", "dr10", "dr12", "dr14", \
  528. "dr16", "dr18", "dr20", "dr22", "dr24", "dr26", "dr28", "dr30", \
  529. "dr32", "dr34", "dr36", "dr38", "dr40", "dr42", "dr44", "dr46", \
  530. "dr48", "dr50", "dr52", "dr54", "dr56", "dr58", "dr60", "dr62" \
  531. }
  532. #define ADDREGNAMES_REGNO(index) \
  533. ((index < 32) ? (FIRST_FP_REG + (index) * 2) \
  534. : (-1))
  535. #define ADDREGNAMES_ARR_INDEX_1(index) \
  536. { (sh_additional_register_names[index]), ADDREGNAMES_REGNO (index) }
  537. #define ADDREGNAMES_ARR_INDEX_2(index) \
  538. ADDREGNAMES_ARR_INDEX_1 ((index)), ADDREGNAMES_ARR_INDEX_1 ((index)+1)
  539. #define ADDREGNAMES_ARR_INDEX_4(index) \
  540. ADDREGNAMES_ARR_INDEX_2 ((index)), ADDREGNAMES_ARR_INDEX_2 ((index)+2)
  541. #define ADDREGNAMES_ARR_INDEX_8(index) \
  542. ADDREGNAMES_ARR_INDEX_4 ((index)), ADDREGNAMES_ARR_INDEX_4 ((index)+4)
  543. #define ADDREGNAMES_ARR_INDEX_16(index) \
  544. ADDREGNAMES_ARR_INDEX_8 ((index)), ADDREGNAMES_ARR_INDEX_8 ((index)+8)
  545. #define ADDREGNAMES_ARR_INDEX_32(index) \
  546. ADDREGNAMES_ARR_INDEX_16 ((index)), ADDREGNAMES_ARR_INDEX_16 ((index)+16)
  547. #define ADDITIONAL_REGISTER_NAMES \
  548. { \
  549. ADDREGNAMES_ARR_INDEX_32 (0) \
  550. }
  551. /* Number of actual hardware registers.
  552. The hardware registers are assigned numbers for the compiler
  553. from 0 to just below FIRST_PSEUDO_REGISTER.
  554. All registers that the compiler knows about must be given numbers,
  555. even those that are not normally considered general registers. */
  556. /* There are many other relevant definitions in sh.md's md_constants. */
  557. #define FIRST_GENERAL_REG R0_REG
  558. #define LAST_GENERAL_REG (FIRST_GENERAL_REG + (TARGET_SHMEDIA ? 63 : 15))
  559. #define FIRST_FP_REG DR0_REG
  560. #define LAST_FP_REG (FIRST_FP_REG + \
  561. (TARGET_SHMEDIA_FPU ? 63 : TARGET_SH2E ? 15 : -1))
  562. #define FIRST_XD_REG XD0_REG
  563. #define LAST_XD_REG (FIRST_XD_REG + ((TARGET_SH4 && TARGET_FMOVD) ? 7 : -1))
  564. #define FIRST_TARGET_REG TR0_REG
  565. #define LAST_TARGET_REG (FIRST_TARGET_REG + (TARGET_SHMEDIA ? 7 : -1))
  566. /* Registers that can be accessed through bank0 or bank1 depending on sr.md. */
  567. #define FIRST_BANKED_REG R0_REG
  568. #define LAST_BANKED_REG R7_REG
  569. #define BANKED_REGISTER_P(REGNO) \
  570. IN_RANGE ((REGNO), \
  571. (unsigned HOST_WIDE_INT) FIRST_BANKED_REG, \
  572. (unsigned HOST_WIDE_INT) LAST_BANKED_REG)
  573. #define GENERAL_REGISTER_P(REGNO) \
  574. IN_RANGE ((REGNO), \
  575. (unsigned HOST_WIDE_INT) FIRST_GENERAL_REG, \
  576. (unsigned HOST_WIDE_INT) LAST_GENERAL_REG)
  577. #define GENERAL_OR_AP_REGISTER_P(REGNO) \
  578. (GENERAL_REGISTER_P (REGNO) || ((REGNO) == AP_REG) \
  579. || ((REGNO) == FRAME_POINTER_REGNUM))
  580. #define FP_REGISTER_P(REGNO) \
  581. ((int) (REGNO) >= FIRST_FP_REG && (int) (REGNO) <= LAST_FP_REG)
  582. #define XD_REGISTER_P(REGNO) \
  583. ((int) (REGNO) >= FIRST_XD_REG && (int) (REGNO) <= LAST_XD_REG)
  584. #define FP_OR_XD_REGISTER_P(REGNO) \
  585. (FP_REGISTER_P (REGNO) || XD_REGISTER_P (REGNO))
  586. #define FP_ANY_REGISTER_P(REGNO) \
  587. (FP_REGISTER_P (REGNO) || XD_REGISTER_P (REGNO) || (REGNO) == FPUL_REG)
  588. #define SPECIAL_REGISTER_P(REGNO) \
  589. ((REGNO) == GBR_REG || (REGNO) == T_REG \
  590. || (REGNO) == MACH_REG || (REGNO) == MACL_REG \
  591. || (REGNO) == FPSCR_MODES_REG || (REGNO) == FPSCR_STAT_REG)
  592. #define TARGET_REGISTER_P(REGNO) \
  593. ((int) (REGNO) >= FIRST_TARGET_REG && (int) (REGNO) <= LAST_TARGET_REG)
  594. #define SHMEDIA_REGISTER_P(REGNO) \
  595. (GENERAL_REGISTER_P (REGNO) || FP_REGISTER_P (REGNO) \
  596. || TARGET_REGISTER_P (REGNO))
  597. /* This is to be used in TARGET_CONDITIONAL_REGISTER_USAGE, to mark
  598. registers that should be fixed. */
  599. #define VALID_REGISTER_P(REGNO) \
  600. (SHMEDIA_REGISTER_P (REGNO) || XD_REGISTER_P (REGNO) \
  601. || (REGNO) == AP_REG || (REGNO) == RAP_REG \
  602. || (REGNO) == FRAME_POINTER_REGNUM \
  603. || (TARGET_SH1 && (SPECIAL_REGISTER_P (REGNO) || (REGNO) == PR_REG)) \
  604. || (TARGET_SH2E && (REGNO) == FPUL_REG))
  605. /* The mode that should be generally used to store a register by
  606. itself in the stack, or to load it back. */
  607. #define REGISTER_NATURAL_MODE(REGNO) \
  608. (FP_REGISTER_P (REGNO) ? SFmode \
  609. : XD_REGISTER_P (REGNO) ? DFmode \
  610. : TARGET_SHMEDIA && ! HARD_REGNO_CALL_PART_CLOBBERED ((REGNO), DImode) \
  611. ? DImode \
  612. : SImode)
  613. #define FIRST_PSEUDO_REGISTER 156
  614. /* Don't count soft frame pointer. */
  615. #define DWARF_FRAME_REGISTERS (153)
  616. /* 1 for registers that have pervasive standard uses
  617. and are not available for the register allocator.
  618. Mach register is fixed 'cause it's only 10 bits wide for SH1.
  619. It is 32 bits wide for SH2. */
  620. #define FIXED_REGISTERS \
  621. { \
  622. /* Regular registers. */ \
  623. 0, 0, 0, 0, 0, 0, 0, 0, \
  624. 0, 0, 0, 0, 0, 0, 0, 1, \
  625. /* r16 is reserved, r18 is the former pr. */ \
  626. 1, 0, 0, 0, 0, 0, 0, 0, \
  627. /* r24 is reserved for the OS; r25, for the assembler or linker. */ \
  628. /* r26 is a global variable data pointer; r27 is for constants. */ \
  629. 1, 1, 1, 1, 0, 0, 0, 0, \
  630. 0, 0, 0, 0, 0, 0, 0, 0, \
  631. 0, 0, 0, 0, 0, 0, 0, 0, \
  632. 0, 0, 0, 0, 0, 0, 0, 0, \
  633. 0, 0, 0, 0, 0, 0, 0, 1, \
  634. /* FP registers. */ \
  635. 0, 0, 0, 0, 0, 0, 0, 0, \
  636. 0, 0, 0, 0, 0, 0, 0, 0, \
  637. 0, 0, 0, 0, 0, 0, 0, 0, \
  638. 0, 0, 0, 0, 0, 0, 0, 0, \
  639. 0, 0, 0, 0, 0, 0, 0, 0, \
  640. 0, 0, 0, 0, 0, 0, 0, 0, \
  641. 0, 0, 0, 0, 0, 0, 0, 0, \
  642. 0, 0, 0, 0, 0, 0, 0, 0, \
  643. /* Branch target registers. */ \
  644. 0, 0, 0, 0, 0, 0, 0, 0, \
  645. /* XD registers. */ \
  646. 0, 0, 0, 0, 0, 0, 0, 0, \
  647. /*"gbr", "ap", "pr", "t", "mach", "macl", "fpul", "fpscr", */ \
  648. 1, 1, 1, 1, 1, 1, 0, 1, \
  649. /*"rap", "sfp","fpscr0","fpscr1" */ \
  650. 1, 1, 1, 1, \
  651. }
  652. /* 1 for registers not available across function calls.
  653. These must include the FIXED_REGISTERS and also any
  654. registers that can be used without being saved.
  655. The latter must include the registers where values are returned
  656. and the register where structure-value addresses are passed.
  657. Aside from that, you can include as many other registers as you like. */
  658. #define CALL_USED_REGISTERS \
  659. { \
  660. /* Regular registers. */ \
  661. 1, 1, 1, 1, 1, 1, 1, 1, \
  662. /* R8 and R9 are call-clobbered on SH5, but not on earlier SH ABIs. \
  663. Only the lower 32bits of R10-R14 are guaranteed to be preserved \
  664. across SH5 function calls. */ \
  665. 0, 0, 0, 0, 0, 0, 0, 1, \
  666. 1, 1, 1, 1, 1, 1, 1, 1, \
  667. 1, 1, 1, 1, 0, 0, 0, 0, \
  668. 0, 0, 0, 0, 1, 1, 1, 1, \
  669. 1, 1, 1, 1, 0, 0, 0, 0, \
  670. 0, 0, 0, 0, 0, 0, 0, 0, \
  671. 0, 0, 0, 0, 1, 1, 1, 1, \
  672. /* FP registers. */ \
  673. 1, 1, 1, 1, 1, 1, 1, 1, \
  674. 1, 1, 1, 1, 0, 0, 0, 0, \
  675. 1, 1, 1, 1, 1, 1, 1, 1, \
  676. 1, 1, 1, 1, 1, 1, 1, 1, \
  677. 1, 1, 1, 1, 0, 0, 0, 0, \
  678. 0, 0, 0, 0, 0, 0, 0, 0, \
  679. 0, 0, 0, 0, 0, 0, 0, 0, \
  680. 0, 0, 0, 0, 0, 0, 0, 0, \
  681. /* Branch target registers. */ \
  682. 1, 1, 1, 1, 1, 0, 0, 0, \
  683. /* XD registers. */ \
  684. 1, 1, 1, 1, 1, 1, 0, 0, \
  685. /*"gbr", "ap", "pr", "t", "mach", "macl", "fpul", "fpscr", */ \
  686. 1, 1, 1, 1, 1, 1, 1, 1, \
  687. /*"rap", "sfp","fpscr0","fpscr1" */ \
  688. 1, 1, 1, 1, \
  689. }
  690. /* CALL_REALLY_USED_REGISTERS is used as a default setting, which is then
  691. overridden by -fcall-saved-* and -fcall-used-* options and then by
  692. TARGET_CONDITIONAL_REGISTER_USAGE. There we might want to make a
  693. register call-used, yet fixed, like PIC_OFFSET_TABLE_REGNUM. */
  694. #define CALL_REALLY_USED_REGISTERS \
  695. { \
  696. /* Regular registers. */ \
  697. 1, 1, 1, 1, 1, 1, 1, 1, \
  698. /* R8 and R9 are call-clobbered on SH5, but not on earlier SH ABIs. \
  699. Only the lower 32bits of R10-R14 are guaranteed to be preserved \
  700. across SH5 function calls. */ \
  701. 0, 0, 0, 0, 0, 0, 0, 1, \
  702. 1, 1, 1, 1, 1, 1, 1, 1, \
  703. 1, 1, 1, 1, 0, 0, 0, 0, \
  704. 0, 0, 0, 0, 1, 1, 1, 1, \
  705. 1, 1, 1, 1, 0, 0, 0, 0, \
  706. 0, 0, 0, 0, 0, 0, 0, 0, \
  707. 0, 0, 0, 0, 1, 1, 1, 1, \
  708. /* FP registers. */ \
  709. 1, 1, 1, 1, 1, 1, 1, 1, \
  710. 1, 1, 1, 1, 0, 0, 0, 0, \
  711. 1, 1, 1, 1, 1, 1, 1, 1, \
  712. 1, 1, 1, 1, 1, 1, 1, 1, \
  713. 1, 1, 1, 1, 0, 0, 0, 0, \
  714. 0, 0, 0, 0, 0, 0, 0, 0, \
  715. 0, 0, 0, 0, 0, 0, 0, 0, \
  716. 0, 0, 0, 0, 0, 0, 0, 0, \
  717. /* Branch target registers. */ \
  718. 1, 1, 1, 1, 1, 0, 0, 0, \
  719. /* XD registers. */ \
  720. 1, 1, 1, 1, 1, 1, 0, 0, \
  721. /*"gbr", "ap", "pr", "t", "mach", "macl", "fpul", "fpscr", */ \
  722. 0, 1, 1, 1, 1, 1, 1, 1, \
  723. /*"rap", "sfp","fpscr0","fpscr1" */ \
  724. 1, 1, 0, 0, \
  725. }
  726. /* Only the lower 32-bits of R10-R14 are guaranteed to be preserved
  727. across SHcompact function calls. We can't tell whether a called
  728. function is SHmedia or SHcompact, so we assume it may be when
  729. compiling SHmedia code with the 32-bit ABI, since that's the only
  730. ABI that can be linked with SHcompact code. */
  731. #define HARD_REGNO_CALL_PART_CLOBBERED(REGNO,MODE) \
  732. (TARGET_SHMEDIA32 \
  733. && GET_MODE_SIZE (MODE) > 4 \
  734. && (((REGNO) >= FIRST_GENERAL_REG + 10 \
  735. && (REGNO) <= FIRST_GENERAL_REG + 15) \
  736. || TARGET_REGISTER_P (REGNO) \
  737. || (REGNO) == PR_MEDIA_REG))
  738. /* Return number of consecutive hard regs needed starting at reg REGNO
  739. to hold something of mode MODE.
  740. This is ordinarily the length in words of a value of mode MODE
  741. but can be less for certain modes in special long registers.
  742. On the SH all but the XD regs are UNITS_PER_WORD bits wide. */
  743. #define HARD_REGNO_NREGS(REGNO, MODE) \
  744. (XD_REGISTER_P (REGNO) \
  745. ? ((GET_MODE_SIZE (MODE) + (2*UNITS_PER_WORD - 1)) / (2*UNITS_PER_WORD)) \
  746. : (TARGET_SHMEDIA && FP_REGISTER_P (REGNO)) \
  747. ? ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD/2 - 1) / (UNITS_PER_WORD/2)) \
  748. : ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
  749. /* Value is 1 if hard register REGNO can hold a value of machine-mode MODE. */
  750. #define HARD_REGNO_MODE_OK(REGNO, MODE) \
  751. sh_hard_regno_mode_ok ((REGNO), (MODE))
  752. /* Value is 1 if it is a good idea to tie two pseudo registers
  753. when one has mode MODE1 and one has mode MODE2.
  754. If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
  755. for any hard reg, then this must be 0 for correct output.
  756. That's the case for xd registers: we don't hold SFmode values in
  757. them, so we can't tie an SFmode pseudos with one in another
  758. floating-point mode. */
  759. #define MODES_TIEABLE_P(MODE1, MODE2) \
  760. ((MODE1) == (MODE2) \
  761. || (TARGET_SHMEDIA \
  762. && GET_MODE_SIZE (MODE1) == GET_MODE_SIZE (MODE2) \
  763. && INTEGRAL_MODE_P (MODE1) && INTEGRAL_MODE_P (MODE2)) \
  764. || (GET_MODE_CLASS (MODE1) == GET_MODE_CLASS (MODE2) \
  765. && (TARGET_SHMEDIA ? ((GET_MODE_SIZE (MODE1) <= 4) \
  766. && (GET_MODE_SIZE (MODE2) <= 4)) \
  767. : ((MODE1) != SFmode && (MODE2) != SFmode))))
  768. /* Specify the modes required to caller save a given hard regno. */
  769. #define HARD_REGNO_CALLER_SAVE_MODE(REGNO, NREGS, MODE) \
  770. sh_hard_regno_caller_save_mode ((REGNO), (NREGS), (MODE))
  771. /* A C expression that is nonzero if hard register NEW_REG can be
  772. considered for use as a rename register for OLD_REG register */
  773. #define HARD_REGNO_RENAME_OK(OLD_REG, NEW_REG) \
  774. sh_hard_regno_rename_ok (OLD_REG, NEW_REG)
  775. /* Specify the registers used for certain standard purposes.
  776. The values of these macros are register numbers. */
  777. /* Define this if the program counter is overloaded on a register. */
  778. /* #define PC_REGNUM 15*/
  779. /* Register to use for pushing function arguments. */
  780. #define STACK_POINTER_REGNUM SP_REG
  781. /* Base register for access to local variables of the function. */
  782. #define HARD_FRAME_POINTER_REGNUM FP_REG
  783. /* Base register for access to local variables of the function. */
  784. #define FRAME_POINTER_REGNUM 153
  785. /* Fake register that holds the address on the stack of the
  786. current function's return address. */
  787. #define RETURN_ADDRESS_POINTER_REGNUM RAP_REG
  788. /* Register to hold the addressing base for position independent
  789. code access to data items. */
  790. #define PIC_OFFSET_TABLE_REGNUM (flag_pic ? PIC_REG : INVALID_REGNUM)
  791. #define GOT_SYMBOL_NAME "*_GLOBAL_OFFSET_TABLE_"
  792. /* Definitions for register eliminations.
  793. We have three registers that can be eliminated on the SH. First, the
  794. frame pointer register can often be eliminated in favor of the stack
  795. pointer register. Secondly, the argument pointer register can always be
  796. eliminated; it is replaced with either the stack or frame pointer.
  797. Third, there is the return address pointer, which can also be replaced
  798. with either the stack or the frame pointer.
  799. This is an array of structures. Each structure initializes one pair
  800. of eliminable registers. The "from" register number is given first,
  801. followed by "to". Eliminations of the same "from" register are listed
  802. in order of preference.
  803. If you add any registers here that are not actually hard registers,
  804. and that have any alternative of elimination that doesn't always
  805. apply, you need to amend calc_live_regs to exclude it, because
  806. reload spills all eliminable registers where it sees an
  807. can_eliminate == 0 entry, thus making them 'live' .
  808. If you add any hard registers that can be eliminated in different
  809. ways, you have to patch reload to spill them only when all alternatives
  810. of elimination fail. */
  811. #define ELIMINABLE_REGS \
  812. {{ HARD_FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
  813. { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
  814. { FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}, \
  815. { RETURN_ADDRESS_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
  816. { RETURN_ADDRESS_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}, \
  817. { ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \
  818. { ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM},}
  819. /* Define the offset between two registers, one to be eliminated, and the other
  820. its replacement, at the start of a routine. */
  821. #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
  822. OFFSET = initial_elimination_offset ((FROM), (TO))
  823. /* Base register for access to arguments of the function. */
  824. #define ARG_POINTER_REGNUM AP_REG
  825. /* Register in which the static-chain is passed to a function. */
  826. #define STATIC_CHAIN_REGNUM (TARGET_SH5 ? 1 : 3)
  827. /* Don't default to pcc-struct-return, because we have already specified
  828. exactly how to return structures in the TARGET_RETURN_IN_MEMORY
  829. target hook. */
  830. #define DEFAULT_PCC_STRUCT_RETURN 0
  831. #define SHMEDIA_REGS_STACK_ADJUST() \
  832. (TARGET_SHCOMPACT && crtl->saves_all_registers \
  833. ? (8 * (/* r28-r35 */ 8 + /* r44-r59 */ 16 + /* tr5-tr7 */ 3) \
  834. + (TARGET_FPU_ANY ? 4 * (/* fr36 - fr63 */ 28) : 0)) \
  835. : 0)
  836. /* Define the classes of registers for register constraints in the
  837. machine description. Also define ranges of constants.
  838. One of the classes must always be named ALL_REGS and include all hard regs.
  839. If there is more than one class, another class must be named NO_REGS
  840. and contain no registers.
  841. The name GENERAL_REGS must be the name of a class (or an alias for
  842. another name such as ALL_REGS). This is the class of registers
  843. that is allowed by "g" or "r" in a register constraint.
  844. Also, registers outside this class are allocated only when
  845. instructions express preferences for them.
  846. The classes must be numbered in nondecreasing order; that is,
  847. a larger-numbered class must never be contained completely
  848. in a smaller-numbered class.
  849. For any two classes, it is very desirable that there be another
  850. class that represents their union.
  851. The SH has two sorts of general registers, R0 and the rest. R0 can
  852. be used as the destination of some of the arithmetic ops. There are
  853. also some special purpose registers; the T bit register, the
  854. Procedure Return Register and the Multiply Accumulate Registers.
  855. Place GENERAL_REGS after FPUL_REGS so that it will be preferred by
  856. reg_class_subunion. We don't want to have an actual union class
  857. of these, because it would only be used when both classes are calculated
  858. to give the same cost, but there is only one FPUL register.
  859. Besides, regclass fails to notice the different REGISTER_MOVE_COSTS
  860. applying to the actual instruction alternative considered. E.g., the
  861. y/r alternative of movsi_ie is considered to have no more cost that
  862. the r/r alternative, which is patently untrue. */
  863. enum reg_class
  864. {
  865. NO_REGS,
  866. R0_REGS,
  867. PR_REGS,
  868. T_REGS,
  869. MAC_REGS,
  870. FPUL_REGS,
  871. SIBCALL_REGS,
  872. NON_SP_REGS,
  873. GENERAL_REGS,
  874. FP0_REGS,
  875. FP_REGS,
  876. DF_REGS,
  877. FPSCR_REGS,
  878. GENERAL_FP_REGS,
  879. GENERAL_DF_REGS,
  880. TARGET_REGS,
  881. ALL_REGS,
  882. LIM_REG_CLASSES
  883. };
  884. #define N_REG_CLASSES (int) LIM_REG_CLASSES
  885. /* Give names of register classes as strings for dump file. */
  886. #define REG_CLASS_NAMES \
  887. { \
  888. "NO_REGS", \
  889. "R0_REGS", \
  890. "PR_REGS", \
  891. "T_REGS", \
  892. "MAC_REGS", \
  893. "FPUL_REGS", \
  894. "SIBCALL_REGS", \
  895. "NON_SP_REGS", \
  896. "GENERAL_REGS", \
  897. "FP0_REGS", \
  898. "FP_REGS", \
  899. "DF_REGS", \
  900. "FPSCR_REGS", \
  901. "GENERAL_FP_REGS", \
  902. "GENERAL_DF_REGS", \
  903. "TARGET_REGS", \
  904. "ALL_REGS", \
  905. }
  906. /* Define which registers fit in which classes.
  907. This is an initializer for a vector of HARD_REG_SET
  908. of length N_REG_CLASSES. */
  909. #define REG_CLASS_CONTENTS \
  910. { \
  911. /* NO_REGS: */ \
  912. { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, \
  913. /* R0_REGS: */ \
  914. { 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, \
  915. /* PR_REGS: */ \
  916. { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00040000 }, \
  917. /* T_REGS: */ \
  918. { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00080000 }, \
  919. /* MAC_REGS: */ \
  920. { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00300000 }, \
  921. /* FPUL_REGS: */ \
  922. { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00400000 }, \
  923. /* SIBCALL_REGS: Initialized in TARGET_CONDITIONAL_REGISTER_USAGE. */ \
  924. { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }, \
  925. /* NON_SP_REGS: */ \
  926. { 0xffff7fff, 0xffffffff, 0x00000000, 0x00000000, 0x03020000 }, \
  927. /* GENERAL_REGS: */ \
  928. { 0xffffffff, 0xffffffff, 0x00000000, 0x00000000, 0x03020000 }, \
  929. /* FP0_REGS: */ \
  930. { 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000 }, \
  931. /* FP_REGS: */ \
  932. { 0x00000000, 0x00000000, 0xffffffff, 0xffffffff, 0x00000000 }, \
  933. /* DF_REGS: */ \
  934. { 0x00000000, 0x00000000, 0xffffffff, 0xffffffff, 0x0000ff00 }, \
  935. /* FPSCR_REGS: */ \
  936. { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00800000 }, \
  937. /* GENERAL_FP_REGS: */ \
  938. { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x03020000 }, \
  939. /* GENERAL_DF_REGS: */ \
  940. { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x0302ff00 }, \
  941. /* TARGET_REGS: */ \
  942. { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x000000ff }, \
  943. /* ALL_REGS: */ \
  944. { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x0fffffff }, \
  945. }
  946. /* The same information, inverted:
  947. Return the class number of the smallest class containing
  948. reg number REGNO. This could be a conditional expression
  949. or could index an array. */
  950. extern enum reg_class regno_reg_class[FIRST_PSEUDO_REGISTER];
  951. #define REGNO_REG_CLASS(REGNO) regno_reg_class[(REGNO)]
  952. /* When this hook returns true for MODE, the compiler allows
  953. registers explicitly used in the rtl to be used as spill registers
  954. but prevents the compiler from extending the lifetime of these
  955. registers. */
  956. #define TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P \
  957. sh_small_register_classes_for_mode_p
  958. /* The order in which register should be allocated. */
  959. /* Sometimes FP0_REGS becomes the preferred class of a floating point pseudo,
  960. and GENERAL_FP_REGS the alternate class. Since FP0 is likely to be
  961. spilled or used otherwise, we better have the FP_REGS allocated first. */
  962. #define REG_ALLOC_ORDER \
  963. {/* Caller-saved FPRs */ \
  964. 65, 66, 67, 68, 69, 70, 71, 64, \
  965. 72, 73, 74, 75, 80, 81, 82, 83, \
  966. 84, 85, 86, 87, 88, 89, 90, 91, \
  967. 92, 93, 94, 95, 96, 97, 98, 99, \
  968. /* Callee-saved FPRs */ \
  969. 76, 77, 78, 79,100,101,102,103, \
  970. 104,105,106,107,108,109,110,111, \
  971. 112,113,114,115,116,117,118,119, \
  972. 120,121,122,123,124,125,126,127, \
  973. 136,137,138,139,140,141,142,143, \
  974. /* FPSCR */ 151, \
  975. /* Caller-saved GPRs (except 8/9 on SH1-4) */ \
  976. 1, 2, 3, 7, 6, 5, 4, 0, \
  977. 8, 9, 17, 19, 20, 21, 22, 23, \
  978. 36, 37, 38, 39, 40, 41, 42, 43, \
  979. 60, 61, 62, \
  980. /* SH1-4 callee-saved saved GPRs / SH5 partially-saved GPRs */ \
  981. 10, 11, 12, 13, 14, 18, \
  982. /* SH5 callee-saved GPRs */ \
  983. 28, 29, 30, 31, 32, 33, 34, 35, \
  984. 44, 45, 46, 47, 48, 49, 50, 51, \
  985. 52, 53, 54, 55, 56, 57, 58, 59, \
  986. /* FPUL */ 150, \
  987. /* SH5 branch target registers */ \
  988. 128,129,130,131,132,133,134,135, \
  989. /* Fixed registers */ \
  990. 15, 16, 24, 25, 26, 27, 63,144, \
  991. 145,146,147,148,149,152,153,154,155 }
  992. /* The class value for index registers, and the one for base regs. */
  993. #define INDEX_REG_CLASS \
  994. (!ALLOW_INDEXED_ADDRESS ? NO_REGS : TARGET_SHMEDIA ? GENERAL_REGS : R0_REGS)
  995. #define BASE_REG_CLASS GENERAL_REGS
  996. /* Defines for sh.md and constraints.md. */
  997. #define CONST_OK_FOR_I08(VALUE) (((HOST_WIDE_INT)(VALUE))>= -128 \
  998. && ((HOST_WIDE_INT)(VALUE)) <= 127)
  999. #define CONST_OK_FOR_I16(VALUE) (((HOST_WIDE_INT)(VALUE)) >= -32768 \
  1000. && ((HOST_WIDE_INT)(VALUE)) <= 32767)
  1001. #define CONST_OK_FOR_J16(VALUE) \
  1002. ((HOST_BITS_PER_WIDE_INT >= 64 && (VALUE) == (HOST_WIDE_INT) 0xffffffff) \
  1003. || (HOST_BITS_PER_WIDE_INT >= 64 && (VALUE) == (HOST_WIDE_INT) -1 << 32))
  1004. #define CONST_OK_FOR_K08(VALUE) (((HOST_WIDE_INT)(VALUE))>= 0 \
  1005. && ((HOST_WIDE_INT)(VALUE)) <= 255)
  1006. #define ZERO_EXTRACT_ANDMASK(EXTRACT_SZ_RTX, EXTRACT_POS_RTX)\
  1007. (((1 << INTVAL (EXTRACT_SZ_RTX)) - 1) << INTVAL (EXTRACT_POS_RTX))
  1008. /* Return the maximum number of consecutive registers
  1009. needed to represent mode MODE in a register of class CLASS.
  1010. If TARGET_SHMEDIA, we need two FP registers per word.
  1011. Otherwise we will need at most one register per word. */
  1012. #define CLASS_MAX_NREGS(CLASS, MODE) \
  1013. (TARGET_SHMEDIA \
  1014. && TEST_HARD_REG_BIT (reg_class_contents[CLASS], FIRST_FP_REG) \
  1015. ? (GET_MODE_SIZE (MODE) + UNITS_PER_WORD/2 - 1) / (UNITS_PER_WORD/2) \
  1016. : (GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
  1017. /* If defined, gives a class of registers that cannot be used as the
  1018. operand of a SUBREG that changes the mode of the object illegally.
  1019. ??? We need to renumber the internal numbers for the frnn registers
  1020. when in little endian in order to allow mode size changes. */
  1021. #define CANNOT_CHANGE_MODE_CLASS(FROM, TO, CLASS) \
  1022. sh_cannot_change_mode_class (FROM, TO, CLASS)
  1023. /* Stack layout; function entry, exit and calling. */
  1024. /* Define the number of registers that can hold parameters.
  1025. These macros are used only in other macro definitions below. */
  1026. #define NPARM_REGS(MODE) \
  1027. (TARGET_FPU_ANY && (MODE) == SFmode \
  1028. ? (TARGET_SH5 ? 12 : 8) \
  1029. : (TARGET_SH4 || TARGET_SH2A_DOUBLE) \
  1030. && (GET_MODE_CLASS (MODE) == MODE_FLOAT \
  1031. || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT) \
  1032. ? (TARGET_SH5 ? 12 : 8) \
  1033. : (TARGET_SH5 ? 8 : 4))
  1034. #define FIRST_PARM_REG (FIRST_GENERAL_REG + (TARGET_SH5 ? 2 : 4))
  1035. #define FIRST_RET_REG (FIRST_GENERAL_REG + (TARGET_SH5 ? 2 : 0))
  1036. #define FIRST_FP_PARM_REG (FIRST_FP_REG + (TARGET_SH5 ? 0 : 4))
  1037. #define FIRST_FP_RET_REG FIRST_FP_REG
  1038. /* Define this if pushing a word on the stack
  1039. makes the stack pointer a smaller address. */
  1040. #define STACK_GROWS_DOWNWARD
  1041. /* Define this macro to nonzero if the addresses of local variable slots
  1042. are at negative offsets from the frame pointer. */
  1043. #define FRAME_GROWS_DOWNWARD 1
  1044. /* Offset from the frame pointer to the first local variable slot to
  1045. be allocated. */
  1046. #define STARTING_FRAME_OFFSET 0
  1047. /* If we generate an insn to push BYTES bytes,
  1048. this says how many the stack pointer really advances by. */
  1049. /* Don't define PUSH_ROUNDING, since the hardware doesn't do this.
  1050. When PUSH_ROUNDING is not defined, PARM_BOUNDARY will cause gcc to
  1051. do correct alignment. */
  1052. #if 0
  1053. #define PUSH_ROUNDING(NPUSHED) (((NPUSHED) + 3) & ~3)
  1054. #endif
  1055. /* Offset of first parameter from the argument pointer register value. */
  1056. #define FIRST_PARM_OFFSET(FNDECL) 0
  1057. /* Value is the number of bytes of arguments automatically popped when
  1058. calling a subroutine.
  1059. CUM is the accumulated argument list.
  1060. On SHcompact, the call trampoline pops arguments off the stack. */
  1061. #define CALL_POPS_ARGS(CUM) (TARGET_SHCOMPACT ? (CUM).stack_regs * 8 : 0)
  1062. /* Some subroutine macros specific to this machine. */
  1063. #define BASE_RETURN_VALUE_REG(MODE) \
  1064. ((TARGET_FPU_ANY && ((MODE) == SFmode)) \
  1065. ? FIRST_FP_RET_REG \
  1066. : TARGET_FPU_ANY && (MODE) == SCmode \
  1067. ? FIRST_FP_RET_REG \
  1068. : (TARGET_FPU_DOUBLE \
  1069. && ((MODE) == DFmode || (MODE) == SFmode \
  1070. || (MODE) == DCmode || (MODE) == SCmode )) \
  1071. ? FIRST_FP_RET_REG \
  1072. : FIRST_RET_REG)
  1073. #define BASE_ARG_REG(MODE) \
  1074. ((TARGET_SH2E && ((MODE) == SFmode)) \
  1075. ? FIRST_FP_PARM_REG \
  1076. : (TARGET_SH4 || TARGET_SH2A_DOUBLE) && (GET_MODE_CLASS (MODE) == MODE_FLOAT \
  1077. || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT)\
  1078. ? FIRST_FP_PARM_REG \
  1079. : FIRST_PARM_REG)
  1080. /* 1 if N is a possible register number for function argument passing. */
  1081. /* ??? There are some callers that pass REGNO as int, and others that pass
  1082. it as unsigned. We get warnings unless we do casts everywhere. */
  1083. #define FUNCTION_ARG_REGNO_P(REGNO) \
  1084. (((unsigned) (REGNO) >= (unsigned) FIRST_PARM_REG \
  1085. && (unsigned) (REGNO) < (unsigned) (FIRST_PARM_REG + NPARM_REGS (SImode)))\
  1086. || (TARGET_FPU_ANY \
  1087. && (unsigned) (REGNO) >= (unsigned) FIRST_FP_PARM_REG \
  1088. && (unsigned) (REGNO) < (unsigned) (FIRST_FP_PARM_REG \
  1089. + NPARM_REGS (SFmode))))
  1090. /* Define a data type for recording info about an argument list
  1091. during the scan of that argument list. This data type should
  1092. hold all necessary information about the function itself
  1093. and about the args processed so far, enough to enable macros
  1094. such as FUNCTION_ARG to determine where the next arg should go.
  1095. On SH, this is a single integer, which is a number of words
  1096. of arguments scanned so far (including the invisible argument,
  1097. if any, which holds the structure-value-address).
  1098. Thus NARGREGS or more means all following args should go on the stack. */
  1099. enum sh_arg_class { SH_ARG_INT = 0, SH_ARG_FLOAT = 1 };
  1100. struct sh_args {
  1101. int arg_count[2];
  1102. int force_mem;
  1103. /* Nonzero if a prototype is available for the function. */
  1104. int prototype_p;
  1105. /* The number of an odd floating-point register, that should be used
  1106. for the next argument of type float. */
  1107. int free_single_fp_reg;
  1108. /* Whether we're processing an outgoing function call. */
  1109. int outgoing;
  1110. /* The number of general-purpose registers that should have been
  1111. used to pass partial arguments, that are passed totally on the
  1112. stack. On SHcompact, a call trampoline will pop them off the
  1113. stack before calling the actual function, and, if the called
  1114. function is implemented in SHcompact mode, the incoming arguments
  1115. decoder will push such arguments back onto the stack. For
  1116. incoming arguments, STACK_REGS also takes into account other
  1117. arguments passed by reference, that the decoder will also push
  1118. onto the stack. */
  1119. int stack_regs;
  1120. /* The number of general-purpose registers that should have been
  1121. used to pass arguments, if the arguments didn't have to be passed
  1122. by reference. */
  1123. int byref_regs;
  1124. /* Set as by shcompact_byref if the current argument is to be passed
  1125. by reference. */
  1126. int byref;
  1127. /* call_cookie is a bitmask used by call expanders, as well as
  1128. function prologue and epilogues, to allow SHcompact to comply
  1129. with the SH5 32-bit ABI, that requires 64-bit registers to be
  1130. used even though only the lower 32-bit half is visible in
  1131. SHcompact mode. The strategy is to call SHmedia trampolines.
  1132. The alternatives for each of the argument-passing registers are
  1133. (a) leave it unchanged; (b) pop it off the stack; (c) load its
  1134. contents from the address in it; (d) add 8 to it, storing the
  1135. result in the next register, then (c); (e) copy it from some
  1136. floating-point register,
  1137. Regarding copies from floating-point registers, r2 may only be
  1138. copied from dr0. r3 may be copied from dr0 or dr2. r4 maybe
  1139. copied from dr0, dr2 or dr4. r5 maybe copied from dr0, dr2,
  1140. dr4 or dr6. r6 may be copied from dr0, dr2, dr4, dr6 or dr8.
  1141. r7 through to r9 may be copied from dr0, dr2, dr4, dr8, dr8 or
  1142. dr10.
  1143. The bit mask is structured as follows:
  1144. - 1 bit to tell whether to set up a return trampoline.
  1145. - 3 bits to count the number consecutive registers to pop off the
  1146. stack.
  1147. - 4 bits for each of r9, r8, r7 and r6.
  1148. - 3 bits for each of r5, r4, r3 and r2.
  1149. - 3 bits set to 0 (the most significant ones)
  1150. 3 2 1 0
  1151. 1098 7654 3210 9876 5432 1098 7654 3210
  1152. FLPF LPFL PFLP FFLP FFLP FFLP FFLP SSST
  1153. 2223 3344 4555 6666 7777 8888 9999 SSS-
  1154. - If F is set, the register must be copied from an FP register,
  1155. whose number is encoded in the remaining bits.
  1156. - Else, if L is set, the register must be loaded from the address
  1157. contained in it. If the P bit is *not* set, the address of the
  1158. following dword should be computed first, and stored in the
  1159. following register.
  1160. - Else, if P is set, the register alone should be popped off the
  1161. stack.
  1162. - After all this processing, the number of registers represented
  1163. in SSS will be popped off the stack. This is an optimization
  1164. for pushing/popping consecutive registers, typically used for
  1165. varargs and large arguments partially passed in registers.
  1166. - If T is set, a return trampoline will be set up for 64-bit
  1167. return values to be split into 2 32-bit registers. */
  1168. long call_cookie;
  1169. /* This is set to nonzero when the call in question must use the Renesas ABI,
  1170. even without the -mrenesas option. */
  1171. int renesas_abi;
  1172. };
  1173. #define CALL_COOKIE_RET_TRAMP_SHIFT 0
  1174. #define CALL_COOKIE_RET_TRAMP(VAL) ((VAL) << CALL_COOKIE_RET_TRAMP_SHIFT)
  1175. #define CALL_COOKIE_STACKSEQ_SHIFT 1
  1176. #define CALL_COOKIE_STACKSEQ(VAL) ((VAL) << CALL_COOKIE_STACKSEQ_SHIFT)
  1177. #define CALL_COOKIE_STACKSEQ_GET(COOKIE) \
  1178. (((COOKIE) >> CALL_COOKIE_STACKSEQ_SHIFT) & 7)
  1179. #define CALL_COOKIE_INT_REG_SHIFT(REG) \
  1180. (4 * (7 - (REG)) + (((REG) <= 2) ? ((REG) - 2) : 1) + 3)
  1181. #define CALL_COOKIE_INT_REG(REG, VAL) \
  1182. ((VAL) << CALL_COOKIE_INT_REG_SHIFT (REG))
  1183. #define CALL_COOKIE_INT_REG_GET(COOKIE, REG) \
  1184. (((COOKIE) >> CALL_COOKIE_INT_REG_SHIFT (REG)) & ((REG) < 4 ? 7 : 15))
  1185. #define CUMULATIVE_ARGS struct sh_args
  1186. #define GET_SH_ARG_CLASS(MODE) \
  1187. ((TARGET_FPU_ANY && (MODE) == SFmode) \
  1188. ? SH_ARG_FLOAT \
  1189. /* There's no mention of complex float types in the SH5 ABI, so we
  1190. should presumably handle them as aggregate types. */ \
  1191. : TARGET_SH5 && GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT \
  1192. ? SH_ARG_INT \
  1193. : TARGET_FPU_DOUBLE && (GET_MODE_CLASS (MODE) == MODE_FLOAT \
  1194. || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT) \
  1195. ? SH_ARG_FLOAT : SH_ARG_INT)
  1196. /* Initialize a variable CUM of type CUMULATIVE_ARGS
  1197. for a call to a function whose data type is FNTYPE.
  1198. For a library call, FNTYPE is 0.
  1199. On SH, the offset always starts at 0: the first parm reg is always
  1200. the same reg for a given argument class.
  1201. For TARGET_HITACHI, the structure value pointer is passed in memory. */
  1202. #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, FNDECL, N_NAMED_ARGS) \
  1203. sh_init_cumulative_args (& (CUM), (FNTYPE), (LIBNAME), (FNDECL),\
  1204. (N_NAMED_ARGS), VOIDmode)
  1205. #define INIT_CUMULATIVE_LIBCALL_ARGS(CUM, MODE, LIBNAME) \
  1206. sh_init_cumulative_args (& (CUM), NULL_TREE, (LIBNAME), NULL_TREE, 0, (MODE))
  1207. /* By accident we got stuck with passing SCmode on SH4 little endian
  1208. in two registers that are nominally successive - which is different from
  1209. two single SFmode values, where we take endianness translation into
  1210. account. That does not work at all if an odd number of registers is
  1211. already in use, so that got fixed, but library functions are still more
  1212. likely to use complex numbers without mixing them with SFmode arguments
  1213. (which in C would have to be structures), so for the sake of ABI
  1214. compatibility the way SCmode values are passed when an even number of
  1215. FP registers is in use remains different from a pair of SFmode values for
  1216. now.
  1217. I.e.:
  1218. foo (double); a: fr5,fr4
  1219. foo (float a, float b); a: fr5 b: fr4
  1220. foo (__complex float a); a.real fr4 a.imag: fr5 - for consistency,
  1221. this should be the other way round...
  1222. foo (float a, __complex float b); a: fr5 b.real: fr4 b.imag: fr7 */
  1223. #define FUNCTION_ARG_SCmode_WART 1
  1224. /* If an argument of size 5, 6 or 7 bytes is to be passed in a 64-bit
  1225. register in SHcompact mode, it must be padded in the most
  1226. significant end. This means that passing it by reference wouldn't
  1227. pad properly on a big-endian machine. In this particular case, we
  1228. pass this argument on the stack, in a way that the call trampoline
  1229. will load its value into the appropriate register. */
  1230. #define SHCOMPACT_FORCE_ON_STACK(MODE,TYPE) \
  1231. ((MODE) == BLKmode \
  1232. && TARGET_SHCOMPACT \
  1233. && TARGET_BIG_ENDIAN \
  1234. && int_size_in_bytes (TYPE) > 4 \
  1235. && int_size_in_bytes (TYPE) < 8)
  1236. /* Minimum alignment for an argument to be passed by callee-copy
  1237. reference. We need such arguments to be aligned to 8 byte
  1238. boundaries, because they'll be loaded using quad loads. */
  1239. #define SH_MIN_ALIGN_FOR_CALLEE_COPY (8 * BITS_PER_UNIT)
  1240. /* The SH5 ABI requires floating-point arguments to be passed to
  1241. functions without a prototype in both an FP register and a regular
  1242. register or the stack. When passing the argument in both FP and
  1243. general-purpose registers, list the FP register first. */
  1244. #define SH5_PROTOTYPELESS_FLOAT_ARG(CUM,MODE) \
  1245. (gen_rtx_PARALLEL \
  1246. ((MODE), \
  1247. gen_rtvec (2, \
  1248. gen_rtx_EXPR_LIST \
  1249. (VOIDmode, \
  1250. ((CUM).arg_count[(int) SH_ARG_INT] < NPARM_REGS (SImode) \
  1251. ? gen_rtx_REG ((MODE), FIRST_FP_PARM_REG \
  1252. + (CUM).arg_count[(int) SH_ARG_FLOAT]) \
  1253. : NULL_RTX), \
  1254. const0_rtx), \
  1255. gen_rtx_EXPR_LIST \
  1256. (VOIDmode, \
  1257. ((CUM).arg_count[(int) SH_ARG_INT] < NPARM_REGS (SImode) \
  1258. ? gen_rtx_REG ((MODE), FIRST_PARM_REG \
  1259. + (CUM).arg_count[(int) SH_ARG_INT]) \
  1260. : gen_rtx_REG ((MODE), FIRST_FP_PARM_REG \
  1261. + (CUM).arg_count[(int) SH_ARG_FLOAT])), \
  1262. const0_rtx))))
  1263. /* The SH5 ABI requires regular registers or stack slots to be
  1264. reserved for floating-point arguments. Registers are taken care of
  1265. in FUNCTION_ARG_ADVANCE, but stack slots must be reserved here.
  1266. Unfortunately, there's no way to just reserve a stack slot, so
  1267. we'll end up needlessly storing a copy of the argument in the
  1268. stack. For incoming arguments, however, the PARALLEL will be
  1269. optimized to the register-only form, and the value in the stack
  1270. slot won't be used at all. */
  1271. #define SH5_PROTOTYPED_FLOAT_ARG(CUM,MODE,REG) \
  1272. ((CUM).arg_count[(int) SH_ARG_INT] < NPARM_REGS (SImode) \
  1273. ? gen_rtx_REG ((MODE), (REG)) \
  1274. : gen_rtx_PARALLEL ((MODE), \
  1275. gen_rtvec (2, \
  1276. gen_rtx_EXPR_LIST \
  1277. (VOIDmode, NULL_RTX, \
  1278. const0_rtx), \
  1279. gen_rtx_EXPR_LIST \
  1280. (VOIDmode, gen_rtx_REG ((MODE), \
  1281. (REG)), \
  1282. const0_rtx))))
  1283. #define SH5_WOULD_BE_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \
  1284. (TARGET_SH5 \
  1285. && ((MODE) == BLKmode || (MODE) == TImode || (MODE) == CDImode \
  1286. || (MODE) == DCmode) \
  1287. && ((CUM).arg_count[(int) SH_ARG_INT] \
  1288. + (((MODE) == BLKmode ? int_size_in_bytes (TYPE) \
  1289. : GET_MODE_SIZE (MODE)) \
  1290. + 7) / 8) > NPARM_REGS (SImode))
  1291. /* Perform any needed actions needed for a function that is receiving a
  1292. variable number of arguments. */
  1293. /* Call the function profiler with a given profile label.
  1294. We use two .aligns, so as to make sure that both the .long is aligned
  1295. on a 4 byte boundary, and that the .long is a fixed distance (2 bytes)
  1296. from the trapa instruction. */
  1297. #define FUNCTION_PROFILER(STREAM,LABELNO) \
  1298. { \
  1299. if (TARGET_SHMEDIA) \
  1300. { \
  1301. fprintf((STREAM), "\tmovi\t33,r0\n"); \
  1302. fprintf((STREAM), "\ttrapa\tr0\n"); \
  1303. asm_fprintf((STREAM), "\t.long\t%LLP%d\n", (LABELNO)); \
  1304. } \
  1305. else \
  1306. { \
  1307. fprintf((STREAM), "\t.align\t2\n"); \
  1308. fprintf((STREAM), "\ttrapa\t#33\n"); \
  1309. fprintf((STREAM), "\t.align\t2\n"); \
  1310. asm_fprintf((STREAM), "\t.long\t%LLP%d\n", (LABELNO)); \
  1311. } \
  1312. }
  1313. /* Define this macro if the code for function profiling should come
  1314. before the function prologue. Normally, the profiling code comes
  1315. after. */
  1316. #define PROFILE_BEFORE_PROLOGUE
  1317. /* EXIT_IGNORE_STACK should be nonzero if, when returning from a function,
  1318. the stack pointer does not matter. The value is tested only in
  1319. functions that have frame pointers.
  1320. No definition is equivalent to always zero. */
  1321. #define EXIT_IGNORE_STACK 1
  1322. /*
  1323. On the SH, the trampoline looks like
  1324. 2 0002 D202 mov.l l2,r2
  1325. 1 0000 D301 mov.l l1,r3
  1326. 3 0004 422B jmp @r2
  1327. 4 0006 0009 nop
  1328. 5 0008 00000000 l1: .long area
  1329. 6 000c 00000000 l2: .long function */
  1330. /* Length in units of the trampoline for entering a nested function. */
  1331. #define TRAMPOLINE_SIZE (TARGET_SHMEDIA64 ? 40 : TARGET_SH5 ? 24 : 16)
  1332. /* Alignment required for a trampoline in bits. */
  1333. #define TRAMPOLINE_ALIGNMENT \
  1334. ((CACHE_LOG < 3 \
  1335. || (optimize_size && ! (TARGET_HARD_SH4 || TARGET_SH5))) ? 32 \
  1336. : TARGET_SHMEDIA ? 256 : 64)
  1337. /* A C expression whose value is RTL representing the value of the return
  1338. address for the frame COUNT steps up from the current frame.
  1339. FRAMEADDR is already the frame pointer of the COUNT frame, so we
  1340. can ignore COUNT. */
  1341. #define RETURN_ADDR_RTX(COUNT, FRAME) \
  1342. (((COUNT) == 0) ? sh_get_pr_initial_val () : NULL_RTX)
  1343. /* A C expression whose value is RTL representing the location of the
  1344. incoming return address at the beginning of any function, before the
  1345. prologue. This RTL is either a REG, indicating that the return
  1346. value is saved in REG, or a MEM representing a location in
  1347. the stack. */
  1348. #define INCOMING_RETURN_ADDR_RTX \
  1349. gen_rtx_REG (Pmode, TARGET_SHMEDIA ? PR_MEDIA_REG : PR_REG)
  1350. /* Addressing modes, and classification of registers for them. */
  1351. #define HAVE_POST_INCREMENT TARGET_SH1
  1352. #define HAVE_PRE_DECREMENT TARGET_SH1
  1353. #define USE_LOAD_POST_INCREMENT(mode) ((mode == SImode || mode == DImode) \
  1354. ? 0 : TARGET_SH1)
  1355. #define USE_LOAD_PRE_DECREMENT(mode) 0
  1356. #define USE_STORE_POST_INCREMENT(mode) 0
  1357. #define USE_STORE_PRE_DECREMENT(mode) ((mode == SImode || mode == DImode) \
  1358. ? 0 : TARGET_SH1)
  1359. /* If a memory clear move would take CLEAR_RATIO or more simple
  1360. move-instruction pairs, we will do a setmem instead. */
  1361. #define CLEAR_RATIO(speed) ((speed) ? 15 : 3)
  1362. /* Macros to check register numbers against specific register classes. */
  1363. /* These assume that REGNO is a hard or pseudo reg number.
  1364. They give nonzero only if REGNO is a hard reg of the suitable class
  1365. or a pseudo reg currently allocated to a suitable hard reg.
  1366. Since they use reg_renumber, they are safe only once reg_renumber
  1367. has been allocated, which happens in reginfo.c during register
  1368. allocation. */
  1369. #define REGNO_OK_FOR_BASE_P(REGNO) \
  1370. (GENERAL_OR_AP_REGISTER_P (REGNO) \
  1371. || GENERAL_OR_AP_REGISTER_P (reg_renumber[(REGNO)]))
  1372. #define REGNO_OK_FOR_INDEX_P(REGNO) \
  1373. (TARGET_SHMEDIA \
  1374. ? (GENERAL_REGISTER_P (REGNO) \
  1375. || GENERAL_REGISTER_P ((unsigned) reg_renumber[(REGNO)])) \
  1376. : (REGNO) == R0_REG || (unsigned) reg_renumber[(REGNO)] == R0_REG)
  1377. /* Maximum number of registers that can appear in a valid memory
  1378. address. */
  1379. #define MAX_REGS_PER_ADDRESS 2
  1380. /* Recognize any constant value that is a valid address. */
  1381. #define CONSTANT_ADDRESS_P(X) (GET_CODE (X) == LABEL_REF)
  1382. /* The macros REG_OK_FOR..._P assume that the arg is a REG rtx
  1383. and check its validity for a certain class.
  1384. The suitable hard regs are always accepted and all pseudo regs
  1385. are also accepted if STRICT is not set. */
  1386. /* Nonzero if X is a reg that can be used as a base reg. */
  1387. #define REG_OK_FOR_BASE_P(X, STRICT) \
  1388. (GENERAL_OR_AP_REGISTER_P (REGNO (X)) \
  1389. || (!STRICT && REGNO (X) >= FIRST_PSEUDO_REGISTER))
  1390. /* Nonzero if X is a reg that can be used as an index. */
  1391. #define REG_OK_FOR_INDEX_P(X, STRICT) \
  1392. ((TARGET_SHMEDIA ? GENERAL_REGISTER_P (REGNO (X)) \
  1393. : REGNO (X) == R0_REG) \
  1394. || (!STRICT && REGNO (X) >= FIRST_PSEUDO_REGISTER))
  1395. /* Nonzero if X/OFFSET is a reg that can be used as an index. */
  1396. #define SUBREG_OK_FOR_INDEX_P(X, OFFSET, STRICT) \
  1397. ((TARGET_SHMEDIA ? GENERAL_REGISTER_P (REGNO (X)) \
  1398. : REGNO (X) == R0_REG && OFFSET == 0) \
  1399. || (!STRICT && REGNO (X) >= FIRST_PSEUDO_REGISTER))
  1400. /* Macros for extra constraints. */
  1401. #define IS_PC_RELATIVE_LOAD_ADDR_P(OP) \
  1402. ((GET_CODE ((OP)) == LABEL_REF) \
  1403. || (GET_CODE ((OP)) == CONST \
  1404. && GET_CODE (XEXP ((OP), 0)) == PLUS \
  1405. && GET_CODE (XEXP (XEXP ((OP), 0), 0)) == LABEL_REF \
  1406. && CONST_INT_P (XEXP (XEXP ((OP), 0), 1))))
  1407. #define IS_NON_EXPLICIT_CONSTANT_P(OP) \
  1408. (CONSTANT_P (OP) \
  1409. && !CONST_INT_P (OP) \
  1410. && GET_CODE (OP) != CONST_DOUBLE \
  1411. && (!flag_pic \
  1412. || (LEGITIMATE_PIC_OPERAND_P (OP) \
  1413. && !PIC_ADDR_P (OP) \
  1414. && GET_CODE (OP) != LABEL_REF)))
  1415. /* Check whether OP is a datalabel unspec. */
  1416. #define DATALABEL_REF_NO_CONST_P(OP) \
  1417. (GET_CODE (OP) == UNSPEC \
  1418. && XINT ((OP), 1) == UNSPEC_DATALABEL \
  1419. && XVECLEN ((OP), 0) == 1 \
  1420. && GET_CODE (XVECEXP ((OP), 0, 0)) == LABEL_REF)
  1421. #define GOT_ENTRY_P(OP) \
  1422. (GET_CODE (OP) == CONST && GET_CODE (XEXP ((OP), 0)) == UNSPEC \
  1423. && XINT (XEXP ((OP), 0), 1) == UNSPEC_GOT)
  1424. #define GOTPLT_ENTRY_P(OP) \
  1425. (GET_CODE (OP) == CONST && GET_CODE (XEXP ((OP), 0)) == UNSPEC \
  1426. && XINT (XEXP ((OP), 0), 1) == UNSPEC_GOTPLT)
  1427. #define UNSPEC_GOTOFF_P(OP) \
  1428. (GET_CODE (OP) == UNSPEC && XINT ((OP), 1) == UNSPEC_GOTOFF)
  1429. #define GOTOFF_P(OP) \
  1430. (GET_CODE (OP) == CONST \
  1431. && (UNSPEC_GOTOFF_P (XEXP ((OP), 0)) \
  1432. || (GET_CODE (XEXP ((OP), 0)) == PLUS \
  1433. && UNSPEC_GOTOFF_P (XEXP (XEXP ((OP), 0), 0)) \
  1434. && CONST_INT_P (XEXP (XEXP ((OP), 0), 1)))))
  1435. #define PIC_ADDR_P(OP) \
  1436. (GET_CODE (OP) == CONST && GET_CODE (XEXP ((OP), 0)) == UNSPEC \
  1437. && XINT (XEXP ((OP), 0), 1) == UNSPEC_PIC)
  1438. #define PCREL_SYMOFF_P(OP) \
  1439. (GET_CODE (OP) == CONST \
  1440. && GET_CODE (XEXP ((OP), 0)) == UNSPEC \
  1441. && XINT (XEXP ((OP), 0), 1) == UNSPEC_PCREL_SYMOFF)
  1442. #define NON_PIC_REFERENCE_P(OP) \
  1443. (GET_CODE (OP) == LABEL_REF || GET_CODE (OP) == SYMBOL_REF \
  1444. || (GET_CODE (OP) == CONST \
  1445. && (GET_CODE (XEXP ((OP), 0)) == LABEL_REF \
  1446. || GET_CODE (XEXP ((OP), 0)) == SYMBOL_REF \
  1447. || DATALABEL_REF_NO_CONST_P (XEXP ((OP), 0)))) \
  1448. || (GET_CODE (OP) == CONST && GET_CODE (XEXP ((OP), 0)) == PLUS \
  1449. && (GET_CODE (XEXP (XEXP ((OP), 0), 0)) == SYMBOL_REF \
  1450. || GET_CODE (XEXP (XEXP ((OP), 0), 0)) == LABEL_REF \
  1451. || DATALABEL_REF_NO_CONST_P (XEXP (XEXP ((OP), 0), 0))) \
  1452. && CONST_INT_P (XEXP (XEXP ((OP), 0), 1))))
  1453. #define PIC_REFERENCE_P(OP) \
  1454. (GOT_ENTRY_P (OP) || GOTPLT_ENTRY_P (OP) \
  1455. || GOTOFF_P (OP) || PIC_ADDR_P (OP))
  1456. #define MOVI_SHORI_BASE_OPERAND_P(OP) \
  1457. (flag_pic \
  1458. ? (GOT_ENTRY_P (OP) || GOTPLT_ENTRY_P (OP) || GOTOFF_P (OP) \
  1459. || PCREL_SYMOFF_P (OP)) \
  1460. : NON_PIC_REFERENCE_P (OP))
  1461. #define MAYBE_BASE_REGISTER_RTX_P(X, STRICT) \
  1462. ((REG_P (X) && REG_OK_FOR_BASE_P (X, STRICT)) \
  1463. || (GET_CODE (X) == SUBREG \
  1464. && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (GET_MODE ((X))), \
  1465. GET_MODE_BITSIZE (GET_MODE (SUBREG_REG (X)))) \
  1466. && REG_P (SUBREG_REG (X)) \
  1467. && REG_OK_FOR_BASE_P (SUBREG_REG (X), STRICT)))
  1468. /* Since this must be r0, which is a single register class, we must check
  1469. SUBREGs more carefully, to be sure that we don't accept one that extends
  1470. outside the class. */
  1471. #define MAYBE_INDEX_REGISTER_RTX_P(X, STRICT) \
  1472. ((REG_P (X) && REG_OK_FOR_INDEX_P (X, STRICT)) \
  1473. || (GET_CODE (X) == SUBREG \
  1474. && TRULY_NOOP_TRUNCATION (GET_MODE_BITSIZE (GET_MODE ((X))), \
  1475. GET_MODE_BITSIZE (GET_MODE (SUBREG_REG (X)))) \
  1476. && REG_P (SUBREG_REG (X)) \
  1477. && SUBREG_OK_FOR_INDEX_P (SUBREG_REG (X), SUBREG_BYTE (X), STRICT)))
  1478. #ifdef REG_OK_STRICT
  1479. #define BASE_REGISTER_RTX_P(X) MAYBE_BASE_REGISTER_RTX_P(X, true)
  1480. #define INDEX_REGISTER_RTX_P(X) MAYBE_INDEX_REGISTER_RTX_P(X, true)
  1481. #else
  1482. #define BASE_REGISTER_RTX_P(X) MAYBE_BASE_REGISTER_RTX_P(X, false)
  1483. #define INDEX_REGISTER_RTX_P(X) MAYBE_INDEX_REGISTER_RTX_P(X, false)
  1484. #endif
  1485. #define ALLOW_INDEXED_ADDRESS \
  1486. ((!TARGET_SHMEDIA32 && !TARGET_SHCOMPACT) || TARGET_ALLOW_INDEXED_ADDRESS)
  1487. /* A C compound statement that attempts to replace X, which is an address
  1488. that needs reloading, with a valid memory address for an operand of
  1489. mode MODE. WIN is a C statement label elsewhere in the code. */
  1490. #define LEGITIMIZE_RELOAD_ADDRESS(X,MODE,OPNUM,TYPE,IND_LEVELS,WIN) \
  1491. do { \
  1492. if (sh_legitimize_reload_address (&(X), (MODE), (OPNUM), (TYPE))) \
  1493. goto WIN; \
  1494. } while (0)
  1495. /* Specify the machine mode that this machine uses
  1496. for the index in the tablejump instruction. */
  1497. #define CASE_VECTOR_MODE ((! optimize || TARGET_BIGTABLE) ? SImode : HImode)
  1498. #define CASE_VECTOR_SHORTEN_MODE(MIN_OFFSET, MAX_OFFSET, BODY) \
  1499. ((MIN_OFFSET) >= 0 && (MAX_OFFSET) <= 127 \
  1500. ? (ADDR_DIFF_VEC_FLAGS (BODY).offset_unsigned = 0, QImode) \
  1501. : (MIN_OFFSET) >= 0 && (MAX_OFFSET) <= 255 \
  1502. ? (ADDR_DIFF_VEC_FLAGS (BODY).offset_unsigned = 1, QImode) \
  1503. : (MIN_OFFSET) >= -32768 && (MAX_OFFSET) <= 32767 ? HImode \
  1504. : SImode)
  1505. /* Define as C expression which evaluates to nonzero if the tablejump
  1506. instruction expects the table to contain offsets from the address of the
  1507. table.
  1508. Do not define this if the table should contain absolute addresses. */
  1509. #define CASE_VECTOR_PC_RELATIVE 1
  1510. /* Define it here, so that it doesn't get bumped to 64-bits on SHmedia. */
  1511. #define FLOAT_TYPE_SIZE 32
  1512. /* Since the SH2e has only `float' support, it is desirable to make all
  1513. floating point types equivalent to `float'. */
  1514. #define DOUBLE_TYPE_SIZE ((TARGET_SH2E && ! TARGET_SH4 && ! TARGET_SH2A_DOUBLE)\
  1515. ? 32 : 64)
  1516. /* 'char' is signed by default. */
  1517. #define DEFAULT_SIGNED_CHAR 1
  1518. /* The type of size_t unsigned int. */
  1519. #define SIZE_TYPE (TARGET_SH5 ? "long unsigned int" : "unsigned int")
  1520. #undef PTRDIFF_TYPE
  1521. #define PTRDIFF_TYPE (TARGET_SH5 ? "long int" : "int")
  1522. #define WCHAR_TYPE "short unsigned int"
  1523. #define WCHAR_TYPE_SIZE 16
  1524. #define SH_ELF_WCHAR_TYPE "long int"
  1525. /* Max number of bytes we can move from memory to memory
  1526. in one reasonably fast instruction. */
  1527. #define MOVE_MAX (TARGET_SHMEDIA ? 8 : 4)
  1528. /* Maximum value possibly taken by MOVE_MAX. Must be defined whenever
  1529. MOVE_MAX is not a compile-time constant. */
  1530. #define MAX_MOVE_MAX 8
  1531. /* Max number of bytes we want move_by_pieces to be able to copy
  1532. efficiently. */
  1533. #define MOVE_MAX_PIECES (TARGET_SH4 || TARGET_SHMEDIA ? 8 : 4)
  1534. /* Define if operations between registers always perform the operation
  1535. on the full register even if a narrower mode is specified. */
  1536. #define WORD_REGISTER_OPERATIONS
  1537. /* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD
  1538. will either zero-extend or sign-extend. The value of this macro should
  1539. be the code that says which one of the two operations is implicitly
  1540. done, UNKNOWN if none.
  1541. For SHmedia, we can truncate to QImode easier using zero extension.
  1542. FP registers can load SImode values, but don't implicitly sign-extend
  1543. them to DImode. */
  1544. #define LOAD_EXTEND_OP(MODE) \
  1545. (((MODE) == QImode && TARGET_SHMEDIA) ? ZERO_EXTEND \
  1546. : (MODE) != SImode ? SIGN_EXTEND : UNKNOWN)
  1547. /* Define if loading short immediate values into registers sign extends. */
  1548. #define SHORT_IMMEDIATES_SIGN_EXTEND
  1549. /* Nonzero if access to memory by bytes is no faster than for words. */
  1550. #define SLOW_BYTE_ACCESS 1
  1551. /* Nonzero if the target supports dynamic shift instructions
  1552. like shad and shld. */
  1553. #define TARGET_DYNSHIFT (TARGET_SH3 || TARGET_SH2A)
  1554. /* The cost of using the dynamic shift insns (shad, shld) are the same
  1555. if they are available. If they are not available a library function will
  1556. be emitted instead, which is more expensive. */
  1557. #define SH_DYNAMIC_SHIFT_COST (TARGET_DYNSHIFT ? 1 : 20)
  1558. /* Defining SHIFT_COUNT_TRUNCATED tells the combine pass that code like
  1559. (X << (Y % 32)) for register X, Y is equivalent to (X << Y).
  1560. This is not generally true when hardware dynamic shifts (shad, shld) are
  1561. used, because they check the sign bit _before_ the modulo op. The sign
  1562. bit determines whether it is a left shift or a right shift:
  1563. if (Y < 0)
  1564. return X << (Y & 31);
  1565. else
  1566. return X >> (-Y) & 31);
  1567. The dynamic shift library routines in lib1funcs.S do not use the sign bit
  1568. like the hardware dynamic shifts and truncate the shift count to 31.
  1569. We define SHIFT_COUNT_TRUNCATED to 0 and express the implied shift count
  1570. truncation in the library function call patterns, as this gives slightly
  1571. more compact code. */
  1572. #define SHIFT_COUNT_TRUNCATED (0)
  1573. /* All integers have the same format so truncation is easy. */
  1574. /* But SHmedia must sign-extend DImode when truncating to SImode. */
  1575. #define TRULY_NOOP_TRUNCATION(OUTPREC,INPREC) \
  1576. (!TARGET_SHMEDIA || (INPREC) < 64 || (OUTPREC) >= 64)
  1577. /* Define this if addresses of constant functions
  1578. shouldn't be put through pseudo regs where they can be cse'd.
  1579. Desirable on machines where ordinary constants are expensive
  1580. but a CALL with constant address is cheap. */
  1581. /*#define NO_FUNCTION_CSE 1*/
  1582. /* The machine modes of pointers and functions. */
  1583. #define Pmode (TARGET_SHMEDIA64 ? DImode : SImode)
  1584. #define FUNCTION_MODE Pmode
  1585. /* The multiply insn on the SH1 and the divide insns on the SH1 and SH2
  1586. are actually function calls with some special constraints on arguments
  1587. and register usage.
  1588. These macros tell reorg that the references to arguments and
  1589. register clobbers for insns of type sfunc do not appear to happen
  1590. until after the millicode call. This allows reorg to put insns
  1591. which set the argument registers into the delay slot of the millicode
  1592. call -- thus they act more like traditional CALL_INSNs.
  1593. get_attr_is_sfunc will try to recognize the given insn, so make sure to
  1594. filter out things it will not accept -- SEQUENCE, USE and CLOBBER insns
  1595. in particular. */
  1596. #define INSN_SETS_ARE_DELAYED(X) \
  1597. ((NONJUMP_INSN_P (X) \
  1598. && GET_CODE (PATTERN (X)) != SEQUENCE \
  1599. && GET_CODE (PATTERN (X)) != USE \
  1600. && GET_CODE (PATTERN (X)) != CLOBBER \
  1601. && get_attr_is_sfunc (X)))
  1602. #define INSN_REFERENCES_ARE_DELAYED(X) \
  1603. ((NONJUMP_INSN_P (X) \
  1604. && GET_CODE (PATTERN (X)) != SEQUENCE \
  1605. && GET_CODE (PATTERN (X)) != USE \
  1606. && GET_CODE (PATTERN (X)) != CLOBBER \
  1607. && get_attr_is_sfunc (X)))
  1608. /* Position Independent Code. */
  1609. /* We can't directly access anything that contains a symbol,
  1610. nor can we indirect via the constant pool. */
  1611. #define LEGITIMATE_PIC_OPERAND_P(X) \
  1612. ((! nonpic_symbol_mentioned_p (X) \
  1613. && (GET_CODE (X) != SYMBOL_REF \
  1614. || ! CONSTANT_POOL_ADDRESS_P (X) \
  1615. || ! nonpic_symbol_mentioned_p (get_pool_constant (X)))) \
  1616. || (TARGET_SHMEDIA && GET_CODE (X) == LABEL_REF))
  1617. #define SYMBOLIC_CONST_P(X) \
  1618. ((GET_CODE (X) == SYMBOL_REF || GET_CODE (X) == LABEL_REF) \
  1619. && nonpic_symbol_mentioned_p (X))
  1620. /* Compute extra cost of moving data between one register class
  1621. and another. */
  1622. /* If SECONDARY*_RELOAD_CLASS says something about the src/dst pair, regclass
  1623. uses this information. Hence, the general register <-> floating point
  1624. register information here is not used for SFmode. */
  1625. #define REGCLASS_HAS_GENERAL_REG(CLASS) \
  1626. ((CLASS) == GENERAL_REGS || (CLASS) == R0_REGS || (CLASS) == NON_SP_REGS \
  1627. || (! TARGET_SHMEDIA && (CLASS) == SIBCALL_REGS))
  1628. #define REGCLASS_HAS_FP_REG(CLASS) \
  1629. ((CLASS) == FP0_REGS || (CLASS) == FP_REGS \
  1630. || (CLASS) == DF_REGS)
  1631. /* ??? Perhaps make MEMORY_MOVE_COST depend on compiler option? This
  1632. would be so that people with slow memory systems could generate
  1633. different code that does fewer memory accesses. */
  1634. /* A C expression for the cost of a branch instruction. A value of 1
  1635. is the default; other values are interpreted relative to that. */
  1636. #define BRANCH_COST(speed_p, predictable_p) sh_branch_cost
  1637. /* Assembler output control. */
  1638. /* A C string constant describing how to begin a comment in the target
  1639. assembler language. The compiler assumes that the comment will end at
  1640. the end of the line. */
  1641. #define ASM_COMMENT_START "!"
  1642. #define ASM_APP_ON ""
  1643. #define ASM_APP_OFF ""
  1644. #define FILE_ASM_OP "\t.file\n"
  1645. #define SET_ASM_OP "\t.set\t"
  1646. /* How to change between sections. */
  1647. #define TEXT_SECTION_ASM_OP (TARGET_SHMEDIA32 \
  1648. ? "\t.section\t.text..SHmedia32,\"ax\"" \
  1649. : "\t.text")
  1650. #define DATA_SECTION_ASM_OP "\t.data"
  1651. #if defined CRT_BEGIN || defined CRT_END
  1652. /* Arrange for TEXT_SECTION_ASM_OP to be a compile-time constant. */
  1653. # undef TEXT_SECTION_ASM_OP
  1654. # if __SHMEDIA__ == 1 && __SH5__ == 32
  1655. # define TEXT_SECTION_ASM_OP "\t.section\t.text..SHmedia32,\"ax\""
  1656. # else
  1657. # define TEXT_SECTION_ASM_OP "\t.text"
  1658. # endif
  1659. #endif
  1660. #ifndef BSS_SECTION_ASM_OP
  1661. #define BSS_SECTION_ASM_OP "\t.section\t.bss"
  1662. #endif
  1663. #ifndef ASM_OUTPUT_ALIGNED_BSS
  1664. #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
  1665. asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
  1666. #endif
  1667. /* Define this so that jump tables go in same section as the current function,
  1668. which could be text or it could be a user defined section. */
  1669. #define JUMP_TABLES_IN_TEXT_SECTION 1
  1670. #undef DO_GLOBAL_CTORS_BODY
  1671. #define DO_GLOBAL_CTORS_BODY \
  1672. { \
  1673. typedef void (*pfunc) (void); \
  1674. extern pfunc __ctors[]; \
  1675. extern pfunc __ctors_end[]; \
  1676. pfunc *p; \
  1677. for (p = __ctors_end; p > __ctors; ) \
  1678. { \
  1679. (*--p)(); \
  1680. } \
  1681. }
  1682. #undef DO_GLOBAL_DTORS_BODY
  1683. #define DO_GLOBAL_DTORS_BODY \
  1684. { \
  1685. typedef void (*pfunc) (void); \
  1686. extern pfunc __dtors[]; \
  1687. extern pfunc __dtors_end[]; \
  1688. pfunc *p; \
  1689. for (p = __dtors; p < __dtors_end; p++) \
  1690. { \
  1691. (*p)(); \
  1692. } \
  1693. }
  1694. #define ASM_OUTPUT_REG_PUSH(file, v) \
  1695. { \
  1696. if (TARGET_SHMEDIA) \
  1697. { \
  1698. fprintf ((file), "\taddi.l\tr15,-8,r15\n"); \
  1699. fprintf ((file), "\tst.q\tr15,0,r%d\n", (v)); \
  1700. } \
  1701. else \
  1702. fprintf ((file), "\tmov.l\tr%d,@-r15\n", (v)); \
  1703. }
  1704. #define ASM_OUTPUT_REG_POP(file, v) \
  1705. { \
  1706. if (TARGET_SHMEDIA) \
  1707. { \
  1708. fprintf ((file), "\tld.q\tr15,0,r%d\n", (v)); \
  1709. fprintf ((file), "\taddi.l\tr15,8,r15\n"); \
  1710. } \
  1711. else \
  1712. fprintf ((file), "\tmov.l\t@r15+,r%d\n", (v)); \
  1713. }
  1714. /* DBX register number for a given compiler register number. */
  1715. /* GDB has FPUL at 23 and FP0 at 25, so we must add one to all FP registers
  1716. to match gdb. */
  1717. /* expand_builtin_init_dwarf_reg_sizes uses this to test if a
  1718. register exists, so we should return -1 for invalid register numbers. */
  1719. #define DBX_REGISTER_NUMBER(REGNO) SH_DBX_REGISTER_NUMBER (REGNO)
  1720. /* SHcompact PR_REG used to use the encoding 241, and SHcompact FP registers
  1721. used to use the encodings 245..260, but that doesn't make sense:
  1722. PR_REG and PR_MEDIA_REG are actually the same register, and likewise
  1723. the FP registers stay the same when switching between compact and media
  1724. mode. Hence, we also need to use the same dwarf frame columns.
  1725. Likewise, we need to support unwind information for SHmedia registers
  1726. even in compact code. */
  1727. #define SH_DBX_REGISTER_NUMBER(REGNO) \
  1728. (IN_RANGE ((REGNO), \
  1729. (unsigned HOST_WIDE_INT) FIRST_GENERAL_REG, \
  1730. FIRST_GENERAL_REG + (TARGET_SH5 ? 63U :15U)) \
  1731. ? ((unsigned) (REGNO) - FIRST_GENERAL_REG) \
  1732. : ((int) (REGNO) >= FIRST_FP_REG \
  1733. && ((int) (REGNO) \
  1734. <= (FIRST_FP_REG + \
  1735. ((TARGET_SH5 && TARGET_FPU_ANY) ? 63 : TARGET_SH2E ? 15 : -1)))) \
  1736. ? ((unsigned) (REGNO) - FIRST_FP_REG \
  1737. + (TARGET_SH5 ? 77 : 25)) \
  1738. : XD_REGISTER_P (REGNO) \
  1739. ? ((unsigned) (REGNO) - FIRST_XD_REG + (TARGET_SH5 ? 289 : 87)) \
  1740. : TARGET_REGISTER_P (REGNO) \
  1741. ? ((unsigned) (REGNO) - FIRST_TARGET_REG + 68) \
  1742. : (REGNO) == PR_REG \
  1743. ? (TARGET_SH5 ? 18 : 17) \
  1744. : (REGNO) == PR_MEDIA_REG \
  1745. ? (TARGET_SH5 ? 18 : (unsigned) -1) \
  1746. : (REGNO) == GBR_REG \
  1747. ? (TARGET_SH5 ? 238 : 18) \
  1748. : (REGNO) == MACH_REG \
  1749. ? (TARGET_SH5 ? 239 : 20) \
  1750. : (REGNO) == MACL_REG \
  1751. ? (TARGET_SH5 ? 240 : 21) \
  1752. : (REGNO) == T_REG \
  1753. ? (TARGET_SH5 ? 242 : 22) \
  1754. : (REGNO) == FPUL_REG \
  1755. ? (TARGET_SH5 ? 244 : 23) \
  1756. : (REGNO) == FPSCR_REG \
  1757. ? (TARGET_SH5 ? 243 : 24) \
  1758. : (unsigned) -1)
  1759. /* This is how to output a reference to a symbol_ref. On SH5,
  1760. references to non-code symbols must be preceded by `datalabel'. */
  1761. #define ASM_OUTPUT_SYMBOL_REF(FILE,SYM) \
  1762. do \
  1763. { \
  1764. if (TARGET_SH5 && !SYMBOL_REF_FUNCTION_P (SYM)) \
  1765. fputs ("datalabel ", (FILE)); \
  1766. assemble_name ((FILE), XSTR ((SYM), 0)); \
  1767. } \
  1768. while (0)
  1769. /* This is how to output an assembler line
  1770. that says to advance the location counter
  1771. to a multiple of 2**LOG bytes. */
  1772. #define ASM_OUTPUT_ALIGN(FILE,LOG) \
  1773. if ((LOG) != 0) \
  1774. fprintf ((FILE), "\t.align %d\n", (LOG))
  1775. /* Globalizing directive for a label. */
  1776. #define GLOBAL_ASM_OP "\t.global\t"
  1777. /* #define ASM_OUTPUT_CASE_END(STREAM,NUM,TABLE) */
  1778. /* Output a relative address table. */
  1779. #define ASM_OUTPUT_ADDR_DIFF_ELT(STREAM,BODY,VALUE,REL) \
  1780. switch (GET_MODE (BODY)) \
  1781. { \
  1782. case SImode: \
  1783. if (TARGET_SH5) \
  1784. { \
  1785. asm_fprintf ((STREAM), "\t.long\t%LL%d-datalabel %LL%d\n", \
  1786. (VALUE), (REL)); \
  1787. break; \
  1788. } \
  1789. asm_fprintf ((STREAM), "\t.long\t%LL%d-%LL%d\n", (VALUE),(REL)); \
  1790. break; \
  1791. case HImode: \
  1792. if (TARGET_SH5) \
  1793. { \
  1794. asm_fprintf ((STREAM), "\t.word\t%LL%d-datalabel %LL%d\n", \
  1795. (VALUE), (REL)); \
  1796. break; \
  1797. } \
  1798. asm_fprintf ((STREAM), "\t.word\t%LL%d-%LL%d\n", (VALUE),(REL)); \
  1799. break; \
  1800. case QImode: \
  1801. if (TARGET_SH5) \
  1802. { \
  1803. asm_fprintf ((STREAM), "\t.byte\t%LL%d-datalabel %LL%d\n", \
  1804. (VALUE), (REL)); \
  1805. break; \
  1806. } \
  1807. asm_fprintf ((STREAM), "\t.byte\t%LL%d-%LL%d\n", (VALUE),(REL)); \
  1808. break; \
  1809. default: \
  1810. break; \
  1811. }
  1812. /* Output an absolute table element. */
  1813. #define ASM_OUTPUT_ADDR_VEC_ELT(STREAM,VALUE) \
  1814. if (! optimize || TARGET_BIGTABLE) \
  1815. asm_fprintf ((STREAM), "\t.long\t%LL%d\n", (VALUE)); \
  1816. else \
  1817. asm_fprintf ((STREAM), "\t.word\t%LL%d\n", (VALUE));
  1818. /* A C statement to be executed just prior to the output of
  1819. assembler code for INSN, to modify the extracted operands so
  1820. they will be output differently.
  1821. Here the argument OPVEC is the vector containing the operands
  1822. extracted from INSN, and NOPERANDS is the number of elements of
  1823. the vector which contain meaningful data for this insn.
  1824. The contents of this vector are what will be used to convert the insn
  1825. template into assembler code, so you can change the assembler output
  1826. by changing the contents of the vector. */
  1827. #define FINAL_PRESCAN_INSN(INSN, OPVEC, NOPERANDS) \
  1828. final_prescan_insn ((INSN), (OPVEC), (NOPERANDS))
  1829. extern rtx sh_compare_op0;
  1830. extern rtx sh_compare_op1;
  1831. /* Which processor to schedule for. The elements of the enumeration must
  1832. match exactly the cpu attribute in the sh.md file. */
  1833. enum processor_type {
  1834. PROCESSOR_SH1,
  1835. PROCESSOR_SH2,
  1836. PROCESSOR_SH2E,
  1837. PROCESSOR_SH2A,
  1838. PROCESSOR_SH3,
  1839. PROCESSOR_SH3E,
  1840. PROCESSOR_SH4,
  1841. PROCESSOR_SH4A,
  1842. PROCESSOR_SH5
  1843. };
  1844. #define sh_cpu_attr ((enum attr_cpu)sh_cpu)
  1845. extern enum processor_type sh_cpu;
  1846. enum mdep_reorg_phase_e
  1847. {
  1848. SH_BEFORE_MDEP_REORG,
  1849. SH_INSERT_USES_LABELS,
  1850. SH_SHORTEN_BRANCHES0,
  1851. SH_FIXUP_PCLOAD,
  1852. SH_SHORTEN_BRANCHES1,
  1853. SH_AFTER_MDEP_REORG
  1854. };
  1855. extern enum mdep_reorg_phase_e mdep_reorg_phase;
  1856. /* Handle Renesas compiler's pragmas. */
  1857. #define REGISTER_TARGET_PRAGMAS() do { \
  1858. c_register_pragma (0, "interrupt", sh_pr_interrupt); \
  1859. c_register_pragma (0, "trapa", sh_pr_trapa); \
  1860. c_register_pragma (0, "nosave_low_regs", sh_pr_nosave_low_regs); \
  1861. } while (0)
  1862. extern tree sh_deferred_function_attributes;
  1863. extern tree *sh_deferred_function_attributes_tail;
  1864. /* Set when processing a function with interrupt attribute. */
  1865. extern int current_function_interrupt;
  1866. /* Instructions with unfilled delay slots take up an
  1867. extra two bytes for the nop in the delay slot.
  1868. sh-dsp parallel processing insns are four bytes long. */
  1869. #define ADJUST_INSN_LENGTH(X, LENGTH) \
  1870. (LENGTH) += sh_insn_length_adjustment (X);
  1871. /* Define this macro if it is advisable to hold scalars in registers
  1872. in a wider mode than that declared by the program. In such cases,
  1873. the value is constrained to be within the bounds of the declared
  1874. type, but kept valid in the wider mode. The signedness of the
  1875. extension may differ from that of the type.
  1876. Leaving the unsignedp unchanged gives better code than always setting it
  1877. to 0. This is despite the fact that we have only signed char and short
  1878. load instructions. */
  1879. #define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \
  1880. if (GET_MODE_CLASS (MODE) == MODE_INT \
  1881. && GET_MODE_SIZE (MODE) < 4/* ! UNITS_PER_WORD */)\
  1882. (UNSIGNEDP) = ((MODE) == SImode ? 0 : (UNSIGNEDP)), \
  1883. (MODE) = (TARGET_SH1 ? SImode \
  1884. : TARGET_SHMEDIA32 ? SImode : DImode);
  1885. #define MAX_FIXED_MODE_SIZE (TARGET_SH5 ? 128 : 64)
  1886. /* Better to allocate once the maximum space for outgoing args in the
  1887. prologue rather than duplicate around each call. */
  1888. #define ACCUMULATE_OUTGOING_ARGS TARGET_ACCUMULATE_OUTGOING_ARGS
  1889. #define NUM_MODES_FOR_MODE_SWITCHING { FP_MODE_NONE }
  1890. #define OPTIMIZE_MODE_SWITCHING(ENTITY) (TARGET_SH4 || TARGET_SH2A_DOUBLE)
  1891. #define ACTUAL_NORMAL_MODE(ENTITY) \
  1892. (TARGET_FPU_SINGLE ? FP_MODE_SINGLE : FP_MODE_DOUBLE)
  1893. #define NORMAL_MODE(ENTITY) \
  1894. (sh_cfun_interrupt_handler_p () \
  1895. ? (TARGET_FMOVD ? FP_MODE_DOUBLE : FP_MODE_NONE) \
  1896. : ACTUAL_NORMAL_MODE (ENTITY))
  1897. #define EPILOGUE_USES(REGNO) ((TARGET_SH2E || TARGET_SH4) \
  1898. && (REGNO) == FPSCR_REG)
  1899. #define DWARF_FRAME_RETURN_COLUMN \
  1900. (TARGET_SH5 ? DWARF_FRAME_REGNUM (PR_MEDIA_REG) : DWARF_FRAME_REGNUM (PR_REG))
  1901. #define EH_RETURN_DATA_REGNO(N) \
  1902. ((N) < 4 ? (N) + (TARGET_SH5 ? 2U : 4U) : INVALID_REGNUM)
  1903. #define EH_RETURN_STACKADJ_REGNO STATIC_CHAIN_REGNUM
  1904. #define EH_RETURN_STACKADJ_RTX gen_rtx_REG (Pmode, EH_RETURN_STACKADJ_REGNO)
  1905. /* We have to distinguish between code and data, so that we apply
  1906. datalabel where and only where appropriate. Use sdataN for data. */
  1907. #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
  1908. ((flag_pic && (GLOBAL) ? DW_EH_PE_indirect : 0) \
  1909. | (flag_pic ? DW_EH_PE_pcrel : DW_EH_PE_absptr) \
  1910. | ((CODE) ? 0 : (TARGET_SHMEDIA64 ? DW_EH_PE_sdata8 : DW_EH_PE_sdata4)))
  1911. /* Handle special EH pointer encodings. Absolute, pc-relative, and
  1912. indirect are handled automatically. */
  1913. #define ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX(FILE, ENCODING, SIZE, ADDR, DONE) \
  1914. do { \
  1915. if (((ENCODING) & 0xf) != DW_EH_PE_sdata4 \
  1916. && ((ENCODING) & 0xf) != DW_EH_PE_sdata8) \
  1917. { \
  1918. gcc_assert (GET_CODE (ADDR) == SYMBOL_REF); \
  1919. SYMBOL_REF_FLAGS (ADDR) |= SYMBOL_FLAG_FUNCTION; \
  1920. if (0) goto DONE; \
  1921. } \
  1922. } while (0)
  1923. #if (defined CRT_BEGIN || defined CRT_END) && ! __SHMEDIA__
  1924. /* SH constant pool breaks the devices in crtstuff.c to control section
  1925. in where code resides. We have to write it as asm code. */
  1926. #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
  1927. asm (SECTION_OP "\n\
  1928. mov.l 1f,r1\n\
  1929. mova 2f,r0\n\
  1930. braf r1\n\
  1931. lds r0,pr\n\
  1932. 0: .p2align 2\n\
  1933. 1: .long " USER_LABEL_PREFIX #FUNC " - 0b\n\
  1934. 2:\n" TEXT_SECTION_ASM_OP);
  1935. #endif /* (defined CRT_BEGIN || defined CRT_END) && ! __SHMEDIA__ */
  1936. #endif /* ! GCC_SH_H */