mie: implement more ir building functionality
This commit is contained in:
26
mie/const.c
26
mie/const.c
@@ -2,25 +2,13 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
void mie_int_init(struct mie_int *out, long long val, unsigned int nr_bits)
|
||||
static struct mie_type *get_type(struct mie_value *v)
|
||||
{
|
||||
memset(out, 0x0, sizeof *out);
|
||||
|
||||
mie_value_init(&out->i_base.c_base, MIE_VALUE_CONST);
|
||||
|
||||
out->i_base.c_type = MIE_CONST_INT;
|
||||
out->i_value = val;
|
||||
out->i_width = nr_bits;
|
||||
struct mie_const *c = MIE_CONST(v);
|
||||
return c->c_type;
|
||||
}
|
||||
|
||||
struct mie_int *mie_int_create(long long val, unsigned int nr_bits)
|
||||
{
|
||||
struct mie_int *out = malloc(sizeof *out);
|
||||
|
||||
if (!out) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
mie_int_init(out, val, nr_bits);
|
||||
return out;
|
||||
}
|
||||
const struct mie_value_type const_value_type = {
|
||||
.t_id = MIE_VALUE_CONST,
|
||||
.t_get_type = get_type,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user