LLVM 23.0.0git
COFFMasmParser.cpp
Go to the documentation of this file.
1//===- COFFMasmParser.cpp - COFF MASM Assembly Parser ---------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10#include "llvm/ADT/Twine.h"
12#include "llvm/MC/MCAsmMacro.h"
13#include "llvm/MC/MCContext.h"
18#include "llvm/MC/MCStreamer.h"
20#include "llvm/MC/SectionKind.h"
21#include "llvm/Support/SMLoc.h"
22#include <cstdint>
23
24using namespace llvm;
25
26namespace {
27
28class COFFMasmParser : public MCAsmParserExtension {
29 template <bool (COFFMasmParser::*HandlerMethod)(StringRef, SMLoc)>
30 void addDirectiveHandler(StringRef Directive) {
32 std::make_pair(this, HandleDirective<COFFMasmParser, HandlerMethod>);
33 getParser().addDirectiveHandler(Directive, Handler);
34 }
35
36 bool parseSectionSwitch(StringRef SectionName, unsigned Characteristics);
37
38 bool parseSectionSwitch(StringRef SectionName, unsigned Characteristics,
39 StringRef COMDATSymName, COFF::COMDATType Type,
40 Align Alignment);
41
42 bool parseDirectiveProc(StringRef, SMLoc);
43 bool parseDirectiveEndProc(StringRef, SMLoc);
44 bool parseDirectiveSegment(StringRef, SMLoc);
45 bool parseDirectiveSegmentEnd(StringRef, SMLoc);
46 bool parseDirectiveIncludelib(StringRef, SMLoc);
47 bool parseDirectiveOption(StringRef, SMLoc);
48
49 bool parseDirectiveAlias(StringRef, SMLoc);
50
51 bool parseSEHDirectiveAllocStack(StringRef, SMLoc);
52 bool parseSEHDirectiveFreeStack(StringRef, SMLoc);
53 bool parseSEHDirectiveEndProlog(StringRef, SMLoc);
54 bool parseSEHDirectiveBeginEpilog(StringRef, SMLoc);
55 bool parseSEHDirectiveEndEpilog(StringRef, SMLoc);
56
57 /// Check that we are inside a PROC FRAME.
58 bool ensureInsideFrame(SMLoc Loc);
59 /// Check that we are in the prolog (before .endprolog).
60 bool ensureInProlog(SMLoc Loc);
61 /// Check that we are inside a .beginepilog/.endepilog block.
62 bool ensureInEpilog(SMLoc Loc);
63
64 bool IgnoreDirective(StringRef, SMLoc) {
65 while (!getLexer().is(AsmToken::EndOfStatement)) {
66 Lex();
67 }
68 return false;
69 }
70
71 void Initialize(MCAsmParser &Parser) override {
72 // Call the base implementation.
74
75 // x64 directives
76 addDirectiveHandler<&COFFMasmParser::parseSEHDirectiveAllocStack>(
77 ".allocstack");
78 addDirectiveHandler<&COFFMasmParser::parseSEHDirectiveFreeStack>(
79 ".freestack");
80 addDirectiveHandler<&COFFMasmParser::parseSEHDirectiveEndProlog>(
81 ".endprolog");
82 addDirectiveHandler<&COFFMasmParser::parseSEHDirectiveBeginEpilog>(
83 ".beginepilog");
84 addDirectiveHandler<&COFFMasmParser::parseSEHDirectiveEndEpilog>(
85 ".endepilog");
86
87 // Code label directives
88 // label
89 // org
90
91 // Conditional control flow directives
92 // .break
93 // .continue
94 // .else
95 // .elseif
96 // .endif
97 // .endw
98 // .if
99 // .repeat
100 // .until
101 // .untilcxz
102 // .while
103
104 // Data allocation directives
105 // align
106 // even
107 // mmword
108 // tbyte
109 // xmmword
110 // ymmword
111
112 // Listing control directives
113 addDirectiveHandler<&COFFMasmParser::IgnoreDirective>(".cref");
114 addDirectiveHandler<&COFFMasmParser::IgnoreDirective>(".list");
115 addDirectiveHandler<&COFFMasmParser::IgnoreDirective>(".listall");
116 addDirectiveHandler<&COFFMasmParser::IgnoreDirective>(".listif");
117 addDirectiveHandler<&COFFMasmParser::IgnoreDirective>(".listmacro");
118 addDirectiveHandler<&COFFMasmParser::IgnoreDirective>(".listmacroall");
119 addDirectiveHandler<&COFFMasmParser::IgnoreDirective>(".nocref");
120 addDirectiveHandler<&COFFMasmParser::IgnoreDirective>(".nolist");
121 addDirectiveHandler<&COFFMasmParser::IgnoreDirective>(".nolistif");
122 addDirectiveHandler<&COFFMasmParser::IgnoreDirective>(".nolistmacro");
123 addDirectiveHandler<&COFFMasmParser::IgnoreDirective>("page");
124 addDirectiveHandler<&COFFMasmParser::IgnoreDirective>("subtitle");
125 addDirectiveHandler<&COFFMasmParser::IgnoreDirective>(".tfcond");
126 addDirectiveHandler<&COFFMasmParser::IgnoreDirective>("title");
127
128 // Macro directives
129 // goto
130
131 // Miscellaneous directives
132 addDirectiveHandler<&COFFMasmParser::parseDirectiveAlias>("alias");
133 // assume
134 // .fpo
135 addDirectiveHandler<&COFFMasmParser::parseDirectiveIncludelib>(
136 "includelib");
137 addDirectiveHandler<&COFFMasmParser::parseDirectiveOption>("option");
138 // popcontext
139 // pushcontext
140 // .safeseh
141
142 // Procedure directives
143 addDirectiveHandler<&COFFMasmParser::parseDirectiveEndProc>("endp");
144 // invoke (32-bit only)
145 addDirectiveHandler<&COFFMasmParser::parseDirectiveProc>("proc");
146 // proto
147
148 // Processor directives; all ignored
149 addDirectiveHandler<&COFFMasmParser::IgnoreDirective>(".386");
150 addDirectiveHandler<&COFFMasmParser::IgnoreDirective>(".386p");
151 addDirectiveHandler<&COFFMasmParser::IgnoreDirective>(".387");
152 addDirectiveHandler<&COFFMasmParser::IgnoreDirective>(".486");
153 addDirectiveHandler<&COFFMasmParser::IgnoreDirective>(".486p");
154 addDirectiveHandler<&COFFMasmParser::IgnoreDirective>(".586");
155 addDirectiveHandler<&COFFMasmParser::IgnoreDirective>(".586p");
156 addDirectiveHandler<&COFFMasmParser::IgnoreDirective>(".686");
157 addDirectiveHandler<&COFFMasmParser::IgnoreDirective>(".686p");
158 addDirectiveHandler<&COFFMasmParser::IgnoreDirective>(".k3d");
159 addDirectiveHandler<&COFFMasmParser::IgnoreDirective>(".mmx");
160 addDirectiveHandler<&COFFMasmParser::IgnoreDirective>(".xmm");
161
162 // Scope directives
163 // comm
164 // externdef
165
166 // Segment directives
167 // .alpha (32-bit only, order segments alphabetically)
168 // .dosseg (32-bit only, order segments in DOS convention)
169 // .seq (32-bit only, order segments sequentially)
170 addDirectiveHandler<&COFFMasmParser::parseDirectiveSegmentEnd>("ends");
171 // group (32-bit only)
172 addDirectiveHandler<&COFFMasmParser::parseDirectiveSegment>("segment");
173
174 // Simplified segment directives
175 addDirectiveHandler<&COFFMasmParser::parseSectionDirectiveCode>(".code");
176 // .const
177 addDirectiveHandler<&COFFMasmParser::parseSectionDirectiveInitializedData>(
178 ".data");
179 addDirectiveHandler<
180 &COFFMasmParser::parseSectionDirectiveUninitializedData>(".data?");
181 // .exit
182 // .fardata
183 // .fardata?
184 addDirectiveHandler<&COFFMasmParser::IgnoreDirective>(".model");
185 // .stack
186 // .startup
187
188 // String directives, written <name> <directive> <params>
189 // catstr (equivalent to <name> TEXTEQU <params>)
190 // instr (equivalent to <name> = @InStr(<params>))
191 // sizestr (equivalent to <name> = @SizeStr(<params>))
192 // substr (equivalent to <name> TEXTEQU @SubStr(<params>))
193
194 // Structure and record directives
195 // record
196 // typedef
197 }
198
199 bool parseSectionDirectiveCode(StringRef, SMLoc) {
200 return parseSectionSwitch(".text", COFF::IMAGE_SCN_CNT_CODE |
203 }
204
205 bool parseSectionDirectiveInitializedData(StringRef, SMLoc) {
206 return parseSectionSwitch(".data", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
209 }
210
211 bool parseSectionDirectiveUninitializedData(StringRef, SMLoc) {
212 return parseSectionSwitch(".bss", COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA |
215 }
216
217 /// Stack of active procedure definitions.
218 SmallVector<StringRef, 1> CurrentProcedures;
219 SmallVector<bool, 1> CurrentProceduresFramed;
220
221public:
222 COFFMasmParser() = default;
223};
224
225} // end anonymous namespace.
226
227bool COFFMasmParser::parseSectionSwitch(StringRef SectionName,
228 unsigned Characteristics) {
229 return parseSectionSwitch(SectionName, Characteristics, "",
230 (COFF::COMDATType)0, Align(16));
231}
232
233bool COFFMasmParser::parseSectionSwitch(StringRef SectionName,
234 unsigned Characteristics,
235 StringRef COMDATSymName,
237 Align Alignment) {
238 if (getLexer().isNot(AsmToken::EndOfStatement))
239 return TokError("unexpected token in section switching directive");
240 Lex();
241
242 MCSection *Section = getContext().getCOFFSection(SectionName, Characteristics,
243 COMDATSymName, Type);
244 Section->setAlignment(Alignment);
245 getStreamer().switchSection(Section);
246
247 return false;
248}
249
250bool COFFMasmParser::parseDirectiveSegment(StringRef Directive, SMLoc Loc) {
251 StringRef SegmentName;
252 if (!getLexer().is(AsmToken::Identifier))
253 return TokError("expected identifier in directive");
254 SegmentName = getTok().getIdentifier();
255 Lex();
256
257 StringRef SectionName = SegmentName;
258 SmallVector<char, 247> SectionNameVector;
259
260 StringRef Class;
261 if (SegmentName == "_TEXT" || SegmentName.starts_with("_TEXT$")) {
262 if (SegmentName.size() == 5) {
263 SectionName = ".text";
264 } else {
266 (".text$" + SegmentName.substr(6)).toStringRef(SectionNameVector);
267 }
268 Class = "CODE";
269 }
270
271 // Parse all options to end of statement.
272 // Alignment defaults to PARA if unspecified.
273 int64_t Alignment = 16;
274 // Default flags are used only if no characteristics are set.
275 bool DefaultCharacteristics = true;
276 unsigned Flags = 0;
277 // "obsolete" according to the documentation, but still supported.
278 bool Readonly = false;
279 while (getLexer().isNot(AsmToken::EndOfStatement)) {
280 switch (getTok().getKind()) {
281 default:
282 break;
283 case AsmToken::String: {
284 // Class identifier; overrides Kind.
285 Class = getTok().getStringContents();
286 Lex();
287 break;
288 }
290 SMLoc KeywordLoc = getTok().getLoc();
291 StringRef Keyword;
292 if (getParser().parseIdentifier(Keyword)) {
293 llvm_unreachable("failed to parse identifier at an identifier token");
294 }
295 if (Keyword.equals_insensitive("byte")) {
296 Alignment = 1;
297 } else if (Keyword.equals_insensitive("word")) {
298 Alignment = 2;
299 } else if (Keyword.equals_insensitive("dword")) {
300 Alignment = 4;
301 } else if (Keyword.equals_insensitive("para")) {
302 Alignment = 16;
303 } else if (Keyword.equals_insensitive("page")) {
304 Alignment = 256;
305 } else if (Keyword.equals_insensitive("align")) {
306 if (getParser().parseToken(AsmToken::LParen) ||
307 getParser().parseIntToken(Alignment,
308 "Expected integer alignment") ||
309 getParser().parseToken(AsmToken::RParen)) {
310 return Error(getTok().getLoc(),
311 "Expected (n) following ALIGN in SEGMENT directive");
312 }
313 if (!isPowerOf2_64(Alignment) || Alignment > 8192) {
314 return Error(KeywordLoc,
315 "ALIGN argument must be a power of 2 from 1 to 8192");
316 }
317 } else if (Keyword.equals_insensitive("alias")) {
318 if (getParser().parseToken(AsmToken::LParen) ||
319 !getTok().is(AsmToken::String))
320 return Error(
321 getTok().getLoc(),
322 "Expected (string) following ALIAS in SEGMENT directive");
323 SectionName = getTok().getStringContents();
324 Lex();
325 if (getParser().parseToken(AsmToken::RParen))
326 return Error(
327 getTok().getLoc(),
328 "Expected (string) following ALIAS in SEGMENT directive");
329 } else if (Keyword.equals_insensitive("readonly")) {
330 Readonly = true;
331 } else {
332 unsigned Characteristic =
333 StringSwitch<unsigned>(Keyword)
334 .CaseLower("info", COFF::IMAGE_SCN_LNK_INFO)
335 .CaseLower("read", COFF::IMAGE_SCN_MEM_READ)
336 .CaseLower("write", COFF::IMAGE_SCN_MEM_WRITE)
337 .CaseLower("execute", COFF::IMAGE_SCN_MEM_EXECUTE)
338 .CaseLower("shared", COFF::IMAGE_SCN_MEM_SHARED)
339 .CaseLower("nopage", COFF::IMAGE_SCN_MEM_NOT_PAGED)
340 .CaseLower("nocache", COFF::IMAGE_SCN_MEM_NOT_CACHED)
341 .CaseLower("discard", COFF::IMAGE_SCN_MEM_DISCARDABLE)
342 .Default(-1);
343 if (Characteristic == static_cast<unsigned>(-1)) {
344 return Error(KeywordLoc,
345 "Expected characteristic in SEGMENT directive; found '" +
346 Keyword + "'");
347 }
348 Flags |= Characteristic;
349 DefaultCharacteristics = false;
350 }
351 }
352 }
353 }
354
355 SectionKind Kind = StringSwitch<SectionKind>(Class)
356 .CaseLower("data", SectionKind::getData())
357 .CaseLower("code", SectionKind::getText())
358 .CaseLower("const", SectionKind::getReadOnly())
359 .Default(SectionKind::getData());
360 if (Kind.isText()) {
361 if (DefaultCharacteristics) {
363 }
365 } else {
366 if (DefaultCharacteristics) {
368 }
370 }
371 if (Readonly) {
372 Flags &= ~COFF::IMAGE_SCN_MEM_WRITE;
373 }
374
375 MCSection *Section = getContext().getCOFFSection(SectionName, Flags, "",
376 (COFF::COMDATType)(0));
377 if (Alignment != 0) {
378 Section->setAlignment(Align(Alignment));
379 }
380 getStreamer().switchSection(Section);
381 return false;
382}
383
384/// parseDirectiveSegmentEnd
385/// ::= identifier "ends"
386bool COFFMasmParser::parseDirectiveSegmentEnd(StringRef Directive, SMLoc Loc) {
387 StringRef SegmentName;
388 if (!getLexer().is(AsmToken::Identifier))
389 return TokError("expected identifier in directive");
390 SegmentName = getTok().getIdentifier();
391
392 // Ignore; no action necessary.
393 Lex();
394 return false;
395}
396
397/// parseDirectiveIncludelib
398/// ::= "includelib" identifier
399bool COFFMasmParser::parseDirectiveIncludelib(StringRef Directive, SMLoc Loc) {
400 StringRef Lib;
401 if (getParser().parseIdentifier(Lib))
402 return TokError("expected identifier in includelib directive");
403
405 getStreamer().pushSection();
406 getStreamer().switchSection(getContext().getCOFFSection(
407 ".drectve", Flags, "", (COFF::COMDATType)(0)));
408 getStreamer().emitBytes("/DEFAULTLIB:");
409 getStreamer().emitBytes(Lib);
410 getStreamer().emitBytes(" ");
411 getStreamer().popSection();
412 return false;
413}
414
415/// parseDirectiveOption
416/// ::= "option" option-list
417bool COFFMasmParser::parseDirectiveOption(StringRef Directive, SMLoc Loc) {
418 auto parseOption = [&]() -> bool {
419 StringRef Option;
420 if (getParser().parseIdentifier(Option))
421 return TokError("expected identifier for option name");
422 if (Option.equals_insensitive("prologue")) {
423 StringRef MacroId;
424 if (parseToken(AsmToken::Colon) || getParser().parseIdentifier(MacroId))
425 return TokError("expected :macroId after OPTION PROLOGUE");
426 if (MacroId.equals_insensitive("none")) {
427 // Since we currently don't implement prologues/epilogues, NONE is our
428 // default.
429 return false;
430 }
431 return TokError("OPTION PROLOGUE is currently unsupported");
432 }
433 if (Option.equals_insensitive("epilogue")) {
434 StringRef MacroId;
435 if (parseToken(AsmToken::Colon) || getParser().parseIdentifier(MacroId))
436 return TokError("expected :macroId after OPTION EPILOGUE");
437 if (MacroId.equals_insensitive("none")) {
438 // Since we currently don't implement prologues/epilogues, NONE is our
439 // default.
440 return false;
441 }
442 return TokError("OPTION EPILOGUE is currently unsupported");
443 }
444 return TokError("OPTION '" + Option + "' is currently unsupported");
445 };
446
447 if (parseMany(parseOption))
448 return addErrorSuffix(" in OPTION directive");
449 return false;
450}
451
452/// parseDirectiveProc
453/// TODO(epastor): Implement parameters and other attributes.
454/// ::= label "proc" [[distance]]
455/// statements
456/// label "endproc"
457bool COFFMasmParser::parseDirectiveProc(StringRef Directive, SMLoc Loc) {
458 if (!getStreamer().getCurrentFragment())
459 return Error(getTok().getLoc(), "expected section directive");
460
461 MCSymbol *Sym;
462 if (getParser().parseSymbol(Sym))
463 return Error(Loc, "expected identifier for procedure");
464 if (getLexer().is(AsmToken::Identifier)) {
465 StringRef nextVal = getTok().getString();
466 SMLoc nextLoc = getTok().getLoc();
467 if (nextVal.equals_insensitive("far")) {
468 // TODO(epastor): Handle far procedure definitions.
469 Lex();
470 return Error(nextLoc, "far procedure definitions not yet supported");
471 } else if (nextVal.equals_insensitive("near")) {
472 Lex();
473 nextVal = getTok().getString();
474 nextLoc = getTok().getLoc();
475 }
476 }
477
478 // Define symbol as simple external function
479 auto *COFFSym = static_cast<MCSymbolCOFF *>(Sym);
480 COFFSym->setExternal(true);
481 COFFSym->setType(COFF::IMAGE_SYM_DTYPE_FUNCTION
483
484 bool Framed = false;
485 if (getLexer().is(AsmToken::Identifier) &&
486 getTok().getString().equals_insensitive("frame")) {
487 Lex();
488 Framed = true;
489 getStreamer().emitWinCFIStartProc(Sym, Loc);
490 }
491 getStreamer().emitLabel(Sym, Loc);
492
493 CurrentProcedures.push_back(Sym->getName());
494 CurrentProceduresFramed.push_back(Framed);
495 return false;
496}
497bool COFFMasmParser::parseDirectiveEndProc(StringRef Directive, SMLoc Loc) {
498 StringRef Label;
499 SMLoc LabelLoc = getTok().getLoc();
500 if (getParser().parseIdentifier(Label))
501 return Error(LabelLoc, "expected identifier for procedure end");
502
503 if (CurrentProcedures.empty())
504 return Error(Loc, "endp outside of procedure block");
505 else if (!CurrentProcedures.back().equals_insensitive(Label))
506 return Error(LabelLoc, "endp does not match current procedure '" +
507 CurrentProcedures.back() + "'");
508
509 if (CurrentProceduresFramed.back()) {
510 getStreamer().emitWinCFIEndProc(Loc);
511 }
512 CurrentProcedures.pop_back();
513 CurrentProceduresFramed.pop_back();
514 return false;
515}
516
517bool COFFMasmParser::parseDirectiveAlias(StringRef Directive, SMLoc Loc) {
518 std::string AliasName, ActualName;
519 if (getTok().isNot(AsmToken::Less) ||
520 getParser().parseAngleBracketString(AliasName))
521 return Error(getTok().getLoc(), "expected <aliasName>");
522 if (getParser().parseToken(AsmToken::Equal))
523 return addErrorSuffix(" in " + Directive + " directive");
524 if (getTok().isNot(AsmToken::Less) ||
525 getParser().parseAngleBracketString(ActualName))
526 return Error(getTok().getLoc(), "expected <actualName>");
527
528 MCSymbol *Alias = getContext().parseSymbol(AliasName);
529 MCSymbol *Actual = getContext().parseSymbol(ActualName);
530
531 getStreamer().emitWeakReference(Alias, Actual);
532
533 return false;
534}
535
536bool COFFMasmParser::ensureInsideFrame(SMLoc Loc) {
537 if (CurrentProceduresFramed.empty() || !CurrentProceduresFramed.back()) {
538 return Error(Loc,
539 "Missing Frame in proc, no unwind code will be generated.");
540 }
541 return false;
542}
543
544bool COFFMasmParser::ensureInProlog(SMLoc Loc) {
545 if (ensureInsideFrame(Loc))
546 return true;
547 if (getStreamer().isWinCFIPrologEnded()) {
548 return Error(Loc, "prolog directive must be used inside a prolog");
549 }
550 return false;
551}
552
553bool COFFMasmParser::ensureInEpilog(SMLoc Loc) {
554 if (ensureInsideFrame(Loc))
555 return true;
556 if (!getStreamer().isInEpilogCFI()) {
557 return Error(Loc, "epilog directive must be used inside an epilog");
558 }
559 return false;
560}
561
562bool COFFMasmParser::parseSEHDirectiveAllocStack(StringRef /*Directive*/,
563 SMLoc Loc) {
564 if (ensureInProlog(Loc))
565 return true;
566 int64_t Size;
567 SMLoc SizeLoc = getTok().getLoc();
568 if (getParser().parseAbsoluteExpression(Size))
569 return Error(SizeLoc, "expected integer size");
570 if (Size < 0)
571 return Error(SizeLoc, "stack size must be non-negative");
572 if (Size % 8 != 0)
573 return Error(SizeLoc, "stack size must be a multiple of 8");
574 getStreamer().emitWinCFIAllocStack(static_cast<unsigned>(Size), Loc);
575 return false;
576}
577
578bool COFFMasmParser::parseSEHDirectiveFreeStack(StringRef /*Directive*/,
579 SMLoc Loc) {
580 if (ensureInEpilog(Loc))
581 return true;
582 int64_t Size;
583 SMLoc SizeLoc = getTok().getLoc();
584 if (getParser().parseAbsoluteExpression(Size))
585 return Error(SizeLoc, "expected integer size");
586 if (Size < 0)
587 return Error(SizeLoc, "stack size must be non-negative");
588 if (Size % 8 != 0)
589 return Error(SizeLoc, "stack size must be a multiple of 8");
590 getStreamer().emitWinCFIAllocStack(static_cast<unsigned>(Size), Loc);
591 return false;
592}
593
594bool COFFMasmParser::parseSEHDirectiveEndProlog(StringRef /*Directive*/,
595 SMLoc Loc) {
596 if (ensureInsideFrame(Loc))
597 return true;
598 getStreamer().emitWinCFIEndProlog(Loc);
599 return false;
600}
601
602bool COFFMasmParser::parseSEHDirectiveBeginEpilog(StringRef /*Directive*/,
603 SMLoc Loc) {
604 if (ensureInsideFrame(Loc))
605 return true;
606 // .beginepilog is only valid after the prolog has ended (.endprolog) and
607 // when not already inside an epilog (i.e. after a prior .endepilog).
608 if (!getStreamer().isWinCFIPrologEnded() || getStreamer().isInEpilogCFI()) {
609 return Error(Loc, ".beginepilog must come after .endprolog or .endepilog");
610 }
611 getStreamer().emitWinCFIBeginEpilogue(Loc);
612 return false;
613}
614
615bool COFFMasmParser::parseSEHDirectiveEndEpilog(StringRef /*Directive*/,
616 SMLoc Loc) {
617 if (ensureInEpilog(Loc))
618 return true;
619 getStreamer().emitWinCFIEndEpilogue(Loc);
620 return false;
621}
622
624 return new COFFMasmParser;
625}
static bool isNot(const MachineRegisterInfo &MRI, const MachineInstr &MI)
Generic interface for extending the MCAsmParser, which is implemented by target and object file assem...
virtual void Initialize(MCAsmParser &Parser)
Initialize the extension for parsing using the given Parser.
std::pair< MCAsmParserExtension *, DirectiveHandler > ExtensionDirectiveHandler
StringRef getName() const
getName - Get the symbol name.
Definition MCSymbol.h:188
static SectionKind getText()
static SectionKind getData()
static SectionKind getReadOnly()
void push_back(const T &Elt)
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Definition StringRef.h:591
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
Definition StringRef.h:258
constexpr size_t size() const
Get the string size.
Definition StringRef.h:144
bool equals_insensitive(StringRef RHS) const
Check for string equality, ignoring case.
Definition StringRef.h:170
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
const char SectionName[]
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
@ IMAGE_SCN_MEM_NOT_PAGED
Definition COFF.h:333
@ IMAGE_SCN_MEM_SHARED
Definition COFF.h:334
@ IMAGE_SCN_CNT_CODE
Definition COFF.h:303
@ IMAGE_SCN_MEM_NOT_CACHED
Definition COFF.h:332
@ IMAGE_SCN_MEM_READ
Definition COFF.h:336
@ IMAGE_SCN_MEM_EXECUTE
Definition COFF.h:335
@ IMAGE_SCN_CNT_UNINITIALIZED_DATA
Definition COFF.h:305
@ IMAGE_SCN_MEM_DISCARDABLE
Definition COFF.h:331
@ IMAGE_SCN_LNK_INFO
Definition COFF.h:307
@ IMAGE_SCN_MEM_16BIT
Definition COFF.h:312
@ IMAGE_SCN_CNT_INITIALIZED_DATA
Definition COFF.h:304
@ IMAGE_SCN_MEM_PRELOAD
Definition COFF.h:314
@ IMAGE_SCN_MEM_WRITE
Definition COFF.h:337
@ IMAGE_SYM_DTYPE_FUNCTION
A function that returns a base type.
Definition COFF.h:276
@ SCT_COMPLEX_TYPE_SHIFT
Type is formed as (base + (derived << SCT_COMPLEX_TYPE_SHIFT))
Definition COFF.h:280
LLVM_ABI SimpleSymbol parseSymbol(StringRef SymName)
Get symbol classification by parsing the name of a symbol.
Definition Symbol.cpp:75
Context & getContext() const
Definition BasicBlock.h:99
This is an optimization pass for GlobalISel generic memory operations.
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
Definition MathExtras.h:284
LLVM_ABI MCAsmParserExtension * createCOFFMasmParser()
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...