3434
3535using namespace Fortran ::frontend;
3636
37- // / Instantiate llvm::Target based on triple
38- static const llvm::Target* getTarget (llvm::StringRef triple) {
37+ // / Print supported cpus of the given target.
38+ static int printSupportedCPUs (llvm::StringRef triple) {
3939 std::string error;
4040 const llvm::Target *target =
4141 llvm::TargetRegistry::lookupTarget (triple, error);
4242 if (!target) {
4343 llvm::errs () << error;
4444 }
4545
46- return target;
47- }
48-
49- // / Print supported cpus of the given target.
50- static int printSupportedCPUs (llvm::StringRef triple) {
51- const llvm::Target *target = getTarget (triple);
52- if (!target) {
53- return 1 ;
54- }
55-
5646 // the target machine will handle the mcpu printing
5747 llvm::TargetOptions targetOpts;
5848 std::unique_ptr<llvm::TargetMachine> targetMachine (
@@ -64,8 +54,9 @@ static int printSupportedCPUs(llvm::StringRef triple) {
6454// / Check that given CPU is valid for given target.
6555static bool checkSupportedCPU (clang::DiagnosticsEngine& diags, llvm::StringRef str_cpu, llvm::StringRef str_triple) {
6656
57+ llvm::errs () << " EE str_cpu = '" << str_cpu << " ', str_triple = '" << str_triple << " '\n " ;
6758 llvm::Triple triple{str_triple};
68- if (triple.getArch () == llvm::Triple::x86_64) {
59+ if (triple.getArch () == llvm::Triple::x86_64 && !str_cpu. empty () ) {
6960 const bool only64bit{true };
7061 llvm::X86::CPUKind x86cpu = llvm::X86::parseArchX86 (str_cpu, only64bit);
7162 if (x86cpu == llvm::X86::CK_None) {
@@ -92,6 +83,12 @@ int fc1_main(llvm::ArrayRef<const char *> argv, const char *argv0) {
9283 if (!flang->hasDiagnostics ())
9384 return 1 ;
9485
86+ llvm::errs () << " EE args: " ;
87+ for (auto arg : argv) {
88+ llvm::errs () << " \" " << arg << " \" " ;
89+ }
90+ llvm::errs () << " \n " ;
91+
9592 // We will buffer diagnostics from argument parsing so that we can output
9693 // them using a well formed diagnostic object.
9794 TextDiagnosticBuffer *diagsBuffer = new TextDiagnosticBuffer;
@@ -116,8 +113,8 @@ int fc1_main(llvm::ArrayRef<const char *> argv, const char *argv0) {
116113 return printSupportedCPUs (flang->getInvocation ().getTargetOpts ().triple );
117114
118115 // Check that requested CPU can be properly supported
119- if (! checkSupportedCPU (diags, flang-> getInvocation (). getTargetOpts (). cpu , flang-> getInvocation (). getTargetOpts (). triple ))
120- return 1 ;
116+ success = success &&
117+ checkSupportedCPU (diags, flang-> getInvocation (). getTargetOpts (). cpu , flang-> getInvocation (). getTargetOpts (). triple ) ;
121118
122119 diagsBuffer->flushDiagnostics (flang->getDiagnostics ());
123120
0 commit comments