2016-09-17 22:02:16 +00:00
|
|
|
#ifndef MCG_H
|
|
|
|
#define MCG_H
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <assert.h>
|
2016-10-18 20:29:42 +00:00
|
|
|
#include "flt_arith.h"
|
2016-09-17 22:02:16 +00:00
|
|
|
#include "em_arith.h"
|
|
|
|
#include "em_label.h"
|
|
|
|
#include "em.h"
|
|
|
|
#include "em_comp.h"
|
|
|
|
#include "em_pseu.h"
|
|
|
|
#include "em_mnem.h"
|
|
|
|
#include "em_flag.h"
|
|
|
|
#include "em_ptyp.h"
|
2016-09-18 21:24:54 +00:00
|
|
|
#include "array.h"
|
2016-10-01 22:30:33 +00:00
|
|
|
#include "imap.h"
|
2016-10-01 10:17:14 +00:00
|
|
|
#include "pmap.h"
|
2016-09-30 17:10:30 +00:00
|
|
|
#include "diagnostics.h"
|
|
|
|
#include "astring.h"
|
2016-09-18 21:24:54 +00:00
|
|
|
#include "ir.h"
|
2016-09-25 21:29:59 +00:00
|
|
|
#include "mcgg.h"
|
2016-10-05 19:00:28 +00:00
|
|
|
#include "reg.h"
|
2016-10-08 21:32:54 +00:00
|
|
|
#include "hop.h"
|
2016-10-02 15:50:34 +00:00
|
|
|
#include "basicblock.h"
|
2016-10-01 22:30:33 +00:00
|
|
|
#include "procedure.h"
|
2016-10-06 19:34:21 +00:00
|
|
|
#include "graph.h"
|
2016-10-15 16:38:46 +00:00
|
|
|
#include "tables.h"
|
2016-09-17 22:02:16 +00:00
|
|
|
|
|
|
|
extern char em_pseu[][4];
|
|
|
|
extern char em_mnem[][4];
|
|
|
|
extern char em_flag[];
|
|
|
|
|
2016-09-18 21:24:54 +00:00
|
|
|
enum {
|
|
|
|
SECTION_UNKNOWN = 0,
|
|
|
|
SECTION_ROM,
|
|
|
|
SECTION_DATA,
|
|
|
|
SECTION_BSS,
|
|
|
|
SECTION_TEXT
|
|
|
|
};
|
|
|
|
|
2016-09-19 21:06:59 +00:00
|
|
|
struct symbol
|
|
|
|
{
|
2016-09-18 21:24:54 +00:00
|
|
|
const char* name;
|
|
|
|
int section;
|
2016-09-23 23:04:00 +00:00
|
|
|
struct procedure* proc;
|
2016-09-18 21:24:54 +00:00
|
|
|
bool is_defined : 1;
|
|
|
|
bool is_exported : 1;
|
|
|
|
bool is_proc : 1;
|
|
|
|
};
|
|
|
|
|
2016-09-19 21:06:59 +00:00
|
|
|
enum
|
|
|
|
{
|
2016-09-18 21:24:54 +00:00
|
|
|
PARAM_NONE,
|
2016-09-19 21:06:59 +00:00
|
|
|
PARAM_IVALUE,
|
|
|
|
PARAM_LVALUE,
|
|
|
|
PARAM_BVALUE,
|
|
|
|
};
|
|
|
|
|
2016-09-25 10:29:03 +00:00
|
|
|
struct em
|
2016-09-19 21:06:59 +00:00
|
|
|
{
|
|
|
|
int opcode;
|
|
|
|
int paramtype;
|
|
|
|
union {
|
|
|
|
arith ivalue;
|
|
|
|
struct {
|
|
|
|
const char* label;
|
|
|
|
arith offset;
|
|
|
|
} lvalue;
|
|
|
|
struct {
|
|
|
|
struct basicblock* left;
|
|
|
|
struct basicblock* right;
|
|
|
|
} bvalue;
|
|
|
|
} u;
|
|
|
|
};
|
|
|
|
|
2016-09-18 21:24:54 +00:00
|
|
|
extern const char* aprintf(const char* fmt, ...);
|
2016-09-21 22:15:48 +00:00
|
|
|
extern void tracef(char k, const char* fmt, ...);
|
|
|
|
extern bool tracing(char k);
|
2016-09-17 22:02:16 +00:00
|
|
|
|
|
|
|
extern void parse_em(void);
|
|
|
|
|
2016-09-18 21:24:54 +00:00
|
|
|
extern void symbol_init(void);
|
|
|
|
extern bool symbol_exists(const char* name);
|
|
|
|
extern struct symbol* symbol_get(const char* name);
|
|
|
|
extern void symbol_declare(const char* name, bool is_exported, bool is_proc);
|
|
|
|
|
2016-09-23 23:04:00 +00:00
|
|
|
typedef bool symbol_walker_t(struct symbol* symbol, void* user);
|
|
|
|
extern struct symbol* symbol_walk(symbol_walker_t* walker, void* user);
|
|
|
|
|
2016-09-18 21:24:54 +00:00
|
|
|
extern void data_label(const char* name);
|
|
|
|
extern void data_int(arith data, size_t size, bool is_ro);
|
2016-10-18 20:29:42 +00:00
|
|
|
extern void data_float(const char* data, size_t size, bool is_ro);
|
2016-09-18 21:24:54 +00:00
|
|
|
extern void data_block(const uint8_t* data, size_t size, bool is_ro);
|
|
|
|
extern void data_offset(const char* label, arith offset, bool is_ro);
|
|
|
|
extern void data_bss(arith size, int init);
|
|
|
|
|
2016-09-17 22:02:16 +00:00
|
|
|
extern void tb_filestart(void);
|
|
|
|
extern void tb_fileend(void);
|
2016-10-15 21:19:44 +00:00
|
|
|
extern void tb_procedure(void);
|
2016-10-01 22:30:33 +00:00
|
|
|
extern void tb_regvar(struct procedure* proc, arith offset, int size, int type, int priority);
|
2016-09-17 22:02:16 +00:00
|
|
|
|
2016-10-15 21:19:44 +00:00
|
|
|
extern void pass_convert_locals_to_ssa(void);
|
|
|
|
extern void pass_convert_stack_ops(void);
|
|
|
|
extern void pass_eliminate_trivial_blocks(void);
|
2016-10-09 20:04:20 +00:00
|
|
|
extern void pass_find_phi_congruence_groups(void);
|
2016-10-15 21:19:44 +00:00
|
|
|
extern void pass_group_irs(void);
|
2016-10-10 21:19:46 +00:00
|
|
|
extern void pass_insert_moves(void);
|
2016-10-07 22:21:23 +00:00
|
|
|
extern void pass_instruction_selector(void);
|
|
|
|
extern void pass_live_vreg_analysis(void);
|
2016-10-15 21:19:44 +00:00
|
|
|
extern void pass_add_prologue_epilogue(void);
|
|
|
|
extern void pass_promote_float_ops(void);
|
|
|
|
extern void pass_register_allocator(void);
|
|
|
|
extern void pass_remove_dead_blocks(void);
|
2016-10-12 19:50:12 +00:00
|
|
|
extern void pass_remove_dead_phis(void);
|
2016-10-15 21:19:44 +00:00
|
|
|
extern void pass_split_critical_edges(void);
|
2016-09-22 21:19:29 +00:00
|
|
|
|
2016-10-15 21:19:44 +00:00
|
|
|
extern void platform_calculate_offsets(void);
|
|
|
|
extern struct hop* platform_prologue(void);
|
|
|
|
extern struct hop* platform_epilogue(void);
|
2016-10-15 16:38:46 +00:00
|
|
|
extern struct hop* platform_move(struct basicblock* bb, struct hreg* src, struct hreg* dest);
|
|
|
|
|
2016-10-10 22:12:11 +00:00
|
|
|
extern FILE* outputfile;
|
2016-10-07 22:21:23 +00:00
|
|
|
extern FILE* dominance_dot_file;
|
|
|
|
extern FILE* cfg_dot_file;
|
|
|
|
|
2016-09-17 22:02:16 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* vim: set sw=4 ts=4 expandtab : */
|