[llvm-branch-commits] [cfe-branch] r71671 - in /cfe/branches/Apple/Dib: lib/CodeGen/CGBuiltin.cpp test/CodeGen/atomic.c
Mike Stump
mrs at apple.com
Wed May 13 08:39:46 PDT 2009
Author: mrs
Date: Wed May 13 10:39:41 2009
New Revision: 71671
URL: http://llvm.org/viewvc/llvm-project?rev=71671&view=rev
Log:
Merge in 71637:
implement __sync_synchronize and __sync_lock_release,
rdar://6880573
Modified:
cfe/branches/Apple/Dib/lib/CodeGen/CGBuiltin.cpp
cfe/branches/Apple/Dib/test/CodeGen/atomic.c
Modified: cfe/branches/Apple/Dib/lib/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/lib/CodeGen/CGBuiltin.cpp?rev=71671&r1=71670&r2=71671&view=diff
==============================================================================
--- cfe/branches/Apple/Dib/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/branches/Apple/Dib/lib/CodeGen/CGBuiltin.cpp Wed May 13 10:39:41 2009
@@ -470,11 +470,23 @@
case Builtin::BI__sync_lock_release_2:
case Builtin::BI__sync_lock_release_4:
case Builtin::BI__sync_lock_release_8:
- case Builtin::BI__sync_lock_release_16:
- assert(0 && "FIXME: Implement");
+ case Builtin::BI__sync_lock_release_16: {
+ Value *Ptr = EmitScalarExpr(E->getArg(0));
+ const llvm::Type *ElTy =
+ cast<llvm::PointerType>(Ptr->getType())->getElementType();
+ Builder.CreateStore(llvm::Constant::getNullValue(ElTy), Ptr, true);
+ return RValue();
+ }
+ case Builtin::BI__sync_synchronize: {
+ Value *C[5];
+ C[0] = C[1] = C[2] = C[3] = llvm::ConstantInt::get(llvm::Type::Int1Ty, 1);
+ C[4] = ConstantInt::get(llvm::Type::Int1Ty, 0);
+ Builder.CreateCall(CGM.getIntrinsic(Intrinsic::memory_barrier), C, C + 5);
+ return RValue();
+ }
+
// Library functions with special handling.
-
case Builtin::BIsqrt:
case Builtin::BIsqrtf:
case Builtin::BIsqrtl: {
Modified: cfe/branches/Apple/Dib/test/CodeGen/atomic.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/test/CodeGen/atomic.c?rev=71671&r1=71670&r2=71671&view=diff
==============================================================================
--- cfe/branches/Apple/Dib/test/CodeGen/atomic.c (original)
+++ cfe/branches/Apple/Dib/test/CodeGen/atomic.c Wed May 13 10:39:41 2009
@@ -33,15 +33,21 @@
old = __sync_fetch_and_and(&val, 0x9);
old = __sync_fetch_and_or(&val, 0xa);
old = __sync_fetch_and_xor(&val, 0xb);
+ old = __sync_fetch_and_nand(&val, 0xb);
old = __sync_add_and_fetch(&val, 1);
old = __sync_sub_and_fetch(&val, 2);
old = __sync_and_and_fetch(&valc, 3);
old = __sync_or_and_fetch(&valc, 4);
old = __sync_xor_and_fetch(&valc, 5);
+ old = __sync_nand_and_fetch(&valc, 5);
__sync_val_compare_and_swap((void **)0, (void *)0, (void *)0);
+
+ __sync_lock_release(&val);
+ __sync_synchronize ();
+
return old;
}
More information about the llvm-branch-commits
mailing list