diff options
author | revitale <revitale@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-09-10 13:16:38 +0000 |
---|---|---|
committer | revitale <revitale@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-09-10 13:16:38 +0000 |
commit | d52fd16a6bacb2e83fcd5cb1ea4c6e76dc74971e (patch) | |
tree | 6a134dc64a3873eb40dadbaa25d0e75243c9a879 /gcc | |
parent | b2ed6df1be52def6627f0609626922b532738e90 (diff) | |
download | gcc-d52fd16a6bacb2e83fcd5cb1ea4c6e76dc74971e.tar.gz |
New target hook to calculate MII
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@128343 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 13 | ||||
-rw-r--r-- | gcc/config/spu/spu.c | 37 | ||||
-rw-r--r-- | gcc/doc/tm.texi | 9 | ||||
-rw-r--r-- | gcc/modulo-sched.c | 3 | ||||
-rw-r--r-- | gcc/target-def.h | 5 | ||||
-rw-r--r-- | gcc/target.h | 9 |
6 files changed, 74 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 69703a7401d..d26bf109f11 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,16 @@ +2007-09-10 Trevor Smigiel <trevor_smigiel@playstation.sony.com> + Revital Eres <eres@il.ibm.com> + + * target.h (struct gcc_target.sched): New field: sms_res_mii. + (struct ddg): Define. + * target-def.h (TARGET_SCHED_SMS_RES_MII): Define. + (TARGET_SCHED): Add TARGET_SCHED_SMS_RES_MII. + * config/spu/spu.c: Include ddg.h. + (TARGET_SCHED_SMS_RES_MII): Define. + (spu_sms_res_mii): New function to calculate mii. + * modulo-sched (res_MII): Use it. + * doc/tm.texi: Document TARGET_SCHED_SMS_RES_MII. + 2007-09-10 Andreas Krebbel <krebbel1@de.ibm.com> * config/s390/s390.c (s390_dump_pool): Create copy of constant diff --git a/gcc/config/spu/spu.c b/gcc/config/spu/spu.c index 00df45b4683..3423cef4266 100644 --- a/gcc/config/spu/spu.c +++ b/gcc/config/spu/spu.c @@ -53,6 +53,7 @@ #include "tree-gimple.h" #include "tm-constrs.h" #include "spu-builtins.h" +#include "ddg.h" /* Builtin types, data and prototypes. */ struct spu_builtin_range @@ -136,6 +137,7 @@ static tree spu_builtin_mul_widen_odd (tree); static tree spu_builtin_mask_for_load (void); static int spu_builtin_vectorization_cost (bool); static bool spu_vector_alignment_reachable (const_tree, bool); +static int spu_sms_res_mii (struct ddg *g); extern const char *reg_names[]; rtx spu_compare_op0, spu_compare_op1; @@ -287,6 +289,9 @@ const struct attribute_spec spu_attribute_table[]; #undef TARGET_LIBGCC_SHIFT_COUNT_MODE #define TARGET_LIBGCC_SHIFT_COUNT_MODE spu_libgcc_shift_count_mode +#undef TARGET_SCHED_SMS_RES_MII +#define TARGET_SCHED_SMS_RES_MII spu_sms_res_mii + struct gcc_target targetm = TARGET_INITIALIZER; void @@ -5506,6 +5511,38 @@ spu_vector_alignment_reachable (const_tree type ATTRIBUTE_UNUSED, bool is_packed return true; } +/* Count the total number of instructions in each pipe and return the + maximum, which is used as the Minimum Iteration Interval (MII) + in the modulo scheduler. get_pipe() will return -2, -1, 0, or 1. + -2 are instructions that can go in pipe0 or pipe1. */ +static int +spu_sms_res_mii (struct ddg *g) +{ + int i; + unsigned t[4] = {0, 0, 0, 0}; + + for (i = 0; i < g->num_nodes; i++) + { + rtx insn = g->nodes[i].insn; + int p = get_pipe (insn) + 2; + + assert (p >= 0); + assert (p < 4); + + t[p]++; + if (dump_file && INSN_P (insn)) + fprintf (dump_file, "i%d %s %d %d\n", + INSN_UID (insn), + insn_data[INSN_CODE(insn)].name, + p, t[p]); + } + if (dump_file) + fprintf (dump_file, "%d %d %d %d\n", t[0], t[1], t[2], t[3]); + + return MAX ((t[0] + t[2] + t[3] + 1) / 2, MAX (t[2], t[3])); +} + + void spu_init_expanders (void) { diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 4f8c0297d1e..deb3abc2e87 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -6342,6 +6342,15 @@ an additional structure @var{spec_info} should be filled by the target. The structure describes speculation types that can be used in the scheduler. @end deftypefn +@deftypefn {Target Hook} int TARGET_SCHED_SMS_RES_MII (struct ddg *@var{g}) +This hook is called by the swing modulo scheduler to calculate a +resource-based lower bound which is based on the resources available in +the machine and the resources required by each instruction. The target +backend can use @var{g} to calculate such bound. A very simple lower +bound will be used in case this hook is not implemented: the total number +of instructions divided by the issue rate. +@end deftypefn + @node Sections @section Dividing the Output into Sections (Texts, Data, @dots{}) @c the above section title is WAY too long. maybe cut the part between diff --git a/gcc/modulo-sched.c b/gcc/modulo-sched.c index 075fe2eae9c..9a806c106e9 100644 --- a/gcc/modulo-sched.c +++ b/gcc/modulo-sched.c @@ -374,6 +374,9 @@ const_iteration_count (rtx count_reg, basic_block pre_header, static int res_MII (ddg_ptr g) { + if (targetm.sched.sms_res_mii) + return targetm.sched.sms_res_mii (g); + return (g->num_nodes / issue_rate); } diff --git a/gcc/target-def.h b/gcc/target-def.h index c195af2004e..5f5c6f3ae27 100644 --- a/gcc/target-def.h +++ b/gcc/target-def.h @@ -322,7 +322,7 @@ #define TARGET_SCHED_GEN_CHECK 0 #define TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD_GUARD_SPEC 0 #define TARGET_SCHED_SET_SCHED_FLAGS 0 - +#define TARGET_SCHED_SMS_RES_MII 0 #define TARGET_SCHED \ {TARGET_SCHED_ADJUST_COST, \ @@ -351,7 +351,8 @@ TARGET_SCHED_NEEDS_BLOCK_P, \ TARGET_SCHED_GEN_CHECK, \ TARGET_SCHED_FIRST_CYCLE_MULTIPASS_DFA_LOOKAHEAD_GUARD_SPEC, \ - TARGET_SCHED_SET_SCHED_FLAGS} + TARGET_SCHED_SET_SCHED_FLAGS, \ + TARGET_SCHED_SMS_RES_MII} #define TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD 0 #define TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION \ diff --git a/gcc/target.h b/gcc/target.h index bf76402eaa5..4d8cd012220 100644 --- a/gcc/target.h +++ b/gcc/target.h @@ -88,6 +88,9 @@ typedef struct secondary_reload_info /* This is defined in sched-int.h . */ struct _dep; +/* This is defined in ddg.h . */ +struct ddg; + struct gcc_target { /* Functions that output assembler for the target. */ @@ -397,6 +400,12 @@ struct gcc_target information about the speculation capabilities of the target. The parameter is a pointer to spec_info variable. */ void (* set_sched_flags) (struct spec_info_def *); + + /* The following member value is a pointer to a function that provides + information about the target resource-based lower bound which is + used by the swing modulo scheduler. The parameter is a pointer + to ddg variable. */ + int (* sms_res_mii) (struct ddg *); } sched; /* Functions relating to vectorization. */ |