summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2014-10-29 16:35:41 +0000
committerSaleem Abdulrasool <compnerd@compnerd.org>2014-10-29 16:35:41 +0000
commita25fbef08857ff0991877bb11e69a25943406915 (patch)
tree1f892bfb27e5f08fbfc45205d451c4a7cfa5f7cb /clang/lib
parent595e598869ec8c0650d57cff15842c94904163cc (diff)
downloadbcm5719-llvm-a25fbef08857ff0991877bb11e69a25943406915.tar.gz
bcm5719-llvm-a25fbef08857ff0991877bb11e69a25943406915.zip
CodeGen: add __readfsdword builtin
The Windows NT SDK uses __readfsdword and declares it as a compiler provided builtin (#pragma intrinsic(__readfsword). Because intrin.h is not referenced by winnt.h, it is not possible to provide an out-of-line definition for the intrinsic. Provide a proper compiler builtin definition. llvm-svn: 220859
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/CodeGen/CGBuiltin.cpp8
-rw-r--r--clang/lib/Headers/Intrin.h4
2 files changed, 8 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index c4f92edc8a8..5cacfa12a47 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -1624,6 +1624,14 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
RMWI->setVolatile(true);
return RValue::get(RMWI);
}
+ case Builtin::BI__readfsdword: {
+ Value *IntToPtr =
+ Builder.CreateIntToPtr(EmitScalarExpr(E->getArg(0)),
+ llvm::PointerType::get(CGM.Int32Ty, 257));
+ LoadInst *Load =
+ Builder.CreateAlignedLoad(IntToPtr, /*Align=*/4, /*isVolatile=*/true);
+ return RValue::get(Load);
+ }
}
// If this is an alias for a lib function (e.g. __builtin_sin), emit
diff --git a/clang/lib/Headers/Intrin.h b/clang/lib/Headers/Intrin.h
index 13e105ec178..d5c334b2da1 100644
--- a/clang/lib/Headers/Intrin.h
+++ b/clang/lib/Headers/Intrin.h
@@ -861,10 +861,6 @@ static __inline__ unsigned char __attribute__((__always_inline__, __nodebug__))
__readfsbyte(unsigned long __offset) {
return *__ptr_to_addr_space(257, unsigned char, __offset);
}
-static __inline__ unsigned long __attribute__((__always_inline__, __nodebug__))
-__readfsdword(unsigned long __offset) {
- return *__ptr_to_addr_space(257, unsigned long, __offset);
-}
static __inline__ unsigned __int64 __attribute__((__always_inline__, __nodebug__))
__readfsqword(unsigned long __offset) {
return *__ptr_to_addr_space(257, unsigned __int64, __offset);
OpenPOWER on IntegriCloud