* Any expression or block returns an ir_value, and needs
* to know the current function.
*/
-typedef qbool ast_expression_codegen(ast_expression*,
- ast_function*,
- ir_value**);
+typedef bool ast_expression_codegen(ast_expression*,
+ ast_function*,
+ ir_value**);
typedef struct
{
ast_node_common node;
int vtype;
ast_value *next;
- qbool isconst;
+ bool isconst;
union {
double vfloat;
int vint;
void ast_value_set_name(ast_value*, const char *name);
-qbool ast_value_codegen(ast_value*, ast_function*, ir_value**);
+bool ast_value_codegen(ast_value*, ast_function*, ir_value**);
/* Binary
*
void ast_binary_delete(ast_binary*);
/* hmm, seperate functions? */
-qbool ast_bin_add_codegen(ast_binary*, ir_function*, ir_value**);
+bool ast_bin_add_codegen(ast_binary*, ir_function*, ir_value**);
/* ... */
/* maybe for this one */
-qbool ast_bin_store_codegen(ast_binary*, ir_function*, ir_value**);
+bool ast_bin_store_codegen(ast_binary*, ir_function*, ir_value**);
/* could decide what to use */
-qbool ast_binary_codegen(ast_binary*, ir_function*, ir_value**);
+bool ast_binary_codegen(ast_binary*, ir_function*, ir_value**);
/* Blocks
*
MEM_VECTOR_PROTO(ast_block, ast_value*, locals);
MEM_VECTOR_PROTO(ast_block, ast_expression*, exprs);
-qbool ast_block_codegen(ast_block*, ir_function*, ir_value**);
+bool ast_block_codegen(ast_block*, ir_function*, ir_value**);
/* Function
*
MEM_VECTOR_PROTO(ast_function, ast_block*, blocks);
-qbool ast_function_codegen(ast_function *self, ir_builder *builder);
+bool ast_function_codegen(ast_function *self, ir_builder *builder);
/* Expression union
*/
#define MEM_VECTOR_PROTO_ALL(Towner, Tmem, mem) \
MEM_VECTOR_PROTO(Towner, Tmem, mem) \
- qbool Towner##_##mem##_find(Towner*, Tmem, size_t*); \
+ bool Towner##_##mem##_find(Towner*, Tmem, size_t*); \
void Towner##_##mem##_clear(Towner*);
#define MEM_VECTOR_MAKE(Twhat, name) \
}
#define _MEM_VEC_FUN_FIND(Tself, Twhat, mem) \
-qbool Tself##_##mem##_find(Tself *self, Twhat obj, size_t *idx) \
+bool Tself##_##mem##_find(Tself *self, Twhat obj, size_t *idx) \
{ \
size_t i; \
for (i = 0; i < self->mem##_count; ++i) { \
_MEM_VEC_FUN_CLEAR(Tself, mem) \
_MEM_VEC_FUN_FIND(Tself, Twhat, mem)
-typedef enum { false, true } qbool;
-
enum qc_types {
/* Main QC types */
qc_void,
mem_d(self);
}
-void ir_instr_op(ir_instr *self, int op, ir_value *v, qbool writing)
+void ir_instr_op(ir_instr *self, int op, ir_value *v, bool writing)
{
if (self->_ops[op]) {
if (writing)
self->name = util_strdup(name);
}
-qbool ir_value_set_float(ir_value *self, float f)
+bool ir_value_set_float(ir_value *self, float f)
{
if (self->vtype != qc_float)
return false;
return true;
}
-qbool ir_value_set_vector(ir_value *self, vector_t v)
+bool ir_value_set_vector(ir_value *self, vector_t v)
{
if (self->vtype != qc_vector)
return false;
return true;
}
-qbool ir_value_set_string(ir_value *self, const char *str)
+bool ir_value_set_string(ir_value *self, const char *str)
{
if (self->vtype != qc_string)
return false;
return true;
}
-qbool ir_value_set_int(ir_value *self, int i)
+bool ir_value_set_int(ir_value *self, int i)
{
if (self->vtype != qc_int)
return false;
return true;
}
-qbool ir_value_lives(ir_value *self, size_t at)
+bool ir_value_lives(ir_value *self, size_t at)
{
size_t i;
for (i = 0; i < self->life_count; ++i)
self->life[idx] = e;
}
-qbool ir_value_life_merge(ir_value *self, size_t s)
+bool ir_value_life_merge(ir_value *self, size_t s)
{
size_t i;
ir_life_entry_t *life = NULL;
*IR main operations
*/
-qbool ir_block_create_store_op(ir_block *self, int op, ir_value *target, ir_value *what)
+bool ir_block_create_store_op(ir_block *self, int op, ir_value *target, ir_value *what)
{
if (target->store == store_value) {
fprintf(stderr, "cannot store to an SSA value\n");
}
}
-qbool ir_block_create_store(ir_block *self, ir_value *target, ir_value *what)
+bool ir_block_create_store(ir_block *self, ir_value *target, ir_value *what)
{
int op = 0;
int vtype;
}
}
-static void ir_block_life_propagate(ir_block *b, ir_block *prev, qbool *changed);
+static void ir_block_life_propagate(ir_block *b, ir_block *prev, bool *changed);
void ir_function_calculate_liferanges(ir_function *self)
{
size_t i;
- qbool changed;
+ bool changed;
do {
self->run_id++;
};
}
-static qbool ir_block_living_add_instr(ir_block *self, size_t eid)
+static bool ir_block_living_add_instr(ir_block *self, size_t eid)
{
size_t i;
- qbool changed = false;
- qbool tempbool;
+ bool changed = false;
+ bool tempbool;
for (i = 0; i != self->living_count; ++i)
{
tempbool = ir_value_life_merge(self->living[i], eid);
return changed;
}
-static void ir_block_life_prop_previous(ir_block* self, ir_block *prev, qbool *changed)
+static void ir_block_life_prop_previous(ir_block* self, ir_block *prev, bool *changed)
{
size_t i;
/* values which have been read in a previous iteration are now
}
}
-static void ir_block_life_propagate(ir_block *self, ir_block *prev, qbool *changed)
+static void ir_block_life_propagate(ir_block *self, ir_block *prev, bool *changed)
{
ir_instr *instr;
ir_value *value;
- qbool tempbool;
+ bool tempbool;
size_t i, o, p, rd;
/* bitmasks which operands are read from or written to */
size_t read, write;
if (write & (1<<o))
{
size_t idx, readidx;
- qbool in_living = ir_block_living_find(self, value, &idx);
- qbool in_reads = new_reads_t_v_find(&new_reads, value, &readidx);
+ bool in_living = ir_block_living_find(self, value, &idx);
+ bool in_reads = new_reads_t_v_find(&new_reads, value, &readidx);
if (!in_living && !in_reads)
{
/* If the value isn't alive it hasn't been read before... */
MEM_VECTOR_MAKE(struct ir_instr_s*, writes);
/* constantvalues */
- qbool isconst;
+ bool isconst;
union {
float vfloat;
int vint;
MEM_VECTOR_PROTO(ir_value, struct ir_instr_s*, reads)
MEM_VECTOR_PROTO(ir_value, struct ir_instr_s*, writes)
-qbool ir_value_set_float(ir_value*, float f);
-qbool ir_value_set_int(ir_value*, int i);
-qbool ir_value_set_string(ir_value*, const char *s);
-qbool ir_value_set_vector(ir_value*, vector_t v);
-/*qbool ir_value_set_pointer_v(ir_value*, ir_value* p); */
-/*qbool ir_value_set_pointer_i(ir_value*, int i); */
+bool ir_value_set_float(ir_value*, float f);
+bool ir_value_set_int(ir_value*, int i);
+bool ir_value_set_string(ir_value*, const char *s);
+bool ir_value_set_vector(ir_value*, vector_t v);
+/*bool ir_value_set_pointer_v(ir_value*, ir_value* p); */
+/*bool ir_value_set_pointer_i(ir_value*, int i); */
MEM_VECTOR_PROTO(ir_value, ir_life_entry_t, life)
/* merge an instruction into the life-range */
/* returns false if the lifepoint was already known */
-qbool ir_value_life_merge(ir_value*, size_t);
+bool ir_value_life_merge(ir_value*, size_t);
/* check if a value lives at a specific point */
-qbool ir_value_lives(ir_value*, size_t);
+bool ir_value_lives(ir_value*, size_t);
void ir_value_dump(ir_value*, int (*oprintf)(const char*,...));
void ir_value_dump_life(ir_value *self, int (*oprintf)(const char*,...));
void ir_instr_delete(ir_instr*);
MEM_VECTOR_PROTO(ir_value, ir_phi_entry_t, phi)
-void ir_instr_op(ir_instr*, int op, ir_value *value, qbool writing);
+void ir_instr_op(ir_instr*, int op, ir_value *value, bool writing);
void ir_instr_dump(ir_instr* in, char *ind, int (*oprintf)(const char*,...));
{
char *label;
lex_ctx_t context;
- qbool final; /* once a jump is added we're done */
+ bool final; /* once a jump is added we're done */
MEM_VECTOR_MAKE(ir_instr*, instr);
MEM_VECTOR_MAKE(struct ir_block_s*, entries);
/* For the temp-allocation */
size_t eid;
- qbool is_return;
+ bool is_return;
size_t run_id;
struct ir_function_s *owner;
ir_value* ir_block_create_binop(ir_block*, const char *label, int op,
ir_value *left, ir_value *right);
-qbool ir_block_create_store_op(ir_block*, int op, ir_value *target, ir_value *what);
-qbool ir_block_create_store(ir_block*, ir_value *target, ir_value *what);
+bool ir_block_create_store_op(ir_block*, int op, ir_value *target, ir_value *what);
+bool ir_block_create_store(ir_block*, ir_value *target, ir_value *what);
ir_value* ir_block_create_add(ir_block*, const char *label, ir_value *l, ir_value *r);
ir_value* ir_block_create_sub(ir_block*, const char *label, ir_value *l, ir_value *r);