Goose  Artifact [553df0129c]

Artifact 553df0129c451d54a7e9085e1253b9040e76c58a23c8c5a62cc34bed80260b5a:

  • File bs/codegen/module.h — part of check-in [8574428775] at 2019-07-26 16:57:23 on branch trunk — codegen: generate basic blocks. (user: achavasse size: 1585)

#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