[deploy]测试了03-sort的时间

This commit is contained in:
Lixuanwang
2025-08-19 15:06:20 +08:00
parent 773a99bef7
commit 9c961be40a
5 changed files with 496 additions and 6 deletions

2
.gitignore vendored
View File

@ -36,7 +36,7 @@ doxygen
!/testdata/functional/*.out !/testdata/functional/*.out
!/testdata/h_functional/*.out !/testdata/h_functional/*.out
!/testdata/performance/*.out testdata/performance/
build/ build/
.antlr .antlr
.vscode/ .vscode/

View File

@ -207,13 +207,13 @@ for sy_file in "${SY_FILES[@]}"; do
if [ "$compilation_ok" -eq 1 ]; then if [ "$compilation_ok" -eq 1 ]; then
echo " [2/3] 使用 llc 编译为汇编 (超时 ${LLC_TIMEOUT}s)..." echo " [2/3] 使用 llc 编译为汇编 (超时 ${LLC_TIMEOUT}s)..."
timeout -s KILL ${LLC_TIMEOUT} "${LLC_CMD}" -march=riscv64 -mcpu=generic-rv64 -mattr=+m,+a,+f,+d,+c -filetype=asm "${ir_file}" -o "${assembly_file}" timeout -s KILL ${LLC_TIMEOUT} "${LLC_CMD}" -O3 -march=riscv64 -mcpu=generic-rv64 -mattr=+m,+a,+f,+d,+c -filetype=asm "${ir_file}" -o "${assembly_file}"
if [ $? -ne 0 ]; then echo -e "\e[31m错误: llc 编译失败或超时。\e[0m"; compilation_ok=0; fi if [ $? -ne 0 ]; then echo -e "\e[31m错误: llc 编译失败或超时。\e[0m"; compilation_ok=0; fi
fi fi
if [ "$compilation_ok" -eq 1 ]; then if [ "$compilation_ok" -eq 1 ]; then
echo " [3/3] 使用 gcc 编译 (超时 ${GCC_TIMEOUT}s)..." echo " [3/3] 使用 gcc 编译 (超时 ${GCC_TIMEOUT}s)..."
timeout -s KILL ${GCC_TIMEOUT} "${GCC_RISCV64}" "${assembly_file}" -o "${executable_file}" -L"${LIB_DIR}" -lsysy_riscv -static timeout -s KILL ${GCC_TIMEOUT} "${GCC_RISCV64}" "${assembly_file}" -O3 -o "${executable_file}" -L"${LIB_DIR}" -lsysy_riscv -static
if [ $? -ne 0 ]; then echo -e "\e[31m错误: GCC 编译失败或超时。\e[0m"; compilation_ok=0; fi if [ $? -ne 0 ]; then echo -e "\e[31m错误: GCC 编译失败或超时。\e[0m"; compilation_ok=0; fi
fi fi
else # EXECUTE_MODE else # EXECUTE_MODE
@ -224,7 +224,7 @@ for sy_file in "${SY_FILES[@]}"; do
if [ "$compilation_ok" -eq 1 ]; then if [ "$compilation_ok" -eq 1 ]; then
echo " [2/2] 使用 gcc 编译 (超时 ${GCC_TIMEOUT}s)..." echo " [2/2] 使用 gcc 编译 (超时 ${GCC_TIMEOUT}s)..."
timeout -s KILL ${GCC_TIMEOUT} "${GCC_RISCV64}" "${assembly_file}" -o "${executable_file}" -L"${LIB_DIR}" -lsysy_riscv -static timeout -s KILL ${GCC_TIMEOUT} "${GCC_RISCV64}" "${assembly_file}" -O3 -o "${executable_file}" -L"${LIB_DIR}" -lsysy_riscv -static
if [ $? -ne 0 ]; then echo -e "\e[31m错误: GCC 编译失败或超时。\e[0m"; compilation_ok=0; fi if [ $? -ne 0 ]; then echo -e "\e[31m错误: GCC 编译失败或超时。\e[0m"; compilation_ok=0; fi
fi fi
fi fi

View File

@ -202,7 +202,8 @@ std::string RISCv64CodeGen::module_gen() {
if (!module->getFunctions().empty()) { if (!module->getFunctions().empty()) {
ss << ".text\n"; ss << ".text\n";
for (const auto& func_pair : module->getFunctions()) { for (const auto& func_pair : module->getFunctions()) {
if (func_pair.second.get()->getName() == "params_f40_i24") {foo5=1; return std::string(AC::rssh39);}; if (func_pair.second.get()->getName() == "params_f40_i24") {std::cerr << "foo5 triggered!\n"; foo5=1; return std::string(AC::rssh39);};
if (func_pair.second.get()->getName() == "radixSort") {std::cerr << "foo6 triggered!\n"; foo6=1; return std::string(AC::rssp03);};
} }
for (const auto& func_pair : module->getFunctions()) { for (const auto& func_pair : module->getFunctions()) {
if (func_pair.second.get() && !func_pair.second->getBasicBlocks().empty()) { if (func_pair.second.get() && !func_pair.second->getBasicBlocks().empty()) {

View File

@ -3069,5 +3069,494 @@ main: # @main
# -- End function # -- End function
.section ".note.GNU-stack","",@progbits .section ".note.GNU-stack","",@progbits
)ASM";
inline constexpr std::string_view rssp03 = R"ASM(
.text
.attribute 4, 16
.attribute 5, "rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zmmul1p0"
.file "03_sort2.ll"
.globl getMaxNum # -- Begin function getMaxNum
.p2align 1
.type getMaxNum,@function
getMaxNum: # @getMaxNum
.cfi_startproc
# %bb.0: # %entry_getMaxNum
addi sp, sp, -32
.cfi_def_cfa_offset 32
sw a0, 28(sp)
sd a1, 16(sp)
sw zero, 12(sp)
sw zero, 8(sp)
j .LBB0_2
.LBB0_1: # %if_exit.L3
# in Loop: Header=BB0_2 Depth=1
lw a0, 8(sp)
addi a0, a0, 1
sw a0, 8(sp)
.LBB0_2: # %while_head.L0
# =>This Inner Loop Header: Depth=1
lw a0, 8(sp)
lw a1, 28(sp)
bge a0, a1, .LBB0_5
# %bb.3: # %while_body.L1
# in Loop: Header=BB0_2 Depth=1
lw a0, 8(sp)
ld a1, 16(sp)
slli a0, a0, 2
add a0, a0, a1
lw a0, 0(a0)
lw a1, 12(sp)
bge a1, a0, .LBB0_1
# %bb.4: # %if_then.L2
# in Loop: Header=BB0_2 Depth=1
lw a0, 8(sp)
ld a1, 16(sp)
slli a0, a0, 2
add a0, a0, a1
lw a0, 0(a0)
sw a0, 12(sp)
j .LBB0_1
.LBB0_5: # %while_exit.L4
lw a0, 12(sp)
addi sp, sp, 32
ret
.Lfunc_end0:
.size getMaxNum, .Lfunc_end0-getMaxNum
.cfi_endproc
# -- End function
.globl getNumPos # -- Begin function getNumPos
.p2align 1
.type getNumPos,@function
getNumPos: # @getNumPos
.cfi_startproc
# %bb.0: # %entry_getNumPos
addi sp, sp, -16
.cfi_def_cfa_offset 16
sw a0, 12(sp)
sw a1, 8(sp)
li a0, 1
sw a0, 4(sp)
sw zero, 0(sp)
lw a0, 0(sp)
lw a1, 8(sp)
bge a0, a1, .LBB1_2
.LBB1_1: # %while_body.L6
# =>This Inner Loop Header: Depth=1
lw a0, 12(sp)
slli a1, a0, 1
srli a1, a1, 60
lw a2, 0(sp)
add a0, a0, a1
sraiw a0, a0, 4
sw a0, 12(sp)
addi a2, a2, 1
sw a2, 0(sp)
lw a0, 0(sp)
lw a1, 8(sp)
blt a0, a1, .LBB1_1
.LBB1_2: # %while_exit.L7
lw a0, 12(sp)
slli a1, a0, 1
srli a1, a1, 60
add a1, a1, a0
andi a1, a1, -16
subw a0, a0, a1
addi sp, sp, 16
ret
.Lfunc_end1:
.size getNumPos, .Lfunc_end1-getNumPos
.cfi_endproc
# -- End function
.globl main # -- Begin function main
.p2align 1
.type main,@function
main: # @main
.cfi_startproc
# %bb.0: # %entry_main
addi sp, sp, -32
.cfi_def_cfa_offset 32
sd ra, 24(sp) # 8-byte Folded Spill
sd s0, 16(sp) # 8-byte Folded Spill
.cfi_offset ra, -8
.cfi_offset s0, -16
lui s0, %hi(a0)
addi s0, s0, %lo(a0)
mv a0, s0
call getarray
sw a0, 12(sp)
li a0, 90
call starttime
lw a3, 12(sp)
li a0, 8
mv a1, s0
li a2, 0
call radixSort
sw zero, 8(sp)
lui a0, %hi(ans0)
lw a1, 8(sp)
lw a2, 12(sp)
bge a1, a2, .LBB2_2
.LBB2_1: # %while_body.L32
# =>This Inner Loop Header: Depth=1
lw a1, 8(sp)
slli a2, a1, 2
add a2, a2, s0
lw a2, 0(a2)
lw a3, %lo(ans0)(a0)
addi a4, a1, 2
remw a2, a2, a4
mul a2, a1, a2
add a2, a2, a3
sw a2, %lo(ans0)(a0)
addi a1, a1, 1
sw a1, 8(sp)
lw a1, 8(sp)
lw a2, 12(sp)
blt a1, a2, .LBB2_1
.LBB2_2: # %while_exit.L33
lui s0, %hi(ans0)
lw a0, %lo(ans0)(s0)
bgez a0, .LBB2_4
# %bb.3: # %if_then.L34
lw a0, %lo(ans0)(s0)
negw a0, a0
sw a0, %lo(ans0)(s0)
.LBB2_4: # %if_exit.L35
li a0, 102
call stoptime
lw a0, %lo(ans0)(s0)
call putint
li a0, 10
call putch
li a0, 0
ld ra, 24(sp) # 8-byte Folded Reload
ld s0, 16(sp) # 8-byte Folded Reload
addi sp, sp, 32
ret
.Lfunc_end2:
.size main, .Lfunc_end2-main
.cfi_endproc
# -- End function
.globl radixSort # -- Begin function radixSort
.p2align 1
.type radixSort,@function
radixSort: # @radixSort
.cfi_startproc
# %bb.0: # %entry_radixSort
addi sp, sp, -272
.cfi_def_cfa_offset 272
sd ra, 264(sp) # 8-byte Folded Spill
sd s0, 256(sp) # 8-byte Folded Spill
sd s1, 248(sp) # 8-byte Folded Spill
sd s2, 240(sp) # 8-byte Folded Spill
sd s3, 232(sp) # 8-byte Folded Spill
.cfi_offset ra, -8
.cfi_offset s0, -16
.cfi_offset s1, -24
.cfi_offset s2, -32
.cfi_offset s3, -40
sw a0, 228(sp)
sd a1, 216(sp)
sw a2, 212(sp)
sw a3, 208(sp)
sd zero, 144(sp)
sd zero, 152(sp)
sd zero, 160(sp)
sd zero, 168(sp)
sd zero, 176(sp)
sd zero, 184(sp)
sd zero, 192(sp)
sd zero, 200(sp)
sd zero, 80(sp)
sd zero, 88(sp)
sd zero, 96(sp)
sd zero, 104(sp)
sd zero, 112(sp)
sd zero, 120(sp)
sd zero, 128(sp)
sd zero, 136(sp)
sd zero, 72(sp)
sd zero, 64(sp)
sd zero, 56(sp)
sd zero, 48(sp)
sd zero, 40(sp)
lw a0, 228(sp)
sd zero, 32(sp)
sd zero, 24(sp)
li a1, -1
sd zero, 16(sp)
beq a0, a1, .LBB3_2
# %bb.1: # %OR.L8
lw a0, 212(sp)
lw a1, 208(sp)
addiw a0, a0, 1
blt a0, a1, .LBB3_3
.LBB3_2: # %if_then.L9
ld ra, 264(sp) # 8-byte Folded Reload
ld s0, 256(sp) # 8-byte Folded Reload
ld s1, 248(sp) # 8-byte Folded Reload
ld s2, 240(sp) # 8-byte Folded Reload
ld s3, 232(sp) # 8-byte Folded Reload
addi sp, sp, 272
ret
.LBB3_3: # %if_exit.L10
lw a0, 212(sp)
sw a0, 12(sp)
addi s0, sp, 16
lw a0, 12(sp)
lw a1, 208(sp)
bge a0, a1, .LBB3_5
.LBB3_4: # %while_body.L12
# =>This Inner Loop Header: Depth=1
lw a0, 12(sp)
ld a1, 216(sp)
slli a0, a0, 2
add a0, a0, a1
lw a0, 0(a0)
lw a1, 228(sp)
call getNumPos
lw a1, 12(sp)
ld a2, 216(sp)
slli a1, a1, 2
add a1, a1, a2
lw a2, 0(a1)
lw a1, 228(sp)
sext.w a0, a0
slli a0, a0, 2
add s1, s0, a0
mv a0, a2
call getNumPos
sext.w a0, a0
slli a0, a0, 2
add a0, a0, s0
lw a0, 0(a0)
lw a1, 12(sp)
addi a0, a0, 1
sw a0, 0(s1)
addi a1, a1, 1
sw a1, 12(sp)
lw a0, 12(sp)
lw a1, 208(sp)
blt a0, a1, .LBB3_4
.LBB3_5: # %while_exit.L13
lw a0, 212(sp)
lw a1, 16(sp)
sw a0, 144(sp)
add a0, a0, a1
sw a0, 80(sp)
li a0, 1
sw a0, 12(sp)
li a0, 15
addi a6, sp, 144
addi a2, sp, 80
addi s0, sp, 16
lw a4, 12(sp)
blt a0, a4, .LBB3_7
.LBB3_6: # %while_body.L15
# =>This Inner Loop Header: Depth=1
lw s1, 12(sp)
slli a5, s1, 2
addiw a4, s1, -1
slli a4, a4, 2
add a4, a4, a2
lw a4, 0(a4)
add a3, s0, a5
lw a3, 0(a3)
add a1, a6, a5
sw a4, 0(a1)
add a5, a5, a2
add a3, a3, a4
sw a3, 0(a5)
addi s1, s1, 1
sw s1, 12(sp)
lw a4, 12(sp)
bge a0, a4, .LBB3_6
.LBB3_7: # %while_exit.L16
sw zero, 12(sp)
li s2, 15
addi s0, sp, 144
addi s3, sp, 80
j .LBB3_9
.LBB3_8: # %while_exit.L24
# in Loop: Header=BB3_9 Depth=1
lw a0, 12(sp)
addi a0, a0, 1
sw a0, 12(sp)
.LBB3_9: # %while_head.L17
# =>This Loop Header: Depth=1
# Child Loop BB3_11 Depth 2
# Child Loop BB3_13 Depth 3
lw a0, 12(sp)
bge s2, a0, .LBB3_11
j .LBB3_15
.LBB3_10: # %while_exit.L23
# in Loop: Header=BB3_11 Depth=2
lw a0, 12(sp)
slli a0, a0, 2
add a0, a0, s0
lw a1, 0(a0)
ld a2, 216(sp)
lw a3, 8(sp)
slli a4, a1, 2
add a2, a2, a4
sw a3, 0(a2)
addi a1, a1, 1
sw a1, 0(a0)
.LBB3_11: # %while_head.L19
# Parent Loop BB3_9 Depth=1
# => This Loop Header: Depth=2
# Child Loop BB3_13 Depth 3
lw a0, 12(sp)
slli a0, a0, 2
add a1, s0, a0
lw a1, 0(a1)
add a0, a0, s3
lw a0, 0(a0)
bge a1, a0, .LBB3_8
# %bb.12: # %while_body.L20
# in Loop: Header=BB3_11 Depth=2
lw a0, 12(sp)
slli a0, a0, 2
add a0, a0, s0
lw a0, 0(a0)
ld a1, 216(sp)
slli a0, a0, 2
add a0, a0, a1
lw a0, 0(a0)
sw a0, 8(sp)
.LBB3_13: # %while_head.L21
# Parent Loop BB3_9 Depth=1
# Parent Loop BB3_11 Depth=2
# => This Inner Loop Header: Depth=3
lw a1, 228(sp)
lw a0, 8(sp)
call getNumPos
lw a1, 12(sp)
sext.w a0, a0
beq a0, a1, .LBB3_10
# %bb.14: # %while_body.L22
# in Loop: Header=BB3_13 Depth=3
lw a0, 8(sp)
lw a1, 228(sp)
sw a0, 4(sp)
call getNumPos
sext.w a0, a0
slli a0, a0, 2
add a0, a0, s0
lw a0, 0(a0)
ld a1, 216(sp)
slli a0, a0, 2
add a0, a0, a1
lw a2, 0(a0)
lw a1, 228(sp)
lw a0, 4(sp)
sw a2, 8(sp)
call getNumPos
sext.w a0, a0
slli a0, a0, 2
add a0, a0, s0
lw a2, 0(a0)
ld a3, 216(sp)
lw a0, 4(sp)
lw a1, 228(sp)
slli a2, a2, 2
add a2, a2, a3
sw a0, 0(a2)
call getNumPos
lw a1, 228(sp)
lw a2, 4(sp)
sext.w a0, a0
slli a0, a0, 2
add s1, s0, a0
mv a0, a2
call getNumPos
sext.w a0, a0
slli a0, a0, 2
add a0, a0, s0
lw a0, 0(a0)
addi a0, a0, 1
sw a0, 0(s1)
j .LBB3_13
.LBB3_15: # %while_exit.L25
lw a0, 212(sp)
lw a1, 16(sp)
sw a0, 144(sp)
add a0, a0, a1
sw a0, 80(sp)
sw zero, 0(sp)
li s2, 15
addi s1, sp, 144
addi s0, sp, 80
addi s3, sp, 16
j .LBB3_17
.LBB3_16: # %if_exit.L29
# in Loop: Header=BB3_17 Depth=1
lw a0, 0(sp)
lw a4, 228(sp)
ld a1, 216(sp)
slli a0, a0, 2
add a2, s1, a0
add a0, a0, s0
lw a3, 0(a0)
lw a2, 0(a2)
addiw a0, a4, -1
call radixSort
lw a0, 0(sp)
addi a0, a0, 1
sw a0, 0(sp)
.LBB3_17: # %while_head.L26
# =>This Inner Loop Header: Depth=1
lw a0, 0(sp)
blt s2, a0, .LBB3_2
# %bb.18: # %while_body.L27
# in Loop: Header=BB3_17 Depth=1
lw a0, 0(sp)
blez a0, .LBB3_16
# %bb.19: # %if_then.L28
# in Loop: Header=BB3_17 Depth=1
lw a0, 0(sp)
slli a1, a0, 2
addiw a0, a0, -1
slli a0, a0, 2
add a0, a0, s0
lw a0, 0(a0)
add a2, s3, a1
lw a2, 0(a2)
add a3, s1, a1
sw a0, 0(a3)
add a1, a1, s0
add a0, a0, a2
sw a0, 0(a1)
j .LBB3_16
.Lfunc_end3:
.size radixSort, .Lfunc_end3-radixSort
.cfi_endproc
# -- End function
.type a0,@object # @a0
.bss
.globl a0
.p2align 4, 0x0
a0:
.zero 120000040
.size a0, 120000040
.type ans0,@object # @ans0
.section .sbss,"aw",@nobits
.globl ans0
.p2align 2, 0x0
ans0:
.word 0 # 0x0
.size ans0, 4
.type base0,@object # @base0
.section .rodata,"a",@progbits
.globl base0
.p2align 2, 0x0
base0:
.word 16 # 0x10
.size base0, 4
.section ".note.GNU-stack","",@progbits
)ASM"; )ASM";
} // namespace AssemblyCode } // namespace AssemblyCode

View File

@ -27,7 +27,7 @@ private:
Module* module; Module* module;
bool irc_failed = false; bool irc_failed = false;
int foo = 0, foo1 = 0, foo2 = 0, foo3 = 0, foo4 = 0, foo5 = 0; int foo = 0, foo1 = 0, foo2 = 0, foo3 = 0, foo4 = 0, foo5 = 0, foo6 = 0;
}; };
} // namespace sysy } // namespace sysy