Mercurial > hg > CbC > CbC_gcc
comparison gcc/expr.c @ 67:f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
author | nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 22 Mar 2011 17:18:12 +0900 |
parents | b7f97abdc517 |
children | 04ced10e8804 |
comparison
equal
deleted
inserted
replaced
65:65488c3d617d | 67:f6334be47118 |
---|---|
1 /* Convert tree expression to rtl instructions, for GNU compiler. | 1 /* Convert tree expression to rtl instructions, for GNU compiler. |
2 Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, | 2 Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, |
3 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 | 3 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 |
4 Free Software Foundation, Inc. | 4 Free Software Foundation, Inc. |
5 | 5 |
6 This file is part of GCC. | 6 This file is part of GCC. |
7 | 7 |
8 GCC is free software; you can redistribute it and/or modify it under | 8 GCC is free software; you can redistribute it and/or modify it under |
51 #include "target.h" | 51 #include "target.h" |
52 #include "timevar.h" | 52 #include "timevar.h" |
53 #include "df.h" | 53 #include "df.h" |
54 #include "diagnostic.h" | 54 #include "diagnostic.h" |
55 #include "ssaexpand.h" | 55 #include "ssaexpand.h" |
56 #include "target-globals.h" | |
56 | 57 |
57 /* Decide whether a function's arguments should be processed | 58 /* Decide whether a function's arguments should be processed |
58 from first to last or from last to first. | 59 from first to last or from last to first. |
59 | 60 |
60 They should if the stack and args grow in opposite directions, but | 61 They should if the stack and args grow in opposite directions, but |
156 #endif | 157 #endif |
157 static void do_tablejump (rtx, enum machine_mode, rtx, rtx, rtx); | 158 static void do_tablejump (rtx, enum machine_mode, rtx, rtx, rtx); |
158 static rtx const_vector_from_tree (tree); | 159 static rtx const_vector_from_tree (tree); |
159 static void write_complex_part (rtx, rtx, bool); | 160 static void write_complex_part (rtx, rtx, bool); |
160 | 161 |
161 /* Record for each mode whether we can move a register directly to or | |
162 from an object of that mode in memory. If we can't, we won't try | |
163 to use that mode directly when accessing a field of that mode. */ | |
164 | |
165 static char direct_load[NUM_MACHINE_MODES]; | |
166 static char direct_store[NUM_MACHINE_MODES]; | |
167 | |
168 /* Record for each mode whether we can float-extend from memory. */ | |
169 | |
170 static bool float_extend_from_mem[NUM_MACHINE_MODES][NUM_MACHINE_MODES]; | |
171 | |
172 /* This macro is used to determine whether move_by_pieces should be called | 162 /* This macro is used to determine whether move_by_pieces should be called |
173 to perform a structure copy. */ | 163 to perform a structure copy. */ |
174 #ifndef MOVE_BY_PIECES_P | 164 #ifndef MOVE_BY_PIECES_P |
175 #define MOVE_BY_PIECES_P(SIZE, ALIGN) \ | 165 #define MOVE_BY_PIECES_P(SIZE, ALIGN) \ |
176 (move_by_pieces_ninsns (SIZE, ALIGN, MOVE_MAX_PIECES + 1) \ | 166 (move_by_pieces_ninsns (SIZE, ALIGN, MOVE_MAX_PIECES + 1) \ |
198 #ifndef STORE_BY_PIECES_P | 188 #ifndef STORE_BY_PIECES_P |
199 #define STORE_BY_PIECES_P(SIZE, ALIGN) \ | 189 #define STORE_BY_PIECES_P(SIZE, ALIGN) \ |
200 (move_by_pieces_ninsns (SIZE, ALIGN, STORE_MAX_PIECES + 1) \ | 190 (move_by_pieces_ninsns (SIZE, ALIGN, STORE_MAX_PIECES + 1) \ |
201 < (unsigned int) MOVE_RATIO (optimize_insn_for_speed_p ())) | 191 < (unsigned int) MOVE_RATIO (optimize_insn_for_speed_p ())) |
202 #endif | 192 #endif |
203 | |
204 /* This array records the insn_code of insns to perform block moves. */ | |
205 enum insn_code movmem_optab[NUM_MACHINE_MODES]; | |
206 | |
207 /* This array records the insn_code of insns to perform block sets. */ | |
208 enum insn_code setmem_optab[NUM_MACHINE_MODES]; | |
209 | |
210 /* These arrays record the insn_code of three different kinds of insns | |
211 to perform block compares. */ | |
212 enum insn_code cmpstr_optab[NUM_MACHINE_MODES]; | |
213 enum insn_code cmpstrn_optab[NUM_MACHINE_MODES]; | |
214 enum insn_code cmpmem_optab[NUM_MACHINE_MODES]; | |
215 | |
216 /* Synchronization primitives. */ | |
217 enum insn_code sync_add_optab[NUM_MACHINE_MODES]; | |
218 enum insn_code sync_sub_optab[NUM_MACHINE_MODES]; | |
219 enum insn_code sync_ior_optab[NUM_MACHINE_MODES]; | |
220 enum insn_code sync_and_optab[NUM_MACHINE_MODES]; | |
221 enum insn_code sync_xor_optab[NUM_MACHINE_MODES]; | |
222 enum insn_code sync_nand_optab[NUM_MACHINE_MODES]; | |
223 enum insn_code sync_old_add_optab[NUM_MACHINE_MODES]; | |
224 enum insn_code sync_old_sub_optab[NUM_MACHINE_MODES]; | |
225 enum insn_code sync_old_ior_optab[NUM_MACHINE_MODES]; | |
226 enum insn_code sync_old_and_optab[NUM_MACHINE_MODES]; | |
227 enum insn_code sync_old_xor_optab[NUM_MACHINE_MODES]; | |
228 enum insn_code sync_old_nand_optab[NUM_MACHINE_MODES]; | |
229 enum insn_code sync_new_add_optab[NUM_MACHINE_MODES]; | |
230 enum insn_code sync_new_sub_optab[NUM_MACHINE_MODES]; | |
231 enum insn_code sync_new_ior_optab[NUM_MACHINE_MODES]; | |
232 enum insn_code sync_new_and_optab[NUM_MACHINE_MODES]; | |
233 enum insn_code sync_new_xor_optab[NUM_MACHINE_MODES]; | |
234 enum insn_code sync_new_nand_optab[NUM_MACHINE_MODES]; | |
235 enum insn_code sync_compare_and_swap[NUM_MACHINE_MODES]; | |
236 enum insn_code sync_lock_test_and_set[NUM_MACHINE_MODES]; | |
237 enum insn_code sync_lock_release[NUM_MACHINE_MODES]; | |
238 | 193 |
239 /* SLOW_UNALIGNED_ACCESS is nonzero if unaligned accesses are very slow. */ | 194 /* SLOW_UNALIGNED_ACCESS is nonzero if unaligned accesses are very slow. */ |
240 | 195 |
241 #ifndef SLOW_UNALIGNED_ACCESS | 196 #ifndef SLOW_UNALIGNED_ACCESS |
242 #define SLOW_UNALIGNED_ACCESS(MODE, ALIGN) STRICT_ALIGNMENT | 197 #define SLOW_UNALIGNED_ACCESS(MODE, ALIGN) STRICT_ALIGNMENT |
432 else | 387 else |
433 tab = trunc_optab; | 388 tab = trunc_optab; |
434 | 389 |
435 /* Try converting directly if the insn is supported. */ | 390 /* Try converting directly if the insn is supported. */ |
436 | 391 |
437 code = convert_optab_handler (tab, to_mode, from_mode)->insn_code; | 392 code = convert_optab_handler (tab, to_mode, from_mode); |
438 if (code != CODE_FOR_nothing) | 393 if (code != CODE_FOR_nothing) |
439 { | 394 { |
440 emit_unop_insn (code, to, from, | 395 emit_unop_insn (code, to, from, |
441 tab == sext_optab ? FLOAT_EXTEND : FLOAT_TRUNCATE); | 396 tab == sext_optab ? FLOAT_EXTEND : FLOAT_TRUNCATE); |
442 return; | 397 return; |
466 if (GET_MODE_CLASS (to_mode) == MODE_PARTIAL_INT) | 421 if (GET_MODE_CLASS (to_mode) == MODE_PARTIAL_INT) |
467 { | 422 { |
468 enum machine_mode full_mode | 423 enum machine_mode full_mode |
469 = smallest_mode_for_size (GET_MODE_BITSIZE (to_mode), MODE_INT); | 424 = smallest_mode_for_size (GET_MODE_BITSIZE (to_mode), MODE_INT); |
470 | 425 |
471 gcc_assert (convert_optab_handler (trunc_optab, to_mode, full_mode)->insn_code | 426 gcc_assert (convert_optab_handler (trunc_optab, to_mode, full_mode) |
472 != CODE_FOR_nothing); | 427 != CODE_FOR_nothing); |
473 | 428 |
474 if (full_mode != from_mode) | 429 if (full_mode != from_mode) |
475 from = convert_to_mode (full_mode, from, unsignedp); | 430 from = convert_to_mode (full_mode, from, unsignedp); |
476 emit_unop_insn (convert_optab_handler (trunc_optab, to_mode, full_mode)->insn_code, | 431 emit_unop_insn (convert_optab_handler (trunc_optab, to_mode, full_mode), |
477 to, from, UNKNOWN); | 432 to, from, UNKNOWN); |
478 return; | 433 return; |
479 } | 434 } |
480 if (GET_MODE_CLASS (from_mode) == MODE_PARTIAL_INT) | 435 if (GET_MODE_CLASS (from_mode) == MODE_PARTIAL_INT) |
481 { | 436 { |
482 rtx new_from; | 437 rtx new_from; |
483 enum machine_mode full_mode | 438 enum machine_mode full_mode |
484 = smallest_mode_for_size (GET_MODE_BITSIZE (from_mode), MODE_INT); | 439 = smallest_mode_for_size (GET_MODE_BITSIZE (from_mode), MODE_INT); |
485 | 440 |
486 gcc_assert (convert_optab_handler (sext_optab, full_mode, from_mode)->insn_code | 441 gcc_assert (convert_optab_handler (sext_optab, full_mode, from_mode) |
487 != CODE_FOR_nothing); | 442 != CODE_FOR_nothing); |
488 | 443 |
489 if (to_mode == full_mode) | 444 if (to_mode == full_mode) |
490 { | 445 { |
491 emit_unop_insn (convert_optab_handler (sext_optab, full_mode, from_mode)->insn_code, | 446 emit_unop_insn (convert_optab_handler (sext_optab, full_mode, |
447 from_mode), | |
492 to, from, UNKNOWN); | 448 to, from, UNKNOWN); |
493 return; | 449 return; |
494 } | 450 } |
495 | 451 |
496 new_from = gen_reg_rtx (full_mode); | 452 new_from = gen_reg_rtx (full_mode); |
497 emit_unop_insn (convert_optab_handler (sext_optab, full_mode, from_mode)->insn_code, | 453 emit_unop_insn (convert_optab_handler (sext_optab, full_mode, from_mode), |
498 new_from, from, UNKNOWN); | 454 new_from, from, UNKNOWN); |
499 | 455 |
500 /* else proceed to integer conversions below. */ | 456 /* else proceed to integer conversions below. */ |
501 from_mode = full_mode; | 457 from_mode = full_mode; |
502 from = new_from; | 458 from = new_from; |
693 return; | 649 return; |
694 } | 650 } |
695 } | 651 } |
696 | 652 |
697 /* Support special truncate insns for certain modes. */ | 653 /* Support special truncate insns for certain modes. */ |
698 if (convert_optab_handler (trunc_optab, to_mode, from_mode)->insn_code != CODE_FOR_nothing) | 654 if (convert_optab_handler (trunc_optab, to_mode, |
699 { | 655 from_mode) != CODE_FOR_nothing) |
700 emit_unop_insn (convert_optab_handler (trunc_optab, to_mode, from_mode)->insn_code, | 656 { |
657 emit_unop_insn (convert_optab_handler (trunc_optab, to_mode, from_mode), | |
701 to, from, UNKNOWN); | 658 to, from, UNKNOWN); |
702 return; | 659 return; |
703 } | 660 } |
704 | 661 |
705 /* Handle truncation of volatile memrefs, and so on; | 662 /* Handle truncation of volatile memrefs, and so on; |
833 temp = gen_reg_rtx (mode); | 790 temp = gen_reg_rtx (mode); |
834 convert_move (temp, x, unsignedp); | 791 convert_move (temp, x, unsignedp); |
835 return temp; | 792 return temp; |
836 } | 793 } |
837 | 794 |
795 /* Return the largest alignment we can use for doing a move (or store) | |
796 of MAX_PIECES. ALIGN is the largest alignment we could use. */ | |
797 | |
798 static unsigned int | |
799 alignment_for_piecewise_move (unsigned int max_pieces, unsigned int align) | |
800 { | |
801 enum machine_mode tmode; | |
802 | |
803 tmode = mode_for_size (max_pieces * BITS_PER_UNIT, MODE_INT, 1); | |
804 if (align >= GET_MODE_ALIGNMENT (tmode)) | |
805 align = GET_MODE_ALIGNMENT (tmode); | |
806 else | |
807 { | |
808 enum machine_mode tmode, xmode; | |
809 | |
810 for (tmode = GET_CLASS_NARROWEST_MODE (MODE_INT), xmode = tmode; | |
811 tmode != VOIDmode; | |
812 xmode = tmode, tmode = GET_MODE_WIDER_MODE (tmode)) | |
813 if (GET_MODE_SIZE (tmode) > max_pieces | |
814 || SLOW_UNALIGNED_ACCESS (tmode, align)) | |
815 break; | |
816 | |
817 align = MAX (align, GET_MODE_ALIGNMENT (xmode)); | |
818 } | |
819 | |
820 return align; | |
821 } | |
822 | |
823 /* Return the widest integer mode no wider than SIZE. If no such mode | |
824 can be found, return VOIDmode. */ | |
825 | |
826 static enum machine_mode | |
827 widest_int_mode_for_size (unsigned int size) | |
828 { | |
829 enum machine_mode tmode, mode = VOIDmode; | |
830 | |
831 for (tmode = GET_CLASS_NARROWEST_MODE (MODE_INT); | |
832 tmode != VOIDmode; tmode = GET_MODE_WIDER_MODE (tmode)) | |
833 if (GET_MODE_SIZE (tmode) < size) | |
834 mode = tmode; | |
835 | |
836 return mode; | |
837 } | |
838 | |
838 /* STORE_MAX_PIECES is the number of bytes at a time that we can | 839 /* STORE_MAX_PIECES is the number of bytes at a time that we can |
839 store efficiently. Due to internal GCC limitations, this is | 840 store efficiently. Due to internal GCC limitations, this is |
840 MOVE_MAX_PIECES limited by the number of bytes GCC can represent | 841 MOVE_MAX_PIECES limited by the number of bytes GCC can represent |
841 for an immediate constant. */ | 842 for an immediate constant. */ |
842 | 843 |
872 struct move_by_pieces_d data; | 873 struct move_by_pieces_d data; |
873 enum machine_mode to_addr_mode, from_addr_mode | 874 enum machine_mode to_addr_mode, from_addr_mode |
874 = targetm.addr_space.address_mode (MEM_ADDR_SPACE (from)); | 875 = targetm.addr_space.address_mode (MEM_ADDR_SPACE (from)); |
875 rtx to_addr, from_addr = XEXP (from, 0); | 876 rtx to_addr, from_addr = XEXP (from, 0); |
876 unsigned int max_size = MOVE_MAX_PIECES + 1; | 877 unsigned int max_size = MOVE_MAX_PIECES + 1; |
877 enum machine_mode mode = VOIDmode, tmode; | |
878 enum insn_code icode; | 878 enum insn_code icode; |
879 | 879 |
880 align = MIN (to ? MEM_ALIGN (to) : align, MEM_ALIGN (from)); | 880 align = MIN (to ? MEM_ALIGN (to) : align, MEM_ALIGN (from)); |
881 | 881 |
882 data.offset = 0; | 882 data.offset = 0; |
920 copy addresses to registers (to make displacements shorter) | 920 copy addresses to registers (to make displacements shorter) |
921 and use post-increment if available. */ | 921 and use post-increment if available. */ |
922 if (!(data.autinc_from && data.autinc_to) | 922 if (!(data.autinc_from && data.autinc_to) |
923 && move_by_pieces_ninsns (len, align, max_size) > 2) | 923 && move_by_pieces_ninsns (len, align, max_size) > 2) |
924 { | 924 { |
925 /* Find the mode of the largest move... */ | 925 /* Find the mode of the largest move... |
926 for (tmode = GET_CLASS_NARROWEST_MODE (MODE_INT); | 926 MODE might not be used depending on the definitions of the |
927 tmode != VOIDmode; tmode = GET_MODE_WIDER_MODE (tmode)) | 927 USE_* macros below. */ |
928 if (GET_MODE_SIZE (tmode) < max_size) | 928 enum machine_mode mode ATTRIBUTE_UNUSED |
929 mode = tmode; | 929 = widest_int_mode_for_size (max_size); |
930 | 930 |
931 if (USE_LOAD_PRE_DECREMENT (mode) && data.reverse && ! data.autinc_from) | 931 if (USE_LOAD_PRE_DECREMENT (mode) && data.reverse && ! data.autinc_from) |
932 { | 932 { |
933 data.from_addr = copy_to_mode_reg (from_addr_mode, | 933 data.from_addr = copy_to_mode_reg (from_addr_mode, |
934 plus_constant (from_addr, len)); | 934 plus_constant (from_addr, len)); |
958 } | 958 } |
959 if (!data.autinc_to && CONSTANT_P (to_addr)) | 959 if (!data.autinc_to && CONSTANT_P (to_addr)) |
960 data.to_addr = copy_to_mode_reg (to_addr_mode, to_addr); | 960 data.to_addr = copy_to_mode_reg (to_addr_mode, to_addr); |
961 } | 961 } |
962 | 962 |
963 tmode = mode_for_size (MOVE_MAX_PIECES * BITS_PER_UNIT, MODE_INT, 1); | 963 align = alignment_for_piecewise_move (MOVE_MAX_PIECES, align); |
964 if (align >= GET_MODE_ALIGNMENT (tmode)) | |
965 align = GET_MODE_ALIGNMENT (tmode); | |
966 else | |
967 { | |
968 enum machine_mode xmode; | |
969 | |
970 for (tmode = GET_CLASS_NARROWEST_MODE (MODE_INT), xmode = tmode; | |
971 tmode != VOIDmode; | |
972 xmode = tmode, tmode = GET_MODE_WIDER_MODE (tmode)) | |
973 if (GET_MODE_SIZE (tmode) > MOVE_MAX_PIECES | |
974 || SLOW_UNALIGNED_ACCESS (tmode, align)) | |
975 break; | |
976 | |
977 align = MAX (align, GET_MODE_ALIGNMENT (xmode)); | |
978 } | |
979 | 964 |
980 /* First move what we can in the largest integer mode, then go to | 965 /* First move what we can in the largest integer mode, then go to |
981 successively smaller modes. */ | 966 successively smaller modes. */ |
982 | 967 |
983 while (max_size > 1) | 968 while (max_size > 1) |
984 { | 969 { |
985 for (tmode = GET_CLASS_NARROWEST_MODE (MODE_INT); | 970 enum machine_mode mode = widest_int_mode_for_size (max_size); |
986 tmode != VOIDmode; tmode = GET_MODE_WIDER_MODE (tmode)) | |
987 if (GET_MODE_SIZE (tmode) < max_size) | |
988 mode = tmode; | |
989 | 971 |
990 if (mode == VOIDmode) | 972 if (mode == VOIDmode) |
991 break; | 973 break; |
992 | 974 |
993 icode = optab_handler (mov_optab, mode)->insn_code; | 975 icode = optab_handler (mov_optab, mode); |
994 if (icode != CODE_FOR_nothing && align >= GET_MODE_ALIGNMENT (mode)) | 976 if (icode != CODE_FOR_nothing && align >= GET_MODE_ALIGNMENT (mode)) |
995 move_by_pieces_1 (GEN_FCN (icode), mode, &data); | 977 move_by_pieces_1 (GEN_FCN (icode), mode, &data); |
996 | 978 |
997 max_size = GET_MODE_SIZE (mode); | 979 max_size = GET_MODE_SIZE (mode); |
998 } | 980 } |
1037 static unsigned HOST_WIDE_INT | 1019 static unsigned HOST_WIDE_INT |
1038 move_by_pieces_ninsns (unsigned HOST_WIDE_INT l, unsigned int align, | 1020 move_by_pieces_ninsns (unsigned HOST_WIDE_INT l, unsigned int align, |
1039 unsigned int max_size) | 1021 unsigned int max_size) |
1040 { | 1022 { |
1041 unsigned HOST_WIDE_INT n_insns = 0; | 1023 unsigned HOST_WIDE_INT n_insns = 0; |
1042 enum machine_mode tmode; | 1024 |
1043 | 1025 align = alignment_for_piecewise_move (MOVE_MAX_PIECES, align); |
1044 tmode = mode_for_size (MOVE_MAX_PIECES * BITS_PER_UNIT, MODE_INT, 1); | |
1045 if (align >= GET_MODE_ALIGNMENT (tmode)) | |
1046 align = GET_MODE_ALIGNMENT (tmode); | |
1047 else | |
1048 { | |
1049 enum machine_mode tmode, xmode; | |
1050 | |
1051 for (tmode = GET_CLASS_NARROWEST_MODE (MODE_INT), xmode = tmode; | |
1052 tmode != VOIDmode; | |
1053 xmode = tmode, tmode = GET_MODE_WIDER_MODE (tmode)) | |
1054 if (GET_MODE_SIZE (tmode) > MOVE_MAX_PIECES | |
1055 || SLOW_UNALIGNED_ACCESS (tmode, align)) | |
1056 break; | |
1057 | |
1058 align = MAX (align, GET_MODE_ALIGNMENT (xmode)); | |
1059 } | |
1060 | 1026 |
1061 while (max_size > 1) | 1027 while (max_size > 1) |
1062 { | 1028 { |
1063 enum machine_mode mode = VOIDmode; | 1029 enum machine_mode mode; |
1064 enum insn_code icode; | 1030 enum insn_code icode; |
1065 | 1031 |
1066 for (tmode = GET_CLASS_NARROWEST_MODE (MODE_INT); | 1032 mode = widest_int_mode_for_size (max_size); |
1067 tmode != VOIDmode; tmode = GET_MODE_WIDER_MODE (tmode)) | |
1068 if (GET_MODE_SIZE (tmode) < max_size) | |
1069 mode = tmode; | |
1070 | 1033 |
1071 if (mode == VOIDmode) | 1034 if (mode == VOIDmode) |
1072 break; | 1035 break; |
1073 | 1036 |
1074 icode = optab_handler (mov_optab, mode)->insn_code; | 1037 icode = optab_handler (mov_optab, mode); |
1075 if (icode != CODE_FOR_nothing && align >= GET_MODE_ALIGNMENT (mode)) | 1038 if (icode != CODE_FOR_nothing && align >= GET_MODE_ALIGNMENT (mode)) |
1076 n_insns += l / GET_MODE_SIZE (mode), l %= GET_MODE_SIZE (mode); | 1039 n_insns += l / GET_MODE_SIZE (mode), l %= GET_MODE_SIZE (mode); |
1077 | 1040 |
1078 max_size = GET_MODE_SIZE (mode); | 1041 max_size = GET_MODE_SIZE (mode); |
1079 } | 1042 } |
1161 { | 1124 { |
1162 bool may_use_call; | 1125 bool may_use_call; |
1163 rtx retval = 0; | 1126 rtx retval = 0; |
1164 unsigned int align; | 1127 unsigned int align; |
1165 | 1128 |
1129 gcc_assert (size); | |
1130 if (CONST_INT_P (size) | |
1131 && INTVAL (size) == 0) | |
1132 return 0; | |
1133 | |
1166 switch (method) | 1134 switch (method) |
1167 { | 1135 { |
1168 case BLOCK_OP_NORMAL: | 1136 case BLOCK_OP_NORMAL: |
1169 case BLOCK_OP_TAILCALL: | 1137 case BLOCK_OP_TAILCALL: |
1170 may_use_call = true; | 1138 may_use_call = true; |
1184 | 1152 |
1185 default: | 1153 default: |
1186 gcc_unreachable (); | 1154 gcc_unreachable (); |
1187 } | 1155 } |
1188 | 1156 |
1157 gcc_assert (MEM_P (x) && MEM_P (y)); | |
1189 align = MIN (MEM_ALIGN (x), MEM_ALIGN (y)); | 1158 align = MIN (MEM_ALIGN (x), MEM_ALIGN (y)); |
1190 gcc_assert (align >= BITS_PER_UNIT); | 1159 gcc_assert (align >= BITS_PER_UNIT); |
1191 | |
1192 gcc_assert (MEM_P (x)); | |
1193 gcc_assert (MEM_P (y)); | |
1194 gcc_assert (size); | |
1195 | 1160 |
1196 /* Make sure we've got BLKmode addresses; store_one_arg can decide that | 1161 /* Make sure we've got BLKmode addresses; store_one_arg can decide that |
1197 block copy is more efficient for other large modes, e.g. DCmode. */ | 1162 block copy is more efficient for other large modes, e.g. DCmode. */ |
1198 x = adjust_address (x, BLKmode, 0); | 1163 x = adjust_address (x, BLKmode, 0); |
1199 y = adjust_address (y, BLKmode, 0); | 1164 y = adjust_address (y, BLKmode, 0); |
1200 | 1165 |
1201 /* Set MEM_SIZE as appropriate for this block copy. The main place this | 1166 /* Set MEM_SIZE as appropriate for this block copy. The main place this |
1202 can be incorrect is coming from __builtin_memcpy. */ | 1167 can be incorrect is coming from __builtin_memcpy. */ |
1203 if (CONST_INT_P (size)) | 1168 if (CONST_INT_P (size)) |
1204 { | 1169 { |
1205 if (INTVAL (size) == 0) | |
1206 return 0; | |
1207 | |
1208 x = shallow_copy_rtx (x); | 1170 x = shallow_copy_rtx (x); |
1209 y = shallow_copy_rtx (y); | 1171 y = shallow_copy_rtx (y); |
1210 set_mem_size (x, size); | 1172 set_mem_size (x, size); |
1211 set_mem_size (y, size); | 1173 set_mem_size (y, size); |
1212 } | 1174 } |
1274 | 1236 |
1275 arg = TYPE_ARG_TYPES (TREE_TYPE (fn)); | 1237 arg = TYPE_ARG_TYPES (TREE_TYPE (fn)); |
1276 for ( ; arg != void_list_node ; arg = TREE_CHAIN (arg)) | 1238 for ( ; arg != void_list_node ; arg = TREE_CHAIN (arg)) |
1277 { | 1239 { |
1278 enum machine_mode mode = TYPE_MODE (TREE_VALUE (arg)); | 1240 enum machine_mode mode = TYPE_MODE (TREE_VALUE (arg)); |
1279 rtx tmp = FUNCTION_ARG (args_so_far, mode, NULL_TREE, 1); | 1241 rtx tmp = targetm.calls.function_arg (&args_so_far, mode, |
1242 NULL_TREE, true); | |
1280 if (!tmp || !REG_P (tmp)) | 1243 if (!tmp || !REG_P (tmp)) |
1281 return false; | 1244 return false; |
1282 if (targetm.calls.arg_partial_bytes (&args_so_far, mode, NULL, 1)) | 1245 if (targetm.calls.arg_partial_bytes (&args_so_far, mode, NULL, 1)) |
1283 return false; | 1246 return false; |
1284 FUNCTION_ARG_ADVANCE (args_so_far, mode, NULL_TREE, 1); | 1247 targetm.calls.function_arg_advance (&args_so_far, mode, |
1248 NULL_TREE, true); | |
1285 } | 1249 } |
1286 } | 1250 } |
1287 return true; | 1251 return true; |
1288 } | 1252 } |
1289 | 1253 |
1309 the more limited one has some advantage. */ | 1273 the more limited one has some advantage. */ |
1310 | 1274 |
1311 for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT); mode != VOIDmode; | 1275 for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT); mode != VOIDmode; |
1312 mode = GET_MODE_WIDER_MODE (mode)) | 1276 mode = GET_MODE_WIDER_MODE (mode)) |
1313 { | 1277 { |
1314 enum insn_code code = movmem_optab[(int) mode]; | 1278 enum insn_code code = direct_optab_handler (movmem_optab, mode); |
1315 insn_operand_predicate_fn pred; | 1279 insn_operand_predicate_fn pred; |
1316 | 1280 |
1317 if (code != CODE_FOR_nothing | 1281 if (code != CODE_FOR_nothing |
1318 /* We don't need MODE to be narrower than BITS_PER_HOST_WIDE_INT | 1282 /* We don't need MODE to be narrower than BITS_PER_HOST_WIDE_INT |
1319 here because if SIZE is less than the mode mask, as it is | 1283 here because if SIZE is less than the mode mask, as it is |
1743 tmps[i] = XEXP (src, bytepos / slen0); | 1707 tmps[i] = XEXP (src, bytepos / slen0); |
1744 if (! CONSTANT_P (tmps[i]) | 1708 if (! CONSTANT_P (tmps[i]) |
1745 && (!REG_P (tmps[i]) || GET_MODE (tmps[i]) != mode)) | 1709 && (!REG_P (tmps[i]) || GET_MODE (tmps[i]) != mode)) |
1746 tmps[i] = extract_bit_field (tmps[i], bytelen * BITS_PER_UNIT, | 1710 tmps[i] = extract_bit_field (tmps[i], bytelen * BITS_PER_UNIT, |
1747 (bytepos % slen0) * BITS_PER_UNIT, | 1711 (bytepos % slen0) * BITS_PER_UNIT, |
1748 1, NULL_RTX, mode, mode); | 1712 1, false, NULL_RTX, mode, mode); |
1749 } | 1713 } |
1750 else | 1714 else |
1751 { | 1715 { |
1752 rtx mem; | 1716 rtx mem; |
1753 | 1717 |
1754 gcc_assert (!bytepos); | 1718 gcc_assert (!bytepos); |
1755 mem = assign_stack_temp (GET_MODE (src), slen, 0); | 1719 mem = assign_stack_temp (GET_MODE (src), slen, 0); |
1756 emit_move_insn (mem, src); | 1720 emit_move_insn (mem, src); |
1757 tmps[i] = extract_bit_field (mem, bytelen * BITS_PER_UNIT, | 1721 tmps[i] = extract_bit_field (mem, bytelen * BITS_PER_UNIT, |
1758 0, 1, NULL_RTX, mode, mode); | 1722 0, 1, false, NULL_RTX, mode, mode); |
1759 } | 1723 } |
1760 } | 1724 } |
1761 /* FIXME: A SIMD parallel will eventually lead to a subreg of a | 1725 /* FIXME: A SIMD parallel will eventually lead to a subreg of a |
1762 SIMD register, which is currently broken. While we get GCC | 1726 SIMD register, which is currently broken. While we get GCC |
1763 to emit proper RTL for these cases, let's dump to memory. */ | 1727 to emit proper RTL for these cases, let's dump to memory. */ |
1794 } | 1758 } |
1795 else if (REG_P (src) && GET_MODE (src) == mode) | 1759 else if (REG_P (src) && GET_MODE (src) == mode) |
1796 tmps[i] = src; | 1760 tmps[i] = src; |
1797 else | 1761 else |
1798 tmps[i] = extract_bit_field (src, bytelen * BITS_PER_UNIT, | 1762 tmps[i] = extract_bit_field (src, bytelen * BITS_PER_UNIT, |
1799 bytepos * BITS_PER_UNIT, 1, NULL_RTX, | 1763 bytepos * BITS_PER_UNIT, 1, false, NULL_RTX, |
1800 mode, mode); | 1764 mode, mode); |
1801 | 1765 |
1802 if (shift) | 1766 if (shift) |
1803 tmps[i] = expand_shift (LSHIFT_EXPR, mode, tmps[i], | 1767 tmps[i] = expand_shift (LSHIFT_EXPR, mode, tmps[i], |
1804 build_int_cst (NULL_TREE, shift), tmps[i], 0); | 1768 build_int_cst (NULL_TREE, shift), tmps[i], 0); |
2207 | 2171 |
2208 /* Use xbitpos for the source extraction (right justified) and | 2172 /* Use xbitpos for the source extraction (right justified) and |
2209 bitpos for the destination store (left justified). */ | 2173 bitpos for the destination store (left justified). */ |
2210 store_bit_field (dst, bitsize, bitpos % BITS_PER_WORD, copy_mode, | 2174 store_bit_field (dst, bitsize, bitpos % BITS_PER_WORD, copy_mode, |
2211 extract_bit_field (src, bitsize, | 2175 extract_bit_field (src, bitsize, |
2212 xbitpos % BITS_PER_WORD, 1, | 2176 xbitpos % BITS_PER_WORD, 1, false, |
2213 NULL_RTX, copy_mode, copy_mode)); | 2177 NULL_RTX, copy_mode, copy_mode)); |
2214 } | 2178 } |
2215 | 2179 |
2216 return tgtblk; | 2180 return tgtblk; |
2217 } | 2181 } |
2298 void *constfundata, unsigned int align, bool memsetp) | 2262 void *constfundata, unsigned int align, bool memsetp) |
2299 { | 2263 { |
2300 unsigned HOST_WIDE_INT l; | 2264 unsigned HOST_WIDE_INT l; |
2301 unsigned int max_size; | 2265 unsigned int max_size; |
2302 HOST_WIDE_INT offset = 0; | 2266 HOST_WIDE_INT offset = 0; |
2303 enum machine_mode mode, tmode; | 2267 enum machine_mode mode; |
2304 enum insn_code icode; | 2268 enum insn_code icode; |
2305 int reverse; | 2269 int reverse; |
2306 rtx cst; | 2270 /* cst is set but not used if LEGITIMATE_CONSTANT doesn't use it. */ |
2271 rtx cst ATTRIBUTE_UNUSED; | |
2307 | 2272 |
2308 if (len == 0) | 2273 if (len == 0) |
2309 return 1; | 2274 return 1; |
2310 | 2275 |
2311 if (! (memsetp | 2276 if (! (memsetp |
2312 ? SET_BY_PIECES_P (len, align) | 2277 ? SET_BY_PIECES_P (len, align) |
2313 : STORE_BY_PIECES_P (len, align))) | 2278 : STORE_BY_PIECES_P (len, align))) |
2314 return 0; | 2279 return 0; |
2315 | 2280 |
2316 tmode = mode_for_size (STORE_MAX_PIECES * BITS_PER_UNIT, MODE_INT, 1); | 2281 align = alignment_for_piecewise_move (STORE_MAX_PIECES, align); |
2317 if (align >= GET_MODE_ALIGNMENT (tmode)) | |
2318 align = GET_MODE_ALIGNMENT (tmode); | |
2319 else | |
2320 { | |
2321 enum machine_mode xmode; | |
2322 | |
2323 for (tmode = GET_CLASS_NARROWEST_MODE (MODE_INT), xmode = tmode; | |
2324 tmode != VOIDmode; | |
2325 xmode = tmode, tmode = GET_MODE_WIDER_MODE (tmode)) | |
2326 if (GET_MODE_SIZE (tmode) > STORE_MAX_PIECES | |
2327 || SLOW_UNALIGNED_ACCESS (tmode, align)) | |
2328 break; | |
2329 | |
2330 align = MAX (align, GET_MODE_ALIGNMENT (xmode)); | |
2331 } | |
2332 | 2282 |
2333 /* We would first store what we can in the largest integer mode, then go to | 2283 /* We would first store what we can in the largest integer mode, then go to |
2334 successively smaller modes. */ | 2284 successively smaller modes. */ |
2335 | 2285 |
2336 for (reverse = 0; | 2286 for (reverse = 0; |
2337 reverse <= (HAVE_PRE_DECREMENT || HAVE_POST_DECREMENT); | 2287 reverse <= (HAVE_PRE_DECREMENT || HAVE_POST_DECREMENT); |
2338 reverse++) | 2288 reverse++) |
2339 { | 2289 { |
2340 l = len; | 2290 l = len; |
2341 mode = VOIDmode; | |
2342 max_size = STORE_MAX_PIECES + 1; | 2291 max_size = STORE_MAX_PIECES + 1; |
2343 while (max_size > 1) | 2292 while (max_size > 1) |
2344 { | 2293 { |
2345 for (tmode = GET_CLASS_NARROWEST_MODE (MODE_INT); | 2294 mode = widest_int_mode_for_size (max_size); |
2346 tmode != VOIDmode; tmode = GET_MODE_WIDER_MODE (tmode)) | |
2347 if (GET_MODE_SIZE (tmode) < max_size) | |
2348 mode = tmode; | |
2349 | 2295 |
2350 if (mode == VOIDmode) | 2296 if (mode == VOIDmode) |
2351 break; | 2297 break; |
2352 | 2298 |
2353 icode = optab_handler (mov_optab, mode)->insn_code; | 2299 icode = optab_handler (mov_optab, mode); |
2354 if (icode != CODE_FOR_nothing | 2300 if (icode != CODE_FOR_nothing |
2355 && align >= GET_MODE_ALIGNMENT (mode)) | 2301 && align >= GET_MODE_ALIGNMENT (mode)) |
2356 { | 2302 { |
2357 unsigned int size = GET_MODE_SIZE (mode); | 2303 unsigned int size = GET_MODE_SIZE (mode); |
2358 | 2304 |
2484 { | 2430 { |
2485 enum machine_mode to_addr_mode | 2431 enum machine_mode to_addr_mode |
2486 = targetm.addr_space.address_mode (MEM_ADDR_SPACE (data->to)); | 2432 = targetm.addr_space.address_mode (MEM_ADDR_SPACE (data->to)); |
2487 rtx to_addr = XEXP (data->to, 0); | 2433 rtx to_addr = XEXP (data->to, 0); |
2488 unsigned int max_size = STORE_MAX_PIECES + 1; | 2434 unsigned int max_size = STORE_MAX_PIECES + 1; |
2489 enum machine_mode mode = VOIDmode, tmode; | |
2490 enum insn_code icode; | 2435 enum insn_code icode; |
2491 | 2436 |
2492 data->offset = 0; | 2437 data->offset = 0; |
2493 data->to_addr = to_addr; | 2438 data->to_addr = to_addr; |
2494 data->autinc_to | 2439 data->autinc_to |
2505 copy addresses to registers (to make displacements shorter) | 2450 copy addresses to registers (to make displacements shorter) |
2506 and use post-increment if available. */ | 2451 and use post-increment if available. */ |
2507 if (!data->autinc_to | 2452 if (!data->autinc_to |
2508 && move_by_pieces_ninsns (data->len, align, max_size) > 2) | 2453 && move_by_pieces_ninsns (data->len, align, max_size) > 2) |
2509 { | 2454 { |
2510 /* Determine the main mode we'll be using. */ | 2455 /* Determine the main mode we'll be using. |
2511 for (tmode = GET_CLASS_NARROWEST_MODE (MODE_INT); | 2456 MODE might not be used depending on the definitions of the |
2512 tmode != VOIDmode; tmode = GET_MODE_WIDER_MODE (tmode)) | 2457 USE_* macros below. */ |
2513 if (GET_MODE_SIZE (tmode) < max_size) | 2458 enum machine_mode mode ATTRIBUTE_UNUSED |
2514 mode = tmode; | 2459 = widest_int_mode_for_size (max_size); |
2515 | 2460 |
2516 if (USE_STORE_PRE_DECREMENT (mode) && data->reverse && ! data->autinc_to) | 2461 if (USE_STORE_PRE_DECREMENT (mode) && data->reverse && ! data->autinc_to) |
2517 { | 2462 { |
2518 data->to_addr = copy_to_mode_reg (to_addr_mode, | 2463 data->to_addr = copy_to_mode_reg (to_addr_mode, |
2519 plus_constant (to_addr, data->len)); | 2464 plus_constant (to_addr, data->len)); |
2531 | 2476 |
2532 if ( !data->autinc_to && CONSTANT_P (to_addr)) | 2477 if ( !data->autinc_to && CONSTANT_P (to_addr)) |
2533 data->to_addr = copy_to_mode_reg (to_addr_mode, to_addr); | 2478 data->to_addr = copy_to_mode_reg (to_addr_mode, to_addr); |
2534 } | 2479 } |
2535 | 2480 |
2536 tmode = mode_for_size (STORE_MAX_PIECES * BITS_PER_UNIT, MODE_INT, 1); | 2481 align = alignment_for_piecewise_move (STORE_MAX_PIECES, align); |
2537 if (align >= GET_MODE_ALIGNMENT (tmode)) | |
2538 align = GET_MODE_ALIGNMENT (tmode); | |
2539 else | |
2540 { | |
2541 enum machine_mode xmode; | |
2542 | |
2543 for (tmode = GET_CLASS_NARROWEST_MODE (MODE_INT), xmode = tmode; | |
2544 tmode != VOIDmode; | |
2545 xmode = tmode, tmode = GET_MODE_WIDER_MODE (tmode)) | |
2546 if (GET_MODE_SIZE (tmode) > STORE_MAX_PIECES | |
2547 || SLOW_UNALIGNED_ACCESS (tmode, align)) | |
2548 break; | |
2549 | |
2550 align = MAX (align, GET_MODE_ALIGNMENT (xmode)); | |
2551 } | |
2552 | 2482 |
2553 /* First store what we can in the largest integer mode, then go to | 2483 /* First store what we can in the largest integer mode, then go to |
2554 successively smaller modes. */ | 2484 successively smaller modes. */ |
2555 | 2485 |
2556 while (max_size > 1) | 2486 while (max_size > 1) |
2557 { | 2487 { |
2558 for (tmode = GET_CLASS_NARROWEST_MODE (MODE_INT); | 2488 enum machine_mode mode = widest_int_mode_for_size (max_size); |
2559 tmode != VOIDmode; tmode = GET_MODE_WIDER_MODE (tmode)) | |
2560 if (GET_MODE_SIZE (tmode) < max_size) | |
2561 mode = tmode; | |
2562 | 2489 |
2563 if (mode == VOIDmode) | 2490 if (mode == VOIDmode) |
2564 break; | 2491 break; |
2565 | 2492 |
2566 icode = optab_handler (mov_optab, mode)->insn_code; | 2493 icode = optab_handler (mov_optab, mode); |
2567 if (icode != CODE_FOR_nothing && align >= GET_MODE_ALIGNMENT (mode)) | 2494 if (icode != CODE_FOR_nothing && align >= GET_MODE_ALIGNMENT (mode)) |
2568 store_by_pieces_2 (GEN_FCN (icode), mode, data); | 2495 store_by_pieces_2 (GEN_FCN (icode), mode, data); |
2569 | 2496 |
2570 max_size = GET_MODE_SIZE (mode); | 2497 max_size = GET_MODE_SIZE (mode); |
2571 } | 2498 } |
2785 expected_align = align; | 2712 expected_align = align; |
2786 | 2713 |
2787 for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT); mode != VOIDmode; | 2714 for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT); mode != VOIDmode; |
2788 mode = GET_MODE_WIDER_MODE (mode)) | 2715 mode = GET_MODE_WIDER_MODE (mode)) |
2789 { | 2716 { |
2790 enum insn_code code = setmem_optab[(int) mode]; | 2717 enum insn_code code = direct_optab_handler (setmem_optab, mode); |
2791 insn_operand_predicate_fn pred; | 2718 insn_operand_predicate_fn pred; |
2792 | 2719 |
2793 if (code != CODE_FOR_nothing | 2720 if (code != CODE_FOR_nothing |
2794 /* We don't need MODE to be narrower than | 2721 /* We don't need MODE to be narrower than |
2795 BITS_PER_HOST_WIDE_INT here because if SIZE is less than | 2722 BITS_PER_HOST_WIDE_INT here because if SIZE is less than |
2964 /* simplify_gen_subreg may fail for sub-word MEMs. */ | 2891 /* simplify_gen_subreg may fail for sub-word MEMs. */ |
2965 gcc_assert (MEM_P (cplx) && ibitsize < BITS_PER_WORD); | 2892 gcc_assert (MEM_P (cplx) && ibitsize < BITS_PER_WORD); |
2966 } | 2893 } |
2967 | 2894 |
2968 return extract_bit_field (cplx, ibitsize, imag_p ? ibitsize : 0, | 2895 return extract_bit_field (cplx, ibitsize, imag_p ? ibitsize : 0, |
2969 true, NULL_RTX, imode, imode); | 2896 true, false, NULL_RTX, imode, imode); |
2970 } | 2897 } |
2971 | 2898 |
2972 /* A subroutine of emit_move_insn_1. Yet another lowpart generator. | 2899 /* A subroutine of emit_move_insn_1. Yet another lowpart generator. |
2973 NEW_MODE and OLD_MODE are the same size. Return NULL if X cannot be | 2900 NEW_MODE and OLD_MODE are the same size. Return NULL if X cannot be |
2974 represented in NEW_MODE. If FORCE is true, this will never happen, as | 2901 represented in NEW_MODE. If FORCE is true, this will never happen, as |
3030 imode = int_mode_for_mode (mode); | 2957 imode = int_mode_for_mode (mode); |
3031 if (imode == BLKmode) | 2958 if (imode == BLKmode) |
3032 return NULL_RTX; | 2959 return NULL_RTX; |
3033 | 2960 |
3034 /* The target must support moves in this mode. */ | 2961 /* The target must support moves in this mode. */ |
3035 code = optab_handler (mov_optab, imode)->insn_code; | 2962 code = optab_handler (mov_optab, imode); |
3036 if (code == CODE_FOR_nothing) | 2963 if (code == CODE_FOR_nothing) |
3037 return NULL_RTX; | 2964 return NULL_RTX; |
3038 | 2965 |
3039 x = emit_move_change_mode (imode, mode, x, force); | 2966 x = emit_move_change_mode (imode, mode, x, force); |
3040 if (x == NULL_RTX) | 2967 if (x == NULL_RTX) |
3180 | 3107 |
3181 /* See if we can coerce the target into moving both values at once. */ | 3108 /* See if we can coerce the target into moving both values at once. */ |
3182 | 3109 |
3183 /* Move floating point as parts. */ | 3110 /* Move floating point as parts. */ |
3184 if (GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT | 3111 if (GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT |
3185 && optab_handler (mov_optab, GET_MODE_INNER (mode))->insn_code != CODE_FOR_nothing) | 3112 && optab_handler (mov_optab, GET_MODE_INNER (mode)) != CODE_FOR_nothing) |
3186 try_int = false; | 3113 try_int = false; |
3187 /* Not possible if the values are inherently not adjacent. */ | 3114 /* Not possible if the values are inherently not adjacent. */ |
3188 else if (GET_CODE (x) == CONCAT || GET_CODE (y) == CONCAT) | 3115 else if (GET_CODE (x) == CONCAT || GET_CODE (y) == CONCAT) |
3189 try_int = false; | 3116 try_int = false; |
3190 /* Is possible if both are registers (or subregs of registers). */ | 3117 /* Is possible if both are registers (or subregs of registers). */ |
3231 rtx ret; | 3158 rtx ret; |
3232 | 3159 |
3233 /* Assume all MODE_CC modes are equivalent; if we have movcc, use it. */ | 3160 /* Assume all MODE_CC modes are equivalent; if we have movcc, use it. */ |
3234 if (mode != CCmode) | 3161 if (mode != CCmode) |
3235 { | 3162 { |
3236 enum insn_code code = optab_handler (mov_optab, CCmode)->insn_code; | 3163 enum insn_code code = optab_handler (mov_optab, CCmode); |
3237 if (code != CODE_FOR_nothing) | 3164 if (code != CODE_FOR_nothing) |
3238 { | 3165 { |
3239 x = emit_move_change_mode (CCmode, mode, x, true); | 3166 x = emit_move_change_mode (CCmode, mode, x, true); |
3240 y = emit_move_change_mode (CCmode, mode, y, true); | 3167 y = emit_move_change_mode (CCmode, mode, y, true); |
3241 return emit_insn (GEN_FCN (code) (x, y)); | 3168 return emit_insn (GEN_FCN (code) (x, y)); |
3371 enum machine_mode mode = GET_MODE (x); | 3298 enum machine_mode mode = GET_MODE (x); |
3372 enum insn_code code; | 3299 enum insn_code code; |
3373 | 3300 |
3374 gcc_assert ((unsigned int) mode < (unsigned int) MAX_MACHINE_MODE); | 3301 gcc_assert ((unsigned int) mode < (unsigned int) MAX_MACHINE_MODE); |
3375 | 3302 |
3376 code = optab_handler (mov_optab, mode)->insn_code; | 3303 code = optab_handler (mov_optab, mode); |
3377 if (code != CODE_FOR_nothing) | 3304 if (code != CODE_FOR_nothing) |
3378 return emit_insn (GEN_FCN (code) (x, y)); | 3305 return emit_insn (GEN_FCN (code) (x, y)); |
3379 | 3306 |
3380 /* Expand complex moves by moving real part and imag part. */ | 3307 /* Expand complex moves by moving real part and imag part. */ |
3381 if (COMPLEX_MODE_P (mode)) | 3308 if (COMPLEX_MODE_P (mode)) |
3469 | 3396 |
3470 if (y_cst && REG_P (x) | 3397 if (y_cst && REG_P (x) |
3471 && (set = single_set (last_insn)) != NULL_RTX | 3398 && (set = single_set (last_insn)) != NULL_RTX |
3472 && SET_DEST (set) == x | 3399 && SET_DEST (set) == x |
3473 && ! rtx_equal_p (y_cst, SET_SRC (set))) | 3400 && ! rtx_equal_p (y_cst, SET_SRC (set))) |
3474 set_unique_reg_note (last_insn, REG_EQUAL, y_cst); | 3401 set_unique_reg_note (last_insn, REG_EQUAL, copy_rtx (y_cst)); |
3475 | 3402 |
3476 return last_insn; | 3403 return last_insn; |
3477 } | 3404 } |
3478 | 3405 |
3479 /* If Y is representable exactly in a narrower mode, and the target can | 3406 /* If Y is representable exactly in a narrower mode, and the target can |
3623 insn_operand_predicate_fn pred; | 3550 insn_operand_predicate_fn pred; |
3624 | 3551 |
3625 stack_pointer_delta += PUSH_ROUNDING (GET_MODE_SIZE (mode)); | 3552 stack_pointer_delta += PUSH_ROUNDING (GET_MODE_SIZE (mode)); |
3626 /* If there is push pattern, use it. Otherwise try old way of throwing | 3553 /* If there is push pattern, use it. Otherwise try old way of throwing |
3627 MEM representing push operation to move expander. */ | 3554 MEM representing push operation to move expander. */ |
3628 icode = optab_handler (push_optab, mode)->insn_code; | 3555 icode = optab_handler (push_optab, mode); |
3629 if (icode != CODE_FOR_nothing) | 3556 if (icode != CODE_FOR_nothing) |
3630 { | 3557 { |
3631 if (((pred = insn_data[(int) icode].operand[0].predicate) | 3558 if (((pred = insn_data[(int) icode].operand[0].predicate) |
3632 && !((*pred) (x, mode)))) | 3559 && !((*pred) (x, mode)))) |
3633 x = force_reg (mode, x); | 3560 x = force_reg (mode, x); |
3815 and such small pushes do rounding that causes trouble. */ | 3742 and such small pushes do rounding that causes trouble. */ |
3816 && ((! SLOW_UNALIGNED_ACCESS (word_mode, align)) | 3743 && ((! SLOW_UNALIGNED_ACCESS (word_mode, align)) |
3817 || align >= BIGGEST_ALIGNMENT | 3744 || align >= BIGGEST_ALIGNMENT |
3818 || (PUSH_ROUNDING (align / BITS_PER_UNIT) | 3745 || (PUSH_ROUNDING (align / BITS_PER_UNIT) |
3819 == (align / BITS_PER_UNIT))) | 3746 == (align / BITS_PER_UNIT))) |
3820 && PUSH_ROUNDING (INTVAL (size)) == INTVAL (size)) | 3747 && (HOST_WIDE_INT) PUSH_ROUNDING (INTVAL (size)) == INTVAL (size)) |
3821 { | 3748 { |
3822 /* Push padding now if padding above and stack grows down, | 3749 /* Push padding now if padding above and stack grows down, |
3823 or if padding below and stack grows up. | 3750 or if padding below and stack grows up. |
3824 But if space already allocated, this has already been done. */ | 3751 But if space already allocated, this has already been done. */ |
3825 if (extra && args_addr == 0 | 3752 if (extra && args_addr == 0 |
4191 void | 4118 void |
4192 expand_assignment (tree to, tree from, bool nontemporal) | 4119 expand_assignment (tree to, tree from, bool nontemporal) |
4193 { | 4120 { |
4194 rtx to_rtx = 0; | 4121 rtx to_rtx = 0; |
4195 rtx result; | 4122 rtx result; |
4123 enum machine_mode mode; | |
4124 int align, icode; | |
4196 | 4125 |
4197 /* Don't crash if the lhs of the assignment was erroneous. */ | 4126 /* Don't crash if the lhs of the assignment was erroneous. */ |
4198 if (TREE_CODE (to) == ERROR_MARK) | 4127 if (TREE_CODE (to) == ERROR_MARK) |
4199 { | 4128 { |
4200 result = expand_normal (from); | 4129 result = expand_normal (from); |
4202 } | 4131 } |
4203 | 4132 |
4204 /* Optimize away no-op moves without side-effects. */ | 4133 /* Optimize away no-op moves without side-effects. */ |
4205 if (operand_equal_p (to, from, 0)) | 4134 if (operand_equal_p (to, from, 0)) |
4206 return; | 4135 return; |
4136 | |
4137 mode = TYPE_MODE (TREE_TYPE (to)); | |
4138 if ((TREE_CODE (to) == MEM_REF | |
4139 || TREE_CODE (to) == TARGET_MEM_REF) | |
4140 && mode != BLKmode | |
4141 && ((align = MAX (TYPE_ALIGN (TREE_TYPE (to)), | |
4142 get_object_alignment (to, BIGGEST_ALIGNMENT))) | |
4143 < (signed) GET_MODE_ALIGNMENT (mode)) | |
4144 && ((icode = optab_handler (movmisalign_optab, mode)) | |
4145 != CODE_FOR_nothing)) | |
4146 { | |
4147 enum machine_mode address_mode, op_mode1; | |
4148 rtx insn, reg, op0, mem; | |
4149 | |
4150 reg = expand_expr (from, NULL_RTX, VOIDmode, EXPAND_NORMAL); | |
4151 reg = force_not_mem (reg); | |
4152 | |
4153 if (TREE_CODE (to) == MEM_REF) | |
4154 { | |
4155 addr_space_t as | |
4156 = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (TREE_OPERAND (to, 1)))); | |
4157 tree base = TREE_OPERAND (to, 0); | |
4158 address_mode = targetm.addr_space.address_mode (as); | |
4159 op0 = expand_expr (base, NULL_RTX, VOIDmode, EXPAND_NORMAL); | |
4160 op0 = convert_memory_address_addr_space (address_mode, op0, as); | |
4161 if (!integer_zerop (TREE_OPERAND (to, 1))) | |
4162 { | |
4163 rtx off | |
4164 = immed_double_int_const (mem_ref_offset (to), address_mode); | |
4165 op0 = simplify_gen_binary (PLUS, address_mode, op0, off); | |
4166 } | |
4167 op0 = memory_address_addr_space (mode, op0, as); | |
4168 mem = gen_rtx_MEM (mode, op0); | |
4169 set_mem_attributes (mem, to, 0); | |
4170 set_mem_addr_space (mem, as); | |
4171 } | |
4172 else if (TREE_CODE (to) == TARGET_MEM_REF) | |
4173 { | |
4174 addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (to)); | |
4175 struct mem_address addr; | |
4176 | |
4177 get_address_description (to, &addr); | |
4178 op0 = addr_for_mem_ref (&addr, as, true); | |
4179 op0 = memory_address_addr_space (mode, op0, as); | |
4180 mem = gen_rtx_MEM (mode, op0); | |
4181 set_mem_attributes (mem, to, 0); | |
4182 set_mem_addr_space (mem, as); | |
4183 } | |
4184 else | |
4185 gcc_unreachable (); | |
4186 if (TREE_THIS_VOLATILE (to)) | |
4187 MEM_VOLATILE_P (mem) = 1; | |
4188 | |
4189 op_mode1 = insn_data[icode].operand[1].mode; | |
4190 if (! (*insn_data[icode].operand[1].predicate) (reg, op_mode1) | |
4191 && op_mode1 != VOIDmode) | |
4192 reg = copy_to_mode_reg (op_mode1, reg); | |
4193 | |
4194 insn = GEN_FCN (icode) (mem, reg); | |
4195 /* The movmisalign<mode> pattern cannot fail, else the assignment would | |
4196 silently be omitted. */ | |
4197 gcc_assert (insn != NULL_RTX); | |
4198 emit_insn (insn); | |
4199 return; | |
4200 } | |
4207 | 4201 |
4208 /* Assignment of a structure component needs special treatment | 4202 /* Assignment of a structure component needs special treatment |
4209 if the structure component's rtx is not simply a MEM. | 4203 if the structure component's rtx is not simply a MEM. |
4210 Assignment of an array element at a constant index, and assignment of | 4204 Assignment of an array element at a constant index, and assignment of |
4211 an array element in an unaligned packed structure field, has the same | 4205 an array element in an unaligned packed structure field, has the same |
4212 problem. */ | 4206 problem. */ |
4213 if (handled_component_p (to) | 4207 if (handled_component_p (to) |
4208 /* ??? We only need to handle MEM_REF here if the access is not | |
4209 a full access of the base object. */ | |
4210 || (TREE_CODE (to) == MEM_REF | |
4211 && TREE_CODE (TREE_OPERAND (to, 0)) == ADDR_EXPR) | |
4214 || TREE_CODE (TREE_TYPE (to)) == ARRAY_TYPE) | 4212 || TREE_CODE (TREE_TYPE (to)) == ARRAY_TYPE) |
4215 { | 4213 { |
4216 enum machine_mode mode1; | 4214 enum machine_mode mode1; |
4217 HOST_WIDE_INT bitsize, bitpos; | 4215 HOST_WIDE_INT bitsize, bitpos; |
4218 tree offset; | 4216 tree offset; |
4227 /* If we are going to use store_bit_field and extract_bit_field, | 4225 /* If we are going to use store_bit_field and extract_bit_field, |
4228 make sure to_rtx will be safe for multiple use. */ | 4226 make sure to_rtx will be safe for multiple use. */ |
4229 | 4227 |
4230 to_rtx = expand_normal (tem); | 4228 to_rtx = expand_normal (tem); |
4231 | 4229 |
4230 /* If the bitfield is volatile, we want to access it in the | |
4231 field's mode, not the computed mode. | |
4232 If a MEM has VOIDmode (external with incomplete type), | |
4233 use BLKmode for it instead. */ | |
4234 if (MEM_P (to_rtx)) | |
4235 { | |
4236 if (volatilep && flag_strict_volatile_bitfields > 0) | |
4237 to_rtx = adjust_address (to_rtx, mode1, 0); | |
4238 else if (GET_MODE (to_rtx) == VOIDmode) | |
4239 to_rtx = adjust_address (to_rtx, BLKmode, 0); | |
4240 } | |
4241 | |
4232 if (offset != 0) | 4242 if (offset != 0) |
4233 { | 4243 { |
4234 enum machine_mode address_mode; | 4244 enum machine_mode address_mode; |
4235 rtx offset_rtx; | 4245 rtx offset_rtx; |
4236 | 4246 |
4266 to_rtx = offset_address (to_rtx, offset_rtx, | 4276 to_rtx = offset_address (to_rtx, offset_rtx, |
4267 highest_pow2_factor_for_target (to, | 4277 highest_pow2_factor_for_target (to, |
4268 offset)); | 4278 offset)); |
4269 } | 4279 } |
4270 | 4280 |
4281 /* No action is needed if the target is not a memory and the field | |
4282 lies completely outside that target. This can occur if the source | |
4283 code contains an out-of-bounds access to a small array. */ | |
4284 if (!MEM_P (to_rtx) | |
4285 && GET_MODE (to_rtx) != BLKmode | |
4286 && (unsigned HOST_WIDE_INT) bitpos | |
4287 >= GET_MODE_BITSIZE (GET_MODE (to_rtx))) | |
4288 { | |
4289 expand_normal (from); | |
4290 result = NULL; | |
4291 } | |
4271 /* Handle expand_expr of a complex value returning a CONCAT. */ | 4292 /* Handle expand_expr of a complex value returning a CONCAT. */ |
4272 if (GET_CODE (to_rtx) == CONCAT) | 4293 else if (GET_CODE (to_rtx) == CONCAT) |
4273 { | 4294 { |
4274 if (COMPLEX_MODE_P (TYPE_MODE (TREE_TYPE (from)))) | 4295 if (COMPLEX_MODE_P (TYPE_MODE (TREE_TYPE (from)))) |
4275 { | 4296 { |
4276 gcc_assert (bitpos == 0); | 4297 gcc_assert (bitpos == 0); |
4277 result = store_expr (from, to_rtx, false, nontemporal); | 4298 result = store_expr (from, to_rtx, false, nontemporal); |
4315 free_temp_slots (); | 4336 free_temp_slots (); |
4316 pop_temp_slots (); | 4337 pop_temp_slots (); |
4317 return; | 4338 return; |
4318 } | 4339 } |
4319 | 4340 |
4320 else if (TREE_CODE (to) == MISALIGNED_INDIRECT_REF) | |
4321 { | |
4322 addr_space_t as = ADDR_SPACE_GENERIC; | |
4323 enum machine_mode mode, op_mode1; | |
4324 enum insn_code icode; | |
4325 rtx reg, addr, mem, insn; | |
4326 | |
4327 if (POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (to, 0)))) | |
4328 as = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (TREE_OPERAND (to, 0)))); | |
4329 | |
4330 reg = expand_expr (from, NULL_RTX, VOIDmode, EXPAND_NORMAL); | |
4331 reg = force_not_mem (reg); | |
4332 | |
4333 mode = TYPE_MODE (TREE_TYPE (to)); | |
4334 addr = expand_expr (TREE_OPERAND (to, 0), NULL_RTX, VOIDmode, | |
4335 EXPAND_SUM); | |
4336 addr = memory_address_addr_space (mode, addr, as); | |
4337 mem = gen_rtx_MEM (mode, addr); | |
4338 | |
4339 set_mem_attributes (mem, to, 0); | |
4340 set_mem_addr_space (mem, as); | |
4341 | |
4342 icode = movmisalign_optab->handlers[mode].insn_code; | |
4343 gcc_assert (icode != CODE_FOR_nothing); | |
4344 | |
4345 op_mode1 = insn_data[icode].operand[1].mode; | |
4346 if (! (*insn_data[icode].operand[1].predicate) (reg, op_mode1) | |
4347 && op_mode1 != VOIDmode) | |
4348 reg = copy_to_mode_reg (op_mode1, reg); | |
4349 | |
4350 insn = GEN_FCN (icode) (mem, reg); | |
4351 emit_insn (insn); | |
4352 return; | |
4353 } | |
4354 | |
4355 /* If the rhs is a function call and its value is not an aggregate, | 4341 /* If the rhs is a function call and its value is not an aggregate, |
4356 call the function before we start to compute the lhs. | 4342 call the function before we start to compute the lhs. |
4357 This is needed for correct code for cases such as | 4343 This is needed for correct code for cases such as |
4358 val = setjmp (buf) on machines where reference to val | 4344 val = setjmp (buf) on machines where reference to val |
4359 requires loading up part of an address in a separate insn. | 4345 requires loading up part of an address in a separate insn. |
4470 | 4456 |
4471 bool | 4457 bool |
4472 emit_storent_insn (rtx to, rtx from) | 4458 emit_storent_insn (rtx to, rtx from) |
4473 { | 4459 { |
4474 enum machine_mode mode = GET_MODE (to), imode; | 4460 enum machine_mode mode = GET_MODE (to), imode; |
4475 enum insn_code code = optab_handler (storent_optab, mode)->insn_code; | 4461 enum insn_code code = optab_handler (storent_optab, mode); |
4476 rtx pattern; | 4462 rtx pattern; |
4477 | 4463 |
4478 if (code == CODE_FOR_nothing) | 4464 if (code == CODE_FOR_nothing) |
4479 return false; | 4465 return false; |
4480 | 4466 |
4622 convert_move (SUBREG_REG (target), temp, | 4608 convert_move (SUBREG_REG (target), temp, |
4623 SUBREG_PROMOTED_UNSIGNED_P (target)); | 4609 SUBREG_PROMOTED_UNSIGNED_P (target)); |
4624 | 4610 |
4625 return NULL_RTX; | 4611 return NULL_RTX; |
4626 } | 4612 } |
4627 else if (TREE_CODE (exp) == STRING_CST | 4613 else if ((TREE_CODE (exp) == STRING_CST |
4614 || (TREE_CODE (exp) == MEM_REF | |
4615 && TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR | |
4616 && TREE_CODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)) | |
4617 == STRING_CST | |
4618 && integer_zerop (TREE_OPERAND (exp, 1)))) | |
4628 && !nontemporal && !call_param_p | 4619 && !nontemporal && !call_param_p |
4629 && TREE_STRING_LENGTH (exp) > 0 | 4620 && MEM_P (target)) |
4630 && TYPE_MODE (TREE_TYPE (exp)) == BLKmode) | |
4631 { | 4621 { |
4632 /* Optimize initialization of an array with a STRING_CST. */ | 4622 /* Optimize initialization of an array with a STRING_CST. */ |
4633 HOST_WIDE_INT exp_len, str_copy_len; | 4623 HOST_WIDE_INT exp_len, str_copy_len; |
4634 rtx dest_mem; | 4624 rtx dest_mem; |
4625 tree str = TREE_CODE (exp) == STRING_CST | |
4626 ? exp : TREE_OPERAND (TREE_OPERAND (exp, 0), 0); | |
4635 | 4627 |
4636 exp_len = int_expr_size (exp); | 4628 exp_len = int_expr_size (exp); |
4637 if (exp_len <= 0) | 4629 if (exp_len <= 0) |
4638 goto normal_expr; | 4630 goto normal_expr; |
4639 | 4631 |
4640 str_copy_len = strlen (TREE_STRING_POINTER (exp)); | 4632 if (TREE_STRING_LENGTH (str) <= 0) |
4641 if (str_copy_len < TREE_STRING_LENGTH (exp) - 1) | |
4642 goto normal_expr; | 4633 goto normal_expr; |
4643 | 4634 |
4644 str_copy_len = TREE_STRING_LENGTH (exp); | 4635 str_copy_len = strlen (TREE_STRING_POINTER (str)); |
4645 if ((STORE_MAX_PIECES & (STORE_MAX_PIECES - 1)) == 0) | 4636 if (str_copy_len < TREE_STRING_LENGTH (str) - 1) |
4637 goto normal_expr; | |
4638 | |
4639 str_copy_len = TREE_STRING_LENGTH (str); | |
4640 if ((STORE_MAX_PIECES & (STORE_MAX_PIECES - 1)) == 0 | |
4641 && TREE_STRING_POINTER (str)[TREE_STRING_LENGTH (str) - 1] == '\0') | |
4646 { | 4642 { |
4647 str_copy_len += STORE_MAX_PIECES - 1; | 4643 str_copy_len += STORE_MAX_PIECES - 1; |
4648 str_copy_len &= ~(STORE_MAX_PIECES - 1); | 4644 str_copy_len &= ~(STORE_MAX_PIECES - 1); |
4649 } | 4645 } |
4650 str_copy_len = MIN (str_copy_len, exp_len); | 4646 str_copy_len = MIN (str_copy_len, exp_len); |
4651 if (!can_store_by_pieces (str_copy_len, builtin_strncpy_read_str, | 4647 if (!can_store_by_pieces (str_copy_len, builtin_strncpy_read_str, |
4652 CONST_CAST(char *, TREE_STRING_POINTER (exp)), | 4648 CONST_CAST (char *, TREE_STRING_POINTER (str)), |
4653 MEM_ALIGN (target), false)) | 4649 MEM_ALIGN (target), false)) |
4654 goto normal_expr; | 4650 goto normal_expr; |
4655 | 4651 |
4656 dest_mem = target; | 4652 dest_mem = target; |
4657 | 4653 |
4658 dest_mem = store_by_pieces (dest_mem, | 4654 dest_mem = store_by_pieces (dest_mem, |
4659 str_copy_len, builtin_strncpy_read_str, | 4655 str_copy_len, builtin_strncpy_read_str, |
4660 CONST_CAST(char *, TREE_STRING_POINTER (exp)), | 4656 CONST_CAST (char *, |
4657 TREE_STRING_POINTER (str)), | |
4661 MEM_ALIGN (target), false, | 4658 MEM_ALIGN (target), false, |
4662 exp_len > str_copy_len ? 1 : 0); | 4659 exp_len > str_copy_len ? 1 : 0); |
4663 if (exp_len > str_copy_len) | 4660 if (exp_len > str_copy_len) |
4664 clear_storage (adjust_address (dest_mem, BLKmode, 0), | 4661 clear_storage (adjust_address (dest_mem, BLKmode, 0), |
4665 GEN_INT (exp_len - str_copy_len), | 4662 GEN_INT (exp_len - str_copy_len), |
4713 || side_effects_p (target)))) | 4710 || side_effects_p (target)))) |
4714 && TREE_CODE (exp) != ERROR_MARK | 4711 && TREE_CODE (exp) != ERROR_MARK |
4715 /* If store_expr stores a DECL whose DECL_RTL(exp) == TARGET, | 4712 /* If store_expr stores a DECL whose DECL_RTL(exp) == TARGET, |
4716 but TARGET is not valid memory reference, TEMP will differ | 4713 but TARGET is not valid memory reference, TEMP will differ |
4717 from TARGET although it is really the same location. */ | 4714 from TARGET although it is really the same location. */ |
4718 && !(alt_rtl && rtx_equal_p (alt_rtl, target)) | 4715 && !(alt_rtl |
4716 && rtx_equal_p (alt_rtl, target) | |
4717 && !side_effects_p (alt_rtl) | |
4718 && !side_effects_p (target)) | |
4719 /* If there's nothing to copy, don't bother. Don't call | 4719 /* If there's nothing to copy, don't bother. Don't call |
4720 expr_size unless necessary, because some front-ends (C++) | 4720 expr_size unless necessary, because some front-ends (C++) |
4721 expr_size-hook must not be given objects that are not | 4721 expr_size-hook must not be given objects that are not |
4722 supposed to be bit-copied or bit-initialized. */ | 4722 supposed to be bit-copied or bit-initialized. */ |
4723 && expr_size (exp) != const0_rtx) | 4723 && expr_size (exp) != const0_rtx) |
4725 if (GET_MODE (temp) != GET_MODE (target) | 4725 if (GET_MODE (temp) != GET_MODE (target) |
4726 && GET_MODE (temp) != VOIDmode) | 4726 && GET_MODE (temp) != VOIDmode) |
4727 { | 4727 { |
4728 int unsignedp = TYPE_UNSIGNED (TREE_TYPE (exp)); | 4728 int unsignedp = TYPE_UNSIGNED (TREE_TYPE (exp)); |
4729 if (GET_MODE (target) == BLKmode | 4729 if (GET_MODE (target) == BLKmode |
4730 || GET_MODE (temp) == BLKmode) | 4730 && GET_MODE (temp) == BLKmode) |
4731 emit_block_move (target, temp, expr_size (exp), | 4731 emit_block_move (target, temp, expr_size (exp), |
4732 (call_param_p | 4732 (call_param_p |
4733 ? BLOCK_OP_CALL_PARM | 4733 ? BLOCK_OP_CALL_PARM |
4734 : BLOCK_OP_NORMAL)); | 4734 : BLOCK_OP_NORMAL)); |
4735 else if (GET_MODE (target) == BLKmode) | |
4736 store_bit_field (target, INTVAL (expr_size (exp)) * BITS_PER_UNIT, | |
4737 0, GET_MODE (temp), temp); | |
4735 else | 4738 else |
4736 convert_move (target, temp, unsignedp); | 4739 convert_move (target, temp, unsignedp); |
4737 } | 4740 } |
4738 | 4741 |
4739 else if (GET_MODE (temp) == BLKmode && TREE_CODE (exp) == STRING_CST) | 4742 else if (GET_MODE (temp) == BLKmode && TREE_CODE (exp) == STRING_CST) |
5026 case RECORD_TYPE: | 5029 case RECORD_TYPE: |
5027 { | 5030 { |
5028 HOST_WIDE_INT n = 0, t; | 5031 HOST_WIDE_INT n = 0, t; |
5029 tree f; | 5032 tree f; |
5030 | 5033 |
5031 for (f = TYPE_FIELDS (type); f ; f = TREE_CHAIN (f)) | 5034 for (f = TYPE_FIELDS (type); f ; f = DECL_CHAIN (f)) |
5032 if (TREE_CODE (f) == FIELD_DECL) | 5035 if (TREE_CODE (f) == FIELD_DECL) |
5033 { | 5036 { |
5034 t = count_type_elements (TREE_TYPE (f), false); | 5037 t = count_type_elements (TREE_TYPE (f), false); |
5035 if (t < 0) | 5038 if (t < 0) |
5036 { | 5039 { |
5037 /* Check for structures with flexible array member. */ | 5040 /* Check for structures with flexible array member. */ |
5038 tree tf = TREE_TYPE (f); | 5041 tree tf = TREE_TYPE (f); |
5039 if (allow_flexarr | 5042 if (allow_flexarr |
5040 && TREE_CHAIN (f) == NULL | 5043 && DECL_CHAIN (f) == NULL |
5041 && TREE_CODE (tf) == ARRAY_TYPE | 5044 && TREE_CODE (tf) == ARRAY_TYPE |
5042 && TYPE_DOMAIN (tf) | 5045 && TYPE_DOMAIN (tf) |
5043 && TYPE_MIN_VALUE (TYPE_DOMAIN (tf)) | 5046 && TYPE_MIN_VALUE (TYPE_DOMAIN (tf)) |
5044 && integer_zerop (TYPE_MIN_VALUE (TYPE_DOMAIN (tf))) | 5047 && integer_zerop (TYPE_MIN_VALUE (TYPE_DOMAIN (tf))) |
5045 && !TYPE_MAX_VALUE (TYPE_DOMAIN (tf)) | 5048 && !TYPE_MAX_VALUE (TYPE_DOMAIN (tf)) |
5632 n_elts = TYPE_VECTOR_SUBPARTS (type); | 5635 n_elts = TYPE_VECTOR_SUBPARTS (type); |
5633 if (REG_P (target) && VECTOR_MODE_P (GET_MODE (target))) | 5636 if (REG_P (target) && VECTOR_MODE_P (GET_MODE (target))) |
5634 { | 5637 { |
5635 enum machine_mode mode = GET_MODE (target); | 5638 enum machine_mode mode = GET_MODE (target); |
5636 | 5639 |
5637 icode = (int) optab_handler (vec_init_optab, mode)->insn_code; | 5640 icode = (int) optab_handler (vec_init_optab, mode); |
5638 if (icode != CODE_FOR_nothing) | 5641 if (icode != CODE_FOR_nothing) |
5639 { | 5642 { |
5640 unsigned int i; | 5643 unsigned int i; |
5641 | 5644 |
5642 vector = rtvec_alloc (n_elts); | 5645 vector = rtvec_alloc (n_elts); |
5830 /* If the RHS and field are a constant size and the size of the | 5833 /* If the RHS and field are a constant size and the size of the |
5831 RHS isn't the same size as the bitfield, we must use bitfield | 5834 RHS isn't the same size as the bitfield, we must use bitfield |
5832 operations. */ | 5835 operations. */ |
5833 || (bitsize >= 0 | 5836 || (bitsize >= 0 |
5834 && TREE_CODE (TYPE_SIZE (TREE_TYPE (exp))) == INTEGER_CST | 5837 && TREE_CODE (TYPE_SIZE (TREE_TYPE (exp))) == INTEGER_CST |
5835 && compare_tree_int (TYPE_SIZE (TREE_TYPE (exp)), bitsize) != 0)) | 5838 && compare_tree_int (TYPE_SIZE (TREE_TYPE (exp)), bitsize) != 0) |
5839 /* If we are expanding a MEM_REF of a non-BLKmode non-addressable | |
5840 decl we must use bitfield operations. */ | |
5841 || (bitsize >= 0 | |
5842 && TREE_CODE (exp) == MEM_REF | |
5843 && TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR | |
5844 && DECL_P (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)) | |
5845 && !TREE_ADDRESSABLE (TREE_OPERAND (TREE_OPERAND (exp, 0),0 )) | |
5846 && DECL_MODE (TREE_OPERAND (TREE_OPERAND (exp, 0), 0)) != BLKmode)) | |
5836 { | 5847 { |
5837 rtx temp; | 5848 rtx temp; |
5838 gimple nop_def; | 5849 gimple nop_def; |
5839 | 5850 |
5840 /* If EXP is a NOP_EXPR of precision less than its mode, then that | 5851 /* If EXP is a NOP_EXPR of precision less than its mode, then that |
5911 rtx to_rtx = adjust_address (target, mode, bitpos / BITS_PER_UNIT); | 5922 rtx to_rtx = adjust_address (target, mode, bitpos / BITS_PER_UNIT); |
5912 | 5923 |
5913 if (to_rtx == target) | 5924 if (to_rtx == target) |
5914 to_rtx = copy_rtx (to_rtx); | 5925 to_rtx = copy_rtx (to_rtx); |
5915 | 5926 |
5916 MEM_SET_IN_STRUCT_P (to_rtx, 1); | 5927 if (!MEM_SCALAR_P (to_rtx)) |
5928 MEM_IN_STRUCT_P (to_rtx) = 1; | |
5917 if (!MEM_KEEP_ALIAS_SET_P (to_rtx) && MEM_ALIAS_SET (to_rtx) != 0) | 5929 if (!MEM_KEEP_ALIAS_SET_P (to_rtx) && MEM_ALIAS_SET (to_rtx) != 0) |
5918 set_mem_alias_set (to_rtx, alias_set); | 5930 set_mem_alias_set (to_rtx, alias_set); |
5919 | 5931 |
5920 return store_expr (exp, to_rtx, 0, nontemporal); | 5932 return store_expr (exp, to_rtx, 0, nontemporal); |
5921 } | 5933 } |
5964 { | 5976 { |
5965 tree size_tree = 0; | 5977 tree size_tree = 0; |
5966 enum machine_mode mode = VOIDmode; | 5978 enum machine_mode mode = VOIDmode; |
5967 bool blkmode_bitfield = false; | 5979 bool blkmode_bitfield = false; |
5968 tree offset = size_zero_node; | 5980 tree offset = size_zero_node; |
5969 tree bit_offset = bitsize_zero_node; | 5981 double_int bit_offset = double_int_zero; |
5970 | 5982 |
5971 /* First get the mode, signedness, and size. We do this from just the | 5983 /* First get the mode, signedness, and size. We do this from just the |
5972 outermost expression. */ | 5984 outermost expression. */ |
5973 *pbitsize = -1; | 5985 *pbitsize = -1; |
5974 if (TREE_CODE (exp) == COMPONENT_REF) | 5986 if (TREE_CODE (exp) == COMPONENT_REF) |
5977 size_tree = DECL_SIZE (field); | 5989 size_tree = DECL_SIZE (field); |
5978 if (!DECL_BIT_FIELD (field)) | 5990 if (!DECL_BIT_FIELD (field)) |
5979 mode = DECL_MODE (field); | 5991 mode = DECL_MODE (field); |
5980 else if (DECL_MODE (field) == BLKmode) | 5992 else if (DECL_MODE (field) == BLKmode) |
5981 blkmode_bitfield = true; | 5993 blkmode_bitfield = true; |
5994 else if (TREE_THIS_VOLATILE (exp) | |
5995 && flag_strict_volatile_bitfields > 0) | |
5996 /* Volatile bitfields should be accessed in the mode of the | |
5997 field's type, not the mode computed based on the bit | |
5998 size. */ | |
5999 mode = TYPE_MODE (DECL_BIT_FIELD_TYPE (field)); | |
5982 | 6000 |
5983 *punsignedp = DECL_UNSIGNED (field); | 6001 *punsignedp = DECL_UNSIGNED (field); |
5984 } | 6002 } |
5985 else if (TREE_CODE (exp) == BIT_FIELD_REF) | 6003 else if (TREE_CODE (exp) == BIT_FIELD_REF) |
5986 { | 6004 { |
6019 while (1) | 6037 while (1) |
6020 { | 6038 { |
6021 switch (TREE_CODE (exp)) | 6039 switch (TREE_CODE (exp)) |
6022 { | 6040 { |
6023 case BIT_FIELD_REF: | 6041 case BIT_FIELD_REF: |
6024 bit_offset = size_binop (PLUS_EXPR, bit_offset, | 6042 bit_offset |
6025 TREE_OPERAND (exp, 2)); | 6043 = double_int_add (bit_offset, |
6044 tree_to_double_int (TREE_OPERAND (exp, 2))); | |
6026 break; | 6045 break; |
6027 | 6046 |
6028 case COMPONENT_REF: | 6047 case COMPONENT_REF: |
6029 { | 6048 { |
6030 tree field = TREE_OPERAND (exp, 1); | 6049 tree field = TREE_OPERAND (exp, 1); |
6035 type construction. */ | 6054 type construction. */ |
6036 if (this_offset == 0) | 6055 if (this_offset == 0) |
6037 break; | 6056 break; |
6038 | 6057 |
6039 offset = size_binop (PLUS_EXPR, offset, this_offset); | 6058 offset = size_binop (PLUS_EXPR, offset, this_offset); |
6040 bit_offset = size_binop (PLUS_EXPR, bit_offset, | 6059 bit_offset = double_int_add (bit_offset, |
6041 DECL_FIELD_BIT_OFFSET (field)); | 6060 tree_to_double_int |
6061 (DECL_FIELD_BIT_OFFSET (field))); | |
6042 | 6062 |
6043 /* ??? Right now we don't do anything with DECL_OFFSET_ALIGN. */ | 6063 /* ??? Right now we don't do anything with DECL_OFFSET_ALIGN. */ |
6044 } | 6064 } |
6045 break; | 6065 break; |
6046 | 6066 |
6068 | 6088 |
6069 case REALPART_EXPR: | 6089 case REALPART_EXPR: |
6070 break; | 6090 break; |
6071 | 6091 |
6072 case IMAGPART_EXPR: | 6092 case IMAGPART_EXPR: |
6073 bit_offset = size_binop (PLUS_EXPR, bit_offset, | 6093 bit_offset = double_int_add (bit_offset, |
6074 bitsize_int (*pbitsize)); | 6094 uhwi_to_double_int (*pbitsize)); |
6075 break; | 6095 break; |
6076 | 6096 |
6077 case VIEW_CONVERT_EXPR: | 6097 case VIEW_CONVERT_EXPR: |
6078 if (keep_aligning && STRICT_ALIGNMENT | 6098 if (keep_aligning && STRICT_ALIGNMENT |
6079 && (TYPE_ALIGN (TREE_TYPE (exp)) | 6099 && (TYPE_ALIGN (TREE_TYPE (exp)) |
6083 && (TYPE_ALIGN_OK (TREE_TYPE (exp)) | 6103 && (TYPE_ALIGN_OK (TREE_TYPE (exp)) |
6084 || TYPE_ALIGN_OK (TREE_TYPE (TREE_OPERAND (exp, 0))))) | 6104 || TYPE_ALIGN_OK (TREE_TYPE (TREE_OPERAND (exp, 0))))) |
6085 goto done; | 6105 goto done; |
6086 break; | 6106 break; |
6087 | 6107 |
6108 case MEM_REF: | |
6109 /* Hand back the decl for MEM[&decl, off]. */ | |
6110 if (TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR) | |
6111 { | |
6112 tree off = TREE_OPERAND (exp, 1); | |
6113 if (!integer_zerop (off)) | |
6114 { | |
6115 double_int boff, coff = mem_ref_offset (exp); | |
6116 boff = double_int_lshift (coff, | |
6117 BITS_PER_UNIT == 8 | |
6118 ? 3 : exact_log2 (BITS_PER_UNIT), | |
6119 HOST_BITS_PER_DOUBLE_INT, true); | |
6120 bit_offset = double_int_add (bit_offset, boff); | |
6121 } | |
6122 exp = TREE_OPERAND (TREE_OPERAND (exp, 0), 0); | |
6123 } | |
6124 goto done; | |
6125 | |
6088 default: | 6126 default: |
6089 goto done; | 6127 goto done; |
6090 } | 6128 } |
6091 | 6129 |
6092 /* If any reference in the chain is volatile, the effect is volatile. */ | 6130 /* If any reference in the chain is volatile, the effect is volatile. */ |
6100 /* If OFFSET is constant, see if we can return the whole thing as a | 6138 /* If OFFSET is constant, see if we can return the whole thing as a |
6101 constant bit position. Make sure to handle overflow during | 6139 constant bit position. Make sure to handle overflow during |
6102 this conversion. */ | 6140 this conversion. */ |
6103 if (host_integerp (offset, 0)) | 6141 if (host_integerp (offset, 0)) |
6104 { | 6142 { |
6105 double_int tem = double_int_mul (tree_to_double_int (offset), | 6143 double_int tem = double_int_lshift (tree_to_double_int (offset), |
6106 uhwi_to_double_int (BITS_PER_UNIT)); | 6144 BITS_PER_UNIT == 8 |
6107 tem = double_int_add (tem, tree_to_double_int (bit_offset)); | 6145 ? 3 : exact_log2 (BITS_PER_UNIT), |
6146 HOST_BITS_PER_DOUBLE_INT, true); | |
6147 tem = double_int_add (tem, bit_offset); | |
6108 if (double_int_fits_in_shwi_p (tem)) | 6148 if (double_int_fits_in_shwi_p (tem)) |
6109 { | 6149 { |
6110 *pbitpos = double_int_to_shwi (tem); | 6150 *pbitpos = double_int_to_shwi (tem); |
6111 *poffset = offset = NULL_TREE; | 6151 *poffset = offset = NULL_TREE; |
6112 } | 6152 } |
6113 } | 6153 } |
6114 | 6154 |
6115 /* Otherwise, split it up. */ | 6155 /* Otherwise, split it up. */ |
6116 if (offset) | 6156 if (offset) |
6117 { | 6157 { |
6118 *pbitpos = tree_low_cst (bit_offset, 0); | 6158 *pbitpos = double_int_to_shwi (bit_offset); |
6119 *poffset = offset; | 6159 *poffset = offset; |
6120 } | 6160 } |
6121 | 6161 |
6122 /* We can use BLKmode for a byte-aligned BLKmode bitfield. */ | 6162 /* We can use BLKmode for a byte-aligned BLKmode bitfield. */ |
6123 if (mode == VOIDmode | 6163 if (mode == VOIDmode |
6533 else if (TREE_CODE (exp) == CONSTRUCTOR) | 6573 else if (TREE_CODE (exp) == CONSTRUCTOR) |
6534 { | 6574 { |
6535 constructor_elt *ce; | 6575 constructor_elt *ce; |
6536 unsigned HOST_WIDE_INT idx; | 6576 unsigned HOST_WIDE_INT idx; |
6537 | 6577 |
6538 for (idx = 0; | 6578 FOR_EACH_VEC_ELT (constructor_elt, CONSTRUCTOR_ELTS (exp), idx, ce) |
6539 VEC_iterate (constructor_elt, CONSTRUCTOR_ELTS (exp), idx, ce); | |
6540 idx++) | |
6541 if ((ce->index != NULL_TREE && !safe_from_p (x, ce->index, 0)) | 6579 if ((ce->index != NULL_TREE && !safe_from_p (x, ce->index, 0)) |
6542 || !safe_from_p (x, ce->value, 0)) | 6580 || !safe_from_p (x, ce->value, 0)) |
6543 return 0; | 6581 return 0; |
6544 return 1; | 6582 return 1; |
6545 } | 6583 } |
6595 else | 6633 else |
6596 exp_rtl = XEXP (DECL_RTL (exp), 0); | 6634 exp_rtl = XEXP (DECL_RTL (exp), 0); |
6597 } | 6635 } |
6598 break; | 6636 break; |
6599 | 6637 |
6600 case MISALIGNED_INDIRECT_REF: | 6638 case MEM_REF: |
6601 case ALIGN_INDIRECT_REF: | |
6602 case INDIRECT_REF: | |
6603 if (MEM_P (x) | 6639 if (MEM_P (x) |
6604 && alias_sets_conflict_p (MEM_ALIAS_SET (x), | 6640 && alias_sets_conflict_p (MEM_ALIAS_SET (x), |
6605 get_alias_set (exp))) | 6641 get_alias_set (exp))) |
6606 return 0; | 6642 return 0; |
6607 break; | 6643 break; |
6756 unsigned HOST_WIDE_INT factor = highest_pow2_factor (exp); | 6792 unsigned HOST_WIDE_INT factor = highest_pow2_factor (exp); |
6757 | 6793 |
6758 return MAX (factor, talign); | 6794 return MAX (factor, talign); |
6759 } | 6795 } |
6760 | 6796 |
6761 /* Return &VAR expression for emulated thread local VAR. */ | |
6762 | |
6763 static tree | |
6764 emutls_var_address (tree var) | |
6765 { | |
6766 tree emuvar = emutls_decl (var); | |
6767 tree fn = built_in_decls [BUILT_IN_EMUTLS_GET_ADDRESS]; | |
6768 tree arg = build_fold_addr_expr_with_type (emuvar, ptr_type_node); | |
6769 tree arglist = build_tree_list (NULL_TREE, arg); | |
6770 tree call = build_function_call_expr (UNKNOWN_LOCATION, fn, arglist); | |
6771 return fold_convert (build_pointer_type (TREE_TYPE (var)), call); | |
6772 } | |
6773 | |
6774 | |
6775 /* Subroutine of expand_expr. Expand the two operands of a binary | 6797 /* Subroutine of expand_expr. Expand the two operands of a binary |
6776 expression EXP0 and EXP1 placing the results in OP0 and OP1. | 6798 expression EXP0 and EXP1 placing the results in OP0 and OP1. |
6777 The value may be stored in TARGET if TARGET is nonzero. The | 6799 The value may be stored in TARGET if TARGET is nonzero. The |
6778 MODIFIER argument is as documented by expand_expr. */ | 6800 MODIFIER argument is as documented by expand_expr. */ |
6779 | 6801 |
6841 { | 6863 { |
6842 case INDIRECT_REF: | 6864 case INDIRECT_REF: |
6843 /* This case will happen via recursion for &a->b. */ | 6865 /* This case will happen via recursion for &a->b. */ |
6844 return expand_expr (TREE_OPERAND (exp, 0), target, tmode, modifier); | 6866 return expand_expr (TREE_OPERAND (exp, 0), target, tmode, modifier); |
6845 | 6867 |
6868 case MEM_REF: | |
6869 { | |
6870 tree tem = TREE_OPERAND (exp, 0); | |
6871 if (!integer_zerop (TREE_OPERAND (exp, 1))) | |
6872 tem = build2 (POINTER_PLUS_EXPR, TREE_TYPE (TREE_OPERAND (exp, 1)), | |
6873 tem, | |
6874 double_int_to_tree (sizetype, mem_ref_offset (exp))); | |
6875 return expand_expr (tem, target, tmode, modifier); | |
6876 } | |
6877 | |
6846 case CONST_DECL: | 6878 case CONST_DECL: |
6847 /* Expand the initializer like constants above. */ | 6879 /* Expand the initializer like constants above. */ |
6848 return XEXP (expand_expr_constant (DECL_INITIAL (exp), 0, modifier), 0); | 6880 return XEXP (expand_expr_constant (DECL_INITIAL (exp), 0, modifier), 0); |
6849 | 6881 |
6850 case REALPART_EXPR: | 6882 case REALPART_EXPR: |
6861 scalar type. */ | 6893 scalar type. */ |
6862 offset = 0; | 6894 offset = 0; |
6863 bitpos = GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (exp))); | 6895 bitpos = GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (exp))); |
6864 inner = TREE_OPERAND (exp, 0); | 6896 inner = TREE_OPERAND (exp, 0); |
6865 break; | 6897 break; |
6866 | |
6867 case VAR_DECL: | |
6868 /* TLS emulation hook - replace __thread VAR's &VAR with | |
6869 __emutls_get_address (&_emutls.VAR). */ | |
6870 if (! targetm.have_tls | |
6871 && TREE_CODE (exp) == VAR_DECL | |
6872 && DECL_THREAD_LOCAL_P (exp)) | |
6873 { | |
6874 exp = emutls_var_address (exp); | |
6875 return expand_expr (exp, target, tmode, modifier); | |
6876 } | |
6877 /* Fall through. */ | |
6878 | 6898 |
6879 default: | 6899 default: |
6880 /* If the object is a DECL, then expand it for its rtl. Don't bypass | 6900 /* If the object is a DECL, then expand it for its rtl. Don't bypass |
6881 expand_expr, as that can have various side effects; LABEL_DECLs for | 6901 expand_expr, as that can have various side effects; LABEL_DECLs for |
6882 example, may not have their DECL_RTL set yet. Expand the rtl of | 6902 example, may not have their DECL_RTL set yet. Expand the rtl of |
6949 | 6969 |
6950 result = convert_memory_address_addr_space (tmode, result, as); | 6970 result = convert_memory_address_addr_space (tmode, result, as); |
6951 tmp = convert_memory_address_addr_space (tmode, tmp, as); | 6971 tmp = convert_memory_address_addr_space (tmode, tmp, as); |
6952 | 6972 |
6953 if (modifier == EXPAND_SUM || modifier == EXPAND_INITIALIZER) | 6973 if (modifier == EXPAND_SUM || modifier == EXPAND_INITIALIZER) |
6954 result = gen_rtx_PLUS (tmode, result, tmp); | 6974 result = simplify_gen_binary (PLUS, tmode, result, tmp); |
6955 else | 6975 else |
6956 { | 6976 { |
6957 subtarget = bitpos ? NULL_RTX : target; | 6977 subtarget = bitpos ? NULL_RTX : target; |
6958 result = expand_simple_binop (tmode, PLUS, result, tmp, subtarget, | 6978 result = expand_simple_binop (tmode, PLUS, result, tmp, subtarget, |
6959 1, OPTAB_LIB_WIDEN); | 6979 1, OPTAB_LIB_WIDEN); |
7209 enum tree_code code = ops->code; | 7229 enum tree_code code = ops->code; |
7210 optab this_optab; | 7230 optab this_optab; |
7211 rtx subtarget, original_target; | 7231 rtx subtarget, original_target; |
7212 int ignore; | 7232 int ignore; |
7213 bool reduce_bit_field; | 7233 bool reduce_bit_field; |
7214 gimple subexp0_def, subexp1_def; | |
7215 tree top0, top1; | |
7216 location_t loc = ops->location; | 7234 location_t loc = ops->location; |
7217 tree treeop0, treeop1; | 7235 tree treeop0, treeop1, treeop2; |
7218 #define REDUCE_BIT_FIELD(expr) (reduce_bit_field \ | 7236 #define REDUCE_BIT_FIELD(expr) (reduce_bit_field \ |
7219 ? reduce_to_bit_field_precision ((expr), \ | 7237 ? reduce_to_bit_field_precision ((expr), \ |
7220 target, \ | 7238 target, \ |
7221 type) \ | 7239 type) \ |
7222 : (expr)) | 7240 : (expr)) |
7225 mode = TYPE_MODE (type); | 7243 mode = TYPE_MODE (type); |
7226 unsignedp = TYPE_UNSIGNED (type); | 7244 unsignedp = TYPE_UNSIGNED (type); |
7227 | 7245 |
7228 treeop0 = ops->op0; | 7246 treeop0 = ops->op0; |
7229 treeop1 = ops->op1; | 7247 treeop1 = ops->op1; |
7248 treeop2 = ops->op2; | |
7230 | 7249 |
7231 /* We should be called only on simple (binary or unary) expressions, | 7250 /* We should be called only on simple (binary or unary) expressions, |
7232 exactly those that are valid in gimple expressions that aren't | 7251 exactly those that are valid in gimple expressions that aren't |
7233 GIMPLE_SINGLE_RHS (or invalid). */ | 7252 GIMPLE_SINGLE_RHS (or invalid). */ |
7234 gcc_assert (get_gimple_rhs_class (code) == GIMPLE_UNARY_RHS | 7253 gcc_assert (get_gimple_rhs_class (code) == GIMPLE_UNARY_RHS |
7235 || get_gimple_rhs_class (code) == GIMPLE_BINARY_RHS); | 7254 || get_gimple_rhs_class (code) == GIMPLE_BINARY_RHS |
7255 || get_gimple_rhs_class (code) == GIMPLE_TERNARY_RHS); | |
7236 | 7256 |
7237 ignore = (target == const0_rtx | 7257 ignore = (target == const0_rtx |
7238 || ((CONVERT_EXPR_CODE_P (code) | 7258 || ((CONVERT_EXPR_CODE_P (code) |
7239 || code == COND_EXPR || code == VIEW_CONVERT_EXPR) | 7259 || code == COND_EXPR || code == VIEW_CONVERT_EXPR) |
7240 && TREE_CODE (type) == VOID_TYPE)); | 7260 && TREE_CODE (type) == VOID_TYPE)); |
7405 if (TYPE_PRECISION (sizetype) < TYPE_PRECISION (type)) | 7425 if (TYPE_PRECISION (sizetype) < TYPE_PRECISION (type)) |
7406 treeop1 = fold_convert_loc (loc, type, | 7426 treeop1 = fold_convert_loc (loc, type, |
7407 fold_convert_loc (loc, ssizetype, | 7427 fold_convert_loc (loc, ssizetype, |
7408 treeop1)); | 7428 treeop1)); |
7409 case PLUS_EXPR: | 7429 case PLUS_EXPR: |
7410 | |
7411 /* Check if this is a case for multiplication and addition. */ | |
7412 if ((TREE_CODE (type) == INTEGER_TYPE | |
7413 || TREE_CODE (type) == FIXED_POINT_TYPE) | |
7414 && (subexp0_def = get_def_for_expr (treeop0, | |
7415 MULT_EXPR))) | |
7416 { | |
7417 tree subsubexp0, subsubexp1; | |
7418 gimple subsubexp0_def, subsubexp1_def; | |
7419 enum tree_code this_code; | |
7420 | |
7421 this_code = TREE_CODE (type) == INTEGER_TYPE ? NOP_EXPR | |
7422 : FIXED_CONVERT_EXPR; | |
7423 subsubexp0 = gimple_assign_rhs1 (subexp0_def); | |
7424 subsubexp0_def = get_def_for_expr (subsubexp0, this_code); | |
7425 subsubexp1 = gimple_assign_rhs2 (subexp0_def); | |
7426 subsubexp1_def = get_def_for_expr (subsubexp1, this_code); | |
7427 if (subsubexp0_def && subsubexp1_def | |
7428 && (top0 = gimple_assign_rhs1 (subsubexp0_def)) | |
7429 && (top1 = gimple_assign_rhs1 (subsubexp1_def)) | |
7430 && (TYPE_PRECISION (TREE_TYPE (top0)) | |
7431 < TYPE_PRECISION (TREE_TYPE (subsubexp0))) | |
7432 && (TYPE_PRECISION (TREE_TYPE (top0)) | |
7433 == TYPE_PRECISION (TREE_TYPE (top1))) | |
7434 && (TYPE_UNSIGNED (TREE_TYPE (top0)) | |
7435 == TYPE_UNSIGNED (TREE_TYPE (top1)))) | |
7436 { | |
7437 tree op0type = TREE_TYPE (top0); | |
7438 enum machine_mode innermode = TYPE_MODE (op0type); | |
7439 bool zextend_p = TYPE_UNSIGNED (op0type); | |
7440 bool sat_p = TYPE_SATURATING (TREE_TYPE (subsubexp0)); | |
7441 if (sat_p == 0) | |
7442 this_optab = zextend_p ? umadd_widen_optab : smadd_widen_optab; | |
7443 else | |
7444 this_optab = zextend_p ? usmadd_widen_optab | |
7445 : ssmadd_widen_optab; | |
7446 if (mode == GET_MODE_2XWIDER_MODE (innermode) | |
7447 && (optab_handler (this_optab, mode)->insn_code | |
7448 != CODE_FOR_nothing)) | |
7449 { | |
7450 expand_operands (top0, top1, NULL_RTX, &op0, &op1, | |
7451 EXPAND_NORMAL); | |
7452 op2 = expand_expr (treeop1, subtarget, | |
7453 VOIDmode, EXPAND_NORMAL); | |
7454 temp = expand_ternary_op (mode, this_optab, op0, op1, op2, | |
7455 target, unsignedp); | |
7456 gcc_assert (temp); | |
7457 return REDUCE_BIT_FIELD (temp); | |
7458 } | |
7459 } | |
7460 } | |
7461 | |
7462 /* If we are adding a constant, a VAR_DECL that is sp, fp, or ap, and | 7430 /* If we are adding a constant, a VAR_DECL that is sp, fp, or ap, and |
7463 something else, make sure we add the register to the constant and | 7431 something else, make sure we add the register to the constant and |
7464 then to the other thing. This case can occur during strength | 7432 then to the other thing. This case can occur during strength |
7465 reduction and doing it this way will produce better code if the | 7433 reduction and doing it this way will produce better code if the |
7466 frame pointer or argument pointer is eliminated. | 7434 frame pointer or argument pointer is eliminated. |
7550 op0 = force_operand (op0, target); | 7518 op0 = force_operand (op0, target); |
7551 return REDUCE_BIT_FIELD (op0); | 7519 return REDUCE_BIT_FIELD (op0); |
7552 } | 7520 } |
7553 } | 7521 } |
7554 | 7522 |
7523 /* Use TER to expand pointer addition of a negated value | |
7524 as pointer subtraction. */ | |
7525 if ((POINTER_TYPE_P (TREE_TYPE (treeop0)) | |
7526 || (TREE_CODE (TREE_TYPE (treeop0)) == VECTOR_TYPE | |
7527 && POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (treeop0))))) | |
7528 && TREE_CODE (treeop1) == SSA_NAME | |
7529 && TYPE_MODE (TREE_TYPE (treeop0)) | |
7530 == TYPE_MODE (TREE_TYPE (treeop1))) | |
7531 { | |
7532 gimple def = get_def_for_expr (treeop1, NEGATE_EXPR); | |
7533 if (def) | |
7534 { | |
7535 treeop1 = gimple_assign_rhs1 (def); | |
7536 code = MINUS_EXPR; | |
7537 goto do_minus; | |
7538 } | |
7539 } | |
7540 | |
7555 /* No sense saving up arithmetic to be done | 7541 /* No sense saving up arithmetic to be done |
7556 if it's all in the wrong mode to form part of an address. | 7542 if it's all in the wrong mode to form part of an address. |
7557 And force_operand won't know whether to sign-extend or | 7543 And force_operand won't know whether to sign-extend or |
7558 zero-extend. */ | 7544 zero-extend. */ |
7559 if ((modifier != EXPAND_SUM && modifier != EXPAND_INITIALIZER) | 7545 if ((modifier != EXPAND_SUM && modifier != EXPAND_INITIALIZER) |
7571 expand_operands (treeop0, treeop1, | 7557 expand_operands (treeop0, treeop1, |
7572 subtarget, &op0, &op1, modifier); | 7558 subtarget, &op0, &op1, modifier); |
7573 return REDUCE_BIT_FIELD (simplify_gen_binary (PLUS, mode, op0, op1)); | 7559 return REDUCE_BIT_FIELD (simplify_gen_binary (PLUS, mode, op0, op1)); |
7574 | 7560 |
7575 case MINUS_EXPR: | 7561 case MINUS_EXPR: |
7576 /* Check if this is a case for multiplication and subtraction. */ | 7562 do_minus: |
7577 if ((TREE_CODE (type) == INTEGER_TYPE | |
7578 || TREE_CODE (type) == FIXED_POINT_TYPE) | |
7579 && (subexp1_def = get_def_for_expr (treeop1, | |
7580 MULT_EXPR))) | |
7581 { | |
7582 tree subsubexp0, subsubexp1; | |
7583 gimple subsubexp0_def, subsubexp1_def; | |
7584 enum tree_code this_code; | |
7585 | |
7586 this_code = TREE_CODE (type) == INTEGER_TYPE ? NOP_EXPR | |
7587 : FIXED_CONVERT_EXPR; | |
7588 subsubexp0 = gimple_assign_rhs1 (subexp1_def); | |
7589 subsubexp0_def = get_def_for_expr (subsubexp0, this_code); | |
7590 subsubexp1 = gimple_assign_rhs2 (subexp1_def); | |
7591 subsubexp1_def = get_def_for_expr (subsubexp1, this_code); | |
7592 if (subsubexp0_def && subsubexp1_def | |
7593 && (top0 = gimple_assign_rhs1 (subsubexp0_def)) | |
7594 && (top1 = gimple_assign_rhs1 (subsubexp1_def)) | |
7595 && (TYPE_PRECISION (TREE_TYPE (top0)) | |
7596 < TYPE_PRECISION (TREE_TYPE (subsubexp0))) | |
7597 && (TYPE_PRECISION (TREE_TYPE (top0)) | |
7598 == TYPE_PRECISION (TREE_TYPE (top1))) | |
7599 && (TYPE_UNSIGNED (TREE_TYPE (top0)) | |
7600 == TYPE_UNSIGNED (TREE_TYPE (top1)))) | |
7601 { | |
7602 tree op0type = TREE_TYPE (top0); | |
7603 enum machine_mode innermode = TYPE_MODE (op0type); | |
7604 bool zextend_p = TYPE_UNSIGNED (op0type); | |
7605 bool sat_p = TYPE_SATURATING (TREE_TYPE (subsubexp0)); | |
7606 if (sat_p == 0) | |
7607 this_optab = zextend_p ? umsub_widen_optab : smsub_widen_optab; | |
7608 else | |
7609 this_optab = zextend_p ? usmsub_widen_optab | |
7610 : ssmsub_widen_optab; | |
7611 if (mode == GET_MODE_2XWIDER_MODE (innermode) | |
7612 && (optab_handler (this_optab, mode)->insn_code | |
7613 != CODE_FOR_nothing)) | |
7614 { | |
7615 expand_operands (top0, top1, NULL_RTX, &op0, &op1, | |
7616 EXPAND_NORMAL); | |
7617 op2 = expand_expr (treeop0, subtarget, | |
7618 VOIDmode, EXPAND_NORMAL); | |
7619 temp = expand_ternary_op (mode, this_optab, op0, op1, op2, | |
7620 target, unsignedp); | |
7621 gcc_assert (temp); | |
7622 return REDUCE_BIT_FIELD (temp); | |
7623 } | |
7624 } | |
7625 } | |
7626 | |
7627 /* For initializers, we are allowed to return a MINUS of two | 7563 /* For initializers, we are allowed to return a MINUS of two |
7628 symbolic constants. Here we handle all cases when both operands | 7564 symbolic constants. Here we handle all cases when both operands |
7629 are constant. */ | 7565 are constant. */ |
7630 /* Handle difference of two symbolic constants, | 7566 /* Handle difference of two symbolic constants, |
7631 for the sake of an initializer. */ | 7567 for the sake of an initializer. */ |
7662 return REDUCE_BIT_FIELD (simplify_gen_binary (PLUS, mode, op0, op1)); | 7598 return REDUCE_BIT_FIELD (simplify_gen_binary (PLUS, mode, op0, op1)); |
7663 } | 7599 } |
7664 | 7600 |
7665 goto binop2; | 7601 goto binop2; |
7666 | 7602 |
7603 case WIDEN_MULT_PLUS_EXPR: | |
7604 case WIDEN_MULT_MINUS_EXPR: | |
7605 expand_operands (treeop0, treeop1, NULL_RTX, &op0, &op1, EXPAND_NORMAL); | |
7606 op2 = expand_normal (treeop2); | |
7607 target = expand_widen_pattern_expr (ops, op0, op1, op2, | |
7608 target, unsignedp); | |
7609 return target; | |
7610 | |
7667 case WIDEN_MULT_EXPR: | 7611 case WIDEN_MULT_EXPR: |
7668 /* If first operand is constant, swap them. | 7612 /* If first operand is constant, swap them. |
7669 Thus the following special case checks need only | 7613 Thus the following special case checks need only |
7670 check the second operand. */ | 7614 check the second operand. */ |
7671 if (TREE_CODE (treeop0) == INTEGER_CST) | 7615 if (TREE_CODE (treeop0) == INTEGER_CST) |
7683 { | 7627 { |
7684 enum machine_mode innermode = TYPE_MODE (TREE_TYPE (treeop0)); | 7628 enum machine_mode innermode = TYPE_MODE (TREE_TYPE (treeop0)); |
7685 this_optab = usmul_widen_optab; | 7629 this_optab = usmul_widen_optab; |
7686 if (mode == GET_MODE_2XWIDER_MODE (innermode)) | 7630 if (mode == GET_MODE_2XWIDER_MODE (innermode)) |
7687 { | 7631 { |
7688 if (optab_handler (this_optab, mode)->insn_code != CODE_FOR_nothing) | 7632 if (optab_handler (this_optab, mode) != CODE_FOR_nothing) |
7689 { | 7633 { |
7690 if (TYPE_UNSIGNED (TREE_TYPE (treeop0))) | 7634 if (TYPE_UNSIGNED (TREE_TYPE (treeop0))) |
7691 expand_operands (treeop0, treeop1, subtarget, &op0, &op1, | 7635 expand_operands (treeop0, treeop1, NULL_RTX, &op0, &op1, |
7692 EXPAND_NORMAL); | 7636 EXPAND_NORMAL); |
7693 else | 7637 else |
7694 expand_operands (treeop0, treeop1, subtarget, &op1, &op0, | 7638 expand_operands (treeop0, treeop1, NULL_RTX, &op1, &op0, |
7695 EXPAND_NORMAL); | 7639 EXPAND_NORMAL); |
7696 goto binop3; | 7640 goto binop3; |
7697 } | 7641 } |
7698 } | 7642 } |
7699 } | 7643 } |
7707 enum machine_mode innermode = TYPE_MODE (op0type); | 7651 enum machine_mode innermode = TYPE_MODE (op0type); |
7708 bool zextend_p = TYPE_UNSIGNED (op0type); | 7652 bool zextend_p = TYPE_UNSIGNED (op0type); |
7709 optab other_optab = zextend_p ? smul_widen_optab : umul_widen_optab; | 7653 optab other_optab = zextend_p ? smul_widen_optab : umul_widen_optab; |
7710 this_optab = zextend_p ? umul_widen_optab : smul_widen_optab; | 7654 this_optab = zextend_p ? umul_widen_optab : smul_widen_optab; |
7711 | 7655 |
7712 if (mode == GET_MODE_2XWIDER_MODE (innermode)) | 7656 if (mode == GET_MODE_2XWIDER_MODE (innermode) |
7657 && TREE_CODE (treeop0) != INTEGER_CST) | |
7713 { | 7658 { |
7714 if (optab_handler (this_optab, mode)->insn_code != CODE_FOR_nothing) | 7659 if (optab_handler (this_optab, mode) != CODE_FOR_nothing) |
7715 { | 7660 { |
7716 expand_operands (treeop0, treeop1, NULL_RTX, &op0, &op1, | 7661 expand_operands (treeop0, treeop1, NULL_RTX, &op0, &op1, |
7717 EXPAND_NORMAL); | 7662 EXPAND_NORMAL); |
7718 temp = expand_widening_mult (mode, op0, op1, target, | 7663 temp = expand_widening_mult (mode, op0, op1, target, |
7719 unsignedp, this_optab); | 7664 unsignedp, this_optab); |
7720 return REDUCE_BIT_FIELD (temp); | 7665 return REDUCE_BIT_FIELD (temp); |
7721 } | 7666 } |
7722 if (optab_handler (other_optab, mode)->insn_code != CODE_FOR_nothing | 7667 if (optab_handler (other_optab, mode) != CODE_FOR_nothing |
7723 && innermode == word_mode) | 7668 && innermode == word_mode) |
7724 { | 7669 { |
7725 rtx htem, hipart; | 7670 rtx htem, hipart; |
7726 op0 = expand_normal (treeop0); | 7671 op0 = expand_normal (treeop0); |
7727 if (TREE_CODE (treeop1) == INTEGER_CST) | 7672 if (TREE_CODE (treeop1) == INTEGER_CST) |
7743 } | 7688 } |
7744 treeop0 = fold_build1 (CONVERT_EXPR, type, treeop0); | 7689 treeop0 = fold_build1 (CONVERT_EXPR, type, treeop0); |
7745 treeop1 = fold_build1 (CONVERT_EXPR, type, treeop1); | 7690 treeop1 = fold_build1 (CONVERT_EXPR, type, treeop1); |
7746 expand_operands (treeop0, treeop1, subtarget, &op0, &op1, EXPAND_NORMAL); | 7691 expand_operands (treeop0, treeop1, subtarget, &op0, &op1, EXPAND_NORMAL); |
7747 return REDUCE_BIT_FIELD (expand_mult (mode, op0, op1, target, unsignedp)); | 7692 return REDUCE_BIT_FIELD (expand_mult (mode, op0, op1, target, unsignedp)); |
7693 | |
7694 case FMA_EXPR: | |
7695 { | |
7696 optab opt = fma_optab; | |
7697 gimple def0, def2; | |
7698 | |
7699 /* If there is no insn for FMA, emit it as __builtin_fma{,f,l} | |
7700 call. */ | |
7701 if (optab_handler (fma_optab, mode) == CODE_FOR_nothing) | |
7702 { | |
7703 tree fn = mathfn_built_in (TREE_TYPE (treeop0), BUILT_IN_FMA); | |
7704 tree call_expr; | |
7705 | |
7706 gcc_assert (fn != NULL_TREE); | |
7707 call_expr = build_call_expr (fn, 3, treeop0, treeop1, treeop2); | |
7708 return expand_builtin (call_expr, target, subtarget, mode, false); | |
7709 } | |
7710 | |
7711 def0 = get_def_for_expr (treeop0, NEGATE_EXPR); | |
7712 def2 = get_def_for_expr (treeop2, NEGATE_EXPR); | |
7713 | |
7714 op0 = op2 = NULL; | |
7715 | |
7716 if (def0 && def2 | |
7717 && optab_handler (fnms_optab, mode) != CODE_FOR_nothing) | |
7718 { | |
7719 opt = fnms_optab; | |
7720 op0 = expand_normal (gimple_assign_rhs1 (def0)); | |
7721 op2 = expand_normal (gimple_assign_rhs1 (def2)); | |
7722 } | |
7723 else if (def0 | |
7724 && optab_handler (fnma_optab, mode) != CODE_FOR_nothing) | |
7725 { | |
7726 opt = fnma_optab; | |
7727 op0 = expand_normal (gimple_assign_rhs1 (def0)); | |
7728 } | |
7729 else if (def2 | |
7730 && optab_handler (fms_optab, mode) != CODE_FOR_nothing) | |
7731 { | |
7732 opt = fms_optab; | |
7733 op2 = expand_normal (gimple_assign_rhs1 (def2)); | |
7734 } | |
7735 | |
7736 if (op0 == NULL) | |
7737 op0 = expand_expr (treeop0, subtarget, VOIDmode, EXPAND_NORMAL); | |
7738 if (op2 == NULL) | |
7739 op2 = expand_normal (treeop2); | |
7740 op1 = expand_normal (treeop1); | |
7741 | |
7742 return expand_ternary_op (TYPE_MODE (type), opt, | |
7743 op0, op1, op2, target, 0); | |
7744 } | |
7748 | 7745 |
7749 case MULT_EXPR: | 7746 case MULT_EXPR: |
7750 /* If this is a fixed-point operation, then we cannot use the code | 7747 /* If this is a fixed-point operation, then we cannot use the code |
7751 below because "expand_mult" doesn't support sat/no-sat fixed-point | 7748 below because "expand_mult" doesn't support sat/no-sat fixed-point |
7752 multiplications. */ | 7749 multiplications. */ |
8271 tree context; | 8268 tree context; |
8272 bool reduce_bit_field; | 8269 bool reduce_bit_field; |
8273 location_t loc = EXPR_LOCATION (exp); | 8270 location_t loc = EXPR_LOCATION (exp); |
8274 struct separate_ops ops; | 8271 struct separate_ops ops; |
8275 tree treeop0, treeop1, treeop2; | 8272 tree treeop0, treeop1, treeop2; |
8273 tree ssa_name = NULL_TREE; | |
8274 gimple g; | |
8276 | 8275 |
8277 type = TREE_TYPE (exp); | 8276 type = TREE_TYPE (exp); |
8278 mode = TYPE_MODE (type); | 8277 mode = TYPE_MODE (type); |
8279 unsignedp = TYPE_UNSIGNED (type); | 8278 unsignedp = TYPE_UNSIGNED (type); |
8280 | 8279 |
8383 /* ??? ivopts calls expander, without any preparation from | 8382 /* ??? ivopts calls expander, without any preparation from |
8384 out-of-ssa. So fake instructions as if this was an access to the | 8383 out-of-ssa. So fake instructions as if this was an access to the |
8385 base variable. This unnecessarily allocates a pseudo, see how we can | 8384 base variable. This unnecessarily allocates a pseudo, see how we can |
8386 reuse it, if partition base vars have it set already. */ | 8385 reuse it, if partition base vars have it set already. */ |
8387 if (!currently_expanding_to_rtl) | 8386 if (!currently_expanding_to_rtl) |
8388 return expand_expr_real_1 (SSA_NAME_VAR (exp), target, tmode, modifier, NULL); | 8387 return expand_expr_real_1 (SSA_NAME_VAR (exp), target, tmode, modifier, |
8389 { | 8388 NULL); |
8390 gimple g = get_gimple_for_ssa_name (exp); | 8389 |
8391 if (g) | 8390 g = get_gimple_for_ssa_name (exp); |
8392 return expand_expr_real (gimple_assign_rhs_to_tree (g), target, | 8391 /* For EXPAND_INITIALIZER try harder to get something simpler. */ |
8393 tmode, modifier, NULL); | 8392 if (g == NULL |
8394 } | 8393 && modifier == EXPAND_INITIALIZER |
8395 decl_rtl = get_rtx_for_ssa_name (exp); | 8394 && !SSA_NAME_IS_DEFAULT_DEF (exp) |
8396 exp = SSA_NAME_VAR (exp); | 8395 && (optimize || DECL_IGNORED_P (SSA_NAME_VAR (exp))) |
8396 && stmt_is_replaceable_p (SSA_NAME_DEF_STMT (exp))) | |
8397 g = SSA_NAME_DEF_STMT (exp); | |
8398 if (g) | |
8399 return expand_expr_real (gimple_assign_rhs_to_tree (g), target, tmode, | |
8400 modifier, NULL); | |
8401 | |
8402 ssa_name = exp; | |
8403 decl_rtl = get_rtx_for_ssa_name (ssa_name); | |
8404 exp = SSA_NAME_VAR (ssa_name); | |
8397 goto expand_decl_rtl; | 8405 goto expand_decl_rtl; |
8398 | 8406 |
8399 case PARM_DECL: | 8407 case PARM_DECL: |
8400 case VAR_DECL: | 8408 case VAR_DECL: |
8401 /* If a static var's type was incomplete when the decl was written, | 8409 /* If a static var's type was incomplete when the decl was written, |
8403 if (DECL_SIZE (exp) == 0 | 8411 if (DECL_SIZE (exp) == 0 |
8404 && COMPLETE_OR_UNBOUND_ARRAY_TYPE_P (TREE_TYPE (exp)) | 8412 && COMPLETE_OR_UNBOUND_ARRAY_TYPE_P (TREE_TYPE (exp)) |
8405 && (TREE_STATIC (exp) || DECL_EXTERNAL (exp))) | 8413 && (TREE_STATIC (exp) || DECL_EXTERNAL (exp))) |
8406 layout_decl (exp, 0); | 8414 layout_decl (exp, 0); |
8407 | 8415 |
8408 /* TLS emulation hook - replace __thread vars with | |
8409 *__emutls_get_address (&_emutls.var). */ | |
8410 if (! targetm.have_tls | |
8411 && TREE_CODE (exp) == VAR_DECL | |
8412 && DECL_THREAD_LOCAL_P (exp)) | |
8413 { | |
8414 exp = build_fold_indirect_ref_loc (loc, emutls_var_address (exp)); | |
8415 return expand_expr_real_1 (exp, target, tmode, modifier, NULL); | |
8416 } | |
8417 | |
8418 /* ... fall through ... */ | 8416 /* ... fall through ... */ |
8419 | 8417 |
8420 case FUNCTION_DECL: | 8418 case FUNCTION_DECL: |
8421 case RESULT_DECL: | 8419 case RESULT_DECL: |
8422 decl_rtl = DECL_RTL (exp); | 8420 decl_rtl = DECL_RTL (exp); |
8423 expand_decl_rtl: | 8421 expand_decl_rtl: |
8424 gcc_assert (decl_rtl); | 8422 gcc_assert (decl_rtl); |
8425 decl_rtl = copy_rtx (decl_rtl); | 8423 decl_rtl = copy_rtx (decl_rtl); |
8424 /* Record writes to register variables. */ | |
8425 if (modifier == EXPAND_WRITE && REG_P (decl_rtl) | |
8426 && REGNO (decl_rtl) < FIRST_PSEUDO_REGISTER) | |
8427 { | |
8428 int i = REGNO (decl_rtl); | |
8429 int nregs = hard_regno_nregs[i][GET_MODE (decl_rtl)]; | |
8430 while (nregs) | |
8431 { | |
8432 SET_HARD_REG_BIT (crtl->asm_clobbers, i); | |
8433 i++; | |
8434 nregs--; | |
8435 } | |
8436 } | |
8426 | 8437 |
8427 /* Ensure variable marked as used even if it doesn't go through | 8438 /* Ensure variable marked as used even if it doesn't go through |
8428 a parser. If it hasn't be used yet, write out an external | 8439 a parser. If it hasn't be used yet, write out an external |
8429 definition. */ | 8440 definition. */ |
8430 if (! TREE_USED (exp)) | 8441 if (! TREE_USED (exp)) |
8440 been lowered by this point. */ | 8451 been lowered by this point. */ |
8441 context = decl_function_context (exp); | 8452 context = decl_function_context (exp); |
8442 gcc_assert (!context | 8453 gcc_assert (!context |
8443 || context == current_function_decl | 8454 || context == current_function_decl |
8444 || TREE_STATIC (exp) | 8455 || TREE_STATIC (exp) |
8456 || DECL_EXTERNAL (exp) | |
8445 /* ??? C++ creates functions that are not TREE_STATIC. */ | 8457 /* ??? C++ creates functions that are not TREE_STATIC. */ |
8446 || TREE_CODE (exp) == FUNCTION_DECL); | 8458 || TREE_CODE (exp) == FUNCTION_DECL); |
8447 | 8459 |
8448 /* This is the case of an array whose size is to be determined | 8460 /* This is the case of an array whose size is to be determined |
8449 from its initializer, while the initializer is still being parsed. | 8461 from its initializer, while the initializer is still being parsed. |
8480 } | 8492 } |
8481 | 8493 |
8482 /* If the mode of DECL_RTL does not match that of the decl, it | 8494 /* If the mode of DECL_RTL does not match that of the decl, it |
8483 must be a promoted value. We return a SUBREG of the wanted mode, | 8495 must be a promoted value. We return a SUBREG of the wanted mode, |
8484 but mark it so that we know that it was already extended. */ | 8496 but mark it so that we know that it was already extended. */ |
8485 | 8497 if (REG_P (decl_rtl) && GET_MODE (decl_rtl) != DECL_MODE (exp)) |
8486 if (REG_P (decl_rtl) | |
8487 && GET_MODE (decl_rtl) != DECL_MODE (exp)) | |
8488 { | 8498 { |
8489 enum machine_mode pmode; | 8499 enum machine_mode pmode; |
8490 | 8500 |
8491 /* Get the signedness used for this variable. Ensure we get the | 8501 /* Get the signedness to be used for this variable. Ensure we get |
8492 same mode we got when the variable was declared. */ | 8502 the same mode we got when the variable was declared. */ |
8493 pmode = promote_decl_mode (exp, &unsignedp); | 8503 if (code == SSA_NAME |
8504 && (g = SSA_NAME_DEF_STMT (ssa_name)) | |
8505 && gimple_code (g) == GIMPLE_CALL) | |
8506 pmode = promote_function_mode (type, mode, &unsignedp, | |
8507 TREE_TYPE | |
8508 (TREE_TYPE (gimple_call_fn (g))), | |
8509 2); | |
8510 else | |
8511 pmode = promote_decl_mode (exp, &unsignedp); | |
8494 gcc_assert (GET_MODE (decl_rtl) == pmode); | 8512 gcc_assert (GET_MODE (decl_rtl) == pmode); |
8495 | 8513 |
8496 temp = gen_lowpart_SUBREG (mode, decl_rtl); | 8514 temp = gen_lowpart_SUBREG (mode, decl_rtl); |
8497 SUBREG_PROMOTED_VAR_P (temp) = 1; | 8515 SUBREG_PROMOTED_VAR_P (temp) = 1; |
8498 SUBREG_PROMOTED_UNSIGNED_SET (temp, unsignedp); | 8516 SUBREG_PROMOTED_UNSIGNED_SET (temp, unsignedp); |
8634 return const0_rtx; | 8652 return const0_rtx; |
8635 } | 8653 } |
8636 | 8654 |
8637 return expand_constructor (exp, target, modifier, false); | 8655 return expand_constructor (exp, target, modifier, false); |
8638 | 8656 |
8639 case MISALIGNED_INDIRECT_REF: | |
8640 case ALIGN_INDIRECT_REF: | |
8641 case INDIRECT_REF: | |
8642 { | |
8643 tree exp1 = treeop0; | |
8644 addr_space_t as = ADDR_SPACE_GENERIC; | |
8645 enum machine_mode address_mode = Pmode; | |
8646 | |
8647 if (modifier != EXPAND_WRITE) | |
8648 { | |
8649 tree t; | |
8650 | |
8651 t = fold_read_from_constant_string (exp); | |
8652 if (t) | |
8653 return expand_expr (t, target, tmode, modifier); | |
8654 } | |
8655 | |
8656 if (POINTER_TYPE_P (TREE_TYPE (exp1))) | |
8657 { | |
8658 as = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (exp1))); | |
8659 address_mode = targetm.addr_space.address_mode (as); | |
8660 } | |
8661 | |
8662 op0 = expand_expr (exp1, NULL_RTX, VOIDmode, EXPAND_SUM); | |
8663 op0 = memory_address_addr_space (mode, op0, as); | |
8664 | |
8665 if (code == ALIGN_INDIRECT_REF) | |
8666 { | |
8667 int align = TYPE_ALIGN_UNIT (type); | |
8668 op0 = gen_rtx_AND (address_mode, op0, GEN_INT (-align)); | |
8669 op0 = memory_address_addr_space (mode, op0, as); | |
8670 } | |
8671 | |
8672 temp = gen_rtx_MEM (mode, op0); | |
8673 | |
8674 set_mem_attributes (temp, exp, 0); | |
8675 set_mem_addr_space (temp, as); | |
8676 | |
8677 /* Resolve the misalignment now, so that we don't have to remember | |
8678 to resolve it later. Of course, this only works for reads. */ | |
8679 if (code == MISALIGNED_INDIRECT_REF) | |
8680 { | |
8681 int icode; | |
8682 rtx reg, insn; | |
8683 | |
8684 gcc_assert (modifier == EXPAND_NORMAL | |
8685 || modifier == EXPAND_STACK_PARM); | |
8686 | |
8687 /* The vectorizer should have already checked the mode. */ | |
8688 icode = optab_handler (movmisalign_optab, mode)->insn_code; | |
8689 gcc_assert (icode != CODE_FOR_nothing); | |
8690 | |
8691 /* We've already validated the memory, and we're creating a | |
8692 new pseudo destination. The predicates really can't fail. */ | |
8693 reg = gen_reg_rtx (mode); | |
8694 | |
8695 /* Nor can the insn generator. */ | |
8696 insn = GEN_FCN (icode) (reg, temp); | |
8697 emit_insn (insn); | |
8698 | |
8699 return reg; | |
8700 } | |
8701 | |
8702 return temp; | |
8703 } | |
8704 | |
8705 case TARGET_MEM_REF: | 8657 case TARGET_MEM_REF: |
8706 { | 8658 { |
8707 addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (exp)); | 8659 addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (exp)); |
8708 struct mem_address addr; | 8660 struct mem_address addr; |
8709 tree base; | 8661 int icode, align; |
8710 | 8662 |
8711 get_address_description (exp, &addr); | 8663 get_address_description (exp, &addr); |
8712 op0 = addr_for_mem_ref (&addr, as, true); | 8664 op0 = addr_for_mem_ref (&addr, as, true); |
8713 op0 = memory_address_addr_space (mode, op0, as); | 8665 op0 = memory_address_addr_space (mode, op0, as); |
8714 temp = gen_rtx_MEM (mode, op0); | 8666 temp = gen_rtx_MEM (mode, op0); |
8715 set_mem_attributes (temp, TMR_ORIGINAL (exp), 0); | 8667 set_mem_attributes (temp, exp, 0); |
8716 set_mem_addr_space (temp, as); | 8668 set_mem_addr_space (temp, as); |
8717 base = get_base_address (TMR_ORIGINAL (exp)); | 8669 align = MAX (TYPE_ALIGN (TREE_TYPE (exp)), |
8718 if (INDIRECT_REF_P (base) | 8670 get_object_alignment (exp, BIGGEST_ALIGNMENT)); |
8719 && TMR_BASE (exp) | 8671 if (mode != BLKmode |
8720 && TREE_CODE (TMR_BASE (exp)) == SSA_NAME | 8672 && (unsigned) align < GET_MODE_ALIGNMENT (mode) |
8721 && POINTER_TYPE_P (TREE_TYPE (TMR_BASE (exp)))) | 8673 /* If the target does not have special handling for unaligned |
8674 loads of mode then it can use regular moves for them. */ | |
8675 && ((icode = optab_handler (movmisalign_optab, mode)) | |
8676 != CODE_FOR_nothing)) | |
8722 { | 8677 { |
8723 set_mem_expr (temp, build1 (INDIRECT_REF, | 8678 rtx reg, insn; |
8724 TREE_TYPE (exp), TMR_BASE (exp))); | 8679 |
8725 set_mem_offset (temp, NULL_RTX); | 8680 /* We've already validated the memory, and we're creating a |
8681 new pseudo destination. The predicates really can't fail. */ | |
8682 reg = gen_reg_rtx (mode); | |
8683 | |
8684 /* Nor can the insn generator. */ | |
8685 insn = GEN_FCN (icode) (reg, temp); | |
8686 gcc_assert (insn != NULL_RTX); | |
8687 emit_insn (insn); | |
8688 | |
8689 return reg; | |
8726 } | 8690 } |
8691 return temp; | |
8727 } | 8692 } |
8728 return temp; | 8693 |
8694 case MEM_REF: | |
8695 { | |
8696 addr_space_t as | |
8697 = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (TREE_OPERAND (exp, 1)))); | |
8698 enum machine_mode address_mode; | |
8699 tree base = TREE_OPERAND (exp, 0); | |
8700 gimple def_stmt; | |
8701 int icode, align; | |
8702 /* Handle expansion of non-aliased memory with non-BLKmode. That | |
8703 might end up in a register. */ | |
8704 if (TREE_CODE (base) == ADDR_EXPR) | |
8705 { | |
8706 HOST_WIDE_INT offset = mem_ref_offset (exp).low; | |
8707 tree bit_offset; | |
8708 base = TREE_OPERAND (base, 0); | |
8709 if (!DECL_P (base)) | |
8710 { | |
8711 HOST_WIDE_INT off; | |
8712 base = get_addr_base_and_unit_offset (base, &off); | |
8713 gcc_assert (base); | |
8714 offset += off; | |
8715 } | |
8716 /* If we are expanding a MEM_REF of a non-BLKmode non-addressable | |
8717 decl we must use bitfield operations. */ | |
8718 if (DECL_P (base) | |
8719 && !TREE_ADDRESSABLE (base) | |
8720 && DECL_MODE (base) != BLKmode | |
8721 && DECL_RTL_SET_P (base) | |
8722 && !MEM_P (DECL_RTL (base))) | |
8723 { | |
8724 tree bftype; | |
8725 if (offset == 0 | |
8726 && host_integerp (TYPE_SIZE (TREE_TYPE (exp)), 1) | |
8727 && (GET_MODE_BITSIZE (DECL_MODE (base)) | |
8728 == TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (exp))))) | |
8729 return expand_expr (build1 (VIEW_CONVERT_EXPR, | |
8730 TREE_TYPE (exp), base), | |
8731 target, tmode, modifier); | |
8732 bit_offset = bitsize_int (offset * BITS_PER_UNIT); | |
8733 bftype = TREE_TYPE (base); | |
8734 if (TYPE_MODE (TREE_TYPE (exp)) != BLKmode) | |
8735 bftype = TREE_TYPE (exp); | |
8736 return expand_expr (build3 (BIT_FIELD_REF, bftype, | |
8737 base, | |
8738 TYPE_SIZE (TREE_TYPE (exp)), | |
8739 bit_offset), | |
8740 target, tmode, modifier); | |
8741 } | |
8742 } | |
8743 address_mode = targetm.addr_space.address_mode (as); | |
8744 base = TREE_OPERAND (exp, 0); | |
8745 if ((def_stmt = get_def_for_expr (base, BIT_AND_EXPR))) | |
8746 { | |
8747 tree mask = gimple_assign_rhs2 (def_stmt); | |
8748 base = build2 (BIT_AND_EXPR, TREE_TYPE (base), | |
8749 gimple_assign_rhs1 (def_stmt), mask); | |
8750 TREE_OPERAND (exp, 0) = base; | |
8751 } | |
8752 align = MAX (TYPE_ALIGN (TREE_TYPE (exp)), | |
8753 get_object_alignment (exp, BIGGEST_ALIGNMENT)); | |
8754 op0 = expand_expr (base, NULL_RTX, VOIDmode, EXPAND_SUM); | |
8755 op0 = memory_address_addr_space (address_mode, op0, as); | |
8756 if (!integer_zerop (TREE_OPERAND (exp, 1))) | |
8757 { | |
8758 rtx off | |
8759 = immed_double_int_const (mem_ref_offset (exp), address_mode); | |
8760 op0 = simplify_gen_binary (PLUS, address_mode, op0, off); | |
8761 } | |
8762 op0 = memory_address_addr_space (mode, op0, as); | |
8763 temp = gen_rtx_MEM (mode, op0); | |
8764 set_mem_attributes (temp, exp, 0); | |
8765 set_mem_addr_space (temp, as); | |
8766 if (TREE_THIS_VOLATILE (exp)) | |
8767 MEM_VOLATILE_P (temp) = 1; | |
8768 if (mode != BLKmode | |
8769 && (unsigned) align < GET_MODE_ALIGNMENT (mode) | |
8770 /* If the target does not have special handling for unaligned | |
8771 loads of mode then it can use regular moves for them. */ | |
8772 && ((icode = optab_handler (movmisalign_optab, mode)) | |
8773 != CODE_FOR_nothing)) | |
8774 { | |
8775 rtx reg, insn; | |
8776 | |
8777 /* We've already validated the memory, and we're creating a | |
8778 new pseudo destination. The predicates really can't fail. */ | |
8779 reg = gen_reg_rtx (mode); | |
8780 | |
8781 /* Nor can the insn generator. */ | |
8782 insn = GEN_FCN (icode) (reg, temp); | |
8783 emit_insn (insn); | |
8784 | |
8785 return reg; | |
8786 } | |
8787 return temp; | |
8788 } | |
8729 | 8789 |
8730 case ARRAY_REF: | 8790 case ARRAY_REF: |
8731 | 8791 |
8732 { | 8792 { |
8733 tree array = treeop0; | 8793 tree array = treeop0; |
8778 && modifier != EXPAND_INITIALIZER | 8838 && modifier != EXPAND_INITIALIZER |
8779 && modifier != EXPAND_MEMORY | 8839 && modifier != EXPAND_MEMORY |
8780 && TREE_READONLY (array) && ! TREE_SIDE_EFFECTS (array) | 8840 && TREE_READONLY (array) && ! TREE_SIDE_EFFECTS (array) |
8781 && TREE_CODE (array) == VAR_DECL && DECL_INITIAL (array) | 8841 && TREE_CODE (array) == VAR_DECL && DECL_INITIAL (array) |
8782 && TREE_CODE (DECL_INITIAL (array)) != ERROR_MARK | 8842 && TREE_CODE (DECL_INITIAL (array)) != ERROR_MARK |
8783 && targetm.binds_local_p (array)) | 8843 && const_value_known_p (array)) |
8784 { | 8844 { |
8785 if (TREE_CODE (index) == INTEGER_CST) | 8845 if (TREE_CODE (index) == INTEGER_CST) |
8786 { | 8846 { |
8787 tree init = DECL_INITIAL (array); | 8847 tree init = DECL_INITIAL (array); |
8788 | 8848 |
8915 { | 8975 { |
8916 enum machine_mode mode1, mode2; | 8976 enum machine_mode mode1, mode2; |
8917 HOST_WIDE_INT bitsize, bitpos; | 8977 HOST_WIDE_INT bitsize, bitpos; |
8918 tree offset; | 8978 tree offset; |
8919 int volatilep = 0, must_force_mem; | 8979 int volatilep = 0, must_force_mem; |
8980 bool packedp = false; | |
8920 tree tem = get_inner_reference (exp, &bitsize, &bitpos, &offset, | 8981 tree tem = get_inner_reference (exp, &bitsize, &bitpos, &offset, |
8921 &mode1, &unsignedp, &volatilep, true); | 8982 &mode1, &unsignedp, &volatilep, true); |
8922 rtx orig_op0, memloc; | 8983 rtx orig_op0, memloc; |
8923 | 8984 |
8924 /* If we got back the original object, something is wrong. Perhaps | 8985 /* If we got back the original object, something is wrong. Perhaps |
8925 we are evaluating an expression too early. In any event, don't | 8986 we are evaluating an expression too early. In any event, don't |
8926 infinitely recurse. */ | 8987 infinitely recurse. */ |
8927 gcc_assert (tem != exp); | 8988 gcc_assert (tem != exp); |
8989 | |
8990 if (TYPE_PACKED (TREE_TYPE (TREE_OPERAND (exp, 0))) | |
8991 || (TREE_CODE (TREE_OPERAND (exp, 1)) == FIELD_DECL | |
8992 && DECL_PACKED (TREE_OPERAND (exp, 1)))) | |
8993 packedp = true; | |
8928 | 8994 |
8929 /* If TEM's type is a union of variable size, pass TARGET to the inner | 8995 /* If TEM's type is a union of variable size, pass TARGET to the inner |
8930 computation, since it will need a temporary and TARGET is known | 8996 computation, since it will need a temporary and TARGET is known |
8931 to have to do. This occurs in unchecked conversion in Ada. */ | 8997 to have to do. This occurs in unchecked conversion in Ada. */ |
8932 orig_op0 = op0 | 8998 orig_op0 = op0 |
8939 VOIDmode, | 9005 VOIDmode, |
8940 (modifier == EXPAND_INITIALIZER | 9006 (modifier == EXPAND_INITIALIZER |
8941 || modifier == EXPAND_CONST_ADDRESS | 9007 || modifier == EXPAND_CONST_ADDRESS |
8942 || modifier == EXPAND_STACK_PARM) | 9008 || modifier == EXPAND_STACK_PARM) |
8943 ? modifier : EXPAND_NORMAL); | 9009 ? modifier : EXPAND_NORMAL); |
9010 | |
9011 | |
9012 /* If the bitfield is volatile, we want to access it in the | |
9013 field's mode, not the computed mode. | |
9014 If a MEM has VOIDmode (external with incomplete type), | |
9015 use BLKmode for it instead. */ | |
9016 if (MEM_P (op0)) | |
9017 { | |
9018 if (volatilep && flag_strict_volatile_bitfields > 0) | |
9019 op0 = adjust_address (op0, mode1, 0); | |
9020 else if (GET_MODE (op0) == VOIDmode) | |
9021 op0 = adjust_address (op0, BLKmode, 0); | |
9022 } | |
8944 | 9023 |
8945 mode2 | 9024 mode2 |
8946 = CONSTANT_P (op0) ? TYPE_MODE (TREE_TYPE (tem)) : GET_MODE (op0); | 9025 = CONSTANT_P (op0) ? TYPE_MODE (TREE_TYPE (tem)) : GET_MODE (op0); |
8947 | 9026 |
8948 /* If we have either an offset, a BLKmode result, or a reference | 9027 /* If we have either an offset, a BLKmode result, or a reference |
9065 || (mode1 != BLKmode && ! direct_load[(int) mode1] | 9144 || (mode1 != BLKmode && ! direct_load[(int) mode1] |
9066 && GET_MODE_CLASS (mode) != MODE_COMPLEX_INT | 9145 && GET_MODE_CLASS (mode) != MODE_COMPLEX_INT |
9067 && GET_MODE_CLASS (mode) != MODE_COMPLEX_FLOAT | 9146 && GET_MODE_CLASS (mode) != MODE_COMPLEX_FLOAT |
9068 && modifier != EXPAND_CONST_ADDRESS | 9147 && modifier != EXPAND_CONST_ADDRESS |
9069 && modifier != EXPAND_INITIALIZER) | 9148 && modifier != EXPAND_INITIALIZER) |
9149 /* If the field is volatile, we always want an aligned | |
9150 access. */ | |
9151 || (volatilep && flag_strict_volatile_bitfields > 0) | |
9070 /* If the field isn't aligned enough to fetch as a memref, | 9152 /* If the field isn't aligned enough to fetch as a memref, |
9071 fetch it as a bit field. */ | 9153 fetch it as a bit field. */ |
9072 || (mode1 != BLKmode | 9154 || (mode1 != BLKmode |
9073 && (((TYPE_ALIGN (TREE_TYPE (tem)) < GET_MODE_ALIGNMENT (mode) | 9155 && (((TYPE_ALIGN (TREE_TYPE (tem)) < GET_MODE_ALIGNMENT (mode) |
9074 || (bitpos % GET_MODE_ALIGNMENT (mode) != 0) | 9156 || (bitpos % GET_MODE_ALIGNMENT (mode) != 0) |
9125 op0 = validize_mem (op0); | 9207 op0 = validize_mem (op0); |
9126 | 9208 |
9127 if (MEM_P (op0) && REG_P (XEXP (op0, 0))) | 9209 if (MEM_P (op0) && REG_P (XEXP (op0, 0))) |
9128 mark_reg_pointer (XEXP (op0, 0), MEM_ALIGN (op0)); | 9210 mark_reg_pointer (XEXP (op0, 0), MEM_ALIGN (op0)); |
9129 | 9211 |
9130 op0 = extract_bit_field (op0, bitsize, bitpos, unsignedp, | 9212 op0 = extract_bit_field (op0, bitsize, bitpos, unsignedp, packedp, |
9131 (modifier == EXPAND_STACK_PARM | 9213 (modifier == EXPAND_STACK_PARM |
9132 ? NULL_RTX : target), | 9214 ? NULL_RTX : target), |
9133 ext_mode, ext_mode); | 9215 ext_mode, ext_mode); |
9134 | 9216 |
9135 /* If the result is a record type and BITSIZE is narrower than | 9217 /* If the result is a record type and BITSIZE is narrower than |
9318 && GET_MODE_SIZE (mode) == GET_MODE_SIZE (GET_MODE (op0)) | 9400 && GET_MODE_SIZE (mode) == GET_MODE_SIZE (GET_MODE (op0)) |
9319 && !COMPLEX_MODE_P (GET_MODE (op0))) | 9401 && !COMPLEX_MODE_P (GET_MODE (op0))) |
9320 { | 9402 { |
9321 if (GET_CODE (op0) == SUBREG) | 9403 if (GET_CODE (op0) == SUBREG) |
9322 op0 = force_reg (GET_MODE (op0), op0); | 9404 op0 = force_reg (GET_MODE (op0), op0); |
9323 op0 = gen_lowpart (mode, op0); | 9405 temp = gen_lowpart_common (mode, op0); |
9406 if (temp) | |
9407 op0 = temp; | |
9408 else | |
9409 { | |
9410 if (!REG_P (op0) && !MEM_P (op0)) | |
9411 op0 = force_reg (GET_MODE (op0), op0); | |
9412 op0 = gen_lowpart (mode, op0); | |
9413 } | |
9324 } | 9414 } |
9325 /* If both types are integral, convert from one mode to the other. */ | 9415 /* If both types are integral, convert from one mode to the other. */ |
9326 else if (INTEGRAL_TYPE_P (type) && INTEGRAL_TYPE_P (TREE_TYPE (treeop0))) | 9416 else if (INTEGRAL_TYPE_P (type) && INTEGRAL_TYPE_P (TREE_TYPE (treeop0))) |
9327 op0 = convert_modes (mode, GET_MODE (op0), op0, | 9417 op0 = convert_modes (mode, GET_MODE (op0), op0, |
9328 TYPE_UNSIGNED (TREE_TYPE (treeop0))); | 9418 TYPE_UNSIGNED (TREE_TYPE (treeop0))); |
9783 if (TREE_CODE (array) == STRING_CST) | 9873 if (TREE_CODE (array) == STRING_CST) |
9784 { | 9874 { |
9785 *ptr_offset = fold_convert (sizetype, offset); | 9875 *ptr_offset = fold_convert (sizetype, offset); |
9786 return array; | 9876 return array; |
9787 } | 9877 } |
9788 else if (TREE_CODE (array) == VAR_DECL) | 9878 else if (TREE_CODE (array) == VAR_DECL |
9879 || TREE_CODE (array) == CONST_DECL) | |
9789 { | 9880 { |
9790 int length; | 9881 int length; |
9791 | 9882 |
9792 /* Variables initialized to string literals can be handled too. */ | 9883 /* Variables initialized to string literals can be handled too. */ |
9793 if (DECL_INITIAL (array) == NULL_TREE | 9884 if (!const_value_known_p (array) |
9885 || !DECL_INITIAL (array) | |
9794 || TREE_CODE (DECL_INITIAL (array)) != STRING_CST) | 9886 || TREE_CODE (DECL_INITIAL (array)) != STRING_CST) |
9795 return 0; | |
9796 | |
9797 /* If they are read-only, non-volatile and bind locally. */ | |
9798 if (! TREE_READONLY (array) | |
9799 || TREE_SIDE_EFFECTS (array) | |
9800 || ! targetm.binds_local_p (array)) | |
9801 return 0; | 9887 return 0; |
9802 | 9888 |
9803 /* Avoid const char foo[4] = "abcde"; */ | 9889 /* Avoid const char foo[4] = "abcde"; */ |
9804 if (DECL_SIZE_UNIT (array) == NULL_TREE | 9890 if (DECL_SIZE_UNIT (array) == NULL_TREE |
9805 || TREE_CODE (DECL_SIZE_UNIT (array)) != INTEGER_CST | 9891 || TREE_CODE (DECL_SIZE_UNIT (array)) != INTEGER_CST |
10175 TYPE_UNSIGNED (TREE_TYPE (range))), | 10261 TYPE_UNSIGNED (TREE_TYPE (range))), |
10176 table_label, default_label); | 10262 table_label, default_label); |
10177 return 1; | 10263 return 1; |
10178 } | 10264 } |
10179 | 10265 |
10180 /* Nonzero if the mode is a valid vector mode for this architecture. | |
10181 This returns nonzero even if there is no hardware support for the | |
10182 vector mode, but we can emulate with narrower modes. */ | |
10183 | |
10184 int | |
10185 vector_mode_valid_p (enum machine_mode mode) | |
10186 { | |
10187 enum mode_class mclass = GET_MODE_CLASS (mode); | |
10188 enum machine_mode innermode; | |
10189 | |
10190 /* Doh! What's going on? */ | |
10191 if (mclass != MODE_VECTOR_INT | |
10192 && mclass != MODE_VECTOR_FLOAT | |
10193 && mclass != MODE_VECTOR_FRACT | |
10194 && mclass != MODE_VECTOR_UFRACT | |
10195 && mclass != MODE_VECTOR_ACCUM | |
10196 && mclass != MODE_VECTOR_UACCUM) | |
10197 return 0; | |
10198 | |
10199 /* Hardware support. Woo hoo! */ | |
10200 if (targetm.vector_mode_supported_p (mode)) | |
10201 return 1; | |
10202 | |
10203 innermode = GET_MODE_INNER (mode); | |
10204 | |
10205 /* We should probably return 1 if requesting V4DI and we have no DI, | |
10206 but we have V2DI, but this is probably very unlikely. */ | |
10207 | |
10208 /* If we have support for the inner mode, we can safely emulate it. | |
10209 We may not have V2DI, but me can emulate with a pair of DIs. */ | |
10210 return targetm.scalar_mode_supported_p (innermode); | |
10211 } | |
10212 | |
10213 /* Return a CONST_VECTOR rtx for a VECTOR_CST tree. */ | 10266 /* Return a CONST_VECTOR rtx for a VECTOR_CST tree. */ |
10214 static rtx | 10267 static rtx |
10215 const_vector_from_tree (tree exp) | 10268 const_vector_from_tree (tree exp) |
10216 { | 10269 { |
10217 rtvec v; | 10270 rtvec v; |
10250 RTVEC_ELT (v, i) = CONST0_RTX (inner); | 10303 RTVEC_ELT (v, i) = CONST0_RTX (inner); |
10251 | 10304 |
10252 return gen_rtx_CONST_VECTOR (mode, v); | 10305 return gen_rtx_CONST_VECTOR (mode, v); |
10253 } | 10306 } |
10254 | 10307 |
10255 | 10308 /* Build a decl for a personality function given a language prefix. */ |
10256 /* Build a decl for a EH personality function named NAME. */ | |
10257 | 10309 |
10258 tree | 10310 tree |
10259 build_personality_function (const char *name) | 10311 build_personality_function (const char *lang) |
10260 { | 10312 { |
10313 const char *unwind_and_version; | |
10261 tree decl, type; | 10314 tree decl, type; |
10315 char *name; | |
10316 | |
10317 switch (targetm.except_unwind_info (&global_options)) | |
10318 { | |
10319 case UI_NONE: | |
10320 return NULL; | |
10321 case UI_SJLJ: | |
10322 unwind_and_version = "_sj0"; | |
10323 break; | |
10324 case UI_DWARF2: | |
10325 case UI_TARGET: | |
10326 unwind_and_version = "_v0"; | |
10327 break; | |
10328 default: | |
10329 gcc_unreachable (); | |
10330 } | |
10331 | |
10332 name = ACONCAT (("__", lang, "_personality", unwind_and_version, NULL)); | |
10262 | 10333 |
10263 type = build_function_type_list (integer_type_node, integer_type_node, | 10334 type = build_function_type_list (integer_type_node, integer_type_node, |
10264 long_long_unsigned_type_node, | 10335 long_long_unsigned_type_node, |
10265 ptr_type_node, ptr_type_node, NULL_TREE); | 10336 ptr_type_node, ptr_type_node, NULL_TREE); |
10266 decl = build_decl (UNKNOWN_LOCATION, FUNCTION_DECL, | 10337 decl = build_decl (UNKNOWN_LOCATION, FUNCTION_DECL, |