diff --git a/driver/CompileGo.cpp b/driver/CompileGo.cpp index 585957c..88e1612 100644 --- a/driver/CompileGo.cpp +++ b/driver/CompileGo.cpp @@ -469,8 +469,25 @@ bool CompileGoImpl::setup(const Action &jobAction) Options.AllowFPOpFusion = *dofuse; // Support -march - std::string cpuStr; opt::Arg *cpuarg = args_.getLastArg(gollvm::options::OPT_march_EQ); + if (!setupArch(cpuarg, targetCpuAttr_, targetFeaturesAttr_, triple_, progname_)) + return false; + + // Create target machine + Optional CM = None; + target_.reset( + TheTarget->createTargetMachine(triple_.getTriple(), + targetCpuAttr_, targetFeaturesAttr_, + Options, driver_.reconcileRelocModel(), + CM, cgolvl_)); + assert(target_.get() && "Could not allocate target machine!"); + + return true; +} + +bool setupArch(opt::Arg *cpuarg, std::string &cpu, std::string &attrs, + Triple triple_, const char *progname_) { + std::string cpuStr; if (cpuarg != nullptr) { std::string val(cpuarg->getValue()); if (val == "native") @@ -510,18 +527,8 @@ bool CompileGoImpl::setup(const Action &jobAction) return false; } } - targetCpuAttr_ = cpuAttrs->cpu; - targetFeaturesAttr_ = cpuAttrs->attrs; - - // Create target machine - Optional CM = None; - target_.reset( - TheTarget->createTargetMachine(triple_.getTriple(), - targetCpuAttr_, targetFeaturesAttr_, - Options, driver_.reconcileRelocModel(), - CM, cgolvl_)); - assert(target_.get() && "Could not allocate target machine!"); - + cpu = cpuAttrs->cpu; + attrs = cpuAttrs->attrs; return true; } diff --git a/driver/CompileGo.h b/driver/CompileGo.h index c33b8df..62551b1 100644 --- a/driver/CompileGo.h +++ b/driver/CompileGo.h @@ -43,6 +43,9 @@ class CompileGo : public InternalTool { std::unique_ptr impl_; }; +bool setupArch(llvm::opt::Arg *cpuarg, std::string &cpu, std::string &attrs, + llvm::Triple triple_, const char *progname_); + } // end namespace driver } // end namespace gollvm diff --git a/driver/Driver.cpp b/driver/Driver.cpp index 856ba15..c8a7db5 100644 --- a/driver/Driver.cpp +++ b/driver/Driver.cpp @@ -186,7 +186,8 @@ bool Driver::supportedAsmOptions() continue; } if (value.startswith("-compress-debug-sections") || - value.startswith("--compress-debug-sections")) { + value.startswith("--compress-debug-sections") || + value.startswith("-march")) { continue; } // Unrecognized -Wa,... option diff --git a/driver/IntegAssembler.cpp b/driver/IntegAssembler.cpp index 39d080f..ee6bf65 100644 --- a/driver/IntegAssembler.cpp +++ b/driver/IntegAssembler.cpp @@ -20,6 +20,7 @@ #include "GollvmOptions.h" #include "GollvmConfig.h" #include "GollvmPasses.h" +#include "CompileGo.h" #include "Action.h" #include "Artifact.h" @@ -178,6 +179,8 @@ bool IntegAssemblerImpl::invokeAssembler() assert(MRI && "Unable to create target register info!"); MCTargetOptions MCOptions; + if (triple_.getArch() == llvm::Triple::riscv64) + MCOptions.ABIName = "lp64d"; std::unique_ptr MAI( TheTarget->createMCAsmInfo(*MRI, Trip, MCOptions)); assert(MAI && "Unable to create target asm info!"); @@ -185,16 +188,6 @@ bool IntegAssemblerImpl::invokeAssembler() // Note: -Xassembler and -Wa, options should already have been // examined at this point. - // FIXME: no support yet for -march (bring over from CompileGo.cpp) - opt::Arg *cpuarg = args_.getLastArg(gollvm::options::OPT_march_EQ); - if (cpuarg != nullptr) { - errs() << progname_ << ": internal error: option '" - << cpuarg->getAsString(args_) - << "' not yet implemented in integrated assembler\n"; - assert(false); - return false; - } - // Support for compressed debug. llvm::DebugCompressionType CompressDebugSections = llvm::DebugCompressionType::None; @@ -208,6 +201,8 @@ bool IntegAssemblerImpl::invokeAssembler() // Build up the feature string from the target feature list. std::string FS; std::string CPU; + opt::Arg *cpuarg = args_.getLastArg(gollvm::options::OPT_march_EQ); + setupArch(cpuarg, CPU, FS, triple_, progname_); std::unique_ptr Str; std::unique_ptr MCII(TheTarget->createMCInstrInfo()); std::unique_ptr STI(