-onlytrans \
-predboolint \
-boolops \
- -exportlocal \
-incondefs \
-macroredef \
-retvalint \
ast_node_init((ast_node*)self, ctx, TYPE_##T); \
( (ast_node*)self )->node.destroy = (ast_node_delete*)destroyfn
+/*
+ * forward declarations, these need not be in ast.h for obvious
+ * static reasons.
+ */
+static bool ast_member_codegen(ast_member*, ast_function*, bool lvalue, ir_value**);
+static void ast_array_index_delete(ast_array_index*);
+static bool ast_array_index_codegen(ast_array_index*, ast_function*, bool lvalue, ir_value**);
+static void ast_store_delete(ast_store*);
+static bool ast_store_codegen(ast_store*, ast_function*, bool lvalue, ir_value**);
+static void ast_ifthen_delete(ast_ifthen*);
+static bool ast_ifthen_codegen(ast_ifthen*, ast_function*, bool lvalue, ir_value**);
+static void ast_ternary_delete(ast_ternary*);
+static bool ast_ternary_codegen(ast_ternary*, ast_function*, bool lvalue, ir_value**);
+static void ast_loop_delete(ast_loop*);
+static bool ast_loop_codegen(ast_loop*, ast_function*, bool lvalue, ir_value**);
+static void ast_breakcont_delete(ast_breakcont*);
+static bool ast_breakcont_codegen(ast_breakcont*, ast_function*, bool lvalue, ir_value**);
+static void ast_switch_delete(ast_switch*);
+static bool ast_switch_codegen(ast_switch*, ast_function*, bool lvalue, ir_value**);
+static void ast_label_delete(ast_label*);
+static void ast_label_register_goto(ast_label*, ast_goto*);
+static bool ast_label_codegen(ast_label*, ast_function*, bool lvalue, ir_value**);
+static bool ast_goto_codegen(ast_goto*, ast_function*, bool lvalue, ir_value**);
+static void ast_goto_delete(ast_goto*);
+static void ast_call_delete(ast_call*);
+static bool ast_call_codegen(ast_call*, ast_function*, bool lvalue, ir_value**);
+static bool ast_block_codegen(ast_block*, ast_function*, bool lvalue, ir_value**);
+static void ast_unary_delete(ast_unary*);
+static bool ast_unary_codegen(ast_unary*, ast_function*, bool lvalue, ir_value**);
+static void ast_entfield_delete(ast_entfield*);
+static bool ast_entfield_codegen(ast_entfield*, ast_function*, bool lvalue, ir_value**);
+static void ast_return_delete(ast_return*);
+static bool ast_return_codegen(ast_return*, ast_function*, bool lvalue, ir_value**);
+static void ast_binstore_delete(ast_binstore*);
+static bool ast_binstore_codegen(ast_binstore*, ast_function*, bool lvalue, ir_value**);
+static void ast_binary_delete(ast_binary*);
+static bool ast_binary_codegen(ast_binary*, ast_function*, bool lvalue, ir_value**);
/* It must not be possible to get here. */
static GMQCC_NORETURN void _ast_node_destroy(ast_node *self)
buf[pos] = 0;
}
+static bool ast_value_codegen(ast_value *self, ast_function *func, bool lvalue, ir_value **out);
ast_value* ast_value_new(lex_ctx ctx, const char *name, int t)
{
ast_instantiate(ast_value, ctx, ast_value_delete);
mem_d(self);
}
-void ast_label_register_goto(ast_label *self, ast_goto *g)
+static void ast_label_register_goto(ast_label *self, ast_goto *g)
{
vec_push(self->gotos, g);
}
mem_d(self);
}
-const char* ast_function_label(ast_function *self, const char *prefix)
+static const char* ast_function_label(ast_function *self, const char *prefix)
{
size_t id;
size_t len;
* But I can't imagine a pituation where the output is truly unnecessary.
*/
-void _ast_codegen_output_type(ast_expression_common *self, ir_value *out)
+static void _ast_codegen_output_type(ast_expression_common *self, ir_value *out)
{
if (out->vtype == TYPE_FIELD)
out->fieldtype = self->next->expression.vtype;
return false;
}
-bool ast_local_codegen(ast_value *self, ir_function *func, bool param)
+static bool ast_local_codegen(ast_value *self, ir_function *func, bool param)
{
ir_value *v = NULL;
/*
* Copyright (C) 2012, 2013
* Wolfgang Bumiller
+ * Dale Weiler
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
bool ast_value_set_name(ast_value*, const char *name);
+/*
bool ast_value_codegen(ast_value*, ast_function*, bool lvalue, ir_value**);
bool ast_local_codegen(ast_value *self, ir_function *func, bool isparam);
+*/
+
bool ast_global_codegen(ast_value *self, ir_builder *ir, bool isfield);
void ast_value_params_add(ast_value*, ast_value*);
int op,
ast_expression *left,
ast_expression *right);
-void ast_binary_delete(ast_binary*);
-
-bool ast_binary_codegen(ast_binary*, ast_function*, bool lvalue, ir_value**);
/* Binstore
*
int op,
ast_expression *left,
ast_expression *right);
-void ast_binstore_delete(ast_binstore*);
-
-bool ast_binstore_codegen(ast_binstore*, ast_function*, bool lvalue, ir_value**);
/* Unary
*
ast_unary* ast_unary_new(lex_ctx ctx,
int op,
ast_expression *expr);
-void ast_unary_delete(ast_unary*);
-
-bool ast_unary_codegen(ast_unary*, ast_function*, bool lvalue, ir_value**);
/* Return
*
};
ast_return* ast_return_new(lex_ctx ctx,
ast_expression *expr);
-void ast_return_delete(ast_return*);
-
-bool ast_return_codegen(ast_return*, ast_function*, bool lvalue, ir_value**);
/* Entity-field
*
};
ast_entfield* ast_entfield_new(lex_ctx ctx, ast_expression *entity, ast_expression *field);
ast_entfield* ast_entfield_new_force(lex_ctx ctx, ast_expression *entity, ast_expression *field, const ast_expression *outtype);
-void ast_entfield_delete(ast_entfield*);
-
-bool ast_entfield_codegen(ast_entfield*, ast_function*, bool lvalue, ir_value**);
/* Member access:
*
void ast_member_delete(ast_member*);
bool ast_member_set_name(ast_member*, const char *name);
-bool ast_member_codegen(ast_member*, ast_function*, bool lvalue, ir_value**);
/* Array index access:
*
ast_expression *index;
};
ast_array_index* ast_array_index_new(lex_ctx ctx, ast_expression *array, ast_expression *index);
-void ast_array_index_delete(ast_array_index*);
-
-bool ast_array_index_codegen(ast_array_index*, ast_function*, bool lvalue, ir_value**);
/* Store
*
};
ast_store* ast_store_new(lex_ctx ctx, int op,
ast_expression *d, ast_expression *s);
-void ast_store_delete(ast_store*);
-
-bool ast_store_codegen(ast_store*, ast_function*, bool lvalue, ir_value**);
/* If
*
ast_expression *on_false;
};
ast_ifthen* ast_ifthen_new(lex_ctx ctx, ast_expression *cond, ast_expression *ontrue, ast_expression *onfalse);
-void ast_ifthen_delete(ast_ifthen*);
-
-bool ast_ifthen_codegen(ast_ifthen*, ast_function*, bool lvalue, ir_value**);
/* Ternary expressions...
*
ast_expression *on_false;
};
ast_ternary* ast_ternary_new(lex_ctx ctx, ast_expression *cond, ast_expression *ontrue, ast_expression *onfalse);
-void ast_ternary_delete(ast_ternary*);
-
-bool ast_ternary_codegen(ast_ternary*, ast_function*, bool lvalue, ir_value**);
/* A general loop node
*
ast_expression *postcond, bool post_not,
ast_expression *increment,
ast_expression *body);
-void ast_loop_delete(ast_loop*);
-
-bool ast_loop_codegen(ast_loop*, ast_function*, bool lvalue, ir_value**);
/* Break/Continue
*/
unsigned int levels;
};
ast_breakcont* ast_breakcont_new(lex_ctx ctx, bool iscont, unsigned int levels);
-void ast_breakcont_delete(ast_breakcont*);
-
-bool ast_breakcont_codegen(ast_breakcont*, ast_function*, bool lvalue, ir_value**);
/* Switch Statements
*
};
ast_switch* ast_switch_new(lex_ctx ctx, ast_expression *op);
-void ast_switch_delete(ast_switch*);
-
-bool ast_switch_codegen(ast_switch*, ast_function*, bool lvalue, ir_value**);
/* Label nodes
*
};
ast_label* ast_label_new(lex_ctx ctx, const char *name, bool undefined);
-void ast_label_delete(ast_label*);
-void ast_label_register_goto(ast_label*, ast_goto*);
-
-bool ast_label_codegen(ast_label*, ast_function*, bool lvalue, ir_value**);
/* GOTO nodes
*
};
ast_goto* ast_goto_new(lex_ctx ctx, const char *name);
-void ast_goto_delete(ast_goto*);
void ast_goto_set_label(ast_goto*, ast_label*);
-bool ast_goto_codegen(ast_goto*, ast_function*, bool lvalue, ir_value**);
-
/* CALL node
*
* Contains an ast_expression as target, rather than an ast_function/value.
};
ast_call* ast_call_new(lex_ctx ctx,
ast_expression *funcexpr);
-void ast_call_delete(ast_call*);
-bool ast_call_codegen(ast_call*, ast_function*, bool lvalue, ir_value**);
bool ast_call_check_types(ast_call*);
/* Blocks
ast_block* ast_block_new(lex_ctx ctx);
void ast_block_delete(ast_block*);
void ast_block_set_type(ast_block*, ast_expression *from);
-
-bool ast_block_codegen(ast_block*, ast_function*, bool lvalue, ir_value**);
void ast_block_collect(ast_block*, ast_expression*);
bool GMQCC_WARN ast_block_add_expr(ast_block*, ast_expression*);
/* For "optimized" builds this can just keep returning "foo"...
* or whatever...
*/
-const char* ast_function_label(ast_function*, const char *prefix);
+/*const char* ast_function_label(ast_function*, const char *prefix);*/
bool ast_function_codegen(ast_function *self, ir_builder *builder);
bool ast_generate_accessors(ast_value *asvalue, ir_builder *ir);
* for reporting of file:line based on lexer context, These are used
* heavily in the parser/ir/ast.
*/
-void con_vprintmsg_c(int level, const char *name, size_t line, const char *msgtype, const char *msg, va_list ap, const char *condname) {
+static void con_vprintmsg_c(int level, const char *name, size_t line, const char *msgtype, const char *msg, va_list ap, const char *condname) {
/* color selection table */
static int sel[] = {
CON_WHITE,
static uint32_t ftepp_predef_randval = 0;
/* __DATE__ */
-char *ftepp_predef_date(lex_file *context) {
+static char *ftepp_predef_date(lex_file *context) {
struct tm *itime = NULL;
time_t rtime;
char *value = (char*)mem_a(82);
}
/* __TIME__ */
-char *ftepp_predef_time(lex_file *context) {
+static char *ftepp_predef_time(lex_file *context) {
struct tm *itime = NULL;
time_t rtime;
char *value = (char*)mem_a(82);
}
/* __LINE__ */
-char *ftepp_predef_line(lex_file *context) {
+static char *ftepp_predef_line(lex_file *context) {
char *value;
util_asprintf(&value, "%d", (int)context->line);
return value;
}
/* __FILE__ */
-char *ftepp_predef_file(lex_file *context) {
+static char *ftepp_predef_file(lex_file *context) {
size_t length = strlen(context->name) + 3; /* two quotes and a terminator */
char *value = (char*)mem_a(length);
util_snprintf(value, length, "\"%s\"", context->name);
return value;
}
/* __COUNTER_LAST__ */
-char *ftepp_predef_counterlast(lex_file *context) {
+static char *ftepp_predef_counterlast(lex_file *context) {
char *value;
util_asprintf(&value, "%u", ftepp_predef_countval);
return value;
}
/* __COUNTER__ */
-char *ftepp_predef_counter(lex_file *context) {
+static char *ftepp_predef_counter(lex_file *context) {
char *value;
ftepp_predef_countval ++;
util_asprintf(&value, "%u", ftepp_predef_countval);
return value;
}
/* __RANDOM__ */
-char *ftepp_predef_random(lex_file *context) {
+static char *ftepp_predef_random(lex_file *context) {
char *value;
ftepp_predef_randval = (util_rand() % 0xFF) + 1;
util_asprintf(&value, "%u", ftepp_predef_randval);
return value;
}
/* __RANDOM_LAST__ */
-char *ftepp_predef_randomlast(lex_file *context) {
+static char *ftepp_predef_randomlast(lex_file *context) {
char *value;
util_asprintf(&value, "%u", ftepp_predef_randval);
return value;
}
/* __TIMESTAMP__ */
-char *ftepp_predef_timestamp(lex_file *context) {
+static char *ftepp_predef_timestamp(lex_file *context) {
struct stat finfo;
char *find;
char *value;
const char *alias;
} intrin_t;
-ht intrin_intrinsics() {
+static ht intrin_intrinsics() {
static ht intrinsics = NULL;
if (!intrinsics)
intrinsics = util_htnew(PARSER_HT_SIZE);
vec_push(parser->globals, (ast_expression*)(VALUE)); \
} while (0)
-
-ast_expression *intrin_func (parser_t *parser, const char *name);
-
#define QC_M_E 2.71828182845905
-ast_expression *intrin_pow(parser_t *parser) {
+static ast_expression *intrin_func(parser_t *parser, const char *name);
+static ast_expression *intrin_pow (parser_t *parser) {
/*
* float pow(float x, float y) {
* float local = 1.0f;
return (ast_expression*)value;
}
-ast_expression *intrin_mod(parser_t *parser) {
+static ast_expression *intrin_mod(parser_t *parser) {
/*
* float mod(float x, float y) {
* return x - y * floor(x / y);
return (ast_expression*)value;
}
-ast_expression *intrin_exp(parser_t *parser) {
+static ast_expression *intrin_exp(parser_t *parser) {
/*
* float exp(float x) {
* return pow(QC_M_E, x);
return (ast_expression*)value;
}
-ast_expression *intrin_isnan(parser_t *parser) {
+static ast_expression *intrin_isnan(parser_t *parser) {
/*
* float isnan(float x) {
* float local;
}
-ast_expression *intrin_func(parser_t *parser, const char *name) {
+static ast_expression *intrin_func(parser_t *parser, const char *name) {
static bool init = false;
size_t i = 0;
void *find;
/*
* Copyright (C) 2012, 2013
* Wolfgang Bumiller
+ * Dale Weiler
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
};
/* protos */
-static ir_value* ir_gen_extparam_proto(ir_builder *ir);
-static void ir_gen_extparam (code_t *, ir_builder *ir);
-
+static ir_value* ir_value_var(const char *name, int st, int vtype);
+static bool ir_value_set_name(ir_value*, const char *name);
+static void ir_value_dump(ir_value*, int (*oprintf)(const char*,...));
+
+static ir_value* ir_gen_extparam_proto(ir_builder *ir);
+static void ir_gen_extparam (code_t *, ir_builder *ir);
+
+static bool ir_builder_set_name(ir_builder *self, const char *name);
+
+static ir_function* ir_function_new(struct ir_builder_s *owner, int returntype);
+static bool ir_function_set_name(ir_function*, const char *name);
+static void ir_function_delete(ir_function*);
+static void ir_function_dump(ir_function*, char *ind, int (*oprintf)(const char*,...));
+
+static ir_value* ir_block_create_general_instr(ir_block *self, lex_ctx, const char *label,
+ int op, ir_value *a, ir_value *b, int outype);
+static void ir_block_delete(ir_block*);
+static ir_block* ir_block_new(struct ir_function_s *owner, const char *label);
+static bool GMQCC_WARN ir_block_create_store(ir_block*, lex_ctx, ir_value *target, ir_value *what);
+static bool ir_block_set_label(ir_block*, const char *label);
+static void ir_block_dump(ir_block*, char *ind, int (*oprintf)(const char*,...));
+
+static bool ir_instr_op(ir_instr*, int op, ir_value *value, bool writing);
+static void ir_instr_delete(ir_instr*);
+static void ir_instr_dump(ir_instr* in, char *ind, int (*oprintf)(const char*,...));
/* error functions */
static void irerror(lex_ctx ctx, const char *msg, ...)
* Vector utility functions
*/
-bool GMQCC_WARN vec_ir_value_find(ir_value **vec, const ir_value *what, size_t *idx)
+static bool GMQCC_WARN vec_ir_value_find(ir_value **vec, const ir_value *what, size_t *idx)
{
size_t i;
size_t len = vec_size(vec);
return false;
}
-bool GMQCC_WARN vec_ir_block_find(ir_block **vec, ir_block *what, size_t *idx)
+static bool GMQCC_WARN vec_ir_block_find(ir_block **vec, ir_block *what, size_t *idx)
{
size_t i;
size_t len = vec_size(vec);
return false;
}
-bool GMQCC_WARN vec_ir_instr_find(ir_instr **vec, ir_instr *what, size_t *idx)
+static bool GMQCC_WARN vec_ir_instr_find(ir_instr **vec, ir_instr *what, size_t *idx)
{
size_t i;
size_t len = vec_size(vec);
return !!self->name;
}
-ir_function* ir_builder_get_function(ir_builder *self, const char *name)
+static ir_function* ir_builder_get_function(ir_builder *self, const char *name)
{
return (ir_function*)util_htget(self->htfunctions, name);
}
return fn;
}
-ir_value* ir_builder_get_global(ir_builder *self, const char *name)
+static ir_value* ir_builder_get_global(ir_builder *self, const char *name)
{
return (ir_value*)util_htget(self->htglobals, name);
}
return (self->reserved_va_count = ir_builder_create_global(self, "reserved:va_count", TYPE_FLOAT));
}
-ir_value* ir_builder_get_field(ir_builder *self, const char *name)
+static ir_value* ir_builder_get_field(ir_builder *self, const char *name)
{
return (ir_value*)util_htget(self->htfields, name);
}
*IR Function
*/
-bool ir_function_naive_phi(ir_function*);
-void ir_function_enumerate(ir_function*);
-bool ir_function_calculate_liferanges(ir_function*);
-bool ir_function_allocate_locals(ir_function*);
+static bool ir_function_naive_phi(ir_function*);
+static void ir_function_enumerate(ir_function*);
+static bool ir_function_calculate_liferanges(ir_function*);
+static bool ir_function_allocate_locals(ir_function*);
ir_function* ir_function_new(ir_builder* owner, int outtype)
{
mem_d(self);
}
-void ir_function_collect_value(ir_function *self, ir_value *v)
+static void ir_function_collect_value(ir_function *self, ir_value *v)
{
vec_push(self->values, v);
}
(op >= INSTR_CALL0 && op <= INSTR_CALL8) );
}
-bool ir_function_pass_peephole(ir_function *self)
+static bool ir_function_pass_peephole(ir_function *self)
{
size_t b;
return true;
}
-bool ir_function_pass_tailrecursion(ir_function *self)
+static bool ir_function_pass_tailrecursion(ir_function *self)
{
size_t b, p;
*IR Instructions
*/
-ir_instr* ir_instr_new(lex_ctx ctx, ir_block* owner, int op)
+static ir_instr* ir_instr_new(lex_ctx ctx, ir_block* owner, int op)
{
ir_instr *self;
self = (ir_instr*)mem_a(sizeof(*self));
mem_d(self);
}
-void ir_instr_delete(ir_instr *self)
+static void ir_instr_delete(ir_instr *self)
{
size_t i;
/* The following calls can only delete from
mem_d(self);
}
-bool ir_instr_op(ir_instr *self, int op, ir_value *v, bool writing)
+static bool ir_instr_op(ir_instr *self, int op, ir_value *v, bool writing)
{
if (self->_ops[op]) {
size_t idx;
*IR Value
*/
-void ir_value_code_setaddr(ir_value *self, int32_t gaddr)
+static void ir_value_code_setaddr(ir_value *self, int32_t gaddr)
{
self->code.globaladdr = gaddr;
if (self->members[0]) self->members[0]->code.globaladdr = gaddr;
if (self->members[2]) self->members[2]->code.globaladdr = gaddr;
}
-int32_t ir_value_code_addr(const ir_value *self)
+static int32_t ir_value_code_addr(const ir_value *self)
{
if (self->store == store_return)
return OFS_RETURN + self->code.addroffset;
return type_sizeof_[self->vtype];
}
-ir_value* ir_value_out(ir_function *owner, const char *name, int storetype, int vtype)
+static ir_value* ir_value_out(ir_function *owner, const char *name, int storetype, int vtype)
{
ir_value *v = ir_value_var(name, storetype, vtype);
if (!v)
return false;
}
-bool ir_value_life_insert(ir_value *self, size_t idx, ir_life_entry_t e)
+static bool ir_value_life_insert(ir_value *self, size_t idx, ir_life_entry_t e)
{
size_t k;
vec_push(self->life, e);
return true;
}
-bool ir_value_life_merge(ir_value *self, size_t s)
+static bool ir_value_life_merge(ir_value *self, size_t s)
{
size_t i;
const size_t vs = vec_size(self->life);
return ir_value_life_insert(self, i, new_entry);
}
-bool ir_value_life_merge_into(ir_value *self, const ir_value *other)
+static bool ir_value_life_merge_into(ir_value *self, const ir_value *other)
{
size_t i, myi;
return true;
}
-bool ir_values_overlap(const ir_value *a, const ir_value *b)
+static bool ir_values_overlap(const ir_value *a, const ir_value *b)
{
/* For any life entry in A see if it overlaps with
* any life entry in B.
return true;
}
-bool ir_block_create_store(ir_block *self, lex_ctx ctx, ir_value *target, ir_value *what)
+static bool ir_block_create_store(ir_block *self, lex_ctx ctx, ir_value *target, ir_value *what)
{
int op = 0;
int vtype;
return ir_block_create_general_instr(self, ctx, label, opcode, operand, NULL, ot);
}
-ir_value* ir_block_create_general_instr(ir_block *self, lex_ctx ctx, const char *label,
+static ir_value* ir_block_create_general_instr(ir_block *self, lex_ctx ctx, const char *label,
int op, ir_value *a, ir_value *b, int outype)
{
ir_instr *instr;
# define strncat(dst, src, sz) strncat_s(dst, sz, src, _TRUNCATE)
#endif
-const char *qc_opname(int op)
+static const char *qc_opname(int op)
{
if (op < 0) return "<INVALID>";
if (op < (int)( sizeof(asm_instr) / sizeof(asm_instr[0]) ))
ind[strlen(ind)-1] = 0;
}
-void dump_phi(ir_instr *in, int (*oprintf)(const char*, ...))
+static void dump_phi(ir_instr *in, int (*oprintf)(const char*, ...))
{
size_t i;
oprintf("%s <- phi ", in->_ops[0]->name);
ind[strlen(ind)-1] = 0;
}
-void ir_value_dump_string(const char *str, int (*oprintf)(const char*, ...))
+static void ir_value_dump_string(const char *str, int (*oprintf)(const char*, ...))
{
oprintf("\"");
for (; *str; ++str) {
#ifndef GMQCC_IR_HDR
#define GMQCC_IR_HDR
#include "gmqcc.h"
-/* ir_value */
typedef struct
{
ir_life_entry_t *life;
} ir_value;
-int32_t ir_value_code_addr(const ir_value*);
-
/* ir_value can be a variable, or created by an operation */
-ir_value* ir_value_var(const char *name, int st, int vtype);
/* if a result of an operation: the function should store
* it to remember to delete it / garbage collect it
*/
-ir_value* ir_value_out(struct ir_function_s *owner, const char *name, int st, int vtype);
-void ir_value_delete(ir_value*);
-bool ir_value_set_name(ir_value*, const char *name);
-ir_value* ir_value_vector_member(ir_value*, unsigned int member);
-
-bool GMQCC_WARN vec_ir_value_find(ir_value **vec, const ir_value *what, size_t *idx);
-
+void ir_value_delete(ir_value*);
+ir_value* ir_value_vector_member(ir_value*, unsigned int member);
bool GMQCC_WARN ir_value_set_float(ir_value*, float f);
bool GMQCC_WARN ir_value_set_func(ir_value*, int f);
-#if 0
-bool GMQCC_WARN ir_value_set_int(ir_value*, int i);
-#endif
bool GMQCC_WARN ir_value_set_string(ir_value*, const char *s);
bool GMQCC_WARN ir_value_set_vector(ir_value*, vector v);
bool GMQCC_WARN ir_value_set_field(ir_value*, ir_value *fld);
-/*bool ir_value_set_pointer_v(ir_value*, ir_value* p); */
-/*bool ir_value_set_pointer_i(ir_value*, int i); */
-
-/* merge an instruction into the life-range */
-/* returns false if the lifepoint was already known */
-bool ir_value_life_merge(ir_value*, size_t);
-bool ir_value_life_merge_into(ir_value*, const ir_value*);
-/* check if a value lives at a specific point */
-bool ir_value_lives(ir_value*, size_t);
-/* check if the life-range of 2 values overlaps */
-bool ir_values_overlap(const ir_value*, const ir_value*);
-
-void ir_value_dump(ir_value*, int (*oprintf)(const char*,...));
-void ir_value_dump_life(const ir_value *self, int (*oprintf)(const char*,...));
+bool ir_value_lives(ir_value*, size_t);
+void ir_value_dump_life(const ir_value *self, int (*oprintf)(const char*,...));
/* PHI data */
typedef struct ir_phi_entry_s
struct ir_block_s *owner;
} ir_instr;
-ir_instr* ir_instr_new(lex_ctx ctx, struct ir_block_s *owner, int opcode);
-void ir_instr_delete(ir_instr*);
-
-bool GMQCC_WARN vec_ir_instr_find(ir_instr **vec, ir_instr *what, size_t *idx);
-
-bool 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*,...));
-
/* block */
typedef struct ir_block_s
{
size_t code_start;
} ir_block;
-ir_block* ir_block_new(struct ir_function_s *owner, const char *label);
-void ir_block_delete(ir_block*);
-
-bool ir_block_set_label(ir_block*, const char *label);
-
-ir_value* ir_block_create_binop(ir_block*, lex_ctx, const char *label, int op,
- ir_value *left, ir_value *right);
-ir_value* ir_block_create_unary(ir_block*, lex_ctx, const char *label, int op,
- ir_value *operand);
+ir_value* ir_block_create_binop(ir_block*, lex_ctx, const char *label, int op, ir_value *left, ir_value *right);
+ir_value* ir_block_create_unary(ir_block*, lex_ctx, const char *label, int op, ir_value *operand);
bool GMQCC_WARN ir_block_create_store_op(ir_block*, lex_ctx, int op, ir_value *target, ir_value *what);
-bool GMQCC_WARN ir_block_create_store(ir_block*, lex_ctx, ir_value *target, ir_value *what);
bool GMQCC_WARN ir_block_create_storep(ir_block*, lex_ctx, ir_value *target, ir_value *what);
-
-/* field must be of TYPE_FIELD */
-ir_value* ir_block_create_load_from_ent(ir_block*, lex_ctx, const char *label, ir_value *ent, ir_value *field, int outype);
-
-ir_value* ir_block_create_fieldaddress(ir_block*, lex_ctx, const char *label, ir_value *entity, ir_value *field);
+ir_value* ir_block_create_load_from_ent(ir_block*, lex_ctx, const char *label, ir_value *ent, ir_value *field, int outype);
+ir_value* ir_block_create_fieldaddress(ir_block*, lex_ctx, const char *label, ir_value *entity, ir_value *field);
/* This is to create an instruction of the form
* <outtype>%label := opcode a, b
*/
-ir_value* ir_block_create_general_instr(ir_block *self, lex_ctx, const char *label,
- int op, ir_value *a, ir_value *b, int outype);
-
ir_instr* ir_block_create_phi(ir_block*, lex_ctx, const char *label, int vtype);
ir_value* ir_phi_value(ir_instr*);
void ir_phi_add(ir_instr*, ir_block *b, ir_value *v);
bool GMQCC_WARN ir_block_create_jump(ir_block*, lex_ctx, ir_block *to);
bool GMQCC_WARN ir_block_create_goto(ir_block*, lex_ctx, ir_block *to);
-void ir_block_dump(ir_block*, char *ind, int (*oprintf)(const char*,...));
-
/* function */
-
typedef struct ir_function_s
{
char *name;
/* vararg support: */
size_t max_varargs;
} ir_function;
+
#define IR_FLAG_HAS_ARRAYS (1<<1)
#define IR_FLAG_HAS_UNINITIALIZED (1<<2)
#define IR_FLAG_HAS_GOTO (1<<3)
#define IR_FLAG_MASK_NO_OVERLAP (IR_FLAG_HAS_ARRAYS | IR_FLAG_HAS_UNINITIALIZED)
#define IR_FLAG_MASK_NO_LOCAL_TEMPS (IR_FLAG_HAS_ARRAYS | IR_FLAG_HAS_UNINITIALIZED)
-ir_function* ir_function_new(struct ir_builder_s *owner, int returntype);
-void ir_function_delete(ir_function*);
-
-void ir_function_collect_value(ir_function*, ir_value *value);
-
-bool ir_function_set_name(ir_function*, const char *name);
-
-ir_value* ir_function_create_local(ir_function *self, const char *name, int vtype, bool param);
-
+ir_value* ir_function_create_local(ir_function *self, const char *name, int vtype, bool param);
bool GMQCC_WARN ir_function_finalize(ir_function*);
-/*
-bool ir_function_naive_phi(ir_function*);
-bool ir_function_enumerate(ir_function*);
-bool ir_function_calculate_liferanges(ir_function*);
-*/
-
-ir_block* ir_function_create_block(lex_ctx ctx, ir_function*, const char *label);
-
-void ir_function_dump(ir_function*, char *ind, int (*oprintf)(const char*,...));
+ir_block* ir_function_create_block(lex_ctx ctx, ir_function*, const char *label);
/* builder */
#define IR_HT_SIZE 1024
ir_value *reserved_va_count;
} ir_builder;
-ir_builder* ir_builder_new(const char *modulename);
-void ir_builder_delete(ir_builder*);
-
-bool ir_builder_set_name(ir_builder *self, const char *name);
-
-ir_function* ir_builder_get_function(ir_builder*, const char *fun);
+ir_builder* ir_builder_new(const char *modulename);
+void ir_builder_delete(ir_builder*);
ir_function* ir_builder_create_function(ir_builder*, const char *name, int outtype);
-
-ir_value* ir_builder_get_global(ir_builder*, const char *fun);
-ir_value* ir_builder_create_global(ir_builder*, const char *name, int vtype);
-ir_value* ir_builder_get_field(ir_builder*, const char *fun);
-ir_value* ir_builder_create_field(ir_builder*, const char *name, int vtype);
-
-ir_value* ir_builder_get_va_count(ir_builder*);
-
-bool ir_builder_generate(code_t *, ir_builder *self, const char *filename);
-
-void ir_builder_dump(ir_builder*, int (*oprintf)(const char*, ...));
-
+ir_value* ir_builder_create_global(ir_builder*, const char *name, int vtype);
+ir_value* ir_builder_create_field(ir_builder*, const char *name, int vtype);
+ir_value* ir_builder_get_va_count(ir_builder*);
+bool ir_builder_generate(code_t *, ir_builder *self, const char *filename);
+void ir_builder_dump(ir_builder*, int (*oprintf)(const char*, ...));
/*
* This code assumes 32 bit floats while generating binary
static char* *lex_filenames;
-void lexerror(lex_file *lex, const char *fmt, ...)
+static void lexerror(lex_file *lex, const char *fmt, ...)
{
va_list ap;
va_end(ap);
}
-bool lexwarn(lex_file *lex, int warntype, const char *fmt, ...)
+static bool lexwarn(lex_file *lex, int warntype, const char *fmt, ...)
{
bool r;
lex_ctx ctx;
extern const oper_info *operators;
extern size_t operator_count;
-void lexerror(lex_file*, const char *fmt, ...);
+/*void lexerror(lex_file*, const char *fmt, ...);*/
#endif
return pak;
}
-pak_file_t *pak_open(const char *file, const char *mode) {
+static pak_file_t *pak_open(const char *file, const char *mode) {
if (!file || !mode)
return NULL;
return NULL;
}
-bool pak_exists(pak_file_t *pak, const char *file, pak_directory_t **dir) {
+static bool pak_exists(pak_file_t *pak, const char *file, pak_directory_t **dir) {
size_t itr;
if (!pak || !file)
/*
* Extraction abilities. These work as you expect them to.
*/
-bool pak_extract_one(pak_file_t *pak, const char *file, const char *outdir) {
+static bool pak_extract_one(pak_file_t *pak, const char *file, const char *outdir) {
pak_directory_t *dir = NULL;
unsigned char *dat = NULL;
char *local = NULL;
return true;
}
-bool pak_extract_all(pak_file_t *pak, const char *dir) {
+static bool pak_extract_all(pak_file_t *pak, const char *dir) {
size_t itr;
if (!fs_dir_make(dir))
* Insertion functions (the opposite of extraction). Yes for generating
* PAKs.
*/
-bool pak_insert_one(pak_file_t *pak, const char *file) {
+static bool pak_insert_one(pak_file_t *pak, const char *file) {
pak_directory_t dir;
unsigned char *dat;
FILE *fp;
return true;
}
-bool pak_close(pak_file_t *pak) {
+static bool pak_close(pak_file_t *pak) {
size_t itr;
if (!pak)
* parsing
*/
-bool parser_next(parser_t *parser)
+static bool parser_next(parser_t *parser)
{
/* lex_do kills the previous token */
parser->tok = lex_do(parser->lex);
return parser;
}
-bool parser_compile(parser_t *parser)
+static bool parser_compile(parser_t *parser)
{
/* initial lexer/parser state */
parser->lex->flags.noops = true;
int pid;
} popen_t;
-FILE ** task_popen(const char *command, const char *mode) {
+static FILE ** task_popen(const char *command, const char *mode) {
int inhandle [2];
int outhandle [2];
int errhandle [2];
return NULL;
}
-int task_pclose(FILE **handles) {
+static int task_pclose(FILE **handles) {
popen_t *data = (popen_t*)handles;
int status = 0;
char name_out[L_tmpnam];
} popen_t;
- FILE **task_popen(const char *command, const char *mode) {
+ static FILE **task_popen(const char *command, const char *mode) {
char *cmd = NULL;
popen_t *open = (popen_t*)mem_a(sizeof(popen_t));
return open->handles;
}
- void task_pclose(FILE **files) {
+ static void task_pclose(FILE **files) {
popen_t *open = ((popen_t*)files);
fs_file_close(files[1]);
fs_file_close(files[2]);
* This is very much like a compiler code generator :-). This generates
* a value from some data observed from the compiler.
*/
-bool task_template_generate(task_template_t *tmpl, char tag, const char *file, size_t line, char *value, size_t *pad) {
+static bool task_template_generate(task_template_t *tmpl, char tag, const char *file, size_t line, char *value, size_t *pad) {
size_t desclen = 0;
size_t filelen = 0;
char **destval = NULL;
return true;
}
-bool task_template_parse(const char *file, task_template_t *tmpl, FILE *fp, size_t *pad) {
+static bool task_template_parse(const char *file, task_template_t *tmpl, FILE *fp, size_t *pad) {
char *data = NULL;
char *back = NULL;
size_t size = 0;
* Nullifies the template data: used during initialization of a new
* template and free.
*/
-void task_template_nullify(task_template_t *tmpl) {
+static void task_template_nullify(task_template_t *tmpl) {
if (!tmpl)
return;
tmpl->testflags = NULL;
}
-task_template_t *task_template_compile(const char *file, const char *dir, size_t *pad) {
+static task_template_t *task_template_compile(const char *file, const char *dir, size_t *pad) {
/* a page should be enough */
char fullfile[4096];
size_t filepadd = 0;
return NULL;
}
-void task_template_destroy(task_template_t **tmpl) {
+static void task_template_destroy(task_template_t **tmpl) {
if (!tmpl)
return;
* Read a directory and searches for all template files in it
* which is later used to run all tests.
*/
-bool task_propagate(const char *curdir, size_t *pad, const char *defs) {
+static bool task_propagate(const char *curdir, size_t *pad, const char *defs) {
bool success = true;
DIR *dir;
struct dirent *files;
* Task precleanup removes any existing temporary files or log files
* left behind from a previous invoke of the test-suite.
*/
-void task_precleanup(const char *curdir) {
+static void task_precleanup(const char *curdir) {
DIR *dir;
struct dirent *files;
char buffer[4096];
fs_dir_close(dir);
}
-void task_destroy(void) {
+static void task_destroy(void) {
/*
* Free all the data in the task list and finally the list itself
* then proceed to cleanup anything else outside the program like
* messages IF the procedure type is -execute, otherwise it matches
* the preprocessor output.
*/
-bool task_trymatch(task_template_t *tmpl, char ***line) {
+static bool task_trymatch(task_template_t *tmpl, char ***line) {
bool success = true;
bool preprocessing = false;
FILE *execute;
return success;
}
-const char *task_type(task_template_t *tmpl) {
+static const char *task_type(task_template_t *tmpl) {
if (!strcmp(tmpl->proceduretype, "-pp"))
return "type: preprocessor";
if (!strcmp(tmpl->proceduretype, "-execute"))
* from thin air and executed INLINE.
*/
#include <math.h>
-void task_schedualize(size_t *pad) {
+static void task_schedualize(size_t *pad) {
char space[2][64];
bool execute = false;
char *data = NULL;
*
* It expects con_init() was called before hand.
*/
-GMQCC_WARN bool test_perform(const char *curdir, const char *defs) {
+static GMQCC_WARN bool test_perform(const char *curdir, const char *defs) {
static const char *default_defs = "defs.qh";
size_t pad[] = {
return (size_t) (hash % ht->size);
}
-hash_node_t *_util_htnewpair(const char *key, void *value) {
+static hash_node_t *_util_htnewpair(const char *key, void *value) {
hash_node_t *node;
if (!(node = (hash_node_t*)mem_a(sizeof(hash_node_t))))
return NULL;