Add versions of OutputArgReg, AnalyzeReturn, and AnalyzeCallOperands
authorDan Gohman <gohman@apple.com>
Tue, 6 Jul 2010 15:39:54 +0000 (15:39 +0000)
committerDan Gohman <gohman@apple.com>
Tue, 6 Jul 2010 15:39:54 +0000 (15:39 +0000)
which do not depend on SelectionDAG.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107666 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/CallingConvLower.h
include/llvm/CodeGen/SelectionDAGNodes.h
lib/CodeGen/SelectionDAG/CallingConvLower.cpp

index 0e60c963c0e368ddeeb7e0c7fe4b69b74a8ebb68..71b246c0c92c71e3de9f2d148f39a5b6bc7ff9fb 100644 (file)
@@ -185,6 +185,8 @@ public:
   /// incorporating info about the result values into this state.
   void AnalyzeReturn(const SmallVectorImpl<ISD::OutputArg> &Outs,
                      CCAssignFn Fn);
+  void AnalyzeReturn(const SmallVectorImpl<ISD::OutputArgReg> &Outs,
+                     CCAssignFn Fn);
 
   /// CheckReturn - Analyze the return values of a function, returning
   /// true if the return can be performed without sret-demotion, and
@@ -197,6 +199,8 @@ public:
   /// incorporating info about the passed values into this state.
   void AnalyzeCallOperands(const SmallVectorImpl<ISD::OutputArg> &Outs,
                            CCAssignFn Fn);
+  void AnalyzeCallOperands(const SmallVectorImpl<ISD::OutputArgReg> &Outs,
+                           CCAssignFn Fn);
 
   /// AnalyzeCallOperands - Same as above except it takes vectors of types
   /// and argument flags.
index 7b8c1dcfb830eebd519140caffed6e685bcc055e..bceb17bcbd4aa8aac903f0566e50e59e27478227 100644 (file)
@@ -1583,6 +1583,23 @@ namespace ISD {
              "OutputArg value type must be Simple!");
     }
   };
+
+  /// OutputArgReg - This struct carries flags and a register value for a
+  /// single outgoing (actual) argument or outgoing (from the perspective
+  /// of the caller) return value virtual register.
+  ///
+  struct OutputArgReg {
+    ArgFlagsTy Flags;
+    EVT VT;
+    unsigned Reg;
+
+    /// IsFixed - Is this a "fixed" value, ie not passed through a vararg "...".
+    bool IsFixed;
+
+    OutputArgReg() : IsFixed(false) {}
+    OutputArgReg(ISD::ArgFlagsTy flags, EVT vt, unsigned reg, bool isfixed)
+      : Flags(flags), VT(vt), Reg(reg), IsFixed(isfixed) {}
+  };
 }
 
 /// VTSDNode - This class is used to represent EVT's, which are used
index 4e6c1fcc96049fca4d66d24ab8a6e976c59a16b0..ba097e089aa19cefe2820baab7871a0ee3df5590 100644 (file)
@@ -111,6 +111,22 @@ void CCState::AnalyzeReturn(const SmallVectorImpl<ISD::OutputArg> &Outs,
   }
 }
 
+void CCState::AnalyzeReturn(const SmallVectorImpl<ISD::OutputArgReg> &Outs,
+                            CCAssignFn Fn) {
+  // Determine which register each value should be copied into.
+  for (unsigned i = 0, e = Outs.size(); i != e; ++i) {
+    EVT VT = Outs[i].VT;
+    ISD::ArgFlagsTy ArgFlags = Outs[i].Flags;
+    if (Fn(i, VT, VT, CCValAssign::Full, ArgFlags, *this)) {
+#ifndef NDEBUG
+      dbgs() << "Return operand #" << i << " has unhandled type "
+             << VT.getEVTString();
+#endif
+      llvm_unreachable(0);
+    }
+  }
+}
+
 
 /// AnalyzeCallOperands - Analyze the outgoing arguments to a call,
 /// incorporating info about the passed values into this state.
@@ -130,6 +146,25 @@ void CCState::AnalyzeCallOperands(const SmallVectorImpl<ISD::OutputArg> &Outs,
   }
 }
 
+/// AnalyzeCallOperands - Analyze the outgoing arguments to a call,
+/// incorporating info about the passed values into this state.
+void
+CCState::AnalyzeCallOperands(const SmallVectorImpl<ISD::OutputArgReg> &Outs,
+                             CCAssignFn Fn) {
+  unsigned NumOps = Outs.size();
+  for (unsigned i = 0; i != NumOps; ++i) {
+    EVT ArgVT = Outs[i].VT;
+    ISD::ArgFlagsTy ArgFlags = Outs[i].Flags;
+    if (Fn(i, ArgVT, ArgVT, CCValAssign::Full, ArgFlags, *this)) {
+#ifndef NDEBUG
+      dbgs() << "Call operand #" << i << " has unhandled type "
+             << ArgVT.getEVTString();
+#endif
+      llvm_unreachable(0);
+    }
+  }
+}
+
 /// AnalyzeCallOperands - Same as above except it takes vectors of types
 /// and argument flags.
 void CCState::AnalyzeCallOperands(SmallVectorImpl<EVT> &ArgVTs,