Commit ddaf8125 by Richard Sandiford

mips-protos.h (SYMBOL_FORCE_TO_MEM): Delete.

gcc/
2012-01-08  Chung-Lin Tang  <cltang@codesourcery.com>
	    Richard Sandiford  <rdsandiford@googlemail.com>

	* config/mips/mips-protos.h (SYMBOL_FORCE_TO_MEM): Delete.
	(SYMBOL_32_HIGH): Likewise.
	(mips_output_tls_reloc_directive): Declare.
	* config/mips/mips.h (PIC_FUNCTION_ADDR_REGNUM): Move to mips.md.
	(mips_use_pcrel_pool_p, mips_lo_relocs, mips_hi_relocs): Declare.
	* config/mips/mips.c (mips_use_pcrel_pool_p): New variable.
	(mips_lo_relocs, mips_hi_relocs): Make extern.
	(mips16_stub_function): Move up file.
	(mips_classify_symbol): Remove SYMBOL_FORCE_TO_MEM handling.
	(mips_symbolic_constant_p): Likewise.  Remove SYMBOL_32_HIGH too.
	(mips_symbol_insns_1): Likewise.  Check mips_use_pcrel_pool_p.
	(mips_cannot_force_const_mem): Use mips_use_pcrel_pool_p instead
	of SYMBOL_FORCE_TO_MEM.  Only check mips_tls_symbol_ref_1
	if it's false.
	(mips_get_tp): Add MIPS16 support.
	(mips_legitimize_tls_address): Remove MIPS16 sorry().
	Generalize DTPREL and TPREL handling.
	(mips_init_relocs): Initialize mips_use_pcrel_pool_p.
	Add MIPS16 TLS support.
	(mips_output_tls_reloc_directive): New function.
	(mips16_rewrite_pool_refs): Ignore UNSPEC_TLS_GET_TPs.
	* config/mips/predicates.md (symbolic_operand_with_high)
	(tls_reloc_operand): New predicates.
	(force_to_mem_operand): Use mips_use_pcrel_pool_p.
	* config/mips/mips.md (UNSPEC_UNSHIFTED_HIGH): New unspec.
	(PIC_FUNCTION_ADDR_REGNUM): Moved from mips.h.
	(*unshifted_high): New instruction.  Use it for MIPS16
	high splitter.
	(consttable_tls_reloc, tls_get_tp_mips16_<mode>): New patterns.
	(*tls_get_tp_mips16_call_<mode>): Likewise.

gcc/testsuite/
	* gcc.target/mips/code-readable-2.c: Allow the jump table address
	to be loaded from the constant pool, rather than via %hi and %lo.

libgcc/
2012-01-08  Chung-Lin Tang  <cltang@codesourcery.com>
	    Richard Sandiford  <rdsandiford@googlemail.com>

	* config/mips/libgcc-mips16.ver (__mips16_rdhwr): Add.
	* config/mips/mips16.S (__mips16_rdhwr): New function.
	* config/mips/t-mips16 (LIB1ASMFUNCS): Add _m16rdhwr.

