-
Notifications
You must be signed in to change notification settings - Fork 0
/
compiler.h
74 lines (58 loc) · 1.76 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
#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_LINUX_ARM64,
COMPILE_TARGET_ARCH_EEP,
COMPILE_TARGET_ARCH_RV32I
};
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_LOWER = 32,
COMPILE_LOG_FLAGS_REGALLOC = 64,
COMPILE_LOG_FLAGS_EMIT = 256,
COMPILE_LOG_FLAGS_ASM = 512,
COMPILE_LOG_FLAGS_ALL = -1,
};
enum compile_c_standard {
COMPILE_C_STANDARD_C11,
COMPILE_C_STANDARD_C17,
COMPILE_C_STANDARD_C23,
};
#define COMPILER_LOG_ENABLED(compiler, flag) compiler->args.log_flags &flag
struct compile_args {
enum compile_c_standard c_standard;
enum compile_target_arch target_arch;
enum compile_log_flags log_flags;
bool preproc_only;
bool build_object_file;
size_t num_include_paths;
const char **include_paths;
const char *fixed_timestamp;
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,
COMPILE_RESULT_FAILURE
};
enum compiler_create_result create_compiler(struct program *program,
const char *output,
const char *working_dir,
const struct compile_args *args,
struct compiler **compiler);
enum compile_result compile(struct compiler *compiler);
void free_compiler(struct compiler **compiler);
#endif