Index: genopinit.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/genopinit.c,v retrieving revision 1.82 diff -c -3 -p -r1.82 genopinit.c *** genopinit.c 28 Sep 2004 00:13:11 -0000 1.82 --- genopinit.c 6 Dec 2004 21:41:18 -0000 *************** static const char * const optabs[] = *** 170,176 **** "vec_set_optab->handlers[$A].insn_code = CODE_FOR_$(vec_set$a$)", "vec_extract_optab->handlers[$A].insn_code = CODE_FOR_$(vec_extract$a$)", "vec_init_optab->handlers[$A].insn_code = CODE_FOR_$(vec_init$a$)", - "vec_realign_store_optab->handlers[$A].insn_code = CODE_FOR_$(vec_realign_store_$a$)", "vec_realign_load_optab->handlers[$A].insn_code = CODE_FOR_$(vec_realign_load_$a$)", "vcond_gen_code[$A] = CODE_FOR_$(vcond$a$)", "vcondu_gen_code[$A] = CODE_FOR_$(vcondu$a$)" }; --- 170,175 ---- Index: optabs.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/optabs.c,v retrieving revision 1.251 diff -c -3 -p -r1.251 optabs.c *** optabs.c 2 Dec 2004 18:31:26 -0000 1.251 --- optabs.c 6 Dec 2004 21:41:19 -0000 *************** optab_for_tree_code (enum tree_code code *** 294,302 **** case MIN_EXPR: return TYPE_UNSIGNED (type) ? umin_optab : smin_optab; - case REALIGN_STORE_EXPR: - return vec_realign_store_optab; - case REALIGN_LOAD_EXPR: return vec_realign_load_optab; --- 294,299 ---- Index: optabs.h =================================================================== RCS file: /cvs/gcc/gcc/gcc/optabs.h,v retrieving revision 1.41 diff -c -3 -p -r1.41 optabs.h *** optabs.h 24 Nov 2004 18:50:20 -0000 1.41 --- optabs.h 6 Dec 2004 21:41:19 -0000 *************** enum optab_index *** 228,235 **** OTI_vec_extract, /* Initialize vector operand. */ OTI_vec_init, - /* Extract specified elements from vectors, for vector store. */ - OTI_vec_realign_store, /* Extract specified elements from vectors, for vector load. */ OTI_vec_realign_load, --- 228,233 ---- *************** extern GTY(()) optab optab_table[OTI_MAX *** 334,340 **** #define vec_set_optab (optab_table[OTI_vec_set]) #define vec_extract_optab (optab_table[OTI_vec_extract]) #define vec_init_optab (optab_table[OTI_vec_init]) - #define vec_realign_store_optab (optab_table[OTI_vec_realign_store]) #define vec_realign_load_optab (optab_table[OTI_vec_realign_load]) /* Conversion optabs have their own table and indexes. */ --- 332,337 ---- Index: target-def.h =================================================================== RCS file: /cvs/gcc/gcc/gcc/target-def.h,v retrieving revision 1.108 diff -c -3 -p -r1.108 target-def.h *** target-def.h 26 Nov 2004 19:21:14 -0000 1.108 --- target-def.h 6 Dec 2004 21:41:19 -0000 *************** Foundation, 59 Temple Place - Suite 330, *** 277,288 **** #define TARGET_VECTORIZE_MISALIGNED_MEM_OK default_vect_misaligned_mem_ok #endif #define TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD 0 - #define TARGET_VECTORIZE_BUILTIN_MASK_FOR_STORE 0 #define TARGET_VECTORIZE \ {TARGET_VECTORIZE_MISALIGNED_MEM_OK, \ ! TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD, \ ! TARGET_VECTORIZE_BUILTIN_MASK_FOR_STORE} /* In except.c */ #define TARGET_EH_RETURN_FILTER_MODE default_eh_return_filter_mode --- 277,286 ---- #define TARGET_VECTORIZE_MISALIGNED_MEM_OK default_vect_misaligned_mem_ok #endif #define TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD 0 #define TARGET_VECTORIZE \ {TARGET_VECTORIZE_MISALIGNED_MEM_OK, \ ! TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD} /* In except.c */ #define TARGET_EH_RETURN_FILTER_MODE default_eh_return_filter_mode Index: target.h =================================================================== RCS file: /cvs/gcc/gcc/gcc/target.h,v retrieving revision 1.120 diff -c -3 -p -r1.120 target.h *** target.h 26 Nov 2004 19:21:14 -0000 1.120 --- target.h 6 Dec 2004 21:41:19 -0000 *************** struct gcc_target *** 286,302 **** struct vectorize { /* The following member value is a pointer to a function called ! by the vectorizer, and when expanding a MISALIGNED_INDIREC_REF expression. If the hook returns true (false) then a move* pattern to/from memory can (cannot) be generated for this mode even if the memory location is unaligned. */ bool (* misaligned_mem_ok) (enum machine_mode); ! /* The following member values are pointers to functions called by the vectorizer, and return the decl of the target builtin function. */ tree (* builtin_mask_for_load) (void); - tree (* builtin_mask_for_store) (void); } vectorize; /* Return machine mode for filter value. */ --- 286,301 ---- struct vectorize { /* The following member value is a pointer to a function called ! by te vectorizer, and when expanding a MISALIGNED_INDIRECT_REF expression. If the hook returns true (false) then a move* pattern to/from memory can (cannot) be generated for this mode even if the memory location is unaligned. */ bool (* misaligned_mem_ok) (enum machine_mode); ! /* The following member value is a pointer to a function called by the vectorizer, and return the decl of the target builtin function. */ tree (* builtin_mask_for_load) (void); } vectorize; /* Return machine mode for filter value. */ Index: tree.def =================================================================== RCS file: /cvs/gcc/gcc/gcc/tree.def,v retrieving revision 1.104 diff -c -3 -p -r1.104 tree.def *** tree.def 24 Nov 2004 11:41:33 -0000 1.104 --- tree.def 6 Dec 2004 21:41:19 -0000 *************** DEFTREECODE (WITH_SIZE_EXPR, "with_size_ *** 898,914 **** generated by the builtin targetm.vectorize.mask_for_load_builtin_decl. */ DEFTREECODE (REALIGN_LOAD_EXPR, "realign_load", tcc_expression, 3) - /* Extract elements from two input vectors Operand 0 and Operand 1 - size VS, according to the offset OFF defined by Operand 2 as - follows: - If OFF > 0, the last OFF elements of vector OP0 are concatenated to - the first VS - OFF elements of the vector OP1. - If OFF == 0, then the returned vector is OP0. - On different targets OFF may take different forms; It can be an address, in - which case its low log2(VS)-1 bits define the offset, or it can be a mask - generated by the builtin targetm.vectorize.mask_for_store_builtin_decl. */ - DEFTREECODE (REALIGN_STORE_EXPR, "realign_store", tcc_expression, 3) - /* Local variables: mode:c --- 898,903 ---- Index: config/rs6000/rs6000.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000.c,v retrieving revision 1.763 diff -c -3 -p -r1.763 rs6000.c *** config/rs6000/rs6000.c 3 Dec 2004 15:47:44 -0000 1.763 --- config/rs6000/rs6000.c 6 Dec 2004 21:41:23 -0000 *************** enum rs6000_nop_insertion rs6000_sched_i *** 147,154 **** /* Support targetm.vectorize.builtin_mask_for_load. */ static GTY(()) tree altivec_builtin_mask_for_load; - /* Support targetm.vectorize.builtin_mask_for_store. */ - static GTY(()) tree altivec_builtin_mask_for_store; /* Size of long double */ const char *rs6000_long_double_size_string; --- 147,152 ---- *************** static int pad_groups (FILE *, int, rtx, *** 693,699 **** static void rs6000_sched_finish (FILE *, int); static int rs6000_use_sched_lookahead (void); static tree rs6000_builtin_mask_for_load (void); - static tree rs6000_builtin_mask_for_store (void); static void rs6000_init_builtins (void); static rtx rs6000_expand_unop_builtin (enum insn_code, tree, rtx); --- 691,696 ---- *************** static const char alt_reg_names[][8] = *** 933,941 **** #undef TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD #define TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD rs6000_builtin_mask_for_load - #undef TARGET_VECTORIZE_BUILTIN_MASK_FOR_STORE - #define TARGET_VECTORIZE_BUILTIN_MASK_FOR_STORE rs6000_builtin_mask_for_store - #undef TARGET_INIT_BUILTINS #define TARGET_INIT_BUILTINS rs6000_init_builtins --- 930,935 ---- *************** rs6000_builtin_mask_for_load (void) *** 1592,1607 **** return 0; } - /* Implement targetm.vectorize.builtin_mask_for_store. */ - static tree - rs6000_builtin_mask_for_store (void) - { - if (TARGET_ALTIVEC) - return altivec_builtin_mask_for_store; - else - return 0; - } - /* Handle generic options of the form -mfoo=yes/no. NAME is the option name. VALUE is the option value. --- 1586,1591 ---- *************** altivec_init_builtins (void) *** 8308,8324 **** BUILT_IN_MD, NULL, NULL_TREE); /* Record the decl. Will be used by rs6000_builtin_mask_for_load. */ altivec_builtin_mask_for_load = decl; - - - /* Initialize target builtin that implements - targetm.vectorize.builtin_mask_for_store. */ - - decl = lang_hooks.builtin_function ("__builtin_altivec_mask_for_store", - v16qi_ftype_long_pcvoid, - ALTIVEC_BUILTIN_MASK_FOR_STORE, - BUILT_IN_MD, NULL, NULL_TREE); - /* Record the decl. Will be used by rs6000_builtin_mask_for_store. */ - altivec_builtin_mask_for_store = decl; } } --- 8292,8297 ---- Index: doc/tm.texi =================================================================== RCS file: /cvs/gcc/gcc/gcc/doc/tm.texi,v retrieving revision 1.402 diff -c -3 -p -r1.402 tm.texi *** doc/tm.texi 4 Dec 2004 00:34:43 -0000 1.402 --- doc/tm.texi 6 Dec 2004 21:41:25 -0000 *************** holding the constant. This restriction *** 5178,5183 **** --- 5178,5222 ---- of TLS symbols for various targets. @end deftypefn + @deftypefn {Target Hook} bool TARGET_VECTORIZE_MISALIGNED_MEM_OK (@var{mode}) + This hook should return true if a move* pattern to/from memory + can be generated for machine_mode @var{mode} even if the memory location + is unaligned. + If a move* of data to/from unaligned memory locations is not supported for + machine_mode @var{mode}, the hook should return false. + This hook is used by the autovectorizer, and when expanding a + @code{MISALIGNED_INDIRECT_REF} expression. + @end deftypefn + + @deftypefn {Target Hook} tree TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD (void) + This hook should return the DECL of a function @var{f} that given an + address @var{addr} as an argument returns a mask @var{m} that can be + used to extract from two vectors the relevant data that resides in + @var{addr} in case @var{addr} is not properly aligned. + + The autovectrizer, when vectorizing a load operation from an address + @var{addr} that may be unaligned, will generate two vector loads from + the two aligned addresses around @var{addr}. It then generates a + @code{REALIGN_LOAD} operation to extract the relevant data from the + two loaded vectors. The first two arguments to @code{REALIGN_LOAD}, + @var{v1} and @var{v2}, are the two vectors, each of size @var{VS}, and + the third argument, @var{OFF}, defines how the data will be extracted + from these two vectors: if @var{OFF} is 0, then the returned vector is + @var{v2}; otherwise, the returned vector is composed from the last + @var{VS}-@var{OFF} elements of @var{v1} concatenated to the first + @var{OFF} elements of @var{v2}. + + If this hook is defined, the autovectorizer will generate a call + to @var{f} (using the DECL tree that this hook returns) and will + use the return value of @var{f} as the argument @var{OFF} to + @code{REALIGN_LOAD}. Therefore, the mask @var{m} returned by @var{f} + should comply with the semantics expected by @code{REALIGN_LOAD} + described above. + If this hook is not defined, then @var{addr} will be used as + the argument @var{OFF} to @code{REALIGN_LOAD}, in which case the low + log2(@var{VS})-1 bits of @var{addr} will be considered. + @end deftypefn + @node Condition Code @section Condition Code Status @cindex condition code status