From-SVN: r183195
parent bf63ef6c
2012-01-15 Chung-Lin Tang <cltang@codesourcery.com>
Richard Sandiford <rdsandiford@googlemail.com>
* config/mips/mips-protos.h (SYMBOL_FORCE_TO_MEM): Delete.
(SYMBOL_32_HIGH): Likewise.
(mips_output_tls_reloc_directive): Declare.
* config/mips/mips.h (PIC_FUNCTION_ADDR_REGNUM): Move to mips.md.
(mips_use_pcrel_pool_p, mips_lo_relocs, mips_hi_relocs): Declare.
* config/mips/mips.c (mips_use_pcrel_pool_p): New variable.
(mips_lo_relocs, mips_hi_relocs): Make extern.
(mips16_stub_function): Move up file.
(mips_classify_symbol): Remove SYMBOL_FORCE_TO_MEM handling.
(mips_symbolic_constant_p): Likewise. Remove SYMBOL_32_HIGH too.
(mips_symbol_insns_1): Likewise. Check mips_use_pcrel_pool_p.
(mips_cannot_force_const_mem): Use mips_use_pcrel_pool_p instead
of SYMBOL_FORCE_TO_MEM. Only check mips_tls_symbol_ref_1
if it's false.
(mips_get_tp): Add MIPS16 support.
(mips_legitimize_tls_address): Remove MIPS16 sorry().
Generalize DTPREL and TPREL handling.
(mips_init_relocs): Initialize mips_use_pcrel_pool_p.
Add MIPS16 TLS support.
(mips_output_tls_reloc_directive): New function.
(mips16_rewrite_pool_refs): Ignore UNSPEC_TLS_GET_TPs.
* config/mips/predicates.md (symbolic_operand_with_high)
(tls_reloc_operand): New predicates.
(force_to_mem_operand): Use mips_use_pcrel_pool_p.
* config/mips/mips.md (UNSPEC_UNSHIFTED_HIGH): New unspec.
(PIC_FUNCTION_ADDR_REGNUM): Moved from mips.h.
(*unshifted_high): New instruction. Use it for MIPS16
high splitter.
(consttable_tls_reloc, tls_get_tp_mips16_<mode>): New patterns.
(*tls_get_tp_mips16_call_<mode>): Likewise.
2012-01-15 Uros Bizjak <ubizjak@gmail.com>
PR rtl-optimization/51821
......
......@@ -56,9 +56,6 @@ enum mips_symbol_context {
The symbol's value will be calculated using a MIPS16 PC-relative
calculation.
SYMBOL_FORCE_TO_MEM
The symbol's value must be forced to memory and loaded from there.
SYMBOL_GOT_PAGE_OFST
The symbol's value will be calculated by loading an address
from the GOT and then applying a 16-bit offset.
......@@ -94,9 +91,6 @@ enum mips_symbol_context {
UNSPEC wrappers around SYMBOL_TLS, corresponding to the
thread-local storage relocation operators.
SYMBOL_32_HIGH
For a 32-bit symbolic address X, this is the value of %hi(X).
SYMBOL_64_HIGH
For a 64-bit symbolic address X, this is the value of
(%highest(X) << 16) + %higher(X).
......@@ -116,7 +110,6 @@ enum mips_symbol_type {
SYMBOL_ABSOLUTE,
SYMBOL_GP_RELATIVE,
SYMBOL_PC_RELATIVE,
SYMBOL_FORCE_TO_MEM,
SYMBOL_GOT_PAGE_OFST,
SYMBOL_GOT_DISP,
SYMBOL_GOTOFF_PAGE,
......@@ -129,7 +122,6 @@ enum mips_symbol_type {
SYMBOL_DTPREL,
SYMBOL_GOTTPREL,
SYMBOL_TPREL,
SYMBOL_32_HIGH,
SYMBOL_64_HIGH,
SYMBOL_64_MID,
SYMBOL_64_LOW,
......@@ -260,6 +252,7 @@ extern void mips_push_asm_switch (struct mips_asm_switch *);
extern void mips_pop_asm_switch (struct mips_asm_switch *);
extern void mips_output_external (FILE *, tree, const char *);
extern void mips_output_ascii (FILE *, const char *, size_t);
extern const char *mips_output_tls_reloc_directive (rtx *);
extern void mips_output_aligned_decl_common (FILE *, tree, const char *,
unsigned HOST_WIDE_INT,
unsigned int);
......
......@@ -1785,8 +1785,6 @@ struct mips_cpu_info {
from there after reload. */
#define PIC_OFFSET_TABLE_REGNUM \
(reload_completed ? REGNO (pic_offset_table_rtx) : GLOBAL_POINTER_REGNUM)
#define PIC_FUNCTION_ADDR_REGNUM (GP_REG_FIRST + 25)
/* Define the classes of registers for register constraints in the
machine description. Also define ranges of constants.
......@@ -2868,6 +2866,9 @@ extern int mips_dbx_regno[];
extern int mips_dwarf_regno[];
extern bool mips_split_p[];
extern bool mips_split_hi_p[];
extern bool mips_use_pcrel_pool_p[];
extern const char *mips_lo_relocs[];
extern const char *mips_hi_relocs[];
extern enum processor mips_arch; /* which cpu to codegen for */
extern enum processor mips_tune; /* which cpu to schedule for */
extern int mips_isa; /* architectural level */
......
......@@ -103,6 +103,7 @@
UNSPEC_LOAD_GOT
UNSPEC_TLS_LDM
UNSPEC_TLS_GET_TP
UNSPEC_UNSHIFTED_HIGH
;; MIPS16 constant pools.
UNSPEC_ALIGN
......@@ -135,6 +136,7 @@
(define_constants
[(TLS_GET_TP_REGNUM 3)
(PIC_FUNCTION_ADDR_REGNUM 25)
(RETURN_ADDR_REGNUM 31)
(CPRESTORE_SLOT_REGNUM 76)
(GOT_VERSION_REGNUM 79)
......@@ -3924,14 +3926,19 @@
;;
;; on MIPS16 targets.
(define_split
[(set (match_operand:SI 0 "d_operand")
(high:SI (match_operand:SI 1 "absolute_symbolic_operand")))]
[(set (match_operand:P 0 "d_operand")
(high:P (match_operand:P 1 "symbolic_operand_with_high")))]
"TARGET_MIPS16 && reload_completed"
[(set (match_dup 0) (match_dup 2))
(set (match_dup 0) (ashift:SI (match_dup 0) (const_int 16)))]
{
operands[2] = mips_unspec_address (operands[1], SYMBOL_32_HIGH);
})
[(set (match_dup 0) (unspec:P [(match_dup 1)] UNSPEC_UNSHIFTED_HIGH))
(set (match_dup 0) (ashift:P (match_dup 0) (const_int 16)))])
(define_insn "*unshifted_high"
[(set (match_operand:P 0 "d_operand" "=d")
(unspec:P [(match_operand:P 1 "symbolic_operand_with_high")]
UNSPEC_UNSHIFTED_HIGH))]
""
"li\t%0,%h1"
[(set_attr "extended_mips16" "yes")])
;; Insns to fetch a symbol from a big GOT.
......@@ -6492,6 +6499,14 @@
;; ....................
;;
(define_insn "consttable_tls_reloc"
[(unspec_volatile [(match_operand 0 "tls_reloc_operand" "")
(match_operand 1 "const_int_operand" "")]
UNSPEC_CONSTTABLE_INT)]
"TARGET_MIPS16_PCREL_LOADS"
{ return mips_output_tls_reloc_directive (&operands[0]); }
[(set (attr "length") (symbol_ref "INTVAL (operands[1])"))])
(define_insn "consttable_int"
[(unspec_volatile [(match_operand 0 "consttable_operand" "")
(match_operand 1 "const_int_operand" "")]
......@@ -6593,6 +6608,49 @@
; See tls_get_tp_<mode>
(set_attr "can_delay" "no")
(set_attr "mode" "<MODE>")])
;; In MIPS16 mode, the TLS base pointer is accessed by a
;; libgcc helper function __mips16_rdhwr(), as 'rdhwr' is not
;; accessible in MIPS16.
;;
;; This is not represented as a call insn, to avoid the
;; unnecesarry clobbering of caller-save registers by a
;; function consisting only of: "rdhwr $3,$29; j $31; nop;"
;;
;; A $25 clobber is added to cater for a $25 load stub added by the
;; linker to __mips16_rdhwr when the call is made from non-PIC code.
(define_insn_and_split "tls_get_tp_mips16_<mode>"
[(set (match_operand:P 0 "register_operand" "=d")
(unspec:P [(match_operand:P 1 "call_insn_operand" "dS")]
UNSPEC_TLS_GET_TP))
(clobber (reg:P TLS_GET_TP_REGNUM))
(clobber (reg:P PIC_FUNCTION_ADDR_REGNUM))
(clobber (reg:P RETURN_ADDR_REGNUM))]
"HAVE_AS_TLS && TARGET_MIPS16"
"#"
"&& reload_completed"
[(parallel [(set (reg:P TLS_GET_TP_REGNUM)
(unspec:P [(match_dup 1)] UNSPEC_TLS_GET_TP))
(clobber (reg:P PIC_FUNCTION_ADDR_REGNUM))
(clobber (reg:P RETURN_ADDR_REGNUM))])
(set (match_dup 0) (reg:P TLS_GET_TP_REGNUM))]
""
[(set_attr "type" "multi")
(set_attr "length" "16")
(set_attr "mode" "<MODE>")])
(define_insn "*tls_get_tp_mips16_call_<mode>"
[(set (reg:P TLS_GET_TP_REGNUM)
(unspec:P [(match_operand:P 0 "call_insn_operand" "dS")]
UNSPEC_TLS_GET_TP))
(clobber (reg:P PIC_FUNCTION_ADDR_REGNUM))
(clobber (reg:P RETURN_ADDR_REGNUM))]
"HAVE_AS_TLS && TARGET_MIPS16"
{ return MIPS_CALL ("jal", operands, 0, -1); }
[(set_attr "type" "call")
(set_attr "length" "12")
(set_attr "mode" "<MODE>")])
;; Synchronization instructions.
......
......@@ -288,12 +288,20 @@
&& type == SYMBOL_ABSOLUTE);
})
(define_predicate "symbolic_operand_with_high"
(match_code "const,symbol_ref,label_ref")
{
enum mips_symbol_type type;
return (mips_symbolic_constant_p (op, SYMBOL_CONTEXT_LEA, &type)
&& mips_hi_relocs[(int) type]);
})
(define_predicate "force_to_mem_operand"
(match_code "const,symbol_ref,label_ref")
{
enum mips_symbol_type symbol_type;
return (mips_symbolic_constant_p (op, SYMBOL_CONTEXT_LEA, &symbol_type)
&& symbol_type == SYMBOL_FORCE_TO_MEM);
&& mips_use_pcrel_pool_p[(int) symbol_type]);
})
(define_predicate "got_disp_operand"
......@@ -312,6 +320,14 @@
&& type == SYMBOL_GOT_PAGE_OFST);
})
(define_predicate "tls_reloc_operand"
(match_code "const,symbol_ref,label_ref")
{
enum mips_symbol_type type;
return (mips_symbolic_constant_p (op, SYMBOL_CONTEXT_LEA, &type)
&& (type == SYMBOL_DTPREL || type == SYMBOL_TPREL));
})
(define_predicate "symbol_ref_operand"
(match_code "symbol_ref"))
......
2012-01-15 Richard Sandiford <rdsandiford@googlemail.com>
* gcc.target/mips/code-readable-2.c: Allow the jump table address
to be loaded from the constant pool, rather than via %hi and %lo.
2012-01-15 Uros Bizjak <ubizjak@gmail.com>
PR rtl-optimization/51821
......
......@@ -26,8 +26,7 @@ bar (void)
/* { dg-final { scan-assembler-not "\tla\t" } } */
/* { dg-final { scan-assembler-not "\t\\.half\t" } } */
/* { dg-final { scan-assembler "%hi\\(\[^)\]*L" } } */
/* { dg-final { scan-assembler "%lo\\(\[^)\]*L" } } */
/* { dg-final { scan-assembler "\t\\.word\t\[^\n\]*L" } } */
/* { dg-final { scan-assembler "\t\\.word\tk\n" } } */
/* { dg-final { scan-assembler-not "%hi\\(k\\)" } } */
......
2012-01-15 Chung-Lin Tang <cltang@codesourcery.com>
Richard Sandiford <rdsandiford@googlemail.com>
* config/mips/libgcc-mips16.ver (__mips16_rdhwr): Add.
* config/mips/mips16.S (__mips16_rdhwr): New function.
* config/mips/t-mips16 (LIB1ASMFUNCS): Add _m16rdhwr.
2012-01-11 Nathan Sidwell <nathan@acm.org>
* libgcov.c (__gcov_init): Ignore objects with no functions.
......
......@@ -84,3 +84,7 @@ GCC_4.4.0 {
__mips16_call_stub_dc_9
__mips16_call_stub_dc_10
}
GCC_4.7.0 {
__mips16_rdhwr
}
......@@ -709,4 +709,15 @@ CALL_STUB_RET (__mips16_call_stub_dc_9, 9, DC)
CALL_STUB_RET (__mips16_call_stub_dc_10, 10, DC)
#endif
#endif /* !__mips_single_float */
#ifdef L_m16rdhwr
STARTFN (__mips16_rdhwr)
.set push
.set mips32r2
.set noreorder
rdhwr $3,$29
.set pop
j $31
ENDFN (__mips16_rdhwr)
#endif
#endif
......@@ -36,7 +36,8 @@ LIB1ASMFUNCS = _m16addsf3 _m16subsf3 _m16mulsf3 _m16divsf3 \
_m16stubsc0 _m16stubsc1 _m16stubsc2 _m16stubsc5 _m16stubsc6 \
_m16stubsc9 _m16stubsc10 \
_m16stubdc0 _m16stubdc1 _m16stubdc2 _m16stubdc5 _m16stubdc6 \
_m16stubdc9 _m16stubdc10
_m16stubdc9 _m16stubdc10 \
_m16rdhwr
SYNC = yes
SYNC_CFLAGS = -mno-mips16
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment