2011-01-19 06:47:45 +00:00
|
|
|
/*
|
|
|
|
statement.h
|
|
|
|
|
|
|
|
Internal statements
|
|
|
|
|
|
|
|
Copyright (C) 2011 Bill Currie <bill@taniwha.org>
|
|
|
|
|
|
|
|
Author: Bill Currie <bill@taniwha.org>
|
|
|
|
Date: 2011/01/18
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
#ifndef statement_h
|
|
|
|
#define statement_h
|
|
|
|
|
2012-05-08 02:43:29 +00:00
|
|
|
#include "QF/pr_comp.h"
|
|
|
|
|
2011-01-19 06:47:45 +00:00
|
|
|
typedef enum {
|
|
|
|
op_symbol,
|
|
|
|
op_value,
|
|
|
|
op_label,
|
|
|
|
op_temp,
|
2011-02-08 05:45:48 +00:00
|
|
|
op_pointer,
|
2011-03-03 04:46:07 +00:00
|
|
|
op_alias,
|
2011-01-19 06:47:45 +00:00
|
|
|
} op_type_e;
|
|
|
|
|
2012-07-16 08:37:13 +00:00
|
|
|
typedef struct {
|
|
|
|
struct def_s *def;
|
|
|
|
struct daglabel_s *daglabel;
|
|
|
|
} tempop_t;
|
|
|
|
|
2011-01-19 06:47:45 +00:00
|
|
|
typedef struct operand_s {
|
|
|
|
struct operand_s *next;
|
2011-01-21 01:54:40 +00:00
|
|
|
op_type_e op_type;
|
|
|
|
etype_t type; ///< possibly override symbol's type
|
2011-03-23 12:32:14 +00:00
|
|
|
int size; ///< for structures
|
2011-01-19 06:47:45 +00:00
|
|
|
union {
|
|
|
|
struct symbol_s *symbol;
|
|
|
|
struct ex_value_s *value;
|
|
|
|
struct ex_label_s *label;
|
2012-07-16 08:37:13 +00:00
|
|
|
tempop_t tempop;
|
2011-03-03 04:46:07 +00:00
|
|
|
struct operand_s *alias;
|
2011-01-19 06:47:45 +00:00
|
|
|
} o;
|
|
|
|
} operand_t;
|
|
|
|
|
|
|
|
typedef struct statement_s {
|
|
|
|
struct statement_s *next;
|
|
|
|
const char *opcode;
|
|
|
|
operand_t *opa;
|
|
|
|
operand_t *opb;
|
|
|
|
operand_t *opc;
|
2012-11-05 06:21:40 +00:00
|
|
|
struct expr_s *expr; ///< source expression for this statement
|
|
|
|
int number; ///< number of this statement in function
|
2011-01-19 06:47:45 +00:00
|
|
|
} statement_t;
|
|
|
|
|
|
|
|
typedef struct sblock_s {
|
|
|
|
struct sblock_s *next;
|
2011-01-25 06:45:31 +00:00
|
|
|
struct reloc_s *relocs;
|
2011-01-28 02:41:53 +00:00
|
|
|
struct ex_label_s *labels;
|
2012-07-18 06:29:30 +00:00
|
|
|
struct dagnode_s *dag;
|
2011-01-25 06:45:31 +00:00
|
|
|
int offset; ///< offset of first statement of block
|
2011-01-28 02:41:53 +00:00
|
|
|
int reachable;
|
2012-10-30 08:41:40 +00:00
|
|
|
int number; ///< number of this block in flow graph
|
2011-01-19 06:47:45 +00:00
|
|
|
statement_t *statements;
|
|
|
|
statement_t **tail;
|
|
|
|
} sblock_t;
|
|
|
|
|
|
|
|
struct expr_s;
|
|
|
|
|
|
|
|
sblock_t *make_statements (struct expr_s *expr);
|
|
|
|
void print_statement (statement_t *s);
|
2012-11-01 03:19:38 +00:00
|
|
|
void print_sblock (sblock_t *sblock, const char *filename);
|
2012-11-05 05:51:39 +00:00
|
|
|
void dump_sblock (sblock_t *sblock, const char *stage);
|
2012-05-08 02:43:29 +00:00
|
|
|
const char *operand_string (operand_t *op);
|
2011-01-19 06:47:45 +00:00
|
|
|
|
|
|
|
#endif//statement_h
|