OSDN Git Service

Make Function arguments type-safe.
authorNicolas Capens <capn@google.com>
Thu, 14 Jan 2016 14:32:35 +0000 (09:32 -0500)
committerNicolas Capens <capn@google.com>
Thu, 14 Jan 2016 15:53:50 +0000 (15:53 +0000)
Change-Id: I3d4262ea4be0c7b1128b2ca410e985cc6f58c9c9
Reviewed-on: https://swiftshader-review.googlesource.com/1970
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
src/Main/FrameBuffer.cpp
src/Reactor/Nucleus.cpp
src/Reactor/Nucleus.hpp
src/Renderer/Blitter.cpp
src/Renderer/QuadRasterizer.cpp
src/Shader/SetupRoutine.cpp
src/Shader/VertexRoutine.cpp

index cd387c8..aa3e55f 100644 (file)
@@ -236,8 +236,8 @@ namespace sw
 
                Function<Void(Pointer<Byte>, Pointer<Byte>)> function;
                {
-                       Pointer<Byte> dst(function.arg(0));
-                       Pointer<Byte> src(function.arg(1));
+                       Pointer<Byte> dst(function.Arg<0>());
+                       Pointer<Byte> src(function.Arg<1>());
 
                        For(Int y = 0, y < height, y++)
                        {
index 094481b..2325c7f 100644 (file)
@@ -294,7 +294,7 @@ namespace sw
                return function;
        }
 
-       llvm::Argument *Nucleus::getArgument(llvm::Function *function, unsigned int index)
+       llvm::Value *Nucleus::getArgument(llvm::Function *function, unsigned int index)
        {
                llvm::Function::arg_iterator args = function->arg_begin();
 
@@ -847,9 +847,9 @@ namespace sw
                return Type::getX86_MMXTy(*Nucleus::getContext());
        }
 
-       Bool::Bool(Argument *argument)
+       Bool::Bool(Argument<Bool> argument)
        {
-               storeValue(argument);
+               storeValue(argument.value);
        }
 
        Bool::Bool()
@@ -921,9 +921,9 @@ namespace sw
                return Type::getInt1Ty(*Nucleus::getContext());
        }
 
-       Byte::Byte(Argument *argument)
+       Byte::Byte(Argument<Byte> argument)
        {
-               storeValue(argument);
+               storeValue(argument.value);
        }
 
        Byte::Byte(RValue<Int> cast)
@@ -1187,9 +1187,9 @@ namespace sw
                return Type::getInt8Ty(*Nucleus::getContext());
        }
 
-       SByte::SByte(Argument *argument)
+       SByte::SByte(Argument<SByte> argument)
        {
-               storeValue(argument);
+               storeValue(argument.value);
        }
 
        SByte::SByte(RValue<Int> cast)
@@ -1441,9 +1441,9 @@ namespace sw
                return Type::getInt8Ty(*Nucleus::getContext());
        }
 
-       Short::Short(Argument *argument)
+       Short::Short(Argument<Short> argument)
        {
-               storeValue(argument);
+               storeValue(argument.value);
        }
 
        Short::Short(RValue<Int> cast)
@@ -1688,9 +1688,9 @@ namespace sw
                return Type::getInt16Ty(*Nucleus::getContext());
        }
 
-       UShort::UShort(Argument *argument)
+       UShort::UShort(Argument<UShort> argument)
        {
-               storeValue(argument);
+               storeValue(argument.value);
        }
 
        UShort::UShort(RValue<UInt> cast)
@@ -3747,9 +3747,9 @@ namespace sw
                return VectorType::get(UShort::getType(), 8);
        }
 
-       Int::Int(Argument *argument)
+       Int::Int(Argument<Int> argument)
        {
-               storeValue(argument);
+               storeValue(argument.value);
        }
 
        Int::Int(RValue<Byte> cast)
@@ -4225,9 +4225,9 @@ namespace sw
                return VectorType::get(Long::getType(), 2);
        }
 
