[opengtl-commits] [256] add a function to generate rounding code ( (int)(x+0.5) ) |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/opengtl-commits Archives
]
Revision: 256
Author: cyrille
Date: 2008-06-28 00:18:12 +0200 (Sat, 28 Jun 2008)
Log Message:
-----------
add a function to generate rounding code ( (int)(x+0.5) )
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-06-27 22:14:16 UTC (rev 255)
+++ trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp 2008-06-27 22:18:12 UTC (rev 256)
@@ -202,6 +202,15 @@
return new llvm::ExtractElementInst( _vector, _index, "", _currentBlock );
}
+llvm::Value* CodeGenerator::createRound( llvm::BasicBlock* _currentBlock, llvm::Value* _val )
+{
+ _val = GTLCore::CodeGenerator::createAdditionExpression( _currentBlock, _val, GTLCore::Type::Float,
+ GTLCore::CodeGenerator::floatToConstant( 0.5 ), GTLCore::Type::Float );
+ return GTLCore::CodeGenerator::convertValueTo( _currentBlock, _val,
+ GTLCore::Type::Float, GTLCore::Type::Integer32 );
+}
+
+
void CodeGenerator::createIfStatement( llvm::BasicBlock* before, llvm::Value* test, const Type* testType, llvm::BasicBlock* firstAction, llvm::BasicBlock* lastAction, llvm::BasicBlock* after)
{
if( not lastAction->getTerminator() )
Modified: trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.h 2008-06-27 22:14:16 UTC (rev 255)
+++ trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.h 2008-06-27 22:18:12 UTC (rev 256)
@@ -94,6 +94,7 @@
static llvm::Value* convertToHalf( GenerationContext& generationContext, llvm::BasicBlock* currentBlock, llvm::Value* value, const Type* _valueType);
static llvm::Value* convertFromHalf( GenerationContext& generationContext, llvm::BasicBlock* currentBlock, llvm::Value* value);
static llvm::Value* vectorValueAt( llvm::BasicBlock* _currentBlock, llvm::Value* _vector, llvm::Value* _index);
+ static llvm::Value* createRound( llvm::BasicBlock* _currentBlock, llvm::Value* _val );
public: // Boolean Expression
llvm::Value* createOrExpression(llvm::BasicBlock* currentBlock, llvm::Value* lhs, const Type* lhsType, llvm::Value* rhs, const Type* rhsType);
ExpressionResult createOrExpression( llvm::BasicBlock* currentBlock, ExpressionResult lhs, const Type* lhsType, ExpressionResult rhs, const Type* rhsType);