Skip to content

Commit d25308d

Browse files
committed
Remove experimental code
1 parent 12e6d9a commit d25308d

File tree

5 files changed

+13
-115
lines changed

5 files changed

+13
-115
lines changed

flang/include/flang/Frontend/CompilerInvocation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ class CompilerInvocation : public CompilerInvocationBase {
294294

295295
/// Set the Fortran options to user-specified values.
296296
/// These values are found in the preprocessor options.
297-
void setFortranOpts( const llvm::TargetMachine &targetMachine);
297+
void setFortranOpts();
298298

299299
/// Set the Semantic Options
300300
void setSemanticsOpts(Fortran::parser::AllCookedSources &);

flang/include/flang/Parser/options.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,8 @@ struct Options {
2626
bool isFixedForm{false};
2727
int fixedFormColumns{72};
2828
common::LanguageFeatureControl features;
29-
30-
/// Search paths from -I/-J/-module-dir/-fintrinsic-modules-path for
3129
std::vector<std::string> searchDirectories;
32-
33-
/// Search paths from -fintrinsic-modules-path
34-
/// Muliple paths are supported.
35-
std::vector<std::string> intrinsicModuleDirectories;
36-
30+
std::vector<std::string> intrinsicModuleDirectories;
3731
std::vector<Predefinition> predefinitions;
3832
bool instrumentedParse{false};
3933
bool isModuleFile{false};

flang/include/flang/Semantics/semantics.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -315,19 +315,9 @@ class SemanticsContext {
315315
const common::LangOptions &langOpts_;
316316
parser::AllCookedSources &allCookedSources_;
317317
std::optional<parser::CharBlock> location_;
318-
319-
/// Search paths for non-intrinsic modules.
320-
/// Originates from the -J/-module-dir command line options
321318
std::vector<std::string> searchDirectories_;
322-
323-
/// Search paths for intrinsic modules.
324-
/// Originates from the -fintrinsic-modules-path line option
325319
std::vector<std::string> intrinsicModuleDirectories_;
326-
327-
/// Location for emitting module files.
328-
/// Originates from the -J/-module-dir command line options
329320
std::string moduleDirectory_{"."s};
330-
331321
std::string moduleFileSuffix_{".mod"};
332322
bool underscoring_{true};
333323
bool warnOnNonstandardUsage_{false};

flang/lib/Frontend/CompilerInstance.cpp

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -154,23 +154,14 @@ bool CompilerInstance::executeAction(FrontendAction &act) {
154154

155155
llvm::Triple targetTriple{llvm::Triple(invoc.getTargetOpts().triple)};
156156

157-
158-
159-
160-
if (!setUpTargetMachine())
161-
return false;
162-
163157
// Set some sane defaults for the frontend.
164158
invoc.setDefaultFortranOpts();
165-
166-
// Update the fortran options based on user-based input.
167-
invoc.setFortranOpts(getTargetMachine());
168-
169-
170-
// Set the encoding to read all input files in based on user input.
159+
// Update the fortran options based on user-based input.
160+
invoc.setFortranOpts();
161+
// Set the encoding to read all input files in based on user input.
171162
allSources->set_encoding(invoc.getFortranOpts().encoding);
172-
173-
163+
if (!setUpTargetMachine())
164+
return false;
174165
// Set options controlling lowering to FIR.
175166
invoc.setLoweringOptions();
176167

flang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 6 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,11 @@
2525
#include "clang/Basic/DiagnosticOptions.h"
2626
#include "clang/Driver/CommonArgs.h"
2727
#include "clang/Driver/Driver.h"
28-
#include "clang/Driver/ToolChain.h"
2928
#include "clang/Driver/OptionUtils.h"
3029
#include "clang/Driver/Options.h"
3130
#include "llvm/ADT/ArrayRef.h"
3231
#include "llvm/ADT/StringRef.h"
3332
#include "llvm/ADT/StringSwitch.h"
34-
#include "llvm/Support/VirtualFileSystem.h"
3533
#include "llvm/Frontend/Debug/Options.h"
3634
#include "llvm/Frontend/Driver/CodeGenOptions.h"
3735
#include "llvm/Option/Arg.h"
@@ -1501,11 +1499,11 @@ bool CompilerInvocation::createFromArgs(
15011499
success = false;
15021500
}
15031501

1504-
// User-specified or default resource dir
1502+
// User-specified or default resource dir
15051503
if (const llvm::opt::Arg *a = args.getLastArg(clang::driver::options::OPT_resource_dir))
15061504
invoc.resourceDir = a->getValue();
15071505
else
1508-
clang::driver::Driver::GetResourcesPath(llvm::sys::fs::getMainExecutable(argv0, nullptr));
1506+
invoc.resourceDir = clang::driver::Driver::GetResourcesPath(llvm::sys::fs::getMainExecutable(argv0, nullptr));
15091507

15101508
// -flang-experimental-hlfir
15111509
if (args.hasArg(clang::driver::options::OPT_flang_experimental_hlfir) ||
@@ -1726,7 +1724,7 @@ void CompilerInvocation::setDefaultPredefinitions() {
17261724
}
17271725
}
17281726

1729-
void CompilerInvocation::setFortranOpts(const llvm::TargetMachine &targetMachine) {
1727+
void CompilerInvocation::setFortranOpts() {
17301728
auto &fortranOptions = getFortranOpts();
17311729
const auto &frontendOptions = getFrontendOpts();
17321730
const auto &preprocessorOptions = getPreprocessorOpts();
@@ -1751,61 +1749,23 @@ void CompilerInvocation::setFortranOpts(const llvm::TargetMachine &targetMachine
17511749
preprocessorOptions.searchDirectoriesFromDashI.begin(),
17521750
preprocessorOptions.searchDirectoriesFromDashI.end());
17531751

1754-
// Add the ordered list of -fintrinsic-modules-path
1755-
#if 1
1756-
// Legacy
1757-
// TODO: should not be used for finding 'INCLUDE' files
1752+
// Add the ordered list of -intrinsic-modules-path
17581753
fortranOptions.searchDirectories.insert(
17591754
fortranOptions.searchDirectories.end(),
1760-
preprocessorOptions.searchDirectoriesFromIntrModPath.begin(), // should this be searchDirectoriesFromDashJ???
1755+
preprocessorOptions.searchDirectoriesFromIntrModPath.begin(),
17611756
preprocessorOptions.searchDirectoriesFromIntrModPath.end());
1762-
#endif
1763-
1764-
1765-
1766-
17671757

17681758

1769-
// Add the default intrinsic module directory
1770-
#if 1
1771-
// gfortran prepends this path to the usual intrinsics dir
1759+
// Add the ordered list of -fintrinsic-modules-path
17721760
fortranOptions.intrinsicModuleDirectories.insert(
17731761
fortranOptions.intrinsicModuleDirectories.end(),
17741762
preprocessorOptions.searchDirectoriesFromIntrModPath.begin(),
17751763
preprocessorOptions.searchDirectoriesFromIntrModPath.end());
1776-
#endif
1777-
1778-
// FIXME: Assembling the list of module search paths is the driver's job.
1779-
1780-
#if 0
1781-
auto vfs = llvm::vfs::createPhysicalFileSystem();
1782-
auto defaultIntrinsicsDir = clang::driver:: ToolChain:: getDefaultIntrinsicModuleDir(getResourceDir(), targetMachine.getTargetTriple(),*vfs , nullptr) ;
1783-
if (defaultIntrinsicsDir)
1784-
fortranOptions.intrinsicModuleDirectories.push_back(*defaultIntrinsicsDir);
1785-
#endif
1786-
1787-
#if 0
1788-
llvm::errs() << "\nnew intr search dirs:\n";
1789-
for (auto&& x : fortranOptions.intrinsicModuleDirectories) {
1790-
llvm::errs() << x << "\n";
1791-
}
1792-
#endif
1793-
1794-
#if 0
1795-
llvm::SmallString<128> intrinsicsDir { resourceDir };
1796-
llvm::sys::path::append(intrinsicsDir, "finclude", triple);
1797-
fortranOptions.intrinsicModuleDirectories.emplace_back(intrinsicsDir);
1798-
fortranOptions.intrinsicModuleDirectories.emplace_back(getIntrinsicDir(getArgv0()));
1799-
#endif
18001764

1801-
1802-
// FIXME: Assembling the list of module search paths is the driver's job.
1803-
#if 1
18041765
// Add the directory supplied through -J/-module-dir to the list of search
18051766
// directories
18061767
if (moduleDirJ != ".")
18071768
fortranOptions.searchDirectories.emplace_back(moduleDirJ);
1808-
#endif
18091769

18101770
if (frontendOptions.instrumentedParse)
18111771
fortranOptions.instrumentedParse = true;
@@ -1825,47 +1785,10 @@ CompilerInvocation::getSemanticsCtx(
18251785
const llvm::TargetMachine &targetMachine) {
18261786
auto &fortranOptions = getFortranOpts();
18271787

1828-
1829-
1830-
#if 0
1831-
auto &moduleDirJ = getModuleDir();
1832-
1833-
auto triple = targetMachine.getTargetTriple();
1834-
llvm::SmallVector<std::string> searchDirectories{ llvm ::ArrayRef ( fortranOptions.searchDirectories))};
1835-
if (moduleDirJ != ".")
1836-
searchDirectories.emplace_back(moduleDirJ);
1837-
1838-
llvm::SmallVector<std::string> intrinsicModuleDirectories { llvm::ArrayRef(fortranOptions.intrinsicModuleDirectories)};
1839-
1840-
// FIXME: Do not modify intrinsicIncludeDirs directly, should be treated as immutable just like argv.
1841-
// TODO: Normlize triple directory as clang does; best refactor with ToolChain::getDefaultIntrinsicModulePaths() used by the flang driver.
1842-
std::string mainExe = llvm::sys::fs::getMainExecutable(argv[0], nullptr);
1843-
llvm::StringRef prefixDir = llvm::sys::path::parent_path( llvm::sys::path::parent_path(mainExe ));
1844-
llvm::SmallString<128> resourceDir (prefixDir);
1845-
llvm::sys::path::append(resourceDir, /*CLANG_INSTALL_LIBDIR_BASENAME*/ "lib", "clang", FLANG_VERSION_MAJOR_STRING);
1846-
llvm::sys::path::append(resourceDir, "finclude", triple);
1847-
llvm::errs() << resourceDir << "\n";
1848-
intrinsicIncludeDirs.push_back(resourceDir.str().str());
1849-
1850-
#endif
1851-
1852-
18531788
auto semanticsContext = std::make_unique<semantics::SemanticsContext>(
18541789
getDefaultKinds(), fortranOptions.features, getLangOpts(),
18551790
allCookedSources);
18561791

1857-
#if 0
1858-
llvm::errs() << "\nsearch dirs:\n";
1859-
for (auto&& x : fortranOptions.searchDirectories) {
1860-
llvm::errs() << x << "\n";
1861-
}
1862-
1863-
llvm::errs() << "\nintrinsic search dirs:\n";
1864-
for (auto&& x : fortranOptions.intrinsicModuleDirectories) {
1865-
llvm::errs() << x << "\n";
1866-
}
1867-
#endif
1868-
18691792
semanticsContext->set_moduleDirectory(getModuleDir())
18701793
.set_searchDirectories(fortranOptions.searchDirectories)
18711794
.set_intrinsicModuleDirectories(fortranOptions.intrinsicModuleDirectories)

0 commit comments

Comments
 (0)