[opengtl-commits] [322] s/_NDEBUG_/NDEBUG and fix compilation when used in release mode |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/opengtl-commits Archives
]
Revision: 322
Author: cyrille
Date: 2008-08-30 14:31:47 +0200 (Sat, 30 Aug 2008)
Log Message:
-----------
s/_NDEBUG_/NDEBUG and fix compilation when used in release mode
Modified Paths:
--------------
trunk/OpenGTL/OpenCTL/OpenCTL/Program.cpp
trunk/OpenGTL/OpenGTL/GTLCore/AST/BinaryExpression.cpp
trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp
trunk/OpenGTL/OpenGTL/GTLCore/Debug.h
trunk/OpenGTL/OpenGTL/GTLCore/Function_p.cpp
trunk/OpenGTL/OpenGTL/GTLCore/Macros_p.h
Modified: trunk/OpenGTL/OpenCTL/OpenCTL/Program.cpp
===================================================================
--- trunk/OpenGTL/OpenCTL/OpenCTL/Program.cpp 2008-08-28 23:13:12 UTC (rev 321)
+++ trunk/OpenGTL/OpenCTL/OpenCTL/Program.cpp 2008-08-30 12:31:47 UTC (rev 322)
@@ -131,6 +131,7 @@
OCTL_ASSERT(dstPixelDescription.bitsSize() % 8== 0);
// Configure input buffer
+ OCTL_DEBUG("Configure input buffer");
const std::vector< const GTLCore::Type*>& srcChannelsTypes = srcPixelDescription.channelTypes();
llvm::Value** srcIndexes = new llvm::Value*[ srcChannelsTypes.size() ];
bool* srcNeedBuffer = new bool[ srcChannelsTypes.size() ]; // CTL doesn't support Int8 or Int16 (and OpenCTL's VM doesn't know about half), so when some pixel channel is in Int8 or Int16 (or half) it first need to be converted to Int32 (or float)
@@ -162,6 +163,7 @@
// }
// return;
// }
+ OCTL_DEBUG("Initialize the function type");
llvm::Value* srcPixelSizeValue = cg.integerToConstant( srcPixelSize );
llvm::Value* dstPixelSizeValue = cg.integerToConstant( dstPixelSize );
std::vector<const llvm::Type*> params;
@@ -175,9 +177,11 @@
// Initialise a generation context
GTLCore::GenerationContext gc( &cg, func, 0, d->moduleData );
// {
+ OCTL_DEBUG("Initial block");
llvm::BasicBlock* initialBlock = llvm::BasicBlock::Create();
func->getBasicBlockList().push_back( initialBlock );
// Initialise the buffer, as needed
+ OCTL_DEBUG("Initialise buffer");
GTLCore::VariableNG** buffer = new GTLCore::VariableNG*[dstCountChannels];
for(int i = 0; i < dstCountChannels; ++i)
{
@@ -196,6 +200,7 @@
buffer[i] = 0;
}
}
+ OCTL_DEBUG("Get the arguments");
// Get the args.
llvm::Function::arg_iterator arg_it = func->arg_begin();
// const char* in8 = first arg;
@@ -208,31 +213,37 @@
llvm::Value* size = arg_it;
// Construct the "conditions" of the loop
// int i = 0;
+ OCTL_DEBUG("int i = 0");
GTLCore::VariableNG* posSrc = new GTLCore::VariableNG( GTLCore::Type::Integer32, false);
posSrc->initialise( gc, initialBlock, GTLCore::ExpressionResult(cg.integerToConstant(0), GTLCore::Type::Integer32), std::list<llvm::Value*>());
GTLCore::VariableNG* posDst = new GTLCore::VariableNG( GTLCore::Type::Integer32, false);
posDst->initialise( gc, initialBlock, GTLCore::ExpressionResult(cg.integerToConstant(0), GTLCore::Type::Integer32), std::list<llvm::Value*>());
// i < size
+ OCTL_DEBUG("i < size");
llvm::BasicBlock* forTestBlock = llvm::BasicBlock::Create("forTestBlock");
func->getBasicBlockList().push_back( forTestBlock);
llvm::Value* forTest = cg.createStrictInferiorExpression(forTestBlock, posSrc->get( gc, forTestBlock ), posSrc->type(), size, GTLCore::Type::Integer32 );
// i += pixelSize
+ OCTL_DEBUG("i += pixelSize");
llvm::BasicBlock* updateBlock = llvm::BasicBlock::Create("updateBlock");
func->getBasicBlockList().push_back( updateBlock);
posSrc->set( gc, updateBlock, cg.createAdditionExpression( updateBlock, posSrc->get( gc, updateBlock), posSrc->type(), srcPixelSizeValue, GTLCore::Type::Integer32 ), GTLCore::Type::Integer32 );
posDst->set( gc, updateBlock, cg.createAdditionExpression( updateBlock, posDst->get( gc, updateBlock), posSrc->type(), dstPixelSizeValue, GTLCore::Type::Integer32 ), GTLCore::Type::Integer32 );
// Construct the body of the for loop
+ OCTL_DEBUG("bodyBlock");
llvm::BasicBlock* bodyBlock = llvm::BasicBlock::Create("bodyBlock");
+ func->getBasicBlockList().push_back( bodyBlock);
// function(in[i], in[i+indexes[1]] ..., out + i, out + i +indexes[1], ...);
- func->getBasicBlockList().push_back( bodyBlock);
std::vector<llvm::Value*> arguments;
// Generate in[i], in[i+indexes[1]] ...
+ OCTL_DEBUG("Generate in[i], in[i+indexes[1]] ...");
llvm::Value* srcIndex = posSrc->get( gc, bodyBlock);
for(int i = 0; i < srcCountChannels; ++i)
{
// Load the value from the input buffer
+ OCTL_DEBUG("Load the value from the input buffer");
llvm::Value* convertedIn = new llvm::LoadInst(
cg.convertPointerTo( bodyBlock,
llvm::GetElementPtrInst::Create( in, cg.createAdditionExpression( bodyBlock, srcIndex, posSrc->type(), srcIndexes[i], GTLCore::Type::Integer32), "", bodyBlock),
@@ -240,6 +251,7 @@
"", bodyBlock);
if( srcNeedBuffer[i])
{ // if a buffer is needed that means that the value must be converted
+ OCTL_DEBUG("if a buffer is needed that means that the value must be converted");
if(srcChannelsTypes[i] == GTLCore::Type::Half)
{
convertedIn = GTLCore::CodeGenerator::convertFromHalf( gc, bodyBlock, convertedIn);
@@ -251,6 +263,7 @@
}
// Generate ut + i, out + i +indexes[1], ...
+ OCTL_DEBUG("Generate ut + i, out + i +indexes[1], ...");
llvm::Value* dstIndex = posDst->get( gc, bodyBlock);
for(int i = 0; i < dstCountChannels; ++i)
{
@@ -265,6 +278,7 @@
}
}
// Check if there are more parameters to call
+ OCTL_DEBUG("Check if there are more parameters to call");
const std::vector< GTLCore::Parameter >& parameters = functionDef->parameters();
if( arguments.size() < parameters.size() )
{
@@ -294,6 +308,7 @@
llvm::CallInst *CallFunc = llvm::CallInst::Create(function, arguments.begin(), arguments.end(), "", bodyBlock);
CallFunc->setTailCall();
// If there was buffering, save to output
+ OCTL_DEBUG("If there was buffering, save to output");
for(int i = 0; i < dstCountChannels; ++i)
{
if( dstNeedBuffer[i])
@@ -312,14 +327,18 @@
}
}
// Put the for loop together
+ OCTL_DEBUG("Put the for loop together");
// for(int i = 0; i < size; ++i)
+ OCTL_DEBUG("for(int i = 0; i < size; ++i)");
llvm::BasicBlock* finBlock = llvm::BasicBlock::Create("finBlock");
func->getBasicBlockList().push_back( finBlock);
cg.createForStatement(initialBlock, forTestBlock, forTest, GTLCore::Type::Boolean, updateBlock, bodyBlock, bodyBlock, finBlock);
// return;
+ OCTL_DEBUG("return;");
llvm::ReturnInst::Create(finBlock);
OCTL_DEBUG(*d->module);
- //
+ // Optimize, FIXME: use GTLCore's optimizer
+ OCTL_DEBUG("Optimize");
llvm::PassManager Passes;
// Add in the passes we want to execute
Passes.add(new llvm::TargetData(d->module));
Modified: trunk/OpenGTL/OpenGTL/GTLCore/AST/BinaryExpression.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/AST/BinaryExpression.cpp 2008-08-28 23:13:12 UTC (rev 321)
+++ trunk/OpenGTL/OpenGTL/GTLCore/AST/BinaryExpression.cpp 2008-08-30 12:31:47 UTC (rev 322)
@@ -24,6 +24,7 @@
#include <GTLCore/Debug.h>
#include <GTLCore/CodeGenerator_p.h>
#include <GTLCore/ExpressionResult_p.h>
+#include <GTLCore/Macros_p.h>
#include <GTLCore/Type.h>
#include <GTLCore/VariableNG_p.h>
#include <GTLCore/Visitor_p.h>
@@ -205,6 +206,7 @@
GTL_ASSERT( m_lhs);
llvm::BasicBlock* bbr = generateStatement( _gc, _bb );
GTL_ASSERT( bbr == _bb);
+ UNUSED( bbr );
return GTLCore::ExpressionResult( m_lhs->generateValue( _gc, _bb) );
}
Modified: trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp 2008-08-28 23:13:12 UTC (rev 321)
+++ trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp 2008-08-30 12:31:47 UTC (rev 322)
@@ -156,6 +156,7 @@
}
if( _targetType->dataType() == Type::VECTOR and _valueType->dataType() != Type::VECTOR )
{
+ GTL_DEBUG("Convert value to a vector");
// Create a vector
llvm::Value* result = new llvm::AllocaInst( _targetType->d->type(), integerToConstant(1), "", _currentBlock);
llvm::Value* resultLoad = new llvm::LoadInst( result, "", _currentBlock);
@@ -167,8 +168,10 @@
}
// store back
new llvm::StoreInst( resultLoad, result, "", _currentBlock);
+ GTL_DEBUG("Done");
return result;
}
+ GTL_DEBUG("Create cast instruction");
GTL_ASSERT(_targetType->d->type()->isFirstClassType());
GTL_ASSERT(_value->getType()->isFirstClassType());
return llvm::CastInst::create(
@@ -626,8 +629,10 @@
// Function Type
GTL_ASSERT( _function );
llvm::Function* llvmFunction = _function->d->data->function( _arguments.size() );
+#ifndef NDEBUG
const llvm::FunctionType *FTy = llvm::cast<llvm::FunctionType>(llvm::cast<llvm::PointerType>( llvmFunction->getType())->getElementType());
GTL_DEBUG( *FTy );
+#endif
GTL_ASSERT( llvmFunction );
std::vector< Parameter >::const_iterator oparam_it = _function->parameters().begin();
std::vector<llvm::Value*> convertedParams;
Modified: trunk/OpenGTL/OpenGTL/GTLCore/Debug.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Debug.h 2008-08-28 23:13:12 UTC (rev 321)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Debug.h 2008-08-30 12:31:47 UTC (rev 322)
@@ -54,6 +54,14 @@
}
+#if (defined(__GNUC__) && !( defined(__sun) || defined(sun) )) || ( ( defined(hpux) || defined(__hpux) ) && ( defined(__HP_aCC) || __cplusplus >= 199707L ) )
+# define FUNC_INFO __PRETTY_FUNCTION__
+#elif defined(_MSC_VER) && _MSC_VER > 1300
+# define FUNC_INFO __FUNCSIG__
+#else
+# define FUNC_INFO ""
+#endif
+
#define GTL_WARNING(msg) \
GTLCore::Debug::warning(COUMPONENT_NAME, __FILE__, __LINE__, FUNC_INFO ) << msg << std::endl;
@@ -64,18 +72,8 @@
GTL_ERROR(msg); \
abort();
-#ifndef _NDEBUG_
+#ifndef NDEBUG
-#if (defined(__GNUC__) && !( defined(__sun) || defined(sun) )) || ( ( defined(hpux) || defined(__hpux) ) && ( defined(__HP_aCC) || __cplusplus >= 199707L ) )
-# define FUNC_INFO __PRETTY_FUNCTION__
-#elif defined(_MSC_VER) && _MSC_VER > 1300
-# define FUNC_INFO __FUNCSIG__
-#else
-# define FUNC_INFO ""
-#endif
-
-
-
#include <assert.h>
#define GTL_DEBUG(msg) \
Modified: trunk/OpenGTL/OpenGTL/GTLCore/Function_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Function_p.cpp 2008-08-28 23:13:12 UTC (rev 321)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Function_p.cpp 2008-08-30 12:31:47 UTC (rev 322)
@@ -111,7 +111,7 @@
std::vector<GTLCore::Parameter> arguments;
va_list argp;
va_start(argp, _count);
-#ifndef _NDEBUG_
+#ifndef NDEBUG
const llvm::FunctionType *FTy =
llvm::cast<llvm::FunctionType>(llvm::cast<llvm::PointerType>(_function->getType())->getElementType());
#endif
@@ -119,7 +119,7 @@
{
const GTLCore::Type* type = va_arg(argp, const GTLCore::Type*);
arguments.push_back(GTLCore::Parameter("", type, false, false, GTLCore::Value() ) );
-#ifndef _NDEBUG_
+#ifndef NDEBUG
GTL_DEBUG( *type->d->asArgumentType() << " == " << *FTy->getParamType(i) );
GTL_ASSERT( type->d->asArgumentType() == FTy->getParamType(i) );
#endif
Modified: trunk/OpenGTL/OpenGTL/GTLCore/Macros_p.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/Macros_p.h 2008-08-28 23:13:12 UTC (rev 321)
+++ trunk/OpenGTL/OpenGTL/GTLCore/Macros_p.h 2008-08-30 12:31:47 UTC (rev 322)
@@ -78,5 +78,7 @@
_name_##Deleter instance##_name_ ; \
_name_##Deleter::~_name_##Deleter()
+
+#define UNUSED( _var_) (void)_var_;
#endif