2020 年《编译原理》基础实验参考代码仓库。
助教提供的参考代码放在不同 git branch 上, 具体请看实验指导书。
相关链接
The MiniDecaf compilers.
你好,我是哈尔滨工业大学的一名本科生,最近在网站 https://decaf-lang.github.io/minidecaf-tutorial/ 上看到贵系的编译课程指导,想自我尝试一下这门课程的实验部分,希望从中学到知识。
但是我无法获得框架源代码,似乎需要从清华的代码托管平台上获取,所以我在github上搜索框架源代码,最终找到的只有各位助教写好的已经能通过测试用例的代码。
我想问一下您能提供一下 https://decaf-lang.github.io/minidecaf-tutorial/ 该网站上所用到的框架的源代码吗?我想按照这个指导自己去实现一个能通过测试用例的编译器 minidecaf。 谢谢!!!
代码159-162行,233-235行,在访问循环体时,应该同时开一个新的作用域。
Hi,
I tried to compile the C program in the doc on macOS, but failed:
❯ cat test.c
#include <stdio.h>
int main() { printf("Hello world!\n"); }
❯ riscv64-unknown-elf-gcc -O3 test.c -march=rv32im -mabi=ilp32
riscv64-unknown-elf-gcc: fatal error: Can't found suitable multilib set for '-march=rv32im'/'-mabi=ilp32'
compilation terminated.
However, I can generate the assembly code:
❯ riscv64-unknown-elf-gcc -O3 -S test.c -march=rv32im -mabi=ilp32
❯ cat test.s
.file "test.c"
.option nopic
.attribute arch, "rv32i2p0_m2p0"
.attribute unaligned_access, 0
.attribute stack_align, 16
.text
.section .rodata.str1.4,"aMS",@progbits,1
.align 2
.LC0:
.string "Hello world!"
.section .text.startup,"ax",@progbits
.align 2
.globl main
.type main, @function
main:
lui a0,%hi(.LC0)
addi sp,sp,-16
addi a0,a0,%lo(.LC0)
sw ra,12(sp)
call puts
lw ra,12(sp)
li a0,0
addi sp,sp,16
jr ra
.size main, .-main
.ident "GCC: (SiFive GCC-Metal 10.2.0-2020.12.8) 10.2.0"
Additionally, when I removed the options for 32-bit, It worked well. But it didn't meet the requirement of this course.
❯ riscv64-unknown-elf-gcc -O3 test.c
❯ ls | grep a.out
a.out
BTW, the last snippet on this page which uses qemu-riscv32
is not compatible for macOS. It can be removed to avoid confusion.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.