Implement PR673: for explicit register references, use type information

if available


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24597 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2005-12-05 02:36:37 +00:00
parent 5c4736a3da
commit 22faeabb3a

View File

@ -467,9 +467,12 @@ static unsigned char getIntrinsicType(Record *R, bool NotRegisters,
// Pattern fragment types will be resolved when they are inlined. // Pattern fragment types will be resolved when they are inlined.
return MVT::isUnknown; return MVT::isUnknown;
} else if (R->isSubClassOf("Register")) { } else if (R->isSubClassOf("Register")) {
//const CodeGenTarget &T = TP.getDAGISelEmitter().getTargetInfo(); // If the register appears in exactly one regclass, and the regclass has one
// TODO: if a register appears in exactly one regclass, we could use that // value type, use it as the known type.
// type info. const CodeGenTarget &T = TP.getDAGISelEmitter().getTargetInfo();
if (const CodeGenRegisterClass *RC = T.getRegisterClassForRegister(R))
if (RC->getNumValueTypes() == 1)
return RC->getValueTypeNum(0);
return MVT::isUnknown; return MVT::isUnknown;
} else if (R->isSubClassOf("ValueType") || R->isSubClassOf("CondCode")) { } else if (R->isSubClassOf("ValueType") || R->isSubClassOf("CondCode")) {
// Using a VTSDNode or CondCodeSDNode. // Using a VTSDNode or CondCodeSDNode.
@ -1719,18 +1722,8 @@ void DAGISelEmitter::EmitMatchForPattern(TreePatternNode *N,
/// getRegisterValueType - Look up and return the first ValueType of specified /// getRegisterValueType - Look up and return the first ValueType of specified
/// RegisterClass record /// RegisterClass record
static MVT::ValueType getRegisterValueType(Record *R, const CodeGenTarget &T) { static MVT::ValueType getRegisterValueType(Record *R, const CodeGenTarget &T) {
const std::vector<CodeGenRegisterClass> &RegisterClasses = if (const CodeGenRegisterClass *RC = T.getRegisterClassForRegister(R))
T.getRegisterClasses(); return RC->getValueTypeNum(0);
for (unsigned i = 0, e = RegisterClasses.size(); i != e; ++i) {
const CodeGenRegisterClass &RC = RegisterClasses[i];
for (unsigned ei = 0, ee = RC.Elements.size(); ei != ee; ++ei) {
if (R == RC.Elements[ei]) {
return RC.getValueTypeNum(0);
}
}
}
return MVT::Other; return MVT::Other;
} }