-
Notifications
You must be signed in to change notification settings - Fork 0
/
compiler.h
84 lines (63 loc) · 1.62 KB
/
compiler.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef uint32_t u32;
#define VERBOSE
#ifdef VERBOSE
#define verbose_printf(...) printf(__VA_ARGS__)
#else
#define verbose_printf(...) ;
#endif
#define LEN(X) (sizeof((X)) / sizeof(*(X)))
#define log(...) fprintf(stderr, __VA_ARGS__)
u32 initMemsetCount = 0, initMemsetZeroCount = 0, msSimpleCount = 0;
/** input = input as bytes, mem = main memory, s = length(mem) */
bool *filled;
u32 *input, *mem, s;
void finish(int status);
#define SADGE(s) \
{ \
printf(s "\n"); \
finish(1); \
}
FILE *cacheFile;
typedef struct TsfavCacheData {
u32 searchIdx;
u32 resolvedIdx;
u32 value;
u32 A;
u32 B;
u32 C;
u32 D;
} TsfavCacheData;
typedef struct TsfavCacheNode {
TsfavCacheData data;
struct TsfavCacheNode *next;
} TsfavCacheNode;
TsfavCacheNode *tsfavHead;
TsfavCacheNode *tsfavTail;
#define CACHE_FILE "cache/tsfav"
#define SETSZ (1 << 18)
#define MINLOOKUP (1 << 11)
// value in set if thing[value % n % SETSZ] == value
typedef struct Set {
u32 n;
u32 thing[SETSZ];
} Set;
FILE *labelsFile;
typedef struct Label {
u32 pos;
char *name;
bool is_from_label_pass;
} Label;
Label *labels;
u32 num_labels = 0;
#define LABEL_NOT_DEFINED (-1)
typedef struct Mnemonic {
u32 value;
char *name;
} Mnemonic;
#define NO_NEXT_POS (-1)
FILE *inputFile;