[llvm-commits] [llvm] r50312 - in /llvm/trunk: include/llvm/Target/TargetLowering.h lib/CodeGen/SelectionDAG/TargetLowering.cpp lib/Target/PowerPC/PPCISelLowering.cpp lib/Target/PowerPC/PPCISelLowering.h lib/Target/X86/X86ISelLowering.cpp lib/Target/X86/X86ISelLowering.h

Chris Lattner sabre at nondot.org
Sat Apr 26 16:02:14 PDT 2008


Author: lattner
Date: Sat Apr 26 18:02:14 2008
New Revision: 50312

URL: http://llvm.org/viewvc/llvm-project?rev=50312&view=rev
Log:
A few inline asm cleanups:
  - Make targetlowering.h fit in 80 cols.
  - Make LowerAsmOperandForConstraint const.
  - Make lowerXConstraint -> LowerXConstraint
  - Make LowerXConstraint return a const char* instead of taking a string byref.

Modified:
    llvm/trunk/include/llvm/Target/TargetLowering.h
    llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp
    llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp
    llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h
    llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
    llvm/trunk/lib/Target/X86/X86ISelLowering.h

Modified: llvm/trunk/include/llvm/Target/TargetLowering.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLowering.h?rev=50312&r1=50311&r2=50312&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Target/TargetLowering.h (original)
+++ llvm/trunk/include/llvm/Target/TargetLowering.h Sat Apr 26 18:02:14 2008
@@ -1100,16 +1100,19 @@
   
       std::string *Current = &Codes[0];
       TargetLowering::ConstraintType CurType = TLI.getConstraintType(*Current);
