|
12 | 12 | #include "llvm/BinaryFormat/COFF.h" |
13 | 13 | #include "llvm/MC/MCContext.h" |
14 | 14 | #include "llvm/MC/MCDirectives.h" |
| 15 | +#include "llvm/MC/MCObjectFileInfo.h" |
15 | 16 | #include "llvm/MC/MCParser/MCAsmLexer.h" |
16 | 17 | #include "llvm/MC/MCParser/MCAsmParserExtension.h" |
17 | 18 | #include "llvm/MC/MCSectionCOFF.h" |
@@ -70,6 +71,7 @@ class COFFAsmParser : public MCAsmParserExtension { |
70 | 71 | addDirectiveHandler<&COFFAsmParser::parseDirectiveSymbolAttribute>( |
71 | 72 | ".weak_anti_dep"); |
72 | 73 | addDirectiveHandler<&COFFAsmParser::parseDirectiveCGProfile>(".cg_profile"); |
| 74 | + addDirectiveHandler<&COFFAsmParser::parseDirectiveImpCall>(".impcall"); |
73 | 75 |
|
74 | 76 | // Win64 EH directives. |
75 | 77 | addDirectiveHandler<&COFFAsmParser::parseSEHDirectiveStartProc>( |
@@ -126,6 +128,7 @@ class COFFAsmParser : public MCAsmParserExtension { |
126 | 128 | bool parseDirectiveLinkOnce(StringRef, SMLoc); |
127 | 129 | bool parseDirectiveRVA(StringRef, SMLoc); |
128 | 130 | bool parseDirectiveCGProfile(StringRef, SMLoc); |
| 131 | + bool parseDirectiveImpCall(StringRef, SMLoc); |
129 | 132 |
|
130 | 133 | // Win64 EH directives. |
131 | 134 | bool parseSEHDirectiveStartProc(StringRef, SMLoc); |
@@ -577,6 +580,24 @@ bool COFFAsmParser::parseDirectiveSymIdx(StringRef, SMLoc) { |
577 | 580 | return false; |
578 | 581 | } |
579 | 582 |
|
| 583 | +bool COFFAsmParser::parseDirectiveImpCall(StringRef, SMLoc) { |
| 584 | + if (!getContext().getObjectFileInfo()->getImportCallSection()) |
| 585 | + return TokError("target does not have an import call section"); |
| 586 | + |
| 587 | + StringRef SymbolID; |
| 588 | + if (getParser().parseIdentifier(SymbolID)) |
| 589 | + return TokError("expected identifier in directive"); |
| 590 | + |
| 591 | + if (getLexer().isNot(AsmToken::EndOfStatement)) |
| 592 | + return TokError("unexpected token in directive"); |
| 593 | + |
| 594 | + MCSymbol *Symbol = getContext().getOrCreateSymbol(SymbolID); |
| 595 | + |
| 596 | + Lex(); |
| 597 | + getStreamer().emitCOFFImpCall(Symbol); |
| 598 | + return false; |
| 599 | +} |
| 600 | + |
580 | 601 | /// ::= [ identifier ] |
581 | 602 | bool COFFAsmParser::parseCOMDATType(COFF::COMDATType &Type) { |
582 | 603 | StringRef TypeId = getTok().getIdentifier(); |
|
0 commit comments