-       UInt::UInt(Argument *argument)
+       UInt::UInt(Argument<UInt> argument)
        {
-               storeValue(argument);
+               storeValue(argument.value);
        }
 
        UInt::UInt(RValue<UShort> cast)
@@ -6765,62 +6765,62 @@ namespace sw
                return VectorType::get(Float::getType(), 4);
        }
 
-       RValue<Pointer<Byte> > operator+(RValue<Pointer<Byte> > lhs, int offset)
+       RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, int offset)
        {
-               return RValue<Pointer<Byte> >(Nucleus::createGEP(lhs.value, Nucleus::createConstantInt(offset)));
+               return RValue<Pointer<Byte>>(Nucleus::createGEP(lhs.value, Nucleus::createConstantInt(offset)));
        }
 
-       RValue<Pointer<Byte> > operator+(RValue<Pointer<Byte> > lhs, RValue<Int> offset)
+       RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, RValue<Int> offset)
        {
-               return RValue<Pointer<Byte> >(Nucleus::createGEP(lhs.value, offset.value));
+               return RValue<Pointer<Byte>>(Nucleus::createGEP(lhs.value, offset.value));
        }
 
-       RValue<Pointer<Byte> > operator+(RValue<Pointer<Byte> > lhs, RValue<UInt> offset)
+       RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, RValue<UInt> offset)
        {
-               return RValue<Pointer<Byte> >(Nucleus::createGEP(lhs.value, offset.value));
+               return RValue<Pointer<Byte>>(Nucleus::createGEP(lhs.value, offset.value));
        }
 
-       RValue<Pointer<Byte> > operator+=(const Pointer<Byte> &lhs, int offset)
+       RValue<Pointer<Byte>> operator+=(const Pointer<Byte> &lhs, int offset)
        {
                return lhs = lhs + offset;
        }
 
-       RValue<Pointer<Byte> > operator+=(const Pointer<Byte> &lhs, RValue<Int> offset)
+       RValue<Pointer<Byte>> operator+=(const Pointer<Byte> &lhs, RValue<Int> offset)
        {
                return lhs = lhs + offset;
        }
 
-       RValue<Pointer<Byte> > operator+=(const Pointer<Byte> &lhs, RValue<UInt> offset)
+       RValue<Pointer<Byte>> operator+=(const Pointer<Byte> &lhs, RValue<UInt> offset)
        {
                return lhs = lhs + offset;
        }
 
-       RValue<Pointer<Byte> > operator-(RValue<Pointer<Byte> > lhs, int offset)
+       RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, int offset)
        {
                return lhs + -offset;
        }
 
-       RValue<Pointer<Byte> > operator-(RValue<Pointer<Byte> > lhs, RValue<Int> offset)
+       RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, RValue<Int> offset)
        {
                return lhs + -offset;
        }
 
-       RValue<Pointer<Byte> > operator-(RValue<Pointer<Byte> > lhs, RValue<UInt> offset)
+       RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, RValue<UInt> offset)
        {
                return lhs + -offset;
        }
 
-       RValue<Pointer<Byte> > operator-=(const Pointer<Byte> &lhs, int offset)
+       RValue<Pointer<Byte>> operator-=(const Pointer<Byte> &lhs, int offset)
        {
                return lhs = lhs - offset;
        }
 
-       RValue<Pointer<Byte> > operator-=(const Pointer<Byte> &lhs, RValue<Int> offset)
+       RValue<Pointer<Byte>> operator-=(const Pointer<Byte> &lhs, RValue<Int> offset)
        {
                return lhs = lhs - offset;
        }
 
-       RValue<Pointer<Byte> > operator-=(const Pointer<Byte> &lhs, RValue<UInt> offset)
+       RValue<Pointer<Byte>> operator-=(const Pointer<Byte> &lhs, RValue<UInt> offset)
        {
                return lhs = lhs - offset;
        }
@@ -7761,7 +7761,7 @@ namespace sw
                        return RValue<Int>(Nucleus::createCall(pmovmskb, As<MMX>(x).value));
                }
 
-               //RValue<Int2> movd(RValue<Pointer<Int> > x)
+               //RValue<Int2> movd(RValue<Pointer<Int>> x)
                //{
                //      Value *element = Nucleus::createLoad(x.value);
 
