arnamoy10 updated this revision to Diff 325208.
arnamoy10 added a comment.

Updating the test case to include `-fc1` as well


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97080/new/

https://reviews.llvm.org/D97080

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/PreprocessorOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Flang-Driver/Inputs/ieee_arithmetic.mod
  flang/test/Flang-Driver/Inputs/iso_fortran_env.mod
  flang/test/Flang-Driver/driver-help-hidden.f90
  flang/test/Flang-Driver/driver-help.f90
  flang/test/Flang-Driver/intrinsic_module_path.f90

Index: flang/test/Flang-Driver/intrinsic_module_path.f90
===================================================================
--- /dev/null
+++ flang/test/Flang-Driver/intrinsic_module_path.f90
@@ -0,0 +1,33 @@
+! Ensure argument -fintrinsic-modules-path works as expected.
+
+
+!--------------------------
+! FLANG DRIVER (flang-new)
+!--------------------------
+! RUN: not %flang-new -fsyntax-only %s  2>&1 | FileCheck %s --check-prefix=WITHOUT
+! RUN: not %flang-new -fsyntax-only -fintrinsic-modules-path %S/Inputs/ %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+
+!-----------------------------------------
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!-----------------------------------------
+! RUN: not %flang-new -fc1 -fsyntax-only %s  2>&1 | FileCheck %s --check-prefix=WITHOUT
+! RUN: not %flang-new -fc1 -fsyntax-only -fintrinsic-modules-path %S/Inputs/ %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+
+!-----------------------------------------
+! EXPECTED OUTPUT WITHOUT
+!-----------------------------------------
+! WITHOUT: 'ieee_arithmetic.mod' was not found
+! WITHOUT: 'iso_fortran_env.mod' was not found
+
+!-----------------------------------------
+! EXPECTED OUTPUT WITH
+!-----------------------------------------
+! GIVEN-NOT: 'ieee_arithmetic.mod' was not found
+! GIVEN-NOT: 'iso_fortran_env.mod' was not found
+
+
+program test_intrinsic_module_path
+   use,intrinsic :: ieee_arithmetic
+   use iso_fortran_env, only: team_type, event_type, lock_type
+end program
+  
Index: flang/test/Flang-Driver/driver-help.f90
===================================================================
--- flang/test/Flang-Driver/driver-help.f90
+++ flang/test/Flang-Driver/driver-help.f90
@@ -32,6 +32,8 @@
 ! HELP-NEXT: -ffree-form            Process source files in free form
 ! HELP-NEXT: -fimplicit-none        No implicit typing allowed unless overridden by IMPLICIT statements
 ! HELP-NEXT: -finput-charset=<value> Specify the default character set for source files
+! HELP-NEXT: -fintrinsic-modules-path <dir>
+! HELP-NEXT:                        Specify the location of pre-compiled intrinsic modules.
 ! HELP-NEXT: -flogical-abbreviations Enable logical abbreviations
 ! HELP-NEXT: -fno-color-diagnostics Disable colors in diagnostics
 ! HELP-NEXT: -fopenacc              Enable OpenACC
@@ -71,6 +73,8 @@
 ! HELP-FC1-NEXT: -ffree-form            Process source files in free form
 ! HELP-FC1-NEXT: -fimplicit-none        No implicit typing allowed unless overridden by IMPLICIT statements
 ! HELP-FC1-NEXT: -finput-charset=<value> Specify the default character set for source files
+! HELP-FC1-NEXT: -fintrinsic-modules-path <dir>
+! HELP-FC1-NEXT:                        Specify the location of pre-compiled intrinsic modules.
 ! HELP-FC1-NEXT: -flogical-abbreviations Enable logical abbreviations
 ! HELP-FC1-NEXT: -fopenacc              Enable OpenACC
 ! HELP-FC1-NEXT: -fopenmp               Parse OpenMP pragmas and generate parallel code.
Index: flang/test/Flang-Driver/driver-help-hidden.f90
===================================================================
--- flang/test/Flang-Driver/driver-help-hidden.f90
+++ flang/test/Flang-Driver/driver-help-hidden.f90
@@ -32,6 +32,8 @@
 ! CHECK-NEXT: -ffree-form            Process source files in free form
 ! CHECK-NEXT: -fimplicit-none        No implicit typing allowed unless overridden by IMPLICIT statements
 ! CHECK-NEXT: -finput-charset=<value> Specify the default character set for source files
+! CHECK-NEXT: -fintrinsic-modules-path <dir>
+! CHECK-NEXT:                        Specify the location of pre-compiled intrinsic modules.
 ! CHECK-NEXT: -flogical-abbreviations Enable logical abbreviations
 ! CHECK-NEXT: -fno-color-diagnostics Disable colors in diagnostics
 ! CHECK-NEXT: -fopenacc              Enable OpenACC
