[opengtl-commits] [247] * cleanup

[ Thread Index | Date Index | More lists.tuxfamily.org/opengtl-commits Archives ]


Revision: 247
Author:   cyrille
Date:     2008-06-27 22:31:32 +0200 (Fri, 27 Jun 2008)

Log Message:
-----------
* cleanup
* add a convenient function to convert pointer to char*

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-26 21:01:17 UTC (rev 246)
+++ trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp	2008-06-27 20:31:32 UTC (rev 247)
@@ -129,73 +129,11 @@
   return 0;
 }
 
-#if 0
-llvm::Value* CodeGenerator::convertValueTo(llvm::BasicBlock* currentBlock, llvm::Value* value, const llvm::Type* type)
+llvm::Value* CodeGenerator::convertPointerToCharP(llvm::BasicBlock* _currentBlock, llvm::Value* _value)
 {
-  llvm::Constant* constant = dynamic_cast<llvm::Constant*>(value);
-  if(constant)
-  {
-    return convertConstantTo( constant, type);
-  }
-  if(value->getType() == type)
-  { // Don't cast the value as it has allready the correct type
-    return value;
-  }
-  GTL_ASSERT(type->isFirstClassType());
-  GTL_ASSERT(value->getType()->isFirstClassType());
-  if( value->getType()->isInteger() and type->isInteger())
-  { // Cast integers between integers
-    return llvm::CastInst::createIntegerCast(value, type, false, "", currentBlock);
-  } else if( value->getType()->isFloatingPoint() and type->isFloatingPoint() )
-  { // Cast floats between floats
-    return llvm::CastInst::createFPCast(value, type, "", currentBlock);
-  } else { // Other casts
-    return llvm::CastInst::create(
-                      llvm::CastInst::getCastOpcode(value, true, type, true), value, type, "", currentBlock ); // TODO support for unsigned
-  }
+  return convertPointerTo( _currentBlock, _value, llvm::IntegerType::get(8) );
 }
 
-llvm::Value* CodeGenerator::convertValueTo(llvm::BasicBlock* _currentBlock, llvm::Value* _value, const Type* _type)
-{
-  return convertValueTo(_currentBlock, _value, _type->data()->type());
-}
-
-llvm::Constant* CodeGenerator::convertConstantTo(llvm::Constant* constant, const llvm::Type* type)
-{
-   if(constant->getType() == type)
-  { // Don't cast the value as it has allready the correct type
-    return constant;
-  }
-  GTL_ASSERT(type->isFirstClassType());
-  GTL_ASSERT(constant->getType()->isFirstClassType());
-  if( constant->getType()->isInteger() and type->isInteger())
-  { // Cast integers between integers
-    if( constant->getType()->getPrimitiveSizeInBits() > type->getPrimitiveSizeInBits() )
-    {
-      return llvm::ConstantExpr::getTrunc(constant, type);
-    } else {
-      return llvm::ConstantExpr::getZExt(constant, type);
-    }
-  } else if( constant->getType()->isFloatingPoint() and type->isFloatingPoint() )
-  { // Cast floats between floats
-    if( constant->getType()->getPrimitiveSizeInBits() > type->getPrimitiveSizeInBits() )
-    {
-      return llvm::ConstantExpr::getFPTrunc(constant, type);
-    } else {
-      return llvm::ConstantExpr::getFPExtend(constant, type);
-    }
-  } else { // Other casts
-    return llvm::ConstantExpr::getCast(
-                      (unsigned)llvm::CastInst::getCastOpcode(constant, true, type, true), constant, type ); // TODO support for unsigned
-  }
-}
-
-llvm::Constant* CodeGenerator::convertConstantTo(llvm::Constant* _constant, const Type* _type)
-{
-  return convertConstantTo( _constant, _type->data()->type());
-}
-#endif
-
 llvm::Value* CodeGenerator::convertPointerTo(llvm::BasicBlock* _currentBlock, llvm::Value* _value, const llvm::Type* _type)
 {
   return new llvm::BitCastInst( _value, llvm::PointerType::get( _type, 0 ), "", _currentBlock );

Modified: trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.h	2008-06-26 21:01:17 UTC (rev 246)
+++ trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.h	2008-06-27 20:31:32 UTC (rev 247)
@@ -89,7 +89,8 @@
       llvm::Function* createFunction( llvm::FunctionType* type, const GTLCore::String& name);
 //       llvm::Value* convertValueTo(llvm::BasicBlock* currentBlock, llvm::Value* value, const llvm::Type* type);
 //       llvm::Constant* convertConstantTo(llvm::Constant* constant, const llvm::Type* type);
-      llvm::Value* convertPointerTo(llvm::BasicBlock* currentBlock, llvm::Value* value, const llvm::Type* type);
+      static llvm::Value* convertPointerToCharP(llvm::BasicBlock* currentBlock, llvm::Value* value);
+      static llvm::Value* convertPointerTo(llvm::BasicBlock* currentBlock, llvm::Value* value, const llvm::Type* type);
       static llvm::Value* convertValueTo(llvm::BasicBlock* currentBlock, llvm::Value* value, const Type* valueType, const Type* type);
       static llvm::Constant* convertConstantTo(llvm::Constant* constant, const Type* constantType, const Type* type);
       static llvm::Value* convertToHalf( GenerationContext& generationContext, llvm::BasicBlock* currentBlock, llvm::Value* value, const Type* _valueType);


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/