index b4758c0..e305b1a 100644 (file)
@@ -88,7 +88,7 @@ namespace sw
                static llvm::BasicBlock *getPredecessor(llvm::BasicBlock *basicBlock);\r
 \r
                static llvm::Function *createFunction(llvm::Type *ReturnType, std::vector<llvm::Type*> &Params);\r
-               static llvm::Argument *getArgument(llvm::Function *function, unsigned int index);\r
+               static llvm::Value *getArgument(llvm::Function *function, unsigned int index);\r
 \r
                // Terminators\r
                static llvm::Value *createRetVoid();\r
@@ -293,7 +293,7 @@ namespace sw
        public:\r
                Variable(int arraySize = 0);\r
 \r
-               RValue<Pointer<T> > operator&();\r
+               RValue<Pointer<T>> operator&();\r
        };\r
 \r
        template<class T>\r
@@ -368,6 +368,14 @@ namespace sw
                llvm::Value *value;   // FIXME: Make private\r
        };\r
 \r
+       template<typename T>\r
+       struct Argument\r
+       {\r
+               explicit Argument(llvm::Value *value) : value(value) {}\r
+\r
+               llvm::Value *value;\r
+       };\r
+\r
        class MMX : public Variable<MMX>\r
        {\r
        public:\r
@@ -377,7 +385,7 @@ namespace sw
        class Bool : public Variable<Bool>\r
        {\r
        public:\r
-               explicit Bool(llvm::Argument *argument);\r
+               Bool(Argument<Bool> argument);\r
 \r
                Bool();\r
                Bool(bool x);\r
@@ -400,7 +408,7 @@ namespace sw
        class Byte : public Variable<Byte>\r
        {\r
        public:\r
-               explicit Byte(llvm::Argument *argument);\r
+               Byte(Argument<Byte> argument);\r
 \r
                explicit Byte(RValue<Int> cast);\r
                explicit Byte(RValue<UInt> cast);\r
@@ -458,7 +466,7 @@ namespace sw
        class SByte : public Variable<SByte>\r
        {\r
        public:\r
-               explicit SByte(llvm::Argument *argument);\r
+               SByte(Argument<SByte> argument);\r
 \r
                explicit SByte(RValue<Int> cast);\r
                explicit SByte(RValue<Short> cast);\r
@@ -514,7 +522,7 @@ namespace sw
        class Short : public Variable<Short>\r
        {\r
        public:\r
-               explicit Short(llvm::Argument *argument);\r
+               Short(Argument<Short> argument);\r
 \r
                explicit Short(RValue<Int> cast);\r
 \r
@@ -569,7 +577,7 @@ namespace sw
        class UShort : public Variable<UShort>\r
        {\r
        public:\r
-               explicit UShort(llvm::Argument *argument);\r
+               UShort(Argument<UShort> argument);\r
 \r
                explicit UShort(RValue<UInt> cast);\r
                explicit UShort(RValue<Int> cast);\r
@@ -1167,7 +1175,7 @@ namespace sw
        class Int : public Variable<Int>\r
        {\r
        public:\r
-               explicit Int(llvm::Argument *argument);\r
+               Int(Argument<Int> argument);\r
 \r
                explicit Int(RValue<Byte> cast);\r
                explicit Int(RValue<SByte> cast);\r
@@ -1239,7 +1247,7 @@ namespace sw
        class Long : public Variable<Long>\r
        {\r
        public:\r
-       //      explicit Long(llvm::Argument *argument);\r
+       //      Long(Argument<Long> argument);\r
 \r
        //      explicit Long(RValue<Short> cast);\r
        //      explicit Long(RValue<UShort> cast);\r
@@ -1302,12 +1310,12 @@ namespace sw
 //     RValue<Bool> operator==(RValue<Long> lhs, RValue<Long> rhs);\r
 \r
 //     RValue<Long> RoundLong(RValue<Float> cast);\r
-    RValue<Long> AddAtomic( RValue<Pointer<Long> > x, RValue<Long> y);\r
+    RValue<Long> AddAtomic( RValue<Pointer<Long>> x, RValue<Long> y);\r
 \r
        class Long1 : public Variable<Long1>\r
        {\r
        public:\r
-       //      explicit Long1(llvm::Argument *argument);\r
+       //      Long1(Argument<Long1> argument);\r
 \r
        //      explicit Long1(RValue<Short> cast);\r
        //      explicit Long1(RValue<UShort> cast);\r
@@ -1437,7 +1445,7 @@ namespace sw
        class UInt : public Variable<UInt>\r
        {\r
        public:\r
-               explicit UInt(llvm::Argument *argument);\r
+               UInt(Argument<UInt> argument);\r
 \r
                explicit UInt(RValue<UShort> cast);\r
                explicit UInt(RValue<Long> cast);\r
@@ -2393,11 +2401,11 @@ namespace sw
        RValue<Float4> Ceil(RValue<Float4> x);\r
 \r
        template<class T>\r
-       class Pointer : public Variable<Pointer<T> >\r
+       class Pointer : public Variable<Pointer<T>>\r
        {\r
        public:\r
                template<class S>\r
-               Pointer(RValue<Pointer<S> > pointerS, int alignment = 1) : alignment(alignment)\r
+               Pointer(RValue<Pointer<S>> pointerS, int alignment = 1) : alignment(alignment)\r
                {\r
                        llvm::Value *pointerT = Nucleus::createBitCast(pointerS.value, Nucleus::getPointerType(T::getType()));\r
                        LValue::storeValue(pointerT);\r
@@ -2411,17 +2419,17 @@ namespace sw
                        LValue::storeValue(pointerT);\r
                }\r
 \r
-               explicit Pointer(llvm::Argument *argument);\r
+               Pointer(Argument<Pointer<T>> argument);\r
                explicit Pointer(const void *external);\r
 \r
                Pointer();\r
-               Pointer(RValue<Pointer<T> > rhs);\r
+               Pointer(RValue<Pointer<T>> rhs);\r
                Pointer(const Pointer<T> &rhs);\r
-               Pointer(const Reference<Pointer<T> > &rhs);\r
+               Pointer(const Reference<Pointer<T>> &rhs);\r
 \r
-               RValue<Pointer<T> > operator=(RValue<Pointer<T> > rhs) const;\r
-               RValue<Pointer<T> > operator=(const Pointer<T> &rhs) const;\r
-               RValue<Pointer<T> > operator=(const Reference<Pointer<T> > &rhs) const;\r
+               RValue<Pointer<T>> operator=(RValue<Pointer<T>> rhs) const;\r
+               RValue<Pointer<T>> operator=(const Pointer<T> &rhs) const;\r
+               RValue<Pointer<T>> operator=(const Reference<Pointer<T>> &rhs) const;\r
 \r
                Reference<T> operator*();\r
 \r
@@ -2431,19 +2439,19 @@ namespace sw
                const int alignment;\r
        };\r
 \r
-    RValue<Pointer<Byte> > operator+(RValue<Pointer<Byte> > lhs, int offset);\r
-    RValue<Pointer<Byte> > operator+(RValue<Pointer<Byte> > lhs, RValue<Int> offset);\r
-    RValue<Pointer<Byte> > operator+(RValue<Pointer<Byte> > lhs, RValue<UInt> offset);\r
-    RValue<Pointer<Byte> > operator+=(const Pointer<Byte> &lhs, int offset);\r
-    RValue<Pointer<Byte> > operator+=(const Pointer<Byte> &lhs, RValue<Int> offset);\r
-    RValue<Pointer<Byte> > operator+=(const Pointer<Byte> &lhs, RValue<UInt> offset);\r
+    RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, int offset);\r
+    RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, RValue<Int> offset);\r
+    RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, RValue<UInt> offset);\r
+    RValue<Pointer<Byte>> operator+=(const Pointer<Byte> &lhs, int offset);\r
+    RValue<Pointer<Byte>> operator+=(const Pointer<Byte> &lhs, RValue<Int> offset);\r
+    RValue<Pointer<Byte>> operator+=(const Pointer<Byte> &lhs, RValue<UInt> offset);\r
 \r
-    RValue<Pointer<Byte> > operator-(RValue<Pointer<Byte> > lhs, int offset);\r
-    RValue<Pointer<Byte> > operator-(RValue<Pointer<Byte> > lhs, RValue<Int> offset);\r
-    RValue<Pointer<Byte> > operator-(RValue<Pointer<Byte> > lhs, RValue<UInt> offset);\r
-    RValue<Pointer<Byte> > operator-=(const Pointer<Byte> &lhs, int offset);\r
-    RValue<Pointer<Byte> > operator-=(const Pointer<Byte> &lhs, RValue<Int> offset);\r
-    RValue<Pointer<Byte> > operator-=(const Pointer<Byte> &lhs, RValue<UInt> offset);\r
+    RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, int offset);\r
+    RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, RValue<Int> offset);\r
+    RValue<Pointer<Byte>> operator-(RValue<Pointer<Byte>> lhs, RValue<UInt> offset);\r
+    RValue<Pointer<Byte>> operator-=(const Pointer<Byte> &lhs, int offset);\r
+    RValue<Pointer<Byte>> operator-=(const Pointer<Byte> &lhs, RValue<Int> offset);\r
+    RValue<Pointer<Byte>> operator-=(const Pointer<Byte> &lhs, RValue<UInt> offset);\r
 \r
        template<class T, int S = 1>\r
        class Array : public Variable<T>\r
@@ -2456,9 +2464,9 @@ namespace sw
                Reference<T> operator[](RValue<UInt> index);\r
        };\r
 \r
-//     RValue<Array<T> > operator++(const Array<T> &val, int);   // Post-increment\r
+//     RValue<Array<T>> operator++(const Array<T> &val, int);   // Post-increment\r
 //     const Array<T> &operator++(const Array<T> &val);   // Pre-increment\r
-//     RValue<Array<T> > operator--(const Array<T> &val, int);   // Post-decrement\r
+//     RValue<Array<T>> operator--(const Array<T> &val, int);   // Post-decrement\r
 //     const Array<T> &operator--(const Array<T> &val);   // Pre-decrement\r
 \r
        llvm::BasicBlock *beginLoop();\r
@@ -2473,7 +2481,22 @@ namespace sw
        void Return(const Pointer<T> &ret);\r
 \r
        template<class T>\r
-       void Return(RValue<Pointer<T> > ret);\r
+       void Return(RValue<Pointer<T>> ret);\r
+\r
+       template<unsigned int index, typename... Arguments>\r
+       struct ArgI;\r
+\r
+       template<typename Arg0, typename... Arguments>\r
+       struct ArgI<0, Arg0, Arguments...>\r
+       {\r
+               typedef Arg0 Type;\r
+       };\r
+\r
+       template<unsigned int index, typename Arg0, typename... Arguments>\r
+       struct ArgI<index, Arg0, Arguments...>\r
+       {\r
+               typedef typename ArgI<index - 1, Arguments...>::Type Type;\r
+       };\r
 \r
        // Generic template, leave undefined!\r
        template<typename FunctionType>\r
@@ -2488,7 +2511,12 @@ namespace sw
 \r
                virtual ~Function();\r
 \r
-               llvm::Argument *arg(int index);\r
+               template<int index>\r
+        Argument<typename ArgI<index, Arguments...>::Type> Arg() const\r
+        {\r
+                       llvm::Value *arg = Nucleus::getArgument(function, index);\r
+            return Argument<typename ArgI<index, Arguments...>::Type>(arg);\r
+        }\r
 \r
                Routine *operator()(const wchar_t *name, ...);\r
 \r
@@ -2498,6 +2526,12 @@ namespace sw
                std::vector<llvm::Type*> arguments;\r
        };\r
 \r
+       template<int index, typename Return, typename... Arguments>\r
+       Argument<typename ArgI<index, Arguments...>::Type> Arg(Function<Return(Arguments...)> &function)\r
+       {\r
+               return Argument<typename ArgI<index, Arguments...>::Type>(function.arg(index));\r
+       }\r
+\r
        RValue<Long> Ticks();\r
 }\r
 \r
@@ -2509,9 +2543,9 @@ namespace sw
        }\r
 \r
        template<class T>\r
-       RValue<Pointer<T> > Variable<T>::operator&()\r
+       RValue<Pointer<T>> Variable<T>::operator&()\r
        {\r
-               return RValue<Pointer<T> >(LValue::address);\r
+               return RValue<Pointer<T>>(LValue::address);\r
        }\r
 \r
        template<class T>\r
@@ -2740,9 +2774,9 @@ namespace sw
        }\r
 \r
        template<class T>\r