Index: flang/test/Flang-Driver/Inputs/iso_fortran_env.mod
===================================================================
--- /dev/null
+++ flang/test/Flang-Driver/Inputs/iso_fortran_env.mod
@@ -0,0 +1,87 @@
+!mod$ v1 sum:2bc045d927f2d22c
+module iso_fortran_env
+use __fortran_builtins,only:event_type=>__builtin_event_type
+use __fortran_builtins,only:lock_type=>__builtin_lock_type
+use __fortran_builtins,only:team_type=>__builtin_team_type
+integer(4),parameter::atomic_int_kind=8_4
+intrinsic::selected_int_kind
+integer(4),parameter::atomic_logical_kind=8_4
+integer(4),parameter,private::selectedascii=1_4
+intrinsic::selected_char_kind
+integer(4),parameter,private::selecteducs_2=2_4
+integer(4),parameter,private::selectedunicode=4_4
+integer(4),parameter::character_kinds(1_8:*)=[INTEGER(4)::1_4,2_4,4_4]
+integer(4),parameter,private::selectedint8=1_4
+integer(4),parameter,private::selectedint16=2_4
+integer(4),parameter,private::selectedint32=4_4
+integer(4),parameter,private::selectedint64=8_4
+integer(4),parameter,private::selectedint128=16_4
+integer(4),parameter,private::safeint8=1_4
+intrinsic::merge
+integer(4),parameter,private::safeint16=2_4
+integer(4),parameter,private::safeint32=4_4
+integer(4),parameter,private::safeint64=8_4
+integer(4),parameter,private::safeint128=16_4
+integer(4),parameter::int8=1_4
+intrinsic::digits
+intrinsic::int
+integer(4),parameter::int16=2_4
+integer(4),parameter::int32=4_4
+integer(4),parameter::int64=8_4
+integer(4),parameter::int128=16_4
+integer(4),parameter::integer_kinds(1_8:*)=[INTEGER(4)::1_4,2_4,4_4,8_4,16_4]
+integer(4),parameter::logical8=1_4
+integer(4),parameter::logical16=2_4
+integer(4),parameter::logical32=4_4
+integer(4),parameter::logical64=8_4
+integer(4),parameter::logical_kinds(1_8:*)=[INTEGER(4)::1_4,2_4,4_4,8_4]
+integer(4),parameter,private::selectedreal16=2_4
+intrinsic::selected_real_kind
+integer(4),parameter,private::selectedbfloat16=3_4
+integer(4),parameter,private::selectedreal32=4_4
+integer(4),parameter,private::selectedreal64=8_4
+integer(4),parameter,private::selectedreal80=10_4
+integer(4),parameter,private::selectedreal64x2=16_4
+integer(4),parameter,private::selectedreal128=16_4
+integer(4),parameter,private::safereal16=2_4
+integer(4),parameter,private::safebfloat16=3_4
+integer(4),parameter,private::safereal32=4_4
+integer(4),parameter,private::safereal64=8_4
+integer(4),parameter,private::safereal80=10_4
+integer(4),parameter,private::safereal64x2=16_4
+integer(4),parameter,private::safereal128=16_4
+integer(4),parameter::real16=2_4
+intrinsic::real
+integer(4),parameter::bfloat16=3_4
+integer(4),parameter::real32=4_4
+integer(4),parameter::real64=8_4
+integer(4),parameter::real80=10_4
+integer(4),parameter::real64x2=-2_4
+integer(4),parameter::real128=16_4
+integer(4),parameter::real_kinds(1_8:*)=[INTEGER(4)::2_4,3_4,4_4,8_4,10_4,16_4]
+integer(4),parameter::current_team=-1_4
+integer(4),parameter::initial_team=-2_4
+integer(4),parameter::parent_team=-3_4
+integer(4),parameter::input_unit=5_4
+integer(4),parameter::output_unit=6_4
+integer(4),parameter::error_unit=6_4
+integer(4),parameter::iostat_end=-1_4
+integer(4),parameter::iostat_eor=-2_4
+integer(4),parameter::iostat_inquire_internal_unit=-1_4
+integer(4),parameter::character_storage_size=8_4
+integer(4),parameter::file_storage_size=8_4
+integer(4),parameter::numeric_storage_size=32_4
+integer(4),parameter::stat_failed_image=101_4
+integer(4),parameter::stat_locked=102_4
+integer(4),parameter::stat_locked_other_image=103_4
+integer(4),parameter::stat_stopped_image=104_4
+integer(4),parameter::stat_unlocked=105_4
+integer(4),parameter::stat_unlocked_failed_image=106_4
+contains
+function compiler_options()
+character(80_4,1)::compiler_options
+end
+function compiler_version()
+character(80_4,1)::compiler_version
+end
+end
Index: flang/test/Flang-Driver/Inputs/ieee_arithmetic.mod
===================================================================
--- /dev/null
+++ flang/test/Flang-Driver/Inputs/ieee_arithmetic.mod
@@ -0,0 +1,196 @@
+!mod$ v1 sum:629f5b1989985c7f
+module ieee_arithmetic
+use __fortran_builtins,only:ieee_support_datatype=>__builtin_ieee_support_datatype
+use __fortran_builtins,only:ieee_support_denormal=>__builtin_ieee_support_denormal
+use __fortran_builtins,only:ieee_support_divide=>__builtin_ieee_support_divide
+use __fortran_builtins,only:ieee_support_inf=>__builtin_ieee_support_inf
+use __fortran_builtins,only:ieee_support_io=>__builtin_ieee_support_io
+use __fortran_builtins,only:ieee_support_nan=>__builtin_ieee_support_nan
+use __fortran_builtins,only:ieee_support_sqrt=>__builtin_ieee_support_sqrt
+use __fortran_builtins,only:ieee_support_standard=>__builtin_ieee_support_standard
+use __fortran_builtins,only:ieee_support_subnormal=>__builtin_ieee_support_subnormal
+use __fortran_builtins,only:ieee_support_underflow_control=>__builtin_ieee_support_underflow_control
+type::ieee_class_type
+integer(1),private::which=0_1
+end type
+type(ieee_class_type),parameter::ieee_signaling_nan=ieee_class_type(which=1_1)
+type(ieee_class_type),parameter::ieee_quiet_nan=ieee_class_type(which=2_1)
+type(ieee_class_type),parameter::ieee_negative_inf=ieee_class_type(which=3_1)
+type(ieee_class_type),parameter::ieee_negative_normal=ieee_class_type(which=4_1)
+type(ieee_class_type),parameter::ieee_negative_denormal=ieee_class_type(which=5_1)
+type(ieee_class_type),parameter::ieee_negative_zero=ieee_class_type(which=6_1)
+type(ieee_class_type),parameter::ieee_positive_zero=ieee_class_type(which=7_1)
+type(ieee_class_type),parameter::ieee_positive_subnormal=ieee_class_type(which=8_1)
+type(ieee_class_type),parameter::ieee_positive_normal=ieee_class_type(which=9_1)
+type(ieee_class_type),parameter::ieee_positive_inf=ieee_class_type(which=10_1)
+type(ieee_class_type),parameter::ieee_other_value=ieee_class_type(which=11_1)
+type(ieee_class_type),parameter::ieee_negative_subnormal=ieee_class_type(which=5_1)
+type(ieee_class_type),parameter::ieee_positive_denormal=ieee_class_type(which=5_1)
+type::ieee_round_type
+integer(1),private::mode=0_1
+end type
+type(ieee_round_type),parameter::ieee_nearest=ieee_round_type(mode=1_1)
+type(ieee_round_type),parameter::ieee_to_zero=ieee_round_type(mode=2_1)
+type(ieee_round_type),parameter::ieee_up=ieee_round_type(mode=3_1)
+type(ieee_round_type),parameter::ieee_down=ieee_round_type(mode=4_1)
+type(ieee_round_type),parameter::ieee_away=ieee_round_type(mode=5_1)
+type(ieee_round_type),parameter::ieee_other=ieee_round_type(mode=6_1)
+interface operator(==)
+procedure::class_eq
+procedure::round_eq
+end interface
+interface operator(/=)
+procedure::class_ne
+procedure::round_ne
+end interface
+interface ieee_class
+procedure::ieee_class_a2
+procedure::ieee_class_a3
+procedure::ieee_class_a4
+procedure::ieee_class_a8
+procedure::ieee_class_a10
+procedure::ieee_class_a16
+end interface
+interface ieee_copy_sign
+procedure::ieee_copy_sign_a2
+procedure::ieee_copy_sign_a3
+procedure::ieee_copy_sign_a4
+procedure::ieee_copy_sign_a8
+procedure::ieee_copy_sign_a10
+procedure::ieee_copy_sign_a16
+end interface
+interface ieee_support_rounding
+procedure::ieee_support_rounding_
+procedure::ieee_support_rounding_2
+procedure::ieee_support_rounding_3
+procedure::ieee_support_rounding_4
+procedure::ieee_support_rounding_8
+procedure::ieee_support_rounding_10
+procedure::ieee_support_rounding_16
+end interface
+private::classify
+private::ieee_support_rounding_
+private::ieee_support_rounding_2
+private::ieee_support_rounding_3
+private::ieee_support_rounding_4
+private::ieee_support_rounding_8
+private::ieee_support_rounding_10
+private::ieee_support_rounding_16
+contains
+elemental function class_eq(x,y)
+type(ieee_class_type),intent(in)::x
+type(ieee_class_type),intent(in)::y
+logical(4)::class_eq
+end
+elemental function class_ne(x,y)
+type(ieee_class_type),intent(in)::x
+type(ieee_class_type),intent(in)::y
+logical(4)::class_ne
+end
+elemental function round_eq(x,y)
+type(ieee_round_type),intent(in)::x
+type(ieee_round_type),intent(in)::y
+logical(4)::round_eq
+end
+elemental function round_ne(x,y)
+type(ieee_round_type),intent(in)::x
+type(ieee_round_type),intent(in)::y
+logical(4)::round_ne
+end
+elemental function classify(expo,maxexpo,negative,significandnz,quietbit)
+integer(4),intent(in)::expo
+integer(4),intent(in)::maxexpo
+logical(4),intent(in)::negative
+logical(4),intent(in)::significandnz
+logical(4),intent(in)::quietbit
+type(ieee_class_type)::classify
+end
+elemental function ieee_class_a2(x)
+real(2),intent(in)::x
+type(ieee_class_type)::ieee_class_a2
+end
+elemental function ieee_class_a3(x)
+real(3),intent(in)::x
+type(ieee_class_type)::ieee_class_a3
+end
+elemental function ieee_class_a4(x)
+real(4),intent(in)::x
+type(ieee_class_type)::ieee_class_a4
+end
+elemental function ieee_class_a8(x)
+real(8),intent(in)::x
+type(ieee_class_type)::ieee_class_a8
+end
+elemental function ieee_class_a10(x)
+real(10),intent(in)::x
+type(ieee_class_type)::ieee_class_a10
+end
+elemental function ieee_class_a16(x)
+real(16),intent(in)::x
+type(ieee_class_type)::ieee_class_a16
+end
+elemental function ieee_copy_sign_a2(x,y)
+real(2),intent(in)::x
+real(2),intent(in)::y
+real(2)::ieee_copy_sign_a2
+end
+elemental function ieee_copy_sign_a3(x,y)
+real(3),intent(in)::x
+real(3),intent(in)::y
+real(3)::ieee_copy_sign_a3
+end
+elemental function ieee_copy_sign_a4(x,y)
+real(4),intent(in)::x
+real(4),intent(in)::y
+real(4)::ieee_copy_sign_a4
+end
+elemental function ieee_copy_sign_a8(x,y)
+real(8),intent(in)::x
+real(8),intent(in)::y
+real(8)::ieee_copy_sign_a8
+end
+elemental function ieee_copy_sign_a10(x,y)
+real(10),intent(in)::x
+real(10),intent(in)::y
+real(10)::ieee_copy_sign_a10
+end
+elemental function ieee_copy_sign_a16(x,y)
+real(16),intent(in)::x
+real(16),intent(in)::y
+real(16)::ieee_copy_sign_a16
+end
+pure function ieee_support_rounding_(round_type)
+type(ieee_round_type),intent(in)::round_type
+logical(4)::ieee_support_rounding_
+end
+pure function ieee_support_rounding_2(round_type,x)
+type(ieee_round_type),intent(in)::round_type
+real(2),intent(in)::x
+logical(4)::ieee_support_rounding_2
+end
+pure function ieee_support_rounding_3(round_type,x)
+type(ieee_round_type),intent(in)::round_type
+real(3),intent(in)::x
+logical(4)::ieee_support_rounding_3
+end
+pure function ieee_support_rounding_4(round_type,x)
+type(ieee_round_type),intent(in)::round_type
+real(4),intent(in)::x
+logical(4)::ieee_support_rounding_4
+end
+pure function ieee_support_rounding_8(round_type,x)
+type(ieee_round_type),intent(in)::round_type
+real(8),intent(in)::x
+logical(4)::ieee_support_rounding_8
+end
+pure function ieee_support_rounding_10(round_type,x)
+type(ieee_round_type),intent(in)::round_type
+real(10),intent(in)::x
+logical(4)::ieee_support_rounding_10
+end
+pure function ieee_support_rounding_16(round_type,x)
+type(ieee_round_type),intent(in)::round_type
+real(16),intent(in)::x
+logical(4)::ieee_support_rounding_16
+end
+end
Index: flang/lib/Frontend/CompilerInvocation.cpp
===================================================================
--- flang/lib/Frontend/CompilerInvocation.cpp
+++ flang/lib/Frontend/CompilerInvocation.cpp
@@ -293,7 +293,12 @@
 
   // Add the ordered list of -I's.
   for (const auto *currentArg : args.filtered(clang::driver::options::OPT_I))
