[opengtl-commits] [495] more create vectors need initialiser

[ Thread Index | Date Index | More lists.tuxfamily.org/opengtl-commits Archives ]


Revision: 495
Author:   cyrille
Date:     2008-11-22 23:20:17 +0100 (Sat, 22 Nov 2008)

Log Message:
-----------
more create vectors need initialiser

Modified Paths:
--------------
    trunk/OpenGTL/OpenGTL/GTLCore/AST/CoumpoundExpression.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.h


Modified: trunk/OpenGTL/OpenGTL/GTLCore/AST/CoumpoundExpression.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/AST/CoumpoundExpression.cpp	2008-11-22 22:08:29 UTC (rev 494)
+++ trunk/OpenGTL/OpenGTL/GTLCore/AST/CoumpoundExpression.cpp	2008-11-22 22:20:17 UTC (rev 495)
@@ -66,7 +66,7 @@
     {
       GTL_DEBUG( m_expressions.size() << " " << m_type->vectorSize() );
       GTL_ASSERT( m_expressions.size() == m_type->vectorSize() );
-      llvm::Value* resultLoad = llvm::ConstantVector::get( static_cast<const llvm::VectorType*>( m_type->d->type()), std::vector<llvm::Constant*>() );
+      llvm::Value* resultLoad = CodeGenerator::createVector( m_type );
       // Affect the same value to each element of the vector
       for(std::size_t i = 0; i < m_expressions.size(); ++i)
       {

Modified: trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp	2008-11-22 22:08:29 UTC (rev 494)
+++ trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp	2008-11-22 22:20:17 UTC (rev 495)
@@ -120,6 +120,26 @@
   return 0;
 }
 
+llvm::Value* CodeGenerator::createVector( const GTLCore::Type* _vecType)
+{
+  llvm::Constant* _const = 0;
+  switch( _vecType->embeddedType()->dataType() )
+  {
+    case Type::UNSIGNED_INTEGER32:
+    case Type::INTEGER32:
+      _const = integerToConstant( 0 );
+      break;
+    case Type::FLOAT:
+    case Type::HALF:
+      _const = floatToConstant( 0.0 );
+      break;
+    default:  
+      break;
+  }
+  GTL_ASSERT( _const );
+  return createVector( _vecType, _const );
+}
+
 llvm::Value* CodeGenerator::createVector( const GTLCore::Type* _vecType, llvm::Constant* _val)
 {
   GTL_ASSERT( _vecType->dataType() == Type::VECTOR );
@@ -129,7 +149,6 @@
     inits.push_back( _val );
   }
   return llvm::ConstantVector::get( static_cast<const llvm::VectorType*>( _vecType->d->type()), inits );
-  
 }
 
 llvm::Value* CodeGenerator::createVector( int _size, llvm::Constant* _val, const GTLCore::Type* _valType)

Modified: trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.h	2008-11-22 22:08:29 UTC (rev 494)
+++ trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.h	2008-11-22 22:20:17 UTC (rev 495)
@@ -83,6 +83,10 @@
       /**
        * Create a vector of type @p _vecType
        */
+      static llvm::Value* createVector( const GTLCore::Type* _vecType);
+      /**
+       * Create a vector of type @p _vecType
+       */
       static llvm::Value* createVector( const GTLCore::Type* _vecType, llvm::Constant* _val);
       /**
        * Create a vector of @p _size values equal to @p _val


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/