[llvm] Implement support for OP_TLS_GET_REG on osx/amd64.
authorZoltan Varga <vargaz@gmail.com>
Tue, 19 Nov 2013 11:05:04 +0000 (12:05 +0100)
committerZoltan Varga <vargaz@gmail.com>
Tue, 19 Nov 2013 11:05:04 +0000 (12:05 +0100)
mono/mini/mini-llvm.c

index 0f91727befe573f3a3262996db4f14ce34138b76..6f9ca9ee2fd634b24b441c31fa6332a3532b853d 100644 (file)
@@ -3354,6 +3354,22 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb)
 
                        break;
                }
+               case OP_TLS_GET_REG: {
+#if defined(TARGET_AMD64) && defined(TARGET_OSX)
+                       /* See emit_tls_get_reg () */
+                       LLVMValueRef base, shifted_offset, offset;
+                       
+                       base = LLVMConstInt (LLVMInt32Type (), mono_amd64_get_tls_gs_offset (), TRUE);
+                       shifted_offset = LLVMBuildMul (builder, convert (ctx, lhs, LLVMInt32Type ()), LLVMConstInt (LLVMInt32Type (), 8, TRUE), "");
+                       offset = LLVMBuildAdd (builder, base, shifted_offset, "");
+                       // 256 == GS segment register
+                       LLVMTypeRef ptrtype = LLVMPointerType (IntPtrType (), 256);
+                       values [ins->dreg] = LLVMBuildLoad (builder, LLVMBuildIntToPtr (builder, offset, ptrtype, ""), "");
+#else
+                       LLVM_FAILURE (ctx, "opcode tls-get");
+#endif
+                       break;
+               }
 
                        /*
                         * Overflow opcodes.