diff options
Diffstat (limited to 'tools/llvm-mc/llvm-mc.cpp')
-rw-r--r-- | tools/llvm-mc/llvm-mc.cpp | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/tools/llvm-mc/llvm-mc.cpp b/tools/llvm-mc/llvm-mc.cpp index 61fd2c4..84d578b 100644 --- a/tools/llvm-mc/llvm-mc.cpp +++ b/tools/llvm-mc/llvm-mc.cpp @@ -25,6 +25,7 @@ #include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCSubtargetInfo.h" #include "llvm/MC/MCTargetAsmParser.h" +#include "llvm/MC/MCTargetOptionsCommandFlags.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Compression.h" #include "llvm/Support/FileUtilities.h" @@ -64,12 +65,6 @@ static cl::opt<unsigned> OutputAsmVariant("output-asm-variant", cl::desc("Syntax variant to use for output printing")); -static cl::opt<bool> -RelaxAll("mc-relax-all", cl::desc("Relax all fixups")); - -static cl::opt<bool> -NoExecStack("mc-no-exec-stack", cl::desc("File doesn't need an exec stack")); - enum OutputFileType { OFT_Null, OFT_AssemblyFile, @@ -147,12 +142,12 @@ NoInitialTextSection("n", cl::desc("Don't assume assembly file starts " "in the text section")); static cl::opt<bool> -SaveTempLabels("L", cl::desc("Don't discard temporary labels")); - -static cl::opt<bool> GenDwarfForAssembly("g", cl::desc("Generate dwarf debugging info for assembly " "source files")); +static cl::opt<int> +DwarfVersion("dwarf-version", cl::desc("Dwarf version"), cl::init(4)); + static cl::opt<std::string> DebugCompilationDir("fdebug-compilation-dir", cl::desc("Specifies the debug info's compilation dir")); @@ -161,6 +156,12 @@ static cl::opt<std::string> MainFileName("main-file-name", cl::desc("Specifies the name we should consider the input file")); +static cl::opt<bool> SaveTempLabels("save-temp-labels", + cl::desc("Don't discard temporary labels")); + +static cl::opt<bool> NoExecStack("no-exec-stack", + cl::desc("File doesn't need an exec stack")); + enum ActionType { AC_AsLex, AC_Assemble, @@ -197,7 +198,7 @@ static const Target *GetTarget(const char *ProgName) { Error); if (!TheTarget) { errs() << ProgName << ": " << Error; - return 0; + return nullptr; } // Update the triple name and return the found target. @@ -215,7 +216,7 @@ static tool_output_file *GetOutputStream() { if (!Err.empty()) { errs() << Err << '\n'; delete Out; - return 0; + return nullptr; } return Out; @@ -320,9 +321,11 @@ static int AsLexInput(SourceMgr &SrcMgr, MCAsmInfo &MAI, tool_output_file *Out) static int AssembleInput(const char *ProgName, const Target *TheTarget, SourceMgr &SrcMgr, MCContext &Ctx, MCStreamer &Str, MCAsmInfo &MAI, MCSubtargetInfo &STI, MCInstrInfo &MCII) { - std::unique_ptr<MCAsmParser> Parser(createMCAsmParser(SrcMgr, Ctx, Str, MAI)); + std::unique_ptr<MCAsmParser> Parser( + createMCAsmParser(SrcMgr, Ctx, Str, MAI)); std::unique_ptr<MCTargetAsmParser> TAP( - TheTarget->createMCAsmParser(STI, *Parser, MCII)); + TheTarget->createMCAsmParser(STI, *Parser, MCII, + InitMCTargetOptionsFromFlags())); if (!TAP) { errs() << ProgName << ": error: this target does not support assembly parsing.\n"; @@ -403,6 +406,12 @@ int main(int argc, char **argv) { Ctx.setAllowTemporaryLabels(false); Ctx.setGenDwarfForAssembly(GenDwarfForAssembly); + if (DwarfVersion < 2 || DwarfVersion > 4) { + errs() << ProgName << ": Dwarf version " << DwarfVersion + << " is not supported." << '\n'; + return 1; + } + Ctx.setDwarfVersion(DwarfVersion); if (!DwarfDebugFlags.empty()) Ctx.setDwarfDebugFlags(StringRef(DwarfDebugFlags)); if (!DwarfDebugProducer.empty()) @@ -432,20 +441,19 @@ int main(int argc, char **argv) { std::unique_ptr<MCSubtargetInfo> STI( TheTarget->createMCSubtargetInfo(TripleName, MCPU, FeaturesStr)); - MCInstPrinter *IP = NULL; + MCInstPrinter *IP = nullptr; if (FileType == OFT_AssemblyFile) { IP = TheTarget->createMCInstPrinter(OutputAsmVariant, *MAI, *MCII, *MRI, *STI); - MCCodeEmitter *CE = 0; - MCAsmBackend *MAB = 0; + MCCodeEmitter *CE = nullptr; + MCAsmBackend *MAB = nullptr; if (ShowEncoding) { CE = TheTarget->createMCCodeEmitter(*MCII, *MRI, *STI, Ctx); MAB = TheTarget->createMCAsmBackend(*MRI, TripleName, MCPU); } Str.reset(TheTarget->createAsmStreamer(Ctx, FOS, /*asmverbose*/ true, - /*UseCFI*/ true, - /*useDwarfDirectory*/ - true, IP, CE, MAB, ShowInst)); + /*useDwarfDirectory*/ true, IP, CE, + MAB, ShowInst)); } else if (FileType == OFT_Null) { Str.reset(createNullStreamer(Ctx)); |