[llvm-branch-commits] [flang] 5244bb1 - Modify an IO format error message
Author: V Donaldson Date: 2022-01-04T10:34:07-08:00 New Revision: 5244bb18abbf70d2f4475fa8facb34d4d8af0d32 URL: https://github.com/llvm/llvm-project/commit/5244bb18abbf70d2f4475fa8facb34d4d8af0d32 DIFF: https://github.com/llvm/llvm-project/commit/5244bb18abbf70d2f4475fa8facb34d4d8af0d32.diff LOG: Modify an IO format error message F18 constraint C1308 is: For the G edit descriptor, e shall not be specified if w is zero. For an edit descriptor such as 'G0.2E4', change the error message from: error: Unexpected 'e' in 'G0' edit descriptor To: error: A 'G0' edit descriptor must not have an 'e' value Added: Modified: flang/include/flang/Common/format.h flang/test/Semantics/io07.f90 flang/test/Semantics/io08.f90 Removed: diff --git a/flang/include/flang/Common/format.h b/flang/include/flang/Common/format.h index e38ea6b0dfedf..7ca3faa79f290 100644 --- a/flang/include/flang/Common/format.h +++ b/flang/include/flang/Common/format.h @@ -606,8 +606,8 @@ template bool FormatValidator::Check() { check_e(); } } else if (token_.kind() == TokenKind::Point && check_d() && -token_.kind() == TokenKind::E) { - ReportError("Unexpected 'e' in 'G0' edit descriptor"); // C1308 +token_.kind() == TokenKind::E) { // C1308 + ReportError("A 'G0' edit descriptor must not have an 'e' value"); NextToken(); if (token_.kind() == TokenKind::UnsignedInteger) { NextToken(); diff --git a/flang/test/Semantics/io07.f90 b/flang/test/Semantics/io07.f90 index 5c4c2b419d978..9b1f048e5b17c 100644 --- a/flang/test/Semantics/io07.f90 +++ b/flang/test/Semantics/io07.f90 @@ -74,9 +74,9 @@ 8001 format(9G0.5) - !ERROR: Unexpected 'e' in 'G0' edit descriptor + !ERROR: A 'G0' edit descriptor must not have an 'e' value 8101 format(9(G0.5e1)) - !ERROR: Unexpected 'e' in 'G0' edit descriptor + !ERROR: A 'G0' edit descriptor must not have an 'e' value 8102 format(9(G0.5 E 1)) end diff --git a/flang/test/Semantics/io08.f90 b/flang/test/Semantics/io08.f90 index c074e1562e222..843028acfd5bf 100644 --- a/flang/test/Semantics/io08.f90 +++ b/flang/test/Semantics/io08.f90 @@ -189,10 +189,10 @@ !ERROR: Expected 'G' edit descriptor '.d' value write(*,'(G4)') - !ERROR: Unexpected 'e' in 'G0' edit descriptor + !ERROR: A 'G0' edit descriptor must not have an 'e' value write(*,'(G0.8e)') - !ERROR: Unexpected 'e' in 'G0' edit descriptor + !ERROR: A 'G0' edit descriptor must not have an 'e' value write(*,'(G0.8e2)') !ERROR: Kind parameter '_' character in format expression ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [flang] acff94a - Update intrinsic module source files
Author: V Donaldson Date: 2022-05-25T15:32:02-07:00 New Revision: acff94a87a3b531e4613b4b886d96219c9415882 URL: https://github.com/llvm/llvm-project/commit/acff94a87a3b531e4613b4b886d96219c9415882 DIFF: https://github.com/llvm/llvm-project/commit/acff94a87a3b531e4613b4b886d96219c9415882.diff LOG: Update intrinsic module source files The f18 standard defines several intrinsic modules containing definitions and declarations for various constants, types, and procedures. This PR adds declarations for missing procedures in these modules. Added: Modified: flang/module/__fortran_builtins.f90 flang/module/__fortran_ieee_exceptions.f90 flang/module/ieee_arithmetic.f90 flang/module/iso_fortran_env.f90 Removed: diff --git a/flang/module/__fortran_builtins.f90 b/flang/module/__fortran_builtins.f90 index 4a4c55e44e056..4ce4901c4505d 100644 --- a/flang/module/__fortran_builtins.f90 +++ b/flang/module/__fortran_builtins.f90 @@ -41,8 +41,8 @@ procedure(type(__builtin_c_ptr)) :: __builtin_c_loc - intrinsic :: __builtin_ieee_is_nan, __builtin_ieee_is_normal, & -__builtin_ieee_is_negative + intrinsic :: __builtin_ieee_is_nan, __builtin_ieee_is_negative, & +__builtin_ieee_is_normal intrinsic :: __builtin_ieee_next_after, __builtin_ieee_next_down, & __builtin_ieee_next_up intrinsic :: scale ! for ieee_scalb diff --git a/flang/module/__fortran_ieee_exceptions.f90 b/flang/module/__fortran_ieee_exceptions.f90 index bd8782e4db5a6..7232bbf53cd61 100644 --- a/flang/module/__fortran_ieee_exceptions.f90 +++ b/flang/module/__fortran_ieee_exceptions.f90 @@ -40,90 +40,110 @@ private end type ieee_status_type - private :: ieee_support_flag_2, ieee_support_flag_3, & - ieee_support_flag_4, ieee_support_flag_8, ieee_support_flag_10, & - ieee_support_flag_16 - interface ieee_support_flag -module procedure :: ieee_support_flag, & - ieee_support_flag_2, ieee_support_flag_3, & - ieee_support_flag_4, ieee_support_flag_8, ieee_support_flag_10, & - ieee_support_flag_16 +! Define specifics with 1 LOGICAL or REAL argument for generic G. +#define SPECIFICS_L(G) \ + G(1) G(2) G(4) G(8) +#define SPECIFICS_R(G) \ + G(2) G(3) G(4) G(8) G(10) G(16) + +! Set PRIVATE accessibility for specifics with 1 LOGICAL or REAL argument for +! generic G. +#define PRIVATE_L(G) private :: \ + G##_l1, G##_l2, G##_l4, G##_l8 +#define PRIVATE_R(G) private :: \ + G##_a2, G##_a3, G##_a4, G##_a8, G##_a10, G##_a16 + + interface +elemental subroutine ieee_get_flag(flag, flag_value) + import ieee_flag_type + type(ieee_flag_type), intent(in) :: flag + logical, intent(out) :: flag_value +end subroutine ieee_get_flag + end interface + + interface +elemental subroutine ieee_get_halting_mode(flag, halting) + import ieee_flag_type + type(ieee_flag_type), intent(in) :: flag + logical, intent(out) :: halting +end subroutine ieee_get_halting_mode + end interface + + interface +subroutine ieee_get_modes(modes) + import ieee_modes_type + type(ieee_modes_type), intent(out) :: modes +end subroutine ieee_get_modes + end interface + + interface +subroutine ieee_get_status(status) + import ieee_status_type + type(ieee_status_type), intent(out) :: status +end subroutine ieee_get_status + end interface + +#define IEEE_SET_FLAG_L(FVKIND) \ + pure subroutine ieee_set_flag_l##FVKIND(flag,flag_value); \ +import ieee_flag_type; \ +type(ieee_flag_type), intent(in) :: flag(..); \ +logical(FVKIND), intent(in) :: flag_value(..); \ + end subroutine ieee_set_flag_l##FVKIND; + interface ieee_set_flag +SPECIFICS_L(IEEE_SET_FLAG_L) + end interface ieee_set_flag + private :: ieee_set_flag_1 + PRIVATE_L(IEEE_SET_FLAG) +#undef IEEE_SET_FLAG_L + +#define IEEE_SET_HALTING_MODE_L(HKIND) \ + pure subroutine ieee_set_halting_mode_l##HKIND(flag,halting); \ +import ieee_flag_type; \ +type(ieee_flag_type), intent(in) :: flag(..); \ +logical(HKIND), intent(in) :: halting(..); \ + end subroutine ieee_set_halting_mode_l##HKIND; + interface ieee_set_halting_mode +SPECIFICS_L(IEEE_SET_HALTING_MODE_L) + end interface ieee_set_halting_mode + private :: ieee_set_halting_mode_1 + PRIVATE_L(IEEE_SET_HALTING_MODE) +#undef IEEE_SET_HALTING_MODE_L + + interface +subroutine ieee_set_modes(modes) + import ieee_modes_type + type(ieee_modes_type), intent(in) :: modes +end subroutine ieee_set_modes + end interface + + interface +subroutine ieee_set_status(status) + import ieee_status_type + type(ieee_status_type), intent(in) :: status +end subroutine ieee_set_status end interface - contains - elemental subroutine ieee_get_flag(flag, flag_value) -type(ieee_flag_type), intent(in) :: flag -logical, intent(out) :: flag_value - end subroutine ieee_get_flag - -
[llvm-branch-commits] [flang] 6986167 - [flang] Submodules
Author: V Donaldson Date: 2022-12-05T13:46:36-08:00 New Revision: 6986167ea3116fce7281a6ce1c1be88ef9b0be27 URL: https://github.com/llvm/llvm-project/commit/6986167ea3116fce7281a6ce1c1be88ef9b0be27 DIFF: https://github.com/llvm/llvm-project/commit/6986167ea3116fce7281a6ce1c1be88ef9b0be27.diff LOG: [flang] Submodules A submodule is a program unit that may contain the implementions of procedures declared in a parent module or an intermediate ancestor submodule. Processing for the equivalence groups and variables declared in a submodule scope is similar to existing processing for the equivalence groups and variables in module and procedure scopes. However, module and procedure scopes are tied directly to code in the Pre-FIR Tree (PFT), whereas processing for a submodule must have access to a module scope that, while guaranteed to be present in a .mod file, is not guaranteed to be in the PFT. This difference is accommodated by tying all scope processing to a front end scope, independent of the PFT. Function scopes that can be processed on the fly are done that way; the resulting variable information is never stored. Module and submodule scopes whose symbol information may be needed during lowering of any number of module procedures are instead cached on first use, and reused as needed. These changes are a direct extension of current code. All module and submodule variables in scope are processed, whether referenced or not. A possible alternative would be to instead process symbols only when first used. While this could ultimately be beneficial, such an approach must account for the presence of equivalence groups. That information is not currently available for on-the-fly variable processing. Some additional changes are needed to include submodules in places where modules must be considered, and to include separate module procedures in places where other subprogram variants are considered. There are also some incidental bug fixes, such as for variables in equivalence groups used in namelist groups, which have a loose association with scope processing code. Added: flang/test/Lower/submodule.f90 Modified: flang/include/flang/Lower/ConvertVariable.h flang/include/flang/Lower/PFTBuilder.h flang/lib/Lower/Bridge.cpp flang/lib/Lower/ConvertVariable.cpp flang/lib/Lower/IO.cpp flang/lib/Lower/Mangler.cpp flang/lib/Lower/PFTBuilder.cpp flang/test/Lower/pre-fir-tree01.f90 flang/test/Lower/pre-fir-tree02.f90 flang/test/Lower/pre-fir-tree06.f90 flang/test/Lower/pre-fir-tree07.f90 Removed: diff --git a/flang/include/flang/Lower/ConvertVariable.h b/flang/include/flang/Lower/ConvertVariable.h index a715d546e682a..ee8ef168a07d0 100644 --- a/flang/include/flang/Lower/ConvertVariable.h +++ b/flang/include/flang/Lower/ConvertVariable.h @@ -50,6 +50,11 @@ using AggregateStoreMap = llvm::DenseMap; void instantiateVariable(AbstractConverter &, const pft::Variable &var, SymMap &symMap, AggregateStoreMap &storeMap); +/// Return the compiler-generated name of a static namelist variable descriptor. +std::string +globalNamelistDescriptorName(Fortran::lower::AbstractConverter &converter, + const Fortran::semantics::Symbol &sym); + /// Create a fir::GlobalOp given a module variable definition. This is intended /// to be used when lowering a module definition, not when lowering variables /// used from a module. For used variables instantiateVariable must directly be diff --git a/flang/include/flang/Lower/PFTBuilder.h b/flang/include/flang/Lower/PFTBuilder.h index 933d50a0c015b..be3f9f3b10593 100644 --- a/flang/include/flang/Lower/PFTBuilder.h +++ b/flang/include/flang/Lower/PFTBuilder.h @@ -37,7 +37,6 @@ struct ModuleLikeUnit; struct FunctionLikeUnit; using EvaluationList = std::list; -using LabelEvalMap = llvm::DenseMap; /// Provide a variant like container that can hold references. It can hold /// constant or mutable references. It is used in the other classes to provide @@ -445,7 +444,7 @@ struct Variable { const semantics::Symbol *namingSymbol; /// Compiler generated symbol with the aggregate initial value if any. const semantics::Symbol *initialValueSymbol = nullptr; -/// Is this a global aggregate ? +/// Is this a global aggregate? bool isGlobalAggregate; }; @@ -485,10 +484,10 @@ struct Variable { return std::visit([](const auto &x) { return x.isGlobal(); }, var); } - /// Is this a module variable ? - bool isModuleVariable() const { + /// Is this a module or submodule variable? + bool isModuleOrSubmodule() const { const semantics::Scope *scope = getOwningScope(); -return scope && scope->IsModule(); +return scope && scope->kind() == Fortran::semantics::Scope::Kind::Module; } const Fortran::semantics::Scope *getOwningScope() const { @@ -522,7 +521,7
[llvm-branch-commits] [flang] 5ea6b46 - [flang] REAL(KIND=3) and COMPLEX(KIND=3) descriptors
Author: V Donaldson Date: 2023-04-12T12:15:27-07:00 New Revision: 5ea6b46b586c7dbc4d255d15e34e7a5bdd5fbc65 URL: https://github.com/llvm/llvm-project/commit/5ea6b46b586c7dbc4d255d15e34e7a5bdd5fbc65 DIFF: https://github.com/llvm/llvm-project/commit/5ea6b46b586c7dbc4d255d15e34e7a5bdd5fbc65.diff LOG: [flang] REAL(KIND=3) and COMPLEX(KIND=3) descriptors Update descriptor generation to correctly set the `type` field for REAL(3) and COMPLEX(3) objects. Added: flang/lib/Optimizer/Support/TypeCode.cpp flang/test/Lower/real-descriptors.f90 Modified: flang/include/flang/ISO_Fortran_binding.h flang/include/flang/Optimizer/Support/TypeCode.h flang/lib/Optimizer/CodeGen/CodeGen.cpp flang/lib/Optimizer/Support/CMakeLists.txt flang/lib/Optimizer/Transforms/PolymorphicOpConversion.cpp flang/test/Fir/convert-to-llvm.fir Removed: diff --git a/flang/include/flang/ISO_Fortran_binding.h b/flang/include/flang/ISO_Fortran_binding.h index dbfc882c37edf..b4a5e7c3653c4 100644 --- a/flang/include/flang/ISO_Fortran_binding.h +++ b/flang/include/flang/ISO_Fortran_binding.h @@ -43,8 +43,7 @@ typedef unsigned char CFI_attribute_t; typedef signed char CFI_type_t; /* These codes are required to be macros (i.e., #ifdef will work). * They are not required to be distinct, but neither are they required - * to have had their synonyms combined. Codes marked as extensions may be - * place holders for as yet unimplemented types. + * to have had their synonyms combined. */ #define CFI_type_signed_char 1 #define CFI_type_short 2 @@ -56,7 +55,7 @@ typedef signed char CFI_type_t; #define CFI_type_int16_t 8 #define CFI_type_int32_t 9 #define CFI_type_int64_t 10 -#define CFI_type_int128_t 11 /* extension */ +#define CFI_type_int128_t 11 /* extension kind=16 */ #define CFI_type_int_least8_t 12 #define CFI_type_int_least16_t 13 #define CFI_type_int_least32_t 14 @@ -88,8 +87,8 @@ typedef signed char CFI_type_t; #define CFI_type_char 40 #define CFI_type_cptr 41 #define CFI_type_struct 42 -#define CFI_type_char16_t 43 /* extension */ -#define CFI_type_char32_t 44 /* extension */ +#define CFI_type_char16_t 43 /* extension kind=2 */ +#define CFI_type_char32_t 44 /* extension kind=4 */ #define CFI_TYPE_LAST CFI_type_char32_t #define CFI_type_other (-1) // must be negative diff --git a/flang/include/flang/Optimizer/Support/TypeCode.h b/flang/include/flang/Optimizer/Support/TypeCode.h index fef937b518aa8..c2539e5278059 100644 --- a/flang/include/flang/Optimizer/Support/TypeCode.h +++ b/flang/include/flang/Optimizer/Support/TypeCode.h @@ -13,80 +13,12 @@ #ifndef FORTRAN_OPTIMIZER_SUPPORT_TYPECODE_H #define FORTRAN_OPTIMIZER_SUPPORT_TYPECODE_H -#include "flang/ISO_Fortran_binding.h" -#include "llvm/Support/ErrorHandling.h" +#include "flang/Optimizer/Dialect/Support/KindMapping.h" +#include "mlir/IR/Types.h" namespace fir { - -//===--===// -// Translations of category and bitwidths to the type codes defined in flang's -// ISO_Fortran_binding.h. -//===--===// - -inline int characterBitsToTypeCode(unsigned bitwidth) { - // clang-format off - switch (bitwidth) { - case 8: return CFI_type_char; - case 16: return CFI_type_char16_t; - case 32: return CFI_type_char32_t; - default: llvm_unreachable("unsupported character size"); - } - // clang-format on -} - -inline int complexBitsToTypeCode(unsigned bitwidth) { - // clang-format off - switch (bitwidth) { - case 16: return CFI_type_half_float_Complex; // CFI_type_bfloat_Complex ? - case 32: return CFI_type_float_Complex; - case 64: return CFI_type_double_Complex; - case 80: return CFI_type_extended_double_Complex; - case 128: return CFI_type_float128_Complex; - default: llvm_unreachable("unsupported complex size"); - } - // clang-format on -} - -inline int integerBitsToTypeCode(unsigned bitwidth) { - // clang-format off - switch (bitwidth) { - case 8: return CFI_type_int8_t; - case 16: return CFI_type_int16_t; - case 32: return CFI_type_int32_t; - case 64: return CFI_type_int64_t; - case 128: return CFI_type_int128_t; - default: llvm_unreachable("unsupported integer size"); - } - // clang-format on -} - -inline int logicalBitsToTypeCode(unsigned bitwidth) { - // clang-format off - switch (bitwidth) { - case 8: return CFI_type_Bool; - case 16: return CFI_type_int_least16_t; - case 32: return CFI_type_int_least32_t; - case 64: return CFI_type_int_least64_t; - default: llvm_unreachable("unsupported logical size"); - } - // clang-format on -} - -inline int realBitsToTypeCode(unsigned bitwidth) { - // clang-format off - switch (bitwidth) { - case 16: return CFI_type_half_float; // CFI_type_bfloat ? - case 32: return CFI_type_float; - case 64: return CFI_type_double; - case 80