diff options
author | Jiong Wang <jiwang@gcc.gnu.org> | 2015-08-26 13:38:40 +0000 |
---|---|---|
committer | Jiong Wang <jiwang@gcc.gnu.org> | 2015-08-26 13:38:40 +0000 |
commit | 5ae7caad5160a2238fa40324095d7c07fcc3885d (patch) | |
tree | c20b5b6afa579efa756b23ce6f725a647c26e7ba /gcc | |
parent | e656fbc820265bdab84bdc2ab6c4e32a4713ea1e (diff) | |
download | gcc-5ae7caad5160a2238fa40324095d7c07fcc3885d.zip gcc-5ae7caad5160a2238fa40324095d7c07fcc3885d.tar.gz gcc-5ae7caad5160a2238fa40324095d7c07fcc3885d.tar.bz2 |
[AArch64][TLSIE][2/2] Implement TLS IE for tiny model
2015-08-26 Marcus Shawcroft <marcus.shawcroft@arm.com>
Jiong Wang <jiong.wang@arm.com>
gcc/
* config/aarch64/aarch64.md (UNSPEC_GOTTINYTLS): New UNSPEC.
(tlsie_tiny_<mode>): New define_insn.
(tlsie_tiny_sidi): Likewise.
* config/aarch64/aarch64-protos.h (aarch64_symbol_type): Define
SYMBOL_TINY_TLSIE.
(aarch64_symbol_context): New comment for SYMBOL_TINY_TLSIE.
* config/aarch64/aarch64.c (aarch64_load_symref_appropriately): Support
SYMBOL_TINY_TLSIE.
(aarch64_expand_mov_immediate): Likewise.
(aarch64_print_operand): Likewise.
(arch64_classify_tls_symbol): Likewise.
gcc/testsuite/
* gcc.target/aarch64/tlsie_tiny_1.c: New testcase.
From-SVN: r227220
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 15 | ||||
-rw-r--r-- | gcc/config/aarch64/aarch64-protos.h | 2 | ||||
-rw-r--r-- | gcc/config/aarch64/aarch64.c | 39 | ||||
-rw-r--r-- | gcc/config/aarch64/aarch64.md | 25 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/aarch64/tlsie_tiny_1.c | 7 |
6 files changed, 91 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8f92283..a0c4fb9 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,18 @@ +2015-08-26 Marcus Shawcroft <marcus.shawcroft@arm.com> + Jiong Wang <jiong.wang@arm.com> + + * config/aarch64/aarch64.md (UNSPEC_GOTTINYTLS): New UNSPEC. + (tlsie_tiny_<mode>): New define_insn. + (tlsie_tiny_sidi): Likewise. + * config/aarch64/aarch64-protos.h (aarch64_symbol_type): Define + SYMBOL_TINY_TLSIE. + (aarch64_symbol_context): New comment for SYMBOL_TINY_TLSIE. + * config/aarch64/aarch64.c (aarch64_load_symref_appropriately): Support + SYMBOL_TINY_TLSIE. + (aarch64_expand_mov_immediate): Likewise. + (aarch64_print_operand): Likewise. + (arch64_classify_tls_symbol): Likewise. + 2015-08-26 Matthew Wahab <matthew.wahab@arm.com> * config/arm/arm-arches.def: Replace single value flags with diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h index 59c364d..8fbc204 100644 --- a/gcc/config/aarch64/aarch64-protos.h +++ b/gcc/config/aarch64/aarch64-protos.h @@ -74,6 +74,7 @@ enum aarch64_symbol_context SYMBOL_SMALL_TLSGD SYMBOL_SMALL_TLSDESC SYMBOL_SMALL_GOTTPREL + SYMBOL_TINY_TLSIE SYMBOL_TLSLE12 SYMBOL_TLSLE24 SYMBOL_TLSLE32 @@ -114,6 +115,7 @@ enum aarch64_symbol_type SYMBOL_SMALL_GOTTPREL, SYMBOL_TINY_ABSOLUTE, SYMBOL_TINY_GOT, + SYMBOL_TINY_TLSIE, SYMBOL_TLSLE12, SYMBOL_TLSLE24, SYMBOL_TLSLE32, diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index 6265898..c74bf84 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -1159,6 +1159,31 @@ aarch64_load_symref_appropriately (rtx dest, rtx imm, emit_insn (gen_ldr_got_tiny (dest, imm)); return; + case SYMBOL_TINY_TLSIE: + { + machine_mode mode = GET_MODE (dest); + rtx tp = aarch64_load_tp (NULL); + + if (mode == ptr_mode) + { + if (mode == DImode) + emit_insn (gen_tlsie_tiny_di (dest, imm, tp)); + else + { + tp = gen_lowpart (mode, tp); + emit_insn (gen_tlsie_tiny_si (dest, imm, tp)); + } + } + else + { + gcc_assert (mode == Pmode); + emit_insn (gen_tlsie_tiny_sidi (dest, imm, tp)); + } + + set_unique_reg_note (get_last_insn (), REG_EQUIV, imm); + return; + } + default: gcc_unreachable (); } @@ -1693,6 +1718,7 @@ aarch64_expand_mov_immediate (rtx dest, rtx imm) case SYMBOL_SMALL_GOT_28K: case SYMBOL_SMALL_GOT_4G: case SYMBOL_TINY_GOT: + case SYMBOL_TINY_TLSIE: if (offset != const0_rtx) { gcc_assert(can_create_pseudo_p ()); @@ -4623,6 +4649,10 @@ aarch64_print_operand (FILE *f, rtx x, char code) asm_fprintf (asm_out_file, ":got:"); break; + case SYMBOL_TINY_TLSIE: + asm_fprintf (asm_out_file, ":gottprel:"); + break; + default: break; } @@ -8728,7 +8758,14 @@ aarch64_classify_tls_symbol (rtx x) return TARGET_TLS_DESC ? SYMBOL_SMALL_TLSDESC : SYMBOL_SMALL_TLSGD; case TLS_MODEL_INITIAL_EXEC: - return SYMBOL_SMALL_GOTTPREL; + switch (aarch64_cmodel) + { + case AARCH64_CMODEL_TINY: + case AARCH64_CMODEL_TINY_PIC: + return SYMBOL_TINY_TLSIE; + default: + return SYMBOL_SMALL_GOTTPREL; + } case TLS_MODEL_LOCAL_EXEC: if (aarch64_tls_size == 12) diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md index deac211..80fd6c4 100644 --- a/gcc/config/aarch64/aarch64.md +++ b/gcc/config/aarch64/aarch64.md @@ -90,6 +90,7 @@ UNSPEC_GOTSMALLPIC28K UNSPEC_GOTSMALLTLS UNSPEC_GOTTINYPIC + UNSPEC_GOTTINYTLS UNSPEC_LD1 UNSPEC_LD2 UNSPEC_LD2_DUP @@ -4515,6 +4516,30 @@ (set_attr "length" "8")] ) +(define_insn "tlsie_tiny_<mode>" + [(set (match_operand:PTR 0 "register_operand" "=&r") + (unspec:PTR [(match_operand 1 "aarch64_tls_ie_symref" "S") + (match_operand:PTR 2 "register_operand" "r")] + UNSPEC_GOTTINYTLS))] + "" + "ldr\\t%<w>0, %L1\;add\\t%<w>0, %<w>0, %<w>2" + [(set_attr "type" "multiple") + (set_attr "length" "8")] +) + +(define_insn "tlsie_tiny_sidi" + [(set (match_operand:DI 0 "register_operand" "=&r") + (zero_extend:DI + (unspec:SI [(match_operand 1 "aarch64_tls_ie_symref" "S") + (match_operand:DI 2 "register_operand" "r") + ] + UNSPEC_GOTTINYTLS)))] + "" + "ldr\\t%w0, %L1\;add\\t%<w>0, %<w>0, %<w>2" + [(set_attr "type" "multiple") + (set_attr "length" "8")] +) + (define_insn "tlsle12_<mode>" [(set (match_operand:P 0 "register_operand" "=r") (unspec:P [(match_operand:P 1 "register_operand" "r") diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2e1198e..b1dcc15 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,9 @@ 2015-08-26 Jiong Wang <jiong.wang@arm.com> + * gcc.target/aarch64/tlsie_tiny_1.c: New testcase. + +2015-08-26 Jiong Wang <jiong.wang@arm.com> + * gcc.target/aarch64/tlsle_1.x: Rename to tls_1.x * gcc.target/aarch64/aarch64/tlsle12_1.c: Update source file name. * gcc.target/aarch64/aarch64/tlsle24_1.c: Likewise. diff --git a/gcc/testsuite/gcc.target/aarch64/tlsie_tiny_1.c b/gcc/testsuite/gcc.target/aarch64/tlsie_tiny_1.c new file mode 100644 index 0000000..7477fa6 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/tlsie_tiny_1.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target tls_native } */ +/* { dg-options "-O2 -fpic -ftls-model=initial-exec -mcmodel=tiny" } */ + +#include "tls_1.x" + +/* { dg-final { scan-assembler-times ":gottprel:" 2 } } */ |