[PATCH] D19582: [X86] Add support for llvm.thread.pointer
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Wed May 4 11:59:43 PDT 2016
This is missing documentation. It *looks* like you're trying to get the
thread local storage pointer. Is that correct? This can't be reviewed
without context and documented intent.
Philip
On 04/27/2016 01:27 AM, Marcin KoĆcielnicki via llvm-commits wrote:
> koriakin created this revision.
> koriakin added reviewers: nadav, bruno.
> koriakin added a subscriber: llvm-commits.
> koriakin set the repository for this revision to rL LLVM.
>
> This will be used for __builtin_thread_pointer in clang.
>
> Repository:
> rL LLVM
>
> http://reviews.llvm.org/D19582
>
> Files:
> lib/Target/X86/X86ISelLowering.cpp
> test/CodeGen/X86/thread-pointer.ll
>
> Index: test/CodeGen/X86/thread-pointer.ll
> ===================================================================
> --- /dev/null
> +++ test/CodeGen/X86/thread-pointer.ll
> @@ -0,0 +1,12 @@
> +; RUN: llc < %s -mtriple=i386-unknown-linux | FileCheck %s --check-prefix=CHECK-32
> +; RUN: llc < %s -mtriple=x86_64-unknown-linux | FileCheck %s --check-prefix=CHECK-64
> +
> +; Function Attrs: nounwind readnone
> +declare i8* @llvm.thread.pointer() #1
> +
> +define i8* @thread_pointer() {
> +; CHECK-32: movl %gs:0, %eax
> +; CHECK-64: movq %fs:0, %rax
> + %1 = tail call i8* @llvm.thread.pointer()
> + ret i8* %1
> +}
> Index: lib/Target/X86/X86ISelLowering.cpp
> ===================================================================
> --- lib/Target/X86/X86ISelLowering.cpp
> +++ lib/Target/X86/X86ISelLowering.cpp
> @@ -17818,6 +17818,17 @@
> Reg = RegInfo->getPtrSizedFrameRegister(MF);
> return DAG.getCopyFromReg(DAG.getEntryNode(), dl, Reg, VT);
> }
> +
> + case Intrinsic::thread_pointer: {
> + const TargetLowering &TLI = DAG.getTargetLoweringInfo();
> + EVT PtrVT = TLI.getPointerTy(DAG.getDataLayout());
> + // Get the Thread Pointer, which is %gs:0 (32-bit) or %fs:0 (64-bit).
> + Value *Ptr = Constant::getNullValue(
> + Type::getInt8PtrTy(*DAG.getContext(), Subtarget.is64Bit() ? 257 : 256));
> + return DAG.getLoad(PtrVT, dl, DAG.getEntryNode(),
> + DAG.getIntPtrConstant(0, dl),
> + MachinePointerInfo(Ptr), false, false, false, 0);
> + }
> }
> }
>
>
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160504/950db64f/attachment.html>
More information about the llvm-commits
mailing list