#ifndef _SYSYF_MODULE_H_ #define _SYSYF_MODULE_H_ #include #include #include #include "internal_types.h" #include "internal_macros.h" #include "Type.h" #include "GlobalVariable.h" #include "Value.h" #include "Function.h" namespace SysYF { namespace IR { class GlobalVariable; class Module; class Module : public std::enable_shared_from_this { public: static Ptr create(std::string name); ~Module() = default; Ptr get_void_type(); Ptr get_label_type(); Ptr get_int1_type(); Ptr get_int32_type(); Ptr get_float_type(); Ptr get_int32_ptr_type(); Ptr get_float_ptr_type(); Ptr get_pointer_type(Ptr contained); Ptr get_array_type(Ptr contained, unsigned num_elements); void add_function(Ptr f); PtrList &get_functions(); void add_global_variable(Ptr g); PtrList &get_global_variable(); std::string get_instr_op_name( Instruction::OpID instr ) { return instr_id2string_[instr]; } void set_print_name(); void set_file_name(std::string name){source_file_name_ = name;} std::string get_file_name(){return source_file_name_;} virtual std::string print(); private: explicit Module(std::string name); void init(std::string name); PtrList global_list_; // The Global Variables in the module PtrList function_list_; // The Functions in the module std::map> value_sym_; // Symbol table for values std::map instr_id2string_; // Instruction from opid to string std::string module_name_; // Human readable identifier for the module std::string source_file_name_; // Original source file name for module, for test and debug private: Ptr int1_ty_; Ptr int32_ty_; Ptr float32_ty_; Ptr label_ty_; Ptr void_ty_; std::map , Ptr> pointer_map_; std::map ,int>, Ptr > array_map_; }; } } #endif // _SYSYF_MODULE_H_