targhooks.c 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942
  1. /* Default target hook functions.
  2. Copyright (C) 2003-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 under
  5. the terms of the GNU General Public License as published by the Free
  6. Software Foundation; either version 3, or (at your option) any later
  7. version.
  8. GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  9. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  11. 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. /* The migration of target macros to target hooks works as follows:
  16. 1. Create a target hook that uses the existing target macros to
  17. implement the same functionality.
  18. 2. Convert all the MI files to use the hook instead of the macro.
  19. 3. Repeat for a majority of the remaining target macros. This will
  20. take some time.
  21. 4. Tell target maintainers to start migrating.
  22. 5. Eventually convert the backends to override the hook instead of
  23. defining the macros. This will take some time too.
  24. 6. TBD when, poison the macros. Unmigrated targets will break at
  25. this point.
  26. Note that we expect steps 1-3 to be done by the people that
  27. understand what the MI does with each macro, and step 5 to be done
  28. by the target maintainers for their respective targets.
  29. Note that steps 1 and 2 don't have to be done together, but no
  30. target can override the new hook until step 2 is complete for it.
  31. Once the macros are poisoned, we will revert to the old migration
  32. rules - migrate the macro, callers, and targets all at once. This
  33. comment can thus be removed at that point. */
  34. #include "config.h"
  35. #include "system.h"
  36. #include "coretypes.h"
  37. #include "tm.h"
  38. #include "machmode.h"
  39. #include "rtl.h"
  40. #include "hash-set.h"
  41. #include "vec.h"
  42. #include "double-int.h"
  43. #include "input.h"
  44. #include "alias.h"
  45. #include "symtab.h"
  46. #include "wide-int.h"
  47. #include "inchash.h"
  48. #include "tree.h"
  49. #include "fold-const.h"
  50. #include "stor-layout.h"
  51. #include "varasm.h"
  52. #include "hashtab.h"
  53. #include "hard-reg-set.h"
  54. #include "function.h"
  55. #include "flags.h"
  56. #include "statistics.h"
  57. #include "real.h"
  58. #include "fixed-value.h"
  59. #include "insn-config.h"
  60. #include "expmed.h"
  61. #include "dojump.h"
  62. #include "explow.h"
  63. #include "calls.h"
  64. #include "emit-rtl.h"
  65. #include "stmt.h"
  66. #include "expr.h"
  67. #include "output.h"
  68. #include "diagnostic-core.h"
  69. #include "target.h"
  70. #include "tm_p.h"
  71. #include "target-def.h"
  72. #include "regs.h"
  73. #include "reload.h"
  74. #include "insn-codes.h"
  75. #include "optabs.h"
  76. #include "recog.h"
  77. #include "intl.h"
  78. #include "opts.h"
  79. #include "tree-ssa-alias.h"
  80. #include "gimple-expr.h"
  81. #include "gimplify.h"
  82. #include "stringpool.h"
  83. #include "tree-ssanames.h"
  84. bool
  85. default_legitimate_address_p (machine_mode mode ATTRIBUTE_UNUSED,
  86. rtx addr ATTRIBUTE_UNUSED,
  87. bool strict ATTRIBUTE_UNUSED)
  88. {
  89. #ifdef GO_IF_LEGITIMATE_ADDRESS
  90. /* Defer to the old implementation using a goto. */
  91. if (strict)
  92. return strict_memory_address_p (mode, addr);
  93. else
  94. return memory_address_p (mode, addr);
  95. #else
  96. gcc_unreachable ();
  97. #endif
  98. }
  99. void
  100. default_external_libcall (rtx fun ATTRIBUTE_UNUSED)
  101. {
  102. #ifdef ASM_OUTPUT_EXTERNAL_LIBCALL
  103. ASM_OUTPUT_EXTERNAL_LIBCALL (asm_out_file, fun);
  104. #endif
  105. }
  106. int
  107. default_unspec_may_trap_p (const_rtx x, unsigned flags)
  108. {
  109. int i;
  110. /* Any floating arithmetic may trap. */
  111. if ((SCALAR_FLOAT_MODE_P (GET_MODE (x)) && flag_trapping_math))
  112. return 1;
  113. for (i = 0; i < XVECLEN (x, 0); ++i)
  114. {
  115. if (may_trap_p_1 (XVECEXP (x, 0, i), flags))
  116. return 1;
  117. }
  118. return 0;
  119. }
  120. machine_mode
  121. default_promote_function_mode (const_tree type ATTRIBUTE_UNUSED,
  122. machine_mode mode,
  123. int *punsignedp ATTRIBUTE_UNUSED,
  124. const_tree funtype ATTRIBUTE_UNUSED,
  125. int for_return ATTRIBUTE_UNUSED)
  126. {
  127. if (type != NULL_TREE && for_return == 2)
  128. return promote_mode (type, mode, punsignedp);
  129. return mode;
  130. }
  131. machine_mode
  132. default_promote_function_mode_always_promote (const_tree type,
  133. machine_mode mode,
  134. int *punsignedp,
  135. const_tree funtype ATTRIBUTE_UNUSED,
  136. int for_return ATTRIBUTE_UNUSED)
  137. {
  138. return promote_mode (type, mode, punsignedp);
  139. }
  140. machine_mode
  141. default_cc_modes_compatible (machine_mode m1, machine_mode m2)
  142. {
  143. if (m1 == m2)
  144. return m1;
  145. return VOIDmode;
  146. }
  147. bool
  148. default_return_in_memory (const_tree type,
  149. const_tree fntype ATTRIBUTE_UNUSED)
  150. {
  151. return (TYPE_MODE (type) == BLKmode);
  152. }
  153. rtx
  154. default_legitimize_address (rtx x, rtx orig_x ATTRIBUTE_UNUSED,
  155. machine_mode mode ATTRIBUTE_UNUSED)
  156. {
  157. return x;
  158. }
  159. bool
  160. default_legitimize_address_displacement (rtx *disp ATTRIBUTE_UNUSED,
  161. rtx *offset ATTRIBUTE_UNUSED,
  162. machine_mode mode ATTRIBUTE_UNUSED)
  163. {
  164. return false;
  165. }
  166. rtx
  167. default_expand_builtin_saveregs (void)
  168. {
  169. error ("__builtin_saveregs not supported by this target");
  170. return const0_rtx;
  171. }
  172. void
  173. default_setup_incoming_varargs (cumulative_args_t ca ATTRIBUTE_UNUSED,
  174. machine_mode mode ATTRIBUTE_UNUSED,
  175. tree type ATTRIBUTE_UNUSED,
  176. int *pretend_arg_size ATTRIBUTE_UNUSED,
  177. int second_time ATTRIBUTE_UNUSED)
  178. {
  179. }
  180. /* The default implementation of TARGET_BUILTIN_SETJMP_FRAME_VALUE. */
  181. rtx
  182. default_builtin_setjmp_frame_value (void)
  183. {
  184. return virtual_stack_vars_rtx;
  185. }
  186. /* Generic hook that takes a CUMULATIVE_ARGS pointer and returns false. */
  187. bool
  188. hook_bool_CUMULATIVE_ARGS_false (cumulative_args_t ca ATTRIBUTE_UNUSED)
  189. {
  190. return false;
  191. }
  192. bool
  193. default_pretend_outgoing_varargs_named (cumulative_args_t ca ATTRIBUTE_UNUSED)
  194. {
  195. return (targetm.calls.setup_incoming_varargs
  196. != default_setup_incoming_varargs);
  197. }
  198. machine_mode
  199. default_eh_return_filter_mode (void)
  200. {
  201. return targetm.unwind_word_mode ();
  202. }
  203. machine_mode
  204. default_libgcc_cmp_return_mode (void)
  205. {
  206. return word_mode;
  207. }
  208. machine_mode
  209. default_libgcc_shift_count_mode (void)
  210. {
  211. return word_mode;
  212. }
  213. machine_mode
  214. default_unwind_word_mode (void)
  215. {
  216. return word_mode;
  217. }
  218. /* The default implementation of TARGET_SHIFT_TRUNCATION_MASK. */
  219. unsigned HOST_WIDE_INT
  220. default_shift_truncation_mask (machine_mode mode)
  221. {
  222. return SHIFT_COUNT_TRUNCATED ? GET_MODE_BITSIZE (mode) - 1 : 0;
  223. }
  224. /* The default implementation of TARGET_MIN_DIVISIONS_FOR_RECIP_MUL. */
  225. unsigned int
  226. default_min_divisions_for_recip_mul (machine_mode mode ATTRIBUTE_UNUSED)
  227. {
  228. return have_insn_for (DIV, mode) ? 3 : 2;
  229. }
  230. /* The default implementation of TARGET_MODE_REP_EXTENDED. */
  231. int
  232. default_mode_rep_extended (machine_mode mode ATTRIBUTE_UNUSED,
  233. machine_mode mode_rep ATTRIBUTE_UNUSED)
  234. {
  235. return UNKNOWN;
  236. }
  237. /* Generic hook that takes a CUMULATIVE_ARGS pointer and returns true. */
  238. bool
  239. hook_bool_CUMULATIVE_ARGS_true (cumulative_args_t a ATTRIBUTE_UNUSED)
  240. {
  241. return true;
  242. }
  243. /* Return machine mode for non-standard suffix
  244. or VOIDmode if non-standard suffixes are unsupported. */
  245. machine_mode
  246. default_mode_for_suffix (char suffix ATTRIBUTE_UNUSED)
  247. {
  248. return VOIDmode;
  249. }
  250. /* The generic C++ ABI specifies this is a 64-bit value. */
  251. tree
  252. default_cxx_guard_type (void)
  253. {
  254. return long_long_integer_type_node;
  255. }
  256. /* Returns the size of the cookie to use when allocating an array
  257. whose elements have the indicated TYPE. Assumes that it is already
  258. known that a cookie is needed. */
  259. tree
  260. default_cxx_get_cookie_size (tree type)
  261. {
  262. tree cookie_size;
  263. /* We need to allocate an additional max (sizeof (size_t), alignof
  264. (true_type)) bytes. */
  265. tree sizetype_size;
  266. tree type_align;
  267. sizetype_size = size_in_bytes (sizetype);
  268. type_align = size_int (TYPE_ALIGN_UNIT (type));
  269. if (tree_int_cst_lt (type_align, sizetype_size))
  270. cookie_size = sizetype_size;
  271. else
  272. cookie_size = type_align;
  273. return cookie_size;
  274. }
  275. /* Return true if a parameter must be passed by reference. This version
  276. of the TARGET_PASS_BY_REFERENCE hook uses just MUST_PASS_IN_STACK. */
  277. bool
  278. hook_pass_by_reference_must_pass_in_stack (cumulative_args_t c ATTRIBUTE_UNUSED,
  279. machine_mode mode ATTRIBUTE_UNUSED, const_tree type ATTRIBUTE_UNUSED,
  280. bool named_arg ATTRIBUTE_UNUSED)
  281. {
  282. return targetm.calls.must_pass_in_stack (mode, type);
  283. }
  284. /* Return true if a parameter follows callee copies conventions. This
  285. version of the hook is true for all named arguments. */
  286. bool
  287. hook_callee_copies_named (cumulative_args_t ca ATTRIBUTE_UNUSED,
  288. machine_mode mode ATTRIBUTE_UNUSED,
  289. const_tree type ATTRIBUTE_UNUSED, bool named)
  290. {
  291. return named;
  292. }
  293. /* Emit to STREAM the assembler syntax for insn operand X. */
  294. void
  295. default_print_operand (FILE *stream ATTRIBUTE_UNUSED, rtx x ATTRIBUTE_UNUSED,
  296. int code ATTRIBUTE_UNUSED)
  297. {
  298. #ifdef PRINT_OPERAND
  299. PRINT_OPERAND (stream, x, code);
  300. #else
  301. gcc_unreachable ();
  302. #endif
  303. }
  304. /* Emit to STREAM the assembler syntax for an insn operand whose memory
  305. address is X. */
  306. void
  307. default_print_operand_address (FILE *stream ATTRIBUTE_UNUSED,
  308. rtx x ATTRIBUTE_UNUSED)
  309. {
  310. #ifdef PRINT_OPERAND_ADDRESS
  311. PRINT_OPERAND_ADDRESS (stream, x);
  312. #else
  313. gcc_unreachable ();
  314. #endif
  315. }
  316. /* Return true if CODE is a valid punctuation character for the
  317. `print_operand' hook. */
  318. bool
  319. default_print_operand_punct_valid_p (unsigned char code ATTRIBUTE_UNUSED)
  320. {
  321. #ifdef PRINT_OPERAND_PUNCT_VALID_P
  322. return PRINT_OPERAND_PUNCT_VALID_P (code);
  323. #else
  324. return false;
  325. #endif
  326. }
  327. /* The default implementation of TARGET_MANGLE_ASSEMBLER_NAME. */
  328. tree
  329. default_mangle_assembler_name (const char *name ATTRIBUTE_UNUSED)
  330. {
  331. const char *skipped = name + (*name == '*' ? 1 : 0);
  332. const char *stripped = targetm.strip_name_encoding (skipped);
  333. if (*name != '*' && user_label_prefix[0])
  334. stripped = ACONCAT ((user_label_prefix, stripped, NULL));
  335. return get_identifier (stripped);
  336. }
  337. /* True if MODE is valid for the target. By "valid", we mean able to
  338. be manipulated in non-trivial ways. In particular, this means all
  339. the arithmetic is supported.
  340. By default we guess this means that any C type is supported. If
  341. we can't map the mode back to a type that would be available in C,
  342. then reject it. Special case, here, is the double-word arithmetic
  343. supported by optabs.c. */
  344. bool
  345. default_scalar_mode_supported_p (machine_mode mode)
  346. {
  347. int precision = GET_MODE_PRECISION (mode);
  348. switch (GET_MODE_CLASS (mode))
  349. {
  350. case MODE_PARTIAL_INT:
  351. case MODE_INT:
  352. if (precision == CHAR_TYPE_SIZE)
  353. return true;
  354. if (precision == SHORT_TYPE_SIZE)
  355. return true;
  356. if (precision == INT_TYPE_SIZE)
  357. return true;
  358. if (precision == LONG_TYPE_SIZE)
  359. return true;
  360. if (precision == LONG_LONG_TYPE_SIZE)
  361. return true;
  362. if (precision == 2 * BITS_PER_WORD)
  363. return true;
  364. return false;
  365. case MODE_FLOAT:
  366. if (precision == FLOAT_TYPE_SIZE)
  367. return true;
  368. if (precision == DOUBLE_TYPE_SIZE)
  369. return true;
  370. if (precision == LONG_DOUBLE_TYPE_SIZE)
  371. return true;
  372. return false;
  373. case MODE_DECIMAL_FLOAT:
  374. case MODE_FRACT:
  375. case MODE_UFRACT:
  376. case MODE_ACCUM:
  377. case MODE_UACCUM:
  378. return false;
  379. default:
  380. gcc_unreachable ();
  381. }
  382. }
  383. /* Return true if libgcc supports floating-point mode MODE (known to
  384. be supported as a scalar mode). */
  385. bool
  386. default_libgcc_floating_mode_supported_p (machine_mode mode)
  387. {
  388. switch (mode)
  389. {
  390. #ifdef HAVE_SFmode
  391. case SFmode:
  392. #endif
  393. #ifdef HAVE_DFmode
  394. case DFmode:
  395. #endif
  396. #ifdef HAVE_XFmode
  397. case XFmode:
  398. #endif
  399. #ifdef HAVE_TFmode
  400. case TFmode:
  401. #endif
  402. return true;
  403. default:
  404. return false;
  405. }
  406. }
  407. /* Make some target macros useable by target-independent code. */
  408. bool
  409. targhook_words_big_endian (void)
  410. {
  411. return !!WORDS_BIG_ENDIAN;
  412. }
  413. bool
  414. targhook_float_words_big_endian (void)
  415. {
  416. return !!FLOAT_WORDS_BIG_ENDIAN;
  417. }
  418. /* True if the target supports floating-point exceptions and rounding
  419. modes. */
  420. bool
  421. default_float_exceptions_rounding_supported_p (void)
  422. {
  423. #ifdef HAVE_adddf3
  424. return HAVE_adddf3;
  425. #else
  426. return false;
  427. #endif
  428. }
  429. /* True if the target supports decimal floating point. */
  430. bool
  431. default_decimal_float_supported_p (void)
  432. {
  433. return ENABLE_DECIMAL_FLOAT;
  434. }
  435. /* True if the target supports fixed-point arithmetic. */
  436. bool
  437. default_fixed_point_supported_p (void)
  438. {
  439. return ENABLE_FIXED_POINT;
  440. }
  441. /* True if the target supports GNU indirect functions. */
  442. bool
  443. default_has_ifunc_p (void)
  444. {
  445. return HAVE_GNU_INDIRECT_FUNCTION;
  446. }
  447. /* NULL if INSN insn is valid within a low-overhead loop, otherwise returns
  448. an error message.
  449. This function checks whether a given INSN is valid within a low-overhead
  450. loop. If INSN is invalid it returns the reason for that, otherwise it
  451. returns NULL. A called function may clobber any special registers required
  452. for low-overhead looping. Additionally, some targets (eg, PPC) use the count
  453. register for branch on table instructions. We reject the doloop pattern in
  454. these cases. */
  455. const char *
  456. default_invalid_within_doloop (const rtx_insn *insn)
  457. {
  458. if (CALL_P (insn))
  459. return "Function call in loop.";
  460. if (tablejump_p (insn, NULL, NULL) || computed_jump_p (insn))
  461. return "Computed branch in the loop.";
  462. return NULL;
  463. }
  464. /* Mapping of builtin functions to vectorized variants. */
  465. tree
  466. default_builtin_vectorized_function (tree fndecl ATTRIBUTE_UNUSED,
  467. tree type_out ATTRIBUTE_UNUSED,
  468. tree type_in ATTRIBUTE_UNUSED)
  469. {
  470. return NULL_TREE;
  471. }
  472. /* Vectorized conversion. */
  473. tree
  474. default_builtin_vectorized_conversion (unsigned int code ATTRIBUTE_UNUSED,
  475. tree dest_type ATTRIBUTE_UNUSED,
  476. tree src_type ATTRIBUTE_UNUSED)
  477. {
  478. return NULL_TREE;
  479. }
  480. /* Default vectorizer cost model values. */
  481. int
  482. default_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost,
  483. tree vectype,
  484. int misalign ATTRIBUTE_UNUSED)
  485. {
  486. unsigned elements;
  487. switch (type_of_cost)
  488. {
  489. case scalar_stmt:
  490. case scalar_load:
  491. case scalar_store:
  492. case vector_stmt:
  493. case vector_load:
  494. case vector_store:
  495. case vec_to_scalar:
  496. case scalar_to_vec:
  497. case cond_branch_not_taken:
  498. case vec_perm:
  499. case vec_promote_demote:
  500. return 1;
  501. case unaligned_load:
  502. case unaligned_store:
  503. return 2;
  504. case cond_branch_taken:
  505. return 3;
  506. case vec_construct:
  507. elements = TYPE_VECTOR_SUBPARTS (vectype);
  508. return elements / 2 + 1;
  509. default:
  510. gcc_unreachable ();
  511. }
  512. }
  513. /* Reciprocal. */
  514. tree
  515. default_builtin_reciprocal (unsigned int fn ATTRIBUTE_UNUSED,
  516. bool md_fn ATTRIBUTE_UNUSED,
  517. bool sqrt ATTRIBUTE_UNUSED)
  518. {
  519. return NULL_TREE;
  520. }
  521. bool
  522. hook_bool_CUMULATIVE_ARGS_mode_tree_bool_false (
  523. cumulative_args_t ca ATTRIBUTE_UNUSED,
  524. machine_mode mode ATTRIBUTE_UNUSED,
  525. const_tree type ATTRIBUTE_UNUSED, bool named ATTRIBUTE_UNUSED)
  526. {
  527. return false;
  528. }
  529. bool
  530. hook_bool_CUMULATIVE_ARGS_mode_tree_bool_true (
  531. cumulative_args_t ca ATTRIBUTE_UNUSED,
  532. machine_mode mode ATTRIBUTE_UNUSED,
  533. const_tree type ATTRIBUTE_UNUSED, bool named ATTRIBUTE_UNUSED)
  534. {
  535. return true;
  536. }
  537. int
  538. hook_int_CUMULATIVE_ARGS_mode_tree_bool_0 (
  539. cumulative_args_t ca ATTRIBUTE_UNUSED,
  540. machine_mode mode ATTRIBUTE_UNUSED,
  541. tree type ATTRIBUTE_UNUSED, bool named ATTRIBUTE_UNUSED)
  542. {
  543. return 0;
  544. }
  545. void
  546. default_function_arg_advance (cumulative_args_t ca ATTRIBUTE_UNUSED,
  547. machine_mode mode ATTRIBUTE_UNUSED,
  548. const_tree type ATTRIBUTE_UNUSED,
  549. bool named ATTRIBUTE_UNUSED)
  550. {
  551. gcc_unreachable ();
  552. }
  553. rtx
  554. default_function_arg (cumulative_args_t ca ATTRIBUTE_UNUSED,
  555. machine_mode mode ATTRIBUTE_UNUSED,
  556. const_tree type ATTRIBUTE_UNUSED,
  557. bool named ATTRIBUTE_UNUSED)
  558. {
  559. gcc_unreachable ();
  560. }
  561. rtx
  562. default_function_incoming_arg (cumulative_args_t ca ATTRIBUTE_UNUSED,
  563. machine_mode mode ATTRIBUTE_UNUSED,
  564. const_tree type ATTRIBUTE_UNUSED,
  565. bool named ATTRIBUTE_UNUSED)
  566. {
  567. gcc_unreachable ();
  568. }
  569. unsigned int
  570. default_function_arg_boundary (machine_mode mode ATTRIBUTE_UNUSED,
  571. const_tree type ATTRIBUTE_UNUSED)
  572. {
  573. return PARM_BOUNDARY;
  574. }
  575. unsigned int
  576. default_function_arg_round_boundary (machine_mode mode ATTRIBUTE_UNUSED,
  577. const_tree type ATTRIBUTE_UNUSED)
  578. {
  579. return PARM_BOUNDARY;
  580. }
  581. void
  582. hook_void_bitmap (bitmap regs ATTRIBUTE_UNUSED)
  583. {
  584. }
  585. const char *
  586. hook_invalid_arg_for_unprototyped_fn (
  587. const_tree typelist ATTRIBUTE_UNUSED,
  588. const_tree funcdecl ATTRIBUTE_UNUSED,
  589. const_tree val ATTRIBUTE_UNUSED)
  590. {
  591. return NULL;
  592. }
  593. /* Initialize the stack protection decls. */
  594. /* Stack protection related decls living in libgcc. */
  595. static GTY(()) tree stack_chk_guard_decl;
  596. tree
  597. default_stack_protect_guard (void)
  598. {
  599. tree t = stack_chk_guard_decl;
  600. if (t == NULL)
  601. {
  602. rtx x;
  603. t = build_decl (UNKNOWN_LOCATION,
  604. VAR_DECL, get_identifier ("__stack_chk_guard"),
  605. ptr_type_node);
  606. TREE_STATIC (t) = 1;
  607. TREE_PUBLIC (t) = 1;
  608. DECL_EXTERNAL (t) = 1;
  609. TREE_USED (t) = 1;
  610. TREE_THIS_VOLATILE (t) = 1;
  611. DECL_ARTIFICIAL (t) = 1;
  612. DECL_IGNORED_P (t) = 1;
  613. /* Do not share RTL as the declaration is visible outside of
  614. current function. */
  615. x = DECL_RTL (t);
  616. RTX_FLAG (x, used) = 1;
  617. stack_chk_guard_decl = t;
  618. }
  619. return t;
  620. }
  621. static GTY(()) tree stack_chk_fail_decl;
  622. tree
  623. default_external_stack_protect_fail (void)
  624. {
  625. tree t = stack_chk_fail_decl;
  626. if (t == NULL_TREE)
  627. {
  628. t = build_function_type_list (void_type_node, NULL_TREE);
  629. t = build_decl (UNKNOWN_LOCATION,
  630. FUNCTION_DECL, get_identifier ("__stack_chk_fail"), t);
  631. TREE_STATIC (t) = 1;
  632. TREE_PUBLIC (t) = 1;
  633. DECL_EXTERNAL (t) = 1;
  634. TREE_USED (t) = 1;
  635. TREE_THIS_VOLATILE (t) = 1;
  636. TREE_NOTHROW (t) = 1;
  637. DECL_ARTIFICIAL (t) = 1;
  638. DECL_IGNORED_P (t) = 1;
  639. DECL_VISIBILITY (t) = VISIBILITY_DEFAULT;
  640. DECL_VISIBILITY_SPECIFIED (t) = 1;
  641. stack_chk_fail_decl = t;
  642. }
  643. return build_call_expr (t, 0);
  644. }
  645. tree
  646. default_hidden_stack_protect_fail (void)
  647. {
  648. #ifndef HAVE_GAS_HIDDEN
  649. return default_external_stack_protect_fail ();
  650. #else
  651. tree t = stack_chk_fail_decl;
  652. if (!flag_pic)
  653. return default_external_stack_protect_fail ();
  654. if (t == NULL_TREE)
  655. {
  656. t = build_function_type_list (void_type_node, NULL_TREE);
  657. t = build_decl (UNKNOWN_LOCATION, FUNCTION_DECL,
  658. get_identifier ("__stack_chk_fail_local"), t);
  659. TREE_STATIC (t) = 1;
  660. TREE_PUBLIC (t) = 1;
  661. DECL_EXTERNAL (t) = 1;
  662. TREE_USED (t) = 1;
  663. TREE_THIS_VOLATILE (t) = 1;
  664. TREE_NOTHROW (t) = 1;
  665. DECL_ARTIFICIAL (t) = 1;
  666. DECL_IGNORED_P (t) = 1;
  667. DECL_VISIBILITY_SPECIFIED (t) = 1;
  668. DECL_VISIBILITY (t) = VISIBILITY_HIDDEN;
  669. stack_chk_fail_decl = t;
  670. }
  671. return build_call_expr (t, 0);
  672. #endif
  673. }
  674. bool
  675. hook_bool_const_rtx_commutative_p (const_rtx x,
  676. int outer_code ATTRIBUTE_UNUSED)
  677. {
  678. return COMMUTATIVE_P (x);
  679. }
  680. rtx
  681. default_function_value (const_tree ret_type ATTRIBUTE_UNUSED,
  682. const_tree fn_decl_or_type,
  683. bool outgoing ATTRIBUTE_UNUSED)
  684. {
  685. /* The old interface doesn't handle receiving the function type. */
  686. if (fn_decl_or_type
  687. && !DECL_P (fn_decl_or_type))
  688. fn_decl_or_type = NULL;
  689. #ifdef FUNCTION_VALUE
  690. return FUNCTION_VALUE (ret_type, fn_decl_or_type);
  691. #else
  692. gcc_unreachable ();
  693. #endif
  694. }
  695. rtx
  696. default_libcall_value (machine_mode mode ATTRIBUTE_UNUSED,
  697. const_rtx fun ATTRIBUTE_UNUSED)
  698. {
  699. #ifdef LIBCALL_VALUE
  700. return LIBCALL_VALUE (mode);
  701. #else
  702. gcc_unreachable ();
  703. #endif
  704. }
  705. /* The default hook for TARGET_FUNCTION_VALUE_REGNO_P. */
  706. bool
  707. default_function_value_regno_p (const unsigned int regno ATTRIBUTE_UNUSED)
  708. {
  709. #ifdef FUNCTION_VALUE_REGNO_P
  710. return FUNCTION_VALUE_REGNO_P (regno);
  711. #else
  712. gcc_unreachable ();
  713. #endif
  714. }
  715. rtx
  716. default_internal_arg_pointer (void)
  717. {
  718. /* If the reg that the virtual arg pointer will be translated into is
  719. not a fixed reg or is the stack pointer, make a copy of the virtual
  720. arg pointer, and address parms via the copy. The frame pointer is
  721. considered fixed even though it is not marked as such. */
  722. if ((ARG_POINTER_REGNUM == STACK_POINTER_REGNUM
  723. || ! (fixed_regs[ARG_POINTER_REGNUM]
  724. || ARG_POINTER_REGNUM == FRAME_POINTER_REGNUM)))
  725. return copy_to_reg (virtual_incoming_args_rtx);
  726. else
  727. return virtual_incoming_args_rtx;
  728. }
  729. rtx
  730. default_static_chain (const_tree ARG_UNUSED (fndecl_or_type), bool incoming_p)
  731. {
  732. if (incoming_p)
  733. {
  734. #ifdef STATIC_CHAIN_INCOMING_REGNUM
  735. return gen_rtx_REG (Pmode, STATIC_CHAIN_INCOMING_REGNUM);
  736. #endif
  737. }
  738. #ifdef STATIC_CHAIN_REGNUM
  739. return gen_rtx_REG (Pmode, STATIC_CHAIN_REGNUM);
  740. #endif
  741. {
  742. static bool issued_error;
  743. if (!issued_error)
  744. {
  745. issued_error = true;
  746. sorry ("nested functions not supported on this target");
  747. }
  748. /* It really doesn't matter what we return here, so long at it
  749. doesn't cause the rest of the compiler to crash. */
  750. return gen_rtx_MEM (Pmode, stack_pointer_rtx);
  751. }
  752. }
  753. void
  754. default_trampoline_init (rtx ARG_UNUSED (m_tramp), tree ARG_UNUSED (t_func),
  755. rtx ARG_UNUSED (r_chain))
  756. {
  757. sorry ("nested function trampolines not supported on this target");
  758. }
  759. int
  760. default_return_pops_args (tree fundecl ATTRIBUTE_UNUSED,
  761. tree funtype ATTRIBUTE_UNUSED,
  762. int size ATTRIBUTE_UNUSED)
  763. {
  764. return 0;
  765. }
  766. reg_class_t
  767. default_branch_target_register_class (void)
  768. {
  769. return NO_REGS;
  770. }
  771. extern bool
  772. default_lra_p (void)
  773. {
  774. return false;
  775. }
  776. int
  777. default_register_priority (int hard_regno ATTRIBUTE_UNUSED)
  778. {
  779. return 0;
  780. }
  781. extern bool
  782. default_register_usage_leveling_p (void)
  783. {
  784. return false;
  785. }
  786. extern bool
  787. default_different_addr_displacement_p (void)
  788. {
  789. return false;
  790. }
  791. reg_class_t
  792. default_secondary_reload (bool in_p ATTRIBUTE_UNUSED, rtx x ATTRIBUTE_UNUSED,
  793. reg_class_t reload_class_i ATTRIBUTE_UNUSED,
  794. machine_mode reload_mode ATTRIBUTE_UNUSED,
  795. secondary_reload_info *sri)
  796. {
  797. enum reg_class rclass = NO_REGS;
  798. enum reg_class reload_class = (enum reg_class) reload_class_i;
  799. if (sri->prev_sri && sri->prev_sri->t_icode != CODE_FOR_nothing)
  800. {
  801. sri->icode = sri->prev_sri->t_icode;
  802. return NO_REGS;
  803. }
  804. #ifdef SECONDARY_INPUT_RELOAD_CLASS
  805. if (in_p)
  806. rclass = SECONDARY_INPUT_RELOAD_CLASS (reload_class, reload_mode, x);
  807. #endif
  808. #ifdef SECONDARY_OUTPUT_RELOAD_CLASS
  809. if (! in_p)
  810. rclass = SECONDARY_OUTPUT_RELOAD_CLASS (reload_class, reload_mode, x);
  811. #endif
  812. if (rclass != NO_REGS)
  813. {
  814. enum insn_code icode
  815. = direct_optab_handler (in_p ? reload_in_optab : reload_out_optab,
  816. reload_mode);
  817. if (icode != CODE_FOR_nothing
  818. && !insn_operand_matches (icode, in_p, x))
  819. icode = CODE_FOR_nothing;
  820. else if (icode != CODE_FOR_nothing)
  821. {
  822. const char *insn_constraint, *scratch_constraint;
  823. enum reg_class insn_class, scratch_class;
  824. gcc_assert (insn_data[(int) icode].n_operands == 3);
  825. insn_constraint = insn_data[(int) icode].operand[!in_p].constraint;
  826. if (!*insn_constraint)
  827. insn_class = ALL_REGS;
  828. else
  829. {
  830. if (in_p)
  831. {
  832. gcc_assert (*insn_constraint == '=');
  833. insn_constraint++;
  834. }
  835. insn_class = (reg_class_for_constraint
  836. (lookup_constraint (insn_constraint)));
  837. gcc_assert (insn_class != NO_REGS);
  838. }
  839. scratch_constraint = insn_data[(int) icode].operand[2].constraint;
  840. /* The scratch register's constraint must start with "=&",
  841. except for an input reload, where only "=" is necessary,
  842. and where it might be beneficial to re-use registers from
  843. the input. */
  844. gcc_assert (scratch_constraint[0] == '='
  845. && (in_p || scratch_constraint[1] == '&'));
  846. scratch_constraint++;
  847. if (*scratch_constraint == '&')
  848. scratch_constraint++;
  849. scratch_class = (reg_class_for_constraint
  850. (lookup_constraint (scratch_constraint)));
  851. if (reg_class_subset_p (reload_class, insn_class))
  852. {
  853. gcc_assert (scratch_class == rclass);
  854. rclass = NO_REGS;
  855. }
  856. else
  857. rclass = insn_class;
  858. }
  859. if (rclass == NO_REGS)
  860. sri->icode = icode;
  861. else
  862. sri->t_icode = icode;
  863. }
  864. return rclass;
  865. }
  866. /* By default, if flag_pic is true, then neither local nor global relocs
  867. should be placed in readonly memory. */
  868. int
  869. default_reloc_rw_mask (void)
  870. {
  871. return flag_pic ? 3 : 0;
  872. }
  873. /* By default, do no modification. */
  874. tree default_mangle_decl_assembler_name (tree decl ATTRIBUTE_UNUSED,
  875. tree id)
  876. {
  877. return id;
  878. }
  879. /* Default to natural alignment for vector types. */
  880. HOST_WIDE_INT
  881. default_vector_alignment (const_tree type)
  882. {
  883. return tree_to_shwi (TYPE_SIZE (type));
  884. }
  885. bool
  886. default_builtin_vector_alignment_reachable (const_tree type, bool is_packed)
  887. {
  888. if (is_packed)
  889. return false;
  890. /* Assuming that types whose size is > pointer-size are not guaranteed to be
  891. naturally aligned. */
  892. if (tree_int_cst_compare (TYPE_SIZE (type), bitsize_int (POINTER_SIZE)) > 0)
  893. return false;
  894. /* Assuming that types whose size is <= pointer-size
  895. are naturally aligned. */
  896. return true;
  897. }
  898. /* By default, assume that a target supports any factor of misalignment
  899. memory access if it supports movmisalign patten.
  900. is_packed is true if the memory access is defined in a packed struct. */
  901. bool
  902. default_builtin_support_vector_misalignment (machine_mode mode,
  903. const_tree type
  904. ATTRIBUTE_UNUSED,
  905. int misalignment
  906. ATTRIBUTE_UNUSED,
  907. bool is_packed
  908. ATTRIBUTE_UNUSED)
  909. {
  910. if (optab_handler (movmisalign_optab, mode) != CODE_FOR_nothing)
  911. return true;
  912. return false;
  913. }
  914. /* By default, only attempt to parallelize bitwise operations, and
  915. possibly adds/subtracts using bit-twiddling. */
  916. machine_mode
  917. default_preferred_simd_mode (machine_mode mode ATTRIBUTE_UNUSED)
  918. {
  919. return word_mode;
  920. }
  921. /* By default only the size derived from the preferred vector mode
  922. is tried. */
  923. unsigned int
  924. default_autovectorize_vector_sizes (void)
  925. {
  926. return 0;
  927. }
  928. /* By default, the cost model accumulates three separate costs (prologue,
  929. loop body, and epilogue) for a vectorized loop or block. So allocate an
  930. array of three unsigned ints, set it to zero, and return its address. */
  931. void *
  932. default_init_cost (struct loop *loop_info ATTRIBUTE_UNUSED)
  933. {
  934. unsigned *cost = XNEWVEC (unsigned, 3);
  935. cost[vect_prologue] = cost[vect_body] = cost[vect_epilogue] = 0;
  936. return cost;
  937. }
  938. /* By default, the cost model looks up the cost of the given statement
  939. kind and mode, multiplies it by the occurrence count, accumulates
  940. it into the cost specified by WHERE, and returns the cost added. */
  941. unsigned
  942. default_add_stmt_cost (void *data, int count, enum vect_cost_for_stmt kind,
  943. struct _stmt_vec_info *stmt_info, int misalign,
  944. enum vect_cost_model_location where)
  945. {
  946. unsigned *cost = (unsigned *) data;
  947. unsigned retval = 0;
  948. tree vectype = stmt_info ? stmt_vectype (stmt_info) : NULL_TREE;
  949. int stmt_cost = targetm.vectorize.builtin_vectorization_cost (kind, vectype,
  950. misalign);
  951. /* Statements in an inner loop relative to the loop being
  952. vectorized are weighted more heavily. The value here is
  953. arbitrary and could potentially be improved with analysis. */
  954. if (where == vect_body && stmt_info && stmt_in_inner_loop_p (stmt_info))
  955. count *= 50; /* FIXME. */
  956. retval = (unsigned) (count * stmt_cost);
  957. cost[where] += retval;
  958. return retval;
  959. }
  960. /* By default, the cost model just returns the accumulated costs. */
  961. void
  962. default_finish_cost (void *data, unsigned *prologue_cost,
  963. unsigned *body_cost, unsigned *epilogue_cost)
  964. {
  965. unsigned *cost = (unsigned *) data;
  966. *prologue_cost = cost[vect_prologue];
  967. *body_cost = cost[vect_body];
  968. *epilogue_cost = cost[vect_epilogue];
  969. }
  970. /* Free the cost data. */
  971. void
  972. default_destroy_cost_data (void *data)
  973. {
  974. free (data);
  975. }
  976. /* Determine whether or not a pointer mode is valid. Assume defaults
  977. of ptr_mode or Pmode - can be overridden. */
  978. bool
  979. default_valid_pointer_mode (machine_mode mode)
  980. {
  981. return (mode == ptr_mode || mode == Pmode);
  982. }
  983. /* Determine whether the memory reference specified by REF may alias
  984. the C libraries errno location. */
  985. bool
  986. default_ref_may_alias_errno (ao_ref *ref)
  987. {
  988. tree base = ao_ref_base (ref);
  989. /* The default implementation assumes the errno location is
  990. a declaration of type int or is always accessed via a
  991. pointer to int. We assume that accesses to errno are
  992. not deliberately obfuscated (even in conforming ways). */
  993. if (TYPE_UNSIGNED (TREE_TYPE (base))
  994. || TYPE_MODE (TREE_TYPE (base)) != TYPE_MODE (integer_type_node))
  995. return false;
  996. /* The default implementation assumes an errno location
  997. declaration is never defined in the current compilation unit. */
  998. if (DECL_P (base)
  999. && !TREE_STATIC (base))
  1000. return true;
  1001. else if (TREE_CODE (base) == MEM_REF
  1002. && TREE_CODE (TREE_OPERAND (base, 0)) == SSA_NAME)
  1003. {
  1004. struct ptr_info_def *pi = SSA_NAME_PTR_INFO (TREE_OPERAND (base, 0));
  1005. return !pi || pi->pt.anything || pi->pt.nonlocal;
  1006. }
  1007. return false;
  1008. }
  1009. /* Return the mode for a pointer to a given ADDRSPACE, defaulting to ptr_mode
  1010. for the generic address space only. */
  1011. machine_mode
  1012. default_addr_space_pointer_mode (addr_space_t addrspace ATTRIBUTE_UNUSED)
  1013. {
  1014. gcc_assert (ADDR_SPACE_GENERIC_P (addrspace));
  1015. return ptr_mode;
  1016. }
  1017. /* Return the mode for an address in a given ADDRSPACE, defaulting to Pmode
  1018. for the generic address space only. */
  1019. machine_mode
  1020. default_addr_space_address_mode (addr_space_t addrspace ATTRIBUTE_UNUSED)
  1021. {
  1022. gcc_assert (ADDR_SPACE_GENERIC_P (addrspace));
  1023. return Pmode;
  1024. }
  1025. /* Named address space version of valid_pointer_mode. */
  1026. bool
  1027. default_addr_space_valid_pointer_mode (machine_mode mode, addr_space_t as)
  1028. {
  1029. if (!ADDR_SPACE_GENERIC_P (as))
  1030. return (mode == targetm.addr_space.pointer_mode (as)
  1031. || mode == targetm.addr_space.address_mode (as));
  1032. return targetm.valid_pointer_mode (mode);
  1033. }
  1034. /* Some places still assume that all pointer or address modes are the
  1035. standard Pmode and ptr_mode. These optimizations become invalid if
  1036. the target actually supports multiple different modes. For now,
  1037. we disable such optimizations on such targets, using this function. */
  1038. bool
  1039. target_default_pointer_address_modes_p (void)
  1040. {
  1041. if (targetm.addr_space.address_mode != default_addr_space_address_mode)
  1042. return false;
  1043. if (targetm.addr_space.pointer_mode != default_addr_space_pointer_mode)
  1044. return false;
  1045. return true;
  1046. }
  1047. /* Named address space version of legitimate_address_p. */
  1048. bool
  1049. default_addr_space_legitimate_address_p (machine_mode mode, rtx mem,
  1050. bool strict, addr_space_t as)
  1051. {
  1052. if (!ADDR_SPACE_GENERIC_P (as))
  1053. gcc_unreachable ();
  1054. return targetm.legitimate_address_p (mode, mem, strict);
  1055. }
  1056. /* Named address space version of LEGITIMIZE_ADDRESS. */
  1057. rtx
  1058. default_addr_space_legitimize_address (rtx x, rtx oldx,
  1059. machine_mode mode, addr_space_t as)
  1060. {
  1061. if (!ADDR_SPACE_GENERIC_P (as))
  1062. return x;
  1063. return targetm.legitimize_address (x, oldx, mode);
  1064. }
  1065. /* The default hook for determining if one named address space is a subset of
  1066. another and to return which address space to use as the common address
  1067. space. */
  1068. bool
  1069. default_addr_space_subset_p (addr_space_t subset, addr_space_t superset)
  1070. {
  1071. return (subset == superset);
  1072. }
  1073. /* The default hook for TARGET_ADDR_SPACE_CONVERT. This hook should never be
  1074. called for targets with only a generic address space. */
  1075. rtx
  1076. default_addr_space_convert (rtx op ATTRIBUTE_UNUSED,
  1077. tree from_type ATTRIBUTE_UNUSED,
  1078. tree to_type ATTRIBUTE_UNUSED)
  1079. {
  1080. gcc_unreachable ();
  1081. }
  1082. bool
  1083. default_hard_regno_scratch_ok (unsigned int regno ATTRIBUTE_UNUSED)
  1084. {
  1085. return true;
  1086. }
  1087. /* The default implementation of TARGET_MODE_DEPENDENT_ADDRESS_P. */
  1088. bool
  1089. default_mode_dependent_address_p (const_rtx addr ATTRIBUTE_UNUSED,
  1090. addr_space_t addrspace ATTRIBUTE_UNUSED)
  1091. {
  1092. return false;
  1093. }
  1094. bool
  1095. default_target_option_valid_attribute_p (tree ARG_UNUSED (fndecl),
  1096. tree ARG_UNUSED (name),
  1097. tree ARG_UNUSED (args),
  1098. int ARG_UNUSED (flags))
  1099. {
  1100. warning (OPT_Wattributes,
  1101. "target attribute is not supported on this machine");
  1102. return false;
  1103. }
  1104. bool
  1105. default_target_option_pragma_parse (tree ARG_UNUSED (args),
  1106. tree ARG_UNUSED (pop_target))
  1107. {
  1108. warning (OPT_Wpragmas,
  1109. "#pragma GCC target is not supported for this machine");
  1110. return false;
  1111. }
  1112. bool
  1113. default_target_can_inline_p (tree caller, tree callee)
  1114. {
  1115. bool ret = false;
  1116. tree callee_opts = DECL_FUNCTION_SPECIFIC_TARGET (callee);
  1117. tree caller_opts = DECL_FUNCTION_SPECIFIC_TARGET (caller);
  1118. /* If callee has no option attributes, then it is ok to inline */
  1119. if (!callee_opts)
  1120. ret = true;
  1121. /* If caller has no option attributes, but callee does then it is not ok to
  1122. inline */
  1123. else if (!caller_opts)
  1124. ret = false;
  1125. /* If both caller and callee have attributes, assume that if the
  1126. pointer is different, the two functions have different target
  1127. options since build_target_option_node uses a hash table for the
  1128. options. */
  1129. else
  1130. ret = (callee_opts == caller_opts);
  1131. return ret;
  1132. }
  1133. #ifndef HAVE_casesi
  1134. # define HAVE_casesi 0
  1135. #endif
  1136. /* If the machine does not have a case insn that compares the bounds,
  1137. this means extra overhead for dispatch tables, which raises the
  1138. threshold for using them. */
  1139. unsigned int
  1140. default_case_values_threshold (void)
  1141. {
  1142. return (HAVE_casesi ? 4 : 5);
  1143. }
  1144. bool
  1145. default_have_conditional_execution (void)
  1146. {
  1147. #ifdef HAVE_conditional_execution
  1148. return HAVE_conditional_execution;
  1149. #else
  1150. return false;
  1151. #endif
  1152. }
  1153. /* By default we assume that c99 functions are present at the runtime,
  1154. but sincos is not. */
  1155. bool
  1156. default_libc_has_function (enum function_class fn_class)
  1157. {
  1158. if (fn_class == function_c94
  1159. || fn_class == function_c99_misc
  1160. || fn_class == function_c99_math_complex)
  1161. return true;
  1162. return false;
  1163. }
  1164. bool
  1165. gnu_libc_has_function (enum function_class fn_class ATTRIBUTE_UNUSED)
  1166. {
  1167. return true;
  1168. }
  1169. bool
  1170. no_c99_libc_has_function (enum function_class fn_class ATTRIBUTE_UNUSED)
  1171. {
  1172. return false;
  1173. }
  1174. tree
  1175. default_builtin_tm_load_store (tree ARG_UNUSED (type))
  1176. {
  1177. return NULL_TREE;
  1178. }
  1179. /* Compute cost of moving registers to/from memory. */
  1180. int
  1181. default_memory_move_cost (machine_mode mode ATTRIBUTE_UNUSED,
  1182. reg_class_t rclass ATTRIBUTE_UNUSED,
  1183. bool in ATTRIBUTE_UNUSED)
  1184. {
  1185. #ifndef MEMORY_MOVE_COST
  1186. return (4 + memory_move_secondary_cost (mode, (enum reg_class) rclass, in));
  1187. #else
  1188. return MEMORY_MOVE_COST (mode, (enum reg_class) rclass, in);
  1189. #endif
  1190. }
  1191. /* Compute cost of moving data from a register of class FROM to one of
  1192. TO, using MODE. */
  1193. int
  1194. default_register_move_cost (machine_mode mode ATTRIBUTE_UNUSED,
  1195. reg_class_t from ATTRIBUTE_UNUSED,
  1196. reg_class_t to ATTRIBUTE_UNUSED)
  1197. {
  1198. #ifndef REGISTER_MOVE_COST
  1199. return 2;
  1200. #else
  1201. return REGISTER_MOVE_COST (mode, (enum reg_class) from, (enum reg_class) to);
  1202. #endif
  1203. }
  1204. /* For hooks which use the MOVE_RATIO macro, this gives the legacy default
  1205. behaviour. SPEED_P is true if we are compiling for speed. */
  1206. unsigned int
  1207. get_move_ratio (bool speed_p ATTRIBUTE_UNUSED)
  1208. {
  1209. unsigned int move_ratio;
  1210. #ifdef MOVE_RATIO
  1211. move_ratio = (unsigned int) MOVE_RATIO (speed_p);
  1212. #else
  1213. #if defined (HAVE_movmemqi) || defined (HAVE_movmemhi) || defined (HAVE_movmemsi) || defined (HAVE_movmemdi) || defined (HAVE_movmemti)
  1214. move_ratio = 2;
  1215. #else /* No movmem patterns, pick a default. */
  1216. move_ratio = ((speed_p) ? 15 : 3);
  1217. #endif
  1218. #endif
  1219. return move_ratio;
  1220. }
  1221. /* Return TRUE if the move_by_pieces/set_by_pieces infrastructure should be
  1222. used; return FALSE if the movmem/setmem optab should be expanded, or
  1223. a call to memcpy emitted. */
  1224. bool
  1225. default_use_by_pieces_infrastructure_p (unsigned HOST_WIDE_INT size,
  1226. unsigned int alignment,
  1227. enum by_pieces_operation op,
  1228. bool speed_p)
  1229. {
  1230. unsigned int max_size = 0;
  1231. unsigned int ratio = 0;
  1232. switch (op)
  1233. {
  1234. case CLEAR_BY_PIECES:
  1235. max_size = STORE_MAX_PIECES;
  1236. ratio = CLEAR_RATIO (speed_p);
  1237. break;
  1238. case MOVE_BY_PIECES:
  1239. max_size = MOVE_MAX_PIECES;
  1240. ratio = get_move_ratio (speed_p);
  1241. break;
  1242. case SET_BY_PIECES:
  1243. max_size = STORE_MAX_PIECES;
  1244. ratio = SET_RATIO (speed_p);
  1245. break;
  1246. case STORE_BY_PIECES:
  1247. max_size = STORE_MAX_PIECES;
  1248. ratio = get_move_ratio (speed_p);
  1249. break;
  1250. }
  1251. return move_by_pieces_ninsns (size, alignment, max_size + 1) < ratio;
  1252. }
  1253. bool
  1254. default_profile_before_prologue (void)
  1255. {
  1256. #ifdef PROFILE_BEFORE_PROLOGUE
  1257. return true;
  1258. #else
  1259. return false;
  1260. #endif
  1261. }
  1262. /* The default implementation of TARGET_PREFERRED_RELOAD_CLASS. */
  1263. reg_class_t
  1264. default_preferred_reload_class (rtx x ATTRIBUTE_UNUSED,
  1265. reg_class_t rclass)
  1266. {
  1267. #ifdef PREFERRED_RELOAD_CLASS
  1268. return (reg_class_t) PREFERRED_RELOAD_CLASS (x, (enum reg_class) rclass);
  1269. #else
  1270. return rclass;
  1271. #endif
  1272. }
  1273. /* The default implementation of TARGET_OUTPUT_PREFERRED_RELOAD_CLASS. */
  1274. reg_class_t
  1275. default_preferred_output_reload_class (rtx x ATTRIBUTE_UNUSED,
  1276. reg_class_t rclass)
  1277. {
  1278. return rclass;
  1279. }
  1280. /* The default implementation of TARGET_PREFERRED_RENAME_CLASS. */
  1281. reg_class_t
  1282. default_preferred_rename_class (reg_class_t rclass ATTRIBUTE_UNUSED)
  1283. {
  1284. return NO_REGS;
  1285. }
  1286. /* The default implementation of TARGET_CLASS_LIKELY_SPILLED_P. */
  1287. bool
  1288. default_class_likely_spilled_p (reg_class_t rclass)
  1289. {
  1290. return (reg_class_size[(int) rclass] == 1);
  1291. }
  1292. /* The default implementation of TARGET_CLASS_MAX_NREGS. */
  1293. unsigned char
  1294. default_class_max_nregs (reg_class_t rclass ATTRIBUTE_UNUSED,
  1295. machine_mode mode ATTRIBUTE_UNUSED)
  1296. {
  1297. #ifdef CLASS_MAX_NREGS
  1298. return (unsigned char) CLASS_MAX_NREGS ((enum reg_class) rclass, mode);
  1299. #else
  1300. return ((GET_MODE_SIZE (mode) + UNITS_PER_WORD - 1) / UNITS_PER_WORD);
  1301. #endif
  1302. }
  1303. /* Determine the debugging unwind mechanism for the target. */
  1304. enum unwind_info_type
  1305. default_debug_unwind_info (void)
  1306. {
  1307. /* If the target wants to force the use of dwarf2 unwind info, let it. */
  1308. /* ??? Change all users to the hook, then poison this. */
  1309. #ifdef DWARF2_FRAME_INFO
  1310. if (DWARF2_FRAME_INFO)
  1311. return UI_DWARF2;
  1312. #endif
  1313. /* Otherwise, only turn it on if dwarf2 debugging is enabled. */
  1314. #ifdef DWARF2_DEBUGGING_INFO
  1315. if (write_symbols == DWARF2_DEBUG || write_symbols == VMS_AND_DWARF2_DEBUG)
  1316. return UI_DWARF2;
  1317. #endif
  1318. return UI_NONE;
  1319. }
  1320. /* Determine the correct mode for a Dwarf frame register that represents
  1321. register REGNO. */
  1322. machine_mode
  1323. default_dwarf_frame_reg_mode (int regno)
  1324. {
  1325. machine_mode save_mode = reg_raw_mode[regno];
  1326. if (HARD_REGNO_CALL_PART_CLOBBERED (regno, save_mode))
  1327. save_mode = choose_hard_reg_mode (regno, 1, true);
  1328. return save_mode;
  1329. }
  1330. /* To be used by targets where reg_raw_mode doesn't return the right
  1331. mode for registers used in apply_builtin_return and apply_builtin_arg. */
  1332. machine_mode
  1333. default_get_reg_raw_mode (int regno)
  1334. {
  1335. return reg_raw_mode[regno];
  1336. }
  1337. /* Return true if a leaf function should stay leaf even with profiling
  1338. enabled. */
  1339. bool
  1340. default_keep_leaf_when_profiled ()
  1341. {
  1342. return false;
  1343. }
  1344. /* Return true if the state of option OPTION should be stored in PCH files
  1345. and checked by default_pch_valid_p. Store the option's current state
  1346. in STATE if so. */
  1347. static inline bool
  1348. option_affects_pch_p (int option, struct cl_option_state *state)
  1349. {
  1350. if ((cl_options[option].flags & CL_TARGET) == 0)
  1351. return false;
  1352. if ((cl_options[option].flags & CL_PCH_IGNORE) != 0)
  1353. return false;
  1354. if (option_flag_var (option, &global_options) == &target_flags)
  1355. if (targetm.check_pch_target_flags)
  1356. return false;
  1357. return get_option_state (&global_options, option, state);
  1358. }
  1359. /* Default version of get_pch_validity.
  1360. By default, every flag difference is fatal; that will be mostly right for
  1361. most targets, but completely right for very few. */
  1362. void *
  1363. default_get_pch_validity (size_t *sz)
  1364. {
  1365. struct cl_option_state state;
  1366. size_t i;
  1367. char *result, *r;
  1368. *sz = 2;
  1369. if (targetm.check_pch_target_flags)
  1370. *sz += sizeof (target_flags);
  1371. for (i = 0; i < cl_options_count; i++)
  1372. if (option_affects_pch_p (i, &state))
  1373. *sz += state.size;
  1374. result = r = XNEWVEC (char, *sz);
  1375. r[0] = flag_pic;
  1376. r[1] = flag_pie;
  1377. r += 2;
  1378. if (targetm.check_pch_target_flags)
  1379. {
  1380. memcpy (r, &target_flags, sizeof (target_flags));
  1381. r += sizeof (target_flags);
  1382. }
  1383. for (i = 0; i < cl_options_count; i++)
  1384. if (option_affects_pch_p (i, &state))
  1385. {
  1386. memcpy (r, state.data, state.size);
  1387. r += state.size;
  1388. }
  1389. return result;
  1390. }
  1391. /* Return a message which says that a PCH file was created with a different
  1392. setting of OPTION. */
  1393. static const char *
  1394. pch_option_mismatch (const char *option)
  1395. {
  1396. return xasprintf (_("created and used with differing settings of '%s'"),
  1397. option);
  1398. }
  1399. /* Default version of pch_valid_p. */
  1400. const char *
  1401. default_pch_valid_p (const void *data_p, size_t len)
  1402. {
  1403. struct cl_option_state state;
  1404. const char *data = (const char *)data_p;
  1405. size_t i;
  1406. /* -fpic and -fpie also usually make a PCH invalid. */
  1407. if (data[0] != flag_pic)
  1408. return _("created and used with different settings of -fpic");
  1409. if (data[1] != flag_pie)
  1410. return _("created and used with different settings of -fpie");
  1411. data += 2;
  1412. /* Check target_flags. */
  1413. if (targetm.check_pch_target_flags)
  1414. {
  1415. int tf;
  1416. const char *r;
  1417. memcpy (&tf, data, sizeof (target_flags));
  1418. data += sizeof (target_flags);
  1419. len -= sizeof (target_flags);
  1420. r = targetm.check_pch_target_flags (tf);
  1421. if (r != NULL)
  1422. return r;
  1423. }
  1424. for (i = 0; i < cl_options_count; i++)
  1425. if (option_affects_pch_p (i, &state))
  1426. {
  1427. if (memcmp (data, state.data, state.size) != 0)
  1428. return pch_option_mismatch (cl_options[i].opt_text);
  1429. data += state.size;
  1430. len -= state.size;
  1431. }
  1432. return NULL;
  1433. }
  1434. /* Default version of cstore_mode. */
  1435. machine_mode
  1436. default_cstore_mode (enum insn_code icode)
  1437. {
  1438. return insn_data[(int) icode].operand[0].mode;
  1439. }
  1440. /* Default version of member_type_forces_blk. */
  1441. bool
  1442. default_member_type_forces_blk (const_tree, machine_mode)
  1443. {
  1444. return false;
  1445. }
  1446. rtx
  1447. default_load_bounds_for_arg (rtx addr ATTRIBUTE_UNUSED,
  1448. rtx ptr ATTRIBUTE_UNUSED,
  1449. rtx bnd ATTRIBUTE_UNUSED)
  1450. {
  1451. gcc_unreachable ();
  1452. }
  1453. void
  1454. default_store_bounds_for_arg (rtx val ATTRIBUTE_UNUSED,
  1455. rtx addr ATTRIBUTE_UNUSED,
  1456. rtx bounds ATTRIBUTE_UNUSED,
  1457. rtx to ATTRIBUTE_UNUSED)
  1458. {
  1459. gcc_unreachable ();
  1460. }
  1461. rtx
  1462. default_load_returned_bounds (rtx slot ATTRIBUTE_UNUSED)
  1463. {
  1464. gcc_unreachable ();
  1465. }
  1466. void
  1467. default_store_returned_bounds (rtx slot ATTRIBUTE_UNUSED,
  1468. rtx bounds ATTRIBUTE_UNUSED)
  1469. {
  1470. gcc_unreachable ();
  1471. }
  1472. /* Default version of canonicalize_comparison. */
  1473. void
  1474. default_canonicalize_comparison (int *, rtx *, rtx *, bool)
  1475. {
  1476. }
  1477. /* Default implementation of TARGET_ATOMIC_ASSIGN_EXPAND_FENV. */
  1478. void
  1479. default_atomic_assign_expand_fenv (tree *, tree *, tree *)
  1480. {
  1481. }
  1482. #ifndef PAD_VARARGS_DOWN
  1483. #define PAD_VARARGS_DOWN BYTES_BIG_ENDIAN
  1484. #endif
  1485. /* Build an indirect-ref expression over the given TREE, which represents a
  1486. piece of a va_arg() expansion. */
  1487. tree
  1488. build_va_arg_indirect_ref (tree addr)
  1489. {
  1490. addr = build_simple_mem_ref_loc (EXPR_LOCATION (addr), addr);
  1491. return addr;
  1492. }
  1493. /* The "standard" implementation of va_arg: read the value from the
  1494. current (padded) address and increment by the (padded) size. */
  1495. tree
  1496. std_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p,
  1497. gimple_seq *post_p)
  1498. {
  1499. tree addr, t, type_size, rounded_size, valist_tmp;
  1500. unsigned HOST_WIDE_INT align, boundary;
  1501. bool indirect;
  1502. #ifdef ARGS_GROW_DOWNWARD
  1503. /* All of the alignment and movement below is for args-grow-up machines.
  1504. As of 2004, there are only 3 ARGS_GROW_DOWNWARD targets, and they all
  1505. implement their own specialized gimplify_va_arg_expr routines. */
  1506. gcc_unreachable ();
  1507. #endif
  1508. indirect = pass_by_reference (NULL, TYPE_MODE (type), type, false);
  1509. if (indirect)
  1510. type = build_pointer_type (type);
  1511. align = PARM_BOUNDARY / BITS_PER_UNIT;
  1512. boundary = targetm.calls.function_arg_boundary (TYPE_MODE (type), type);
  1513. /* When we align parameter on stack for caller, if the parameter
  1514. alignment is beyond MAX_SUPPORTED_STACK_ALIGNMENT, it will be
  1515. aligned at MAX_SUPPORTED_STACK_ALIGNMENT. We will match callee
  1516. here with caller. */
  1517. if (boundary > MAX_SUPPORTED_STACK_ALIGNMENT)
  1518. boundary = MAX_SUPPORTED_STACK_ALIGNMENT;
  1519. boundary /= BITS_PER_UNIT;
  1520. /* Hoist the valist value into a temporary for the moment. */
  1521. valist_tmp = get_initialized_tmp_var (valist, pre_p, NULL);
  1522. /* va_list pointer is aligned to PARM_BOUNDARY. If argument actually
  1523. requires greater alignment, we must perform dynamic alignment. */
  1524. if (boundary > align
  1525. && !integer_zerop (TYPE_SIZE (type)))
  1526. {
  1527. t = build2 (MODIFY_EXPR, TREE_TYPE (valist), valist_tmp,
  1528. fold_build_pointer_plus_hwi (valist_tmp, boundary - 1));
  1529. gimplify_and_add (t, pre_p);
  1530. t = build2 (MODIFY_EXPR, TREE_TYPE (valist), valist_tmp,
  1531. fold_build2 (BIT_AND_EXPR, TREE_TYPE (valist),
  1532. valist_tmp,
  1533. build_int_cst (TREE_TYPE (valist), -boundary)));
  1534. gimplify_and_add (t, pre_p);
  1535. }
  1536. else
  1537. boundary = align;
  1538. /* If the actual alignment is less than the alignment of the type,
  1539. adjust the type accordingly so that we don't assume strict alignment
  1540. when dereferencing the pointer. */
  1541. boundary *= BITS_PER_UNIT;
  1542. if (boundary < TYPE_ALIGN (type))
  1543. {
  1544. type = build_variant_type_copy (type);
  1545. TYPE_ALIGN (type) = boundary;
  1546. }
  1547. /* Compute the rounded size of the type. */
  1548. type_size = size_in_bytes (type);
  1549. rounded_size = round_up (type_size, align);
  1550. /* Reduce rounded_size so it's sharable with the postqueue. */
  1551. gimplify_expr (&rounded_size, pre_p, post_p, is_gimple_val, fb_rvalue);
  1552. /* Get AP. */
  1553. addr = valist_tmp;
  1554. if (PAD_VARARGS_DOWN && !integer_zerop (rounded_size))
  1555. {
  1556. /* Small args are padded downward. */
  1557. t = fold_build2_loc (input_location, GT_EXPR, sizetype,
  1558. rounded_size, size_int (align));
  1559. t = fold_build3 (COND_EXPR, sizetype, t, size_zero_node,
  1560. size_binop (MINUS_EXPR, rounded_size, type_size));
  1561. addr = fold_build_pointer_plus (addr, t);
  1562. }
  1563. /* Compute new value for AP. */
  1564. t = fold_build_pointer_plus (valist_tmp, rounded_size);
  1565. t = build2 (MODIFY_EXPR, TREE_TYPE (valist), valist, t);
  1566. gimplify_and_add (t, pre_p);
  1567. addr = fold_convert (build_pointer_type (type), addr);
  1568. if (indirect)
  1569. addr = build_va_arg_indirect_ref (addr);
  1570. return build_va_arg_indirect_ref (addr);
  1571. }
  1572. tree
  1573. default_chkp_bound_type (void)
  1574. {
  1575. tree res = make_node (POINTER_BOUNDS_TYPE);
  1576. TYPE_PRECISION (res) = TYPE_PRECISION (size_type_node) * 2;
  1577. TYPE_NAME (res) = get_identifier ("__bounds_type");
  1578. SET_TYPE_MODE (res, targetm.chkp_bound_mode ());
  1579. layout_type (res);
  1580. return res;
  1581. }
  1582. enum machine_mode
  1583. default_chkp_bound_mode (void)
  1584. {
  1585. return VOIDmode;
  1586. }
  1587. tree
  1588. default_builtin_chkp_function (unsigned int fcode ATTRIBUTE_UNUSED)
  1589. {
  1590. return NULL_TREE;
  1591. }
  1592. rtx
  1593. default_chkp_function_value_bounds (const_tree ret_type ATTRIBUTE_UNUSED,
  1594. const_tree fn_decl_or_type ATTRIBUTE_UNUSED,
  1595. bool outgoing ATTRIBUTE_UNUSED)
  1596. {
  1597. gcc_unreachable ();
  1598. }
  1599. tree
  1600. default_chkp_make_bounds_constant (HOST_WIDE_INT lb ATTRIBUTE_UNUSED,
  1601. HOST_WIDE_INT ub ATTRIBUTE_UNUSED)
  1602. {
  1603. return NULL_TREE;
  1604. }
  1605. int
  1606. default_chkp_initialize_bounds (tree var ATTRIBUTE_UNUSED,
  1607. tree lb ATTRIBUTE_UNUSED,
  1608. tree ub ATTRIBUTE_UNUSED,
  1609. tree *stmts ATTRIBUTE_UNUSED)
  1610. {
  1611. return 0;
  1612. }
  1613. void
  1614. default_setup_incoming_vararg_bounds (cumulative_args_t ca ATTRIBUTE_UNUSED,
  1615. enum machine_mode mode ATTRIBUTE_UNUSED,
  1616. tree type ATTRIBUTE_UNUSED,
  1617. int *pretend_arg_size ATTRIBUTE_UNUSED,
  1618. int second_time ATTRIBUTE_UNUSED)
  1619. {
  1620. }
  1621. /* An implementation of TARGET_CAN_USE_DOLOOP_P for targets that do
  1622. not support nested low-overhead loops. */
  1623. bool
  1624. can_use_doloop_if_innermost (const widest_int &, const widest_int &,
  1625. unsigned int loop_depth, bool)
  1626. {
  1627. return loop_depth == 1;
  1628. }
  1629. #include "gt-targhooks.h"