-       Pointer<T>::Pointer(llvm::Argument *argument) : alignment(1)\r
+       Pointer<T>::Pointer(Argument<Pointer<T>> argument) : alignment(1)\r
        {\r
-               LValue::storeValue((llvm::Value*)argument);\r
+               LValue::storeValue(argument.value);\r
        }\r
 \r
        template<class T>\r
@@ -2767,7 +2801,7 @@ namespace sw
        }\r
 \r
        template<class T>\r
-       Pointer<T>::Pointer(RValue<Pointer<T> > rhs) : alignment(1)\r
+       Pointer<T>::Pointer(RValue<Pointer<T>> rhs) : alignment(1)\r
        {\r
                LValue::storeValue(rhs.value);\r
        }\r
@@ -2780,14 +2814,14 @@ namespace sw
        }\r
 \r
        template<class T>\r
-       Pointer<T>::Pointer(const Reference<Pointer<T> > &rhs) : alignment(rhs.getAlignment())\r
+       Pointer<T>::Pointer(const Reference<Pointer<T>> &rhs) : alignment(rhs.getAlignment())\r
        {\r
                llvm::Value *value = rhs.loadValue();\r
                LValue::storeValue(value);\r
        }\r
 \r
        template<class T>\r
-       RValue<Pointer<T> > Pointer<T>::operator=(RValue<Pointer<T> > rhs) const\r
+       RValue<Pointer<T>> Pointer<T>::operator=(RValue<Pointer<T>> rhs) const\r
        {\r
                LValue::storeValue(rhs.value);\r
 \r
@@ -2795,21 +2829,21 @@ namespace sw
        }\r
 \r
        template<class T>\r
