codegen: introduce cg-spill.inc
[ajla.git] / ajla.c
blob3fc3f6c60b9430343cba44cdbd6c53a871aa1114
1 /*
2 * Copyright (C) 2024 Mikulas Patocka
4 * This file is part of Ajla.
6 * Ajla is free software: you can redistribute it and/or modify it under the
7 * terms of the GNU General Public License as published by the Free Software
8 * Foundation, either version 3 of the License, or (at your option) any later
9 * version.
11 * Ajla is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along with
16 * Ajla. If not, see <https://www.gnu.org/licenses/>.
19 #include "ajla.h"
21 #include "args.h"
22 #include "amalloc.h"
23 #include "mem_al.h"
24 #include "obj_reg.h"
25 #include "os.h"
26 #include "asm.h"
27 #include "codegen.h"
28 #include "mpint.h"
29 #include "thread.h"
30 #include "addrlock.h"
31 #include "type.h"
32 #include "data.h"
33 #include "arindex.h"
34 #include "funct.h"
35 #include "pcode.h"
36 #include "profile.h"
37 #include "builtin.h"
38 #include "save.h"
39 #include "module.h"
40 #include "tick.h"
41 #include "timer.h"
42 #include "iomux.h"
43 #include "resolver.h"
44 #include "task.h"
46 extern_const bool dll = false;
47 int retval = 0;
49 int main(int argc, const char * const argv[])
51 #ifdef OS_OS2
52 EXCEPTIONREGISTRATIONRECORD ex;
53 APIRET r;
54 #endif
55 error_init();
56 args_init(argc, argv);
57 amalloc_init();
58 mem_init();
59 obj_registry_init();
60 os_init();
61 asm_init();
62 codegen_init();
63 mpint_init();
64 thread_init();
65 error_init_multithreaded();
66 mem_init_multithreaded();
67 obj_registry_init_multithreaded();
68 address_lock_init();
69 os_init_multithreaded();
70 #ifdef OS_OS2
71 ex.ExceptionHandler = os2_exception_handler;
72 r = DosSetExceptionHandler(&ex);
73 if (unlikely(r))
74 fatal("DosSetExceptionHandler failed: %ld", r);
75 #endif
76 amalloc_init_multithreaded();
77 type_init();
78 data_init();
79 array_index_init();
80 function_init();
81 pcode_init();
82 profile_init();
83 ipio_init();
84 save_init();
85 builtin_init();
86 module_init();
87 ipret_init();
88 tick_init();
89 timer_init();
90 iomux_init();
91 resolver_init();
92 task_init();
94 bist();
96 program_run();
98 task_run();
100 task_done();
101 resolver_done();
102 iomux_done();
103 timer_done();
104 tick_done();
105 ipret_done();
106 module_done();
107 builtin_done();
108 save_done();
109 ipio_done();
110 profile_done();
111 pcode_done();
112 function_done();
113 array_index_done();
114 data_done();
115 type_done();
116 amalloc_done_multithreaded();
117 #ifdef OS_OS2
118 r = DosUnsetExceptionHandler(&ex);
119 if (unlikely(r))
120 fatal("DosUnsetExceptionHandler failed: %ld", r);
121 #endif
122 os_done_multithreaded();
123 address_lock_done();
124 obj_registry_done_multithreaded();
125 mem_done_multithreaded();
126 error_done_multithreaded();
127 thread_done();
128 mpint_done();
129 codegen_done();
130 asm_done();
131 os_done();
132 obj_registry_done();
133 mem_done();
134 amalloc_done();
135 args_done();
136 error_done();
137 return retval;