2018-12-31 22:47:31 -05:00
|
|
|
#ifndef TDL_INCLUDE_IR_CONSTANT_H
|
|
|
|
#define TDL_INCLUDE_IR_CONSTANT_H
|
|
|
|
|
|
|
|
#include "value.h"
|
|
|
|
|
|
|
|
namespace tdl{
|
|
|
|
namespace ir{
|
|
|
|
|
|
|
|
class type;
|
|
|
|
class context;
|
|
|
|
|
|
|
|
/* Constant */
|
2019-01-03 03:42:10 -05:00
|
|
|
class constant: public user{
|
|
|
|
protected:
|
|
|
|
using user::user;
|
|
|
|
|
2019-01-02 14:37:14 -05:00
|
|
|
public:
|
|
|
|
static constant* get_all_ones_value(type *ty);
|
2019-01-03 03:42:10 -05:00
|
|
|
static constant* get_null_value(type *ty);
|
2018-12-31 22:47:31 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Undef value */
|
|
|
|
class undef_value: public constant{
|
2019-01-03 03:42:10 -05:00
|
|
|
private:
|
|
|
|
undef_value(type *ty);
|
2018-12-31 22:47:31 -05:00
|
|
|
|
|
|
|
public:
|
2019-01-03 03:42:10 -05:00
|
|
|
static undef_value* get(type* ty);
|
2018-12-31 22:47:31 -05:00
|
|
|
};
|
|
|
|
|
2019-01-02 14:37:14 -05:00
|
|
|
/* Constant int */
|
|
|
|
class constant_int: public constant{
|
2019-01-03 03:42:10 -05:00
|
|
|
constant_int(type *ty, uint64_t value);
|
2019-01-02 14:37:14 -05:00
|
|
|
|
2019-01-03 03:42:10 -05:00
|
|
|
public:
|
|
|
|
static constant *get(type *ty, uint64_t value);
|
|
|
|
|
|
|
|
private:
|
|
|
|
uint64_t value_;
|
2019-01-02 14:37:14 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
/* constant fp */
|
|
|
|
class constant_fp: public constant{
|
2019-01-03 03:42:10 -05:00
|
|
|
constant_fp(context &ctx, double value);
|
|
|
|
|
2019-01-02 14:37:14 -05:00
|
|
|
public:
|
2019-01-03 03:42:10 -05:00
|
|
|
static constant* get_negative_zero(type *ty);
|
2019-01-02 14:37:14 -05:00
|
|
|
static constant* get_zero_value_for_negation(type *ty);
|
2019-01-03 03:42:10 -05:00
|
|
|
static constant *get(context &ctx, double v);
|
|
|
|
|
|
|
|
private:
|
|
|
|
double value_;
|
2019-01-02 14:37:14 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-12-31 22:47:31 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|