[llvm-commits] [llvm] r41953 - in /llvm/trunk: lib/Target/X86/X86ISelLowering.cpp lib/Target/X86/X86ISelLowering.h test/CodeGen/X86/byval.ll

Rafael Espindola rafael.espindola at gmail.com
Fri Sep 14 08:48:25 PDT 2007


Author: rafael
Date: Fri Sep 14 10:48:13 2007
New Revision: 41953

URL: http://llvm.org/viewvc/llvm-project?rev=41953&view=rev
Log:
Add support for functions with byval arguments on x86

Modified:
    llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
    llvm/trunk/lib/Target/X86/X86ISelLowering.h
    llvm/trunk/test/CodeGen/X86/byval.ll

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

==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Fri Sep 14 10:48:13 2007
@@ -694,6 +694,23 @@
   return VReg;
 }
 
+SDOperand X86TargetLowering::LowerMemArgument(SDOperand Op, SelectionDAG &DAG,
+                                              const CCValAssign &VA,
+                                              MachineFrameInfo *MFI,
+                                              SDOperand Root, unsigned i) {
+  // Create the nodes corresponding to a load from this parameter slot.
+  int FI = MFI->CreateFixedObject(MVT::getSizeInBits(VA.getValVT())/8,
+                                  VA.getLocMemOffset());
+  SDOperand FIN = DAG.getFrameIndex(FI, getPointerTy());
+
+  unsigned Flags =  cast<ConstantSDNode>(Op.getOperand(3 + i))->getValue();
+
+  if (Flags & ISD::ParamFlags::ByVal)
+    return FIN;
+  else
+    return DAG.getLoad(VA.getValVT(), Root, FIN, NULL, 0);
+}
+
 SDOperand X86TargetLowering::LowerCCCArguments(SDOperand Op, SelectionDAG &DAG,
                                                bool isStdCall) {
   unsigned NumArgs = Op.Val->getNumValues() - 1;
@@ -747,12 +764,7 @@
       ArgValues.push_back(ArgValue);
     } else {
       assert(VA.isMemLoc());
-      
-      // Create the nodes corresponding to a load from this parameter slot.
-      int FI = MFI->CreateFixedObject(MVT::getSizeInBits(VA.getValVT())/8,
-                                      VA.getLocMemOffset());
-      SDOperand FIN = DAG.getFrameIndex(FI, getPointerTy());
-      ArgValues.push_back(DAG.getLoad(VA.getValVT(), Root, FIN, NULL, 0));
+      ArgValues.push_back(LowerMemArgument(Op, DAG, VA, MFI, Root, i));
     }
   }
   
@@ -1279,17 +1291,7 @@
       ArgValues.push_back(ArgValue);
     } else {
       assert(VA.isMemLoc());
-    
-      // Create the nodes corresponding to a load from this parameter slot.
-      int FI = MFI->CreateFixedObject(MVT::getSizeInBits(VA.getValVT())/8,
-                                      VA.getLocMemOffset());
-      SDOperand FIN = DAG.getFrameIndex(FI, getPointerTy());
-
-      unsigned Flags =  cast<ConstantSDNode>(Op.getOperand(3 + i))->getValue();
-      if (Flags & ISD::ParamFlags::ByVal)
-        ArgValues.push_back(FIN);
-      else
-        ArgValues.push_back(DAG.getLoad(VA.getValVT(), Root, FIN, NULL, 0));
+      ArgValues.push_back(LowerMemArgument(Op, DAG, VA, MFI, Root, i));
     }
   }
   

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

==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.h (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.h Fri Sep 14 10:48:13 2007
@@ -380,6 +380,10 @@
                             unsigned CallingConv, SelectionDAG &DAG);
         
 
+    SDOperand LowerMemArgument(SDOperand Op, SelectionDAG &DAG,
+                               const CCValAssign &VA,  MachineFrameInfo *MFI,
+                               SDOperand Root, unsigned i);
+
     SDOperand LowerMemOpCallTo(SDOperand Op, SelectionDAG &DAG,
                                const SDOperand &StackPtr,
                                const CCValAssign &VA, SDOperand Chain,

Modified: llvm/trunk/test/CodeGen/X86/byval.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/byval.ll?rev=41953&r1=41952&r2=41953&view=diff

==============================================================================
--- llvm/trunk/test/CodeGen/X86/byval.ll (original)
+++ llvm/trunk/test/CodeGen/X86/byval.ll Fri Sep 14 10:48:13 2007
@@ -1,4 +1,7 @@
-; RUN: llvm-as < %s | llc -march=x86-64 | grep movq.*8.*rsp.*rax
+; RUN: llvm-as < %s | llc -march=x86-64 | grep {movq	8(%rsp), %rax}
+; RUN: llvm-as < %s | llc -march=x86 > %t
+; RUN: grep {movl	8(%esp), %edx} %t
+; RUN: grep {movl	4(%esp), %eax} %t
 
 %struct.s = type { i64, i64, i64 }
 





More information about the llvm-commits mailing list