// In addition, the subset relation amongst classes induces a partial order
// on such tuples, which we use to resolve ambiguities.
//
-// FIXME: What do we do if a crazy case shows up where this is the wrong
-// resolution?
-//
// 2. The input can now be treated as a tuple of classes (static tokens are
// simple singleton sets). Each such tuple should generally map to a single
// instruction (we currently ignore cases where this isn't true, whee!!!),
/// MatchableInfo - Helper class for storing the necessary information for an
/// instruction or alias which is capable of being matched.
struct MatchableInfo {
- struct Operand {
+ struct AsmOperand {
/// Token - This is the token that the operand came from.
StringRef Token;
/// list. If an operand is tied ($a=$b), this refers to source operand: $b.
const CGIOperandList::OperandInfo *OperandInfo;
- explicit Operand(StringRef T) : Token(T), Class(0), OperandInfo(0) {}
+ explicit AsmOperand(StringRef T) : Token(T), Class(0), OperandInfo(0) {}
};
/// InstrName - The target name for this instruction.
/// annotated with a class and where in the OperandList they were defined.
/// This directly corresponds to the tokenized AsmString after the mnemonic is
/// removed.
- SmallVector<Operand, 4> AsmOperands;
+ SmallVector<AsmOperand, 4> AsmOperands;
/// Predicates - The required subtarget features to match this instruction.
SmallVector<SubtargetFeatureInfo*, 4> RequiredFeatures;
errs() << InstrName << " -- " << "flattened:\"" << AsmString << "\"\n";
for (unsigned i = 0, e = AsmOperands.size(); i != e; ++i) {
- Operand &Op = AsmOperands[i];
+ AsmOperand &Op = AsmOperands[i];
errs() << " op[" << i << "] = " << Op.Class->ClassName << " - ";
if (Op.Class->Kind == ClassInfo::Token) {
errs() << '\"' << Op.Token << "\"\n";
case '\t':
case ',':
if (InTok) {
- AsmOperands.push_back(Operand(String.slice(Prev, i)));
+ AsmOperands.push_back(AsmOperand(String.slice(Prev, i)));
InTok = false;
}
if (!isspace(String[i]) && String[i] != ',')
- AsmOperands.push_back(Operand(String.substr(i, 1)));
+ AsmOperands.push_back(AsmOperand(String.substr(i, 1)));
Prev = i + 1;
break;
case '\\':
if (InTok) {
- AsmOperands.push_back(Operand(String.slice(Prev, i)));
+ AsmOperands.push_back(AsmOperand(String.slice(Prev, i)));
InTok = false;
}
++i;
assert(i != String.size() && "Invalid quoted character");
- AsmOperands.push_back(Operand(String.substr(i, 1)));
+ AsmOperands.push_back(AsmOperand(String.substr(i, 1)));
Prev = i + 1;
break;
// If this isn't "${", treat like a normal token.
if (i + 1 == String.size() || String[i + 1] != '{') {
if (InTok) {
- AsmOperands.push_back(Operand(String.slice(Prev, i)));
+ AsmOperands.push_back(AsmOperand(String.slice(Prev, i)));
InTok = false;
}
Prev = i;
}
if (InTok) {
- AsmOperands.push_back(Operand(String.slice(Prev, i)));
+ AsmOperands.push_back(AsmOperand(String.slice(Prev, i)));
InTok = false;
}
StringRef::iterator End = std::find(String.begin() + i, String.end(),'}');
assert(End != String.end() && "Missing brace in operand reference!");
size_t EndPos = End - String.begin();
- AsmOperands.push_back(Operand(String.slice(i, EndPos+1)));
+ AsmOperands.push_back(AsmOperand(String.slice(i, EndPos+1)));
Prev = EndPos + 1;
i = EndPos;
break;
case '.':
if (InTok)
- AsmOperands.push_back(Operand(String.slice(Prev, i)));
+ AsmOperands.push_back(AsmOperand(String.slice(Prev, i)));
Prev = i;
InTok = true;
break;
}
}
if (InTok && Prev != String.size())
- AsmOperands.push_back(Operand(String.substr(Prev)));
+ AsmOperands.push_back(AsmOperand(String.substr(Prev)));
// The first token of the instruction is the mnemonic, which must be a
// simple string, not a $foo variable or a singleton register.
// Parse the tokens after the mnemonic.
for (unsigned i = 0, e = II->AsmOperands.size(); i != e; ++i) {
- MatchableInfo::Operand &Op = II->AsmOperands[i];
+ MatchableInfo::AsmOperand &Op = II->AsmOperands[i];
StringRef Token = Op.Token;
// Check for singleton registers.
// Order the (class) operands by the order to convert them into an MCInst.
for (unsigned i = 0, e = II.AsmOperands.size(); i != e; ++i) {
- MatchableInfo::Operand &Op = II.AsmOperands[i];
+ MatchableInfo::AsmOperand &Op = II.AsmOperands[i];
if (!Op.OperandInfo) continue;
unsigned LogicalOpNum = Op.OperandInfo - &II.OperandList[0];
int SrcOperand = OperandMap[i];
if (SrcOperand != -1) {
// Otherwise, this comes from something we parsed.
- MatchableInfo::Operand &Op = II.AsmOperands[SrcOperand];
+ MatchableInfo::AsmOperand &Op = II.AsmOperands[SrcOperand];
// Registers are always converted the same, don't duplicate the
// conversion function based on them.
- //
- // FIXME: We could generalize this based on the render method, if it
- // mattered.
Signature += "__";
if (Op.Class->isRegisterClass())
Signature += "Reg";
<< ", \"" << II.Mnemonic << "\""
<< ", " << II.ConversionFnKind << ", { ";
for (unsigned i = 0, e = II.AsmOperands.size(); i != e; ++i) {
- MatchableInfo::Operand &Op = II.AsmOperands[i];
+ MatchableInfo::AsmOperand &Op = II.AsmOperands[i];
if (i) OS << ", ";
OS << Op.Class->Name;