aboutsummaryrefslogtreecommitdiffstats
path: root/tools/llc/llc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/llc/llc.cpp')
-rw-r--r--tools/llc/llc.cpp68
1 files changed, 41 insertions, 27 deletions
diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp
index 8fbdc49..09ff461 100644
--- a/tools/llc/llc.cpp
+++ b/tools/llc/llc.cpp
@@ -28,6 +28,7 @@
#include "llvm/PassManager.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/FileSystem.h"
#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/ManagedStatic.h"
@@ -74,15 +75,24 @@ OptLevel("O",
static cl::opt<std::string>
TargetTriple("mtriple", cl::desc("Override target triple for module"));
-cl::opt<bool> NoVerify("disable-verify", cl::Hidden,
- cl::desc("Do not verify input module"));
+static cl::opt<bool> NoVerify("disable-verify", cl::Hidden,
+ cl::desc("Do not verify input module"));
-cl::opt<bool>
-DisableSimplifyLibCalls("disable-simplify-libcalls",
- cl::desc("Disable simplify-libcalls"),
- cl::init(false));
+static cl::opt<bool> DisableSimplifyLibCalls("disable-simplify-libcalls",
+ cl::desc("Disable simplify-libcalls"));
-static int compileModule(char**, LLVMContext&);
+static cl::opt<bool> ShowMCEncoding("show-mc-encoding", cl::Hidden,
+ cl::desc("Show encoding in .s output"));
+
+static cl::opt<bool> EnableDwarfDirectory(
+ "enable-dwarf-directory", cl::Hidden,
+ cl::desc("Use .file directives with an explicit directory."));
+
+static cl::opt<bool> AsmVerbose("asm-verbose",
+ cl::desc("Add comments to directives."),
+ cl::init(true));
+
+static int compileModule(char **, LLVMContext &);
// GetFileNameRoot - Helper function to get the basename of a filename.
static inline std::string
@@ -157,7 +167,7 @@ static tool_output_file *GetOutputStream(const char *TargetName,
if (!error.empty()) {
errs() << error << '\n';
delete FDOut;
- return 0;
+ return nullptr;
}
return FDOut;
@@ -207,17 +217,23 @@ static int compileModule(char **argv, LLVMContext &Context) {
// Load the module to be compiled...
SMDiagnostic Err;
std::unique_ptr<Module> M;
- Module *mod = 0;
+ Module *mod = nullptr;
Triple TheTriple;
bool SkipModule = MCPU == "help" ||
(!MAttrs.empty() && MAttrs.front() == "help");
+ // If user asked for the 'native' CPU, autodetect here. If autodection fails,
+ // this will set the CPU to an empty string which tells the target to
+ // pick a basic default.
+ if (MCPU == "native")
+ MCPU = sys::getHostCPUName();
+
// If user just wants to list available options, skip module loading
if (!SkipModule) {
M.reset(ParseIRFile(InputFilename, Err, Context));
mod = M.get();
- if (mod == 0) {
+ if (mod == nullptr) {
Err.print(argv[0], errs());
return 1;
}
@@ -265,19 +281,23 @@ static int compileModule(char **argv, LLVMContext &Context) {
TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
Options.DisableIntegratedAS = NoIntegratedAssembler;
+ Options.MCOptions.ShowMCEncoding = ShowMCEncoding;
+ Options.MCOptions.MCUseDwarfDirectory = EnableDwarfDirectory;
+ Options.MCOptions.AsmVerbose = AsmVerbose;
std::unique_ptr<TargetMachine> target(
TheTarget->createTargetMachine(TheTriple.getTriple(), MCPU, FeaturesStr,
Options, RelocModel, CMModel, OLvl));
assert(target.get() && "Could not allocate target machine!");
- assert(mod && "Should have exited after outputting help!");
- TargetMachine &Target = *target.get();
- if (DisableCFI)
- Target.setMCUseCFI(false);
+ // If we don't have a module then just exit now. We do this down
+ // here since the CPU/Feature help is underneath the target machine
+ // creation.
+ if (SkipModule)
+ return 0;
- if (EnableDwarfDirectory)
- Target.setMCUseDwarfDirectory(true);
+ assert(mod && "Should have exited if we didn't have a module!");
+ TargetMachine &Target = *target.get();
if (GenerateSoftFloatCalls)
FloatABIForCalls = FloatABI::Soft;
@@ -301,22 +321,16 @@ static int compileModule(char **argv, LLVMContext &Context) {
mod->setDataLayout(DL);
PM.add(new DataLayoutPass(mod));
- // Override default to generate verbose assembly.
- Target.setAsmVerbosityDefault(true);
-
- if (RelaxAll) {
- if (FileType != TargetMachine::CGFT_ObjectFile)
- errs() << argv[0]
+ if (RelaxAll.getNumOccurrences() > 0 &&
+ FileType != TargetMachine::CGFT_ObjectFile)
+ errs() << argv[0]
<< ": warning: ignoring -mc-relax-all because filetype != obj";
- else
- Target.setMCRelaxAll(true);
- }
{
formatted_raw_ostream FOS(Out->os());
- AnalysisID StartAfterID = 0;
- AnalysisID StopAfterID = 0;
+ AnalysisID StartAfterID = nullptr;
+ AnalysisID StopAfterID = nullptr;
const PassRegistry *PR = PassRegistry::getPassRegistry();
if (!StartAfter.empty()) {
const PassInfo *PI = PR->getPassInfo(StartAfter);