-
Notifications
You must be signed in to change notification settings - Fork 0
/
asm.h
66 lines (56 loc) · 1.03 KB
/
asm.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef ASM_H
#define ASM_H
#include <stdint.h>
#include <stdio.h>
#include <stdbool.h>
#include "asm_types.h"
#include "env.h"
typedef enum {
OPERAND_REG,
OPERAND_MEM_LOC,
OPERAND_VAR,
OPERAND_IMM,
OPERAND_LABEL,
} operand_type_t;
typedef struct {
string_t *name;
enum {
LABEL_STATIC,
LABEL_GLOBAL,
} linkage;
} label_t;
typedef struct {
operand_type_t type;
union {
reg_t reg;
mem_loc_t mem;
//var_t var;
imm_t imm;
string_t *label;
};
} operand_t;
// TODO do all instructions have only one or two operands?
typedef struct {
opcode_t op;
int num_args;
operand_t src;
operand_t dst;
} instr_t;
typedef enum {
OUTPUT_INSTR,
OUTPUT_LABEL,
} output_type_t;
typedef struct {
output_type_t type;
union {
instr_t instr;
label_t label;
};
} output_t;
typedef struct {
string_t *return_label;
string_t *iter_continue_label;
string_t *iter_break_label;
env_t *env;
} context_t;
#endif