llvm.org GIT mirror llvm / b461e83
Target: Allow target specific operand types This adds two new fields to the RegisterOperand TableGen class: string OperandNamespace = "MCOI"; string OperandType = "OPERAND_REGISTER"; These fields can be used to specify a target specific operand type, which will be stored in the OperandType member of the MCOperandInfo object. This can be useful for targets that need to store some extra information about operands that cannot be expressed using the target independent types. For example, in the R600 backend, there are operands which can take either registers or immediates and it is convenient to be able to specify this in the TableGen definitions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225661 91177308-0d34-0410-b5e6-96231b3b80d8 Tom Stellard 4 years ago
4 changed file(s) with 15 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
4343
4444 /// Operand Type - Operands are tagged with one of the values of this enum.
4545 enum OperandType {
46 OPERAND_UNKNOWN,
47 OPERAND_IMMEDIATE,
48 OPERAND_REGISTER,
49 OPERAND_MEMORY,
50 OPERAND_PCREL
46 OPERAND_UNKNOWN = 0,
47 OPERAND_IMMEDIATE = 1,
48 OPERAND_REGISTER = 2,
49 OPERAND_MEMORY = 3,
50 OPERAND_PCREL = 4,
51 OPERAND_FIRST_TARGET = 5
5152 };
5253 }
5354
623623 // can match a subset of some other class, in which case the AsmOperandClass
624624 // should declare the other operand as one of its super classes.
625625 AsmOperandClass ParserMatchClass;
626
627 string OperandNamespace = "MCOI";
628 string OperandType = "OPERAND_REGISTER";
626629 }
627630
628631 let OperandType = "OPERAND_IMMEDIATE" in {
6767 std::string PrintMethod = "printOperand";
6868 std::string EncoderMethod;
6969 std::string OperandType = "OPERAND_UNKNOWN";
70 std::string OperandNamespace = "MCOI";
7071 unsigned NumOps = 1;
7172 DagInit *MIOpInfo = nullptr;
7273 if (Rec->isSubClassOf("RegisterOperand")) {
7374 PrintMethod = Rec->getValueAsString("PrintMethod");
75 OperandType = Rec->getValueAsString("OperandType");
76 OperandNamespace = Rec->getValueAsString("OperandNamespace");
7477 } else if (Rec->isSubClassOf("Operand")) {
7578 PrintMethod = Rec->getValueAsString("PrintMethod");
7679 OperandType = Rec->getValueAsString("OperandType");
112115 Twine(i) + " has the same name as a previous operand!");
113116
114117 OperandList.push_back(OperandInfo(Rec, ArgName, PrintMethod, EncoderMethod,
115 OperandType, MIOperandNo, NumOps,
116 MIOpInfo));
118 OperandNamespace + "::" + OperandType,
119 MIOperandNo, NumOps, MIOpInfo));
117120 MIOperandNo += NumOps;
118121 }
119122
142142 Res += "|(1<
143143
144144 // Fill in operand type.
145 Res += ", MCOI::";
145 Res += ", ";
146146 assert(!Op.OperandType.empty() && "Invalid operand type.");
147147 Res += Op.OperandType;
148148