1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 12:43:36 +01:00

[ms-inline asm] Asm operands can map to one or more MCOperands. Therefore, add

the NumMCOperands argument to the GetMCInstOperandNum() function that is set
to the number of MCOperands this asm operand mapped to.

llvm-svn: 163124
This commit is contained in:
Chad Rosier 2012-09-03 20:31:23 +00:00
parent 6d692c7883
commit 294688cf56
6 changed files with 33 additions and 11 deletions

View File

@ -113,7 +113,8 @@ public:
virtual unsigned GetMCInstOperandNum(unsigned Kind, MCInst &Inst,
const SmallVectorImpl<MCParsedAsmOperand*> &Operands,
unsigned OperandNum) = 0;
unsigned OperandNum,
unsigned &NumMCOperands) = 0;
};
} // End llvm namespace

View File

@ -265,8 +265,8 @@ public:
unsigned GetMCInstOperandNum(unsigned Kind, MCInst &Inst,
const SmallVectorImpl<MCParsedAsmOperand*> &Operands,
unsigned OperandNum) {
return GetMCInstOperandNumImpl(Kind, Inst, Operands, OperandNum);
unsigned OperandNum, unsigned &NumMCOperands) {
return GetMCInstOperandNumImpl(Kind, Inst, Operands, OperandNum, NumMCOperands);
}
};
} // end anonymous namespace

View File

@ -58,8 +58,9 @@ class MBlazeAsmParser : public MCTargetAsmParser {
unsigned GetMCInstOperandNum(unsigned Kind, MCInst &Inst,
const SmallVectorImpl<MCParsedAsmOperand*> &Operands,
unsigned OperandNum) {
return GetMCInstOperandNumImpl(Kind, Inst, Operands, OperandNum);
unsigned OperandNum, unsigned &NumMCOperands) {
return GetMCInstOperandNumImpl(Kind, Inst, Operands, OperandNum,
NumMCOperands);
}
public:

View File

@ -40,7 +40,7 @@ class MipsAsmParser : public MCTargetAsmParser {
unsigned GetMCInstOperandNum(unsigned Kind, MCInst &Inst,
const SmallVectorImpl<MCParsedAsmOperand*> &Operands,
unsigned OperandNum);
unsigned OperandNum, unsigned &NumMCOperands);
public:
MipsAsmParser(MCSubtargetInfo &sti, MCAsmParser &parser)
@ -104,11 +104,12 @@ public:
unsigned MipsAsmParser::
GetMCInstOperandNum(unsigned Kind, MCInst &Inst,
const SmallVectorImpl<MCParsedAsmOperand*> &Operands,
unsigned OperandNum) {
unsigned OperandNum, unsigned &NumMCOperands) {
assert (0 && "GetMCInstOperandNum() not supported by the Mips target.");
// The Mips backend doesn't currently include the matcher implementation, so
// the GetMCInstOperandNumImpl() is undefined. This is a temporary
// work around.
NumMCOperands = 0;
return 0;
}

View File

@ -75,8 +75,9 @@ private:
unsigned GetMCInstOperandNum(unsigned Kind, MCInst &Inst,
const SmallVectorImpl<MCParsedAsmOperand*> &Operands,
unsigned OperandNum) {
return GetMCInstOperandNumImpl(Kind, Inst, Operands, OperandNum);
unsigned OperandNum, unsigned &NumMCOperands) {
return GetMCInstOperandNumImpl(Kind, Inst, Operands, OperandNum,
NumMCOperands);
}
/// isSrcOp - Returns true if operand is either (%rsi) or %ds:%(rsi)

View File

@ -1703,8 +1703,10 @@ static void emitConvertToMCInst(CodeGenTarget &Target, StringRef ClassName,
OpOS << "unsigned " << Target.getName() << ClassName << "::\n"
<< "GetMCInstOperandNumImpl(unsigned Kind, MCInst &Inst,\n"
<< " const SmallVectorImpl<MCParsedAsmOperand*> "
<< "&Operands,\n unsigned OperandNum) {\n"
<< "&Operands,\n unsigned OperandNum, unsigned "
<< "&NumMCOperands) {\n"
<< " assert(Kind < CVT_NUM_SIGNATURES && \"Invalid signature!\");\n"
<< " NumMCOperands = 0;\n"
<< " unsigned MCOperandNum = 0;\n"
<< " uint8_t *Converter = ConversionTable[Kind];\n"
<< " for (uint8_t *p = Converter; *p; p+= 2) {\n"
@ -1712,6 +1714,10 @@ static void emitConvertToMCInst(CodeGenTarget &Target, StringRef ClassName,
<< " switch (*p) {\n"
<< " default: llvm_unreachable(\"invalid conversion entry!\");\n"
<< " case CVT_Reg:\n"
<< " if (*(p + 1) == OperandNum) {\n"
<< " NumMCOperands = 1;\n"
<< " break;\n"
<< " }\n"
<< " ++MCOperandNum;\n"
<< " break;\n"
<< " case CVT_Tied:\n"
@ -1811,6 +1817,10 @@ static void emitConvertToMCInst(CodeGenTarget &Target, StringRef ClassName,
// Add a handler for the operand number lookup.
OpOS << " case " << Name << ":\n"
<< " if (*(p + 1) == OperandNum) {\n"
<< " NumMCOperands = " << OpInfo.MINumOperands << ";\n"
<< " break;\n"
<< " }\n"
<< " MCOperandNum += " << OpInfo.MINumOperands << ";\n"
<< " break;\n";
break;
@ -1848,6 +1858,10 @@ static void emitConvertToMCInst(CodeGenTarget &Target, StringRef ClassName,
<< " break;\n";
OpOS << " case " << Name << ":\n"
<< " if (*(p + 1) == OperandNum) {\n"
<< " NumMCOperands = 1;\n"
<< " break;\n"
<< " }\n"
<< " ++MCOperandNum;\n"
<< " break;\n";
break;
@ -1877,6 +1891,10 @@ static void emitConvertToMCInst(CodeGenTarget &Target, StringRef ClassName,
<< " break;\n";
OpOS << " case " << Name << ":\n"
<< " if (*(p + 1) == OperandNum) {\n"
<< " NumMCOperands = 1;\n"
<< " break;\n"
<< " }\n"
<< " ++MCOperandNum;\n"
<< " break;\n";
}
@ -2583,7 +2601,7 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
OS << " unsigned GetMCInstOperandNumImpl(unsigned Kind, MCInst &Inst,\n "
<< " const "
<< "SmallVectorImpl<MCParsedAsmOperand*> &Operands,\n "
<< " unsigned OperandNum);\n";
<< " unsigned OperandNum, unsigned &NumMCOperands);\n";
OS << " bool MnemonicIsValid(StringRef Mnemonic);\n";
OS << " unsigned MatchInstructionImpl(\n"
<< " const SmallVectorImpl<MCParsedAsmOperand*> &Operands,\n"