preliminary work on sea of nodes based intermediate representation.
This commit is contained in:
parent
989a32fa7b
commit
849e0b6863
13 changed files with 918 additions and 58 deletions
63
ir.h
Normal file
63
ir.h
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
#ifndef IR_H
|
||||
#define IR_H
|
||||
|
||||
#include "utils.h"
|
||||
#include "parser.h"
|
||||
|
||||
struct _ir_node;
|
||||
struct symbol_def {
|
||||
struct _ir_node *node;
|
||||
bool is_lvalue;
|
||||
};
|
||||
|
||||
typedef struct { char *key; struct symbol_def *value; } symbol_table;
|
||||
|
||||
typedef enum {
|
||||
OC_START,
|
||||
OC_ADD,
|
||||
OC_SUB,
|
||||
OC_MUL,
|
||||
OC_DIV,
|
||||
OC_MOD,
|
||||
OC_BAND,
|
||||
OC_BOR,
|
||||
OC_BXOR,
|
||||
OC_NEG,
|
||||
OC_EQ,
|
||||
|
||||
OC_CONST_INT,
|
||||
OC_CONST_FLOAT,
|
||||
|
||||
OC_FRAME_PTR,
|
||||
OC_ADDR,
|
||||
|
||||
OC_STORE,
|
||||
OC_LOAD,
|
||||
|
||||
OC_REGION,
|
||||
OC_PHI,
|
||||
|
||||
OC_IF,
|
||||
OC_PROJ,
|
||||
|
||||
OC_STOP,
|
||||
OC_RETURN,
|
||||
|
||||
OC_SCOPE,
|
||||
} opcode;
|
||||
|
||||
typedef struct _ir_node {
|
||||
opcode code;
|
||||
usize id;
|
||||
struct _ir_node **in;
|
||||
struct _ir_node **out;
|
||||
union {
|
||||
i64 const_int;
|
||||
f64 const_float;
|
||||
symbol_table **symbol_tables;
|
||||
} data;
|
||||
} ir_node;
|
||||
|
||||
void ir_build(ast_node *ast);
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue