mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-22 22:11:50 +00:00
llvm-mc/AsmParser: Allow .td users to redefine the names of the methods to call
on target specific operands for testing class membership and converting to MCInst operands. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78597 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e74f3c0ce6
commit
5c468e3d70
@ -290,14 +290,25 @@ def unknown;
|
||||
/// match a subset of some other class, in which case the super class field
|
||||
/// should be defined.
|
||||
class AsmOperandClass {
|
||||
/// The name to use for this class, this should be usable as an enum value,
|
||||
/// and will be used to generated the names for the methods to test whether a
|
||||
/// particular target specific operand matches this class, and the method to
|
||||
/// convert an operand of this class into an MCInst operand.
|
||||
/// The name to use for this class, which should be usable as an enum value.
|
||||
string Name = ?;
|
||||
|
||||
/// The super class of this operand.
|
||||
AsmOperandClass SuperClass = ?;
|
||||
|
||||
/// The name of the method on the target specific operand to call to test
|
||||
/// whether the operand is an instance of this class. If not set, this will
|
||||
/// default to "isFoo", where Foo is the AsmOperandClass name. The method
|
||||
/// signature should be:
|
||||
/// bool isFoo() const;
|
||||
string PredicateMethod = ?;
|
||||
|
||||
/// The name of the method on the target specific operand to call to add the
|
||||
/// target specific operand to an MCInst. If not set, this will default to
|
||||
/// "addFooOperands", where Foo is the AsmOperandClass name. The method
|
||||
/// signature should be:
|
||||
/// void addFooOperands(MCInst &Inst, unsigned N) const;
|
||||
string RenderMethod = ?;
|
||||
}
|
||||
|
||||
def ImmAsmOperand : AsmOperandClass {
|
||||
|
@ -154,23 +154,23 @@ struct X86Operand {
|
||||
|
||||
bool isReg() const { return Kind == Register; }
|
||||
|
||||
void addRegOperands(MCInst &Inst, unsigned N) {
|
||||
void addRegOperands(MCInst &Inst, unsigned N) const {
|
||||
assert(N == 1 && "Invalid number of operands!");
|
||||
Inst.addOperand(MCOperand::CreateReg(getReg()));
|
||||
}
|
||||
|
||||
void addImmOperands(MCInst &Inst, unsigned N) {
|
||||
void addImmOperands(MCInst &Inst, unsigned N) const {
|
||||
assert(N == 1 && "Invalid number of operands!");
|
||||
Inst.addOperand(MCOperand::CreateMCValue(getImm()));
|
||||
}
|
||||
|
||||
void addImmSExt8Operands(MCInst &Inst, unsigned N) {
|
||||
void addImmSExt8Operands(MCInst &Inst, unsigned N) const {
|
||||
// FIXME: Support user customization of the render method.
|
||||
assert(N == 1 && "Invalid number of operands!");
|
||||
Inst.addOperand(MCOperand::CreateMCValue(getImm()));
|
||||
}
|
||||
|
||||
void addMemOperands(MCInst &Inst, unsigned N) {
|
||||
void addMemOperands(MCInst &Inst, unsigned N) const {
|
||||
assert((N == 4 || N == 5) && "Invalid number of operands!");
|
||||
|
||||
Inst.addOperand(MCOperand::CreateReg(getMemBaseReg()));
|
||||
|
@ -589,8 +589,27 @@ void AsmMatcherInfo::BuildInfo(CodeGenTarget &Target) {
|
||||
CI->ClassName = (*it)->getValueAsString("Name");
|
||||
CI->Name = "MCK_" + CI->ClassName;
|
||||
CI->ValueName = (*it)->getName();
|
||||
CI->PredicateMethod = "is" + CI->ClassName;
|
||||
CI->RenderMethod = "add" + CI->ClassName + "Operands";
|
||||
|
||||
// Get or construct the predicate method name.
|
||||
Init *PMName = (*it)->getValueInit("PredicateMethod");
|
||||
if (StringInit *SI = dynamic_cast<StringInit*>(PMName)) {
|
||||
CI->PredicateMethod = SI->getValue();
|
||||
} else {
|
||||
assert(dynamic_cast<UnsetInit*>(PMName) &&
|
||||
"Unexpected PredicateMethod field!");
|
||||
CI->PredicateMethod = "is" + CI->ClassName;
|
||||
}
|
||||
|
||||
// Get or construct the render method name.
|
||||
Init *RMName = (*it)->getValueInit("RenderMethod");
|
||||
if (StringInit *SI = dynamic_cast<StringInit*>(RMName)) {
|
||||
CI->RenderMethod = SI->getValue();
|
||||
} else {
|
||||
assert(dynamic_cast<UnsetInit*>(RMName) &&
|
||||
"Unexpected RenderMethod field!");
|
||||
CI->RenderMethod = "add" + CI->ClassName + "Operands";
|
||||
}
|
||||
|
||||
AsmOperandClasses[*it] = CI;
|
||||
Classes.push_back(CI);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user