-       RValue<Pointer<T> > Pointer<T>::operator=(const Pointer<T> &rhs) const\r
+       RValue<Pointer<T>> Pointer<T>::operator=(const Pointer<T> &rhs) const\r
        {\r
                llvm::Value *value = rhs.loadValue();\r
                LValue::storeValue(value);\r
 \r
-               return RValue<Pointer<T> >(value);\r
+               return RValue<Pointer<T>>(value);\r
        }\r
 \r
        template<class T>\r
-       RValue<Pointer<T> > Pointer<T>::operator=(const Reference<Pointer<T> > &rhs) const\r
+       RValue<Pointer<T>> Pointer<T>::operator=(const Reference<Pointer<T>> &rhs) const\r
        {\r
                llvm::Value *value = rhs.loadValue();\r
                LValue::storeValue(value);\r
 \r
-               return RValue<Pointer<T> >(value);\r
+               return RValue<Pointer<T>>(value);\r
        }\r
 \r
        template<class T>\r
@@ -2854,7 +2888,7 @@ namespace sw
        }\r
 \r
 //     template<class T>\r
-//     RValue<Array<T> > operator++(const Array<T> &val, int)\r
+//     RValue<Array<T>> operator++(const Array<T> &val, int)\r
 //     {\r
 //             // FIXME: Requires storing the address of the array\r
 //     }\r
