[PATCH] CodeGen: improve ms instrincics support
Reid Kleckner
rnk at google.com
Wed Jun 18 11:41:51 PDT 2014
lgtm with some nits
================
Comment at: include/clang/Basic/Builtins.def:690
@@ -688,1 +689,3 @@
LANGBUILTIN(_InterlockedExchangeAdd, "LiLiD*Li", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_InterlockedExchangePointer, "v*v*D*v*", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_InterlockedExchange, "LiLiD*Li", "n", ALL_MS_LANGUAGES)
----------------
MSVC doesn't provide this in 32-bit mode, but I think we can go ahead and do that anyway.
================
Comment at: lib/CodeGen/CGBuiltin.cpp:1523
@@ +1522,3 @@
+ }
+ case Builtin::BI_InterlockedCompareExchangePointer: {
+ llvm::Type *RTy;
----------------
I'd like this to be factored better, but I can live with it as is.
================
Comment at: lib/CodeGen/CGBuiltin.cpp:1535
@@ +1534,3 @@
+ RTy = Exchange->getType();
+ Exchange = Builder.CreatePtrToInt(Exchange, CGM.Int32Ty);
+
----------------
CGM.Int32Ty doesn't seem correct for x64, it should be IntType.
================
Comment at: lib/CodeGen/CGBuiltin.cpp:1537
@@ +1536,3 @@
+
+ llvm::Value *Comparend =
+ Builder.CreatePtrToInt(EmitScalarExpr(E->getArg(2)), CGM.Int32Ty);
----------------
MSDN says "Comparand" with an 'a'.
================
Comment at: lib/CodeGen/CGBuiltin.cpp:1540
@@ +1539,3 @@
+
+ Value *Result = Builder.CreateAtomicCmpXchg(Destination, Comparend,
+ Exchange,
----------------
MSDN says the 'Dest' is volatile, so I'd call Result->setVolatile(true) here.
http://reviews.llvm.org/D4182
More information about the cfe-commits
mailing list