summaryrefslogtreecommitdiff
path: root/lib/MC
diff options
context:
space:
mode:
authorChad Rosier <mcrosier@apple.com>2012-10-13 00:26:04 +0000
committerChad Rosier <mcrosier@apple.com>2012-10-13 00:26:04 +0000
commit84125ca43c758fd21fdab2b05196e0df57c55c96 (patch)
tree539f0b38eee40c8e292f5a35a0b46cd2641edfc5 /lib/MC
parentfa8cd9d64a3bd090d9176ea019a6d1b6b2051dd0 (diff)
downloadllvm-84125ca43c758fd21fdab2b05196e0df57c55c96.tar.gz
llvm-84125ca43c758fd21fdab2b05196e0df57c55c96.tar.bz2
llvm-84125ca43c758fd21fdab2b05196e0df57c55c96.tar.xz
[ms-inline asm] Remove the MatchInstruction() function. Previously, this was
the interface between the front-end and the MC layer when parsing inline assembly. Unfortunately, this is too deep into the parsing stack. Specifically, we're unable to handle target-independent assembly (i.e., assembly directives, labels, etc.). Note the MatchAndEmitInstruction() isn't the correct abstraction either. I'll be exposing target-independent hooks shortly, so this is really just a cleanup. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165858 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC')
-rw-r--r--lib/MC/MCParser/AsmParser.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/MC/MCParser/AsmParser.cpp b/lib/MC/MCParser/AsmParser.cpp
index c2fff3c520..8bf017a1a0 100644
--- a/lib/MC/MCParser/AsmParser.cpp
+++ b/lib/MC/MCParser/AsmParser.cpp
@@ -133,6 +133,9 @@ private:
/// IsDarwin - is Darwin compatibility enabled?
bool IsDarwin;
+ /// ParsingInlineAsm - are we parsing ms-style inline assembly?
+ bool ParsingInlineAsm;
+
public:
AsmParser(SourceMgr &SM, MCContext &Ctx, MCStreamer &Out,
const MCAsmInfo &MAI);
@@ -171,6 +174,8 @@ public:
virtual const AsmToken &Lex();
+ void setParsingInlineAsm(bool V) { ParsingInlineAsm = V; }
+
bool ParseExpression(const MCExpr *&Res);
virtual bool ParseExpression(const MCExpr *&Res, SMLoc &EndLoc);
virtual bool ParseParenExpression(const MCExpr *&Res, SMLoc &EndLoc);
@@ -412,7 +417,7 @@ AsmParser::AsmParser(SourceMgr &_SM, MCContext &_Ctx,
: Lexer(_MAI), Ctx(_Ctx), Out(_Out), MAI(_MAI), SrcMgr(_SM),
GenericParser(new GenericAsmParser), PlatformParser(0),
CurBuffer(0), MacrosEnabled(true), CppHashLineNumber(0),
- AssemblerDialect(~0U), IsDarwin(false) {
+ AssemblerDialect(~0U), IsDarwin(false), ParsingInlineAsm(false) {
// Save the old handler.
SavedDiagHandler = SrcMgr.getDiagHandler();
SavedDiagContext = SrcMgr.getDiagContext();
@@ -604,7 +609,7 @@ bool AsmParser::Run(bool NoInitialTextSection, bool NoFinalize) {
}
void AsmParser::CheckForValidSection() {
- if (!getStreamer().getCurrentSection()) {
+ if (!ParsingInlineAsm && !getStreamer().getCurrentSection()) {
TokError("expected section directive before assembly directive");
Out.SwitchSection(Ctx.getMachOSection(
"__TEXT", "__text",
@@ -1346,9 +1351,14 @@ bool AsmParser::ParseStatement() {
}
// If parsing succeeded, match the instruction.
- if (!HadError)
- HadError = getTargetParser().MatchAndEmitInstruction(IDLoc, ParsedOperands,
- Out);
+ if (!HadError) {
+ unsigned Opcode;
+ unsigned ErrorInfo;
+ HadError = getTargetParser().MatchAndEmitInstruction(IDLoc, Opcode,
+ ParsedOperands,
+ Out, ErrorInfo,
+ ParsingInlineAsm);
+ }
// Free any parsed operands.
for (unsigned i = 0, e = ParsedOperands.size(); i != e; ++i)