[opengtl-commits] [559] add a code generator function to allocate memory

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


Revision: 559
Author:   cyrille
Date:     2009-02-27 14:30:01 +0100 (Fri, 27 Feb 2009)

Log Message:
-----------
add a code generator function to allocate memory

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	2009-02-22 20:00:49 UTC (rev 558)
+++ trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp	2009-02-27 13:30:01 UTC (rev 559)
@@ -728,3 +728,13 @@
   new llvm::StoreInst( val, pointerCF, "CodeGenerator::incrementCountFieldOf", _currentBlock );
   return val;
 }
+
+llvm::Value* CodeGenerator::allocateMemory( const llvm::Type* _type, llvm::Value* _size, llvm::BasicBlock* _bb)
+{
+  return new llvm::MallocInst( _type, _size, "", _bb);
+}
+
+void CodeGenerator::allocateMemory( llvm::Value* _ptr, llvm::BasicBlock* _bb)
+{
+  new llvm::FreeInst( _ptr, _bb );
+}

Modified: trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.h	2009-02-22 20:00:49 UTC (rev 558)
+++ trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.h	2009-02-27 13:30:01 UTC (rev 559)
@@ -266,6 +266,9 @@
     public:
       GTLCore::ExpressionResult callFunction( GenerationContext& _gc, llvm::BasicBlock* _bb, const GTLCore::Function* _function, const std::list<AST::Expression*>& m_arguments );
     private:
+      llvm::Value* allocateMemory( const llvm::Type* _type, llvm::Value* _size, llvm::BasicBlock* _bb);
+      void allocateMemory( llvm::Value* _ptr, llvm::BasicBlock* _bb);
+    private:
       static llvm::Value* createComparisonExpression(llvm::BasicBlock* currentBlock, llvm::Value* lhs, const Type* lhsType, llvm::Value* rhs, const Type* rhsType, unsigned int unsignedIntegerPred, unsigned int signedIntegerPred, unsigned int floatPred);
       static ExpressionResult createComparisonExpression( llvm::BasicBlock* currentBlock, ExpressionResult lhs, const Type* lhsType, ExpressionResult rhs, const Type* rhsType, unsigned int unsignedIntegerPred, unsigned int signedIntegerPred, unsigned int floatPred);
       static llvm::Constant* createComparisonExpression( llvm::Constant* lhs, const Type* lhsType, llvm::Constant* rhs, const Type* rhsType, unsigned int unsignedIntegerPred, unsigned int signedIntegerPred, unsigned int floatPred);


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