/*
- * Copyright (C) 2012, 2013, 2014
+ * Copyright (C) 2012, 2013, 2014, 2015
* Wolfgang Bumiller
* Dale Weiler
*
/* helper function */
static ir_value* ir_builder_imm_float(ir_builder *self, float value, bool add_to_list) {
ir_value *v = ir_value_var("#IMMEDIATE", store_global, TYPE_FLOAT);
+ v->flags |= IR_FLAG_ERASABLE;
v->hasvalue = true;
+ v->cvq = CV_CONST;
v->constval.vfloat = value;
vec_push(self->globals, v);
* If there is no definition and the thing is eraseable, we can ignore
* outputting the function to begin with.
*/
- if (global->flags & IR_FLAG_ERASEABLE && irfun->code_function_def < 0) {
+ if (global->flags & IR_FLAG_ERASABLE && irfun->code_function_def < 0) {
return true;
}
* if we're eraseable and the function isn't referenced ignore outputting
* the function.
*/
- if (global->flags & IR_FLAG_ERASEABLE && vec_size(global->reads) == 0) {
+ if (global->flags & IR_FLAG_ERASABLE && vec_size(global->reads) == 0) {
return true;
}
{
ir_value_code_setaddr(global, vec_size(self->code->globals));
if (global->hasvalue) {
+ if (global->cvq == CV_CONST && !vec_size(global->reads))
+ return true;
iptr = (int32_t*)&global->constval.ivec[0];
vec_push(self->code->globals, *iptr);
} else {
{
ir_value_code_setaddr(global, vec_size(self->code->globals));
if (global->hasvalue) {
- uint32_t load = code_genstring(self->code, global->constval.vstring);
+ uint32_t load;
+ if (global->cvq == CV_CONST && !vec_size(global->reads))
+ return true;
+ load = code_genstring(self->code, global->constval.vstring);
vec_push(self->code->globals, load);
} else {
vec_push(self->code->globals, 0);