PageRenderTime 71ms CodeModel.GetById 38ms RepoModel.GetById 1ms app.codeStats 0ms

/gcc/config/s390/s390.h

https://bitbucket.org/vaporoid/gcc
C Header | 924 lines | 441 code | 182 blank | 301 comment | 110 complexity | 01afd5c43ece4c467203727c3f1cb6bc MD5 | raw file
Possible License(s): GPL-3.0, BSD-3-Clause, LGPL-2.0, GPL-2.0, LGPL-2.1, AGPL-1.0
  1. /* Definitions of target machine for GNU compiler, for IBM S/390
  2. Copyright (C) 1999-2013 Free Software Foundation, Inc.
  3. Contributed by Hartmut Penner (hpenner@de.ibm.com) and
  4. Ulrich Weigand (uweigand@de.ibm.com).
  5. Andreas Krebbel (Andreas.Krebbel@de.ibm.com)
  6. This file is part of GCC.
  7. GCC is free software; you can redistribute it and/or modify it under
  8. the terms of the GNU General Public License as published by the Free
  9. Software Foundation; either version 3, or (at your option) any later
  10. version.
  11. GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  12. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  14. for more details.
  15. You should have received a copy of the GNU General Public License
  16. along with GCC; see the file COPYING3. If not see
  17. <http://www.gnu.org/licenses/>. */
  18. #ifndef _S390_H
  19. #define _S390_H
  20. /* Optional architectural facilities supported by the processor. */
  21. enum processor_flags
  22. {
  23. PF_IEEE_FLOAT = 1,
  24. PF_ZARCH = 2,
  25. PF_LONG_DISPLACEMENT = 4,
  26. PF_EXTIMM = 8,
  27. PF_DFP = 16,
  28. PF_Z10 = 32,
  29. PF_Z196 = 64,
  30. PF_ZEC12 = 128,
  31. PF_TX = 256
  32. };
  33. /* This is necessary to avoid a warning about comparing different enum
  34. types. */
  35. #define s390_tune_attr ((enum attr_cpu)s390_tune)
  36. /* These flags indicate that the generated code should run on a cpu
  37. providing the respective hardware facility regardless of the
  38. current cpu mode (ESA or z/Architecture). */
  39. #define TARGET_CPU_IEEE_FLOAT \
  40. (s390_arch_flags & PF_IEEE_FLOAT)
  41. #define TARGET_CPU_ZARCH \
  42. (s390_arch_flags & PF_ZARCH)
  43. #define TARGET_CPU_LONG_DISPLACEMENT \
  44. (s390_arch_flags & PF_LONG_DISPLACEMENT)
  45. #define TARGET_CPU_EXTIMM \
  46. (s390_arch_flags & PF_EXTIMM)
  47. #define TARGET_CPU_DFP \
  48. (s390_arch_flags & PF_DFP)
  49. #define TARGET_CPU_Z10 \
  50. (s390_arch_flags & PF_Z10)
  51. #define TARGET_CPU_Z196 \
  52. (s390_arch_flags & PF_Z196)
  53. #define TARGET_CPU_ZEC12 \
  54. (s390_arch_flags & PF_ZEC12)
  55. #define TARGET_CPU_HTM \
  56. (s390_arch_flags & PF_TX)
  57. /* These flags indicate that the generated code should run on a cpu
  58. providing the respective hardware facility when run in
  59. z/Architecture mode. */
  60. #define TARGET_LONG_DISPLACEMENT \
  61. (TARGET_ZARCH && TARGET_CPU_LONG_DISPLACEMENT)
  62. #define TARGET_EXTIMM \
  63. (TARGET_ZARCH && TARGET_CPU_EXTIMM)
  64. #define TARGET_DFP \
  65. (TARGET_ZARCH && TARGET_CPU_DFP && TARGET_HARD_FLOAT)
  66. #define TARGET_Z10 \
  67. (TARGET_ZARCH && TARGET_CPU_Z10)
  68. #define TARGET_Z196 \
  69. (TARGET_ZARCH && TARGET_CPU_Z196)
  70. #define TARGET_ZEC12 \
  71. (TARGET_ZARCH && TARGET_CPU_ZEC12)
  72. #define TARGET_HTM (TARGET_OPT_HTM)
  73. #define TARGET_AVOID_CMP_AND_BRANCH (s390_tune == PROCESSOR_2817_Z196)
  74. /* Run-time target specification. */
  75. /* Defaults for option flags defined only on some subtargets. */
  76. #ifndef TARGET_TPF_PROFILING
  77. #define TARGET_TPF_PROFILING 0
  78. #endif
  79. /* This will be overridden by OS headers. */
  80. #define TARGET_TPF 0
  81. /* Target CPU builtins. */
  82. #define TARGET_CPU_CPP_BUILTINS() \
  83. do \
  84. { \
  85. builtin_assert ("cpu=s390"); \
  86. builtin_assert ("machine=s390"); \
  87. builtin_define ("__s390__"); \
  88. if (TARGET_ZARCH) \
  89. builtin_define ("__zarch__"); \
  90. if (TARGET_64BIT) \
  91. builtin_define ("__s390x__"); \
  92. if (TARGET_LONG_DOUBLE_128) \
  93. builtin_define ("__LONG_DOUBLE_128__"); \
  94. if (TARGET_HTM) \
  95. builtin_define ("__HTM__"); \
  96. } \
  97. while (0)
  98. #ifdef DEFAULT_TARGET_64BIT
  99. #define TARGET_DEFAULT (MASK_64BIT | MASK_ZARCH | MASK_HARD_DFP | MASK_OPT_HTM)
  100. #else
  101. #define TARGET_DEFAULT 0
  102. #endif
  103. /* Support for configure-time defaults. */
  104. #define OPTION_DEFAULT_SPECS \
  105. { "mode", "%{!mesa:%{!mzarch:-m%(VALUE)}}" }, \
  106. { "arch", "%{!march=*:-march=%(VALUE)}" }, \
  107. { "tune", "%{!mtune=*:-mtune=%(VALUE)}" }
  108. /* Defaulting rules. */
  109. #ifdef DEFAULT_TARGET_64BIT
  110. #define DRIVER_SELF_SPECS \
  111. "%{!m31:%{!m64:-m64}}", \
  112. "%{!mesa:%{!mzarch:%{m31:-mesa}%{m64:-mzarch}}}", \
  113. "%{!march=*:%{mesa:-march=g5}%{mzarch:-march=z900}}"
  114. #else
  115. #define DRIVER_SELF_SPECS \
  116. "%{!m31:%{!m64:-m31}}", \
  117. "%{!mesa:%{!mzarch:%{m31:-mesa}%{m64:-mzarch}}}", \
  118. "%{!march=*:%{mesa:-march=g5}%{mzarch:-march=z900}}"
  119. #endif
  120. /* Constants needed to control the TEST DATA CLASS (TDC) instruction. */
  121. #define S390_TDC_POSITIVE_ZERO (1 << 11)
  122. #define S390_TDC_NEGATIVE_ZERO (1 << 10)
  123. #define S390_TDC_POSITIVE_NORMALIZED_BFP_NUMBER (1 << 9)
  124. #define S390_TDC_NEGATIVE_NORMALIZED_BFP_NUMBER (1 << 8)
  125. #define S390_TDC_POSITIVE_DENORMALIZED_BFP_NUMBER (1 << 7)
  126. #define S390_TDC_NEGATIVE_DENORMALIZED_BFP_NUMBER (1 << 6)
  127. #define S390_TDC_POSITIVE_INFINITY (1 << 5)
  128. #define S390_TDC_NEGATIVE_INFINITY (1 << 4)
  129. #define S390_TDC_POSITIVE_QUIET_NAN (1 << 3)
  130. #define S390_TDC_NEGATIVE_QUIET_NAN (1 << 2)
  131. #define S390_TDC_POSITIVE_SIGNALING_NAN (1 << 1)
  132. #define S390_TDC_NEGATIVE_SIGNALING_NAN (1 << 0)
  133. /* The following values are different for DFP. */
  134. #define S390_TDC_POSITIVE_DENORMALIZED_DFP_NUMBER (1 << 9)
  135. #define S390_TDC_NEGATIVE_DENORMALIZED_DFP_NUMBER (1 << 8)
  136. #define S390_TDC_POSITIVE_NORMALIZED_DFP_NUMBER (1 << 7)
  137. #define S390_TDC_NEGATIVE_NORMALIZED_DFP_NUMBER (1 << 6)
  138. /* For signbit, the BFP-DFP-difference makes no difference. */
  139. #define S390_TDC_SIGNBIT_SET (S390_TDC_NEGATIVE_ZERO \
  140. | S390_TDC_NEGATIVE_NORMALIZED_BFP_NUMBER \
  141. | S390_TDC_NEGATIVE_DENORMALIZED_BFP_NUMBER\
  142. | S390_TDC_NEGATIVE_INFINITY \
  143. | S390_TDC_NEGATIVE_QUIET_NAN \
  144. | S390_TDC_NEGATIVE_SIGNALING_NAN )
  145. #define S390_TDC_INFINITY (S390_TDC_POSITIVE_INFINITY \
  146. | S390_TDC_NEGATIVE_INFINITY )
  147. /* This is used by float.h to define the float_t and double_t data
  148. types. For historical reasons both are double on s390 what cannot
  149. be changed anymore. */
  150. #define TARGET_FLT_EVAL_METHOD 1
  151. /* Target machine storage layout. */
  152. /* Everything is big-endian. */
  153. #define BITS_BIG_ENDIAN 1
  154. #define BYTES_BIG_ENDIAN 1
  155. #define WORDS_BIG_ENDIAN 1
  156. #define STACK_SIZE_MODE (Pmode)
  157. #ifndef IN_LIBGCC2
  158. /* Width of a word, in units (bytes). */
  159. #define UNITS_PER_WORD (TARGET_ZARCH ? 8 : 4)
  160. /* Width of a pointer. To be used instead of UNITS_PER_WORD in
  161. ABI-relevant contexts. This always matches
  162. GET_MODE_SIZE (Pmode). */
  163. #define UNITS_PER_LONG (TARGET_64BIT ? 8 : 4)
  164. #define MIN_UNITS_PER_WORD 4
  165. #define MAX_BITS_PER_WORD 64
  166. #else
  167. /* In libgcc, UNITS_PER_WORD has ABI-relevant effects, e.g. whether
  168. the library should export TImode functions or not. Thus, we have
  169. to redefine UNITS_PER_WORD depending on __s390x__ for libgcc. */
  170. #ifdef __s390x__
  171. #define UNITS_PER_WORD 8
  172. #else
  173. #define UNITS_PER_WORD 4
  174. #endif
  175. #endif
  176. /* Width of a pointer, in bits. */
  177. #define POINTER_SIZE (TARGET_64BIT ? 64 : 32)
  178. /* Allocation boundary (in *bits*) for storing arguments in argument list. */
  179. #define PARM_BOUNDARY (TARGET_64BIT ? 64 : 32)
  180. /* Boundary (in *bits*) on which stack pointer should be aligned. */
  181. #define STACK_BOUNDARY 64
  182. /* Allocation boundary (in *bits*) for the code of a function. */
  183. #define FUNCTION_BOUNDARY 32
  184. /* There is no point aligning anything to a rounder boundary than this. */
  185. #define BIGGEST_ALIGNMENT 64
  186. /* Alignment of field after `int : 0' in a structure. */
  187. #define EMPTY_FIELD_BOUNDARY 32
  188. /* Alignment on even addresses for LARL instruction. */
  189. #define CONSTANT_ALIGNMENT(EXP, ALIGN) (ALIGN) < 16 ? 16 : (ALIGN)
  190. #define DATA_ALIGNMENT(TYPE, ALIGN) (ALIGN) < 16 ? 16 : (ALIGN)
  191. /* Alignment is not required by the hardware. */
  192. #define STRICT_ALIGNMENT 0
  193. /* Mode of stack savearea.
  194. FUNCTION is VOIDmode because calling convention maintains SP.
  195. BLOCK needs Pmode for SP.
  196. NONLOCAL needs twice Pmode to maintain both backchain and SP. */
  197. #define STACK_SAVEAREA_MODE(LEVEL) \
  198. (LEVEL == SAVE_FUNCTION ? VOIDmode \
  199. : LEVEL == SAVE_NONLOCAL ? (TARGET_64BIT ? OImode : TImode) : Pmode)
  200. /* Type layout. */
  201. /* Sizes in bits of the source language data types. */
  202. #define SHORT_TYPE_SIZE 16
  203. #define INT_TYPE_SIZE 32
  204. #define LONG_TYPE_SIZE (TARGET_64BIT ? 64 : 32)
  205. #define LONG_LONG_TYPE_SIZE 64
  206. #define FLOAT_TYPE_SIZE 32
  207. #define DOUBLE_TYPE_SIZE 64
  208. #define LONG_DOUBLE_TYPE_SIZE (TARGET_LONG_DOUBLE_128 ? 128 : 64)
  209. /* Define this to set long double type size to use in libgcc2.c, which can
  210. not depend on target_flags. */
  211. #ifdef __LONG_DOUBLE_128__
  212. #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 128
  213. #else
  214. #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64
  215. #endif
  216. /* Work around target_flags dependency in ada/targtyps.c. */
  217. #define WIDEST_HARDWARE_FP_SIZE 64
  218. /* We use "unsigned char" as default. */
  219. #define DEFAULT_SIGNED_CHAR 0
  220. /* Register usage. */
  221. /* We have 16 general purpose registers (registers 0-15),
  222. and 16 floating point registers (registers 16-31).
  223. (On non-IEEE machines, we have only 4 fp registers.)
  224. Amongst the general purpose registers, some are used
  225. for specific purposes:
  226. GPR 11: Hard frame pointer (if needed)
  227. GPR 12: Global offset table pointer (if needed)
  228. GPR 13: Literal pool base register
  229. GPR 14: Return address register
  230. GPR 15: Stack pointer
  231. Registers 32-35 are 'fake' hard registers that do not
  232. correspond to actual hardware:
  233. Reg 32: Argument pointer
  234. Reg 33: Condition code
  235. Reg 34: Frame pointer
  236. Reg 35: Return address pointer
  237. Registers 36 and 37 are mapped to access registers
  238. 0 and 1, used to implement thread-local storage. */
  239. #define FIRST_PSEUDO_REGISTER 38
  240. /* Standard register usage. */
  241. #define GENERAL_REGNO_P(N) ((int)(N) >= 0 && (N) < 16)
  242. #define ADDR_REGNO_P(N) ((N) >= 1 && (N) < 16)
  243. #define FP_REGNO_P(N) ((N) >= 16 && (N) < 32)
  244. #define CC_REGNO_P(N) ((N) == 33)
  245. #define FRAME_REGNO_P(N) ((N) == 32 || (N) == 34 || (N) == 35)
  246. #define ACCESS_REGNO_P(N) ((N) == 36 || (N) == 37)
  247. #define GENERAL_REG_P(X) (REG_P (X) && GENERAL_REGNO_P (REGNO (X)))
  248. #define ADDR_REG_P(X) (REG_P (X) && ADDR_REGNO_P (REGNO (X)))
  249. #define FP_REG_P(X) (REG_P (X) && FP_REGNO_P (REGNO (X)))
  250. #define CC_REG_P(X) (REG_P (X) && CC_REGNO_P (REGNO (X)))
  251. #define FRAME_REG_P(X) (REG_P (X) && FRAME_REGNO_P (REGNO (X)))
  252. #define ACCESS_REG_P(X) (REG_P (X) && ACCESS_REGNO_P (REGNO (X)))
  253. /* Set up fixed registers and calling convention:
  254. GPRs 0-5 are always call-clobbered,
  255. GPRs 6-15 are always call-saved.
  256. GPR 12 is fixed if used as GOT pointer.
  257. GPR 13 is always fixed (as literal pool pointer).
  258. GPR 14 is always fixed on S/390 machines (as return address).
  259. GPR 15 is always fixed (as stack pointer).
  260. The 'fake' hard registers are call-clobbered and fixed.
  261. The access registers are call-saved and fixed.
  262. On 31-bit, FPRs 18-19 are call-clobbered;
  263. on 64-bit, FPRs 24-31 are call-clobbered.
  264. The remaining FPRs are call-saved. */
  265. #define FIXED_REGISTERS \
  266. { 0, 0, 0, 0, \
  267. 0, 0, 0, 0, \
  268. 0, 0, 0, 0, \
  269. 0, 1, 1, 1, \
  270. 0, 0, 0, 0, \
  271. 0, 0, 0, 0, \
  272. 0, 0, 0, 0, \
  273. 0, 0, 0, 0, \
  274. 1, 1, 1, 1, \
  275. 1, 1 }
  276. #define CALL_USED_REGISTERS \
  277. { 1, 1, 1, 1, \
  278. 1, 1, 0, 0, \
  279. 0, 0, 0, 0, \
  280. 0, 1, 1, 1, \
  281. 1, 1, 1, 1, \
  282. 1, 1, 1, 1, \
  283. 1, 1, 1, 1, \
  284. 1, 1, 1, 1, \
  285. 1, 1, 1, 1, \
  286. 1, 1 }
  287. #define CALL_REALLY_USED_REGISTERS \
  288. { 1, 1, 1, 1, \
  289. 1, 1, 0, 0, \
  290. 0, 0, 0, 0, \
  291. 0, 0, 0, 0, \
  292. 1, 1, 1, 1, \
  293. 1, 1, 1, 1, \
  294. 1, 1, 1, 1, \
  295. 1, 1, 1, 1, \
  296. 1, 1, 1, 1, \
  297. 0, 0 }
  298. /* Preferred register allocation order. */
  299. #define REG_ALLOC_ORDER \
  300. { 1, 2, 3, 4, 5, 0, 12, 11, 10, 9, 8, 7, 6, 14, 13, \
  301. 16, 17, 18, 19, 20, 21, 22, 23, \
  302. 24, 25, 26, 27, 28, 29, 30, 31, \
  303. 15, 32, 33, 34, 35, 36, 37 }
  304. /* Fitting values into registers. */
  305. /* Integer modes <= word size fit into any GPR.
  306. Integer modes > word size fit into successive GPRs, starting with
  307. an even-numbered register.
  308. SImode and DImode fit into FPRs as well.
  309. Floating point modes <= word size fit into any FPR or GPR.
  310. Floating point modes > word size (i.e. DFmode on 32-bit) fit
  311. into any FPR, or an even-odd GPR pair.
  312. TFmode fits only into an even-odd FPR pair.
  313. Complex floating point modes fit either into two FPRs, or into
  314. successive GPRs (again starting with an even number).
  315. TCmode fits only into two successive even-odd FPR pairs.
  316. Condition code modes fit only into the CC register. */
  317. /* Because all registers in a class have the same size HARD_REGNO_NREGS
  318. is equivalent to CLASS_MAX_NREGS. */
  319. #define HARD_REGNO_NREGS(REGNO, MODE) \
  320. s390_class_max_nregs (REGNO_REG_CLASS (REGNO), (MODE))
  321. #define HARD_REGNO_MODE_OK(REGNO, MODE) \
  322. s390_hard_regno_mode_ok ((REGNO), (MODE))
  323. #define HARD_REGNO_RENAME_OK(FROM, TO) \
  324. s390_hard_regno_rename_ok (FROM, TO)
  325. #define MODES_TIEABLE_P(MODE1, MODE2) \
  326. (((MODE1) == SFmode || (MODE1) == DFmode) \
  327. == ((MODE2) == SFmode || (MODE2) == DFmode))
  328. /* When generating code that runs in z/Architecture mode,
  329. but conforms to the 31-bit ABI, GPRs can hold 8 bytes;
  330. the ABI guarantees only that the lower 4 bytes are
  331. saved across calls, however. */
  332. #define HARD_REGNO_CALL_PART_CLOBBERED(REGNO, MODE) \
  333. (!TARGET_64BIT && TARGET_ZARCH \
  334. && GET_MODE_SIZE (MODE) > 4 \
  335. && (((REGNO) >= 6 && (REGNO) <= 15) || (REGNO) == 32))
  336. /* Maximum number of registers to represent a value of mode MODE
  337. in a register of class CLASS. */
  338. #define CLASS_MAX_NREGS(CLASS, MODE) \
  339. s390_class_max_nregs ((CLASS), (MODE))
  340. /* If a 4-byte value is loaded into a FPR, it is placed into the
  341. *upper* half of the register, not the lower. Therefore, we
  342. cannot use SUBREGs to switch between modes in FP registers.
  343. Likewise for access registers, since they have only half the
  344. word size on 64-bit. */
  345. #define CANNOT_CHANGE_MODE_CLASS(FROM, TO, CLASS) \
  346. (GET_MODE_SIZE (FROM) != GET_MODE_SIZE (TO) \
  347. ? ((reg_classes_intersect_p (FP_REGS, CLASS) \
  348. && (GET_MODE_SIZE (FROM) < 8 || GET_MODE_SIZE (TO) < 8)) \
  349. || reg_classes_intersect_p (ACCESS_REGS, CLASS)) : 0)
  350. /* Register classes. */
  351. /* We use the following register classes:
  352. GENERAL_REGS All general purpose registers
  353. ADDR_REGS All general purpose registers except %r0
  354. (These registers can be used in address generation)
  355. FP_REGS All floating point registers
  356. CC_REGS The condition code register
  357. ACCESS_REGS The access registers
  358. GENERAL_FP_REGS Union of GENERAL_REGS and FP_REGS
  359. ADDR_FP_REGS Union of ADDR_REGS and FP_REGS
  360. GENERAL_CC_REGS Union of GENERAL_REGS and CC_REGS
  361. ADDR_CC_REGS Union of ADDR_REGS and CC_REGS
  362. NO_REGS No registers
  363. ALL_REGS All registers
  364. Note that the 'fake' frame pointer and argument pointer registers
  365. are included amongst the address registers here. */
  366. enum reg_class
  367. {
  368. NO_REGS, CC_REGS, ADDR_REGS, GENERAL_REGS, ACCESS_REGS,
  369. ADDR_CC_REGS, GENERAL_CC_REGS,
  370. FP_REGS, ADDR_FP_REGS, GENERAL_FP_REGS,
  371. ALL_REGS, LIM_REG_CLASSES
  372. };
  373. #define N_REG_CLASSES (int) LIM_REG_CLASSES
  374. #define REG_CLASS_NAMES \
  375. { "NO_REGS", "CC_REGS", "ADDR_REGS", "GENERAL_REGS", "ACCESS_REGS", \
  376. "ADDR_CC_REGS", "GENERAL_CC_REGS", \
  377. "FP_REGS", "ADDR_FP_REGS", "GENERAL_FP_REGS", "ALL_REGS" }
  378. /* Class -> register mapping. */
  379. #define REG_CLASS_CONTENTS \
  380. { \
  381. { 0x00000000, 0x00000000 }, /* NO_REGS */ \
  382. { 0x00000000, 0x00000002 }, /* CC_REGS */ \
  383. { 0x0000fffe, 0x0000000d }, /* ADDR_REGS */ \
  384. { 0x0000ffff, 0x0000000d }, /* GENERAL_REGS */ \
  385. { 0x00000000, 0x00000030 }, /* ACCESS_REGS */ \
  386. { 0x0000fffe, 0x0000000f }, /* ADDR_CC_REGS */ \
  387. { 0x0000ffff, 0x0000000f }, /* GENERAL_CC_REGS */ \
  388. { 0xffff0000, 0x00000000 }, /* FP_REGS */ \
  389. { 0xfffffffe, 0x0000000d }, /* ADDR_FP_REGS */ \
  390. { 0xffffffff, 0x0000000d }, /* GENERAL_FP_REGS */ \
  391. { 0xffffffff, 0x0000003f }, /* ALL_REGS */ \
  392. }
  393. /* In some case register allocation order is not enough for IRA to
  394. generate a good code. The following macro (if defined) increases
  395. cost of REGNO for a pseudo approximately by pseudo usage frequency
  396. multiplied by the macro value.
  397. We avoid usage of BASE_REGNUM by nonzero macro value because the
  398. reload can decide not to use the hard register because some
  399. constant was forced to be in memory. */
  400. #define IRA_HARD_REGNO_ADD_COST_MULTIPLIER(regno) \
  401. (regno == BASE_REGNUM ? 0.0 : 0.5)
  402. /* Register -> class mapping. */
  403. extern const enum reg_class regclass_map[FIRST_PSEUDO_REGISTER];
  404. #define REGNO_REG_CLASS(REGNO) (regclass_map[REGNO])
  405. /* ADDR_REGS can be used as base or index register. */
  406. #define INDEX_REG_CLASS ADDR_REGS
  407. #define BASE_REG_CLASS ADDR_REGS
  408. /* Check whether REGNO is a hard register of the suitable class
  409. or a pseudo register currently allocated to one such. */
  410. #define REGNO_OK_FOR_INDEX_P(REGNO) \
  411. (((REGNO) < FIRST_PSEUDO_REGISTER \
  412. && REGNO_REG_CLASS ((REGNO)) == ADDR_REGS) \
  413. || ADDR_REGNO_P (reg_renumber[REGNO]))
  414. #define REGNO_OK_FOR_BASE_P(REGNO) REGNO_OK_FOR_INDEX_P (REGNO)
  415. /* We need secondary memory to move data between GPRs and FPRs. With
  416. DFP the ldgr lgdr instructions are available. But these
  417. instructions do not handle GPR pairs so it is not possible for 31
  418. bit. */
  419. #define SECONDARY_MEMORY_NEEDED(CLASS1, CLASS2, MODE) \
  420. ((CLASS1) != (CLASS2) \
  421. && ((CLASS1) == FP_REGS || (CLASS2) == FP_REGS) \
  422. && (!TARGET_DFP || !TARGET_64BIT || GET_MODE_SIZE (MODE) != 8))
  423. /* Get_secondary_mem widens its argument to BITS_PER_WORD which loses on 64bit
  424. because the movsi and movsf patterns don't handle r/f moves. */
  425. #define SECONDARY_MEMORY_NEEDED_MODE(MODE) \
  426. (GET_MODE_BITSIZE (MODE) < 32 \
  427. ? mode_for_size (32, GET_MODE_CLASS (MODE), 0) \
  428. : MODE)
  429. /* Stack layout and calling conventions. */
  430. /* Our stack grows from higher to lower addresses. However, local variables
  431. are accessed by positive offsets, and function arguments are stored at
  432. increasing addresses. */
  433. #define STACK_GROWS_DOWNWARD
  434. #define FRAME_GROWS_DOWNWARD 1
  435. /* #undef ARGS_GROW_DOWNWARD */
  436. /* The basic stack layout looks like this: the stack pointer points
  437. to the register save area for called functions. Above that area
  438. is the location to place outgoing arguments. Above those follow
  439. dynamic allocations (alloca), and finally the local variables. */
  440. /* Offset from stack-pointer to first location of outgoing args. */
  441. #define STACK_POINTER_OFFSET (TARGET_64BIT ? 160 : 96)
  442. /* Offset within stack frame to start allocating local variables at. */
  443. #define STARTING_FRAME_OFFSET 0
  444. /* Offset from the stack pointer register to an item dynamically
  445. allocated on the stack, e.g., by `alloca'. */
  446. #define STACK_DYNAMIC_OFFSET(FUNDECL) \
  447. (STACK_POINTER_OFFSET + crtl->outgoing_args_size)
  448. /* Offset of first parameter from the argument pointer register value.
  449. We have a fake argument pointer register that points directly to
  450. the argument area. */
  451. #define FIRST_PARM_OFFSET(FNDECL) 0
  452. /* Defining this macro makes __builtin_frame_address(0) and
  453. __builtin_return_address(0) work with -fomit-frame-pointer. */
  454. #define INITIAL_FRAME_ADDRESS_RTX \
  455. (plus_constant (Pmode, arg_pointer_rtx, -STACK_POINTER_OFFSET))
  456. /* The return address of the current frame is retrieved
  457. from the initial value of register RETURN_REGNUM.
  458. For frames farther back, we use the stack slot where
  459. the corresponding RETURN_REGNUM register was saved. */
  460. #define DYNAMIC_CHAIN_ADDRESS(FRAME) \
  461. (TARGET_PACKED_STACK ? \
  462. plus_constant (Pmode, (FRAME), \
  463. STACK_POINTER_OFFSET - UNITS_PER_LONG) : (FRAME))
  464. /* For -mpacked-stack this adds 160 - 8 (96 - 4) to the output of
  465. builtin_frame_address. Otherwise arg pointer -
  466. STACK_POINTER_OFFSET would be returned for
  467. __builtin_frame_address(0) what might result in an address pointing
  468. somewhere into the middle of the local variables since the packed
  469. stack layout generally does not need all the bytes in the register
  470. save area. */
  471. #define FRAME_ADDR_RTX(FRAME) \
  472. DYNAMIC_CHAIN_ADDRESS ((FRAME))
  473. #define RETURN_ADDR_RTX(COUNT, FRAME) \
  474. s390_return_addr_rtx ((COUNT), DYNAMIC_CHAIN_ADDRESS ((FRAME)))
  475. /* In 31-bit mode, we need to mask off the high bit of return addresses. */
  476. #define MASK_RETURN_ADDR (TARGET_64BIT ? constm1_rtx : GEN_INT (0x7fffffff))
  477. /* Exception handling. */
  478. /* Describe calling conventions for DWARF-2 exception handling. */
  479. #define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (Pmode, RETURN_REGNUM)
  480. #define INCOMING_FRAME_SP_OFFSET STACK_POINTER_OFFSET
  481. #define DWARF_FRAME_RETURN_COLUMN 14
  482. /* Describe how we implement __builtin_eh_return. */
  483. #define EH_RETURN_DATA_REGNO(N) ((N) < 4 ? (N) + 6 : INVALID_REGNUM)
  484. #define EH_RETURN_HANDLER_RTX gen_rtx_MEM (Pmode, return_address_pointer_rtx)
  485. /* Select a format to encode pointers in exception handling data. */
  486. #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
  487. (flag_pic \
  488. ? ((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_sdata4 \
  489. : DW_EH_PE_absptr)
  490. /* Register save slot alignment. */
  491. #define DWARF_CIE_DATA_ALIGNMENT (-UNITS_PER_LONG)
  492. /* Let the assembler generate debug line info. */
  493. #define DWARF2_ASM_LINE_DEBUG_INFO 1
  494. /* Frame registers. */
  495. #define STACK_POINTER_REGNUM 15
  496. #define FRAME_POINTER_REGNUM 34
  497. #define HARD_FRAME_POINTER_REGNUM 11
  498. #define ARG_POINTER_REGNUM 32
  499. #define RETURN_ADDRESS_POINTER_REGNUM 35
  500. /* The static chain must be call-clobbered, but not used for
  501. function argument passing. As register 1 is clobbered by
  502. the trampoline code, we only have one option. */
  503. #define STATIC_CHAIN_REGNUM 0
  504. /* Number of hardware registers that go into the DWARF-2 unwind info.
  505. To avoid ABI incompatibility, this number must not change even as
  506. 'fake' hard registers are added or removed. */
  507. #define DWARF_FRAME_REGISTERS 34
  508. /* Frame pointer and argument pointer elimination. */
  509. #define ELIMINABLE_REGS \
  510. {{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
  511. { FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM }, \
  512. { ARG_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
  513. { ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM }, \
  514. { RETURN_ADDRESS_POINTER_REGNUM, STACK_POINTER_REGNUM }, \
  515. { RETURN_ADDRESS_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM }, \
  516. { BASE_REGNUM, BASE_REGNUM }}
  517. #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
  518. (OFFSET) = s390_initial_elimination_offset ((FROM), (TO))
  519. /* Stack arguments. */
  520. /* We need current_function_outgoing_args to be valid. */
  521. #define ACCUMULATE_OUTGOING_ARGS 1
  522. /* Register arguments. */
  523. typedef struct s390_arg_structure
  524. {
  525. int gprs; /* gpr so far */
  526. int fprs; /* fpr so far */
  527. }
  528. CUMULATIVE_ARGS;
  529. #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, NN, N_NAMED_ARGS) \
  530. ((CUM).gprs=0, (CUM).fprs=0)
  531. /* Arguments can be placed in general registers 2 to 6, or in floating
  532. point registers 0 and 2 for 31 bit and fprs 0, 2, 4 and 6 for 64
  533. bit. */
  534. #define FUNCTION_ARG_REGNO_P(N) (((N) >=2 && (N) <7) || \
  535. (N) == 16 || (N) == 17 || (TARGET_64BIT && ((N) == 18 || (N) == 19)))
  536. /* Only gpr 2 and fpr 0 are ever used as return registers. */
  537. #define FUNCTION_VALUE_REGNO_P(N) ((N) == 2 || (N) == 16)
  538. /* Function entry and exit. */
  539. /* When returning from a function, the stack pointer does not matter. */
  540. #define EXIT_IGNORE_STACK 1
  541. /* Profiling. */
  542. #define FUNCTION_PROFILER(FILE, LABELNO) \
  543. s390_function_profiler ((FILE), ((LABELNO)))
  544. #define PROFILE_BEFORE_PROLOGUE 1
  545. /* Trampolines for nested functions. */
  546. #define TRAMPOLINE_SIZE (TARGET_64BIT ? 32 : 16)
  547. #define TRAMPOLINE_ALIGNMENT BITS_PER_WORD
  548. /* Addressing modes, and classification of registers for them. */
  549. /* Recognize any constant value that is a valid address. */
  550. #define CONSTANT_ADDRESS_P(X) 0
  551. /* Maximum number of registers that can appear in a valid memory address. */
  552. #define MAX_REGS_PER_ADDRESS 2
  553. /* This definition replaces the formerly used 'm' constraint with a
  554. different constraint letter in order to avoid changing semantics of
  555. the 'm' constraint when accepting new address formats in
  556. TARGET_LEGITIMATE_ADDRESS_P. The constraint letter defined here
  557. must not be used in insn definitions or inline assemblies. */
  558. #define TARGET_MEM_CONSTRAINT 'e'
  559. /* Try a machine-dependent way of reloading an illegitimate address
  560. operand. If we find one, push the reload and jump to WIN. This
  561. macro is used in only one place: `find_reloads_address' in reload.c. */
  562. #define LEGITIMIZE_RELOAD_ADDRESS(AD, MODE, OPNUM, TYPE, IND, WIN) \
  563. do { \
  564. rtx new_rtx = legitimize_reload_address (AD, MODE, OPNUM, (int)(TYPE)); \
  565. if (new_rtx) \
  566. { \
  567. (AD) = new_rtx; \
  568. goto WIN; \
  569. } \
  570. } while (0)
  571. /* Helper macro for s390.c and s390.md to check for symbolic constants. */
  572. #define SYMBOLIC_CONST(X) \
  573. (GET_CODE (X) == SYMBOL_REF \
  574. || GET_CODE (X) == LABEL_REF \
  575. || (GET_CODE (X) == CONST && symbolic_reference_mentioned_p (X)))
  576. #define TLS_SYMBOLIC_CONST(X) \
  577. ((GET_CODE (X) == SYMBOL_REF && tls_symbolic_operand (X)) \
  578. || (GET_CODE (X) == CONST && tls_symbolic_reference_mentioned_p (X)))
  579. /* Condition codes. */
  580. /* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE,
  581. return the mode to be used for the comparison. */
  582. #define SELECT_CC_MODE(OP, X, Y) s390_select_ccmode ((OP), (X), (Y))
  583. /* Relative costs of operations. */
  584. /* A C expression for the cost of a branch instruction. A value of 1
  585. is the default; other values are interpreted relative to that. */
  586. #define BRANCH_COST(speed_p, predictable_p) s390_branch_cost
  587. /* Nonzero if access to memory by bytes is slow and undesirable. */
  588. #define SLOW_BYTE_ACCESS 1
  589. /* An integer expression for the size in bits of the largest integer machine
  590. mode that should actually be used. We allow pairs of registers. */
  591. #define MAX_FIXED_MODE_SIZE GET_MODE_BITSIZE (TARGET_64BIT ? TImode : DImode)
  592. /* The maximum number of bytes that a single instruction can move quickly
  593. between memory and registers or between two memory locations. */
  594. #define MOVE_MAX (TARGET_ZARCH ? 16 : 8)
  595. #define MOVE_MAX_PIECES (TARGET_ZARCH ? 8 : 4)
  596. #define MAX_MOVE_MAX 16
  597. /* Determine whether to use move_by_pieces or block move insn. */
  598. #define MOVE_BY_PIECES_P(SIZE, ALIGN) \
  599. ( (SIZE) == 1 || (SIZE) == 2 || (SIZE) == 4 \
  600. || (TARGET_ZARCH && (SIZE) == 8) )
  601. /* Determine whether to use clear_by_pieces or block clear insn. */
  602. #define CLEAR_BY_PIECES_P(SIZE, ALIGN) \
  603. ( (SIZE) == 1 || (SIZE) == 2 || (SIZE) == 4 \
  604. || (TARGET_ZARCH && (SIZE) == 8) )
  605. /* This macro is used to determine whether store_by_pieces should be
  606. called to "memcpy" storage when the source is a constant string. */
  607. #define STORE_BY_PIECES_P(SIZE, ALIGN) MOVE_BY_PIECES_P (SIZE, ALIGN)
  608. /* Likewise to decide whether to "memset" storage with byte values
  609. other than zero. */
  610. #define SET_BY_PIECES_P(SIZE, ALIGN) STORE_BY_PIECES_P (SIZE, ALIGN)
  611. /* Don't perform CSE on function addresses. */
  612. #define NO_FUNCTION_CSE
  613. /* This value is used in tree-sra to decide whether it might benefical
  614. to split a struct move into several word-size moves. For S/390
  615. only small values make sense here since struct moves are relatively
  616. cheap thanks to mvc so the small default value chosen for archs
  617. with memmove patterns should be ok. But this value is multiplied
  618. in tree-sra with UNITS_PER_WORD to make a decision so we adjust it
  619. here to compensate for that factor since mvc costs exactly the same
  620. on 31 and 64 bit. */
  621. #define MOVE_RATIO(speed) (TARGET_64BIT? 2 : 4)
  622. /* Sections. */
  623. /* Output before read-only data. */
  624. #define TEXT_SECTION_ASM_OP ".text"
  625. /* Output before writable (initialized) data. */
  626. #define DATA_SECTION_ASM_OP ".data"
  627. /* Output before writable (uninitialized) data. */
  628. #define BSS_SECTION_ASM_OP ".bss"
  629. /* S/390 constant pool breaks the devices in crtstuff.c to control section
  630. in where code resides. We have to write it as asm code. */
  631. #ifndef __s390x__
  632. #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
  633. asm (SECTION_OP "\n\
  634. bras\t%r2,1f\n\
  635. 0: .long\t" USER_LABEL_PREFIX #FUNC " - 0b\n\
  636. 1: l\t%r3,0(%r2)\n\
  637. bas\t%r14,0(%r3,%r2)\n\
  638. .previous");
  639. #endif
  640. /* Position independent code. */
  641. #define PIC_OFFSET_TABLE_REGNUM (flag_pic ? 12 : INVALID_REGNUM)
  642. #define LEGITIMATE_PIC_OPERAND_P(X) legitimate_pic_operand_p (X)
  643. /* Assembler file format. */
  644. /* Character to start a comment. */
  645. #define ASM_COMMENT_START "#"
  646. /* Declare an uninitialized external linkage data object. */
  647. #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
  648. asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
  649. /* Globalizing directive for a label. */
  650. #define GLOBAL_ASM_OP ".globl "
  651. /* Advance the location counter to a multiple of 2**LOG bytes. */
  652. #define ASM_OUTPUT_ALIGN(FILE, LOG) \
  653. if ((LOG)) fprintf ((FILE), "\t.align\t%d\n", 1 << (LOG))
  654. /* Advance the location counter by SIZE bytes. */
  655. #define ASM_OUTPUT_SKIP(FILE, SIZE) \
  656. fprintf ((FILE), "\t.set\t.,.+"HOST_WIDE_INT_PRINT_UNSIGNED"\n", (SIZE))
  657. /* The LOCAL_LABEL_PREFIX variable is used by dbxelf.h. */
  658. #define LOCAL_LABEL_PREFIX "."
  659. #define LABEL_ALIGN(LABEL) \
  660. s390_label_align (LABEL)
  661. /* How to refer to registers in assembler output. This sequence is
  662. indexed by compiler's hard-register-number (see above). */
  663. #define REGISTER_NAMES \
  664. { "%r0", "%r1", "%r2", "%r3", "%r4", "%r5", "%r6", "%r7", \
  665. "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15", \
  666. "%f0", "%f2", "%f4", "%f6", "%f1", "%f3", "%f5", "%f7", \
  667. "%f8", "%f10", "%f12", "%f14", "%f9", "%f11", "%f13", "%f15", \
  668. "%ap", "%cc", "%fp", "%rp", "%a0", "%a1" \
  669. }
  670. /* Print operand X (an rtx) in assembler syntax to file FILE. */
  671. #define PRINT_OPERAND(FILE, X, CODE) print_operand (FILE, X, CODE)
  672. #define PRINT_OPERAND_ADDRESS(FILE, ADDR) print_operand_address (FILE, ADDR)
  673. /* Output an element of a case-vector that is absolute. */
  674. #define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \
  675. do { \
  676. char buf[32]; \
  677. fputs (integer_asm_op (UNITS_PER_LONG, TRUE), (FILE)); \
  678. ASM_GENERATE_INTERNAL_LABEL (buf, "L", (VALUE)); \
  679. assemble_name ((FILE), buf); \
  680. fputc ('\n', (FILE)); \
  681. } while (0)
  682. /* Output an element of a case-vector that is relative. */
  683. #define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
  684. do { \
  685. char buf[32]; \
  686. fputs (integer_asm_op (UNITS_PER_LONG, TRUE), (FILE)); \
  687. ASM_GENERATE_INTERNAL_LABEL (buf, "L", (VALUE)); \
  688. assemble_name ((FILE), buf); \
  689. fputc ('-', (FILE)); \
  690. ASM_GENERATE_INTERNAL_LABEL (buf, "L", (REL)); \
  691. assemble_name ((FILE), buf); \
  692. fputc ('\n', (FILE)); \
  693. } while (0)
  694. /* Miscellaneous parameters. */
  695. /* Specify the machine mode that this machine uses for the index in the
  696. tablejump instruction. */
  697. #define CASE_VECTOR_MODE (TARGET_64BIT ? DImode : SImode)
  698. /* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits
  699. is done just by pretending it is already truncated. */
  700. #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
  701. /* Specify the machine mode that pointers have.
  702. After generation of rtl, the compiler makes no further distinction
  703. between pointers and any other objects of this machine mode. */
  704. #define Pmode ((enum machine_mode) (TARGET_64BIT ? DImode : SImode))
  705. /* This is -1 for "pointer mode" extend. See ptr_extend in s390.md. */
  706. #define POINTERS_EXTEND_UNSIGNED -1
  707. /* A function address in a call instruction is a byte address (for
  708. indexing purposes) so give the MEM rtx a byte's mode. */
  709. #define FUNCTION_MODE QImode
  710. /* Specify the value which is used when clz operand is zero. */
  711. #define CLZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) ((VALUE) = 64, 1)
  712. /* Machine-specific symbol_ref flags. */
  713. #define SYMBOL_FLAG_ALIGN1 (SYMBOL_FLAG_MACH_DEP << 0)
  714. #define SYMBOL_REF_ALIGN1_P(X) \
  715. ((SYMBOL_REF_FLAGS (X) & SYMBOL_FLAG_ALIGN1))
  716. #define SYMBOL_FLAG_NOT_NATURALLY_ALIGNED (SYMBOL_FLAG_MACH_DEP << 1)
  717. #define SYMBOL_REF_NOT_NATURALLY_ALIGNED_P(X) \
  718. ((SYMBOL_REF_FLAGS (X) & SYMBOL_FLAG_NOT_NATURALLY_ALIGNED))
  719. /* Check whether integer displacement is in range. */
  720. #define DISP_IN_RANGE(d) \
  721. (TARGET_LONG_DISPLACEMENT? ((d) >= -524288 && (d) <= 524287) \
  722. : ((d) >= 0 && (d) <= 4095))
  723. /* Reads can reuse write prefetches, used by tree-ssa-prefetch-loops.c. */
  724. #define READ_CAN_USE_WRITE_PREFETCH 1
  725. extern const int processor_flags_table[];
  726. #endif