1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 11:42:57 +01:00

[ms-inline asm] Perform field lookups with the dot operator.

llvm-svn: 166724
This commit is contained in:
Chad Rosier 2012-10-25 21:51:10 +00:00
parent 0ccb9515e1
commit a9537e1bfc
2 changed files with 21 additions and 4 deletions

View File

@ -37,6 +37,8 @@ public:
virtual ~MCAsmParserSemaCallback(); virtual ~MCAsmParserSemaCallback();
virtual void *LookupInlineAsmIdentifier(StringRef Name, void *Loc, virtual void *LookupInlineAsmIdentifier(StringRef Name, void *Loc,
unsigned &Size) = 0; unsigned &Size) = 0;
virtual bool LookupInlineAsmField(StringRef Base, StringRef Member,
unsigned &Offset) = 0;
}; };
/// MCAsmParser - Generic assembler parser interface, for use by target specific /// MCAsmParser - Generic assembler parser interface, for use by target specific

View File

@ -841,15 +841,30 @@ bool X86AsmParser::ParseIntelDotOperator(const MCExpr *Disp,
APInt DotDisp; APInt DotDisp;
DotDispStr.getAsInteger(10, DotDisp); DotDispStr.getAsInteger(10, DotDisp);
DotDispVal = DotDisp.getZExtValue(); DotDispVal = DotDisp.getZExtValue();
} else if (Tok.is(AsmToken::Identifier)) {
// We should only see an identifier when parsing the original inline asm.
// The front-end should rewrite this in terms of immediates.
assert (isParsingInlineAsm() && "Unexpected field name!");
unsigned DotDisp;
std::pair<StringRef, StringRef> BaseMember = DotDispStr.split('.');
if (SemaCallback->LookupInlineAsmField(BaseMember.first, BaseMember.second,
DotDisp)) {
Err = "Unable to lookup field reference!";
return true;
}
DotDispVal = DotDisp;
} else { } else {
Err = "Unexpected token type!"; Err = "Unexpected token type!";
return true; return true;
} }
// Special case zero dot displacement. if (isParsingInlineAsm() && Tok.is(AsmToken::Identifier)) {
if (!DotDispVal) { SMLoc Loc = SMLoc::getFromPointer(DotDispStr.data());
*NewDisp = Disp; unsigned Len = DotDispStr.size();
return false; unsigned Val = OrigDispVal + DotDispVal;
InstInfo->AsmRewrites->push_back(AsmRewrite(AOK_DotOperator, Loc, Len,
Val));
} }
*NewDisp = MCConstantExpr::Create(OrigDispVal + DotDispVal, getContext()); *NewDisp = MCConstantExpr::Create(OrigDispVal + DotDispVal, getContext());