-      if (Codes.size() == 1) {   // Single-letter constraints ('r') are very common.
+      // Single-letter constraints ('r') are very common.
+      if (Codes.size() == 1) {
         ConstraintCode = *Current;
         ConstraintType = CurType;
       } else {
         unsigned CurGenerality = getConstraintGenerality(CurType);
 
-        // If we have multiple constraints, try to pick the most general one ahead
-        // of time.  This isn't a wonderful solution, but handles common cases.
+        // If we have multiple constraints, try to pick the most general one
+        // ahead of time.  This isn't a wonderful solution, but handles common
+        // cases.
         for (unsigned j = 1, e = Codes.size(); j != e; ++j) {
-          TargetLowering::ConstraintType ThisType = TLI.getConstraintType(Codes[j]);
+          TargetLowering::ConstraintType ThisType = 
+            TLI.getConstraintType(Codes[j]);
           unsigned ThisGenerality = getConstraintGenerality(ThisType);
           if (ThisGenerality > CurGenerality) {
             // This constraint letter is more general than the previous one,
@@ -1124,17 +1127,17 @@
         ConstraintType = CurType;
       }
 
+      // 'X' matches anything.
       if (ConstraintCode == "X" && CallOperandVal) {
+        // Labels and constants are handled elsewhere ('X' is the only thing
+        // that matches labels).
         if (isa<BasicBlock>(CallOperandVal) || isa<ConstantInt>(CallOperandVal))
           return;
-        // This matches anything.  Labels and constants we handle elsewhere 
-        // ('X' is the only thing that matches labels).  Otherwise, try to 
-        // resolve it to something we know about by looking at the actual 
-        // operand type.
-        std::string s = "";
-        TLI.lowerXConstraint(ConstraintVT, s);
-        if (s!="") {
-          ConstraintCode = s;
+        
+        // Otherwise, try to resolve it to something we know about by looking at
+        // the actual operand type.
+        if (const char *Repl = TLI.LowerXConstraint(ConstraintVT)) {
+          ConstraintCode = Repl;
           ConstraintType = TLI.getConstraintType(ConstraintCode);
         }
       }
@@ -1168,15 +1171,15 @@
   
   /// LowerXConstraint - try to replace an X constraint, which matches anything,
   /// with another that has more specific requirements based on the type of the
-  /// corresponding operand.
-  virtual void lowerXConstraint(MVT::ValueType ConstraintVT, 
-                                std::string&) const;
+  /// corresponding operand.  This returns null if there is no replacement to
+  /// make.
+  virtual const char *LowerXConstraint(MVT::ValueType ConstraintVT) const;
   
   /// LowerAsmOperandForConstraint - Lower the specified operand into the Ops
   /// vector.  If it is invalid, don't add anything to Ops.
   virtual void LowerAsmOperandForConstraint(SDOperand Op, char ConstraintLetter,
                                             std::vector<SDOperand> &Ops,
-                                            SelectionDAG &DAG);
+                                            SelectionDAG &DAG) const;
   
   //===--------------------------------------------------------------------===//
   // Scheduler hooks

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp?rev=50312&r1=50311&r2=50312&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp Sat Apr 26 18:02:14 2008
@@ -1534,14 +1534,12 @@
 /// LowerXConstraint - try to replace an X constraint, which matches anything,
 /// with another that has more specific requirements based on the type of the
 /// corresponding operand.
-void TargetLowering::lowerXConstraint(MVT::ValueType ConstraintVT, 
-                                      std::string& s) const {
+const char *TargetLowering::LowerXConstraint(MVT::ValueType ConstraintVT) const{
   if (MVT::isInteger(ConstraintVT))
-    s = "r";
-  else if (MVT::isFloatingPoint(ConstraintVT))
-    s = "f";      // works for many targets
-  else 
-    s = "";
+    return "r";
+  if (MVT::isFloatingPoint(ConstraintVT))
+    return "f";      // works for many targets
+  return 0;
 }
 
 /// LowerAsmOperandForConstraint - Lower the specified operand into the Ops
@@ -1549,7 +1547,7 @@
 void TargetLowering::LowerAsmOperandForConstraint(SDOperand Op,
                                                   char ConstraintLetter,
                                                   std::vector<SDOperand> &Ops,
-                                                  SelectionDAG &DAG) {
+                                                  SelectionDAG &DAG) const {
   switch (ConstraintLetter) {
   default: break;
   case 'X':     // Allows any operand; labels (basic block) use this.

Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=50312&r1=50311&r2=50312&view=diff

==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Sat Apr 26 18:02:14 2008
@@ -3984,7 +3984,7 @@
 /// vector.  If it is invalid, don't add anything to Ops.
 void PPCTargetLowering::LowerAsmOperandForConstraint(SDOperand Op, char Letter,
                                                      std::vector<SDOperand>&Ops,
-                                                     SelectionDAG &DAG) {
+                                                     SelectionDAG &DAG) const {
   SDOperand Result(0,0);
   switch (Letter) {
   default: break;

Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h?rev=50312&r1=50311&r2=50312&view=diff

==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h Sat Apr 26 18:02:14 2008
@@ -293,7 +293,7 @@
     virtual void LowerAsmOperandForConstraint(SDOperand Op,
                                               char ConstraintLetter,
                                               std::vector<SDOperand> &Ops,
-                                              SelectionDAG &DAG);
+                                              SelectionDAG &DAG) const;
     
     /// isLegalAddressingMode - Return true if the addressing mode represented
     /// by AM is legal for this target, for a load/store of the specified type.

Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=50312&r1=50311&r2=50312&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Sat Apr 26 18:02:14 2008
@@ -6280,17 +6280,18 @@
 /// LowerXConstraint - try to replace an X constraint, which matches anything,
 /// with another that has more specific requirements based on the type of the
 /// corresponding operand.
-void X86TargetLowering::lowerXConstraint(MVT::ValueType ConstraintVT, 
-                                         std::string& s) const {
+const char *X86TargetLowering::
+LowerXConstraint(MVT::ValueType ConstraintVT) const {
+  // FP X constraints get lowered to SSE1/2 registers if available, otherwise
+  // 'f' like normal targets.
   if (MVT::isFloatingPoint(ConstraintVT)) {
     if (Subtarget->hasSSE2())
-      s = "Y";
-    else if (Subtarget->hasSSE1())
-      s = "x";
-    else
-      s = "f";
-  } else
-    return TargetLowering::lowerXConstraint(ConstraintVT, s);
+      return "Y";
+    if (Subtarget->hasSSE1())
+      return "x";
+  }
+  
+  return TargetLowering::LowerXConstraint(ConstraintVT);
 }
 
 /// LowerAsmOperandForConstraint - Lower the specified operand into the Ops
@@ -6298,7 +6299,7 @@
 void X86TargetLowering::LowerAsmOperandForConstraint(SDOperand Op,
                                                      char Constraint,
                                                      std::vector<SDOperand>&Ops,
-                                                     SelectionDAG &DAG) {
+                                                     SelectionDAG &DAG) const {
   SDOperand Result(0, 0);
   
   switch (Constraint) {

Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.h?rev=50312&r1=50311&r2=50312&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.h (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.h Sat Apr 26 18:02:14 2008
@@ -371,15 +371,14 @@
       getRegClassForInlineAsmConstraint(const std::string &Constraint,
                                         MVT::ValueType VT) const;
 
-    virtual void lowerXConstraint(MVT::ValueType ConstraintVT, 
-                                  std::string&) const;
+    virtual const char *LowerXConstraint(MVT::ValueType ConstraintVT) const;
 
     /// LowerAsmOperandForConstraint - Lower the specified operand into the Ops
     /// vector.  If it is invalid, don't add anything to Ops.
     virtual void LowerAsmOperandForConstraint(SDOperand Op,
                                               char ConstraintLetter,
                                               std::vector<SDOperand> &Ops,
-                                              SelectionDAG &DAG);
+                                              SelectionDAG &DAG) const;
     
     /// getRegForInlineAsmConstraint - Given a physical register constraint
     /// (e.g. {edx}), return the register number and the register class for the





More information about the llvm-commits mailing list