Daniel Dunbar | fb4a6b3 | 2009-08-21 09:11:24 +0000 | [diff] [blame] | 1 | //===- lib/MC/MCMachOStreamer.cpp - Mach-O Object Output ------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "llvm/MC/MCStreamer.h" |
| 11 | |
Daniel Dunbar | fb4a6b3 | 2009-08-21 09:11:24 +0000 | [diff] [blame] | 12 | #include "llvm/MC/MCAssembler.h" |
| 13 | #include "llvm/MC/MCContext.h" |
Daniel Dunbar | 4fac749 | 2009-08-27 08:17:51 +0000 | [diff] [blame] | 14 | #include "llvm/MC/MCCodeEmitter.h" |
Daniel Dunbar | 8c2eebe | 2009-08-31 08:08:38 +0000 | [diff] [blame] | 15 | #include "llvm/MC/MCExpr.h" |
Daniel Dunbar | 4fac749 | 2009-08-27 08:17:51 +0000 | [diff] [blame] | 16 | #include "llvm/MC/MCInst.h" |
Daniel Dunbar | 8dc68ab | 2010-06-16 20:04:22 +0000 | [diff] [blame] | 17 | #include "llvm/MC/MCObjectStreamer.h" |
Daniel Dunbar | fb4a6b3 | 2009-08-21 09:11:24 +0000 | [diff] [blame] | 18 | #include "llvm/MC/MCSection.h" |
| 19 | #include "llvm/MC/MCSymbol.h" |
Kevin Enderby | a6eeb6e | 2010-05-07 21:44:23 +0000 | [diff] [blame] | 20 | #include "llvm/MC/MCMachOSymbolFlags.h" |
Kevin Enderby | b07ce60 | 2010-08-09 22:52:14 +0000 | [diff] [blame] | 21 | #include "llvm/MC/MCSectionMachO.h" |
| 22 | #include "llvm/MC/MCDwarf.h" |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame^] | 23 | #include "llvm/Support/Dwarf.h" |
Daniel Dunbar | fb4a6b3 | 2009-08-21 09:11:24 +0000 | [diff] [blame] | 24 | #include "llvm/Support/ErrorHandling.h" |
Daniel Dunbar | 4fac749 | 2009-08-27 08:17:51 +0000 | [diff] [blame] | 25 | #include "llvm/Support/raw_ostream.h" |
Daniel Dunbar | d8036fb | 2010-03-23 05:09:03 +0000 | [diff] [blame] | 26 | #include "llvm/Target/TargetAsmBackend.h" |
| 27 | |
Daniel Dunbar | fb4a6b3 | 2009-08-21 09:11:24 +0000 | [diff] [blame] | 28 | using namespace llvm; |
| 29 | |
| 30 | namespace { |
| 31 | |
Daniel Dunbar | 8dc68ab | 2010-06-16 20:04:22 +0000 | [diff] [blame] | 32 | class MCMachOStreamer : public MCObjectStreamer { |
Daniel Dunbar | 6aff2fb | 2009-08-24 08:40:12 +0000 | [diff] [blame] | 33 | private: |
Daniel Dunbar | 2ac0c45 | 2010-05-26 20:37:00 +0000 | [diff] [blame] | 34 | void EmitInstToFragment(const MCInst &Inst); |
| 35 | void EmitInstToData(const MCInst &Inst); |
| 36 | |
Daniel Dunbar | fb4a6b3 | 2009-08-21 09:11:24 +0000 | [diff] [blame] | 37 | public: |
Daniel Dunbar | 1f3e445 | 2010-03-11 01:34:27 +0000 | [diff] [blame] | 38 | MCMachOStreamer(MCContext &Context, TargetAsmBackend &TAB, |
Daniel Dunbar | 8dc68ab | 2010-06-16 20:04:22 +0000 | [diff] [blame] | 39 | raw_ostream &OS, MCCodeEmitter *Emitter) |
Rafael Espindola | 59ff3c9 | 2010-09-22 22:27:05 +0000 | [diff] [blame] | 40 | : MCObjectStreamer(Context, TAB, OS, Emitter, true) {} |
Daniel Dunbar | ac2884a | 2010-03-25 22:49:09 +0000 | [diff] [blame] | 41 | |
Daniel Dunbar | fb4a6b3 | 2009-08-21 09:11:24 +0000 | [diff] [blame] | 42 | /// @name MCStreamer Interface |
| 43 | /// @{ |
| 44 | |
Rafael Espindola | d80781b | 2010-09-15 21:48:40 +0000 | [diff] [blame] | 45 | virtual void InitSections(); |
Daniel Dunbar | fb4a6b3 | 2009-08-21 09:11:24 +0000 | [diff] [blame] | 46 | virtual void EmitLabel(MCSymbol *Symbol); |
Chris Lattner | a5ad93a | 2010-01-23 06:39:22 +0000 | [diff] [blame] | 47 | virtual void EmitAssemblerFlag(MCAssemblerFlag Flag); |
Daniel Dunbar | 821e333 | 2009-08-31 08:09:28 +0000 | [diff] [blame] | 48 | virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value); |
Chris Lattner | a5ad93a | 2010-01-23 06:39:22 +0000 | [diff] [blame] | 49 | virtual void EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute); |
Daniel Dunbar | fb4a6b3 | 2009-08-21 09:11:24 +0000 | [diff] [blame] | 50 | virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue); |
Chris Lattner | 9eb158d | 2010-01-23 07:47:02 +0000 | [diff] [blame] | 51 | virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, |
Daniel Dunbar | 7092c7e | 2009-08-30 06:17:16 +0000 | [diff] [blame] | 52 | unsigned ByteAlignment); |
Chris Lattner | b54b9dd | 2010-05-08 19:54:22 +0000 | [diff] [blame] | 53 | virtual void BeginCOFFSymbolDef(const MCSymbol *Symbol) { |
| 54 | assert(0 && "macho doesn't support this directive"); |
| 55 | } |
| 56 | virtual void EmitCOFFSymbolStorageClass(int StorageClass) { |
| 57 | assert(0 && "macho doesn't support this directive"); |
| 58 | } |
| 59 | virtual void EmitCOFFSymbolType(int Type) { |
| 60 | assert(0 && "macho doesn't support this directive"); |
| 61 | } |
| 62 | virtual void EndCOFFSymbolDef() { |
| 63 | assert(0 && "macho doesn't support this directive"); |
| 64 | } |
Chris Lattner | 99328ad | 2010-01-25 07:52:13 +0000 | [diff] [blame] | 65 | virtual void EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) { |
| 66 | assert(0 && "macho doesn't support this directive"); |
| 67 | } |
Chris Lattner | 9eb158d | 2010-01-23 07:47:02 +0000 | [diff] [blame] | 68 | virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size) { |
| 69 | assert(0 && "macho doesn't support this directive"); |
| 70 | } |
Daniel Dunbar | 8751b94 | 2009-08-28 05:48:22 +0000 | [diff] [blame] | 71 | virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = 0, |
Daniel Dunbar | 7092c7e | 2009-08-30 06:17:16 +0000 | [diff] [blame] | 72 | unsigned Size = 0, unsigned ByteAlignment = 0); |
Eric Christopher | 011c3f1 | 2010-05-18 21:26:41 +0000 | [diff] [blame] | 73 | virtual void EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol, |
| 74 | uint64_t Size, unsigned ByteAlignment = 0); |
Chris Lattner | aaec205 | 2010-01-19 19:46:13 +0000 | [diff] [blame] | 75 | virtual void EmitBytes(StringRef Data, unsigned AddrSpace); |
Chris Lattner | aaec205 | 2010-01-19 19:46:13 +0000 | [diff] [blame] | 76 | virtual void EmitValue(const MCExpr *Value, unsigned Size,unsigned AddrSpace); |
Chris Lattner | 718fb59 | 2010-01-25 21:28:50 +0000 | [diff] [blame] | 77 | virtual void EmitGPRel32Value(const MCExpr *Value) { |
| 78 | assert(0 && "macho doesn't support this directive"); |
| 79 | } |
Daniel Dunbar | fb4a6b3 | 2009-08-21 09:11:24 +0000 | [diff] [blame] | 80 | virtual void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value = 0, |
| 81 | unsigned ValueSize = 1, |
| 82 | unsigned MaxBytesToEmit = 0); |
Kevin Enderby | 6e72048 | 2010-02-23 18:26:34 +0000 | [diff] [blame] | 83 | virtual void EmitCodeAlignment(unsigned ByteAlignment, |
| 84 | unsigned MaxBytesToEmit = 0); |
Daniel Dunbar | 821e333 | 2009-08-31 08:09:28 +0000 | [diff] [blame] | 85 | virtual void EmitValueToOffset(const MCExpr *Offset, |
Daniel Dunbar | fb4a6b3 | 2009-08-21 09:11:24 +0000 | [diff] [blame] | 86 | unsigned char Value = 0); |
Daniel Dunbar | 2ac0c45 | 2010-05-26 20:37:00 +0000 | [diff] [blame] | 87 | |
Chris Lattner | a6594fc | 2010-01-25 18:58:59 +0000 | [diff] [blame] | 88 | virtual void EmitFileDirective(StringRef Filename) { |
Daniel Dunbar | 9674967 | 2010-07-19 20:44:20 +0000 | [diff] [blame] | 89 | // FIXME: Just ignore the .file; it isn't important enough to fail the |
| 90 | // entire assembly. |
| 91 | |
| 92 | //report_fatal_error("unsupported directive: '.file'"); |
Chris Lattner | a6594fc | 2010-01-25 18:58:59 +0000 | [diff] [blame] | 93 | } |
| 94 | virtual void EmitDwarfFileDirective(unsigned FileNo, StringRef Filename) { |
Daniel Dunbar | 9674967 | 2010-07-19 20:44:20 +0000 | [diff] [blame] | 95 | // FIXME: Just ignore the .file; it isn't important enough to fail the |
| 96 | // entire assembly. |
| 97 | |
| 98 | //report_fatal_error("unsupported directive: '.file'"); |
Chris Lattner | a6594fc | 2010-01-25 18:58:59 +0000 | [diff] [blame] | 99 | } |
Daniel Dunbar | 2ac0c45 | 2010-05-26 20:37:00 +0000 | [diff] [blame] | 100 | |
Daniel Dunbar | fb4a6b3 | 2009-08-21 09:11:24 +0000 | [diff] [blame] | 101 | virtual void EmitInstruction(const MCInst &Inst); |
Daniel Dunbar | fb4a6b3 | 2009-08-21 09:11:24 +0000 | [diff] [blame] | 102 | |
Daniel Dunbar | a86de10 | 2010-06-16 20:04:32 +0000 | [diff] [blame] | 103 | virtual void Finish(); |
| 104 | |
Daniel Dunbar | fb4a6b3 | 2009-08-21 09:11:24 +0000 | [diff] [blame] | 105 | /// @} |
| 106 | }; |
| 107 | |
| 108 | } // end anonymous namespace. |
| 109 | |
Rafael Espindola | d80781b | 2010-09-15 21:48:40 +0000 | [diff] [blame] | 110 | void MCMachOStreamer::InitSections() { |
| 111 | SwitchSection(getContext().getMachOSection("__TEXT", "__text", |
| 112 | MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS, |
| 113 | 0, SectionKind::getText())); |
| 114 | |
| 115 | } |
| 116 | |
Daniel Dunbar | fb4a6b3 | 2009-08-21 09:11:24 +0000 | [diff] [blame] | 117 | void MCMachOStreamer::EmitLabel(MCSymbol *Symbol) { |
Michael J. Spencer | 8067adc | 2010-07-19 06:13:10 +0000 | [diff] [blame] | 118 | // TODO: This is almost exactly the same as WinCOFFStreamer. Consider merging |
| 119 | // into MCObjectStreamer. |
Daniel Dunbar | 8906ff1 | 2009-08-22 07:22:36 +0000 | [diff] [blame] | 120 | assert(Symbol->isUndefined() && "Cannot define a symbol twice!"); |
Daniel Dunbar | c304718 | 2010-05-05 19:01:00 +0000 | [diff] [blame] | 121 | assert(!Symbol->isVariable() && "Cannot emit a variable symbol!"); |
| 122 | assert(CurSection && "Cannot emit before setting section!"); |
Daniel Dunbar | fb4a6b3 | 2009-08-21 09:11:24 +0000 | [diff] [blame] | 123 | |
Daniel Dunbar | a86de10 | 2010-06-16 20:04:32 +0000 | [diff] [blame] | 124 | Symbol->setSection(*CurSection); |
| 125 | |
Daniel Dunbar | 8dc68ab | 2010-06-16 20:04:22 +0000 | [diff] [blame] | 126 | MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol); |
Daniel Dunbar | 071f73d | 2010-05-10 22:45:09 +0000 | [diff] [blame] | 127 | |
Daniel Dunbar | a86de10 | 2010-06-16 20:04:32 +0000 | [diff] [blame] | 128 | // We have to create a new fragment if this is an atom defining symbol, |
| 129 | // fragments cannot span atoms. |
| 130 | if (getAssembler().isSymbolLinkerVisible(SD.getSymbol())) |
| 131 | new MCDataFragment(getCurrentSectionData()); |
Daniel Dunbar | 071f73d | 2010-05-10 22:45:09 +0000 | [diff] [blame] | 132 | |
Daniel Dunbar | f70f477 | 2010-03-22 20:35:46 +0000 | [diff] [blame] | 133 | // FIXME: This is wasteful, we don't necessarily need to create a data |
| 134 | // fragment. Instead, we should mark the symbol as pointing into the data |
| 135 | // fragment if it exists, otherwise we should just queue the label and set its |
| 136 | // fragment pointer when we emit the next fragment. |
Daniel Dunbar | a86de10 | 2010-06-16 20:04:32 +0000 | [diff] [blame] | 137 | MCDataFragment *F = getOrCreateDataFragment(); |
Daniel Dunbar | f3d2ef0 | 2009-08-22 10:13:24 +0000 | [diff] [blame] | 138 | assert(!SD.getFragment() && "Unexpected fragment on symbol data!"); |
| 139 | SD.setFragment(F); |
| 140 | SD.setOffset(F->getContents().size()); |
Daniel Dunbar | 6aff2fb | 2009-08-24 08:40:12 +0000 | [diff] [blame] | 141 | |
Daniel Dunbar | b18d2dd | 2010-05-17 20:12:31 +0000 | [diff] [blame] | 142 | // This causes the reference type flag to be cleared. Darwin 'as' was "trying" |
| 143 | // to clear the weak reference and weak definition bits too, but the |
| 144 | // implementation was buggy. For now we just try to match 'as', for |
| 145 | // diffability. |
| 146 | // |
| 147 | // FIXME: Cleanup this code, these bits should be emitted based on semantic |
| 148 | // properties, not on the order of definition, etc. |
| 149 | SD.setFlags(SD.getFlags() & ~SF_ReferenceTypeMask); |
Daniel Dunbar | fb4a6b3 | 2009-08-21 09:11:24 +0000 | [diff] [blame] | 150 | } |
| 151 | |
Chris Lattner | a5ad93a | 2010-01-23 06:39:22 +0000 | [diff] [blame] | 152 | void MCMachOStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) { |
Daniel Dunbar | 6009db4 | 2009-08-26 21:22:22 +0000 | [diff] [blame] | 153 | switch (Flag) { |
Chris Lattner | a5ad93a | 2010-01-23 06:39:22 +0000 | [diff] [blame] | 154 | case MCAF_SubsectionsViaSymbols: |
Daniel Dunbar | 8dc68ab | 2010-06-16 20:04:22 +0000 | [diff] [blame] | 155 | getAssembler().setSubsectionsViaSymbols(true); |
Daniel Dunbar | 8c3eaf4 | 2009-08-28 07:08:47 +0000 | [diff] [blame] | 156 | return; |
Chandler Carruth | 5c0d472 | 2010-09-30 10:59:51 +0000 | [diff] [blame] | 157 | default: |
| 158 | llvm_unreachable("invalid assembler flag!"); |
Daniel Dunbar | 6009db4 | 2009-08-26 21:22:22 +0000 | [diff] [blame] | 159 | } |
Daniel Dunbar | fb4a6b3 | 2009-08-21 09:11:24 +0000 | [diff] [blame] | 160 | } |
| 161 | |
Daniel Dunbar | 821e333 | 2009-08-31 08:09:28 +0000 | [diff] [blame] | 162 | void MCMachOStreamer::EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) { |
Michael J. Spencer | 8067adc | 2010-07-19 06:13:10 +0000 | [diff] [blame] | 163 | // TODO: This is exactly the same as WinCOFFStreamer. Consider merging into |
| 164 | // MCObjectStreamer. |
Daniel Dunbar | a4d8667 | 2009-10-16 01:58:23 +0000 | [diff] [blame] | 165 | // FIXME: Lift context changes into super class. |
Daniel Dunbar | 8dc68ab | 2010-06-16 20:04:22 +0000 | [diff] [blame] | 166 | getAssembler().getOrCreateSymbolData(*Symbol); |
Daniel Dunbar | 08a408a | 2010-05-05 17:41:00 +0000 | [diff] [blame] | 167 | Symbol->setVariableValue(AddValueSymbols(Value)); |
Daniel Dunbar | fb4a6b3 | 2009-08-21 09:11:24 +0000 | [diff] [blame] | 168 | } |
| 169 | |
| 170 | void MCMachOStreamer::EmitSymbolAttribute(MCSymbol *Symbol, |
Chris Lattner | a5ad93a | 2010-01-23 06:39:22 +0000 | [diff] [blame] | 171 | MCSymbolAttr Attribute) { |
Daniel Dunbar | 0c7761b | 2009-08-24 11:56:58 +0000 | [diff] [blame] | 172 | // Indirect symbols are handled differently, to match how 'as' handles |
| 173 | // them. This makes writing matching .o files easier. |
Chris Lattner | a5ad93a | 2010-01-23 06:39:22 +0000 | [diff] [blame] | 174 | if (Attribute == MCSA_IndirectSymbol) { |
Daniel Dunbar | ad7c3d5 | 2009-08-26 00:18:21 +0000 | [diff] [blame] | 175 | // Note that we intentionally cannot use the symbol data here; this is |
| 176 | // important for matching the string table that 'as' generates. |
Daniel Dunbar | 0c7761b | 2009-08-24 11:56:58 +0000 | [diff] [blame] | 177 | IndirectSymbolData ISD; |
| 178 | ISD.Symbol = Symbol; |
Daniel Dunbar | 83b4671 | 2010-06-16 20:04:25 +0000 | [diff] [blame] | 179 | ISD.SectionData = getCurrentSectionData(); |
Daniel Dunbar | 8dc68ab | 2010-06-16 20:04:22 +0000 | [diff] [blame] | 180 | getAssembler().getIndirectSymbols().push_back(ISD); |
Daniel Dunbar | 0c7761b | 2009-08-24 11:56:58 +0000 | [diff] [blame] | 181 | return; |
| 182 | } |
| 183 | |
Daniel Dunbar | 6aff2fb | 2009-08-24 08:40:12 +0000 | [diff] [blame] | 184 | // Adding a symbol attribute always introduces the symbol, note that an |
Daniel Dunbar | 46836a7 | 2010-03-10 20:58:29 +0000 | [diff] [blame] | 185 | // important side effect of calling getOrCreateSymbolData here is to register |
| 186 | // the symbol with the assembler. |
Daniel Dunbar | 8dc68ab | 2010-06-16 20:04:22 +0000 | [diff] [blame] | 187 | MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol); |
Daniel Dunbar | 6aff2fb | 2009-08-24 08:40:12 +0000 | [diff] [blame] | 188 | |
| 189 | // The implementation of symbol attributes is designed to match 'as', but it |
| 190 | // leaves much to desired. It doesn't really make sense to arbitrarily add and |
| 191 | // remove flags, but 'as' allows this (in particular, see .desc). |
| 192 | // |
| 193 | // In the future it might be worth trying to make these operations more well |
| 194 | // defined. |
Daniel Dunbar | 3edd9bb | 2009-08-22 11:41:10 +0000 | [diff] [blame] | 195 | switch (Attribute) { |
Chris Lattner | a5ad93a | 2010-01-23 06:39:22 +0000 | [diff] [blame] | 196 | case MCSA_Invalid: |
Chris Lattner | ed0ab15 | 2010-01-25 18:30:45 +0000 | [diff] [blame] | 197 | case MCSA_ELF_TypeFunction: |
| 198 | case MCSA_ELF_TypeIndFunction: |
| 199 | case MCSA_ELF_TypeObject: |
| 200 | case MCSA_ELF_TypeTLS: |
| 201 | case MCSA_ELF_TypeCommon: |
| 202 | case MCSA_ELF_TypeNoType: |
Chris Lattner | a5ad93a | 2010-01-23 06:39:22 +0000 | [diff] [blame] | 203 | case MCSA_IndirectSymbol: |
| 204 | case MCSA_Hidden: |
| 205 | case MCSA_Internal: |
| 206 | case MCSA_Protected: |
| 207 | case MCSA_Weak: |
| 208 | case MCSA_Local: |
Daniel Dunbar | 6aff2fb | 2009-08-24 08:40:12 +0000 | [diff] [blame] | 209 | assert(0 && "Invalid symbol attribute for Mach-O!"); |
| 210 | break; |
Daniel Dunbar | 3edd9bb | 2009-08-22 11:41:10 +0000 | [diff] [blame] | 211 | |
Chris Lattner | a5ad93a | 2010-01-23 06:39:22 +0000 | [diff] [blame] | 212 | case MCSA_Global: |
Daniel Dunbar | 8f4d146 | 2009-08-28 07:08:35 +0000 | [diff] [blame] | 213 | SD.setExternal(true); |
Daniel Dunbar | b18d2dd | 2010-05-17 20:12:31 +0000 | [diff] [blame] | 214 | // This effectively clears the undefined lazy bit, in Darwin 'as', although |
| 215 | // it isn't very consistent because it implements this as part of symbol |
| 216 | // lookup. |
| 217 | // |
| 218 | // FIXME: Cleanup this code, these bits should be emitted based on semantic |
| 219 | // properties, not on the order of definition, etc. |
| 220 | SD.setFlags(SD.getFlags() & ~SF_ReferenceTypeUndefinedLazy); |
Daniel Dunbar | 3edd9bb | 2009-08-22 11:41:10 +0000 | [diff] [blame] | 221 | break; |
Daniel Dunbar | 6aff2fb | 2009-08-24 08:40:12 +0000 | [diff] [blame] | 222 | |
Chris Lattner | a5ad93a | 2010-01-23 06:39:22 +0000 | [diff] [blame] | 223 | case MCSA_LazyReference: |
Daniel Dunbar | 6aff2fb | 2009-08-24 08:40:12 +0000 | [diff] [blame] | 224 | // FIXME: This requires -dynamic. |
| 225 | SD.setFlags(SD.getFlags() | SF_NoDeadStrip); |
| 226 | if (Symbol->isUndefined()) |
| 227 | SD.setFlags(SD.getFlags() | SF_ReferenceTypeUndefinedLazy); |
| 228 | break; |
| 229 | |
Daniel Dunbar | 6aff2fb | 2009-08-24 08:40:12 +0000 | [diff] [blame] | 230 | // Since .reference sets the no dead strip bit, it is equivalent to |
| 231 | // .no_dead_strip in practice. |
Chris Lattner | a5ad93a | 2010-01-23 06:39:22 +0000 | [diff] [blame] | 232 | case MCSA_Reference: |
| 233 | case MCSA_NoDeadStrip: |
Daniel Dunbar | 6aff2fb | 2009-08-24 08:40:12 +0000 | [diff] [blame] | 234 | SD.setFlags(SD.getFlags() | SF_NoDeadStrip); |
| 235 | break; |
| 236 | |
Chris Lattner | a5ad93a | 2010-01-23 06:39:22 +0000 | [diff] [blame] | 237 | case MCSA_PrivateExtern: |
Daniel Dunbar | 6aff2fb | 2009-08-24 08:40:12 +0000 | [diff] [blame] | 238 | SD.setExternal(true); |
| 239 | SD.setPrivateExtern(true); |
| 240 | break; |
| 241 | |
Chris Lattner | a5ad93a | 2010-01-23 06:39:22 +0000 | [diff] [blame] | 242 | case MCSA_WeakReference: |
Daniel Dunbar | 6aff2fb | 2009-08-24 08:40:12 +0000 | [diff] [blame] | 243 | // FIXME: This requires -dynamic. |
| 244 | if (Symbol->isUndefined()) |
| 245 | SD.setFlags(SD.getFlags() | SF_WeakReference); |
| 246 | break; |
| 247 | |
Chris Lattner | a5ad93a | 2010-01-23 06:39:22 +0000 | [diff] [blame] | 248 | case MCSA_WeakDefinition: |
Daniel Dunbar | 6aff2fb | 2009-08-24 08:40:12 +0000 | [diff] [blame] | 249 | // FIXME: 'as' enforces that this is defined and global. The manual claims |
| 250 | // it has to be in a coalesced section, but this isn't enforced. |
| 251 | SD.setFlags(SD.getFlags() | SF_WeakDefinition); |
| 252 | break; |
Kevin Enderby | f59cac5 | 2010-07-08 17:22:42 +0000 | [diff] [blame] | 253 | |
| 254 | case MCSA_WeakDefAutoPrivate: |
| 255 | SD.setFlags(SD.getFlags() | SF_WeakDefinition | SF_WeakReference); |
| 256 | break; |
Daniel Dunbar | 3edd9bb | 2009-08-22 11:41:10 +0000 | [diff] [blame] | 257 | } |
Daniel Dunbar | fb4a6b3 | 2009-08-21 09:11:24 +0000 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | void MCMachOStreamer::EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) { |
Daniel Dunbar | 6aff2fb | 2009-08-24 08:40:12 +0000 | [diff] [blame] | 261 | // Encode the 'desc' value into the lowest implementation defined bits. |
Daniel Dunbar | 2ac0c45 | 2010-05-26 20:37:00 +0000 | [diff] [blame] | 262 | assert(DescValue == (DescValue & SF_DescFlagsMask) && |
Daniel Dunbar | 6aff2fb | 2009-08-24 08:40:12 +0000 | [diff] [blame] | 263 | "Invalid .desc value!"); |
Daniel Dunbar | 8dc68ab | 2010-06-16 20:04:22 +0000 | [diff] [blame] | 264 | getAssembler().getOrCreateSymbolData(*Symbol).setFlags( |
| 265 | DescValue & SF_DescFlagsMask); |
Daniel Dunbar | fb4a6b3 | 2009-08-21 09:11:24 +0000 | [diff] [blame] | 266 | } |
| 267 | |
Chris Lattner | 9eb158d | 2010-01-23 07:47:02 +0000 | [diff] [blame] | 268 | void MCMachOStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, |
Daniel Dunbar | 7092c7e | 2009-08-30 06:17:16 +0000 | [diff] [blame] | 269 | unsigned ByteAlignment) { |
Daniel Dunbar | 8f4d146 | 2009-08-28 07:08:35 +0000 | [diff] [blame] | 270 | // FIXME: Darwin 'as' does appear to allow redef of a .comm by itself. |
| 271 | assert(Symbol->isUndefined() && "Cannot define a symbol twice!"); |
| 272 | |
Daniel Dunbar | 8dc68ab | 2010-06-16 20:04:22 +0000 | [diff] [blame] | 273 | MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol); |
Daniel Dunbar | 8f4d146 | 2009-08-28 07:08:35 +0000 | [diff] [blame] | 274 | SD.setExternal(true); |
Daniel Dunbar | 7092c7e | 2009-08-30 06:17:16 +0000 | [diff] [blame] | 275 | SD.setCommon(Size, ByteAlignment); |
Daniel Dunbar | fb4a6b3 | 2009-08-21 09:11:24 +0000 | [diff] [blame] | 276 | } |
| 277 | |
Daniel Dunbar | 8751b94 | 2009-08-28 05:48:22 +0000 | [diff] [blame] | 278 | void MCMachOStreamer::EmitZerofill(const MCSection *Section, MCSymbol *Symbol, |
Daniel Dunbar | 7092c7e | 2009-08-30 06:17:16 +0000 | [diff] [blame] | 279 | unsigned Size, unsigned ByteAlignment) { |
Daniel Dunbar | 8dc68ab | 2010-06-16 20:04:22 +0000 | [diff] [blame] | 280 | MCSectionData &SectData = getAssembler().getOrCreateSectionData(*Section); |
Daniel Dunbar | d5a8e98 | 2009-08-28 05:49:21 +0000 | [diff] [blame] | 281 | |
| 282 | // The symbol may not be present, which only creates the section. |
| 283 | if (!Symbol) |
| 284 | return; |
| 285 | |
| 286 | // FIXME: Assert that this section has the zerofill type. |
| 287 | |
| 288 | assert(Symbol->isUndefined() && "Cannot define a symbol twice!"); |
| 289 | |
Daniel Dunbar | 8dc68ab | 2010-06-16 20:04:22 +0000 | [diff] [blame] | 290 | MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol); |
Daniel Dunbar | d5a8e98 | 2009-08-28 05:49:21 +0000 | [diff] [blame] | 291 | |
Daniel Dunbar | e73d49e | 2010-05-12 22:51:27 +0000 | [diff] [blame] | 292 | // Emit an align fragment if necessary. |
| 293 | if (ByteAlignment != 1) |
Daniel Dunbar | 1c15413 | 2010-05-12 22:56:23 +0000 | [diff] [blame] | 294 | new MCAlignFragment(ByteAlignment, 0, 0, ByteAlignment, &SectData); |
Daniel Dunbar | e73d49e | 2010-05-12 22:51:27 +0000 | [diff] [blame] | 295 | |
Daniel Dunbar | 4e54487 | 2010-05-12 22:51:38 +0000 | [diff] [blame] | 296 | MCFragment *F = new MCFillFragment(0, 0, Size, &SectData); |
Daniel Dunbar | d5a8e98 | 2009-08-28 05:49:21 +0000 | [diff] [blame] | 297 | SD.setFragment(F); |
| 298 | |
| 299 | Symbol->setSection(*Section); |
| 300 | |
| 301 | // Update the maximum alignment on the zero fill section if necessary. |
| 302 | if (ByteAlignment > SectData.getAlignment()) |
| 303 | SectData.setAlignment(ByteAlignment); |
Daniel Dunbar | fb4a6b3 | 2009-08-21 09:11:24 +0000 | [diff] [blame] | 304 | } |
| 305 | |
Eric Christopher | 070c1ab | 2010-05-21 23:03:53 +0000 | [diff] [blame] | 306 | // This should always be called with the thread local bss section. Like the |
| 307 | // .zerofill directive this doesn't actually switch sections on us. |
Eric Christopher | 011c3f1 | 2010-05-18 21:26:41 +0000 | [diff] [blame] | 308 | void MCMachOStreamer::EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol, |
| 309 | uint64_t Size, unsigned ByteAlignment) { |
| 310 | EmitZerofill(Section, Symbol, Size, ByteAlignment); |
| 311 | return; |
Eric Christopher | 482eba0 | 2010-05-14 01:50:28 +0000 | [diff] [blame] | 312 | } |
| 313 | |
Chris Lattner | aaec205 | 2010-01-19 19:46:13 +0000 | [diff] [blame] | 314 | void MCMachOStreamer::EmitBytes(StringRef Data, unsigned AddrSpace) { |
Michael J. Spencer | 8067adc | 2010-07-19 06:13:10 +0000 | [diff] [blame] | 315 | // TODO: This is exactly the same as WinCOFFStreamer. Consider merging into |
| 316 | // MCObjectStreamer. |
Daniel Dunbar | f70f477 | 2010-03-22 20:35:46 +0000 | [diff] [blame] | 317 | getOrCreateDataFragment()->getContents().append(Data.begin(), Data.end()); |
Daniel Dunbar | fb4a6b3 | 2009-08-21 09:11:24 +0000 | [diff] [blame] | 318 | } |
| 319 | |
Chris Lattner | aaec205 | 2010-01-19 19:46:13 +0000 | [diff] [blame] | 320 | void MCMachOStreamer::EmitValue(const MCExpr *Value, unsigned Size, |
| 321 | unsigned AddrSpace) { |
Michael J. Spencer | 8067adc | 2010-07-19 06:13:10 +0000 | [diff] [blame] | 322 | // TODO: This is exactly the same as WinCOFFStreamer. Consider merging into |
| 323 | // MCObjectStreamer. |
Daniel Dunbar | f70f477 | 2010-03-22 20:35:46 +0000 | [diff] [blame] | 324 | MCDataFragment *DF = getOrCreateDataFragment(); |
Daniel Dunbar | 45f4874 | 2010-02-13 09:28:22 +0000 | [diff] [blame] | 325 | |
| 326 | // Avoid fixups when possible. |
| 327 | int64_t AbsValue; |
Daniel Dunbar | 40ebe247 | 2010-02-22 22:08:57 +0000 | [diff] [blame] | 328 | if (AddValueSymbols(Value)->EvaluateAsAbsolute(AbsValue)) { |
Daniel Dunbar | 45f4874 | 2010-02-13 09:28:22 +0000 | [diff] [blame] | 329 | // FIXME: Endianness assumption. |
| 330 | for (unsigned i = 0; i != Size; ++i) |
| 331 | DF->getContents().push_back(uint8_t(AbsValue >> (i * 8))); |
| 332 | } else { |
Daniel Dunbar | c90e30a | 2010-05-26 15:18:56 +0000 | [diff] [blame] | 333 | DF->addFixup(MCFixup::Create(DF->getContents().size(), |
| 334 | AddValueSymbols(Value), |
| 335 | MCFixup::getKindForSize(Size))); |
Daniel Dunbar | 45f4874 | 2010-02-13 09:28:22 +0000 | [diff] [blame] | 336 | DF->getContents().resize(DF->getContents().size() + Size, 0); |
| 337 | } |
Daniel Dunbar | fb4a6b3 | 2009-08-21 09:11:24 +0000 | [diff] [blame] | 338 | } |
| 339 | |
| 340 | void MCMachOStreamer::EmitValueToAlignment(unsigned ByteAlignment, |
| 341 | int64_t Value, unsigned ValueSize, |
| 342 | unsigned MaxBytesToEmit) { |
Michael J. Spencer | 8067adc | 2010-07-19 06:13:10 +0000 | [diff] [blame] | 343 | // TODO: This is exactly the same as WinCOFFStreamer. Consider merging into |
| 344 | // MCObjectStreamer. |
Daniel Dunbar | d6f761e | 2009-08-21 23:07:38 +0000 | [diff] [blame] | 345 | if (MaxBytesToEmit == 0) |
| 346 | MaxBytesToEmit = ByteAlignment; |
Daniel Dunbar | a86de10 | 2010-06-16 20:04:32 +0000 | [diff] [blame] | 347 | new MCAlignFragment(ByteAlignment, Value, ValueSize, MaxBytesToEmit, |
| 348 | getCurrentSectionData()); |
Kevin Enderby | 6e72048 | 2010-02-23 18:26:34 +0000 | [diff] [blame] | 349 | |
| 350 | // Update the maximum alignment on the current section if necessary. |
Daniel Dunbar | 83b4671 | 2010-06-16 20:04:25 +0000 | [diff] [blame] | 351 | if (ByteAlignment > getCurrentSectionData()->getAlignment()) |
| 352 | getCurrentSectionData()->setAlignment(ByteAlignment); |
Kevin Enderby | 6e72048 | 2010-02-23 18:26:34 +0000 | [diff] [blame] | 353 | } |
| 354 | |
| 355 | void MCMachOStreamer::EmitCodeAlignment(unsigned ByteAlignment, |
| 356 | unsigned MaxBytesToEmit) { |
Michael J. Spencer | 8067adc | 2010-07-19 06:13:10 +0000 | [diff] [blame] | 357 | // TODO: This is exactly the same as WinCOFFStreamer. Consider merging into |
| 358 | // MCObjectStreamer. |
Kevin Enderby | 6e72048 | 2010-02-23 18:26:34 +0000 | [diff] [blame] | 359 | if (MaxBytesToEmit == 0) |
| 360 | MaxBytesToEmit = ByteAlignment; |
Daniel Dunbar | 1c15413 | 2010-05-12 22:56:23 +0000 | [diff] [blame] | 361 | MCAlignFragment *F = new MCAlignFragment(ByteAlignment, 0, 1, MaxBytesToEmit, |
Daniel Dunbar | 83b4671 | 2010-06-16 20:04:25 +0000 | [diff] [blame] | 362 | getCurrentSectionData()); |
Daniel Dunbar | 1c15413 | 2010-05-12 22:56:23 +0000 | [diff] [blame] | 363 | F->setEmitNops(true); |
Daniel Dunbar | 0705fbf | 2009-08-21 18:29:01 +0000 | [diff] [blame] | 364 | |
Daniel Dunbar | f3d2ef0 | 2009-08-22 10:13:24 +0000 | [diff] [blame] | 365 | // Update the maximum alignment on the current section if necessary. |
Daniel Dunbar | 83b4671 | 2010-06-16 20:04:25 +0000 | [diff] [blame] | 366 | if (ByteAlignment > getCurrentSectionData()->getAlignment()) |
| 367 | getCurrentSectionData()->setAlignment(ByteAlignment); |
Daniel Dunbar | fb4a6b3 | 2009-08-21 09:11:24 +0000 | [diff] [blame] | 368 | } |
| 369 | |
Daniel Dunbar | 821e333 | 2009-08-31 08:09:28 +0000 | [diff] [blame] | 370 | void MCMachOStreamer::EmitValueToOffset(const MCExpr *Offset, |
Daniel Dunbar | fb4a6b3 | 2009-08-21 09:11:24 +0000 | [diff] [blame] | 371 | unsigned char Value) { |
Daniel Dunbar | a86de10 | 2010-06-16 20:04:32 +0000 | [diff] [blame] | 372 | new MCOrgFragment(*Offset, Value, getCurrentSectionData()); |
Daniel Dunbar | fb4a6b3 | 2009-08-21 09:11:24 +0000 | [diff] [blame] | 373 | } |
| 374 | |
Daniel Dunbar | 2ac0c45 | 2010-05-26 20:37:00 +0000 | [diff] [blame] | 375 | void MCMachOStreamer::EmitInstToFragment(const MCInst &Inst) { |
Daniel Dunbar | 83b4671 | 2010-06-16 20:04:25 +0000 | [diff] [blame] | 376 | MCInstFragment *IF = new MCInstFragment(Inst, getCurrentSectionData()); |
Daniel Dunbar | 2ac0c45 | 2010-05-26 20:37:00 +0000 | [diff] [blame] | 377 | |
| 378 | // Add the fixups and data. |
| 379 | // |
| 380 | // FIXME: Revisit this design decision when relaxation is done, we may be |
| 381 | // able to get away with not storing any extra data in the MCInst. |
| 382 | SmallVector<MCFixup, 4> Fixups; |
| 383 | SmallString<256> Code; |
| 384 | raw_svector_ostream VecOS(Code); |
Daniel Dunbar | 8dc68ab | 2010-06-16 20:04:22 +0000 | [diff] [blame] | 385 | getAssembler().getEmitter().EncodeInstruction(Inst, VecOS, Fixups); |
Daniel Dunbar | 2ac0c45 | 2010-05-26 20:37:00 +0000 | [diff] [blame] | 386 | VecOS.flush(); |
| 387 | |
| 388 | IF->getCode() = Code; |
| 389 | IF->getFixups() = Fixups; |
| 390 | } |
| 391 | |
| 392 | void MCMachOStreamer::EmitInstToData(const MCInst &Inst) { |
| 393 | MCDataFragment *DF = getOrCreateDataFragment(); |
| 394 | |
| 395 | SmallVector<MCFixup, 4> Fixups; |
| 396 | SmallString<256> Code; |
| 397 | raw_svector_ostream VecOS(Code); |
Daniel Dunbar | 8dc68ab | 2010-06-16 20:04:22 +0000 | [diff] [blame] | 398 | getAssembler().getEmitter().EncodeInstruction(Inst, VecOS, Fixups); |
Daniel Dunbar | 2ac0c45 | 2010-05-26 20:37:00 +0000 | [diff] [blame] | 399 | VecOS.flush(); |
| 400 | |
| 401 | // Add the fixups and data. |
| 402 | for (unsigned i = 0, e = Fixups.size(); i != e; ++i) { |
| 403 | Fixups[i].setOffset(Fixups[i].getOffset() + DF->getContents().size()); |
| 404 | DF->addFixup(Fixups[i]); |
| 405 | } |
| 406 | DF->getContents().append(Code.begin(), Code.end()); |
| 407 | } |
| 408 | |
Daniel Dunbar | fb4a6b3 | 2009-08-21 09:11:24 +0000 | [diff] [blame] | 409 | void MCMachOStreamer::EmitInstruction(const MCInst &Inst) { |
Daniel Dunbar | 4fac749 | 2009-08-27 08:17:51 +0000 | [diff] [blame] | 410 | // Scan for values. |
Daniel Dunbar | db9014d | 2010-05-17 21:19:59 +0000 | [diff] [blame] | 411 | for (unsigned i = Inst.getNumOperands(); i--; ) |
Daniel Dunbar | 8c2eebe | 2009-08-31 08:08:38 +0000 | [diff] [blame] | 412 | if (Inst.getOperand(i).isExpr()) |
| 413 | AddValueSymbols(Inst.getOperand(i).getExpr()); |
Daniel Dunbar | 4fac749 | 2009-08-27 08:17:51 +0000 | [diff] [blame] | 414 | |
Daniel Dunbar | 83b4671 | 2010-06-16 20:04:25 +0000 | [diff] [blame] | 415 | getCurrentSectionData()->setHasInstructions(true); |
Daniel Dunbar | e1ec617 | 2010-02-02 21:44:01 +0000 | [diff] [blame] | 416 | |
Kevin Enderby | 232ab94 | 2010-08-31 22:55:11 +0000 | [diff] [blame] | 417 | // Now that a machine instruction has been assembled into this section, make |
| 418 | // a line entry for any .loc directive that has been seen. |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame^] | 419 | MCLineEntry::Make(this, getCurrentSection()); |
Kevin Enderby | 232ab94 | 2010-08-31 22:55:11 +0000 | [diff] [blame] | 420 | |
Daniel Dunbar | 83194de | 2010-05-26 20:37:03 +0000 | [diff] [blame] | 421 | // If this instruction doesn't need relaxation, just emit it as data. |
Daniel Dunbar | 8dc68ab | 2010-06-16 20:04:22 +0000 | [diff] [blame] | 422 | if (!getAssembler().getBackend().MayNeedRelaxation(Inst)) { |
Daniel Dunbar | 2ac0c45 | 2010-05-26 20:37:00 +0000 | [diff] [blame] | 423 | EmitInstToData(Inst); |
Daniel Dunbar | 83194de | 2010-05-26 20:37:03 +0000 | [diff] [blame] | 424 | return; |
| 425 | } |
| 426 | |
| 427 | // Otherwise, if we are relaxing everything, relax the instruction as much as |
| 428 | // possible and emit it as data. |
Daniel Dunbar | 8dc68ab | 2010-06-16 20:04:22 +0000 | [diff] [blame] | 429 | if (getAssembler().getRelaxAll()) { |
Daniel Dunbar | 83194de | 2010-05-26 20:37:03 +0000 | [diff] [blame] | 430 | MCInst Relaxed; |
Daniel Dunbar | 8dc68ab | 2010-06-16 20:04:22 +0000 | [diff] [blame] | 431 | getAssembler().getBackend().RelaxInstruction(Inst, Relaxed); |
| 432 | while (getAssembler().getBackend().MayNeedRelaxation(Relaxed)) |
| 433 | getAssembler().getBackend().RelaxInstruction(Relaxed, Relaxed); |
Daniel Dunbar | 83194de | 2010-05-26 20:37:03 +0000 | [diff] [blame] | 434 | EmitInstToData(Relaxed); |
| 435 | return; |
| 436 | } |
| 437 | |
| 438 | // Otherwise emit to a separate fragment. |
| 439 | EmitInstToFragment(Inst); |
Daniel Dunbar | fb4a6b3 | 2009-08-21 09:11:24 +0000 | [diff] [blame] | 440 | } |
| 441 | |
Daniel Dunbar | a86de10 | 2010-06-16 20:04:32 +0000 | [diff] [blame] | 442 | void MCMachOStreamer::Finish() { |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame^] | 443 | // Dump out the dwarf file & directory tables and line tables. |
| 444 | if (getContext().hasDwarfFiles() && |
| 445 | // TODO: This not enabled for 64-bit Mach-O targets. As there are needed |
| 446 | // changes in the handling of 64-bit relocation entries for dwarf Mach-O |
| 447 | // sections that need to made. Currently it gets |
| 448 | // LLVM ERROR: unsupported local relocations in difference |
| 449 | // due dealing with "a-b" expressions made up for dwarf line entries |
| 450 | // because the line section has no non-local symbols thus it can't find |
| 451 | // an atom symbol for the base. |
| 452 | getAssembler().getBackend().getPointerSize() != 8) { |
| 453 | const MCSection *DwarfLineSection = getContext().getMachOSection("__DWARF", |
| 454 | "__debug_line", |
| 455 | MCSectionMachO::S_ATTR_DEBUG, |
| 456 | 0, SectionKind::getDataRelLocal()); |
| 457 | MCDwarfFileTable::Emit(this, DwarfLineSection); |
| 458 | } |
Kevin Enderby | b07ce60 | 2010-08-09 22:52:14 +0000 | [diff] [blame] | 459 | |
Daniel Dunbar | a86de10 | 2010-06-16 20:04:32 +0000 | [diff] [blame] | 460 | // We have to set the fragment atom associations so we can relax properly for |
| 461 | // Mach-O. |
| 462 | |
| 463 | // First, scan the symbol table to build a lookup table from fragments to |
| 464 | // defining symbols. |
| 465 | DenseMap<const MCFragment*, MCSymbolData*> DefiningSymbolMap; |
| 466 | for (MCAssembler::symbol_iterator it = getAssembler().symbol_begin(), |
| 467 | ie = getAssembler().symbol_end(); it != ie; ++it) { |
| 468 | if (getAssembler().isSymbolLinkerVisible(it->getSymbol()) && |
| 469 | it->getFragment()) { |
| 470 | // An atom defining symbol should never be internal to a fragment. |
| 471 | assert(it->getOffset() == 0 && "Invalid offset in atom defining symbol!"); |
| 472 | DefiningSymbolMap[it->getFragment()] = it; |
| 473 | } |
| 474 | } |
| 475 | |
| 476 | // Set the fragment atom associations by tracking the last seen atom defining |
| 477 | // symbol. |
| 478 | for (MCAssembler::iterator it = getAssembler().begin(), |
| 479 | ie = getAssembler().end(); it != ie; ++it) { |
| 480 | MCSymbolData *CurrentAtom = 0; |
| 481 | for (MCSectionData::iterator it2 = it->begin(), |
| 482 | ie2 = it->end(); it2 != ie2; ++it2) { |
| 483 | if (MCSymbolData *SD = DefiningSymbolMap.lookup(it2)) |
| 484 | CurrentAtom = SD; |
| 485 | it2->setAtom(CurrentAtom); |
| 486 | } |
| 487 | } |
| 488 | |
| 489 | this->MCObjectStreamer::Finish(); |
| 490 | } |
| 491 | |
Daniel Dunbar | 1f3e445 | 2010-03-11 01:34:27 +0000 | [diff] [blame] | 492 | MCStreamer *llvm::createMachOStreamer(MCContext &Context, TargetAsmBackend &TAB, |
Daniel Dunbar | ac2884a | 2010-03-25 22:49:09 +0000 | [diff] [blame] | 493 | raw_ostream &OS, MCCodeEmitter *CE, |
| 494 | bool RelaxAll) { |
| 495 | MCMachOStreamer *S = new MCMachOStreamer(Context, TAB, OS, CE); |
| 496 | if (RelaxAll) |
| 497 | S->getAssembler().setRelaxAll(true); |
| 498 | return S; |
Daniel Dunbar | fb4a6b3 | 2009-08-21 09:11:24 +0000 | [diff] [blame] | 499 | } |