X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=blobdiff_plain;f=ir.h;h=6dcbd5a905044bbdcb58c5fc5ca49da0bb9c26f4;hp=7f4106ee902eff29a63a17b71b93d254778f3d23;hb=7e0e041527e812a112635fe511fb1ad566b6c7fe;hpb=aabefd1bfe0c5b08bea9341c1394cfa8b96d754d diff --git a/ir.h b/ir.h index 7f4106e..6dcbd5a 100644 --- a/ir.h +++ b/ir.h @@ -14,11 +14,11 @@ struct ir_block; struct ir_function; struct ir_builder; -typedef struct { +struct ir_life_entry_t { /* both inclusive */ size_t start; size_t end; -} ir_life_entry_t; +}; enum { IR_FLAG_HAS_ARRAYS = 1 << 0, @@ -36,50 +36,47 @@ enum { }; struct ir_value { - char *name; - int vtype; - int store; - lex_ctx_t context; - - - int fieldtype; /* even the IR knows the subtype of a field */ - int outtype; /* and the output type of a function */ - int cvq; /* 'const' vs 'var' qualifier */ + char *name; + int vtype; + int store; + lex_ctx_t context; + int fieldtype; // even the IR knows the subtype of a field + int outtype; // and the output type of a function + int cvq; // 'const' vs 'var' qualifier ir_flag_t flags; - ir_instr **reads; - ir_instr **writes; + std::vector reads; + std::vector writes; - /* constantvalues */ + // constant values bool hasvalue; union { - qcfloat_t vfloat; - int vint; - vec3_t vvec; - int32_t ivec[3]; - char *vstring; - ir_value *vpointer; + qcfloat_t vfloat; + int vint; + vec3_t vvec; + int32_t ivec[3]; + char *vstring; + ir_value *vpointer; ir_function *vfunc; } constval; struct { int32_t globaladdr; int32_t name; - int32_t local; /* filled by the local-allocator */ - int32_t addroffset; /* added for members */ - int32_t fieldaddr; /* to generate field-addresses early */ + int32_t local; // filled by the local-allocator + int32_t addroffset; // added for members + int32_t fieldaddr; // to generate field-addresses early } code; - /* for acessing vectors */ + // for accessing vectors ir_value *members[3]; ir_value *memberof; - - bool unique_life; /* arrays will never overlap with temps */ - bool locked; /* temps living during a CALL must be locked */ + bool unique_life; // arrays will never overlap with temps + bool locked; // temps living during a CALL must be locked bool callparam; - ir_life_entry_t *life; /* For the temp allocator */ + ir_life_entry_t *life; // For the temp allocator }; /* @@ -110,13 +107,13 @@ struct ir_instr { ir_value *(_ops[3]); ir_block *(bops[2]); - ir_phi_entry_t *phi; - ir_value **params; + std::vector phi; + std::vector params; - /* For the temp-allocation */ + // For the temp-allocation size_t eid; - /* For IFs */ + // For IFs bool likely; ir_block *owner; @@ -124,23 +121,23 @@ struct ir_instr { /* block */ struct ir_block { - char *label; - lex_ctx_t context; - bool final; /* once a jump is added we're done */ + char *label; + lex_ctx_t context; + bool final; /* once a jump is added we're done */ ir_instr **instr; ir_block **entries; ir_block **exits; - ir_value **living; + std::vector living; /* For the temp-allocation */ size_t entry_id; size_t eid; - bool is_return; + bool is_return; ir_function *owner; - bool generated; + bool generated; size_t code_start; };