blob: 7b9f822d0c61123c05d7e019f43619c892bfa368 [file] [log] [blame]
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +00001//===- DarwinAsmParser.cpp - Darwin (Mach-O) Assembly Parser --------------===//
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/MCParser/MCAsmParserExtension.h"
Rafael Espindolac49ac5e2015-12-16 23:49:14 +000011#include "llvm/ADT/STLExtras.h"
Chandler Carruthed0881b2012-12-03 16:50:05 +000012#include "llvm/ADT/StringRef.h"
13#include "llvm/ADT/StringSwitch.h"
Akira Hatanaka8ad73992015-10-15 05:28:38 +000014#include "llvm/ADT/Triple.h"
Chandler Carruthed0881b2012-12-03 16:50:05 +000015#include "llvm/ADT/Twine.h"
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +000016#include "llvm/MC/MCContext.h"
Akira Hatanaka8ad73992015-10-15 05:28:38 +000017#include "llvm/MC/MCObjectFileInfo.h"
Chandler Carruthed0881b2012-12-03 16:50:05 +000018#include "llvm/MC/MCParser/MCAsmLexer.h"
19#include "llvm/MC/MCParser/MCAsmParser.h"
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +000020#include "llvm/MC/MCSectionMachO.h"
21#include "llvm/MC/MCStreamer.h"
22#include "llvm/MC/MCSymbol.h"
Benjamin Kramerd59664f2014-04-29 23:26:49 +000023#include "llvm/Support/FileSystem.h"
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +000024#include "llvm/Support/MemoryBuffer.h"
25#include "llvm/Support/SourceMgr.h"
26using namespace llvm;
27
28namespace {
29
30/// \brief Implementation of directive handling which is shared across all
31/// Darwin targets.
32class DarwinAsmParser : public MCAsmParserExtension {
Eli Bendersky29b9f472013-01-16 00:50:52 +000033 template<bool (DarwinAsmParser::*HandlerMethod)(StringRef, SMLoc)>
Jim Grosbachd2037eb2013-02-20 22:21:35 +000034 void addDirectiveHandler(StringRef Directive) {
Eli Bendersky29b9f472013-01-16 00:50:52 +000035 MCAsmParser::ExtensionDirectiveHandler Handler = std::make_pair(
36 this, HandleDirective<DarwinAsmParser, HandlerMethod>);
Jim Grosbachd2037eb2013-02-20 22:21:35 +000037 getParser().addDirectiveHandler(Directive, Handler);
Daniel Dunbar8897d472010-07-18 22:22:07 +000038 }
39
Jim Grosbach319026d2014-03-18 22:09:10 +000040 bool parseSectionSwitch(const char *Segment, const char *Section,
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +000041 unsigned TAA = 0, unsigned ImplicitAlign = 0,
42 unsigned StubSize = 0);
43
Tim Northover2d4d1612015-10-28 22:36:05 +000044 SMLoc LastVersionMinDirective;
45
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +000046public:
47 DarwinAsmParser() {}
48
Craig Topper59be68f2014-03-08 07:14:16 +000049 void Initialize(MCAsmParser &Parser) override {
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +000050 // Call the base implementation.
51 this->MCAsmParserExtension::Initialize(Parser);
52
Lang Hamesf9033bb2016-04-11 18:33:45 +000053 addDirectiveHandler<&DarwinAsmParser::parseDirectiveAltEntry>(".alt_entry");
Jim Grosbach319026d2014-03-18 22:09:10 +000054 addDirectiveHandler<&DarwinAsmParser::parseDirectiveDesc>(".desc");
55 addDirectiveHandler<&DarwinAsmParser::parseDirectiveIndirectSymbol>(
Kevin Enderby3aeada22013-08-28 17:50:59 +000056 ".indirect_symbol");
Jim Grosbach319026d2014-03-18 22:09:10 +000057 addDirectiveHandler<&DarwinAsmParser::parseDirectiveLsym>(".lsym");
58 addDirectiveHandler<&DarwinAsmParser::parseDirectiveSubsectionsViaSymbols>(
Daniel Dunbar8897d472010-07-18 22:22:07 +000059 ".subsections_via_symbols");
Jim Grosbach319026d2014-03-18 22:09:10 +000060 addDirectiveHandler<&DarwinAsmParser::parseDirectiveDumpOrLoad>(".dump");
61 addDirectiveHandler<&DarwinAsmParser::parseDirectiveDumpOrLoad>(".load");
62 addDirectiveHandler<&DarwinAsmParser::parseDirectiveSection>(".section");
63 addDirectiveHandler<&DarwinAsmParser::parseDirectivePushSection>(
Daniel Dunbarb94c5782013-01-18 01:25:25 +000064 ".pushsection");
Jim Grosbach319026d2014-03-18 22:09:10 +000065 addDirectiveHandler<&DarwinAsmParser::parseDirectivePopSection>(
Daniel Dunbarb94c5782013-01-18 01:25:25 +000066 ".popsection");
Jim Grosbach319026d2014-03-18 22:09:10 +000067 addDirectiveHandler<&DarwinAsmParser::parseDirectivePrevious>(".previous");
68 addDirectiveHandler<&DarwinAsmParser::parseDirectiveSecureLogUnique>(
Daniel Dunbar8897d472010-07-18 22:22:07 +000069 ".secure_log_unique");
Jim Grosbach319026d2014-03-18 22:09:10 +000070 addDirectiveHandler<&DarwinAsmParser::parseDirectiveSecureLogReset>(
Daniel Dunbar8897d472010-07-18 22:22:07 +000071 ".secure_log_reset");
Jim Grosbach319026d2014-03-18 22:09:10 +000072 addDirectiveHandler<&DarwinAsmParser::parseDirectiveTBSS>(".tbss");
73 addDirectiveHandler<&DarwinAsmParser::parseDirectiveZerofill>(".zerofill");
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +000074
Jim Grosbach319026d2014-03-18 22:09:10 +000075 addDirectiveHandler<&DarwinAsmParser::parseDirectiveDataRegion>(
Daniel Dunbarb94c5782013-01-18 01:25:25 +000076 ".data_region");
Jim Grosbach319026d2014-03-18 22:09:10 +000077 addDirectiveHandler<&DarwinAsmParser::parseDirectiveDataRegionEnd>(
Daniel Dunbarb94c5782013-01-18 01:25:25 +000078 ".end_data_region");
Jim Grosbach4b63d2a2012-05-18 19:12:01 +000079
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +000080 // Special section directives.
Jim Grosbach319026d2014-03-18 22:09:10 +000081 addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveBss>(".bss");
82 addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveConst>(".const");
83 addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveConstData>(
Daniel Dunbarb94c5782013-01-18 01:25:25 +000084 ".const_data");
Jim Grosbach319026d2014-03-18 22:09:10 +000085 addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveConstructor>(
Daniel Dunbarb94c5782013-01-18 01:25:25 +000086 ".constructor");
Jim Grosbach319026d2014-03-18 22:09:10 +000087 addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveCString>(
Daniel Dunbarb94c5782013-01-18 01:25:25 +000088 ".cstring");
Jim Grosbach319026d2014-03-18 22:09:10 +000089 addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveData>(".data");
90 addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveDestructor>(
Daniel Dunbarb94c5782013-01-18 01:25:25 +000091 ".destructor");
Jim Grosbach319026d2014-03-18 22:09:10 +000092 addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveDyld>(".dyld");
93 addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveFVMLibInit0>(
Daniel Dunbarb94c5782013-01-18 01:25:25 +000094 ".fvmlib_init0");
Jim Grosbach319026d2014-03-18 22:09:10 +000095 addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveFVMLibInit1>(
Daniel Dunbarb94c5782013-01-18 01:25:25 +000096 ".fvmlib_init1");
Jim Grosbachd2037eb2013-02-20 22:21:35 +000097 addDirectiveHandler<
Jim Grosbach319026d2014-03-18 22:09:10 +000098 &DarwinAsmParser::parseSectionDirectiveLazySymbolPointers>(
Daniel Dunbarb94c5782013-01-18 01:25:25 +000099 ".lazy_symbol_pointer");
Jim Grosbach319026d2014-03-18 22:09:10 +0000100 addDirectiveHandler<&DarwinAsmParser::parseDirectiveLinkerOption>(
Daniel Dunbar16004b82013-01-18 01:25:48 +0000101 ".linker_option");
Jim Grosbach319026d2014-03-18 22:09:10 +0000102 addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveLiteral16>(
Daniel Dunbarb94c5782013-01-18 01:25:25 +0000103 ".literal16");
Jim Grosbach319026d2014-03-18 22:09:10 +0000104 addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveLiteral4>(
Daniel Dunbarb94c5782013-01-18 01:25:25 +0000105 ".literal4");
Jim Grosbach319026d2014-03-18 22:09:10 +0000106 addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveLiteral8>(
Daniel Dunbarb94c5782013-01-18 01:25:25 +0000107 ".literal8");
Jim Grosbach319026d2014-03-18 22:09:10 +0000108 addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveModInitFunc>(
Daniel Dunbarb94c5782013-01-18 01:25:25 +0000109 ".mod_init_func");
Jim Grosbach319026d2014-03-18 22:09:10 +0000110 addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveModTermFunc>(
Daniel Dunbarb94c5782013-01-18 01:25:25 +0000111 ".mod_term_func");
Jim Grosbachd2037eb2013-02-20 22:21:35 +0000112 addDirectiveHandler<
Jim Grosbach319026d2014-03-18 22:09:10 +0000113 &DarwinAsmParser::parseSectionDirectiveNonLazySymbolPointers>(
Daniel Dunbarb94c5782013-01-18 01:25:25 +0000114 ".non_lazy_symbol_pointer");
Tim Northover5c3140f2016-04-25 21:12:04 +0000115 addDirectiveHandler<
116 &DarwinAsmParser::parseSectionDirectiveThreadLocalVariablePointers>(
117 ".thread_local_variable_pointer");
Jim Grosbach319026d2014-03-18 22:09:10 +0000118 addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveObjCCatClsMeth>(
Daniel Dunbarb94c5782013-01-18 01:25:25 +0000119 ".objc_cat_cls_meth");
Jim Grosbach319026d2014-03-18 22:09:10 +0000120 addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveObjCCatInstMeth>(
Daniel Dunbarb94c5782013-01-18 01:25:25 +0000121 ".objc_cat_inst_meth");
Jim Grosbach319026d2014-03-18 22:09:10 +0000122 addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveObjCCategory>(
Daniel Dunbarb94c5782013-01-18 01:25:25 +0000123 ".objc_category");
Jim Grosbach319026d2014-03-18 22:09:10 +0000124 addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveObjCClass>(
Daniel Dunbarb94c5782013-01-18 01:25:25 +0000125 ".objc_class");
Jim Grosbach319026d2014-03-18 22:09:10 +0000126 addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveObjCClassNames>(
Daniel Dunbarb94c5782013-01-18 01:25:25 +0000127 ".objc_class_names");
Jim Grosbach319026d2014-03-18 22:09:10 +0000128 addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveObjCClassVars>(
Daniel Dunbarb94c5782013-01-18 01:25:25 +0000129 ".objc_class_vars");
Jim Grosbach319026d2014-03-18 22:09:10 +0000130 addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveObjCClsMeth>(
Daniel Dunbarb94c5782013-01-18 01:25:25 +0000131 ".objc_cls_meth");
Jim Grosbach319026d2014-03-18 22:09:10 +0000132 addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveObjCClsRefs>(
Daniel Dunbarb94c5782013-01-18 01:25:25 +0000133 ".objc_cls_refs");
Jim Grosbach319026d2014-03-18 22:09:10 +0000134 addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveObjCInstMeth>(
Daniel Dunbarb94c5782013-01-18 01:25:25 +0000135 ".objc_inst_meth");
Jim Grosbachd2037eb2013-02-20 22:21:35 +0000136 addDirectiveHandler<
Jim Grosbach319026d2014-03-18 22:09:10 +0000137 &DarwinAsmParser::parseSectionDirectiveObjCInstanceVars>(
Daniel Dunbarb94c5782013-01-18 01:25:25 +0000138 ".objc_instance_vars");
Jim Grosbach319026d2014-03-18 22:09:10 +0000139 addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveObjCMessageRefs>(
Daniel Dunbarb94c5782013-01-18 01:25:25 +0000140 ".objc_message_refs");
Jim Grosbach319026d2014-03-18 22:09:10 +0000141 addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveObjCMetaClass>(
Daniel Dunbarb94c5782013-01-18 01:25:25 +0000142 ".objc_meta_class");
Jim Grosbachd2037eb2013-02-20 22:21:35 +0000143 addDirectiveHandler<
Jim Grosbach319026d2014-03-18 22:09:10 +0000144 &DarwinAsmParser::parseSectionDirectiveObjCMethVarNames>(
Daniel Dunbarb94c5782013-01-18 01:25:25 +0000145 ".objc_meth_var_names");
Jim Grosbachd2037eb2013-02-20 22:21:35 +0000146 addDirectiveHandler<
Jim Grosbach319026d2014-03-18 22:09:10 +0000147 &DarwinAsmParser::parseSectionDirectiveObjCMethVarTypes>(
Daniel Dunbarb94c5782013-01-18 01:25:25 +0000148 ".objc_meth_var_types");
Jim Grosbach319026d2014-03-18 22:09:10 +0000149 addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveObjCModuleInfo>(
Daniel Dunbarb94c5782013-01-18 01:25:25 +0000150 ".objc_module_info");
Jim Grosbach319026d2014-03-18 22:09:10 +0000151 addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveObjCProtocol>(
Daniel Dunbarb94c5782013-01-18 01:25:25 +0000152 ".objc_protocol");
Jim Grosbachd2037eb2013-02-20 22:21:35 +0000153 addDirectiveHandler<
Jim Grosbach319026d2014-03-18 22:09:10 +0000154 &DarwinAsmParser::parseSectionDirectiveObjCSelectorStrs>(
Daniel Dunbarb94c5782013-01-18 01:25:25 +0000155 ".objc_selector_strs");
Jim Grosbachd2037eb2013-02-20 22:21:35 +0000156 addDirectiveHandler<
Jim Grosbach319026d2014-03-18 22:09:10 +0000157 &DarwinAsmParser::parseSectionDirectiveObjCStringObject>(
Daniel Dunbarb94c5782013-01-18 01:25:25 +0000158 ".objc_string_object");
Jim Grosbach319026d2014-03-18 22:09:10 +0000159 addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveObjCSymbols>(
Daniel Dunbarb94c5782013-01-18 01:25:25 +0000160 ".objc_symbols");
Jim Grosbach319026d2014-03-18 22:09:10 +0000161 addDirectiveHandler<&DarwinAsmParser::parseSectionDirectivePICSymbolStub>(
Daniel Dunbarb94c5782013-01-18 01:25:25 +0000162 ".picsymbol_stub");
Jim Grosbach319026d2014-03-18 22:09:10 +0000163 addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveStaticConst>(
Daniel Dunbarb94c5782013-01-18 01:25:25 +0000164 ".static_const");
Jim Grosbach319026d2014-03-18 22:09:10 +0000165 addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveStaticData>(
Daniel Dunbarb94c5782013-01-18 01:25:25 +0000166 ".static_data");
Jim Grosbach319026d2014-03-18 22:09:10 +0000167 addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveSymbolStub>(
Daniel Dunbarb94c5782013-01-18 01:25:25 +0000168 ".symbol_stub");
Jim Grosbach319026d2014-03-18 22:09:10 +0000169 addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveTData>(".tdata");
170 addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveText>(".text");
171 addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveThreadInitFunc>(
Daniel Dunbarb94c5782013-01-18 01:25:25 +0000172 ".thread_init_func");
Jim Grosbach319026d2014-03-18 22:09:10 +0000173 addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveTLV>(".tlv");
Jim Grosbach14be61a2011-03-08 19:17:19 +0000174
Jim Grosbach319026d2014-03-18 22:09:10 +0000175 addDirectiveHandler<&DarwinAsmParser::parseSectionDirectiveIdent>(".ident");
Tim Northover2d4d1612015-10-28 22:36:05 +0000176 addDirectiveHandler<&DarwinAsmParser::parseVersionMin>(
177 ".watchos_version_min");
178 addDirectiveHandler<&DarwinAsmParser::parseVersionMin>(".tvos_version_min");
Jim Grosbach319026d2014-03-18 22:09:10 +0000179 addDirectiveHandler<&DarwinAsmParser::parseVersionMin>(".ios_version_min");
180 addDirectiveHandler<&DarwinAsmParser::parseVersionMin>(
Jim Grosbach448334a2014-03-18 22:09:05 +0000181 ".macosx_version_min");
Tim Northover2d4d1612015-10-28 22:36:05 +0000182
183 LastVersionMinDirective = SMLoc();
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000184 }
185
Lang Hamesf9033bb2016-04-11 18:33:45 +0000186 bool parseDirectiveAltEntry(StringRef, SMLoc);
Jim Grosbach319026d2014-03-18 22:09:10 +0000187 bool parseDirectiveDesc(StringRef, SMLoc);
188 bool parseDirectiveIndirectSymbol(StringRef, SMLoc);
189 bool parseDirectiveDumpOrLoad(StringRef, SMLoc);
190 bool parseDirectiveLsym(StringRef, SMLoc);
191 bool parseDirectiveLinkerOption(StringRef, SMLoc);
192 bool parseDirectiveSection(StringRef, SMLoc);
193 bool parseDirectivePushSection(StringRef, SMLoc);
194 bool parseDirectivePopSection(StringRef, SMLoc);
195 bool parseDirectivePrevious(StringRef, SMLoc);
196 bool parseDirectiveSecureLogReset(StringRef, SMLoc);
197 bool parseDirectiveSecureLogUnique(StringRef, SMLoc);
198 bool parseDirectiveSubsectionsViaSymbols(StringRef, SMLoc);
199 bool parseDirectiveTBSS(StringRef, SMLoc);
200 bool parseDirectiveZerofill(StringRef, SMLoc);
201 bool parseDirectiveDataRegion(StringRef, SMLoc);
202 bool parseDirectiveDataRegionEnd(StringRef, SMLoc);
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000203
204 // Named Section Directive
Jim Grosbach319026d2014-03-18 22:09:10 +0000205 bool parseSectionDirectiveBss(StringRef, SMLoc) {
206 return parseSectionSwitch("__DATA", "__bss");
Rafael Espindola3402c052013-10-02 14:09:29 +0000207 }
208
Jim Grosbach319026d2014-03-18 22:09:10 +0000209 bool parseSectionDirectiveConst(StringRef, SMLoc) {
210 return parseSectionSwitch("__TEXT", "__const");
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000211 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000212 bool parseSectionDirectiveStaticConst(StringRef, SMLoc) {
213 return parseSectionSwitch("__TEXT", "__static_const");
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000214 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000215 bool parseSectionDirectiveCString(StringRef, SMLoc) {
216 return parseSectionSwitch("__TEXT","__cstring",
David Majnemer7b583052014-03-07 07:36:05 +0000217 MachO::S_CSTRING_LITERALS);
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000218 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000219 bool parseSectionDirectiveLiteral4(StringRef, SMLoc) {
220 return parseSectionSwitch("__TEXT", "__literal4",
David Majnemer7b583052014-03-07 07:36:05 +0000221 MachO::S_4BYTE_LITERALS, 4);
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000222 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000223 bool parseSectionDirectiveLiteral8(StringRef, SMLoc) {
224 return parseSectionSwitch("__TEXT", "__literal8",
David Majnemer7b583052014-03-07 07:36:05 +0000225 MachO::S_8BYTE_LITERALS, 8);
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000226 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000227 bool parseSectionDirectiveLiteral16(StringRef, SMLoc) {
228 return parseSectionSwitch("__TEXT","__literal16",
David Majnemer7b583052014-03-07 07:36:05 +0000229 MachO::S_16BYTE_LITERALS, 16);
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000230 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000231 bool parseSectionDirectiveConstructor(StringRef, SMLoc) {
232 return parseSectionSwitch("__TEXT","__constructor");
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000233 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000234 bool parseSectionDirectiveDestructor(StringRef, SMLoc) {
235 return parseSectionSwitch("__TEXT","__destructor");
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000236 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000237 bool parseSectionDirectiveFVMLibInit0(StringRef, SMLoc) {
238 return parseSectionSwitch("__TEXT","__fvmlib_init0");
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000239 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000240 bool parseSectionDirectiveFVMLibInit1(StringRef, SMLoc) {
241 return parseSectionSwitch("__TEXT","__fvmlib_init1");
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000242 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000243 bool parseSectionDirectiveSymbolStub(StringRef, SMLoc) {
244 return parseSectionSwitch("__TEXT","__symbol_stub",
David Majnemer7b583052014-03-07 07:36:05 +0000245 MachO::S_SYMBOL_STUBS |
246 MachO::S_ATTR_PURE_INSTRUCTIONS,
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000247 // FIXME: Different on PPC and ARM.
248 0, 16);
249 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000250 bool parseSectionDirectivePICSymbolStub(StringRef, SMLoc) {
251 return parseSectionSwitch("__TEXT","__picsymbol_stub",
David Majnemer7b583052014-03-07 07:36:05 +0000252 MachO::S_SYMBOL_STUBS |
253 MachO::S_ATTR_PURE_INSTRUCTIONS, 0, 26);
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000254 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000255 bool parseSectionDirectiveData(StringRef, SMLoc) {
256 return parseSectionSwitch("__DATA", "__data");
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000257 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000258 bool parseSectionDirectiveStaticData(StringRef, SMLoc) {
259 return parseSectionSwitch("__DATA", "__static_data");
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000260 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000261 bool parseSectionDirectiveNonLazySymbolPointers(StringRef, SMLoc) {
262 return parseSectionSwitch("__DATA", "__nl_symbol_ptr",
David Majnemer7b583052014-03-07 07:36:05 +0000263 MachO::S_NON_LAZY_SYMBOL_POINTERS, 4);
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000264 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000265 bool parseSectionDirectiveLazySymbolPointers(StringRef, SMLoc) {
266 return parseSectionSwitch("__DATA", "__la_symbol_ptr",
David Majnemer7b583052014-03-07 07:36:05 +0000267 MachO::S_LAZY_SYMBOL_POINTERS, 4);
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000268 }
Tim Northover5c3140f2016-04-25 21:12:04 +0000269 bool parseSectionDirectiveThreadLocalVariablePointers(StringRef, SMLoc) {
270 return parseSectionSwitch("__DATA", "__thread_ptr",
271 MachO::S_THREAD_LOCAL_VARIABLE_POINTERS, 4);
272 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000273 bool parseSectionDirectiveDyld(StringRef, SMLoc) {
274 return parseSectionSwitch("__DATA", "__dyld");
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000275 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000276 bool parseSectionDirectiveModInitFunc(StringRef, SMLoc) {
277 return parseSectionSwitch("__DATA", "__mod_init_func",
David Majnemer7b583052014-03-07 07:36:05 +0000278 MachO::S_MOD_INIT_FUNC_POINTERS, 4);
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000279 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000280 bool parseSectionDirectiveModTermFunc(StringRef, SMLoc) {
281 return parseSectionSwitch("__DATA", "__mod_term_func",
David Majnemer7b583052014-03-07 07:36:05 +0000282 MachO::S_MOD_TERM_FUNC_POINTERS, 4);
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000283 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000284 bool parseSectionDirectiveConstData(StringRef, SMLoc) {
285 return parseSectionSwitch("__DATA", "__const");
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000286 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000287 bool parseSectionDirectiveObjCClass(StringRef, SMLoc) {
288 return parseSectionSwitch("__OBJC", "__class",
David Majnemer7b583052014-03-07 07:36:05 +0000289 MachO::S_ATTR_NO_DEAD_STRIP);
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000290 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000291 bool parseSectionDirectiveObjCMetaClass(StringRef, SMLoc) {
292 return parseSectionSwitch("__OBJC", "__meta_class",
David Majnemer7b583052014-03-07 07:36:05 +0000293 MachO::S_ATTR_NO_DEAD_STRIP);
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000294 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000295 bool parseSectionDirectiveObjCCatClsMeth(StringRef, SMLoc) {
296 return parseSectionSwitch("__OBJC", "__cat_cls_meth",
David Majnemer7b583052014-03-07 07:36:05 +0000297 MachO::S_ATTR_NO_DEAD_STRIP);
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000298 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000299 bool parseSectionDirectiveObjCCatInstMeth(StringRef, SMLoc) {
300 return parseSectionSwitch("__OBJC", "__cat_inst_meth",
David Majnemer7b583052014-03-07 07:36:05 +0000301 MachO::S_ATTR_NO_DEAD_STRIP);
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000302 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000303 bool parseSectionDirectiveObjCProtocol(StringRef, SMLoc) {
304 return parseSectionSwitch("__OBJC", "__protocol",
David Majnemer7b583052014-03-07 07:36:05 +0000305 MachO::S_ATTR_NO_DEAD_STRIP);
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000306 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000307 bool parseSectionDirectiveObjCStringObject(StringRef, SMLoc) {
308 return parseSectionSwitch("__OBJC", "__string_object",
David Majnemer7b583052014-03-07 07:36:05 +0000309 MachO::S_ATTR_NO_DEAD_STRIP);
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000310 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000311 bool parseSectionDirectiveObjCClsMeth(StringRef, SMLoc) {
312 return parseSectionSwitch("__OBJC", "__cls_meth",
David Majnemer7b583052014-03-07 07:36:05 +0000313 MachO::S_ATTR_NO_DEAD_STRIP);
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000314 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000315 bool parseSectionDirectiveObjCInstMeth(StringRef, SMLoc) {
316 return parseSectionSwitch("__OBJC", "__inst_meth",
David Majnemer7b583052014-03-07 07:36:05 +0000317 MachO::S_ATTR_NO_DEAD_STRIP);
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000318 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000319 bool parseSectionDirectiveObjCClsRefs(StringRef, SMLoc) {
320 return parseSectionSwitch("__OBJC", "__cls_refs",
David Majnemer7b583052014-03-07 07:36:05 +0000321 MachO::S_ATTR_NO_DEAD_STRIP |
322 MachO::S_LITERAL_POINTERS, 4);
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000323 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000324 bool parseSectionDirectiveObjCMessageRefs(StringRef, SMLoc) {
325 return parseSectionSwitch("__OBJC", "__message_refs",
David Majnemer7b583052014-03-07 07:36:05 +0000326 MachO::S_ATTR_NO_DEAD_STRIP |
327 MachO::S_LITERAL_POINTERS, 4);
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000328 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000329 bool parseSectionDirectiveObjCSymbols(StringRef, SMLoc) {
330 return parseSectionSwitch("__OBJC", "__symbols",
David Majnemer7b583052014-03-07 07:36:05 +0000331 MachO::S_ATTR_NO_DEAD_STRIP);
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000332 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000333 bool parseSectionDirectiveObjCCategory(StringRef, SMLoc) {
334 return parseSectionSwitch("__OBJC", "__category",
David Majnemer7b583052014-03-07 07:36:05 +0000335 MachO::S_ATTR_NO_DEAD_STRIP);
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000336 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000337 bool parseSectionDirectiveObjCClassVars(StringRef, SMLoc) {
338 return parseSectionSwitch("__OBJC", "__class_vars",
David Majnemer7b583052014-03-07 07:36:05 +0000339 MachO::S_ATTR_NO_DEAD_STRIP);
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000340 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000341 bool parseSectionDirectiveObjCInstanceVars(StringRef, SMLoc) {
342 return parseSectionSwitch("__OBJC", "__instance_vars",
David Majnemer7b583052014-03-07 07:36:05 +0000343 MachO::S_ATTR_NO_DEAD_STRIP);
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000344 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000345 bool parseSectionDirectiveObjCModuleInfo(StringRef, SMLoc) {
346 return parseSectionSwitch("__OBJC", "__module_info",
David Majnemer7b583052014-03-07 07:36:05 +0000347 MachO::S_ATTR_NO_DEAD_STRIP);
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000348 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000349 bool parseSectionDirectiveObjCClassNames(StringRef, SMLoc) {
350 return parseSectionSwitch("__TEXT", "__cstring",
David Majnemer7b583052014-03-07 07:36:05 +0000351 MachO::S_CSTRING_LITERALS);
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000352 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000353 bool parseSectionDirectiveObjCMethVarTypes(StringRef, SMLoc) {
354 return parseSectionSwitch("__TEXT", "__cstring",
David Majnemer7b583052014-03-07 07:36:05 +0000355 MachO::S_CSTRING_LITERALS);
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000356 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000357 bool parseSectionDirectiveObjCMethVarNames(StringRef, SMLoc) {
358 return parseSectionSwitch("__TEXT", "__cstring",
David Majnemer7b583052014-03-07 07:36:05 +0000359 MachO::S_CSTRING_LITERALS);
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000360 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000361 bool parseSectionDirectiveObjCSelectorStrs(StringRef, SMLoc) {
362 return parseSectionSwitch("__OBJC", "__selector_strs",
David Majnemer7b583052014-03-07 07:36:05 +0000363 MachO::S_CSTRING_LITERALS);
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000364 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000365 bool parseSectionDirectiveTData(StringRef, SMLoc) {
366 return parseSectionSwitch("__DATA", "__thread_data",
David Majnemer7b583052014-03-07 07:36:05 +0000367 MachO::S_THREAD_LOCAL_REGULAR);
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000368 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000369 bool parseSectionDirectiveText(StringRef, SMLoc) {
370 return parseSectionSwitch("__TEXT", "__text",
David Majnemer7b583052014-03-07 07:36:05 +0000371 MachO::S_ATTR_PURE_INSTRUCTIONS);
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000372 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000373 bool parseSectionDirectiveTLV(StringRef, SMLoc) {
374 return parseSectionSwitch("__DATA", "__thread_vars",
David Majnemer7b583052014-03-07 07:36:05 +0000375 MachO::S_THREAD_LOCAL_VARIABLES);
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000376 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000377 bool parseSectionDirectiveIdent(StringRef, SMLoc) {
Jim Grosbach14be61a2011-03-08 19:17:19 +0000378 // Darwin silently ignores the .ident directive.
Jim Grosbachd2037eb2013-02-20 22:21:35 +0000379 getParser().eatToEndOfStatement();
Jim Grosbach14be61a2011-03-08 19:17:19 +0000380 return false;
381 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000382 bool parseSectionDirectiveThreadInitFunc(StringRef, SMLoc) {
383 return parseSectionSwitch("__DATA", "__thread_init",
David Majnemer7b583052014-03-07 07:36:05 +0000384 MachO::S_THREAD_LOCAL_INIT_FUNCTION_POINTERS);
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000385 }
Jim Grosbach319026d2014-03-18 22:09:10 +0000386 bool parseVersionMin(StringRef, SMLoc);
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000387
388};
389
Bill Wendlingce4fe412012-08-08 06:30:30 +0000390} // end anonymous namespace
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000391
Jim Grosbach319026d2014-03-18 22:09:10 +0000392bool DarwinAsmParser::parseSectionSwitch(const char *Segment,
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000393 const char *Section,
394 unsigned TAA, unsigned Align,
395 unsigned StubSize) {
396 if (getLexer().isNot(AsmToken::EndOfStatement))
397 return TokError("unexpected token in section switching directive");
398 Lex();
399
400 // FIXME: Arch specific.
David Majnemer7b583052014-03-07 07:36:05 +0000401 bool isText = TAA & MachO::S_ATTR_PURE_INSTRUCTIONS;
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000402 getStreamer().SwitchSection(getContext().getMachOSection(
Rafael Espindola449711c2015-11-18 06:02:15 +0000403 Segment, Section, TAA, StubSize,
404 isText ? SectionKind::getText() : SectionKind::getData()));
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000405
406 // Set the implicit alignment, if any.
407 //
408 // FIXME: This isn't really what 'as' does; I think it just uses the implicit
409 // alignment on the section (e.g., if one manually inserts bytes into the
Bill Wendling5391eb62010-10-19 10:18:23 +0000410 // section, then just issuing the section switch directive will not realign
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000411 // the section. However, this is arguably more reasonable behavior, and there
412 // is no good reason for someone to intentionally emit incorrectly sized
413 // values into the implicitly aligned sections.
414 if (Align)
Rafael Espindola7b514962014-02-04 18:34:04 +0000415 getStreamer().EmitValueToAlignment(Align);
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000416
417 return false;
418}
419
Lang Hamesf9033bb2016-04-11 18:33:45 +0000420/// parseDirectiveAltEntry
421/// ::= .alt_entry identifier
422bool DarwinAsmParser::parseDirectiveAltEntry(StringRef, SMLoc) {
423 StringRef Name;
424 if (getParser().parseIdentifier(Name))
425 return TokError("expected identifier in directive");
426
427 // Look up symbol.
428 MCSymbol *Sym = getContext().getOrCreateSymbol(Name);
429
430 if (Sym->isDefined())
431 return TokError(".alt_entry must preceed symbol definition");
432
433 if (!getStreamer().EmitSymbolAttribute(Sym, MCSA_AltEntry))
434 return TokError("unable to emit symbol attribute");
435
436 Lex();
437 return false;
438}
439
Jim Grosbach319026d2014-03-18 22:09:10 +0000440/// parseDirectiveDesc
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000441/// ::= .desc identifier , expression
Jim Grosbach319026d2014-03-18 22:09:10 +0000442bool DarwinAsmParser::parseDirectiveDesc(StringRef, SMLoc) {
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000443 StringRef Name;
Jim Grosbachd2037eb2013-02-20 22:21:35 +0000444 if (getParser().parseIdentifier(Name))
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000445 return TokError("expected identifier in directive");
446
447 // Handle the identifier as the key symbol.
Jim Grosbach6f482002015-05-18 18:43:14 +0000448 MCSymbol *Sym = getContext().getOrCreateSymbol(Name);
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000449
450 if (getLexer().isNot(AsmToken::Comma))
451 return TokError("unexpected token in '.desc' directive");
452 Lex();
453
454 int64_t DescValue;
Jim Grosbachd2037eb2013-02-20 22:21:35 +0000455 if (getParser().parseAbsoluteExpression(DescValue))
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000456 return true;
457
458 if (getLexer().isNot(AsmToken::EndOfStatement))
459 return TokError("unexpected token in '.desc' directive");
460
461 Lex();
462
463 // Set the n_desc field of this Symbol to this DescValue
464 getStreamer().EmitSymbolDesc(Sym, DescValue);
465
466 return false;
467}
468
Jim Grosbach319026d2014-03-18 22:09:10 +0000469/// parseDirectiveIndirectSymbol
Kevin Enderby3aeada22013-08-28 17:50:59 +0000470/// ::= .indirect_symbol identifier
Jim Grosbach319026d2014-03-18 22:09:10 +0000471bool DarwinAsmParser::parseDirectiveIndirectSymbol(StringRef, SMLoc Loc) {
Kevin Enderby3aeada22013-08-28 17:50:59 +0000472 const MCSectionMachO *Current = static_cast<const MCSectionMachO*>(
473 getStreamer().getCurrentSection().first);
David Majnemercd481d32014-03-07 18:49:54 +0000474 MachO::SectionType SectionType = Current->getType();
David Majnemer7b583052014-03-07 07:36:05 +0000475 if (SectionType != MachO::S_NON_LAZY_SYMBOL_POINTERS &&
476 SectionType != MachO::S_LAZY_SYMBOL_POINTERS &&
Tim Northover5c3140f2016-04-25 21:12:04 +0000477 SectionType != MachO::S_THREAD_LOCAL_VARIABLE_POINTERS &&
David Majnemer7b583052014-03-07 07:36:05 +0000478 SectionType != MachO::S_SYMBOL_STUBS)
Kevin Enderby3aeada22013-08-28 17:50:59 +0000479 return Error(Loc, "indirect symbol not in a symbol pointer or stub "
480 "section");
481
482 StringRef Name;
483 if (getParser().parseIdentifier(Name))
484 return TokError("expected identifier in .indirect_symbol directive");
485
Jim Grosbach6f482002015-05-18 18:43:14 +0000486 MCSymbol *Sym = getContext().getOrCreateSymbol(Name);
Kevin Enderby3aeada22013-08-28 17:50:59 +0000487
488 // Assembler local symbols don't make any sense here. Complain loudly.
489 if (Sym->isTemporary())
490 return TokError("non-local symbol required in directive");
491
492 if (!getStreamer().EmitSymbolAttribute(Sym, MCSA_IndirectSymbol))
493 return TokError("unable to emit indirect symbol attribute for: " + Name);
494
495 if (getLexer().isNot(AsmToken::EndOfStatement))
496 return TokError("unexpected token in '.indirect_symbol' directive");
497
498 Lex();
499
500 return false;
501}
502
Jim Grosbach319026d2014-03-18 22:09:10 +0000503/// parseDirectiveDumpOrLoad
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000504/// ::= ( .dump | .load ) "filename"
Jim Grosbach319026d2014-03-18 22:09:10 +0000505bool DarwinAsmParser::parseDirectiveDumpOrLoad(StringRef Directive,
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000506 SMLoc IDLoc) {
507 bool IsDump = Directive == ".dump";
508 if (getLexer().isNot(AsmToken::String))
509 return TokError("expected string in '.dump' or '.load' directive");
510
511 Lex();
512
513 if (getLexer().isNot(AsmToken::EndOfStatement))
514 return TokError("unexpected token in '.dump' or '.load' directive");
515
516 Lex();
517
518 // FIXME: If/when .dump and .load are implemented they will be done in the
519 // the assembly parser and not have any need for an MCStreamer API.
520 if (IsDump)
Joerg Sonnenberger74ba2622011-05-19 18:00:13 +0000521 return Warning(IDLoc, "ignoring directive .dump for now");
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000522 else
Joerg Sonnenberger74ba2622011-05-19 18:00:13 +0000523 return Warning(IDLoc, "ignoring directive .load for now");
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000524}
525
Daniel Dunbar16004b82013-01-18 01:25:48 +0000526/// ParseDirectiveLinkerOption
527/// ::= .linker_option "string" ( , "string" )*
Jim Grosbach319026d2014-03-18 22:09:10 +0000528bool DarwinAsmParser::parseDirectiveLinkerOption(StringRef IDVal, SMLoc) {
Daniel Dunbar16004b82013-01-18 01:25:48 +0000529 SmallVector<std::string, 4> Args;
530 for (;;) {
531 if (getLexer().isNot(AsmToken::String))
532 return TokError("expected string in '" + Twine(IDVal) + "' directive");
533
534 std::string Data;
Jim Grosbachd2037eb2013-02-20 22:21:35 +0000535 if (getParser().parseEscapedString(Data))
Daniel Dunbar16004b82013-01-18 01:25:48 +0000536 return true;
537
538 Args.push_back(Data);
539
540 Lex();
541 if (getLexer().is(AsmToken::EndOfStatement))
542 break;
543
544 if (getLexer().isNot(AsmToken::Comma))
545 return TokError("unexpected token in '" + Twine(IDVal) + "' directive");
546 Lex();
547 }
548
549 getStreamer().EmitLinkerOptions(Args);
550 return false;
551}
552
Jim Grosbach319026d2014-03-18 22:09:10 +0000553/// parseDirectiveLsym
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000554/// ::= .lsym identifier , expression
Jim Grosbach319026d2014-03-18 22:09:10 +0000555bool DarwinAsmParser::parseDirectiveLsym(StringRef, SMLoc) {
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000556 StringRef Name;
Jim Grosbachd2037eb2013-02-20 22:21:35 +0000557 if (getParser().parseIdentifier(Name))
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000558 return TokError("expected identifier in directive");
559
560 // Handle the identifier as the key symbol.
Jim Grosbach6f482002015-05-18 18:43:14 +0000561 MCSymbol *Sym = getContext().getOrCreateSymbol(Name);
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000562
563 if (getLexer().isNot(AsmToken::Comma))
564 return TokError("unexpected token in '.lsym' directive");
565 Lex();
566
567 const MCExpr *Value;
Jim Grosbachd2037eb2013-02-20 22:21:35 +0000568 if (getParser().parseExpression(Value))
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000569 return true;
570
571 if (getLexer().isNot(AsmToken::EndOfStatement))
572 return TokError("unexpected token in '.lsym' directive");
573
574 Lex();
575
576 // We don't currently support this directive.
577 //
578 // FIXME: Diagnostic location!
579 (void) Sym;
580 return TokError("directive '.lsym' is unsupported");
581}
582
Jim Grosbach319026d2014-03-18 22:09:10 +0000583/// parseDirectiveSection:
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000584/// ::= .section identifier (',' identifier)*
Jim Grosbach319026d2014-03-18 22:09:10 +0000585bool DarwinAsmParser::parseDirectiveSection(StringRef, SMLoc) {
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000586 SMLoc Loc = getLexer().getLoc();
587
588 StringRef SectionName;
Jim Grosbachd2037eb2013-02-20 22:21:35 +0000589 if (getParser().parseIdentifier(SectionName))
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000590 return Error(Loc, "expected identifier after '.section' directive");
591
592 // Verify there is a following comma.
593 if (!getLexer().is(AsmToken::Comma))
594 return TokError("unexpected token in '.section' directive");
595
596 std::string SectionSpec = SectionName;
597 SectionSpec += ",";
598
599 // Add all the tokens until the end of the line, ParseSectionSpecifier will
600 // handle this.
601 StringRef EOL = getLexer().LexUntilEndOfStatement();
602 SectionSpec.append(EOL.begin(), EOL.end());
603
604 Lex();
605 if (getLexer().isNot(AsmToken::EndOfStatement))
606 return TokError("unexpected token in '.section' directive");
607 Lex();
608
609
610 StringRef Segment, Section;
Daniel Dunbarf1d62cf2011-03-17 16:25:24 +0000611 unsigned StubSize;
Stuart Hastings12d53122011-03-19 02:42:31 +0000612 unsigned TAA;
613 bool TAAParsed;
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000614 std::string ErrorStr =
615 MCSectionMachO::ParseSectionSpecifier(SectionSpec, Segment, Section,
Stuart Hastings12d53122011-03-19 02:42:31 +0000616 TAA, TAAParsed, StubSize);
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000617
618 if (!ErrorStr.empty())
619 return Error(Loc, ErrorStr.c_str());
620
Akira Hatanaka8ad73992015-10-15 05:28:38 +0000621 // Issue a warning if the target is not powerpc and Section is a *coal* section.
622 Triple TT = getParser().getContext().getObjectFileInfo()->getTargetTriple();
623 Triple::ArchType ArchTy = TT.getArch();
624
625 if (ArchTy != Triple::ppc && ArchTy != Triple::ppc64) {
626 StringRef NonCoalSection = StringSwitch<StringRef>(Section)
627 .Case("__textcoal_nt", "__text")
628 .Case("__const_coal", "__const")
629 .Case("__datacoal_nt", "__data")
630 .Default(Section);
631
632 if (!Section.equals(NonCoalSection)) {
633 StringRef SectionVal(Loc.getPointer());
634 size_t B = SectionVal.find(',') + 1, E = SectionVal.find(',', B);
635 SMLoc BLoc = SMLoc::getFromPointer(SectionVal.data() + B);
636 SMLoc ELoc = SMLoc::getFromPointer(SectionVal.data() + E);
637 getParser().Warning(Loc, "section \"" + Section + "\" is deprecated",
638 SMRange(BLoc, ELoc));
639 getParser().Note(Loc, "change section name to \"" + NonCoalSection +
640 "\"", SMRange(BLoc, ELoc));
641 }
642 }
643
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000644 // FIXME: Arch specific.
645 bool isText = Segment == "__TEXT"; // FIXME: Hack.
646 getStreamer().SwitchSection(getContext().getMachOSection(
Rafael Espindola449711c2015-11-18 06:02:15 +0000647 Segment, Section, TAA, StubSize,
648 isText ? SectionKind::getText() : SectionKind::getData()));
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000649 return false;
650}
651
Bill Wendlingce4fe412012-08-08 06:30:30 +0000652/// ParseDirectivePushSection:
653/// ::= .pushsection identifier (',' identifier)*
Jim Grosbach319026d2014-03-18 22:09:10 +0000654bool DarwinAsmParser::parseDirectivePushSection(StringRef S, SMLoc Loc) {
Bill Wendlingce4fe412012-08-08 06:30:30 +0000655 getStreamer().PushSection();
656
Jim Grosbach319026d2014-03-18 22:09:10 +0000657 if (parseDirectiveSection(S, Loc)) {
Bill Wendlingce4fe412012-08-08 06:30:30 +0000658 getStreamer().PopSection();
659 return true;
660 }
661
662 return false;
663}
664
665/// ParseDirectivePopSection:
666/// ::= .popsection
Jim Grosbach319026d2014-03-18 22:09:10 +0000667bool DarwinAsmParser::parseDirectivePopSection(StringRef, SMLoc) {
Bill Wendlingce4fe412012-08-08 06:30:30 +0000668 if (!getStreamer().PopSection())
669 return TokError(".popsection without corresponding .pushsection");
670 return false;
671}
672
673/// ParseDirectivePrevious:
674/// ::= .previous
Jim Grosbach319026d2014-03-18 22:09:10 +0000675bool DarwinAsmParser::parseDirectivePrevious(StringRef DirName, SMLoc) {
Peter Collingbourne2f495b92013-04-17 21:18:16 +0000676 MCSectionSubPair PreviousSection = getStreamer().getPreviousSection();
Craig Topper353eda42014-04-24 06:44:33 +0000677 if (!PreviousSection.first)
678 return TokError(".previous without corresponding .section");
Peter Collingbourne2f495b92013-04-17 21:18:16 +0000679 getStreamer().SwitchSection(PreviousSection.first, PreviousSection.second);
Bill Wendlingce4fe412012-08-08 06:30:30 +0000680 return false;
681}
682
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000683/// ParseDirectiveSecureLogUnique
Daniel Dunbar40a564f2010-07-18 20:15:59 +0000684/// ::= .secure_log_unique ... message ...
Jim Grosbach319026d2014-03-18 22:09:10 +0000685bool DarwinAsmParser::parseDirectiveSecureLogUnique(StringRef, SMLoc IDLoc) {
Jim Grosbachd2037eb2013-02-20 22:21:35 +0000686 StringRef LogMessage = getParser().parseStringToEndOfStatement();
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000687 if (getLexer().isNot(AsmToken::EndOfStatement))
688 return TokError("unexpected token in '.secure_log_unique' directive");
689
David Blaikiedc3f01e2015-03-09 01:57:13 +0000690 if (getContext().getSecureLogUsed())
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000691 return Error(IDLoc, ".secure_log_unique specified multiple times");
692
Daniel Dunbar40a564f2010-07-18 20:15:59 +0000693 // Get the secure log path.
694 const char *SecureLogFile = getContext().getSecureLogFile();
Craig Topper353eda42014-04-24 06:44:33 +0000695 if (!SecureLogFile)
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000696 return Error(IDLoc, ".secure_log_unique used but AS_SECURE_LOG_FILE "
697 "environment variable unset.");
698
Daniel Dunbar40a564f2010-07-18 20:15:59 +0000699 // Open the secure log file if we haven't already.
Rafael Espindolac49ac5e2015-12-16 23:49:14 +0000700 raw_fd_ostream *OS = getContext().getSecureLog();
Craig Topper353eda42014-04-24 06:44:33 +0000701 if (!OS) {
Rafael Espindola3fd1e992014-08-25 18:16:47 +0000702 std::error_code EC;
Rafael Espindolac49ac5e2015-12-16 23:49:14 +0000703 auto NewOS = llvm::make_unique<raw_fd_ostream>(
704 SecureLogFile, EC, sys::fs::F_Append | sys::fs::F_Text);
705 if (EC)
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000706 return Error(IDLoc, Twine("can't open secure log file: ") +
Rafael Espindola3fd1e992014-08-25 18:16:47 +0000707 SecureLogFile + " (" + EC.message() + ")");
Rafael Espindolac49ac5e2015-12-16 23:49:14 +0000708 OS = NewOS.get();
709 getContext().setSecureLog(std::move(NewOS));
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000710 }
711
Daniel Dunbar40a564f2010-07-18 20:15:59 +0000712 // Write the message.
Alp Tokera55b95b2014-07-06 10:33:31 +0000713 unsigned CurBuf = getSourceManager().FindBufferContainingLoc(IDLoc);
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000714 *OS << getSourceManager().getBufferInfo(CurBuf).Buffer->getBufferIdentifier()
715 << ":" << getSourceManager().FindLineNumber(IDLoc, CurBuf) << ":"
716 << LogMessage + "\n";
717
718 getContext().setSecureLogUsed(true);
719
720 return false;
721}
722
723/// ParseDirectiveSecureLogReset
724/// ::= .secure_log_reset
Jim Grosbach319026d2014-03-18 22:09:10 +0000725bool DarwinAsmParser::parseDirectiveSecureLogReset(StringRef, SMLoc IDLoc) {
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000726 if (getLexer().isNot(AsmToken::EndOfStatement))
727 return TokError("unexpected token in '.secure_log_reset' directive");
728
729 Lex();
730
731 getContext().setSecureLogUsed(false);
732
733 return false;
734}
735
Jim Grosbach319026d2014-03-18 22:09:10 +0000736/// parseDirectiveSubsectionsViaSymbols
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000737/// ::= .subsections_via_symbols
Jim Grosbach319026d2014-03-18 22:09:10 +0000738bool DarwinAsmParser::parseDirectiveSubsectionsViaSymbols(StringRef, SMLoc) {
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000739 if (getLexer().isNot(AsmToken::EndOfStatement))
740 return TokError("unexpected token in '.subsections_via_symbols' directive");
741
742 Lex();
743
744 getStreamer().EmitAssemblerFlag(MCAF_SubsectionsViaSymbols);
745
746 return false;
747}
748
749/// ParseDirectiveTBSS
750/// ::= .tbss identifier, size, align
Jim Grosbach319026d2014-03-18 22:09:10 +0000751bool DarwinAsmParser::parseDirectiveTBSS(StringRef, SMLoc) {
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000752 SMLoc IDLoc = getLexer().getLoc();
753 StringRef Name;
Jim Grosbachd2037eb2013-02-20 22:21:35 +0000754 if (getParser().parseIdentifier(Name))
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000755 return TokError("expected identifier in directive");
756
757 // Handle the identifier as the key symbol.
Jim Grosbach6f482002015-05-18 18:43:14 +0000758 MCSymbol *Sym = getContext().getOrCreateSymbol(Name);
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000759
760 if (getLexer().isNot(AsmToken::Comma))
761 return TokError("unexpected token in directive");
762 Lex();
763
764 int64_t Size;
765 SMLoc SizeLoc = getLexer().getLoc();
Jim Grosbachd2037eb2013-02-20 22:21:35 +0000766 if (getParser().parseAbsoluteExpression(Size))
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000767 return true;
768
769 int64_t Pow2Alignment = 0;
770 SMLoc Pow2AlignmentLoc;
771 if (getLexer().is(AsmToken::Comma)) {
772 Lex();
773 Pow2AlignmentLoc = getLexer().getLoc();
Jim Grosbachd2037eb2013-02-20 22:21:35 +0000774 if (getParser().parseAbsoluteExpression(Pow2Alignment))
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000775 return true;
776 }
777
778 if (getLexer().isNot(AsmToken::EndOfStatement))
779 return TokError("unexpected token in '.tbss' directive");
780
781 Lex();
782
783 if (Size < 0)
784 return Error(SizeLoc, "invalid '.tbss' directive size, can't be less than"
785 "zero");
786
787 // FIXME: Diagnose overflow.
788 if (Pow2Alignment < 0)
789 return Error(Pow2AlignmentLoc, "invalid '.tbss' alignment, can't be less"
790 "than zero");
791
792 if (!Sym->isUndefined())
793 return Error(IDLoc, "invalid symbol redefinition");
794
795 getStreamer().EmitTBSSSymbol(getContext().getMachOSection(
796 "__DATA", "__thread_bss",
David Majnemer7b583052014-03-07 07:36:05 +0000797 MachO::S_THREAD_LOCAL_ZEROFILL,
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000798 0, SectionKind::getThreadBSS()),
799 Sym, Size, 1 << Pow2Alignment);
800
801 return false;
802}
803
804/// ParseDirectiveZerofill
805/// ::= .zerofill segname , sectname [, identifier , size_expression [
806/// , align_expression ]]
Jim Grosbach319026d2014-03-18 22:09:10 +0000807bool DarwinAsmParser::parseDirectiveZerofill(StringRef, SMLoc) {
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000808 StringRef Segment;
Jim Grosbachd2037eb2013-02-20 22:21:35 +0000809 if (getParser().parseIdentifier(Segment))
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000810 return TokError("expected segment name after '.zerofill' directive");
811
812 if (getLexer().isNot(AsmToken::Comma))
813 return TokError("unexpected token in directive");
814 Lex();
815
816 StringRef Section;
Jim Grosbachd2037eb2013-02-20 22:21:35 +0000817 if (getParser().parseIdentifier(Section))
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000818 return TokError("expected section name after comma in '.zerofill' "
819 "directive");
820
821 // If this is the end of the line all that was wanted was to create the
822 // the section but with no symbol.
823 if (getLexer().is(AsmToken::EndOfStatement)) {
824 // Create the zerofill section but no symbol
825 getStreamer().EmitZerofill(getContext().getMachOSection(
David Majnemer7b583052014-03-07 07:36:05 +0000826 Segment, Section, MachO::S_ZEROFILL,
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000827 0, SectionKind::getBSS()));
828 return false;
829 }
830
831 if (getLexer().isNot(AsmToken::Comma))
832 return TokError("unexpected token in directive");
833 Lex();
834
835 SMLoc IDLoc = getLexer().getLoc();
836 StringRef IDStr;
Jim Grosbachd2037eb2013-02-20 22:21:35 +0000837 if (getParser().parseIdentifier(IDStr))
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000838 return TokError("expected identifier in directive");
839
840 // handle the identifier as the key symbol.
Jim Grosbach6f482002015-05-18 18:43:14 +0000841 MCSymbol *Sym = getContext().getOrCreateSymbol(IDStr);
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000842
843 if (getLexer().isNot(AsmToken::Comma))
844 return TokError("unexpected token in directive");
845 Lex();
846
847 int64_t Size;
848 SMLoc SizeLoc = getLexer().getLoc();
Jim Grosbachd2037eb2013-02-20 22:21:35 +0000849 if (getParser().parseAbsoluteExpression(Size))
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000850 return true;
851
852 int64_t Pow2Alignment = 0;
853 SMLoc Pow2AlignmentLoc;
854 if (getLexer().is(AsmToken::Comma)) {
855 Lex();
856 Pow2AlignmentLoc = getLexer().getLoc();
Jim Grosbachd2037eb2013-02-20 22:21:35 +0000857 if (getParser().parseAbsoluteExpression(Pow2Alignment))
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000858 return true;
859 }
860
861 if (getLexer().isNot(AsmToken::EndOfStatement))
862 return TokError("unexpected token in '.zerofill' directive");
863
864 Lex();
865
866 if (Size < 0)
867 return Error(SizeLoc, "invalid '.zerofill' directive size, can't be less "
868 "than zero");
869
870 // NOTE: The alignment in the directive is a power of 2 value, the assembler
871 // may internally end up wanting an alignment in bytes.
872 // FIXME: Diagnose overflow.
873 if (Pow2Alignment < 0)
874 return Error(Pow2AlignmentLoc, "invalid '.zerofill' directive alignment, "
875 "can't be less than zero");
876
877 if (!Sym->isUndefined())
878 return Error(IDLoc, "invalid symbol redefinition");
879
880 // Create the zerofill Symbol with Size and Pow2Alignment
881 //
882 // FIXME: Arch specific.
883 getStreamer().EmitZerofill(getContext().getMachOSection(
David Majnemer7b583052014-03-07 07:36:05 +0000884 Segment, Section, MachO::S_ZEROFILL,
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000885 0, SectionKind::getBSS()),
886 Sym, Size, 1 << Pow2Alignment);
887
888 return false;
889}
890
Jim Grosbach4b63d2a2012-05-18 19:12:01 +0000891/// ParseDirectiveDataRegion
892/// ::= .data_region [ ( jt8 | jt16 | jt32 ) ]
Jim Grosbach319026d2014-03-18 22:09:10 +0000893bool DarwinAsmParser::parseDirectiveDataRegion(StringRef, SMLoc) {
Jim Grosbach4b63d2a2012-05-18 19:12:01 +0000894 if (getLexer().is(AsmToken::EndOfStatement)) {
895 Lex();
896 getStreamer().EmitDataRegion(MCDR_DataRegion);
897 return false;
898 }
899 StringRef RegionType;
900 SMLoc Loc = getParser().getTok().getLoc();
Jim Grosbachd2037eb2013-02-20 22:21:35 +0000901 if (getParser().parseIdentifier(RegionType))
Jim Grosbach4b63d2a2012-05-18 19:12:01 +0000902 return TokError("expected region type after '.data_region' directive");
903 int Kind = StringSwitch<int>(RegionType)
904 .Case("jt8", MCDR_DataRegionJT8)
905 .Case("jt16", MCDR_DataRegionJT16)
906 .Case("jt32", MCDR_DataRegionJT32)
907 .Default(-1);
908 if (Kind == -1)
909 return Error(Loc, "unknown region type in '.data_region' directive");
910 Lex();
911
912 getStreamer().EmitDataRegion((MCDataRegionType)Kind);
913 return false;
914}
915
916/// ParseDirectiveDataRegionEnd
917/// ::= .end_data_region
Jim Grosbach319026d2014-03-18 22:09:10 +0000918bool DarwinAsmParser::parseDirectiveDataRegionEnd(StringRef, SMLoc) {
Jim Grosbach4b63d2a2012-05-18 19:12:01 +0000919 if (getLexer().isNot(AsmToken::EndOfStatement))
920 return TokError("unexpected token in '.end_data_region' directive");
921
922 Lex();
923 getStreamer().EmitDataRegion(MCDR_DataRegionEnd);
924 return false;
925}
926
Jim Grosbach319026d2014-03-18 22:09:10 +0000927/// parseVersionMin
Jim Grosbach448334a2014-03-18 22:09:05 +0000928/// ::= .ios_version_min major,minor[,update]
929/// ::= .macosx_version_min major,minor[,update]
Tim Northover2d4d1612015-10-28 22:36:05 +0000930bool DarwinAsmParser::parseVersionMin(StringRef Directive, SMLoc Loc) {
Jim Grosbach448334a2014-03-18 22:09:05 +0000931 int64_t Major = 0, Minor = 0, Update = 0;
932 int Kind = StringSwitch<int>(Directive)
Tim Northover2d4d1612015-10-28 22:36:05 +0000933 .Case(".watchos_version_min", MCVM_WatchOSVersionMin)
934 .Case(".tvos_version_min", MCVM_TvOSVersionMin)
Jim Grosbach448334a2014-03-18 22:09:05 +0000935 .Case(".ios_version_min", MCVM_IOSVersionMin)
936 .Case(".macosx_version_min", MCVM_OSXVersionMin);
937 // Get the major version number.
938 if (getLexer().isNot(AsmToken::Integer))
939 return TokError("invalid OS major version number");
940 Major = getLexer().getTok().getIntVal();
941 if (Major > 65535 || Major <= 0)
942 return TokError("invalid OS major version number");
943 Lex();
944 if (getLexer().isNot(AsmToken::Comma))
945 return TokError("minor OS version number required, comma expected");
946 Lex();
947 // Get the minor version number.
948 if (getLexer().isNot(AsmToken::Integer))
949 return TokError("invalid OS minor version number");
950 Minor = getLexer().getTok().getIntVal();
951 if (Minor > 255 || Minor < 0)
952 return TokError("invalid OS minor version number");
953 Lex();
954 // Get the update level, if specified
955 if (getLexer().isNot(AsmToken::EndOfStatement)) {
956 if (getLexer().isNot(AsmToken::Comma))
957 return TokError("invalid update specifier, comma expected");
958 Lex();
959 if (getLexer().isNot(AsmToken::Integer))
960 return TokError("invalid OS update number");
961 Update = getLexer().getTok().getIntVal();
Davide Italianoa8d89f32016-07-05 16:56:09 +0000962 if (Update > 255 || Update < 0)
963 return TokError("invalid OS update number");
Jim Grosbach448334a2014-03-18 22:09:05 +0000964 Lex();
965 }
966
Tim Northover2d4d1612015-10-28 22:36:05 +0000967 const Triple &T = getContext().getObjectFileInfo()->getTargetTriple();
968 Triple::OSType ExpectedOS = Triple::UnknownOS;
969 switch ((MCVersionMinType)Kind) {
970 case MCVM_WatchOSVersionMin: ExpectedOS = Triple::WatchOS; break;
971 case MCVM_TvOSVersionMin: ExpectedOS = Triple::TvOS; break;
972 case MCVM_IOSVersionMin: ExpectedOS = Triple::IOS; break;
973 case MCVM_OSXVersionMin: ExpectedOS = Triple::MacOSX; break;
974 }
975 if (T.getOS() != ExpectedOS)
976 Warning(Loc, Directive + " should only be used for " +
977 Triple::getOSTypeName(ExpectedOS) + " targets");
978
979 if (LastVersionMinDirective.isValid()) {
980 Warning(Loc, "overriding previous version_min directive");
981 Note(LastVersionMinDirective, "previous definition is here");
982 }
983 LastVersionMinDirective = Loc;
984
Jim Grosbach448334a2014-03-18 22:09:05 +0000985 // We've parsed a correct version specifier, so send it to the streamer.
986 getStreamer().EmitVersionMin((MCVersionMinType)Kind, Major, Minor, Update);
987
988 return false;
989}
990
Daniel Dunbar0cb91cf2010-07-12 20:51:51 +0000991namespace llvm {
992
993MCAsmParserExtension *createDarwinAsmParser() {
994 return new DarwinAsmParser;
995}
996
Bill Wendlingce4fe412012-08-08 06:30:30 +0000997} // end llvm namespace