-    opts.searchDirectoriesFromDashI.emplace_back(currentArg->getValue());
+    opts.searchDirectories.emplace_back(currentArg->getValue());
+
+  // Add the ordered list of -intrinsic-modules-path
+  for (const auto *currentArg :
+       args.filtered(clang::driver::options::OPT_fintrinsic_modules_path))
+    opts.searchDirectories.emplace_back(currentArg->getValue());
 }
 
 /// Parses all semantic related arguments and populates the variables
@@ -440,8 +445,8 @@
 
   fortranOptions.searchDirectories.insert(
       fortranOptions.searchDirectories.end(),
-      preprocessorOptions.searchDirectoriesFromDashI.begin(),
-      preprocessorOptions.searchDirectoriesFromDashI.end());
+      preprocessorOptions.searchDirectories.begin(),
+      preprocessorOptions.searchDirectories.end());
 
   // Add the directory supplied through -J/-module-dir to the list of search
   // directories
Index: flang/include/flang/Frontend/PreprocessorOptions.h
===================================================================
--- flang/include/flang/Frontend/PreprocessorOptions.h
+++ flang/include/flang/Frontend/PreprocessorOptions.h
@@ -24,11 +24,12 @@
 class PreprocessorOptions {
 public:
   std::vector<std::pair<std::string, /*isUndef*/ bool>> macros;
-  // Search directories specified by the user with -I
+  // Search directories specified by the user with -I and
+  // -fintrinsic-modules-path
   // TODO: When adding support for more options related to search paths,
   // consider collecting them in a separate aggregate. For now we keep it here
   // as there is no point creating a class for just one field.
-  std::vector<std::string> searchDirectoriesFromDashI;
+  std::vector<std::string> searchDirectories;
 
 public:
   PreprocessorOptions() {}
@@ -44,4 +45,4 @@
 
 } // namespace Fortran::frontend
 
