Skip to content

Commit

Permalink
[codegen] Add a test: spill.ll
Browse files Browse the repository at this point in the history
  • Loading branch information
maekawatoshiki committed May 23, 2022
1 parent d1f6446 commit 68e0e9c
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 0 deletions.
1 change: 1 addition & 0 deletions codegen/tests/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ mod x86_64 {
test!(X86_64, test_i8, "i8");
test!(X86_64, test_i8_load_store, "i8_load_store");
test!(X86_64, test_global, "global");
test!(X86_64, test_spill, "spill");
}
46 changes: 46 additions & 0 deletions codegen/tests/codegen/spill.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
source_filename = "spill"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"

define i32 @main() {
%a1 = alloca i32
%a2 = alloca i32
%a3 = alloca i32
%a4 = alloca i32
%a5 = alloca i32
%a6 = alloca i32
%a7 = alloca i32
%a8 = alloca i32
%a9 = alloca i32
%a10 = alloca i32
store i32 1, i32* %a1
store i32 2, i32* %a2
store i32 3, i32* %a3
store i32 4, i32* %a4
store i32 5, i32* %a5
store i32 6, i32* %a6
store i32 7, i32* %a7
store i32 8, i32* %a8
store i32 9, i32* %a9
store i32 10, i32* %a10
%a11 = load i32, i32* %a1
%a12 = load i32, i32* %a2
%a13 = load i32, i32* %a3
%a14 = load i32, i32* %a4
%a15 = load i32, i32* %a5
%a16 = load i32, i32* %a6
%a17 = load i32, i32* %a7
%a18 = load i32, i32* %a8
%a19 = load i32, i32* %a9
%a20 = load i32, i32* %a10
%a21 = add nsw i32 %a11, %a12
%a22 = add nsw i32 %a21, %a13
%a23 = add nsw i32 %a22, %a14
%a24 = add nsw i32 %a23, %a15
%a25 = add nsw i32 %a24, %a16
%a26 = add nsw i32 %a25, %a17
%a27 = add nsw i32 %a26, %a18
%a28 = add nsw i32 %a27, %a19
%a29 = add nsw i32 %a28, %a20
ret i32 %a29
}
59 changes: 59 additions & 0 deletions codegen/tests/snapshots/codegen__x86_64__spill.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
source: codegen/tests/codegen.rs
assertion_line: 44
expression: mach_module.display_asm()
---
.text
.intel_syntax noprefix
.text
.globl main
main:
.LBL0_0:
push rbp
mov rbp, rsp
sub rsp, 64
mov dword ptr [rbp-4], 1
mov dword ptr [rbp-8], 2
mov dword ptr [rbp-12], 3
mov dword ptr [rbp-16], 4
mov dword ptr [rbp-20], 5
mov dword ptr [rbp-24], 6
mov dword ptr [rbp-28], 7
mov dword ptr [rbp-32], 8
mov dword ptr [rbp-36], 9
mov dword ptr [rbp-40], 10
mov eax, dword ptr [rbp-4]
mov ecx, dword ptr [rbp-8]
mov edx, dword ptr [rbp-12]
mov edi, dword ptr [rbp-16]
mov esi, dword ptr [rbp-20]
mov dword ptr [rbp-44], esi
mov esi, dword ptr [rbp-24]
mov dword ptr [rbp-48], esi
mov esi, dword ptr [rbp-28]
mov dword ptr [rbp-52], esi
mov esi, dword ptr [rbp-32]
mov dword ptr [rbp-56], esi
mov esi, dword ptr [rbp-36]
mov dword ptr [rbp-60], esi
mov esi, dword ptr [rbp-40]
mov dword ptr [rbp-64], esi
add eax, ecx
add eax, edx
add eax, edi
mov esi, dword ptr [rbp-44]
add eax, esi
mov esi, dword ptr [rbp-48]
add eax, esi
mov esi, dword ptr [rbp-52]
add eax, esi
mov esi, dword ptr [rbp-56]
add eax, esi
mov esi, dword ptr [rbp-60]
add eax, esi
mov esi, dword ptr [rbp-64]
add eax, esi
add rsp, 64
pop rbp
ret

0 comments on commit 68e0e9c

Please sign in to comment.