X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=blobdiff_plain;f=ir.cpp;h=5f2ef7e3801037ee504702ee9aca50cd5b935ea5;hp=f5bc4520147f3765be59b31738056d308ec91535;hb=566c17a964ee573ede4ac00abeed51ca60c15c4e;hpb=17c0812ae48533e4207dd9ffc5408f781020ce97 diff --git a/ir.cpp b/ir.cpp index f5bc452..5f2ef7e 100644 --- a/ir.cpp +++ b/ir.cpp @@ -235,15 +235,14 @@ static bool GMQCC_WARN vec_ir_value_find(std::vector &vec, const ir_ return false; } -static bool GMQCC_WARN vec_ir_block_find(ir_block **vec, ir_block *what, size_t *idx) +static bool GMQCC_WARN vec_ir_block_find(std::vector &vec, ir_block *what, size_t *idx) { - size_t i; - size_t len = vec_size(vec); - for (i = 0; i < len; ++i) { - if (vec[i] == what) { - if (idx) *idx = i; - return true; - } + for (auto &it : vec) { + if (it != what) + continue; + if (idx) + *idx = &it - &vec[0]; + return true; } return false; } @@ -638,7 +637,7 @@ bool ir_function_finalize(ir_function *self) // claiming it's unused, otherwise skip the vector entierly if (v->m_vtype == TYPE_VECTOR) { - size_t mask = (1 << 0) | (1 << 1) | (1 << 2), bits = 0; + size_t mask = (1 << 3) - 1, bits = 0; for (size_t i = 0; i < 3; i++) if (!v->m_members[i] || (v->m_members[i]->m_reads.empty() && v->m_members[i]->m_writes.size())) @@ -746,7 +745,6 @@ ir_block::~ir_block() for (size_t i = 0; i != vec_size(m_instr); ++i) delete m_instr[i]; vec_free(m_instr); - vec_free(m_entries); vec_free(m_exits); } @@ -1383,8 +1381,8 @@ bool ir_block_create_if(ir_block *self, lex_ctx_t ctx, ir_value *v, vec_push(self->m_exits, ontrue); vec_push(self->m_exits, onfalse); - vec_push(ontrue->m_entries, self); - vec_push(onfalse->m_entries, self); + ontrue->m_entries.push_back(self); + onfalse->m_entries.push_back(self); return true; } @@ -1402,7 +1400,7 @@ bool ir_block_create_jump(ir_block *self, lex_ctx_t ctx, ir_block *to) vec_push(self->m_instr, in); vec_push(self->m_exits, to); - vec_push(to->m_entries, self); + to->m_entries.push_back(self); return true; }