OLD | NEW |
1 //===-- X86AsmPrinter.cpp - Convert X86 LLVM code to AT&T assembly --------===// | 1 //===-- X86AsmPrinter.cpp - Convert X86 LLVM code to AT&T assembly --------===// |
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 file contains a printer that converts from our internal representation | 10 // This file contains a printer that converts from our internal representation |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "llvm/CodeGen/MachineValueType.h" | 23 #include "llvm/CodeGen/MachineValueType.h" |
24 #include "llvm/CodeGen/TargetLoweringObjectFileImpl.h" | 24 #include "llvm/CodeGen/TargetLoweringObjectFileImpl.h" |
25 #include "llvm/IR/DebugInfo.h" | 25 #include "llvm/IR/DebugInfo.h" |
26 #include "llvm/IR/DerivedTypes.h" | 26 #include "llvm/IR/DerivedTypes.h" |
27 #include "llvm/IR/Mangler.h" | 27 #include "llvm/IR/Mangler.h" |
28 #include "llvm/IR/Module.h" | 28 #include "llvm/IR/Module.h" |
29 #include "llvm/IR/Type.h" | 29 #include "llvm/IR/Type.h" |
30 #include "llvm/MC/MCAsmInfo.h" | 30 #include "llvm/MC/MCAsmInfo.h" |
31 #include "llvm/MC/MCContext.h" | 31 #include "llvm/MC/MCContext.h" |
32 #include "llvm/MC/MCExpr.h" | 32 #include "llvm/MC/MCExpr.h" |
| 33 #include "llvm/MC/MCNaCl.h" // @LOCALMOD |
33 #include "llvm/MC/MCSectionCOFF.h" | 34 #include "llvm/MC/MCSectionCOFF.h" |
34 #include "llvm/MC/MCSectionMachO.h" | 35 #include "llvm/MC/MCSectionMachO.h" |
35 #include "llvm/MC/MCStreamer.h" | 36 #include "llvm/MC/MCStreamer.h" |
36 #include "llvm/MC/MCSymbol.h" | 37 #include "llvm/MC/MCSymbol.h" |
37 #include "llvm/Support/COFF.h" | 38 #include "llvm/Support/COFF.h" |
38 #include "llvm/Support/Debug.h" | 39 #include "llvm/Support/Debug.h" |
39 #include "llvm/Support/ErrorHandling.h" | 40 #include "llvm/Support/ErrorHandling.h" |
40 #include "llvm/Support/TargetRegistry.h" | 41 #include "llvm/Support/TargetRegistry.h" |
41 using namespace llvm; | 42 using namespace llvm; |
42 | 43 |
(...skipping 21 matching lines...) Expand all Loading... |
64 // Have common code print out the function header with linkage info etc. | 65 // Have common code print out the function header with linkage info etc. |
65 EmitFunctionHeader(); | 66 EmitFunctionHeader(); |
66 | 67 |
67 // Emit the rest of the function body. | 68 // Emit the rest of the function body. |
68 EmitFunctionBody(); | 69 EmitFunctionBody(); |
69 | 70 |
70 // We didn't modify anything. | 71 // We didn't modify anything. |
71 return false; | 72 return false; |
72 } | 73 } |
73 | 74 |
| 75 // @LOCALMOD-BEGIN |
| 76 bool X86AsmPrinter::UseReadOnlyJumpTables() const { |
| 77 return Subtarget->isTargetNaCl(); |
| 78 } |
| 79 |
| 80 unsigned X86AsmPrinter::GetTargetBasicBlockAlign() const { |
| 81 if (Subtarget->isTargetNaCl()) |
| 82 return 5; |
| 83 return 0; |
| 84 } |
| 85 |
| 86 unsigned X86AsmPrinter::GetTargetLabelAlign(const MachineInstr *MI) const { |
| 87 if (Subtarget->isTargetNaCl()) { |
| 88 switch (MI->getOpcode()) { |
| 89 default: return 0; |
| 90 // These labels may indicate an indirect entry point that is |
| 91 // externally reachable and hence must be bundle aligned. |
| 92 // Note: these labels appear to be always at basic block beginnings |
| 93 // so it may be possible to simply set the MBB alignment. |
| 94 // However, it is unclear whether this always holds. |
| 95 case TargetOpcode::EH_LABEL: |
| 96 case TargetOpcode::GC_LABEL: |
| 97 return 5; |
| 98 } |
| 99 } |
| 100 return 0; |
| 101 } |
| 102 // @LOCALMOD-END |
| 103 |
74 /// printSymbolOperand - Print a raw symbol reference operand. This handles | 104 /// printSymbolOperand - Print a raw symbol reference operand. This handles |
75 /// jump tables, constant pools, global address and external symbols, all of | 105 /// jump tables, constant pools, global address and external symbols, all of |
76 /// which print to a label with various suffixes for relocation types etc. | 106 /// which print to a label with various suffixes for relocation types etc. |
77 static void printSymbolOperand(X86AsmPrinter &P, const MachineOperand &MO, | 107 static void printSymbolOperand(X86AsmPrinter &P, const MachineOperand &MO, |
78 raw_ostream &O) { | 108 raw_ostream &O) { |
79 switch (MO.getType()) { | 109 switch (MO.getType()) { |
80 default: llvm_unreachable("unknown symbol type!"); | 110 default: llvm_unreachable("unknown symbol type!"); |
81 case MachineOperand::MO_ConstantPoolIndex: | 111 case MachineOperand::MO_ConstantPoolIndex: |
82 O << *P.GetCPISymbol(MO.getIndex()); | 112 O << *P.GetCPISymbol(MO.getIndex()); |
83 P.printOffset(MO.getOffset(), O); | 113 P.printOffset(MO.getOffset(), O); |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 // for "registered SEH". This means that all SEH handler entry points | 551 // for "registered SEH". This means that all SEH handler entry points |
522 // must be registered in .sxdata. Use of any unregistered handlers will | 552 // must be registered in .sxdata. Use of any unregistered handlers will |
523 // cause the process to terminate immediately. LLVM does not know how to | 553 // cause the process to terminate immediately. LLVM does not know how to |
524 // register any SEH handlers, so its object files should be safe. | 554 // register any SEH handlers, so its object files should be safe. |
525 S->setAbsolute(); | 555 S->setAbsolute(); |
526 OutStreamer.EmitSymbolAttribute(S, MCSA_Global); | 556 OutStreamer.EmitSymbolAttribute(S, MCSA_Global); |
527 OutStreamer.EmitAssignment( | 557 OutStreamer.EmitAssignment( |
528 S, MCConstantExpr::Create(int64_t(1), MMI->getContext())); | 558 S, MCConstantExpr::Create(int64_t(1), MMI->getContext())); |
529 } | 559 } |
530 } | 560 } |
| 561 |
| 562 // @LOCALMOD-BEGIN |
| 563 if (Subtarget->isTargetNaCl()) |
| 564 initializeNaClMCStreamer(OutStreamer, OutContext, |
| 565 Subtarget->getTargetTriple()); |
| 566 // @LOCALMOD-END |
531 } | 567 } |
532 | 568 |
533 static void | 569 static void |
534 emitNonLazySymbolPointer(MCStreamer &OutStreamer, MCSymbol *StubLabel, | 570 emitNonLazySymbolPointer(MCStreamer &OutStreamer, MCSymbol *StubLabel, |
535 MachineModuleInfoImpl::StubValueTy &MCSym) { | 571 MachineModuleInfoImpl::StubValueTy &MCSym) { |
536 // L_foo$stub: | 572 // L_foo$stub: |
537 OutStreamer.EmitLabel(StubLabel); | 573 OutStreamer.EmitLabel(StubLabel); |
538 // .indirect_symbol _foo | 574 // .indirect_symbol _foo |
539 OutStreamer.EmitSymbolAttribute(MCSym.getPointer(), MCSA_IndirectSymbol); | 575 OutStreamer.EmitSymbolAttribute(MCSym.getPointer(), MCSA_IndirectSymbol); |
540 | 576 |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 | 781 |
746 //===----------------------------------------------------------------------===// | 782 //===----------------------------------------------------------------------===// |
747 // Target Registry Stuff | 783 // Target Registry Stuff |
748 //===----------------------------------------------------------------------===// | 784 //===----------------------------------------------------------------------===// |
749 | 785 |
750 // Force static initialization. | 786 // Force static initialization. |
751 extern "C" void LLVMInitializeX86AsmPrinter() { | 787 extern "C" void LLVMInitializeX86AsmPrinter() { |
752 RegisterAsmPrinter<X86AsmPrinter> X(TheX86_32Target); | 788 RegisterAsmPrinter<X86AsmPrinter> X(TheX86_32Target); |
753 RegisterAsmPrinter<X86AsmPrinter> Y(TheX86_64Target); | 789 RegisterAsmPrinter<X86AsmPrinter> Y(TheX86_64Target); |
754 } | 790 } |
OLD | NEW |