[opengtl-commits] [207] move the call to memcpy in an independent function |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/opengtl-commits Archives
]
Revision: 207
Author: cyrille
Date: 2008-06-21 00:46:39 +0200 (Sat, 21 Jun 2008)
Log Message:
-----------
move the call to memcpy in an independent function
Modified Paths:
--------------
trunk/OpenGTL/OpenShiva/OpenShiva/CodeGenerator_p.cpp
trunk/OpenGTL/OpenShiva/OpenShiva/CodeGenerator_p.h
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/CodeGenerator_p.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/CodeGenerator_p.cpp 2008-06-20 22:39:26 UTC (rev 206)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/CodeGenerator_p.cpp 2008-06-20 22:46:39 UTC (rev 207)
@@ -89,23 +89,30 @@
_pointerToPixelVector, llvm::PointerType::get(llvm::IntegerType::get(8), 0), "", _currentBlock);
}
-llvm::BasicBlock* CodeGenerator::memToPixel( GTLCore::GenerationContext& _gc, llvm::BasicBlock* _currentBlock, llvm::Value* _dataPointer, llvm::Value* _pixel, int _size )
+llvm::Value* CodeGenerator::callMemcpy( GTLCore::GenerationContext& _gc, llvm::BasicBlock* _currentBlock, llvm::Value* _dst, llvm::Value* _src, llvm::Value* _n )
{
// Initialise llvm_memcpy_i32
llvm::Function* func_llvm_memcpy_i32 = createMemCpyFunction( _gc.llvmModule() );
- // Access to the data pointer for the _pixel
- llvm::Value* _pointerToPixelVectorU8 = accessPixelData( _gc, _currentBlock, _pixel );
- // Call llvm.memcpy.i32
+ // Set parameters
std::vector<llvm::Value*> memcpy_params;
- memcpy_params.push_back( _pointerToPixelVectorU8 );
- memcpy_params.push_back( _dataPointer );
- memcpy_params.push_back( GTLCore::CodeGenerator::integerToConstant( _size ) );
+ memcpy_params.push_back( _dst );
+ memcpy_params.push_back( _src );
+ memcpy_params.push_back( _n );
memcpy_params.push_back( GTLCore::CodeGenerator::integerToConstant( 1 ) );
llvm::CallInst* callMemCpy = new llvm::CallInst(
func_llvm_memcpy_i32, memcpy_params.begin(), memcpy_params.end(), "", _currentBlock);
callMemCpy->setCallingConv(llvm::CallingConv::C);
callMemCpy->setTailCall( false );
+ return callMemCpy;
+}
+llvm::BasicBlock* CodeGenerator::memToPixel( GTLCore::GenerationContext& _gc, llvm::BasicBlock* _currentBlock, llvm::Value* _dataPointer, llvm::Value* _pixel, int _size )
+{
+ // Access to the data pointer for the _pixel
+ llvm::Value* _pointerToPixelVectorU8 = accessPixelData( _gc, _currentBlock, _pixel );
+ // Call llvm.memcpy.i32
+ callMemcpy( _gc, _currentBlock, _pointerToPixelVectorU8, _dataPointer, GTLCore::CodeGenerator::integerToConstant( _size ) );
+
return _currentBlock;
}
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/CodeGenerator_p.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/CodeGenerator_p.h 2008-06-20 22:39:26 UTC (rev 206)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/CodeGenerator_p.h 2008-06-20 22:46:39 UTC (rev 207)
@@ -51,6 +51,7 @@
private:
static llvm::Function* createMemCpyFunction( llvm::Module* _module );
static llvm::Value* accessPixelData( GTLCore::GenerationContext& _gc, llvm::BasicBlock* _currentBlock, llvm::Value* _pixel);
+ static llvm::Value* callMemcpy( GTLCore::GenerationContext& _gc, llvm::BasicBlock* _currentBlock, llvm::Value* _dst, llvm::Value* _src, llvm::Value* _n );
private:
static int s_evaluatePixelesId;
};