[llvm-commits] CVS: llvm/lib/Target/TargetLowering.cpp

Chris Lattner lattner at cs.uiuc.edu
Tue Feb 21 16:56:52 PST 2006



Changes in directory llvm/lib/Target:

TargetLowering.cpp updated: 1.34 -> 1.35
---
Log message:

split register class handling from explicit physreg handling.


---
Diffs of the changes:  (+21 -11)

 TargetLowering.cpp |   32 +++++++++++++++++++++-----------
 1 files changed, 21 insertions(+), 11 deletions(-)


Index: llvm/lib/Target/TargetLowering.cpp
diff -u llvm/lib/Target/TargetLowering.cpp:1.34 llvm/lib/Target/TargetLowering.cpp:1.35
--- llvm/lib/Target/TargetLowering.cpp:1.34	Tue Feb 21 17:11:00 2006
+++ llvm/lib/Target/TargetLowering.cpp	Tue Feb 21 18:56:38 2006
@@ -745,24 +745,34 @@
 
 
 std::vector<unsigned> TargetLowering::
+getRegClassForInlineAsmConstraint(const std::string &Constraint,
+                                  MVT::ValueType VT) const {
+  return std::vector<unsigned>();
+}
+
+
+std::pair<unsigned, const TargetRegisterClass*> TargetLowering::
 getRegForInlineAsmConstraint(const std::string &Constraint,
                              MVT::ValueType VT) const {
-  // Not a physreg, must not be a register reference or something.
-  if (Constraint[0] != '{') return std::vector<unsigned>();
+  if (Constraint[0] != '{')
+    return std::pair<unsigned, const TargetRegisterClass*>(0, 0);
   assert(*(Constraint.end()-1) == '}' && "Not a brace enclosed constraint?");
 
   // Remove the braces from around the name.
   std::string RegName(Constraint.begin()+1, Constraint.end()-1);
-  
-  // Scan to see if this constraint is a register name.
+
+  // Figure out which register class contains this reg.
   const MRegisterInfo *RI = TM.getRegisterInfo();
-  for (unsigned i = 1, e = RI->getNumRegs(); i != e; ++i) {
-    if (const char *Name = RI->get(i).Name)
-      if (StringsEqualNoCase(RegName, Name))
-        return std::vector<unsigned>(1, i);
+  for (MRegisterInfo::regclass_iterator RCI = RI->regclass_begin(),
+       E = RI->regclass_end(); RCI != E; ++RCI) {
+    const TargetRegisterClass *RC = *RCI;
+    for (TargetRegisterClass::iterator I = RC->begin(), E = RC->end(); 
+         I != E; ++I) {
+      if (StringsEqualNoCase(RegName, RI->get(*I).Name)) {
+        return std::make_pair(*I, RC);
+      }
+    }
   }
   
-  // Unknown physreg.
-  return std::vector<unsigned>();
+  return std::pair<unsigned, const TargetRegisterClass*>(0, 0);
 }
-






More information about the llvm-commits mailing list