tm-isi68.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. /* Definitions of target machine for GNU compiler. ISI 68000/68020 version.
  2. Copyright (C) 1987 Free Software Foundation, Inc.
  3. This file is part of GNU CC.
  4. GNU CC is distributed in the hope that it will be useful,
  5. but WITHOUT ANY WARRANTY. No author or distributor
  6. accepts responsibility to anyone for the consequences of using it
  7. or for whether it serves any particular purpose or works at all,
  8. unless he says so in writing. Refer to the GNU CC General Public
  9. License for full details.
  10. Everyone is granted permission to copy, modify and redistribute
  11. GNU CC, but only under the conditions described in the
  12. GNU CC General Public License. A copy of this license is
  13. supposed to have been given to you along with GNU CC so you
  14. can know your rights and responsibilities. It should be in a
  15. file named COPYING. Among other things, the copyright notice
  16. and this notice must be preserved on all copies. */
  17. #include "tm-m68k.h"
  18. /* Control conditionals in m68k.md. */
  19. #define ISI_OV
  20. /* See tm-m68k.h. 7 means 68020 with 68881.
  21. Use 017 if in addition the C library is compiled with 68881 insns;
  22. in that case, SFmode and DFmode values are returned in register f0. */
  23. #define TARGET_DEFAULT 7
  24. /* Names to predefine in the preprocessor for this target machine. */
  25. #define CPP_PREDEFINES "-Dmc68000 -Dis68k"
  26. /* Override parts of tm-m68k.h to fit the ISI 68k machine. */
  27. #undef TARGET_SWITCHES
  28. #undef FUNCTION_PROLOGUE
  29. #undef FUNCTION_EPILOGUE
  30. #undef REGISTER_NAMES
  31. #undef FUNCTION_VALUE
  32. #undef LIBCALL_VALUE
  33. #undef FUNCTION_VALUE_REGNO_P
  34. #undef ASM_FILE_START
  35. #undef ASM_APP_ON
  36. #undef ASM_APP_OFF
  37. #undef ASM_OUTPUT_DOUBLE
  38. #undef ASM_OUTPUT_FLOAT
  39. #undef ASM_OUTPUT_ALIGN
  40. #undef ASM_OUTPUT_SKIP
  41. #undef PRINT_OPERAND
  42. #undef PRINT_OPERAND_ADDRESS
  43. #define TARGET_LIBC_68881 (target_flags & 8)
  44. #define TARGET_SWITCHES \
  45. { { "68020", 5}, \
  46. { "68881", 2}, \
  47. { "bitfield", 4}, \
  48. { "68000", -5}, \
  49. { "soft-float", -2}, \
  50. { "nobitfield", -4}, \
  51. { "libc-68881", 8}, \
  52. { "libc-soft-float", -8}, \
  53. { "", TARGET_DEFAULT}}
  54. /* Difference from tm-m68k.h is in `fp' instead of `a6'
  55. and `f' instead of `fp' for the 68881 registers. */
  56. #define REGISTER_NAMES \
  57. {"d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", \
  58. "a0", "a1", "a2", "a3", "a4", "a5", "fp", "sp", \
  59. "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7"}
  60. /* If TARGET_LIBC_68881, return SF and DF values in f0 instead of d0. */
  61. #define FUNCTION_VALUE(VALTYPE,FUNC) LIBCALL_VALUE (TYPE_MODE (VALTYPE))
  62. #define LIBCALL_VALUE(MODE) \
  63. gen_rtx (REG, (MODE), ((TARGET_LIBC_68881 && ((MODE) == SFmode || (MODE) == DFmode)) ? 16 : 0))
  64. /* 1 if N is a possible register number for a function value.
  65. D0 may be used, and F0 as well if -mlibc-68881 is specified. */
  66. #define FUNCTION_VALUE_REGNO_P(N) \
  67. ((N) == 0 || (TARGET_LIBC_68881 && (N) == 16))
  68. /* These definitions of FUNCTION_PROLOGUE and FUNCTION_EPILOGUE
  69. are the same as in tm-m68k.h except for syntax of assembler code:
  70. It uses `fp' instead of `a6'. */
  71. #define FUNCTION_PROLOGUE(FILE, SIZE) \
  72. { register int regno; \
  73. register int mask = 0; \
  74. static char *reg_names[] = REGISTER_NAMES; \
  75. extern char call_used_regs[]; \
  76. int fsize = (SIZE); \
  77. if (frame_pointer_needed) \
  78. { if (TARGET_68020 || fsize < 0x10000) \
  79. fprintf (FILE, "\tlink fp,#%d\n", -fsize); \
  80. else \
  81. fprintf (FILE, "\tlink fp,#0\n\tsubl #%d,sp\n", fsize); } \
  82. for (regno = 16; regno < FIRST_PSEUDO_REGISTER; regno++) \
  83. if (regs_ever_live[regno] && ! call_used_regs[regno]) \
  84. mask |= 1 << (regno - 16); \
  85. if (mask != 0) \
  86. fprintf (FILE, "\tfmovem #0x%x,sp@-\n", mask & 0xff); \
  87. mask = 0; \
  88. for (regno = 0; regno < 16; regno++) \
  89. if (regs_ever_live[regno] && ! call_used_regs[regno]) \
  90. mask |= 1 << (15 - regno); \
  91. if (frame_pointer_needed) \
  92. mask &= ~ (1 << (15-FRAME_POINTER_REGNUM)); \
  93. if (exact_log2 (mask) >= 0) \
  94. fprintf (FILE, "\tmovl %s,sp@-\n", reg_names[15 - exact_log2 (mask)]); \
  95. else if (mask) fprintf (FILE, "\tmoveml #0x%x,sp@-\n", mask); }
  96. #define FUNCTION_EPILOGUE(FILE, SIZE) \
  97. { register int regno; \
  98. register int mask, fmask; \
  99. register int nregs; \
  100. int offset, foffset; \
  101. extern char call_used_regs[]; \
  102. static char *reg_names[] = REGISTER_NAMES; \
  103. extern int current_function_pops_args; \
  104. extern int current_function_args_size; \
  105. int fsize = (SIZE); \
  106. int big = 0; \
  107. nregs = 0; fmask = 0; \
  108. for (regno = 16; regno < FIRST_PSEUDO_REGISTER; regno++) \
  109. if (regs_ever_live[regno] && ! call_used_regs[regno]) \
  110. { nregs++; fmask |= 1 << (23 - regno); } \
  111. foffset = nregs * 12; \
  112. nregs = 0; mask = 0; \
  113. if (frame_pointer_needed) regs_ever_live[FRAME_POINTER_REGNUM] = 0; \
  114. for (regno = 0; regno < 16; regno++) \
  115. if (regs_ever_live[regno] && ! call_used_regs[regno]) \
  116. { nregs++; mask |= 1 << regno; } \
  117. offset = foffset + nregs * 4; \
  118. if (offset + fsize >= 0x8000 && frame_pointer_needed) \
  119. { fprintf (FILE, "\tmovel #%d,a0\n", -fsize); \
  120. fsize = 0, big = 1; } \
  121. if (exact_log2 (mask) >= 0) { \
  122. if (big) \
  123. fprintf (FILE, "\tmovel fp@(-%d,a0:l),%s\n", \
  124. offset + fsize, reg_names[exact_log2 (mask)]); \
  125. else if (! frame_pointer_needed) \
  126. fprintf (FILE, "\tmovel sp@+,%s\n", \
  127. reg_names[exact_log2 (mask)]); \
  128. else \
  129. fprintf (FILE, "\tmovel fp@(-%d),%s\n", \
  130. offset + fsize, reg_names[exact_log2 (mask)]); } \
  131. else if (mask) { \
  132. if (big) \
  133. fprintf (FILE, "\tmoveml fp@(-%d,a0:l),#0x%x\n", \
  134. offset + fsize, mask); \
  135. else if (! frame_pointer_needed) \
  136. fprintf (FILE, "\tmoveml sp@+,#0x%x\n", mask); \
  137. else \
  138. fprintf (FILE, "\tmoveml fp@(-%d),#0x%x\n", \
  139. offset + fsize, mask); } \
  140. if (fmask) { \
  141. if (big) \
  142. fprintf (FILE, "\tfmovem fp@(-%d,a0:l),#0x%x\n", \
  143. foffset + fsize, fmask); \
  144. else if (! frame_pointer_needed) \
  145. fprintf (FILE, "\tfmovem sp@+,#0x%x\n", fmask); \
  146. else \
  147. fprintf (FILE, "\tfmovem fp@(-%d),#0x%x\n", \
  148. foffset + fsize, fmask); } \
  149. if (frame_pointer_needed) \
  150. fprintf (FILE, "\tunlk fp\n"); \
  151. if (current_function_pops_args && current_function_args_size) \
  152. fprintf (FILE, "\trtd #%d\n", current_function_args_size); \
  153. else fprintf (FILE, "\trts\n"); }
  154. /* Do NOT output the usual #NO_APP, because the ISI assembler
  155. doesn't accept # as a comment starter.
  156. And DO output something to cause the correct _doprnt to be loaded. */
  157. #define ASM_FILE_START ".globl fltused\n"
  158. /* There is no need to turn on and off app processing
  159. since this output is not for the GNU assembler. */
  160. #define ASM_APP_ON ""
  161. #define ASM_APP_OFF ""
  162. #define ASM_OUTPUT_DOUBLE(FILE,VALUE) \
  163. fprintf (FILE, "\t.double 0d%.20g\n", (VALUE))
  164. #define ASM_OUTPUT_FLOAT(FILE,VALUE) \
  165. fprintf (FILE, "\t.float 0f%.10g\n", (VALUE))
  166. #define ASM_OUTPUT_ALIGN(FILE,LOG) \
  167. if ((LOG) != 0) fprintf (FILE, "\t.align %d\n", (LOG));
  168. #define ASM_OUTPUT_SKIP(FILE,SIZE) \
  169. fprintf (FILE, "\t.space %d\n", (SIZE))
  170. #define PRINT_OPERAND(FILE, X, CODE) \
  171. { if (CODE == '.') ; \
  172. else if (GET_CODE (X) == REG) \
  173. fprintf (FILE, "%s", reg_name [REGNO (X)]); \
  174. else if (GET_CODE (X) == MEM) \
  175. output_address (XEXP (X, 0)); \
  176. else if (GET_CODE (X) == CONST_DOUBLE && GET_MODE (X) == SFmode) \
  177. { union { double d; int i[2]; } u; \
  178. union { float f; int i; } u1; \
  179. u.i[0] = XINT (X, 0); u.i[1] = XINT (X, 1); \
  180. u1.f = u.d; \
  181. if (CODE == 'f') \
  182. fprintf (FILE, "#0f%.9g", u1.f); \
  183. else \
  184. fprintf (FILE, "#0x%x", u1.i); } \
  185. else if (GET_CODE (X) == CONST_DOUBLE) \
  186. { union { double d; int i[2]; } u; \
  187. u.i[0] = XINT (X, 0); u.i[1] = XINT (X, 1); \
  188. fprintf (FILE, "#0d%.20g", u.d); } \
  189. else if (CODE == 'b') output_addr_const (FILE, X); \
  190. else { putc ('#', FILE); output_addr_const (FILE, X); }}
  191. /* Note that this contains a kludge that knows that the only reason
  192. we have an address (plus (label_ref...) (reg...))
  193. is in the insn before a tablejump, and the displacement must be 6. */
  194. #define PRINT_OPERAND_ADDRESS(FILE, ADDR) \
  195. { register rtx reg1, reg2, breg, ireg; \
  196. register rtx addr = ADDR; \
  197. rtx offset; \
  198. switch (GET_CODE (addr)) \
  199. { \
  200. case REG: \
  201. fprintf (FILE, "%s@", reg_name [REGNO (addr)]); \
  202. break; \
  203. case PRE_DEC: \
  204. fprintf (FILE, "%s@-", reg_name [REGNO (XEXP (addr, 0))]); \
  205. break; \
  206. case POST_INC: \
  207. fprintf (FILE, "%s@+", reg_name [REGNO (XEXP (addr, 0))]); \
  208. break; \
  209. case PLUS: \
  210. reg1 = 0; reg2 = 0; \
  211. ireg = 0; breg = 0; \
  212. offset = 0; \
  213. if (CONSTANT_ADDRESS_P (XEXP (addr, 0))) \
  214. { \
  215. offset = XEXP (addr, 0); \
  216. addr = XEXP (addr, 1); \
  217. } \
  218. else if (CONSTANT_ADDRESS_P (XEXP (addr, 1))) \
  219. { \
  220. offset = XEXP (addr, 1); \
  221. addr = XEXP (addr, 0); \
  222. } \
  223. if (GET_CODE (addr) != PLUS) ; \
  224. else if (GET_CODE (XEXP (addr, 0)) == SIGN_EXTEND) \
  225. { \
  226. reg1 = XEXP (addr, 0); \
  227. addr = XEXP (addr, 1); \
  228. } \
  229. else if (GET_CODE (XEXP (addr, 1)) == SIGN_EXTEND) \
  230. { \
  231. reg1 = XEXP (addr, 1); \
  232. addr = XEXP (addr, 0); \
  233. } \
  234. else if (GET_CODE (XEXP (addr, 0)) == MULT) \
  235. { \
  236. reg1 = XEXP (addr, 0); \
  237. addr = XEXP (addr, 1); \
  238. } \
  239. else if (GET_CODE (XEXP (addr, 1)) == MULT) \
  240. { \
  241. reg1 = XEXP (addr, 1); \
  242. addr = XEXP (addr, 0); \
  243. } \
  244. else if (GET_CODE (XEXP (addr, 0)) == REG) \
  245. { \
  246. reg1 = XEXP (addr, 0); \
  247. addr = XEXP (addr, 1); \
  248. } \
  249. else if (GET_CODE (XEXP (addr, 1)) == REG) \
  250. { \
  251. reg1 = XEXP (addr, 1); \
  252. addr = XEXP (addr, 0); \
  253. } \
  254. if (GET_CODE (addr) == REG || GET_CODE (addr) == MULT \
  255. || GET_CODE (addr) == SIGN_EXTEND) \
  256. { if (reg1 == 0) reg1 = addr; else reg2 = addr; addr = 0; } \
  257. /* for OLD_INDEXING \
  258. else if (GET_CODE (addr) == PLUS) \
  259. { \
  260. if (GET_CODE (XEXP (addr, 0)) == REG) \
  261. { \
  262. reg2 = XEXP (addr, 0); \
  263. addr = XEXP (addr, 1); \
  264. } \
  265. else if (GET_CODE (XEXP (addr, 1)) == REG) \
  266. { \
  267. reg2 = XEXP (addr, 1); \
  268. addr = XEXP (addr, 0); \
  269. } \
  270. } \
  271. */ \
  272. if (offset != 0) { if (addr != 0) abort (); addr = offset; } \
  273. if ((reg1 && (GET_CODE (reg1) == SIGN_EXTEND \
  274. || GET_CODE (reg1) == MULT)) \
  275. || (reg2 != 0 && REGNO_OK_FOR_BASE_P (REGNO (reg2)))) \
  276. { breg = reg2; ireg = reg1; } \
  277. else if (reg1 != 0 && REGNO_OK_FOR_BASE_P (REGNO (reg1))) \
  278. { breg = reg1; ireg = reg2; } \
  279. if (ireg != 0 && breg == 0 && GET_CODE (addr) == LABEL_REF) \
  280. { int scale = 1; \
  281. if (GET_CODE (ireg) == MULT) \
  282. { scale = INTVAL (XEXP (ireg, 1)); \
  283. ireg = XEXP (ireg, 0); } \
  284. if (GET_CODE (ireg) == SIGN_EXTEND) \
  285. fprintf (FILE, "pc@(L%d-LI%d-2:b,%s:w", \
  286. CODE_LABEL_NUMBER (XEXP (addr, 0)), \
  287. CODE_LABEL_NUMBER (XEXP (addr, 0)), \
  288. reg_name[REGNO (XEXP (ireg, 0))]); \
  289. else \
  290. fprintf (FILE, "pc@(L%d-LI%d-2:b,%s:l", \
  291. CODE_LABEL_NUMBER (XEXP (addr, 0)), \
  292. CODE_LABEL_NUMBER (XEXP (addr, 0)), \
  293. reg_name[REGNO (ireg)]); \
  294. if (scale != 1) fprintf (FILE, "*%d", scale); \
  295. putc (')', FILE); \
  296. break; } \
  297. if (ireg != 0 || breg != 0) \
  298. { int scale = 1; \
  299. if (breg == 0) \
  300. abort (); \
  301. fprintf (FILE, "%s@(", reg_name[REGNO (breg)]); \
  302. if (addr != 0) \
  303. output_addr_const (FILE, addr); \
  304. else putc ('0', FILE); \
  305. if (ireg != 0 && GET_CODE (ireg) == MULT) \
  306. { scale = INTVAL (XEXP (ireg, 1)); \
  307. ireg = XEXP (ireg, 0); } \
  308. if (ireg != 0 && GET_CODE (ireg) == SIGN_EXTEND) \
  309. fprintf (FILE, ",%s:w", reg_name[REGNO (XEXP (ireg, 0))]); \
  310. else if (ireg != 0) \
  311. fprintf (FILE, ",%s:l", reg_name[REGNO (ireg)]); \
  312. if (scale != 1) fprintf (FILE, "*%d", scale); \
  313. putc (')', FILE); \
  314. break; \
  315. } \
  316. else if (reg1 != 0 && GET_CODE (addr) == LABEL_REF) \
  317. { fprintf (FILE, "pc@(L%d-LI%d-2:b,%s:l)", \
  318. CODE_LABEL_NUMBER (XEXP (addr, 0)), \
  319. CODE_LABEL_NUMBER (XEXP (addr, 0)), \
  320. reg_name[REGNO (reg1)]); \
  321. break; } \
  322. default: \
  323. if (GET_CODE (addr) == CONST_INT \
  324. && INTVAL (addr) < 0x8000 \
  325. && INTVAL (addr) >= -0x8000) \
  326. fprintf (FILE, "%d:w", INTVAL (addr)); \
  327. else \
  328. output_addr_const (FILE, addr); \
  329. }}