alpha.c (ALPHA_BUILTIN_THREAD_POINTER): New.
authorRichard Henderson <rth@redhat.com>
Wed, 12 Jun 2002 02:57:02 +0000 (19:57 -0700)
committerRichard Henderson <rth@gcc.gnu.org>
Wed, 12 Jun 2002 02:57:02 +0000 (19:57 -0700)
        * config/alpha/alpha.c (ALPHA_BUILTIN_THREAD_POINTER): New.
        (ALPHA_BUILTIN_SET_THREAD_POINTER): New.
        (code_for_builtns): Update.
        (alpha_init_builtins): Add __builtin_thread_pointer and
        __builtin_set_thread_pointer.
        (alpha_expand_builtin): Handle void builtins.
        * doc/extend.texi (Alpha Built-in Functions): Update.

From-SVN: r54543

gcc/ChangeLog
gcc/config/alpha/alpha.c
gcc/doc/extend.texi

index e777c5f4673343b36664e6f4078ce2c73f40c980..01d3cc680a69582808b5d498da2ba6e166a83b9a 100644 (file)
@@ -1,3 +1,13 @@
+2002-06-11  Richard Henderson  <rth@redhat.com>
+
+       * config/alpha/alpha.c (ALPHA_BUILTIN_THREAD_POINTER): New.
+       (ALPHA_BUILTIN_SET_THREAD_POINTER): New.
+       (code_for_builtns): Update.
+       (alpha_init_builtins): Add __builtin_thread_pointer and
+       __builtin_set_thread_pointer.
+       (alpha_expand_builtin): Handle void builtins.
+       * doc/extend.texi (Alpha Built-in Functions): Update.
+
 2002-06-11  Hans-Peter Nilsson  <hp@axis.com>
 
        PR target/6997
index 543d9d044b5103e2280f6d2a3c7fd010b7b28966..24e8c5c5eda762ba755dee2c949ae130b6043df2 100644 (file)
@@ -6345,6 +6345,8 @@ enum alpha_builtin
   ALPHA_BUILTIN_AMASK,
   ALPHA_BUILTIN_IMPLVER,
   ALPHA_BUILTIN_RPCC,
+  ALPHA_BUILTIN_THREAD_POINTER,
+  ALPHA_BUILTIN_SET_THREAD_POINTER,
 
   /* TARGET_MAX */
   ALPHA_BUILTIN_MINUB8,
@@ -6398,6 +6400,8 @@ static unsigned int const code_for_builtin[ALPHA_BUILTIN_max] = {
   CODE_FOR_builtin_amask,
   CODE_FOR_builtin_implver,
   CODE_FOR_builtin_rpcc,
+  CODE_FOR_load_tp,
+  CODE_FOR_set_tp,
 
   /* TARGET_MAX */
   CODE_FOR_builtin_minub8,
@@ -6515,6 +6519,16 @@ alpha_init_builtins ()
   for (i = 0; i < ARRAY_SIZE (two_arg_builtins); ++i, ++p)
     if ((target_flags & p->target_mask) == p->target_mask)
       builtin_function (p->name, ftype, p->code, BUILT_IN_MD, NULL);
+
+  ftype = build_function_type (ptr_type_node, void_list_node);
+  builtin_function ("__builtin_thread_pointer", ftype,
+                   ALPHA_BUILTIN_THREAD_POINTER, BUILT_IN_MD, NULL);
+
+  ftype = build_function_type (void_type_node, tree_cons (NULL_TREE,
+                                                         ptr_type_node,
+                                                         void_list_node));
+  builtin_function ("__builtin_set_thread_pointer", ftype,
+                   ALPHA_BUILTIN_SET_THREAD_POINTER, BUILT_IN_MD, NULL);
 }
 
 /* Expand an expression EXP that calls a built-in function,
@@ -6539,7 +6553,7 @@ alpha_expand_builtin (exp, target, subtarget, mode, ignore)
   enum insn_code icode;
   rtx op[MAX_ARGS], pat;
   int arity;
-  enum machine_mode tmode;
+  bool nonvoid;
 
   if (fcode >= ALPHA_BUILTIN_max)
     internal_error ("bad builtin fcode");
@@ -6547,6 +6561,8 @@ alpha_expand_builtin (exp, target, subtarget, mode, ignore)
   if (icode == 0)
     internal_error ("bad builtin fcode");
 
+  nonvoid = TREE_TYPE (TREE_TYPE (fndecl)) != void_type_node;
+
   for (arglist = TREE_OPERAND (exp, 1), arity = 0;
        arglist;
        arglist = TREE_CHAIN (arglist), arity++)
@@ -6559,18 +6575,22 @@ alpha_expand_builtin (exp, target, subtarget, mode, ignore)
       if (arity > MAX_ARGS)
        return NULL_RTX;
 
-      op[arity] = expand_expr (arg, NULL_RTX, VOIDmode, 0);
+      insn_op = &insn_data[icode].operand[arity + nonvoid];
+
+      op[arity] = expand_expr (arg, NULL_RTX, insn_op->mode, 0);
 
-      insn_op = &insn_data[icode].operand[arity + 1];
       if (!(*insn_op->predicate) (op[arity], insn_op->mode))
        op[arity] = copy_to_mode_reg (insn_op->mode, op[arity]);
     }
 
-  tmode = insn_data[icode].operand[0].mode;
-  if (!target
-      || GET_MODE (target) != tmode
-      || !(*insn_data[icode].operand[0].predicate) (target, tmode))
-    target = gen_reg_rtx (tmode);
+  if (nonvoid)
+    {
+      enum machine_mode tmode = insn_data[icode].operand[0].mode;
+      if (!target
+         || GET_MODE (target) != tmode
+         || !(*insn_data[icode].operand[0].predicate) (target, tmode))
+       target = gen_reg_rtx (tmode);
+    }
 
   switch (arity)
     {
@@ -6578,7 +6598,10 @@ alpha_expand_builtin (exp, target, subtarget, mode, ignore)
       pat = GEN_FCN (icode) (target);
       break;
     case 1:
-      pat = GEN_FCN (icode) (target, op[0]);
+      if (nonvoid)
+        pat = GEN_FCN (icode) (target, op[0]);
+      else
+       pat = GEN_FCN (icode) (op[0]);
       break;
     case 2:
       pat = GEN_FCN (icode) (target, op[0], op[1]);
@@ -6590,7 +6613,10 @@ alpha_expand_builtin (exp, target, subtarget, mode, ignore)
     return NULL_RTX;
   emit_insn (pat);
 
-  return target;
+  if (nonvoid)
+    return target;
+  else
+    return const0_rtx;
 }
 \f
 /* This page contains routines that are used to determine what the function
index 76aa540806576f992ab391997102a780733dcb95..68d231db05a2fe4503313690e06396ec6ee62d79 100644 (file)
@@ -4834,6 +4834,16 @@ long __builtin_alpha_ctlz (long)
 long __builtin_alpha_ctpop (long)
 @end example
 
+The following builtins are available on systems that use the OSF/1
+PALcode.  Normally they invoke the @code{rduniq} and @code{wruniq}
+PAL calls, but when invoked with @option{-mtls-kernel}, they invoke
+@code{rdval} and @code{wrval}.
+
+@example
+void *__builtin_thread_pointer (void)
+void __builtin_set_thread_pointer (void *)
+@end example
+
 @node X86 Built-in Functions
 @subsection X86 Built-in Functions