[llvm-commits] [llvm] r37940 - in /llvm/trunk: include/llvm/CodeGen/SelectionDAGNodes.h include/llvm/ParameterAttributes.h lib/AsmParser/Lexer.l lib/AsmParser/llvmAsmParser.y lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp lib/Target/TargetCallingConv.td lib/Target/X86/X86CallingConv.td lib/VMCore/Function.cpp lib/VMCore/Verifier.cpp utils/TableGen/CallingConvEmitter.cpp

Rafael Espindola rafael.espindola at gmail.com
Fri Jul 6 03:57:03 PDT 2007


Author: rafael
Date: Fri Jul  6 05:57:03 2007
New Revision: 37940

URL: http://llvm.org/viewvc/llvm-project?rev=37940&view=rev
Log:
Add the byval attribute

Modified:
    llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h
    llvm/trunk/include/llvm/ParameterAttributes.h
    llvm/trunk/lib/AsmParser/Lexer.l
    llvm/trunk/lib/AsmParser/llvmAsmParser.y
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
    llvm/trunk/lib/Target/TargetCallingConv.td
    llvm/trunk/lib/Target/X86/X86CallingConv.td
    llvm/trunk/lib/VMCore/Function.cpp
    llvm/trunk/lib/VMCore/Verifier.cpp
    llvm/trunk/utils/TableGen/CallingConvEmitter.cpp

Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h?rev=37940&r1=37939&r2=37940&view=diff

==============================================================================
--- llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h (original)
+++ llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Fri Jul  6 05:57:03 2007
@@ -63,6 +63,8 @@
     InRegOffs         = 2,
     StructReturn      = 1<<3,  ///< Hidden struct-return pointer
     StructReturnOffs  = 3,
+    ByVal             = 1<<4,  ///< Struct passed by value
+    ByValOffs         = 4,
     OrigAlignment     = 0x1F<<27,
     OrigAlignmentOffs = 27
   };

Modified: llvm/trunk/include/llvm/ParameterAttributes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ParameterAttributes.h?rev=37940&r1=37939&r2=37940&view=diff

==============================================================================
--- llvm/trunk/include/llvm/ParameterAttributes.h (original)
+++ llvm/trunk/include/llvm/ParameterAttributes.h Fri Jul  6 05:57:03 2007
@@ -36,7 +36,8 @@
   InReg      = 1 << 3, ///< force argument to be passed in register
   StructRet  = 1 << 4, ///< hidden pointer to structure to return
   NoUnwind   = 1 << 5, ///< Function doesn't unwind stack
-  NoAlias    = 1 << 6  ///< Considered to not alias after call.
+  NoAlias    = 1 << 6, ///< Considered to not alias after call.
+  ByVal      = 1 << 7  ///< Pass structure by value
 };
 
 }

Modified: llvm/trunk/lib/AsmParser/Lexer.l
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/Lexer.l?rev=37940&r1=37939&r2=37940&view=diff

==============================================================================
--- llvm/trunk/lib/AsmParser/Lexer.l (original)
+++ llvm/trunk/lib/AsmParser/Lexer.l Fri Jul  6 05:57:03 2007
@@ -230,6 +230,7 @@
 nounwind        { return NOUNWIND; }
 noreturn        { return NORETURN; }
 noalias         { return NOALIAS; }
+byval           { return BYVAL; }
 
 void            { RET_TY(Type::VoidTy,  VOID);  }
 float           { RET_TY(Type::FloatTy, FLOAT); }

Modified: llvm/trunk/lib/AsmParser/llvmAsmParser.y
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/llvmAsmParser.y?rev=37940&r1=37939&r2=37940&view=diff

==============================================================================
--- llvm/trunk/lib/AsmParser/llvmAsmParser.y (original)
+++ llvm/trunk/lib/AsmParser/llvmAsmParser.y Fri Jul  6 05:57:03 2007
@@ -1101,7 +1101,7 @@
 %token <OtherOpVal> EXTRACTELEMENT INSERTELEMENT SHUFFLEVECTOR
 
 // Function Attributes
-%token NORETURN INREG SRET NOUNWIND NOALIAS
+%token NORETURN INREG SRET NOUNWIND NOALIAS BYVAL
 
 // Visibility Styles
 %token DEFAULT HIDDEN PROTECTED
@@ -1229,6 +1229,7 @@
               | INREG   { $$ = ParamAttr::InReg;     }
               | SRET    { $$ = ParamAttr::StructRet; }
               | NOALIAS { $$ = ParamAttr::NoAlias;   }
+              | BYVAL   { $$ = ParamAttr::ByVal;   }
               ;
 
 OptParamAttrs : /* empty */  { $$ = ParamAttr::None; }

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

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Fri Jul  6 05:57:03 2007
@@ -3789,6 +3789,8 @@
       Flags |= ISD::ParamFlags::InReg;
     if (Attrs && Attrs->paramHasAttr(j, ParamAttr::StructRet))
       Flags |= ISD::ParamFlags::StructReturn;
