[opengtl-commits] [430] use a vector of size 3 for vectors of size 3 |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/opengtl-commits Archives
]
Revision: 430
Author: cyrille
Date: 2008-10-07 00:17:23 +0200 (Tue, 07 Oct 2008)
Log Message:
-----------
use a vector of size 3 for vectors of size 3
Modified Paths:
--------------
trunk/OpenGTL/OpenGTL/GTLCore/AST/CoumpoundExpression.cpp
trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp
trunk/OpenGTL/OpenGTL/GTLCore/Type.cpp
trunk/OpenGTL/OpenGTL/GTLCore/Type.h
trunk/OpenGTL/OpenGTL/GTLCore/Type_p.h
trunk/OpenGTL/OpenShiva/OpenShiva/Parser_p.cpp
trunk/OpenGTL/OpenShiva/OpenShiva/Wrapper_p.cpp
Modified: trunk/OpenGTL/OpenGTL/GTLCore/AST/CoumpoundExpression.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/AST/CoumpoundExpression.cpp 2008-10-06 13:47:19 UTC (rev 429)
+++ trunk/OpenGTL/OpenGTL/GTLCore/AST/CoumpoundExpression.cpp 2008-10-06 22:17:23 UTC (rev 430)
@@ -58,17 +58,20 @@
GTLCore::ExpressionResult CoumpoundExpression::generateValue( GenerationContext& _gc, llvm::BasicBlock* _bb ) const
{
- GTL_DEBUG( m_type->dataType() << " " << Type::ARRAY << " " << Type::STRUCTURE << " " << Type::VECTOR );
+ GTL_DEBUG( *m_type << " " << m_type->dataType() << " " << Type::ARRAY << " " << Type::STRUCTURE << " " << Type::VECTOR );
switch( m_type->dataType() )
{
case Type::VECTOR:
{
+ 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*>() );
// Affect the same value to each element of the vector
for(std::size_t i = 0; i < m_expressions.size(); ++i)
{
llvm::Value* val = m_expressions[i]->generateValue( _gc, _bb ).value();
+ GTL_DEBUG( i << " " << *val );
resultLoad = llvm::InsertElementInst::Create( resultLoad, val, i, "", _bb );
}
return GTLCore::ExpressionResult( resultLoad, m_type );
Modified: trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp 2008-10-06 13:47:19 UTC (rev 429)
+++ trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp 2008-10-06 22:17:23 UTC (rev 430)
@@ -151,7 +151,7 @@
llvm::Value* resultLoad = llvm::ConstantVector::get( static_cast<const llvm::VectorType*>(_targetType->d->type()), std::vector<llvm::Constant*>() );
llvm::Value* vecElt = convertValueTo( _currentBlock, _value, _valueType, _targetType->embeddedType() );
// Affect the same value to each element of the vector
- for(int i = 0; i < _targetType->vectorSize(); ++i)
+ for(unsigned int i = 0; i < _targetType->vectorSize(); ++i)
{
resultLoad = llvm::InsertElementInst::Create( resultLoad, vecElt, i, "", _currentBlock );
}
@@ -178,7 +178,7 @@
llvm::Constant* vecElt = convertConstantTo( _constant, _constantType, _targetType->embeddedType() );
// Affect the same value to each element of the vector
std::vector<llvm::Constant*> constants;
- for(int i = 0; i < _targetType->vectorSize(); ++i)
+ for(unsigned int i = 0; i < _targetType->vectorSize(); ++i)
{
constants.push_back( vecElt );
}
Modified: trunk/OpenGTL/OpenGTL/GTLCore/Type.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Type.cpp 2008-10-06 13:47:19 UTC (rev 429)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Type.cpp 2008-10-06 22:17:23 UTC (rev 430)
@@ -270,7 +270,7 @@
}
}
-int Type::vectorSize() const
+unsigned int Type::vectorSize() const
{
GTL_ASSERT( dataType() == Type::VECTOR );
return d->vectorSize;
Modified: trunk/OpenGTL/OpenGTL/GTLCore/Type.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Type.h 2008-10-06 13:47:19 UTC (rev 429)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Type.h 2008-10-06 22:17:23 UTC (rev 430)
@@ -206,7 +206,7 @@
/**
* @return the size of a vector
*/
- int vectorSize() const;
+ unsigned int vectorSize() const;
/**
* @return true if the type is a number (this return false if the type is a \ref VECTOR )
*/
Modified: trunk/OpenGTL/OpenGTL/GTLCore/Type_p.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Type_p.h 2008-10-06 13:47:19 UTC (rev 429)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Type_p.h 2008-10-06 22:17:23 UTC (rev 430)
@@ -143,7 +143,7 @@
void setType( const llvm::Type* _type);
const llvm::Type* m_type;
DataType dataType;
- int vectorSize;
+ unsigned int vectorSize;
const Type* arrayType;
GTLCore::String structName;
std::vector<StructDataMember>* structDataMembers;
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Parser_p.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Parser_p.cpp 2008-10-06 13:47:19 UTC (rev 429)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Parser_p.cpp 2008-10-06 22:17:23 UTC (rev 430)
@@ -173,6 +173,8 @@
getNextToken();
return typeManager()->getVector( GTLCore::Type::Boolean, 2 );
case GTLCore::Token::BOOL3:
+ getNextToken();
+ return typeManager()->getVector( GTLCore::Type::Boolean, 3 );
case GTLCore::Token::BOOL4:
getNextToken();
return typeManager()->getVector( GTLCore::Type::Boolean, 4 );
@@ -180,6 +182,8 @@
getNextToken();
return typeManager()->getVector( GTLCore::Type::Integer32, 2 );
case GTLCore::Token::INT3:
+ getNextToken();
+ return typeManager()->getVector( GTLCore::Type::Integer32, 3 );
case GTLCore::Token::INT4:
getNextToken();
return typeManager()->getVector( GTLCore::Type::Integer32, 4 );
@@ -187,6 +191,8 @@
getNextToken();
return typeManager()->getVector( GTLCore::Type::Float, 2 );
case GTLCore::Token::FLOAT3:
+ getNextToken();
+ return typeManager()->getVector( GTLCore::Type::Float, 3 );
case GTLCore::Token::FLOAT4:
getNextToken();
return typeManager()->getVector( GTLCore::Type::Float, 4 );
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Wrapper_p.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Wrapper_p.cpp 2008-10-06 13:47:19 UTC (rev 429)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Wrapper_p.cpp 2008-10-06 22:17:23 UTC (rev 430)
@@ -253,11 +253,5 @@
{
return GTLCore::Type::Float;
}
- // Compute the size of the vector
- int size_vector = 1;
- while( size_vector < _channels )
- {
- size_vector *= 2;
- }
- return _typeManager->getVector( GTLCore::Type::Float, size_vector);
+ return _typeManager->getVector( GTLCore::Type::Float, _channels);
}