[cfe-commits] Atomic builtin patch
Chris Lattner
clattner at apple.com
Mon May 5 17:00:51 PDT 2008
On May 5, 2008, at 3:06 PM, Mon P Wang wrote:
> Hi,
>
> I plan to checkin the following change to add support for sub, and,
> or, xor, min and max (the latter two in both signed and unsigned
> version) to clang. In generates the llvm intrinsic
> __sync_fetch_and_[opname]. Please let me know if you have any
> issues or concerns.
Looks great to me, one minor change then please commit:
+static RValue EmitBinaryAtomic(CodeGenFunction& CFG,
+ Intrinsic::ID Id, const CallExpr *E) {
+ Value *Args[2];
+ Args[0]= CFG.EmitScalarExpr(E->getArg(0));
+ Args[1] = CFG.EmitScalarExpr(E->getArg(1));
+ const llvm::Type *ResType = CFG.ConvertType(E->getType());
+ Value *AtomF = CFG.CGM.getIntrinsic(Id, &ResType, 1);
+ return RValue::get(CFG.Builder.CreateCall(AtomF, &Args[0],
&Args[1]+1));
This can use Builder.CreateCall2(AtomF, x, y)
to avoid creating the temporary args array.
-Chris
More information about the cfe-commits
mailing list