+    if (Attrs && Attrs->paramHasAttr(j, ParamAttr::ByVal))
+      Flags |= ISD::ParamFlags::ByVal;
     Flags |= (OriginalAlignment << ISD::ParamFlags::OrigAlignmentOffs);
     
     switch (getTypeAction(VT)) {

Modified: llvm/trunk/lib/Target/TargetCallingConv.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetCallingConv.td?rev=37940&r1=37939&r2=37940&view=diff

==============================================================================
--- llvm/trunk/lib/Target/TargetCallingConv.td (original)
+++ llvm/trunk/lib/Target/TargetCallingConv.td Fri Jul  6 05:57:03 2007
@@ -32,6 +32,11 @@
   string Predicate = predicate;
 }
 
+/// CCIfStruct - If the current argument is a struct, apply
+/// Action A.
+class CCIfStruct<CCAction A> : CCIf<"ArgFlags & ISD::ParamFlags::ByVal", A> {
+}
+
 /// CCIfCC - Match of the current calling convention is 'CC'.
 class CCIfCC<string CC, CCAction A>
   : CCIf<!strconcat("State.getCallingConv() == ", CC), A> {}
@@ -57,6 +62,12 @@
   int Align = align;
 }
 
+/// CCStructAssign - This action always matches: it will use the C ABI and
+/// the register availability to decided whether to assign to a set of
+/// registers or to a stack slot.
+class CCStructAssign<list<Register> regList> : CCAction {
+  list<Register> RegList = regList;
+}
 
 /// CCPromoteToType - If applied, this promotes the specified current value to
 /// the specified type.
@@ -75,4 +86,3 @@
 class CallingConv<list<CCAction> actions> {
   list<CCAction> Actions = actions;
 }
-

Modified: llvm/trunk/lib/Target/X86/X86CallingConv.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86CallingConv.td?rev=37940&r1=37939&r2=37940&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/X86CallingConv.td (original)
+++ llvm/trunk/lib/Target/X86/X86CallingConv.td Fri Jul  6 05:57:03 2007
@@ -94,6 +94,8 @@
   // Promote i8/i16 arguments to i32.
   CCIfType<[i8, i16], CCPromoteToType<i32>>,
   
+  CCIfStruct<CCStructAssign<[RDI, RSI, RDX, RCX, R8, R9 ]>>,
+
   // The first 6 integer arguments are passed in integer registers.
   CCIfType<[i32], CCAssignToReg<[EDI, ESI, EDX, ECX, R8D, R9D]>>,
   CCIfType<[i64], CCAssignToReg<[RDI, RSI, RDX, RCX, R8 , R9 ]>>,
@@ -168,5 +170,3 @@
   // Otherwise, same as everything else.
   CCDelegateTo<CC_X86_32_Common>
 ]>;
-
-

Modified: llvm/trunk/lib/VMCore/Function.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Function.cpp?rev=37940&r1=37939&r2=37940&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Function.cpp (original)
+++ llvm/trunk/lib/VMCore/Function.cpp Fri Jul  6 05:57:03 2007
@@ -103,6 +103,8 @@
     Result += "noalias ";
   if (Attrs & ParamAttr::StructRet)
     Result += "sret ";  
+  if (Attrs & ParamAttr::ByVal)
+    Result += "byval ";
   return Result;
 }
 

Modified: llvm/trunk/lib/VMCore/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=37940&r1=37939&r2=37940&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Verifier.cpp (original)
+++ llvm/trunk/lib/VMCore/Verifier.cpp Fri Jul  6 05:57:03 2007
@@ -370,6 +370,9 @@
       if (Attrs->paramHasAttr(Idx, ParamAttr::NoAlias))
         Assert1(isa<PointerType>(FT->getParamType(Idx-1)),
                 "Attribute NoAlias should only apply to Pointer type!", &F);
+      if (Attrs->paramHasAttr(Idx, ParamAttr::ByVal))
+        Assert1(isa<PointerType>(FT->getParamType(Idx-1)),
+                "Attribute ByVal should only apply to Pointer type!", &F);
     }
   }
 

Modified: llvm/trunk/utils/TableGen/CallingConvEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CallingConvEmitter.cpp?rev=37940&r1=37939&r2=37940&view=diff

==============================================================================
--- llvm/trunk/utils/TableGen/CallingConvEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/CallingConvEmitter.cpp Fri Jul  6 05:57:03 2007
@@ -129,10 +129,11 @@
         << IndentStr << IndentStr << "LocInfo = CCValAssign::ZExt;\n"
         << IndentStr << "else\n"
         << IndentStr << IndentStr << "LocInfo = CCValAssign::AExt;\n";
+    } else if (Action->isSubClassOf("CCStructAssign")) {
+      O << "assert(0 && \"Not Implemented\");\n";
     } else {
       Action->dump();
       throw "Unknown CCAction!";
     }
   }
 }
-





More information about the llvm-commits mailing list