#ifndef EMPATHY_CODEGEN_MODULE_H
#define EMPATHY_CODEGEN_MODULE_H
namespace empathy::codegen
{
class Module
{
public:
Module( const string& name );
void dumpAsLlvmIr( const string& filename ) const;
llvm::FunctionType* getOrCreateFuncType( const Context& c, const builtins::FuncType& ftype );
llvm::Function* buildFuncProto( const Context& c, const builtins::Func& func, const string& name );
llvm::Function* getOrCreateFunc( const Context& c, const builtins::Func& func );
llvm::Function* getOrCreateFunc( const Context& c, const builtins::Func& func, const string& name );
private:
llvm::BasicBlock* buildBasicBlock( const Context& c, llvm::Function* pllvmFunc, const ptr< llr::BasicBlock >& pBB );
llvm::Value* buildValue( const Context& c, llvm::Function* pllvmFunc, const Value& val );
llvm::Value* buildInstruction( const Context& c, llvm::Function* pllvmFunc, const llr::Instruction& instr );
llvm::Value* buildInstruction( const Context& c, llvm::Function* pllvmFunc, const llr::GetArg& ga );
llvm::Value* buildInstruction( const Context& c, llvm::Function* pllvmFunc, const llr::Call& call );
bool buildTerminator( const Context& c, llvm::Function* pllvmFunc, const llr::Terminator& terminator );
bool buildTerminator( const Context& c, llvm::Function* pllvmFunc, const llr::Ret& r );
llvm::Module m_llvmModule;
llvm::IRBuilder<> m_llvmBuilder;
};
}
#endif