Commit 8cc9a5a5 by Edgar E. Iglesias Committed by Michael Eager

Add support for TLS in MicroBlaze

 * configure.ac: Add MicroBlaze TLS support detection.
 * configure: Regenerate.
 * config/microblaze/microblaze-protos.h: (microblaze_cannot_force_const_mem,
   microblaze_tls_referenced_p, symbol_mentioned_p,
   label_mentioned_p): Add prototypes.
 * config/microblaze/microblaze.c (microblaze_address_type): Add ADDRESS_TLS
   and tls_reloc address types.
   (microblaze_address_info): Add tls_reloc.
   (TARGET_HAVE_TLS): Define.
   (get_tls_get_addr, microblaze_tls_symbol_p, microblaze_tls_operand_p_1,
    microblaze_tls_referenced_p, microblaze_cannot_force_const_mem,
    symbol_mentioned_p, label_mentioned_p, tls_mentioned_p, load_tls_operand,
    microblaze_call_tls_get_addr, microblaze_legitimize_tls_address): New functions.
   (microblaze_classify_unspec): Handle UNSPEC_TLS.
   (get_base_reg): Use microblaze_tls_symbol_p.
   (microblaze_classify_address): Handle TLS.
   (microblaze_legitimate_pic_operand): Use symbol_mentioned_p, label_mentioned_p
    and microblaze_tls_referenced_p.
   (microblaze_legitimize_address): Handle TLS.
   (microblaze_address_insns): Handle ADDRESS_TLS.
   (pic_address_needs_scratch): Handle TLS.
   (print_operand_address): Handle TLS.
   (microblaze_expand_prologue): Check TLS_NEEDS_GOT.
   (microblaze_expand_move): Handle TLS.
   (microblaze_legitimate_constant_p): Check microblaze_cannot_force_const_mem
    and microblaze_tls_symbol_p.
   (TARGET_CANNOT_FORCE_CONST_MEM): Define.
 * config/microblaze/microblaze.h (TLS_NEEDS_GOT): Define
   (PIC_OFFSET_TABLE_REGNUM): Set.
 * config/microblaze/linux.h (TLS_NEEDS_GOT): Define.
 * config/microblaze/microblaze.md (UNSPEC_TLS): Define.
   (addsi3, movsi_internal2, movdf_internal): Update constraints
 * config/microblaze/predicates.md (arith_plus_operand): Define
   (move_operand): Redefine as move_src_operand, check microblaze_tls_referenced_p.



Co-Authored-By: David Holsgrove <david.holsgrove@xilinx.com>

