[ms-inline asm] Move the immediate asm rewrite into the target specific

logic as a QOI cleanup.  No functional change.  Tests already in place.
rdar://13456414

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177446 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chad Rosier 2013-03-19 21:58:18 +00:00
parent 9deb91722c
commit 811ddf64af
2 changed files with 5 additions and 15 deletions

View File

@ -4105,12 +4105,8 @@ AsmParser::parseMSInlineAsm(void *AsmLoc, std::string &AsmString,
MCParsedAsmOperand *Operand = Info.ParsedOperands[i]; MCParsedAsmOperand *Operand = Info.ParsedOperands[i];
// Immediate. // Immediate.
if (Operand->isImm()) { if (Operand->isImm())
if (Operand->needAsmRewrite())
AsmStrRewrites.push_back(AsmRewrite(AOK_ImmPrefix,
Operand->getStartLoc()));
continue; continue;
}
// Register operand. // Register operand.
if (Operand->isReg() && !Operand->needAddressOf()) { if (Operand->isReg() && !Operand->needAddressOf()) {

View File

@ -184,7 +184,6 @@ struct X86Operand : public MCParsedAsmOperand {
struct ImmOp { struct ImmOp {
const MCExpr *Val; const MCExpr *Val;
bool NeedAsmRewrite;
}; };
struct MemOp { struct MemOp {
@ -238,11 +237,6 @@ struct X86Operand : public MCParsedAsmOperand {
return Imm.Val; return Imm.Val;
} }
bool needAsmRewrite() const {
assert(Kind == Immediate && "Invalid access!");
return Imm.NeedAsmRewrite;
}
const MCExpr *getMemDisp() const { const MCExpr *getMemDisp() const {
assert(Kind == Memory && "Invalid access!"); assert(Kind == Memory && "Invalid access!");
return Mem.Disp; return Mem.Disp;
@ -482,11 +476,9 @@ struct X86Operand : public MCParsedAsmOperand {
return Res; return Res;
} }
static X86Operand *CreateImm(const MCExpr *Val, SMLoc StartLoc, SMLoc EndLoc, static X86Operand *CreateImm(const MCExpr *Val, SMLoc StartLoc, SMLoc EndLoc){
bool NeedRewrite = true){
X86Operand *Res = new X86Operand(Immediate, StartLoc, EndLoc); X86Operand *Res = new X86Operand(Immediate, StartLoc, EndLoc);
Res->Imm.Val = Val; Res->Imm.Val = Val;
Res->Imm.NeedAsmRewrite = NeedRewrite;
return Res; return Res;
} }
@ -1205,7 +1197,7 @@ X86Operand *X86AsmParser::ParseIntelOperator(SMLoc Start, unsigned OpKind) {
InstInfo->AsmRewrites->push_back(AsmRewrite(AOK_Imm, TypeLoc, Len, CVal)); InstInfo->AsmRewrites->push_back(AsmRewrite(AOK_Imm, TypeLoc, Len, CVal));
const MCExpr *Imm = MCConstantExpr::Create(CVal, getContext()); const MCExpr *Imm = MCConstantExpr::Create(CVal, getContext());
return X86Operand::CreateImm(Imm, Start, End, /*NeedAsmRewrite*/false); return X86Operand::CreateImm(Imm, Start, End);
} }
X86Operand *X86AsmParser::ParseIntelOperand() { X86Operand *X86AsmParser::ParseIntelOperand() {
@ -1229,6 +1221,8 @@ X86Operand *X86AsmParser::ParseIntelOperand() {
getLexer().is(AsmToken::Minus)) { getLexer().is(AsmToken::Minus)) {
const MCExpr *Val; const MCExpr *Val;
if (!getParser().parseExpression(Val, End)) { if (!getParser().parseExpression(Val, End)) {
if (isParsingInlineAsm())
InstInfo->AsmRewrites->push_back(AsmRewrite(AOK_ImmPrefix, Start));
return X86Operand::CreateImm(Val, Start, End); return X86Operand::CreateImm(Val, Start, End);
} }
} }