     (set_attr "modrm" "0")])
  
  (define_insn "return_indirect_internal"
-@@ -21562,9 +21949,11 @@
+@@ -15944,6 +16331,30 @@
+   operands[2] = ix86_tls_get_addr ();
+ })
+ 
++(define_insn "*naclcall_tls"
++  [(set (match_operand 0 "register_operand" "=a")
++	(call (mem:QI (match_operand:DI 2 "call_insn_operand" ""))
++		 (match_operand 3 "" "")))
++   (unspec:SI [(match_operand:SI 1 "tls_symbolic_operand" "")]
++	      UNSPEC_TPOFF)]
++  "TARGET_64BIT"
++  { return "mov{q}\t{$%a1@TPOFF, %%rdi|rdi, %a1@TPOFF}\n\tcall\t%P2"; }
++  [(set_attr "type" "multi")])
++
++(define_expand "naclcall_tls"
++  [(parallel [(set (match_operand 0 "" "")
++		   (call (mem:QI (match_dup 2)) (const_int 0)))
++	      (unspec:SI [(match_operand:SI 1 "tls_symbolic_operand" "")]
++			 UNSPEC_TPOFF)])]
++  "TARGET_64BIT"
++{
++  rtx op = gen_lowpart(SImode, operands[1]);
++  SYMBOL_REF_FLAGS(op) = SYMBOL_REF_FLAGS(operands[1]);
++  operands[1] = op;
++  operands[2] = ix86_tls_get_addr ();
++}
++)
++
+ (define_insn "*tls_local_dynamic_base_32_gnu"
+   [(set (match_operand:SI 0 "register_operand" "=a")
+ 	(unspec:SI [(match_operand:SI 1 "register_operand" "b")
+@@ -21562,9 +21973,11 @@
  	(call (mem:QI (match_operand:SI 1 "sibcall_insn_operand" "s,U"))
  	      (match_operand:SI 2 "" "")))]
    "SIBLING_CALL_P (insn) && !TARGET_64BIT"

       while (GET_CODE (op) == PLUS);
       if (n >= 4)
 	return 0;
@@ -8785,6 +8890,11 @@
 	      if (index)
 		return 0;
 	      index = XEXP (op, 0);

+int
+insn_is_nacl_lea(rtx insn)
+{
+  rtx body = PATTERN(insn);
+
+  if (!TARGET_64BIT)
