comparison gcc/config/rs6000/rs6000.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
comparison
equal deleted inserted replaced
111:04ced10e8804 131:84e7813d76e9
1 /* Subroutines used for code generation on IBM RS/6000. 1 /* Subroutines used for code generation on IBM RS/6000.
2 Copyright (C) 1991-2017 Free Software Foundation, Inc. 2 Copyright (C) 1991-2018 Free Software Foundation, Inc.
3 Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu) 3 Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
4 4
5 This file is part of GCC. 5 This file is part of GCC.
6 6
7 GCC is free software; you can redistribute it and/or modify it 7 GCC is free software; you can redistribute it and/or modify it
15 License for more details. 15 License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see 18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */ 19 <http://www.gnu.org/licenses/>. */
20
21 #define IN_TARGET_CODE 1
20 22
21 #include "config.h" 23 #include "config.h"
22 #include "system.h" 24 #include "system.h"
23 #include "coretypes.h" 25 #include "coretypes.h"
24 #include "backend.h" 26 #include "backend.h"
64 #include "params.h" 66 #include "params.h"
65 #include "tm-constrs.h" 67 #include "tm-constrs.h"
66 #include "tree-vectorizer.h" 68 #include "tree-vectorizer.h"
67 #include "target-globals.h" 69 #include "target-globals.h"
68 #include "builtins.h" 70 #include "builtins.h"
71 #include "tree-vector-builder.h"
69 #include "context.h" 72 #include "context.h"
70 #include "tree-pass.h" 73 #include "tree-pass.h"
71 #include "except.h" 74 #include "except.h"
72 #if TARGET_XCOFF 75 #if TARGET_XCOFF
73 #include "xcoffout.h" /* get declarations of xcoff_*_section_name */ 76 #include "xcoffout.h" /* get declarations of xcoff_*_section_name */
97 #define TARGET_IEEEQUAD_DEFAULT 1 100 #define TARGET_IEEEQUAD_DEFAULT 1
98 #else 101 #else
99 #define TARGET_IEEEQUAD_DEFAULT 0 102 #define TARGET_IEEEQUAD_DEFAULT 0
100 #endif 103 #endif
101 #endif 104 #endif
102
103 #define min(A,B) ((A) < (B) ? (A) : (B))
104 #define max(A,B) ((A) > (B) ? (A) : (B))
105 105
106 static pad_direction rs6000_function_arg_padding (machine_mode, const_tree); 106 static pad_direction rs6000_function_arg_padding (machine_mode, const_tree);
107 107
108 /* Structure used to define the rs6000 stack */ 108 /* Structure used to define the rs6000 stack */
109 typedef struct rs6000_stack { 109 typedef struct rs6000_stack {
169 /* The components already handled by separate shrink-wrapping, which should 169 /* The components already handled by separate shrink-wrapping, which should
170 not be considered by the prologue and epilogue. */ 170 not be considered by the prologue and epilogue. */
171 bool gpr_is_wrapped_separately[32]; 171 bool gpr_is_wrapped_separately[32];
172 bool fpr_is_wrapped_separately[32]; 172 bool fpr_is_wrapped_separately[32];
173 bool lr_is_wrapped_separately; 173 bool lr_is_wrapped_separately;
174 bool toc_is_wrapped_separately;
174 } machine_function; 175 } machine_function;
175 176
176 /* Support targetm.vectorize.builtin_mask_for_load. */ 177 /* Support targetm.vectorize.builtin_mask_for_load. */
177 static GTY(()) tree altivec_builtin_mask_for_load; 178 static GTY(()) tree altivec_builtin_mask_for_load;
178 179
193 194
194 /* Specify the machine mode that pointers have. After generation of rtl, the 195 /* Specify the machine mode that pointers have. After generation of rtl, the
195 compiler makes no further distinction between pointers and any other objects 196 compiler makes no further distinction between pointers and any other objects
196 of this machine mode. */ 197 of this machine mode. */
197 scalar_int_mode rs6000_pmode; 198 scalar_int_mode rs6000_pmode;
199
200 #if TARGET_ELF
201 /* Note whether IEEE 128-bit floating point was passed or returned, either as
202 the __float128/_Float128 explicit type, or when long double is IEEE 128-bit
203 floating point. We changed the default C++ mangling for these types and we
204 may want to generate a weak alias of the old mangling (U10__float128) to the
205 new mangling (u9__ieee128). */
206 static bool rs6000_passes_ieee128;
207 #endif
208
209 /* Generate the manged name (i.e. U10__float128) used in GCC 8.1, and not the
210 name used in current releases (i.e. u9__ieee128). */
211 static bool ieee128_mangling_gcc_8_1;
198 212
199 /* Width in bits of a pointer. */ 213 /* Width in bits of a pointer. */
200 unsigned rs6000_pointer_size; 214 unsigned rs6000_pointer_size;
201 215
202 #ifdef HAVE_AS_GNU_ATTRIBUTE 216 #ifdef HAVE_AS_GNU_ATTRIBUTE
385 { "arch_2_07", PPC_FEATURE2_ARCH_2_07, 1 }, 399 { "arch_2_07", PPC_FEATURE2_ARCH_2_07, 1 },
386 { "dscr", PPC_FEATURE2_HAS_DSCR, 1 }, 400 { "dscr", PPC_FEATURE2_HAS_DSCR, 1 },
387 { "ebb", PPC_FEATURE2_HAS_EBB, 1 }, 401 { "ebb", PPC_FEATURE2_HAS_EBB, 1 },
388 { "htm", PPC_FEATURE2_HAS_HTM, 1 }, 402 { "htm", PPC_FEATURE2_HAS_HTM, 1 },
389 { "htm-nosc", PPC_FEATURE2_HTM_NOSC, 1 }, 403 { "htm-nosc", PPC_FEATURE2_HTM_NOSC, 1 },
404 { "htm-no-suspend", PPC_FEATURE2_HTM_NO_SUSPEND, 1 },
390 { "isel", PPC_FEATURE2_HAS_ISEL, 1 }, 405 { "isel", PPC_FEATURE2_HAS_ISEL, 1 },
391 { "tar", PPC_FEATURE2_HAS_TAR, 1 }, 406 { "tar", PPC_FEATURE2_HAS_TAR, 1 },
392 { "vcrypto", PPC_FEATURE2_HAS_VEC_CRYPTO, 1 }, 407 { "vcrypto", PPC_FEATURE2_HAS_VEC_CRYPTO, 1 },
393 { "arch_3_00", PPC_FEATURE2_ARCH_3_00, 1 }, 408 { "arch_3_00", PPC_FEATURE2_ARCH_3_00, 1 },
394 { "ieee128", PPC_FEATURE2_HAS_IEEE128, 1 }, 409 { "ieee128", PPC_FEATURE2_HAS_IEEE128, 1 },
514 enum insn_code reload_load; /* INSN to reload for loading. */ 529 enum insn_code reload_load; /* INSN to reload for loading. */
515 enum insn_code reload_store; /* INSN to reload for storing. */ 530 enum insn_code reload_store; /* INSN to reload for storing. */
516 enum insn_code reload_fpr_gpr; /* INSN to move from FPR to GPR. */ 531 enum insn_code reload_fpr_gpr; /* INSN to move from FPR to GPR. */
517 enum insn_code reload_gpr_vsx; /* INSN to move from GPR to VSX. */ 532 enum insn_code reload_gpr_vsx; /* INSN to move from GPR to VSX. */
518 enum insn_code reload_vsx_gpr; /* INSN to move from VSX to GPR. */ 533 enum insn_code reload_vsx_gpr; /* INSN to move from VSX to GPR. */
519 enum insn_code fusion_gpr_ld; /* INSN for fusing gpr ADDIS/loads. */
520 /* INSNs for fusing addi with loads
521 or stores for each reg. class. */
522 enum insn_code fusion_addi_ld[(int)N_RELOAD_REG];
523 enum insn_code fusion_addi_st[(int)N_RELOAD_REG];
524 /* INSNs for fusing addis with loads
525 or stores for each reg. class. */
526 enum insn_code fusion_addis_ld[(int)N_RELOAD_REG];
527 enum insn_code fusion_addis_st[(int)N_RELOAD_REG];
528 addr_mask_type addr_mask[(int)N_RELOAD_REG]; /* Valid address masks. */ 534 addr_mask_type addr_mask[(int)N_RELOAD_REG]; /* Valid address masks. */
529 bool scalar_in_vmx_p; /* Scalar value can go in VMX. */ 535 bool scalar_in_vmx_p; /* Scalar value can go in VMX. */
530 bool fused_toc; /* Mode supports TOC fusion. */
531 }; 536 };
532 537
533 static struct rs6000_reg_addr reg_addr[NUM_MACHINE_MODES]; 538 static struct rs6000_reg_addr reg_addr[NUM_MACHINE_MODES];
534 539
535 /* Helper function to say whether a mode supports PRE_INC or PRE_DEC. */ 540 /* Helper function to say whether a mode supports PRE_INC or PRE_DEC. */
543 /* Helper function to say whether a mode supports PRE_MODIFY. */ 548 /* Helper function to say whether a mode supports PRE_MODIFY. */
544 static inline bool 549 static inline bool
545 mode_supports_pre_modify_p (machine_mode mode) 550 mode_supports_pre_modify_p (machine_mode mode)
546 { 551 {
547 return ((reg_addr[mode].addr_mask[RELOAD_REG_ANY] & RELOAD_REG_PRE_MODIFY) 552 return ((reg_addr[mode].addr_mask[RELOAD_REG_ANY] & RELOAD_REG_PRE_MODIFY)
553 != 0);
554 }
555
556 /* Return true if we have D-form addressing in altivec registers. */
557 static inline bool
558 mode_supports_vmx_dform (machine_mode mode)
559 {
560 return ((reg_addr[mode].addr_mask[RELOAD_REG_VMX] & RELOAD_REG_OFFSET) != 0);
561 }
562
563 /* Return true if we have D-form addressing in VSX registers. This addressing
564 is more limited than normal d-form addressing in that the offset must be
565 aligned on a 16-byte boundary. */
566 static inline bool
567 mode_supports_dq_form (machine_mode mode)
568 {
569 return ((reg_addr[mode].addr_mask[RELOAD_REG_ANY] & RELOAD_REG_QUAD_OFFSET)
548 != 0); 570 != 0);
549 } 571 }
550 572
551 /* Given that there exists at least one variable that is set (produced) 573 /* Given that there exists at least one variable that is set (produced)
552 by OUT_INSN and read (consumed) by IN_INSN, return true iff 574 by OUT_INSN and read (consumed) by IN_INSN, return true iff
629 } 651 }
630 } 652 }
631 } 653 }
632 } 654 }
633 return store_data_bypass_p (out_insn, in_insn); 655 return store_data_bypass_p (out_insn, in_insn);
634 }
635
636 /* Return true if we have D-form addressing in altivec registers. */
637 static inline bool
638 mode_supports_vmx_dform (machine_mode mode)
639 {
640 return ((reg_addr[mode].addr_mask[RELOAD_REG_VMX] & RELOAD_REG_OFFSET) != 0);
641 }
642
643 /* Return true if we have D-form addressing in VSX registers. This addressing
644 is more limited than normal d-form addressing in that the offset must be
645 aligned on a 16-byte boundary. */
646 static inline bool
647 mode_supports_vsx_dform_quad (machine_mode mode)
648 {
649 return ((reg_addr[mode].addr_mask[RELOAD_REG_ANY] & RELOAD_REG_QUAD_OFFSET)
650 != 0);
651 } 656 }
652 657
653 658
654 /* Processor costs (relative to an add) */ 659 /* Processor costs (relative to an add) */
655 660
1264 #undef RS6000_BUILTIN_3 1269 #undef RS6000_BUILTIN_3
1265 #undef RS6000_BUILTIN_A 1270 #undef RS6000_BUILTIN_A
1266 #undef RS6000_BUILTIN_D 1271 #undef RS6000_BUILTIN_D
1267 #undef RS6000_BUILTIN_H 1272 #undef RS6000_BUILTIN_H
1268 #undef RS6000_BUILTIN_P 1273 #undef RS6000_BUILTIN_P
1269 #undef RS6000_BUILTIN_Q
1270 #undef RS6000_BUILTIN_X 1274 #undef RS6000_BUILTIN_X
1271 1275
1272 #define RS6000_BUILTIN_0(ENUM, NAME, MASK, ATTR, ICODE) \ 1276 #define RS6000_BUILTIN_0(ENUM, NAME, MASK, ATTR, ICODE) \
1273 { NAME, ICODE, MASK, ATTR }, 1277 { NAME, ICODE, MASK, ATTR },
1274 1278
1289 1293
1290 #define RS6000_BUILTIN_H(ENUM, NAME, MASK, ATTR, ICODE) \ 1294 #define RS6000_BUILTIN_H(ENUM, NAME, MASK, ATTR, ICODE) \
1291 { NAME, ICODE, MASK, ATTR }, 1295 { NAME, ICODE, MASK, ATTR },
1292 1296
1293 #define RS6000_BUILTIN_P(ENUM, NAME, MASK, ATTR, ICODE) \ 1297 #define RS6000_BUILTIN_P(ENUM, NAME, MASK, ATTR, ICODE) \
1294 { NAME, ICODE, MASK, ATTR },
1295
1296 #define RS6000_BUILTIN_Q(ENUM, NAME, MASK, ATTR, ICODE) \
1297 { NAME, ICODE, MASK, ATTR }, 1298 { NAME, ICODE, MASK, ATTR },
1298 1299
1299 #define RS6000_BUILTIN_X(ENUM, NAME, MASK, ATTR, ICODE) \ 1300 #define RS6000_BUILTIN_X(ENUM, NAME, MASK, ATTR, ICODE) \
1300 { NAME, ICODE, MASK, ATTR }, 1301 { NAME, ICODE, MASK, ATTR },
1301 1302
1317 #undef RS6000_BUILTIN_3 1318 #undef RS6000_BUILTIN_3
1318 #undef RS6000_BUILTIN_A 1319 #undef RS6000_BUILTIN_A
1319 #undef RS6000_BUILTIN_D 1320 #undef RS6000_BUILTIN_D
1320 #undef RS6000_BUILTIN_H 1321 #undef RS6000_BUILTIN_H
1321 #undef RS6000_BUILTIN_P 1322 #undef RS6000_BUILTIN_P
1322 #undef RS6000_BUILTIN_Q
1323 #undef RS6000_BUILTIN_X 1323 #undef RS6000_BUILTIN_X
1324 1324
1325 /* Support for -mveclibabi=<xxx> to control which vector library to use. */ 1325 /* Support for -mveclibabi=<xxx> to control which vector library to use. */
1326 static tree (*rs6000_veclib_handler) (combined_fn, tree, tree); 1326 static tree (*rs6000_veclib_handler) (combined_fn, tree, tree);
1327 1327
1352 static void altivec_init_builtins (void); 1352 static void altivec_init_builtins (void);
1353 static tree builtin_function_type (machine_mode, machine_mode, 1353 static tree builtin_function_type (machine_mode, machine_mode,
1354 machine_mode, machine_mode, 1354 machine_mode, machine_mode,
1355 enum rs6000_builtins, const char *name); 1355 enum rs6000_builtins, const char *name);
1356 static void rs6000_common_init_builtins (void); 1356 static void rs6000_common_init_builtins (void);
1357 static void paired_init_builtins (void);
1358 static rtx paired_expand_predicate_builtin (enum insn_code, tree, rtx);
1359 static void htm_init_builtins (void); 1357 static void htm_init_builtins (void);
1360 static int rs6000_emit_int_cmove (rtx, rtx, rtx, rtx);
1361 static rs6000_stack_t *rs6000_stack_info (void); 1358 static rs6000_stack_t *rs6000_stack_info (void);
1362 static void is_altivec_return_reg (rtx, void *); 1359 static void is_altivec_return_reg (rtx, void *);
1363 int easy_vector_constant (rtx, machine_mode); 1360 int easy_vector_constant (rtx, machine_mode);
1364 static rtx rs6000_debug_legitimize_address (rtx, rtx, machine_mode); 1361 static rtx rs6000_debug_legitimize_address (rtx, rtx, machine_mode);
1365 static rtx rs6000_legitimize_tls_address (rtx, enum tls_model); 1362 static rtx rs6000_legitimize_tls_address (rtx, enum tls_model);
1372 int, int *); 1369 int, int *);
1373 static rtx rs6000_debug_legitimize_reload_address (rtx, machine_mode, int, 1370 static rtx rs6000_debug_legitimize_reload_address (rtx, machine_mode, int,
1374 int, int, int *); 1371 int, int, int *);
1375 static bool rs6000_mode_dependent_address (const_rtx); 1372 static bool rs6000_mode_dependent_address (const_rtx);
1376 static bool rs6000_debug_mode_dependent_address (const_rtx); 1373 static bool rs6000_debug_mode_dependent_address (const_rtx);
1374 static bool rs6000_offsettable_memref_p (rtx, machine_mode, bool);
1377 static enum reg_class rs6000_secondary_reload_class (enum reg_class, 1375 static enum reg_class rs6000_secondary_reload_class (enum reg_class,
1378 machine_mode, rtx); 1376 machine_mode, rtx);
1379 static enum reg_class rs6000_debug_secondary_reload_class (enum reg_class, 1377 static enum reg_class rs6000_debug_secondary_reload_class (enum reg_class,
1380 machine_mode, 1378 machine_mode,
1381 rtx); 1379 rtx);
1515 1513
1516 /* Table of valid machine attributes. */ 1514 /* Table of valid machine attributes. */
1517 1515
1518 static const struct attribute_spec rs6000_attribute_table[] = 1516 static const struct attribute_spec rs6000_attribute_table[] =
1519 { 1517 {
1520 /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler, 1518 /* { name, min_len, max_len, decl_req, type_req, fn_type_req,
1521 affects_type_identity } */ 1519 affects_type_identity, handler, exclude } */
1522 { "altivec", 1, 1, false, true, false, rs6000_handle_altivec_attribute, 1520 { "altivec", 1, 1, false, true, false, false,
1523 false }, 1521 rs6000_handle_altivec_attribute, NULL },
1524 { "longcall", 0, 0, false, true, true, rs6000_handle_longcall_attribute, 1522 { "longcall", 0, 0, false, true, true, false,
1525 false }, 1523 rs6000_handle_longcall_attribute, NULL },
1526 { "shortcall", 0, 0, false, true, true, rs6000_handle_longcall_attribute, 1524 { "shortcall", 0, 0, false, true, true, false,
1527 false }, 1525 rs6000_handle_longcall_attribute, NULL },
1528 { "ms_struct", 0, 0, false, false, false, rs6000_handle_struct_attribute, 1526 { "ms_struct", 0, 0, false, false, false, false,
1529 false }, 1527 rs6000_handle_struct_attribute, NULL },
1530 { "gcc_struct", 0, 0, false, false, false, rs6000_handle_struct_attribute, 1528 { "gcc_struct", 0, 0, false, false, false, false,
1531 false }, 1529 rs6000_handle_struct_attribute, NULL },
1532 #ifdef SUBTARGET_ATTRIBUTE_TABLE 1530 #ifdef SUBTARGET_ATTRIBUTE_TABLE
1533 SUBTARGET_ATTRIBUTE_TABLE, 1531 SUBTARGET_ATTRIBUTE_TABLE,
1534 #endif 1532 #endif
1535 { NULL, 0, 0, false, false, false, NULL, false } 1533 { NULL, 0, 0, false, false, false, false, NULL, NULL }
1536 }; 1534 };
1537 1535
1538 #ifndef TARGET_PROFILE_KERNEL 1536 #ifndef TARGET_PROFILE_KERNEL
1539 #define TARGET_PROFILE_KERNEL 0 1537 #define TARGET_PROFILE_KERNEL 0
1540 #endif 1538 #endif
1792 #define TARGET_GIMPLIFY_VA_ARG_EXPR rs6000_gimplify_va_arg 1790 #define TARGET_GIMPLIFY_VA_ARG_EXPR rs6000_gimplify_va_arg
1793 1791
1794 #undef TARGET_EH_RETURN_FILTER_MODE 1792 #undef TARGET_EH_RETURN_FILTER_MODE
1795 #define TARGET_EH_RETURN_FILTER_MODE rs6000_eh_return_filter_mode 1793 #define TARGET_EH_RETURN_FILTER_MODE rs6000_eh_return_filter_mode
1796 1794
1795 #undef TARGET_TRANSLATE_MODE_ATTRIBUTE
1796 #define TARGET_TRANSLATE_MODE_ATTRIBUTE rs6000_translate_mode_attribute
1797
1797 #undef TARGET_SCALAR_MODE_SUPPORTED_P 1798 #undef TARGET_SCALAR_MODE_SUPPORTED_P
1798 #define TARGET_SCALAR_MODE_SUPPORTED_P rs6000_scalar_mode_supported_p 1799 #define TARGET_SCALAR_MODE_SUPPORTED_P rs6000_scalar_mode_supported_p
1799 1800
1800 #undef TARGET_VECTOR_MODE_SUPPORTED_P 1801 #undef TARGET_VECTOR_MODE_SUPPORTED_P
1801 #define TARGET_VECTOR_MODE_SUPPORTED_P rs6000_vector_mode_supported_p 1802 #define TARGET_VECTOR_MODE_SUPPORTED_P rs6000_vector_mode_supported_p
1803 #undef TARGET_FLOATN_MODE 1804 #undef TARGET_FLOATN_MODE
1804 #define TARGET_FLOATN_MODE rs6000_floatn_mode 1805 #define TARGET_FLOATN_MODE rs6000_floatn_mode
1805 1806
1806 #undef TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN 1807 #undef TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN
1807 #define TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN invalid_arg_for_unprototyped_fn 1808 #define TARGET_INVALID_ARG_FOR_UNPROTOTYPED_FN invalid_arg_for_unprototyped_fn
1808
1809 #undef TARGET_ASM_LOOP_ALIGN_MAX_SKIP
1810 #define TARGET_ASM_LOOP_ALIGN_MAX_SKIP rs6000_loop_align_max_skip
1811 1809
1812 #undef TARGET_MD_ASM_ADJUST 1810 #undef TARGET_MD_ASM_ADJUST
1813 #define TARGET_MD_ASM_ADJUST rs6000_md_asm_adjust 1811 #define TARGET_MD_ASM_ADJUST rs6000_md_asm_adjust
1814 1812
1815 #undef TARGET_OPTION_OVERRIDE 1813 #undef TARGET_OPTION_OVERRIDE
1905 #define TARGET_SET_CURRENT_FUNCTION rs6000_set_current_function 1903 #define TARGET_SET_CURRENT_FUNCTION rs6000_set_current_function
1906 1904
1907 #undef TARGET_LEGITIMATE_CONSTANT_P 1905 #undef TARGET_LEGITIMATE_CONSTANT_P
1908 #define TARGET_LEGITIMATE_CONSTANT_P rs6000_legitimate_constant_p 1906 #define TARGET_LEGITIMATE_CONSTANT_P rs6000_legitimate_constant_p
1909 1907
1910 #undef TARGET_VECTORIZE_VEC_PERM_CONST_OK 1908 #undef TARGET_VECTORIZE_VEC_PERM_CONST
1911 #define TARGET_VECTORIZE_VEC_PERM_CONST_OK rs6000_vectorize_vec_perm_const_ok 1909 #define TARGET_VECTORIZE_VEC_PERM_CONST rs6000_vectorize_vec_perm_const
1912 1910
1913 #undef TARGET_CAN_USE_DOLOOP_P 1911 #undef TARGET_CAN_USE_DOLOOP_P
1914 #define TARGET_CAN_USE_DOLOOP_P can_use_doloop_if_innermost 1912 #define TARGET_CAN_USE_DOLOOP_P can_use_doloop_if_innermost
1915 1913
1916 #undef TARGET_ATOMIC_ASSIGN_EXPAND_FENV 1914 #undef TARGET_ATOMIC_ASSIGN_EXPAND_FENV
1973 #undef TARGET_CONSTANT_ALIGNMENT 1971 #undef TARGET_CONSTANT_ALIGNMENT
1974 #define TARGET_CONSTANT_ALIGNMENT rs6000_constant_alignment 1972 #define TARGET_CONSTANT_ALIGNMENT rs6000_constant_alignment
1975 1973
1976 #undef TARGET_STARTING_FRAME_OFFSET 1974 #undef TARGET_STARTING_FRAME_OFFSET
1977 #define TARGET_STARTING_FRAME_OFFSET rs6000_starting_frame_offset 1975 #define TARGET_STARTING_FRAME_OFFSET rs6000_starting_frame_offset
1976
1977 #if TARGET_ELF && RS6000_WEAK
1978 #undef TARGET_ASM_GLOBALIZE_DECL_NAME
1979 #define TARGET_ASM_GLOBALIZE_DECL_NAME rs6000_globalize_decl_name
1980 #endif
1981
1982 #undef TARGET_SETJMP_PRESERVES_NONVOLATILE_REGS_P
1983 #define TARGET_SETJMP_PRESERVES_NONVOLATILE_REGS_P hook_bool_void_true
1984
1985 #undef TARGET_MANGLE_DECL_ASSEMBLER_NAME
1986 #define TARGET_MANGLE_DECL_ASSEMBLER_NAME rs6000_mangle_decl_assembler_name
1978 1987
1979 1988
1980 /* Processor table. */ 1989 /* Processor table. */
1981 struct rs6000_ptt 1990 struct rs6000_ptt
1982 { 1991 {
2110 2119
2111 if (TARGET_P9_VECTOR && (mode == QImode || mode == HImode)) 2120 if (TARGET_P9_VECTOR && (mode == QImode || mode == HImode))
2112 return 1; 2121 return 1;
2113 } 2122 }
2114 2123
2115 if (PAIRED_SIMD_REGNO_P (regno) && TARGET_PAIRED_FLOAT
2116 && PAIRED_VECTOR_MODE (mode))
2117 return 1;
2118
2119 return 0; 2124 return 0;
2120 } 2125 }
2121 2126
2122 /* The CR register can only hold CC modes. */ 2127 /* The CR register can only hold CC modes. */
2123 if (CR_REGNO_P (regno)) 2128 if (CR_REGNO_P (regno))
2181 return false; 2186 return false;
2182 2187
2183 if (GET_MODE_CLASS (mode1) == MODE_CC) 2188 if (GET_MODE_CLASS (mode1) == MODE_CC)
2184 return GET_MODE_CLASS (mode2) == MODE_CC; 2189 return GET_MODE_CLASS (mode2) == MODE_CC;
2185 if (GET_MODE_CLASS (mode2) == MODE_CC) 2190 if (GET_MODE_CLASS (mode2) == MODE_CC)
2186 return false;
2187
2188 if (PAIRED_VECTOR_MODE (mode1))
2189 return PAIRED_VECTOR_MODE (mode2);
2190 if (PAIRED_VECTOR_MODE (mode2))
2191 return false; 2191 return false;
2192 2192
2193 return true; 2193 return true;
2194 } 2194 }
2195 2195
2304 { 2304 {
2305 case VECTOR_NONE: ret = "none"; break; 2305 case VECTOR_NONE: ret = "none"; break;
2306 case VECTOR_ALTIVEC: ret = "altivec"; break; 2306 case VECTOR_ALTIVEC: ret = "altivec"; break;
2307 case VECTOR_VSX: ret = "vsx"; break; 2307 case VECTOR_VSX: ret = "vsx"; break;
2308 case VECTOR_P8_VECTOR: ret = "p8_vector"; break; 2308 case VECTOR_P8_VECTOR: ret = "p8_vector"; break;
2309 case VECTOR_PAIRED: ret = "paired"; break;
2310 case VECTOR_OTHER: ret = "other"; break;
2311 default: ret = "unknown"; break; 2309 default: ret = "unknown"; break;
2312 } 2310 }
2313 2311
2314 return ret; 2312 return ret;
2315 } 2313 }
2368 DEBUG_FUNCTION void 2366 DEBUG_FUNCTION void
2369 rs6000_debug_print_mode (ssize_t m) 2367 rs6000_debug_print_mode (ssize_t m)
2370 { 2368 {
2371 ssize_t rc; 2369 ssize_t rc;
2372 int spaces = 0; 2370 int spaces = 0;
2373 bool fuse_extra_p;
2374 2371
2375 fprintf (stderr, "Mode: %-5s", GET_MODE_NAME (m)); 2372 fprintf (stderr, "Mode: %-5s", GET_MODE_NAME (m));
2376 for (rc = 0; rc < N_RELOAD_REG; rc++) 2373 for (rc = 0; rc < N_RELOAD_REG; rc++)
2377 fprintf (stderr, " %s: %s", reload_reg_map[rc].name, 2374 fprintf (stderr, " %s: %s", reload_reg_map[rc].name,
2378 rs6000_debug_addr_mask (reg_addr[m].addr_mask[rc], true)); 2375 rs6000_debug_addr_mask (reg_addr[m].addr_mask[rc], true));
2379 2376
2380 if ((reg_addr[m].reload_store != CODE_FOR_nothing) 2377 if ((reg_addr[m].reload_store != CODE_FOR_nothing)
2381 || (reg_addr[m].reload_load != CODE_FOR_nothing)) 2378 || (reg_addr[m].reload_load != CODE_FOR_nothing))
2382 fprintf (stderr, " Reload=%c%c", 2379 {
2383 (reg_addr[m].reload_store != CODE_FOR_nothing) ? 's' : '*', 2380 fprintf (stderr, "%*s Reload=%c%c", spaces, "",
2384 (reg_addr[m].reload_load != CODE_FOR_nothing) ? 'l' : '*'); 2381 (reg_addr[m].reload_store != CODE_FOR_nothing) ? 's' : '*',
2382 (reg_addr[m].reload_load != CODE_FOR_nothing) ? 'l' : '*');
2383 spaces = 0;
2384 }
2385 else 2385 else
2386 spaces += sizeof (" Reload=sl") - 1; 2386 spaces += sizeof (" Reload=sl") - 1;
2387 2387
2388 if (reg_addr[m].scalar_in_vmx_p) 2388 if (reg_addr[m].scalar_in_vmx_p)
2389 { 2389 {
2390 fprintf (stderr, "%*s Upper=y", spaces, ""); 2390 fprintf (stderr, "%*s Upper=y", spaces, "");
2391 spaces = 0; 2391 spaces = 0;
2392 } 2392 }
2393 else 2393 else
2394 spaces += sizeof (" Upper=y") - 1; 2394 spaces += sizeof (" Upper=y") - 1;
2395
2396 fuse_extra_p = ((reg_addr[m].fusion_gpr_ld != CODE_FOR_nothing)
2397 || reg_addr[m].fused_toc);
2398 if (!fuse_extra_p)
2399 {
2400 for (rc = 0; rc < N_RELOAD_REG; rc++)
2401 {
2402 if (rc != RELOAD_REG_ANY)
2403 {
2404 if (reg_addr[m].fusion_addi_ld[rc] != CODE_FOR_nothing
2405 || reg_addr[m].fusion_addi_ld[rc] != CODE_FOR_nothing
2406 || reg_addr[m].fusion_addi_st[rc] != CODE_FOR_nothing
2407 || reg_addr[m].fusion_addis_ld[rc] != CODE_FOR_nothing
2408 || reg_addr[m].fusion_addis_st[rc] != CODE_FOR_nothing)
2409 {
2410 fuse_extra_p = true;
2411 break;
2412 }
2413 }
2414 }
2415 }
2416
2417 if (fuse_extra_p)
2418 {
2419 fprintf (stderr, "%*s Fuse:", spaces, "");
2420 spaces = 0;
2421
2422 for (rc = 0; rc < N_RELOAD_REG; rc++)
2423 {
2424 if (rc != RELOAD_REG_ANY)
2425 {
2426 char load, store;
2427
2428 if (reg_addr[m].fusion_addis_ld[rc] != CODE_FOR_nothing)
2429 load = 'l';
2430 else if (reg_addr[m].fusion_addi_ld[rc] != CODE_FOR_nothing)
2431 load = 'L';
2432 else
2433 load = '-';
2434
2435 if (reg_addr[m].fusion_addis_st[rc] != CODE_FOR_nothing)
2436 store = 's';
2437 else if (reg_addr[m].fusion_addi_st[rc] != CODE_FOR_nothing)
2438 store = 'S';
2439 else
2440 store = '-';
2441
2442 if (load == '-' && store == '-')
2443 spaces += 5;
2444 else
2445 {
2446 fprintf (stderr, "%*s%c=%c%c", (spaces + 1), "",
2447 reload_reg_map[rc].name[0], load, store);
2448 spaces = 0;
2449 }
2450 }
2451 }
2452
2453 if (reg_addr[m].fusion_gpr_ld != CODE_FOR_nothing)
2454 {
2455 fprintf (stderr, "%*sP8gpr", (spaces + 1), "");
2456 spaces = 0;
2457 }
2458 else
2459 spaces += sizeof (" P8gpr") - 1;
2460
2461 if (reg_addr[m].fused_toc)
2462 {
2463 fprintf (stderr, "%*sToc", (spaces + 1), "");
2464 spaces = 0;
2465 }
2466 else
2467 spaces += sizeof (" Toc") - 1;
2468 }
2469 else
2470 spaces += sizeof (" Fuse: G=ls F=ls v=ls P8gpr Toc") - 1;
2471 2395
2472 if (rs6000_vector_unit[m] != VECTOR_NONE 2396 if (rs6000_vector_unit[m] != VECTOR_NONE
2473 || rs6000_vector_mem[m] != VECTOR_NONE) 2397 || rs6000_vector_mem[m] != VECTOR_NONE)
2474 { 2398 {
2475 fprintf (stderr, "%*s vector: arith=%-10s mem=%s", 2399 fprintf (stderr, "%*s vector: arith=%-10s mem=%s",
2518 IFmode, 2442 IFmode,
2519 KFmode, 2443 KFmode,
2520 SDmode, 2444 SDmode,
2521 DDmode, 2445 DDmode,
2522 TDmode, 2446 TDmode,
2523 V2SImode,
2524 V16QImode, 2447 V16QImode,
2525 V8HImode, 2448 V8HImode,
2526 V4SImode, 2449 V4SImode,
2527 V2DImode, 2450 V2DImode,
2528 V1TImode, 2451 V1TImode,
2529 V32QImode, 2452 V32QImode,
2530 V16HImode, 2453 V16HImode,
2531 V8SImode, 2454 V8SImode,
2532 V4DImode, 2455 V4DImode,
2533 V2TImode, 2456 V2TImode,
2534 V2SFmode,
2535 V4SFmode, 2457 V4SFmode,
2536 V2DFmode, 2458 V2DFmode,
2537 V8SFmode, 2459 V8SFmode,
2538 V4DFmode, 2460 V4DFmode,
2539 CCmode, 2461 CCmode,
2853 fprintf (stderr, DEBUG_FMT_S, "altivec_abi", "true"); 2775 fprintf (stderr, DEBUG_FMT_S, "altivec_abi", "true");
2854 2776
2855 if (rs6000_darwin64_abi) 2777 if (rs6000_darwin64_abi)
2856 fprintf (stderr, DEBUG_FMT_S, "darwin64_abi", "true"); 2778 fprintf (stderr, DEBUG_FMT_S, "darwin64_abi", "true");
2857 2779
2858 fprintf (stderr, DEBUG_FMT_S, "single_float",
2859 (TARGET_SINGLE_FLOAT ? "true" : "false"));
2860
2861 fprintf (stderr, DEBUG_FMT_S, "double_float",
2862 (TARGET_DOUBLE_FLOAT ? "true" : "false"));
2863
2864 fprintf (stderr, DEBUG_FMT_S, "soft_float", 2780 fprintf (stderr, DEBUG_FMT_S, "soft_float",
2865 (TARGET_SOFT_FLOAT ? "true" : "false")); 2781 (TARGET_SOFT_FLOAT ? "true" : "false"));
2866 2782
2867 if (TARGET_LINK_STACK) 2783 if (TARGET_LINK_STACK)
2868 fprintf (stderr, DEBUG_FMT_S, "link_stack", "true"); 2784 fprintf (stderr, DEBUG_FMT_S, "link_stack", "true");
2870 if (TARGET_P8_FUSION) 2786 if (TARGET_P8_FUSION)
2871 { 2787 {
2872 char options[80]; 2788 char options[80];
2873 2789
2874 strcpy (options, (TARGET_P9_FUSION) ? "power9" : "power8"); 2790 strcpy (options, (TARGET_P9_FUSION) ? "power9" : "power8");
2875 if (TARGET_TOC_FUSION)
2876 strcat (options, ", toc");
2877
2878 if (TARGET_P8_FUSION_SIGN) 2791 if (TARGET_P8_FUSION_SIGN)
2879 strcat (options, ", sign"); 2792 strcat (options, ", sign");
2880 2793
2881 fprintf (stderr, DEBUG_FMT_S, "fusion", options); 2794 fprintf (stderr, DEBUG_FMT_S, "fusion", options);
2882 } 2795 }
2890 fprintf (stderr, DEBUG_FMT_S, "align_branch", 2803 fprintf (stderr, DEBUG_FMT_S, "align_branch",
2891 tf[!!rs6000_align_branch_targets]); 2804 tf[!!rs6000_align_branch_targets]);
2892 fprintf (stderr, DEBUG_FMT_D, "tls_size", rs6000_tls_size); 2805 fprintf (stderr, DEBUG_FMT_D, "tls_size", rs6000_tls_size);
2893 fprintf (stderr, DEBUG_FMT_D, "long_double_size", 2806 fprintf (stderr, DEBUG_FMT_D, "long_double_size",
2894 rs6000_long_double_type_size); 2807 rs6000_long_double_type_size);
2895 if (rs6000_long_double_type_size == 128) 2808 if (rs6000_long_double_type_size > 64)
2896 { 2809 {
2897 fprintf (stderr, DEBUG_FMT_S, "long double type", 2810 fprintf (stderr, DEBUG_FMT_S, "long double type",
2898 TARGET_IEEEQUAD ? "IEEE" : "IBM"); 2811 TARGET_IEEEQUAD ? "IEEE" : "IBM");
2899 fprintf (stderr, DEBUG_FMT_S, "default long double type", 2812 fprintf (stderr, DEBUG_FMT_S, "default long double type",
2900 TARGET_IEEEQUAD_DEFAULT ? "IEEE" : "IBM"); 2813 TARGET_IEEEQUAD_DEFAULT ? "IEEE" : "IBM");
2976 else 2889 else
2977 addr_mask |= RELOAD_REG_INDEXED; 2890 addr_mask |= RELOAD_REG_INDEXED;
2978 2891
2979 /* Figure out if we can do PRE_INC, PRE_DEC, or PRE_MODIFY 2892 /* Figure out if we can do PRE_INC, PRE_DEC, or PRE_MODIFY
2980 addressing. If we allow scalars into Altivec registers, 2893 addressing. If we allow scalars into Altivec registers,
2981 don't allow PRE_INC, PRE_DEC, or PRE_MODIFY. */ 2894 don't allow PRE_INC, PRE_DEC, or PRE_MODIFY.
2895
2896 For VSX systems, we don't allow update addressing for
2897 DFmode/SFmode if those registers can go in both the
2898 traditional floating point registers and Altivec registers.
2899 The load/store instructions for the Altivec registers do not
2900 have update forms. If we allowed update addressing, it seems
2901 to break IV-OPT code using floating point if the index type is
2902 int instead of long (PR target/81550 and target/84042). */
2982 2903
2983 if (TARGET_UPDATE 2904 if (TARGET_UPDATE
2984 && (rc == RELOAD_REG_GPR || rc == RELOAD_REG_FPR) 2905 && (rc == RELOAD_REG_GPR || rc == RELOAD_REG_FPR)
2985 && msize <= 8 2906 && msize <= 8
2986 && !VECTOR_MODE_P (m2) 2907 && !VECTOR_MODE_P (m2)
2987 && !FLOAT128_VECTOR_P (m2) 2908 && !FLOAT128_VECTOR_P (m2)
2988 && !complex_p 2909 && !complex_p
2910 && (m != E_DFmode || !TARGET_VSX)
2911 && (m != E_SFmode || !TARGET_P8_VECTOR)
2989 && !small_int_vsx_p) 2912 && !small_int_vsx_p)
2990 { 2913 {
2991 addr_mask |= RELOAD_REG_PRE_INCDEC; 2914 addr_mask |= RELOAD_REG_PRE_INCDEC;
2992 2915
2993 /* PRE_MODIFY is more restricted than PRE_INC/PRE_DEC in that 2916 /* PRE_MODIFY is more restricted than PRE_INC/PRE_DEC in that
3004 addr_mask |= RELOAD_REG_PRE_MODIFY; 2927 addr_mask |= RELOAD_REG_PRE_MODIFY;
3005 break; 2928 break;
3006 2929
3007 case E_DFmode: 2930 case E_DFmode:
3008 case E_DDmode: 2931 case E_DDmode:
3009 if (TARGET_DF_INSN) 2932 if (TARGET_HARD_FLOAT)
3010 addr_mask |= RELOAD_REG_PRE_MODIFY; 2933 addr_mask |= RELOAD_REG_PRE_MODIFY;
3011 break; 2934 break;
3012 } 2935 }
3013 } 2936 }
3014 } 2937 }
3239 if (TARGET_VSX) 3162 if (TARGET_VSX)
3240 { 3163 {
3241 rs6000_vector_mem[TImode] = VECTOR_VSX; 3164 rs6000_vector_mem[TImode] = VECTOR_VSX;
3242 rs6000_vector_align[TImode] = align64; 3165 rs6000_vector_align[TImode] = align64;
3243 } 3166 }
3244
3245 /* TODO add paired floating point vector support. */
3246 3167
3247 /* Register class constraints for the constraints that depend on compile 3168 /* Register class constraints for the constraints that depend on compile
3248 switches. When the VSX code was added, different constraints were added 3169 switches. When the VSX code was added, different constraints were added
3249 based on the type (DFmode, V2DFmode, V4SFmode). For the vector types, all 3170 based on the type (DFmode, V2DFmode, V4SFmode). For the vector types, all
3250 of the VSX registers are used. The register classes for scalar floating 3171 of the VSX registers are used. The register classes for scalar floating
3282 wI - VSX register if SImode is allowed in VSX registers. 3203 wI - VSX register if SImode is allowed in VSX registers.
3283 wJ - VSX register if QImode/HImode are allowed in VSX registers. 3204 wJ - VSX register if QImode/HImode are allowed in VSX registers.
3284 wK - Altivec register if QImode/HImode are allowed in VSX registers. */ 3205 wK - Altivec register if QImode/HImode are allowed in VSX registers. */
3285 3206
3286 if (TARGET_HARD_FLOAT) 3207 if (TARGET_HARD_FLOAT)
3287 rs6000_constraints[RS6000_CONSTRAINT_f] = FLOAT_REGS; /* SFmode */ 3208 {
3288 3209 rs6000_constraints[RS6000_CONSTRAINT_f] = FLOAT_REGS; /* SFmode */
3289 if (TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT) 3210 rs6000_constraints[RS6000_CONSTRAINT_d] = FLOAT_REGS; /* DFmode */
3290 rs6000_constraints[RS6000_CONSTRAINT_d] = FLOAT_REGS; /* DFmode */ 3211 }
3291 3212
3292 if (TARGET_VSX) 3213 if (TARGET_VSX)
3293 { 3214 {
3294 rs6000_constraints[RS6000_CONSTRAINT_wa] = VSX_REGS; 3215 rs6000_constraints[RS6000_CONSTRAINT_wa] = VSX_REGS;
3295 rs6000_constraints[RS6000_CONSTRAINT_wd] = VSX_REGS; /* V2DFmode */ 3216 rs6000_constraints[RS6000_CONSTRAINT_wd] = VSX_REGS; /* V2DFmode */
3529 if (TARGET_P9_VECTOR) 3450 if (TARGET_P9_VECTOR)
3530 { 3451 {
3531 reg_addr[HImode].scalar_in_vmx_p = true; 3452 reg_addr[HImode].scalar_in_vmx_p = true;
3532 reg_addr[QImode].scalar_in_vmx_p = true; 3453 reg_addr[QImode].scalar_in_vmx_p = true;
3533 } 3454 }
3534 }
3535 }
3536
3537 /* Setup the fusion operations. */
3538 if (TARGET_P8_FUSION)
3539 {
3540 reg_addr[QImode].fusion_gpr_ld = CODE_FOR_fusion_gpr_load_qi;
3541 reg_addr[HImode].fusion_gpr_ld = CODE_FOR_fusion_gpr_load_hi;
3542 reg_addr[SImode].fusion_gpr_ld = CODE_FOR_fusion_gpr_load_si;
3543 if (TARGET_64BIT)
3544 reg_addr[DImode].fusion_gpr_ld = CODE_FOR_fusion_gpr_load_di;
3545 }
3546
3547 if (TARGET_P9_FUSION)
3548 {
3549 struct fuse_insns {
3550 enum machine_mode mode; /* mode of the fused type. */
3551 enum machine_mode pmode; /* pointer mode. */
3552 enum rs6000_reload_reg_type rtype; /* register type. */
3553 enum insn_code load; /* load insn. */
3554 enum insn_code store; /* store insn. */
3555 };
3556
3557 static const struct fuse_insns addis_insns[] = {
3558 { E_SFmode, E_DImode, RELOAD_REG_FPR,
3559 CODE_FOR_fusion_vsx_di_sf_load,
3560 CODE_FOR_fusion_vsx_di_sf_store },
3561
3562 { E_SFmode, E_SImode, RELOAD_REG_FPR,
3563 CODE_FOR_fusion_vsx_si_sf_load,
3564 CODE_FOR_fusion_vsx_si_sf_store },
3565
3566 { E_DFmode, E_DImode, RELOAD_REG_FPR,
3567 CODE_FOR_fusion_vsx_di_df_load,
3568 CODE_FOR_fusion_vsx_di_df_store },
3569
3570 { E_DFmode, E_SImode, RELOAD_REG_FPR,
3571 CODE_FOR_fusion_vsx_si_df_load,
3572 CODE_FOR_fusion_vsx_si_df_store },
3573
3574 { E_DImode, E_DImode, RELOAD_REG_FPR,
3575 CODE_FOR_fusion_vsx_di_di_load,
3576 CODE_FOR_fusion_vsx_di_di_store },
3577
3578 { E_DImode, E_SImode, RELOAD_REG_FPR,
3579 CODE_FOR_fusion_vsx_si_di_load,
3580 CODE_FOR_fusion_vsx_si_di_store },
3581
3582 { E_QImode, E_DImode, RELOAD_REG_GPR,
3583 CODE_FOR_fusion_gpr_di_qi_load,
3584 CODE_FOR_fusion_gpr_di_qi_store },
3585
3586 { E_QImode, E_SImode, RELOAD_REG_GPR,
3587 CODE_FOR_fusion_gpr_si_qi_load,
3588 CODE_FOR_fusion_gpr_si_qi_store },
3589
3590 { E_HImode, E_DImode, RELOAD_REG_GPR,
3591 CODE_FOR_fusion_gpr_di_hi_load,
3592 CODE_FOR_fusion_gpr_di_hi_store },
3593
3594 { E_HImode, E_SImode, RELOAD_REG_GPR,
3595 CODE_FOR_fusion_gpr_si_hi_load,
3596 CODE_FOR_fusion_gpr_si_hi_store },
3597
3598 { E_SImode, E_DImode, RELOAD_REG_GPR,
3599 CODE_FOR_fusion_gpr_di_si_load,
3600 CODE_FOR_fusion_gpr_di_si_store },
3601
3602 { E_SImode, E_SImode, RELOAD_REG_GPR,
3603 CODE_FOR_fusion_gpr_si_si_load,
3604 CODE_FOR_fusion_gpr_si_si_store },
3605
3606 { E_SFmode, E_DImode, RELOAD_REG_GPR,
3607 CODE_FOR_fusion_gpr_di_sf_load,
3608 CODE_FOR_fusion_gpr_di_sf_store },
3609
3610 { E_SFmode, E_SImode, RELOAD_REG_GPR,
3611 CODE_FOR_fusion_gpr_si_sf_load,
3612 CODE_FOR_fusion_gpr_si_sf_store },
3613
3614 { E_DImode, E_DImode, RELOAD_REG_GPR,
3615 CODE_FOR_fusion_gpr_di_di_load,
3616 CODE_FOR_fusion_gpr_di_di_store },
3617
3618 { E_DFmode, E_DImode, RELOAD_REG_GPR,
3619 CODE_FOR_fusion_gpr_di_df_load,
3620 CODE_FOR_fusion_gpr_di_df_store },
3621 };
3622
3623 machine_mode cur_pmode = Pmode;
3624 size_t i;
3625
3626 for (i = 0; i < ARRAY_SIZE (addis_insns); i++)
3627 {
3628 machine_mode xmode = addis_insns[i].mode;
3629 enum rs6000_reload_reg_type rtype = addis_insns[i].rtype;
3630
3631 if (addis_insns[i].pmode != cur_pmode)
3632 continue;
3633
3634 if (rtype == RELOAD_REG_FPR && !TARGET_HARD_FLOAT)
3635 continue;
3636
3637 reg_addr[xmode].fusion_addis_ld[rtype] = addis_insns[i].load;
3638 reg_addr[xmode].fusion_addis_st[rtype] = addis_insns[i].store;
3639
3640 if (rtype == RELOAD_REG_FPR && TARGET_P9_VECTOR)
3641 {
3642 reg_addr[xmode].fusion_addis_ld[RELOAD_REG_VMX]
3643 = addis_insns[i].load;
3644 reg_addr[xmode].fusion_addis_st[RELOAD_REG_VMX]
3645 = addis_insns[i].store;
3646 }
3647 }
3648 }
3649
3650 /* Note which types we support fusing TOC setup plus memory insn. We only do
3651 fused TOCs for medium/large code models. */
3652 if (TARGET_P8_FUSION && TARGET_TOC_FUSION && TARGET_POWERPC64
3653 && (TARGET_CMODEL != CMODEL_SMALL))
3654 {
3655 reg_addr[QImode].fused_toc = true;
3656 reg_addr[HImode].fused_toc = true;
3657 reg_addr[SImode].fused_toc = true;
3658 reg_addr[DImode].fused_toc = true;
3659 if (TARGET_HARD_FLOAT)
3660 {
3661 if (TARGET_SINGLE_FLOAT)
3662 reg_addr[SFmode].fused_toc = true;
3663 if (TARGET_DOUBLE_FLOAT)
3664 reg_addr[DFmode].fused_toc = true;
3665 } 3455 }
3666 } 3456 }
3667 3457
3668 /* Precalculate HARD_REGNO_NREGS. */ 3458 /* Precalculate HARD_REGNO_NREGS. */
3669 for (r = 0; r < FIRST_PSEUDO_REGISTER; ++r) 3459 for (r = 0; r < FIRST_PSEUDO_REGISTER; ++r)
3879 #define RS6000_DEFAULT_LONG_DOUBLE_SIZE 64 3669 #define RS6000_DEFAULT_LONG_DOUBLE_SIZE 64
3880 #endif 3670 #endif
3881 3671
3882 /* Return the builtin mask of the various options used that could affect which 3672 /* Return the builtin mask of the various options used that could affect which
3883 builtins were used. In the past we used target_flags, but we've run out of 3673 builtins were used. In the past we used target_flags, but we've run out of
3884 bits, and some options like PAIRED are no longer in target_flags. */ 3674 bits, and some options are no longer in target_flags. */
3885 3675
3886 HOST_WIDE_INT 3676 HOST_WIDE_INT
3887 rs6000_builtin_mask_calculate (void) 3677 rs6000_builtin_mask_calculate (void)
3888 { 3678 {
3889 return (((TARGET_ALTIVEC) ? RS6000_BTM_ALTIVEC : 0) 3679 return (((TARGET_ALTIVEC) ? RS6000_BTM_ALTIVEC : 0)
3890 | ((TARGET_CMPB) ? RS6000_BTM_CMPB : 0) 3680 | ((TARGET_CMPB) ? RS6000_BTM_CMPB : 0)
3891 | ((TARGET_VSX) ? RS6000_BTM_VSX : 0) 3681 | ((TARGET_VSX) ? RS6000_BTM_VSX : 0)
3892 | ((TARGET_PAIRED_FLOAT) ? RS6000_BTM_PAIRED : 0)
3893 | ((TARGET_FRE) ? RS6000_BTM_FRE : 0) 3682 | ((TARGET_FRE) ? RS6000_BTM_FRE : 0)
3894 | ((TARGET_FRES) ? RS6000_BTM_FRES : 0) 3683 | ((TARGET_FRES) ? RS6000_BTM_FRES : 0)
3895 | ((TARGET_FRSQRTE) ? RS6000_BTM_FRSQRTE : 0) 3684 | ((TARGET_FRSQRTE) ? RS6000_BTM_FRSQRTE : 0)
3896 | ((TARGET_FRSQRTES) ? RS6000_BTM_FRSQRTES : 0) 3685 | ((TARGET_FRSQRTES) ? RS6000_BTM_FRSQRTES : 0)
3897 | ((TARGET_POPCNTD) ? RS6000_BTM_POPCNTD : 0) 3686 | ((TARGET_POPCNTD) ? RS6000_BTM_POPCNTD : 0)
3899 | ((TARGET_P8_VECTOR) ? RS6000_BTM_P8_VECTOR : 0) 3688 | ((TARGET_P8_VECTOR) ? RS6000_BTM_P8_VECTOR : 0)
3900 | ((TARGET_P9_VECTOR) ? RS6000_BTM_P9_VECTOR : 0) 3689 | ((TARGET_P9_VECTOR) ? RS6000_BTM_P9_VECTOR : 0)
3901 | ((TARGET_P9_MISC) ? RS6000_BTM_P9_MISC : 0) 3690 | ((TARGET_P9_MISC) ? RS6000_BTM_P9_MISC : 0)
3902 | ((TARGET_MODULO) ? RS6000_BTM_MODULO : 0) 3691 | ((TARGET_MODULO) ? RS6000_BTM_MODULO : 0)
3903 | ((TARGET_64BIT) ? RS6000_BTM_64BIT : 0) 3692 | ((TARGET_64BIT) ? RS6000_BTM_64BIT : 0)
3693 | ((TARGET_POWERPC64) ? RS6000_BTM_POWERPC64 : 0)
3904 | ((TARGET_CRYPTO) ? RS6000_BTM_CRYPTO : 0) 3694 | ((TARGET_CRYPTO) ? RS6000_BTM_CRYPTO : 0)
3905 | ((TARGET_HTM) ? RS6000_BTM_HTM : 0) 3695 | ((TARGET_HTM) ? RS6000_BTM_HTM : 0)
3906 | ((TARGET_DFP) ? RS6000_BTM_DFP : 0) 3696 | ((TARGET_DFP) ? RS6000_BTM_DFP : 0)
3907 | ((TARGET_HARD_FLOAT) ? RS6000_BTM_HARD_FLOAT : 0) 3697 | ((TARGET_HARD_FLOAT) ? RS6000_BTM_HARD_FLOAT : 0)
3908 | ((TARGET_LONG_DOUBLE_128) ? RS6000_BTM_LDBL128 : 0) 3698 | ((TARGET_LONG_DOUBLE_128
3699 && TARGET_HARD_FLOAT
3700 && !TARGET_IEEEQUAD) ? RS6000_BTM_LDBL128 : 0)
3909 | ((TARGET_FLOAT128_TYPE) ? RS6000_BTM_FLOAT128 : 0) 3701 | ((TARGET_FLOAT128_TYPE) ? RS6000_BTM_FLOAT128 : 0)
3910 | ((TARGET_FLOAT128_HW) ? RS6000_BTM_FLOAT128_HW : 0)); 3702 | ((TARGET_FLOAT128_HW) ? RS6000_BTM_FLOAT128_HW : 0));
3911 } 3703 }
3912 3704
3913 /* Implement TARGET_MD_ASM_ADJUST. All asm statements are considered 3705 /* Implement TARGET_MD_ASM_ADJUST. All asm statements are considered
4083 else if (main_target_opt != NULL && main_target_opt->x_rs6000_cpu_index >= 0) 3875 else if (main_target_opt != NULL && main_target_opt->x_rs6000_cpu_index >= 0)
4084 cpu_index = main_target_opt->x_rs6000_cpu_index; 3876 cpu_index = main_target_opt->x_rs6000_cpu_index;
4085 else if (OPTION_TARGET_CPU_DEFAULT) 3877 else if (OPTION_TARGET_CPU_DEFAULT)
4086 cpu_index = rs6000_cpu_name_lookup (OPTION_TARGET_CPU_DEFAULT); 3878 cpu_index = rs6000_cpu_name_lookup (OPTION_TARGET_CPU_DEFAULT);
4087 3879
4088 if (cpu_index >= 0)
4089 {
4090 const char *unavailable_cpu = NULL;
4091 switch (processor_target_table[cpu_index].processor)
4092 {
4093 #ifndef HAVE_AS_POWER9
4094 case PROCESSOR_POWER9:
4095 unavailable_cpu = "power9";
4096 break;
4097 #endif
4098 #ifndef HAVE_AS_POWER8
4099 case PROCESSOR_POWER8:
4100 unavailable_cpu = "power8";
4101 break;
4102 #endif
4103 #ifndef HAVE_AS_POPCNTD
4104 case PROCESSOR_POWER7:
4105 unavailable_cpu = "power7";
4106 break;
4107 #endif
4108 #ifndef HAVE_AS_DFP
4109 case PROCESSOR_POWER6:
4110 unavailable_cpu = "power6";
4111 break;
4112 #endif
4113 #ifndef HAVE_AS_POPCNTB
4114 case PROCESSOR_POWER5:
4115 unavailable_cpu = "power5";
4116 break;
4117 #endif
4118 default:
4119 break;
4120 }
4121 if (unavailable_cpu)
4122 {
4123 cpu_index = -1;
4124 warning (0, "will not generate %qs instructions because "
4125 "assembler lacks %qs support", unavailable_cpu,
4126 unavailable_cpu);
4127 }
4128 }
4129
4130 /* If we have a cpu, either through an explicit -mcpu=<xxx> or if the 3880 /* If we have a cpu, either through an explicit -mcpu=<xxx> or if the
4131 compiler was configured with --with-cpu=<xxx>, replace all of the ISA bits 3881 compiler was configured with --with-cpu=<xxx>, replace all of the ISA bits
4132 with those from the cpu, except for options that were explicitly set. If 3882 with those from the cpu, except for options that were explicitly set. If
4133 we don't have a cpu, do not override the target bits set in 3883 we don't have a cpu, do not override the target bits set in
4134 TARGET_DEFAULT. */ 3884 TARGET_DEFAULT. */
4182 tune_index = i; 3932 tune_index = i;
4183 break; 3933 break;
4184 } 3934 }
4185 } 3935 }
4186 3936
3937 if (cpu_index >= 0)
3938 rs6000_cpu = processor_target_table[cpu_index].processor;
3939 else
3940 rs6000_cpu = TARGET_POWERPC64 ? PROCESSOR_DEFAULT64 : PROCESSOR_DEFAULT;
3941
4187 gcc_assert (tune_index >= 0); 3942 gcc_assert (tune_index >= 0);
4188 rs6000_cpu = processor_target_table[tune_index].processor; 3943 rs6000_tune = processor_target_table[tune_index].processor;
4189 3944
4190 if (rs6000_cpu == PROCESSOR_PPCE300C2 || rs6000_cpu == PROCESSOR_PPCE300C3 3945 if (rs6000_cpu == PROCESSOR_PPCE300C2 || rs6000_cpu == PROCESSOR_PPCE300C3
4191 || rs6000_cpu == PROCESSOR_PPCE500MC || rs6000_cpu == PROCESSOR_PPCE500MC64 3946 || rs6000_cpu == PROCESSOR_PPCE500MC || rs6000_cpu == PROCESSOR_PPCE500MC64
4192 || rs6000_cpu == PROCESSOR_PPCE5500) 3947 || rs6000_cpu == PROCESSOR_PPCE5500)
4193 { 3948 {
4194 if (TARGET_ALTIVEC) 3949 if (TARGET_ALTIVEC)
4195 error ("AltiVec not supported in this target"); 3950 error ("AltiVec not supported in this target");
4196 } 3951 }
4197 3952
4198 /* If we are optimizing big endian systems for space, use the load/store 3953 /* If we are optimizing big endian systems for space, use the load/store
4199 multiple and string instructions. */ 3954 multiple instructions. */
4200 if (BYTES_BIG_ENDIAN && optimize_size) 3955 if (BYTES_BIG_ENDIAN && optimize_size)
4201 rs6000_isa_flags |= ~rs6000_isa_flags_explicit & (OPTION_MASK_MULTIPLE 3956 rs6000_isa_flags |= ~rs6000_isa_flags_explicit & OPTION_MASK_MULTIPLE;
4202 | OPTION_MASK_STRING); 3957
4203 3958 /* Don't allow -mmultiple on little endian systems unless the cpu is a 750,
4204 /* Don't allow -mmultiple or -mstring on little endian systems 3959 because the hardware doesn't support the instructions used in little
4205 unless the cpu is a 750, because the hardware doesn't support the 3960 endian mode, and causes an alignment trap. The 750 does not cause an
4206 instructions used in little endian mode, and causes an alignment 3961 alignment trap (except when the target is unaligned). */
4207 trap. The 750 does not cause an alignment trap (except when the 3962
4208 target is unaligned). */ 3963 if (!BYTES_BIG_ENDIAN && rs6000_cpu != PROCESSOR_PPC750 && TARGET_MULTIPLE)
4209 3964 {
4210 if (!BYTES_BIG_ENDIAN && rs6000_cpu != PROCESSOR_PPC750) 3965 rs6000_isa_flags &= ~OPTION_MASK_MULTIPLE;
4211 { 3966 if ((rs6000_isa_flags_explicit & OPTION_MASK_MULTIPLE) != 0)
4212 if (TARGET_MULTIPLE) 3967 warning (0, "%qs is not supported on little endian systems",
4213 { 3968 "-mmultiple");
4214 rs6000_isa_flags &= ~OPTION_MASK_MULTIPLE;
4215 if ((rs6000_isa_flags_explicit & OPTION_MASK_MULTIPLE) != 0)
4216 warning (0, "%qs is not supported on little endian systems",
4217 "-mmultiple");
4218 }
4219
4220 if (TARGET_STRING)
4221 {
4222 rs6000_isa_flags &= ~OPTION_MASK_STRING;
4223 if ((rs6000_isa_flags_explicit & OPTION_MASK_STRING) != 0)
4224 warning (0, "%qs is not supported on little endian systems",
4225 "-mstring");
4226 }
4227 } 3969 }
4228 3970
4229 /* If little-endian, default to -mstrict-align on older processors. 3971 /* If little-endian, default to -mstrict-align on older processors.
4230 Testing for htm matches power8 and later. */ 3972 Testing for htm matches power8 and later. */
4231 if (!BYTES_BIG_ENDIAN 3973 if (!BYTES_BIG_ENDIAN
4232 && !(processor_target_table[tune_index].target_enable & OPTION_MASK_HTM)) 3974 && !(processor_target_table[tune_index].target_enable & OPTION_MASK_HTM))
4233 rs6000_isa_flags |= ~rs6000_isa_flags_explicit & OPTION_MASK_STRICT_ALIGN; 3975 rs6000_isa_flags |= ~rs6000_isa_flags_explicit & OPTION_MASK_STRICT_ALIGN;
4234 3976
4235 /* -maltivec={le,be} implies -maltivec. */
4236 if (rs6000_altivec_element_order != 0)
4237 rs6000_isa_flags |= OPTION_MASK_ALTIVEC;
4238
4239 /* Disallow -maltivec=le in big endian mode for now. This is not
4240 known to be useful for anyone. */
4241 if (BYTES_BIG_ENDIAN && rs6000_altivec_element_order == 1)
4242 {
4243 warning (0, N_("-maltivec=le not allowed for big-endian targets"));
4244 rs6000_altivec_element_order = 0;
4245 }
4246
4247 if (!rs6000_fold_gimple) 3977 if (!rs6000_fold_gimple)
4248 fprintf (stderr, 3978 fprintf (stderr,
4249 "gimple folding of rs6000 builtins has been disabled.\n"); 3979 "gimple folding of rs6000 builtins has been disabled.\n");
4250 3980
4251 /* Add some warnings for VSX. */ 3981 /* Add some warnings for VSX. */
4252 if (TARGET_VSX) 3982 if (TARGET_VSX)
4253 { 3983 {
4254 const char *msg = NULL; 3984 const char *msg = NULL;
4255 if (!TARGET_HARD_FLOAT || !TARGET_SINGLE_FLOAT || !TARGET_DOUBLE_FLOAT) 3985 if (!TARGET_HARD_FLOAT)
4256 { 3986 {
4257 if (rs6000_isa_flags_explicit & OPTION_MASK_VSX) 3987 if (rs6000_isa_flags_explicit & OPTION_MASK_VSX)
4258 msg = N_("-mvsx requires hardware floating point"); 3988 msg = N_("-mvsx requires hardware floating point");
4259 else 3989 else
4260 { 3990 {
4261 rs6000_isa_flags &= ~ OPTION_MASK_VSX; 3991 rs6000_isa_flags &= ~ OPTION_MASK_VSX;
4262 rs6000_isa_flags_explicit |= OPTION_MASK_VSX; 3992 rs6000_isa_flags_explicit |= OPTION_MASK_VSX;
4263 } 3993 }
4264 } 3994 }
4265 else if (TARGET_PAIRED_FLOAT)
4266 msg = N_("-mvsx and -mpaired are incompatible");
4267 else if (TARGET_AVOID_XFORM > 0) 3995 else if (TARGET_AVOID_XFORM > 0)
4268 msg = N_("-mvsx needs indexed addressing"); 3996 msg = N_("-mvsx needs indexed addressing");
4269 else if (!TARGET_ALTIVEC && (rs6000_isa_flags_explicit 3997 else if (!TARGET_ALTIVEC && (rs6000_isa_flags_explicit
4270 & OPTION_MASK_ALTIVEC)) 3998 & OPTION_MASK_ALTIVEC))
4271 { 3999 {
4425 if (TARGET_QUAD_MEMORY 4153 if (TARGET_QUAD_MEMORY
4426 && !TARGET_QUAD_MEMORY_ATOMIC 4154 && !TARGET_QUAD_MEMORY_ATOMIC
4427 && ((rs6000_isa_flags_explicit & OPTION_MASK_QUAD_MEMORY_ATOMIC) == 0)) 4155 && ((rs6000_isa_flags_explicit & OPTION_MASK_QUAD_MEMORY_ATOMIC) == 0))
4428 rs6000_isa_flags |= OPTION_MASK_QUAD_MEMORY_ATOMIC; 4156 rs6000_isa_flags |= OPTION_MASK_QUAD_MEMORY_ATOMIC;
4429 4157
4158 /* If we can shrink-wrap the TOC register save separately, then use
4159 -msave-toc-indirect unless explicitly disabled. */
4160 if ((rs6000_isa_flags_explicit & OPTION_MASK_SAVE_TOC_INDIRECT) == 0
4161 && flag_shrink_wrap_separate
4162 && optimize_function_for_speed_p (cfun))
4163 rs6000_isa_flags |= OPTION_MASK_SAVE_TOC_INDIRECT;
4164
4430 /* Enable power8 fusion if we are tuning for power8, even if we aren't 4165 /* Enable power8 fusion if we are tuning for power8, even if we aren't
4431 generating power8 instructions. */ 4166 generating power8 instructions. */
4432 if (!(rs6000_isa_flags_explicit & OPTION_MASK_P8_FUSION)) 4167 if (!(rs6000_isa_flags_explicit & OPTION_MASK_P8_FUSION))
4433 rs6000_isa_flags |= (processor_target_table[tune_index].target_enable 4168 rs6000_isa_flags |= (processor_target_table[tune_index].target_enable
4434 & OPTION_MASK_P8_FUSION); 4169 & OPTION_MASK_P8_FUSION);
4435 4170
4436 /* Setting additional fusion flags turns on base fusion. */ 4171 /* Setting additional fusion flags turns on base fusion. */
4437 if (!TARGET_P8_FUSION && (TARGET_P8_FUSION_SIGN || TARGET_TOC_FUSION)) 4172 if (!TARGET_P8_FUSION && TARGET_P8_FUSION_SIGN)
4438 { 4173 {
4439 if (rs6000_isa_flags_explicit & OPTION_MASK_P8_FUSION) 4174 if (rs6000_isa_flags_explicit & OPTION_MASK_P8_FUSION)
4440 { 4175 {
4441 if (TARGET_P8_FUSION_SIGN) 4176 if (TARGET_P8_FUSION_SIGN)
4442 error ("%qs requires %qs", "-mpower8-fusion-sign", 4177 error ("%qs requires %qs", "-mpower8-fusion-sign",
4443 "-mpower8-fusion"); 4178 "-mpower8-fusion");
4444
4445 if (TARGET_TOC_FUSION)
4446 error ("%qs requires %qs", "-mtoc-fusion", "-mpower8-fusion");
4447 4179
4448 rs6000_isa_flags &= ~OPTION_MASK_P8_FUSION; 4180 rs6000_isa_flags &= ~OPTION_MASK_P8_FUSION;
4449 } 4181 }
4450 else 4182 else
4451 rs6000_isa_flags |= OPTION_MASK_P8_FUSION; 4183 rs6000_isa_flags |= OPTION_MASK_P8_FUSION;
4480 && !(rs6000_isa_flags_explicit & OPTION_MASK_P8_FUSION_SIGN) 4212 && !(rs6000_isa_flags_explicit & OPTION_MASK_P8_FUSION_SIGN)
4481 && optimize_function_for_speed_p (cfun) 4213 && optimize_function_for_speed_p (cfun)
4482 && optimize >= 3) 4214 && optimize >= 3)
4483 rs6000_isa_flags |= OPTION_MASK_P8_FUSION_SIGN; 4215 rs6000_isa_flags |= OPTION_MASK_P8_FUSION_SIGN;
4484 4216
4485 /* TOC fusion requires 64-bit and medium/large code model. */
4486 if (TARGET_TOC_FUSION && !TARGET_POWERPC64)
4487 {
4488 rs6000_isa_flags &= ~OPTION_MASK_TOC_FUSION;
4489 if ((rs6000_isa_flags_explicit & OPTION_MASK_TOC_FUSION) != 0)
4490 warning (0, N_("-mtoc-fusion requires 64-bit"));
4491 }
4492
4493 if (TARGET_TOC_FUSION && (TARGET_CMODEL == CMODEL_SMALL))
4494 {
4495 rs6000_isa_flags &= ~OPTION_MASK_TOC_FUSION;
4496 if ((rs6000_isa_flags_explicit & OPTION_MASK_TOC_FUSION) != 0)
4497 warning (0, N_("-mtoc-fusion requires medium/large code model"));
4498 }
4499
4500 /* Turn on -mtoc-fusion by default if p8-fusion and 64-bit medium/large code
4501 model. */
4502 if (TARGET_P8_FUSION && !TARGET_TOC_FUSION && TARGET_POWERPC64
4503 && (TARGET_CMODEL != CMODEL_SMALL)
4504 && !(rs6000_isa_flags_explicit & OPTION_MASK_TOC_FUSION))
4505 rs6000_isa_flags |= OPTION_MASK_TOC_FUSION;
4506
4507 /* ISA 3.0 vector instructions include ISA 2.07. */ 4217 /* ISA 3.0 vector instructions include ISA 2.07. */
4508 if (TARGET_P9_VECTOR && !TARGET_P8_VECTOR) 4218 if (TARGET_P9_VECTOR && !TARGET_P8_VECTOR)
4509 { 4219 {
4510 /* We prefer to not mention undocumented options in 4220 /* We prefer to not mention undocumented options in
4511 error messages. However, if users have managed to select 4221 error messages. However, if users have managed to select
4568 4278
4569 rs6000_isa_flags &= ~OPTION_MASK_EFFICIENT_UNALIGNED_VSX; 4279 rs6000_isa_flags &= ~OPTION_MASK_EFFICIENT_UNALIGNED_VSX;
4570 } 4280 }
4571 } 4281 }
4572 4282
4283 /* Use long double size to select the appropriate long double. We use
4284 TYPE_PRECISION to differentiate the 3 different long double types. We map
4285 128 into the precision used for TFmode. */
4286 int default_long_double_size = (RS6000_DEFAULT_LONG_DOUBLE_SIZE == 64
4287 ? 64
4288 : FLOAT_PRECISION_TFmode);
4289
4573 /* Set long double size before the IEEE 128-bit tests. */ 4290 /* Set long double size before the IEEE 128-bit tests. */
4574 if (!global_options_set.x_rs6000_long_double_type_size) 4291 if (!global_options_set.x_rs6000_long_double_type_size)
4575 { 4292 {
4576 if (main_target_opt != NULL 4293 if (main_target_opt != NULL
4577 && (main_target_opt->x_rs6000_long_double_type_size 4294 && (main_target_opt->x_rs6000_long_double_type_size
4578 != RS6000_DEFAULT_LONG_DOUBLE_SIZE)) 4295 != default_long_double_size))
4579 error ("target attribute or pragma changes long double size"); 4296 error ("target attribute or pragma changes long double size");
4580 else 4297 else
4581 rs6000_long_double_type_size = RS6000_DEFAULT_LONG_DOUBLE_SIZE; 4298 rs6000_long_double_type_size = default_long_double_size;
4582 } 4299 }
4300 else if (rs6000_long_double_type_size == 128)
4301 rs6000_long_double_type_size = FLOAT_PRECISION_TFmode;
4583 4302
4584 /* Set -mabi=ieeelongdouble on some old targets. In the future, power server 4303 /* Set -mabi=ieeelongdouble on some old targets. In the future, power server
4585 systems will also set long double to be IEEE 128-bit. AIX and Darwin 4304 systems will also set long double to be IEEE 128-bit. AIX and Darwin
4586 explicitly redefine TARGET_IEEEQUAD and TARGET_IEEEQUAD_DEFAULT to 0, so 4305 explicitly redefine TARGET_IEEEQUAD and TARGET_IEEEQUAD_DEFAULT to 0, so
4587 those systems will not pick up this default. Warn if the user changes the 4306 those systems will not pick up this default. Warn if the user changes the
4665 rs6000_print_isa_options (stderr, 0, "after defaults", rs6000_isa_flags); 4384 rs6000_print_isa_options (stderr, 0, "after defaults", rs6000_isa_flags);
4666 4385
4667 /* E500mc does "better" if we inline more aggressively. Respect the 4386 /* E500mc does "better" if we inline more aggressively. Respect the
4668 user's opinion, though. */ 4387 user's opinion, though. */
4669 if (rs6000_block_move_inline_limit == 0 4388 if (rs6000_block_move_inline_limit == 0
4670 && (rs6000_cpu == PROCESSOR_PPCE500MC 4389 && (rs6000_tune == PROCESSOR_PPCE500MC
4671 || rs6000_cpu == PROCESSOR_PPCE500MC64 4390 || rs6000_tune == PROCESSOR_PPCE500MC64
4672 || rs6000_cpu == PROCESSOR_PPCE5500 4391 || rs6000_tune == PROCESSOR_PPCE5500
4673 || rs6000_cpu == PROCESSOR_PPCE6500)) 4392 || rs6000_tune == PROCESSOR_PPCE6500))
4674 rs6000_block_move_inline_limit = 128; 4393 rs6000_block_move_inline_limit = 128;
4675 4394
4676 /* store_one_arg depends on expand_block_move to handle at least the 4395 /* store_one_arg depends on expand_block_move to handle at least the
4677 size of reg_parm_stack_space. */ 4396 size of reg_parm_stack_space. */
4678 if (rs6000_block_move_inline_limit < (TARGET_POWERPC64 ? 64 : 32)) 4397 if (rs6000_block_move_inline_limit < (TARGET_POWERPC64 ? 64 : 32))
4794 #endif 4513 #endif
4795 4514
4796 if (TARGET_DEBUG_REG || TARGET_DEBUG_TARGET) 4515 if (TARGET_DEBUG_REG || TARGET_DEBUG_TARGET)
4797 rs6000_print_isa_options (stderr, 0, "after subtarget", rs6000_isa_flags); 4516 rs6000_print_isa_options (stderr, 0, "after subtarget", rs6000_isa_flags);
4798 4517
4799 /* For the E500 family of cores, reset the single/double FP flags to let us 4518 rs6000_always_hint = (rs6000_tune != PROCESSOR_POWER4
4800 check that they remain constant across attributes or pragmas. Also, 4519 && rs6000_tune != PROCESSOR_POWER5
4801 clear a possible request for string instructions, not supported and which 4520 && rs6000_tune != PROCESSOR_POWER6
4802 we might have silently queried above for -Os. 4521 && rs6000_tune != PROCESSOR_POWER7
4803 4522 && rs6000_tune != PROCESSOR_POWER8
4804 For other families, clear ISEL in case it was set implicitly. 4523 && rs6000_tune != PROCESSOR_POWER9
4805 */ 4524 && rs6000_tune != PROCESSOR_PPCA2
4806 4525 && rs6000_tune != PROCESSOR_CELL
4807 switch (rs6000_cpu) 4526 && rs6000_tune != PROCESSOR_PPC476);
4808 { 4527 rs6000_sched_groups = (rs6000_tune == PROCESSOR_POWER4
4809 case PROCESSOR_PPC8540: 4528 || rs6000_tune == PROCESSOR_POWER5
4810 case PROCESSOR_PPC8548: 4529 || rs6000_tune == PROCESSOR_POWER7
4811 case PROCESSOR_PPCE500MC: 4530 || rs6000_tune == PROCESSOR_POWER8);
4812 case PROCESSOR_PPCE500MC64: 4531 rs6000_align_branch_targets = (rs6000_tune == PROCESSOR_POWER4
4813 case PROCESSOR_PPCE5500: 4532 || rs6000_tune == PROCESSOR_POWER5
4814 case PROCESSOR_PPCE6500: 4533 || rs6000_tune == PROCESSOR_POWER6
4815 4534 || rs6000_tune == PROCESSOR_POWER7
4816 rs6000_single_float = 0; 4535 || rs6000_tune == PROCESSOR_POWER8
4817 rs6000_double_float = 0; 4536 || rs6000_tune == PROCESSOR_POWER9
4818 4537 || rs6000_tune == PROCESSOR_PPCE500MC
4819 rs6000_isa_flags &= ~OPTION_MASK_STRING; 4538 || rs6000_tune == PROCESSOR_PPCE500MC64
4820 4539 || rs6000_tune == PROCESSOR_PPCE5500
4821 break; 4540 || rs6000_tune == PROCESSOR_PPCE6500);
4822
4823 default:
4824
4825 if (cpu_index >= 0 && !(rs6000_isa_flags_explicit & OPTION_MASK_ISEL))
4826 rs6000_isa_flags &= ~OPTION_MASK_ISEL;
4827
4828 break;
4829 }
4830
4831 if (main_target_opt)
4832 {
4833 if (main_target_opt->x_rs6000_single_float != rs6000_single_float)
4834 error ("target attribute or pragma changes single precision floating "
4835 "point");
4836 if (main_target_opt->x_rs6000_double_float != rs6000_double_float)
4837 error ("target attribute or pragma changes double precision floating "
4838 "point");
4839 }
4840
4841 rs6000_always_hint = (rs6000_cpu != PROCESSOR_POWER4
4842 && rs6000_cpu != PROCESSOR_POWER5
4843 && rs6000_cpu != PROCESSOR_POWER6
4844 && rs6000_cpu != PROCESSOR_POWER7
4845 && rs6000_cpu != PROCESSOR_POWER8
4846 && rs6000_cpu != PROCESSOR_POWER9
4847 && rs6000_cpu != PROCESSOR_PPCA2
4848 && rs6000_cpu != PROCESSOR_CELL
4849 && rs6000_cpu != PROCESSOR_PPC476);
4850 rs6000_sched_groups = (rs6000_cpu == PROCESSOR_POWER4
4851 || rs6000_cpu == PROCESSOR_POWER5
4852 || rs6000_cpu == PROCESSOR_POWER7
4853 || rs6000_cpu == PROCESSOR_POWER8);
4854 rs6000_align_branch_targets = (rs6000_cpu == PROCESSOR_POWER4
4855 || rs6000_cpu == PROCESSOR_POWER5
4856 || rs6000_cpu == PROCESSOR_POWER6
4857 || rs6000_cpu == PROCESSOR_POWER7
4858 || rs6000_cpu == PROCESSOR_POWER8
4859 || rs6000_cpu == PROCESSOR_POWER9
4860 || rs6000_cpu == PROCESSOR_PPCE500MC
4861 || rs6000_cpu == PROCESSOR_PPCE500MC64
4862 || rs6000_cpu == PROCESSOR_PPCE5500
4863 || rs6000_cpu == PROCESSOR_PPCE6500);
4864 4541
4865 /* Allow debug switches to override the above settings. These are set to -1 4542 /* Allow debug switches to override the above settings. These are set to -1
4866 in rs6000.opt to indicate the user hasn't directly set the switch. */ 4543 in rs6000.opt to indicate the user hasn't directly set the switch. */
4867 if (TARGET_ALWAYS_HINT >= 0) 4544 if (TARGET_ALWAYS_HINT >= 0)
4868 rs6000_always_hint = TARGET_ALWAYS_HINT; 4545 rs6000_always_hint = TARGET_ALWAYS_HINT;
4998 /* Set branch target alignment, if not optimizing for size. */ 4675 /* Set branch target alignment, if not optimizing for size. */
4999 if (!optimize_size) 4676 if (!optimize_size)
5000 { 4677 {
5001 /* Cell wants to be aligned 8byte for dual issue. Titan wants to be 4678 /* Cell wants to be aligned 8byte for dual issue. Titan wants to be
5002 aligned 8byte to avoid misprediction by the branch predictor. */ 4679 aligned 8byte to avoid misprediction by the branch predictor. */
5003 if (rs6000_cpu == PROCESSOR_TITAN 4680 if (rs6000_tune == PROCESSOR_TITAN
5004 || rs6000_cpu == PROCESSOR_CELL) 4681 || rs6000_tune == PROCESSOR_CELL)
5005 { 4682 {
5006 if (align_functions <= 0) 4683 if (flag_align_functions && !str_align_functions)
5007 align_functions = 8; 4684 str_align_functions = "8";
5008 if (align_jumps <= 0) 4685 if (flag_align_jumps && !str_align_jumps)
5009 align_jumps = 8; 4686 str_align_jumps = "8";
5010 if (align_loops <= 0) 4687 if (flag_align_loops && !str_align_loops)
5011 align_loops = 8; 4688 str_align_loops = "8";
5012 } 4689 }
5013 if (rs6000_align_branch_targets) 4690 if (rs6000_align_branch_targets)
5014 { 4691 {
5015 if (align_functions <= 0) 4692 if (flag_align_functions && !str_align_functions)
5016 align_functions = 16; 4693 str_align_functions = "16";
5017 if (align_jumps <= 0) 4694 if (flag_align_jumps && !str_align_jumps)
5018 align_jumps = 16; 4695 str_align_jumps = "16";
5019 if (align_loops <= 0) 4696 if (flag_align_loops && !str_align_loops)
5020 { 4697 {
5021 can_override_loop_align = 1; 4698 can_override_loop_align = 1;
5022 align_loops = 16; 4699 str_align_loops = "16";
5023 } 4700 }
5024 } 4701 }
5025 if (align_jumps_max_skip <= 0) 4702
5026 align_jumps_max_skip = 15; 4703 if (flag_align_jumps && !str_align_jumps)
5027 if (align_loops_max_skip <= 0) 4704 str_align_jumps = "16";
5028 align_loops_max_skip = 15; 4705 if (flag_align_loops && !str_align_loops)
4706 str_align_loops = "16";
5029 } 4707 }
5030 4708
5031 /* Arrange to save and restore machine status around nested functions. */ 4709 /* Arrange to save and restore machine status around nested functions. */
5032 init_machine_status = rs6000_init_machine_status; 4710 init_machine_status = rs6000_init_machine_status;
5033 4711
5043 4721
5044 /* Initialize rs6000_cost with the appropriate target costs. */ 4722 /* Initialize rs6000_cost with the appropriate target costs. */
5045 if (optimize_size) 4723 if (optimize_size)
5046 rs6000_cost = TARGET_POWERPC64 ? &size64_cost : &size32_cost; 4724 rs6000_cost = TARGET_POWERPC64 ? &size64_cost : &size32_cost;
5047 else 4725 else
5048 switch (rs6000_cpu) 4726 switch (rs6000_tune)
5049 { 4727 {
5050 case PROCESSOR_RS64A: 4728 case PROCESSOR_RS64A:
5051 rs6000_cost = &rs64a_cost; 4729 rs6000_cost = &rs64a_cost;
5052 break; 4730 break;
5053 4731
5203 ap = __builtin_next_arg (0). */ 4881 ap = __builtin_next_arg (0). */
5204 if (DEFAULT_ABI != ABI_V4) 4882 if (DEFAULT_ABI != ABI_V4)
5205 targetm.expand_builtin_va_start = NULL; 4883 targetm.expand_builtin_va_start = NULL;
5206 } 4884 }
5207 4885
5208 /* Set up single/double float flags.
5209 If TARGET_HARD_FLOAT is set, but neither single or double is set,
5210 then set both flags. */
5211 if (TARGET_HARD_FLOAT && rs6000_single_float == 0 && rs6000_double_float == 0)
5212 rs6000_single_float = rs6000_double_float = 1;
5213
5214 /* If not explicitly specified via option, decide whether to generate indexed 4886 /* If not explicitly specified via option, decide whether to generate indexed
5215 load/store instructions. A value of -1 indicates that the 4887 load/store instructions. A value of -1 indicates that the
5216 initial value of this variable has not been overwritten. During 4888 initial value of this variable has not been overwritten. During
5217 compilation, TARGET_AVOID_XFORM is either 0 or 1. */ 4889 compilation, TARGET_AVOID_XFORM is either 0 or 1. */
5218 if (TARGET_AVOID_XFORM == -1) 4890 if (TARGET_AVOID_XFORM == -1)
5219 /* Avoid indexed addressing when targeting Power6 in order to avoid the 4891 /* Avoid indexed addressing when targeting Power6 in order to avoid the
5220 DERAT mispredict penalty. However the LVE and STVE altivec instructions 4892 DERAT mispredict penalty. However the LVE and STVE altivec instructions
5221 need indexed accesses and the type used is the scalar type of the element 4893 need indexed accesses and the type used is the scalar type of the element
5222 being loaded or stored. */ 4894 being loaded or stored. */
5223 TARGET_AVOID_XFORM = (rs6000_cpu == PROCESSOR_POWER6 && TARGET_CMPB 4895 TARGET_AVOID_XFORM = (rs6000_tune == PROCESSOR_POWER6 && TARGET_CMPB
5224 && !TARGET_ALTIVEC); 4896 && !TARGET_ALTIVEC);
5225 4897
5226 /* Set the -mrecip options. */ 4898 /* Set the -mrecip options. */
5227 if (rs6000_recip_name) 4899 if (rs6000_recip_name)
5228 { 4900 {
5270 } 4942 }
5271 } 4943 }
5272 4944
5273 /* Set the builtin mask of the various options used that could affect which 4945 /* Set the builtin mask of the various options used that could affect which
5274 builtins were used. In the past we used target_flags, but we've run out 4946 builtins were used. In the past we used target_flags, but we've run out
5275 of bits, and some options like PAIRED are no longer in target_flags. */ 4947 of bits, and some options are no longer in target_flags. */
5276 rs6000_builtin_mask = rs6000_builtin_mask_calculate (); 4948 rs6000_builtin_mask = rs6000_builtin_mask_calculate ();
5277 if (TARGET_DEBUG_BUILTIN || TARGET_DEBUG_TARGET) 4949 if (TARGET_DEBUG_BUILTIN || TARGET_DEBUG_TARGET)
5278 rs6000_print_builtin_options (stderr, 0, "builtin mask", 4950 rs6000_print_builtin_options (stderr, 0, "builtin mask",
5279 rs6000_builtin_mask); 4951 rs6000_builtin_mask);
5280 4952
5287 = build_target_option_node (&global_options); 4959 = build_target_option_node (&global_options);
5288 4960
5289 /* If not explicitly specified via option, decide whether to generate the 4961 /* If not explicitly specified via option, decide whether to generate the
5290 extra blr's required to preserve the link stack on some cpus (eg, 476). */ 4962 extra blr's required to preserve the link stack on some cpus (eg, 476). */
5291 if (TARGET_LINK_STACK == -1) 4963 if (TARGET_LINK_STACK == -1)
5292 SET_TARGET_LINK_STACK (rs6000_cpu == PROCESSOR_PPC476 && flag_pic); 4964 SET_TARGET_LINK_STACK (rs6000_tune == PROCESSOR_PPC476 && flag_pic);
4965
4966 /* Deprecate use of -mno-speculate-indirect-jumps. */
4967 if (!rs6000_speculate_indirect_jumps)
4968 warning (0, "%qs is deprecated and not recommended in any circumstances",
4969 "-mno-speculate-indirect-jumps");
5293 4970
5294 return ret; 4971 return ret;
5295 } 4972 }
5296 4973
5297 /* Implement TARGET_OPTION_OVERRIDE. On the RS/6000 this is used to 4974 /* Implement TARGET_OPTION_OVERRIDE. On the RS/6000 this is used to
5315 else 4992 else
5316 return 0; 4993 return 0;
5317 } 4994 }
5318 4995
5319 /* Implement LOOP_ALIGN. */ 4996 /* Implement LOOP_ALIGN. */
5320 int 4997 align_flags
5321 rs6000_loop_align (rtx label) 4998 rs6000_loop_align (rtx label)
5322 { 4999 {
5323 basic_block bb; 5000 basic_block bb;
5324 int ninsns; 5001 int ninsns;
5325 5002
5326 /* Don't override loop alignment if -falign-loops was specified. */ 5003 /* Don't override loop alignment if -falign-loops was specified. */
5327 if (!can_override_loop_align) 5004 if (!can_override_loop_align)
5328 return align_loops_log; 5005 return align_loops;
5329 5006
5330 bb = BLOCK_FOR_INSN (label); 5007 bb = BLOCK_FOR_INSN (label);
5331 ninsns = num_loop_insns(bb->loop_father); 5008 ninsns = num_loop_insns(bb->loop_father);
5332 5009
5333 /* Align small loops to 32 bytes to fit in an icache sector, otherwise return default. */ 5010 /* Align small loops to 32 bytes to fit in an icache sector, otherwise return default. */
5334 if (ninsns > 4 && ninsns <= 8 5011 if (ninsns > 4 && ninsns <= 8
5335 && (rs6000_cpu == PROCESSOR_POWER4 5012 && (rs6000_tune == PROCESSOR_POWER4
5336 || rs6000_cpu == PROCESSOR_POWER5 5013 || rs6000_tune == PROCESSOR_POWER5
5337 || rs6000_cpu == PROCESSOR_POWER6 5014 || rs6000_tune == PROCESSOR_POWER6
5338 || rs6000_cpu == PROCESSOR_POWER7 5015 || rs6000_tune == PROCESSOR_POWER7
5339 || rs6000_cpu == PROCESSOR_POWER8 5016 || rs6000_tune == PROCESSOR_POWER8))
5340 || rs6000_cpu == PROCESSOR_POWER9)) 5017 return align_flags (5);
5341 return 5;
5342 else 5018 else
5343 return align_loops_log; 5019 return align_loops;
5344 }
5345
5346 /* Implement TARGET_LOOP_ALIGN_MAX_SKIP. */
5347 static int
5348 rs6000_loop_align_max_skip (rtx_insn *label)
5349 {
5350 return (1 << rs6000_loop_align (label)) - 1;
5351 } 5020 }
5352 5021
5353 /* Return true iff, data reference of TYPE can reach vector alignment (16) 5022 /* Return true iff, data reference of TYPE can reach vector alignment (16)
5354 after applying N number of iterations. This routine does not determine 5023 after applying N number of iterations. This routine does not determine
5355 how may iterations are required to reach desired alignment. */ 5024 how may iterations are required to reach desired alignment. */
5593 return V8HImode; 5262 return V8HImode;
5594 case E_QImode: 5263 case E_QImode:
5595 return V16QImode; 5264 return V16QImode;
5596 default:; 5265 default:;
5597 } 5266 }
5598 if (TARGET_PAIRED_FLOAT
5599 && mode == SFmode)
5600 return V2SFmode;
5601 return word_mode; 5267 return word_mode;
5602 } 5268 }
5603 5269
5604 typedef struct _rs6000_cost_data 5270 typedef struct _rs6000_cost_data
5605 { 5271 {
5620 const int DENSITY_SIZE_THRESHOLD = 70; 5286 const int DENSITY_SIZE_THRESHOLD = 70;
5621 const int DENSITY_PENALTY = 10; 5287 const int DENSITY_PENALTY = 10;
5622 struct loop *loop = data->loop_info; 5288 struct loop *loop = data->loop_info;
5623 basic_block *bbs = get_loop_body (loop); 5289 basic_block *bbs = get_loop_body (loop);
5624 int nbbs = loop->num_nodes; 5290 int nbbs = loop->num_nodes;
5291 loop_vec_info loop_vinfo = loop_vec_info_for_loop (data->loop_info);
5625 int vec_cost = data->cost[vect_body], not_vec_cost = 0; 5292 int vec_cost = data->cost[vect_body], not_vec_cost = 0;
5626 int i, density_pct; 5293 int i, density_pct;
5627 5294
5628 for (i = 0; i < nbbs; i++) 5295 for (i = 0; i < nbbs; i++)
5629 { 5296 {
5631 gimple_stmt_iterator gsi; 5298 gimple_stmt_iterator gsi;
5632 5299
5633 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) 5300 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
5634 { 5301 {
5635 gimple *stmt = gsi_stmt (gsi); 5302 gimple *stmt = gsi_stmt (gsi);
5636 stmt_vec_info stmt_info = vinfo_for_stmt (stmt); 5303 stmt_vec_info stmt_info = loop_vinfo->lookup_stmt (stmt);
5637 5304
5638 if (!STMT_VINFO_RELEVANT_P (stmt_info) 5305 if (!STMT_VINFO_RELEVANT_P (stmt_info)
5639 && !STMT_VINFO_IN_PATTERN_P (stmt_info)) 5306 && !STMT_VINFO_IN_PATTERN_P (stmt_info))
5640 not_vec_cost++; 5307 not_vec_cost++;
5641 } 5308 }
6272 } 5939 }
6273 } 5940 }
6274 5941
6275 /* Interpret element ELT of the CONST_VECTOR OP as an integer value. 5942 /* Interpret element ELT of the CONST_VECTOR OP as an integer value.
6276 If the mode of OP is MODE_VECTOR_INT, this simply returns the 5943 If the mode of OP is MODE_VECTOR_INT, this simply returns the
6277 corresponding element of the vector, but for V4SFmode and V2SFmode, 5944 corresponding element of the vector, but for V4SFmode, the
6278 the corresponding "float" is interpreted as an SImode integer. */ 5945 corresponding "float" is interpreted as an SImode integer. */
6279 5946
6280 HOST_WIDE_INT 5947 HOST_WIDE_INT
6281 const_vector_elt_as_int (rtx op, unsigned int elt) 5948 const_vector_elt_as_int (rtx op, unsigned int elt)
6282 { 5949 {
6283 rtx tmp; 5950 rtx tmp;
6285 /* We can't handle V2DImode and V2DFmode vector constants here yet. */ 5952 /* We can't handle V2DImode and V2DFmode vector constants here yet. */
6286 gcc_assert (GET_MODE (op) != V2DImode 5953 gcc_assert (GET_MODE (op) != V2DImode
6287 && GET_MODE (op) != V2DFmode); 5954 && GET_MODE (op) != V2DFmode);
6288 5955
6289 tmp = CONST_VECTOR_ELT (op, elt); 5956 tmp = CONST_VECTOR_ELT (op, elt);
6290 if (GET_MODE (op) == V4SFmode 5957 if (GET_MODE (op) == V4SFmode)
6291 || GET_MODE (op) == V2SFmode)
6292 tmp = gen_lowpart (SImode, tmp); 5958 tmp = gen_lowpart (SImode, tmp);
6293 return INTVAL (tmp); 5959 return INTVAL (tmp);
6294 } 5960 }
6295 5961
6296 /* Return true if OP can be synthesized with a particular vspltisb, vspltish 5962 /* Return true if OP can be synthesized with a particular vspltisb, vspltish
6788 gcc_unreachable (); 6454 gcc_unreachable ();
6789 } 6455 }
6790 } 6456 }
6791 6457
6792 gcc_unreachable (); 6458 gcc_unreachable ();
6793 }
6794
6795 /* Initialize TARGET of vector PAIRED to VALS. */
6796
6797 void
6798 paired_expand_vector_init (rtx target, rtx vals)
6799 {
6800 machine_mode mode = GET_MODE (target);
6801 int n_elts = GET_MODE_NUNITS (mode);
6802 int n_var = 0;
6803 rtx x, new_rtx, tmp, constant_op, op1, op2;
6804 int i;
6805
6806 for (i = 0; i < n_elts; ++i)
6807 {
6808 x = XVECEXP (vals, 0, i);
6809 if (!(CONST_SCALAR_INT_P (x) || CONST_DOUBLE_P (x) || CONST_FIXED_P (x)))
6810 ++n_var;
6811 }
6812 if (n_var == 0)
6813 {
6814 /* Load from constant pool. */
6815 emit_move_insn (target, gen_rtx_CONST_VECTOR (mode, XVEC (vals, 0)));
6816 return;
6817 }
6818
6819 if (n_var == 2)
6820 {
6821 /* The vector is initialized only with non-constants. */
6822 new_rtx = gen_rtx_VEC_CONCAT (V2SFmode, XVECEXP (vals, 0, 0),
6823 XVECEXP (vals, 0, 1));
6824
6825 emit_move_insn (target, new_rtx);
6826 return;
6827 }
6828
6829 /* One field is non-constant and the other one is a constant. Load the
6830 constant from the constant pool and use ps_merge instruction to
6831 construct the whole vector. */
6832 op1 = XVECEXP (vals, 0, 0);
6833 op2 = XVECEXP (vals, 0, 1);
6834
6835 constant_op = (CONSTANT_P (op1)) ? op1 : op2;
6836
6837 tmp = gen_reg_rtx (GET_MODE (constant_op));
6838 emit_move_insn (tmp, constant_op);
6839
6840 if (CONSTANT_P (op1))
6841 new_rtx = gen_rtx_VEC_CONCAT (V2SFmode, tmp, op2);
6842 else
6843 new_rtx = gen_rtx_VEC_CONCAT (V2SFmode, op1, tmp);
6844
6845 emit_move_insn (target, new_rtx);
6846 }
6847
6848 void
6849 paired_expand_vector_move (rtx operands[])
6850 {
6851 rtx op0 = operands[0], op1 = operands[1];
6852
6853 emit_move_insn (op0, op1);
6854 }
6855
6856 /* Emit vector compare for code RCODE. DEST is destination, OP1 and
6857 OP2 are two VEC_COND_EXPR operands, CC_OP0 and CC_OP1 are the two
6858 operands for the relation operation COND. This is a recursive
6859 function. */
6860
6861 static void
6862 paired_emit_vector_compare (enum rtx_code rcode,
6863 rtx dest, rtx op0, rtx op1,
6864 rtx cc_op0, rtx cc_op1)
6865 {
6866 rtx tmp = gen_reg_rtx (V2SFmode);
6867 rtx tmp1, max, min;
6868
6869 gcc_assert (TARGET_PAIRED_FLOAT);
6870 gcc_assert (GET_MODE (op0) == GET_MODE (op1));
6871
6872 switch (rcode)
6873 {
6874 case LT:
6875 case LTU:
6876 paired_emit_vector_compare (GE, dest, op1, op0, cc_op0, cc_op1);
6877 return;
6878 case GE:
6879 case GEU:
6880 emit_insn (gen_subv2sf3 (tmp, cc_op0, cc_op1));
6881 emit_insn (gen_selv2sf4 (dest, tmp, op0, op1, CONST0_RTX (SFmode)));
6882 return;
6883 case LE:
6884 case LEU:
6885 paired_emit_vector_compare (GE, dest, op0, op1, cc_op1, cc_op0);
6886 return;
6887 case GT:
6888 paired_emit_vector_compare (LE, dest, op1, op0, cc_op0, cc_op1);
6889 return;
6890 case EQ:
6891 tmp1 = gen_reg_rtx (V2SFmode);
6892 max = gen_reg_rtx (V2SFmode);
6893 min = gen_reg_rtx (V2SFmode);
6894 gen_reg_rtx (V2SFmode);
6895
6896 emit_insn (gen_subv2sf3 (tmp, cc_op0, cc_op1));
6897 emit_insn (gen_selv2sf4
6898 (max, tmp, cc_op0, cc_op1, CONST0_RTX (SFmode)));
6899 emit_insn (gen_subv2sf3 (tmp, cc_op1, cc_op0));
6900 emit_insn (gen_selv2sf4
6901 (min, tmp, cc_op0, cc_op1, CONST0_RTX (SFmode)));
6902 emit_insn (gen_subv2sf3 (tmp1, min, max));
6903 emit_insn (gen_selv2sf4 (dest, tmp1, op0, op1, CONST0_RTX (SFmode)));
6904 return;
6905 case NE:
6906 paired_emit_vector_compare (EQ, dest, op1, op0, cc_op0, cc_op1);
6907 return;
6908 case UNLE:
6909 paired_emit_vector_compare (LE, dest, op1, op0, cc_op0, cc_op1);
6910 return;
6911 case UNLT:
6912 paired_emit_vector_compare (LT, dest, op1, op0, cc_op0, cc_op1);
6913 return;
6914 case UNGE:
6915 paired_emit_vector_compare (GE, dest, op1, op0, cc_op0, cc_op1);
6916 return;
6917 case UNGT:
6918 paired_emit_vector_compare (GT, dest, op1, op0, cc_op0, cc_op1);
6919 return;
6920 default:
6921 gcc_unreachable ();
6922 }
6923
6924 return;
6925 }
6926
6927 /* Emit vector conditional expression.
6928 DEST is destination. OP1 and OP2 are two VEC_COND_EXPR operands.
6929 CC_OP0 and CC_OP1 are the two operands for the relation operation COND. */
6930
6931 int
6932 paired_emit_vector_cond_expr (rtx dest, rtx op1, rtx op2,
6933 rtx cond, rtx cc_op0, rtx cc_op1)
6934 {
6935 enum rtx_code rcode = GET_CODE (cond);
6936
6937 if (!TARGET_PAIRED_FLOAT)
6938 return 0;
6939
6940 paired_emit_vector_compare (rcode, dest, op1, op2, cc_op0, cc_op1);
6941
6942 return 1;
6943 } 6459 }
6944 6460
6945 /* Initialize vector TARGET to VALS. */ 6461 /* Initialize vector TARGET to VALS. */
6946 6462
6947 void 6463 void
7062 { 6578 {
7063 rtx elements[4]; 6579 rtx elements[4];
7064 size_t i; 6580 size_t i;
7065 6581
7066 for (i = 0; i < 4; i++) 6582 for (i = 0; i < 4; i++)
7067 { 6583 elements[i] = force_reg (SImode, XVECEXP (vals, 0, i));
7068 elements[i] = XVECEXP (vals, 0, i);
7069 if (!CONST_INT_P (elements[i]) && !REG_P (elements[i]))
7070 elements[i] = copy_to_mode_reg (SImode, elements[i]);
7071 }
7072 6584
7073 emit_insn (gen_vsx_init_v4si (target, elements[0], elements[1], 6585 emit_insn (gen_vsx_init_v4si (target, elements[0], elements[1],
7074 elements[2], elements[3])); 6586 elements[2], elements[3]));
7075 return; 6587 return;
7076 } 6588 }
7293 UNSPEC_VPERM); 6805 UNSPEC_VPERM);
7294 else 6806 else
7295 { 6807 {
7296 if (TARGET_P9_VECTOR) 6808 if (TARGET_P9_VECTOR)
7297 x = gen_rtx_UNSPEC (mode, 6809 x = gen_rtx_UNSPEC (mode,
7298 gen_rtvec (3, target, reg, 6810 gen_rtvec (3, reg, target,
7299 force_reg (V16QImode, x)), 6811 force_reg (V16QImode, x)),
7300 UNSPEC_VPERMR); 6812 UNSPEC_VPERMR);
7301 else 6813 else
7302 { 6814 {
7303 /* Invert selector. We prefer to generate VNAND on P8 so 6815 /* Invert selector. We prefer to generate VNAND on P8 so
7644 { 7156 {
7645 rtx dest_si = gen_rtx_REG (SImode, dest_regno); 7157 rtx dest_si = gen_rtx_REG (SImode, dest_regno);
7646 rtx element_si = gen_rtx_REG (SImode, element_regno); 7158 rtx element_si = gen_rtx_REG (SImode, element_regno);
7647 7159
7648 if (mode == V16QImode) 7160 if (mode == V16QImode)
7649 emit_insn (VECTOR_ELT_ORDER_BIG 7161 emit_insn (BYTES_BIG_ENDIAN
7650 ? gen_vextublx (dest_si, element_si, src) 7162 ? gen_vextublx (dest_si, element_si, src)
7651 : gen_vextubrx (dest_si, element_si, src)); 7163 : gen_vextubrx (dest_si, element_si, src));
7652 7164
7653 else if (mode == V8HImode) 7165 else if (mode == V8HImode)
7654 { 7166 {
7655 rtx tmp_gpr_si = gen_rtx_REG (SImode, REGNO (tmp_gpr)); 7167 rtx tmp_gpr_si = gen_rtx_REG (SImode, REGNO (tmp_gpr));
7656 emit_insn (gen_ashlsi3 (tmp_gpr_si, element_si, const1_rtx)); 7168 emit_insn (gen_ashlsi3 (tmp_gpr_si, element_si, const1_rtx));
7657 emit_insn (VECTOR_ELT_ORDER_BIG 7169 emit_insn (BYTES_BIG_ENDIAN
7658 ? gen_vextuhlx (dest_si, tmp_gpr_si, src) 7170 ? gen_vextuhlx (dest_si, tmp_gpr_si, src)
7659 : gen_vextuhrx (dest_si, tmp_gpr_si, src)); 7171 : gen_vextuhrx (dest_si, tmp_gpr_si, src));
7660 } 7172 }
7661 7173
7662 7174
7663 else 7175 else
7664 { 7176 {
7665 rtx tmp_gpr_si = gen_rtx_REG (SImode, REGNO (tmp_gpr)); 7177 rtx tmp_gpr_si = gen_rtx_REG (SImode, REGNO (tmp_gpr));
7666 emit_insn (gen_ashlsi3 (tmp_gpr_si, element_si, const2_rtx)); 7178 emit_insn (gen_ashlsi3 (tmp_gpr_si, element_si, const2_rtx));
7667 emit_insn (VECTOR_ELT_ORDER_BIG 7179 emit_insn (BYTES_BIG_ENDIAN
7668 ? gen_vextuwlx (dest_si, tmp_gpr_si, src) 7180 ? gen_vextuwlx (dest_si, tmp_gpr_si, src)
7669 : gen_vextuwrx (dest_si, tmp_gpr_si, src)); 7181 : gen_vextuwrx (dest_si, tmp_gpr_si, src));
7670 } 7182 }
7671 7183
7672 return; 7184 return;
7679 an XOR, otherwise we need to subtract. The shift amount is so VSLO 7191 an XOR, otherwise we need to subtract. The shift amount is so VSLO
7680 will shift the element into the upper position (adding 3 to convert a 7192 will shift the element into the upper position (adding 3 to convert a
7681 byte shift into a bit shift). */ 7193 byte shift into a bit shift). */
7682 if (scalar_size == 8) 7194 if (scalar_size == 8)
7683 { 7195 {
7684 if (!VECTOR_ELT_ORDER_BIG) 7196 if (!BYTES_BIG_ENDIAN)
7685 { 7197 {
7686 emit_insn (gen_xordi3 (tmp_gpr, element, const1_rtx)); 7198 emit_insn (gen_xordi3 (tmp_gpr, element, const1_rtx));
7687 element2 = tmp_gpr; 7199 element2 = tmp_gpr;
7688 } 7200 }
7689 else 7201 else
7698 GEN_INT (6)), 7210 GEN_INT (6)),
7699 GEN_INT (64)))); 7211 GEN_INT (64))));
7700 } 7212 }
7701 else 7213 else
7702 { 7214 {
7703 if (!VECTOR_ELT_ORDER_BIG) 7215 if (!BYTES_BIG_ENDIAN)
7704 { 7216 {
7705 rtx num_ele_m1 = GEN_INT (GET_MODE_NUNITS (mode) - 1); 7217 rtx num_ele_m1 = GEN_INT (GET_MODE_NUNITS (mode) - 1);
7706 7218
7707 emit_insn (gen_anddi3 (tmp_gpr, element, num_ele_m1)); 7219 emit_insn (gen_anddi3 (tmp_gpr, element, num_ele_m1));
7708 emit_insn (gen_subdi3 (tmp_gpr, num_ele_m1, tmp_gpr)); 7220 emit_insn (gen_subdi3 (tmp_gpr, num_ele_m1, tmp_gpr));
7773 } 7285 }
7774 else 7286 else
7775 gcc_unreachable (); 7287 gcc_unreachable ();
7776 } 7288 }
7777 7289
7778 /* Helper function for rs6000_split_v4si_init to build up a DImode value from
7779 two SImode values. */
7780
7781 static void
7782 rs6000_split_v4si_init_di_reg (rtx dest, rtx si1, rtx si2, rtx tmp)
7783 {
7784 const unsigned HOST_WIDE_INT mask_32bit = HOST_WIDE_INT_C (0xffffffff);
7785
7786 if (CONST_INT_P (si1) && CONST_INT_P (si2))
7787 {
7788 unsigned HOST_WIDE_INT const1 = (UINTVAL (si1) & mask_32bit) << 32;
7789 unsigned HOST_WIDE_INT const2 = UINTVAL (si2) & mask_32bit;
7790
7791 emit_move_insn (dest, GEN_INT (const1 | const2));
7792 return;
7793 }
7794
7795 /* Put si1 into upper 32-bits of dest. */
7796 if (CONST_INT_P (si1))
7797 emit_move_insn (dest, GEN_INT ((UINTVAL (si1) & mask_32bit) << 32));
7798 else
7799 {
7800 /* Generate RLDIC. */
7801 rtx si1_di = gen_rtx_REG (DImode, regno_or_subregno (si1));
7802 rtx shift_rtx = gen_rtx_ASHIFT (DImode, si1_di, GEN_INT (32));
7803 rtx mask_rtx = GEN_INT (mask_32bit << 32);
7804 rtx and_rtx = gen_rtx_AND (DImode, shift_rtx, mask_rtx);
7805 gcc_assert (!reg_overlap_mentioned_p (dest, si1));
7806 emit_insn (gen_rtx_SET (dest, and_rtx));
7807 }
7808
7809 /* Put si2 into the temporary. */
7810 gcc_assert (!reg_overlap_mentioned_p (dest, tmp));
7811 if (CONST_INT_P (si2))
7812 emit_move_insn (tmp, GEN_INT (UINTVAL (si2) & mask_32bit));
7813 else
7814 emit_insn (gen_zero_extendsidi2 (tmp, si2));
7815
7816 /* Combine the two parts. */
7817 emit_insn (gen_iordi3 (dest, dest, tmp));
7818 return;
7819 }
7820
7821 /* Split a V4SI initialization. */
7822
7823 void
7824 rs6000_split_v4si_init (rtx operands[])
7825 {
7826 rtx dest = operands[0];
7827
7828 /* Destination is a GPR, build up the two DImode parts in place. */
7829 if (REG_P (dest) || SUBREG_P (dest))
7830 {
7831 int d_regno = regno_or_subregno (dest);
7832 rtx scalar1 = operands[1];
7833 rtx scalar2 = operands[2];
7834 rtx scalar3 = operands[3];
7835 rtx scalar4 = operands[4];
7836 rtx tmp1 = operands[5];
7837 rtx tmp2 = operands[6];
7838
7839 /* Even though we only need one temporary (plus the destination, which
7840 has an early clobber constraint, try to use two temporaries, one for
7841 each double word created. That way the 2nd insn scheduling pass can
7842 rearrange things so the two parts are done in parallel. */
7843 if (BYTES_BIG_ENDIAN)
7844 {
7845 rtx di_lo = gen_rtx_REG (DImode, d_regno);
7846 rtx di_hi = gen_rtx_REG (DImode, d_regno + 1);
7847 rs6000_split_v4si_init_di_reg (di_lo, scalar1, scalar2, tmp1);
7848 rs6000_split_v4si_init_di_reg (di_hi, scalar3, scalar4, tmp2);
7849 }
7850 else
7851 {
7852 rtx di_lo = gen_rtx_REG (DImode, d_regno + 1);
7853 rtx di_hi = gen_rtx_REG (DImode, d_regno);
7854 gcc_assert (!VECTOR_ELT_ORDER_BIG);
7855 rs6000_split_v4si_init_di_reg (di_lo, scalar4, scalar3, tmp1);
7856 rs6000_split_v4si_init_di_reg (di_hi, scalar2, scalar1, tmp2);
7857 }
7858 return;
7859 }
7860
7861 else
7862 gcc_unreachable ();
7863 }
7864
7865 /* Return alignment of TYPE. Existing alignment is ALIGN. HOW 7290 /* Return alignment of TYPE. Existing alignment is ALIGN. HOW
7866 selects whether the alignment is abi mandated, optional, or 7291 selects whether the alignment is abi mandated, optional, or
7867 both abi and optional alignment. */ 7292 both abi and optional alignment. */
7868 7293
7869 unsigned int 7294 unsigned int
7870 rs6000_data_alignment (tree type, unsigned int align, enum data_align how) 7295 rs6000_data_alignment (tree type, unsigned int align, enum data_align how)
7871 { 7296 {
7872 if (how != align_opt) 7297 if (how != align_opt)
7873 { 7298 {
7874 if (TREE_CODE (type) == VECTOR_TYPE) 7299 if (TREE_CODE (type) == VECTOR_TYPE && align < 128)
7875 { 7300 align = 128;
7876 if (TARGET_PAIRED_FLOAT && PAIRED_VECTOR_MODE (TYPE_MODE (type)))
7877 {
7878 if (align < 64)
7879 align = 64;
7880 }
7881 else if (align < 128)
7882 align = 128;
7883 }
7884 } 7301 }
7885 7302
7886 if (how != align_abi) 7303 if (how != align_abi)
7887 { 7304 {
7888 if (TREE_CODE (type) == ARRAY_TYPE 7305 if (TREE_CODE (type) == ARRAY_TYPE
8108 return false; 7525 return false;
8109 7526
8110 if (legitimate_indirect_address_p (addr, strict)) 7527 if (legitimate_indirect_address_p (addr, strict))
8111 return true; 7528 return true;
8112 7529
8113 if (VECTOR_MODE_P (mode) && !mode_supports_vsx_dform_quad (mode)) 7530 if (VECTOR_MODE_P (mode) && !mode_supports_dq_form (mode))
8114 return false; 7531 return false;
8115 7532
8116 if (GET_CODE (addr) != PLUS) 7533 if (GET_CODE (addr) != PLUS)
8117 return false; 7534 return false;
8118 7535
8208 mem_operand_gpr (rtx op, machine_mode mode) 7625 mem_operand_gpr (rtx op, machine_mode mode)
8209 { 7626 {
8210 unsigned HOST_WIDE_INT offset; 7627 unsigned HOST_WIDE_INT offset;
8211 int extra; 7628 int extra;
8212 rtx addr = XEXP (op, 0); 7629 rtx addr = XEXP (op, 0);
7630
7631 /* PR85755: Allow PRE_INC and PRE_DEC addresses. */
7632 if (TARGET_UPDATE
7633 && (GET_CODE (addr) == PRE_INC || GET_CODE (addr) == PRE_DEC)
7634 && mode_supports_pre_incdec_p (mode)
7635 && legitimate_indirect_address_p (XEXP (addr, 0), false))
7636 return true;
7637
7638 /* Don't allow non-offsettable addresses. See PRs 83969 and 84279. */
7639 if (!rs6000_offsettable_memref_p (op, mode, false))
7640 return false;
8213 7641
8214 op = address_offset (addr); 7642 op = address_offset (addr);
8215 if (op == NULL_RTX) 7643 if (op == NULL_RTX)
8216 return true; 7644 return true;
8217 7645
8286 a vector mode, if we want to use the VSX registers to move it around, 7714 a vector mode, if we want to use the VSX registers to move it around,
8287 we need to restrict ourselves to reg+reg addressing. Similarly for 7715 we need to restrict ourselves to reg+reg addressing. Similarly for
8288 IEEE 128-bit floating point that is passed in a single vector 7716 IEEE 128-bit floating point that is passed in a single vector
8289 register. */ 7717 register. */
8290 if (VECTOR_MEM_ALTIVEC_OR_VSX_P (mode)) 7718 if (VECTOR_MEM_ALTIVEC_OR_VSX_P (mode))
8291 return mode_supports_vsx_dform_quad (mode); 7719 return mode_supports_dq_form (mode);
8292 break;
8293
8294 case E_V2SImode:
8295 case E_V2SFmode:
8296 /* Paired vector modes. Only reg+reg addressing is valid. */
8297 if (TARGET_PAIRED_FLOAT)
8298 return false;
8299 break; 7720 break;
8300 7721
8301 case E_SDmode: 7722 case E_SDmode:
8302 /* If we can do direct load/stores of SDmode, restrict it to reg+reg 7723 /* If we can do direct load/stores of SDmode, restrict it to reg+reg
8303 addressing for the LFIWZX and STFIWX instructions. */ 7724 addressing for the LFIWZX and STFIWX instructions. */
8353 if (GET_CODE (op) != SYMBOL_REF) 7774 if (GET_CODE (op) != SYMBOL_REF)
8354 return false; 7775 return false;
8355 7776
8356 /* ISA 3.0 vector d-form addressing is restricted, don't allow 7777 /* ISA 3.0 vector d-form addressing is restricted, don't allow
8357 SYMBOL_REF. */ 7778 SYMBOL_REF. */
8358 if (mode_supports_vsx_dform_quad (mode)) 7779 if (mode_supports_dq_form (mode))
8359 return false; 7780 return false;
8360 7781
8361 dsize = GET_MODE_SIZE (mode); 7782 dsize = GET_MODE_SIZE (mode);
8362 decl = SYMBOL_REF_DECL (op); 7783 decl = SYMBOL_REF_DECL (op);
8363 if (!decl) 7784 if (!decl)
8483 *tocrel_base_ret = tocrel_base; 7904 *tocrel_base_ret = tocrel_base;
8484 if (tocrel_offset_ret) 7905 if (tocrel_offset_ret)
8485 *tocrel_offset_ret = tocrel_offset; 7906 *tocrel_offset_ret = tocrel_offset;
8486 7907
8487 return (GET_CODE (tocrel_base) == UNSPEC 7908 return (GET_CODE (tocrel_base) == UNSPEC
8488 && XINT (tocrel_base, 1) == UNSPEC_TOCREL); 7909 && XINT (tocrel_base, 1) == UNSPEC_TOCREL
7910 && REG_P (XVECEXP (tocrel_base, 0, 1))
7911 && REGNO (XVECEXP (tocrel_base, 0, 1)) == TOC_REGISTER);
8489 } 7912 }
8490 7913
8491 /* Return true if X is a constant pool address, and also for cmodel=medium 7914 /* Return true if X is a constant pool address, and also for cmodel=medium
8492 if X is a toc-relative address known to be offsettable within MODE. */ 7915 if X is a toc-relative address known to be offsettable within MODE. */
8493 7916
8524 return false; 7947 return false;
8525 if (!REG_P (XEXP (x, 0))) 7948 if (!REG_P (XEXP (x, 0)))
8526 return false; 7949 return false;
8527 if (!INT_REG_OK_FOR_BASE_P (XEXP (x, 0), strict)) 7950 if (!INT_REG_OK_FOR_BASE_P (XEXP (x, 0), strict))
8528 return false; 7951 return false;
8529 if (mode_supports_vsx_dform_quad (mode)) 7952 if (mode_supports_dq_form (mode))
8530 return quad_address_p (x, mode, strict); 7953 return quad_address_p (x, mode, strict);
8531 if (!reg_offset_addressing_ok_p (mode)) 7954 if (!reg_offset_addressing_ok_p (mode))
8532 return virtual_stack_registers_memory_p (x); 7955 return virtual_stack_registers_memory_p (x);
8533 if (legitimate_constant_pool_address_p (x, mode, strict || lra_in_progress)) 7956 if (legitimate_constant_pool_address_p (x, mode, strict || lra_in_progress))
8534 return true; 7957 return true;
8537 7960
8538 offset = INTVAL (XEXP (x, 1)); 7961 offset = INTVAL (XEXP (x, 1));
8539 extra = 0; 7962 extra = 0;
8540 switch (mode) 7963 switch (mode)
8541 { 7964 {
8542 case E_V2SImode:
8543 case E_V2SFmode:
8544 /* Paired single modes: offset addressing isn't valid. */
8545 return false;
8546
8547 case E_DFmode: 7965 case E_DFmode:
8548 case E_DDmode: 7966 case E_DDmode:
8549 case E_DImode: 7967 case E_DImode:
8550 /* If we are using VSX scalar loads, restrict ourselves to reg+reg 7968 /* If we are using VSX scalar loads, restrict ourselves to reg+reg
8551 addressing. */ 7969 addressing. */
8642 if (GET_CODE (XEXP (x, 0)) != REG) 8060 if (GET_CODE (XEXP (x, 0)) != REG)
8643 return false; 8061 return false;
8644 if (!INT_REG_OK_FOR_BASE_P (XEXP (x, 0), strict)) 8062 if (!INT_REG_OK_FOR_BASE_P (XEXP (x, 0), strict))
8645 return false; 8063 return false;
8646 /* quad word addresses are restricted, and we can't use LO_SUM. */ 8064 /* quad word addresses are restricted, and we can't use LO_SUM. */
8647 if (mode_supports_vsx_dform_quad (mode)) 8065 if (mode_supports_dq_form (mode))
8648 return false; 8066 return false;
8649 x = XEXP (x, 1); 8067 x = XEXP (x, 1);
8650 8068
8651 if (TARGET_ELF || TARGET_MACHO) 8069 if (TARGET_ELF || TARGET_MACHO)
8652 { 8070 {
8668 return false; 8086 return false;
8669 if (GET_MODE_NUNITS (mode) != 1) 8087 if (GET_MODE_NUNITS (mode) != 1)
8670 return false; 8088 return false;
8671 if (GET_MODE_SIZE (mode) > UNITS_PER_WORD 8089 if (GET_MODE_SIZE (mode) > UNITS_PER_WORD
8672 && !(/* ??? Assume floating point reg based on mode? */ 8090 && !(/* ??? Assume floating point reg based on mode? */
8673 TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT 8091 TARGET_HARD_FLOAT && (mode == DFmode || mode == DDmode)))
8674 && (mode == DFmode || mode == DDmode)))
8675 return false; 8092 return false;
8676 8093
8677 return CONSTANT_P (x) || large_toc_ok; 8094 return CONSTANT_P (x) || large_toc_ok;
8678 } 8095 }
8679 8096
8707 machine_mode mode) 8124 machine_mode mode)
8708 { 8125 {
8709 unsigned int extra; 8126 unsigned int extra;
8710 8127
8711 if (!reg_offset_addressing_ok_p (mode) 8128 if (!reg_offset_addressing_ok_p (mode)
8712 || mode_supports_vsx_dform_quad (mode)) 8129 || mode_supports_dq_form (mode))
8713 { 8130 {
8714 if (virtual_stack_registers_memory_p (x)) 8131 if (virtual_stack_registers_memory_p (x))
8715 return x; 8132 return x;
8716 8133
8717 /* In theory we should not be seeing addresses of the form reg+0, 8134 /* In theory we should not be seeing addresses of the form reg+0,
8759 8176
8760 if (GET_CODE (x) == PLUS 8177 if (GET_CODE (x) == PLUS
8761 && GET_CODE (XEXP (x, 0)) == REG 8178 && GET_CODE (XEXP (x, 0)) == REG
8762 && GET_CODE (XEXP (x, 1)) == CONST_INT 8179 && GET_CODE (XEXP (x, 1)) == CONST_INT
8763 && ((unsigned HOST_WIDE_INT) (INTVAL (XEXP (x, 1)) + 0x8000) 8180 && ((unsigned HOST_WIDE_INT) (INTVAL (XEXP (x, 1)) + 0x8000)
8764 >= 0x10000 - extra) 8181 >= 0x10000 - extra))
8765 && !PAIRED_VECTOR_MODE (mode))
8766 { 8182 {
8767 HOST_WIDE_INT high_int, low_int; 8183 HOST_WIDE_INT high_int, low_int;
8768 rtx sum; 8184 rtx sum;
8769 low_int = ((INTVAL (XEXP (x, 1)) & 0xffff) ^ 0x8000) - 0x8000; 8185 low_int = ((INTVAL (XEXP (x, 1)) & 0xffff) ^ 0x8000) - 0x8000;
8770 if (low_int >= 0x8000 - extra) 8186 if (low_int >= 0x8000 - extra)
8778 && GET_CODE (XEXP (x, 0)) == REG 8194 && GET_CODE (XEXP (x, 0)) == REG
8779 && GET_CODE (XEXP (x, 1)) != CONST_INT 8195 && GET_CODE (XEXP (x, 1)) != CONST_INT
8780 && GET_MODE_NUNITS (mode) == 1 8196 && GET_MODE_NUNITS (mode) == 1
8781 && (GET_MODE_SIZE (mode) <= UNITS_PER_WORD 8197 && (GET_MODE_SIZE (mode) <= UNITS_PER_WORD
8782 || (/* ??? Assume floating point reg based on mode? */ 8198 || (/* ??? Assume floating point reg based on mode? */
8783 (TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT) 8199 TARGET_HARD_FLOAT && (mode == DFmode || mode == DDmode)))
8784 && (mode == DFmode || mode == DDmode)))
8785 && !avoiding_indexed_address_p (mode)) 8200 && !avoiding_indexed_address_p (mode))
8786 { 8201 {
8787 return gen_rtx_PLUS (Pmode, XEXP (x, 0), 8202 return gen_rtx_PLUS (Pmode, XEXP (x, 0),
8788 force_reg (Pmode, force_operand (XEXP (x, 1), 0))); 8203 force_reg (Pmode, force_operand (XEXP (x, 1), 0)));
8789 }
8790 else if (PAIRED_VECTOR_MODE (mode))
8791 {
8792 if (mode == DImode)
8793 return x;
8794 /* We accept [reg + reg]. */
8795
8796 if (GET_CODE (x) == PLUS)
8797 {
8798 rtx op1 = XEXP (x, 0);
8799 rtx op2 = XEXP (x, 1);
8800 rtx y;
8801
8802 op1 = force_reg (Pmode, op1);
8803 op2 = force_reg (Pmode, op2);
8804
8805 /* We can't always do [reg + reg] for these, because [reg +
8806 reg + offset] is not a legitimate addressing mode. */
8807 y = gen_rtx_PLUS (Pmode, op1, op2);
8808
8809 if ((GET_MODE_SIZE (mode) > 8 || mode == DDmode) && REG_P (op2))
8810 return force_reg (Pmode, y);
8811 else
8812 return y;
8813 }
8814
8815 return force_reg (Pmode, x);
8816 } 8204 }
8817 else if ((TARGET_ELF 8205 else if ((TARGET_ELF
8818 #if TARGET_MACHO 8206 #if TARGET_MACHO
8819 || !MACHO_DYNAMIC_NO_PIC_P 8207 || !MACHO_DYNAMIC_NO_PIC_P
8820 #endif 8208 #endif
8827 && GET_CODE (x) != CONST_DOUBLE 8215 && GET_CODE (x) != CONST_DOUBLE
8828 && CONSTANT_P (x) 8216 && CONSTANT_P (x)
8829 && GET_MODE_NUNITS (mode) == 1 8217 && GET_MODE_NUNITS (mode) == 1
8830 && (GET_MODE_SIZE (mode) <= UNITS_PER_WORD 8218 && (GET_MODE_SIZE (mode) <= UNITS_PER_WORD
8831 || (/* ??? Assume floating point reg based on mode? */ 8219 || (/* ??? Assume floating point reg based on mode? */
8832 (TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT) 8220 TARGET_HARD_FLOAT && (mode == DFmode || mode == DDmode))))
8833 && (mode == DFmode || mode == DDmode))))
8834 { 8221 {
8835 rtx reg = gen_reg_rtx (Pmode); 8222 rtx reg = gen_reg_rtx (Pmode);
8836 if (TARGET_ELF) 8223 if (TARGET_ELF)
8837 emit_insn (gen_elf_high (reg, x)); 8224 emit_insn (gen_elf_high (reg, x));
8838 else 8225 else
9065 splitter that runs after reload needs memory to transfer from 8452 splitter that runs after reload needs memory to transfer from
9066 a gpr to fpr. See PR70098 and PR71763 which are not fixed 8453 a gpr to fpr. See PR70098 and PR71763 which are not fixed
9067 for the difficult case. It's better to not create problems 8454 for the difficult case. It's better to not create problems
9068 in the first place. */ 8455 in the first place. */
9069 if (icode != CODE_FOR_nothing 8456 if (icode != CODE_FOR_nothing
9070 && (icode == CODE_FOR_ctrsi_internal1 8457 && (icode == CODE_FOR_bdz_si
9071 || icode == CODE_FOR_ctrdi_internal1 8458 || icode == CODE_FOR_bdz_di
9072 || icode == CODE_FOR_ctrsi_internal2 8459 || icode == CODE_FOR_bdnz_si
9073 || icode == CODE_FOR_ctrdi_internal2)) 8460 || icode == CODE_FOR_bdnz_di
8461 || icode == CODE_FOR_bdztf_si
8462 || icode == CODE_FOR_bdztf_di
8463 || icode == CODE_FOR_bdnztf_si
8464 || icode == CODE_FOR_bdnztf_di))
9074 return false; 8465 return false;
9075 8466
9076 return true; 8467 return true;
9077 } 8468 }
9078 8469
9447 rs6000_legitimize_reload_address (rtx x, machine_mode mode, 8838 rs6000_legitimize_reload_address (rtx x, machine_mode mode,
9448 int opnum, int type, 8839 int opnum, int type,
9449 int ind_levels ATTRIBUTE_UNUSED, int *win) 8840 int ind_levels ATTRIBUTE_UNUSED, int *win)
9450 { 8841 {
9451 bool reg_offset_p = reg_offset_addressing_ok_p (mode); 8842 bool reg_offset_p = reg_offset_addressing_ok_p (mode);
9452 bool quad_offset_p = mode_supports_vsx_dform_quad (mode); 8843 bool quad_offset_p = mode_supports_dq_form (mode);
9453 8844
9454 /* Nasty hack for vsx_splat_v2df/v2di load from mem, which takes a 8845 /* Nasty hack for vsx_splat_v2df/v2di load from mem, which takes a
9455 DFmode/DImode MEM. Ditto for ISA 3.0 vsx_splat_v4sf/v4si. */ 8846 DFmode/DImode MEM. Ditto for ISA 3.0 vsx_splat_v4sf/v4si. */
9456 if (reg_offset_p 8847 if (reg_offset_p
9457 && opnum == 1 8848 && opnum == 1
9540 && REG_P (XEXP (x, 0)) 8931 && REG_P (XEXP (x, 0))
9541 && REGNO (XEXP (x, 0)) < FIRST_PSEUDO_REGISTER 8932 && REGNO (XEXP (x, 0)) < FIRST_PSEUDO_REGISTER
9542 && INT_REG_OK_FOR_BASE_P (XEXP (x, 0), 1) 8933 && INT_REG_OK_FOR_BASE_P (XEXP (x, 0), 1)
9543 && CONST_INT_P (XEXP (x, 1)) 8934 && CONST_INT_P (XEXP (x, 1))
9544 && reg_offset_p 8935 && reg_offset_p
9545 && !PAIRED_VECTOR_MODE (mode)
9546 && (quad_offset_p || !VECTOR_MODE_P (mode) || VECTOR_MEM_NONE_P (mode))) 8936 && (quad_offset_p || !VECTOR_MODE_P (mode) || VECTOR_MEM_NONE_P (mode)))
9547 { 8937 {
9548 HOST_WIDE_INT val = INTVAL (XEXP (x, 1)); 8938 HOST_WIDE_INT val = INTVAL (XEXP (x, 1));
9549 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000; 8939 HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
9550 HOST_WIDE_INT high 8940 HOST_WIDE_INT high
9581 8971
9582 if (GET_CODE (x) == SYMBOL_REF 8972 if (GET_CODE (x) == SYMBOL_REF
9583 && reg_offset_p 8973 && reg_offset_p
9584 && !quad_offset_p 8974 && !quad_offset_p
9585 && (!VECTOR_MODE_P (mode) || VECTOR_MEM_NONE_P (mode)) 8975 && (!VECTOR_MODE_P (mode) || VECTOR_MEM_NONE_P (mode))
9586 && !PAIRED_VECTOR_MODE (mode)
9587 #if TARGET_MACHO 8976 #if TARGET_MACHO
9588 && DEFAULT_ABI == ABI_DARWIN 8977 && DEFAULT_ABI == ABI_DARWIN
9589 && (flag_pic || MACHO_DYNAMIC_NO_PIC_P) 8978 && (flag_pic || MACHO_DYNAMIC_NO_PIC_P)
9590 && machopic_symbol_defined_p (x) 8979 && machopic_symbol_defined_p (x)
9591 #else 8980 #else
9616 && mode != KFmode 9005 && mode != KFmode
9617 && (mode != TImode || !TARGET_VSX) 9006 && (mode != TImode || !TARGET_VSX)
9618 && mode != PTImode 9007 && mode != PTImode
9619 && (mode != DImode || TARGET_POWERPC64) 9008 && (mode != DImode || TARGET_POWERPC64)
9620 && ((mode != DFmode && mode != DDmode) || TARGET_POWERPC64 9009 && ((mode != DFmode && mode != DDmode) || TARGET_POWERPC64
9621 || (TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT))) 9010 || TARGET_HARD_FLOAT))
9622 { 9011 {
9623 #if TARGET_MACHO 9012 #if TARGET_MACHO
9624 if (flag_pic) 9013 if (flag_pic)
9625 { 9014 {
9626 rtx offset = machopic_gen_offset (x); 9015 rtx offset = machopic_gen_offset (x);
9735 during assembly output. */ 9124 during assembly output. */
9736 static bool 9125 static bool
9737 rs6000_legitimate_address_p (machine_mode mode, rtx x, bool reg_ok_strict) 9126 rs6000_legitimate_address_p (machine_mode mode, rtx x, bool reg_ok_strict)
9738 { 9127 {
9739 bool reg_offset_p = reg_offset_addressing_ok_p (mode); 9128 bool reg_offset_p = reg_offset_addressing_ok_p (mode);
9740 bool quad_offset_p = mode_supports_vsx_dform_quad (mode); 9129 bool quad_offset_p = mode_supports_dq_form (mode);
9741 9130
9742 /* If this is an unaligned stvx/ldvx type address, discard the outer AND. */ 9131 /* If this is an unaligned stvx/ldvx type address, discard the outer AND. */
9743 if (VECTOR_MEM_ALTIVEC_P (mode) 9132 if (VECTOR_MEM_ALTIVEC_P (mode)
9744 && GET_CODE (x) == AND 9133 && GET_CODE (x) == AND
9745 && GET_CODE (XEXP (x, 1)) == CONST_INT 9134 && GET_CODE (XEXP (x, 1)) == CONST_INT
9768 { 9157 {
9769 if (legitimate_small_data_p (mode, x)) 9158 if (legitimate_small_data_p (mode, x))
9770 return 1; 9159 return 1;
9771 if (legitimate_constant_pool_address_p (x, mode, 9160 if (legitimate_constant_pool_address_p (x, mode,
9772 reg_ok_strict || lra_in_progress)) 9161 reg_ok_strict || lra_in_progress))
9773 return 1;
9774 if (reg_addr[mode].fused_toc && GET_CODE (x) == UNSPEC
9775 && XINT (x, 1) == UNSPEC_FUSION_ADDIS)
9776 return 1; 9162 return 1;
9777 } 9163 }
9778 9164
9779 /* For TImode, if we have TImode in VSX registers, only allow register 9165 /* For TImode, if we have TImode in VSX registers, only allow register
9780 indirect addresses. This will allow the values to go in either GPRs 9166 indirect addresses. This will allow the values to go in either GPRs
9797 && GET_CODE (XEXP (x, 1)) == CONST_INT) 9183 && GET_CODE (XEXP (x, 1)) == CONST_INT)
9798 return 1; 9184 return 1;
9799 if (rs6000_legitimate_offset_address_p (mode, x, reg_ok_strict, false)) 9185 if (rs6000_legitimate_offset_address_p (mode, x, reg_ok_strict, false))
9800 return 1; 9186 return 1;
9801 if (!FLOAT128_2REG_P (mode) 9187 if (!FLOAT128_2REG_P (mode)
9802 && ((TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT) 9188 && (TARGET_HARD_FLOAT
9803 || TARGET_POWERPC64 9189 || TARGET_POWERPC64
9804 || (mode != DFmode && mode != DDmode)) 9190 || (mode != DFmode && mode != DDmode))
9805 && (TARGET_POWERPC64 || mode != DImode) 9191 && (TARGET_POWERPC64 || mode != DImode)
9806 && (mode != TImode || VECTOR_MEM_VSX_P (TImode)) 9192 && (mode != TImode || VECTOR_MEM_VSX_P (TImode))
9807 && mode != PTImode 9193 && mode != PTImode
9948 (mem:DI (plus:SI (reg/f:SI 31 31) (const_int 32760 [0x7ff8]))) 9334 (mem:DI (plus:SI (reg/f:SI 31 31) (const_int 32760 [0x7ff8])))
9949 9335
9950 in 32-bit mode, that the recog predicate rejects. */ 9336 in 32-bit mode, that the recog predicate rejects. */
9951 9337
9952 static bool 9338 static bool
9953 rs6000_offsettable_memref_p (rtx op, machine_mode reg_mode) 9339 rs6000_offsettable_memref_p (rtx op, machine_mode reg_mode, bool strict)
9954 { 9340 {
9955 bool worst_case; 9341 bool worst_case;
9956 9342
9957 if (!MEM_P (op)) 9343 if (!MEM_P (op))
9958 return false; 9344 return false;
9959 9345
9960 /* First mimic offsettable_memref_p. */ 9346 /* First mimic offsettable_memref_p. */
9961 if (offsettable_address_p (true, GET_MODE (op), XEXP (op, 0))) 9347 if (offsettable_address_p (strict, GET_MODE (op), XEXP (op, 0)))
9962 return true; 9348 return true;
9963 9349
9964 /* offsettable_address_p invokes rs6000_mode_dependent_address, but 9350 /* offsettable_address_p invokes rs6000_mode_dependent_address, but
9965 the latter predicate knows nothing about the mode of the memory 9351 the latter predicate knows nothing about the mode of the memory
9966 reference and, therefore, assumes that it is the largest supported 9352 reference and, therefore, assumes that it is the largest supported
9970 at least with a little bit of help here given that we know the 9356 at least with a little bit of help here given that we know the
9971 actual registers used. */ 9357 actual registers used. */
9972 worst_case = ((TARGET_POWERPC64 && GET_MODE_CLASS (reg_mode) == MODE_INT) 9358 worst_case = ((TARGET_POWERPC64 && GET_MODE_CLASS (reg_mode) == MODE_INT)
9973 || GET_MODE_SIZE (reg_mode) == 4); 9359 || GET_MODE_SIZE (reg_mode) == 4);
9974 return rs6000_legitimate_offset_address_p (GET_MODE (op), XEXP (op, 0), 9360 return rs6000_legitimate_offset_address_p (GET_MODE (op), XEXP (op, 0),
9975 true, worst_case); 9361 strict, worst_case);
9976 } 9362 }
9977 9363
9978 /* Determine the reassociation width to be used in reassociate_bb. 9364 /* Determine the reassociation width to be used in reassociate_bb.
9979 This takes into account how many parallel operations we 9365 This takes into account how many parallel operations we
9980 can actually do of a given type, and also the latency. 9366 can actually do of a given type, and also the latency.
9988 9374
9989 static int 9375 static int
9990 rs6000_reassociation_width (unsigned int opc ATTRIBUTE_UNUSED, 9376 rs6000_reassociation_width (unsigned int opc ATTRIBUTE_UNUSED,
9991 machine_mode mode) 9377 machine_mode mode)
9992 { 9378 {
9993 switch (rs6000_cpu) 9379 switch (rs6000_tune)
9994 { 9380 {
9995 case PROCESSOR_POWER8: 9381 case PROCESSOR_POWER8:
9996 case PROCESSOR_POWER9: 9382 case PROCESSOR_POWER9:
9997 if (DECIMAL_FLOAT_MODE_P (mode)) 9383 if (DECIMAL_FLOAT_MODE_P (mode))
9998 return 1; 9384 return 1;
9999 if (VECTOR_MODE_P (mode)) 9385 if (VECTOR_MODE_P (mode))
10000 return 4; 9386 return 4;
10001 if (INTEGRAL_MODE_P (mode)) 9387 if (INTEGRAL_MODE_P (mode))
10002 return opc == MULT_EXPR ? 4 : 6; 9388 return 1;
10003 if (FLOAT_MODE_P (mode)) 9389 if (FLOAT_MODE_P (mode))
10004 return 4; 9390 return 4;
10005 break; 9391 break;
10006 default: 9392 default:
10007 break; 9393 break;
10494 { 9880 {
10495 /* This should be fixed with the introduction of CONST_WIDE_INT. */ 9881 /* This should be fixed with the introduction of CONST_WIDE_INT. */
10496 gcc_unreachable (); 9882 gcc_unreachable ();
10497 } 9883 }
10498 9884
9885 #ifdef HAVE_AS_GNU_ATTRIBUTE
9886 /* If we use a long double type, set the flags in .gnu_attribute that say
9887 what the long double type is. This is to allow the linker's warning
9888 message for the wrong long double to be useful, even if the function does
9889 not do a call (for example, doing a 128-bit add on power9 if the long
9890 double type is IEEE 128-bit. Do not set this if __ibm128 or __floa128 are
9891 used if they aren't the default long dobule type. */
9892 if (rs6000_gnu_attr && (HAVE_LD_PPC_GNU_ATTR_LONG_DOUBLE || TARGET_64BIT))
9893 {
9894 if (TARGET_LONG_DOUBLE_128 && (mode == TFmode || mode == TCmode))
9895 rs6000_passes_float = rs6000_passes_long_double = true;
9896
9897 else if (!TARGET_LONG_DOUBLE_128 && (mode == DFmode || mode == DCmode))
9898 rs6000_passes_float = rs6000_passes_long_double = true;
9899 }
9900 #endif
9901
10499 /* See if we need to special case SImode/SFmode SUBREG moves. */ 9902 /* See if we need to special case SImode/SFmode SUBREG moves. */
10500 if ((mode == SImode || mode == SFmode) && SUBREG_P (source) 9903 if ((mode == SImode || mode == SFmode) && SUBREG_P (source)
10501 && rs6000_emit_move_si_sf_subreg (dest, source, mode)) 9904 && rs6000_emit_move_si_sf_subreg (dest, source, mode))
10502 return; 9905 return;
10503 9906
10585 int regno = REGNO (SUBREG_REG (operands[1])); 9988 int regno = REGNO (SUBREG_REG (operands[1]));
10586 9989
10587 if (regno >= FIRST_PSEUDO_REGISTER) 9990 if (regno >= FIRST_PSEUDO_REGISTER)
10588 { 9991 {
10589 cl = reg_preferred_class (regno); 9992 cl = reg_preferred_class (regno);
10590 regno = cl == NO_REGS ? -1 : ira_class_hard_regs[cl][1]; 9993 regno = reg_renumber[regno];
9994 if (regno < 0)
9995 regno = cl == NO_REGS ? -1 : ira_class_hard_regs[cl][1];
10591 } 9996 }
10592 if (regno >= 0 && ! FP_REGNO_P (regno)) 9997 if (regno >= 0 && ! FP_REGNO_P (regno))
10593 { 9998 {
10594 mode = SDmode; 9999 mode = SDmode;
10595 operands[0] = gen_lowpart_SUBREG (SDmode, operands[0]); 10000 operands[0] = gen_lowpart_SUBREG (SDmode, operands[0]);
10610 10015
10611 if (regno >= FIRST_PSEUDO_REGISTER) 10016 if (regno >= FIRST_PSEUDO_REGISTER)
10612 { 10017 {
10613 cl = reg_preferred_class (regno); 10018 cl = reg_preferred_class (regno);
10614 gcc_assert (cl != NO_REGS); 10019 gcc_assert (cl != NO_REGS);
10615 regno = ira_class_hard_regs[cl][0]; 10020 regno = reg_renumber[regno];
10021 if (regno < 0)
10022 regno = ira_class_hard_regs[cl][0];
10616 } 10023 }
10617 if (FP_REGNO_P (regno)) 10024 if (FP_REGNO_P (regno))
10618 { 10025 {
10619 if (GET_MODE (operands[0]) != DDmode) 10026 if (GET_MODE (operands[0]) != DDmode)
10620 operands[0] = gen_rtx_SUBREG (DDmode, operands[0], 0); 10027 operands[0] = gen_rtx_SUBREG (DDmode, operands[0], 0);
10639 int regno = REGNO (SUBREG_REG (operands[0])); 10046 int regno = REGNO (SUBREG_REG (operands[0]));
10640 10047
10641 if (regno >= FIRST_PSEUDO_REGISTER) 10048 if (regno >= FIRST_PSEUDO_REGISTER)
10642 { 10049 {
10643 cl = reg_preferred_class (regno); 10050 cl = reg_preferred_class (regno);
10644 regno = cl == NO_REGS ? -1 : ira_class_hard_regs[cl][0]; 10051 regno = reg_renumber[regno];
10052 if (regno < 0)
10053 regno = cl == NO_REGS ? -1 : ira_class_hard_regs[cl][0];
10645 } 10054 }
10646 if (regno >= 0 && ! FP_REGNO_P (regno)) 10055 if (regno >= 0 && ! FP_REGNO_P (regno))
10647 { 10056 {
10648 mode = SDmode; 10057 mode = SDmode;
10649 operands[0] = SUBREG_REG (operands[0]); 10058 operands[0] = SUBREG_REG (operands[0]);
10664 10073
10665 if (regno >= FIRST_PSEUDO_REGISTER) 10074 if (regno >= FIRST_PSEUDO_REGISTER)
10666 { 10075 {
10667 cl = reg_preferred_class (regno); 10076 cl = reg_preferred_class (regno);
10668 gcc_assert (cl != NO_REGS); 10077 gcc_assert (cl != NO_REGS);
10669 regno = ira_class_hard_regs[cl][0]; 10078 regno = reg_renumber[regno];
10079 if (regno < 0)
10080 regno = ira_class_hard_regs[cl][0];
10670 } 10081 }
10671 if (FP_REGNO_P (regno)) 10082 if (FP_REGNO_P (regno))
10672 { 10083 {
10673 if (GET_MODE (operands[1]) != DDmode) 10084 if (GET_MODE (operands[1]) != DDmode)
10674 operands[1] = gen_rtx_SUBREG (DDmode, operands[1], 0); 10085 operands[1] = gen_rtx_SUBREG (DDmode, operands[1], 0);
10712 10123
10713 case E_V16QImode: 10124 case E_V16QImode:
10714 case E_V8HImode: 10125 case E_V8HImode:
10715 case E_V4SFmode: 10126 case E_V4SFmode:
10716 case E_V4SImode: 10127 case E_V4SImode:
10717 case E_V2SFmode:
10718 case E_V2SImode:
10719 case E_V2DFmode: 10128 case E_V2DFmode:
10720 case E_V2DImode: 10129 case E_V2DImode:
10721 case E_V1TImode: 10130 case E_V1TImode:
10722 if (CONSTANT_P (operands[1]) 10131 if (CONSTANT_P (operands[1])
10723 && !easy_vector_constant (operands[1], mode)) 10132 && !easy_vector_constant (operands[1], mode))
11090 { 10499 {
11091 /* Note that we do not accept complex types at the top level as 10500 /* Note that we do not accept complex types at the top level as
11092 homogeneous aggregates; these types are handled via the 10501 homogeneous aggregates; these types are handled via the
11093 targetm.calls.split_complex_arg mechanism. Complex types 10502 targetm.calls.split_complex_arg mechanism. Complex types
11094 can be elements of homogeneous aggregates, however. */ 10503 can be elements of homogeneous aggregates, however. */
11095 if (DEFAULT_ABI == ABI_ELFv2 && type && AGGREGATE_TYPE_P (type)) 10504 if (TARGET_HARD_FLOAT && DEFAULT_ABI == ABI_ELFv2 && type
10505 && AGGREGATE_TYPE_P (type))
11096 { 10506 {
11097 machine_mode field_mode = VOIDmode; 10507 machine_mode field_mode = VOIDmode;
11098 int field_count = rs6000_aggregate_candidate (type, &field_mode); 10508 int field_count = rs6000_aggregate_candidate (type, &field_mode);
11099 10509
11100 if (field_count > 0) 10510 if (field_count > 0)
11101 { 10511 {
11102 int n_regs = (SCALAR_FLOAT_MODE_P (field_mode) ? 10512 int reg_size = ALTIVEC_OR_VSX_VECTOR_MODE (field_mode) ? 16 : 8;
11103 (GET_MODE_SIZE (field_mode) + 7) >> 3 : 1); 10513 int field_size = ROUND_UP (GET_MODE_SIZE (field_mode), reg_size);
11104 10514
11105 /* The ELFv2 ABI allows homogeneous aggregates to occupy 10515 /* The ELFv2 ABI allows homogeneous aggregates to occupy
11106 up to AGGR_ARG_NUM_REG registers. */ 10516 up to AGGR_ARG_NUM_REG registers. */
11107 if (field_count * n_regs <= AGGR_ARG_NUM_REG) 10517 if (field_count * field_size <= AGGR_ARG_NUM_REG * reg_size)
11108 { 10518 {
11109 if (elt_mode) 10519 if (elt_mode)
11110 *elt_mode = field_mode; 10520 *elt_mode = field_mode;
11111 if (n_elts) 10521 if (n_elts)
11112 *n_elts = field_count; 10522 *n_elts = field_count;
11351 || FLOAT128_IEEE_P (return_mode) 10761 || FLOAT128_IEEE_P (return_mode)
11352 || (return_type != NULL 10762 || (return_type != NULL
11353 && (TYPE_MAIN_VARIANT (return_type) 10763 && (TYPE_MAIN_VARIANT (return_type)
11354 == long_double_type_node)))) 10764 == long_double_type_node))))
11355 rs6000_passes_long_double = true; 10765 rs6000_passes_long_double = true;
10766
10767 /* Note if we passed or return a IEEE 128-bit type. We changed
10768 the mangling for these types, and we may need to make an alias
10769 with the old mangling. */
10770 if (FLOAT128_IEEE_P (return_mode))
10771 rs6000_passes_ieee128 = true;
11356 } 10772 }
11357 if (ALTIVEC_OR_VSX_VECTOR_MODE (return_mode) 10773 if (ALTIVEC_OR_VSX_VECTOR_MODE (return_mode))
11358 || PAIRED_VECTOR_MODE (return_mode))
11359 rs6000_passes_vector = true; 10774 rs6000_passes_vector = true;
11360 } 10775 }
11361 } 10776 }
11362 #endif 10777 #endif
11363 10778
11417 } 10832 }
11418 10833
11419 static inline bool 10834 static inline bool
11420 is_complex_IBM_long_double (machine_mode mode) 10835 is_complex_IBM_long_double (machine_mode mode)
11421 { 10836 {
11422 return mode == ICmode || (!TARGET_IEEEQUAD && mode == TCmode); 10837 return mode == ICmode || (mode == TCmode && FLOAT128_IBM_P (TCmode));
11423 } 10838 }
11424 10839
11425 /* Whether ABI_V4 passes MODE args to a function in floating point 10840 /* Whether ABI_V4 passes MODE args to a function in floating point
11426 registers. */ 10841 registers. */
11427 10842
11428 static bool 10843 static bool
11429 abi_v4_pass_in_fpr (machine_mode mode) 10844 abi_v4_pass_in_fpr (machine_mode mode, bool named)
11430 { 10845 {
11431 if (!TARGET_HARD_FLOAT) 10846 if (!TARGET_HARD_FLOAT)
11432 return false; 10847 return false;
11433 if (TARGET_SINGLE_FLOAT && mode == SFmode) 10848 if (mode == DFmode)
11434 return true; 10849 return true;
11435 if (TARGET_DOUBLE_FLOAT && mode == DFmode) 10850 if (mode == SFmode && named)
11436 return true; 10851 return true;
11437 /* ABI_V4 passes complex IBM long double in 8 gprs. 10852 /* ABI_V4 passes complex IBM long double in 8 gprs.
11438 Stupid, but we can't change the ABI now. */ 10853 Stupid, but we can't change the ABI now. */
11439 if (is_complex_IBM_long_double (mode)) 10854 if (is_complex_IBM_long_double (mode))
11440 return false; 10855 return false;
11526 && !is_complex_IBM_long_double (mode) 10941 && !is_complex_IBM_long_double (mode)
11527 && FLOAT128_2REG_P (mode)))) 10942 && FLOAT128_2REG_P (mode))))
11528 return 64; 10943 return 64;
11529 else if (FLOAT128_VECTOR_P (mode)) 10944 else if (FLOAT128_VECTOR_P (mode))
11530 return 128; 10945 return 128;
11531 else if (PAIRED_VECTOR_MODE (mode) 10946 else if (type && TREE_CODE (type) == VECTOR_TYPE
11532 || (type && TREE_CODE (type) == VECTOR_TYPE 10947 && int_size_in_bytes (type) >= 8
11533 && int_size_in_bytes (type) >= 8 10948 && int_size_in_bytes (type) < 16)
11534 && int_size_in_bytes (type) < 16))
11535 return 64; 10949 return 64;
11536 else if (ALTIVEC_OR_VSX_VECTOR_MODE (elt_mode) 10950 else if (ALTIVEC_OR_VSX_VECTOR_MODE (elt_mode)
11537 || (type && TREE_CODE (type) == VECTOR_TYPE 10951 || (type && TREE_CODE (type) == VECTOR_TYPE
11538 && int_size_in_bytes (type) >= 16)) 10952 && int_size_in_bytes (type) >= 16))
11539 return 128; 10953 return 128;
11804 && (FLOAT128_IBM_P (mode) 11218 && (FLOAT128_IBM_P (mode)
11805 || FLOAT128_IEEE_P (mode) 11219 || FLOAT128_IEEE_P (mode)
11806 || (type != NULL 11220 || (type != NULL
11807 && TYPE_MAIN_VARIANT (type) == long_double_type_node))) 11221 && TYPE_MAIN_VARIANT (type) == long_double_type_node)))
11808 rs6000_passes_long_double = true; 11222 rs6000_passes_long_double = true;
11809 } 11223
11810 if ((named && ALTIVEC_OR_VSX_VECTOR_MODE (mode)) 11224 /* Note if we passed or return a IEEE 128-bit type. We changed the
11811 || (PAIRED_VECTOR_MODE (mode) 11225 mangling for these types, and we may need to make an alias with
11812 && !cum->stdarg 11226 the old mangling. */
11813 && cum->sysv_gregno <= GP_ARG_MAX_REG)) 11227 if (FLOAT128_IEEE_P (mode))
11228 rs6000_passes_ieee128 = true;
11229 }
11230 if (named && ALTIVEC_OR_VSX_VECTOR_MODE (mode))
11814 rs6000_passes_vector = true; 11231 rs6000_passes_vector = true;
11815 } 11232 }
11816 #endif 11233 #endif
11817 11234
11818 if (TARGET_ALTIVEC_ABI 11235 if (TARGET_ALTIVEC_ABI
11901 GET_MODE_NAME (mode)); 11318 GET_MODE_NAME (mode));
11902 } 11319 }
11903 } 11320 }
11904 else if (DEFAULT_ABI == ABI_V4) 11321 else if (DEFAULT_ABI == ABI_V4)
11905 { 11322 {
11906 if (abi_v4_pass_in_fpr (mode)) 11323 if (abi_v4_pass_in_fpr (mode, named))
11907 { 11324 {
11908 /* _Decimal128 must use an even/odd register pair. This assumes 11325 /* _Decimal128 must use an even/odd register pair. This assumes
11909 that the register number is odd when fregno is odd. */ 11326 that the register number is odd when fregno is odd. */
11910 if (mode == TDmode && (cum->fregno % 2) == 1) 11327 if (mode == TDmode && (cum->fregno % 2) == 1)
11911 cum->fregno++; 11328 cum->fregno++;
12453 } 11870 }
12454 } 11871 }
12455 11872
12456 else if (abi == ABI_V4) 11873 else if (abi == ABI_V4)
12457 { 11874 {
12458 if (abi_v4_pass_in_fpr (mode)) 11875 if (abi_v4_pass_in_fpr (mode, named))
12459 { 11876 {
12460 /* _Decimal128 must use an even/odd register pair. This assumes 11877 /* _Decimal128 must use an even/odd register pair. This assumes
12461 that the register number is odd when fregno is odd. */ 11878 that the register number is odd when fregno is odd. */
12462 if (mode == TDmode && (cum->fregno % 2) == 1) 11879 if (mode == TDmode && (cum->fregno % 2) == 1)
12463 cum->fregno++; 11880 cum->fregno++;
13102 12519
13103 for (nregs = 0; 12520 for (nregs = 0;
13104 fregno <= FP_ARG_V4_MAX_REG && nregs < cfun->va_list_fpr_size; 12521 fregno <= FP_ARG_V4_MAX_REG && nregs < cfun->va_list_fpr_size;
13105 fregno++, off += UNITS_PER_FP_WORD, nregs++) 12522 fregno++, off += UNITS_PER_FP_WORD, nregs++)
13106 { 12523 {
13107 mem = gen_rtx_MEM ((TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT) 12524 mem = gen_rtx_MEM (TARGET_HARD_FLOAT ? DFmode : SFmode,
13108 ? DFmode : SFmode,
13109 plus_constant (Pmode, save_area, off)); 12525 plus_constant (Pmode, save_area, off));
13110 MEM_NOTRAP_P (mem) = 1; 12526 MEM_NOTRAP_P (mem) = 1;
13111 set_mem_alias_set (mem, set); 12527 set_mem_alias_set (mem, set);
13112 set_mem_align (mem, GET_MODE_ALIGNMENT ( 12528 set_mem_align (mem, GET_MODE_ALIGNMENT (
13113 (TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT) 12529 TARGET_HARD_FLOAT ? DFmode : SFmode));
13114 ? DFmode : SFmode));
13115 emit_move_insn (mem, gen_rtx_REG ( 12530 emit_move_insn (mem, gen_rtx_REG (
13116 (TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT) 12531 TARGET_HARD_FLOAT ? DFmode : SFmode, fregno));
13117 ? DFmode : SFmode, fregno));
13118 } 12532 }
13119 12533
13120 emit_label (lab); 12534 emit_label (lab);
13121 } 12535 }
13122 } 12536 }
13377 rsize = (size + 3) / 4; 12791 rsize = (size + 3) / 4;
13378 int pad = 4 * rsize - size; 12792 int pad = 4 * rsize - size;
13379 align = 1; 12793 align = 1;
13380 12794
13381 machine_mode mode = TYPE_MODE (type); 12795 machine_mode mode = TYPE_MODE (type);
13382 if (abi_v4_pass_in_fpr (mode)) 12796 if (abi_v4_pass_in_fpr (mode, false))
13383 { 12797 {
13384 /* FP args go in FP registers, if present. */ 12798 /* FP args go in FP registers, if present. */
13385 reg = fpr; 12799 reg = fpr;
13386 n_reg = (size + 7) / 8; 12800 n_reg = (size + 7) / 8;
13387 sav_ofs = ((TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT) ? 8 : 4) * 4; 12801 sav_ofs = (TARGET_HARD_FLOAT ? 8 : 4) * 4;
13388 sav_scale = ((TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT) ? 8 : 4); 12802 sav_scale = (TARGET_HARD_FLOAT ? 8 : 4);
13389 if (mode != SFmode && mode != SDmode) 12803 if (mode != SFmode && mode != SDmode)
13390 align = 8; 12804 align = 8;
13391 } 12805 }
13392 else 12806 else
13393 { 12807 {
13511 tree tmp = create_tmp_var (type, "va_arg_tmp"); 12925 tree tmp = create_tmp_var (type, "va_arg_tmp");
13512 tree dest_addr = build_fold_addr_expr (tmp); 12926 tree dest_addr = build_fold_addr_expr (tmp);
13513 12927
13514 tree copy = build_call_expr (builtin_decl_implicit (BUILT_IN_MEMCPY), 12928 tree copy = build_call_expr (builtin_decl_implicit (BUILT_IN_MEMCPY),
13515 3, dest_addr, addr, size_int (rsize * 4)); 12929 3, dest_addr, addr, size_int (rsize * 4));
12930 TREE_ADDRESSABLE (tmp) = 1;
13516 12931
13517 gimplify_and_add (copy, pre_p); 12932 gimplify_and_add (copy, pre_p);
13518 addr = dest_addr; 12933 addr = dest_addr;
13519 } 12934 }
13520 12935
13594 #undef RS6000_BUILTIN_3 13009 #undef RS6000_BUILTIN_3
13595 #undef RS6000_BUILTIN_A 13010 #undef RS6000_BUILTIN_A
13596 #undef RS6000_BUILTIN_D 13011 #undef RS6000_BUILTIN_D
13597 #undef RS6000_BUILTIN_H 13012 #undef RS6000_BUILTIN_H
13598 #undef RS6000_BUILTIN_P 13013 #undef RS6000_BUILTIN_P
13599 #undef RS6000_BUILTIN_Q
13600 #undef RS6000_BUILTIN_X 13014 #undef RS6000_BUILTIN_X
13601 13015
13602 #define RS6000_BUILTIN_0(ENUM, NAME, MASK, ATTR, ICODE) 13016 #define RS6000_BUILTIN_0(ENUM, NAME, MASK, ATTR, ICODE)
13603 #define RS6000_BUILTIN_1(ENUM, NAME, MASK, ATTR, ICODE) 13017 #define RS6000_BUILTIN_1(ENUM, NAME, MASK, ATTR, ICODE)
13604 #define RS6000_BUILTIN_2(ENUM, NAME, MASK, ATTR, ICODE) 13018 #define RS6000_BUILTIN_2(ENUM, NAME, MASK, ATTR, ICODE)
13607 13021
13608 #define RS6000_BUILTIN_A(ENUM, NAME, MASK, ATTR, ICODE) 13022 #define RS6000_BUILTIN_A(ENUM, NAME, MASK, ATTR, ICODE)
13609 #define RS6000_BUILTIN_D(ENUM, NAME, MASK, ATTR, ICODE) 13023 #define RS6000_BUILTIN_D(ENUM, NAME, MASK, ATTR, ICODE)
13610 #define RS6000_BUILTIN_H(ENUM, NAME, MASK, ATTR, ICODE) 13024 #define RS6000_BUILTIN_H(ENUM, NAME, MASK, ATTR, ICODE)
13611 #define RS6000_BUILTIN_P(ENUM, NAME, MASK, ATTR, ICODE) 13025 #define RS6000_BUILTIN_P(ENUM, NAME, MASK, ATTR, ICODE)
13612 #define RS6000_BUILTIN_Q(ENUM, NAME, MASK, ATTR, ICODE)
13613 #define RS6000_BUILTIN_X(ENUM, NAME, MASK, ATTR, ICODE) 13026 #define RS6000_BUILTIN_X(ENUM, NAME, MASK, ATTR, ICODE)
13614 13027
13615 static const struct builtin_description bdesc_3arg[] = 13028 static const struct builtin_description bdesc_3arg[] =
13616 { 13029 {
13617 #include "rs6000-builtin.def" 13030 #include "rs6000-builtin.def"
13625 #undef RS6000_BUILTIN_3 13038 #undef RS6000_BUILTIN_3
13626 #undef RS6000_BUILTIN_A 13039 #undef RS6000_BUILTIN_A
13627 #undef RS6000_BUILTIN_D 13040 #undef RS6000_BUILTIN_D
13628 #undef RS6000_BUILTIN_H 13041 #undef RS6000_BUILTIN_H
13629 #undef RS6000_BUILTIN_P 13042 #undef RS6000_BUILTIN_P
13630 #undef RS6000_BUILTIN_Q
13631 #undef RS6000_BUILTIN_X 13043 #undef RS6000_BUILTIN_X
13632 13044
13633 #define RS6000_BUILTIN_0(ENUM, NAME, MASK, ATTR, ICODE) 13045 #define RS6000_BUILTIN_0(ENUM, NAME, MASK, ATTR, ICODE)
13634 #define RS6000_BUILTIN_1(ENUM, NAME, MASK, ATTR, ICODE) 13046 #define RS6000_BUILTIN_1(ENUM, NAME, MASK, ATTR, ICODE)
13635 #define RS6000_BUILTIN_2(ENUM, NAME, MASK, ATTR, ICODE) 13047 #define RS6000_BUILTIN_2(ENUM, NAME, MASK, ATTR, ICODE)
13638 #define RS6000_BUILTIN_D(ENUM, NAME, MASK, ATTR, ICODE) \ 13050 #define RS6000_BUILTIN_D(ENUM, NAME, MASK, ATTR, ICODE) \
13639 { MASK, ICODE, NAME, ENUM }, 13051 { MASK, ICODE, NAME, ENUM },
13640 13052
13641 #define RS6000_BUILTIN_H(ENUM, NAME, MASK, ATTR, ICODE) 13053 #define RS6000_BUILTIN_H(ENUM, NAME, MASK, ATTR, ICODE)
13642 #define RS6000_BUILTIN_P(ENUM, NAME, MASK, ATTR, ICODE) 13054 #define RS6000_BUILTIN_P(ENUM, NAME, MASK, ATTR, ICODE)
13643 #define RS6000_BUILTIN_Q(ENUM, NAME, MASK, ATTR, ICODE)
13644 #define RS6000_BUILTIN_X(ENUM, NAME, MASK, ATTR, ICODE) 13055 #define RS6000_BUILTIN_X(ENUM, NAME, MASK, ATTR, ICODE)
13645 13056
13646 static const struct builtin_description bdesc_dst[] = 13057 static const struct builtin_description bdesc_dst[] =
13647 { 13058 {
13648 #include "rs6000-builtin.def" 13059 #include "rs6000-builtin.def"
13656 #undef RS6000_BUILTIN_3 13067 #undef RS6000_BUILTIN_3
13657 #undef RS6000_BUILTIN_A 13068 #undef RS6000_BUILTIN_A
13658 #undef RS6000_BUILTIN_D 13069 #undef RS6000_BUILTIN_D
13659 #undef RS6000_BUILTIN_H 13070 #undef RS6000_BUILTIN_H
13660 #undef RS6000_BUILTIN_P 13071 #undef RS6000_BUILTIN_P
13661 #undef RS6000_BUILTIN_Q
13662 #undef RS6000_BUILTIN_X 13072 #undef RS6000_BUILTIN_X
13663 13073
13664 #define RS6000_BUILTIN_0(ENUM, NAME, MASK, ATTR, ICODE) 13074 #define RS6000_BUILTIN_0(ENUM, NAME, MASK, ATTR, ICODE)
13665 #define RS6000_BUILTIN_1(ENUM, NAME, MASK, ATTR, ICODE) 13075 #define RS6000_BUILTIN_1(ENUM, NAME, MASK, ATTR, ICODE)
13666 #define RS6000_BUILTIN_2(ENUM, NAME, MASK, ATTR, ICODE) \ 13076 #define RS6000_BUILTIN_2(ENUM, NAME, MASK, ATTR, ICODE) \
13669 #define RS6000_BUILTIN_3(ENUM, NAME, MASK, ATTR, ICODE) 13079 #define RS6000_BUILTIN_3(ENUM, NAME, MASK, ATTR, ICODE)
13670 #define RS6000_BUILTIN_A(ENUM, NAME, MASK, ATTR, ICODE) 13080 #define RS6000_BUILTIN_A(ENUM, NAME, MASK, ATTR, ICODE)
13671 #define RS6000_BUILTIN_D(ENUM, NAME, MASK, ATTR, ICODE) 13081 #define RS6000_BUILTIN_D(ENUM, NAME, MASK, ATTR, ICODE)
13672 #define RS6000_BUILTIN_H(ENUM, NAME, MASK, ATTR, ICODE) 13082 #define RS6000_BUILTIN_H(ENUM, NAME, MASK, ATTR, ICODE)
13673 #define RS6000_BUILTIN_P(ENUM, NAME, MASK, ATTR, ICODE) 13083 #define RS6000_BUILTIN_P(ENUM, NAME, MASK, ATTR, ICODE)
13674 #define RS6000_BUILTIN_Q(ENUM, NAME, MASK, ATTR, ICODE)
13675 #define RS6000_BUILTIN_X(ENUM, NAME, MASK, ATTR, ICODE) 13084 #define RS6000_BUILTIN_X(ENUM, NAME, MASK, ATTR, ICODE)
13676 13085
13677 static const struct builtin_description bdesc_2arg[] = 13086 static const struct builtin_description bdesc_2arg[] =
13678 { 13087 {
13679 #include "rs6000-builtin.def" 13088 #include "rs6000-builtin.def"
13685 #undef RS6000_BUILTIN_3 13094 #undef RS6000_BUILTIN_3
13686 #undef RS6000_BUILTIN_A 13095 #undef RS6000_BUILTIN_A
13687 #undef RS6000_BUILTIN_D 13096 #undef RS6000_BUILTIN_D
13688 #undef RS6000_BUILTIN_H 13097 #undef RS6000_BUILTIN_H
13689 #undef RS6000_BUILTIN_P 13098 #undef RS6000_BUILTIN_P
13690 #undef RS6000_BUILTIN_Q
13691 #undef RS6000_BUILTIN_X 13099 #undef RS6000_BUILTIN_X
13692 13100
13693 #define RS6000_BUILTIN_0(ENUM, NAME, MASK, ATTR, ICODE) 13101 #define RS6000_BUILTIN_0(ENUM, NAME, MASK, ATTR, ICODE)
13694 #define RS6000_BUILTIN_1(ENUM, NAME, MASK, ATTR, ICODE) 13102 #define RS6000_BUILTIN_1(ENUM, NAME, MASK, ATTR, ICODE)
13695 #define RS6000_BUILTIN_2(ENUM, NAME, MASK, ATTR, ICODE) 13103 #define RS6000_BUILTIN_2(ENUM, NAME, MASK, ATTR, ICODE)
13698 #define RS6000_BUILTIN_D(ENUM, NAME, MASK, ATTR, ICODE) 13106 #define RS6000_BUILTIN_D(ENUM, NAME, MASK, ATTR, ICODE)
13699 #define RS6000_BUILTIN_H(ENUM, NAME, MASK, ATTR, ICODE) 13107 #define RS6000_BUILTIN_H(ENUM, NAME, MASK, ATTR, ICODE)
13700 #define RS6000_BUILTIN_P(ENUM, NAME, MASK, ATTR, ICODE) \ 13108 #define RS6000_BUILTIN_P(ENUM, NAME, MASK, ATTR, ICODE) \
13701 { MASK, ICODE, NAME, ENUM }, 13109 { MASK, ICODE, NAME, ENUM },
13702 13110
13703 #define RS6000_BUILTIN_Q(ENUM, NAME, MASK, ATTR, ICODE)
13704 #define RS6000_BUILTIN_X(ENUM, NAME, MASK, ATTR, ICODE) 13111 #define RS6000_BUILTIN_X(ENUM, NAME, MASK, ATTR, ICODE)
13705 13112
13706 /* AltiVec predicates. */ 13113 /* AltiVec predicates. */
13707 13114
13708 static const struct builtin_description bdesc_altivec_preds[] = 13115 static const struct builtin_description bdesc_altivec_preds[] =
13709 { 13116 {
13710 #include "rs6000-builtin.def" 13117 #include "rs6000-builtin.def"
13711 }; 13118 };
13712 13119
13713 /* PAIRED predicates. */ 13120 /* ABS* operations. */
13121
13714 #undef RS6000_BUILTIN_0 13122 #undef RS6000_BUILTIN_0
13715 #undef RS6000_BUILTIN_1 13123 #undef RS6000_BUILTIN_1
13716 #undef RS6000_BUILTIN_2 13124 #undef RS6000_BUILTIN_2
13717 #undef RS6000_BUILTIN_3 13125 #undef RS6000_BUILTIN_3
13718 #undef RS6000_BUILTIN_A 13126 #undef RS6000_BUILTIN_A
13719 #undef RS6000_BUILTIN_D 13127 #undef RS6000_BUILTIN_D
13720 #undef RS6000_BUILTIN_H 13128 #undef RS6000_BUILTIN_H
13721 #undef RS6000_BUILTIN_P 13129 #undef RS6000_BUILTIN_P
13722 #undef RS6000_BUILTIN_Q
13723 #undef RS6000_BUILTIN_X 13130 #undef RS6000_BUILTIN_X
13724 13131
13725 #define RS6000_BUILTIN_0(ENUM, NAME, MASK, ATTR, ICODE) 13132 #define RS6000_BUILTIN_0(ENUM, NAME, MASK, ATTR, ICODE)
13726 #define RS6000_BUILTIN_1(ENUM, NAME, MASK, ATTR, ICODE) 13133 #define RS6000_BUILTIN_1(ENUM, NAME, MASK, ATTR, ICODE)
13727 #define RS6000_BUILTIN_2(ENUM, NAME, MASK, ATTR, ICODE) 13134 #define RS6000_BUILTIN_2(ENUM, NAME, MASK, ATTR, ICODE)
13728 #define RS6000_BUILTIN_3(ENUM, NAME, MASK, ATTR, ICODE) 13135 #define RS6000_BUILTIN_3(ENUM, NAME, MASK, ATTR, ICODE)
13729 #define RS6000_BUILTIN_A(ENUM, NAME, MASK, ATTR, ICODE) 13136 #define RS6000_BUILTIN_A(ENUM, NAME, MASK, ATTR, ICODE) \
13137 { MASK, ICODE, NAME, ENUM },
13138
13730 #define RS6000_BUILTIN_D(ENUM, NAME, MASK, ATTR, ICODE) 13139 #define RS6000_BUILTIN_D(ENUM, NAME, MASK, ATTR, ICODE)
13731 #define RS6000_BUILTIN_H(ENUM, NAME, MASK, ATTR, ICODE) 13140 #define RS6000_BUILTIN_H(ENUM, NAME, MASK, ATTR, ICODE)
13732 #define RS6000_BUILTIN_P(ENUM, NAME, MASK, ATTR, ICODE) 13141 #define RS6000_BUILTIN_P(ENUM, NAME, MASK, ATTR, ICODE)
13733 #define RS6000_BUILTIN_Q(ENUM, NAME, MASK, ATTR, ICODE) \
13734 { MASK, ICODE, NAME, ENUM },
13735
13736 #define RS6000_BUILTIN_X(ENUM, NAME, MASK, ATTR, ICODE) 13142 #define RS6000_BUILTIN_X(ENUM, NAME, MASK, ATTR, ICODE)
13737 13143
13738 static const struct builtin_description bdesc_paired_preds[] = 13144 static const struct builtin_description bdesc_abs[] =
13739 { 13145 {
13740 #include "rs6000-builtin.def" 13146 #include "rs6000-builtin.def"
13741 }; 13147 };
13742 13148
13743 /* ABS* operations. */ 13149 /* Simple unary operations: VECb = foo (unsigned literal) or VECb =
13150 foo (VECa). */
13744 13151
13745 #undef RS6000_BUILTIN_0 13152 #undef RS6000_BUILTIN_0
13746 #undef RS6000_BUILTIN_1 13153 #undef RS6000_BUILTIN_1
13747 #undef RS6000_BUILTIN_2 13154 #undef RS6000_BUILTIN_2
13748 #undef RS6000_BUILTIN_3 13155 #undef RS6000_BUILTIN_3
13749 #undef RS6000_BUILTIN_A 13156 #undef RS6000_BUILTIN_A
13750 #undef RS6000_BUILTIN_D 13157 #undef RS6000_BUILTIN_D
13751 #undef RS6000_BUILTIN_H 13158 #undef RS6000_BUILTIN_H
13752 #undef RS6000_BUILTIN_P 13159 #undef RS6000_BUILTIN_P
13753 #undef RS6000_BUILTIN_Q
13754 #undef RS6000_BUILTIN_X 13160 #undef RS6000_BUILTIN_X
13755 13161
13756 #define RS6000_BUILTIN_0(ENUM, NAME, MASK, ATTR, ICODE) 13162 #define RS6000_BUILTIN_0(ENUM, NAME, MASK, ATTR, ICODE)
13757 #define RS6000_BUILTIN_1(ENUM, NAME, MASK, ATTR, ICODE) 13163 #define RS6000_BUILTIN_1(ENUM, NAME, MASK, ATTR, ICODE) \
13164 { MASK, ICODE, NAME, ENUM },
13165
13758 #define RS6000_BUILTIN_2(ENUM, NAME, MASK, ATTR, ICODE) 13166 #define RS6000_BUILTIN_2(ENUM, NAME, MASK, ATTR, ICODE)
13759 #define RS6000_BUILTIN_3(ENUM, NAME, MASK, ATTR, ICODE) 13167 #define RS6000_BUILTIN_3(ENUM, NAME, MASK, ATTR, ICODE)
13760 #define RS6000_BUILTIN_A(ENUM, NAME, MASK, ATTR, ICODE) \ 13168 #define RS6000_BUILTIN_A(ENUM, NAME, MASK, ATTR, ICODE)
13761 { MASK, ICODE, NAME, ENUM },
13762
13763 #define RS6000_BUILTIN_D(ENUM, NAME, MASK, ATTR, ICODE) 13169 #define RS6000_BUILTIN_D(ENUM, NAME, MASK, ATTR, ICODE)
13764 #define RS6000_BUILTIN_H(ENUM, NAME, MASK, ATTR, ICODE) 13170 #define RS6000_BUILTIN_H(ENUM, NAME, MASK, ATTR, ICODE)
13765 #define RS6000_BUILTIN_P(ENUM, NAME, MASK, ATTR, ICODE) 13171 #define RS6000_BUILTIN_P(ENUM, NAME, MASK, ATTR, ICODE)
13766 #define RS6000_BUILTIN_Q(ENUM, NAME, MASK, ATTR, ICODE)
13767 #define RS6000_BUILTIN_X(ENUM, NAME, MASK, ATTR, ICODE) 13172 #define RS6000_BUILTIN_X(ENUM, NAME, MASK, ATTR, ICODE)
13768 13173
13769 static const struct builtin_description bdesc_abs[] = 13174 static const struct builtin_description bdesc_1arg[] =
13770 { 13175 {
13771 #include "rs6000-builtin.def" 13176 #include "rs6000-builtin.def"
13772 }; 13177 };
13773 13178
13774 /* Simple unary operations: VECb = foo (unsigned literal) or VECb = 13179 /* Simple no-argument operations: result = __builtin_darn_32 () */
13775 foo (VECa). */
13776 13180
13777 #undef RS6000_BUILTIN_0 13181 #undef RS6000_BUILTIN_0
13778 #undef RS6000_BUILTIN_1 13182 #undef RS6000_BUILTIN_1
13779 #undef RS6000_BUILTIN_2 13183 #undef RS6000_BUILTIN_2
13780 #undef RS6000_BUILTIN_3 13184 #undef RS6000_BUILTIN_3
13781 #undef RS6000_BUILTIN_A 13185 #undef RS6000_BUILTIN_A
13782 #undef RS6000_BUILTIN_D 13186 #undef RS6000_BUILTIN_D
13783 #undef RS6000_BUILTIN_H 13187 #undef RS6000_BUILTIN_H
13784 #undef RS6000_BUILTIN_P 13188 #undef RS6000_BUILTIN_P
13785 #undef RS6000_BUILTIN_Q
13786 #undef RS6000_BUILTIN_X
13787
13788 #define RS6000_BUILTIN_0(ENUM, NAME, MASK, ATTR, ICODE)
13789 #define RS6000_BUILTIN_1(ENUM, NAME, MASK, ATTR, ICODE) \
13790 { MASK, ICODE, NAME, ENUM },
13791
13792 #define RS6000_BUILTIN_2(ENUM, NAME, MASK, ATTR, ICODE)
13793 #define RS6000_BUILTIN_3(ENUM, NAME, MASK, ATTR, ICODE)
13794 #define RS6000_BUILTIN_A(ENUM, NAME, MASK, ATTR, ICODE)
13795 #define RS6000_BUILTIN_D(ENUM, NAME, MASK, ATTR, ICODE)
13796 #define RS6000_BUILTIN_H(ENUM, NAME, MASK, ATTR, ICODE)
13797 #define RS6000_BUILTIN_P(ENUM, NAME, MASK, ATTR, ICODE)
13798 #define RS6000_BUILTIN_Q(ENUM, NAME, MASK, ATTR, ICODE)
13799 #define RS6000_BUILTIN_X(ENUM, NAME, MASK, ATTR, ICODE)
13800
13801 static const struct builtin_description bdesc_1arg[] =
13802 {
13803 #include "rs6000-builtin.def"
13804 };
13805
13806 /* Simple no-argument operations: result = __builtin_darn_32 () */
13807
13808 #undef RS6000_BUILTIN_0
13809 #undef RS6000_BUILTIN_1
13810 #undef RS6000_BUILTIN_2
13811 #undef RS6000_BUILTIN_3
13812 #undef RS6000_BUILTIN_A
13813 #undef RS6000_BUILTIN_D
13814 #undef RS6000_BUILTIN_H
13815 #undef RS6000_BUILTIN_P
13816 #undef RS6000_BUILTIN_Q
13817 #undef RS6000_BUILTIN_X 13189 #undef RS6000_BUILTIN_X
13818 13190
13819 #define RS6000_BUILTIN_0(ENUM, NAME, MASK, ATTR, ICODE) \ 13191 #define RS6000_BUILTIN_0(ENUM, NAME, MASK, ATTR, ICODE) \
13820 { MASK, ICODE, NAME, ENUM }, 13192 { MASK, ICODE, NAME, ENUM },
13821 13193
13824 #define RS6000_BUILTIN_3(ENUM, NAME, MASK, ATTR, ICODE) 13196 #define RS6000_BUILTIN_3(ENUM, NAME, MASK, ATTR, ICODE)
13825 #define RS6000_BUILTIN_A(ENUM, NAME, MASK, ATTR, ICODE) 13197 #define RS6000_BUILTIN_A(ENUM, NAME, MASK, ATTR, ICODE)
13826 #define RS6000_BUILTIN_D(ENUM, NAME, MASK, ATTR, ICODE) 13198 #define RS6000_BUILTIN_D(ENUM, NAME, MASK, ATTR, ICODE)
13827 #define RS6000_BUILTIN_H(ENUM, NAME, MASK, ATTR, ICODE) 13199 #define RS6000_BUILTIN_H(ENUM, NAME, MASK, ATTR, ICODE)
13828 #define RS6000_BUILTIN_P(ENUM, NAME, MASK, ATTR, ICODE) 13200 #define RS6000_BUILTIN_P(ENUM, NAME, MASK, ATTR, ICODE)
13829 #define RS6000_BUILTIN_Q(ENUM, NAME, MASK, ATTR, ICODE)
13830 #define RS6000_BUILTIN_X(ENUM, NAME, MASK, ATTR, ICODE) 13201 #define RS6000_BUILTIN_X(ENUM, NAME, MASK, ATTR, ICODE)
13831 13202
13832 static const struct builtin_description bdesc_0arg[] = 13203 static const struct builtin_description bdesc_0arg[] =
13833 { 13204 {
13834 #include "rs6000-builtin.def" 13205 #include "rs6000-builtin.def"
13841 #undef RS6000_BUILTIN_3 13212 #undef RS6000_BUILTIN_3
13842 #undef RS6000_BUILTIN_A 13213 #undef RS6000_BUILTIN_A
13843 #undef RS6000_BUILTIN_D 13214 #undef RS6000_BUILTIN_D
13844 #undef RS6000_BUILTIN_H 13215 #undef RS6000_BUILTIN_H
13845 #undef RS6000_BUILTIN_P 13216 #undef RS6000_BUILTIN_P
13846 #undef RS6000_BUILTIN_Q
13847 #undef RS6000_BUILTIN_X 13217 #undef RS6000_BUILTIN_X
13848 13218
13849 #define RS6000_BUILTIN_0(ENUM, NAME, MASK, ATTR, ICODE) 13219 #define RS6000_BUILTIN_0(ENUM, NAME, MASK, ATTR, ICODE)
13850 #define RS6000_BUILTIN_1(ENUM, NAME, MASK, ATTR, ICODE) 13220 #define RS6000_BUILTIN_1(ENUM, NAME, MASK, ATTR, ICODE)
13851 #define RS6000_BUILTIN_2(ENUM, NAME, MASK, ATTR, ICODE) 13221 #define RS6000_BUILTIN_2(ENUM, NAME, MASK, ATTR, ICODE)
13854 #define RS6000_BUILTIN_D(ENUM, NAME, MASK, ATTR, ICODE) 13224 #define RS6000_BUILTIN_D(ENUM, NAME, MASK, ATTR, ICODE)
13855 #define RS6000_BUILTIN_H(ENUM, NAME, MASK, ATTR, ICODE) \ 13225 #define RS6000_BUILTIN_H(ENUM, NAME, MASK, ATTR, ICODE) \
13856 { MASK, ICODE, NAME, ENUM }, 13226 { MASK, ICODE, NAME, ENUM },
13857 13227
13858 #define RS6000_BUILTIN_P(ENUM, NAME, MASK, ATTR, ICODE) 13228 #define RS6000_BUILTIN_P(ENUM, NAME, MASK, ATTR, ICODE)
13859 #define RS6000_BUILTIN_Q(ENUM, NAME, MASK, ATTR, ICODE)
13860 #define RS6000_BUILTIN_X(ENUM, NAME, MASK, ATTR, ICODE) 13229 #define RS6000_BUILTIN_X(ENUM, NAME, MASK, ATTR, ICODE)
13861 13230
13862 static const struct builtin_description bdesc_htm[] = 13231 static const struct builtin_description bdesc_htm[] =
13863 { 13232 {
13864 #include "rs6000-builtin.def" 13233 #include "rs6000-builtin.def"
13870 #undef RS6000_BUILTIN_3 13239 #undef RS6000_BUILTIN_3
13871 #undef RS6000_BUILTIN_A 13240 #undef RS6000_BUILTIN_A
13872 #undef RS6000_BUILTIN_D 13241 #undef RS6000_BUILTIN_D
13873 #undef RS6000_BUILTIN_H 13242 #undef RS6000_BUILTIN_H
13874 #undef RS6000_BUILTIN_P 13243 #undef RS6000_BUILTIN_P
13875 #undef RS6000_BUILTIN_Q
13876 13244
13877 /* Return true if a builtin function is overloaded. */ 13245 /* Return true if a builtin function is overloaded. */
13878 bool 13246 bool
13879 rs6000_overloaded_builtin_p (enum rs6000_builtins fncode) 13247 rs6000_overloaded_builtin_p (enum rs6000_builtins fncode)
13880 { 13248 {
13895 machine_mode tmode = insn_data[icode].operand[0].mode; 13263 machine_mode tmode = insn_data[icode].operand[0].mode;
13896 13264
13897 if (icode == CODE_FOR_nothing) 13265 if (icode == CODE_FOR_nothing)
13898 /* Builtin not supported on this processor. */ 13266 /* Builtin not supported on this processor. */
13899 return 0; 13267 return 0;
13268
13269 if (icode == CODE_FOR_rs6000_mffsl
13270 && rs6000_isa_flags_explicit & OPTION_MASK_SOFT_FLOAT)
13271 {
13272 error ("__builtin_mffsl() not supported with -msoft-float");
13273 return const0_rtx;
13274 }
13900 13275
13901 if (target == 0 13276 if (target == 0
13902 || GET_MODE (target) != tmode 13277 || GET_MODE (target) != tmode
13903 || ! (*insn_data[icode].operand[0].predicate) (target, tmode)) 13278 || ! (*insn_data[icode].operand[0].predicate) (target, tmode))
13904 target = gen_reg_rtx (tmode); 13279 target = gen_reg_rtx (tmode);
13944 13319
13945 if (! (*insn_data[icode].operand[1].predicate) (op1, mode1)) 13320 if (! (*insn_data[icode].operand[1].predicate) (op1, mode1))
13946 op1 = copy_to_mode_reg (mode1, op1); 13321 op1 = copy_to_mode_reg (mode1, op1);
13947 13322
13948 pat = GEN_FCN (icode) (op0, op1); 13323 pat = GEN_FCN (icode) (op0, op1);
13324 if (!pat)
13325 return const0_rtx;
13326 emit_insn (pat);
13327
13328 return NULL_RTX;
13329 }
13330
13331 static rtx
13332 rs6000_expand_mtfsb_builtin (enum insn_code icode, tree exp)
13333 {
13334 rtx pat;
13335 tree arg0 = CALL_EXPR_ARG (exp, 0);
13336 rtx op0 = expand_normal (arg0);
13337
13338 if (icode == CODE_FOR_nothing)
13339 /* Builtin not supported on this processor. */
13340 return 0;
13341
13342 if (rs6000_isa_flags_explicit & OPTION_MASK_SOFT_FLOAT)
13343 {
13344 error ("__builtin_mtfsb0 and __builtin_mtfsb1 not supported with -msoft-float");
13345 return const0_rtx;
13346 }
13347
13348 /* If we got invalid arguments bail out before generating bad rtl. */
13349 if (arg0 == error_mark_node)
13350 return const0_rtx;
13351
13352 /* Only allow bit numbers 0 to 31. */
13353 if (!u5bit_cint_operand (op0, VOIDmode))
13354 {
13355 error ("Argument must be a constant between 0 and 31.");
13356 return const0_rtx;
13357 }
13358
13359 pat = GEN_FCN (icode) (op0);
13360 if (!pat)
13361 return const0_rtx;
13362 emit_insn (pat);
13363
13364 return NULL_RTX;
13365 }
13366
13367 static rtx
13368 rs6000_expand_set_fpscr_rn_builtin (enum insn_code icode, tree exp)
13369 {
13370 rtx pat;
13371 tree arg0 = CALL_EXPR_ARG (exp, 0);
13372 rtx op0 = expand_normal (arg0);
13373 machine_mode mode0 = insn_data[icode].operand[0].mode;
13374
13375 if (icode == CODE_FOR_nothing)
13376 /* Builtin not supported on this processor. */
13377 return 0;
13378
13379 if (rs6000_isa_flags_explicit & OPTION_MASK_SOFT_FLOAT)
13380 {
13381 error ("__builtin_set_fpscr_rn not supported with -msoft-float");
13382 return const0_rtx;
13383 }
13384
13385 /* If we got invalid arguments bail out before generating bad rtl. */
13386 if (arg0 == error_mark_node)
13387 return const0_rtx;
13388
13389 /* If the argument is a constant, check the range. Argument can only be a
13390 2-bit value. Unfortunately, can't check the range of the value at
13391 compile time if the argument is a variable. The least significant two
13392 bits of the argument, regardless of type, are used to set the rounding
13393 mode. All other bits are ignored. */
13394 if (GET_CODE (op0) == CONST_INT && !const_0_to_3_operand(op0, VOIDmode))
13395 {
13396 error ("Argument must be a value between 0 and 3.");
13397 return const0_rtx;
13398 }
13399
13400 if (! (*insn_data[icode].operand[0].predicate) (op0, mode0))
13401 op0 = copy_to_mode_reg (mode0, op0);
13402
13403 pat = GEN_FCN (icode) (op0);
13404 if (!pat)
13405 return const0_rtx;
13406 emit_insn (pat);
13407
13408 return NULL_RTX;
13409 }
13410 static rtx
13411 rs6000_expand_set_fpscr_drn_builtin (enum insn_code icode, tree exp)
13412 {
13413 rtx pat;
13414 tree arg0 = CALL_EXPR_ARG (exp, 0);
13415 rtx op0 = expand_normal (arg0);
13416 machine_mode mode0 = insn_data[icode].operand[0].mode;
13417
13418 if (TARGET_32BIT)
13419 /* Builtin not supported in 32-bit mode. */
13420 fatal_error (input_location,
13421 "__builtin_set_fpscr_drn is not supported in 32-bit mode.");
13422
13423 if (rs6000_isa_flags_explicit & OPTION_MASK_SOFT_FLOAT)
13424 {
13425 error ("__builtin_set_fpscr_drn not supported with -msoft-float");
13426 return const0_rtx;
13427 }
13428
13429 if (icode == CODE_FOR_nothing)
13430 /* Builtin not supported on this processor. */
13431 return 0;
13432
13433 /* If we got invalid arguments bail out before generating bad rtl. */
13434 if (arg0 == error_mark_node)
13435 return const0_rtx;
13436
13437 /* If the argument is a constant, check the range. Agrument can only be a
13438 3-bit value. Unfortunately, can't check the range of the value at
13439 compile time if the argument is a variable. The least significant two
13440 bits of the argument, regardless of type, are used to set the rounding
13441 mode. All other bits are ignored. */
13442 if (GET_CODE (op0) == CONST_INT && !const_0_to_7_operand(op0, VOIDmode))
13443 {
13444 error ("Argument must be a value between 0 and 7.");
13445 return const0_rtx;
13446 }
13447
13448 if (! (*insn_data[icode].operand[0].predicate) (op0, mode0))
13449 op0 = copy_to_mode_reg (mode0, op0);
13450
13451 pat = GEN_FCN (icode) (op0);
13949 if (! pat) 13452 if (! pat)
13950 return const0_rtx; 13453 return const0_rtx;
13951 emit_insn (pat); 13454 emit_insn (pat);
13952 13455
13953 return NULL_RTX; 13456 return NULL_RTX;
14050 13553
14051 /* If we got invalid arguments bail out before generating bad rtl. */ 13554 /* If we got invalid arguments bail out before generating bad rtl. */
14052 if (arg0 == error_mark_node || arg1 == error_mark_node) 13555 if (arg0 == error_mark_node || arg1 == error_mark_node)
14053 return const0_rtx; 13556 return const0_rtx;
14054 13557
14055 if (icode == CODE_FOR_altivec_vcfux 13558 if (icode == CODE_FOR_unpackv1ti
13559 || icode == CODE_FOR_unpackkf
13560 || icode == CODE_FOR_unpacktf
13561 || icode == CODE_FOR_unpackif
13562 || icode == CODE_FOR_unpacktd)
13563 {
13564 /* Only allow 1-bit unsigned literals. */
13565 STRIP_NOPS (arg1);
13566 if (TREE_CODE (arg1) != INTEGER_CST
13567 || !IN_RANGE (TREE_INT_CST_LOW (arg1), 0, 1))
13568 {
13569 error ("argument 2 must be a 1-bit unsigned literal");
13570 return CONST0_RTX (tmode);
13571 }
13572 }
13573 else if (icode == CODE_FOR_altivec_vspltw)
13574 {
13575 /* Only allow 2-bit unsigned literals. */
13576 STRIP_NOPS (arg1);
13577 if (TREE_CODE (arg1) != INTEGER_CST
13578 || TREE_INT_CST_LOW (arg1) & ~3)
13579 {
13580 error ("argument 2 must be a 2-bit unsigned literal");
13581 return CONST0_RTX (tmode);
13582 }
13583 }
13584 else if (icode == CODE_FOR_altivec_vsplth)
13585 {
13586 /* Only allow 3-bit unsigned literals. */
13587 STRIP_NOPS (arg1);
13588 if (TREE_CODE (arg1) != INTEGER_CST
13589 || TREE_INT_CST_LOW (arg1) & ~7)
13590 {
13591 error ("argument 2 must be a 3-bit unsigned literal");
13592 return CONST0_RTX (tmode);
13593 }
13594 }
13595 else if (icode == CODE_FOR_altivec_vspltb)
13596 {
13597 /* Only allow 4-bit unsigned literals. */
13598 STRIP_NOPS (arg1);
13599 if (TREE_CODE (arg1) != INTEGER_CST
13600 || TREE_INT_CST_LOW (arg1) & ~15)
13601 {
13602 error ("argument 2 must be a 4-bit unsigned literal");
13603 return CONST0_RTX (tmode);
13604 }
13605 }
13606 else if (icode == CODE_FOR_altivec_vcfux
14056 || icode == CODE_FOR_altivec_vcfsx 13607 || icode == CODE_FOR_altivec_vcfsx
14057 || icode == CODE_FOR_altivec_vctsxs 13608 || icode == CODE_FOR_altivec_vctsxs
14058 || icode == CODE_FOR_altivec_vctuxs 13609 || icode == CODE_FOR_altivec_vctuxs)
14059 || icode == CODE_FOR_altivec_vspltb
14060 || icode == CODE_FOR_altivec_vsplth
14061 || icode == CODE_FOR_altivec_vspltw)
14062 { 13610 {
14063 /* Only allow 5-bit unsigned literals. */ 13611 /* Only allow 5-bit unsigned literals. */
14064 STRIP_NOPS (arg1); 13612 STRIP_NOPS (arg1);
14065 if (TREE_CODE (arg1) != INTEGER_CST 13613 if (TREE_CODE (arg1) != INTEGER_CST
14066 || TREE_INT_CST_LOW (arg1) & ~0x1f) 13614 || TREE_INT_CST_LOW (arg1) & ~0x1f)
14085 { 13633 {
14086 error ("argument 1 must be a 6-bit unsigned literal"); 13634 error ("argument 1 must be a 6-bit unsigned literal");
14087 return CONST0_RTX (tmode); 13635 return CONST0_RTX (tmode);
14088 } 13636 }
14089 } 13637 }
14090 else if (icode == CODE_FOR_xststdcqp 13638 else if (icode == CODE_FOR_xststdcqp_kf
13639 || icode == CODE_FOR_xststdcqp_tf
14091 || icode == CODE_FOR_xststdcdp 13640 || icode == CODE_FOR_xststdcdp
14092 || icode == CODE_FOR_xststdcsp 13641 || icode == CODE_FOR_xststdcsp
14093 || icode == CODE_FOR_xvtstdcdp 13642 || icode == CODE_FOR_xvtstdcdp
14094 || icode == CODE_FOR_xvtstdcsp) 13643 || icode == CODE_FOR_xvtstdcsp)
14095 { 13644 {
14097 STRIP_NOPS (arg1); 13646 STRIP_NOPS (arg1);
14098 if (TREE_CODE (arg1) != INTEGER_CST 13647 if (TREE_CODE (arg1) != INTEGER_CST
14099 || !IN_RANGE (TREE_INT_CST_LOW (arg1), 0, 127)) 13648 || !IN_RANGE (TREE_INT_CST_LOW (arg1), 0, 127))
14100 { 13649 {
14101 error ("argument 2 must be a 7-bit unsigned literal"); 13650 error ("argument 2 must be a 7-bit unsigned literal");
14102 return CONST0_RTX (tmode);
14103 }
14104 }
14105 else if (icode == CODE_FOR_unpackv1ti
14106 || icode == CODE_FOR_unpackkf
14107 || icode == CODE_FOR_unpacktf
14108 || icode == CODE_FOR_unpackif
14109 || icode == CODE_FOR_unpacktd)
14110 {
14111 /* Only allow 1-bit unsigned literals. */
14112 STRIP_NOPS (arg1);
14113 if (TREE_CODE (arg1) != INTEGER_CST
14114 || !IN_RANGE (TREE_INT_CST_LOW (arg1), 0, 1))
14115 {
14116 error ("argument 2 must be a 1-bit unsigned literal");
14117 return CONST0_RTX (tmode); 13651 return CONST0_RTX (tmode);
14118 } 13652 }
14119 } 13653 }
14120 13654
14121 if (target == 0 13655 if (target == 0
14216 } 13750 }
14217 13751
14218 return target; 13752 return target;
14219 } 13753 }
14220 13754
14221 static rtx 13755 rtx
14222 paired_expand_lv_builtin (enum insn_code icode, tree exp, rtx target) 13756 swap_endian_selector_for_mode (machine_mode mode)
14223 { 13757 {
14224 rtx pat, addr; 13758 unsigned int swap1[16] = {15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0};
14225 tree arg0 = CALL_EXPR_ARG (exp, 0);
14226 tree arg1 = CALL_EXPR_ARG (exp, 1);
14227 machine_mode tmode = insn_data[icode].operand[0].mode;
14228 machine_mode mode0 = Pmode;
14229 machine_mode mode1 = Pmode;
14230 rtx op0 = expand_normal (arg0);
14231 rtx op1 = expand_normal (arg1);
14232
14233 if (icode == CODE_FOR_nothing)
14234 /* Builtin not supported on this processor. */
14235 return 0;
14236
14237 /* If we got invalid arguments bail out before generating bad rtl. */
14238 if (arg0 == error_mark_node || arg1 == error_mark_node)
14239 return const0_rtx;
14240
14241 if (target == 0
14242 || GET_MODE (target) != tmode
14243 || ! (*insn_data[icode].operand[0].predicate) (target, tmode))
14244 target = gen_reg_rtx (tmode);
14245
14246 op1 = copy_to_mode_reg (mode1, op1);
14247
14248 if (op0 == const0_rtx)
14249 {
14250 addr = gen_rtx_MEM (tmode, op1);
14251 }
14252 else
14253 {
14254 op0 = copy_to_mode_reg (mode0, op0);
14255 addr = gen_rtx_MEM (tmode, gen_rtx_PLUS (Pmode, op0, op1));
14256 }
14257
14258 pat = GEN_FCN (icode) (target, addr);
14259
14260 if (! pat)
14261 return 0;
14262 emit_insn (pat);
14263
14264 return target;
14265 }
14266
14267 /* Return a constant vector for use as a little-endian permute control vector
14268 to reverse the order of elements of the given vector mode. */
14269 static rtx
14270 swap_selector_for_mode (machine_mode mode)
14271 {
14272 /* These are little endian vectors, so their elements are reversed
14273 from what you would normally expect for a permute control vector. */
14274 unsigned int swap2[16] = {7,6,5,4,3,2,1,0,15,14,13,12,11,10,9,8}; 13759 unsigned int swap2[16] = {7,6,5,4,3,2,1,0,15,14,13,12,11,10,9,8};
14275 unsigned int swap4[16] = {3,2,1,0,7,6,5,4,11,10,9,8,15,14,13,12}; 13760 unsigned int swap4[16] = {3,2,1,0,7,6,5,4,11,10,9,8,15,14,13,12};
14276 unsigned int swap8[16] = {1,0,3,2,5,4,7,6,9,8,11,10,13,12,15,14}; 13761 unsigned int swap8[16] = {1,0,3,2,5,4,7,6,9,8,11,10,13,12,15,14};
14277 unsigned int swap16[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; 13762
14278 unsigned int *swaparray, i; 13763 unsigned int *swaparray, i;
14279 rtx perm[16]; 13764 rtx perm[16];
14280 13765
14281 switch (mode) 13766 switch (mode)
14282 { 13767 {
13768 case E_V1TImode:
13769 swaparray = swap1;
13770 break;
14283 case E_V2DFmode: 13771 case E_V2DFmode:
14284 case E_V2DImode: 13772 case E_V2DImode:
14285 swaparray = swap2; 13773 swaparray = swap2;
14286 break; 13774 break;
14287 case E_V4SFmode: 13775 case E_V4SFmode:
14289 swaparray = swap4; 13777 swaparray = swap4;
14290 break; 13778 break;
14291 case E_V8HImode: 13779 case E_V8HImode:
14292 swaparray = swap8; 13780 swaparray = swap8;
14293 break; 13781 break;
14294 case E_V16QImode:
14295 swaparray = swap16;
14296 break;
14297 default: 13782 default:
14298 gcc_unreachable (); 13783 gcc_unreachable ();
14299 } 13784 }
14300 13785
14301 for (i = 0; i < 16; ++i) 13786 for (i = 0; i < 16; ++i)
14302 perm[i] = GEN_INT (swaparray[i]); 13787 perm[i] = GEN_INT (swaparray[i]);
14303 13788
14304 return force_reg (V16QImode, gen_rtx_CONST_VECTOR (V16QImode, gen_rtvec_v (16, perm))); 13789 return force_reg (V16QImode, gen_rtx_CONST_VECTOR (V16QImode,
14305 } 13790 gen_rtvec_v (16, perm)));
14306
14307 /* Generate code for an "lvxl", or "lve*x" built-in for a little endian target
14308 with -maltivec=be specified. Issue the load followed by an element-
14309 reversing permute. */
14310 void
14311 altivec_expand_lvx_be (rtx op0, rtx op1, machine_mode mode, unsigned unspec)
14312 {
14313 rtx tmp = gen_reg_rtx (mode);
14314 rtx load = gen_rtx_SET (tmp, op1);
14315 rtx lvx = gen_rtx_UNSPEC (mode, gen_rtvec (1, const0_rtx), unspec);
14316 rtx par = gen_rtx_PARALLEL (mode, gen_rtvec (2, load, lvx));
14317 rtx sel = swap_selector_for_mode (mode);
14318 rtx vperm = gen_rtx_UNSPEC (mode, gen_rtvec (3, tmp, tmp, sel), UNSPEC_VPERM);
14319
14320 gcc_assert (REG_P (op0));
14321 emit_insn (par);
14322 emit_insn (gen_rtx_SET (op0, vperm));
14323 }
14324
14325 /* Generate code for a "stvxl" built-in for a little endian target with
14326 -maltivec=be specified. Issue the store preceded by an element-reversing
14327 permute. */
14328 void
14329 altivec_expand_stvx_be (rtx op0, rtx op1, machine_mode mode, unsigned unspec)
14330 {
14331 rtx tmp = gen_reg_rtx (mode);
14332 rtx store = gen_rtx_SET (op0, tmp);
14333 rtx stvx = gen_rtx_UNSPEC (mode, gen_rtvec (1, const0_rtx), unspec);
14334 rtx par = gen_rtx_PARALLEL (mode, gen_rtvec (2, store, stvx));
14335 rtx sel = swap_selector_for_mode (mode);
14336 rtx vperm;
14337
14338 gcc_assert (REG_P (op1));
14339 vperm = gen_rtx_UNSPEC (mode, gen_rtvec (3, op1, op1, sel), UNSPEC_VPERM);
14340 emit_insn (gen_rtx_SET (tmp, vperm));
14341 emit_insn (par);
14342 }
14343
14344 /* Generate code for a "stve*x" built-in for a little endian target with -maltivec=be
14345 specified. Issue the store preceded by an element-reversing permute. */
14346 void
14347 altivec_expand_stvex_be (rtx op0, rtx op1, machine_mode mode, unsigned unspec)
14348 {
14349 machine_mode inner_mode = GET_MODE_INNER (mode);
14350 rtx tmp = gen_reg_rtx (mode);
14351 rtx stvx = gen_rtx_UNSPEC (inner_mode, gen_rtvec (1, tmp), unspec);
14352 rtx sel = swap_selector_for_mode (mode);
14353 rtx vperm;
14354
14355 gcc_assert (REG_P (op1));
14356 vperm = gen_rtx_UNSPEC (mode, gen_rtvec (3, op1, op1, sel), UNSPEC_VPERM);
14357 emit_insn (gen_rtx_SET (tmp, vperm));
14358 emit_insn (gen_rtx_SET (op0, stvx));
14359 } 13791 }
14360 13792
14361 static rtx 13793 static rtx
14362 altivec_expand_lv_builtin (enum insn_code icode, tree exp, rtx target, bool blk) 13794 altivec_expand_lv_builtin (enum insn_code icode, tree exp, rtx target, bool blk)
14363 { 13795 {
14386 op1 = copy_to_mode_reg (mode1, op1); 13818 op1 = copy_to_mode_reg (mode1, op1);
14387 13819
14388 /* For LVX, express the RTL accurately by ANDing the address with -16. 13820 /* For LVX, express the RTL accurately by ANDing the address with -16.
14389 LVXL and LVE*X expand to use UNSPECs to hide their special behavior, 13821 LVXL and LVE*X expand to use UNSPECs to hide their special behavior,
14390 so the raw address is fine. */ 13822 so the raw address is fine. */
14391 if (icode == CODE_FOR_altivec_lvx_v2df_2op 13823 if (icode == CODE_FOR_altivec_lvx_v1ti
14392 || icode == CODE_FOR_altivec_lvx_v2di_2op 13824 || icode == CODE_FOR_altivec_lvx_v2df
14393 || icode == CODE_FOR_altivec_lvx_v4sf_2op 13825 || icode == CODE_FOR_altivec_lvx_v2di
14394 || icode == CODE_FOR_altivec_lvx_v4si_2op 13826 || icode == CODE_FOR_altivec_lvx_v4sf
14395 || icode == CODE_FOR_altivec_lvx_v8hi_2op 13827 || icode == CODE_FOR_altivec_lvx_v4si
14396 || icode == CODE_FOR_altivec_lvx_v16qi_2op) 13828 || icode == CODE_FOR_altivec_lvx_v8hi
13829 || icode == CODE_FOR_altivec_lvx_v16qi)
14397 { 13830 {
14398 rtx rawaddr; 13831 rtx rawaddr;
14399 if (op0 == const0_rtx) 13832 if (op0 == const0_rtx)
14400 rawaddr = op1; 13833 rawaddr = op1;
14401 else 13834 else
14404 rawaddr = gen_rtx_PLUS (Pmode, op1, op0); 13837 rawaddr = gen_rtx_PLUS (Pmode, op1, op0);
14405 } 13838 }
14406 addr = gen_rtx_AND (Pmode, rawaddr, gen_rtx_CONST_INT (Pmode, -16)); 13839 addr = gen_rtx_AND (Pmode, rawaddr, gen_rtx_CONST_INT (Pmode, -16));
14407 addr = gen_rtx_MEM (blk ? BLKmode : tmode, addr); 13840 addr = gen_rtx_MEM (blk ? BLKmode : tmode, addr);
14408 13841
14409 /* For -maltivec=be, emit the load and follow it up with a 13842 emit_insn (gen_rtx_SET (target, addr));
14410 permute to swap the elements. */
14411 if (!BYTES_BIG_ENDIAN && VECTOR_ELT_ORDER_BIG)
14412 {
14413 rtx temp = gen_reg_rtx (tmode);
14414 emit_insn (gen_rtx_SET (temp, addr));
14415
14416 rtx sel = swap_selector_for_mode (tmode);
14417 rtx vperm = gen_rtx_UNSPEC (tmode, gen_rtvec (3, temp, temp, sel),
14418 UNSPEC_VPERM);
14419 emit_insn (gen_rtx_SET (target, vperm));
14420 }
14421 else
14422 emit_insn (gen_rtx_SET (target, addr));
14423 } 13843 }
14424 else 13844 else
14425 { 13845 {
14426 if (op0 == const0_rtx) 13846 if (op0 == const0_rtx)
14427 addr = gen_rtx_MEM (blk ? BLKmode : tmode, op1); 13847 addr = gen_rtx_MEM (blk ? BLKmode : tmode, op1);
14437 return 0; 13857 return 0;
14438 emit_insn (pat); 13858 emit_insn (pat);
14439 } 13859 }
14440 13860
14441 return target; 13861 return target;
14442 }
14443
14444 static rtx
14445 altivec_expand_xl_be_builtin (enum insn_code icode, tree exp, rtx target, bool blk)
14446 {
14447 rtx pat, addr;
14448 tree arg0 = CALL_EXPR_ARG (exp, 0);
14449 tree arg1 = CALL_EXPR_ARG (exp, 1);
14450 machine_mode tmode = insn_data[icode].operand[0].mode;
14451 machine_mode mode0 = Pmode;
14452 machine_mode mode1 = Pmode;
14453 rtx op0 = expand_normal (arg0);
14454 rtx op1 = expand_normal (arg1);
14455
14456 if (icode == CODE_FOR_nothing)
14457 /* Builtin not supported on this processor. */
14458 return 0;
14459
14460 /* If we got invalid arguments bail out before generating bad rtl. */
14461 if (arg0 == error_mark_node || arg1 == error_mark_node)
14462 return const0_rtx;
14463
14464 if (target == 0
14465 || GET_MODE (target) != tmode
14466 || ! (*insn_data[icode].operand[0].predicate) (target, tmode))
14467 target = gen_reg_rtx (tmode);
14468
14469 op1 = copy_to_mode_reg (mode1, op1);
14470
14471 if (op0 == const0_rtx)
14472 addr = gen_rtx_MEM (blk ? BLKmode : tmode, op1);
14473 else
14474 {
14475 op0 = copy_to_mode_reg (mode0, op0);
14476 addr = gen_rtx_MEM (blk ? BLKmode : tmode,
14477 gen_rtx_PLUS (Pmode, op1, op0));
14478 }
14479
14480 pat = GEN_FCN (icode) (target, addr);
14481 if (!pat)
14482 return 0;
14483
14484 emit_insn (pat);
14485 /* Reverse element order of elements if in LE mode */
14486 if (!VECTOR_ELT_ORDER_BIG)
14487 {
14488 rtx sel = swap_selector_for_mode (tmode);
14489 rtx vperm = gen_rtx_UNSPEC (tmode, gen_rtvec (3, target, target, sel),
14490 UNSPEC_VPERM);
14491 emit_insn (gen_rtx_SET (target, vperm));
14492 }
14493 return target;
14494 }
14495
14496 static rtx
14497 paired_expand_stv_builtin (enum insn_code icode, tree exp)
14498 {
14499 tree arg0 = CALL_EXPR_ARG (exp, 0);
14500 tree arg1 = CALL_EXPR_ARG (exp, 1);
14501 tree arg2 = CALL_EXPR_ARG (exp, 2);
14502 rtx op0 = expand_normal (arg0);
14503 rtx op1 = expand_normal (arg1);
14504 rtx op2 = expand_normal (arg2);
14505 rtx pat, addr;
14506 machine_mode tmode = insn_data[icode].operand[0].mode;
14507 machine_mode mode1 = Pmode;
14508 machine_mode mode2 = Pmode;
14509
14510 /* Invalid arguments. Bail before doing anything stoopid! */
14511 if (arg0 == error_mark_node
14512 || arg1 == error_mark_node
14513 || arg2 == error_mark_node)
14514 return const0_rtx;
14515
14516 if (! (*insn_data[icode].operand[1].predicate) (op0, tmode))
14517 op0 = copy_to_mode_reg (tmode, op0);
14518
14519 op2 = copy_to_mode_reg (mode2, op2);
14520
14521 if (op1 == const0_rtx)
14522 {
14523 addr = gen_rtx_MEM (tmode, op2);
14524 }
14525 else
14526 {
14527 op1 = copy_to_mode_reg (mode1, op1);
14528 addr = gen_rtx_MEM (tmode, gen_rtx_PLUS (Pmode, op1, op2));
14529 }
14530
14531 pat = GEN_FCN (icode) (addr, op0);
14532 if (pat)
14533 emit_insn (pat);
14534 return NULL_RTX;
14535 } 13862 }
14536 13863
14537 static rtx 13864 static rtx
14538 altivec_expand_stxvl_builtin (enum insn_code icode, tree exp) 13865 altivec_expand_stxvl_builtin (enum insn_code icode, tree exp)
14539 { 13866 {
14596 op2 = copy_to_mode_reg (mode2, op2); 13923 op2 = copy_to_mode_reg (mode2, op2);
14597 13924
14598 /* For STVX, express the RTL accurately by ANDing the address with -16. 13925 /* For STVX, express the RTL accurately by ANDing the address with -16.
14599 STVXL and STVE*X expand to use UNSPECs to hide their special behavior, 13926 STVXL and STVE*X expand to use UNSPECs to hide their special behavior,
14600 so the raw address is fine. */ 13927 so the raw address is fine. */
14601 if (icode == CODE_FOR_altivec_stvx_v2df_2op 13928 if (icode == CODE_FOR_altivec_stvx_v2df
14602 || icode == CODE_FOR_altivec_stvx_v2di_2op 13929 || icode == CODE_FOR_altivec_stvx_v2di
14603 || icode == CODE_FOR_altivec_stvx_v4sf_2op 13930 || icode == CODE_FOR_altivec_stvx_v4sf
14604 || icode == CODE_FOR_altivec_stvx_v4si_2op 13931 || icode == CODE_FOR_altivec_stvx_v4si
14605 || icode == CODE_FOR_altivec_stvx_v8hi_2op 13932 || icode == CODE_FOR_altivec_stvx_v8hi
14606 || icode == CODE_FOR_altivec_stvx_v16qi_2op) 13933 || icode == CODE_FOR_altivec_stvx_v16qi)
14607 { 13934 {
14608 if (op1 == const0_rtx) 13935 if (op1 == const0_rtx)
14609 rawaddr = op2; 13936 rawaddr = op2;
14610 else 13937 else
14611 { 13938 {
14616 addr = gen_rtx_AND (Pmode, rawaddr, gen_rtx_CONST_INT (Pmode, -16)); 13943 addr = gen_rtx_AND (Pmode, rawaddr, gen_rtx_CONST_INT (Pmode, -16));
14617 addr = gen_rtx_MEM (tmode, addr); 13944 addr = gen_rtx_MEM (tmode, addr);
14618 13945
14619 op0 = copy_to_mode_reg (tmode, op0); 13946 op0 = copy_to_mode_reg (tmode, op0);
14620 13947
14621 /* For -maltivec=be, emit a permute to swap the elements, followed 13948 emit_insn (gen_rtx_SET (addr, op0));
14622 by the store. */
14623 if (!BYTES_BIG_ENDIAN && VECTOR_ELT_ORDER_BIG)
14624 {
14625 rtx temp = gen_reg_rtx (tmode);
14626 rtx sel = swap_selector_for_mode (tmode);
14627 rtx vperm = gen_rtx_UNSPEC (tmode, gen_rtvec (3, op0, op0, sel),
14628 UNSPEC_VPERM);
14629 emit_insn (gen_rtx_SET (temp, vperm));
14630 emit_insn (gen_rtx_SET (addr, temp));
14631 }
14632 else
14633 emit_insn (gen_rtx_SET (addr, op0));
14634 } 13949 }
14635 else 13950 else
14636 { 13951 {
14637 if (! (*insn_data[icode].operand[1].predicate) (op0, smode)) 13952 if (! (*insn_data[icode].operand[1].predicate) (op0, smode))
14638 op0 = copy_to_mode_reg (smode, op0); 13953 op0 = copy_to_mode_reg (smode, op0);
15159 if (! (*insn_data[icode].operand[2].predicate) (op1, mode1)) 14474 if (! (*insn_data[icode].operand[2].predicate) (op1, mode1))
15160 op1 = copy_to_mode_reg (mode1, op1); 14475 op1 = copy_to_mode_reg (mode1, op1);
15161 if (! (*insn_data[icode].operand[3].predicate) (op2, mode2)) 14476 if (! (*insn_data[icode].operand[3].predicate) (op2, mode2))
15162 op2 = copy_to_mode_reg (mode2, op2); 14477 op2 = copy_to_mode_reg (mode2, op2);
15163 14478
15164 if (TARGET_PAIRED_FLOAT && icode == CODE_FOR_selv2sf4) 14479 pat = GEN_FCN (icode) (target, op0, op1, op2);
15165 pat = GEN_FCN (icode) (target, op0, op1, op2, CONST0_RTX (SFmode));
15166 else
15167 pat = GEN_FCN (icode) (target, op0, op1, op2);
15168 if (! pat) 14480 if (! pat)
15169 return 0; 14481 return 0;
15170 emit_insn (pat); 14482 emit_insn (pat);
15171 14483
15172 return target; 14484 return target;
15173 } 14485 }
15174 14486
15175 /* Expand the lvx builtins. */
15176 static rtx
15177 altivec_expand_ld_builtin (tree exp, rtx target, bool *expandedp)
15178 {
15179 tree fndecl = TREE_OPERAND (CALL_EXPR_FN (exp), 0);
15180 unsigned int fcode = DECL_FUNCTION_CODE (fndecl);
15181 tree arg0;
15182 machine_mode tmode, mode0;
15183 rtx pat, op0;
15184 enum insn_code icode;
15185
15186 switch (fcode)
15187 {
15188 case ALTIVEC_BUILTIN_LD_INTERNAL_16qi:
15189 icode = CODE_FOR_vector_altivec_load_v16qi;
15190 break;
15191 case ALTIVEC_BUILTIN_LD_INTERNAL_8hi:
15192 icode = CODE_FOR_vector_altivec_load_v8hi;
15193 break;
15194 case ALTIVEC_BUILTIN_LD_INTERNAL_4si:
15195 icode = CODE_FOR_vector_altivec_load_v4si;
15196 break;
15197 case ALTIVEC_BUILTIN_LD_INTERNAL_4sf:
15198 icode = CODE_FOR_vector_altivec_load_v4sf;
15199 break;
15200 case ALTIVEC_BUILTIN_LD_INTERNAL_2df:
15201 icode = CODE_FOR_vector_altivec_load_v2df;
15202 break;
15203 case ALTIVEC_BUILTIN_LD_INTERNAL_2di:
15204 icode = CODE_FOR_vector_altivec_load_v2di;
15205 break;
15206 case ALTIVEC_BUILTIN_LD_INTERNAL_1ti:
15207 icode = CODE_FOR_vector_altivec_load_v1ti;
15208 break;
15209 default:
15210 *expandedp = false;
15211 return NULL_RTX;
15212 }
15213
15214 *expandedp = true;
15215
15216 arg0 = CALL_EXPR_ARG (exp, 0);
15217 op0 = expand_normal (arg0);
15218 tmode = insn_data[icode].operand[0].mode;
15219 mode0 = insn_data[icode].operand[1].mode;
15220
15221 if (target == 0
15222 || GET_MODE (target) != tmode
15223 || ! (*insn_data[icode].operand[0].predicate) (target, tmode))
15224 target = gen_reg_rtx (tmode);
15225
15226 if (! (*insn_data[icode].operand[1].predicate) (op0, mode0))
15227 op0 = gen_rtx_MEM (mode0, copy_to_mode_reg (Pmode, op0));
15228
15229 pat = GEN_FCN (icode) (target, op0);
15230 if (! pat)
15231 return 0;
15232 emit_insn (pat);
15233 return target;
15234 }
15235
15236 /* Expand the stvx builtins. */
15237 static rtx
15238 altivec_expand_st_builtin (tree exp, rtx target ATTRIBUTE_UNUSED,
15239 bool *expandedp)
15240 {
15241 tree fndecl = TREE_OPERAND (CALL_EXPR_FN (exp), 0);
15242 unsigned int fcode = DECL_FUNCTION_CODE (fndecl);
15243 tree arg0, arg1;
15244 machine_mode mode0, mode1;
15245 rtx pat, op0, op1;
15246 enum insn_code icode;
15247
15248 switch (fcode)
15249 {
15250 case ALTIVEC_BUILTIN_ST_INTERNAL_16qi:
15251 icode = CODE_FOR_vector_altivec_store_v16qi;
15252 break;
15253 case ALTIVEC_BUILTIN_ST_INTERNAL_8hi:
15254 icode = CODE_FOR_vector_altivec_store_v8hi;
15255 break;
15256 case ALTIVEC_BUILTIN_ST_INTERNAL_4si:
15257 icode = CODE_FOR_vector_altivec_store_v4si;
15258 break;
15259 case ALTIVEC_BUILTIN_ST_INTERNAL_4sf:
15260 icode = CODE_FOR_vector_altivec_store_v4sf;
15261 break;
15262 case ALTIVEC_BUILTIN_ST_INTERNAL_2df:
15263 icode = CODE_FOR_vector_altivec_store_v2df;
15264 break;
15265 case ALTIVEC_BUILTIN_ST_INTERNAL_2di:
15266 icode = CODE_FOR_vector_altivec_store_v2di;
15267 break;
15268 case ALTIVEC_BUILTIN_ST_INTERNAL_1ti:
15269 icode = CODE_FOR_vector_altivec_store_v1ti;
15270 break;
15271 default:
15272 *expandedp = false;
15273 return NULL_RTX;
15274 }
15275
15276 arg0 = CALL_EXPR_ARG (exp, 0);
15277 arg1 = CALL_EXPR_ARG (exp, 1);
15278 op0 = expand_normal (arg0);
15279 op1 = expand_normal (arg1);
15280 mode0 = insn_data[icode].operand[0].mode;
15281 mode1 = insn_data[icode].operand[1].mode;
15282
15283 if (! (*insn_data[icode].operand[0].predicate) (op0, mode0))
15284 op0 = gen_rtx_MEM (mode0, copy_to_mode_reg (Pmode, op0));
15285 if (! (*insn_data[icode].operand[1].predicate) (op1, mode1))
15286 op1 = copy_to_mode_reg (mode1, op1);
15287
15288 pat = GEN_FCN (icode) (op0, op1);
15289 if (pat)
15290 emit_insn (pat);
15291
15292 *expandedp = true;
15293 return NULL_RTX;
15294 }
15295 14487
15296 /* Expand the dst builtins. */ 14488 /* Expand the dst builtins. */
15297 static rtx 14489 static rtx
15298 altivec_expand_dst_builtin (tree exp, rtx target ATTRIBUTE_UNUSED, 14490 altivec_expand_dst_builtin (tree exp, rtx target ATTRIBUTE_UNUSED,
15299 bool *expandedp) 14491 bool *expandedp)
15494 14686
15495 /* Given it is invalid, just generate a normal call. */ 14687 /* Given it is invalid, just generate a normal call. */
15496 return expand_call (exp, target, false); 14688 return expand_call (exp, target, false);
15497 } 14689 }
15498 14690
15499 target = altivec_expand_ld_builtin (exp, target, expandedp);
15500 if (*expandedp)
15501 return target;
15502
15503 target = altivec_expand_st_builtin (exp, target, expandedp);
15504 if (*expandedp)
15505 return target;
15506
15507 target = altivec_expand_dst_builtin (exp, target, expandedp); 14691 target = altivec_expand_dst_builtin (exp, target, expandedp);
15508 if (*expandedp) 14692 if (*expandedp)
15509 return target; 14693 return target;
15510 14694
15511 *expandedp = true; 14695 *expandedp = true;
15512 14696
15513 switch (fcode) 14697 switch (fcode)
15514 { 14698 {
15515 case ALTIVEC_BUILTIN_STVX_V2DF: 14699 case ALTIVEC_BUILTIN_STVX_V2DF:
15516 return altivec_expand_stv_builtin (CODE_FOR_altivec_stvx_v2df_2op, exp); 14700 return altivec_expand_stv_builtin (CODE_FOR_altivec_stvx_v2df, exp);
15517 case ALTIVEC_BUILTIN_STVX_V2DI: 14701 case ALTIVEC_BUILTIN_STVX_V2DI:
15518 return altivec_expand_stv_builtin (CODE_FOR_altivec_stvx_v2di_2op, exp); 14702 return altivec_expand_stv_builtin (CODE_FOR_altivec_stvx_v2di, exp);
15519 case ALTIVEC_BUILTIN_STVX_V4SF: 14703 case ALTIVEC_BUILTIN_STVX_V4SF:
15520 return altivec_expand_stv_builtin (CODE_FOR_altivec_stvx_v4sf_2op, exp); 14704 return altivec_expand_stv_builtin (CODE_FOR_altivec_stvx_v4sf, exp);
15521 case ALTIVEC_BUILTIN_STVX: 14705 case ALTIVEC_BUILTIN_STVX:
15522 case ALTIVEC_BUILTIN_STVX_V4SI: 14706 case ALTIVEC_BUILTIN_STVX_V4SI:
15523 return altivec_expand_stv_builtin (CODE_FOR_altivec_stvx_v4si_2op, exp); 14707 return altivec_expand_stv_builtin (CODE_FOR_altivec_stvx_v4si, exp);
15524 case ALTIVEC_BUILTIN_STVX_V8HI: 14708 case ALTIVEC_BUILTIN_STVX_V8HI:
15525 return altivec_expand_stv_builtin (CODE_FOR_altivec_stvx_v8hi_2op, exp); 14709 return altivec_expand_stv_builtin (CODE_FOR_altivec_stvx_v8hi, exp);
15526 case ALTIVEC_BUILTIN_STVX_V16QI: 14710 case ALTIVEC_BUILTIN_STVX_V16QI:
15527 return altivec_expand_stv_builtin (CODE_FOR_altivec_stvx_v16qi_2op, exp); 14711 return altivec_expand_stv_builtin (CODE_FOR_altivec_stvx_v16qi, exp);
15528 case ALTIVEC_BUILTIN_STVEBX: 14712 case ALTIVEC_BUILTIN_STVEBX:
15529 return altivec_expand_stv_builtin (CODE_FOR_altivec_stvebx, exp); 14713 return altivec_expand_stv_builtin (CODE_FOR_altivec_stvebx, exp);
15530 case ALTIVEC_BUILTIN_STVEHX: 14714 case ALTIVEC_BUILTIN_STVEHX:
15531 return altivec_expand_stv_builtin (CODE_FOR_altivec_stvehx, exp); 14715 return altivec_expand_stv_builtin (CODE_FOR_altivec_stvehx, exp);
15532 case ALTIVEC_BUILTIN_STVEWX: 14716 case ALTIVEC_BUILTIN_STVEWX:
15577 14761
15578 /* For the following on big endian, it's ok to use any appropriate 14762 /* For the following on big endian, it's ok to use any appropriate
15579 unaligned-supporting store, so use a generic expander. For 14763 unaligned-supporting store, so use a generic expander. For
15580 little-endian, the exact element-reversing instruction must 14764 little-endian, the exact element-reversing instruction must
15581 be used. */ 14765 be used. */
14766 case VSX_BUILTIN_ST_ELEMREV_V1TI:
14767 {
14768 enum insn_code code = (BYTES_BIG_ENDIAN ? CODE_FOR_vsx_store_v1ti
14769 : CODE_FOR_vsx_st_elemrev_v1ti);
14770 return altivec_expand_stv_builtin (code, exp);
14771 }
15582 case VSX_BUILTIN_ST_ELEMREV_V2DF: 14772 case VSX_BUILTIN_ST_ELEMREV_V2DF:
15583 { 14773 {
15584 enum insn_code code = (BYTES_BIG_ENDIAN ? CODE_FOR_vsx_store_v2df 14774 enum insn_code code = (BYTES_BIG_ENDIAN ? CODE_FOR_vsx_store_v2df
15585 : CODE_FOR_vsx_st_elemrev_v2df); 14775 : CODE_FOR_vsx_st_elemrev_v2df);
15586 return altivec_expand_stv_builtin (code, exp); 14776 return altivec_expand_stv_builtin (code, exp);
15702 case VSX_BUILTIN_VEC_EXT_V2DF: 14892 case VSX_BUILTIN_VEC_EXT_V2DF:
15703 case VSX_BUILTIN_VEC_EXT_V2DI: 14893 case VSX_BUILTIN_VEC_EXT_V2DI:
15704 case VSX_BUILTIN_VEC_EXT_V1TI: 14894 case VSX_BUILTIN_VEC_EXT_V1TI:
15705 return altivec_expand_vec_ext_builtin (exp, target); 14895 return altivec_expand_vec_ext_builtin (exp, target);
15706 14896
15707 case P9V_BUILTIN_VEXTRACT4B: 14897 case P9V_BUILTIN_VEC_EXTRACT4B:
15708 case P9V_BUILTIN_VEC_VEXTRACT4B:
15709 arg1 = CALL_EXPR_ARG (exp, 1); 14898 arg1 = CALL_EXPR_ARG (exp, 1);
15710 STRIP_NOPS (arg1); 14899 STRIP_NOPS (arg1);
15711 14900
15712 /* Generate a normal call if it is invalid. */ 14901 /* Generate a normal call if it is invalid. */
15713 if (arg1 == error_mark_node) 14902 if (arg1 == error_mark_node)
15718 error ("second argument to %qs must be 0..12", "vec_vextract4b"); 14907 error ("second argument to %qs must be 0..12", "vec_vextract4b");
15719 return expand_call (exp, target, false); 14908 return expand_call (exp, target, false);
15720 } 14909 }
15721 break; 14910 break;
15722 14911
15723 case P9V_BUILTIN_VINSERT4B: 14912 case P9V_BUILTIN_VEC_INSERT4B:
15724 case P9V_BUILTIN_VINSERT4B_DI:
15725 case P9V_BUILTIN_VEC_VINSERT4B:
15726 arg2 = CALL_EXPR_ARG (exp, 2); 14913 arg2 = CALL_EXPR_ARG (exp, 2);
15727 STRIP_NOPS (arg2); 14914 STRIP_NOPS (arg2);
15728 14915
15729 /* Generate a normal call if it is invalid. */ 14916 /* Generate a normal call if it is invalid. */
15730 if (arg2 == error_mark_node) 14917 if (arg2 == error_mark_node)
15789 return altivec_expand_lv_builtin (CODE_FOR_altivec_lvxl_v8hi, 14976 return altivec_expand_lv_builtin (CODE_FOR_altivec_lvxl_v8hi,
15790 exp, target, false); 14977 exp, target, false);
15791 case ALTIVEC_BUILTIN_LVXL_V16QI: 14978 case ALTIVEC_BUILTIN_LVXL_V16QI:
15792 return altivec_expand_lv_builtin (CODE_FOR_altivec_lvxl_v16qi, 14979 return altivec_expand_lv_builtin (CODE_FOR_altivec_lvxl_v16qi,
15793 exp, target, false); 14980 exp, target, false);
14981 case ALTIVEC_BUILTIN_LVX_V1TI:
14982 return altivec_expand_lv_builtin (CODE_FOR_altivec_lvx_v1ti,
14983 exp, target, false);
15794 case ALTIVEC_BUILTIN_LVX_V2DF: 14984 case ALTIVEC_BUILTIN_LVX_V2DF:
15795 return altivec_expand_lv_builtin (CODE_FOR_altivec_lvx_v2df_2op, 14985 return altivec_expand_lv_builtin (CODE_FOR_altivec_lvx_v2df,
15796 exp, target, false); 14986 exp, target, false);
15797 case ALTIVEC_BUILTIN_LVX_V2DI: 14987 case ALTIVEC_BUILTIN_LVX_V2DI:
15798 return altivec_expand_lv_builtin (CODE_FOR_altivec_lvx_v2di_2op, 14988 return altivec_expand_lv_builtin (CODE_FOR_altivec_lvx_v2di,
15799 exp, target, false); 14989 exp, target, false);
15800 case ALTIVEC_BUILTIN_LVX_V4SF: 14990 case ALTIVEC_BUILTIN_LVX_V4SF:
15801 return altivec_expand_lv_builtin (CODE_FOR_altivec_lvx_v4sf_2op, 14991 return altivec_expand_lv_builtin (CODE_FOR_altivec_lvx_v4sf,
15802 exp, target, false); 14992 exp, target, false);
15803 case ALTIVEC_BUILTIN_LVX: 14993 case ALTIVEC_BUILTIN_LVX:
15804 case ALTIVEC_BUILTIN_LVX_V4SI: 14994 case ALTIVEC_BUILTIN_LVX_V4SI:
15805 return altivec_expand_lv_builtin (CODE_FOR_altivec_lvx_v4si_2op, 14995 return altivec_expand_lv_builtin (CODE_FOR_altivec_lvx_v4si,
15806 exp, target, false); 14996 exp, target, false);
15807 case ALTIVEC_BUILTIN_LVX_V8HI: 14997 case ALTIVEC_BUILTIN_LVX_V8HI:
15808 return altivec_expand_lv_builtin (CODE_FOR_altivec_lvx_v8hi_2op, 14998 return altivec_expand_lv_builtin (CODE_FOR_altivec_lvx_v8hi,
15809 exp, target, false); 14999 exp, target, false);
15810 case ALTIVEC_BUILTIN_LVX_V16QI: 15000 case ALTIVEC_BUILTIN_LVX_V16QI:
15811 return altivec_expand_lv_builtin (CODE_FOR_altivec_lvx_v16qi_2op, 15001 return altivec_expand_lv_builtin (CODE_FOR_altivec_lvx_v16qi,
15812 exp, target, false); 15002 exp, target, false);
15813 case ALTIVEC_BUILTIN_LVLX: 15003 case ALTIVEC_BUILTIN_LVLX:
15814 return altivec_expand_lv_builtin (CODE_FOR_altivec_lvlx, 15004 return altivec_expand_lv_builtin (CODE_FOR_altivec_lvlx,
15815 exp, target, true); 15005 exp, target, true);
15816 case ALTIVEC_BUILTIN_LVLXL: 15006 case ALTIVEC_BUILTIN_LVLXL:
15851 { 15041 {
15852 enum insn_code code = (BYTES_BIG_ENDIAN ? CODE_FOR_vsx_load_v2df 15042 enum insn_code code = (BYTES_BIG_ENDIAN ? CODE_FOR_vsx_load_v2df
15853 : CODE_FOR_vsx_ld_elemrev_v2df); 15043 : CODE_FOR_vsx_ld_elemrev_v2df);
15854 return altivec_expand_lv_builtin (code, exp, target, false); 15044 return altivec_expand_lv_builtin (code, exp, target, false);
15855 } 15045 }
15046 case VSX_BUILTIN_LD_ELEMREV_V1TI:
15047 {
15048 enum insn_code code = (BYTES_BIG_ENDIAN ? CODE_FOR_vsx_load_v1ti
15049 : CODE_FOR_vsx_ld_elemrev_v1ti);
15050 return altivec_expand_lv_builtin (code, exp, target, false);
15051 }
15856 case VSX_BUILTIN_LD_ELEMREV_V2DI: 15052 case VSX_BUILTIN_LD_ELEMREV_V2DI:
15857 { 15053 {
15858 enum insn_code code = (BYTES_BIG_ENDIAN ? CODE_FOR_vsx_load_v2di 15054 enum insn_code code = (BYTES_BIG_ENDIAN ? CODE_FOR_vsx_load_v2di
15859 : CODE_FOR_vsx_ld_elemrev_v2di); 15055 : CODE_FOR_vsx_ld_elemrev_v2di);
15860 return altivec_expand_lv_builtin (code, exp, target, false); 15056 return altivec_expand_lv_builtin (code, exp, target, false);
15887 default: 15083 default:
15888 break; 15084 break;
15889 /* Fall through. */ 15085 /* Fall through. */
15890 } 15086 }
15891 15087
15892 /* XL_BE We initialized them to always load in big endian order. */
15893 switch (fcode)
15894 {
15895 case VSX_BUILTIN_XL_BE_V2DI:
15896 {
15897 enum insn_code code = CODE_FOR_vsx_load_v2di;
15898 return altivec_expand_xl_be_builtin (code, exp, target, false);
15899 }
15900 break;
15901 case VSX_BUILTIN_XL_BE_V4SI:
15902 {
15903 enum insn_code code = CODE_FOR_vsx_load_v4si;
15904 return altivec_expand_xl_be_builtin (code, exp, target, false);
15905 }
15906 break;
15907 case VSX_BUILTIN_XL_BE_V8HI:
15908 {
15909 enum insn_code code = CODE_FOR_vsx_load_v8hi;
15910 return altivec_expand_xl_be_builtin (code, exp, target, false);
15911 }
15912 break;
15913 case VSX_BUILTIN_XL_BE_V16QI:
15914 {
15915 enum insn_code code = CODE_FOR_vsx_load_v16qi;
15916 return altivec_expand_xl_be_builtin (code, exp, target, false);
15917 }
15918 break;
15919 case VSX_BUILTIN_XL_BE_V2DF:
15920 {
15921 enum insn_code code = CODE_FOR_vsx_load_v2df;
15922 return altivec_expand_xl_be_builtin (code, exp, target, false);
15923 }
15924 break;
15925 case VSX_BUILTIN_XL_BE_V4SF:
15926 {
15927 enum insn_code code = CODE_FOR_vsx_load_v4sf;
15928 return altivec_expand_xl_be_builtin (code, exp, target, false);
15929 }
15930 break;
15931 default:
15932 break;
15933 /* Fall through. */
15934 }
15935
15936 *expandedp = false; 15088 *expandedp = false;
15937 return NULL_RTX; 15089 return NULL_RTX;
15938 } 15090 }
15939 15091
15940 /* Expand the builtin in EXP and store the result in TARGET. Store 15092 /* Check whether a builtin function is supported in this target
15941 true in *EXPANDEDP if we found a builtin to expand. */ 15093 configuration. */
15942 static rtx 15094 bool
15943 paired_expand_builtin (tree exp, rtx target, bool * expandedp) 15095 rs6000_builtin_is_supported_p (enum rs6000_builtins fncode)
15944 { 15096 {
15945 tree fndecl = TREE_OPERAND (CALL_EXPR_FN (exp), 0); 15097 HOST_WIDE_INT fnmask = rs6000_builtin_info[fncode].mask;
15946 enum rs6000_builtins fcode = (enum rs6000_builtins) DECL_FUNCTION_CODE (fndecl); 15098 if ((fnmask & rs6000_builtin_mask) != fnmask)
15947 const struct builtin_description *d; 15099 return false;
15948 size_t i;
15949
15950 *expandedp = true;
15951
15952 switch (fcode)
15953 {
15954 case PAIRED_BUILTIN_STX:
15955 return paired_expand_stv_builtin (CODE_FOR_paired_stx, exp);
15956 case PAIRED_BUILTIN_LX:
15957 return paired_expand_lv_builtin (CODE_FOR_paired_lx, exp, target);
15958 default:
15959 break;
15960 /* Fall through. */
15961 }
15962
15963 /* Expand the paired predicates. */
15964 d = bdesc_paired_preds;
15965 for (i = 0; i < ARRAY_SIZE (bdesc_paired_preds); i++, d++)
15966 if (d->code == fcode)
15967 return paired_expand_predicate_builtin (d->icode, exp, target);
15968
15969 *expandedp = false;
15970 return NULL_RTX;
15971 }
15972
15973 static rtx
15974 paired_expand_predicate_builtin (enum insn_code icode, tree exp, rtx target)
15975 {
15976 rtx pat, scratch, tmp;
15977 tree form = CALL_EXPR_ARG (exp, 0);
15978 tree arg0 = CALL_EXPR_ARG (exp, 1);
15979 tree arg1 = CALL_EXPR_ARG (exp, 2);
15980 rtx op0 = expand_normal (arg0);
15981 rtx op1 = expand_normal (arg1);
15982 machine_mode mode0 = insn_data[icode].operand[1].mode;
15983 machine_mode mode1 = insn_data[icode].operand[2].mode;
15984 int form_int;
15985 enum rtx_code code;
15986
15987 if (TREE_CODE (form) != INTEGER_CST)
15988 {
15989 error ("argument 1 of %s must be a constant",
15990 "__builtin_paired_predicate");
15991 return const0_rtx;
15992 }
15993 else 15100 else
15994 form_int = TREE_INT_CST_LOW (form); 15101 return true;
15995
15996 gcc_assert (mode0 == mode1);
15997
15998 if (arg0 == error_mark_node || arg1 == error_mark_node)
15999 return const0_rtx;
16000
16001 if (target == 0
16002 || GET_MODE (target) != SImode
16003 || !(*insn_data[icode].operand[0].predicate) (target, SImode))
16004 target = gen_reg_rtx (SImode);
16005 if (!(*insn_data[icode].operand[1].predicate) (op0, mode0))
16006 op0 = copy_to_mode_reg (mode0, op0);
16007 if (!(*insn_data[icode].operand[2].predicate) (op1, mode1))
16008 op1 = copy_to_mode_reg (mode1, op1);
16009
16010 scratch = gen_reg_rtx (CCFPmode);
16011
16012 pat = GEN_FCN (icode) (scratch, op0, op1);
16013 if (!pat)
16014 return const0_rtx;
16015
16016 emit_insn (pat);
16017
16018 switch (form_int)
16019 {
16020 /* LT bit. */
16021 case 0:
16022 code = LT;
16023 break;
16024 /* GT bit. */
16025 case 1:
16026 code = GT;
16027 break;
16028 /* EQ bit. */
16029 case 2:
16030 code = EQ;
16031 break;
16032 /* UN bit. */
16033 case 3:
16034 emit_insn (gen_move_from_CR_ov_bit (target, scratch));
16035 return target;
16036 default:
16037 error ("argument 1 of %qs is out of range",
16038 "__builtin_paired_predicate");
16039 return const0_rtx;
16040 }
16041
16042 tmp = gen_rtx_fmt_ee (code, SImode, scratch, const0_rtx);
16043 emit_move_insn (target, tmp);
16044 return target;
16045 } 15102 }
16046 15103
16047 /* Raise an error message for a builtin function that is called without the 15104 /* Raise an error message for a builtin function that is called without the
16048 appropriate target options being set. */ 15105 appropriate target options being set. */
16049 15106
16061 error ("builtin function %qs requires the %qs option", name, "-mvsx"); 15118 error ("builtin function %qs requires the %qs option", name, "-mvsx");
16062 else if ((fnmask & RS6000_BTM_HTM) != 0) 15119 else if ((fnmask & RS6000_BTM_HTM) != 0)
16063 error ("builtin function %qs requires the %qs option", name, "-mhtm"); 15120 error ("builtin function %qs requires the %qs option", name, "-mhtm");
16064 else if ((fnmask & RS6000_BTM_ALTIVEC) != 0) 15121 else if ((fnmask & RS6000_BTM_ALTIVEC) != 0)
16065 error ("builtin function %qs requires the %qs option", name, "-maltivec"); 15122 error ("builtin function %qs requires the %qs option", name, "-maltivec");
16066 else if ((fnmask & RS6000_BTM_PAIRED) != 0)
16067 error ("builtin function %qs requires the %qs option", name, "-mpaired");
16068 else if ((fnmask & (RS6000_BTM_DFP | RS6000_BTM_P8_VECTOR)) 15123 else if ((fnmask & (RS6000_BTM_DFP | RS6000_BTM_P8_VECTOR))
16069 == (RS6000_BTM_DFP | RS6000_BTM_P8_VECTOR)) 15124 == (RS6000_BTM_DFP | RS6000_BTM_P8_VECTOR))
16070 error ("builtin function %qs requires the %qs and %qs options", 15125 error ("builtin function %qs requires the %qs and %qs options",
16071 name, "-mhard-dfp", "-mpower8-vector"); 15126 name, "-mhard-dfp", "-mpower8-vector");
16072 else if ((fnmask & RS6000_BTM_DFP) != 0) 15127 else if ((fnmask & RS6000_BTM_DFP) != 0)
16086 error ("builtin function %qs requires the %qs and %qs options", 15141 error ("builtin function %qs requires the %qs and %qs options",
16087 name, "-mcpu=power9", "-m64"); 15142 name, "-mcpu=power9", "-m64");
16088 else if ((fnmask & RS6000_BTM_P9_MISC) == RS6000_BTM_P9_MISC) 15143 else if ((fnmask & RS6000_BTM_P9_MISC) == RS6000_BTM_P9_MISC)
16089 error ("builtin function %qs requires the %qs option", name, 15144 error ("builtin function %qs requires the %qs option", name,
16090 "-mcpu=power9"); 15145 "-mcpu=power9");
16091 else if ((fnmask & (RS6000_BTM_HARD_FLOAT | RS6000_BTM_LDBL128)) 15146 else if ((fnmask & RS6000_BTM_LDBL128) == RS6000_BTM_LDBL128)
16092 == (RS6000_BTM_HARD_FLOAT | RS6000_BTM_LDBL128)) 15147 {
16093 error ("builtin function %qs requires the %qs and %qs options", 15148 if (!TARGET_HARD_FLOAT)
16094 name, "-mhard-float", "-mlong-double-128"); 15149 error ("builtin function %qs requires the %qs option", name,
15150 "-mhard-float");
15151 else
15152 error ("builtin function %qs requires the %qs option", name,
15153 TARGET_IEEEQUAD ? "-mabi=ibmlongdouble" : "-mlong-double-128");
15154 }
16095 else if ((fnmask & RS6000_BTM_HARD_FLOAT) != 0) 15155 else if ((fnmask & RS6000_BTM_HARD_FLOAT) != 0)
16096 error ("builtin function %qs requires the %qs option", name, 15156 error ("builtin function %qs requires the %qs option", name,
16097 "-mhard-float"); 15157 "-mhard-float");
16098 else if ((fnmask & RS6000_BTM_FLOAT128_HW) != 0) 15158 else if ((fnmask & RS6000_BTM_FLOAT128_HW) != 0)
16099 error ("builtin function %qs requires ISA 3.0 IEEE 128-bit floating point", 15159 error ("builtin function %qs requires ISA 3.0 IEEE 128-bit floating point",
16100 name); 15160 name);
16101 else if ((fnmask & RS6000_BTM_FLOAT128) != 0) 15161 else if ((fnmask & RS6000_BTM_FLOAT128) != 0)
16102 error ("builtin function %qs requires the %qs option", name, "-mfloat128"); 15162 error ("builtin function %qs requires the %qs option", name, "-mfloat128");
15163 else if ((fnmask & (RS6000_BTM_POPCNTD | RS6000_BTM_POWERPC64))
15164 == (RS6000_BTM_POPCNTD | RS6000_BTM_POWERPC64))
15165 error ("builtin function %qs requires the %qs (or newer), and "
15166 "%qs or %qs options",
15167 name, "-mcpu=power7", "-m64", "-mpowerpc64");
16103 else 15168 else
16104 error ("builtin function %qs is not supported with the current options", 15169 error ("builtin function %qs is not supported with the current options",
16105 name); 15170 name);
16106 } 15171 }
16107 15172
16108 /* Target hook for early folding of built-ins, shamelessly stolen 15173 /* Target hook for early folding of built-ins, shamelessly stolen
16109 from ia64.c. */ 15174 from ia64.c. */
16110 15175
16111 static tree 15176 static tree
16112 rs6000_fold_builtin (tree fndecl, int n_args ATTRIBUTE_UNUSED, 15177 rs6000_fold_builtin (tree fndecl ATTRIBUTE_UNUSED,
16113 tree *args, bool ignore ATTRIBUTE_UNUSED) 15178 int n_args ATTRIBUTE_UNUSED,
16114 { 15179 tree *args ATTRIBUTE_UNUSED,
16115 if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD) 15180 bool ignore ATTRIBUTE_UNUSED)
16116 { 15181 {
16117 enum rs6000_builtins fn_code
16118 = (enum rs6000_builtins) DECL_FUNCTION_CODE (fndecl);
16119 switch (fn_code)
16120 {
16121 case RS6000_BUILTIN_NANQ:
16122 case RS6000_BUILTIN_NANSQ:
16123 {
16124 tree type = TREE_TYPE (TREE_TYPE (fndecl));
16125 const char *str = c_getstr (*args);
16126 int quiet = fn_code == RS6000_BUILTIN_NANQ;
16127 REAL_VALUE_TYPE real;
16128
16129 if (str && real_nan (&real, str, quiet, TYPE_MODE (type)))
16130 return build_real (type, real);
16131 return NULL_TREE;
16132 }
16133 case RS6000_BUILTIN_INFQ:
16134 case RS6000_BUILTIN_HUGE_VALQ:
16135 {
16136 tree type = TREE_TYPE (TREE_TYPE (fndecl));
16137 REAL_VALUE_TYPE inf;
16138 real_inf (&inf);
16139 return build_real (type, inf);
16140 }
16141 default:
16142 break;
16143 }
16144 }
16145 #ifdef SUBTARGET_FOLD_BUILTIN 15182 #ifdef SUBTARGET_FOLD_BUILTIN
16146 return SUBTARGET_FOLD_BUILTIN (fndecl, n_args, args, ignore); 15183 return SUBTARGET_FOLD_BUILTIN (fndecl, n_args, args, ignore);
16147 #else 15184 #else
16148 return NULL_TREE; 15185 return NULL_TREE;
16149 #endif 15186 #endif
16160 case ALTIVEC_BUILTIN_STVX_V8HI: 15197 case ALTIVEC_BUILTIN_STVX_V8HI:
16161 case ALTIVEC_BUILTIN_STVX_V4SI: 15198 case ALTIVEC_BUILTIN_STVX_V4SI:
16162 case ALTIVEC_BUILTIN_STVX_V4SF: 15199 case ALTIVEC_BUILTIN_STVX_V4SF:
16163 case ALTIVEC_BUILTIN_STVX_V2DI: 15200 case ALTIVEC_BUILTIN_STVX_V2DI:
16164 case ALTIVEC_BUILTIN_STVX_V2DF: 15201 case ALTIVEC_BUILTIN_STVX_V2DF:
15202 case VSX_BUILTIN_STXVW4X_V16QI:
15203 case VSX_BUILTIN_STXVW4X_V8HI:
15204 case VSX_BUILTIN_STXVW4X_V4SF:
15205 case VSX_BUILTIN_STXVW4X_V4SI:
15206 case VSX_BUILTIN_STXVD2X_V2DF:
15207 case VSX_BUILTIN_STXVD2X_V2DI:
16165 return true; 15208 return true;
16166 default: 15209 default:
16167 return false; 15210 return false;
16168 } 15211 }
15212 }
15213
15214 /* Helper function to handle the gimple folding of a vector compare
15215 operation. This sets up true/false vectors, and uses the
15216 VEC_COND_EXPR operation.
15217 CODE indicates which comparison is to be made. (EQ, GT, ...).
15218 TYPE indicates the type of the result. */
15219 static tree
15220 fold_build_vec_cmp (tree_code code, tree type,
15221 tree arg0, tree arg1)
15222 {
15223 tree cmp_type = build_same_sized_truth_vector_type (type);
15224 tree zero_vec = build_zero_cst (type);
15225 tree minus_one_vec = build_minus_one_cst (type);
15226 tree cmp = fold_build2 (code, cmp_type, arg0, arg1);
15227 return fold_build3 (VEC_COND_EXPR, type, cmp, minus_one_vec, zero_vec);
15228 }
15229
15230 /* Helper function to handle the in-between steps for the
15231 vector compare built-ins. */
15232 static void
15233 fold_compare_helper (gimple_stmt_iterator *gsi, tree_code code, gimple *stmt)
15234 {
15235 tree arg0 = gimple_call_arg (stmt, 0);
15236 tree arg1 = gimple_call_arg (stmt, 1);
15237 tree lhs = gimple_call_lhs (stmt);
15238 tree cmp = fold_build_vec_cmp (code, TREE_TYPE (lhs), arg0, arg1);
15239 gimple *g = gimple_build_assign (lhs, cmp);
15240 gimple_set_location (g, gimple_location (stmt));
15241 gsi_replace (gsi, g, true);
15242 }
15243
15244 /* Helper function to map V2DF and V4SF types to their
15245 integral equivalents (V2DI and V4SI). */
15246 tree map_to_integral_tree_type (tree input_tree_type)
15247 {
15248 if (INTEGRAL_TYPE_P (TREE_TYPE (input_tree_type)))
15249 return input_tree_type;
15250 else
15251 {
15252 if (types_compatible_p (TREE_TYPE (input_tree_type),
15253 TREE_TYPE (V2DF_type_node)))
15254 return V2DI_type_node;
15255 else if (types_compatible_p (TREE_TYPE (input_tree_type),
15256 TREE_TYPE (V4SF_type_node)))
15257 return V4SI_type_node;
15258 else
15259 gcc_unreachable ();
15260 }
15261 }
15262
15263 /* Helper function to handle the vector merge[hl] built-ins. The
15264 implementation difference between h and l versions for this code are in
15265 the values used when building of the permute vector for high word versus
15266 low word merge. The variance is keyed off the use_high parameter. */
15267 static void
15268 fold_mergehl_helper (gimple_stmt_iterator *gsi, gimple *stmt, int use_high)
15269 {
15270 tree arg0 = gimple_call_arg (stmt, 0);
15271 tree arg1 = gimple_call_arg (stmt, 1);
15272 tree lhs = gimple_call_lhs (stmt);
15273 tree lhs_type = TREE_TYPE (lhs);
15274 int n_elts = TYPE_VECTOR_SUBPARTS (lhs_type);
15275 int midpoint = n_elts / 2;
15276 int offset = 0;
15277
15278 if (use_high == 1)
15279 offset = midpoint;
15280
15281 /* The permute_type will match the lhs for integral types. For double and
15282 float types, the permute type needs to map to the V2 or V4 type that
15283 matches size. */
15284 tree permute_type;
15285 permute_type = map_to_integral_tree_type (lhs_type);
15286 tree_vector_builder elts (permute_type, VECTOR_CST_NELTS (arg0), 1);
15287
15288 for (int i = 0; i < midpoint; i++)
15289 {
15290 elts.safe_push (build_int_cst (TREE_TYPE (permute_type),
15291 offset + i));
15292 elts.safe_push (build_int_cst (TREE_TYPE (permute_type),
15293 offset + n_elts + i));
15294 }
15295
15296 tree permute = elts.build ();
15297
15298 gimple *g = gimple_build_assign (lhs, VEC_PERM_EXPR, arg0, arg1, permute);
15299 gimple_set_location (g, gimple_location (stmt));
15300 gsi_replace (gsi, g, true);
15301 }
15302
15303 /* Helper function to handle the vector merge[eo] built-ins. */
15304 static void
15305 fold_mergeeo_helper (gimple_stmt_iterator *gsi, gimple *stmt, int use_odd)
15306 {
15307 tree arg0 = gimple_call_arg (stmt, 0);
15308 tree arg1 = gimple_call_arg (stmt, 1);
15309 tree lhs = gimple_call_lhs (stmt);
15310 tree lhs_type = TREE_TYPE (lhs);
15311 int n_elts = TYPE_VECTOR_SUBPARTS (lhs_type);
15312
15313 /* The permute_type will match the lhs for integral types. For double and
15314 float types, the permute type needs to map to the V2 or V4 type that
15315 matches size. */
15316 tree permute_type;
15317 permute_type = map_to_integral_tree_type (lhs_type);
15318
15319 tree_vector_builder elts (permute_type, VECTOR_CST_NELTS (arg0), 1);
15320
15321 /* Build the permute vector. */
15322 for (int i = 0; i < n_elts / 2; i++)
15323 {
15324 elts.safe_push (build_int_cst (TREE_TYPE (permute_type),
15325 2*i + use_odd));
15326 elts.safe_push (build_int_cst (TREE_TYPE (permute_type),
15327 2*i + use_odd + n_elts));
15328 }
15329
15330 tree permute = elts.build ();
15331
15332 gimple *g = gimple_build_assign (lhs, VEC_PERM_EXPR, arg0, arg1, permute);
15333 gimple_set_location (g, gimple_location (stmt));
15334 gsi_replace (gsi, g, true);
16169 } 15335 }
16170 15336
16171 /* Fold a machine-dependent built-in in GIMPLE. (For folding into 15337 /* Fold a machine-dependent built-in in GIMPLE. (For folding into
16172 a constant, use rs6000_fold_builtin.) */ 15338 a constant, use rs6000_fold_builtin.) */
16173 15339
16177 gimple *stmt = gsi_stmt (*gsi); 15343 gimple *stmt = gsi_stmt (*gsi);
16178 tree fndecl = gimple_call_fndecl (stmt); 15344 tree fndecl = gimple_call_fndecl (stmt);
16179 gcc_checking_assert (fndecl && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD); 15345 gcc_checking_assert (fndecl && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD);
16180 enum rs6000_builtins fn_code 15346 enum rs6000_builtins fn_code
16181 = (enum rs6000_builtins) DECL_FUNCTION_CODE (fndecl); 15347 = (enum rs6000_builtins) DECL_FUNCTION_CODE (fndecl);
16182 tree arg0, arg1, lhs; 15348 tree arg0, arg1, lhs, temp;
15349 gimple *g;
16183 15350
16184 size_t uns_fncode = (size_t) fn_code; 15351 size_t uns_fncode = (size_t) fn_code;
16185 enum insn_code icode = rs6000_builtin_info[uns_fncode].icode; 15352 enum insn_code icode = rs6000_builtin_info[uns_fncode].icode;
16186 const char *fn_name1 = rs6000_builtin_info[uns_fncode].name; 15353 const char *fn_name1 = rs6000_builtin_info[uns_fncode].name;
16187 const char *fn_name2 = (icode != CODE_FOR_nothing) 15354 const char *fn_name2 = (icode != CODE_FOR_nothing)
16194 15361
16195 if (!rs6000_fold_gimple) 15362 if (!rs6000_fold_gimple)
16196 return false; 15363 return false;
16197 15364
16198 /* Prevent gimple folding for code that does not have a LHS, unless it is 15365 /* Prevent gimple folding for code that does not have a LHS, unless it is
16199 allowed per the rs6000_builtin_valid_without_lhs helper function. */ 15366 allowed per the rs6000_builtin_valid_without_lhs helper function. */
16200 if (!gimple_call_lhs (stmt) && !rs6000_builtin_valid_without_lhs (fn_code)) 15367 if (!gimple_call_lhs (stmt) && !rs6000_builtin_valid_without_lhs (fn_code))
15368 return false;
15369
15370 /* Don't fold invalid builtins, let rs6000_expand_builtin diagnose it. */
15371 HOST_WIDE_INT mask = rs6000_builtin_info[uns_fncode].mask;
15372 bool func_valid_p = (rs6000_builtin_mask & mask) == mask;
15373 if (!func_valid_p)
16201 return false; 15374 return false;
16202 15375
16203 switch (fn_code) 15376 switch (fn_code)
16204 { 15377 {
16205 /* Flavors of vec_add. We deliberately don't expand 15378 /* Flavors of vec_add. We deliberately don't expand
16209 case ALTIVEC_BUILTIN_VADDUHM: 15382 case ALTIVEC_BUILTIN_VADDUHM:
16210 case ALTIVEC_BUILTIN_VADDUWM: 15383 case ALTIVEC_BUILTIN_VADDUWM:
16211 case P8V_BUILTIN_VADDUDM: 15384 case P8V_BUILTIN_VADDUDM:
16212 case ALTIVEC_BUILTIN_VADDFP: 15385 case ALTIVEC_BUILTIN_VADDFP:
16213 case VSX_BUILTIN_XVADDDP: 15386 case VSX_BUILTIN_XVADDDP:
16214 { 15387 arg0 = gimple_call_arg (stmt, 0);
16215 arg0 = gimple_call_arg (stmt, 0); 15388 arg1 = gimple_call_arg (stmt, 1);
16216 arg1 = gimple_call_arg (stmt, 1); 15389 lhs = gimple_call_lhs (stmt);
16217 lhs = gimple_call_lhs (stmt); 15390 g = gimple_build_assign (lhs, PLUS_EXPR, arg0, arg1);
16218 gimple *g = gimple_build_assign (lhs, PLUS_EXPR, arg0, arg1); 15391 gimple_set_location (g, gimple_location (stmt));
16219 gimple_set_location (g, gimple_location (stmt)); 15392 gsi_replace (gsi, g, true);
16220 gsi_replace (gsi, g, true); 15393 return true;
16221 return true;
16222 }
16223 /* Flavors of vec_sub. We deliberately don't expand 15394 /* Flavors of vec_sub. We deliberately don't expand
16224 P8V_BUILTIN_VSUBUQM. */ 15395 P8V_BUILTIN_VSUBUQM. */
16225 case ALTIVEC_BUILTIN_VSUBUBM: 15396 case ALTIVEC_BUILTIN_VSUBUBM:
16226 case ALTIVEC_BUILTIN_VSUBUHM: 15397 case ALTIVEC_BUILTIN_VSUBUHM:
16227 case ALTIVEC_BUILTIN_VSUBUWM: 15398 case ALTIVEC_BUILTIN_VSUBUWM:
16228 case P8V_BUILTIN_VSUBUDM: 15399 case P8V_BUILTIN_VSUBUDM:
16229 case ALTIVEC_BUILTIN_VSUBFP: 15400 case ALTIVEC_BUILTIN_VSUBFP:
16230 case VSX_BUILTIN_XVSUBDP: 15401 case VSX_BUILTIN_XVSUBDP:
16231 { 15402 arg0 = gimple_call_arg (stmt, 0);
16232 arg0 = gimple_call_arg (stmt, 0); 15403 arg1 = gimple_call_arg (stmt, 1);
16233 arg1 = gimple_call_arg (stmt, 1); 15404 lhs = gimple_call_lhs (stmt);
16234 lhs = gimple_call_lhs (stmt); 15405 g = gimple_build_assign (lhs, MINUS_EXPR, arg0, arg1);
16235 gimple *g = gimple_build_assign (lhs, MINUS_EXPR, arg0, arg1); 15406 gimple_set_location (g, gimple_location (stmt));
16236 gimple_set_location (g, gimple_location (stmt)); 15407 gsi_replace (gsi, g, true);
16237 gsi_replace (gsi, g, true); 15408 return true;
16238 return true;
16239 }
16240 case VSX_BUILTIN_XVMULSP: 15409 case VSX_BUILTIN_XVMULSP:
16241 case VSX_BUILTIN_XVMULDP: 15410 case VSX_BUILTIN_XVMULDP:
16242 { 15411 arg0 = gimple_call_arg (stmt, 0);
16243 arg0 = gimple_call_arg (stmt, 0); 15412 arg1 = gimple_call_arg (stmt, 1);
16244 arg1 = gimple_call_arg (stmt, 1); 15413 lhs = gimple_call_lhs (stmt);
16245 lhs = gimple_call_lhs (stmt); 15414 g = gimple_build_assign (lhs, MULT_EXPR, arg0, arg1);
16246 gimple *g = gimple_build_assign (lhs, MULT_EXPR, arg0, arg1); 15415 gimple_set_location (g, gimple_location (stmt));
16247 gimple_set_location (g, gimple_location (stmt)); 15416 gsi_replace (gsi, g, true);
16248 gsi_replace (gsi, g, true); 15417 return true;
16249 return true;
16250 }
16251 /* Even element flavors of vec_mul (signed). */ 15418 /* Even element flavors of vec_mul (signed). */
16252 case ALTIVEC_BUILTIN_VMULESB: 15419 case ALTIVEC_BUILTIN_VMULESB:
16253 case ALTIVEC_BUILTIN_VMULESH: 15420 case ALTIVEC_BUILTIN_VMULESH:
16254 case ALTIVEC_BUILTIN_VMULESW: 15421 case P8V_BUILTIN_VMULESW:
16255 /* Even element flavors of vec_mul (unsigned). */ 15422 /* Even element flavors of vec_mul (unsigned). */
16256 case ALTIVEC_BUILTIN_VMULEUB: 15423 case ALTIVEC_BUILTIN_VMULEUB:
16257 case ALTIVEC_BUILTIN_VMULEUH: 15424 case ALTIVEC_BUILTIN_VMULEUH:
16258 case ALTIVEC_BUILTIN_VMULEUW: 15425 case P8V_BUILTIN_VMULEUW:
16259 { 15426 arg0 = gimple_call_arg (stmt, 0);
16260 arg0 = gimple_call_arg (stmt, 0); 15427 arg1 = gimple_call_arg (stmt, 1);
16261 arg1 = gimple_call_arg (stmt, 1); 15428 lhs = gimple_call_lhs (stmt);
16262 lhs = gimple_call_lhs (stmt); 15429 g = gimple_build_assign (lhs, VEC_WIDEN_MULT_EVEN_EXPR, arg0, arg1);
16263 gimple *g = gimple_build_assign (lhs, VEC_WIDEN_MULT_EVEN_EXPR, arg0, arg1); 15430 gimple_set_location (g, gimple_location (stmt));
16264 gimple_set_location (g, gimple_location (stmt)); 15431 gsi_replace (gsi, g, true);
16265 gsi_replace (gsi, g, true); 15432 return true;
16266 return true;
16267 }
16268 /* Odd element flavors of vec_mul (signed). */ 15433 /* Odd element flavors of vec_mul (signed). */
16269 case ALTIVEC_BUILTIN_VMULOSB: 15434 case ALTIVEC_BUILTIN_VMULOSB:
16270 case ALTIVEC_BUILTIN_VMULOSH: 15435 case ALTIVEC_BUILTIN_VMULOSH:
16271 case ALTIVEC_BUILTIN_VMULOSW: 15436 case P8V_BUILTIN_VMULOSW:
16272 /* Odd element flavors of vec_mul (unsigned). */ 15437 /* Odd element flavors of vec_mul (unsigned). */
16273 case ALTIVEC_BUILTIN_VMULOUB: 15438 case ALTIVEC_BUILTIN_VMULOUB:
16274 case ALTIVEC_BUILTIN_VMULOUH: 15439 case ALTIVEC_BUILTIN_VMULOUH:
16275 case ALTIVEC_BUILTIN_VMULOUW: 15440 case P8V_BUILTIN_VMULOUW:
16276 { 15441 arg0 = gimple_call_arg (stmt, 0);
16277 arg0 = gimple_call_arg (stmt, 0); 15442 arg1 = gimple_call_arg (stmt, 1);
16278 arg1 = gimple_call_arg (stmt, 1); 15443 lhs = gimple_call_lhs (stmt);
16279 lhs = gimple_call_lhs (stmt); 15444 g = gimple_build_assign (lhs, VEC_WIDEN_MULT_ODD_EXPR, arg0, arg1);
16280 gimple *g = gimple_build_assign (lhs, VEC_WIDEN_MULT_ODD_EXPR, arg0, arg1); 15445 gimple_set_location (g, gimple_location (stmt));
16281 gimple_set_location (g, gimple_location (stmt)); 15446 gsi_replace (gsi, g, true);
16282 gsi_replace (gsi, g, true); 15447 return true;
16283 return true;
16284 }
16285 /* Flavors of vec_div (Integer). */ 15448 /* Flavors of vec_div (Integer). */
16286 case VSX_BUILTIN_DIV_V2DI: 15449 case VSX_BUILTIN_DIV_V2DI:
16287 case VSX_BUILTIN_UDIV_V2DI: 15450 case VSX_BUILTIN_UDIV_V2DI:
16288 { 15451 arg0 = gimple_call_arg (stmt, 0);
16289 arg0 = gimple_call_arg (stmt, 0); 15452 arg1 = gimple_call_arg (stmt, 1);
16290 arg1 = gimple_call_arg (stmt, 1); 15453 lhs = gimple_call_lhs (stmt);
16291 lhs = gimple_call_lhs (stmt); 15454 g = gimple_build_assign (lhs, TRUNC_DIV_EXPR, arg0, arg1);
16292 gimple *g = gimple_build_assign (lhs, TRUNC_DIV_EXPR, arg0, arg1); 15455 gimple_set_location (g, gimple_location (stmt));
16293 gimple_set_location (g, gimple_location (stmt)); 15456 gsi_replace (gsi, g, true);
16294 gsi_replace (gsi, g, true); 15457 return true;
16295 return true;
16296 }
16297 /* Flavors of vec_div (Float). */ 15458 /* Flavors of vec_div (Float). */
16298 case VSX_BUILTIN_XVDIVSP: 15459 case VSX_BUILTIN_XVDIVSP:
16299 case VSX_BUILTIN_XVDIVDP: 15460 case VSX_BUILTIN_XVDIVDP:
16300 { 15461 arg0 = gimple_call_arg (stmt, 0);
16301 arg0 = gimple_call_arg (stmt, 0); 15462 arg1 = gimple_call_arg (stmt, 1);
16302 arg1 = gimple_call_arg (stmt, 1); 15463 lhs = gimple_call_lhs (stmt);
16303 lhs = gimple_call_lhs (stmt); 15464 g = gimple_build_assign (lhs, RDIV_EXPR, arg0, arg1);
16304 gimple *g = gimple_build_assign (lhs, RDIV_EXPR, arg0, arg1); 15465 gimple_set_location (g, gimple_location (stmt));
16305 gimple_set_location (g, gimple_location (stmt)); 15466 gsi_replace (gsi, g, true);
16306 gsi_replace (gsi, g, true); 15467 return true;
16307 return true;
16308 }
16309 /* Flavors of vec_and. */ 15468 /* Flavors of vec_and. */
16310 case ALTIVEC_BUILTIN_VAND: 15469 case ALTIVEC_BUILTIN_VAND:
16311 { 15470 arg0 = gimple_call_arg (stmt, 0);
16312 arg0 = gimple_call_arg (stmt, 0); 15471 arg1 = gimple_call_arg (stmt, 1);
16313 arg1 = gimple_call_arg (stmt, 1); 15472 lhs = gimple_call_lhs (stmt);
16314 lhs = gimple_call_lhs (stmt); 15473 g = gimple_build_assign (lhs, BIT_AND_EXPR, arg0, arg1);
16315 gimple *g = gimple_build_assign (lhs, BIT_AND_EXPR, arg0, arg1); 15474 gimple_set_location (g, gimple_location (stmt));
16316 gimple_set_location (g, gimple_location (stmt)); 15475 gsi_replace (gsi, g, true);
16317 gsi_replace (gsi, g, true); 15476 return true;
16318 return true;
16319 }
16320 /* Flavors of vec_andc. */ 15477 /* Flavors of vec_andc. */
16321 case ALTIVEC_BUILTIN_VANDC: 15478 case ALTIVEC_BUILTIN_VANDC:
16322 { 15479 arg0 = gimple_call_arg (stmt, 0);
16323 arg0 = gimple_call_arg (stmt, 0); 15480 arg1 = gimple_call_arg (stmt, 1);
16324 arg1 = gimple_call_arg (stmt, 1); 15481 lhs = gimple_call_lhs (stmt);
16325 lhs = gimple_call_lhs (stmt); 15482 temp = create_tmp_reg_or_ssa_name (TREE_TYPE (arg1));
16326 tree temp = create_tmp_reg_or_ssa_name (TREE_TYPE (arg1)); 15483 g = gimple_build_assign (temp, BIT_NOT_EXPR, arg1);
16327 gimple *g = gimple_build_assign(temp, BIT_NOT_EXPR, arg1); 15484 gimple_set_location (g, gimple_location (stmt));
16328 gimple_set_location (g, gimple_location (stmt)); 15485 gsi_insert_before (gsi, g, GSI_SAME_STMT);
16329 gsi_insert_before(gsi, g, GSI_SAME_STMT); 15486 g = gimple_build_assign (lhs, BIT_AND_EXPR, arg0, temp);
16330 g = gimple_build_assign (lhs, BIT_AND_EXPR, arg0, temp); 15487 gimple_set_location (g, gimple_location (stmt));
16331 gimple_set_location (g, gimple_location (stmt)); 15488 gsi_replace (gsi, g, true);
16332 gsi_replace (gsi, g, true); 15489 return true;
16333 return true;
16334 }
16335 /* Flavors of vec_nand. */ 15490 /* Flavors of vec_nand. */
16336 case P8V_BUILTIN_VEC_NAND: 15491 case P8V_BUILTIN_VEC_NAND:
16337 case P8V_BUILTIN_NAND_V16QI: 15492 case P8V_BUILTIN_NAND_V16QI:
16338 case P8V_BUILTIN_NAND_V8HI: 15493 case P8V_BUILTIN_NAND_V8HI:
16339 case P8V_BUILTIN_NAND_V4SI: 15494 case P8V_BUILTIN_NAND_V4SI:
16340 case P8V_BUILTIN_NAND_V4SF: 15495 case P8V_BUILTIN_NAND_V4SF:
16341 case P8V_BUILTIN_NAND_V2DF: 15496 case P8V_BUILTIN_NAND_V2DF:
16342 case P8V_BUILTIN_NAND_V2DI: 15497 case P8V_BUILTIN_NAND_V2DI:
16343 { 15498 arg0 = gimple_call_arg (stmt, 0);
16344 arg0 = gimple_call_arg (stmt, 0); 15499 arg1 = gimple_call_arg (stmt, 1);
16345 arg1 = gimple_call_arg (stmt, 1); 15500 lhs = gimple_call_lhs (stmt);
16346 lhs = gimple_call_lhs (stmt); 15501 temp = create_tmp_reg_or_ssa_name (TREE_TYPE (arg1));
16347 tree temp = create_tmp_reg_or_ssa_name (TREE_TYPE (arg1)); 15502 g = gimple_build_assign (temp, BIT_AND_EXPR, arg0, arg1);
16348 gimple *g = gimple_build_assign(temp, BIT_AND_EXPR, arg0, arg1); 15503 gimple_set_location (g, gimple_location (stmt));
16349 gimple_set_location (g, gimple_location (stmt)); 15504 gsi_insert_before (gsi, g, GSI_SAME_STMT);
16350 gsi_insert_before(gsi, g, GSI_SAME_STMT); 15505 g = gimple_build_assign (lhs, BIT_NOT_EXPR, temp);
16351 g = gimple_build_assign (lhs, BIT_NOT_EXPR, temp); 15506 gimple_set_location (g, gimple_location (stmt));
16352 gimple_set_location (g, gimple_location (stmt)); 15507 gsi_replace (gsi, g, true);
16353 gsi_replace (gsi, g, true); 15508 return true;
16354 return true;
16355 }
16356 /* Flavors of vec_or. */ 15509 /* Flavors of vec_or. */
16357 case ALTIVEC_BUILTIN_VOR: 15510 case ALTIVEC_BUILTIN_VOR:
16358 { 15511 arg0 = gimple_call_arg (stmt, 0);
16359 arg0 = gimple_call_arg (stmt, 0); 15512 arg1 = gimple_call_arg (stmt, 1);
16360 arg1 = gimple_call_arg (stmt, 1); 15513 lhs = gimple_call_lhs (stmt);
16361 lhs = gimple_call_lhs (stmt); 15514 g = gimple_build_assign (lhs, BIT_IOR_EXPR, arg0, arg1);
16362 gimple *g = gimple_build_assign (lhs, BIT_IOR_EXPR, arg0, arg1); 15515 gimple_set_location (g, gimple_location (stmt));
16363 gimple_set_location (g, gimple_location (stmt)); 15516 gsi_replace (gsi, g, true);
16364 gsi_replace (gsi, g, true); 15517 return true;
16365 return true;
16366 }
16367 /* flavors of vec_orc. */ 15518 /* flavors of vec_orc. */
16368 case P8V_BUILTIN_ORC_V16QI: 15519 case P8V_BUILTIN_ORC_V16QI:
16369 case P8V_BUILTIN_ORC_V8HI: 15520 case P8V_BUILTIN_ORC_V8HI:
16370 case P8V_BUILTIN_ORC_V4SI: 15521 case P8V_BUILTIN_ORC_V4SI:
16371 case P8V_BUILTIN_ORC_V4SF: 15522 case P8V_BUILTIN_ORC_V4SF:
16372 case P8V_BUILTIN_ORC_V2DF: 15523 case P8V_BUILTIN_ORC_V2DF:
16373 case P8V_BUILTIN_ORC_V2DI: 15524 case P8V_BUILTIN_ORC_V2DI:
16374 { 15525 arg0 = gimple_call_arg (stmt, 0);
16375 arg0 = gimple_call_arg (stmt, 0); 15526 arg1 = gimple_call_arg (stmt, 1);
16376 arg1 = gimple_call_arg (stmt, 1); 15527 lhs = gimple_call_lhs (stmt);
16377 lhs = gimple_call_lhs (stmt); 15528 temp = create_tmp_reg_or_ssa_name (TREE_TYPE (arg1));
16378 tree temp = create_tmp_reg_or_ssa_name (TREE_TYPE (arg1)); 15529 g = gimple_build_assign (temp, BIT_NOT_EXPR, arg1);
16379 gimple *g = gimple_build_assign(temp, BIT_NOT_EXPR, arg1); 15530 gimple_set_location (g, gimple_location (stmt));
16380 gimple_set_location (g, gimple_location (stmt)); 15531 gsi_insert_before (gsi, g, GSI_SAME_STMT);
16381 gsi_insert_before(gsi, g, GSI_SAME_STMT); 15532 g = gimple_build_assign (lhs, BIT_IOR_EXPR, arg0, temp);
16382 g = gimple_build_assign (lhs, BIT_IOR_EXPR, arg0, temp); 15533 gimple_set_location (g, gimple_location (stmt));
16383 gimple_set_location (g, gimple_location (stmt)); 15534 gsi_replace (gsi, g, true);
16384 gsi_replace (gsi, g, true); 15535 return true;
16385 return true;
16386 }
16387 /* Flavors of vec_xor. */ 15536 /* Flavors of vec_xor. */
16388 case ALTIVEC_BUILTIN_VXOR: 15537 case ALTIVEC_BUILTIN_VXOR:
16389 { 15538 arg0 = gimple_call_arg (stmt, 0);
16390 arg0 = gimple_call_arg (stmt, 0); 15539 arg1 = gimple_call_arg (stmt, 1);
16391 arg1 = gimple_call_arg (stmt, 1); 15540 lhs = gimple_call_lhs (stmt);
16392 lhs = gimple_call_lhs (stmt); 15541 g = gimple_build_assign (lhs, BIT_XOR_EXPR, arg0, arg1);
16393 gimple *g = gimple_build_assign (lhs, BIT_XOR_EXPR, arg0, arg1); 15542 gimple_set_location (g, gimple_location (stmt));
16394 gimple_set_location (g, gimple_location (stmt)); 15543 gsi_replace (gsi, g, true);
16395 gsi_replace (gsi, g, true); 15544 return true;
16396 return true;
16397 }
16398 /* Flavors of vec_nor. */ 15545 /* Flavors of vec_nor. */
16399 case ALTIVEC_BUILTIN_VNOR: 15546 case ALTIVEC_BUILTIN_VNOR:
16400 { 15547 arg0 = gimple_call_arg (stmt, 0);
16401 arg0 = gimple_call_arg (stmt, 0); 15548 arg1 = gimple_call_arg (stmt, 1);
16402 arg1 = gimple_call_arg (stmt, 1); 15549 lhs = gimple_call_lhs (stmt);
16403 lhs = gimple_call_lhs (stmt); 15550 temp = create_tmp_reg_or_ssa_name (TREE_TYPE (arg1));
16404 tree temp = create_tmp_reg_or_ssa_name (TREE_TYPE (arg1)); 15551 g = gimple_build_assign (temp, BIT_IOR_EXPR, arg0, arg1);
16405 gimple *g = gimple_build_assign (temp, BIT_IOR_EXPR, arg0, arg1); 15552 gimple_set_location (g, gimple_location (stmt));
16406 gimple_set_location (g, gimple_location (stmt)); 15553 gsi_insert_before (gsi, g, GSI_SAME_STMT);
16407 gsi_insert_before(gsi, g, GSI_SAME_STMT); 15554 g = gimple_build_assign (lhs, BIT_NOT_EXPR, temp);
16408 g = gimple_build_assign (lhs, BIT_NOT_EXPR, temp); 15555 gimple_set_location (g, gimple_location (stmt));
16409 gimple_set_location (g, gimple_location (stmt)); 15556 gsi_replace (gsi, g, true);
16410 gsi_replace (gsi, g, true); 15557 return true;
16411 return true;
16412 }
16413 /* flavors of vec_abs. */ 15558 /* flavors of vec_abs. */
16414 case ALTIVEC_BUILTIN_ABS_V16QI: 15559 case ALTIVEC_BUILTIN_ABS_V16QI:
16415 case ALTIVEC_BUILTIN_ABS_V8HI: 15560 case ALTIVEC_BUILTIN_ABS_V8HI:
16416 case ALTIVEC_BUILTIN_ABS_V4SI: 15561 case ALTIVEC_BUILTIN_ABS_V4SI:
16417 case ALTIVEC_BUILTIN_ABS_V4SF: 15562 case ALTIVEC_BUILTIN_ABS_V4SF:
16418 case P8V_BUILTIN_ABS_V2DI: 15563 case P8V_BUILTIN_ABS_V2DI:
16419 case VSX_BUILTIN_XVABSDP: 15564 case VSX_BUILTIN_XVABSDP:
16420 { 15565 arg0 = gimple_call_arg (stmt, 0);
16421 arg0 = gimple_call_arg (stmt, 0); 15566 if (INTEGRAL_TYPE_P (TREE_TYPE (TREE_TYPE (arg0)))
16422 if (INTEGRAL_TYPE_P (TREE_TYPE (TREE_TYPE (arg0))) 15567 && !TYPE_OVERFLOW_WRAPS (TREE_TYPE (TREE_TYPE (arg0))))
16423 && !TYPE_OVERFLOW_WRAPS (TREE_TYPE (TREE_TYPE (arg0)))) 15568 return false;
16424 return false; 15569 lhs = gimple_call_lhs (stmt);
16425 lhs = gimple_call_lhs (stmt); 15570 g = gimple_build_assign (lhs, ABS_EXPR, arg0);
16426 gimple *g = gimple_build_assign (lhs, ABS_EXPR, arg0); 15571 gimple_set_location (g, gimple_location (stmt));
16427 gimple_set_location (g, gimple_location (stmt)); 15572 gsi_replace (gsi, g, true);
16428 gsi_replace (gsi, g, true); 15573 return true;
16429 return true;
16430 }
16431 /* flavors of vec_min. */ 15574 /* flavors of vec_min. */
16432 case VSX_BUILTIN_XVMINDP: 15575 case VSX_BUILTIN_XVMINDP:
16433 case P8V_BUILTIN_VMINSD: 15576 case P8V_BUILTIN_VMINSD:
16434 case P8V_BUILTIN_VMINUD: 15577 case P8V_BUILTIN_VMINUD:
16435 case ALTIVEC_BUILTIN_VMINSB: 15578 case ALTIVEC_BUILTIN_VMINSB:
16437 case ALTIVEC_BUILTIN_VMINSW: 15580 case ALTIVEC_BUILTIN_VMINSW:
16438 case ALTIVEC_BUILTIN_VMINUB: 15581 case ALTIVEC_BUILTIN_VMINUB:
16439 case ALTIVEC_BUILTIN_VMINUH: 15582 case ALTIVEC_BUILTIN_VMINUH:
16440 case ALTIVEC_BUILTIN_VMINUW: 15583 case ALTIVEC_BUILTIN_VMINUW:
16441 case ALTIVEC_BUILTIN_VMINFP: 15584 case ALTIVEC_BUILTIN_VMINFP:
16442 { 15585 arg0 = gimple_call_arg (stmt, 0);
16443 arg0 = gimple_call_arg (stmt, 0); 15586 arg1 = gimple_call_arg (stmt, 1);
16444 arg1 = gimple_call_arg (stmt, 1); 15587 lhs = gimple_call_lhs (stmt);
16445 lhs = gimple_call_lhs (stmt); 15588 g = gimple_build_assign (lhs, MIN_EXPR, arg0, arg1);
16446 gimple *g = gimple_build_assign (lhs, MIN_EXPR, arg0, arg1); 15589 gimple_set_location (g, gimple_location (stmt));
16447 gimple_set_location (g, gimple_location (stmt)); 15590 gsi_replace (gsi, g, true);
16448 gsi_replace (gsi, g, true); 15591 return true;
16449 return true;
16450 }
16451 /* flavors of vec_max. */ 15592 /* flavors of vec_max. */
16452 case VSX_BUILTIN_XVMAXDP: 15593 case VSX_BUILTIN_XVMAXDP:
16453 case P8V_BUILTIN_VMAXSD: 15594 case P8V_BUILTIN_VMAXSD:
16454 case P8V_BUILTIN_VMAXUD: 15595 case P8V_BUILTIN_VMAXUD:
16455 case ALTIVEC_BUILTIN_VMAXSB: 15596 case ALTIVEC_BUILTIN_VMAXSB:
16457 case ALTIVEC_BUILTIN_VMAXSW: 15598 case ALTIVEC_BUILTIN_VMAXSW:
16458 case ALTIVEC_BUILTIN_VMAXUB: 15599 case ALTIVEC_BUILTIN_VMAXUB:
16459 case ALTIVEC_BUILTIN_VMAXUH: 15600 case ALTIVEC_BUILTIN_VMAXUH:
16460 case ALTIVEC_BUILTIN_VMAXUW: 15601 case ALTIVEC_BUILTIN_VMAXUW:
16461 case ALTIVEC_BUILTIN_VMAXFP: 15602 case ALTIVEC_BUILTIN_VMAXFP:
16462 { 15603 arg0 = gimple_call_arg (stmt, 0);
16463 arg0 = gimple_call_arg (stmt, 0); 15604 arg1 = gimple_call_arg (stmt, 1);
16464 arg1 = gimple_call_arg (stmt, 1); 15605 lhs = gimple_call_lhs (stmt);
16465 lhs = gimple_call_lhs (stmt); 15606 g = gimple_build_assign (lhs, MAX_EXPR, arg0, arg1);
16466 gimple *g = gimple_build_assign (lhs, MAX_EXPR, arg0, arg1); 15607 gimple_set_location (g, gimple_location (stmt));
16467 gimple_set_location (g, gimple_location (stmt)); 15608 gsi_replace (gsi, g, true);
16468 gsi_replace (gsi, g, true); 15609 return true;
16469 return true;
16470 }
16471 /* Flavors of vec_eqv. */ 15610 /* Flavors of vec_eqv. */
16472 case P8V_BUILTIN_EQV_V16QI: 15611 case P8V_BUILTIN_EQV_V16QI:
16473 case P8V_BUILTIN_EQV_V8HI: 15612 case P8V_BUILTIN_EQV_V8HI:
16474 case P8V_BUILTIN_EQV_V4SI: 15613 case P8V_BUILTIN_EQV_V4SI:
16475 case P8V_BUILTIN_EQV_V4SF: 15614 case P8V_BUILTIN_EQV_V4SF:
16476 case P8V_BUILTIN_EQV_V2DF: 15615 case P8V_BUILTIN_EQV_V2DF:
16477 case P8V_BUILTIN_EQV_V2DI: 15616 case P8V_BUILTIN_EQV_V2DI:
16478 { 15617 arg0 = gimple_call_arg (stmt, 0);
16479 arg0 = gimple_call_arg (stmt, 0); 15618 arg1 = gimple_call_arg (stmt, 1);
16480 arg1 = gimple_call_arg (stmt, 1); 15619 lhs = gimple_call_lhs (stmt);
16481 lhs = gimple_call_lhs (stmt); 15620 temp = create_tmp_reg_or_ssa_name (TREE_TYPE (arg1));
16482 tree temp = create_tmp_reg_or_ssa_name (TREE_TYPE (arg1)); 15621 g = gimple_build_assign (temp, BIT_XOR_EXPR, arg0, arg1);
16483 gimple *g = gimple_build_assign (temp, BIT_XOR_EXPR, arg0, arg1); 15622 gimple_set_location (g, gimple_location (stmt));
16484 gimple_set_location (g, gimple_location (stmt)); 15623 gsi_insert_before (gsi, g, GSI_SAME_STMT);
16485 gsi_insert_before (gsi, g, GSI_SAME_STMT); 15624 g = gimple_build_assign (lhs, BIT_NOT_EXPR, temp);
16486 g = gimple_build_assign (lhs, BIT_NOT_EXPR, temp); 15625 gimple_set_location (g, gimple_location (stmt));
16487 gimple_set_location (g, gimple_location (stmt)); 15626 gsi_replace (gsi, g, true);
16488 gsi_replace (gsi, g, true); 15627 return true;
16489 return true;
16490 }
16491 /* Flavors of vec_rotate_left. */ 15628 /* Flavors of vec_rotate_left. */
16492 case ALTIVEC_BUILTIN_VRLB: 15629 case ALTIVEC_BUILTIN_VRLB:
16493 case ALTIVEC_BUILTIN_VRLH: 15630 case ALTIVEC_BUILTIN_VRLH:
16494 case ALTIVEC_BUILTIN_VRLW: 15631 case ALTIVEC_BUILTIN_VRLW:
16495 case P8V_BUILTIN_VRLD: 15632 case P8V_BUILTIN_VRLD:
16496 { 15633 arg0 = gimple_call_arg (stmt, 0);
16497 arg0 = gimple_call_arg (stmt, 0); 15634 arg1 = gimple_call_arg (stmt, 1);
16498 arg1 = gimple_call_arg (stmt, 1); 15635 lhs = gimple_call_lhs (stmt);
16499 lhs = gimple_call_lhs (stmt); 15636 g = gimple_build_assign (lhs, LROTATE_EXPR, arg0, arg1);
16500 gimple *g = gimple_build_assign (lhs, LROTATE_EXPR, arg0, arg1); 15637 gimple_set_location (g, gimple_location (stmt));
16501 gimple_set_location (g, gimple_location (stmt)); 15638 gsi_replace (gsi, g, true);
16502 gsi_replace (gsi, g, true); 15639 return true;
16503 return true;
16504 }
16505 /* Flavors of vector shift right algebraic. 15640 /* Flavors of vector shift right algebraic.
16506 vec_sra{b,h,w} -> vsra{b,h,w}. */ 15641 vec_sra{b,h,w} -> vsra{b,h,w}. */
16507 case ALTIVEC_BUILTIN_VSRAB: 15642 case ALTIVEC_BUILTIN_VSRAB:
16508 case ALTIVEC_BUILTIN_VSRAH: 15643 case ALTIVEC_BUILTIN_VSRAH:
16509 case ALTIVEC_BUILTIN_VSRAW: 15644 case ALTIVEC_BUILTIN_VSRAW:
16510 case P8V_BUILTIN_VSRAD: 15645 case P8V_BUILTIN_VSRAD:
16511 { 15646 arg0 = gimple_call_arg (stmt, 0);
16512 arg0 = gimple_call_arg (stmt, 0); 15647 arg1 = gimple_call_arg (stmt, 1);
16513 arg1 = gimple_call_arg (stmt, 1); 15648 lhs = gimple_call_lhs (stmt);
16514 lhs = gimple_call_lhs (stmt); 15649 g = gimple_build_assign (lhs, RSHIFT_EXPR, arg0, arg1);
16515 gimple *g = gimple_build_assign (lhs, RSHIFT_EXPR, arg0, arg1); 15650 gimple_set_location (g, gimple_location (stmt));
16516 gimple_set_location (g, gimple_location (stmt)); 15651 gsi_replace (gsi, g, true);
16517 gsi_replace (gsi, g, true); 15652 return true;
16518 return true;
16519 }
16520 /* Flavors of vector shift left. 15653 /* Flavors of vector shift left.
16521 builtin_altivec_vsl{b,h,w} -> vsl{b,h,w}. */ 15654 builtin_altivec_vsl{b,h,w} -> vsl{b,h,w}. */
16522 case ALTIVEC_BUILTIN_VSLB: 15655 case ALTIVEC_BUILTIN_VSLB:
16523 case ALTIVEC_BUILTIN_VSLH: 15656 case ALTIVEC_BUILTIN_VSLH:
16524 case ALTIVEC_BUILTIN_VSLW: 15657 case ALTIVEC_BUILTIN_VSLW:
16525 case P8V_BUILTIN_VSLD: 15658 case P8V_BUILTIN_VSLD:
16526 { 15659 {
15660 location_t loc;
15661 gimple_seq stmts = NULL;
16527 arg0 = gimple_call_arg (stmt, 0); 15662 arg0 = gimple_call_arg (stmt, 0);
16528 if (INTEGRAL_TYPE_P (TREE_TYPE (TREE_TYPE (arg0))) 15663 tree arg0_type = TREE_TYPE (arg0);
16529 && !TYPE_OVERFLOW_WRAPS (TREE_TYPE (TREE_TYPE (arg0)))) 15664 if (INTEGRAL_TYPE_P (TREE_TYPE (arg0_type))
16530 return false; 15665 && !TYPE_OVERFLOW_WRAPS (TREE_TYPE (arg0_type)))
15666 return false;
16531 arg1 = gimple_call_arg (stmt, 1); 15667 arg1 = gimple_call_arg (stmt, 1);
15668 tree arg1_type = TREE_TYPE (arg1);
15669 tree unsigned_arg1_type = unsigned_type_for (TREE_TYPE (arg1));
15670 tree unsigned_element_type = unsigned_type_for (TREE_TYPE (arg1_type));
15671 loc = gimple_location (stmt);
16532 lhs = gimple_call_lhs (stmt); 15672 lhs = gimple_call_lhs (stmt);
16533 gimple *g = gimple_build_assign (lhs, LSHIFT_EXPR, arg0, arg1); 15673 /* Force arg1 into the range valid matching the arg0 type. */
15674 /* Build a vector consisting of the max valid bit-size values. */
15675 int n_elts = VECTOR_CST_NELTS (arg1);
15676 int tree_size_in_bits = TREE_INT_CST_LOW (size_in_bytes (arg1_type))
15677 * BITS_PER_UNIT;
15678 tree element_size = build_int_cst (unsigned_element_type,
15679 tree_size_in_bits / n_elts);
15680 tree_vector_builder elts (unsigned_type_for (arg1_type), n_elts, 1);
15681 for (int i = 0; i < n_elts; i++)
15682 elts.safe_push (element_size);
15683 tree modulo_tree = elts.build ();
15684 /* Modulo the provided shift value against that vector. */
15685 tree unsigned_arg1 = gimple_build (&stmts, VIEW_CONVERT_EXPR,
15686 unsigned_arg1_type, arg1);
15687 tree new_arg1 = gimple_build (&stmts, loc, TRUNC_MOD_EXPR,
15688 unsigned_arg1_type, unsigned_arg1,
15689 modulo_tree);
15690 gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT);
15691 /* And finally, do the shift. */
15692 g = gimple_build_assign (lhs, LSHIFT_EXPR, arg0, new_arg1);
16534 gimple_set_location (g, gimple_location (stmt)); 15693 gimple_set_location (g, gimple_location (stmt));
16535 gsi_replace (gsi, g, true); 15694 gsi_replace (gsi, g, true);
16536 return true; 15695 return true;
16537 } 15696 }
16538 /* Flavors of vector shift right. */ 15697 /* Flavors of vector shift right. */
16545 arg1 = gimple_call_arg (stmt, 1); 15704 arg1 = gimple_call_arg (stmt, 1);
16546 lhs = gimple_call_lhs (stmt); 15705 lhs = gimple_call_lhs (stmt);
16547 gimple_seq stmts = NULL; 15706 gimple_seq stmts = NULL;
16548 /* Convert arg0 to unsigned. */ 15707 /* Convert arg0 to unsigned. */
16549 tree arg0_unsigned 15708 tree arg0_unsigned
16550 = gimple_build (&stmts, VIEW_CONVERT_EXPR, 15709 = gimple_build (&stmts, VIEW_CONVERT_EXPR,
16551 unsigned_type_for (TREE_TYPE (arg0)), arg0); 15710 unsigned_type_for (TREE_TYPE (arg0)), arg0);
16552 tree res 15711 tree res
16553 = gimple_build (&stmts, RSHIFT_EXPR, 15712 = gimple_build (&stmts, RSHIFT_EXPR,
16554 TREE_TYPE (arg0_unsigned), arg0_unsigned, arg1); 15713 TREE_TYPE (arg0_unsigned), arg0_unsigned, arg1);
16555 /* Convert result back to the lhs type. */ 15714 /* Convert result back to the lhs type. */
16556 res = gimple_build (&stmts, VIEW_CONVERT_EXPR, TREE_TYPE (lhs), res); 15715 res = gimple_build (&stmts, VIEW_CONVERT_EXPR, TREE_TYPE (lhs), res);
16557 gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT); 15716 gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT);
16558 update_call_from_tree (gsi, res); 15717 update_call_from_tree (gsi, res);
16559 return true; 15718 return true;
16563 case ALTIVEC_BUILTIN_LVX_V8HI: 15722 case ALTIVEC_BUILTIN_LVX_V8HI:
16564 case ALTIVEC_BUILTIN_LVX_V4SI: 15723 case ALTIVEC_BUILTIN_LVX_V4SI:
16565 case ALTIVEC_BUILTIN_LVX_V4SF: 15724 case ALTIVEC_BUILTIN_LVX_V4SF:
16566 case ALTIVEC_BUILTIN_LVX_V2DI: 15725 case ALTIVEC_BUILTIN_LVX_V2DI:
16567 case ALTIVEC_BUILTIN_LVX_V2DF: 15726 case ALTIVEC_BUILTIN_LVX_V2DF:
15727 case ALTIVEC_BUILTIN_LVX_V1TI:
16568 { 15728 {
16569 arg0 = gimple_call_arg (stmt, 0); // offset 15729 arg0 = gimple_call_arg (stmt, 0); // offset
16570 arg1 = gimple_call_arg (stmt, 1); // address 15730 arg1 = gimple_call_arg (stmt, 1); // address
16571 /* Do not fold for -maltivec=be on LE targets. */ 15731 lhs = gimple_call_lhs (stmt);
16572 if (VECTOR_ELT_ORDER_BIG && !BYTES_BIG_ENDIAN) 15732 location_t loc = gimple_location (stmt);
16573 return false; 15733 /* Since arg1 may be cast to a different type, just use ptr_type_node
16574 lhs = gimple_call_lhs (stmt); 15734 here instead of trying to enforce TBAA on pointer types. */
16575 location_t loc = gimple_location (stmt); 15735 tree arg1_type = ptr_type_node;
16576 /* Since arg1 may be cast to a different type, just use ptr_type_node 15736 tree lhs_type = TREE_TYPE (lhs);
16577 here instead of trying to enforce TBAA on pointer types. */ 15737 /* POINTER_PLUS_EXPR wants the offset to be of type 'sizetype'. Create
16578 tree arg1_type = ptr_type_node; 15738 the tree using the value from arg0. The resulting type will match
16579 tree lhs_type = TREE_TYPE (lhs); 15739 the type of arg1. */
16580 /* POINTER_PLUS_EXPR wants the offset to be of type 'sizetype'. Create 15740 gimple_seq stmts = NULL;
16581 the tree using the value from arg0. The resulting type will match 15741 tree temp_offset = gimple_convert (&stmts, loc, sizetype, arg0);
16582 the type of arg1. */ 15742 tree temp_addr = gimple_build (&stmts, loc, POINTER_PLUS_EXPR,
16583 gimple_seq stmts = NULL;
16584 tree temp_offset = gimple_convert (&stmts, loc, sizetype, arg0);
16585 tree temp_addr = gimple_build (&stmts, loc, POINTER_PLUS_EXPR,
16586 arg1_type, arg1, temp_offset); 15743 arg1_type, arg1, temp_offset);
16587 /* Mask off any lower bits from the address. */ 15744 /* Mask off any lower bits from the address. */
16588 tree aligned_addr = gimple_build (&stmts, loc, BIT_AND_EXPR, 15745 tree aligned_addr = gimple_build (&stmts, loc, BIT_AND_EXPR,
16589 arg1_type, temp_addr, 15746 arg1_type, temp_addr,
16590 build_int_cst (arg1_type, -16)); 15747 build_int_cst (arg1_type, -16));
16591 gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT); 15748 gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT);
16592 /* Use the build2 helper to set up the mem_ref. The MEM_REF could also 15749 /* Use the build2 helper to set up the mem_ref. The MEM_REF could also
16593 take an offset, but since we've already incorporated the offset 15750 take an offset, but since we've already incorporated the offset
16594 above, here we just pass in a zero. */ 15751 above, here we just pass in a zero. */
16595 gimple *g; 15752 gimple *g
16596 g = gimple_build_assign (lhs, build2 (MEM_REF, lhs_type, aligned_addr, 15753 = gimple_build_assign (lhs, build2 (MEM_REF, lhs_type, aligned_addr,
16597 build_int_cst (arg1_type, 0))); 15754 build_int_cst (arg1_type, 0)));
16598 gimple_set_location (g, loc); 15755 gimple_set_location (g, loc);
16599 gsi_replace (gsi, g, true); 15756 gsi_replace (gsi, g, true);
16600 return true; 15757 return true;
16601 } 15758 }
16602 /* Vector stores. */ 15759 /* Vector stores. */
16603 case ALTIVEC_BUILTIN_STVX_V16QI: 15760 case ALTIVEC_BUILTIN_STVX_V16QI:
16604 case ALTIVEC_BUILTIN_STVX_V8HI: 15761 case ALTIVEC_BUILTIN_STVX_V8HI:
16605 case ALTIVEC_BUILTIN_STVX_V4SI: 15762 case ALTIVEC_BUILTIN_STVX_V4SI:
16606 case ALTIVEC_BUILTIN_STVX_V4SF: 15763 case ALTIVEC_BUILTIN_STVX_V4SF:
16607 case ALTIVEC_BUILTIN_STVX_V2DI: 15764 case ALTIVEC_BUILTIN_STVX_V2DI:
16608 case ALTIVEC_BUILTIN_STVX_V2DF: 15765 case ALTIVEC_BUILTIN_STVX_V2DF:
16609 { 15766 {
16610 /* Do not fold for -maltivec=be on LE targets. */ 15767 arg0 = gimple_call_arg (stmt, 0); /* Value to be stored. */
16611 if (VECTOR_ELT_ORDER_BIG && !BYTES_BIG_ENDIAN) 15768 arg1 = gimple_call_arg (stmt, 1); /* Offset. */
16612 return false; 15769 tree arg2 = gimple_call_arg (stmt, 2); /* Store-to address. */
16613 arg0 = gimple_call_arg (stmt, 0); /* Value to be stored. */ 15770 location_t loc = gimple_location (stmt);
16614 arg1 = gimple_call_arg (stmt, 1); /* Offset. */ 15771 tree arg0_type = TREE_TYPE (arg0);
16615 tree arg2 = gimple_call_arg (stmt, 2); /* Store-to address. */ 15772 /* Use ptr_type_node (no TBAA) for the arg2_type.
16616 location_t loc = gimple_location (stmt); 15773 FIXME: (Richard) "A proper fix would be to transition this type as
16617 tree arg0_type = TREE_TYPE (arg0); 15774 seen from the frontend to GIMPLE, for example in a similar way we
16618 /* Use ptr_type_node (no TBAA) for the arg2_type. 15775 do for MEM_REFs by piggy-backing that on an extra argument, a
16619 FIXME: (Richard) "A proper fix would be to transition this type as 15776 constant zero pointer of the alias pointer type to use (which would
16620 seen from the frontend to GIMPLE, for example in a similar way we 15777 also serve as a type indicator of the store itself). I'd use a
16621 do for MEM_REFs by piggy-backing that on an extra argument, a 15778 target specific internal function for this (not sure if we can have
16622 constant zero pointer of the alias pointer type to use (which would 15779 those target specific, but I guess if it's folded away then that's
16623 also serve as a type indicator of the store itself). I'd use a 15780 fine) and get away with the overload set." */
16624 target specific internal function for this (not sure if we can have 15781 tree arg2_type = ptr_type_node;
16625 those target specific, but I guess if it's folded away then that's 15782 /* POINTER_PLUS_EXPR wants the offset to be of type 'sizetype'. Create
16626 fine) and get away with the overload set." 15783 the tree using the value from arg0. The resulting type will match
16627 */ 15784 the type of arg2. */
16628 tree arg2_type = ptr_type_node; 15785 gimple_seq stmts = NULL;
16629 /* POINTER_PLUS_EXPR wants the offset to be of type 'sizetype'. Create 15786 tree temp_offset = gimple_convert (&stmts, loc, sizetype, arg1);
16630 the tree using the value from arg0. The resulting type will match 15787 tree temp_addr = gimple_build (&stmts, loc, POINTER_PLUS_EXPR,
16631 the type of arg2. */
16632 gimple_seq stmts = NULL;
16633 tree temp_offset = gimple_convert (&stmts, loc, sizetype, arg1);
16634 tree temp_addr = gimple_build (&stmts, loc, POINTER_PLUS_EXPR,
16635 arg2_type, arg2, temp_offset); 15788 arg2_type, arg2, temp_offset);
16636 /* Mask off any lower bits from the address. */ 15789 /* Mask off any lower bits from the address. */
16637 tree aligned_addr = gimple_build (&stmts, loc, BIT_AND_EXPR, 15790 tree aligned_addr = gimple_build (&stmts, loc, BIT_AND_EXPR,
16638 arg2_type, temp_addr, 15791 arg2_type, temp_addr,
16639 build_int_cst (arg2_type, -16)); 15792 build_int_cst (arg2_type, -16));
16640 gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT); 15793 gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT);
16641 /* The desired gimple result should be similar to: 15794 /* The desired gimple result should be similar to:
16642 MEM[(__vector floatD.1407 *)_1] = vf1D.2697; */ 15795 MEM[(__vector floatD.1407 *)_1] = vf1D.2697; */
16643 gimple *g; 15796 gimple *g
16644 g = gimple_build_assign (build2 (MEM_REF, arg0_type, aligned_addr, 15797 = gimple_build_assign (build2 (MEM_REF, arg0_type, aligned_addr,
16645 build_int_cst (arg2_type, 0)), arg0); 15798 build_int_cst (arg2_type, 0)), arg0);
16646 gimple_set_location (g, loc); 15799 gimple_set_location (g, loc);
16647 gsi_replace (gsi, g, true); 15800 gsi_replace (gsi, g, true);
16648 return true; 15801 return true;
16649 } 15802 }
15803
15804 /* unaligned Vector loads. */
15805 case VSX_BUILTIN_LXVW4X_V16QI:
15806 case VSX_BUILTIN_LXVW4X_V8HI:
15807 case VSX_BUILTIN_LXVW4X_V4SF:
15808 case VSX_BUILTIN_LXVW4X_V4SI:
15809 case VSX_BUILTIN_LXVD2X_V2DF:
15810 case VSX_BUILTIN_LXVD2X_V2DI:
15811 {
15812 arg0 = gimple_call_arg (stmt, 0); // offset
15813 arg1 = gimple_call_arg (stmt, 1); // address
15814 lhs = gimple_call_lhs (stmt);
15815 location_t loc = gimple_location (stmt);
15816 /* Since arg1 may be cast to a different type, just use ptr_type_node
15817 here instead of trying to enforce TBAA on pointer types. */
15818 tree arg1_type = ptr_type_node;
15819 tree lhs_type = TREE_TYPE (lhs);
15820 /* In GIMPLE the type of the MEM_REF specifies the alignment. The
15821 required alignment (power) is 4 bytes regardless of data type. */
15822 tree align_ltype = build_aligned_type (lhs_type, 4);
15823 /* POINTER_PLUS_EXPR wants the offset to be of type 'sizetype'. Create
15824 the tree using the value from arg0. The resulting type will match
15825 the type of arg1. */
15826 gimple_seq stmts = NULL;
15827 tree temp_offset = gimple_convert (&stmts, loc, sizetype, arg0);
15828 tree temp_addr = gimple_build (&stmts, loc, POINTER_PLUS_EXPR,
15829 arg1_type, arg1, temp_offset);
15830 gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT);
15831 /* Use the build2 helper to set up the mem_ref. The MEM_REF could also
15832 take an offset, but since we've already incorporated the offset
15833 above, here we just pass in a zero. */
15834 gimple *g;
15835 g = gimple_build_assign (lhs, build2 (MEM_REF, align_ltype, temp_addr,
15836 build_int_cst (arg1_type, 0)));
15837 gimple_set_location (g, loc);
15838 gsi_replace (gsi, g, true);
15839 return true;
15840 }
15841
15842 /* unaligned Vector stores. */
15843 case VSX_BUILTIN_STXVW4X_V16QI:
15844 case VSX_BUILTIN_STXVW4X_V8HI:
15845 case VSX_BUILTIN_STXVW4X_V4SF:
15846 case VSX_BUILTIN_STXVW4X_V4SI:
15847 case VSX_BUILTIN_STXVD2X_V2DF:
15848 case VSX_BUILTIN_STXVD2X_V2DI:
15849 {
15850 arg0 = gimple_call_arg (stmt, 0); /* Value to be stored. */
15851 arg1 = gimple_call_arg (stmt, 1); /* Offset. */
15852 tree arg2 = gimple_call_arg (stmt, 2); /* Store-to address. */
15853 location_t loc = gimple_location (stmt);
15854 tree arg0_type = TREE_TYPE (arg0);
15855 /* Use ptr_type_node (no TBAA) for the arg2_type. */
15856 tree arg2_type = ptr_type_node;
15857 /* In GIMPLE the type of the MEM_REF specifies the alignment. The
15858 required alignment (power) is 4 bytes regardless of data type. */
15859 tree align_stype = build_aligned_type (arg0_type, 4);
15860 /* POINTER_PLUS_EXPR wants the offset to be of type 'sizetype'. Create
15861 the tree using the value from arg1. */
15862 gimple_seq stmts = NULL;
15863 tree temp_offset = gimple_convert (&stmts, loc, sizetype, arg1);
15864 tree temp_addr = gimple_build (&stmts, loc, POINTER_PLUS_EXPR,
15865 arg2_type, arg2, temp_offset);
15866 gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT);
15867 gimple *g;
15868 g = gimple_build_assign (build2 (MEM_REF, align_stype, temp_addr,
15869 build_int_cst (arg2_type, 0)), arg0);
15870 gimple_set_location (g, loc);
15871 gsi_replace (gsi, g, true);
15872 return true;
15873 }
15874
15875 /* Vector Fused multiply-add (fma). */
15876 case ALTIVEC_BUILTIN_VMADDFP:
15877 case VSX_BUILTIN_XVMADDDP:
15878 case ALTIVEC_BUILTIN_VMLADDUHM:
15879 {
15880 arg0 = gimple_call_arg (stmt, 0);
15881 arg1 = gimple_call_arg (stmt, 1);
15882 tree arg2 = gimple_call_arg (stmt, 2);
15883 lhs = gimple_call_lhs (stmt);
15884 gcall *g = gimple_build_call_internal (IFN_FMA, 3, arg0, arg1, arg2);
15885 gimple_call_set_lhs (g, lhs);
15886 gimple_call_set_nothrow (g, true);
15887 gimple_set_location (g, gimple_location (stmt));
15888 gsi_replace (gsi, g, true);
15889 return true;
15890 }
15891
15892 /* Vector compares; EQ, NE, GE, GT, LE. */
15893 case ALTIVEC_BUILTIN_VCMPEQUB:
15894 case ALTIVEC_BUILTIN_VCMPEQUH:
15895 case ALTIVEC_BUILTIN_VCMPEQUW:
15896 case P8V_BUILTIN_VCMPEQUD:
15897 fold_compare_helper (gsi, EQ_EXPR, stmt);
15898 return true;
15899
15900 case P9V_BUILTIN_CMPNEB:
15901 case P9V_BUILTIN_CMPNEH:
15902 case P9V_BUILTIN_CMPNEW:
15903 fold_compare_helper (gsi, NE_EXPR, stmt);
15904 return true;
15905
15906 case VSX_BUILTIN_CMPGE_16QI:
15907 case VSX_BUILTIN_CMPGE_U16QI:
15908 case VSX_BUILTIN_CMPGE_8HI:
15909 case VSX_BUILTIN_CMPGE_U8HI:
15910 case VSX_BUILTIN_CMPGE_4SI:
15911 case VSX_BUILTIN_CMPGE_U4SI:
15912 case VSX_BUILTIN_CMPGE_2DI:
15913 case VSX_BUILTIN_CMPGE_U2DI:
15914 fold_compare_helper (gsi, GE_EXPR, stmt);
15915 return true;
15916
15917 case ALTIVEC_BUILTIN_VCMPGTSB:
15918 case ALTIVEC_BUILTIN_VCMPGTUB:
15919 case ALTIVEC_BUILTIN_VCMPGTSH:
15920 case ALTIVEC_BUILTIN_VCMPGTUH:
15921 case ALTIVEC_BUILTIN_VCMPGTSW:
15922 case ALTIVEC_BUILTIN_VCMPGTUW:
15923 case P8V_BUILTIN_VCMPGTUD:
15924 case P8V_BUILTIN_VCMPGTSD:
15925 fold_compare_helper (gsi, GT_EXPR, stmt);
15926 return true;
15927
15928 case VSX_BUILTIN_CMPLE_16QI:
15929 case VSX_BUILTIN_CMPLE_U16QI:
15930 case VSX_BUILTIN_CMPLE_8HI:
15931 case VSX_BUILTIN_CMPLE_U8HI:
15932 case VSX_BUILTIN_CMPLE_4SI:
15933 case VSX_BUILTIN_CMPLE_U4SI:
15934 case VSX_BUILTIN_CMPLE_2DI:
15935 case VSX_BUILTIN_CMPLE_U2DI:
15936 fold_compare_helper (gsi, LE_EXPR, stmt);
15937 return true;
15938
15939 /* flavors of vec_splat_[us]{8,16,32}. */
15940 case ALTIVEC_BUILTIN_VSPLTISB:
15941 case ALTIVEC_BUILTIN_VSPLTISH:
15942 case ALTIVEC_BUILTIN_VSPLTISW:
15943 {
15944 int size;
15945 if (fn_code == ALTIVEC_BUILTIN_VSPLTISB)
15946 size = 8;
15947 else if (fn_code == ALTIVEC_BUILTIN_VSPLTISH)
15948 size = 16;
15949 else
15950 size = 32;
15951
15952 arg0 = gimple_call_arg (stmt, 0);
15953 lhs = gimple_call_lhs (stmt);
15954
15955 /* Only fold the vec_splat_*() if the lower bits of arg 0 is a
15956 5-bit signed constant in range -16 to +15. */
15957 if (TREE_CODE (arg0) != INTEGER_CST
15958 || !IN_RANGE (sext_hwi (TREE_INT_CST_LOW (arg0), size),
15959 -16, 15))
15960 return false;
15961 gimple_seq stmts = NULL;
15962 location_t loc = gimple_location (stmt);
15963 tree splat_value = gimple_convert (&stmts, loc,
15964 TREE_TYPE (TREE_TYPE (lhs)), arg0);
15965 gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT);
15966 tree splat_tree = build_vector_from_val (TREE_TYPE (lhs), splat_value);
15967 g = gimple_build_assign (lhs, splat_tree);
15968 gimple_set_location (g, gimple_location (stmt));
15969 gsi_replace (gsi, g, true);
15970 return true;
15971 }
15972
15973 /* Flavors of vec_splat. */
15974 /* a = vec_splat (b, 0x3) becomes a = { b[3],b[3],b[3],...}; */
15975 case ALTIVEC_BUILTIN_VSPLTB:
15976 case ALTIVEC_BUILTIN_VSPLTH:
15977 case ALTIVEC_BUILTIN_VSPLTW:
15978 case VSX_BUILTIN_XXSPLTD_V2DI:
15979 case VSX_BUILTIN_XXSPLTD_V2DF:
15980 {
15981 arg0 = gimple_call_arg (stmt, 0); /* input vector. */
15982 arg1 = gimple_call_arg (stmt, 1); /* index into arg0. */
15983 /* Only fold the vec_splat_*() if arg1 is both a constant value and
15984 is a valid index into the arg0 vector. */
15985 unsigned int n_elts = VECTOR_CST_NELTS (arg0);
15986 if (TREE_CODE (arg1) != INTEGER_CST
15987 || TREE_INT_CST_LOW (arg1) > (n_elts -1))
15988 return false;
15989 lhs = gimple_call_lhs (stmt);
15990 tree lhs_type = TREE_TYPE (lhs);
15991 tree arg0_type = TREE_TYPE (arg0);
15992 tree splat;
15993 if (TREE_CODE (arg0) == VECTOR_CST)
15994 splat = VECTOR_CST_ELT (arg0, TREE_INT_CST_LOW (arg1));
15995 else
15996 {
15997 /* Determine (in bits) the length and start location of the
15998 splat value for a call to the tree_vec_extract helper. */
15999 int splat_elem_size = TREE_INT_CST_LOW (size_in_bytes (arg0_type))
16000 * BITS_PER_UNIT / n_elts;
16001 int splat_start_bit = TREE_INT_CST_LOW (arg1) * splat_elem_size;
16002 tree len = build_int_cst (bitsizetype, splat_elem_size);
16003 tree start = build_int_cst (bitsizetype, splat_start_bit);
16004 splat = tree_vec_extract (gsi, TREE_TYPE (lhs_type), arg0,
16005 len, start);
16006 }
16007 /* And finally, build the new vector. */
16008 tree splat_tree = build_vector_from_val (lhs_type, splat);
16009 g = gimple_build_assign (lhs, splat_tree);
16010 gimple_set_location (g, gimple_location (stmt));
16011 gsi_replace (gsi, g, true);
16012 return true;
16013 }
16014
16015 /* vec_mergel (integrals). */
16016 case ALTIVEC_BUILTIN_VMRGLH:
16017 case ALTIVEC_BUILTIN_VMRGLW:
16018 case VSX_BUILTIN_XXMRGLW_4SI:
16019 case ALTIVEC_BUILTIN_VMRGLB:
16020 case VSX_BUILTIN_VEC_MERGEL_V2DI:
16021 case VSX_BUILTIN_XXMRGLW_4SF:
16022 case VSX_BUILTIN_VEC_MERGEL_V2DF:
16023 fold_mergehl_helper (gsi, stmt, 1);
16024 return true;
16025 /* vec_mergeh (integrals). */
16026 case ALTIVEC_BUILTIN_VMRGHH:
16027 case ALTIVEC_BUILTIN_VMRGHW:
16028 case VSX_BUILTIN_XXMRGHW_4SI:
16029 case ALTIVEC_BUILTIN_VMRGHB:
16030 case VSX_BUILTIN_VEC_MERGEH_V2DI:
16031 case VSX_BUILTIN_XXMRGHW_4SF:
16032 case VSX_BUILTIN_VEC_MERGEH_V2DF:
16033 fold_mergehl_helper (gsi, stmt, 0);
16034 return true;
16035
16036 /* Flavors of vec_mergee. */
16037 case P8V_BUILTIN_VMRGEW_V4SI:
16038 case P8V_BUILTIN_VMRGEW_V2DI:
16039 case P8V_BUILTIN_VMRGEW_V4SF:
16040 case P8V_BUILTIN_VMRGEW_V2DF:
16041 fold_mergeeo_helper (gsi, stmt, 0);
16042 return true;
16043 /* Flavors of vec_mergeo. */
16044 case P8V_BUILTIN_VMRGOW_V4SI:
16045 case P8V_BUILTIN_VMRGOW_V2DI:
16046 case P8V_BUILTIN_VMRGOW_V4SF:
16047 case P8V_BUILTIN_VMRGOW_V2DF:
16048 fold_mergeeo_helper (gsi, stmt, 1);
16049 return true;
16050
16051 /* d = vec_pack (a, b) */
16052 case P8V_BUILTIN_VPKUDUM:
16053 case ALTIVEC_BUILTIN_VPKUHUM:
16054 case ALTIVEC_BUILTIN_VPKUWUM:
16055 {
16056 arg0 = gimple_call_arg (stmt, 0);
16057 arg1 = gimple_call_arg (stmt, 1);
16058 lhs = gimple_call_lhs (stmt);
16059 gimple *g = gimple_build_assign (lhs, VEC_PACK_TRUNC_EXPR, arg0, arg1);
16060 gimple_set_location (g, gimple_location (stmt));
16061 gsi_replace (gsi, g, true);
16062 return true;
16063 }
16064
16065 /* d = vec_unpackh (a) */
16066 /* Note that the UNPACK_{HI,LO}_EXPR used in the gimple_build_assign call
16067 in this code is sensitive to endian-ness, and needs to be inverted to
16068 handle both LE and BE targets. */
16069 case ALTIVEC_BUILTIN_VUPKHSB:
16070 case ALTIVEC_BUILTIN_VUPKHSH:
16071 case P8V_BUILTIN_VUPKHSW:
16072 {
16073 arg0 = gimple_call_arg (stmt, 0);
16074 lhs = gimple_call_lhs (stmt);
16075 if (BYTES_BIG_ENDIAN)
16076 g = gimple_build_assign (lhs, VEC_UNPACK_HI_EXPR, arg0);
16077 else
16078 g = gimple_build_assign (lhs, VEC_UNPACK_LO_EXPR, arg0);
16079 gimple_set_location (g, gimple_location (stmt));
16080 gsi_replace (gsi, g, true);
16081 return true;
16082 }
16083 /* d = vec_unpackl (a) */
16084 case ALTIVEC_BUILTIN_VUPKLSB:
16085 case ALTIVEC_BUILTIN_VUPKLSH:
16086 case P8V_BUILTIN_VUPKLSW:
16087 {
16088 arg0 = gimple_call_arg (stmt, 0);
16089 lhs = gimple_call_lhs (stmt);
16090 if (BYTES_BIG_ENDIAN)
16091 g = gimple_build_assign (lhs, VEC_UNPACK_LO_EXPR, arg0);
16092 else
16093 g = gimple_build_assign (lhs, VEC_UNPACK_HI_EXPR, arg0);
16094 gimple_set_location (g, gimple_location (stmt));
16095 gsi_replace (gsi, g, true);
16096 return true;
16097 }
16098 /* There is no gimple type corresponding with pixel, so just return. */
16099 case ALTIVEC_BUILTIN_VUPKHPX:
16100 case ALTIVEC_BUILTIN_VUPKLPX:
16101 return false;
16102
16103 /* vec_perm. */
16104 case ALTIVEC_BUILTIN_VPERM_16QI:
16105 case ALTIVEC_BUILTIN_VPERM_8HI:
16106 case ALTIVEC_BUILTIN_VPERM_4SI:
16107 case ALTIVEC_BUILTIN_VPERM_2DI:
16108 case ALTIVEC_BUILTIN_VPERM_4SF:
16109 case ALTIVEC_BUILTIN_VPERM_2DF:
16110 {
16111 arg0 = gimple_call_arg (stmt, 0);
16112 arg1 = gimple_call_arg (stmt, 1);
16113 tree permute = gimple_call_arg (stmt, 2);
16114 lhs = gimple_call_lhs (stmt);
16115 location_t loc = gimple_location (stmt);
16116 gimple_seq stmts = NULL;
16117 // convert arg0 and arg1 to match the type of the permute
16118 // for the VEC_PERM_EXPR operation.
16119 tree permute_type = (TREE_TYPE (permute));
16120 tree arg0_ptype = gimple_convert (&stmts, loc, permute_type, arg0);
16121 tree arg1_ptype = gimple_convert (&stmts, loc, permute_type, arg1);
16122 tree lhs_ptype = gimple_build (&stmts, loc, VEC_PERM_EXPR,
16123 permute_type, arg0_ptype, arg1_ptype,
16124 permute);
16125 // Convert the result back to the desired lhs type upon completion.
16126 tree temp = gimple_convert (&stmts, loc, TREE_TYPE (lhs), lhs_ptype);
16127 gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT);
16128 g = gimple_build_assign (lhs, temp);
16129 gimple_set_location (g, loc);
16130 gsi_replace (gsi, g, true);
16131 return true;
16132 }
16133
16650 default: 16134 default:
16651 if (TARGET_DEBUG_BUILTIN) 16135 if (TARGET_DEBUG_BUILTIN)
16652 fprintf (stderr, "gimple builtin intrinsic not matched:%d %s %s\n", 16136 fprintf (stderr, "gimple builtin intrinsic not matched:%d %s %s\n",
16653 fn_code, fn_name1, fn_name2); 16137 fn_code, fn_name1, fn_name2);
16654 break; 16138 break;
16655 } 16139 }
16656 16140
16657 return false; 16141 return false;
16658 } 16142 }
16676 size_t i; 16160 size_t i;
16677 rtx ret; 16161 rtx ret;
16678 bool success; 16162 bool success;
16679 HOST_WIDE_INT mask = rs6000_builtin_info[uns_fcode].mask; 16163 HOST_WIDE_INT mask = rs6000_builtin_info[uns_fcode].mask;
16680 bool func_valid_p = ((rs6000_builtin_mask & mask) == mask); 16164 bool func_valid_p = ((rs6000_builtin_mask & mask) == mask);
16165 enum insn_code icode = rs6000_builtin_info[uns_fcode].icode;
16166
16167 /* We have two different modes (KFmode, TFmode) that are the IEEE 128-bit
16168 floating point type, depending on whether long double is the IBM extended
16169 double (KFmode) or long double is IEEE 128-bit (TFmode). It is simpler if
16170 we only define one variant of the built-in function, and switch the code
16171 when defining it, rather than defining two built-ins and using the
16172 overload table in rs6000-c.c to switch between the two. If we don't have
16173 the proper assembler, don't do this switch because CODE_FOR_*kf* and
16174 CODE_FOR_*tf* will be CODE_FOR_nothing. */
16175 if (FLOAT128_IEEE_P (TFmode))
16176 switch (icode)
16177 {
16178 default:
16179 break;
16180
16181 case CODE_FOR_sqrtkf2_odd: icode = CODE_FOR_sqrttf2_odd; break;
16182 case CODE_FOR_trunckfdf2_odd: icode = CODE_FOR_trunctfdf2_odd; break;
16183 case CODE_FOR_addkf3_odd: icode = CODE_FOR_addtf3_odd; break;
16184 case CODE_FOR_subkf3_odd: icode = CODE_FOR_subtf3_odd; break;
16185 case CODE_FOR_mulkf3_odd: icode = CODE_FOR_multf3_odd; break;
16186 case CODE_FOR_divkf3_odd: icode = CODE_FOR_divtf3_odd; break;
16187 case CODE_FOR_fmakf4_odd: icode = CODE_FOR_fmatf4_odd; break;
16188 case CODE_FOR_xsxexpqp_kf: icode = CODE_FOR_xsxexpqp_tf; break;
16189 case CODE_FOR_xsxsigqp_kf: icode = CODE_FOR_xsxsigqp_tf; break;
16190 case CODE_FOR_xststdcnegqp_kf: icode = CODE_FOR_xststdcnegqp_tf; break;
16191 case CODE_FOR_xsiexpqp_kf: icode = CODE_FOR_xsiexpqp_tf; break;
16192 case CODE_FOR_xsiexpqpf_kf: icode = CODE_FOR_xsiexpqpf_tf; break;
16193 case CODE_FOR_xststdcqp_kf: icode = CODE_FOR_xststdcqp_tf; break;
16194 }
16681 16195
16682 if (TARGET_DEBUG_BUILTIN) 16196 if (TARGET_DEBUG_BUILTIN)
16683 { 16197 {
16684 enum insn_code icode = rs6000_builtin_info[uns_fcode].icode;
16685 const char *name1 = rs6000_builtin_info[uns_fcode].name; 16198 const char *name1 = rs6000_builtin_info[uns_fcode].name;
16686 const char *name2 = (icode != CODE_FOR_nothing) 16199 const char *name2 = (icode != CODE_FOR_nothing)
16687 ? get_insn_name ((int) icode) 16200 ? get_insn_name ((int) icode)
16688 : "nothing"; 16201 : "nothing";
16689 const char *name3; 16202 const char *name3;
16747 target); 16260 target);
16748 16261
16749 case RS6000_BUILTIN_MFFS: 16262 case RS6000_BUILTIN_MFFS:
16750 return rs6000_expand_zeroop_builtin (CODE_FOR_rs6000_mffs, target); 16263 return rs6000_expand_zeroop_builtin (CODE_FOR_rs6000_mffs, target);
16751 16264
16265 case RS6000_BUILTIN_MTFSB0:
16266 return rs6000_expand_mtfsb_builtin (CODE_FOR_rs6000_mtfsb0, exp);
16267
16268 case RS6000_BUILTIN_MTFSB1:
16269 return rs6000_expand_mtfsb_builtin (CODE_FOR_rs6000_mtfsb1, exp);
16270
16271 case RS6000_BUILTIN_SET_FPSCR_RN:
16272 return rs6000_expand_set_fpscr_rn_builtin (CODE_FOR_rs6000_set_fpscr_rn,
16273 exp);
16274
16275 case RS6000_BUILTIN_SET_FPSCR_DRN:
16276 return
16277 rs6000_expand_set_fpscr_drn_builtin (CODE_FOR_rs6000_set_fpscr_drn,
16278 exp);
16279
16280 case RS6000_BUILTIN_MFFSL:
16281 return rs6000_expand_zeroop_builtin (CODE_FOR_rs6000_mffsl, target);
16282
16752 case RS6000_BUILTIN_MTFSF: 16283 case RS6000_BUILTIN_MTFSF:
16753 return rs6000_expand_mtfsf_builtin (CODE_FOR_rs6000_mtfsf, exp); 16284 return rs6000_expand_mtfsf_builtin (CODE_FOR_rs6000_mtfsf, exp);
16754 16285
16755 case RS6000_BUILTIN_CPU_INIT: 16286 case RS6000_BUILTIN_CPU_INIT:
16756 case RS6000_BUILTIN_CPU_IS: 16287 case RS6000_BUILTIN_CPU_IS:
16757 case RS6000_BUILTIN_CPU_SUPPORTS: 16288 case RS6000_BUILTIN_CPU_SUPPORTS:
16758 return cpu_expand_builtin (fcode, exp, target); 16289 return cpu_expand_builtin (fcode, exp, target);
16759 16290
16291 case MISC_BUILTIN_SPEC_BARRIER:
16292 {
16293 emit_insn (gen_speculation_barrier ());
16294 return NULL_RTX;
16295 }
16296
16760 case ALTIVEC_BUILTIN_MASK_FOR_LOAD: 16297 case ALTIVEC_BUILTIN_MASK_FOR_LOAD:
16761 case ALTIVEC_BUILTIN_MASK_FOR_STORE: 16298 case ALTIVEC_BUILTIN_MASK_FOR_STORE:
16762 { 16299 {
16763 int icode = (BYTES_BIG_ENDIAN ? (int) CODE_FOR_altivec_lvsr_direct 16300 int icode2 = (BYTES_BIG_ENDIAN ? (int) CODE_FOR_altivec_lvsr_direct
16764 : (int) CODE_FOR_altivec_lvsl_direct); 16301 : (int) CODE_FOR_altivec_lvsl_direct);
16765 machine_mode tmode = insn_data[icode].operand[0].mode; 16302 machine_mode tmode = insn_data[icode2].operand[0].mode;
16766 machine_mode mode = insn_data[icode].operand[1].mode; 16303 machine_mode mode = insn_data[icode2].operand[1].mode;
16767 tree arg; 16304 tree arg;
16768 rtx op, addr, pat; 16305 rtx op, addr, pat;
16769 16306
16770 gcc_assert (TARGET_ALTIVEC); 16307 gcc_assert (TARGET_ALTIVEC);
16771 16308
16783 } 16320 }
16784 op = gen_rtx_MEM (mode, op); 16321 op = gen_rtx_MEM (mode, op);
16785 16322
16786 if (target == 0 16323 if (target == 0
16787 || GET_MODE (target) != tmode 16324 || GET_MODE (target) != tmode
16788 || ! (*insn_data[icode].operand[0].predicate) (target, tmode)) 16325 || ! (*insn_data[icode2].operand[0].predicate) (target, tmode))
16789 target = gen_reg_rtx (tmode); 16326 target = gen_reg_rtx (tmode);
16790 16327
16791 pat = GEN_FCN (icode) (target, op); 16328 pat = GEN_FCN (icode2) (target, op);
16792 if (!pat) 16329 if (!pat)
16793 return 0; 16330 return 0;
16794 emit_insn (pat); 16331 emit_insn (pat);
16795 16332
16796 return target; 16333 return target;
16807 exp = build_call_nary (TREE_TYPE (exp), CALL_EXPR_FN (exp), 16344 exp = build_call_nary (TREE_TYPE (exp), CALL_EXPR_FN (exp),
16808 2, CALL_EXPR_ARG (exp, 0), integer_zero_node); 16345 2, CALL_EXPR_ARG (exp, 0), integer_zero_node);
16809 } 16346 }
16810 break; 16347 break;
16811 16348
16349 /* For the pack and unpack int128 routines, fix up the builtin so it
16350 uses the correct IBM128 type. */
16351 case MISC_BUILTIN_PACK_IF:
16352 if (TARGET_LONG_DOUBLE_128 && !TARGET_IEEEQUAD)
16353 {
16354 icode = CODE_FOR_packtf;
16355 fcode = MISC_BUILTIN_PACK_TF;
16356 uns_fcode = (size_t)fcode;
16357 }
16358 break;
16359
16360 case MISC_BUILTIN_UNPACK_IF:
16361 if (TARGET_LONG_DOUBLE_128 && !TARGET_IEEEQUAD)
16362 {
16363 icode = CODE_FOR_unpacktf;
16364 fcode = MISC_BUILTIN_UNPACK_TF;
16365 uns_fcode = (size_t)fcode;
16366 }
16367 break;
16368
16812 default: 16369 default:
16813 break; 16370 break;
16814 } 16371 }
16815 16372
16816 if (TARGET_ALTIVEC) 16373 if (TARGET_ALTIVEC)
16818 ret = altivec_expand_builtin (exp, target, &success); 16375 ret = altivec_expand_builtin (exp, target, &success);
16819 16376
16820 if (success) 16377 if (success)
16821 return ret; 16378 return ret;
16822 } 16379 }
16823 if (TARGET_PAIRED_FLOAT)
16824 {
16825 ret = paired_expand_builtin (exp, target, &success);
16826
16827 if (success)
16828 return ret;
16829 }
16830 if (TARGET_HTM) 16380 if (TARGET_HTM)
16831 { 16381 {
16832 ret = htm_expand_builtin (exp, target, &success); 16382 ret = htm_expand_builtin (exp, target, &success);
16833 16383
16834 if (success) 16384 if (success)
16844 16394
16845 /* Handle simple unary operations. */ 16395 /* Handle simple unary operations. */
16846 d = bdesc_1arg; 16396 d = bdesc_1arg;
16847 for (i = 0; i < ARRAY_SIZE (bdesc_1arg); i++, d++) 16397 for (i = 0; i < ARRAY_SIZE (bdesc_1arg); i++, d++)
16848 if (d->code == fcode) 16398 if (d->code == fcode)
16849 return rs6000_expand_unop_builtin (d->icode, exp, target); 16399 return rs6000_expand_unop_builtin (icode, exp, target);
16850 16400
16851 /* Handle simple binary operations. */ 16401 /* Handle simple binary operations. */
16852 d = bdesc_2arg; 16402 d = bdesc_2arg;
16853 for (i = 0; i < ARRAY_SIZE (bdesc_2arg); i++, d++) 16403 for (i = 0; i < ARRAY_SIZE (bdesc_2arg); i++, d++)
16854 if (d->code == fcode) 16404 if (d->code == fcode)
16855 return rs6000_expand_binop_builtin (d->icode, exp, target); 16405 return rs6000_expand_binop_builtin (icode, exp, target);
16856 16406
16857 /* Handle simple ternary operations. */ 16407 /* Handle simple ternary operations. */
16858 d = bdesc_3arg; 16408 d = bdesc_3arg;
16859 for (i = 0; i < ARRAY_SIZE (bdesc_3arg); i++, d++) 16409 for (i = 0; i < ARRAY_SIZE (bdesc_3arg); i++, d++)
16860 if (d->code == fcode) 16410 if (d->code == fcode)
16861 return rs6000_expand_ternop_builtin (d->icode, exp, target); 16411 return rs6000_expand_ternop_builtin (icode, exp, target);
16862 16412
16863 /* Handle simple no-argument operations. */ 16413 /* Handle simple no-argument operations. */
16864 d = bdesc_0arg; 16414 d = bdesc_0arg;
16865 for (i = 0; i < ARRAY_SIZE (bdesc_0arg); i++, d++) 16415 for (i = 0; i < ARRAY_SIZE (bdesc_0arg); i++, d++)
16866 if (d->code == fcode) 16416 if (d->code == fcode)
16867 return rs6000_expand_zeroop_builtin (d->icode, target); 16417 return rs6000_expand_zeroop_builtin (icode, target);
16868 16418
16869 gcc_unreachable (); 16419 gcc_unreachable ();
16870 } 16420 }
16871 16421
16872 /* Create a builtin vector type with a name. Taking care not to give 16422 /* Create a builtin vector type with a name. Taking care not to give
16891 tree tdecl; 16441 tree tdecl;
16892 tree ftype; 16442 tree ftype;
16893 machine_mode mode; 16443 machine_mode mode;
16894 16444
16895 if (TARGET_DEBUG_BUILTIN) 16445 if (TARGET_DEBUG_BUILTIN)
16896 fprintf (stderr, "rs6000_init_builtins%s%s%s\n", 16446 fprintf (stderr, "rs6000_init_builtins%s%s\n",
16897 (TARGET_PAIRED_FLOAT) ? ", paired" : "",
16898 (TARGET_ALTIVEC) ? ", altivec" : "", 16447 (TARGET_ALTIVEC) ? ", altivec" : "",
16899 (TARGET_VSX) ? ", vsx" : ""); 16448 (TARGET_VSX) ? ", vsx" : "");
16900 16449
16901 V2SI_type_node = build_vector_type (intSI_type_node, 2);
16902 V2SF_type_node = build_vector_type (float_type_node, 2);
16903 V2DI_type_node = rs6000_vector_type (TARGET_POWERPC64 ? "__vector long" 16450 V2DI_type_node = rs6000_vector_type (TARGET_POWERPC64 ? "__vector long"
16904 : "__vector long long", 16451 : "__vector long long",
16905 intDI_type_node, 2); 16452 intDI_type_node, 2);
16906 V2DF_type_node = rs6000_vector_type ("__vector double", double_type_node, 2); 16453 V2DF_type_node = rs6000_vector_type ("__vector double", double_type_node, 2);
16907 V4SI_type_node = rs6000_vector_type ("__vector signed int", 16454 V4SI_type_node = rs6000_vector_type ("__vector signed int",
16921 unsigned_V2DI_type_node = rs6000_vector_type (TARGET_POWERPC64 16468 unsigned_V2DI_type_node = rs6000_vector_type (TARGET_POWERPC64
16922 ? "__vector unsigned long" 16469 ? "__vector unsigned long"
16923 : "__vector unsigned long long", 16470 : "__vector unsigned long long",
16924 unsigned_intDI_type_node, 2); 16471 unsigned_intDI_type_node, 2);
16925 16472
16926 opaque_V2SF_type_node = build_opaque_vector_type (float_type_node, 2);
16927 opaque_V2SI_type_node = build_opaque_vector_type (intSI_type_node, 2);
16928 opaque_p_V2SI_type_node = build_pointer_type (opaque_V2SI_type_node);
16929 opaque_V4SI_type_node = build_opaque_vector_type (intSI_type_node, 4); 16473 opaque_V4SI_type_node = build_opaque_vector_type (intSI_type_node, 4);
16930 16474
16931 const_str_type_node 16475 const_str_type_node
16932 = build_pointer_type (build_qualified_type (char_type_node, 16476 = build_pointer_type (build_qualified_type (char_type_node,
16933 TYPE_QUAL_CONST)); 16477 TYPE_QUAL_CONST));
16948 'vector unsigned short'. */ 16492 'vector unsigned short'. */
16949 16493
16950 bool_char_type_node = build_distinct_type_copy (unsigned_intQI_type_node); 16494 bool_char_type_node = build_distinct_type_copy (unsigned_intQI_type_node);
16951 bool_short_type_node = build_distinct_type_copy (unsigned_intHI_type_node); 16495 bool_short_type_node = build_distinct_type_copy (unsigned_intHI_type_node);
16952 bool_int_type_node = build_distinct_type_copy (unsigned_intSI_type_node); 16496 bool_int_type_node = build_distinct_type_copy (unsigned_intSI_type_node);
16953 bool_long_type_node = build_distinct_type_copy (unsigned_intDI_type_node); 16497 bool_long_long_type_node = build_distinct_type_copy (unsigned_intDI_type_node);
16954 pixel_type_node = build_distinct_type_copy (unsigned_intHI_type_node); 16498 pixel_type_node = build_distinct_type_copy (unsigned_intHI_type_node);
16955 16499
16956 long_integer_type_internal_node = long_integer_type_node; 16500 long_integer_type_internal_node = long_integer_type_node;
16957 long_unsigned_type_internal_node = long_unsigned_type_node; 16501 long_unsigned_type_internal_node = long_unsigned_type_node;
16958 long_long_integer_type_internal_node = long_long_integer_type_node; 16502 long_long_integer_type_internal_node = long_long_integer_type_node;
16982 16526
16983 If we don't support for either 128-bit IBM double double or IEEE 128-bit 16527 If we don't support for either 128-bit IBM double double or IEEE 128-bit
16984 floating point, we need make sure the type is non-zero or else self-test 16528 floating point, we need make sure the type is non-zero or else self-test
16985 fails during bootstrap. 16529 fails during bootstrap.
16986 16530
16987 We don't register a built-in type for __ibm128 if the type is the same as 16531 Always create __ibm128 as a separate type, even if the current long double
16988 long double. Instead we add a #define for __ibm128 in 16532 format is IBM extended double.
16989 rs6000_cpu_cpp_builtins to long double.
16990 16533
16991 For IEEE 128-bit floating point, always create the type __ieee128. If the 16534 For IEEE 128-bit floating point, always create the type __ieee128. If the
16992 user used -mfloat128, rs6000-c.c will create a define from __float128 to 16535 user used -mfloat128, rs6000-c.c will create a define from __float128 to
16993 __ieee128. */ 16536 __ieee128. */
16994 if (TARGET_LONG_DOUBLE_128 && FLOAT128_IEEE_P (TFmode)) 16537 if (TARGET_FLOAT128_TYPE)
16995 { 16538 {
16996 ibm128_float_type_node = make_node (REAL_TYPE); 16539 if (!TARGET_IEEEQUAD && TARGET_LONG_DOUBLE_128)
16997 TYPE_PRECISION (ibm128_float_type_node) = 128; 16540 ibm128_float_type_node = long_double_type_node;
16998 SET_TYPE_MODE (ibm128_float_type_node, IFmode); 16541 else
16999 layout_type (ibm128_float_type_node); 16542 {
16543 ibm128_float_type_node = make_node (REAL_TYPE);
16544 TYPE_PRECISION (ibm128_float_type_node) = 128;
16545 SET_TYPE_MODE (ibm128_float_type_node, IFmode);
16546 layout_type (ibm128_float_type_node);
16547 }
17000 16548
17001 lang_hooks.types.register_builtin_type (ibm128_float_type_node, 16549 lang_hooks.types.register_builtin_type (ibm128_float_type_node,
17002 "__ibm128"); 16550 "__ibm128");
17003 } 16551
17004 else 16552 if (TARGET_IEEEQUAD && TARGET_LONG_DOUBLE_128)
17005 ibm128_float_type_node = long_double_type_node; 16553 ieee128_float_type_node = long_double_type_node;
17006 16554 else
17007 if (TARGET_FLOAT128_TYPE) 16555 ieee128_float_type_node = float128_type_node;
17008 { 16556
17009 ieee128_float_type_node = float128_type_node;
17010 lang_hooks.types.register_builtin_type (ieee128_float_type_node, 16557 lang_hooks.types.register_builtin_type (ieee128_float_type_node,
17011 "__ieee128"); 16558 "__ieee128");
17012 } 16559 }
17013 16560
17014 else 16561 else
17015 ieee128_float_type_node = long_double_type_node; 16562 ieee128_float_type_node = ibm128_float_type_node = long_double_type_node;
17016 16563
17017 /* Initialize the modes for builtin_function_type, mapping a machine mode to 16564 /* Initialize the modes for builtin_function_type, mapping a machine mode to
17018 tree type node. */ 16565 tree type node. */
17019 builtin_mode_to_type[QImode][0] = integer_type_node; 16566 builtin_mode_to_type[QImode][0] = integer_type_node;
17020 builtin_mode_to_type[HImode][0] = integer_type_node; 16567 builtin_mode_to_type[HImode][0] = integer_type_node;
17031 builtin_mode_to_type[TFmode][0] = long_double_type_node; 16578 builtin_mode_to_type[TFmode][0] = long_double_type_node;
17032 builtin_mode_to_type[DDmode][0] = dfloat64_type_node; 16579 builtin_mode_to_type[DDmode][0] = dfloat64_type_node;
17033 builtin_mode_to_type[TDmode][0] = dfloat128_type_node; 16580 builtin_mode_to_type[TDmode][0] = dfloat128_type_node;
17034 builtin_mode_to_type[V1TImode][0] = V1TI_type_node; 16581 builtin_mode_to_type[V1TImode][0] = V1TI_type_node;
17035 builtin_mode_to_type[V1TImode][1] = unsigned_V1TI_type_node; 16582 builtin_mode_to_type[V1TImode][1] = unsigned_V1TI_type_node;
17036 builtin_mode_to_type[V2SImode][0] = V2SI_type_node;
17037 builtin_mode_to_type[V2SFmode][0] = V2SF_type_node;
17038 builtin_mode_to_type[V2DImode][0] = V2DI_type_node; 16583 builtin_mode_to_type[V2DImode][0] = V2DI_type_node;
17039 builtin_mode_to_type[V2DImode][1] = unsigned_V2DI_type_node; 16584 builtin_mode_to_type[V2DImode][1] = unsigned_V2DI_type_node;
17040 builtin_mode_to_type[V2DFmode][0] = V2DF_type_node; 16585 builtin_mode_to_type[V2DFmode][0] = V2DF_type_node;
17041 builtin_mode_to_type[V4SImode][0] = V4SI_type_node; 16586 builtin_mode_to_type[V4SImode][0] = V4SI_type_node;
17042 builtin_mode_to_type[V4SImode][1] = unsigned_V4SI_type_node; 16587 builtin_mode_to_type[V4SImode][1] = unsigned_V4SI_type_node;
17065 bool_V4SI_type_node = rs6000_vector_type ("__vector __bool int", 16610 bool_V4SI_type_node = rs6000_vector_type ("__vector __bool int",
17066 bool_int_type_node, 4); 16611 bool_int_type_node, 4);
17067 bool_V2DI_type_node = rs6000_vector_type (TARGET_POWERPC64 16612 bool_V2DI_type_node = rs6000_vector_type (TARGET_POWERPC64
17068 ? "__vector __bool long" 16613 ? "__vector __bool long"
17069 : "__vector __bool long long", 16614 : "__vector __bool long long",
17070 bool_long_type_node, 2); 16615 bool_long_long_type_node, 2);
17071 pixel_V8HI_type_node = rs6000_vector_type ("__vector __pixel", 16616 pixel_V8HI_type_node = rs6000_vector_type ("__vector __pixel",
17072 pixel_type_node, 8); 16617 pixel_type_node, 8);
17073 16618
17074 /* Paired builtins are only available if you build a compiler with the 16619 /* Create Altivec and VSX builtins on machines with at least the
17075 appropriate options, so only create those builtins with the appropriate 16620 general purpose extensions (970 and newer) to allow the use of
17076 compiler option. Create Altivec and VSX builtins on machines with at
17077 least the general purpose extensions (970 and newer) to allow the use of
17078 the target attribute. */ 16621 the target attribute. */
17079 if (TARGET_PAIRED_FLOAT)
17080 paired_init_builtins ();
17081 if (TARGET_EXTRA_BUILTINS) 16622 if (TARGET_EXTRA_BUILTINS)
17082 altivec_init_builtins (); 16623 altivec_init_builtins ();
17083 if (TARGET_HTM) 16624 if (TARGET_HTM)
17084 htm_init_builtins (); 16625 htm_init_builtins ();
17085 16626
17086 if (TARGET_EXTRA_BUILTINS || TARGET_PAIRED_FLOAT) 16627 if (TARGET_EXTRA_BUILTINS)
17087 rs6000_common_init_builtins (); 16628 rs6000_common_init_builtins ();
17088
17089 ftype = build_function_type_list (ieee128_float_type_node,
17090 const_str_type_node, NULL_TREE);
17091 def_builtin ("__builtin_nanq", ftype, RS6000_BUILTIN_NANQ);
17092 def_builtin ("__builtin_nansq", ftype, RS6000_BUILTIN_NANSQ);
17093
17094 ftype = build_function_type_list (ieee128_float_type_node, NULL_TREE);
17095 def_builtin ("__builtin_infq", ftype, RS6000_BUILTIN_INFQ);
17096 def_builtin ("__builtin_huge_valq", ftype, RS6000_BUILTIN_HUGE_VALQ);
17097 16629
17098 ftype = builtin_function_type (DFmode, DFmode, DFmode, VOIDmode, 16630 ftype = builtin_function_type (DFmode, DFmode, DFmode, VOIDmode,
17099 RS6000_BUILTIN_RECIP, "__builtin_recipdiv"); 16631 RS6000_BUILTIN_RECIP, "__builtin_recipdiv");
17100 def_builtin ("__builtin_recipdiv", ftype, RS6000_BUILTIN_RECIP); 16632 def_builtin ("__builtin_recipdiv", ftype, RS6000_BUILTIN_RECIP);
17101 16633
17129 def_builtin ("__builtin_ppc_mftb", ftype, RS6000_BUILTIN_MFTB); 16661 def_builtin ("__builtin_ppc_mftb", ftype, RS6000_BUILTIN_MFTB);
17130 16662
17131 ftype = build_function_type_list (double_type_node, NULL_TREE); 16663 ftype = build_function_type_list (double_type_node, NULL_TREE);
17132 def_builtin ("__builtin_mffs", ftype, RS6000_BUILTIN_MFFS); 16664 def_builtin ("__builtin_mffs", ftype, RS6000_BUILTIN_MFFS);
17133 16665
16666 ftype = build_function_type_list (double_type_node, NULL_TREE);
16667 def_builtin ("__builtin_mffsl", ftype, RS6000_BUILTIN_MFFSL);
16668
16669 ftype = build_function_type_list (void_type_node,
16670 intSI_type_node,
16671 NULL_TREE);
16672 def_builtin ("__builtin_mtfsb0", ftype, RS6000_BUILTIN_MTFSB0);
16673
16674 ftype = build_function_type_list (void_type_node,
16675 intSI_type_node,
16676 NULL_TREE);
16677 def_builtin ("__builtin_mtfsb1", ftype, RS6000_BUILTIN_MTFSB1);
16678
16679 ftype = build_function_type_list (void_type_node,
16680 intDI_type_node,
16681 NULL_TREE);
16682 def_builtin ("__builtin_set_fpscr_rn", ftype, RS6000_BUILTIN_SET_FPSCR_RN);
16683
16684 ftype = build_function_type_list (void_type_node,
16685 intDI_type_node,
16686 NULL_TREE);
16687 def_builtin ("__builtin_set_fpscr_drn", ftype, RS6000_BUILTIN_SET_FPSCR_DRN);
16688
17134 ftype = build_function_type_list (void_type_node, 16689 ftype = build_function_type_list (void_type_node,
17135 intSI_type_node, double_type_node, 16690 intSI_type_node, double_type_node,
17136 NULL_TREE); 16691 NULL_TREE);
17137 def_builtin ("__builtin_mtfsf", ftype, RS6000_BUILTIN_MTFSF); 16692 def_builtin ("__builtin_mtfsf", ftype, RS6000_BUILTIN_MTFSF);
17138 16693
17139 ftype = build_function_type_list (void_type_node, NULL_TREE); 16694 ftype = build_function_type_list (void_type_node, NULL_TREE);
17140 def_builtin ("__builtin_cpu_init", ftype, RS6000_BUILTIN_CPU_INIT); 16695 def_builtin ("__builtin_cpu_init", ftype, RS6000_BUILTIN_CPU_INIT);
16696 def_builtin ("__builtin_ppc_speculation_barrier", ftype,
16697 MISC_BUILTIN_SPEC_BARRIER);
17141 16698
17142 ftype = build_function_type_list (bool_int_type_node, const_ptr_type_node, 16699 ftype = build_function_type_list (bool_int_type_node, const_ptr_type_node,
17143 NULL_TREE); 16700 NULL_TREE);
17144 def_builtin ("__builtin_cpu_is", ftype, RS6000_BUILTIN_CPU_IS); 16701 def_builtin ("__builtin_cpu_is", ftype, RS6000_BUILTIN_CPU_IS);
17145 def_builtin ("__builtin_cpu_supports", ftype, RS6000_BUILTIN_CPU_SUPPORTS); 16702 def_builtin ("__builtin_cpu_supports", ftype, RS6000_BUILTIN_CPU_SUPPORTS);
17170 rs6000_invalid_builtin ((enum rs6000_builtins)code); 16727 rs6000_invalid_builtin ((enum rs6000_builtins)code);
17171 return error_mark_node; 16728 return error_mark_node;
17172 } 16729 }
17173 16730
17174 return rs6000_builtin_decls[code]; 16731 return rs6000_builtin_decls[code];
17175 }
17176
17177 static void
17178 paired_init_builtins (void)
17179 {
17180 const struct builtin_description *d;
17181 size_t i;
17182 HOST_WIDE_INT builtin_mask = rs6000_builtin_mask;
17183
17184 tree int_ftype_int_v2sf_v2sf
17185 = build_function_type_list (integer_type_node,
17186 integer_type_node,
17187 V2SF_type_node,
17188 V2SF_type_node,
17189 NULL_TREE);
17190 tree pcfloat_type_node =
17191 build_pointer_type (build_qualified_type
17192 (float_type_node, TYPE_QUAL_CONST));
17193
17194 tree v2sf_ftype_long_pcfloat = build_function_type_list (V2SF_type_node,
17195 long_integer_type_node,
17196 pcfloat_type_node,
17197 NULL_TREE);
17198 tree void_ftype_v2sf_long_pcfloat =
17199 build_function_type_list (void_type_node,
17200 V2SF_type_node,
17201 long_integer_type_node,
17202 pcfloat_type_node,
17203 NULL_TREE);
17204
17205
17206 def_builtin ("__builtin_paired_lx", v2sf_ftype_long_pcfloat,
17207 PAIRED_BUILTIN_LX);
17208
17209
17210 def_builtin ("__builtin_paired_stx", void_ftype_v2sf_long_pcfloat,
17211 PAIRED_BUILTIN_STX);
17212
17213 /* Predicates. */
17214 d = bdesc_paired_preds;
17215 for (i = 0; i < ARRAY_SIZE (bdesc_paired_preds); ++i, d++)
17216 {
17217 tree type;
17218 HOST_WIDE_INT mask = d->mask;
17219
17220 if ((mask & builtin_mask) != mask)
17221 {
17222 if (TARGET_DEBUG_BUILTIN)
17223 fprintf (stderr, "paired_init_builtins, skip predicate %s\n",
17224 d->name);
17225 continue;
17226 }
17227
17228 /* Cannot define builtin if the instruction is disabled. */
17229 gcc_assert (d->icode != CODE_FOR_nothing);
17230
17231 if (TARGET_DEBUG_BUILTIN)
17232 fprintf (stderr, "paired pred #%d, insn = %s [%d], mode = %s\n",
17233 (int)i, get_insn_name (d->icode), (int)d->icode,
17234 GET_MODE_NAME (insn_data[d->icode].operand[1].mode));
17235
17236 switch (insn_data[d->icode].operand[1].mode)
17237 {
17238 case E_V2SFmode:
17239 type = int_ftype_int_v2sf_v2sf;
17240 break;
17241 default:
17242 gcc_unreachable ();
17243 }
17244
17245 def_builtin (d->name, type, d->code);
17246 }
17247 } 16732 }
17248 16733
17249 static void 16734 static void
17250 altivec_init_builtins (void) 16735 altivec_init_builtins (void)
17251 { 16736 {
17328 NULL_TREE); 16813 NULL_TREE);
17329 tree v2di_ftype_long_pcvoid 16814 tree v2di_ftype_long_pcvoid
17330 = build_function_type_list (V2DI_type_node, 16815 = build_function_type_list (V2DI_type_node,
17331 long_integer_type_node, pcvoid_type_node, 16816 long_integer_type_node, pcvoid_type_node,
17332 NULL_TREE); 16817 NULL_TREE);
16818 tree v1ti_ftype_long_pcvoid
16819 = build_function_type_list (V1TI_type_node,
16820 long_integer_type_node, pcvoid_type_node,
16821 NULL_TREE);
17333 16822
17334 tree void_ftype_opaque_long_pvoid 16823 tree void_ftype_opaque_long_pvoid
17335 = build_function_type_list (void_type_node, 16824 = build_function_type_list (void_type_node,
17336 opaque_V4SI_type_node, long_integer_type_node, 16825 opaque_V4SI_type_node, long_integer_type_node,
17337 pvoid_type_node, NULL_TREE); 16826 pvoid_type_node, NULL_TREE);
17358 V4SF_type_node, long_integer_type_node, 16847 V4SF_type_node, long_integer_type_node,
17359 pvoid_type_node, NULL_TREE); 16848 pvoid_type_node, NULL_TREE);
17360 tree void_ftype_v2df_long_pvoid 16849 tree void_ftype_v2df_long_pvoid
17361 = build_function_type_list (void_type_node, 16850 = build_function_type_list (void_type_node,
17362 V2DF_type_node, long_integer_type_node, 16851 V2DF_type_node, long_integer_type_node,
16852 pvoid_type_node, NULL_TREE);
16853 tree void_ftype_v1ti_long_pvoid
16854 = build_function_type_list (void_type_node,
16855 V1TI_type_node, long_integer_type_node,
17363 pvoid_type_node, NULL_TREE); 16856 pvoid_type_node, NULL_TREE);
17364 tree void_ftype_v2di_long_pvoid 16857 tree void_ftype_v2di_long_pvoid
17365 = build_function_type_list (void_type_node, 16858 = build_function_type_list (void_type_node,
17366 V2DI_type_node, long_integer_type_node, 16859 V2DI_type_node, long_integer_type_node,
17367 pvoid_type_node, NULL_TREE); 16860 pvoid_type_node, NULL_TREE);
17419 def_builtin ("__builtin_altivec_lvxl_v8hi", v8hi_ftype_long_pcvoid, 16912 def_builtin ("__builtin_altivec_lvxl_v8hi", v8hi_ftype_long_pcvoid,
17420 ALTIVEC_BUILTIN_LVXL_V8HI); 16913 ALTIVEC_BUILTIN_LVXL_V8HI);
17421 def_builtin ("__builtin_altivec_lvxl_v16qi", v16qi_ftype_long_pcvoid, 16914 def_builtin ("__builtin_altivec_lvxl_v16qi", v16qi_ftype_long_pcvoid,
17422 ALTIVEC_BUILTIN_LVXL_V16QI); 16915 ALTIVEC_BUILTIN_LVXL_V16QI);
17423 def_builtin ("__builtin_altivec_lvx", v4si_ftype_long_pcvoid, ALTIVEC_BUILTIN_LVX); 16916 def_builtin ("__builtin_altivec_lvx", v4si_ftype_long_pcvoid, ALTIVEC_BUILTIN_LVX);
16917 def_builtin ("__builtin_altivec_lvx_v1ti", v1ti_ftype_long_pcvoid,
16918 ALTIVEC_BUILTIN_LVX_V1TI);
17424 def_builtin ("__builtin_altivec_lvx_v2df", v2df_ftype_long_pcvoid, 16919 def_builtin ("__builtin_altivec_lvx_v2df", v2df_ftype_long_pcvoid,
17425 ALTIVEC_BUILTIN_LVX_V2DF); 16920 ALTIVEC_BUILTIN_LVX_V2DF);
17426 def_builtin ("__builtin_altivec_lvx_v2di", v2di_ftype_long_pcvoid, 16921 def_builtin ("__builtin_altivec_lvx_v2di", v2di_ftype_long_pcvoid,
17427 ALTIVEC_BUILTIN_LVX_V2DI); 16922 ALTIVEC_BUILTIN_LVX_V2DI);
17428 def_builtin ("__builtin_altivec_lvx_v4sf", v4sf_ftype_long_pcvoid, 16923 def_builtin ("__builtin_altivec_lvx_v4sf", v4sf_ftype_long_pcvoid,
17508 VSX_BUILTIN_LD_ELEMREV_V2DI); 17003 VSX_BUILTIN_LD_ELEMREV_V2DI);
17509 def_builtin ("__builtin_vsx_ld_elemrev_v4sf", v4sf_ftype_long_pcvoid, 17004 def_builtin ("__builtin_vsx_ld_elemrev_v4sf", v4sf_ftype_long_pcvoid,
17510 VSX_BUILTIN_LD_ELEMREV_V4SF); 17005 VSX_BUILTIN_LD_ELEMREV_V4SF);
17511 def_builtin ("__builtin_vsx_ld_elemrev_v4si", v4si_ftype_long_pcvoid, 17006 def_builtin ("__builtin_vsx_ld_elemrev_v4si", v4si_ftype_long_pcvoid,
17512 VSX_BUILTIN_LD_ELEMREV_V4SI); 17007 VSX_BUILTIN_LD_ELEMREV_V4SI);
17008 def_builtin ("__builtin_vsx_ld_elemrev_v8hi", v8hi_ftype_long_pcvoid,
17009 VSX_BUILTIN_LD_ELEMREV_V8HI);
17010 def_builtin ("__builtin_vsx_ld_elemrev_v16qi", v16qi_ftype_long_pcvoid,
17011 VSX_BUILTIN_LD_ELEMREV_V16QI);
17513 def_builtin ("__builtin_vsx_st_elemrev_v2df", void_ftype_v2df_long_pvoid, 17012 def_builtin ("__builtin_vsx_st_elemrev_v2df", void_ftype_v2df_long_pvoid,
17514 VSX_BUILTIN_ST_ELEMREV_V2DF); 17013 VSX_BUILTIN_ST_ELEMREV_V2DF);
17014 def_builtin ("__builtin_vsx_st_elemrev_v1ti", void_ftype_v1ti_long_pvoid,
17015 VSX_BUILTIN_ST_ELEMREV_V1TI);
17515 def_builtin ("__builtin_vsx_st_elemrev_v2di", void_ftype_v2di_long_pvoid, 17016 def_builtin ("__builtin_vsx_st_elemrev_v2di", void_ftype_v2di_long_pvoid,
17516 VSX_BUILTIN_ST_ELEMREV_V2DI); 17017 VSX_BUILTIN_ST_ELEMREV_V2DI);
17517 def_builtin ("__builtin_vsx_st_elemrev_v4sf", void_ftype_v4sf_long_pvoid, 17018 def_builtin ("__builtin_vsx_st_elemrev_v4sf", void_ftype_v4sf_long_pvoid,
17518 VSX_BUILTIN_ST_ELEMREV_V4SF); 17019 VSX_BUILTIN_ST_ELEMREV_V4SF);
17519 def_builtin ("__builtin_vsx_st_elemrev_v4si", void_ftype_v4si_long_pvoid, 17020 def_builtin ("__builtin_vsx_st_elemrev_v4si", void_ftype_v4si_long_pvoid,
17520 VSX_BUILTIN_ST_ELEMREV_V4SI); 17021 VSX_BUILTIN_ST_ELEMREV_V4SI);
17521 17022 def_builtin ("__builtin_vsx_st_elemrev_v8hi", void_ftype_v8hi_long_pvoid,
17522 def_builtin ("__builtin_vsx_le_be_v8hi", v8hi_ftype_long_pcvoid, 17023 VSX_BUILTIN_ST_ELEMREV_V8HI);
17523 VSX_BUILTIN_XL_BE_V8HI); 17024 def_builtin ("__builtin_vsx_st_elemrev_v16qi", void_ftype_v16qi_long_pvoid,
17524 def_builtin ("__builtin_vsx_le_be_v4si", v4si_ftype_long_pcvoid, 17025 VSX_BUILTIN_ST_ELEMREV_V16QI);
17525 VSX_BUILTIN_XL_BE_V4SI);
17526 def_builtin ("__builtin_vsx_le_be_v2di", v2di_ftype_long_pcvoid,
17527 VSX_BUILTIN_XL_BE_V2DI);
17528 def_builtin ("__builtin_vsx_le_be_v4sf", v4sf_ftype_long_pcvoid,
17529 VSX_BUILTIN_XL_BE_V4SF);
17530 def_builtin ("__builtin_vsx_le_be_v2df", v2df_ftype_long_pcvoid,
17531 VSX_BUILTIN_XL_BE_V2DF);
17532 def_builtin ("__builtin_vsx_le_be_v16qi", v16qi_ftype_long_pcvoid,
17533 VSX_BUILTIN_XL_BE_V16QI);
17534
17535 if (TARGET_P9_VECTOR)
17536 {
17537 def_builtin ("__builtin_vsx_ld_elemrev_v8hi", v8hi_ftype_long_pcvoid,
17538 VSX_BUILTIN_LD_ELEMREV_V8HI);
17539 def_builtin ("__builtin_vsx_ld_elemrev_v16qi", v16qi_ftype_long_pcvoid,
17540 VSX_BUILTIN_LD_ELEMREV_V16QI);
17541 def_builtin ("__builtin_vsx_st_elemrev_v8hi",
17542 void_ftype_v8hi_long_pvoid, VSX_BUILTIN_ST_ELEMREV_V8HI);
17543 def_builtin ("__builtin_vsx_st_elemrev_v16qi",
17544 void_ftype_v16qi_long_pvoid, VSX_BUILTIN_ST_ELEMREV_V16QI);
17545 }
17546 else
17547 {
17548 rs6000_builtin_decls[(int) VSX_BUILTIN_LD_ELEMREV_V8HI]
17549 = rs6000_builtin_decls[(int) VSX_BUILTIN_LXVW4X_V8HI];
17550 rs6000_builtin_decls[(int) VSX_BUILTIN_LD_ELEMREV_V16QI]
17551 = rs6000_builtin_decls[(int) VSX_BUILTIN_LXVW4X_V16QI];
17552 rs6000_builtin_decls[(int) VSX_BUILTIN_ST_ELEMREV_V8HI]
17553 = rs6000_builtin_decls[(int) VSX_BUILTIN_STXVW4X_V8HI];
17554 rs6000_builtin_decls[(int) VSX_BUILTIN_ST_ELEMREV_V16QI]
17555 = rs6000_builtin_decls[(int) VSX_BUILTIN_STXVW4X_V16QI];
17556 }
17557 17026
17558 def_builtin ("__builtin_vec_vsx_ld", opaque_ftype_long_pcvoid, 17027 def_builtin ("__builtin_vec_vsx_ld", opaque_ftype_long_pcvoid,
17559 VSX_BUILTIN_VEC_LD); 17028 VSX_BUILTIN_VEC_LD);
17560 def_builtin ("__builtin_vec_vsx_st", void_ftype_opaque_long_pvoid, 17029 def_builtin ("__builtin_vec_vsx_st", void_ftype_opaque_long_pvoid,
17561 VSX_BUILTIN_VEC_ST); 17030 VSX_BUILTIN_VEC_ST);
17563 VSX_BUILTIN_VEC_XL); 17032 VSX_BUILTIN_VEC_XL);
17564 def_builtin ("__builtin_vec_xl_be", opaque_ftype_long_pcvoid, 17033 def_builtin ("__builtin_vec_xl_be", opaque_ftype_long_pcvoid,
17565 VSX_BUILTIN_VEC_XL_BE); 17034 VSX_BUILTIN_VEC_XL_BE);
17566 def_builtin ("__builtin_vec_xst", void_ftype_opaque_long_pvoid, 17035 def_builtin ("__builtin_vec_xst", void_ftype_opaque_long_pvoid,
17567 VSX_BUILTIN_VEC_XST); 17036 VSX_BUILTIN_VEC_XST);
17037 def_builtin ("__builtin_vec_xst_be", void_ftype_opaque_long_pvoid,
17038 VSX_BUILTIN_VEC_XST_BE);
17568 17039
17569 def_builtin ("__builtin_vec_step", int_ftype_opaque, ALTIVEC_BUILTIN_VEC_STEP); 17040 def_builtin ("__builtin_vec_step", int_ftype_opaque, ALTIVEC_BUILTIN_VEC_STEP);
17570 def_builtin ("__builtin_vec_splats", opaque_ftype_opaque, ALTIVEC_BUILTIN_VEC_SPLATS); 17041 def_builtin ("__builtin_vec_splats", opaque_ftype_opaque, ALTIVEC_BUILTIN_VEC_SPLATS);
17571 def_builtin ("__builtin_vec_promote", opaque_ftype_opaque, ALTIVEC_BUILTIN_VEC_PROMOTE); 17042 def_builtin ("__builtin_vec_promote", opaque_ftype_opaque, ALTIVEC_BUILTIN_VEC_PROMOTE);
17572 17043
17863 NULL_TREE); 17334 NULL_TREE);
17864 tree void_ftype_v1ti_long_pvoid 17335 tree void_ftype_v1ti_long_pvoid
17865 = build_function_type_list (void_type_node, 17336 = build_function_type_list (void_type_node,
17866 V1TI_type_node, long_integer_type_node, 17337 V1TI_type_node, long_integer_type_node,
17867 pvoid_type_node, NULL_TREE); 17338 pvoid_type_node, NULL_TREE);
17339 def_builtin ("__builtin_vsx_ld_elemrev_v1ti", v1ti_ftype_long_pcvoid,
17340 VSX_BUILTIN_LD_ELEMREV_V1TI);
17868 def_builtin ("__builtin_vsx_lxvd2x_v1ti", v1ti_ftype_long_pcvoid, 17341 def_builtin ("__builtin_vsx_lxvd2x_v1ti", v1ti_ftype_long_pcvoid,
17869 VSX_BUILTIN_LXVD2X_V1TI); 17342 VSX_BUILTIN_LXVD2X_V1TI);
17870 def_builtin ("__builtin_vsx_stxvd2x_v1ti", void_ftype_v1ti_long_pvoid, 17343 def_builtin ("__builtin_vsx_stxvd2x_v1ti", void_ftype_v1ti_long_pvoid,
17871 VSX_BUILTIN_STXVD2X_V1TI); 17344 VSX_BUILTIN_STXVD2X_V1TI);
17872 ftype = build_function_type_list (V1TI_type_node, intTI_type_node, 17345 ftype = build_function_type_list (V1TI_type_node, intTI_type_node,
18046 arguments, and it is returned as a decl for the vectorizer (such as 17519 arguments, and it is returned as a decl for the vectorizer (such as
18047 widening multiplies, permute), make sure the arguments and return value 17520 widening multiplies, permute), make sure the arguments and return value
18048 are type correct. */ 17521 are type correct. */
18049 switch (builtin) 17522 switch (builtin)
18050 { 17523 {
18051 /* unsigned 1 argument functions. */ 17524 /* unsigned 1 argument functions. */
18052 case CRYPTO_BUILTIN_VSBOX: 17525 case CRYPTO_BUILTIN_VSBOX:
18053 case P8V_BUILTIN_VGBBD: 17526 case P8V_BUILTIN_VGBBD:
18054 case MISC_BUILTIN_CDTBCD: 17527 case MISC_BUILTIN_CDTBCD:
18055 case MISC_BUILTIN_CBCDTD: 17528 case MISC_BUILTIN_CBCDTD:
18056 h.uns_p[0] = 1; 17529 h.uns_p[0] = 1;
18057 h.uns_p[1] = 1; 17530 h.uns_p[1] = 1;
18058 break; 17531 break;
18059 17532
18060 /* unsigned 2 argument functions. */ 17533 /* unsigned 2 argument functions. */
18061 case ALTIVEC_BUILTIN_VMULEUB: 17534 case ALTIVEC_BUILTIN_VMULEUB:
18062 case ALTIVEC_BUILTIN_VMULEUH: 17535 case ALTIVEC_BUILTIN_VMULEUH:
18063 case ALTIVEC_BUILTIN_VMULEUW: 17536 case P8V_BUILTIN_VMULEUW:
18064 case ALTIVEC_BUILTIN_VMULOUB: 17537 case ALTIVEC_BUILTIN_VMULOUB:
18065 case ALTIVEC_BUILTIN_VMULOUH: 17538 case ALTIVEC_BUILTIN_VMULOUH:
18066 case ALTIVEC_BUILTIN_VMULOUW: 17539 case P8V_BUILTIN_VMULOUW:
18067 case CRYPTO_BUILTIN_VCIPHER: 17540 case CRYPTO_BUILTIN_VCIPHER:
18068 case CRYPTO_BUILTIN_VCIPHERLAST: 17541 case CRYPTO_BUILTIN_VCIPHERLAST:
18069 case CRYPTO_BUILTIN_VNCIPHER: 17542 case CRYPTO_BUILTIN_VNCIPHER:
18070 case CRYPTO_BUILTIN_VNCIPHERLAST: 17543 case CRYPTO_BUILTIN_VNCIPHERLAST:
18071 case CRYPTO_BUILTIN_VPMSUMB: 17544 case CRYPTO_BUILTIN_VPMSUMB:
18073 case CRYPTO_BUILTIN_VPMSUMW: 17546 case CRYPTO_BUILTIN_VPMSUMW:
18074 case CRYPTO_BUILTIN_VPMSUMD: 17547 case CRYPTO_BUILTIN_VPMSUMD:
18075 case CRYPTO_BUILTIN_VPMSUM: 17548 case CRYPTO_BUILTIN_VPMSUM:
18076 case MISC_BUILTIN_ADDG6S: 17549 case MISC_BUILTIN_ADDG6S:
18077 case MISC_BUILTIN_DIVWEU: 17550 case MISC_BUILTIN_DIVWEU:
18078 case MISC_BUILTIN_DIVWEUO:
18079 case MISC_BUILTIN_DIVDEU: 17551 case MISC_BUILTIN_DIVDEU:
18080 case MISC_BUILTIN_DIVDEUO:
18081 case VSX_BUILTIN_UDIV_V2DI: 17552 case VSX_BUILTIN_UDIV_V2DI:
18082 case ALTIVEC_BUILTIN_VMAXUB: 17553 case ALTIVEC_BUILTIN_VMAXUB:
18083 case ALTIVEC_BUILTIN_VMINUB: 17554 case ALTIVEC_BUILTIN_VMINUB:
18084 case ALTIVEC_BUILTIN_VMAXUH: 17555 case ALTIVEC_BUILTIN_VMAXUH:
18085 case ALTIVEC_BUILTIN_VMINUH: 17556 case ALTIVEC_BUILTIN_VMINUH:
18090 h.uns_p[0] = 1; 17561 h.uns_p[0] = 1;
18091 h.uns_p[1] = 1; 17562 h.uns_p[1] = 1;
18092 h.uns_p[2] = 1; 17563 h.uns_p[2] = 1;
18093 break; 17564 break;
18094 17565
18095 /* unsigned 3 argument functions. */ 17566 /* unsigned 3 argument functions. */
18096 case ALTIVEC_BUILTIN_VPERM_16QI_UNS: 17567 case ALTIVEC_BUILTIN_VPERM_16QI_UNS:
18097 case ALTIVEC_BUILTIN_VPERM_8HI_UNS: 17568 case ALTIVEC_BUILTIN_VPERM_8HI_UNS:
18098 case ALTIVEC_BUILTIN_VPERM_4SI_UNS: 17569 case ALTIVEC_BUILTIN_VPERM_4SI_UNS:
18099 case ALTIVEC_BUILTIN_VPERM_2DI_UNS: 17570 case ALTIVEC_BUILTIN_VPERM_2DI_UNS:
18100 case ALTIVEC_BUILTIN_VSEL_16QI_UNS: 17571 case ALTIVEC_BUILTIN_VSEL_16QI_UNS:
18121 h.uns_p[1] = 1; 17592 h.uns_p[1] = 1;
18122 h.uns_p[2] = 1; 17593 h.uns_p[2] = 1;
18123 h.uns_p[3] = 1; 17594 h.uns_p[3] = 1;
18124 break; 17595 break;
18125 17596
18126 /* signed permute functions with unsigned char mask. */ 17597 /* signed permute functions with unsigned char mask. */
18127 case ALTIVEC_BUILTIN_VPERM_16QI: 17598 case ALTIVEC_BUILTIN_VPERM_16QI:
18128 case ALTIVEC_BUILTIN_VPERM_8HI: 17599 case ALTIVEC_BUILTIN_VPERM_8HI:
18129 case ALTIVEC_BUILTIN_VPERM_4SI: 17600 case ALTIVEC_BUILTIN_VPERM_4SI:
18130 case ALTIVEC_BUILTIN_VPERM_4SF: 17601 case ALTIVEC_BUILTIN_VPERM_4SF:
18131 case ALTIVEC_BUILTIN_VPERM_2DI: 17602 case ALTIVEC_BUILTIN_VPERM_2DI:
18137 case VSX_BUILTIN_VPERM_2DI: 17608 case VSX_BUILTIN_VPERM_2DI:
18138 case VSX_BUILTIN_VPERM_2DF: 17609 case VSX_BUILTIN_VPERM_2DF:
18139 h.uns_p[3] = 1; 17610 h.uns_p[3] = 1;
18140 break; 17611 break;
18141 17612
18142 /* unsigned args, signed return. */ 17613 /* unsigned args, signed return. */
18143 case VSX_BUILTIN_XVCVUXDSP: 17614 case VSX_BUILTIN_XVCVUXDSP:
18144 case VSX_BUILTIN_XVCVUXDDP_UNS: 17615 case VSX_BUILTIN_XVCVUXDDP_UNS:
18145 case ALTIVEC_BUILTIN_UNSFLOAT_V4SI_V4SF: 17616 case ALTIVEC_BUILTIN_UNSFLOAT_V4SI_V4SF:
18146 h.uns_p[1] = 1; 17617 h.uns_p[1] = 1;
18147 break; 17618 break;
18148 17619
18149 /* signed args, unsigned return. */ 17620 /* signed args, unsigned return. */
18150 case VSX_BUILTIN_XVCVDPUXDS_UNS: 17621 case VSX_BUILTIN_XVCVDPUXDS_UNS:
18151 case ALTIVEC_BUILTIN_FIXUNS_V4SF_V4SI: 17622 case ALTIVEC_BUILTIN_FIXUNS_V4SF_V4SI:
18152 case MISC_BUILTIN_UNPACK_TD: 17623 case MISC_BUILTIN_UNPACK_TD:
18153 case MISC_BUILTIN_UNPACK_V1TI: 17624 case MISC_BUILTIN_UNPACK_V1TI:
18154 h.uns_p[0] = 1; 17625 h.uns_p[0] = 1;
18155 break; 17626 break;
18156 17627
18157 /* unsigned arguments for 128-bit pack instructions. */ 17628 /* unsigned arguments, bool return (compares). */
17629 case ALTIVEC_BUILTIN_VCMPEQUB:
17630 case ALTIVEC_BUILTIN_VCMPEQUH:
17631 case ALTIVEC_BUILTIN_VCMPEQUW:
17632 case P8V_BUILTIN_VCMPEQUD:
17633 case VSX_BUILTIN_CMPGE_U16QI:
17634 case VSX_BUILTIN_CMPGE_U8HI:
17635 case VSX_BUILTIN_CMPGE_U4SI:
17636 case VSX_BUILTIN_CMPGE_U2DI:
17637 case ALTIVEC_BUILTIN_VCMPGTUB:
17638 case ALTIVEC_BUILTIN_VCMPGTUH:
17639 case ALTIVEC_BUILTIN_VCMPGTUW:
17640 case P8V_BUILTIN_VCMPGTUD:
17641 h.uns_p[1] = 1;
17642 h.uns_p[2] = 1;
17643 break;
17644
17645 /* unsigned arguments for 128-bit pack instructions. */
18158 case MISC_BUILTIN_PACK_TD: 17646 case MISC_BUILTIN_PACK_TD:
18159 case MISC_BUILTIN_PACK_V1TI: 17647 case MISC_BUILTIN_PACK_V1TI:
18160 h.uns_p[1] = 1; 17648 h.uns_p[1] = 1;
18161 h.uns_p[2] = 1; 17649 h.uns_p[2] = 1;
18162 break; 17650 break;
18163 17651
18164 /* unsigned second arguments (vector shift right). */ 17652 /* unsigned second arguments (vector shift right). */
18165 case ALTIVEC_BUILTIN_VSRB: 17653 case ALTIVEC_BUILTIN_VSRB:
18166 case ALTIVEC_BUILTIN_VSRH: 17654 case ALTIVEC_BUILTIN_VSRH:
18167 case ALTIVEC_BUILTIN_VSRW: 17655 case ALTIVEC_BUILTIN_VSRW:
18168 case P8V_BUILTIN_VSRD: 17656 case P8V_BUILTIN_VSRD:
18169 h.uns_p[2] = 1; 17657 h.uns_p[2] = 1;
18226 size_t i; 17714 size_t i;
18227 17715
18228 tree opaque_ftype_opaque = NULL_TREE; 17716 tree opaque_ftype_opaque = NULL_TREE;
18229 tree opaque_ftype_opaque_opaque = NULL_TREE; 17717 tree opaque_ftype_opaque_opaque = NULL_TREE;
18230 tree opaque_ftype_opaque_opaque_opaque = NULL_TREE; 17718 tree opaque_ftype_opaque_opaque_opaque = NULL_TREE;
18231 tree v2si_ftype = NULL_TREE;
18232 tree v2si_ftype_qi = NULL_TREE;
18233 tree v2si_ftype_v2si_qi = NULL_TREE;
18234 tree v2si_ftype_int_qi = NULL_TREE;
18235 HOST_WIDE_INT builtin_mask = rs6000_builtin_mask; 17719 HOST_WIDE_INT builtin_mask = rs6000_builtin_mask;
18236 17720
18237 if (!TARGET_PAIRED_FLOAT) 17721 /* Create Altivec and VSX builtins on machines with at least the
18238 { 17722 general purpose extensions (970 and newer) to allow the use of
18239 builtin_mode_to_type[V2SImode][0] = opaque_V2SI_type_node; 17723 the target attribute. */
18240 builtin_mode_to_type[V2SFmode][0] = opaque_V2SF_type_node;
18241 }
18242
18243 /* Paired builtins are only available if you build a compiler with the
18244 appropriate options, so only create those builtins with the appropriate
18245 compiler option. Create Altivec and VSX builtins on machines with at
18246 least the general purpose extensions (970 and newer) to allow the use of
18247 the target attribute.. */
18248 17724
18249 if (TARGET_EXTRA_BUILTINS) 17725 if (TARGET_EXTRA_BUILTINS)
18250 builtin_mask |= RS6000_BTM_COMMON; 17726 builtin_mask |= RS6000_BTM_COMMON;
18251 17727
18252 /* Add the ternary operators. */ 17728 /* Add the ternary operators. */
18351 17827
18352 mode0 = insn_data[icode].operand[0].mode; 17828 mode0 = insn_data[icode].operand[0].mode;
18353 mode1 = insn_data[icode].operand[1].mode; 17829 mode1 = insn_data[icode].operand[1].mode;
18354 mode2 = insn_data[icode].operand[2].mode; 17830 mode2 = insn_data[icode].operand[2].mode;
18355 17831
18356 if (mode0 == V2SImode && mode1 == V2SImode && mode2 == QImode) 17832 type = builtin_function_type (mode0, mode1, mode2, VOIDmode,
18357 { 17833 d->code, d->name);
18358 if (! (type = v2si_ftype_v2si_qi))
18359 type = v2si_ftype_v2si_qi
18360 = build_function_type_list (opaque_V2SI_type_node,
18361 opaque_V2SI_type_node,
18362 char_type_node,
18363 NULL_TREE);
18364 }
18365
18366 else if (mode0 == V2SImode && GET_MODE_CLASS (mode1) == MODE_INT
18367 && mode2 == QImode)
18368 {
18369 if (! (type = v2si_ftype_int_qi))
18370 type = v2si_ftype_int_qi
18371 = build_function_type_list (opaque_V2SI_type_node,
18372 integer_type_node,
18373 char_type_node,
18374 NULL_TREE);
18375 }
18376
18377 else
18378 type = builtin_function_type (mode0, mode1, mode2, VOIDmode,
18379 d->code, d->name);
18380 } 17834 }
18381 17835
18382 def_builtin (d->name, type, d->code); 17836 def_builtin (d->name, type, d->code);
18383 } 17837 }
18384 17838
18427 } 17881 }
18428 17882
18429 mode0 = insn_data[icode].operand[0].mode; 17883 mode0 = insn_data[icode].operand[0].mode;
18430 mode1 = insn_data[icode].operand[1].mode; 17884 mode1 = insn_data[icode].operand[1].mode;
18431 17885
18432 if (mode0 == V2SImode && mode1 == QImode) 17886 type = builtin_function_type (mode0, mode1, VOIDmode, VOIDmode,
18433 { 17887 d->code, d->name);
18434 if (! (type = v2si_ftype_qi))
18435 type = v2si_ftype_qi
18436 = build_function_type_list (opaque_V2SI_type_node,
18437 char_type_node,
18438 NULL_TREE);
18439 }
18440
18441 else
18442 type = builtin_function_type (mode0, mode1, VOIDmode, VOIDmode,
18443 d->code, d->name);
18444 } 17888 }
18445 17889
18446 def_builtin (d->name, type, d->code); 17890 def_builtin (d->name, type, d->code);
18447 } 17891 }
18448 17892
18484 "rs6000_builtin, skip no-argument %s (no code)\n", 17928 "rs6000_builtin, skip no-argument %s (no code)\n",
18485 d->name); 17929 d->name);
18486 continue; 17930 continue;
18487 } 17931 }
18488 mode0 = insn_data[icode].operand[0].mode; 17932 mode0 = insn_data[icode].operand[0].mode;
18489 if (mode0 == V2SImode) 17933 type = builtin_function_type (mode0, VOIDmode, VOIDmode, VOIDmode,
18490 { 17934 d->code, d->name);
18491 /* code for paired single */
18492 if (! (type = v2si_ftype))
18493 {
18494 v2si_ftype
18495 = build_function_type_list (opaque_V2SI_type_node,
18496 NULL_TREE);
18497 type = v2si_ftype;
18498 }
18499 }
18500 else
18501 type = builtin_function_type (mode0, VOIDmode, VOIDmode, VOIDmode,
18502 d->code, d->name);
18503 } 17935 }
18504 def_builtin (d->name, type, d->code); 17936 def_builtin (d->name, type, d->code);
18505 } 17937 }
18506 } 17938 }
18507 17939
18547 17979
18548 /* Add various conversions for IFmode to use the traditional TFmode 17980 /* Add various conversions for IFmode to use the traditional TFmode
18549 names. */ 17981 names. */
18550 if (mode == IFmode) 17982 if (mode == IFmode)
18551 { 17983 {
18552 set_conv_libfunc (sext_optab, mode, SDmode, "__dpd_extendsdtf2"); 17984 set_conv_libfunc (sext_optab, mode, SDmode, "__dpd_extendsdtf");
18553 set_conv_libfunc (sext_optab, mode, DDmode, "__dpd_extendddtf2"); 17985 set_conv_libfunc (sext_optab, mode, DDmode, "__dpd_extendddtf");
18554 set_conv_libfunc (trunc_optab, mode, TDmode, "__dpd_trunctftd2"); 17986 set_conv_libfunc (trunc_optab, mode, TDmode, "__dpd_trunctdtf");
18555 set_conv_libfunc (trunc_optab, SDmode, mode, "__dpd_trunctfsd2"); 17987 set_conv_libfunc (trunc_optab, SDmode, mode, "__dpd_trunctfsd");
18556 set_conv_libfunc (trunc_optab, DDmode, mode, "__dpd_trunctfdd2"); 17988 set_conv_libfunc (trunc_optab, DDmode, mode, "__dpd_trunctfdd");
18557 set_conv_libfunc (sext_optab, TDmode, mode, "__dpd_extendtdtf2"); 17989 set_conv_libfunc (sext_optab, TDmode, mode, "__dpd_extendtftd");
18558 17990
18559 if (TARGET_POWERPC64) 17991 if (TARGET_POWERPC64)
18560 { 17992 {
18561 set_conv_libfunc (sfix_optab, TImode, mode, "__fixtfti"); 17993 set_conv_libfunc (sfix_optab, TImode, mode, "__fixtfti");
18562 set_conv_libfunc (ufix_optab, TImode, mode, "__fixunstfti"); 17994 set_conv_libfunc (ufix_optab, TImode, mode, "__fixunstfti");
18563 set_conv_libfunc (sfloat_optab, mode, TImode, "__floattitf"); 17995 set_conv_libfunc (sfloat_optab, mode, TImode, "__floattitf");
18564 set_conv_libfunc (ufloat_optab, mode, TImode, "__floatuntitf"); 17996 set_conv_libfunc (ufloat_optab, mode, TImode, "__floatuntitf");
18565 } 17997 }
18566 } 17998 }
17999 }
18000
18001 /* Create a decl for either complex long double multiply or complex long double
18002 divide when long double is IEEE 128-bit floating point. We can't use
18003 __multc3 and __divtc3 because the original long double using IBM extended
18004 double used those names. The complex multiply/divide functions are encoded
18005 as builtin functions with a complex result and 4 scalar inputs. */
18006
18007 static void
18008 create_complex_muldiv (const char *name, built_in_function fncode, tree fntype)
18009 {
18010 tree fndecl = add_builtin_function (name, fntype, fncode, BUILT_IN_NORMAL,
18011 name, NULL_TREE);
18012
18013 set_builtin_decl (fncode, fndecl, true);
18014
18015 if (TARGET_DEBUG_BUILTIN)
18016 fprintf (stderr, "create complex %s, fncode: %d\n", name, (int) fncode);
18017
18018 return;
18567 } 18019 }
18568 18020
18569 /* Set up IEEE 128-bit floating point routines. Use different names if the 18021 /* Set up IEEE 128-bit floating point routines. Use different names if the
18570 arguments can be passed in a vector register. The historical PowerPC 18022 arguments can be passed in a vector register. The historical PowerPC
18571 implementation of IEEE 128-bit floating point used _q_<op> for the names, so 18023 implementation of IEEE 128-bit floating point used _q_<op> for the names, so
18575 static void 18027 static void
18576 init_float128_ieee (machine_mode mode) 18028 init_float128_ieee (machine_mode mode)
18577 { 18029 {
18578 if (FLOAT128_VECTOR_P (mode)) 18030 if (FLOAT128_VECTOR_P (mode))
18579 { 18031 {
18032 static bool complex_muldiv_init_p = false;
18033
18034 /* Set up to call __mulkc3 and __divkc3 under -mabi=ieeelongdouble. If
18035 we have clone or target attributes, this will be called a second
18036 time. We want to create the built-in function only once. */
18037 if (mode == TFmode && TARGET_IEEEQUAD && !complex_muldiv_init_p)
18038 {
18039 complex_muldiv_init_p = true;
18040 built_in_function fncode_mul =
18041 (built_in_function) (BUILT_IN_COMPLEX_MUL_MIN + TCmode
18042 - MIN_MODE_COMPLEX_FLOAT);
18043 built_in_function fncode_div =
18044 (built_in_function) (BUILT_IN_COMPLEX_DIV_MIN + TCmode
18045 - MIN_MODE_COMPLEX_FLOAT);
18046
18047 tree fntype = build_function_type_list (complex_long_double_type_node,
18048 long_double_type_node,
18049 long_double_type_node,
18050 long_double_type_node,
18051 long_double_type_node,
18052 NULL_TREE);
18053
18054 create_complex_muldiv ("__mulkc3", fncode_mul, fntype);
18055 create_complex_muldiv ("__divkc3", fncode_div, fntype);
18056 }
18057
18580 set_optab_libfunc (add_optab, mode, "__addkf3"); 18058 set_optab_libfunc (add_optab, mode, "__addkf3");
18581 set_optab_libfunc (sub_optab, mode, "__subkf3"); 18059 set_optab_libfunc (sub_optab, mode, "__subkf3");
18582 set_optab_libfunc (neg_optab, mode, "__negkf2"); 18060 set_optab_libfunc (neg_optab, mode, "__negkf2");
18583 set_optab_libfunc (smul_optab, mode, "__mulkf3"); 18061 set_optab_libfunc (smul_optab, mode, "__mulkf3");
18584 set_optab_libfunc (sdiv_optab, mode, "__divkf3"); 18062 set_optab_libfunc (sdiv_optab, mode, "__divkf3");
18585 set_optab_libfunc (sqrt_optab, mode, "__sqrtkf2"); 18063 set_optab_libfunc (sqrt_optab, mode, "__sqrtkf2");
18586 set_optab_libfunc (abs_optab, mode, "__abstkf2"); 18064 set_optab_libfunc (abs_optab, mode, "__abskf2");
18065 set_optab_libfunc (powi_optab, mode, "__powikf2");
18587 18066
18588 set_optab_libfunc (eq_optab, mode, "__eqkf2"); 18067 set_optab_libfunc (eq_optab, mode, "__eqkf2");
18589 set_optab_libfunc (ne_optab, mode, "__nekf2"); 18068 set_optab_libfunc (ne_optab, mode, "__nekf2");
18590 set_optab_libfunc (gt_optab, mode, "__gtkf2"); 18069 set_optab_libfunc (gt_optab, mode, "__gtkf2");
18591 set_optab_libfunc (ge_optab, mode, "__gekf2"); 18070 set_optab_libfunc (ge_optab, mode, "__gekf2");
18596 set_conv_libfunc (sext_optab, mode, SFmode, "__extendsfkf2"); 18075 set_conv_libfunc (sext_optab, mode, SFmode, "__extendsfkf2");
18597 set_conv_libfunc (sext_optab, mode, DFmode, "__extenddfkf2"); 18076 set_conv_libfunc (sext_optab, mode, DFmode, "__extenddfkf2");
18598 set_conv_libfunc (trunc_optab, SFmode, mode, "__trunckfsf2"); 18077 set_conv_libfunc (trunc_optab, SFmode, mode, "__trunckfsf2");
18599 set_conv_libfunc (trunc_optab, DFmode, mode, "__trunckfdf2"); 18078 set_conv_libfunc (trunc_optab, DFmode, mode, "__trunckfdf2");
18600 18079
18601 set_conv_libfunc (sext_optab, mode, IFmode, "__extendtfkf2"); 18080 set_conv_libfunc (sext_optab, mode, IFmode, "__trunctfkf2");
18602 if (mode != TFmode && FLOAT128_IBM_P (TFmode)) 18081 if (mode != TFmode && FLOAT128_IBM_P (TFmode))
18603 set_conv_libfunc (sext_optab, mode, TFmode, "__extendtfkf2"); 18082 set_conv_libfunc (sext_optab, mode, TFmode, "__trunctfkf2");
18604 18083
18605 set_conv_libfunc (trunc_optab, IFmode, mode, "__trunckftf2"); 18084 set_conv_libfunc (trunc_optab, IFmode, mode, "__extendkftf2");
18606 if (mode != TFmode && FLOAT128_IBM_P (TFmode)) 18085 if (mode != TFmode && FLOAT128_IBM_P (TFmode))
18607 set_conv_libfunc (trunc_optab, TFmode, mode, "__trunckftf2"); 18086 set_conv_libfunc (trunc_optab, TFmode, mode, "__extendkftf2");
18608 18087
18609 set_conv_libfunc (sext_optab, mode, SDmode, "__dpd_extendsdkf2"); 18088 set_conv_libfunc (sext_optab, mode, SDmode, "__dpd_extendsdkf");
18610 set_conv_libfunc (sext_optab, mode, DDmode, "__dpd_extendddkf2"); 18089 set_conv_libfunc (sext_optab, mode, DDmode, "__dpd_extendddkf");
18611 set_conv_libfunc (trunc_optab, mode, TDmode, "__dpd_trunckftd2"); 18090 set_conv_libfunc (trunc_optab, mode, TDmode, "__dpd_trunctdkf");
18612 set_conv_libfunc (trunc_optab, SDmode, mode, "__dpd_trunckfsd2"); 18091 set_conv_libfunc (trunc_optab, SDmode, mode, "__dpd_trunckfsd");
18613 set_conv_libfunc (trunc_optab, DDmode, mode, "__dpd_trunckfdd2"); 18092 set_conv_libfunc (trunc_optab, DDmode, mode, "__dpd_trunckfdd");
18614 set_conv_libfunc (sext_optab, TDmode, mode, "__dpd_extendtdkf2"); 18093 set_conv_libfunc (sext_optab, TDmode, mode, "__dpd_extendkftd");
18615 18094
18616 set_conv_libfunc (sfix_optab, SImode, mode, "__fixkfsi"); 18095 set_conv_libfunc (sfix_optab, SImode, mode, "__fixkfsi");
18617 set_conv_libfunc (ufix_optab, SImode, mode, "__fixunskfsi"); 18096 set_conv_libfunc (ufix_optab, SImode, mode, "__fixunskfsi");
18618 set_conv_libfunc (sfix_optab, DImode, mode, "__fixkfdi"); 18097 set_conv_libfunc (sfix_optab, DImode, mode, "__fixkfdi");
18619 set_conv_libfunc (ufix_optab, DImode, mode, "__fixunskfdi"); 18098 set_conv_libfunc (ufix_optab, DImode, mode, "__fixunskfdi");
20295 emit_insn (gen_rtx_SET (scratch, addr)); 19774 emit_insn (gen_rtx_SET (scratch, addr));
20296 new_addr = scratch; 19775 new_addr = scratch;
20297 } 19776 }
20298 } 19777 }
20299 19778
20300 else if (mode_supports_vsx_dform_quad (mode) && CONST_INT_P (op1)) 19779 else if (mode_supports_dq_form (mode) && CONST_INT_P (op1))
20301 { 19780 {
20302 if (((addr_mask & RELOAD_REG_QUAD_OFFSET) == 0) 19781 if (((addr_mask & RELOAD_REG_QUAD_OFFSET) == 0)
20303 || !quad_address_p (addr, mode, false)) 19782 || !quad_address_p (addr, mode, false))
20304 { 19783 {
20305 emit_insn (gen_rtx_SET (scratch, addr)); 19784 emit_insn (gen_rtx_SET (scratch, addr));
20336 new_addr = scratch; 19815 new_addr = scratch;
20337 } 19816 }
20338 } 19817 }
20339 19818
20340 /* Quad offsets are restricted and can't handle normal addresses. */ 19819 /* Quad offsets are restricted and can't handle normal addresses. */
20341 else if (mode_supports_vsx_dform_quad (mode)) 19820 else if (mode_supports_dq_form (mode))
20342 { 19821 {
20343 emit_insn (gen_rtx_SET (scratch, addr)); 19822 emit_insn (gen_rtx_SET (scratch, addr));
20344 new_addr = scratch; 19823 new_addr = scratch;
20345 } 19824 }
20346 19825
20531 return NO_REGS; 20010 return NO_REGS;
20532 } 20011 }
20533 20012
20534 /* D-form addressing can easily reload the value. */ 20013 /* D-form addressing can easily reload the value. */
20535 if (mode_supports_vmx_dform (mode) 20014 if (mode_supports_vmx_dform (mode)
20536 || mode_supports_vsx_dform_quad (mode)) 20015 || mode_supports_dq_form (mode))
20537 return rclass; 20016 return rclass;
20538 20017
20539 /* If this is a scalar floating point value and we don't have D-form 20018 /* If this is a scalar floating point value and we don't have D-form
20540 addressing, prefer the traditional floating point registers so that we 20019 addressing, prefer the traditional floating point registers so that we
20541 can use D-form (register+offset) addressing. */ 20020 can use D-form (register+offset) addressing. */
20934 && altivec_indexed_or_indirect_operand (src, mode)) 20413 && altivec_indexed_or_indirect_operand (src, mode))
20935 return "lvx %0,%y1"; 20414 return "lvx %0,%y1";
20936 20415
20937 else if (TARGET_VSX && dest_vsx_p) 20416 else if (TARGET_VSX && dest_vsx_p)
20938 { 20417 {
20939 if (mode_supports_vsx_dform_quad (mode) 20418 if (mode_supports_dq_form (mode)
20940 && quad_address_p (XEXP (src, 0), mode, true)) 20419 && quad_address_p (XEXP (src, 0), mode, true))
20941 return "lxv %x0,%1"; 20420 return "lxv %x0,%1";
20942 20421
20943 else if (TARGET_P9_VECTOR) 20422 else if (TARGET_P9_VECTOR)
20944 return "lxvx %x0,%y1"; 20423 return "lxvx %x0,%y1";
20967 else 20446 else
20968 return "#"; 20447 return "#";
20969 } 20448 }
20970 20449
20971 else if (TARGET_ALTIVEC && src_vmx_p 20450 else if (TARGET_ALTIVEC && src_vmx_p
20972 && altivec_indexed_or_indirect_operand (src, mode)) 20451 && altivec_indexed_or_indirect_operand (dest, mode))
20973 return "stvx %1,%y0"; 20452 return "stvx %1,%y0";
20974 20453
20975 else if (TARGET_VSX && src_vsx_p) 20454 else if (TARGET_VSX && src_vsx_p)
20976 { 20455 {
20977 if (mode_supports_vsx_dform_quad (mode) 20456 if (mode_supports_dq_form (mode)
20978 && quad_address_p (XEXP (dest, 0), mode, true)) 20457 && quad_address_p (XEXP (dest, 0), mode, true))
20979 return "stxv %x1,%0"; 20458 return "stxv %x1,%0";
20980 20459
20981 else if (TARGET_P9_VECTOR) 20460 else if (TARGET_P9_VECTOR)
20982 return "stxvx %x1,%y0"; 20461 return "stxvx %x1,%y0";
21164 } 20643 }
21165 20644
21166 /* Print an operand. Recognize special options, documented below. */ 20645 /* Print an operand. Recognize special options, documented below. */
21167 20646
21168 #if TARGET_ELF 20647 #if TARGET_ELF
20648 /* Access to .sdata2 through r2 (see -msdata=eabi in invoke.texi) is
20649 only introduced by the linker, when applying the sda21
20650 relocation. */
21169 #define SMALL_DATA_RELOC ((rs6000_sdata == SDATA_EABI) ? "sda21" : "sdarel") 20651 #define SMALL_DATA_RELOC ((rs6000_sdata == SDATA_EABI) ? "sda21" : "sdarel")
21170 #define SMALL_DATA_REG ((rs6000_sdata == SDATA_EABI) ? 0 : 13) 20652 #define SMALL_DATA_REG ((rs6000_sdata == SDATA_EABI) ? 0 : 13)
21171 #else 20653 #else
21172 #define SMALL_DATA_RELOC "sda21" 20654 #define SMALL_DATA_RELOC "sda21"
21173 #define SMALL_DATA_REG 0 20655 #define SMALL_DATA_REG 0
21344 fprintf (file, "@%s(%s)", SMALL_DATA_RELOC, 20826 fprintf (file, "@%s(%s)", SMALL_DATA_RELOC,
21345 reg_names[SMALL_DATA_REG]); 20827 reg_names[SMALL_DATA_REG]);
21346 } 20828 }
21347 return; 20829 return;
21348 20830
21349 case 'N': 20831 case 'N': /* Unused */
21350 /* Write the number of elements in the vector times 4. */ 20832 /* Write the number of elements in the vector times 4. */
21351 if (GET_CODE (x) != PARALLEL) 20833 if (GET_CODE (x) != PARALLEL)
21352 output_operand_lossage ("invalid %%N value"); 20834 output_operand_lossage ("invalid %%N value");
21353 else 20835 else
21354 fprintf (file, "%d", XVECLEN (x, 0) * 4); 20836 fprintf (file, "%d", XVECLEN (x, 0) * 4);
21355 return; 20837 return;
21356 20838
21357 case 'O': 20839 case 'O': /* Unused */
21358 /* Similar, but subtract 1 first. */ 20840 /* Similar, but subtract 1 first. */
21359 if (GET_CODE (x) != PARALLEL) 20841 if (GET_CODE (x) != PARALLEL)
21360 output_operand_lossage ("invalid %%O value"); 20842 output_operand_lossage ("invalid %%O value");
21361 else 20843 else
21362 fprintf (file, "%d", (XVECLEN (x, 0) - 1) * 4); 20844 fprintf (file, "%d", (XVECLEN (x, 0) - 1) * 4);
21652 21134
21653 gcc_assert (MEM_P (x)); 21135 gcc_assert (MEM_P (x));
21654 21136
21655 tmp = XEXP (x, 0); 21137 tmp = XEXP (x, 0);
21656 21138
21657 if (VECTOR_MEM_ALTIVEC_P (GET_MODE (x)) 21139 if (VECTOR_MEM_ALTIVEC_OR_VSX_P (GET_MODE (x))
21658 && GET_CODE (tmp) == AND 21140 && GET_CODE (tmp) == AND
21659 && GET_CODE (XEXP (tmp, 1)) == CONST_INT 21141 && GET_CODE (XEXP (tmp, 1)) == CONST_INT
21660 && INTVAL (XEXP (tmp, 1)) == -16) 21142 && INTVAL (XEXP (tmp, 1)) == -16)
21661 tmp = XEXP (tmp, 0); 21143 tmp = XEXP (tmp, 0);
21662 else if (VECTOR_MEM_VSX_P (GET_MODE (x)) 21144 else if (VECTOR_MEM_VSX_P (GET_MODE (x))
21792 fprintf (file, "@l(%s)", reg_names[REGNO (XEXP (x, 0))]); 21274 fprintf (file, "@l(%s)", reg_names[REGNO (XEXP (x, 0))]);
21793 else 21275 else
21794 fprintf (file, "(%s)", reg_names[REGNO (XVECEXP (tocrel_base_oac, 0, 1))]); 21276 fprintf (file, "(%s)", reg_names[REGNO (XVECEXP (tocrel_base_oac, 0, 1))]);
21795 } 21277 }
21796 else 21278 else
21797 gcc_unreachable (); 21279 output_addr_const (file, x);
21798 } 21280 }
21799 21281
21800 /* Implement TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA. */ 21282 /* Implement TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA. */
21801 21283
21802 static bool 21284 static bool
22431 do_move = true; 21913 do_move = true;
22432 21914
22433 else 21915 else
22434 gcc_unreachable (); 21916 gcc_unreachable ();
22435 21917
22436 /* Handle conversion between TFmode/KFmode. */ 21918 /* Handle conversion between TFmode/KFmode/IFmode. */
22437 if (do_move) 21919 if (do_move)
22438 emit_move_insn (dest, gen_lowpart (dest_mode, src)); 21920 emit_insn (gen_rtx_SET (dest, gen_rtx_FLOAT_EXTEND (dest_mode, src)));
22439 21921
22440 /* Handle conversion if we have hardware support. */ 21922 /* Handle conversion if we have hardware support. */
22441 else if (TARGET_FLOAT128_HW && hw_convert) 21923 else if (TARGET_FLOAT128_HW && hw_convert)
22442 emit_insn ((hw_convert) (dest, src)); 21924 emit_insn ((hw_convert) (dest, src));
22443 21925
22460 21942
22461 return; 21943 return;
22462 } 21944 }
22463 21945
22464 21946
22465 /* Emit the RTL for an sISEL pattern. */
22466
22467 void
22468 rs6000_emit_sISEL (machine_mode mode ATTRIBUTE_UNUSED, rtx operands[])
22469 {
22470 rs6000_emit_int_cmove (operands[0], operands[1], const1_rtx, const0_rtx);
22471 }
22472
22473 /* Emit RTL that sets a register to zero if OP1 and OP2 are equal. SCRATCH 21947 /* Emit RTL that sets a register to zero if OP1 and OP2 are equal. SCRATCH
22474 can be used as that dest register. Return the dest register. */ 21948 can be used as that dest register. Return the dest register. */
22475 21949
22476 rtx 21950 rtx
22477 rs6000_emit_eqne (machine_mode mode, rtx op1, rtx op2, rtx scratch) 21951 rs6000_emit_eqne (machine_mode mode, rtx op1, rtx op2, rtx scratch)
23243 return 1; 22717 return 1;
23244 } 22718 }
23245 22719
23246 /* Same as above, but for ints (isel). */ 22720 /* Same as above, but for ints (isel). */
23247 22721
23248 static int 22722 int
23249 rs6000_emit_int_cmove (rtx dest, rtx op, rtx true_cond, rtx false_cond) 22723 rs6000_emit_int_cmove (rtx dest, rtx op, rtx true_cond, rtx false_cond)
23250 { 22724 {
23251 rtx condition_rtx, cr; 22725 rtx condition_rtx, cr;
23252 machine_mode mode = GET_MODE (dest); 22726 machine_mode mode = GET_MODE (dest);
23253 enum rtx_code cond_code; 22727 enum rtx_code cond_code;
23321 target = emit_conditional_move (dest, c, op0, op1, mode, 22795 target = emit_conditional_move (dest, c, op0, op1, mode,
23322 op1, op0, mode, 0); 22796 op1, op0, mode, 0);
23323 gcc_assert (target); 22797 gcc_assert (target);
23324 if (target != dest) 22798 if (target != dest)
23325 emit_move_insn (dest, target); 22799 emit_move_insn (dest, target);
23326 }
23327
23328 /* Split a signbit operation on 64-bit machines with direct move. Also allow
23329 for the value to come from memory or if it is already loaded into a GPR. */
23330
23331 void
23332 rs6000_split_signbit (rtx dest, rtx src)
23333 {
23334 machine_mode d_mode = GET_MODE (dest);
23335 machine_mode s_mode = GET_MODE (src);
23336 rtx dest_di = (d_mode == DImode) ? dest : gen_lowpart (DImode, dest);
23337 rtx shift_reg = dest_di;
23338
23339 gcc_assert (FLOAT128_IEEE_P (s_mode) && TARGET_POWERPC64);
23340
23341 if (MEM_P (src))
23342 {
23343 rtx mem = (WORDS_BIG_ENDIAN
23344 ? adjust_address (src, DImode, 0)
23345 : adjust_address (src, DImode, 8));
23346 emit_insn (gen_rtx_SET (dest_di, mem));
23347 }
23348
23349 else
23350 {
23351 unsigned int r = reg_or_subregno (src);
23352
23353 if (INT_REGNO_P (r))
23354 shift_reg = gen_rtx_REG (DImode, r + (BYTES_BIG_ENDIAN == 0));
23355
23356 else
23357 {
23358 /* Generate the special mfvsrd instruction to get it in a GPR. */
23359 gcc_assert (VSX_REGNO_P (r));
23360 if (s_mode == KFmode)
23361 emit_insn (gen_signbitkf2_dm2 (dest_di, src));
23362 else
23363 emit_insn (gen_signbittf2_dm2 (dest_di, src));
23364 }
23365 }
23366
23367 emit_insn (gen_lshrdi3 (dest_di, shift_reg, GEN_INT (63)));
23368 return;
23369 } 22800 }
23370 22801
23371 /* A subroutine of the atomic operation splitters. Jump to LABEL if 22802 /* A subroutine of the atomic operation splitters. Jump to LABEL if
23372 COND is true. Mark the jump as unlikely to be taken. */ 22803 COND is true. Mark the jump as unlikely to be taken. */
23373 22804
23924 23355
23925 reg = REG_P (dst) ? REGNO (dst) : REGNO (src); 23356 reg = REG_P (dst) ? REGNO (dst) : REGNO (src);
23926 mode = GET_MODE (dst); 23357 mode = GET_MODE (dst);
23927 nregs = hard_regno_nregs (reg, mode); 23358 nregs = hard_regno_nregs (reg, mode);
23928 if (FP_REGNO_P (reg)) 23359 if (FP_REGNO_P (reg))
23929 reg_mode = DECIMAL_FLOAT_MODE_P (mode) ? DDmode : 23360 reg_mode = DECIMAL_FLOAT_MODE_P (mode) ? DDmode :
23930 ((TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT) ? DFmode : SFmode); 23361 (TARGET_HARD_FLOAT ? DFmode : SFmode);
23931 else if (ALTIVEC_REGNO_P (reg)) 23362 else if (ALTIVEC_REGNO_P (reg))
23932 reg_mode = V16QImode; 23363 reg_mode = V16QImode;
23933 else 23364 else
23934 reg_mode = word_mode; 23365 reg_mode = word_mode;
23935 reg_mode_size = GET_MODE_SIZE (reg_mode); 23366 reg_mode_size = GET_MODE_SIZE (reg_mode);
24000 ? GEN_INT (GET_MODE_SIZE (GET_MODE (src))) 23431 ? GEN_INT (GET_MODE_SIZE (GET_MODE (src)))
24001 : GEN_INT (-GET_MODE_SIZE (GET_MODE (src)))); 23432 : GEN_INT (-GET_MODE_SIZE (GET_MODE (src))));
24002 emit_insn (gen_add3_insn (breg, breg, delta_rtx)); 23433 emit_insn (gen_add3_insn (breg, breg, delta_rtx));
24003 src = replace_equiv_address (src, breg); 23434 src = replace_equiv_address (src, breg);
24004 } 23435 }
24005 else if (! rs6000_offsettable_memref_p (src, reg_mode)) 23436 else if (! rs6000_offsettable_memref_p (src, reg_mode, true))
24006 { 23437 {
24007 if (GET_CODE (XEXP (src, 0)) == PRE_MODIFY) 23438 if (GET_CODE (XEXP (src, 0)) == PRE_MODIFY)
24008 { 23439 {
24009 rtx basereg = XEXP (XEXP (src, 0), 0); 23440 rtx basereg = XEXP (XEXP (src, 0), 0);
24010 if (TARGET_UPDATE) 23441 if (TARGET_UPDATE)
24067 } 23498 }
24068 else 23499 else
24069 emit_insn (gen_add3_insn (breg, breg, delta_rtx)); 23500 emit_insn (gen_add3_insn (breg, breg, delta_rtx));
24070 dst = replace_equiv_address (dst, breg); 23501 dst = replace_equiv_address (dst, breg);
24071 } 23502 }
24072 else if (!rs6000_offsettable_memref_p (dst, reg_mode) 23503 else if (!rs6000_offsettable_memref_p (dst, reg_mode, true)
24073 && GET_CODE (XEXP (dst, 0)) != LO_SUM) 23504 && GET_CODE (XEXP (dst, 0)) != LO_SUM)
24074 { 23505 {
24075 if (GET_CODE (XEXP (dst, 0)) == PRE_MODIFY) 23506 if (GET_CODE (XEXP (dst, 0)) == PRE_MODIFY)
24076 { 23507 {
24077 rtx basereg = XEXP (XEXP (dst, 0), 0); 23508 rtx basereg = XEXP (XEXP (dst, 0), 0);
24106 restore_basereg = gen_sub3_insn (basereg, basereg, offsetreg); 23537 restore_basereg = gen_sub3_insn (basereg, basereg, offsetreg);
24107 dst = replace_equiv_address (dst, basereg); 23538 dst = replace_equiv_address (dst, basereg);
24108 } 23539 }
24109 } 23540 }
24110 else if (GET_CODE (XEXP (dst, 0)) != LO_SUM) 23541 else if (GET_CODE (XEXP (dst, 0)) != LO_SUM)
24111 gcc_assert (rs6000_offsettable_memref_p (dst, reg_mode)); 23542 gcc_assert (rs6000_offsettable_memref_p (dst, reg_mode, true));
24112 } 23543 }
24113 23544
24114 for (i = 0; i < nregs; i++) 23545 for (i = 0; i < nregs; i++)
24115 { 23546 {
24116 /* Calculate index to next subword. */ 23547 /* Calculate index to next subword. */
24387 | SAVE_INLINE_VRS | REST_INLINE_VRS); 23818 | SAVE_INLINE_VRS | REST_INLINE_VRS);
24388 23819
24389 if (info->first_gp_reg_save == 32) 23820 if (info->first_gp_reg_save == 32)
24390 strategy |= SAVE_INLINE_GPRS | REST_INLINE_GPRS; 23821 strategy |= SAVE_INLINE_GPRS | REST_INLINE_GPRS;
24391 23822
24392 if (info->first_fp_reg_save == 64 23823 if (info->first_fp_reg_save == 64)
24393 /* The out-of-line FP routines use double-precision stores;
24394 we can't use those routines if we don't have such stores. */
24395 || (TARGET_HARD_FLOAT && !TARGET_DOUBLE_FLOAT))
24396 strategy |= SAVE_INLINE_FPRS | REST_INLINE_FPRS; 23824 strategy |= SAVE_INLINE_FPRS | REST_INLINE_FPRS;
24397 23825
24398 if (info->first_altivec_reg_save == LAST_ALTIVEC_REGNO + 1) 23826 if (info->first_altivec_reg_save == LAST_ALTIVEC_REGNO + 1)
24399 strategy |= SAVE_INLINE_VRS | REST_INLINE_VRS; 23827 strategy |= SAVE_INLINE_VRS | REST_INLINE_VRS;
24400 23828
25124 static bool 24552 static bool
25125 rs6000_function_ok_for_sibcall (tree decl, tree exp) 24553 rs6000_function_ok_for_sibcall (tree decl, tree exp)
25126 { 24554 {
25127 tree fntype; 24555 tree fntype;
25128 24556
24557 /* The sibcall epilogue may clobber the static chain register.
24558 ??? We could work harder and avoid that, but it's probably
24559 not worth the hassle in practice. */
24560 if (CALL_EXPR_STATIC_CHAIN (exp))
24561 return false;
24562
25129 if (decl) 24563 if (decl)
25130 fntype = TREE_TYPE (decl); 24564 fntype = TREE_TYPE (decl);
25131 else 24565 else
25132 fntype = TREE_TYPE (TREE_TYPE (CALL_EXPR_FN (exp))); 24566 fntype = TREE_TYPE (TREE_TYPE (CALL_EXPR_FN (exp)));
25133 24567
26627 26061
26628 gcc_assert (!(info->savres_strategy & SAVE_MULTIPLE) 26062 gcc_assert (!(info->savres_strategy & SAVE_MULTIPLE)
26629 && !(info->savres_strategy & REST_MULTIPLE)); 26063 && !(info->savres_strategy & REST_MULTIPLE));
26630 26064
26631 /* Component 0 is the save/restore of LR (done via GPR0). 26065 /* Component 0 is the save/restore of LR (done via GPR0).
26066 Component 2 is the save of the TOC (GPR2).
26632 Components 13..31 are the save/restore of GPR13..GPR31. 26067 Components 13..31 are the save/restore of GPR13..GPR31.
26633 Components 46..63 are the save/restore of FPR14..FPR31. */ 26068 Components 46..63 are the save/restore of FPR14..FPR31. */
26634 26069
26635 cfun->machine->n_components = 64; 26070 cfun->machine->n_components = 64;
26636 26071
26701 offset += info->total_size; 26136 offset += info->total_size;
26702 if (IN_RANGE (offset, -0x8000, 0x7fff)) 26137 if (IN_RANGE (offset, -0x8000, 0x7fff))
26703 bitmap_set_bit (components, 0); 26138 bitmap_set_bit (components, 0);
26704 } 26139 }
26705 26140
26141 /* Optimize saving the TOC. This is component 2. */
26142 if (cfun->machine->save_toc_in_prologue)
26143 bitmap_set_bit (components, 2);
26144
26706 return components; 26145 return components;
26707 } 26146 }
26708 26147
26709 /* Implement TARGET_SHRINK_WRAP_COMPONENTS_FOR_BB. */ 26148 /* Implement TARGET_SHRINK_WRAP_COMPONENTS_FOR_BB. */
26710 static sbitmap 26149 static sbitmap
26739 if (bitmap_bit_p (in, LR_REGNO) 26178 if (bitmap_bit_p (in, LR_REGNO)
26740 || bitmap_bit_p (gen, LR_REGNO) 26179 || bitmap_bit_p (gen, LR_REGNO)
26741 || bitmap_bit_p (kill, LR_REGNO)) 26180 || bitmap_bit_p (kill, LR_REGNO))
26742 bitmap_set_bit (components, 0); 26181 bitmap_set_bit (components, 0);
26743 26182
26183 /* The TOC save. */
26184 if (bitmap_bit_p (in, TOC_REGNUM)
26185 || bitmap_bit_p (gen, TOC_REGNUM)
26186 || bitmap_bit_p (kill, TOC_REGNUM))
26187 bitmap_set_bit (components, 2);
26188
26744 return components; 26189 return components;
26745 } 26190 }
26746 26191
26747 /* Implement TARGET_SHRINK_WRAP_DISQUALIFY_COMPONENTS. */ 26192 /* Implement TARGET_SHRINK_WRAP_DISQUALIFY_COMPONENTS. */
26748 static void 26193 static void
26770 ? HARD_FRAME_POINTER_REGNUM 26215 ? HARD_FRAME_POINTER_REGNUM
26771 : STACK_POINTER_REGNUM); 26216 : STACK_POINTER_REGNUM);
26772 26217
26773 machine_mode reg_mode = Pmode; 26218 machine_mode reg_mode = Pmode;
26774 int reg_size = TARGET_32BIT ? 4 : 8; 26219 int reg_size = TARGET_32BIT ? 4 : 8;
26775 machine_mode fp_reg_mode = (TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT) 26220 machine_mode fp_reg_mode = TARGET_HARD_FLOAT ? DFmode : SFmode;
26776 ? DFmode : SFmode;
26777 int fp_reg_size = 8; 26221 int fp_reg_size = 8;
26778 26222
26779 /* Prologue for LR. */ 26223 /* Prologue for LR. */
26780 if (bitmap_bit_p (components, 0)) 26224 if (bitmap_bit_p (components, 0))
26781 { 26225 {
26226 rtx lr = gen_rtx_REG (reg_mode, LR_REGNO);
26782 rtx reg = gen_rtx_REG (reg_mode, 0); 26227 rtx reg = gen_rtx_REG (reg_mode, 0);
26783 rtx_insn *insn = emit_move_insn (reg, gen_rtx_REG (reg_mode, LR_REGNO)); 26228 rtx_insn *insn = emit_move_insn (reg, lr);
26784 RTX_FRAME_RELATED_P (insn) = 1; 26229 RTX_FRAME_RELATED_P (insn) = 1;
26785 add_reg_note (insn, REG_CFA_REGISTER, NULL); 26230 add_reg_note (insn, REG_CFA_REGISTER, gen_rtx_SET (reg, lr));
26786 26231
26787 int offset = info->lr_save_offset; 26232 int offset = info->lr_save_offset;
26788 if (info->push_p) 26233 if (info->push_p)
26789 offset += info->total_size; 26234 offset += info->total_size;
26790 26235
26791 insn = emit_insn (gen_frame_store (reg, ptr_reg, offset)); 26236 insn = emit_insn (gen_frame_store (reg, ptr_reg, offset));
26792 RTX_FRAME_RELATED_P (insn) = 1; 26237 RTX_FRAME_RELATED_P (insn) = 1;
26793 rtx lr = gen_rtx_REG (reg_mode, LR_REGNO);
26794 rtx mem = copy_rtx (SET_DEST (single_set (insn))); 26238 rtx mem = copy_rtx (SET_DEST (single_set (insn)));
26795 add_reg_note (insn, REG_CFA_OFFSET, gen_rtx_SET (mem, lr)); 26239 add_reg_note (insn, REG_CFA_OFFSET, gen_rtx_SET (mem, lr));
26240 }
26241
26242 /* Prologue for TOC. */
26243 if (bitmap_bit_p (components, 2))
26244 {
26245 rtx reg = gen_rtx_REG (reg_mode, TOC_REGNUM);
26246 rtx sp_reg = gen_rtx_REG (Pmode, STACK_POINTER_REGNUM);
26247 emit_insn (gen_frame_store (reg, sp_reg, RS6000_TOC_SAVE_SLOT));
26796 } 26248 }
26797 26249
26798 /* Prologue for the GPRs. */ 26250 /* Prologue for the GPRs. */
26799 int offset = info->gp_save_offset; 26251 int offset = info->gp_save_offset;
26800 if (info->push_p) 26252 if (info->push_p)
26844 : STACK_POINTER_REGNUM); 26296 : STACK_POINTER_REGNUM);
26845 26297
26846 machine_mode reg_mode = Pmode; 26298 machine_mode reg_mode = Pmode;
26847 int reg_size = TARGET_32BIT ? 4 : 8; 26299 int reg_size = TARGET_32BIT ? 4 : 8;
26848 26300
26849 machine_mode fp_reg_mode = (TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT) 26301 machine_mode fp_reg_mode = TARGET_HARD_FLOAT ? DFmode : SFmode;
26850 ? DFmode : SFmode;
26851 int fp_reg_size = 8; 26302 int fp_reg_size = 8;
26852 26303
26853 /* Epilogue for the FPRs. */ 26304 /* Epilogue for the FPRs. */
26854 int offset = info->fp_save_offset; 26305 int offset = info->fp_save_offset;
26855 if (info->push_p) 26306 if (info->push_p)
26917 if (bitmap_bit_p (components, i)) 26368 if (bitmap_bit_p (components, i))
26918 cfun->machine->fpr_is_wrapped_separately[i - 32] = true; 26369 cfun->machine->fpr_is_wrapped_separately[i - 32] = true;
26919 26370
26920 if (bitmap_bit_p (components, 0)) 26371 if (bitmap_bit_p (components, 0))
26921 cfun->machine->lr_is_wrapped_separately = true; 26372 cfun->machine->lr_is_wrapped_separately = true;
26373
26374 if (bitmap_bit_p (components, 2))
26375 cfun->machine->toc_is_wrapped_separately = true;
26922 } 26376 }
26923 26377
26924 /* VRSAVE is a bit vector representing which AltiVec registers 26378 /* VRSAVE is a bit vector representing which AltiVec registers
26925 are used. The OS uses this to determine which vector 26379 are used. The OS uses this to determine which vector
26926 registers to save on a context switch. We need to save 26380 registers to save on a context switch. We need to save
27000 rs6000_emit_prologue (void) 26454 rs6000_emit_prologue (void)
27001 { 26455 {
27002 rs6000_stack_t *info = rs6000_stack_info (); 26456 rs6000_stack_t *info = rs6000_stack_info ();
27003 machine_mode reg_mode = Pmode; 26457 machine_mode reg_mode = Pmode;
27004 int reg_size = TARGET_32BIT ? 4 : 8; 26458 int reg_size = TARGET_32BIT ? 4 : 8;
27005 machine_mode fp_reg_mode = (TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT) 26459 machine_mode fp_reg_mode = TARGET_HARD_FLOAT ? DFmode : SFmode;
27006 ? DFmode : SFmode;
27007 int fp_reg_size = 8; 26460 int fp_reg_size = 8;
27008 rtx sp_reg_rtx = gen_rtx_REG (Pmode, STACK_POINTER_REGNUM); 26461 rtx sp_reg_rtx = gen_rtx_REG (Pmode, STACK_POINTER_REGNUM);
27009 rtx frame_reg_rtx = sp_reg_rtx; 26462 rtx frame_reg_rtx = sp_reg_rtx;
27010 unsigned int cr_save_regno; 26463 unsigned int cr_save_regno;
27011 rtx cr_save_rtx = NULL_RTX; 26464 rtx cr_save_rtx = NULL_RTX;
27145 "*save_world")); 26598 "*save_world"));
27146 /* We do floats first so that the instruction pattern matches 26599 /* We do floats first so that the instruction pattern matches
27147 properly. */ 26600 properly. */
27148 for (i = 0; i < 64 - info->first_fp_reg_save; i++) 26601 for (i = 0; i < 64 - info->first_fp_reg_save; i++)
27149 RTVEC_ELT (p, j++) 26602 RTVEC_ELT (p, j++)
27150 = gen_frame_store (gen_rtx_REG (TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT 26603 = gen_frame_store (gen_rtx_REG (TARGET_HARD_FLOAT ? DFmode : SFmode,
27151 ? DFmode : SFmode,
27152 info->first_fp_reg_save + i), 26604 info->first_fp_reg_save + i),
27153 frame_reg_rtx, 26605 frame_reg_rtx,
27154 info->fp_save_offset + frame_off + 8 * i); 26606 info->fp_save_offset + frame_off + 8 * i);
27155 for (i = 0; info->first_altivec_reg_save + i <= LAST_ALTIVEC_REGNO; i++) 26607 for (i = 0; info->first_altivec_reg_save + i <= LAST_ALTIVEC_REGNO; i++)
27156 RTVEC_ELT (p, j++) 26608 RTVEC_ELT (p, j++)
27874 a shared library. This behavior is costly to describe in DWARF, 27326 a shared library. This behavior is costly to describe in DWARF,
27875 both in terms of the size of DWARF info and the time taken in the 27327 both in terms of the size of DWARF info and the time taken in the
27876 unwinder to interpret it. R2 changes, apart from the 27328 unwinder to interpret it. R2 changes, apart from the
27877 calls_eh_return case earlier in this function, are handled by 27329 calls_eh_return case earlier in this function, are handled by
27878 linux-unwind.h frob_update_context. */ 27330 linux-unwind.h frob_update_context. */
27879 if (rs6000_save_toc_in_prologue_p ()) 27331 if (rs6000_save_toc_in_prologue_p ()
27332 && !cfun->machine->toc_is_wrapped_separately)
27880 { 27333 {
27881 rtx reg = gen_rtx_REG (reg_mode, TOC_REGNUM); 27334 rtx reg = gen_rtx_REG (reg_mode, TOC_REGNUM);
27882 emit_insn (gen_frame_store (reg, sp_reg_rtx, RS6000_TOC_SAVE_SLOT)); 27335 emit_insn (gen_frame_store (reg, sp_reg_rtx, RS6000_TOC_SAVE_SLOT));
27883 } 27336 }
27884 27337
28237 rtx cfa_restores = NULL_RTX; 27690 rtx cfa_restores = NULL_RTX;
28238 rtx insn; 27691 rtx insn;
28239 rtx cr_save_reg = NULL_RTX; 27692 rtx cr_save_reg = NULL_RTX;
28240 machine_mode reg_mode = Pmode; 27693 machine_mode reg_mode = Pmode;
28241 int reg_size = TARGET_32BIT ? 4 : 8; 27694 int reg_size = TARGET_32BIT ? 4 : 8;
28242 machine_mode fp_reg_mode = (TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT) 27695 machine_mode fp_reg_mode = TARGET_HARD_FLOAT ? DFmode : SFmode;
28243 ? DFmode : SFmode;
28244 int fp_reg_size = 8; 27696 int fp_reg_size = 8;
28245 int i; 27697 int i;
28246 bool exit_func; 27698 bool exit_func;
28247 unsigned ptr_regno; 27699 unsigned ptr_regno;
28248 27700
28250 27702
28251 strategy = info->savres_strategy; 27703 strategy = info->savres_strategy;
28252 using_load_multiple = strategy & REST_MULTIPLE; 27704 using_load_multiple = strategy & REST_MULTIPLE;
28253 restoring_FPRs_inline = sibcall || (strategy & REST_INLINE_FPRS); 27705 restoring_FPRs_inline = sibcall || (strategy & REST_INLINE_FPRS);
28254 restoring_GPRs_inline = sibcall || (strategy & REST_INLINE_GPRS); 27706 restoring_GPRs_inline = sibcall || (strategy & REST_INLINE_GPRS);
28255 using_mtcr_multiple = (rs6000_cpu == PROCESSOR_PPC601 27707 using_mtcr_multiple = (rs6000_tune == PROCESSOR_PPC601
28256 || rs6000_cpu == PROCESSOR_PPC603 27708 || rs6000_tune == PROCESSOR_PPC603
28257 || rs6000_cpu == PROCESSOR_PPC750 27709 || rs6000_tune == PROCESSOR_PPC750
28258 || optimize_size); 27710 || optimize_size);
28259 /* Restore via the backchain when we have a large frame, since this 27711 /* Restore via the backchain when we have a large frame, since this
28260 is more efficient than an addis, addi pair. The second condition 27712 is more efficient than an addis, addi pair. The second condition
28261 here will not trigger at the moment; We don't actually need a 27713 here will not trigger at the moment; We don't actually need a
28262 frame pointer for alloca, but the generic parts of the compiler 27714 frame pointer for alloca, but the generic parts of the compiler
28340 && save_reg_p (info->first_altivec_reg_save + i)) 27792 && save_reg_p (info->first_altivec_reg_save + i))
28341 cfa_restores = alloc_reg_note (REG_CFA_RESTORE, reg, cfa_restores); 27793 cfa_restores = alloc_reg_note (REG_CFA_RESTORE, reg, cfa_restores);
28342 } 27794 }
28343 for (i = 0; info->first_fp_reg_save + i <= 63; i++) 27795 for (i = 0; info->first_fp_reg_save + i <= 63; i++)
28344 { 27796 {
28345 rtx reg = gen_rtx_REG ((TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT 27797 rtx reg = gen_rtx_REG (TARGET_HARD_FLOAT ? DFmode : SFmode,
28346 ? DFmode : SFmode),
28347 info->first_fp_reg_save + i); 27798 info->first_fp_reg_save + i);
28348 RTVEC_ELT (p, j++) 27799 RTVEC_ELT (p, j++)
28349 = gen_frame_load (reg, frame_reg_rtx, info->fp_save_offset + 8 * i); 27800 = gen_frame_load (reg, frame_reg_rtx, info->fp_save_offset + 8 * i);
28350 if (flag_shrink_wrap 27801 if (flag_shrink_wrap
28351 && save_reg_p (info->first_fp_reg_save + i)) 27802 && save_reg_p (info->first_fp_reg_save + i))
29178 fputs ("\t.byte 0,", file); 28629 fputs ("\t.byte 0,", file);
29179 28630
29180 /* Language type. Unfortunately, there does not seem to be any 28631 /* Language type. Unfortunately, there does not seem to be any
29181 official way to discover the language being compiled, so we 28632 official way to discover the language being compiled, so we
29182 use language_string. 28633 use language_string.
29183 C is 0. Fortran is 1. Pascal is 2. Ada is 3. C++ is 9. 28634 C is 0. Fortran is 1. Ada is 3. C++ is 9.
29184 Java is 13. Objective-C is 14. Objective-C++ isn't assigned 28635 Java is 13. Objective-C is 14. Objective-C++ isn't assigned
29185 a number, so for now use 9. LTO, Go and JIT aren't assigned numbers 28636 a number, so for now use 9. LTO, Go and JIT aren't assigned numbers
29186 either, so for now use 0. */ 28637 either, so for now use 0. */
29187 if (lang_GNU_C () 28638 if (lang_GNU_C ()
29188 || ! strcmp (language_string, "GNU GIMPLE") 28639 || ! strcmp (language_string, "GNU GIMPLE")
29190 || ! strcmp (language_string, "libgccjit")) 28641 || ! strcmp (language_string, "libgccjit"))
29191 i = 0; 28642 i = 0;
29192 else if (! strcmp (language_string, "GNU F77") 28643 else if (! strcmp (language_string, "GNU F77")
29193 || lang_GNU_Fortran ()) 28644 || lang_GNU_Fortran ())
29194 i = 1; 28645 i = 1;
29195 else if (! strcmp (language_string, "GNU Pascal"))
29196 i = 2;
29197 else if (! strcmp (language_string, "GNU Ada")) 28646 else if (! strcmp (language_string, "GNU Ada"))
29198 i = 3; 28647 i = 3;
29199 else if (lang_GNU_CXX () 28648 else if (lang_GNU_CXX ()
29200 || ! strcmp (language_string, "GNU Objective-C++")) 28649 || ! strcmp (language_string, "GNU Objective-C++"))
29201 i = 9; 28650 i = 9;
29511 gen_rtx_REG (Pmode, 12)); 28960 gen_rtx_REG (Pmode, 12));
29512 push_topmost_sequence (); 28961 push_topmost_sequence ();
29513 emit_insn_after (pat, get_insns ()); 28962 emit_insn_after (pat, get_insns ());
29514 pop_topmost_sequence (); 28963 pop_topmost_sequence ();
29515 } 28964 }
29516 return plus_constant (Pmode, cfun->machine->split_stack_arg_pointer, 28965 rtx ret = plus_constant (Pmode, cfun->machine->split_stack_arg_pointer,
29517 FIRST_PARM_OFFSET (current_function_decl)); 28966 FIRST_PARM_OFFSET (current_function_decl));
28967 return copy_to_reg (ret);
29518 } 28968 }
29519 return virtual_incoming_args_rtx; 28969 return virtual_incoming_args_rtx;
29520 } 28970 }
29521 28971
29522 /* We may have to tell the dataflow pass that the split stack prologue 28972 /* We may have to tell the dataflow pass that the split stack prologue
30545 cached_can_issue_more = more - 1; 29995 cached_can_issue_more = more - 1;
30546 29996
30547 return cached_can_issue_more; 29997 return cached_can_issue_more;
30548 } 29998 }
30549 29999
30550 if (rs6000_cpu_attr == CPU_CELL && is_nonpipeline_insn (insn)) 30000 if (rs6000_tune == PROCESSOR_CELL && is_nonpipeline_insn (insn))
30551 return 0; 30001 return 0;
30552 30002
30553 cached_can_issue_more = more - 1; 30003 cached_can_issue_more = more - 1;
30554 return cached_can_issue_more; 30004 return cached_can_issue_more;
30555 } 30005 }
30581 { 30031 {
30582 /* Data dependency; DEP_INSN writes a register that INSN reads 30032 /* Data dependency; DEP_INSN writes a register that INSN reads
30583 some cycles later. */ 30033 some cycles later. */
30584 30034
30585 /* Separate a load from a narrower, dependent store. */ 30035 /* Separate a load from a narrower, dependent store. */
30586 if ((rs6000_sched_groups || rs6000_cpu_attr == CPU_POWER9) 30036 if ((rs6000_sched_groups || rs6000_tune == PROCESSOR_POWER9)
30587 && GET_CODE (PATTERN (insn)) == SET 30037 && GET_CODE (PATTERN (insn)) == SET
30588 && GET_CODE (PATTERN (dep_insn)) == SET 30038 && GET_CODE (PATTERN (dep_insn)) == SET
30589 && GET_CODE (XEXP (PATTERN (insn), 1)) == MEM 30039 && GET_CODE (XEXP (PATTERN (insn), 1)) == MEM
30590 && GET_CODE (XEXP (PATTERN (dep_insn), 0)) == MEM 30040 && GET_CODE (XEXP (PATTERN (dep_insn), 0)) == MEM
30591 && (GET_MODE_SIZE (GET_MODE (XEXP (PATTERN (insn), 1))) 30041 && (GET_MODE_SIZE (GET_MODE (XEXP (PATTERN (insn), 1)))
30604 to it, will be generated by reload. */ 30054 to it, will be generated by reload. */
30605 return 4; 30055 return 4;
30606 case TYPE_BRANCH: 30056 case TYPE_BRANCH:
30607 /* Leave some extra cycles between a compare and its 30057 /* Leave some extra cycles between a compare and its
30608 dependent branch, to inhibit expensive mispredicts. */ 30058 dependent branch, to inhibit expensive mispredicts. */
30609 if ((rs6000_cpu_attr == CPU_PPC603 30059 if ((rs6000_tune == PROCESSOR_PPC603
30610 || rs6000_cpu_attr == CPU_PPC604 30060 || rs6000_tune == PROCESSOR_PPC604
30611 || rs6000_cpu_attr == CPU_PPC604E 30061 || rs6000_tune == PROCESSOR_PPC604e
30612 || rs6000_cpu_attr == CPU_PPC620 30062 || rs6000_tune == PROCESSOR_PPC620
30613 || rs6000_cpu_attr == CPU_PPC630 30063 || rs6000_tune == PROCESSOR_PPC630
30614 || rs6000_cpu_attr == CPU_PPC750 30064 || rs6000_tune == PROCESSOR_PPC750
30615 || rs6000_cpu_attr == CPU_PPC7400 30065 || rs6000_tune == PROCESSOR_PPC7400
30616 || rs6000_cpu_attr == CPU_PPC7450 30066 || rs6000_tune == PROCESSOR_PPC7450
30617 || rs6000_cpu_attr == CPU_PPCE5500 30067 || rs6000_tune == PROCESSOR_PPCE5500
30618 || rs6000_cpu_attr == CPU_PPCE6500 30068 || rs6000_tune == PROCESSOR_PPCE6500
30619 || rs6000_cpu_attr == CPU_POWER4 30069 || rs6000_tune == PROCESSOR_POWER4
30620 || rs6000_cpu_attr == CPU_POWER5 30070 || rs6000_tune == PROCESSOR_POWER5
30621 || rs6000_cpu_attr == CPU_POWER7 30071 || rs6000_tune == PROCESSOR_POWER7
30622 || rs6000_cpu_attr == CPU_POWER8 30072 || rs6000_tune == PROCESSOR_POWER8
30623 || rs6000_cpu_attr == CPU_POWER9 30073 || rs6000_tune == PROCESSOR_POWER9
30624 || rs6000_cpu_attr == CPU_CELL) 30074 || rs6000_tune == PROCESSOR_CELL)
30625 && recog_memoized (dep_insn) 30075 && recog_memoized (dep_insn)
30626 && (INSN_CODE (dep_insn) >= 0)) 30076 && (INSN_CODE (dep_insn) >= 0))
30627 30077
30628 switch (get_attr_type (dep_insn)) 30078 switch (get_attr_type (dep_insn))
30629 { 30079 {
30630 case TYPE_CMP: 30080 case TYPE_CMP:
30631 case TYPE_FPCOMPARE: 30081 case TYPE_FPCOMPARE:
30632 case TYPE_CR_LOGICAL: 30082 case TYPE_CR_LOGICAL:
30633 case TYPE_DELAYED_CR:
30634 return cost + 2; 30083 return cost + 2;
30635 case TYPE_EXTS: 30084 case TYPE_EXTS:
30636 case TYPE_MUL: 30085 case TYPE_MUL:
30637 if (get_attr_dot (dep_insn) == DOT_YES) 30086 if (get_attr_dot (dep_insn) == DOT_YES)
30638 return cost + 2; 30087 return cost + 2;
30649 } 30098 }
30650 break; 30099 break;
30651 30100
30652 case TYPE_STORE: 30101 case TYPE_STORE:
30653 case TYPE_FPSTORE: 30102 case TYPE_FPSTORE:
30654 if ((rs6000_cpu == PROCESSOR_POWER6) 30103 if ((rs6000_tune == PROCESSOR_POWER6)
30655 && recog_memoized (dep_insn) 30104 && recog_memoized (dep_insn)
30656 && (INSN_CODE (dep_insn) >= 0)) 30105 && (INSN_CODE (dep_insn) >= 0))
30657 { 30106 {
30658 30107
30659 if (GET_CODE (PATTERN (insn)) != SET) 30108 if (GET_CODE (PATTERN (insn)) != SET)
30717 } 30166 }
30718 } 30167 }
30719 break; 30168 break;
30720 30169
30721 case TYPE_LOAD: 30170 case TYPE_LOAD:
30722 if ((rs6000_cpu == PROCESSOR_POWER6) 30171 if ((rs6000_tune == PROCESSOR_POWER6)
30723 && recog_memoized (dep_insn) 30172 && recog_memoized (dep_insn)
30724 && (INSN_CODE (dep_insn) >= 0)) 30173 && (INSN_CODE (dep_insn) >= 0))
30725 { 30174 {
30726 30175
30727 /* Adjust the cost for the case where the value written 30176 /* Adjust the cost for the case where the value written
30780 } 30229 }
30781 } 30230 }
30782 break; 30231 break;
30783 30232
30784 case TYPE_FPLOAD: 30233 case TYPE_FPLOAD:
30785 if ((rs6000_cpu == PROCESSOR_POWER6) 30234 if ((rs6000_tune == PROCESSOR_POWER6)
30786 && get_attr_update (insn) == UPDATE_NO 30235 && get_attr_update (insn) == UPDATE_NO
30787 && recog_memoized (dep_insn) 30236 && recog_memoized (dep_insn)
30788 && (INSN_CODE (dep_insn) >= 0) 30237 && (INSN_CODE (dep_insn) >= 0)
30789 && (get_attr_type (dep_insn) == TYPE_MFFGPR)) 30238 && (get_attr_type (dep_insn) == TYPE_MFFGPR))
30790 return 2; 30239 return 2;
30798 break; 30247 break;
30799 30248
30800 case REG_DEP_OUTPUT: 30249 case REG_DEP_OUTPUT:
30801 /* Output dependency; DEP_INSN writes a register that INSN writes some 30250 /* Output dependency; DEP_INSN writes a register that INSN writes some
30802 cycles later. */ 30251 cycles later. */
30803 if ((rs6000_cpu == PROCESSOR_POWER6) 30252 if ((rs6000_tune == PROCESSOR_POWER6)
30804 && recog_memoized (dep_insn) 30253 && recog_memoized (dep_insn)
30805 && (INSN_CODE (dep_insn) >= 0)) 30254 && (INSN_CODE (dep_insn) >= 0))
30806 { 30255 {
30807 attr_type = get_attr_type (insn); 30256 attr_type = get_attr_type (insn);
30808 30257
30877 if (!insn || !NONDEBUG_INSN_P (insn) 30326 if (!insn || !NONDEBUG_INSN_P (insn)
30878 || GET_CODE (PATTERN (insn)) == USE 30327 || GET_CODE (PATTERN (insn)) == USE
30879 || GET_CODE (PATTERN (insn)) == CLOBBER) 30328 || GET_CODE (PATTERN (insn)) == CLOBBER)
30880 return false; 30329 return false;
30881 30330
30882 if (rs6000_cpu_attr == CPU_CELL) 30331 if (rs6000_tune == PROCESSOR_CELL)
30883 return get_attr_cell_micro (insn) == CELL_MICRO_ALWAYS; 30332 return get_attr_cell_micro (insn) == CELL_MICRO_ALWAYS;
30884 30333
30885 if (rs6000_sched_groups 30334 if (rs6000_sched_groups
30886 && (rs6000_cpu == PROCESSOR_POWER4 || rs6000_cpu == PROCESSOR_POWER5)) 30335 && (rs6000_tune == PROCESSOR_POWER4 || rs6000_tune == PROCESSOR_POWER5))
30887 { 30336 {
30888 enum attr_type type = get_attr_type (insn); 30337 enum attr_type type = get_attr_type (insn);
30889 if ((type == TYPE_LOAD 30338 if ((type == TYPE_LOAD
30890 && get_attr_update (insn) == UPDATE_YES 30339 && get_attr_update (insn) == UPDATE_YES
30891 && get_attr_sign_extend (insn) == SIGN_EXTEND_YES) 30340 && get_attr_sign_extend (insn) == SIGN_EXTEND_YES)
30909 || GET_CODE (PATTERN (insn)) == USE 30358 || GET_CODE (PATTERN (insn)) == USE
30910 || GET_CODE (PATTERN (insn)) == CLOBBER) 30359 || GET_CODE (PATTERN (insn)) == CLOBBER)
30911 return false; 30360 return false;
30912 30361
30913 if (rs6000_sched_groups 30362 if (rs6000_sched_groups
30914 && (rs6000_cpu == PROCESSOR_POWER4 || rs6000_cpu == PROCESSOR_POWER5)) 30363 && (rs6000_tune == PROCESSOR_POWER4 || rs6000_tune == PROCESSOR_POWER5))
30915 { 30364 {
30916 enum attr_type type = get_attr_type (insn); 30365 enum attr_type type = get_attr_type (insn);
30917 if ((type == TYPE_LOAD 30366 if ((type == TYPE_LOAD
30918 && get_attr_sign_extend (insn) == SIGN_EXTEND_YES 30367 && get_attr_sign_extend (insn) == SIGN_EXTEND_YES
30919 && get_attr_update (insn) == UPDATE_NO) 30368 && get_attr_update (insn) == UPDATE_NO)
30924 || (type == TYPE_STORE 30373 || (type == TYPE_STORE
30925 && get_attr_update (insn) == UPDATE_YES 30374 && get_attr_update (insn) == UPDATE_YES
30926 && get_attr_indexed (insn) == INDEXED_NO) 30375 && get_attr_indexed (insn) == INDEXED_NO)
30927 || ((type == TYPE_FPLOAD || type == TYPE_FPSTORE) 30376 || ((type == TYPE_FPLOAD || type == TYPE_FPSTORE)
30928 && get_attr_update (insn) == UPDATE_YES) 30377 && get_attr_update (insn) == UPDATE_YES)
30929 || type == TYPE_DELAYED_CR 30378 || (type == TYPE_CR_LOGICAL
30379 && get_attr_cr_logical_3op (insn) == CR_LOGICAL_3OP_YES)
30930 || (type == TYPE_EXTS 30380 || (type == TYPE_EXTS
30931 && get_attr_dot (insn) == DOT_YES) 30381 && get_attr_dot (insn) == DOT_YES)
30932 || (type == TYPE_SHIFT 30382 || (type == TYPE_SHIFT
30933 && get_attr_dot (insn) == DOT_YES 30383 && get_attr_dot (insn) == DOT_YES
30934 && get_attr_var_shift (insn) == VAR_SHIFT_NO) 30384 && get_attr_var_shift (insn) == VAR_SHIFT_NO)
31077 return priority; 30527 return priority;
31078 30528
31079 if (GET_CODE (PATTERN (insn)) == USE) 30529 if (GET_CODE (PATTERN (insn)) == USE)
31080 return priority; 30530 return priority;
31081 30531
31082 switch (rs6000_cpu_attr) { 30532 switch (rs6000_tune) {
31083 case CPU_PPC750: 30533 case PROCESSOR_PPC750:
31084 switch (get_attr_type (insn)) 30534 switch (get_attr_type (insn))
31085 { 30535 {
31086 default: 30536 default:
31087 break; 30537 break;
31088 30538
31115 haifa-sched.c:ready_sort(), only 'priority' (critical path) 30565 haifa-sched.c:ready_sort(), only 'priority' (critical path)
31116 considerations precede dispatch-slot restriction considerations. */ 30566 considerations precede dispatch-slot restriction considerations. */
31117 return (priority + 1); 30567 return (priority + 1);
31118 } 30568 }
31119 30569
31120 if (rs6000_cpu == PROCESSOR_POWER6 30570 if (rs6000_tune == PROCESSOR_POWER6
31121 && ((load_store_pendulum == -2 && is_load_insn (insn, &load_mem)) 30571 && ((load_store_pendulum == -2 && is_load_insn (insn, &load_mem))
31122 || (load_store_pendulum == 2 && is_store_insn (insn, &str_mem)))) 30572 || (load_store_pendulum == 2 && is_store_insn (insn, &str_mem))))
31123 /* Attach highest priority to insn if the scheduler has just issued two 30573 /* Attach highest priority to insn if the scheduler has just issued two
31124 stores and this instruction is a load, or two loads and this instruction 30574 stores and this instruction is a load, or two loads and this instruction
31125 is a store. Power6 wants loads and stores scheduled alternately 30575 is a store. Power6 wants loads and stores scheduled alternately
31164 /* Unless scheduling for register pressure, use issue rate of 1 for 30614 /* Unless scheduling for register pressure, use issue rate of 1 for
31165 first scheduling pass to decrease degradation. */ 30615 first scheduling pass to decrease degradation. */
31166 if (!reload_completed && !flag_sched_pressure) 30616 if (!reload_completed && !flag_sched_pressure)
31167 return 1; 30617 return 1;
31168 30618
31169 switch (rs6000_cpu_attr) { 30619 switch (rs6000_tune) {
31170 case CPU_RS64A: 30620 case PROCESSOR_RS64A:
31171 case CPU_PPC601: /* ? */ 30621 case PROCESSOR_PPC601: /* ? */
31172 case CPU_PPC7450: 30622 case PROCESSOR_PPC7450:
31173 return 3; 30623 return 3;
31174 case CPU_PPC440: 30624 case PROCESSOR_PPC440:
31175 case CPU_PPC603: 30625 case PROCESSOR_PPC603:
31176 case CPU_PPC750: 30626 case PROCESSOR_PPC750:
31177 case CPU_PPC7400: 30627 case PROCESSOR_PPC7400:
31178 case CPU_PPC8540: 30628 case PROCESSOR_PPC8540:
31179 case CPU_PPC8548: 30629 case PROCESSOR_PPC8548:
31180 case CPU_CELL: 30630 case PROCESSOR_CELL:
31181 case CPU_PPCE300C2: 30631 case PROCESSOR_PPCE300C2:
31182 case CPU_PPCE300C3: 30632 case PROCESSOR_PPCE300C3:
31183 case CPU_PPCE500MC: 30633 case PROCESSOR_PPCE500MC:
31184 case CPU_PPCE500MC64: 30634 case PROCESSOR_PPCE500MC64:
31185 case CPU_PPCE5500: 30635 case PROCESSOR_PPCE5500:
31186 case CPU_PPCE6500: 30636 case PROCESSOR_PPCE6500:
31187 case CPU_TITAN: 30637 case PROCESSOR_TITAN:
31188 return 2; 30638 return 2;
31189 case CPU_PPC476: 30639 case PROCESSOR_PPC476:
31190 case CPU_PPC604: 30640 case PROCESSOR_PPC604:
31191 case CPU_PPC604E: 30641 case PROCESSOR_PPC604e:
31192 case CPU_PPC620: 30642 case PROCESSOR_PPC620:
31193 case CPU_PPC630: 30643 case PROCESSOR_PPC630:
31194 return 4; 30644 return 4;
31195 case CPU_POWER4: 30645 case PROCESSOR_POWER4:
31196 case CPU_POWER5: 30646 case PROCESSOR_POWER5:
31197 case CPU_POWER6: 30647 case PROCESSOR_POWER6:
31198 case CPU_POWER7: 30648 case PROCESSOR_POWER7:
31199 return 5; 30649 return 5;
31200 case CPU_POWER8: 30650 case PROCESSOR_POWER8:
31201 return 7; 30651 return 7;
31202 case CPU_POWER9: 30652 case PROCESSOR_POWER9:
31203 return 6; 30653 return 6;
31204 default: 30654 default:
31205 return 1; 30655 return 1;
31206 } 30656 }
31207 } 30657 }
31210 scheduling. */ 30660 scheduling. */
31211 30661
31212 static int 30662 static int
31213 rs6000_use_sched_lookahead (void) 30663 rs6000_use_sched_lookahead (void)
31214 { 30664 {
31215 switch (rs6000_cpu_attr) 30665 switch (rs6000_tune)
31216 { 30666 {
31217 case CPU_PPC8540: 30667 case PROCESSOR_PPC8540:
31218 case CPU_PPC8548: 30668 case PROCESSOR_PPC8548:
31219 return 4; 30669 return 4;
31220 30670
31221 case CPU_CELL: 30671 case PROCESSOR_CELL:
31222 return (reload_completed ? 8 : 0); 30672 return (reload_completed ? 8 : 0);
31223 30673
31224 default: 30674 default:
31225 return 0; 30675 return 0;
31226 } 30676 }
31232 rs6000_use_sched_lookahead_guard (rtx_insn *insn, int ready_index) 30682 rs6000_use_sched_lookahead_guard (rtx_insn *insn, int ready_index)
31233 { 30683 {
31234 if (ready_index == 0) 30684 if (ready_index == 0)
31235 return 0; 30685 return 0;
31236 30686
31237 if (rs6000_cpu_attr != CPU_CELL) 30687 if (rs6000_tune != PROCESSOR_CELL)
31238 return 0; 30688 return 0;
31239 30689
31240 gcc_assert (insn != NULL_RTX && INSN_P (insn)); 30690 gcc_assert (insn != NULL_RTX && INSN_P (insn));
31241 30691
31242 if (!reload_completed 30692 if (!reload_completed
31623 if (sched_verbose) 31073 if (sched_verbose)
31624 fprintf (dump, "// rs6000_sched_reorder :\n"); 31074 fprintf (dump, "// rs6000_sched_reorder :\n");
31625 31075
31626 /* Reorder the ready list, if the second to last ready insn 31076 /* Reorder the ready list, if the second to last ready insn
31627 is a nonepipeline insn. */ 31077 is a nonepipeline insn. */
31628 if (rs6000_cpu_attr == CPU_CELL && n_ready > 1) 31078 if (rs6000_tune == PROCESSOR_CELL && n_ready > 1)
31629 { 31079 {
31630 if (is_nonpipeline_insn (ready[n_ready - 1]) 31080 if (is_nonpipeline_insn (ready[n_ready - 1])
31631 && (recog_memoized (ready[n_ready - 2]) > 0)) 31081 && (recog_memoized (ready[n_ready - 2]) > 0))
31632 /* Simply swap first two insns. */ 31082 /* Simply swap first two insns. */
31633 std::swap (ready[n_ready - 1], ready[n_ready - 2]); 31083 std::swap (ready[n_ready - 1], ready[n_ready - 2]);
31634 } 31084 }
31635 31085
31636 if (rs6000_cpu == PROCESSOR_POWER6) 31086 if (rs6000_tune == PROCESSOR_POWER6)
31637 load_store_pendulum = 0; 31087 load_store_pendulum = 0;
31638 31088
31639 return rs6000_issue_rate (); 31089 return rs6000_issue_rate ();
31640 } 31090 }
31641 31091
31686 load/store instructions which make use of the LSU and which 31136 load/store instructions which make use of the LSU and which
31687 would need to be accounted for to strictly model the behavior 31137 would need to be accounted for to strictly model the behavior
31688 of the machine. Those instructions are currently unaccounted 31138 of the machine. Those instructions are currently unaccounted
31689 for to help minimize compile time overhead of this code. 31139 for to help minimize compile time overhead of this code.
31690 */ 31140 */
31691 if (rs6000_cpu == PROCESSOR_POWER6 && last_scheduled_insn) 31141 if (rs6000_tune == PROCESSOR_POWER6 && last_scheduled_insn)
31692 { 31142 {
31693 int pos; 31143 int pos;
31694 int i; 31144 int i;
31695 rtx_insn *tmp; 31145 rtx_insn *tmp;
31696 rtx load_mem, str_mem; 31146 rtx load_mem, str_mem;
31840 } 31290 }
31841 } 31291 }
31842 } 31292 }
31843 31293
31844 /* Do Power9 dependent reordering if necessary. */ 31294 /* Do Power9 dependent reordering if necessary. */
31845 if (rs6000_cpu == PROCESSOR_POWER9 && last_scheduled_insn 31295 if (rs6000_tune == PROCESSOR_POWER9 && last_scheduled_insn
31846 && recog_memoized (last_scheduled_insn) >= 0) 31296 && recog_memoized (last_scheduled_insn) >= 0)
31847 return power9_sched_reorder2 (ready, *pn_ready - 1); 31297 return power9_sched_reorder2 (ready, *pn_ready - 1);
31848 31298
31849 return cached_can_issue_more; 31299 return cached_can_issue_more;
31850 } 31300 }
31895 || DEBUG_INSN_P (insn) 31345 || DEBUG_INSN_P (insn)
31896 || GET_CODE (PATTERN (insn)) == USE 31346 || GET_CODE (PATTERN (insn)) == USE
31897 || GET_CODE (PATTERN (insn)) == CLOBBER) 31347 || GET_CODE (PATTERN (insn)) == CLOBBER)
31898 return false; 31348 return false;
31899 31349
31900 switch (rs6000_cpu) 31350 switch (rs6000_tune)
31901 { 31351 {
31902 case PROCESSOR_POWER5: 31352 case PROCESSOR_POWER5:
31903 if (is_cracked_insn (insn)) 31353 if (is_cracked_insn (insn))
31904 return true; 31354 return true;
31905 /* FALLTHRU */ 31355 /* FALLTHRU */
31915 switch (type) 31365 switch (type)
31916 { 31366 {
31917 case TYPE_MFCR: 31367 case TYPE_MFCR:
31918 case TYPE_MFCRF: 31368 case TYPE_MFCRF:
31919 case TYPE_MTCR: 31369 case TYPE_MTCR:
31920 case TYPE_DELAYED_CR:
31921 case TYPE_CR_LOGICAL: 31370 case TYPE_CR_LOGICAL:
31922 case TYPE_MTJMPR: 31371 case TYPE_MTJMPR:
31923 case TYPE_MFJMPR: 31372 case TYPE_MFJMPR:
31924 case TYPE_DIV: 31373 case TYPE_DIV:
31925 case TYPE_LOAD_L: 31374 case TYPE_LOAD_L:
32018 type = get_attr_type (insn); 31467 type = get_attr_type (insn);
32019 31468
32020 switch (type) 31469 switch (type)
32021 { 31470 {
32022 case TYPE_CR_LOGICAL: 31471 case TYPE_CR_LOGICAL:
32023 case TYPE_DELAYED_CR:
32024 case TYPE_MFCR: 31472 case TYPE_MFCR:
32025 case TYPE_MFCRF: 31473 case TYPE_MFCRF:
32026 case TYPE_MTCR: 31474 case TYPE_MTCR:
32027 case TYPE_SYNC: 31475 case TYPE_SYNC:
32028 case TYPE_ISYNC: 31476 case TYPE_ISYNC:
32072 || DEBUG_INSN_P (insn) 31520 || DEBUG_INSN_P (insn)
32073 || GET_CODE (PATTERN (insn)) == USE 31521 || GET_CODE (PATTERN (insn)) == USE
32074 || GET_CODE (PATTERN (insn)) == CLOBBER) 31522 || GET_CODE (PATTERN (insn)) == CLOBBER)
32075 return false; 31523 return false;
32076 31524
32077 switch (rs6000_cpu) { 31525 switch (rs6000_tune) {
32078 case PROCESSOR_POWER4: 31526 case PROCESSOR_POWER4:
32079 case PROCESSOR_POWER5: 31527 case PROCESSOR_POWER5:
32080 if (is_microcoded_insn (insn)) 31528 if (is_microcoded_insn (insn))
32081 return true; 31529 return true;
32082 31530
32260 will be forced to the new group. */ 31708 will be forced to the new group. */
32261 if (can_issue_more && !is_branch_slot_insn (next_insn)) 31709 if (can_issue_more && !is_branch_slot_insn (next_insn))
32262 can_issue_more--; 31710 can_issue_more--;
32263 31711
32264 /* Do we have a special group ending nop? */ 31712 /* Do we have a special group ending nop? */
32265 if (rs6000_cpu_attr == CPU_POWER6 || rs6000_cpu_attr == CPU_POWER7 31713 if (rs6000_tune == PROCESSOR_POWER6 || rs6000_tune == PROCESSOR_POWER7
32266 || rs6000_cpu_attr == CPU_POWER8) 31714 || rs6000_tune == PROCESSOR_POWER8)
32267 { 31715 {
32268 nop = gen_group_ending_nop (); 31716 nop = gen_group_ending_nop ();
32269 emit_insn_before (nop, next_insn); 31717 emit_insn_before (nop, next_insn);
32270 can_issue_more = 0; 31718 can_issue_more = 0;
32271 } 31719 }
32871 *node = lang_hooks.types.reconstruct_complex_type (*node, result); 32319 *node = lang_hooks.types.reconstruct_complex_type (*node, result);
32872 32320
32873 return NULL_TREE; 32321 return NULL_TREE;
32874 } 32322 }
32875 32323
32876 /* AltiVec defines four built-in scalar types that serve as vector 32324 /* AltiVec defines five built-in scalar types that serve as vector
32877 elements; we must teach the compiler how to mangle them. */ 32325 elements; we must teach the compiler how to mangle them. The 128-bit
32326 floating point mangling is target-specific as well. */
32878 32327
32879 static const char * 32328 static const char *
32880 rs6000_mangle_type (const_tree type) 32329 rs6000_mangle_type (const_tree type)
32881 { 32330 {
32882 type = TYPE_MAIN_VARIANT (type); 32331 type = TYPE_MAIN_VARIANT (type);
32887 32336
32888 if (type == bool_char_type_node) return "U6__boolc"; 32337 if (type == bool_char_type_node) return "U6__boolc";
32889 if (type == bool_short_type_node) return "U6__bools"; 32338 if (type == bool_short_type_node) return "U6__bools";
32890 if (type == pixel_type_node) return "u7__pixel"; 32339 if (type == pixel_type_node) return "u7__pixel";
32891 if (type == bool_int_type_node) return "U6__booli"; 32340 if (type == bool_int_type_node) return "U6__booli";
32892 if (type == bool_long_type_node) return "U6__booll"; 32341 if (type == bool_long_long_type_node) return "U6__boolx";
32893 32342
32894 /* Use a unique name for __float128 rather than trying to use "e" or "g". Use 32343 if (SCALAR_FLOAT_TYPE_P (type) && FLOAT128_IBM_P (TYPE_MODE (type)))
32895 "g" for IBM extended double, no matter whether it is long double (using
32896 -mabi=ibmlongdouble) or the distinct __ibm128 type. */
32897 if (TARGET_FLOAT128_TYPE)
32898 {
32899 if (type == ieee128_float_type_node)
32900 return "U10__float128";
32901
32902 if (TARGET_LONG_DOUBLE_128)
32903 {
32904 if (type == long_double_type_node)
32905 return (TARGET_IEEEQUAD) ? "U10__float128" : "g";
32906
32907 if (type == ibm128_float_type_node)
32908 return "g";
32909 }
32910 }
32911
32912 /* Mangle IBM extended float long double as `g' (__float128) on
32913 powerpc*-linux where long-double-64 previously was the default. */
32914 if (TYPE_MAIN_VARIANT (type) == long_double_type_node
32915 && TARGET_ELF
32916 && TARGET_LONG_DOUBLE_128
32917 && !TARGET_IEEEQUAD)
32918 return "g"; 32344 return "g";
32919 32345 if (SCALAR_FLOAT_TYPE_P (type) && FLOAT128_IEEE_P (TYPE_MODE (type)))
32920 /* For all other types, use normal C++ mangling. */ 32346 return ieee128_mangling_gcc_8_1 ? "U10__float128" : "u9__ieee128";
32347
32348 /* For all other types, use the default mangling. */
32921 return NULL; 32349 return NULL;
32922 } 32350 }
32923 32351
32924 /* Handle a "longcall" or "shortcall" attribute; arguments as in 32352 /* Handle a "longcall" or "shortcall" attribute; arguments as in
32925 struct attribute_spec.handler. */ 32353 struct attribute_spec.handler. */
33174 || strcmp (section, ".PPC.EMB.sbss0") == 0) 32602 || strcmp (section, ".PPC.EMB.sbss0") == 0)
33175 return true; 32603 return true;
33176 } 32604 }
33177 else 32605 else
33178 { 32606 {
32607 /* If we are told not to put readonly data in sdata, then don't. */
32608 if (TREE_READONLY (decl) && rs6000_sdata != SDATA_EABI
32609 && !rs6000_readonly_in_sdata)
32610 return false;
32611
33179 HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (decl)); 32612 HOST_WIDE_INT size = int_size_in_bytes (TREE_TYPE (decl));
33180 32613
33181 if (size > 0 32614 if (size > 0
33182 && size <= g_switch_value 32615 && size <= g_switch_value
33183 /* If it's not public, and we're not going to reference it there, 32616 /* If it's not public, and we're not going to reference it there,
33799 if ((TARGET_64BIT || DEFAULT_ABI == ABI_V4) 33232 if ((TARGET_64BIT || DEFAULT_ABI == ABI_V4)
33800 && rs6000_passes_float) 33233 && rs6000_passes_float)
33801 { 33234 {
33802 int fp; 33235 int fp;
33803 33236
33804 if (TARGET_DF_FPR) 33237 if (TARGET_HARD_FLOAT)
33805 fp = 1; 33238 fp = 1;
33806 else if (TARGET_SF_FPR)
33807 fp = 3;
33808 else 33239 else
33809 fp = 2; 33240 fp = 2;
33810 if (rs6000_passes_long_double) 33241 if (rs6000_passes_long_double)
33811 { 33242 {
33812 if (!TARGET_LONG_DOUBLE_128) 33243 if (!TARGET_LONG_DOUBLE_128)
34272 static const char * const visibility_types[] = { 33703 static const char * const visibility_types[] = {
34273 "", ",protected", ",hidden", ",internal" 33704 "", ",protected", ",hidden", ",internal"
34274 }; 33705 };
34275 33706
34276 enum symbol_visibility vis = DECL_VISIBILITY (decl); 33707 enum symbol_visibility vis = DECL_VISIBILITY (decl);
34277
34278 if (TREE_CODE (decl) == FUNCTION_DECL
34279 && cgraph_node::get (decl)
34280 && cgraph_node::get (decl)->instrumentation_clone
34281 && cgraph_node::get (decl)->instrumented_version)
34282 vis = DECL_VISIBILITY (cgraph_node::get (decl)->instrumented_version->decl);
34283
34284 return visibility_types[vis]; 33708 return visibility_types[vis];
34285 } 33709 }
34286 #endif 33710 #endif
34287 33711
34288 33712
34890 && (outer_code == NEG || outer_code == PLUS)) 34314 && (outer_code == NEG || outer_code == PLUS))
34891 { 34315 {
34892 *total = COSTS_N_INSNS (1); 34316 *total = COSTS_N_INSNS (1);
34893 return true; 34317 return true;
34894 } 34318 }
34319 /* FALLTHRU */
34320
34321 case GT:
34322 case LT:
34323 case UNORDERED:
34895 if (outer_code == SET) 34324 if (outer_code == SET)
34896 { 34325 {
34897 if (XEXP (x, 1) == const0_rtx) 34326 if (XEXP (x, 1) == const0_rtx)
34898 { 34327 {
34899 if (TARGET_ISEL && !TARGET_MFCRF) 34328 *total = COSTS_N_INSNS (2);
34900 *total = COSTS_N_INSNS (8);
34901 else
34902 *total = COSTS_N_INSNS (2);
34903 return true; 34329 return true;
34904 } 34330 }
34905 else 34331 else
34906 { 34332 {
34907 *total = COSTS_N_INSNS (3); 34333 *total = COSTS_N_INSNS (3);
34908 return false; 34334 return false;
34909 } 34335 }
34910 }
34911 /* FALLTHRU */
34912
34913 case GT:
34914 case LT:
34915 case UNORDERED:
34916 if (outer_code == SET && (XEXP (x, 1) == const0_rtx))
34917 {
34918 if (TARGET_ISEL && !TARGET_MFCRF)
34919 *total = COSTS_N_INSNS (8);
34920 else
34921 *total = COSTS_N_INSNS (2);
34922 return true;
34923 } 34336 }
34924 /* CC COMPARE. */ 34337 /* CC COMPARE. */
34925 if (outer_code == COMPARE) 34338 if (outer_code == COMPARE)
34926 { 34339 {
34927 *total = 0; 34340 *total = 0;
35029 cost = n * rs6000_cost->ddiv; 34442 cost = n * rs6000_cost->ddiv;
35030 break; 34443 break;
35031 34444
35032 case TYPE_SYNC: 34445 case TYPE_SYNC:
35033 case TYPE_LOAD_L: 34446 case TYPE_LOAD_L:
34447 case TYPE_MFCR:
34448 case TYPE_MFCRF:
35034 cost = COSTS_N_INSNS (n + 2); 34449 cost = COSTS_N_INSNS (n + 2);
35035 break; 34450 break;
35036 34451
35037 default: 34452 default:
35038 cost = COSTS_N_INSNS (n); 34453 cost = COSTS_N_INSNS (n);
35087 else if (rclass == CR_REGS) 34502 else if (rclass == CR_REGS)
35088 ret = 4; 34503 ret = 4;
35089 34504
35090 /* For those processors that have slow LR/CTR moves, make them more 34505 /* For those processors that have slow LR/CTR moves, make them more
35091 expensive than memory in order to bias spills to memory .*/ 34506 expensive than memory in order to bias spills to memory .*/
35092 else if ((rs6000_cpu == PROCESSOR_POWER6 34507 else if ((rs6000_tune == PROCESSOR_POWER6
35093 || rs6000_cpu == PROCESSOR_POWER7 34508 || rs6000_tune == PROCESSOR_POWER7
35094 || rs6000_cpu == PROCESSOR_POWER8 34509 || rs6000_tune == PROCESSOR_POWER8
35095 || rs6000_cpu == PROCESSOR_POWER9) 34510 || rs6000_tune == PROCESSOR_POWER9)
35096 && reg_classes_intersect_p (rclass, LINK_OR_CTR_REGS)) 34511 && reg_classes_intersect_p (rclass, LINK_OR_CTR_REGS))
35097 ret = 6 * hard_regno_nregs (0, mode); 34512 ret = 6 * hard_regno_nregs (0, mode);
35098 34513
35099 else 34514 else
35100 /* A move will cost one instruction per GPR moved. */ 34515 /* A move will cost one instruction per GPR moved. */
35550 emit_insn (gen_anddi3 (dst, tmp, const1_rtx)); 34965 emit_insn (gen_anddi3 (dst, tmp, const1_rtx));
35551 } 34966 }
35552 } 34967 }
35553 34968
35554 /* Expand an Altivec constant permutation for little endian mode. 34969 /* Expand an Altivec constant permutation for little endian mode.
34970 OP0 and OP1 are the input vectors and TARGET is the output vector.
34971 SEL specifies the constant permutation vector.
34972
35555 There are two issues: First, the two input operands must be 34973 There are two issues: First, the two input operands must be
35556 swapped so that together they form a double-wide array in LE 34974 swapped so that together they form a double-wide array in LE
35557 order. Second, the vperm instruction has surprising behavior 34975 order. Second, the vperm instruction has surprising behavior
35558 in LE mode: it interprets the elements of the source vectors 34976 in LE mode: it interprets the elements of the source vectors
35559 in BE mode ("left to right") and interprets the elements of 34977 in BE mode ("left to right") and interprets the elements of
35591 35009
35592 we get the desired 35010 we get the desired
35593 35011
35594 vr9 = 00000006 00000004 00000002 00000000. */ 35012 vr9 = 00000006 00000004 00000002 00000000. */
35595 35013
35596 void 35014 static void
35597 altivec_expand_vec_perm_const_le (rtx operands[4]) 35015 altivec_expand_vec_perm_const_le (rtx target, rtx op0, rtx op1,
35016 const vec_perm_indices &sel)
35598 { 35017 {
35599 unsigned int i; 35018 unsigned int i;
35600 rtx perm[16]; 35019 rtx perm[16];
35601 rtx constv, unspec; 35020 rtx constv, unspec;
35602 rtx target = operands[0];
35603 rtx op0 = operands[1];
35604 rtx op1 = operands[2];
35605 rtx sel = operands[3];
35606 35021
35607 /* Unpack and adjust the constant selector. */ 35022 /* Unpack and adjust the constant selector. */
35608 for (i = 0; i < 16; ++i) 35023 for (i = 0; i < 16; ++i)
35609 { 35024 {
35610 rtx e = XVECEXP (sel, 0, i); 35025 unsigned int elt = 31 - (sel[i] & 31);
35611 unsigned int elt = 31 - (INTVAL (e) & 31);
35612 perm[i] = GEN_INT (elt); 35026 perm[i] = GEN_INT (elt);
35613 } 35027 }
35614 35028
35615 /* Expand to a permute, swapping the inputs and using the 35029 /* Expand to a permute, swapping the inputs and using the
35616 adjusted selector. */ 35030 adjusted selector. */
35659 if (!REG_P (target)) 35073 if (!REG_P (target))
35660 tmp = gen_reg_rtx (mode); 35074 tmp = gen_reg_rtx (mode);
35661 35075
35662 if (TARGET_P9_VECTOR) 35076 if (TARGET_P9_VECTOR)
35663 { 35077 {
35664 unspec = gen_rtx_UNSPEC (mode, gen_rtvec (3, op0, op1, sel), 35078 unspec = gen_rtx_UNSPEC (mode, gen_rtvec (3, op1, op0, sel),
35665 UNSPEC_VPERMR); 35079 UNSPEC_VPERMR);
35666 } 35080 }
35667 else 35081 else
35668 { 35082 {
35669 /* Invert the selector with a VNAND if available, else a VNOR. 35083 /* Invert the selector with a VNAND if available, else a VNOR.
35688 35102
35689 emit_move_insn (target, unspec); 35103 emit_move_insn (target, unspec);
35690 } 35104 }
35691 35105
35692 /* Expand an Altivec constant permutation. Return true if we match 35106 /* Expand an Altivec constant permutation. Return true if we match
35693 an efficient implementation; false to fall back to VPERM. */ 35107 an efficient implementation; false to fall back to VPERM.
35694 35108
35695 bool 35109 OP0 and OP1 are the input vectors and TARGET is the output vector.
35696 altivec_expand_vec_perm_const (rtx operands[4]) 35110 SEL specifies the constant permutation vector. */
35111
35112 static bool
35113 altivec_expand_vec_perm_const (rtx target, rtx op0, rtx op1,
35114 const vec_perm_indices &sel)
35697 { 35115 {
35698 struct altivec_perm_insn { 35116 struct altivec_perm_insn {
35699 HOST_WIDE_INT mask; 35117 HOST_WIDE_INT mask;
35700 enum insn_code impl; 35118 enum insn_code impl;
35701 unsigned char perm[16]; 35119 unsigned char perm[16];
35739 { 4, 5, 6, 7, 20, 21, 22, 23, 12, 13, 14, 15, 28, 29, 30, 31 } } 35157 { 4, 5, 6, 7, 20, 21, 22, 23, 12, 13, 14, 15, 28, 29, 30, 31 } }
35740 }; 35158 };
35741 35159
35742 unsigned int i, j, elt, which; 35160 unsigned int i, j, elt, which;
35743 unsigned char perm[16]; 35161 unsigned char perm[16];
35744 rtx target, op0, op1, sel, x; 35162 rtx x;
35745 bool one_vec; 35163 bool one_vec;
35746
35747 target = operands[0];
35748 op0 = operands[1];
35749 op1 = operands[2];
35750 sel = operands[3];
35751 35164
35752 /* Unpack the constant selector. */ 35165 /* Unpack the constant selector. */
35753 for (i = which = 0; i < 16; ++i) 35166 for (i = which = 0; i < 16; ++i)
35754 { 35167 {
35755 rtx e = XVECEXP (sel, 0, i); 35168 elt = sel[i] & 31;
35756 elt = INTVAL (e) & 31;
35757 which |= (elt < 16 ? 1 : 2); 35169 which |= (elt < 16 ? 1 : 2);
35758 perm[i] = elt; 35170 perm[i] = elt;
35759 } 35171 }
35760 35172
35761 /* Simplify the constant selector based on operands. */ 35173 /* Simplify the constant selector based on operands. */
35907 } 35319 }
35908 } 35320 }
35909 35321
35910 if (!BYTES_BIG_ENDIAN) 35322 if (!BYTES_BIG_ENDIAN)
35911 { 35323 {
35912 altivec_expand_vec_perm_const_le (operands); 35324 altivec_expand_vec_perm_const_le (target, op0, op1, sel);
35913 return true; 35325 return true;
35914 } 35326 }
35915 35327
35916 return false; 35328 return false;
35917 } 35329 }
35918 35330
35919 /* Expand a Paired Single or VSX Permute Doubleword constant permutation. 35331 /* Expand a VSX Permute Doubleword constant permutation.
35920 Return true if we match an efficient implementation. */ 35332 Return true if we match an efficient implementation. */
35921 35333
35922 static bool 35334 static bool
35923 rs6000_expand_vec_perm_const_1 (rtx target, rtx op0, rtx op1, 35335 rs6000_expand_vec_perm_const_1 (rtx target, rtx op0, rtx op1,
35924 unsigned char perm0, unsigned char perm1) 35336 unsigned char perm0, unsigned char perm1)
35967 emit_insn (gen_rtx_SET (target, x)); 35379 emit_insn (gen_rtx_SET (target, x));
35968 } 35380 }
35969 return true; 35381 return true;
35970 } 35382 }
35971 35383
35972 bool 35384 /* Implement TARGET_VECTORIZE_VEC_PERM_CONST. */
35973 rs6000_expand_vec_perm_const (rtx operands[4])
35974 {
35975 rtx target, op0, op1, sel;
35976 unsigned char perm0, perm1;
35977
35978 target = operands[0];
35979 op0 = operands[1];
35980 op1 = operands[2];
35981 sel = operands[3];
35982
35983 /* Unpack the constant selector. */
35984 perm0 = INTVAL (XVECEXP (sel, 0, 0)) & 3;
35985 perm1 = INTVAL (XVECEXP (sel, 0, 1)) & 3;
35986
35987 return rs6000_expand_vec_perm_const_1 (target, op0, op1, perm0, perm1);
35988 }
35989
35990 /* Test whether a constant permutation is supported. */
35991 35385
35992 static bool 35386 static bool
35993 rs6000_vectorize_vec_perm_const_ok (machine_mode vmode, vec_perm_indices sel) 35387 rs6000_vectorize_vec_perm_const (machine_mode vmode, rtx target, rtx op0,
35994 { 35388 rtx op1, const vec_perm_indices &sel)
35389 {
35390 bool testing_p = !target;
35391
35995 /* AltiVec (and thus VSX) can handle arbitrary permutations. */ 35392 /* AltiVec (and thus VSX) can handle arbitrary permutations. */
35393 if (TARGET_ALTIVEC && testing_p)
35394 return true;
35395
35396 /* Check for ps_merge* or xxpermdi insns. */
35397 if ((vmode == V2DFmode || vmode == V2DImode) && VECTOR_MEM_VSX_P (vmode))
35398 {
35399 if (testing_p)
35400 {
35401 op0 = gen_raw_REG (vmode, LAST_VIRTUAL_REGISTER + 1);
35402 op1 = gen_raw_REG (vmode, LAST_VIRTUAL_REGISTER + 2);
35403 }
35404 if (rs6000_expand_vec_perm_const_1 (target, op0, op1, sel[0], sel[1]))
35405 return true;
35406 }
35407
35996 if (TARGET_ALTIVEC) 35408 if (TARGET_ALTIVEC)
35997 return true; 35409 {
35998 35410 /* Force the target-independent code to lower to V16QImode. */
35999 /* Check for ps_merge* or evmerge* insns. */ 35411 if (vmode != V16QImode)
36000 if (TARGET_PAIRED_FLOAT && vmode == V2SFmode) 35412 return false;
36001 { 35413 if (altivec_expand_vec_perm_const (target, op0, op1, sel))
36002 rtx op0 = gen_raw_REG (vmode, LAST_VIRTUAL_REGISTER + 1); 35414 return true;
36003 rtx op1 = gen_raw_REG (vmode, LAST_VIRTUAL_REGISTER + 2);
36004 return rs6000_expand_vec_perm_const_1 (NULL, op0, op1, sel[0], sel[1]);
36005 } 35415 }
36006 35416
36007 return false; 35417 return false;
36008 } 35418 }
36009 35419
36010 /* A subroutine for rs6000_expand_extract_even & rs6000_expand_interleave. */ 35420 /* A subroutine for rs6000_expand_extract_even & rs6000_expand_interleave.
35421 OP0 and OP1 are the input vectors and TARGET is the output vector.
35422 PERM specifies the constant permutation vector. */
36011 35423
36012 static void 35424 static void
36013 rs6000_do_expand_vec_perm (rtx target, rtx op0, rtx op1, 35425 rs6000_do_expand_vec_perm (rtx target, rtx op0, rtx op1,
36014 machine_mode vmode, unsigned nelt, rtx perm[]) 35426 machine_mode vmode, const vec_perm_builder &perm)
36015 { 35427 {
36016 machine_mode imode; 35428 rtx x = expand_vec_perm_const (vmode, op0, op1, perm, BLKmode, target);
36017 rtx x;
36018
36019 imode = vmode;
36020 if (GET_MODE_CLASS (vmode) != MODE_VECTOR_INT)
36021 imode = mode_for_int_vector (vmode).require ();
36022
36023 x = gen_rtx_CONST_VECTOR (imode, gen_rtvec_v (nelt, perm));
36024 x = expand_vec_perm (vmode, op0, op1, x, target);
36025 if (x != target) 35429 if (x != target)
36026 emit_move_insn (target, x); 35430 emit_move_insn (target, x);
36027 } 35431 }
36028 35432
36029 /* Expand an extract even operation. */ 35433 /* Expand an extract even operation. */
36031 void 35435 void
36032 rs6000_expand_extract_even (rtx target, rtx op0, rtx op1) 35436 rs6000_expand_extract_even (rtx target, rtx op0, rtx op1)
36033 { 35437 {
36034 machine_mode vmode = GET_MODE (target); 35438 machine_mode vmode = GET_MODE (target);
36035 unsigned i, nelt = GET_MODE_NUNITS (vmode); 35439 unsigned i, nelt = GET_MODE_NUNITS (vmode);
36036 rtx perm[16]; 35440 vec_perm_builder perm (nelt, nelt, 1);
36037 35441
36038 for (i = 0; i < nelt; i++) 35442 for (i = 0; i < nelt; i++)
36039 perm[i] = GEN_INT (i * 2); 35443 perm.quick_push (i * 2);
36040 35444
36041 rs6000_do_expand_vec_perm (target, op0, op1, vmode, nelt, perm); 35445 rs6000_do_expand_vec_perm (target, op0, op1, vmode, perm);
36042 } 35446 }
36043 35447
36044 /* Expand a vector interleave operation. */ 35448 /* Expand a vector interleave operation. */
36045 35449
36046 void 35450 void
36047 rs6000_expand_interleave (rtx target, rtx op0, rtx op1, bool highp) 35451 rs6000_expand_interleave (rtx target, rtx op0, rtx op1, bool highp)
36048 { 35452 {
36049 machine_mode vmode = GET_MODE (target); 35453 machine_mode vmode = GET_MODE (target);
36050 unsigned i, high, nelt = GET_MODE_NUNITS (vmode); 35454 unsigned i, high, nelt = GET_MODE_NUNITS (vmode);
36051 rtx perm[16]; 35455 vec_perm_builder perm (nelt, nelt, 1);
36052 35456
36053 high = (highp ? 0 : nelt / 2); 35457 high = (highp ? 0 : nelt / 2);
36054 for (i = 0; i < nelt / 2; i++) 35458 for (i = 0; i < nelt / 2; i++)
36055 { 35459 {
36056 perm[i * 2] = GEN_INT (i + high); 35460 perm.quick_push (i + high);
36057 perm[i * 2 + 1] = GEN_INT (i + nelt + high); 35461 perm.quick_push (i + nelt + high);
36058 } 35462 }
36059 35463
36060 rs6000_do_expand_vec_perm (target, op0, op1, vmode, nelt, perm); 35464 rs6000_do_expand_vec_perm (target, op0, op1, vmode, perm);
36061 } 35465 }
36062 35466
36063 /* Scale a V2DF vector SRC by two to the SCALE and place in TGT. */ 35467 /* Scale a V2DF vector SRC by two to the SCALE and place in TGT. */
36064 void 35468 void
36065 rs6000_scale_v2df (rtx tgt, rtx src, int scale) 35469 rs6000_scale_v2df (rtx tgt, rtx src, int scale)
36213 35617
36214 if (DECIMAL_FLOAT_MODE_P (mode) && TARGET_HARD_FLOAT) 35618 if (DECIMAL_FLOAT_MODE_P (mode) && TARGET_HARD_FLOAT)
36215 /* _Decimal128 must use an even/odd register pair. */ 35619 /* _Decimal128 must use an even/odd register pair. */
36216 regno = (mode == TDmode) ? FP_ARG_RETURN + 1 : FP_ARG_RETURN; 35620 regno = (mode == TDmode) ? FP_ARG_RETURN + 1 : FP_ARG_RETURN;
36217 else if (SCALAR_FLOAT_TYPE_P (valtype) && TARGET_HARD_FLOAT 35621 else if (SCALAR_FLOAT_TYPE_P (valtype) && TARGET_HARD_FLOAT
36218 && !FLOAT128_VECTOR_P (mode) 35622 && !FLOAT128_VECTOR_P (mode))
36219 && ((TARGET_SINGLE_FLOAT && (mode == SFmode)) || TARGET_DOUBLE_FLOAT))
36220 regno = FP_ARG_RETURN; 35623 regno = FP_ARG_RETURN;
36221 else if (TREE_CODE (valtype) == COMPLEX_TYPE 35624 else if (TREE_CODE (valtype) == COMPLEX_TYPE
36222 && targetm.calls.split_complex_arg) 35625 && targetm.calls.split_complex_arg)
36223 return rs6000_complex_function_value (mode); 35626 return rs6000_complex_function_value (mode);
36224 /* VSX is a superset of Altivec and adds V2DImode/V2DFmode. Since the same 35627 /* VSX is a superset of Altivec and adds V2DImode/V2DFmode. Since the same
36246 return rs6000_parallel_return (mode, 2, SImode, GP_ARG_RETURN, 1); 35649 return rs6000_parallel_return (mode, 2, SImode, GP_ARG_RETURN, 1);
36247 35650
36248 if (DECIMAL_FLOAT_MODE_P (mode) && TARGET_HARD_FLOAT) 35651 if (DECIMAL_FLOAT_MODE_P (mode) && TARGET_HARD_FLOAT)
36249 /* _Decimal128 must use an even/odd register pair. */ 35652 /* _Decimal128 must use an even/odd register pair. */
36250 regno = (mode == TDmode) ? FP_ARG_RETURN + 1 : FP_ARG_RETURN; 35653 regno = (mode == TDmode) ? FP_ARG_RETURN + 1 : FP_ARG_RETURN;
36251 else if (SCALAR_FLOAT_MODE_NOT_VECTOR_P (mode) 35654 else if (SCALAR_FLOAT_MODE_NOT_VECTOR_P (mode) && TARGET_HARD_FLOAT)
36252 && TARGET_HARD_FLOAT
36253 && ((TARGET_SINGLE_FLOAT && mode == SFmode) || TARGET_DOUBLE_FLOAT))
36254 regno = FP_ARG_RETURN; 35655 regno = FP_ARG_RETURN;
36255 /* VSX is a superset of Altivec and adds V2DImode/V2DFmode. Since the same 35656 /* VSX is a superset of Altivec and adds V2DImode/V2DFmode. Since the same
36256 return register is used in both cases, and we won't see V2DImode/V2DFmode 35657 return register is used in both cases, and we won't see V2DImode/V2DFmode
36257 for pure altivec, combine the two cases. */ 35658 for pure altivec, combine the two cases. */
36258 else if (ALTIVEC_OR_VSX_VECTOR_MODE (mode) 35659 else if (ALTIVEC_OR_VSX_VECTOR_MODE (mode)
36419 rs6000_eh_return_filter_mode (void) 35820 rs6000_eh_return_filter_mode (void)
36420 { 35821 {
36421 return TARGET_32BIT ? SImode : word_mode; 35822 return TARGET_32BIT ? SImode : word_mode;
36422 } 35823 }
36423 35824
35825 /* Target hook for translate_mode_attribute. */
35826 static machine_mode
35827 rs6000_translate_mode_attribute (machine_mode mode)
35828 {
35829 if ((FLOAT128_IEEE_P (mode)
35830 && ieee128_float_type_node == long_double_type_node)
35831 || (FLOAT128_IBM_P (mode)
35832 && ibm128_float_type_node == long_double_type_node))
35833 return COMPLEX_MODE_P (mode) ? E_TCmode : E_TFmode;
35834 return mode;
35835 }
35836
36424 /* Target hook for scalar_mode_supported_p. */ 35837 /* Target hook for scalar_mode_supported_p. */
36425 static bool 35838 static bool
36426 rs6000_scalar_mode_supported_p (scalar_mode mode) 35839 rs6000_scalar_mode_supported_p (scalar_mode mode)
36427 { 35840 {
36428 /* -m32 does not support TImode. This is the default, from 35841 /* -m32 does not support TImode. This is the default, from
36443 35856
36444 /* Target hook for vector_mode_supported_p. */ 35857 /* Target hook for vector_mode_supported_p. */
36445 static bool 35858 static bool
36446 rs6000_vector_mode_supported_p (machine_mode mode) 35859 rs6000_vector_mode_supported_p (machine_mode mode)
36447 { 35860 {
36448
36449 if (TARGET_PAIRED_FLOAT && PAIRED_VECTOR_MODE (mode))
36450 return true;
36451
36452 /* There is no vector form for IEEE 128-bit. If we return true for IEEE 35861 /* There is no vector form for IEEE 128-bit. If we return true for IEEE
36453 128-bit, the compiler might try to widen IEEE 128-bit to IBM 35862 128-bit, the compiler might try to widen IEEE 128-bit to IBM
36454 double-double. */ 35863 double-double. */
36455 else if (VECTOR_MEM_ALTIVEC_OR_VSX_P (mode) && !FLOAT128_IEEE_P (mode)) 35864 if (VECTOR_MEM_ALTIVEC_OR_VSX_P (mode) && !FLOAT128_IEEE_P (mode))
36456 return true; 35865 return true;
36457 35866
36458 else 35867 else
36459 return false; 35868 return false;
36460 } 35869 }
36609 { "powerpc-gpopt", OPTION_MASK_PPC_GPOPT, false, true }, 36018 { "powerpc-gpopt", OPTION_MASK_PPC_GPOPT, false, true },
36610 { "quad-memory", OPTION_MASK_QUAD_MEMORY, false, true }, 36019 { "quad-memory", OPTION_MASK_QUAD_MEMORY, false, true },
36611 { "quad-memory-atomic", OPTION_MASK_QUAD_MEMORY_ATOMIC, false, true }, 36020 { "quad-memory-atomic", OPTION_MASK_QUAD_MEMORY_ATOMIC, false, true },
36612 { "recip-precision", OPTION_MASK_RECIP_PRECISION, false, true }, 36021 { "recip-precision", OPTION_MASK_RECIP_PRECISION, false, true },
36613 { "save-toc-indirect", OPTION_MASK_SAVE_TOC_INDIRECT, false, true }, 36022 { "save-toc-indirect", OPTION_MASK_SAVE_TOC_INDIRECT, false, true },
36614 { "string", OPTION_MASK_STRING, false, true }, 36023 { "string", 0, false, true },
36615 { "toc-fusion", OPTION_MASK_TOC_FUSION, false, true },
36616 { "update", OPTION_MASK_NO_UPDATE, true , true }, 36024 { "update", OPTION_MASK_NO_UPDATE, true , true },
36617 { "vsx", OPTION_MASK_VSX, false, true }, 36025 { "vsx", OPTION_MASK_VSX, false, true },
36618 #ifdef OPTION_MASK_64BIT 36026 #ifdef OPTION_MASK_64BIT
36619 #if TARGET_AIX_OS 36027 #if TARGET_AIX_OS
36620 { "aix64", OPTION_MASK_64BIT, false, false }, 36028 { "aix64", OPTION_MASK_64BIT, false, false },
36636 #endif 36044 #endif
36637 #ifdef OPTION_MASK_STRICT_ALIGN 36045 #ifdef OPTION_MASK_STRICT_ALIGN
36638 { "strict-align", OPTION_MASK_STRICT_ALIGN, false, false }, 36046 { "strict-align", OPTION_MASK_STRICT_ALIGN, false, false },
36639 #endif 36047 #endif
36640 { "soft-float", OPTION_MASK_SOFT_FLOAT, false, false }, 36048 { "soft-float", OPTION_MASK_SOFT_FLOAT, false, false },
36641 { "string", OPTION_MASK_STRING, false, false }, 36049 { "string", 0, false, false },
36642 }; 36050 };
36643 36051
36644 /* Builtin mask mapping for printing the flags. */ 36052 /* Builtin mask mapping for printing the flags. */
36645 static struct rs6000_opt_mask const rs6000_builtin_mask_names[] = 36053 static struct rs6000_opt_mask const rs6000_builtin_mask_names[] =
36646 { 36054 {
36647 { "altivec", RS6000_BTM_ALTIVEC, false, false }, 36055 { "altivec", RS6000_BTM_ALTIVEC, false, false },
36648 { "vsx", RS6000_BTM_VSX, false, false }, 36056 { "vsx", RS6000_BTM_VSX, false, false },
36649 { "paired", RS6000_BTM_PAIRED, false, false },
36650 { "fre", RS6000_BTM_FRE, false, false }, 36057 { "fre", RS6000_BTM_FRE, false, false },
36651 { "fres", RS6000_BTM_FRES, false, false }, 36058 { "fres", RS6000_BTM_FRES, false, false },
36652 { "frsqrte", RS6000_BTM_FRSQRTE, false, false }, 36059 { "frsqrte", RS6000_BTM_FRSQRTE, false, false },
36653 { "frsqrtes", RS6000_BTM_FRSQRTES, false, false }, 36060 { "frsqrtes", RS6000_BTM_FRSQRTES, false, false },
36654 { "popcntd", RS6000_BTM_POPCNTD, false, false }, 36061 { "popcntd", RS6000_BTM_POPCNTD, false, false },
36659 { "crypto", RS6000_BTM_CRYPTO, false, false }, 36066 { "crypto", RS6000_BTM_CRYPTO, false, false },
36660 { "htm", RS6000_BTM_HTM, false, false }, 36067 { "htm", RS6000_BTM_HTM, false, false },
36661 { "hard-dfp", RS6000_BTM_DFP, false, false }, 36068 { "hard-dfp", RS6000_BTM_DFP, false, false },
36662 { "hard-float", RS6000_BTM_HARD_FLOAT, false, false }, 36069 { "hard-float", RS6000_BTM_HARD_FLOAT, false, false },
36663 { "long-double-128", RS6000_BTM_LDBL128, false, false }, 36070 { "long-double-128", RS6000_BTM_LDBL128, false, false },
36071 { "powerpc64", RS6000_BTM_POWERPC64, false, false },
36664 { "float128", RS6000_BTM_FLOAT128, false, false }, 36072 { "float128", RS6000_BTM_FLOAT128, false, false },
36665 { "float128-hw", RS6000_BTM_FLOAT128_HW,false, false }, 36073 { "float128-hw", RS6000_BTM_FLOAT128_HW,false, false },
36666 }; 36074 };
36667 36075
36668 /* Option variables that we want to support inside attribute((target)) and 36076 /* Option variables that we want to support inside attribute((target)) and
36680 offsetof (struct gcc_options, x_TARGET_FRIZ), 36088 offsetof (struct gcc_options, x_TARGET_FRIZ),
36681 offsetof (struct cl_target_option, x_TARGET_FRIZ), }, 36089 offsetof (struct cl_target_option, x_TARGET_FRIZ), },
36682 { "avoid-indexed-addresses", 36090 { "avoid-indexed-addresses",
36683 offsetof (struct gcc_options, x_TARGET_AVOID_XFORM), 36091 offsetof (struct gcc_options, x_TARGET_AVOID_XFORM),
36684 offsetof (struct cl_target_option, x_TARGET_AVOID_XFORM) }, 36092 offsetof (struct cl_target_option, x_TARGET_AVOID_XFORM) },
36685 { "paired",
36686 offsetof (struct gcc_options, x_rs6000_paired_float),
36687 offsetof (struct cl_target_option, x_rs6000_paired_float), },
36688 { "longcall", 36093 { "longcall",
36689 offsetof (struct gcc_options, x_rs6000_default_long_calls), 36094 offsetof (struct gcc_options, x_rs6000_default_long_calls),
36690 offsetof (struct cl_target_option, x_rs6000_default_long_calls), }, 36095 offsetof (struct cl_target_option, x_rs6000_default_long_calls), },
36691 { "optimize-swaps", 36096 { "optimize-swaps",
36692 offsetof (struct gcc_options, x_rs6000_optimize_swaps), 36097 offsetof (struct gcc_options, x_rs6000_optimize_swaps),
36710 offsetof (struct gcc_options, x_TARGET_SCHED_PROLOG), 36115 offsetof (struct gcc_options, x_TARGET_SCHED_PROLOG),
36711 offsetof (struct cl_target_option, x_TARGET_SCHED_PROLOG), }, 36116 offsetof (struct cl_target_option, x_TARGET_SCHED_PROLOG), },
36712 { "sched-epilog", 36117 { "sched-epilog",
36713 offsetof (struct gcc_options, x_TARGET_SCHED_PROLOG), 36118 offsetof (struct gcc_options, x_TARGET_SCHED_PROLOG),
36714 offsetof (struct cl_target_option, x_TARGET_SCHED_PROLOG), }, 36119 offsetof (struct cl_target_option, x_TARGET_SCHED_PROLOG), },
36120 { "speculate-indirect-jumps",
36121 offsetof (struct gcc_options, x_rs6000_speculate_indirect_jumps),
36122 offsetof (struct cl_target_option, x_rs6000_speculate_indirect_jumps), },
36715 }; 36123 };
36716 36124
36717 /* Inner function to handle attribute((target("..."))) and #pragma GCC target 36125 /* Inner function to handle attribute((target("..."))) and #pragma GCC target
36718 parsing. Return true if there were no errors. */ 36126 parsing. Return true if there were no errors. */
36719 36127
37896 { 37304 {
37897 rtx addr; 37305 rtx addr;
37898 37306
37899 gcc_assert (MEM_P (x)); 37307 gcc_assert (MEM_P (x));
37900 addr = XEXP (x, 0); 37308 addr = XEXP (x, 0);
37901 if (! legitimate_indirect_address_p (addr, reload_completed) 37309 if (can_create_pseudo_p ()
37310 && ! legitimate_indirect_address_p (addr, reload_completed)
37902 && ! legitimate_indexed_address_p (addr, reload_completed)) 37311 && ! legitimate_indexed_address_p (addr, reload_completed))
37903 { 37312 {
37904 if (GET_CODE (addr) == PRE_INC || GET_CODE (addr) == PRE_DEC) 37313 if (GET_CODE (addr) == PRE_INC || GET_CODE (addr) == PRE_DEC)
37905 { 37314 {
37906 rtx reg = XEXP (addr, 0); 37315 rtx reg = XEXP (addr, 0);
37919 emit_insn (gen_add3_insn (reg, XEXP (expr, 0), XEXP (expr, 1))); 37328 emit_insn (gen_add3_insn (reg, XEXP (expr, 0), XEXP (expr, 1)));
37920 addr = reg; 37329 addr = reg;
37921 } 37330 }
37922 37331
37923 x = replace_equiv_address (x, copy_addr_to_reg (addr)); 37332 x = replace_equiv_address (x, copy_addr_to_reg (addr));
37924 }
37925
37926 return x;
37927 }
37928
37929 /* Given a memory reference, if it is not in the form for altivec memory
37930 reference instructions (i.e. reg or reg+reg addressing with AND of -16),
37931 convert to the altivec format. */
37932
37933 rtx
37934 rs6000_address_for_altivec (rtx x)
37935 {
37936 gcc_assert (MEM_P (x));
37937 if (!altivec_indexed_or_indirect_operand (x, GET_MODE (x)))
37938 {
37939 rtx addr = XEXP (x, 0);
37940
37941 if (!legitimate_indexed_address_p (addr, reload_completed)
37942 && !legitimate_indirect_address_p (addr, reload_completed))
37943 addr = copy_to_mode_reg (Pmode, addr);
37944
37945 addr = gen_rtx_AND (Pmode, addr, GEN_INT (-16));
37946 x = change_address (x, GET_MODE (x), addr);
37947 } 37333 }
37948 37334
37949 return x; 37335 return x;
37950 } 37336 }
37951 37337
38639 38025
38640 /* Emit the addis instruction that will be part of a fused instruction 38026 /* Emit the addis instruction that will be part of a fused instruction
38641 sequence. */ 38027 sequence. */
38642 38028
38643 void 38029 void
38644 emit_fusion_addis (rtx target, rtx addis_value, const char *comment, 38030 emit_fusion_addis (rtx target, rtx addis_value)
38645 const char *mode_name)
38646 { 38031 {
38647 rtx fuse_ops[10]; 38032 rtx fuse_ops[10];
38648 char insn_template[80];
38649 const char *addis_str = NULL; 38033 const char *addis_str = NULL;
38650 const char *comment_str = ASM_COMMENT_START;
38651
38652 if (*comment_str == ' ')
38653 comment_str++;
38654 38034
38655 /* Emit the addis instruction. */ 38035 /* Emit the addis instruction. */
38656 fuse_ops[0] = target; 38036 fuse_ops[0] = target;
38657 if (satisfies_constraint_L (addis_value)) 38037 if (satisfies_constraint_L (addis_value))
38658 { 38038 {
38728 } 38108 }
38729 38109
38730 if (!addis_str) 38110 if (!addis_str)
38731 fatal_insn ("Could not generate addis value for fusion", addis_value); 38111 fatal_insn ("Could not generate addis value for fusion", addis_value);
38732 38112
38733 sprintf (insn_template, "%s\t\t%s %s, type %s", addis_str, comment_str, 38113 output_asm_insn (addis_str, fuse_ops);
38734 comment, mode_name);
38735 output_asm_insn (insn_template, fuse_ops);
38736 } 38114 }
38737 38115
38738 /* Emit a D-form load or store instruction that is the second instruction 38116 /* Emit a D-form load or store instruction that is the second instruction
38739 of a fusion sequence. */ 38117 of a fusion sequence. */
38740 38118
38803 fatal_insn ("Unable to generate load/store offset for fusion", offset); 38181 fatal_insn ("Unable to generate load/store offset for fusion", offset);
38804 38182
38805 return; 38183 return;
38806 } 38184 }
38807 38185
38808 /* Wrap a TOC address that can be fused to indicate that special fusion
38809 processing is needed. */
38810
38811 rtx
38812 fusion_wrap_memory_address (rtx old_mem)
38813 {
38814 rtx old_addr = XEXP (old_mem, 0);
38815 rtvec v = gen_rtvec (1, old_addr);
38816 rtx new_addr = gen_rtx_UNSPEC (Pmode, v, UNSPEC_FUSION_ADDIS);
38817 return replace_equiv_address_nv (old_mem, new_addr, false);
38818 }
38819
38820 /* Given an address, convert it into the addis and load offset parts. Addresses 38186 /* Given an address, convert it into the addis and load offset parts. Addresses
38821 created during the peephole2 process look like: 38187 created during the peephole2 process look like:
38822 (lo_sum (high (unspec [(sym)] UNSPEC_TOCREL)) 38188 (lo_sum (high (unspec [(sym)] UNSPEC_TOCREL))
38823 (unspec [(...)] UNSPEC_TOCREL)) 38189 (unspec [(...)] UNSPEC_TOCREL)) */
38824
38825 Addresses created via toc fusion look like:
38826 (unspec [(unspec [(...)] UNSPEC_TOCREL)] UNSPEC_FUSION_ADDIS)) */
38827 38190
38828 static void 38191 static void
38829 fusion_split_address (rtx addr, rtx *p_hi, rtx *p_lo) 38192 fusion_split_address (rtx addr, rtx *p_hi, rtx *p_lo)
38830 { 38193 {
38831 rtx hi, lo; 38194 rtx hi, lo;
38832 38195
38833 if (GET_CODE (addr) == UNSPEC && XINT (addr, 1) == UNSPEC_FUSION_ADDIS) 38196 if (GET_CODE (addr) == PLUS || GET_CODE (addr) == LO_SUM)
38834 {
38835 lo = XVECEXP (addr, 0, 0);
38836 hi = gen_rtx_HIGH (Pmode, lo);
38837 }
38838 else if (GET_CODE (addr) == PLUS || GET_CODE (addr) == LO_SUM)
38839 { 38197 {
38840 hi = XEXP (addr, 0); 38198 hi = XEXP (addr, 0);
38841 lo = XEXP (addr, 1); 38199 lo = XEXP (addr, 1);
38842 } 38200 }
38843 else 38201 else
38850 /* Return a string to fuse an addis instruction with a gpr load to the same 38208 /* Return a string to fuse an addis instruction with a gpr load to the same
38851 register that we loaded up the addis instruction. The address that is used 38209 register that we loaded up the addis instruction. The address that is used
38852 is the logical address that was formed during peephole2: 38210 is the logical address that was formed during peephole2:
38853 (lo_sum (high) (low-part)) 38211 (lo_sum (high) (low-part))
38854 38212
38855 Or the address is the TOC address that is wrapped before register allocation:
38856 (unspec [(addr) (toc-reg)] UNSPEC_FUSION_ADDIS)
38857
38858 The code is complicated, so we call output_asm_insn directly, and just 38213 The code is complicated, so we call output_asm_insn directly, and just
38859 return "". */ 38214 return "". */
38860 38215
38861 const char * 38216 const char *
38862 emit_fusion_gpr_load (rtx target, rtx mem) 38217 emit_fusion_gpr_load (rtx target, rtx mem)
38863 { 38218 {
38864 rtx addis_value; 38219 rtx addis_value;
38865 rtx addr; 38220 rtx addr;
38866 rtx load_offset; 38221 rtx load_offset;
38867 const char *load_str = NULL; 38222 const char *load_str = NULL;
38868 const char *mode_name = NULL;
38869 machine_mode mode; 38223 machine_mode mode;
38870 38224
38871 if (GET_CODE (mem) == ZERO_EXTEND) 38225 if (GET_CODE (mem) == ZERO_EXTEND)
38872 mem = XEXP (mem, 0); 38226 mem = XEXP (mem, 0);
38873 38227
38879 /* Now emit the load instruction to the same register. */ 38233 /* Now emit the load instruction to the same register. */
38880 mode = GET_MODE (mem); 38234 mode = GET_MODE (mem);
38881 switch (mode) 38235 switch (mode)
38882 { 38236 {
38883 case E_QImode: 38237 case E_QImode:
38884 mode_name = "char";
38885 load_str = "lbz"; 38238 load_str = "lbz";
38886 break; 38239 break;
38887 38240
38888 case E_HImode: 38241 case E_HImode:
38889 mode_name = "short";
38890 load_str = "lhz"; 38242 load_str = "lhz";
38891 break; 38243 break;
38892 38244
38893 case E_SImode: 38245 case E_SImode:
38894 case E_SFmode: 38246 case E_SFmode:
38895 mode_name = (mode == SFmode) ? "float" : "int";
38896 load_str = "lwz"; 38247 load_str = "lwz";
38897 break; 38248 break;
38898 38249
38899 case E_DImode: 38250 case E_DImode:
38900 case E_DFmode: 38251 case E_DFmode:
38901 gcc_assert (TARGET_POWERPC64); 38252 gcc_assert (TARGET_POWERPC64);
38902 mode_name = (mode == DFmode) ? "double" : "long";
38903 load_str = "ld"; 38253 load_str = "ld";
38904 break; 38254 break;
38905 38255
38906 default: 38256 default:
38907 fatal_insn ("Bad GPR fusion", gen_rtx_SET (target, mem)); 38257 fatal_insn ("Bad GPR fusion", gen_rtx_SET (target, mem));
38908 } 38258 }
38909 38259
38910 /* Emit the addis instruction. */ 38260 /* Emit the addis instruction. */
38911 emit_fusion_addis (target, addis_value, "gpr load fusion", mode_name); 38261 emit_fusion_addis (target, addis_value);
38912 38262
38913 /* Emit the D-form load instruction. */ 38263 /* Emit the D-form load instruction. */
38914 emit_fusion_load_store (target, target, load_offset, load_str); 38264 emit_fusion_load_store (target, target, load_offset, load_str);
38915 38265
38916 return ""; 38266 return "";
39175 38525
39176 addr = XEXP (mem, 0); 38526 addr = XEXP (mem, 0);
39177 fusion_split_address (addr, &hi, &lo); 38527 fusion_split_address (addr, &hi, &lo);
39178 38528
39179 /* Emit the addis instruction. */ 38529 /* Emit the addis instruction. */
39180 emit_fusion_addis (tmp_reg, hi, "power9 load fusion", GET_MODE_NAME (mode)); 38530 emit_fusion_addis (tmp_reg, hi);
39181 38531
39182 /* Emit the D-form load instruction. */ 38532 /* Emit the D-form load instruction. */
39183 emit_fusion_load_store (reg, tmp_reg, lo, load_string); 38533 emit_fusion_load_store (reg, tmp_reg, lo, load_string);
39184 38534
39185 return ""; 38535 return "";
39262 38612
39263 addr = XEXP (mem, 0); 38613 addr = XEXP (mem, 0);
39264 fusion_split_address (addr, &hi, &lo); 38614 fusion_split_address (addr, &hi, &lo);
39265 38615
39266 /* Emit the addis instruction. */ 38616 /* Emit the addis instruction. */
39267 emit_fusion_addis (tmp_reg, hi, "power9 store fusion", GET_MODE_NAME (mode)); 38617 emit_fusion_addis (tmp_reg, hi);
39268 38618
39269 /* Emit the D-form load instruction. */ 38619 /* Emit the D-form load instruction. */
39270 emit_fusion_load_store (reg, tmp_reg, lo, store_string); 38620 emit_fusion_load_store (reg, tmp_reg, lo, store_string);
39271 38621
39272 return ""; 38622 return "";
39436 38786
39437 *update = build2 (COMPOUND_EXPR, void_type_node, update_mffs, update_mtfsf); 38787 *update = build2 (COMPOUND_EXPR, void_type_node, update_mffs, update_mtfsf);
39438 } 38788 }
39439 38789
39440 void 38790 void
39441 rs6000_generate_float2_code (bool signed_convert, rtx dst, rtx src1, rtx src2) 38791 rs6000_generate_float2_double_code (rtx dst, rtx src1, rtx src2)
39442 { 38792 {
39443 rtx rtx_tmp0, rtx_tmp1, rtx_tmp2, rtx_tmp3; 38793 rtx rtx_tmp0, rtx_tmp1, rtx_tmp2, rtx_tmp3;
39444 38794
39445 rtx_tmp0 = gen_reg_rtx (V2DImode); 38795 rtx_tmp0 = gen_reg_rtx (V2DFmode);
39446 rtx_tmp1 = gen_reg_rtx (V2DImode); 38796 rtx_tmp1 = gen_reg_rtx (V2DFmode);
39447 38797
39448 /* The destination of the vmrgew instruction layout is: 38798 /* The destination of the vmrgew instruction layout is:
39449 rtx_tmp2[0] rtx_tmp3[0] rtx_tmp2[1] rtx_tmp3[0]. 38799 rtx_tmp2[0] rtx_tmp3[0] rtx_tmp2[1] rtx_tmp3[0].
39450 Setup rtx_tmp0 and rtx_tmp1 to ensure the order of the elements after the 38800 Setup rtx_tmp0 and rtx_tmp1 to ensure the order of the elements after the
39451 vmrgew instruction will be correct. */ 38801 vmrgew instruction will be correct. */
39452 if (VECTOR_ELT_ORDER_BIG) 38802 if (BYTES_BIG_ENDIAN)
38803 {
38804 emit_insn (gen_vsx_xxpermdi_v2df_be (rtx_tmp0, src1, src2,
38805 GEN_INT (0)));
38806 emit_insn (gen_vsx_xxpermdi_v2df_be (rtx_tmp1, src1, src2,
38807 GEN_INT (3)));
38808 }
38809 else
38810 {
38811 emit_insn (gen_vsx_xxpermdi_v2df (rtx_tmp0, src1, src2, GEN_INT (3)));
38812 emit_insn (gen_vsx_xxpermdi_v2df (rtx_tmp1, src1, src2, GEN_INT (0)));
38813 }
38814
38815 rtx_tmp2 = gen_reg_rtx (V4SFmode);
38816 rtx_tmp3 = gen_reg_rtx (V4SFmode);
38817
38818 emit_insn (gen_vsx_xvcdpsp (rtx_tmp2, rtx_tmp0));
38819 emit_insn (gen_vsx_xvcdpsp (rtx_tmp3, rtx_tmp1));
38820
38821 if (BYTES_BIG_ENDIAN)
38822 emit_insn (gen_p8_vmrgew_v4sf (dst, rtx_tmp2, rtx_tmp3));
38823 else
38824 emit_insn (gen_p8_vmrgew_v4sf (dst, rtx_tmp3, rtx_tmp2));
38825 }
38826
38827 void
38828 rs6000_generate_float2_code (bool signed_convert, rtx dst, rtx src1, rtx src2)
38829 {
38830 rtx rtx_tmp0, rtx_tmp1, rtx_tmp2, rtx_tmp3;
38831
38832 rtx_tmp0 = gen_reg_rtx (V2DImode);
38833 rtx_tmp1 = gen_reg_rtx (V2DImode);
38834
38835 /* The destination of the vmrgew instruction layout is:
38836 rtx_tmp2[0] rtx_tmp3[0] rtx_tmp2[1] rtx_tmp3[0].
38837 Setup rtx_tmp0 and rtx_tmp1 to ensure the order of the elements after the
38838 vmrgew instruction will be correct. */
38839 if (BYTES_BIG_ENDIAN)
39453 { 38840 {
39454 emit_insn (gen_vsx_xxpermdi_v2di_be (rtx_tmp0, src1, src2, GEN_INT (0))); 38841 emit_insn (gen_vsx_xxpermdi_v2di_be (rtx_tmp0, src1, src2, GEN_INT (0)));
39455 emit_insn (gen_vsx_xxpermdi_v2di_be (rtx_tmp1, src1, src2, GEN_INT (3))); 38842 emit_insn (gen_vsx_xxpermdi_v2di_be (rtx_tmp1, src1, src2, GEN_INT (3)));
39456 } 38843 }
39457 else 38844 else
39472 { 38859 {
39473 emit_insn (gen_vsx_xvcvuxdsp (rtx_tmp2, rtx_tmp0)); 38860 emit_insn (gen_vsx_xvcvuxdsp (rtx_tmp2, rtx_tmp0));
39474 emit_insn (gen_vsx_xvcvuxdsp (rtx_tmp3, rtx_tmp1)); 38861 emit_insn (gen_vsx_xvcvuxdsp (rtx_tmp3, rtx_tmp1));
39475 } 38862 }
39476 38863
39477 if (VECTOR_ELT_ORDER_BIG) 38864 if (BYTES_BIG_ENDIAN)
39478 emit_insn (gen_p8_vmrgew_v4sf (dst, rtx_tmp2, rtx_tmp3)); 38865 emit_insn (gen_p8_vmrgew_v4sf (dst, rtx_tmp2, rtx_tmp3));
39479 else 38866 else
39480 emit_insn (gen_p8_vmrgew_v4sf (dst, rtx_tmp3, rtx_tmp2)); 38867 emit_insn (gen_p8_vmrgew_v4sf (dst, rtx_tmp3, rtx_tmp2));
39481 } 38868 }
39482 38869
39545 if (FRAME_GROWS_DOWNWARD) 38932 if (FRAME_GROWS_DOWNWARD)
39546 return 0; 38933 return 0;
39547 return RS6000_STARTING_FRAME_OFFSET; 38934 return RS6000_STARTING_FRAME_OFFSET;
39548 } 38935 }
39549 38936
38937
38938 /* Create an alias for a mangled name where we have changed the mangling (in
38939 GCC 8.1, we used U10__float128, and now we use u9__ieee128). This is called
38940 via the target hook TARGET_ASM_GLOBALIZE_DECL_NAME. */
38941
38942 #if TARGET_ELF && RS6000_WEAK
38943 static void
38944 rs6000_globalize_decl_name (FILE * stream, tree decl)
38945 {
38946 const char *name = XSTR (XEXP (DECL_RTL (decl), 0), 0);
38947
38948 targetm.asm_out.globalize_label (stream, name);
38949
38950 if (rs6000_passes_ieee128 && name[0] == '_' && name[1] == 'Z')
38951 {
38952 tree save_asm_name = DECL_ASSEMBLER_NAME (decl);
38953 const char *old_name;
38954
38955 ieee128_mangling_gcc_8_1 = true;
38956 lang_hooks.set_decl_assembler_name (decl);
38957 old_name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
38958 SET_DECL_ASSEMBLER_NAME (decl, save_asm_name);
38959 ieee128_mangling_gcc_8_1 = false;
38960
38961 if (strcmp (name, old_name) != 0)
38962 {
38963 fprintf (stream, "\t.weak %s\n", old_name);
38964 fprintf (stream, "\t.set %s,%s\n", old_name, name);
38965 }
38966 }
38967 }
38968 #endif
38969
38970
38971 /* On 64-bit Linux and Freebsd systems, possibly switch the long double library
38972 function names from <foo>l to <foo>f128 if the default long double type is
38973 IEEE 128-bit. Typically, with the C and C++ languages, the standard math.h
38974 include file switches the names on systems that support long double as IEEE
38975 128-bit, but that doesn't work if the user uses __builtin_<foo>l directly.
38976 In the future, glibc will export names like __ieee128_sinf128 and we can
38977 switch to using those instead of using sinf128, which pollutes the user's
38978 namespace.
38979
38980 This will switch the names for Fortran math functions as well (which doesn't
38981 use math.h). However, Fortran needs other changes to the compiler and
38982 library before you can switch the real*16 type at compile time.
38983
38984 We use the TARGET_MANGLE_DECL_ASSEMBLER_NAME hook to change this name. We
38985 only do this if the default is that long double is IBM extended double, and
38986 the user asked for IEEE 128-bit. */
38987
38988 static tree
38989 rs6000_mangle_decl_assembler_name (tree decl, tree id)
38990 {
38991 if (!TARGET_IEEEQUAD_DEFAULT && TARGET_IEEEQUAD && TARGET_LONG_DOUBLE_128
38992 && TREE_CODE (decl) == FUNCTION_DECL && DECL_IS_BUILTIN (decl) )
38993 {
38994 size_t len = IDENTIFIER_LENGTH (id);
38995 const char *name = IDENTIFIER_POINTER (id);
38996
38997 if (name[len - 1] == 'l')
38998 {
38999 bool uses_ieee128_p = false;
39000 tree type = TREE_TYPE (decl);
39001 machine_mode ret_mode = TYPE_MODE (type);
39002
39003 /* See if the function returns a IEEE 128-bit floating point type or
39004 complex type. */
39005 if (ret_mode == TFmode || ret_mode == TCmode)
39006 uses_ieee128_p = true;
39007 else
39008 {
39009 function_args_iterator args_iter;
39010 tree arg;
39011
39012 /* See if the function passes a IEEE 128-bit floating point type
39013 or complex type. */
39014 FOREACH_FUNCTION_ARGS (type, arg, args_iter)
39015 {
39016 machine_mode arg_mode = TYPE_MODE (arg);
39017 if (arg_mode == TFmode || arg_mode == TCmode)
39018 {
39019 uses_ieee128_p = true;
39020 break;
39021 }
39022 }
39023 }
39024
39025 /* If we passed or returned an IEEE 128-bit floating point type,
39026 change the name. */
39027 if (uses_ieee128_p)
39028 {
39029 char *name2 = (char *) alloca (len + 4);
39030 memcpy (name2, name, len - 1);
39031 strcpy (name2 + len - 1, "f128");
39032 id = get_identifier (name2);
39033 }
39034 }
39035 }
39036
39037 return id;
39038 }
39039
39040
39550 struct gcc_target targetm = TARGET_INITIALIZER; 39041 struct gcc_target targetm = TARGET_INITIALIZER;
39551 39042
39552 #include "gt-rs6000.h" 39043 #include "gt-rs6000.h"