forked from OSchip/llvm-project
ConstrainedFP: use API compatible with opaque pointers.
This just updates an IRBuilder interface to take Functions instead of Values so the type can be derived, and fixes some callsites in Clang to call the updated API.
This commit is contained in:
parent
50c3bd9e71
commit
85cb560b8a
|
@ -368,10 +368,10 @@ static Value *emitUnaryMaybeConstrainedFPBuiltin(CodeGenFunction &CGF,
|
||||||
llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
|
llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
|
||||||
|
|
||||||
if (CGF.Builder.getIsFPConstrained()) {
|
if (CGF.Builder.getIsFPConstrained()) {
|
||||||
Value *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, Src0->getType());
|
Function *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, Src0->getType());
|
||||||
return CGF.Builder.CreateConstrainedFPCall(F, { Src0 });
|
return CGF.Builder.CreateConstrainedFPCall(F, { Src0 });
|
||||||
} else {
|
} else {
|
||||||
Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
|
Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
|
||||||
return CGF.Builder.CreateCall(F, Src0);
|
return CGF.Builder.CreateCall(F, Src0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -385,10 +385,10 @@ static Value *emitBinaryMaybeConstrainedFPBuiltin(CodeGenFunction &CGF,
|
||||||
llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1));
|
llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1));
|
||||||
|
|
||||||
if (CGF.Builder.getIsFPConstrained()) {
|
if (CGF.Builder.getIsFPConstrained()) {
|
||||||
Value *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, Src0->getType());
|
Function *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, Src0->getType());
|
||||||
return CGF.Builder.CreateConstrainedFPCall(F, { Src0, Src1 });
|
return CGF.Builder.CreateConstrainedFPCall(F, { Src0, Src1 });
|
||||||
} else {
|
} else {
|
||||||
Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
|
Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
|
||||||
return CGF.Builder.CreateCall(F, { Src0, Src1 });
|
return CGF.Builder.CreateCall(F, { Src0, Src1 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -403,10 +403,10 @@ static Value *emitTernaryMaybeConstrainedFPBuiltin(CodeGenFunction &CGF,
|
||||||
llvm::Value *Src2 = CGF.EmitScalarExpr(E->getArg(2));
|
llvm::Value *Src2 = CGF.EmitScalarExpr(E->getArg(2));
|
||||||
|
|
||||||
if (CGF.Builder.getIsFPConstrained()) {
|
if (CGF.Builder.getIsFPConstrained()) {
|
||||||
Value *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, Src0->getType());
|
Function *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, Src0->getType());
|
||||||
return CGF.Builder.CreateConstrainedFPCall(F, { Src0, Src1, Src2 });
|
return CGF.Builder.CreateConstrainedFPCall(F, { Src0, Src1, Src2 });
|
||||||
} else {
|
} else {
|
||||||
Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
|
Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
|
||||||
return CGF.Builder.CreateCall(F, { Src0, Src1, Src2 });
|
return CGF.Builder.CreateCall(F, { Src0, Src1, Src2 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2421,18 +2421,16 @@ public:
|
||||||
Args, OpBundles, Name, FPMathTag);
|
Args, OpBundles, Name, FPMathTag);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated [opaque pointer types]
|
|
||||||
CallInst *CreateConstrainedFPCall(
|
CallInst *CreateConstrainedFPCall(
|
||||||
Value *Callee, ArrayRef<Value *> Args, const Twine &Name = "",
|
Function *Callee, ArrayRef<Value *> Args, const Twine &Name = "",
|
||||||
Optional<fp::RoundingMode> Rounding = None,
|
Optional<fp::RoundingMode> Rounding = None,
|
||||||
Optional<fp::ExceptionBehavior> Except = None) {
|
Optional<fp::ExceptionBehavior> Except = None) {
|
||||||
llvm::SmallVector<Value *, 6> UseArgs;
|
llvm::SmallVector<Value *, 6> UseArgs;
|
||||||
|
|
||||||
for (auto *OneArg : Args)
|
for (auto *OneArg : Args)
|
||||||
UseArgs.push_back(OneArg);
|
UseArgs.push_back(OneArg);
|
||||||
Function *F = cast<Function>(Callee);
|
|
||||||
bool HasRoundingMD = false;
|
bool HasRoundingMD = false;
|
||||||
switch (F->getIntrinsicID()) {
|
switch (Callee->getIntrinsicID()) {
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
#define INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC, DAGN) \
|
#define INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC, DAGN) \
|
||||||
|
@ -2445,9 +2443,7 @@ public:
|
||||||
UseArgs.push_back(getConstrainedFPRounding(Rounding));
|
UseArgs.push_back(getConstrainedFPRounding(Rounding));
|
||||||
UseArgs.push_back(getConstrainedFPExcept(Except));
|
UseArgs.push_back(getConstrainedFPExcept(Except));
|
||||||
|
|
||||||
CallInst *C = CreateCall(
|
CallInst *C = CreateCall(Callee, UseArgs, Name);
|
||||||
cast<FunctionType>(Callee->getType()->getPointerElementType()), Callee,
|
|
||||||
UseArgs, Name);
|
|
||||||
setConstrainedFPCallAttr(C);
|
setConstrainedFPCallAttr(C);
|
||||||
return C;
|
return C;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue