Skip to content

Commit

Permalink
rename states to args
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-s168 committed May 28, 2024
1 parent 68a5c46 commit faebfbe
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 21 deletions.
20 changes: 10 additions & 10 deletions ir/builder.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ void vx_IrOp_init(vx_IrOp *op,

op->parent = parent;

op->states = NULL;
op->states_len = 0;
op->args = NULL;
op->args_len = 0;

op->info = vx_OpInfoList_create();
}
Expand Down Expand Up @@ -227,7 +227,7 @@ void vx_IrOp_destroy(vx_IrOp *op)
// BEFORE CHANGING NOTE THAT MOST PASSES MISUSE THIS FUNCTION!!!
vx_IrOp_remove_params(op);
free(op->outs);
free(op->states);
free(op->args);
vx_OpInfoList_destroy(&op->info);
}

Expand Down Expand Up @@ -272,16 +272,16 @@ void vx_IrOp_remove_param_at(vx_IrOp *op,
void vx_IrOp_remove_state_at(vx_IrOp *op,
const size_t id)
{
memmove(op->states + id, op->states + id + 1, sizeof(vx_IrNamedValue) * (op->states_len - id - 1));
op->states_len --;
memmove(op->args + id, op->args + id + 1, sizeof(vx_IrNamedValue) * (op->args_len - id - 1));
op->args_len --;
}

void vx_IrOp_steal_states(vx_IrOp *dest,
const vx_IrOp *src)
{
free(dest->states);
dest->states = malloc(sizeof(vx_IrValue) * src->states_len);
for (size_t i = 0; i < src->states_len; i ++)
dest->states[i] = src->states[i];
dest->states_len = src->states_len;
free(dest->args);
dest->args = malloc(sizeof(vx_IrValue) * src->args_len);
for (size_t i = 0; i < src->args_len; i ++)
dest->args[i] = src->args[i];
dest->args_len = src->args_len;
}
4 changes: 2 additions & 2 deletions ir/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ void vx_IrOp_dump(const vx_IrOp *op, FILE *out, size_t indent) {

fprintf(out, "%s ", vx_IrOpType_names[op->id]);

for (size_t i = 0; i < op->states_len; i ++) {
const vx_IrValue val = op->states[i];
for (size_t i = 0; i < op->args_len; i ++) {
const vx_IrValue val = op->args[i];
fprintf(out, "state%zu=", i);
vx_IrValue_dump(val, out, indent);
fputc(' ', out);
Expand Down
5 changes: 2 additions & 3 deletions ir/ir.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,9 +373,8 @@ struct vx_IrOp_s {
vx_IrNamedValue *params;
size_t params_len;

// TODO: TODO TODO MOST FNS IGNORE THAT!!!! BAD!!! (also rename and use in alternatives too)
vx_IrValue * states;
size_t states_len;
vx_IrValue * args;
size_t args_len;

vx_IrBlock * parent;
vx_IrOpType id;
Expand Down
2 changes: 1 addition & 1 deletion ir/opt/reduce_loops.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void vx_opt_reduce_loops(vx_IrView view,
*bcond = NULL;
*bdo = NULL;

const vx_IrValue init = op->states[stateId];
const vx_IrValue init = op->args[stateId];

// counter needs to be at pos 0 oviously
vx_IrBlock_swap_in_at(newcond, stateId, 0);
Expand Down
2 changes: 1 addition & 1 deletion ir/transform/normalize.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void vx_CIrBlock_normalize(vx_IrBlock *block)
// we free manually because we don't want to free blocks if should_free
// TODO: ^ is stupid
free(op->outs);
free(op->states);
free(op->args);
vx_IrOp_remove_params(op);

{
Expand Down
8 changes: 4 additions & 4 deletions ir/verify_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ static void analyze_loops(vx_Errors *dest,
vx_OpPath path)
{
const size_t states_count = op->outs_len;
if (states_count != op->states_len) {
if (states_count != op->args_len) {
const vx_OpPath newpath = vx_OpPath_copy_add(path, i);
vx_Error error = {
.path = newpath,
Expand Down Expand Up @@ -149,9 +149,9 @@ void vx_IrBlock_verify_ssa_based(vx_Errors *dest, const vx_IrBlock *block, const
}

// verify states in general
for (size_t j = 0; j < op->states_len; j ++) {
if (op->states[j].type == VX_IR_VAL_BLOCK ||
op->states[j].type == VX_IR_VAL_TYPE)
for (size_t j = 0; j < op->args_len; j ++) {
if (op->args[j].type == VX_IR_VAL_BLOCK ||
op->args[j].type == VX_IR_VAL_TYPE)
{
const vx_OpPath newpath = vx_OpPath_copy_add(path, i);
const vx_Error error = {
Expand Down

0 comments on commit faebfbe

Please sign in to comment.