diff mbox

[PATCH/AARCH64] Fix build after __builtin_thread_pointer changes

Message ID CA+=Sn1kBM0f+BHV6rw3gW+hnZj30b8-zRoWAnn=gUXZWBr+=zQ@mail.gmail.com
State New
Headers show

Commit Message

Andrew Pinski Oct. 29, 2012, 8:25 a.m. UTC
Hi,
  Right now aarch64-*-* is broken because the C front-end also defines
a __builtin_thread_pointer which causes an internal error.  We don't
need to do the __builtin_thread_pointer support in the back-end.  This
patch moves aarch64 to using the common code instead.

OK?  Built for aarch64-thunder-elf.

Thanks,
Andrew Pinski

ChangeLog:

	* config/aarch64/aarch64-protos.h (aarch64_load_tp): New proto.
	* config/aarch64/aarch64.c (aarch64_load_tp): Export.
	(aarch64_init_builtins): Don't add __builtin_thread_pointer builtin.
	* config/aarch64/aarch64.h (aarch64_builtins): Delete
AARCH64_BUILTIN_THREAD_POINTER.
	* config/aarch64/aarch64.md (get_thread_pointerdi): New pattern.

Comments

Richard Earnshaw Oct. 29, 2012, 9:48 a.m. UTC | #1
On 29 Oct 2012, at 09:26, "Andrew Pinski" <andrew.pinski@caviumnetworks.com> wrote:

> Hi,
>  Right now aarch64-*-* is broken because the C front-end also defines
> a __builtin_thread_pointer which causes an internal error.  We don't
> need to do the __builtin_thread_pointer support in the back-end.  This
> patch moves aarch64 to using the common code instead.
> 
> OK?  Built for aarch64-thunder-elf.
> 
> Thanks,
> Andrew Pinski
> 
> ChangeLog:
> 
>    * config/aarch64/aarch64-protos.h (aarch64_load_tp): New proto.
>    * config/aarch64/aarch64.c (aarch64_load_tp): Export.
>    (aarch64_init_builtins): Don't add __builtin_thread_pointer builtin.
>    * config/aarch64/aarch64.h (aarch64_builtins): Delete
> AARCH64_BUILTIN_THREAD_POINTER.
>    * config/aarch64/aarch64.md (get_thread_pointerdi): New pattern.
> <fixaarch64.diff.txt>

Ok.

R.
diff mbox

Patch

diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h
index 765d192..ca4e306 100644
--- a/gcc/config/aarch64/aarch64-protos.h
+++ b/gcc/config/aarch64/aarch64-protos.h
@@ -254,6 +254,7 @@  bool aarch64_split_128bit_move_p (rtx, rtx);
 bool aarch64_legitimate_address_p (enum machine_mode, rtx, RTX_CODE, bool);
 enum machine_mode aarch64_select_cc_mode (RTX_CODE, rtx, rtx);
 rtx aarch64_gen_compare_reg (RTX_CODE, rtx, rtx);
+rtx aarch64_load_tp (rtx);
 
 #endif /* RTX_CODE */
 
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 1bc0c8a..aaebdf6 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -102,7 +102,6 @@  static bool aarch64_vfp_is_call_or_return_candidate (enum machine_mode,
 						     bool *);
 static void aarch64_elf_asm_constructor (rtx, int) ATTRIBUTE_UNUSED;
 static void aarch64_elf_asm_destructor (rtx, int) ATTRIBUTE_UNUSED;
-static rtx aarch64_load_tp (rtx);
 static void aarch64_override_options_after_change (void);
 static int aarch64_simd_valid_immediate (rtx, enum machine_mode, int, rtx *,
 					 int *, unsigned char *, int *, int *);
@@ -4988,20 +4987,11 @@  aarch64_legitimate_constant_p (enum machine_mode mode, rtx x)
 static void
 aarch64_init_builtins (void)
 {
-  tree ftype, decl = NULL;
-
-  ftype = build_function_type (ptr_type_node, void_list_node);
-  decl = add_builtin_function ("__builtin_thread_pointer", ftype,
-			       AARCH64_BUILTIN_THREAD_POINTER, BUILT_IN_MD,
-			       NULL, NULL_TREE);
-  TREE_NOTHROW (decl) = 1;
-  TREE_READONLY (decl) = 1;
-
   if (TARGET_SIMD)
     init_aarch64_simd_builtins ();
 }
 
-static rtx
+rtx
 aarch64_load_tp (rtx target)
 {
   if (!target
@@ -5026,9 +5016,6 @@  aarch64_expand_builtin (tree exp,
   tree fndecl = TREE_OPERAND (CALL_EXPR_FN (exp), 0);
   int fcode = DECL_FUNCTION_CODE (fndecl);
 
-  if (fcode == AARCH64_BUILTIN_THREAD_POINTER)
-    return aarch64_load_tp (target);
-
   if (fcode >= AARCH64_SIMD_BUILTIN_BASE)
     return aarch64_simd_expand_builtin (fcode, exp, target);
 
diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
index 3b8b033..122a7a5 100644
--- a/gcc/config/aarch64/aarch64.h
+++ b/gcc/config/aarch64/aarch64.h
@@ -794,7 +794,6 @@  do {									     \
 enum aarch64_builtins
 {
   AARCH64_BUILTIN_MIN,
-  AARCH64_BUILTIN_THREAD_POINTER,
   AARCH64_SIMD_BUILTIN_BASE
 };
 
diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md
index b803922..804d7e7 100644
--- a/gcc/config/aarch64/aarch64.md
+++ b/gcc/config/aarch64/aarch64.md
@@ -2923,6 +2923,17 @@ 
   [(set_attr "length" "0")]
 )
 
+;; Named pattern for expanding thread pointer reference.
+(define_expand "get_thread_pointerdi"
+  [(match_operand:DI 0 "register_operand" "=r")]
+  ""
+{
+  rtx tmp = aarch64_load_tp (operands[0]);
+  if (tmp != operands[0])
+    emit_move_insn (operands[0], tmp);
+  DONE;
+})
+
 ;; AdvSIMD Stuff
 (include "aarch64-simd.md")