Skip to content

Commit

Permalink
test: Update hl structs to LLVM tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
lkorenc committed Nov 2, 2023
1 parent 3b64bc2 commit 9dc6d3b
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 9 deletions.
7 changes: 6 additions & 1 deletion test/vast/Transform/FromHL/StructsToLLVM/empty-a.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
// RUN: %vast-cc1 -vast-emit-mlir=hl %s -o - | %vast-opt --vast-hl-lower-types --vast-hl-structs-to-llvm | %file-check %s

// CHECK: hl.typedef "X" : !llvm.struct<"X", ()>
struct X {};

int main()
{
// CHECK: {{.*}} = hl.var "x" : !hl.lvalue<!hl.elaborated<!llvm.struct<"X", ()>>>
struct X x;
}
7 changes: 6 additions & 1 deletion test/vast/Transform/FromHL/StructsToLLVM/struct-a.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
// RUN: %vast-cc1 -vast-emit-mlir=hl %s -o - | %vast-opt --vast-hl-lower-types --vast-hl-structs-to-llvm | %file-check %s

// CHECK: hl.typedef "X" : !llvm.struct<"X", (i32)>
struct X { int x; };

int main()
{
// CHECK: {{.*}} = hl.var "x" : !hl.lvalue<!hl.elaborated<!llvm.struct<"X", (si32)>>>
struct X x;
}
8 changes: 6 additions & 2 deletions test/vast/Transform/FromHL/StructsToLLVM/struct-b.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// RUN: %vast-cc1 -vast-emit-mlir=hl %s -o - | %vast-opt --vast-hl-lower-types --vast-hl-structs-to-llvm | %file-check %s

// CHECK: hl.type "Y"
struct Y;
// CHECK: hl.typedef "X" : !llvm.struct<"X", (i32, ptr<struct<"Y", opaque>>)>
struct X { int x; struct Y *y; };

int main()
{
// CHECK: {{.*}} = hl.var "x" : !hl.lvalue<!hl.elaborated<!llvm.struct<"X", (si32, !hl.ptr<!hl.elaborated<!llvm.struct<"Y", opaque>>>)>>> = {
struct X x = { 2, 0 };
}
15 changes: 11 additions & 4 deletions test/vast/Transform/FromHL/StructsToLLVM/struct-c.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@

struct Y;

// CHECK: hl.typedef "X" : !llvm.struct<"X", (i32, ptr<struct<"Y", (f32)>>)>
struct X { int x; struct Y *y; };
struct X { const int x; struct Y *y; };

// CHECK: hl.typedef "Y" : !llvm.struct<"Y", (f32)>
struct Y { float x; };
struct Y { const float x; };

int main()
{
// CHECK: {{.*}} = hl.var "x" : !hl.lvalue<!hl.elaborated<!llvm.struct<"X", (si32, !hl.ptr<!hl.elaborated<!llvm.struct<"Y", (f32)>>>)>>> = {
struct X x = { 2, 0 };

// CHECK: {{.*}} = hl.var "y" : !hl.lvalue<!hl.elaborated<!llvm.struct<"Y", (f32)>>> = {
struct Y y = { 2.0f };
}
8 changes: 7 additions & 1 deletion test/vast/Transform/FromHL/StructsToLLVM/struct-d.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
// RUN: %vast-cc1 -vast-emit-mlir=hl %s -o - | %vast-opt --vast-hl-lower-types --vast-hl-structs-to-llvm | %file-check %s

// CHECK: hl.typedef "X" : !llvm.struct<"X", (i32, ptr<struct<"X">>)>
struct X { int a; struct X *x; };

int main()
{
// CHECK: {{.*}} = hl.var "x" : !hl.lvalue<!hl.elaborated<!llvm.struct<"X", (si32, !hl.ptr<!hl.elaborated<!llvm.struct<"X">>>)>>> = {
struct X x = { 2, 0 };
x.a = 5;
}

0 comments on commit 9dc6d3b

Please sign in to comment.