#ifndef _SYSY_MODULE_H_ #define _SYSY_MODULE_H_ #include #include #include #include "Type.h" #include "GlobalVariable.h" #include "Value.h" #include "Function.h" class GlobalVariable; class Module { public: explicit Module(std::string name); ~Module(); Type *get_void_type(); Type *get_label_type(); IntegerType *get_int1_type(); IntegerType *get_int32_type(); FloatType *get_float_type(); PointerType *get_int32_ptr_type(); PointerType *get_float_ptr_type(); PointerType *get_pointer_type(Type *contained); ArrayType *get_array_type(Type *contained, unsigned num_elements); void add_function(Function *f); std::list &get_functions(); void add_global_variable(GlobalVariable* g); std::list &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: std::list global_list_; // The Global Variables in the module std::list 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: IntegerType *int1_ty_; IntegerType *int32_ty_; FloatType *float32_ty_; Type *label_ty_; Type *void_ty_; std::map pointer_map_; std::map, ArrayType *> array_map_; }; #endif // _SYSY_MODULE_H_