Skip to content

Commit

Permalink
hl: Let RecordDecl use SymbolNameAttr.
Browse files Browse the repository at this point in the history
  • Loading branch information
xlauko committed Sep 9, 2024
1 parent fc29b8c commit 36273f2
Show file tree
Hide file tree
Showing 37 changed files with 75 additions and 75 deletions.
6 changes: 3 additions & 3 deletions include/vast/Dialect/HighLevel/HighLevelOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ class HighLevel_RecordLikeDeclOp< string mnemonic, list< Trait > traits = [] >
DeclareOpInterfaceMethods< AggregateTypeDefinition >
])
>
, Arguments<(ins StrAttr:$name)>
, Arguments<(ins SymbolNameAttr:$sym_name)>
{
let regions = (region AnyRegion:$fields);

Expand Down Expand Up @@ -293,14 +293,14 @@ class HighLevel_RecordLikeDeclOp< string mnemonic, list< Trait > traits = [] >
return hl::get_nested_declarations(*this);
}

llvm::StringRef $cppClass::getDefinedName() { return this->getName(); }
llvm::StringRef $cppClass::getDefinedName() { return this->getSymName(); }

mlir::Type $cppClass::getDefinedType() {
return hl::RecordType::get(getContext(), getDefinedName());
}
}];

let assemblyFormat = [{ $name attr-dict `:` $fields }];
let assemblyFormat = [{ $sym_name attr-dict `:` $fields }];
}

