From: claziss <claz...@synopsys.com> ARCv2 Core3 cpus are comming with dbnz support. Add this feature on the tune option.
gcc/ 2017-09-14 Claudiu Zissulescu <claz...@synopsys.com> * config/arc/arc-arch.h (arc_tune_attr): Add ARC_TUNE_CORE_3. * config/arc/arc.c (arc_sched_issue_rate): Use ARC_TUNE_... . (arc_init): Likewise. (arc_override_options): Likewise. (arc_file_start): Choose Tag_ARC_CPU_variation based on arc_tune value. (hwloop_fail): Use TARGET_DBNZ when we want to check for dbnz insn support. * config/arc/arc.h (TARGET_DBNZ): Define. * config/arc/arc.md (attr tune): Add core_3, use ARC_TUNE_... to properly set the tune attribute. (dbnz): Use TARGET_DBNZ guard. * config/arc/arc.opt (mtune): Add core3 option. --- gcc/config/arc/arc-arch.h | 3 ++- gcc/config/arc/arc.c | 21 ++++++++++++--------- gcc/config/arc/arc.h | 2 ++ gcc/config/arc/arc.md | 22 ++++++++++++---------- gcc/config/arc/arc.opt | 40 ++++++++++++++++++++++------------------ 5 files changed, 50 insertions(+), 38 deletions(-) diff --git a/gcc/config/arc/arc-arch.h b/gcc/config/arc/arc-arch.h index 7c3f47c..38d2bcb 100644 --- a/gcc/config/arc/arc-arch.h +++ b/gcc/config/arc/arc-arch.h @@ -75,7 +75,8 @@ enum arc_tune_attr ARC_TUNE_ARC700_4_2_XMAC, ARC_TUNE_ARCHS4X, ARC_TUNE_ARCHS4XD, - ARC_TUNE_ARCHS4XD_SLOW + ARC_TUNE_ARCHS4XD_SLOW, + ARC_TUNE_CORE_3 }; /* CPU specific properties. */ diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c index 1479a8d..4d7a282 100644 --- a/gcc/config/arc/arc.c +++ b/gcc/config/arc/arc.c @@ -442,8 +442,8 @@ arc_sched_issue_rate (void) { switch (arc_tune) { - case TUNE_ARCHS4X: - case TUNE_ARCHS4XD: + case ARC_TUNE_ARCHS4X: + case ARC_TUNE_ARCHS4XD: return 3; default: break; @@ -866,21 +866,21 @@ arc_init (void) if (arc_multcost < 0) switch (arc_tune) { - case TUNE_ARC700_4_2_STD: + case ARC_TUNE_ARC700_4_2_STD: /* latency 7; max throughput (1 multiply + 4 other insns) / 5 cycles. */ arc_multcost = COSTS_N_INSNS (4); if (TARGET_NOMPY_SET) arc_multcost = COSTS_N_INSNS (30); break; - case TUNE_ARC700_4_2_XMAC: + case ARC_TUNE_ARC700_4_2_XMAC: /* latency 5; max throughput (1 multiply + 2 other insns) / 3 cycles. */ arc_multcost = COSTS_N_INSNS (3); if (TARGET_NOMPY_SET) arc_multcost = COSTS_N_INSNS (30); break; - case TUNE_ARC600: + case ARC_TUNE_ARC600: if (TARGET_MUL64_SET) { arc_multcost = COSTS_N_INSNS (4); @@ -1196,8 +1196,8 @@ arc_override_options (void) #undef ARC_OPT /* Set Tune option. */ - if (arc_tune == TUNE_NONE) - arc_tune = (enum attr_tune) arc_selected_cpu->tune; + if (arc_tune == ARC_TUNE_NONE) + arc_tune = (enum arc_tune_attr) arc_selected_cpu->tune; if (arc_size_opt_level == 3) optimize_size = 1; @@ -5205,6 +5205,9 @@ static void arc_file_start (void) TARGET_NO_SDATA_SET ? 0 : 2); asm_fprintf (asm_out_file, "\t.arc_attribute Tag_ARC_ABI_exceptions, %d\n", TARGET_OPTFPE ? 1 : 0); + if (TARGET_V2) + asm_fprintf (asm_out_file, "\t.arc_attribute Tag_ARC_CPU_variation, %d\n", + arc_tune == ARC_TUNE_CORE_3 ? 3 : 2); } /* Implement `TARGET_ASM_FILE_END'. */ @@ -7389,11 +7392,11 @@ hwloop_fail (hwloop_info loop) rtx test; rtx insn = loop->loop_end; - if (TARGET_V2 + if (TARGET_DBNZ && (loop->length && (loop->length <= ARC_MAX_LOOP_LENGTH)) && REG_P (loop->iter_reg)) { - /* TARGET_V2 has dbnz instructions. */ + /* TARGET_V2 core3 has dbnz instructions. */ test = gen_dbnz (loop->iter_reg, loop->start_label); insn = emit_jump_insn_before (test, loop->loop_end); } diff --git a/gcc/config/arc/arc.h b/gcc/config/arc/arc.h index b5a8f84..8d90975 100644 --- a/gcc/config/arc/arc.h +++ b/gcc/config/arc/arc.h @@ -1628,5 +1628,7 @@ enum /* Custom FP instructions used by QuarkSE EM cpu. */ #define TARGET_FPX_QUARK (TARGET_EM && TARGET_SPFP \ && (arc_fpu_build == FPX_QK)) +/* DBNZ support is available for ARCv2 core3 cpus. */ +#define TARGET_DBNZ (TARGET_V2 && (arc_tune == ARC_TUNE_CORE_3)) #endif /* GCC_ARC_H */ diff --git a/gcc/config/arc/arc.md b/gcc/config/arc/arc.md index 6239483..b8fa44e 100644 --- a/gcc/config/arc/arc.md +++ b/gcc/config/arc/arc.md @@ -597,19 +597,21 @@ ;; is made that makes conditional execution required. (define_attr "tune" "none, arc600, arc700_4_2_std, arc700_4_2_xmac, archs4x, \ -archs4xd, archs4xd_slow" +archs4xd, archs4xd_slow, core_3" (const - (cond [(symbol_ref "arc_tune == TUNE_ARC600") + (cond [(symbol_ref "arc_tune == ARC_TUNE_ARC600") (const_string "arc600") - (symbol_ref "arc_tune == TUNE_ARC700_4_2_STD") + (symbol_ref "arc_tune == ARC_TUNE_ARC700_4_2_STD") (const_string "arc700_4_2_std") - (symbol_ref "arc_tune == TUNE_ARC700_4_2_XMAC") + (symbol_ref "arc_tune == ARC_TUNE_ARC700_4_2_XMAC") (const_string "arc700_4_2_xmac") - (symbol_ref "arc_tune == TUNE_ARCHS4X") + (symbol_ref "arc_tune == ARC_TUNE_ARCHS4X") (const_string "archs4x") - (ior (symbol_ref "arc_tune == TUNE_ARCHS4XD") - (symbol_ref "arc_tune == TUNE_ARCHS4XD_SLOW")) - (const_string "archs4xd")] + (ior (symbol_ref "arc_tune == ARC_TUNE_ARCHS4XD") + (symbol_ref "arc_tune == ARC_TUNE_ARCHS4XD_SLOW")) + (const_string "archs4xd") + (symbol_ref "arc_tune == ARC_TUNE_CORE_3") + (const_string "core_3")] (const_string "none")))) (define_attr "tune_arc700" "false,true" @@ -5200,11 +5202,11 @@ archs4xd, archs4xd_slow" (plus:SI (match_dup 0) (const_int -1))) (clobber (match_scratch:SI 2 "=X,r"))] - "TARGET_V2" + "TARGET_DBNZ" "@ dbnz%#\\t%0,%l1 #" - "TARGET_V2 && reload_completed && memory_operand (operands[0], SImode)" + "TARGET_DBNZ && reload_completed && memory_operand (operands[0], SImode)" [(set (match_dup 2) (match_dup 0)) (set (match_dup 2) (plus:SI (match_dup 2) (const_int -1))) (set (reg:CC CC_REG) (compare:CC (match_dup 2) (const_int 0))) diff --git a/gcc/config/arc/arc.opt b/gcc/config/arc/arc.opt index aacb599..6b0104a 100644 --- a/gcc/config/arc/arc.opt +++ b/gcc/config/arc/arc.opt @@ -249,29 +249,33 @@ mmultcost= Target RejectNegative Joined UInteger Var(arc_multcost) Init(-1) Cost to assume for a multiply instruction, with 4 being equal to a normal insn. -mtune=ARC600 -Target RejectNegative Var(arc_tune, TUNE_ARC600) -Tune for ARC600 cpu. +mtune= +Target RejectNegative ToLower Joined Var(arc_tune) Enum(arc_tune_attr) Init(ARC_TUNE_NONE) +-mcpu=TUNE Tune code for given ARC variant. -mtune=ARC601 -Target RejectNegative Var(arc_tune, TUNE_ARC600) -Tune for ARC601 cpu. +Enum +Name(arc_tune_attr) Type(int) + +EnumValue +Enum(arc_tune_attr) String(arc600) Value(ARC_TUNE_ARC600) -mtune=ARC700 -Target RejectNegative Var(arc_tune, TUNE_ARC700_4_2_STD) -Tune for ARC700 R4.2 Cpu with standard multiplier block. +EnumValue +Enum(arc_tune_attr) String(arc601) Value(ARC_TUNE_ARC600) -mtune=ARC700-xmac -Target RejectNegative Var(arc_tune, TUNE_ARC700_4_2_XMAC) -Tune for ARC700 R4.2 Cpu with XMAC block. +EnumValue +Enum(arc_tune_attr) String(arc700) Value(ARC_TUNE_ARC700_4_2_STD) -mtune=ARC725D -Target RejectNegative Var(arc_tune, TUNE_ARC700_4_2_XMAC) -Tune for ARC700 R4.2 Cpu with XMAC block. +EnumValue +Enum(arc_tune_attr) String(arc700-xmac) Value(ARC_TUNE_ARC700_4_2_XMAC) -mtune=ARC750D -Target RejectNegative Var(arc_tune, TUNE_ARC700_4_2_XMAC) -Tune for ARC700 R4.2 Cpu with XMAC block. +EnumValue +Enum(arc_tune_attr) String(arc725d) Value(ARC_TUNE_ARC700_4_2_XMAC) + +EnumValue +Enum(arc_tune_attr) String(arc750d) Value(ARC_TUNE_ARC700_4_2_XMAC) + +EnumValue +Enum(arc_tune_attr) String(core3) Value(ARC_TUNE_CORE_3) mindexed-loads Target Var(TARGET_INDEXED_LOADS) Init(TARGET_INDEXED_LOADS_DEFAULT) -- 1.9.1