[clang] [flang] [RFC][flang][runtime] Add FortranFloat128Math wrapper library. (PR #81971)
Steve Scalpone via cfe-commits
cfe-commits at lists.llvm.org
Sat Feb 17 17:57:21 PST 2024
================
@@ -657,10 +657,61 @@ static llvm::cl::opt<bool>
"instead of libm complex operations"),
llvm::cl::init(false));
+/// Return a string containing the given Fortran intrinsic name
+/// with the type of its arguments specified in funcType
+/// surrounded by the given prefix/suffix.
+static std::string
+prettyPrintIntrinsicName(fir::FirOpBuilder &builder, mlir::Location loc,
+ llvm::StringRef prefix, llvm::StringRef name,
+ llvm::StringRef suffix, mlir::FunctionType funcType) {
+ std::string output = prefix.str();
+ llvm::raw_string_ostream sstream(output);
+ if (name == "pow") {
+ assert(funcType.getNumInputs() == 2 && "power operator has two arguments");
+ std::string displayName{" ** "};
+ sstream << numericMlirTypeToFortran(builder, funcType.getInput(0), loc,
+ displayName)
+ << displayName
+ << numericMlirTypeToFortran(builder, funcType.getInput(1), loc,
+ displayName);
+ } else {
+ sstream << name.upper() << "(";
+ if (funcType.getNumInputs() > 0)
+ sstream << numericMlirTypeToFortran(builder, funcType.getInput(0), loc,
+ name);
+ for (mlir::Type argType : funcType.getInputs().drop_front()) {
+ sstream << ", " << numericMlirTypeToFortran(builder, argType, loc, name);
+ }
+ sstream << ")";
+ }
+ sstream << suffix;
+ return output;
+}
+
+// Generate a call to the Fortran runtime library providing
+// support for 128-bit float math via a third-party library.
+// If the compiler is built without FLANG_RUNTIME_F128_MATH_LIB,
+// this function will report an error.
+static mlir::Value genLibF128Call(fir::FirOpBuilder &builder,
+ mlir::Location loc,
+ const MathOperation &mathOp,
+ mlir::FunctionType libFuncType,
+ llvm::ArrayRef<mlir::Value> args) {
+#ifndef FLANG_RUNTIME_F128_MATH_LIB
+ std::string message = prettyPrintIntrinsicName(
+ builder, loc, "compiler is built without support for '", mathOp.key, "'",
----------------
sscalpone wrote:
OK for this message to use a form with "not yet implemented:"?
https://github.com/llvm/llvm-project/pull/81971
More information about the cfe-commits
mailing list