├── .gitattributes
├── CMakeLists.txt
├── LICENSE.txt
├── README.md
├── SysY语言定义.pdf
├── SysY运行时库.pdf
├── build.sh
├── readme_images
├── Compiler.png
├── Ideal_Logo_Davies.ico
├── MIT_license.svg
├── result00.png
├── result01.jpeg
├── result02.jpeg
├── result03.jpeg
├── result04.jpeg
├── result05.jpeg
├── result06.jpeg
├── result07.jpeg
└── screenshot.png
├── src
├── back_end
│ ├── arm_generator.cpp
│ ├── arm_generator.h
│ ├── optimizer.cpp
│ └── optimizer.h
├── common
│ ├── config.cpp
│ ├── config.h
│ ├── global.cpp
│ ├── global.h
│ ├── node.cpp
│ ├── node.h
│ ├── type.cpp
│ └── type.h
├── compiler.cpp
├── front_end
│ ├── intermediate_representation.cpp
│ ├── intermediate_representation.h
│ ├── parser.cpp
│ ├── parser.h
│ ├── semantic_analyzer.cpp
│ ├── semantic_analyzer.h
│ ├── tokenize.cpp
│ └── tokenize.h
└── tools
│ ├── common.cpp
│ └── common.h
├── test_sample
├── functional_test
│ ├── 00_arr_defn2.out
│ ├── 00_arr_defn2.sy
│ ├── 00_main.out
│ ├── 00_main.sy
│ ├── 01_var_defn.out
│ ├── 01_var_defn.sy
│ ├── 02_arr_defn4.out
│ ├── 02_arr_defn4.sy
│ ├── 02_var_defn2.out
│ ├── 02_var_defn2.sy
│ ├── 03_arr_defn.out
│ ├── 03_arr_defn.sy
│ ├── 03_var_defn2.out
│ ├── 03_var_defn2.sy
│ ├── 04_const_defn.out
│ ├── 04_const_defn.sy
│ ├── 04_func_defn.out
│ ├── 04_func_defn.sy
│ ├── 05_add.out
│ ├── 05_add.sy
│ ├── 05_const_array_defn.out
│ ├── 05_const_array_defn.sy
│ ├── 06_mod.out
│ ├── 06_mod.sy
│ ├── 06_var_defn_func.out
│ ├── 06_var_defn_func.sy
│ ├── 07_comment1.out
│ ├── 07_comment1.sy
│ ├── 07_return_var.out
│ ├── 07_return_var.sy
│ ├── 08_arr_assign.out
│ ├── 08_arr_assign.sy
│ ├── 08_comment2.out
│ ├── 08_comment2.sy
│ ├── 09_if.out
│ ├── 09_if.sy
│ ├── 09_void_func.out
│ ├── 09_void_func.sy
│ ├── 10_break.out
│ ├── 10_break.sy
│ ├── 10_if_else.out
│ ├── 10_if_else.sy
│ ├── 11_continue.out
│ ├── 11_continue.sy
│ ├── 11_while.out
│ ├── 11_while.sy
│ ├── 12_array_traverse.out
│ ├── 12_array_traverse.sy
│ ├── 12_getint.in
│ ├── 12_getint.out
│ ├── 12_getint.sy
│ ├── 13_and.in
│ ├── 13_and.out
│ ├── 13_and.sy
│ ├── 13_array_traverse2.out
│ ├── 13_array_traverse2.sy
│ ├── 14_or.in
│ ├── 14_or.out
│ ├── 14_or.sy
│ ├── 15_array_test3.out
│ ├── 15_array_test3.sy
│ ├── 15_equal.in
│ ├── 15_equal.out
│ ├── 15_equal.sy
│ ├── 16_greater_eq.out
│ ├── 16_greater_eq.sy
│ ├── 16_nequal.in
│ ├── 16_nequal.out
│ ├── 16_nequal.sy
│ ├── 17_less.in
│ ├── 17_less.out
│ ├── 17_less.sy
│ ├── 17_less_eq.out
│ ├── 17_less_eq.sy
│ ├── 18_cal_prio.in
│ ├── 18_cal_prio.out
│ ├── 18_cal_prio.sy
│ ├── 19_neg_expr.in
│ ├── 19_neg_expr.out
│ ├── 19_neg_expr.sy
│ ├── 20_arr_sum.in
│ ├── 20_arr_sum.out
│ ├── 20_arr_sum.sy
│ ├── 21_suminput.in
│ ├── 21_suminput.out
│ ├── 21_suminput.sy
│ ├── 22_if_test1.out
│ ├── 22_if_test1.sy
│ ├── 23_if_test2.out
│ ├── 23_if_test2.sy
│ ├── 24_if_test3.out
│ ├── 24_if_test3.sy
│ ├── 25_if_test4.out
│ ├── 25_if_test4.sy
│ ├── 26_if_test5.out
│ ├── 26_if_test5.sy
│ ├── 27_while_test1.out
│ ├── 27_while_test1.sy
│ ├── 28_while_test2.out
│ ├── 28_while_test2.sy
│ ├── 29_while_test3.out
│ ├── 29_while_test3.sy
│ ├── 30_while_if_test1.out
│ ├── 30_while_if_test1.sy
│ ├── 31_while_if_test2.out
│ ├── 31_while_if_test2.sy
│ ├── 32_while_if_test3.out
│ ├── 32_while_if_test3.sy
│ ├── 33_func_test1.out
│ ├── 33_func_test1.sy
│ ├── 34_func_test2.out
│ ├── 34_func_test2.sy
│ ├── 35_array_test.out
│ ├── 35_array_test.sy
│ ├── 36_domain_test.out
│ ├── 36_domain_test.sy
│ ├── 38_if_complex_expr.out
│ ├── 38_if_complex_expr.sy
│ ├── 39_assign_complex_expr.out
│ ├── 39_assign_complex_expr.sy
│ ├── 40_index_complex_expr.out
│ ├── 40_index_complex_expr.sy
│ ├── 41_index_arithmetic_expr.out
│ ├── 41_index_arithmetic_expr.sy
│ ├── 42_index_func_ret.out
│ ├── 42_index_func_ret.sy
│ ├── 43_time_prior_plus.out
│ ├── 43_time_prior_plus.sy
│ ├── 44_add_prior_equal.out
│ ├── 44_add_prior_equal.sy
│ ├── 45_equal_prior_logic.out
│ ├── 45_equal_prior_logic.sy
│ ├── 46_and_prior_or.out
│ ├── 46_and_prior_or.sy
│ ├── 47_minus_with_sub.out
│ ├── 47_minus_with_sub.sy
│ ├── 49_decl_in_defn.out
│ ├── 49_decl_in_defn.sy
│ ├── 50_recursion_test1.out
│ ├── 50_recursion_test1.sy
│ ├── 51_recursion_test2.out
│ ├── 51_recursion_test2.sy
│ ├── 52_recursion_test3.out
│ ├── 52_recursion_test3.sy
│ ├── 53_sort_test1.out
│ ├── 53_sort_test1.sy
│ ├── 54_sort_test2.out
│ ├── 54_sort_test2.sy
│ ├── 55_sort_test3.out
│ ├── 55_sort_test3.sy
│ ├── 56_sort_test4.out
│ ├── 56_sort_test4.sy
│ ├── 57_sort_test5.out
│ ├── 57_sort_test5.sy
│ ├── 58_sort_test6.out
│ ├── 58_sort_test6.sy
│ ├── 59_sort_test7.out
│ ├── 59_sort_test7.sy
│ ├── 60_while_fibonacci.in
│ ├── 60_while_fibonacci.out
│ ├── 60_while_fibonacci.sy
│ ├── 61_rec_fibonacci.in
│ ├── 61_rec_fibonacci.out
│ ├── 61_rec_fibonacci.sy
│ ├── 62_long_code.out
│ ├── 62_long_code.sy
│ ├── 63_simple_atoi.in
│ ├── 63_simple_atoi.out
│ ├── 63_simple_atoi.sy
│ ├── 64_alpha_count.in
│ ├── 64_alpha_count.out
│ ├── 64_alpha_count.sy
│ ├── 65_word_count.in
│ ├── 65_word_count.out
│ ├── 65_word_count.sy
│ ├── 66_go_upstairs.out
│ ├── 66_go_upstairs.sy
│ ├── 67_remove_duplicate_element.out
│ ├── 67_remove_duplicate_element.sy
│ ├── 68_accumulate.out
│ ├── 68_accumulate.sy
│ ├── 69_last_word_length.out
│ ├── 69_last_word_length.sy
│ ├── 70_multi.out
│ ├── 70_multi.sy
│ ├── 71_max_subsequence_sum.out
│ ├── 71_max_subsequence_sum.sy
│ ├── 72_enum.out
│ ├── 72_enum.sy
│ ├── 73_exchange_value.in
│ ├── 73_exchange_value.out
│ ├── 73_exchange_value.sy
│ ├── 74_itera_sqrt.out
│ ├── 74_itera_sqrt.sy
│ ├── 75_max_container.out
│ ├── 75_max_container.sy
│ ├── 76_int_factor_sum.out
│ ├── 76_int_factor_sum.sy
│ ├── 77_unique_path.out
│ ├── 77_unique_path.sy
│ ├── 78_decbinoct.out
│ ├── 78_decbinoct.sy
│ ├── 79_gcd.in
│ ├── 79_gcd.out
│ ├── 79_gcd.sy
│ ├── 80_lcm.in
│ ├── 80_lcm.out
│ ├── 80_lcm.sy
│ ├── 81_jump_game.out
│ ├── 81_jump_game.sy
│ ├── 82_int_split.out
│ ├── 82_int_split.sy
│ ├── 83_enc_dec.out
│ ├── 83_enc_dec.sy
│ ├── 84_palindrome_number.out
│ ├── 84_palindrome_number.sy
│ ├── 86_bin_search.in
│ ├── 86_bin_search.out
│ ├── 86_bin_search.sy
│ ├── 88_array_concat.out
│ ├── 88_array_concat.sy
│ ├── 90_insert_order.in
│ ├── 90_insert_order.out
│ ├── 90_insert_order.sy
│ ├── 91_line_search.in
│ ├── 91_line_search.out
│ ├── 91_line_search.sy
│ ├── 92_matrix_add.out
│ ├── 92_matrix_add.sy
│ ├── 93_matrix_sub.out
│ ├── 93_matrix_sub.sy
│ ├── 94_matrix_mul.out
│ ├── 94_matrix_mul.sy
│ ├── 95_matrix_tran.out
│ ├── 95_matrix_tran.sy
│ ├── 96_many_param_call.out
│ ├── 96_many_param_call.sy
│ ├── 97_many_global_var.out
│ ├── 97_many_global_var.sy
│ ├── 98_many_local_var.in
│ ├── 98_many_local_var.out
│ ├── 98_many_local_var.sy
│ ├── 99_register_realloc.out
│ └── 99_register_realloc.sy
└── performance_test
│ ├── 00_bitset1.in
│ ├── 00_bitset1.out
│ ├── 00_bitset1.sy
│ ├── 00_bitset2.in
│ ├── 00_bitset2.out
│ ├── 00_bitset2.sy
│ ├── 00_bitset3.in
│ ├── 00_bitset3.out
│ ├── 00_bitset3.sy
│ ├── 01_mm1.in
│ ├── 01_mm1.out
│ ├── 01_mm1.sy
│ ├── 01_mm2.in
│ ├── 01_mm2.out
│ ├── 01_mm2.sy
│ ├── 01_mm3.in
│ ├── 01_mm3.out
│ ├── 01_mm3.sy
│ ├── 02_mv1.in
│ ├── 02_mv1.out
│ ├── 02_mv1.sy
│ ├── 02_mv2.in
│ ├── 02_mv2.out
│ ├── 02_mv2.sy
│ ├── 02_mv3.in
│ ├── 02_mv3.out
│ ├── 02_mv3.sy
│ ├── 03_sort1.in
│ ├── 03_sort1.out
│ ├── 03_sort1.sy
│ ├── 03_sort2.in
│ ├── 03_sort2.out
│ ├── 03_sort2.sy
│ ├── 03_sort3.in
│ ├── 03_sort3.out
│ ├── 03_sort3.sy
│ ├── 04_spmv1.in
│ ├── 04_spmv1.out
│ ├── 04_spmv1.sy
│ ├── 04_spmv2.in
│ ├── 04_spmv2.out
│ ├── 04_spmv2.sy
│ ├── 04_spmv3.in
│ ├── 04_spmv3.out
│ └── 04_spmv3.sy
└── 项目介绍.pdf
/.gitattributes:
--------------------------------------------------------------------------------
1 | *.in filter=lfs diff=lfs merge=lfs -text
2 | *.pdf filter=lfs diff=lfs merge=lfs -text
3 |
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required (VERSION 2.6)
2 |
3 | # SET (CMAKE_C_COMPILER "/g/sb/llvm/llvm-project-llvmorg-10.0.1/bin/clang")
4 | # SET (CMAKE_CXX_COMPILER "/g/sb/llvm/llvm-project-llvmorg-10.0.1/bin/clang++")
5 | # SET (CMAKE_AR "/g/sb/llvm/llvm-project-llvmorg-10.0.1/bin/llvm-ar")
6 | # SET (CMAKE_LINKER "/g/sb/llvm/llvm-project-llvmorg-10.0.1/bin/llvm-ld")
7 | # SET (CMAKE_NM "/g/sb/llvm/llvm-project-llvmorg-10.0.1/bin/llvm-nm")
8 | # SET (CMAKE_OBJDUMP "/g/sb/llvm/llvm-project-llvmorg-10.0.1/bin/llvm-objdump")
9 | # SET (CMAKE_RANLIB "/g/sb/llvm/llvm-project-llvmorg-10.0.1/bin/llvm-ranlib")
10 |
11 | # set(CMAKE_CXX_STANDARD 17)
12 | # set(CMAKE_CXX_STANDARD_REQUIRED ON)
13 | # set(CMAKE_CXX_EXTENSIONS OFF)
14 |
15 | project (compiler)
16 |
17 | file(GLOB_RECURSE src_cpp RELATIVE ${CMAKE_SOURCE_DIR}
18 | "src/*.cpp"
19 | )
20 | file(GLOB_RECURSE src_c RELATIVE ${CMAKE_SOURCE_DIR}
21 | "src/*.c"
22 | )
23 |
24 | message(STATUS ${src})
25 |
26 | add_executable(
27 | compiler
28 | ${src_cpp}
29 | ${src_c}
30 | )
31 |
32 | set_property(TARGET compiler PROPERTY C_STANDARD 11)
33 | # set_property(TARGET compiler PROPERTY CXX_STANDARD 17)
34 | ADD_DEFINITIONS("-std=c++17")
35 | # ADD_DEFINITIONS("-O2")
36 | ADD_DEFINITIONS("-O0")
37 |
38 | target_link_libraries(compiler m)
39 |
40 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Davies
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [![MIT License][license-shield]][license-url]
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
Maked by Davies
12 |
13 |
14 | Email: 1182176003@qq.com
15 |
24 |
25 |
26 |
27 |
28 |
29 |
30 | ## Table of Contents
31 |
32 | * [About the Project](#about-the-project)
33 | * [Built With](#built-with)
34 | * [Getting Started](#getting-started)
35 | * [Prerequisites](#prerequisites)
36 | * [Installation](#installation)
37 | * [Usage](#usage)
38 | * [功能定制](#功能定制)
39 | * [Roadmap](#roadmap)
40 | * [Contributing](#contributing)
41 | * [License](#license)
42 | * [Contact](#contact)
43 | * [Acknowledgements](#acknowledgements)
44 | * [免责声明](#免责声明)
45 |
46 |
47 |
48 | ## About The Project
49 |
50 | **注意:如果仓库下载不了或者下载不全,请到release中去下载**
51 | 这个项目是我在没学过编译原理的情况下,看了几篇编译相关的文章,然后跟着感觉写的,里面有些编译流程可能不是标准的。编译过程中没有生成中间代码,直接从源代码构建语法树,然后根据语法树生成机器代码。这个项目是最终是用来参加一个编译优化比赛的,编写过程都是从简考虑,基本没有注释,但是变量名和函数名对功能的解释比较清楚。
52 | 如果您使用这个代码来学习编译原理,并在原代码的基础上做了优化改进或者添加了注释,可以考虑提交一个pull request整合到该仓库里面,这将极大的方便他人的学习,感谢您的付出。
53 |
54 | 该项目参考开源编译器9cc开发 [https://github.com/rui314/9cc](https://github.com/rui314/9cc)
55 |
56 |
57 | 运行结果:(其中有一个样例是RE,可能是由于我们函数合并的优化没有考虑数组传入的情况)
58 |
59 | [![Product Name Screen Shot][product-screenshot00]](https://github.com/DaviesGit)
60 |
61 | 编译器一共包括`词法分析`、`语法分析`、`语义分析`、`优化`、`目标代码`等6个部分。
62 |
63 | 
64 |
65 | 语法树结构部分:
66 |
67 | 
68 |
69 | 词法分析部分:
70 |
71 | 
72 |
73 | 语法分析部分:
74 |
75 | 
76 |
77 | 语义分析部分:
78 |
79 | 
80 |
81 | 目标代码生成部分:
82 |
83 | 
84 |
85 | 代码优化部分:
86 |
87 | 
88 |
89 | 系统架构:
90 |
91 | 
92 |
93 | SysY 语言是 C 语言的一个子集。每个 SysY程序的源码存储在一个扩展名为 sy 的文件中。该文件中有且仅有一个名为 main的主函数定义,还可以包含若干全局变量声明、常量声明和其他函数定义。SysY语言支持 int 类型和元素为 int 类型且按行优先存储的多维数组类型,其中 int 型整数为 32 位有符号数;const 修饰符用于声明常量。
94 |
95 | 详细的SysY语言定义请参考`SysY语言定义.pdf`、`SysY运行时库.pdf`。
96 |
97 | 该编译器主要用来将SysY语言编译为arm汇编指令,并且对编译生成的代码进行优化。
98 |
99 | 功能:
100 | * 词法分析
101 | * 语法分析
102 | * 语义分析
103 | * 目标代码
104 | * 优化
105 |
106 | > 1. 对常量表达式进行化简求值
107 | > 2. 合并冗余的函数调用
108 | > 3. 高频访问的变量使用寄存器优化,减少内存访问。
109 | > 4. 合并arm代码中不必要的mov指令。
110 | > 5. 将函数内联进代码中,减少函数调用开销。
111 | > 6. 更多
112 |
113 |
114 |
115 | ### Built With
116 | 依赖
117 | * [CMake](https://cmake.org/)
118 |
119 | - [Make - GNU Project - Free Software Foundation - GNU.org](https://www.gnu.org/software/make/)
120 |
121 | - [GCC, the GNU Compiler Collection - GNU Project - Free ...](https://gcc.gnu.org/)
122 |
123 |
124 |
125 |
126 |
127 | ## Getting Started
128 |
129 | 这个章节将指导你简单的部署和使用该软件。
130 |
131 | ### Prerequisites
132 |
133 | 这个项目的依赖安装步骤在下面给出。
134 | * [CMake](https://cmake.org/)
135 | ```sh
136 | sudo apt-get install cmake
137 | ```
138 |
139 | - [Make - GNU Project - Free Software Foundation - GNU.org](https://www.gnu.org/software/make/)
140 |
141 | ```sh
142 | sudo apt-get install make
143 | ```
144 |
145 | - [GCC, the GNU Compiler Collection - GNU Project - Free ...](https://gcc.gnu.org/)
146 |
147 | ```sh
148 | sudo apt-get install gcc
149 | ```
150 |
151 |
152 |
153 | ### Installation
154 |
155 | 1. 进入项目根目录
156 | ```
157 | cd /path/to/your/project
158 | ```
159 |
160 | 2. 在shell中运行一下代码进行编译
161 |
162 | ```sh
163 | mkdir build
164 | cd build
165 | rm CMake* cmake_install.cmake Makefile compiler -r;
166 | cmake ../ && make VERBOSE=1
167 | ```
168 |
169 | 3. 在build文件夹中会生成一个compiler可执行文件。
170 |
171 |
172 |
173 |
174 |
175 | ## Usage
176 |
177 | 1. 编译sy文件不进行优化
178 | ```sh
179 | compiler ‘输入文件.sy’ -S -o ‘输出文件.s’
180 | ```
181 |
182 | 2. 编译sy文件进行O2优化
183 |
184 | ```sh
185 | compiler ‘输入文件.sy’ -S -o ‘输出文件.s’ -O2
186 | ```
187 |
188 |
189 | ##
190 |
191 | ## 功能定制
192 |
193 | 如果需要功能定制,请联系作者 [1182176003@qq.com](1182176003@qq.com)
194 |
195 |
196 |
197 |
198 |
199 | ## Roadmap
200 |
201 | See the [open issues](https://example.com) for a list of proposed features (and known issues).
202 |
203 |
204 |
205 |
206 | ## Contributing
207 |
208 | Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**.
209 |
210 | 1. Fork the Project
211 | 2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
212 | 3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
213 | 4. Push to the Branch (`git push origin feature/AmazingFeature`)
214 | 5. Open a Pull Request
215 |
216 |
217 |
218 |
219 | ## License
220 |
221 | Distributed under the MIT License. See `LICENSE` for more information.
222 |
223 |
224 |
225 |
226 | ## Contact
227 |
228 | Davies - [@qq](1182176003) - 1182176003
229 |
230 | Davies - [@email](1182176003@qq.com) - 1182176003@qq.com
231 |
232 |
233 |
234 |
235 | ## Acknowledgements
236 | * [GitHub](https://github.com/)
237 | * [GCC, the GNU Compiler Collection](https://gcc.gnu.org/)
238 |
239 |
240 |
241 | ## 免责声明
242 | * 该软件中所包含的部分内容,包括文字、图片、音频、视频、软件、代码、以及网页版式设计等可能来源于网上搜集。
243 |
244 | * 该软件提供的内容仅用于个人学习、研究或欣赏,不可使用于商业和其它意图,一切关于该软件的不正当使用行为均与我们无关,亦不承担任何法律责任。使用该软件应遵守相关法律的规定,通过使用该软件随之而来的风险与我们无关,若使用不当,后果均由个人承担。
245 |
246 | * 该软件不提供任何形式的保证。我们不保证内容的正确性与完整性。所有与使用该软件的直接风险均由用户承担。
247 |
248 | * 如果您认为该软件中所包含的部分内容侵犯了您的权益,请及时通知我们,我们将尽快予以修正或删除。
249 |
250 |
251 |
252 |
253 |
254 | [license-shield]: readme_images/MIT_license.svg
255 | [license-url]: https://opensource.org/licenses/MIT
256 |
257 | [product-screenshot]: readme_images/screenshot.png
258 | [product-screenshot00]: readme_images/result00.png
259 |
--------------------------------------------------------------------------------
/SysY语言定义.pdf:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:c1d8ee3ae6148b8bfdea92e7c6588b10a6c69e943449a4c81c64f0164283b0b2
3 | size 373074
4 |
--------------------------------------------------------------------------------
/SysY运行时库.pdf:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:f9af338e8a4e7ad45810cdff4c21386c00cdd9d48d924481b2a167f146ad9899
3 | size 429420
4 |
--------------------------------------------------------------------------------
/build.sh:
--------------------------------------------------------------------------------
1 | cd build
2 | rm CMake* cmake_install.cmake Makefile compiler -r;
3 | cmake ../ && make VERBOSE=1
--------------------------------------------------------------------------------
/readme_images/Compiler.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DaviesGit/SysY_compiler/be5fcb82e73f87b2116197c8e0c2613b61ecd09c/readme_images/Compiler.png
--------------------------------------------------------------------------------
/readme_images/Ideal_Logo_Davies.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DaviesGit/SysY_compiler/be5fcb82e73f87b2116197c8e0c2613b61ecd09c/readme_images/Ideal_Logo_Davies.ico
--------------------------------------------------------------------------------
/readme_images/MIT_license.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/readme_images/result00.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DaviesGit/SysY_compiler/be5fcb82e73f87b2116197c8e0c2613b61ecd09c/readme_images/result00.png
--------------------------------------------------------------------------------
/readme_images/result01.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DaviesGit/SysY_compiler/be5fcb82e73f87b2116197c8e0c2613b61ecd09c/readme_images/result01.jpeg
--------------------------------------------------------------------------------
/readme_images/result02.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DaviesGit/SysY_compiler/be5fcb82e73f87b2116197c8e0c2613b61ecd09c/readme_images/result02.jpeg
--------------------------------------------------------------------------------
/readme_images/result03.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DaviesGit/SysY_compiler/be5fcb82e73f87b2116197c8e0c2613b61ecd09c/readme_images/result03.jpeg
--------------------------------------------------------------------------------
/readme_images/result04.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DaviesGit/SysY_compiler/be5fcb82e73f87b2116197c8e0c2613b61ecd09c/readme_images/result04.jpeg
--------------------------------------------------------------------------------
/readme_images/result05.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DaviesGit/SysY_compiler/be5fcb82e73f87b2116197c8e0c2613b61ecd09c/readme_images/result05.jpeg
--------------------------------------------------------------------------------
/readme_images/result06.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DaviesGit/SysY_compiler/be5fcb82e73f87b2116197c8e0c2613b61ecd09c/readme_images/result06.jpeg
--------------------------------------------------------------------------------
/readme_images/result07.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DaviesGit/SysY_compiler/be5fcb82e73f87b2116197c8e0c2613b61ecd09c/readme_images/result07.jpeg
--------------------------------------------------------------------------------
/readme_images/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DaviesGit/SysY_compiler/be5fcb82e73f87b2116197c8e0c2613b61ecd09c/readme_images/screenshot.png
--------------------------------------------------------------------------------
/src/back_end/arm_generator.h:
--------------------------------------------------------------------------------
1 | /*
2 | * arm_generator.h
3 | *
4 | * Created on: Aug 1, 2020
5 | * Author: davies
6 | */
7 |
8 | #ifndef SRC_BACK_END_ARM_GENERATOR_H_
9 | #define SRC_BACK_END_ARM_GENERATOR_H_
10 |
11 | #include
12 | #include
13 | #include
14 | #include "../common/node.h"
15 |
16 | extern char const *last_arm_generate_error_msg;
17 |
18 | bool gen_arm_assembly_code(std::shared_ptr const &node, std::ostringstream &oss);
19 |
20 | #endif /* SRC_BACK_END_ARM_GENERATOR_H_ */
21 |
--------------------------------------------------------------------------------
/src/back_end/optimizer.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * optimizer.cpp
3 | *
4 | * Created on: Jul 29, 2020
5 | * Author: davies
6 | */
7 |
8 | #include "optimizer.h"
9 |
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include