[opengtl-commits] [492] sounds like vectors need to have initial values nowdays

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


Revision: 492
Author:   cyrille
Date:     2008-11-22 22:44:21 +0100 (Sat, 22 Nov 2008)

Log Message:
-----------
sounds like vectors need to have initial values nowdays

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


Modified: trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp	2008-11-22 21:32:00 UTC (rev 491)
+++ trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp	2008-11-22 21:44:21 UTC (rev 492)
@@ -35,6 +35,7 @@
 #include "Value.h"
 #include "VariableNG_p.h"
 #include "ModuleData_p.h"
+#include "TypeManager_p.h"
 
 #include "AST/AccessorExpression.h"
 #include "wrappers/ArrayWrap.h"
@@ -119,6 +120,16 @@
   return 0;
 }
 
+llvm::Value* CodeGenerator::createVector( int _size, llvm::Constant* _val, const GTLCore::Type* _valType)
+{
+  std::vector<llvm::Constant*> inits;
+  for( int i = 0; i < _size; ++i)
+  {
+    inits.push_back( _val );
+  }
+  return llvm::ConstantVector::get( static_cast<const llvm::VectorType*>( GTLCore::TypeManager::getVector( _valType, _size)->d->type()), inits );
+}
+
 llvm::Value* CodeGenerator::convertPointerToCharP(llvm::BasicBlock* _currentBlock, llvm::Value* _value)
 {
   return convertPointerTo( _currentBlock, _value, llvm::IntegerType::get(8) );

Modified: trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.h	2008-11-22 21:32:00 UTC (rev 491)
+++ trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.h	2008-11-22 21:44:21 UTC (rev 492)
@@ -81,6 +81,11 @@
        */
       static llvm::Constant* valueToConstant( const GTLCore::Value& v);
       /**
+       * Create a vector of @p _size values equal to @p _val
+       * @param _valType the type of the @p _val
+       */
+      static llvm::Value* createVector( int _size, llvm::Constant* _val, const GTLCore::Type* _valType);
+      /**
        * Create a function and add it to the module.
        * @param name name of the function
        * @param type type of the function

Modified: trunk/OpenGTL/OpenShiva/OpenShiva/CodeGenerator_p.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/CodeGenerator_p.cpp	2008-11-22 21:32:00 UTC (rev 491)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/CodeGenerator_p.cpp	2008-11-22 21:44:21 UTC (rev 492)
@@ -154,7 +154,7 @@
 {
   SHIVA_DEBUG("setPixelCoordinates");
   // Create the coord vector
-  llvm::Value* result = llvm::ConstantVector::get( static_cast<const llvm::VectorType*>( GTLCore::TypeManager::getVector( GTLCore::Type::Float, 2)->d->type()), std::vector<llvm::Constant*>() );
+  llvm::Value* result = GTLCore::CodeGenerator::createVector( 2, GTLCore::CodeGenerator::floatToConstant( 0.0 ),  GTLCore::Type::Float );
   SHIVA_DEBUG(*result << " " << *_iVal << " " << *_jVal);
   result = llvm::InsertElementInst::Create( result, GTLCore::CodeGenerator::convertValueTo( _currentBlock, _iVal, _iValType, GTLCore::Type::Float), (unsigned int)0, "", _currentBlock );
   result = llvm::InsertElementInst::Create( result, GTLCore::CodeGenerator::convertValueTo( _currentBlock, _jVal, _iValType, GTLCore::Type::Float), 1, "", _currentBlock );


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