This is the compiler project release repo for the SOFT130061 @ Fudan University.
hxuhack / compiler_project Goto Github PK
View Code? Open in Web Editor NEWThis is the compiler project webpage for the SOFT130061 @ Fudan University.
This is the compiler project webpage for the SOFT130061 @ Fudan University.
assignment3中没有i1类型寄存器的抽象,是可以直接用i32类型的代替么?
老师好,我在测试的时候,第二个bin_search出错了,但是我仔细看一遍,我的树和参考树是一模一样的(至少肉眼看上去),我想问一下我们应该怎么判断两个文件是不是一样的
我debug的可执行文件时public文件夹下的sort_test7,在执行这个文件的时候出现了段错误。经过我debug,发现该错误出现在该文件的tea代码中MergeSort函数在if循环中第一次调用自身这个位置。我把生成的汇编代码仔仔细细的看了一遍,并把大部分过程中目标寄存器的值进行了注释标注,发现实际运行逻辑并没有问题,但是问题出现段错误的地方是第一次调用自身的ldp x29, x30, [sp], #16 这个地方。下面我给出对应该函数的汇编代码,并给出gdb的调试出现错误的位置:
(gdb) x/10i $pc
=> 0x400c30 <bb25+88>: ldp x29, x30, [sp], #16
0x400c34 <bb25+92>: ldr x15, [sp], #8
0x400c38 <bb25+96>: ldp x13, x14, [sp], #16
0x400c3c <bb25+100>: ldp x11, x12, [sp], #16
0x400c40 <bb25+104>: ldp x9, x10, [sp], #16
0x400c44 <bb25+108>: mov x9, x0
0x400c48 <bb25+112>: mov x9, x13
0x400c4c <bb25+116>: mov x10, #0x1 // #1
0x400c50 <bb25+120>: add x9, x9, x10
0x400c54 <bb25+124>: mov x10, x9
MergeSort:
//bb24:
bb24:
// %r390 = add i32 0, 0
mov x16, #0
sub sp, sp, x16
mov x12, x0 //array
mov x11, x1 //p
mov x10, x2 //q
mov x9, #0
mov x13, x9
// %r391 = add i32 0, 0
mov x9, #0
mov x15, x9
// %r392 = add i32 0, 0
mov x9, #0
// %r393 = add i32 %r241, 0
mov x11, x11
// %r394 = add i32 0, 0
mov x9, #0
// %r395 = add i32 %r243, 0
mov x14, x10
// %r247 = add i32 %r393, 0
mov x9, x11
// %r249 = add i32 %r395, 0
mov x10, x14
// %r245 = icmp slt i32 %r247, %r249
cmp x9, x10
// br i1 %r245, label %bb25, label %bb26
b.lt bb25
b bb26
//bb25:
bb25:
// %r252 = add i32 %r393, 0
mov x9, x11 //p
// %r254 = add i32 %r395, 0
mov x10, x14 //q
// %r255 = add i32 %r252, %r254
add x9, x9, x10 //p+q
// %r256 = sdiv i32 %r255, 2
mov x10, #2
sdiv x9, x9, x10 //(p+q)/2
// %r398 = add i32 %r256, 0
mov x13, x9 //(p+q)/2
// %r261 = getelementptr i32, i32* %r240, i32 0
mov x9, #0
mov x10, #8
mul x9, x9, x10
add x9, x12, x9 //array
// %r263 = add i32 %r393, 0
mov x10, x11 //p
// %r265 = add i32 %r398, 0
mov x15, x13 //(p+q)/2
// %r259 = call i32 @MergeSort(i32* %r261, i32 %r263, i32 %r265)
mov x0, x9
mov x1, x10
mov x2, x15
stp x9, x10, [sp, #-16]!
stp x11, x12, [sp, #-16]!
stp x13, x14, [sp, #-16]!
str x15, [sp, #-8]!
stp x29, x30, [sp, #-16]!
mov x29, sp
bl MergeSort
ldp x29, x30, [sp], #16 //在此处出现了段错误
ldr x15, [sp], #8
ldp x13, x14, [sp], #16
ldp x11, x12, [sp], #16
ldp x9, x10, [sp], #16
mov x9, x0 //return value ,is 0
// %r399 = add i32 %r259, 0
// %r267 = add i32 %r398, 0
mov x9, x13 //(p+q)/2
// %r268 = add i32 %r267, 1
mov x10, #1
add x9, x9, x10 //(p+q)/2+1
// %r400 = add i32 %r268, 0
mov x10, x9 //(p+q)/2+1
// %r272 = getelementptr i32, i32* %r240, i32 0
mov x9, #0
mov x15, #8
mul x9, x9, x15
add x15, x12, x9 //array
// %r274 = add i32 %r400, 0
mov x10, x10
// %r276 = add i32 %r395, 0
mov x9, x14 //q
// %r270 = call i32 @MergeSort(i32* %r272, i32 %r274, i32 %r276)
mov x0, x15 //array
mov x1, x10 //(p+q)/2+1 = tmp
mov x2, x9 //q
stp x9, x10, [sp, #-16]!
stp x11, x12, [sp, #-16]!
stp x13, x14, [sp, #-16]!
str x15, [sp, #-8]!
stp x29, x30, [sp, #-16]!
mov x29, sp
bl MergeSort
ldp x29, x30, [sp], #16
ldr x15, [sp], #8
ldp x13, x14, [sp], #16
ldp x11, x12, [sp], #16
ldp x9, x10, [sp], #16
mov x9, x0
// %r401 = add i32 %r270, 0
// %r280 = getelementptr i32, i32* %r240, i32 0
mov x9, #0
mov x10, #8
mul x9, x9, x10
add x12, x12, x9
// %r282 = add i32 %r393, 0
mov x11, x11
// %r284 = add i32 %r398, 0
mov x10, x13
// %r286 = add i32 %r395, 0
mov x9, x14
// %r278 = call i32 @Merge(i32* %r280, i32 %r282, i32 %r284, i32 %r286)
mov x0, x12
mov x1, x11
mov x2, x10
mov x3, x9
stp x9, x10, [sp, #-16]!
stp x11, x12, [sp, #-16]!
stp x13, x14, [sp, #-16]!
str x15, [sp, #-8]!
stp x29, x30, [sp, #-16]!
mov x29, sp
bl Merge
ldp x29, x30, [sp], #16
ldr x15, [sp], #8
ldp x13, x14, [sp], #16
ldp x11, x12, [sp], #16
ldp x9, x10, [sp], #16
mov x9, x0
// %r402 = add i32 %r278, 0
mov x9, x9
// br label %bb27
b bb27
//bb26:
bb26:
// br label %bb27
b bb27
//bb27:
bb27:
// %r396 = phi i32 [ %r402, %bb25 ], [ %r390, %bb26 ]
// %r397 = phi i32 [ %r398, %bb25 ], [ %r391, %bb26 ]
// ret i32 0
mov x9, #0
mov x0, x9
mov sp, x29
ret
nothin
我的理解是这样的,但是我不清楚“并记录向该地址存取的标量”的意思,而且其实按照助教提供的思路好像load指令不能直接删除,还是需要load指令,因为原先的指令序列中load指令的dst会在后续指令中用到。想问一下上面的理解是否正确。
老师好,关于pj有两个问题
下面的文件用到了不要求实现的bool型转int型
test07
请问变量可以定义后重复声明吗,以及变量允许在外部定义然后在内部声明吗(感觉描述有点混用变量的定义和声明?)
nothing
这个“赋值函数”指的具体是什么?graph.hpp并没有(显式)定义自己的赋值函数啊。
nothing
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.