[qfcc] Record actual statements in a function

This is to help with building ud-chains as I suspect I won't be all that
interested in defs from the dummy blocks.
This commit is contained in:
Bill Currie 2023-05-19 17:50:19 +09:00
parent 74e15fc582
commit 0c116b8ff0
3 changed files with 6 additions and 2 deletions

View file

@ -118,6 +118,7 @@ typedef struct function_s {
int num_vars; ///< total number of variables referenced
struct set_s *global_vars;///< set indicating which vars are global
struct set_s *param_vars; ///< set indicating which vars are params
struct set_s *real_statements;///< actual statements for ud-chaining
struct statement_s **statements;
int num_statements;
int pseudo_addr;///< pseudo address space for flow analysis

View file

@ -108,12 +108,12 @@ typedef enum {
typedef struct statement_s {
struct statement_s *next;
st_type_t type;
int number; ///< number of this statement in function
const char *opcode;
operand_t *opa;
operand_t *opb;
operand_t *opc;
struct expr_s *expr; ///< source expression for this statement
int number; ///< number of this statement in function
operand_t *use; ///< list of auxiliary operands used
operand_t *def; ///< list of auxiliary operands defined
operand_t *kill; ///< list of auxiliary operands killed

View file

@ -530,9 +530,12 @@ flow_build_statements (function_t *func)
func->statements = malloc (num_statements * sizeof (statement_t *));
func->num_statements = num_statements;
func->real_statements = set_new ();
for (sblock = func->sblock; sblock; sblock = sblock->next) {
for (s = sblock->statements; s; s = s->next)
for (s = sblock->statements; s; s = s->next) {
func->statements[s->number] = s;
set_add (func->real_statements, s->number);
}
}
}