You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.1 KiB

12 months ago
#ifndef _SYSYF_GLOBALVARIABLE_H_
#define _SYSYF_GLOBALVARIABLE_H_
#include "Module.h"
#include "User.h"
#include "Constant.h"
namespace SysYF
{
namespace IR
{
class GlobalVariable : public User
{
private:
bool is_const_ ;
bool is_array_ ;
Ptr<std::vector<int>> array_dim_;
12 months ago
Ptr<Constant> init_val_;
explicit GlobalVariable(std::string name, Ptr<Module> m, Ptr<Type> ty, bool is_const, Ptr<Constant> init_val = nullptr);
void init(std::string name, Ptr<Module> m, Ptr<Type> ty, bool is_const, Ptr<Constant> init_val = nullptr);
public:
static Ptr<GlobalVariable> create(std::string name, Ptr<Module> m, Ptr<Type> ty, bool is_const, Ptr<Constant> init_val);
Ptr<Constant> get_init() { return init_val_; }
bool is_const() { return is_const_; }
bool is_array() { return is_array_; }
void set_array(Ptr<std::vector<int>> array_dim) {
is_array_ = true;
array_dim_ = array_dim;
}
Ptr<std::vector<int>> get_array_dim() {
if (is_array_) return array_dim_;
else return nullptr;
}
12 months ago
std::string print();
};
}
}
#endif //_SYSYF_GLOBALVARIABLE_H_