-#endif // LLVM_FLANG_PREPROCESSOROPTIONS_H
\ No newline at end of file
+#endif // LLVM_FLANG_PREPROCESSOROPTIONS_H
Index: clang/lib/Driver/ToolChains/Flang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Flang.cpp
+++ clang/lib/Driver/ToolChains/Flang.cpp
@@ -39,7 +39,8 @@
 }
 
 void Flang::AddOtherOptions(const ArgList &Args, ArgStringList &CmdArgs) const {
-  Args.AddAllArgs(CmdArgs, options::OPT_module_dir);
+  Args.AddAllArgs(
+      CmdArgs, {options::OPT_module_dir, options::OPT_fintrinsic_modules_path});
 }
 
 void Flang::ConstructJob(Compilation &C, const JobAction &JA,
Index: clang/include/clang/Driver/Options.td
===================================================================
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4203,7 +4203,6 @@
 defm frontend_optimize : BooleanFFlag<"frontend-optimize">, Group<gfortran_Group>;
 defm init_local_zero : BooleanFFlag<"init-local-zero">, Group<gfortran_Group>;
 defm integer_4_integer_8 : BooleanFFlag<"integer-4-integer-8">, Group<gfortran_Group>;
-defm intrinsic_modules_path : BooleanFFlag<"intrinsic-modules-path">, Group<gfortran_Group>;
 defm max_identifier_length : BooleanFFlag<"max-identifier-length">, Group<gfortran_Group>;
 defm module_private : BooleanFFlag<"module-private">, Group<gfortran_Group>;
 defm pack_derived : BooleanFFlag<"pack-derived">, Group<gfortran_Group>;
@@ -4270,6 +4269,10 @@
 def fno_implicit_none : Flag<["-"], "fno-implicit-none">, Group<f_Group>;
 def falternative_parameter_statement : Flag<["-"], "falternative-parameter-statement">, Group<f_Group>,
   HelpText<"Enable the old style PARAMETER statement">;
+def fintrinsic_modules_path : Separate<["-"], "fintrinsic-modules-path">,  Group<f_Group>, MetaVarName<"<dir>">,
+  HelpText<"Specify the location of pre-compiled intrinsic modules.">,
+  DocBrief<[{This option specifies the location of pre-compiled intrinsic modules, 
+  if they are not in the default location expected by the compiler.}]>;
 
 }
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to