Skip to content

Commit

Permalink
[test] add compilation test
Browse files Browse the repository at this point in the history
  • Loading branch information
SchrodingerZhu committed Oct 28, 2024
1 parent 496aff5 commit 861a119
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/compile/hello_world.mlir
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// RUN: %gccjit-translate -o %t.gimple %s -mlir-to-gccjit-gimple
// RUN: %filecheck --input-file=%t.gimple %s --check-prefix=CHECK-GIMPLE
// RUN: %gccjit-translate -o %t.exe %s -mlir-to-gccjit-executable && chmod +x %t.exe
// RUN: %t.exe | %filecheck %s --check-prefix=CHECK-OUTPUT

!i32 = !gccjit.int<int32_t>
!char = !gccjit.int<char>
!const_char = !gccjit.qualified<!char, const>
!str = !gccjit.ptr<!const_char>
module @test attributes {
gccjit.opt_level = #gccjit.opt_level<O0>,
gccjit.prog_name = "test",
gccjit.allow_unreachable = false,
gccjit.debug_info = true
} {
gccjit.func imported @puts(!str) -> !i32

gccjit.func exported @main() -> !i32 {
%0 = gccjit.literal <"hello, world!\n"> : !str
// CHECK-GIMPLE: (void)puts ("hello, world!\n");
// CHECK-OUTPUT: hello, world!
%1 = gccjit.call @puts(%0) : (!str) -> !i32 {gccjit.eval}
%2 = gccjit.const #gccjit.zero : !i32
// CHECK-GIMPLE: return (__int32_t)0;
gccjit.return %2 : !i32
}
}

0 comments on commit 861a119

Please sign in to comment.