| OLD | NEW |
| 1 //===-- cc1as_main.cpp - Clang Assembler ---------------------------------===// | 1 //===-- cc1as_main.cpp - Clang Assembler ---------------------------------===// |
| 2 // | 2 // |
| 3 // The LLVM Compiler Infrastructure | 3 // The LLVM Compiler Infrastructure |
| 4 // | 4 // |
| 5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
| 7 // | 7 // |
| 8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
| 9 // | 9 // |
| 10 // This is the entry point to the clang -cc1as functionality, which implements | 10 // This is the entry point to the clang -cc1as functionality, which implements |
| 11 // the direct interface to the LLVM MC based assembler. | 11 // the direct interface to the LLVM MC based assembler. |
| 12 // | 12 // |
| 13 //===----------------------------------------------------------------------===// | 13 //===----------------------------------------------------------------------===// |
| 14 | 14 |
| 15 #include "clang/Basic/Diagnostic.h" | 15 #include "clang/Basic/Diagnostic.h" |
| 16 #include "clang/Basic/DiagnosticOptions.h" | 16 #include "clang/Basic/DiagnosticOptions.h" |
| 17 #include "clang/Driver/DriverDiagnostic.h" | 17 #include "clang/Driver/DriverDiagnostic.h" |
| 18 #include "clang/Driver/Options.h" | 18 #include "clang/Driver/Options.h" |
| 19 #include "clang/Frontend/FrontendDiagnostic.h" | 19 #include "clang/Frontend/FrontendDiagnostic.h" |
| 20 #include "clang/Frontend/TextDiagnosticPrinter.h" | 20 #include "clang/Frontend/TextDiagnosticPrinter.h" |
| 21 #include "clang/Frontend/Utils.h" | 21 #include "clang/Frontend/Utils.h" |
| 22 #include "llvm/ADT/StringSwitch.h" | 22 #include "llvm/ADT/StringSwitch.h" |
| 23 #include "llvm/ADT/Triple.h" | 23 #include "llvm/ADT/Triple.h" |
| 24 #include "llvm/IR/DataLayout.h" | 24 #include "llvm/IR/DataLayout.h" |
| 25 #include "llvm/MC/MCAsmBackend.h" | 25 #include "llvm/MC/MCAsmBackend.h" |
| 26 #include "llvm/MC/MCAsmInfo.h" | 26 #include "llvm/MC/MCAsmInfo.h" |
| 27 #include "llvm/MC/MCCodeEmitter.h" | 27 #include "llvm/MC/MCCodeEmitter.h" |
| 28 #include "llvm/MC/MCContext.h" | 28 #include "llvm/MC/MCContext.h" |
| 29 #include "llvm/MC/MCInstrInfo.h" | 29 #include "llvm/MC/MCInstrInfo.h" |
| 30 #include "llvm/MC/MCNaCl.h" // @LOCALMOD |
| 30 #include "llvm/MC/MCObjectFileInfo.h" | 31 #include "llvm/MC/MCObjectFileInfo.h" |
| 31 #include "llvm/MC/MCParser/MCAsmParser.h" | 32 #include "llvm/MC/MCParser/MCAsmParser.h" |
| 32 #include "llvm/MC/MCRegisterInfo.h" | 33 #include "llvm/MC/MCRegisterInfo.h" |
| 33 #include "llvm/MC/MCStreamer.h" | 34 #include "llvm/MC/MCStreamer.h" |
| 34 #include "llvm/MC/MCSubtargetInfo.h" | 35 #include "llvm/MC/MCSubtargetInfo.h" |
| 35 #include "llvm/MC/MCTargetAsmParser.h" | 36 #include "llvm/MC/MCTargetAsmParser.h" |
| 36 #include "llvm/MC/MCTargetOptions.h" | 37 #include "llvm/MC/MCTargetOptions.h" |
| 37 #include "llvm/Option/Arg.h" | 38 #include "llvm/Option/Arg.h" |
| 38 #include "llvm/Option/ArgList.h" | 39 #include "llvm/Option/ArgList.h" |
| 39 #include "llvm/Option/OptTable.h" | 40 #include "llvm/Option/OptTable.h" |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 Str.reset(createNullStreamer(Ctx)); | 376 Str.reset(createNullStreamer(Ctx)); |
| 376 } else { | 377 } else { |
| 377 assert(Opts.OutputType == AssemblerInvocation::FT_Obj && | 378 assert(Opts.OutputType == AssemblerInvocation::FT_Obj && |
| 378 "Invalid file type!"); | 379 "Invalid file type!"); |
| 379 MCCodeEmitter *CE = TheTarget->createMCCodeEmitter(*MCII, *MRI, *STI, Ctx); | 380 MCCodeEmitter *CE = TheTarget->createMCCodeEmitter(*MCII, *MRI, *STI, Ctx); |
| 380 MCAsmBackend *MAB = TheTarget->createMCAsmBackend(*MRI, Opts.Triple, | 381 MCAsmBackend *MAB = TheTarget->createMCAsmBackend(*MRI, Opts.Triple, |
| 381 Opts.CPU); | 382 Opts.CPU); |
| 382 Str.reset(TheTarget->createMCObjectStreamer(Opts.Triple, Ctx, *MAB, *Out, | 383 Str.reset(TheTarget->createMCObjectStreamer(Opts.Triple, Ctx, *MAB, *Out, |
| 383 CE, *STI, Opts.RelaxAll)); | 384 CE, *STI, Opts.RelaxAll)); |
| 384 Str.get()->InitSections(Opts.NoExecStack); | 385 Str.get()->InitSections(Opts.NoExecStack); |
| 386 // @LOCALMOD-BEGIN |
| 387 Triple T(Opts.Triple); |
| 388 if (T.isOSNaCl()) |
| 389 initializeNaClMCStreamer(*Str.get(), Ctx, T); |
| 390 // @LOCALMOD-END |
| 385 } | 391 } |
| 386 | 392 |
| 387 bool Failed = false; | 393 bool Failed = false; |
| 388 | 394 |
| 389 std::unique_ptr<MCAsmParser> Parser( | 395 std::unique_ptr<MCAsmParser> Parser( |
| 390 createMCAsmParser(SrcMgr, Ctx, *Str.get(), *MAI)); | 396 createMCAsmParser(SrcMgr, Ctx, *Str.get(), *MAI)); |
| 391 | 397 |
| 392 // FIXME: init MCTargetOptions from sanitizer flags here. | 398 // FIXME: init MCTargetOptions from sanitizer flags here. |
| 393 MCTargetOptions Options; | 399 MCTargetOptions Options; |
| 394 std::unique_ptr<MCTargetAsmParser> TAP( | 400 std::unique_ptr<MCTargetAsmParser> TAP( |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 | 486 |
| 481 // Execute the invocation, unless there were parsing errors. | 487 // Execute the invocation, unless there were parsing errors. |
| 482 bool Failed = Diags.hasErrorOccurred() || ExecuteAssembler(Asm, Diags); | 488 bool Failed = Diags.hasErrorOccurred() || ExecuteAssembler(Asm, Diags); |
| 483 | 489 |
| 484 // If any timers were active but haven't been destroyed yet, print their | 490 // If any timers were active but haven't been destroyed yet, print their |
| 485 // results now. | 491 // results now. |
| 486 TimerGroup::printAll(errs()); | 492 TimerGroup::printAll(errs()); |
| 487 | 493 |
| 488 return !!Failed; | 494 return !!Failed; |
| 489 } | 495 } |
| 490 | |
| OLD | NEW |