diff options
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/CGBuiltin.cpp | 52 |
1 files changed, 38 insertions, 14 deletions
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 6a8610973ee..9e6385e2a16 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -1963,7 +1963,10 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, EmitScalarExpr(Call->getCallee()), Call, ReturnValue, Call->getCalleeDecl(), EmitScalarExpr(Chain)); } + case Builtin::BI_InterlockedExchange8: + case Builtin::BI_InterlockedExchange16: case Builtin::BI_InterlockedExchange: + case Builtin::BI_InterlockedExchange64: case Builtin::BI_InterlockedExchangePointer: return EmitBinaryAtomic(*this, llvm::AtomicRMWInst::Xchg, E); case Builtin::BI_InterlockedCompareExchangePointer: { @@ -1993,7 +1996,10 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, 0), RTy)); } - case Builtin::BI_InterlockedCompareExchange: { + case Builtin::BI_InterlockedCompareExchange8: + case Builtin::BI_InterlockedCompareExchange16: + case Builtin::BI_InterlockedCompareExchange: + case Builtin::BI_InterlockedCompareExchange64: { AtomicCmpXchgInst *CXI = Builder.CreateAtomicCmpXchg( EmitScalarExpr(E->getArg(0)), EmitScalarExpr(E->getArg(2)), @@ -2003,35 +2009,53 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, CXI->setVolatile(true); return RValue::get(Builder.CreateExtractValue(CXI, 0)); } - case Builtin::BI_InterlockedIncrement: { + case Builtin::BI_InterlockedIncrement16: + case Builtin::BI_InterlockedIncrement: + case Builtin::BI_InterlockedIncrement64: { llvm::Type *IntTy = ConvertType(E->getType()); AtomicRMWInst *RMWI = Builder.CreateAtomicRMW( AtomicRMWInst::Add, EmitScalarExpr(E->getArg(0)), ConstantInt::get(IntTy, 1), llvm::AtomicOrdering::SequentiallyConsistent); - RMWI->setVolatile(true); return RValue::get(Builder.CreateAdd(RMWI, ConstantInt::get(IntTy, 1))); } - case Builtin::BI_InterlockedDecrement: { + case Builtin::BI_InterlockedDecrement16: + case Builtin::BI_InterlockedDecrement: + case Builtin::BI_InterlockedDecrement64: { llvm::Type *IntTy = ConvertType(E->getType()); AtomicRMWInst *RMWI = Builder.CreateAtomicRMW( AtomicRMWInst::Sub, EmitScalarExpr(E->getArg(0)), ConstantInt::get(IntTy, 1), llvm::AtomicOrdering::SequentiallyConsistent); - RMWI->setVolatile(true); return RValue::get(Builder.CreateSub(RMWI, ConstantInt::get(IntTy, 1))); } - case Builtin::BI_InterlockedExchangeAdd: { - AtomicRMWInst *RMWI = Builder.CreateAtomicRMW( - AtomicRMWInst::Add, - EmitScalarExpr(E->getArg(0)), - EmitScalarExpr(E->getArg(1)), - llvm::AtomicOrdering::SequentiallyConsistent); - RMWI->setVolatile(true); - return RValue::get(RMWI); - } + case Builtin::BI_InterlockedAnd8: + case Builtin::BI_InterlockedAnd16: + case Builtin::BI_InterlockedAnd: + case Builtin::BI_InterlockedAnd64: + return EmitBinaryAtomic(*this, AtomicRMWInst::And, E); + case Builtin::BI_InterlockedExchangeAdd8: + case Builtin::BI_InterlockedExchangeAdd16: + case Builtin::BI_InterlockedExchangeAdd: + case Builtin::BI_InterlockedExchangeAdd64: + return EmitBinaryAtomic(*this, AtomicRMWInst::Add, E); + case Builtin::BI_InterlockedExchangeSub8: + case Builtin::BI_InterlockedExchangeSub16: + case Builtin::BI_InterlockedExchangeSub: + case Builtin::BI_InterlockedExchangeSub64: + return EmitBinaryAtomic(*this, AtomicRMWInst::Sub, E); + case Builtin::BI_InterlockedOr8: + case Builtin::BI_InterlockedOr16: + case Builtin::BI_InterlockedOr: + case Builtin::BI_InterlockedOr64: + return EmitBinaryAtomic(*this, AtomicRMWInst::Or, E); + case Builtin::BI_InterlockedXor8: + case Builtin::BI_InterlockedXor16: + case Builtin::BI_InterlockedXor: + case Builtin::BI_InterlockedXor64: + return EmitBinaryAtomic(*this, AtomicRMWInst::Xor, E); case Builtin::BI__readfsdword: { llvm::Type *IntTy = ConvertType(E->getType()); Value *IntToPtr = |