mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-01-18 14:21:36 +00:00
qbool -> bool
This commit is contained in:
parent
234567cb9f
commit
13ec68bc4f
4 changed files with 45 additions and 47 deletions
20
ast.h
20
ast.h
|
@ -55,9 +55,9 @@ typedef struct
|
|||
* 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;
|
||||
|
@ -80,7 +80,7 @@ struct ast_value_s
|
|||
int vtype;
|
||||
ast_value *next;
|
||||
|
||||
qbool isconst;
|
||||
bool isconst;
|
||||
union {
|
||||
double vfloat;
|
||||
int vint;
|
||||
|
@ -102,7 +102,7 @@ void ast_value_delete(ast_value*);
|
|||
|
||||
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
|
||||
*
|
||||
|
@ -123,14 +123,14 @@ ast_binary* ast_binary_new(lex_ctx_t ctx,
|
|||
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
|
||||
*
|
||||
|
@ -148,7 +148,7 @@ void ast_block_delete(ast_block*);
|
|||
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
|
||||
*
|
||||
|
@ -174,7 +174,7 @@ void ast_function_delete(ast_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
|
||||
*/
|
||||
|
|
6
astir.h
6
astir.h
|
@ -29,7 +29,7 @@
|
|||
|
||||
#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) \
|
||||
|
@ -69,7 +69,7 @@ void Tself##_##mem##_remove(Tself *self, size_t idx) \
|
|||
}
|
||||
|
||||
#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) { \
|
||||
|
@ -116,8 +116,6 @@ MEM_VEC_FUNCTIONS(Tself, Twhat, mem) \
|
|||
_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,
|
||||
|
|
38
ir.c
38
ir.c
|
@ -299,7 +299,7 @@ void ir_instr_delete(ir_instr *self)
|
|||
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)
|
||||
|
@ -369,7 +369,7 @@ void ir_value_set_name(ir_value *self, const char *name)
|
|||
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;
|
||||
|
@ -378,7 +378,7 @@ qbool ir_value_set_float(ir_value *self, float f)
|
|||
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;
|
||||
|
@ -387,7 +387,7 @@ qbool ir_value_set_vector(ir_value *self, vector_t v)
|
|||
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;
|
||||
|
@ -396,7 +396,7 @@ qbool ir_value_set_string(ir_value *self, const char *str)
|
|||
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;
|
||||
|
@ -405,7 +405,7 @@ qbool ir_value_set_int(ir_value *self, int i)
|
|||
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)
|
||||
|
@ -428,7 +428,7 @@ void ir_value_life_insert(ir_value *self, size_t idx, ir_life_entry_t e)
|
|||
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;
|
||||
|
@ -495,7 +495,7 @@ qbool ir_value_life_merge(ir_value *self, size_t s)
|
|||
*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");
|
||||
|
@ -509,7 +509,7 @@ qbool ir_block_create_store_op(ir_block *self, int op, ir_value *target, ir_valu
|
|||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -1057,11 +1057,11 @@ void ir_function_enumerate(ir_function *self)
|
|||
}
|
||||
}
|
||||
|
||||
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++;
|
||||
|
@ -1104,11 +1104,11 @@ static void ir_op_read_write(int op, size_t *read, size_t *write)
|
|||
};
|
||||
}
|
||||
|
||||
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);
|
||||
|
@ -1121,7 +1121,7 @@ static qbool ir_block_living_add_instr(ir_block *self, size_t 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
|
||||
|
@ -1152,11 +1152,11 @@ static void ir_block_life_prop_previous(ir_block* self, ir_block *prev, qbool *c
|
|||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -1223,8 +1223,8 @@ static void ir_block_life_propagate(ir_block *self, ir_block *prev, qbool *chang
|
|||
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... */
|
||||
|
|
28
ir.h
28
ir.h
|
@ -45,7 +45,7 @@ typedef struct ir_value_s {
|
|||
MEM_VECTOR_MAKE(struct ir_instr_s*, writes);
|
||||
|
||||
/* constantvalues */
|
||||
qbool isconst;
|
||||
bool isconst;
|
||||
union {
|
||||
float vfloat;
|
||||
int vint;
|
||||
|
@ -70,19 +70,19 @@ void ir_value_set_name(ir_value*, const char *name);
|
|||
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*,...));
|
||||
|
@ -113,7 +113,7 @@ ir_instr* ir_instr_new(struct ir_block_s *owner, int opcode);
|
|||
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*,...));
|
||||
|
||||
|
@ -122,7 +122,7 @@ typedef struct ir_block_s
|
|||
{
|
||||
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);
|
||||
|
@ -131,7 +131,7 @@ typedef struct ir_block_s
|
|||
|
||||
/* For the temp-allocation */
|
||||
size_t eid;
|
||||
qbool is_return;
|
||||
bool is_return;
|
||||
size_t run_id;
|
||||
|
||||
struct ir_function_s *owner;
|
||||
|
@ -148,8 +148,8 @@ MEM_VECTOR_PROTO_ALL(ir_block, ir_block*, entries)
|
|||
|
||||
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);
|
||||
|
|
Loading…
Reference in a new issue