Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Side by Side Diff: tools/llvm-mc/llvm-mc.cpp

Issue 939073008: Rebased PNaCl localmods in LLVM to 223109 (Closed)
Patch Set: undo localmod Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/llvm-link/CMakeLists.txt ('k') | tools/llvm-nm/CMakeLists.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===-- llvm-mc.cpp - Machine Code Hacking Driver -------------------------===// 1 //===-- llvm-mc.cpp - Machine Code Hacking Driver -------------------------===//
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 utility is a simple driver that allows command line hacking on machine 10 // This utility is a simple driver that allows command line hacking on machine
11 // code. 11 // code.
12 // 12 //
13 //===----------------------------------------------------------------------===// 13 //===----------------------------------------------------------------------===//
14 14
15 #include "Disassembler.h" 15 #include "Disassembler.h"
16 #include "llvm/MC/MCAsmBackend.h" 16 #include "llvm/MC/MCAsmBackend.h"
17 #include "llvm/MC/MCAsmInfo.h" 17 #include "llvm/MC/MCAsmInfo.h"
18 #include "llvm/MC/MCContext.h" 18 #include "llvm/MC/MCContext.h"
19 #include "llvm/MC/MCInstPrinter.h" 19 #include "llvm/MC/MCInstPrinter.h"
20 #include "llvm/MC/MCInstrInfo.h" 20 #include "llvm/MC/MCInstrInfo.h"
21 #include "llvm/MC/MCNaCl.h"
21 #include "llvm/MC/MCObjectFileInfo.h" 22 #include "llvm/MC/MCObjectFileInfo.h"
22 #include "llvm/MC/MCParser/AsmLexer.h" 23 #include "llvm/MC/MCParser/AsmLexer.h"
23 #include "llvm/MC/MCRegisterInfo.h" 24 #include "llvm/MC/MCRegisterInfo.h"
24 #include "llvm/MC/MCSectionMachO.h" 25 #include "llvm/MC/MCSectionMachO.h"
25 #include "llvm/MC/MCStreamer.h" 26 #include "llvm/MC/MCStreamer.h"
26 #include "llvm/MC/MCSubtargetInfo.h" 27 #include "llvm/MC/MCSubtargetInfo.h"
27 #include "llvm/MC/MCTargetAsmParser.h" 28 #include "llvm/MC/MCTargetAsmParser.h"
28 #include "llvm/MC/MCTargetOptionsCommandFlags.h" 29 #include "llvm/MC/MCTargetOptionsCommandFlags.h"
29 #include "llvm/Support/CommandLine.h" 30 #include "llvm/Support/CommandLine.h"
30 #include "llvm/Support/Compression.h" 31 #include "llvm/Support/Compression.h"
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 if (!Out) 440 if (!Out)
440 return 1; 441 return 1;
441 442
442 formatted_raw_ostream FOS(Out->os()); 443 formatted_raw_ostream FOS(Out->os());
443 std::unique_ptr<MCStreamer> Str; 444 std::unique_ptr<MCStreamer> Str;
444 445
445 std::unique_ptr<MCInstrInfo> MCII(TheTarget->createMCInstrInfo()); 446 std::unique_ptr<MCInstrInfo> MCII(TheTarget->createMCInstrInfo());
446 std::unique_ptr<MCSubtargetInfo> STI( 447 std::unique_ptr<MCSubtargetInfo> STI(
447 TheTarget->createMCSubtargetInfo(TripleName, MCPU, FeaturesStr)); 448 TheTarget->createMCSubtargetInfo(TripleName, MCPU, FeaturesStr));
448 449
449 MCInstPrinter *IP = nullptr; 450 Triple T(TripleName); // @LOCALMOD
451
452 MCInstPrinter *IP = NULL;
450 if (FileType == OFT_AssemblyFile) { 453 if (FileType == OFT_AssemblyFile) {
451 IP = 454 IP =
452 TheTarget->createMCInstPrinter(OutputAsmVariant, *MAI, *MCII, *MRI, *STI); 455 TheTarget->createMCInstPrinter(OutputAsmVariant, *MAI, *MCII, *MRI, *STI);
453 456
454 // Set the display preference for hex vs. decimal immediates. 457 // Set the display preference for hex vs. decimal immediates.
455 IP->setPrintImmHex(PrintImmHex); 458 IP->setPrintImmHex(PrintImmHex);
456 459
457 // Set up the AsmStreamer. 460 // Set up the AsmStreamer.
458 MCCodeEmitter *CE = nullptr; 461 MCCodeEmitter *CE = nullptr;
459 MCAsmBackend *MAB = nullptr; 462 MCAsmBackend *MAB = nullptr;
460 if (ShowEncoding) { 463 if (ShowEncoding || T.isOSNaCl()) { // @LOCALMOD
461 CE = TheTarget->createMCCodeEmitter(*MCII, *MRI, *STI, Ctx); 464 CE = TheTarget->createMCCodeEmitter(*MCII, *MRI, *STI, Ctx);
462 MAB = TheTarget->createMCAsmBackend(*MRI, TripleName, MCPU); 465 MAB = TheTarget->createMCAsmBackend(*MRI, TripleName, MCPU);
463 } 466 }
464 Str.reset(TheTarget->createAsmStreamer(Ctx, FOS, /*asmverbose*/ true, 467 Str.reset(TheTarget->createAsmStreamer(Ctx, FOS, /*asmverbose*/ true,
465 /*useDwarfDirectory*/ true, IP, CE, 468 /*useDwarfDirectory*/ true, IP, CE,
466 MAB, ShowInst)); 469 MAB, ShowInst));
467 470
468 } else if (FileType == OFT_Null) { 471 } else if (FileType == OFT_Null) {
469 Str.reset(createNullStreamer(Ctx)); 472 Str.reset(createNullStreamer(Ctx));
470 } else { 473 } else {
471 assert(FileType == OFT_ObjectFile && "Invalid file type!"); 474 assert(FileType == OFT_ObjectFile && "Invalid file type!");
472 MCCodeEmitter *CE = TheTarget->createMCCodeEmitter(*MCII, *MRI, *STI, Ctx); 475 MCCodeEmitter *CE = TheTarget->createMCCodeEmitter(*MCII, *MRI, *STI, Ctx);
473 MCAsmBackend *MAB = TheTarget->createMCAsmBackend(*MRI, TripleName, MCPU); 476 MCAsmBackend *MAB = TheTarget->createMCAsmBackend(*MRI, TripleName, MCPU);
474 Str.reset(TheTarget->createMCObjectStreamer(TripleName, Ctx, *MAB, FOS, CE, 477 Str.reset(TheTarget->createMCObjectStreamer(TripleName, Ctx, *MAB, FOS, CE,
475 *STI, RelaxAll)); 478 *STI, RelaxAll));
476 if (NoExecStack) 479 if (NoExecStack)
477 Str->InitSections(true); 480 Str->InitSections(true);
481 // @LOCALMOD-BEGIN
482 if (T.isOSNaCl()) {
483 // If the above non-localmod does InitSections unconditionally,
484 // we can use that.
485 Str->InitSections(NoExecStack);
486 initializeNaClMCStreamer(*Str.get(), Ctx, T);
487 }
488 // @LOCALMOD-END
478 } 489 }
479 490
480 int Res = 1; 491 int Res = 1;
481 bool disassemble = false; 492 bool disassemble = false;
482 switch (Action) { 493 switch (Action) {
483 case AC_AsLex: 494 case AC_AsLex:
484 Res = AsLexInput(SrcMgr, *MAI, Out.get()); 495 Res = AsLexInput(SrcMgr, *MAI, Out.get());
485 break; 496 break;
486 case AC_Assemble: 497 case AC_Assemble:
487 Res = AssembleInput(ProgName, TheTarget, SrcMgr, Ctx, *Str, *MAI, *STI, 498 Res = AssembleInput(ProgName, TheTarget, SrcMgr, Ctx, *Str, *MAI, *STI,
488 *MCII, MCOptions); 499 *MCII, MCOptions);
489 break; 500 break;
490 case AC_MDisassemble: 501 case AC_MDisassemble:
491 assert(IP && "Expected assembly output"); 502 assert(IP && "Expected assembly output");
492 IP->setUseMarkup(1); 503 IP->setUseMarkup(1);
493 disassemble = true; 504 disassemble = true;
494 break; 505 break;
495 case AC_Disassemble: 506 case AC_Disassemble:
496 disassemble = true; 507 disassemble = true;
497 break; 508 break;
498 } 509 }
499 if (disassemble) 510 if (disassemble)
500 Res = Disassembler::disassemble(*TheTarget, TripleName, *STI, *Str, 511 Res = Disassembler::disassemble(*TheTarget, TripleName, *STI, *Str,
501 *Buffer, SrcMgr, Out->os()); 512 *Buffer, SrcMgr, Out->os());
502 513
503 // Keep output if no errors. 514 // Keep output if no errors.
504 if (Res == 0) Out->keep(); 515 if (Res == 0) Out->keep();
505 return Res; 516 return Res;
506 } 517 }
OLDNEW
« no previous file with comments | « tools/llvm-link/CMakeLists.txt ('k') | tools/llvm-nm/CMakeLists.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698