* [PATCH, nds32] Committed: Remove some features that are not available yet in nds32 port of GNU binutils package.
@ 2015-01-14 7:09 Chung-Ju Wu
0 siblings, 0 replies; only message in thread
From: Chung-Ju Wu @ 2015-01-14 7:09 UTC (permalink / raw)
To: gcc patches; +Cc: Shiva Chen
[-- Attachment #1: Type: text/plain, Size: 1115 bytes --]
Hi, all,
The nds32 target supports two features, fp-as-gp and ex9, designed
for code size optimizations. They are majorly performed by linker
so that compiler is merely to give some hints or directives with
-mforce-fp-as-gp, -mforbid-fp-as-gp, and -mex9 options.
However, those two features are not available yet in the current
nds32 port of GNU binutils package. For consistency concern, I think
it would be better to remove them from gcc trunk as well for now.
Committed as Rev. 219576: https://gcc.gnu.org/r219576
gcc/ChangeLog
2015-01-14 Chung-Ju Wu <jasonwucj@gmail.com>
* config/nds32/nds32.opt (mforce-fp-as-gp): Remove.
(mforbid-fp-as-gp): Remove.
(mex9): Remove.
* config/nds32/nds32-fp-as-gp.c (nds32_have_prologue_p): Remove.
(nds32_symbol_load_store_p): Remove.
(nds32_fp_as_gp_check_available): Clean up implementation.
* config/nds32/nds32.h (LINK_SPEC): Remove -mforce-as-gp and -mex9
cases.
* config/nds32/nds32.c (nds32_asm_file_start): No need to consider
fp-as-gp and ex9 cases.
Best regards,
jasonwucj
[-- Attachment #2: 0010-Remove-some-features-that-are-not-available-yet-in-n.patch --]
[-- Type: application/octet-stream, Size: 8970 bytes --]
diff --git a/gcc/config/nds32/nds32-fp-as-gp.c b/gcc/config/nds32/nds32-fp-as-gp.c
index f68a8e3..c8fa836 100644
--- a/gcc/config/nds32/nds32-fp-as-gp.c
+++ b/gcc/config/nds32/nds32-fp-as-gp.c
@@ -68,55 +68,6 @@
/* ------------------------------------------------------------------------ */
-/* A helper function to check if this function should contain prologue. */
-static int
-nds32_have_prologue_p (void)
-{
- int i;
-
- for (i = 0; i < 28; i++)
- if (NDS32_REQUIRED_CALLEE_SAVED_P (i))
- return 1;
-
- return (flag_pic
- || NDS32_REQUIRED_CALLEE_SAVED_P (FP_REGNUM)
- || NDS32_REQUIRED_CALLEE_SAVED_P (LP_REGNUM));
-}
-
-/* Return true if is load/store with SYMBOL_REF addressing mode
- and memory mode is SImode. */
-static bool
-nds32_symbol_load_store_p (rtx_insn *insn)
-{
- rtx mem_src = NULL_RTX;
-
- switch (get_attr_type (insn))
- {
- case TYPE_LOAD:
- mem_src = SET_SRC (PATTERN (insn));
- break;
- case TYPE_STORE:
- mem_src = SET_DEST (PATTERN (insn));
- break;
- default:
- break;
- }
-
- /* Find load/store insn with addressing mode is SYMBOL_REF. */
- if (mem_src != NULL_RTX)
- {
- if ((GET_CODE (mem_src) == ZERO_EXTEND)
- || (GET_CODE (mem_src) == SIGN_EXTEND))
- mem_src = XEXP (mem_src, 0);
-
- if ((GET_CODE (XEXP (mem_src, 0)) == SYMBOL_REF)
- || (GET_CODE (XEXP (mem_src, 0)) == LO_SUM))
- return true;
- }
-
- return false;
-}
-
/* Function to determine whether it is worth to do fp_as_gp optimization.
Return 0: It is NOT worth to do fp_as_gp optimization.
Return 1: It is APPROXIMATELY worth to do fp_as_gp optimization.
@@ -125,106 +76,6 @@ nds32_symbol_load_store_p (rtx_insn *insn)
int
nds32_fp_as_gp_check_available (void)
{
- /* If there exists ANY of following conditions,
- we DO NOT perform fp_as_gp optimization:
- 1. TARGET_FORBID_FP_AS_GP is set
- regardless of the TARGET_FORCE_FP_AS_GP.
- 2. User explicitly uses 'naked' attribute.
- 3. Not optimize for size.
- 4. Need frame pointer.
- 5. If $fp is already required to be saved,
- it means $fp is already choosen by register allocator.
- Thus we better not to use it for fp_as_gp optimization.
- 6. This function is a vararg function.
- DO NOT apply fp_as_gp optimization on this function
- because it may change and break stack frame.
- 7. The epilogue is empty.
- This happens when the function uses exit()
- or its attribute is no_return.
- In that case, compiler will not expand epilogue
- so that we have no chance to output .omit_fp_end directive. */
- if (TARGET_FORBID_FP_AS_GP
- || lookup_attribute ("naked", DECL_ATTRIBUTES (current_function_decl))
- || !optimize_size
- || frame_pointer_needed
- || NDS32_REQUIRED_CALLEE_SAVED_P (FP_REGNUM)
- || (cfun->stdarg == 1)
- || (find_fallthru_edge (EXIT_BLOCK_PTR_FOR_FN (cfun)->preds) == NULL))
- return 0;
-
- /* Now we can check the possibility of using fp_as_gp optimization. */
- if (TARGET_FORCE_FP_AS_GP)
- {
- /* User explicitly issues -mforce-fp-as-gp option. */
- df_set_regs_ever_live (FP_REGNUM, 1);
- return 1;
- }
- else
- {
- /* In the following we are going to evaluate whether
- it is worth to do fp_as_gp optimization. */
- int good_gain = 0;
- int symbol_count = 0;
-
- int threshold;
- rtx_insn *insn;
-
- /* We check if there already requires prologue.
- Note that $gp will be saved in prologue for PIC code generation.
- After that, we can set threshold by the existence of prologue.
- Each fp-implied instruction will gain 2-byte code size
- from gp-aware instruction, so we have following heuristics. */
- if (flag_pic
- || nds32_have_prologue_p ())
- {
- /* Have-prologue:
- Compiler already intends to generate prologue content,
- so the fp_as_gp optimization will only insert
- 'la $fp,_FP_BASE_' instruction, which will be
- converted into 4-byte instruction at link time.
- The threshold is "3" symbol accesses, 2 + 2 + 2 > 4. */
- threshold = 3;
- }
- else
- {
- /* None-prologue:
- Compiler originally does not generate prologue content,
- so the fp_as_gp optimization will NOT ONLY insert
- 'la $fp,_FP_BASE' instruction, but also causes
- push/pop instructions.
- If we are using v3push (push25/pop25),
- the threshold is "5" symbol accesses, 5*2 > 4 + 2 + 2;
- If we are using normal push (smw/lmw),
- the threshold is "5+2" symbol accesses 7*2 > 4 + 4 + 4. */
- threshold = 5 + (TARGET_V3PUSH ? 0 : 2);
- }
-
- /* We would like to traverse every instruction in this function.
- So we need to have push_topmost_sequence()/pop_topmost_sequence()
- surrounding our for-loop evaluation. */
- push_topmost_sequence ();
- /* Counting the insn number which the addressing mode is symbol. */
- for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
- {
- if (single_set (insn) && nds32_symbol_load_store_p (insn))
- symbol_count++;
-
- if (symbol_count == threshold)
- {
- good_gain = 1;
- break;
- }
- }
- pop_topmost_sequence ();
-
- /* Enable fp_as_gp optimization when potential gain is good enough. */
- if (good_gain)
- {
- df_set_regs_ever_live (FP_REGNUM, 1);
- return 1;
- }
- }
-
/* By default we return 0. */
return 0;
}
diff --git a/gcc/config/nds32/nds32.c b/gcc/config/nds32/nds32.c
index 62fc02c..0ef9b94 100644
--- a/gcc/config/nds32/nds32.c
+++ b/gcc/config/nds32/nds32.c
@@ -2186,26 +2186,6 @@ nds32_asm_file_start (void)
"for checking inconsistency on interrupt handler\n");
fprintf (asm_out_file, "\t.vec_size\t%d\n", nds32_isr_vector_size);
- /* If user enables '-mforce-fp-as-gp' or compiles programs with -Os,
- the compiler may produce 'la $fp,_FP_BASE_' instruction
- at prologue for fp-as-gp optimization.
- We should emit weak reference of _FP_BASE_ to avoid undefined reference
- in case user does not pass '--relax' option to linker. */
- if (TARGET_FORCE_FP_AS_GP || optimize_size)
- {
- fprintf (asm_out_file, "\t! This weak reference is required to do "
- "fp-as-gp link time optimization\n");
- fprintf (asm_out_file, "\t.weak\t_FP_BASE_\n");
- }
- /* If user enables '-mex9', we should emit relaxation directive
- to tell linker that this file is allowed to do ex9 optimization. */
- if (TARGET_EX9)
- {
- fprintf (asm_out_file, "\t! This relaxation directive is required "
- "to do ex9 link time optimization\n");
- fprintf (asm_out_file, "\t.relax\tex9\n");
- }
-
fprintf (asm_out_file, "\t! ------------------------------------\n");
if (TARGET_ISA_V2)
@@ -2739,12 +2719,6 @@ nds32_option_override (void)
fixed_regs[r] = call_used_regs[r] = 1;
}
- /* See if user explicitly would like to use fp-as-gp optimization.
- If so, we must prevent $fp from being allocated
- during register allocation. */
- if (TARGET_FORCE_FP_AS_GP)
- fixed_regs[FP_REGNUM] = call_used_regs[FP_REGNUM] = 1;
-
if (!TARGET_16_BIT)
{
/* Under no 16 bit ISA, we need to strictly disable TARGET_V3PUSH. */
diff --git a/gcc/config/nds32/nds32.h b/gcc/config/nds32/nds32.h
index 4a271cf..7f74159 100644
--- a/gcc/config/nds32/nds32.h
+++ b/gcc/config/nds32/nds32.h
@@ -381,13 +381,10 @@ enum nds32_builtins
#define ASM_SPEC \
" %{mbig-endian:-EB} %{mlittle-endian:-EL}"
-/* If user issues -mrelax, -mforce-fp-as-gp, or -mex9,
- we need to pass '--relax' to linker.
- Besides, for -mex9, we need to further pass '--mex9'. */
+/* If user issues -mrelax, we need to pass '--relax' to linker. */
#define LINK_SPEC \
" %{mbig-endian:-EB} %{mlittle-endian:-EL}" \
- " %{mrelax|mforce-fp-as-gp|mex9:--relax}" \
- " %{mex9:--mex9}"
+ " %{mrelax:--relax}"
#define LIB_SPEC \
" -lc -lgloss"
diff --git a/gcc/config/nds32/nds32.opt b/gcc/config/nds32/nds32.opt
index 6653982..ffaab90 100644
--- a/gcc/config/nds32/nds32.opt
+++ b/gcc/config/nds32/nds32.opt
@@ -95,18 +95,6 @@ Enum(nds32_cmodel_type) String(medium) Value(CMODEL_MEDIUM)
EnumValue
Enum(nds32_cmodel_type) String(large) Value(CMODEL_LARGE)
-mforce-fp-as-gp
-Target Report Mask(FORCE_FP_AS_GP)
-Prevent $fp being allocated during register allocation so that compiler is able to force performing fp-as-gp optimization.
-
-mforbid-fp-as-gp
-Target Report Mask(FORBID_FP_AS_GP)
-Forbid using $fp to access static and global variables. This option strictly forbids fp-as-gp optimization regardless of '-mforce-fp-as-gp'.
-
-mex9
-Target Report Mask(EX9)
-Use special directives to guide linker doing ex9 optimization.
-
mctor-dtor
Target Report
Enable constructor/destructor feature.
--
1.9.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-01-14 6:29 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-14 7:09 [PATCH, nds32] Committed: Remove some features that are not available yet in nds32 port of GNU binutils package Chung-Ju Wu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).