nelhage / bemu

A just-in-time compiler for MIT 6.004's "Beta" processor.

This URL has Read+Write access

bemu / bt.h
100644 34 lines (27 sloc) 0.962 kb
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
#ifndef __BT_H__
#define __BT_H__
 
#define MAX_BYTES_PER_INSTRUCTION 24
#define MAX_FRAG_SIZE 10
#define PC_CHECK_SIZE 12
#define CCBUFF_PROLOGUE_SIZE 26
#define CCBUFF_EPILOGUE_SIZE 11
#define CCBUFF_MAX_SIZE (MAX_BYTES_PER_INSTRUCTION * \
MAX_FRAG_SIZE \
+ CCBUFF_EPILOGUE_SIZE \
+ CCBUFF_PROLOGUE_SIZE \
+ PC_CHECK_SIZE)
#define PGSIZE 0x1000
 
typedef struct {
    byteptr start_pc;
    bdecode insts[MAX_FRAG_SIZE];
    bool tail;
    uint8_t ninsts;
} decode_frag;
 
typedef struct compiled_frag {
    byteptr start_pc;
    struct compiled_frag *hash_next;
    uint8_t *code;
} compiled_frag;
 
#define HASH_PC(pc) (((pc) >> 2) & 0xFF)
 
void bt_run();
 
#endif