From: Chad Rosier Date: Thu, 18 Oct 2012 19:39:30 +0000 (+0000) Subject: [ms-inline asm] Have the LookupInlineAsmIdentifier() callback function return a X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f641baa0300c6742621a04ce6b3d89b2942ae9ac;p=platform%2Fupstream%2Fllvm.git [ms-inline asm] Have the LookupInlineAsmIdentifier() callback function return a *NamedDecl. In turn, build the expressions after we're finished parsing the asm. This avoids a crasher if the lookup fails. llvm-svn: 166212 --- diff --git a/llvm/include/llvm/MC/MCParser/MCAsmParser.h b/llvm/include/llvm/MC/MCParser/MCAsmParser.h index ea20c15..bb71a46 100644 --- a/llvm/include/llvm/MC/MCParser/MCAsmParser.h +++ b/llvm/include/llvm/MC/MCParser/MCAsmParser.h @@ -34,8 +34,7 @@ class Twine; /// MCAsmParserSemaCallback - Generic Sema callback for assembly parser. class MCAsmParserSemaCallback { public: - virtual void *LookupInlineAsmIdentifier(StringRef Name, void *Loc, - void **IdentifierInfoPtr) = 0; + virtual void *LookupInlineAsmIdentifier(StringRef Name, void *Loc) = 0; }; /// MCAsmParser - Generic assembler parser interface, for use by target specific @@ -89,9 +88,8 @@ public: /// ParseMSInlineAsm - Parse ms-style inline assembly. virtual bool ParseMSInlineAsm(void *AsmLoc, std::string &AsmString, unsigned &NumOutputs, unsigned &NumInputs, - SmallVectorImpl &Names, + SmallVectorImpl &OpDecls, SmallVectorImpl &Constraints, - SmallVectorImpl &Exprs, SmallVectorImpl &Clobbers, const MCInstrInfo *MII, const MCInstPrinter *IP, diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp index 78a877b..0e8fe6d 100644 --- a/llvm/lib/MC/MCParser/AsmParser.cpp +++ b/llvm/lib/MC/MCParser/AsmParser.cpp @@ -190,9 +190,8 @@ public: bool ParseMSInlineAsm(void *AsmLoc, std::string &AsmString, unsigned &NumOutputs, unsigned &NumInputs, - SmallVectorImpl &Names, + SmallVectorImpl &OpDecls, SmallVectorImpl &Constraints, - SmallVectorImpl &Exprs, SmallVectorImpl &Clobbers, const MCInstrInfo *MII, const MCInstPrinter *IP, @@ -3592,19 +3591,16 @@ public: bool AsmParser::ParseMSInlineAsm(void *AsmLoc, std::string &AsmString, unsigned &NumOutputs, unsigned &NumInputs, - SmallVectorImpl &Names, + SmallVectorImpl &OpDecls, SmallVectorImpl &Constraints, - SmallVectorImpl &Exprs, SmallVectorImpl &Clobbers, const MCInstrInfo *MII, const MCInstPrinter *IP, MCAsmParserSemaCallback &SI) { - SmallVector Inputs; - SmallVector Outputs; + SmallVector InputDecls; + SmallVector OutputDecls; SmallVector InputConstraints; SmallVector OutputConstraints; - SmallVector InputExprs; - SmallVector OutputExprs; std::set ClobberRegs; SmallVector AsmStrRewrites; @@ -3647,24 +3643,20 @@ bool AsmParser::ParseMSInlineAsm(void *AsmLoc, std::string &AsmString, } // Expr/Input or Output. - void *II; - void *ExprResult = SI.LookupInlineAsmIdentifier(Operand->getName(), - AsmLoc, &II); - if (ExprResult) { + void *OpDecl = SI.LookupInlineAsmIdentifier(Operand->getName(), AsmLoc); + if (OpDecl) { bool isOutput = (i == 1) && Desc.mayStore(); if (isOutput) { std::string Constraint = "="; ++InputIdx; - Outputs.push_back(II); - OutputExprs.push_back(ExprResult); + OutputDecls.push_back(OpDecl); Constraint += Operand->getConstraint().str(); OutputConstraints.push_back(Constraint); AsmStrRewrites.push_back(AsmOpRewrite(AOK_Output, Operand->getStartLoc(), Operand->getNameLen())); } else { - Inputs.push_back(II); - InputExprs.push_back(ExprResult); + InputDecls.push_back(OpDecl); InputConstraints.push_back(Operand->getConstraint().str()); AsmStrRewrites.push_back(AsmOpRewrite(AOK_Input, Operand->getStartLoc(), @@ -3680,8 +3672,8 @@ bool AsmParser::ParseMSInlineAsm(void *AsmLoc, std::string &AsmString, } // Set the number of Outputs and Inputs. - NumOutputs = Outputs.size(); - NumInputs = Inputs.size(); + NumOutputs = OutputDecls.size(); + NumInputs = InputDecls.size(); // Set the unique clobbers. for (std::set::iterator I = ClobberRegs.begin(), @@ -3691,18 +3683,15 @@ bool AsmParser::ParseMSInlineAsm(void *AsmLoc, std::string &AsmString, // Merge the various outputs and inputs. Output are expected first. if (NumOutputs || NumInputs) { unsigned NumExprs = NumOutputs + NumInputs; - Names.resize(NumExprs); + OpDecls.resize(NumExprs); Constraints.resize(NumExprs); - Exprs.resize(NumExprs); for (unsigned i = 0; i < NumOutputs; ++i) { - Names[i] = Outputs[i]; + OpDecls[i] = OutputDecls[i]; Constraints[i] = OutputConstraints[i]; - Exprs[i] = OutputExprs[i]; } for (unsigned i = 0, j = NumOutputs; i < NumInputs; ++i, ++j) { - Names[j] = Inputs[i]; + OpDecls[j] = InputDecls[i]; Constraints[j] = InputConstraints[i]; - Exprs[j] = InputExprs[i]; } }