freebsd64.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  1. /* Definitions for 64-bit PowerPC running FreeBSD using the ELF format
  2. Copyright (C) 2012-2015 Free Software Foundation, Inc.
  3. This file is part of GCC.
  4. GCC is free software; you can redistribute it and/or modify it
  5. under the terms of the GNU General Public License as published
  6. by the Free Software Foundation; either version 3, or (at your
  7. option) any later version.
  8. GCC is distributed in the hope that it will be useful, but WITHOUT
  9. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  10. or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  11. License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GCC; see the file COPYING3. If not see
  14. <http://www.gnu.org/licenses/>. */
  15. /* Override the defaults, which exist to force the proper definition. */
  16. #ifdef IN_LIBGCC2
  17. #undef TARGET_64BIT
  18. #ifdef __powerpc64__
  19. #define TARGET_64BIT 1
  20. #else
  21. #define TARGET_64BIT 0
  22. #endif
  23. #endif
  24. #undef TARGET_AIX
  25. #define TARGET_AIX TARGET_64BIT
  26. #ifdef HAVE_LD_NO_DOT_SYMS
  27. /* New ABI uses a local sym for the function entry point. */
  28. extern int dot_symbols;
  29. #undef DOT_SYMBOLS
  30. #define DOT_SYMBOLS dot_symbols
  31. #endif
  32. #define TARGET_USES_LINUX64_OPT 1
  33. #ifdef HAVE_LD_LARGE_TOC
  34. #undef TARGET_CMODEL
  35. #define TARGET_CMODEL rs6000_current_cmodel
  36. #define SET_CMODEL(opt) rs6000_current_cmodel = opt
  37. #else
  38. #define SET_CMODEL(opt) do {} while (0)
  39. #endif
  40. /* Until now the 970 is the only Processor where FreeBSD 64-bit runs on. */
  41. #undef PROCESSOR_DEFAULT
  42. #define PROCESSOR_DEFAULT PROCESSOR_POWER4
  43. #undef PROCESSOR_DEFAULT64
  44. #define PROCESSOR_DEFAULT64 PROCESSOR_POWER4
  45. /* We don't need to generate entries in .fixup, except when
  46. -mrelocatable or -mrelocatable-lib is given. */
  47. #undef RELOCATABLE_NEEDS_FIXUP
  48. #define RELOCATABLE_NEEDS_FIXUP \
  49. (rs6000_isa_flags & rs6000_isa_flags_explicit & OPTION_MASK_RELOCATABLE)
  50. #undef RS6000_ABI_NAME
  51. #define RS6000_ABI_NAME "freebsd"
  52. #define INVALID_64BIT "-m%s not supported in this configuration"
  53. #define INVALID_32BIT INVALID_64BIT
  54. #undef SUBSUBTARGET_OVERRIDE_OPTIONS
  55. #define SUBSUBTARGET_OVERRIDE_OPTIONS \
  56. do \
  57. { \
  58. if (!global_options_set.x_rs6000_alignment_flags) \
  59. rs6000_alignment_flags = MASK_ALIGN_NATURAL; \
  60. if (TARGET_64BIT) \
  61. { \
  62. if (DEFAULT_ABI != ABI_AIX) \
  63. { \
  64. rs6000_current_abi = ABI_AIX; \
  65. error (INVALID_64BIT, "call"); \
  66. } \
  67. dot_symbols = !strcmp (rs6000_abi_name, "aixdesc"); \
  68. if (rs6000_isa_flags & OPTION_MASK_RELOCATABLE) \
  69. { \
  70. rs6000_isa_flags &= ~OPTION_MASK_RELOCATABLE; \
  71. error (INVALID_64BIT, "relocatable"); \
  72. } \
  73. if (rs6000_isa_flags & OPTION_MASK_EABI) \
  74. { \
  75. rs6000_isa_flags &= ~OPTION_MASK_EABI; \
  76. error (INVALID_64BIT, "eabi"); \
  77. } \
  78. if (TARGET_PROTOTYPE) \
  79. { \
  80. target_prototype = 0; \
  81. error (INVALID_64BIT, "prototype"); \
  82. } \
  83. if ((rs6000_isa_flags & OPTION_MASK_POWERPC64) == 0) \
  84. { \
  85. rs6000_isa_flags |= OPTION_MASK_POWERPC64; \
  86. error ("-m64 requires a PowerPC64 cpu"); \
  87. } \
  88. if ((rs6000_isa_flags_explicit \
  89. & OPTION_MASK_MINIMAL_TOC) != 0) \
  90. { \
  91. if (global_options_set.x_rs6000_current_cmodel \
  92. && rs6000_current_cmodel != CMODEL_SMALL) \
  93. error ("-mcmodel incompatible with other toc options"); \
  94. SET_CMODEL (CMODEL_SMALL); \
  95. } \
  96. else \
  97. { \
  98. if (!global_options_set.x_rs6000_current_cmodel) \
  99. SET_CMODEL (CMODEL_MEDIUM); \
  100. if (rs6000_current_cmodel != CMODEL_SMALL) \
  101. { \
  102. TARGET_NO_FP_IN_TOC = 0; \
  103. TARGET_NO_SUM_IN_TOC = 0; \
  104. } \
  105. } \
  106. } \
  107. } \
  108. while (0)
  109. #undef ASM_DEFAULT_SPEC
  110. #undef ASM_SPEC
  111. #undef LINK_OS_FREEBSD_SPEC
  112. #define ASM_DEFAULT_SPEC "-mppc%{!m32:64}"
  113. #define ASM_SPEC "%{m32:%(asm_spec32)}%{!m32:%(asm_spec64)} %(asm_spec_common)"
  114. #define LINK_OS_FREEBSD_SPEC "%{m32:%(link_os_freebsd_spec32)}%{!m32:%(link_os_freebsd_spec64)}"
  115. #define ASM_SPEC32 "-a32 \
  116. %{mrelocatable} %{mrelocatable-lib} %{fpic:-K PIC} %{fPIC:-K PIC} \
  117. %{memb} %{!memb: %{msdata=eabi: -memb}} \
  118. %{!mlittle: %{!mlittle-endian: %{!mbig: %{!mbig-endian: \
  119. %{mcall-freebsd: -mbig} \
  120. %{mcall-i960-old: -mlittle} \
  121. %{mcall-linux: -mbig} \
  122. %{mcall-gnu: -mbig} \
  123. %{mcall-netbsd: -mbig} \
  124. }}}}"
  125. #define ASM_SPEC64 "-a64"
  126. #define ASM_SPEC_COMMON "%(asm_cpu) \
  127. %{,assembler|,assembler-with-cpp: %{mregnames} %{mno-regnames}} \
  128. %{mlittle} %{mlittle-endian} %{mbig} %{mbig-endian}"
  129. #undef SUBSUBTARGET_EXTRA_SPECS
  130. #define SUBSUBTARGET_EXTRA_SPECS \
  131. { "asm_spec_common", ASM_SPEC_COMMON }, \
  132. { "asm_spec32", ASM_SPEC32 }, \
  133. { "asm_spec64", ASM_SPEC64 }, \
  134. { "link_os_freebsd_spec32", LINK_OS_FREEBSD_SPEC32 }, \
  135. { "link_os_freebsd_spec64", LINK_OS_FREEBSD_SPEC64 },
  136. #define FREEBSD_DYNAMIC_LINKER32 "/libexec/ld-elf32.so.1"
  137. #define FREEBSD_DYNAMIC_LINKER64 "/libexec/ld-elf.so.1"
  138. #define LINK_OS_FREEBSD_SPEC_DEF32 "\
  139. %{p:%nconsider using `-pg' instead of `-p' with gprof(1)} \
  140. %{v:-V} \
  141. %{assert*} %{R*} %{rpath*} %{defsym*} \
  142. %{shared:-Bshareable %{h*} %{soname*}} \
  143. %{!shared: \
  144. %{!static: \
  145. %{rdynamic: -export-dynamic} \
  146. %{!dynamic-linker:-dynamic-linker " FREEBSD_DYNAMIC_LINKER32 "}} \
  147. %{static:-Bstatic}} \
  148. %{symbolic:-Bsymbolic}"
  149. #define LINK_OS_FREEBSD_SPEC_DEF64 "\
  150. %{p:%nconsider using `-pg' instead of `-p' with gprof(1)} \
  151. %{v:-V} \
  152. %{assert*} %{R*} %{rpath*} %{defsym*} \
  153. %{shared:-Bshareable %{h*} %{soname*}} \
  154. %{!shared: \
  155. %{!static: \
  156. %{rdynamic: -export-dynamic} \
  157. %{!dynamic-linker:-dynamic-linker " FREEBSD_DYNAMIC_LINKER64 "}} \
  158. %{static:-Bstatic}} \
  159. %{symbolic:-Bsymbolic}"
  160. #define LINK_OS_FREEBSD_SPEC32 "-melf32ppc_fbsd " LINK_OS_FREEBSD_SPEC_DEF32
  161. #define LINK_OS_FREEBSD_SPEC64 "-melf64ppc_fbsd " LINK_OS_FREEBSD_SPEC_DEF64
  162. #undef MULTILIB_DEFAULTS
  163. #define MULTILIB_DEFAULTS { "m64" }
  164. /* PowerPC-64 FreeBSD increases natural record alignment to doubleword if
  165. the first field is an FP double, only if in power alignment mode. */
  166. #undef ROUND_TYPE_ALIGN
  167. #define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED) \
  168. ((TARGET_64BIT \
  169. && (TREE_CODE (STRUCT) == RECORD_TYPE \
  170. || TREE_CODE (STRUCT) == UNION_TYPE \
  171. || TREE_CODE (STRUCT) == QUAL_UNION_TYPE) \
  172. && TARGET_ALIGN_NATURAL == 0) \
  173. ? rs6000_special_round_type_align (STRUCT, COMPUTED, SPECIFIED) \
  174. : MAX ((COMPUTED), (SPECIFIED)))
  175. /* Use the default for compiling target libs. */
  176. #ifdef IN_TARGET_LIBS
  177. #undef TARGET_ALIGN_NATURAL
  178. #define TARGET_ALIGN_NATURAL 1
  179. #endif
  180. /* Indicate that jump tables go in the text section. */
  181. #undef JUMP_TABLES_IN_TEXT_SECTION
  182. #define JUMP_TABLES_IN_TEXT_SECTION TARGET_64BIT
  183. /* The linux ppc64 ABI isn't explicit on whether aggregates smaller
  184. than a doubleword should be padded upward or downward. You could
  185. reasonably assume that they follow the normal rules for structure
  186. layout treating the parameter area as any other block of memory,
  187. then map the reg param area to registers. i.e. pad upward.
  188. Setting both of the following defines results in this behavior.
  189. Setting just the first one will result in aggregates that fit in a
  190. doubleword being padded downward, and others being padded upward.
  191. Not a bad idea as this results in struct { int x; } being passed
  192. the same way as an int. */
  193. #define AGGREGATE_PADDING_FIXED TARGET_64BIT
  194. #define AGGREGATES_PAD_UPWARD_ALWAYS 0
  195. /* Specify padding for the last element of a block move between
  196. registers and memory. FIRST is nonzero if this is the only
  197. element. */
  198. #define BLOCK_REG_PADDING(MODE, TYPE, FIRST) \
  199. (!(FIRST) ? upward : FUNCTION_ARG_PADDING (MODE, TYPE))
  200. /* FreeBSD doesn't support saving and restoring 64-bit regs with a 32-bit
  201. kernel. This is supported when running on a 64-bit kernel with
  202. COMPAT_FREEBSD32, but tell GCC it isn't so that our 32-bit binaries
  203. are compatible. */
  204. #define OS_MISSING_POWERPC64 !TARGET_64BIT
  205. #undef FBSD_TARGET_CPU_CPP_BUILTINS
  206. #define FBSD_TARGET_CPU_CPP_BUILTINS() \
  207. do \
  208. { \
  209. builtin_define ("__PPC__"); \
  210. builtin_define ("__ppc__"); \
  211. builtin_define ("__powerpc__"); \
  212. if (TARGET_64BIT) \
  213. { \
  214. builtin_define ("__arch64__"); \
  215. builtin_define ("__LP64__"); \
  216. builtin_define ("__PPC64__"); \
  217. builtin_define ("__powerpc64__"); \
  218. builtin_assert ("cpu=powerpc64"); \
  219. builtin_assert ("machine=powerpc64"); \
  220. } \
  221. else \
  222. { \
  223. builtin_define_std ("PPC"); \
  224. builtin_define_std ("powerpc"); \
  225. builtin_assert ("cpu=powerpc"); \
  226. builtin_assert ("machine=powerpc"); \
  227. TARGET_OS_SYSV_CPP_BUILTINS (); \
  228. } \
  229. } \
  230. while (0)
  231. #undef CPP_OS_DEFAULT_SPEC
  232. #define CPP_OS_DEFAULT_SPEC "%(cpp_os_freebsd)"
  233. #undef CPP_OS_FREEBSD_SPEC
  234. #define CPP_OS_FREEBSD_SPEC ""
  235. #undef STARTFILE_DEFAULT_SPEC
  236. #define STARTFILE_DEFAULT_SPEC "%(startfile_freebsd)"
  237. #undef ENDFILE_DEFAULT_SPEC
  238. #define ENDFILE_DEFAULT_SPEC "%(endfile_freebsd)"
  239. #undef LIB_DEFAULT_SPEC
  240. #define LIB_DEFAULT_SPEC "%(lib_freebsd)"
  241. #undef LINK_START_DEFAULT_SPEC
  242. #define LINK_START_DEFAULT_SPEC "%(link_start_freebsd)"
  243. #undef LINK_OS_DEFAULT_SPEC
  244. #define LINK_OS_DEFAULT_SPEC "%(link_os_freebsd)"
  245. /* XXX: This is wrong for many platforms in sysv4.h.
  246. We should work on getting that definition fixed. */
  247. #undef LINK_SHLIB_SPEC
  248. #define LINK_SHLIB_SPEC "%{shared:-shared} %{!shared: %{static:-static}}"
  249. /************************[ Target stuff ]***********************************/
  250. /* Define the actual types of some ANSI-mandated types.
  251. Needs to agree with <machine/ansi.h>. GCC defaults come from c-decl.c,
  252. c-common.c, and config/<arch>/<arch>.h. */
  253. #undef SIZE_TYPE
  254. #define SIZE_TYPE (TARGET_64BIT ? "long unsigned int" : "unsigned int")
  255. #undef PTRDIFF_TYPE
  256. #define PTRDIFF_TYPE (TARGET_64BIT ? "long int" : "int")
  257. /* rs6000.h gets this wrong for FreeBSD. We use the GCC defaults instead. */
  258. #undef WCHAR_TYPE
  259. #define WCHAR_TYPE (TARGET_64BIT ? "int" : "long int")
  260. #undef WCHAR_TYPE_SIZE
  261. #define WCHAR_TYPE_SIZE 32
  262. /* Override rs6000.h definition. */
  263. #undef ASM_APP_ON
  264. #define ASM_APP_ON "#APP\n"
  265. /* Override rs6000.h definition. */
  266. #undef ASM_APP_OFF
  267. #define ASM_APP_OFF "#NO_APP\n"
  268. /* Function profiling bits */
  269. #undef RS6000_MCOUNT
  270. #define RS6000_MCOUNT "_mcount"
  271. #define PROFILE_HOOK(LABEL) \
  272. do { if (TARGET_64BIT) output_profile_hook (LABEL); } while (0)
  273. /* _init and _fini functions are built from bits spread across many
  274. object files, each potentially with a different TOC pointer. For
  275. that reason, place a nop after the call so that the linker can
  276. restore the TOC pointer if a TOC adjusting call stub is needed. */
  277. #ifdef __powerpc64__
  278. #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
  279. asm (SECTION_OP "\n" \
  280. " bl " #FUNC "\n" \
  281. " nop\n" \
  282. " .previous");
  283. #endif
  284. /* FP save and restore routines. */
  285. #undef SAVE_FP_PREFIX
  286. #define SAVE_FP_PREFIX (TARGET_64BIT ? "._savef" : "_savefpr_")
  287. #undef SAVE_FP_SUFFIX
  288. #define SAVE_FP_SUFFIX ""
  289. #undef RESTORE_FP_PREFIX
  290. #define RESTORE_FP_PREFIX (TARGET_64BIT ? "._restf" : "_restfpr_")
  291. #undef RESTORE_FP_SUFFIX
  292. #define RESTORE_FP_SUFFIX ""
  293. /* Select a format to encode pointers in exception handling data. CODE
  294. is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is
  295. true if the symbol may be affected by dynamic relocations. */
  296. #undef ASM_PREFERRED_EH_DATA_FORMAT
  297. #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
  298. ((TARGET_64BIT || flag_pic || TARGET_RELOCATABLE) \
  299. ? (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel \
  300. | (TARGET_64BIT ? DW_EH_PE_udata8 : DW_EH_PE_sdata4)) \
  301. : DW_EH_PE_absptr)
  302. /* Static stack checking is supported by means of probes. */
  303. #define STACK_CHECK_STATIC_BUILTIN 1
  304. /* The default value isn't sufficient in 64-bit mode. */
  305. #define STACK_CHECK_PROTECT (TARGET_64BIT ? 16 * 1024 : 12 * 1024)
  306. /* Use standard DWARF numbering for DWARF debugging information. */
  307. #define RS6000_USE_DWARF_NUMBERING
  308. /* PowerPC64 Linux word-aligns FP doubles when -malign-power is given. */
  309. #undef ADJUST_FIELD_ALIGN
  310. #define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \
  311. (rs6000_special_adjust_field_align_p ((FIELD), (COMPUTED)) \
  312. ? 128 \
  313. : (TARGET_64BIT \
  314. && TARGET_ALIGN_NATURAL == 0 \
  315. && TYPE_MODE (strip_array_types (TREE_TYPE (FIELD))) == DFmode) \
  316. ? MIN ((COMPUTED), 32) \
  317. : (COMPUTED))
  318. #undef TOC_SECTION_ASM_OP
  319. #define TOC_SECTION_ASM_OP \
  320. (TARGET_64BIT \
  321. ? "\t.section\t\".toc\",\"aw\"" \
  322. : "\t.section\t\".got\",\"aw\"")
  323. #undef MINIMAL_TOC_SECTION_ASM_OP
  324. #define MINIMAL_TOC_SECTION_ASM_OP \
  325. (TARGET_64BIT \
  326. ? "\t.section\t\".toc1\",\"aw\"" \
  327. : ((TARGET_RELOCATABLE || flag_pic) \
  328. ? "\t.section\t\".got2\",\"aw\"" \
  329. : "\t.section\t\".got1\",\"aw\""))
  330. /* This is how to declare the size of a function. */
  331. #undef ASM_DECLARE_FUNCTION_SIZE
  332. #define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
  333. do \
  334. { \
  335. if (!flag_inhibit_size_directive) \
  336. { \
  337. fputs ("\t.size\t", (FILE)); \
  338. if (TARGET_64BIT && DOT_SYMBOLS) \
  339. putc ('.', (FILE)); \
  340. assemble_name ((FILE), (FNAME)); \
  341. fputs (",.-", (FILE)); \
  342. rs6000_output_function_entry (FILE, FNAME); \
  343. putc ('\n', (FILE)); \
  344. } \
  345. } \
  346. while (0)
  347. #undef ASM_OUTPUT_SPECIAL_POOL_ENTRY_P
  348. #define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE) \
  349. (TARGET_TOC \
  350. && (GET_CODE (X) == SYMBOL_REF \
  351. || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS \
  352. && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF) \
  353. || GET_CODE (X) == LABEL_REF \
  354. || (GET_CODE (X) == CONST_INT \
  355. && GET_MODE_BITSIZE (MODE) <= GET_MODE_BITSIZE (Pmode)) \
  356. || (GET_CODE (X) == CONST_DOUBLE \
  357. && ((TARGET_64BIT \
  358. && (TARGET_MINIMAL_TOC \
  359. || (SCALAR_FLOAT_MODE_P (GET_MODE (X)) \
  360. && ! TARGET_NO_FP_IN_TOC))) \
  361. || (!TARGET_64BIT \
  362. && !TARGET_NO_FP_IN_TOC \
  363. && !TARGET_RELOCATABLE \
  364. && SCALAR_FLOAT_MODE_P (GET_MODE (X)) \
  365. && BITS_PER_WORD == HOST_BITS_PER_INT)))))
  366. /* Use --as-needed -lgcc_s for eh support. */
  367. #ifdef HAVE_LD_AS_NEEDED
  368. #define USE_LD_AS_NEEDED 1
  369. #endif
  370. #define POWERPC_FREEBSD