2016-09-24 20:46:08 +00:00
|
|
|
#ifndef MCGG_H
|
|
|
|
#define MCGG_H
|
|
|
|
|
|
|
|
/* Excruciating macro which packs ir opcodes and sizes into an int for iburg's benefit.
|
|
|
|
*
|
2016-10-23 19:54:14 +00:00
|
|
|
* Types are mapped to: I=1, F=2, L=3, D=4
|
2016-09-24 20:46:08 +00:00
|
|
|
*/
|
2016-10-23 19:54:14 +00:00
|
|
|
#define ir_to_esn(iropcode, type) \
|
|
|
|
((iropcode)*5 + \
|
|
|
|
(((type) == 'I') ? 1 : \
|
|
|
|
((type) == 'F') ? 2 : \
|
|
|
|
((type) == 'L') ? 3 : \
|
|
|
|
((type) == 'D') ? 4 : 0))
|
2016-09-24 20:46:08 +00:00
|
|
|
|
|
|
|
#define STATE_TYPE void*
|
|
|
|
|
|
|
|
#define STATE_LABEL(p) ((p)->state_label)
|
2016-10-03 18:52:36 +00:00
|
|
|
#define OP_LABEL(p) ((p)->label)
|
|
|
|
#define LEFT_CHILD(p) ((p)->left)
|
|
|
|
#define RIGHT_CHILD(p) ((p)->right)
|
2016-09-24 20:46:08 +00:00
|
|
|
|
2016-10-03 18:52:36 +00:00
|
|
|
struct burm_node
|
|
|
|
{
|
|
|
|
int label;
|
|
|
|
void* state_label;
|
|
|
|
struct burm_node* left;
|
|
|
|
struct burm_node* right;
|
|
|
|
struct ir* ir;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct burm_node* NODEPTR_TYPE;
|
|
|
|
|
|
|
|
extern void* burm_label(NODEPTR_TYPE node);
|
2016-09-24 20:46:08 +00:00
|
|
|
extern int burm_rule(void* state, int goalnt);
|
|
|
|
extern const short *burm_nts[];
|
2016-10-03 18:52:36 +00:00
|
|
|
extern NODEPTR_TYPE* burm_kids(NODEPTR_TYPE p, int eruleno, NODEPTR_TYPE kids[]);
|
|
|
|
extern void burm_trace(NODEPTR_TYPE p, int ruleno, int cost, int bestcost);
|
2016-09-24 20:46:08 +00:00
|
|
|
|
2016-09-25 09:49:51 +00:00
|
|
|
struct burm_emitter_data
|
|
|
|
{
|
|
|
|
void (*emit_string)(const char* data);
|
2016-10-03 22:16:06 +00:00
|
|
|
void (*emit_fragment)(int child);
|
2016-10-21 21:31:00 +00:00
|
|
|
void (*emit_return_reg)(int index);
|
|
|
|
void (*emit_reg)(int child, int index);
|
2016-10-03 22:16:06 +00:00
|
|
|
void (*emit_value)(int child);
|
2016-09-25 10:18:39 +00:00
|
|
|
void (*emit_eoi)(void);
|
2016-10-09 13:09:34 +00:00
|
|
|
void (*constrain_input_reg)(int child, uint32_t attr);
|
2016-10-29 18:22:44 +00:00
|
|
|
void (*constrain_input_reg_preserved)(int child);
|
2016-10-09 13:09:34 +00:00
|
|
|
void (*constrain_output_reg)(uint32_t attr);
|
2016-10-14 20:17:02 +00:00
|
|
|
void (*constrain_output_reg_equal_to)(int child);
|
2016-09-25 09:49:51 +00:00
|
|
|
};
|
|
|
|
|
2016-10-03 22:16:06 +00:00
|
|
|
typedef void burm_emitter_t(const struct burm_emitter_data* data);
|
2016-09-25 15:14:54 +00:00
|
|
|
|
|
|
|
struct burm_instruction_data
|
|
|
|
{
|
|
|
|
const char* name;
|
|
|
|
burm_emitter_t* emitter;
|
|
|
|
bool is_fragment;
|
2016-10-14 23:15:08 +00:00
|
|
|
uint32_t corrupts;
|
2016-09-25 15:14:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern const struct burm_instruction_data burm_instruction_data[];
|
2016-09-29 20:32:43 +00:00
|
|
|
|
|
|
|
struct burm_register_data
|
|
|
|
{
|
2016-10-21 21:31:00 +00:00
|
|
|
const char* id;
|
2016-10-05 19:00:28 +00:00
|
|
|
uint32_t attrs;
|
2016-10-21 21:31:00 +00:00
|
|
|
const char** names;
|
2016-10-20 19:47:28 +00:00
|
|
|
const struct burm_register_data** aliases;
|
2016-09-29 20:32:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern const struct burm_register_data burm_register_data[];
|
2016-09-25 21:29:59 +00:00
|
|
|
extern const char* burm_register_class_names[];
|
2016-09-25 09:49:51 +00:00
|
|
|
|
2016-10-05 20:56:25 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
NONTERM_STMT = 1
|
|
|
|
};
|
|
|
|
|
2016-09-24 20:46:08 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* vim: set sw=4 ts=4 expandtab : */
|