@@ -2866,7 +2900,7 @@ namespace sw
 //     }\r
 \r
 //     template<class T>\r
-//     RValue<Array<T> > operator--(const Array<T> &val, int)\r
+//     RValue<Array<T>> operator--(const Array<T> &val, int)\r
 //     {\r
 //             // FIXME: Requires storing the address of the array\r
 //     }\r
@@ -2916,7 +2950,7 @@ namespace sw
        }\r
 \r
        template<class T>\r
-       void Return(RValue<Pointer<T> > ret)\r
+       void Return(RValue<Pointer<T>> ret)\r
        {\r
                Nucleus::createRet(ret.value);\r
                Nucleus::setInsertBlock(Nucleus::createBasicBlock());\r
@@ -2931,7 +2965,7 @@ namespace sw
                for(llvm::Type *type : types)\r
                {\r
                        arguments.push_back(type);\r
-               } \r
+               }\r
 \r
                function = Nucleus::createFunction(Return::getType(), arguments);\r
                Nucleus::setFunction(function);\r
@@ -2944,12 +2978,6 @@ namespace sw
        }\r
 \r
        template<typename Return, typename... Arguments>\r
-       llvm::Argument *Function<Return(Arguments...)>::arg(int index)\r
-       {\r
-               return Nucleus::getArgument(function, index);\r
-       }\r
-\r
-       template<typename Return, typename... Arguments>\r
        Routine *Function<Return(Arguments...)>::operator()(const wchar_t *name, ...)\r
        {\r
                wchar_t fullName[1024 + 1];\r
index 677b343..07867db 100644 (file)
@@ -589,7 +589,7 @@ namespace sw
                        {
                                unsigned short mask = (writeB ? 0x001F : 0x0000) | (writeG ? 0x07E0 : 0x0000) | (writeR ? 0xF800 : 0x0000);
                                unsigned short unmask = ~mask;
-                               *Pointer<UShort>(element) = (*Pointer<UShort>(element) & UShort(unmask)) | 
+                               *Pointer<UShort>(element) = (*Pointer<UShort>(element) & UShort(unmask)) |
                                                            (UShort(RoundInt(Float(c.z)) |
                                                                   (RoundInt(Float(c.y)) << Int(5)) |
                                                                   (RoundInt(Float(c.x)) << Int(11))) & UShort(mask));
@@ -966,10 +966,10 @@ namespace sw
        {
                Function<Void(Pointer<Byte>)> function;
                {
-                       Pointer<Byte> blit(function.arg(0));
+                       Pointer<Byte> blit(function.Arg<0>());
 
-                       Pointer<Byte> source = *Pointer<Pointer<Byte> >(blit + OFFSET(BlitData,source));
-                       Pointer<Byte> dest = *Pointer<Pointer<Byte> >(blit + OFFSET(BlitData,dest));
+                       Pointer<Byte> source = *Pointer<Pointer<Byte>>(blit + OFFSET(BlitData,source));
+                       Pointer<Byte> dest = *Pointer<Pointer<Byte>>(blit + OFFSET(BlitData,dest));
                        Int sPitchB = *Pointer<Int>(blit + OFFSET(BlitData,sPitchB));
                        Int dPitchB = *Pointer<Int>(blit + OFFSET(BlitData,dPitchB));
 
@@ -1147,7 +1147,7 @@ namespace sw
 
                criticalSection.lock();
                Routine *blitRoutine = blitCache->query(state);
-               
+
                if(!blitRoutine)
                {
                        blitRoutine = generate(state);
@@ -1179,7 +1179,7 @@ namespace sw
                data.h = 1.0f / (dRect.y1 - dRect.y0) * (sRect.y1 - sRect.y0);
                data.x0 = (float)sRect.x0 + 0.5f * data.w;
                data.y0 = (float)sRect.y0 + 0.5f * data.h;
-               
+
                data.x0d = dRect.x0;
                data.x1d = dRect.x1;
                data.y0d = dRect.y0;
index dfee2f6..5ca2622 100644 (file)
@@ -53,16 +53,16 @@ namespace sw
                                Long pixelTime = Ticks();
                        #endif
 
-                       Pointer<Byte> primitive(function.arg(0));
-                       Int count(function.arg(1));
-                       Int cluster(function.arg(2));
-                       Pointer<Byte> data(function.arg(3));
+                       Pointer<Byte> primitive(function.Arg<0>());
+                       Int count(function.Arg<1>());
+                       Int cluster(function.Arg<2>());
+                       Pointer<Byte> data(function.Arg<3>());
 
                        Registers& r = *createRegisters(shader);
                        r.constants = *Pointer<Pointer<Byte> >(data + OFFSET(DrawData,constants));
                        r.cluster = cluster;
                        r.data = data;
-                       
+
                        Do
                        {
                                r.primitive = primitive;
@@ -134,20 +134,20 @@ namespace sw
                }
 
                Int y = yMin;
-               
+
                Do
                {
                        Int x0a = Int(*Pointer<Short>(r.primitive + OFFSET(Primitive,outline->left) + (y + 0) * sizeof(Primitive::Span)));
                        Int x0b = Int(*Pointer<Short>(r.primitive + OFFSET(Primitive,outline->left) + (y + 1) * sizeof(Primitive::Span)));
                        Int x0 = Min(x0a, x0b);
-                       
+
                        for(unsigned int q = 1; q < state.multiSample; q++)
                        {
                                x0a = Int(*Pointer<Short>(r.primitive + q * sizeof(Primitive) + OFFSET(Primitive,outline->left) + (y + 0) * sizeof(Primitive::Span)));
                                x0b = Int(*Pointer<Short>(r.primitive + q * sizeof(Primitive) + OFFSET(Primitive,outline->left) + (y + 1) * sizeof(Primitive::Span)));
                                x0 = Min(x0, Min(x0a, x0b));
                        }
-                       
+
                        x0 &= 0xFFFFFFFE;
 
                        Int x1a = Int(*Pointer<Short>(r.primitive + OFFSET(Primitive,outline->right) + (y + 0) * sizeof(Primitive::Span)));
@@ -193,7 +193,7 @@ namespace sw
                                                pitch = *Pointer<Int>(r.data + OFFSET(DrawData,depthPitchB));
                                        }
                                        else
-                                       {       
+                                       {
                                                buffer = zBuffer + 8 * x0;
                                        }
 
@@ -202,7 +202,7 @@ namespace sw
                                                Float4 z = interpolate(xxxx, r.Dz[0], z, r.primitive + OFFSET(Primitive,z), false, false);
 
                                                Float4 zValue;
-                                               
+
                                                if(!state.quadLayoutDepthBuffer)
                                                {
                                                        // FIXME: Properly optimizes?
index 08cdf59..1e2e897 100644 (file)
@@ -36,10 +36,10 @@ namespace sw
        {
                Function<Bool(Pointer<Byte>, Pointer<Byte>, Pointer<Byte>, Pointer<Byte>)> function;
                {
-                       Pointer<Byte> primitive(function.arg(0));
-                       Pointer<Byte> tri(function.arg(1));
-                       Pointer<Byte> polygon(function.arg(2));
-                       Pointer<Byte> data(function.arg(3));
+                       Pointer<Byte> primitive(function.Arg<0>());
+                       Pointer<Byte> tri(function.Arg<1>());
+                       Pointer<Byte> polygon(function.Arg<2>());
+                       Pointer<Byte> data(function.Arg<3>());
 
                        Pointer<Byte> constants = *Pointer<Pointer<Byte> >(data + OFFSET(DrawData,constants));
 
index 60b193d..b875517 100644 (file)
@@ -36,10 +36,10 @@ namespace sw
        {
                Function<Void(Pointer<Byte>, Pointer<Byte>, Pointer<Byte>, Pointer<Byte>)> function;
                {
-                       Pointer<Byte> vertex(function.arg(0));
-                       Pointer<Byte> batch(function.arg(1));
-                       Pointer<Byte> task(function.arg(2));
-                       Pointer<Byte> data(function.arg(3));
+                       Pointer<Byte> vertex(function.Arg<0>());
+                       Pointer<Byte> batch(function.Arg<1>());
+                       Pointer<Byte> task(function.Arg<2>());
+                       Pointer<Byte> data(function.Arg<3>());
 
                        const bool texldl = state.shaderContainsTexldl;