diff --git a/llvm/include/llvm/MC/MCTargetAsmParser.h b/llvm/include/llvm/MC/MCTargetAsmParser.h index d132a732c416..bfcf233f70ba 100644 --- a/llvm/include/llvm/MC/MCTargetAsmParser.h +++ b/llvm/include/llvm/MC/MCTargetAsmParser.h @@ -182,6 +182,11 @@ public: return 0; } + /// Allow a target to perform any actions after the parse completes + /// successfully. For example, to write out constant pools for ldr pseudo on + /// ARM. + virtual void finishParse() {}; + virtual void onLabelParsed(MCSymbol *Symbol) { }; }; diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp index 35f38a2a87c4..5de10a7ba37e 100644 --- a/llvm/lib/MC/MCParser/AsmParser.cpp +++ b/llvm/lib/MC/MCParser/AsmParser.cpp @@ -677,6 +677,10 @@ bool AsmParser::Run(bool NoInitialTextSection, bool NoFinalize) { } } + // Callback to the target parser in case it needs to do anything. + if (!HadError) + getTargetParser().finishParse(); + // Finalize the output stream if there are no errors and if the client wants // us to. if (!HadError && !NoFinalize)