2016-09-18 21:24:54 +00:00
|
|
|
#ifndef IR_H
|
|
|
|
#define IR_H
|
|
|
|
|
2016-09-23 21:59:15 +00:00
|
|
|
#include "ircodes.h"
|
|
|
|
|
2016-09-18 21:24:54 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
IRR_LB = -1,
|
|
|
|
IRR_AB = -2,
|
|
|
|
IRR_SP = -3,
|
|
|
|
IRR_RR = -4,
|
|
|
|
};
|
|
|
|
|
2016-09-21 22:15:48 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
IRS_1,
|
|
|
|
IRS_2,
|
|
|
|
IRS_4,
|
|
|
|
IRS_8
|
|
|
|
};
|
|
|
|
|
2016-09-18 21:24:54 +00:00
|
|
|
struct ir
|
|
|
|
{
|
|
|
|
int id;
|
2016-09-23 21:59:15 +00:00
|
|
|
enum ir_opcode opcode;
|
2016-09-18 21:24:54 +00:00
|
|
|
int size;
|
2016-09-19 21:06:59 +00:00
|
|
|
struct ir* left;
|
|
|
|
struct ir* right;
|
2016-09-22 21:19:29 +00:00
|
|
|
union
|
|
|
|
{
|
2016-09-18 21:24:54 +00:00
|
|
|
arith ivalue;
|
|
|
|
int rvalue;
|
|
|
|
const char* lvalue;
|
|
|
|
struct basicblock* bvalue;
|
|
|
|
} u;
|
2016-09-24 20:46:08 +00:00
|
|
|
|
|
|
|
void* state_label; /* used by the iburg instruction selector */
|
2016-09-25 20:17:14 +00:00
|
|
|
int insn_no;
|
2016-09-24 20:46:08 +00:00
|
|
|
|
2016-09-19 21:06:59 +00:00
|
|
|
bool is_sequence : 1;
|
2016-09-24 20:46:08 +00:00
|
|
|
bool is_generated : 1;
|
2016-09-18 21:24:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern const char* ir_names[];
|
|
|
|
|
|
|
|
extern struct ir* new_ir0(int opcode, int size);
|
|
|
|
extern struct ir* new_ir1(int opcode, int size,
|
|
|
|
struct ir* c1);
|
|
|
|
extern struct ir* new_ir2(int opcode, int size,
|
|
|
|
struct ir* c1, struct ir* c2);
|
|
|
|
|
|
|
|
extern struct ir* new_labelir(const char* label);
|
|
|
|
extern struct ir* new_wordir(arith value);
|
2016-09-21 22:15:48 +00:00
|
|
|
extern struct ir* new_constir(int size, arith value);
|
2016-09-18 21:24:54 +00:00
|
|
|
extern struct ir* new_bbir(struct basicblock* bb);
|
|
|
|
extern struct ir* new_anyir(int size);
|
2016-09-21 22:15:48 +00:00
|
|
|
extern struct ir* new_localir(int offset);
|
2016-09-18 21:24:54 +00:00
|
|
|
|
2016-09-23 21:59:15 +00:00
|
|
|
typedef bool ir_walker_t(struct ir* node, void* user);
|
|
|
|
extern struct ir* ir_walk(struct ir* ir, ir_walker_t* callback, void* user);
|
2016-09-22 21:19:29 +00:00
|
|
|
extern struct ir* ir_find(struct ir* ir, int opcode);
|
|
|
|
|
2016-09-21 22:15:48 +00:00
|
|
|
extern void ir_print(char k, const struct ir* ir);
|
|
|
|
|
2016-09-18 21:24:54 +00:00
|
|
|
#endif
|
|
|
|
|