Implement __builtin_thread_pointer for x86 TLS.
[gcc.git] / gcc / config / i386 / i386.md
index 446793b78db1e19f5f0b0ff2ffa44227431c9811..93aae8123fd5962a71a5b71fe6e0d0c947524c8a 100644 (file)
       (clobber (reg:CC FLAGS_REG))])])
 
 ;; Load and add the thread base pointer from %<tp_seg>:0.
+(define_expand "get_thread_pointer<mode>"
+  [(set (match_operand:PTR 0 "register_operand")
+       (unspec:PTR [(const_int 0)] UNSPEC_TP))]
+  ""
+{
+  /* targetm is not visible in the scope of the condition.  */
+  if (!targetm.have_tls)
+    error ("%<__builtin_thread_pointer%> is not supported on this target");
+})
+
 (define_insn_and_split "*load_tp_<mode>"
   [(set (match_operand:PTR 0 "register_operand" "=r")
        (unspec:PTR [(const_int 0)] UNSPEC_TP))]