Patchwork [2/6] Thread pointer built-in functions, alpha

login
register
mail settings
Submitter Chung-Lin Tang
Date July 12, 2012, 6:52 a.m.
Message ID <4FFE7429.10201@codesourcery.com>
Download mbox | patch
Permalink /patch/170579/
State New
Headers show

Comments

Chung-Lin Tang - July 12, 2012, 6:52 a.m.
Alpha parts. Note that now the machine-independent
__builtin_thread_pointer() is now marked as const/readonly, slightly
different from the original alpha backend code.

Thanks,
Chung-Lin

        * config/alpha/alpha.c (alpha_builtin): Remove
        ALPHA_BUILTIN_THREAD_POINTER, ALPHA_BUILTIN_SET_THREAD_POINTER.
        (code_for_builtin): Remove CODE_FOR_load_tp, CODE_FOR_set_tp.
        (alpha_init_builtins): Remove __builtin_thread_pointer,
        __builtin_set_thread_pointer machine-specific builtins.
        (alpha_expand_builtin_thread_pointer): Add hook function for
        TARGET_EXPAND_BUILTIN_THREAD_POINTER.
        (alpha_expand_builtin_set_thread_pointer): Add hook function for
        TARGET_EXPAND_BUILTIN_SET_THREAD_POINTER.
        (alpha_fold_builtin): Remove ALPHA_BUILTIN_THREAD_POINTER,
        ALPHA_BUILTIN_SET_THREAD_POINTER cases.

Patch

Index: config/alpha/alpha.c
===================================================================
--- config/alpha/alpha.c	(revision 189431)
+++ config/alpha/alpha.c	(working copy)
@@ -6317,8 +6317,6 @@  enum alpha_builtin
   ALPHA_BUILTIN_AMASK,
   ALPHA_BUILTIN_IMPLVER,
   ALPHA_BUILTIN_RPCC,
-  ALPHA_BUILTIN_THREAD_POINTER,
-  ALPHA_BUILTIN_SET_THREAD_POINTER,
   ALPHA_BUILTIN_ESTABLISH_VMS_CONDITION_HANDLER,
   ALPHA_BUILTIN_REVERT_VMS_CONDITION_HANDLER,
 
@@ -6374,8 +6372,6 @@  static enum insn_code const code_for_builtin[ALPHA
   CODE_FOR_builtin_amask,
   CODE_FOR_builtin_implver,
   CODE_FOR_builtin_rpcc,
-  CODE_FOR_load_tp,
-  CODE_FOR_set_tp,
   CODE_FOR_builtin_establish_vms_condition_handler,
   CODE_FOR_builtin_revert_vms_condition_handler,
 
@@ -6533,14 +6529,6 @@  alpha_init_builtins (void)
 				    alpha_dimode_u, NULL_TREE);
   alpha_add_builtins (two_arg_builtins, ARRAY_SIZE (two_arg_builtins), ftype);
 
-  ftype = build_function_type_list (ptr_type_node, NULL_TREE);
-  alpha_builtin_function ("__builtin_thread_pointer", ftype,
-			  ALPHA_BUILTIN_THREAD_POINTER, ECF_NOTHROW);
-
-  ftype = build_function_type_list (void_type_node, ptr_type_node, NULL_TREE);
-  alpha_builtin_function ("__builtin_set_thread_pointer", ftype,
-			  ALPHA_BUILTIN_SET_THREAD_POINTER, ECF_NOTHROW);
-
   if (TARGET_ABI_OPEN_VMS)
     {
       ftype = build_function_type_list (ptr_type_node, ptr_type_node,
@@ -6645,7 +6633,20 @@  alpha_expand_builtin (tree exp, rtx target,
     return const0_rtx;
 }
 
+static rtx
+alpha_expand_builtin_thread_pointer (rtx target)
+{
+  emit_insn (gen_load_tp (target));
+  return target;
+}
 
+static void
+alpha_expand_builtin_set_thread_pointer (rtx val)
+{
+  emit_insn (gen_set_tp (val));
+}
+
+
 /* Several bits below assume HWI >= 64 bits.  This should be enforced
    by config.gcc.  */
 #if HOST_BITS_PER_WIDE_INT < 64
@@ -7077,8 +7078,6 @@  alpha_fold_builtin (tree fndecl, int n_args, tree
     case ALPHA_BUILTIN_AMASK:
     case ALPHA_BUILTIN_IMPLVER:
     case ALPHA_BUILTIN_RPCC:
-    case ALPHA_BUILTIN_THREAD_POINTER:
-    case ALPHA_BUILTIN_SET_THREAD_POINTER:
       /* None of these are foldable at compile-time.  */
     default:
       return NULL;
@@ -9811,6 +9810,11 @@  alpha_conditional_register_usage (void)
 #undef TARGET_EXPAND_BUILTIN_VA_START
 #define TARGET_EXPAND_BUILTIN_VA_START alpha_va_start
 
+#undef TARGET_EXPAND_BUILTIN_THREAD_POINTER
+#define TARGET_EXPAND_BUILTIN_THREAD_POINTER alpha_expand_builtin_thread_pointer
+#undef TARGET_EXPAND_BUILTIN_SET_THREAD_POINTER
+#define TARGET_EXPAND_BUILTIN_SET_THREAD_POINTER alpha_expand_builtin_set_thread_pointer
+
 /* The Alpha architecture does not require sequential consistency.  See
    http://www.cs.umd.edu/~pugh/java/memoryModel/AlphaReordering.html
    for an example of how it can be violated in practice.  */