[llvm] r179336 - [ms-inline asm] Pass a StringRef reference to ParseIntelVarWithQualifier so we
Chad Rosier
mcrosier at apple.com
Thu Apr 11 16:24:15 PDT 2013
Author: mcrosier
Date: Thu Apr 11 18:24:15 2013
New Revision: 179336
URL: http://llvm.org/viewvc/llvm-project?rev=179336&view=rev
Log:
[ms-inline asm] Pass a StringRef reference to ParseIntelVarWithQualifier so we
can build up the identifier string. No test case as support for looking up
these type of identifiers hasn't been implemented on the clang side.
Part of rdar://13499009
Modified:
llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp
Modified: llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp?rev=179336&r1=179335&r2=179336&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Thu Apr 11 18:24:15 2013
@@ -64,7 +64,7 @@ private:
X86Operand *ParseIntelBracExpression(unsigned SegReg, SMLoc SizeDirLoc,
uint64_t ImmDisp, unsigned Size);
X86Operand *ParseIntelVarWithQualifier(const MCExpr *&Disp,
- SMLoc &IdentStart);
+ StringRef &Identifier);
X86Operand *ParseMemOperand(unsigned SegReg, SMLoc StartLoc);
X86Operand *CreateMemForInlineAsm(const MCExpr *Disp, SMLoc Start, SMLoc End,
@@ -1130,11 +1130,11 @@ X86Operand *X86AsmParser::ParseIntelBrac
SMLoc Loc = Tok.getLoc();
if (ParseRegister(TmpReg, Loc, End)) {
const MCExpr *Disp;
- SMLoc IdentStart = Tok.getLoc();
+ StringRef Identifier = Tok.getString();
if (getParser().parseExpression(Disp, End))
return 0;
- if (X86Operand *Err = ParseIntelVarWithQualifier(Disp, IdentStart))
+ if (X86Operand *Err = ParseIntelVarWithQualifier(Disp, Identifier))
return Err;
if (getLexer().isNot(AsmToken::RBrac))
@@ -1145,12 +1145,11 @@ X86Operand *X86AsmParser::ParseIntelBrac
InstInfo->AsmRewrites->push_back(AsmRewrite(AOK_Skip, Start, 1));
InstInfo->AsmRewrites->push_back(AsmRewrite(AOK_Skip, Tok.getLoc(), 1));
}
- unsigned Len = Tok.getLoc().getPointer() - IdentStart.getPointer();
- StringRef SymName(IdentStart.getPointer(), Len);
Parser.Lex(); // Eat ']'
if (!isParsingInlineAsm())
- return X86Operand::CreateMem(Disp, Start, End, Size, SymName);
- return CreateMemForInlineAsm(Disp, Start, End, SizeDirLoc, Size, SymName);
+ return X86Operand::CreateMem(Disp, Start, End, Size);
+ return CreateMemForInlineAsm(Disp, Start, End, SizeDirLoc, Size,
+ Identifier);
}
}
@@ -1255,7 +1254,7 @@ X86Operand *X86AsmParser::ParseIntelBrac
// Inline assembly may use variable names with namespace alias qualifiers.
X86Operand *X86AsmParser::ParseIntelVarWithQualifier(const MCExpr *&Disp,
- SMLoc &IdentStart) {
+ StringRef &Identifier) {
// We should only see Foo::Bar if we're parsing inline assembly.
if (!isParsingInlineAsm())
return 0;
@@ -1266,6 +1265,7 @@ X86Operand *X86AsmParser::ParseIntelVarW
bool Done = false;
const AsmToken &Tok = Parser.getTok();
+ AsmToken IdentEnd = Tok;
while (!Done) {
switch (getLexer().getKind()) {
default:
@@ -1280,12 +1280,14 @@ X86Operand *X86AsmParser::ParseIntelVarW
return ErrorOperand(Tok.getLoc(), "Expected an identifier token!");
break;
case AsmToken::Identifier:
+ IdentEnd = Tok;
getLexer().Lex(); // Consume the identifier.
break;
}
}
- size_t Len = Tok.getLoc().getPointer() - IdentStart.getPointer();
- StringRef Identifier(IdentStart.getPointer(), Len);
+
+ unsigned Len = IdentEnd.getLoc().getPointer() - Identifier.data();
+ Identifier = StringRef(Identifier.data(), Len + IdentEnd.getString().size());
MCSymbol *Sym = getContext().GetOrCreateSymbol(Identifier);
MCSymbolRefExpr::VariantKind Variant = MCSymbolRefExpr::VK_None;
Disp = MCSymbolRefExpr::Create(Sym, Variant, getParser().getContext());
@@ -1333,19 +1335,17 @@ X86Operand *X86AsmParser::ParseIntelMemO
}
const MCExpr *Disp = 0;
- SMLoc IdentStart = Tok.getLoc();
+ StringRef Identifier = Tok.getString();
if (getParser().parseExpression(Disp, End))
return 0;
if (!isParsingInlineAsm())
return X86Operand::CreateMem(Disp, Start, End, Size);
- if (X86Operand *Err = ParseIntelVarWithQualifier(Disp, IdentStart))
+ if (X86Operand *Err = ParseIntelVarWithQualifier(Disp, Identifier))
return Err;
- unsigned Len = Tok.getLoc().getPointer() - IdentStart.getPointer();
- StringRef SymName(IdentStart.getPointer(), Len);
- return CreateMemForInlineAsm(Disp, Start, End, Start, Size, SymName);
+ return CreateMemForInlineAsm(Disp, Start, End, Start, Size, Identifier);
}
/// Parse the '.' operator.
More information about the llvm-commits
mailing list