diff options
author | Mark Seaborn <mseaborn@chromium.org> | 2012-11-08 07:18:03 -0800 |
---|---|---|
committer | Mark Seaborn <mseaborn@chromium.org> | 2012-11-08 07:18:03 -0800 |
commit | ab80f55fb9bc042c115479c3b5debd86d3b72a6f (patch) | |
tree | 639d06f367080c0a049a12d292e04f78aff523ff /include | |
parent | 96b7ae0415ed0b161b66e57bb6092192ed330ec7 (diff) |
Add @nacl.read.tp() intrinsic, a fast version of NaCl's tls_get() IRT interface
This is in preparation for adding an LLVM pass that will expand out
TLS (thread_local) variable accesses into calls to nacl.read.tp.
On ARM, there is already an arm.thread.pointer intrinsic. We reuse
the code for that.
On x86, we have to add an implementation. The added code is based on
x86's LowerToTLSExecModel() for the %gs:0 case, and on NaCl-MIPS'
LowerGlobalTLSAddress() for the __nacl_read_tp() case. (In contrast,
X86NaClRewritePass.cpp inserts a __nacl_read_tp() call at the lower MI
level; we don't use that approach here.)
We convert LowerINTRINSIC_WO_CHAIN() into a method in order to access
the Subtarget member. This is consistent with other x86 Lower methods
and with the ARM version.
BUG=https://code.google.com/p/nativeclient/issues/detail?id=2837
TEST="llvm-lit test/NaCl"
Review URL: https://codereview.chromium.org/11383002
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/CodeGen/ISDOpcodes.h | 3 | ||||
-rw-r--r-- | include/llvm/Intrinsics.td | 4 |
2 files changed, 7 insertions, 0 deletions
diff --git a/include/llvm/CodeGen/ISDOpcodes.h b/include/llvm/CodeGen/ISDOpcodes.h index 95aafb324d..47170e4e58 100644 --- a/include/llvm/CodeGen/ISDOpcodes.h +++ b/include/llvm/CodeGen/ISDOpcodes.h @@ -643,6 +643,9 @@ namespace ISD { // @LOCALMOD-BEGIN // NACL_* - Native Client instrinsics. + // NACL_READ_TP is a fast built-in version of NaCl's tls_get() IRT + // interface. + NACL_READ_TP, // These correspond to functions in: // native_client/src/untrusted/nacl/tls_params.h NACL_TP_TLS_OFFSET, diff --git a/include/llvm/Intrinsics.td b/include/llvm/Intrinsics.td index 68d7d4cdf4..42b9da6914 100644 --- a/include/llvm/Intrinsics.td +++ b/include/llvm/Intrinsics.td @@ -467,6 +467,10 @@ def int_nacl_setjmp : Intrinsic<[llvm_i32_ty], [llvm_ptr_ty, llvm_ptr_ty]>, def int_nacl_longjmp : Intrinsic<[], [llvm_ptr_ty, llvm_i32_ty]>, GCCBuiltin<"__builtin_nacl_longjmp">; +// Fast built-in version of NaCl's tls_get() IRT interface. +def int_nacl_read_tp : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>, + GCCBuiltin<"__builtin_nacl_read_tp">; + // The following intrinsics provide target-specific implementations of // the interface in native_client/src/untrusted/nacl/tls_params.h. // The intrinsic names are basically the functions there without the |