mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2024-11-23 20:33:05 +00:00
Added a flag to both ast and ir which enforces the generation of a globaldef for a value
This commit is contained in:
parent
5ea710e317
commit
6df3c625b0
4 changed files with 19 additions and 0 deletions
14
ast.c
14
ast.c
|
@ -1164,6 +1164,8 @@ bool ast_global_codegen(ast_value *self, ir_builder *ir, bool isfield)
|
|||
|
||||
self->constval.vfunc->ir_func = func;
|
||||
self->ir_v = func->value;
|
||||
if (self->expression.flags & AST_FLAG_INCLUDE_DEF)
|
||||
self->ir_v->flags |= IR_FLAG_INCLUDE_DEF;
|
||||
/* The function is filled later on ast_function_codegen... */
|
||||
return true;
|
||||
}
|
||||
|
@ -1206,6 +1208,8 @@ bool ast_global_codegen(ast_value *self, ir_builder *ir, bool isfield)
|
|||
v->unique_life = true;
|
||||
v->locked = true;
|
||||
array->ir_v = self->ir_v = v;
|
||||
if (self->expression.flags & AST_FLAG_INCLUDE_DEF)
|
||||
self->ir_v->flags |= IR_FLAG_INCLUDE_DEF;
|
||||
|
||||
namelen = strlen(self->name);
|
||||
name = (char*)mem_a(namelen + 16);
|
||||
|
@ -1224,6 +1228,8 @@ bool ast_global_codegen(ast_value *self, ir_builder *ir, bool isfield)
|
|||
array->ir_values[ai]->context = ast_ctx(self);
|
||||
array->ir_values[ai]->unique_life = true;
|
||||
array->ir_values[ai]->locked = true;
|
||||
if (self->expression.flags & AST_FLAG_INCLUDE_DEF)
|
||||
self->ir_values[ai]->flags |= IR_FLAG_INCLUDE_DEF;
|
||||
}
|
||||
mem_d(name);
|
||||
}
|
||||
|
@ -1234,6 +1240,8 @@ bool ast_global_codegen(ast_value *self, ir_builder *ir, bool isfield)
|
|||
return false;
|
||||
v->context = ast_ctx(self);
|
||||
self->ir_v = v;
|
||||
if (self->expression.flags & AST_FLAG_INCLUDE_DEF)
|
||||
self->ir_v->flags |= IR_FLAG_INCLUDE_DEF;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1258,6 +1266,8 @@ bool ast_global_codegen(ast_value *self, ir_builder *ir, bool isfield)
|
|||
v->context = ast_ctx(self);
|
||||
v->unique_life = true;
|
||||
v->locked = true;
|
||||
if (self->expression.flags & AST_FLAG_INCLUDE_DEF)
|
||||
v->flags |= IR_FLAG_INCLUDE_DEF;
|
||||
|
||||
namelen = strlen(self->name);
|
||||
name = (char*)mem_a(namelen + 16);
|
||||
|
@ -1276,6 +1286,8 @@ bool ast_global_codegen(ast_value *self, ir_builder *ir, bool isfield)
|
|||
self->ir_values[ai]->context = ast_ctx(self);
|
||||
self->ir_values[ai]->unique_life = true;
|
||||
self->ir_values[ai]->locked = true;
|
||||
if (self->expression.flags & AST_FLAG_INCLUDE_DEF)
|
||||
self->ir_values[ai]->flags |= IR_FLAG_INCLUDE_DEF;
|
||||
}
|
||||
mem_d(name);
|
||||
}
|
||||
|
@ -1338,6 +1350,8 @@ bool ast_global_codegen(ast_value *self, ir_builder *ir, bool isfield)
|
|||
/* link us to the ir_value */
|
||||
v->cvq = self->cvq;
|
||||
self->ir_v = v;
|
||||
if (self->expression.flags & AST_FLAG_INCLUDE_DEF)
|
||||
self->ir_v->flags |= IR_FLAG_INCLUDE_DEF;
|
||||
return true;
|
||||
|
||||
error: /* clean up */
|
||||
|
|
1
ast.h
1
ast.h
|
@ -145,6 +145,7 @@ typedef struct
|
|||
#define AST_FLAG_INLINE (1<<2)
|
||||
#define AST_FLAG_INITIALIZED (1<<3)
|
||||
#define AST_FLAG_DEPRECATED (1<<4)
|
||||
#define AST_FLAG_INCLUDE_DEF (1<<5)
|
||||
#define AST_FLAG_TYPE_MASK (AST_FLAG_VARIADIC | AST_FLAG_NORETURN)
|
||||
|
||||
/* Value
|
||||
|
|
2
ir.c
2
ir.c
|
@ -1018,6 +1018,7 @@ ir_value* ir_value_var(const char *name, int storetype, int vtype)
|
|||
self->fieldtype = TYPE_VOID;
|
||||
self->outtype = TYPE_VOID;
|
||||
self->store = storetype;
|
||||
self->flags = 0;
|
||||
|
||||
self->reads = NULL;
|
||||
self->writes = NULL;
|
||||
|
@ -3323,6 +3324,7 @@ static bool ir_builder_gen_global(ir_builder *self, ir_value *global, bool isloc
|
|||
pushdef = true;
|
||||
|
||||
if (OPTS_OPTIMIZATION(OPTIM_STRIP_CONSTANT_NAMES) &&
|
||||
!(global->flags & IR_FLAG_INCLUDE_DEF) &&
|
||||
(global->name[0] == '#' || global->cvq == CV_CONST))
|
||||
{
|
||||
pushdef = false;
|
||||
|
|
2
ir.h
2
ir.h
|
@ -44,6 +44,7 @@ typedef struct ir_value_s {
|
|||
int outtype;
|
||||
/* 'const' vs 'var' qualifier */
|
||||
int cvq;
|
||||
uint32_t flags;
|
||||
|
||||
struct ir_instr_s **reads;
|
||||
struct ir_instr_s **writes;
|
||||
|
@ -276,6 +277,7 @@ typedef struct ir_function_s
|
|||
#define IR_FLAG_HAS_ARRAYS (1<<1)
|
||||
#define IR_FLAG_HAS_UNINITIALIZED (1<<2)
|
||||
#define IR_FLAG_HAS_GOTO (1<<3)
|
||||
#define IR_FLAG_INCLUDE_DEF (1<<4)
|
||||
#define IR_FLAG_MASK_NO_OVERLAP (IR_FLAG_HAS_ARRAYS | IR_FLAG_HAS_UNINITIALIZED)
|
||||
|
||||
ir_function* ir_function_new(struct ir_builder_s *owner, int returntype);
|
||||
|
|
Loading…
Reference in a new issue