Lines Matching +defs:number +defs:to +defs:string

61 /// MLIR operations, or as a call to a runtime function or LLVM intrinsic.
64 /// Fortran intrinsic generic names to FIR generator functions.
76 /// Test if an ExtendedValue is absent. This is used to test if an intrinsic
90 /// Test if an ExtendedValue is present. This is used to test if an intrinsic
93 /// deallocated allocatable. See `handleDynamicOptional` to deal with these
101 /// Flag to indicate that an intrinsic argument has to be handled as
107 /// module procedure one to one mapping with Fortran arguments. If no mapping is
109 /// to look for a match in the runtime a emit a call. Note that the argument
110 /// lowering rules for an intrinsic need to be provided only if at least one
120 {{{"string", asAddr}}},
124 {{{"string", asAddr}}},
296 {{{"number", asValue},
432 {{{"string", asAddr},
459 {{{"string", asInquired}, {"kind", asValue}}},
516 {"to", asInquired},
525 {"to", asAddr},
588 {{{"string", asAddr}, {"ncopies", asValue}}},
608 {{{"string", asAddr},
650 {{{"number", asValue}, {"handler", asAddr}, {"status", asAddr}}},
704 {"trim", &I::genTrim, {{{"string", asAddr}}}, /*isElemental=*/false},
717 {{{"string", asAddr},
759 /// Command line option to modify math runtime behavior used to implement
760 /// intrinsics. This option applies both to early and late math-lowering modes.
776 /// Return a string containing the given Fortran intrinsic name
779 static std::string
783 std::string output = prefix.str();
787 std::string displayName{" ** "};
808 // Generate a call to the Fortran runtime library providing
813 // has to be built with FLANG_RUNTIME_F128_MATH_LIB to guarantee
846 // C-interoperability rules apply to these library functions.
849 // Set fir.runtime attribute to distinguish the function that
871 // It is in general incorrect to use the same definition for the library
872 // call, but we have no other options. Type cast the function to match
873 // the requested signature and generate an indirect call to avoid
878 llvm::Twine("' may lead to undefined behavior.")));
899 assert(args.size() == 2 && "Incorrect #args to genLibSplitComplexArgsCall");
931 // TODO: we have to annotate the math operations with flags
932 // that will allow to define FP accuracy/exception
941 // * For "precise/strict" FP mode generate fir.calls to libm
948 // can be also lowered to libm calls for "fast" and "relaxed"
953 // Some operations do not have to be lowered as conservative
978 // If we have libm functions, we can attempt to generate the more precise
994 // Builder expects an extra return type to be provided if different to
1433 // and result of "from" must be made in order to use "to" instead of "from".
1436 // if no implementation of ACOS(REAL(10)) is available, it is better to use
1438 // Note that this is not a symmetric distance and the order of "from" and "to"
1440 // may be safe to replace foo by bar, but not the opposite.
1445 FunctionDistance(mlir::FunctionType from, mlir::FunctionType to) {
1448 if (nResults != to.getNumResults() || nInputs != to.getNumInputs()) {
1452 addArgumentDistance(from.getInput(i), to.getInput(i));
1454 addResultDistance(to.getResult(i), from.getResult(i));
1460 /// d1.isSmallerThan(d2) is not equivalent to !d2.isSmallerThan(d1)
1477 void addArgumentDistance(mlir::Type from, mlir::Type to) {
1478 switch (conversionBetweenTypes(from, to)) {
1493 void addResultDistance(mlir::Type from, mlir::Type to) {
1494 switch (conversionBetweenTypes(from, to)) {
1518 static Conversion conversionBetweenTypes(mlir::Type from, mlir::Type to) {
1519 if (from == to)
1523 if (auto toIntTy{mlir::dyn_cast<mlir::IntegerType>(to)}) {
1529 if (fir::isa_real(from) && fir::isa_real(to)) {
1530 return getFloatingPointWidth(from) > getFloatingPointWidth(to)
1535 if (fir::isa_complex(from) && fir::isa_complex(to)) {
1536 return getFloatingPointWidth(from) > getFloatingPointWidth(to)
1549 // Below are indexes to access data in conversions.
1560 bool infinite = false; // When forbidden conversion or wrong argument number
1567 /// Look for a MathOperation entry specifying how to lower a mathematical
1571 /// returns a pointer to the corresponding MathOperation.
1618 std::string message = prettyPrintIntrinsicName(
1624 /// Helpers to get function type from arguments and result type.
1638 /// fir::ExtendedValue to mlir::Value translation layer
1649 // FIXME: we may want to allow non character scalar here.
1693 // FIXME: need to access other ExtendedValue variants and handle them
1717 const std::string builtin = "__builtin_";
1828 assert(resultType.getImpl() && "expect elemental intrinsic to be functions");
1847 assert(resultType && "expect elemental intrinsic to be functions");
1927 // FIXME: using toValue to get the type won't work with array arguments.
2043 /// Helper to encode type into string for intrinsic procedure names.
2046 static std::string typeToString(mlir::Type t) {
2071 /// Returns a name suitable to define mlir functions for Fortran intrinsic
2072 /// Procedure. These names are guaranteed to not conflict with user defined
2073 /// procedures. This is needed to implement Fortran generic intrinsics as
2075 /// The result is guaranteed to be distinct for different mlir::FunctionType
2079 /// For subroutines no result type is return but in order to still provide
2083 static std::string mangleIntrinsicProcedure(llvm::StringRef intrinsic,
2085 std::string name = "fir.";
2104 std::string wrapperName = mangleIntrinsicProcedure(name, funcType);
2113 // Create local context to emit code into the newly created function
2114 // This new function is not linked to a source file location, only
2155 /// Helpers to detect absent optional (not yet supported in outlining).
2179 TODO(loc, "cannot outline call to intrinsic " + llvm::Twine(name) +
2184 std::string funcName{name};
2186 if (std::string fmfString{builder.getFastMathFlagsString()};
2200 TODO(loc, "cannot outline call to intrinsic " + llvm::Twine(name) +
2235 std::string nameAndType;
2371 // Runtime call to fp abs. An alternative would be to use mlir
2409 mlir::Value string = builder.createBox(loc, args[0]);
2410 // Create a mutable fir.box to be passed to the runtime for the result.
2417 CallRuntime(builder, loc, resultIrBox, string);
2418 // Read result from mutable fir.box and add it to the list of temps to be
2435 // Skip optional kind argument to search the runtime; it is already reflected
2465 // Create mutable fir.box to be passed to the runtime for the result.
2488 "allocated arg not lowered to MutableBoxValue");
2496 // Skip optional kind argument to search the runtime; it is already reflected
2526 // Create mutable fir.box to be passed to the runtime for the result.
2783 // recursion from n2 to n1. (see https://dlmf.nist.gov/10.74.iv and
2800 // The standard requires n1 <= n2. However, we still need to allocate
2801 // a zero-length array and return it when n1 > n2, so we do need to call
2868 // recursion from n1 to n2. (see https://dlmf.nist.gov/10.74.iv and
2885 // The standard requires n1 <= n2. However, we still need to allocate
2886 // a zero-length array and return it when n1 > n2, so we do need to call
2927 // Arguments do not have to be of the same integer type. However, if neither
2929 // to be converted to the longer by zero-extending (not sign-extending)
2930 // to the left [Fortran 2008, 13.3.2].
2934 // However, that seems to be relevant for the case where the type of the
2936 // these intrinsics, so, again, zero-extend to the larger type.
3002 "argument must have been lowered to box type");
3069 // Get the value of the C address or the result of a reference to C_LOC.
3182 // expect argument to be a scalar integer
3312 // Create mutable fir.box to be passed to the runtime for the result.
3348 // Create mutable fir.box to be passed to the runtime for the result.
3433 // This operation is only used to pass the result type
3434 // information to the DotProduct generator.
3468 // Per the standard, the value of DSHIFTL(I, J, SHIFT) is equal to
3501 // Per the standard, the value of DSHIFTR(I, J, SHIFT) is equal to
3527 // Create mutable fir.box to be passed to the runtime for the result.
3731 // Create mutable fir.box to be passed to the runtime for the result.
3744 // The result will be an array. Create mutable fir.box to be passed to the
3888 mlir::Value number = fir::getBase(args[0]);
3894 if (!number)
3916 builder, loc, number, valBox, lenBox, errBox);
3995 /// Process calls to Maxval, Minval, Product, Sum intrinsic functions that
4003 // Create mutable fir.box to be passed to the runtime for the result.
4019 /// Process calls to Product, Sum, IAll, IAny, IParity intrinsic functions
4183 // Character is in memory, cast to fir.ref<char> and load.
4188 // to a singleton ref is required before loading.
4241 // Generate code to raise \p excepts if \p cond is absent, or present and true.
4257 // Return a reference to the contents of a derived type with one field.
4556 // Copy the sign of REAL arg Y to REAL arg X.
4713 mlir::Value radix, std::string procName) {
4728 // Set arg ROUNDING_VALUE to the current floating point rounding mode.
4729 // Values are chosen to match the llvm.get.rounding encoding.
4752 // Convert real argument A to an integer, with rounding according to argument
4758 // The primary result is generated with a call to IEEE_RINT.
5087 // Convert integer or real argument A to a real of a specified kind.
5088 // Round according to the current rounding mode.
5095 // // Conversion to the same type is a nop except for sNaN processing.
5099 // // Conversion to a larger type is exact.
5162 // Conversion from a smaller type to a larger type is exact.
5167 // A possibly inexact conversion result may need to be rounded up or down.
5183 // Code common to (a < b) and (a > b) branches.
5345 // Return the value of real argument A rounded to an integer value according
5346 // to argument ROUND if present, otherwise according to the current rounding
5377 // IEEE_SET_FLAG: Set an exception FLAG to a FLAG_VALUE.
5378 // IEEE_SET_HALTING: Set an exception halting mode FLAG to a HALTING value.
5399 // Set the current floating point rounding mode to the value of arg
5446 // Workaround: can't bitcast or convert real(3) to integer(2) or real(2).
5506 // Values are chosen to match the llvm.get.rounding encoding:
5508 // 1 - to nearest, ties to even [supported] - default
5511 // 4 - to nearest, ties away from zero [not supported]
5549 // Return a KIND(X) REAL number of IEEE_CLASS_TYPE CLASS.
5562 std::string tableName = RTNAME_STRING(IeeeValueTable_) +
5717 mlir::Value string = builder.createBox(loc, args[0]);
5736 // Create mutable fir.box to be passed to the runtime for the result.
5741 fir::runtime::genIndexDescriptor(builder, loc, resBox, string, substring,
5959 "argument must have been lowered to box type");
6010 // The standard does not specify what to return if the number of bits to be
6041 // Create mutable fir.box to be passed to the runtime for the result.
6049 // Read result from mutable fir.box and add it to the list of temps to be
6068 // Create mutable fir.box to be passed to the runtime for the result.
6076 // Read result from mutable fir.box and add it to the list of temps to be
6094 // polymorphic. TSOURCE and FSOURCE are required to have the same type
6118 // or one may be a fir.logical<> while the other is an i1). Insert a cast to
6175 // checking is needed (to detect 0 divisor) or when precise math is requested.
6177 // No floored modulo op in LLVM/MLIR yet. TODO: add one to MLIR.
6210 // F128 arith::RemFOp may be lowered to a runtime call that may be unsupported
6211 // on the target, so generate a call to Fortran Runtime's ModuloReal16.
6240 const fir::ExtendedValue &to = args[1];
6251 const fir::MutableBoxValue *toBox = to.getBoxOf<fir::MutableBoxValue>();
6305 auto to = builder.create<fir::LoadOp>(loc, signlessType, toAddr);
6317 auto unchanged = builder.create<mlir::arith::AndIOp>(loc, unchangedTmp2, to);
6328 builder.create<mlir::arith::SelectOp>(loc, lenIsZero, to, resTmp);
6339 // Return the number adjacent to arg X in the direction of the infinity
6343 // Return isNan(Y) ? NaN : X==Y ? X : num adjacent to X in the dir of Y.
6347 // Return the number adjacent to X and less than X.
6350 // Return the number adjacent to X and greater than X.
6370 // If isNan(Y), set X to a qNaN that will propagate to the resultIsX result.
6377 // Set valueUp to true if a finite result must be larger than arg X.
6392 // Convert X and Y to a common type to allow comparison. Direct conversions
6394 // are implemented by converting kind=2,3 values to kind=4, possibly
6395 // followed with a conversion of that value to a larger type.
6430 // Result is X. (For ieee_next_after with isNan(Y), X has been set to a NaN.)
6490 // Kind 2, 3, 4, 8, 16. Increment or decrement X cast to integer.
6520 // Skip optional kind argument to search the runtime; it is already reflected
6545 // Create mutable fir.box to be passed to the runtime for the result.
6577 "MOLD argument required to lower NULL outside of any context");
6616 // Create mutable fir.box to be passed to the runtime for the result.
6654 // Create mutable fir.box to be passed to the runtime for the result.
6746 // Arguements to the reduction operation are passed by reference or value?
6813 // Create mutable fir.box to be passed to the runtime for the result.
6861 mlir::Value string = builder.createBox(loc, args[0]);
6863 // Create mutable fir.box to be passed to the runtime for the result.
6869 fir::runtime::genRepeat(builder, loc, resultIrBox, string, ncopies);
6870 // Read result from mutable fir.box and add it to the list of temps to be
6906 // Create mutable fir.box to be passed to the runtime for the result.
6974 // specialized on the kind of characters in string.
6976 // Handle required string base arg
6979 // Handle required set string base arg
6987 // Get string length argument
6990 // Get set string length argument
7020 // Handle required string argument
7021 mlir::Value string = builder.createBox(loc, args[0]);
7035 fir::runtime::genScanDescriptor(builder, loc, resultIrBox, string, set, back,
7140 /// Create a fir.box to be passed to the LBOUND/UBOUND runtime.
7154 // This entity is mapped to a fir.box that may not contain the local
7173 /// Generate runtime call to inquire about all the bounds/extents of an
7184 // big enough to hold the result but still "small" (15 elements). Static size
7200 // Cast to fir.ref<array<?xik>> since the result extent is not a compile
7255 // maintain compatibility with them to an extent.
7295 // the shift amount is equal to the element size.
7296 // So if SHIFT is equal to the bit width then it is handled as a special case.
7320 mlir::Value number = fir::getBase(args[0]);
7325 fir::runtime::genSignal(builder, loc, number, handler, status);
7369 // The front-end rewrites SIZE without the DIM argument to
7472 // be returned. It is important to test extent == 0 and not extent > 0.
7547 // Handle calls to UBOUND with the DIM argument, which return a scalar
7555 // Handle calls to UBOUND without the DIM argument, which return an array
7613 std::string errorMsg;
7731 // Create a dummmy cmdstat to prevent EXECUTE_COMMAND_LINE terminate itself
7782 // Create mutable fir.box to be passed to the runtime for the result.
7822 // Create mutable fir.box to be passed to the runtime for the result.
7831 // Read result from mutable fir.box and add it to the list of temps to be
7873 mlir::Value string = builder.createBox(loc, args[0]);
7874 // Create mutable fir.box to be passed to the runtime for the result.
7880 fir::runtime::genTrim(builder, loc, resultIrBox, string);
7881 // Read result from mutable fir.box and add it to the list of temps to be
7906 // Return the number if one of the inputs is NaN and the other is
7907 // a number.
7974 // Create mutable fir.box to be passed to the runtime for the result.
7996 // specialized on the kind of characters in string.
7998 // Handle required string base arg
8001 // Handle required set string base arg
8009 // Get string length argument
8012 // Get set string length argument
8042 // Handle required string argument
8043 mlir::Value string = builder.createBox(loc, args[0]);
8057 fir::runtime::genVerifyDescriptor(builder, loc, resultIrBox, string, set,
8064 /// Process calls to Minloc, Maxloc intrinsic functions
8102 // Create mutable fir.box to be passed to the runtime for the result.
8116 // Create mutable fir.box to be passed to the runtime for the result.
8145 /// Process calls to Maxval and Minval
8175 // Create mutable fir.box to be passed to the runtime for the result.
8309 // we have to provide an alternative implementation for
8311 // One option is to generate internal function with inlined
8313 // Another option is to implement it in Fortran runtime library