From-SVN: r196659
parent a7137ee1
2013-03-14 Edgar E. Iglesias <edgar.iglesias@xilinx.com>
David Holsgrove <david.holsgrove@xilinx.com>
* configure.ac: Add MicroBlaze TLS support detection.
* configure: Regenerate.
* config/microblaze/microblaze-protos.h: (microblaze_cannot_force_const_mem,
microblaze_tls_referenced_p, symbol_mentioned_p, label_mentioned_p):
Add prototypes.
* config/microblaze/microblaze.c (microblaze_address_type): Add ADDRESS_TLS
and tls_reloc address types.
(microblaze_address_info): Add tls_reloc.
(TARGET_HAVE_TLS): Define.
(get_tls_get_addr, microblaze_tls_symbol_p, microblaze_tls_operand_p_1,
microblaze_tls_referenced_p, microblaze_cannot_force_const_mem,
symbol_mentioned_p, label_mentioned_p, tls_mentioned_p, load_tls_operand,
microblaze_call_tls_get_addr, microblaze_legitimize_tls_address): New functions.
(microblaze_classify_unspec): Handle UNSPEC_TLS.
(get_base_reg): Use microblaze_tls_symbol_p.
(microblaze_classify_address): Handle TLS.
(microblaze_legitimate_pic_operand): Use symbol_mentioned_p, label_mentioned_p
and microblaze_tls_referenced_p.
(microblaze_legitimize_address): Handle TLS.
(microblaze_address_insns): Handle ADDRESS_TLS.
(pic_address_needs_scratch): Handle TLS.
(print_operand_address): Handle TLS.
(microblaze_expand_prologue): Check TLS_NEEDS_GOT.
(microblaze_expand_move): Handle TLS.
(microblaze_legitimate_constant_p): Check microblaze_cannot_force_const_mem
and microblaze_tls_symbol_p.
(TARGET_CANNOT_FORCE_CONST_MEM): Define.
* config/microblaze/microblaze.h (TLS_NEEDS_GOT): Define
(PIC_OFFSET_TABLE_REGNUM): Set.
* config/microblaze/linux.h (TLS_NEEDS_GOT): Define.
* config/microblaze/microblaze.md (UNSPEC_TLS): Define.
(addsi3, movsi_internal2, movdf_internal): Update constraints
* config/microblaze/predicates.md (arith_plus_operand): Define
(move_operand): Redefine as move_src_operand, check microblaze_tls_referenced_p.
2013-03-14 Ian Bolton <ian.bolton@arm.com> 2013-03-14 Ian Bolton <ian.bolton@arm.com>
* config/aarch64/aarch64.md: (*and<mode>3nr_compare0): Use CC_NZ. * config/aarch64/aarch64.md: (*and<mode>3nr_compare0): Use CC_NZ.
......
...@@ -22,6 +22,9 @@ ...@@ -22,6 +22,9 @@
#undef TARGET_SUPPORTS_PIC #undef TARGET_SUPPORTS_PIC
#define TARGET_SUPPORTS_PIC 1 #define TARGET_SUPPORTS_PIC 1
#undef TLS_NEEDS_GOT
#define TLS_NEEDS_GOT 1
#define DYNAMIC_LINKER "/lib/ld.so.1" #define DYNAMIC_LINKER "/lib/ld.so.1"
#undef SUBTARGET_EXTRA_SPECS #undef SUBTARGET_EXTRA_SPECS
#define SUBTARGET_EXTRA_SPECS \ #define SUBTARGET_EXTRA_SPECS \
......
...@@ -50,6 +50,10 @@ extern void microblaze_declare_object (FILE *, const char *, const char *, ...@@ -50,6 +50,10 @@ extern void microblaze_declare_object (FILE *, const char *, const char *,
const char *, int); const char *, int);
extern void microblaze_asm_output_ident (const char *); extern void microblaze_asm_output_ident (const char *);
extern int microblaze_legitimate_pic_operand (rtx); extern int microblaze_legitimate_pic_operand (rtx);
extern bool microblaze_tls_referenced_p (rtx);
extern int symbol_mentioned_p (rtx);
extern int label_mentioned_p (rtx);
extern bool microblaze_cannot_force_const_mem (enum machine_mode, rtx);
#endif /* RTX_CODE */ #endif /* RTX_CODE */
/* Declare functions in microblaze-c.c. */ /* Declare functions in microblaze-c.c. */
......
...@@ -65,6 +65,9 @@ extern enum pipeline_type microblaze_pipe; ...@@ -65,6 +65,9 @@ extern enum pipeline_type microblaze_pipe;
/* The default is to support PIC. */ /* The default is to support PIC. */
#define TARGET_SUPPORTS_PIC 1 #define TARGET_SUPPORTS_PIC 1
/* The default is to not need GOT for TLS. */
#define TLS_NEEDS_GOT 0
/* What is the default setting for -mcpu= . We set it to v4.00.a even though /* What is the default setting for -mcpu= . We set it to v4.00.a even though
we are actually ahead. This is safest version that has generate code we are actually ahead. This is safest version that has generate code
compatible for the original ISA */ compatible for the original ISA */
...@@ -326,9 +329,7 @@ extern char microblaze_hard_regno_mode_ok[][FIRST_PSEUDO_REGISTER]; ...@@ -326,9 +329,7 @@ extern char microblaze_hard_regno_mode_ok[][FIRST_PSEUDO_REGISTER];
#define NO_FUNCTION_CSE 1 #define NO_FUNCTION_CSE 1
#define PIC_OFFSET_TABLE_REGNUM \ #define PIC_OFFSET_TABLE_REGNUM (GP_REG_FIRST + MB_ABI_PIC_ADDR_REGNUM)
(flag_pic ? (GP_REG_FIRST + MB_ABI_PIC_ADDR_REGNUM) : \
INVALID_REGNUM)
enum reg_class enum reg_class
{ {
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
(UNSPEC_PLT 103) ;; jump table (UNSPEC_PLT 103) ;; jump table
(UNSPEC_CMP 104) ;; signed compare (UNSPEC_CMP 104) ;; signed compare
(UNSPEC_CMPU 105) ;; unsigned compare (UNSPEC_CMPU 105) ;; unsigned compare
(UNSPEC_TLS 106) ;; jump table
]) ])
...@@ -459,7 +460,7 @@ ...@@ -459,7 +460,7 @@
(define_insn "addsi3" (define_insn "addsi3"
[(set (match_operand:SI 0 "register_operand" "=d,d,d") [(set (match_operand:SI 0 "register_operand" "=d,d,d")
(plus:SI (match_operand:SI 1 "reg_or_0_operand" "%dJ,dJ,dJ") (plus:SI (match_operand:SI 1 "reg_or_0_operand" "%dJ,dJ,dJ")
(match_operand:SI 2 "arith_operand" "d,I,i")))] (match_operand:SI 2 "arith_plus_operand" "d,I,i")))]
"" ""
"@ "@
addk\t%0,%z1,%2 addk\t%0,%z1,%2
...@@ -892,8 +893,8 @@ ...@@ -892,8 +893,8 @@
(define_insn "*movdi_internal" (define_insn "*movdi_internal"
[(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,d,R,m") [(set (match_operand:DI 0 "nonimmediate_operand" "=d,d,d,d,d,R,o")
(match_operand:DI 1 "general_operand" " d,i,J,R,m,d,d"))] (match_operand:DI 1 "general_operand" " d,i,J,R,o,d,d"))]
"" ""
{ {
switch (which_alternative) switch (which_alternative)
...@@ -999,13 +1000,9 @@ ...@@ -999,13 +1000,9 @@
(set_attr "length" "4")]) (set_attr "length" "4")])
(define_insn "*movsi_internal2" (define_insn "*movsi_internal2"
[(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d, d,d,R, T") [(set (match_operand:SI 0 "nonimmediate_operand" "=d,d,d, d,d,R,m")
(match_operand:SI 1 "move_operand" " d,I,Mnis,R,m,dJ,dJ"))] (match_operand:SI 1 "move_src_operand" " d,I,Mnis,R,m,dJ,dJ"))]
"(register_operand (operands[0], SImode) ""
|| register_operand (operands[1], SImode)
|| (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) == 0))
&& (flag_pic != 2 || (GET_CODE (operands[1]) != SYMBOL_REF
&& GET_CODE (operands[1]) != LABEL_REF))"
"@ "@
addk\t%0,%1,r0 addk\t%0,%1,r0
addik\t%0,r0,%1\t# %X1 addik\t%0,r0,%1\t# %X1
...@@ -1196,7 +1193,7 @@ ...@@ -1196,7 +1193,7 @@
;; Applies to both TARGET_SOFT_FLOAT and TARGET_HARD_FLOAT ;; Applies to both TARGET_SOFT_FLOAT and TARGET_HARD_FLOAT
;; ;;
(define_insn "*movdf_internal" (define_insn "*movdf_internal"
[(set (match_operand:DF 0 "nonimmediate_operand" "=d,d,d,d,To") [(set (match_operand:DF 0 "nonimmediate_operand" "=d,d,d,d,o")
(match_operand:DF 1 "general_operand" "dG,o,F,T,d"))] (match_operand:DF 1 "general_operand" "dG,o,F,T,d"))]
"" ""
{ {
......
...@@ -30,6 +30,52 @@ ...@@ -30,6 +30,52 @@
(and (match_code "const_int,const_double") (and (match_code "const_int,const_double")
(match_test "LARGE_INT (op)")))) (match_test "LARGE_INT (op)"))))
(define_predicate "arith_plus_operand"
(match_operand 0 "general_operand")
{
switch (GET_CODE (op))
{
default:
return 0;
case CONST_INT:
case REG:
return 1;
case SYMBOL_REF:
case LABEL_REF:
if (flag_pic || microblaze_tls_referenced_p(op))
return 0;
return 1;
case CONST:
{
rtx const0;
const0 = XEXP (op, 0);
switch (GET_CODE(const0))
{
default:
return 0;
case UNSPEC :
return 1;
case PLUS :
{
rtx p0, p1;
p0 = XEXP (const0, 0);
p1 = XEXP (const0, 1);
if ((GET_CODE(p0) == SYMBOL_REF
|| GET_CODE (p0) == LABEL_REF)
&& GET_CODE(p1) == CONST_INT)
{
return arith_plus_operand (p0, GET_MODE(p0));
}
}
}
}
}
return 0;
})
(define_predicate "const_0_operand" (define_predicate "const_0_operand"
(and (match_code "const_int,const_double") (and (match_code "const_int,const_double")
(match_test "op == CONST0_RTX (GET_MODE (op))"))) (match_test "op == CONST0_RTX (GET_MODE (op))")))
...@@ -54,14 +100,21 @@ ...@@ -54,14 +100,21 @@
(match_test "GET_CODE (op) == REG || GET_CODE (op) == SYMBOL_REF || GET_CODE (op) == CONST_INT"))) (match_test "GET_CODE (op) == REG || GET_CODE (op) == SYMBOL_REF || GET_CODE (op) == CONST_INT")))
;; Return if OPERAND is valid as a source operand for a move instruction. ;; Return if OPERAND is valid as a source operand for a move instruction.
(define_predicate "move_operand" (define_predicate "move_src_operand"
(and ( (and (
not ( not (
and (match_code "plus") and (match_code "plus")
(not (match_test "(GET_CODE (XEXP (op, 0)) == REG) ^ (GET_CODE (XEXP (op,1)) == REG)")) (not (match_test "(GET_CODE (XEXP (op, 0)) == REG) ^ (GET_CODE (XEXP (op,1)) == REG)"))
) )
) )
(match_operand 0 "general_operand"))) (match_operand 0 "general_operand"))
{
if (microblaze_tls_referenced_p(op)
|| (flag_pic && (symbol_mentioned_p(op) || label_mentioned_p(op))))
return false;
return true;
})
;; Test for valid PIC call operand ;; Test for valid PIC call operand
(define_predicate "call_insn_plt_operand" (define_predicate "call_insn_plt_operand"
......
...@@ -23205,6 +23205,18 @@ foo: data8 25 ...@@ -23205,6 +23205,18 @@ foo: data8 25
tls_first_minor=13 tls_first_minor=13
tls_as_opt=--fatal-warnings tls_as_opt=--fatal-warnings
;; ;;
microblaze*-*-*)
conftest_s='
.section .tdata,"awT",@progbits
x:
.word 2
.text
addik r5,r20,x@TLSGD
addik r5,r20,x@TLSLDM'
tls_first_major=2
tls_first_minor=20
tls_as_opt='--fatal-warnings'
;;
mips*-*-*) mips*-*-*)
conftest_s=' conftest_s='
.section .tdata,"awT",@progbits .section .tdata,"awT",@progbits
......
...@@ -2968,6 +2968,18 @@ foo: data8 25 ...@@ -2968,6 +2968,18 @@ foo: data8 25
tls_first_minor=13 tls_first_minor=13
tls_as_opt=--fatal-warnings tls_as_opt=--fatal-warnings
;; ;;
microblaze*-*-*)
conftest_s='
.section .tdata,"awT",@progbits
x:
.word 2
.text
addik r5,r20,x@TLSGD
addik r5,r20,x@TLSLDM'
tls_first_major=2
tls_first_minor=20
tls_as_opt='--fatal-warnings'
;;
mips*-*-*) mips*-*-*)
conftest_s=' conftest_s='
.section .tdata,"awT",@progbits .section .tdata,"awT",@progbits
......
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