[opengtl-commits] [494] some more vectors need to have initializers |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/opengtl-commits Archives
]
Revision: 494
Author: cyrille
Date: 2008-11-22 23:08:29 +0100 (Sat, 22 Nov 2008)
Log Message:
-----------
some more vectors need to have initializers
Modified Paths:
--------------
trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp
trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.h
Modified: trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp 2008-11-22 21:55:12 UTC (rev 493)
+++ trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp 2008-11-22 22:08:29 UTC (rev 494)
@@ -120,6 +120,18 @@
return 0;
}
+llvm::Value* CodeGenerator::createVector( const GTLCore::Type* _vecType, llvm::Constant* _val)
+{
+ GTL_ASSERT( _vecType->dataType() == Type::VECTOR );
+ std::vector<llvm::Constant*> inits;
+ for( std::size_t i = 0; i < _vecType->vectorSize(); ++i)
+ {
+ 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)
{
std::vector<llvm::Constant*> inits;
@@ -159,7 +171,7 @@
{
GTL_DEBUG("Convert value to a vector");
// Create a vector
- llvm::Value* resultLoad = llvm::ConstantVector::get( static_cast<const llvm::VectorType*>(_targetType->d->type()), std::vector<llvm::Constant*>() );
+ llvm::Value* resultLoad = createVector( _targetType, floatToConstant( 0.0 ) );
llvm::Value* vecElt = convertValueTo( _currentBlock, _value, _valueType, _targetType->embeddedType() );
// Affect the same value to each element of the vector
for(unsigned int i = 0; i < _targetType->vectorSize(); ++i)
Modified: trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.h 2008-11-22 21:55:12 UTC (rev 493)
+++ trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.h 2008-11-22 22:08:29 UTC (rev 494)
@@ -81,6 +81,10 @@
*/
static llvm::Constant* valueToConstant( const GTLCore::Value& v);
/**
+ * 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
* @param _valType the type of the @p _val
*/