================
@@ -18,6 +18,90 @@
using namespace clang;
using namespace clang::CIRGen;
+using namespace cir;
+
+static mlir::Value emitBinaryExpMaybeConstrainedFPBuiltin(
+ CIRGenFunction &CGF, const CallExpr *E, llvm::StringRef IntrinsicName,
+ llvm::StringRef ConstrainedIntrinsicName) {
+ mlir::Value Src0 = CGF.emitScalarExpr(E->getArg(0));
+ mlir::Value Src1 = CGF.emitScalarExpr(E->getArg(1));
+
+ auto &Builder = CGF.getBuilder();
+
+ CIRGenFunction::CIRGenFPOptionsRAII FPOptsRAII(CGF, E);
+
+ if (Builder.getIsFPConstrained()) {
+ return cir::LLVMIntrinsicCallOp::create(
+ Builder, CGF.getLoc(E->getExprLoc()),
+ Builder.getStringAttr(ConstrainedIntrinsicName), Src0.getType(),
+ {Src0, Src1})
+ .getResult();
+ }
+
+ return cir::LLVMIntrinsicCallOp::create(Builder, CGF.getLoc(E->getExprLoc()),
+ Builder.getStringAttr(IntrinsicName),
+ Src0.getType(), {Src0, Src1})
+ .getResult();
+}
+
+static mlir::Value emitLogbBuiltin(CIRGenFunction &CGF, const CallExpr *E,
+ bool IsFloat) {
+ auto &Builder = CGF.getBuilder();
+ mlir::Location Loc = CGF.getLoc(E->getExprLoc());
+
+ mlir::Value Src0 = CGF.emitScalarExpr(E->getArg(0));
+ mlir::Type SrcTy = Src0.getType();
+ mlir::Type Int32Ty = Builder.getSInt32Ty();
+
+ cir::RecordType FrExpResTy =
+ Builder.getAnonRecordTy({SrcTy, Int32Ty}, false, false);
+
+ mlir::Value FrExpResult =
+ cir::LLVMIntrinsicCallOp::create(
+ Builder, Loc, Builder.getStringAttr("llvm.frexp"), FrExpResTy,
{Src0})
+ .getResult();
----------------
andykaylor wrote:
```suggestion
builder.emitIntrinsicCallOp(loc, "llvm.frexp", frExpResTy, {src0})
.getResult();
```
https://github.com/llvm/llvm-project/pull/191344
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits