-
Hyperbola authorede1afdd04
#ifndef MISAKA_FUNCTION
#define MISAKA_FUNCTION
#include <vector>
#include <list>
#include "User.h"
#include "Module.h"
#include "BasicBlock.h"
#include "Type.h"
class Module;
class Argument;
class BasicBlock;
class Type;
class FunctionType;
class Function : public Value
{
public:
Function(FunctionType *type, const std::string &name, Module *parent);
~Function() = default;
static Function *__init__(FunctionType *type, const std::string &name, Module *parent);
std::list<Argument *>::iterator arg_begin() { return argument_list.begin(); }
std::list<Argument *>::iterator arg_end() { return argument_list.end(); }
Module *get_parent();
BasicBlock *get_entry_block() { return *basic_blocks.begin(); }
std::list<BasicBlock *> &get_basic_blocks();
std::list<Argument *> &get_arguments();
void add_basic_block(BasicBlock *bb);
void remove_basic_block(BasicBlock *bb);
// FunctionType *getSelfFuncType();
Type *get_return_type();
std::string print();
int get_num_of_arguments(){return argument_list.size();}
bool is_empty(){return basic_blocks.empty();}
void set_name_of_instruction();
private:
Module *parent;
std::list<BasicBlock *> basic_blocks;
std::list<Argument *> argument_list;
Type *ret_type;
// std::vector<std::set<Value *>> vreg_set_;
// std::set<int> unused_reg_num_;
unsigned seq_cnt;
// std::set<Function *> callee_set_;
// std::set<int> args_has_side_effect_, args_effected_by_side_effect_;
// std::set<Value *> local_array_has_side_effect_, global_var_has_side_effect_, global_array_has_side_effect_;
// std::set<Value *> local_array_effected_by_side_effect_, global_var_effected_by_side_effect_, global_array_effected_by_side_effect_;
};
class Argument : public Value
{
public:
Argument(Type *type, Function *parent);
~Argument() = default;
Function *get_parent();
std::string print();
7172737475
private:
Function *parent;
};
#endif