def HighLevel_StructDeclOp
Expand Down
4 changes: 2 additions & 2 deletions lib/vast/Dialect/HighLevel/HighLevelOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ namespace vast::hl
Builder &bld, State &st, llvm::StringRef name,
maybe_builder_callback_ref fields
) {
st.addAttribute("name", bld.getStringAttr(name));
st.addAttribute("sym_name", bld.getStringAttr(name));

InsertionGuard guard(bld);
build_region(bld, st, fields);
Expand All @@ -439,7 +439,7 @@ namespace vast::hl
maybe_builder_callback_ref bases,
maybe_builder_callback_ref fields
) {
st.addAttribute("name", bld.getStringAttr(name));
st.addAttribute("sym_name", bld.getStringAttr(name));

InsertionGuard guard(bld);
build_region(bld, st, bases);
Expand Down
2 changes: 1 addition & 1 deletion test/vast/Dialect/HighLevel/attr-f.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: %vast-front -vast-emit-mlir=hl -o - %s | %file-check %s
// RUN: %vast-front -vast-emit-mlir=hl -o - %s > %t && %vast-opt %t | diff -B %t -

// CHECK: hl.union "u" {hl.transparent_union = #hl.transparent_union}
// CHECK: hl.union @u {hl.transparent_union = #hl.transparent_union}
union u {
int *a;
char *b;
Expand Down
2 changes: 1 addition & 1 deletion test/vast/Dialect/HighLevel/enum-e.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: %vast-cc1 -vast-emit-mlir=hl %s -o - | %file-check %s
// RUN: %vast-cc1 -vast-emit-mlir=hl %s -o %t && %vast-opt %t | diff -B %t -

// CHECK: hl.struct "Element"
// CHECK: hl.struct @Element
// CHECK: hl.field "z" : !hl.int
// CHECK: hl.enum @State : !hl.int< unsigned >
// CHECK: hl.enum.const @SOLID
Expand Down
2 changes: 1 addition & 1 deletion test/vast/Dialect/HighLevel/indirect-call-a.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ typedef ck_rv_t (*ck_lockmutex_t) (void *mutex);
// CHECK: hl.typedef @ck_unlockmutex_t : !hl.ptr<!hl.paren<!core.fn<(!hl.lvalue<!hl.ptr<!hl.void>>) -> (!hl.elaborated<!hl.typedef<"ck_rv_t">>)>>>
typedef ck_rv_t (*ck_unlockmutex_t) (void *mutex);

// CHECK: hl.struct "ck_c_initialize_args"
// CHECK: hl.struct @ck_c_initialize_args
struct ck_c_initialize_args
{
// CHECK: hl.field "create_mutex" : !hl.elaborated<!hl.typedef<"ck_createmutex_t">>
Expand Down
2 changes: 1 addition & 1 deletion test/vast/Dialect/HighLevel/libc-locale.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

// CHECK-DAG: hl.func @setlocale
// CHECK-DAG: hl.func @localeconv
// CHECK-DAG: hl.struct "lconv"
// CHECK-DAG: hl.struct @lconv
#include <locale.h>
4 changes: 2 additions & 2 deletions test/vast/Dialect/HighLevel/libc-time.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
// CHECK-DAG: hl.func @gmtime
// CHECK-DAG: hl.func @localtime

// CHECK-DAG: hl.struct "tm"
// CHECK-DAG: hl.struct "timespec"
// CHECK-DAG: hl.struct @tm
// CHECK-DAG: hl.struct @timespec
// CHECK-DAG: hl.typedef @time_t
// CHECK-DAG: hl.typedef @clock_t

Expand Down
2 changes: 1 addition & 1 deletion test/vast/Dialect/HighLevel/qualifiers-i.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: %vast-cc1 -vast-emit-mlir=hl %s -o - | %file-check %s
// RUN: %vast-cc1 -vast-emit-mlir=hl %s -o %t && %vast-opt %t | diff -B %t -

// CHECK: hl.union "u"
// CHECK: hl.union @u
union u { int i; double d; };

// CHECK: hl.var @v : !hl.lvalue<!hl.elaborated<!hl.record<"u">>>
Expand Down
4 changes: 2 additions & 2 deletions test/vast/Dialect/HighLevel/quirks-a.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

// adapted from https://gist.github.com/fay59/5ccbe684e6e56a7df8815c3486568f01

// CHECK: hl.struct "foo"
// CHECK: hl.struct @foo
struct foo {
// CHECK: hl.struct "bar"
// CHECK: hl.struct @bar
struct bar {
int x;
} baz;
Expand Down
4 changes: 2 additions & 2 deletions test/vast/Dialect/HighLevel/quirks-i.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

// adapted from https://gist.github.com/fay59/5ccbe684e6e56a7df8815c3486568f01

// CHECK: hl.struct "foo"
// CHECK: hl.struct @foo
struct foo {
// CHECK: hl.field "x" : !hl.int
// CHECK: hl.field "y" : !hl.int
int x, y;
};

// CHECK: hl.struct "lots_of_inits"
// CHECK: hl.struct @lots_of_inits
struct lots_of_inits {
// CHECK: hl.field "z" : !hl.array<2, !hl.elaborated<!hl.record<"foo">>>
struct foo z[2];
Expand Down
2 changes: 1 addition & 1 deletion test/vast/Dialect/HighLevel/quirks-j.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

// adapted from https://gist.github.com/fay59/5ccbe684e6e56a7df8815c3486568f01

// CHECK: hl.struct "bitfield"
// CHECK: hl.struct @bitfield
struct bitfield {
// CHECK: hl.field "x" bw 3 : !hl.int< unsigned >
unsigned x: 3;
Expand Down
2 changes: 1 addition & 1 deletion test/vast/Dialect/HighLevel/quirks-n.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
short typedef signed s16;
// CHECK: hl.typedef @u32 : !hl.int< unsigned >
unsigned int typedef u32;
// CHECK: hl.struct "foo"
// CHECK: hl.struct @foo
// CHECK: hl.field "bar" : !hl.int
// CHECK: hl.typedef @baz : !hl.elaborated<!hl.record<"foo">, const >
struct foo { int bar; } const typedef baz;
Expand Down
10 changes: 5 additions & 5 deletions test/vast/Dialect/HighLevel/struct-a.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// RUN: %vast-cc1 -vast-emit-mlir=hl %s -o - | %file-check %s
// RUN: %vast-cc1 -vast-emit-mlir=hl %s -o %t && %vast-opt %t | diff -B %t -

// CHECK: hl.struct "empty"
// CHECK: hl.struct @empty
struct empty {};

// CHECK: hl.struct "pair" : {
// CHECK: hl.struct @pair : {
// CHECK: hl.field "a" : !hl.int
// CHECK: hl.field "b" : !hl.int
// CHECK: }
Expand All @@ -17,14 +17,14 @@ struct pair p;

struct forward;

// CHECK: hl.struct "forward" : {
// CHECK: hl.struct @forward : {
// CHECK: hl.field "a" : !hl.int
// CHECK: }
struct forward {
int a;
};

// CHECK: hl.struct "wrap" : {
// CHECK: hl.struct @wrap : {
// CHECK: hl.field "v" : !hl.int
// CHECK: }

Expand All @@ -36,7 +36,7 @@ typedef struct wrap {
// CHECK: hl.var @w : !hl.lvalue<!hl.elaborated<!hl.typedef<"wrap_t">>>
wrap_t w;

// CHECK: hl.struct "compound" : {
// CHECK: hl.struct @compound : {
// CHECK: hl.field "e" : !hl.elaborated<!hl.record<"empty">>
// CHECK: hl.field "w" : !hl.elaborated<!hl.typedef<"wrap_t">>
// CHECK: }
Expand Down
2 changes: 1 addition & 1 deletion test/vast/Dialect/HighLevel/struct-b.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: %vast-cc1 -vast-emit-mlir=hl %s -o - | %file-check %s
// RUN: %vast-cc1 -vast-emit-mlir=hl %s -o %t && %vast-opt %t | diff -B %t -

// CHECK: hl.struct "node" : {
// CHECK: hl.struct @node : {
// CHECK: hl.field "data" : !hl.int
// CHECK: hl.field "left" : !hl.ptr<!hl.elaborated<!hl.record<"node">>>
// CHECK: hl.field "right" : !hl.ptr<!hl.elaborated<!hl.record<"node">>>
Expand Down
2 changes: 1 addition & 1 deletion test/vast/Dialect/HighLevel/struct-c.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: %vast-cc1 -vast-emit-mlir=hl %s -o - | %file-check %s
// RUN: %vast-cc1 -vast-emit-mlir=hl %s -o %t && %vast-opt %t | diff -B %t -

// CHECK: hl.struct "[[N:anonymous\[[0-9]+\]]]" : {
// CHECK: hl.struct @"[[N:anonymous\[[0-9]+\]]]" : {
// CHECK: hl.field "data" : !hl.int
// CHECK: }
// CHECK: hl.var @named : !hl.lvalue<!hl.elaborated<!hl.record<"[[N]]">>>
Expand Down
2 changes: 1 addition & 1 deletion test/vast/Dialect/HighLevel/struct-d.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
struct s* p = 0;

// definition for the struct pointed to by p
// CHECK: hl.struct "s" : {
// CHECK: hl.struct @s : {
// CHECK: hl.field "a" : !hl.int
// CHECK: }
struct s { int a; };
Expand Down
2 changes: 1 addition & 1 deletion test/vast/Dialect/HighLevel/struct-e.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: %vast-cc1 -vast-emit-mlir=hl %s -o - | %file-check %s
// RUN: %vast-cc1 -vast-emit-mlir=hl %s -o %t && %vast-opt %t | diff -B %t -

// CHECK: hl.struct "s" : {
// CHECK: hl.struct @s : {
// CHECK: hl.field "a" : !hl.int
// CHECK: hl.field "b" : !hl.short
// CHECK: }
Expand Down
4 changes: 2 additions & 2 deletions test/vast/Dialect/HighLevel/struct-f.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// RUN: %vast-cc1 -vast-emit-mlir=hl %s -o - | %file-check %s
// RUN: %vast-cc1 -vast-emit-mlir=hl %s -o %t && %vast-opt %t | diff -B %t -

// CHECK: hl.struct "X"
// CHECK: hl.struct @X
struct X {};

// CHECK: hl.struct "Y"
// CHECK: hl.struct @Y
// CHECK: hl.typedef @X : !hl.elaborated<!hl.record<"Y">>
typedef struct Y {} X;

Expand Down
2 changes: 1 addition & 1 deletion test/vast/Dialect/HighLevel/union-a.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: %vast-cc1 -vast-emit-mlir=hl %s -o - | %file-check %s
// RUN: %vast-cc1 -vast-emit-mlir=hl %s -o %t && %vast-opt %t | diff -B %t -

// CHECK: hl.union "u" : {
// CHECK: hl.union @u : {
// CHECK: hl.field "u32" : !hl.int< unsigned >
// CHECK: hl.field "u16" : !hl.array<2, !hl.short< unsigned >>
// CHECK: hl.field "u8" : !hl.char< unsigned >
Expand Down
8 changes: 4 additions & 4 deletions test/vast/Dialect/HighLevel/union-b.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// RUN: %vast-cc1 -vast-emit-mlir=hl -std=c11 %s -o - | %file-check %s
// RUN: %vast-cc1 -vast-emit-mlir=hl -std=c11 %s -o %t && %vast-opt %t | diff -B %t -

// CHECK: hl.struct "v"
// CHECK: hl.struct @v
struct v {
// CHECK: hl.union "[[N1:anonymous\[[0-9]+\]]]"
// CHECK: hl.union @"[[N1:anonymous\[[0-9]+\]]]"
union { // anonymous union
// CHECK: hl.struct "[[N2:anonymous\[[0-9]+\]]]"
// CHECK: hl.struct @"[[N2:anonymous\[[0-9]+\]]]"
// CHECK: hl.field "i" : !hl.int
// CHECK: hl.field "j" : !hl.int
// CHECK: hl.field "[[N3:anonymous\[[0-9]+\]]]" : !hl.record<"[[N2]]">
struct { int i, j; }; // anonymous structure
// CHECK: hl.struct "[[N4:anonymous\[[0-9]+\]]]"
// CHECK: hl.struct @"[[N4:anonymous\[[0-9]+\]]]"
// CHECK: hl.field "k" : !hl.long
// CHECK: hl.field "l" : !hl.long
// CHECK: hl.field "w" : !hl.elaborated<!hl.record<"[[N4]]">>
Expand Down
2 changes: 1 addition & 1 deletion test/vast/Transform/HL/LowerTypes/struct-access-a.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: %vast-cc1 -vast-emit-mlir=hl %s -o - | %vast-opt --vast-hl-lower-types | %file-check %s

// CHECK: hl.struct "X" : {
// CHECK: hl.struct @X : {
// CHECK: hl.field "member_x" : si32
// CHECK: hl.field "member_y" : si32
// CHECK: }
Expand Down
4 changes: 2 additions & 2 deletions test/vast/Transform/HL/UDE/func-e.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// RUN: %vast-front -vast-emit-mlir=hl %s -o - | %vast-opt --vast-hl-ude | %file-check %s

// CHECK-NOT: hl.struct "unused"
// CHECK-NOT: hl.struct @unused
struct unused {};

// CHECK-NOT: hl.typedef @unused_t
typedef struct unused unused_t;

// CHECK-NOT: hl.struct "unused_rty"
// CHECK-NOT: hl.struct @unused_rty
struct unused_rty {};

// CHECK-NOT: hl.typedef @unused_rty_t
Expand Down
4 changes: 2 additions & 2 deletions test/vast/Transform/HL/UDE/func-f.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// RUN: %vast-front -vast-emit-mlir=hl %s -o - | %vast-opt --vast-hl-ude | %file-check %s

// CHECK-NOT: hl.struct "unused"
// CHECK-NOT: hl.struct @unused
struct unused {};

// CHECK-NOT: hl.typedef @unused_t
typedef struct unused unused_t;

// CHECK-NOT: hl.struct "unused_rty"
// CHECK-NOT: hl.struct @unused_rty
struct unused_rty {};

// CHECK-NOT: hl.typedef @unused_rty_t
Expand Down
6 changes: 3 additions & 3 deletions test/vast/Transform/HL/UDE/func-g.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// RUN: %vast-front -vast-emit-mlir=hl %s -o - | %vast-opt --vast-hl-ude | %file-check %s

// CHECK-NOT: hl.struct "unused"
// CHECK-NOT: hl.struct @unused
struct unused {};

// CHECK: hl.struct "used"
// CHECK: hl.struct @used
struct used {};

// CHECK-NOT: hl.func @inlined
Expand All @@ -15,4 +15,4 @@ __attribute__((always_inline)) void inlined() {
// CHECK: hl.func @not_inlined
void not_inlined() {
struct used u;
}
}
6 changes: 3 additions & 3 deletions test/vast/Transform/HL/UDE/struct-a.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// RUN: %vast-front -vast-emit-mlir=hl %s -o - | %vast-opt --vast-hl-ude | %file-check %s

// CHECK: hl.struct "used"
// CHECK: hl.struct @used
struct used {};

// CHECK-NOT: hl.struct "unused"
// CHECK-NOT: hl.struct @unused
struct unused {};

int main() {
struct used u;
}
}
6 changes: 3 additions & 3 deletions test/vast/Transform/HL/UDE/struct-b.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// RUN: %vast-front -vast-emit-mlir=hl %s -o - | %vast-opt --vast-hl-ude | %file-check %s

// CHECK: hl.struct "used"
// CHECK: hl.struct @used
struct used {};

// CHECK-NOT: hl.struct "unused"
// CHECK-NOT: hl.struct @unused
struct unused {
struct used d;
};

int main() {
struct used u;
}
}
8 changes: 4 additions & 4 deletions test/vast/Transform/HL/UDE/struct-c.c
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
// RUN: %vast-front -vast-emit-mlir=hl %s -o - | %vast-opt --vast-hl-ude | %file-check %s

// CHECK: hl.struct "used"
// CHECK: hl.struct @used
struct used {};

// CHECK: hl.struct "depedent"
// CHECK: hl.struct @depedent
struct depedent
{
struct used u;
};

// CHECK-NOT: hl.struct "unused"
// CHECK-NOT: hl.struct @unused
struct unused {
struct used u;
};

int main() {
struct depedent d;
}
}
6 changes: 3 additions & 3 deletions test/vast/Transform/HL/UDE/struct-d.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// RUN: %vast-front -vast-emit-mlir=hl %s -o - | %vast-opt --vast-hl-ude | %file-check %s

// CHECK-NOT: hl.struct "in_unused"
// CHECK-NOT: hl.struct @in_unused
struct in_unused {};

// CHECK-NOT: hl.struct "dependent_unused"
// CHECK-NOT: hl.struct @dependent_unused
struct dependent_unused {
struct in_unused d;
};

int main() {}
int main() {}
Loading

0 comments on commit 36273f2

Please sign in to comment.