-
Notifications
You must be signed in to change notification settings - Fork 0
/
compiler.h
55 lines (42 loc) · 1.38 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
#ifndef COMPILER_H
#define COMPILER_H
#include "program.h"
struct compiler;
enum compile_target_arch {
COMPILE_TARGET_ARCH_NATIVE,
COMPILE_TARGET_ARCH_MACOS_ARM64,
COMPILE_TARGET_ARCH_MACOS_X86_64,
COMPILE_TARGET_ARCH_EEP
};
enum compile_log_flags {
COMPILE_LOG_FLAGS_NONE = 0,
COMPILE_LOG_FLAGS_PREPROC = 1,
COMPILE_LOG_FLAGS_PARSE = 2,
COMPILE_LOG_FLAGS_TYPECHK = 4,
COMPILE_LOG_FLAGS_IR = 8,
COMPILE_LOG_FLAGS_REGALLOC = 16,
COMPILE_LOG_FLAGS_PRE_EMIT = 32,
COMPILE_LOG_FLAGS_EMIT = 64,
COMPILE_LOG_FLAGS_ASM = 128,
COMPILE_LOG_FLAGS_ALL = -1,
};
#define COMPILER_LOG_ENABLED(compiler, flag) compiler->args.log_flags &flag
struct compile_args {
enum compile_target_arch target_arch;
enum compile_log_flags log_flags;
size_t num_include_paths;
const char **include_paths;
char *output;
};
enum compiler_create_result {
COMPILER_CREATE_RESULT_SUCCESS,
COMPILER_CREATE_RESULT_FAILURE
};
enum compile_result { COMPILE_RESULT_SUCCESS = 0, COMPILE_RESULT_BAD_FILE };
enum compiler_create_result create_compiler(struct program *program,
const char *output,
const struct compile_args *args,
struct compiler **compiler);
enum compile_result compile(struct compiler *compiler);
void free_compiler(struct compiler **compiler);
#endif