Module.h 2.19 KiB
#ifndef MISAKA_MODULE_H
#define MISAKA_MODULE_H
#include <map>
#include <string>
#include "Type.h"
#include "GlobalVariable.h"
#include "Value.h"
#include "Function.h"
class GlobalVariable;
class Module
public:
    void __init__();
    explicit Module(const std::string &name);
    ~Module();
    PointerType *get_pointer_type(Type *type, bool is_ptr_variable=false);
    ArrayType *get_array_type(Type *type, unsigned arg_num);
    IntType *get_int1_type();
    IntType *get_int32_type();
    FloatType *get_float_type();
    Type *get_void_type();
    Type *get_label_type();
    Type *get_va_arg_type();
    void set_module_name(std::string module_name);
    std::string get_module_name();
    void set_print_name();
    void set_file_name(std::string file_name);
    std::string get_file_name();
    std::list<GlobalVariable *> get_global_variable_list() { return global_var_list; }
    std::list<Function *> get_function_list() { return function_list; }
    void add_global_variable(GlobalVariable *gvar);
    void add_function(Function *func);
    void remove_global_variable(GlobalVariable *gvar);
    void remove_function(Function *func);
    std::string print();
    //Function to ASM::Func map--used in ActiveVariable CFGAnalyse and RegAlloc
    // void set_func_conv_map(std::map<Function*, ASM::Func*> temp_map){func_conv_map=temp_map;}
    // std::map<Function*, ASM::Func*> get_func_conv_map(){return func_conv_map;}
private:
    std::string module_name;
    std::string file_name;
    //类型
    IntType *int_1_type;
    IntType *int_32_type;
    FloatType *float_type;
    Type *void_type;
    Type *label_type;
    Type *va_arg_type;
    std::map<std::pair<bool, Type *>, PointerType *> pointer_map;
    std::map<std::pair<int, Type *>, ArrayType *> array_map;
    std::list<GlobalVariable *> global_var_list;
    std::list<Function *> function_list; // The Functions in the module
    // std::map<std::string, Value*> value_sym_;   // Symbol table for values
    // std::map<Instruction::OpID, std::string> instr_id2string_;   // Instruction from opid to string
    //Function to ASM::Func map--used in ActiveVariable CFGAnalyse and RegAlloc
7172737475
//std::map<Function*, ASM::Func*> func_conv_map; }; #endif