Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backend: (csl) Array literals #3292

Merged
merged 7 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tests/filecheck/backend/csl/print_csl.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@
%global_array = memref.get_global @global_array : memref<10xf32>
%const_array = memref.get_global @const_array : memref<10xi32>

%literal_array = arith.constant dense<[1.200000e+00, 2.300000e+00, 3.400000e+00]> : memref<3xf32>

%uninit_ptr = "csl.addressof"(%uninit_array) : (memref<10xf32>) -> !csl.ptr<f32, #csl<ptr_kind many>, #csl<ptr_const var>>
%global_ptr = "csl.addressof"(%global_array) : (memref<10xf32>) -> !csl.ptr<f32, #csl<ptr_kind many>, #csl<ptr_const var>>
%const_ptr = "csl.addressof"(%const_array) : (memref<10xi32>) -> !csl.ptr<i32, #csl<ptr_kind many>, #csl<ptr_const const>>
Expand Down Expand Up @@ -652,6 +654,7 @@ csl.func @builtins() {
// CHECK-NEXT: var uninit_array : [10]f32;
// CHECK-NEXT: var global_array : [10]f32 = @constants([10]f32, 4.2);
// CHECK-NEXT: const const_array : [10]i32 = @constants([10]i32, 10);
// CHECK-NEXT: const literal_array : [3]f32 = [3]f32{1.2, 2.3, 3.4};
// CHECK-NEXT: var uninit_ptr : [*]f32 = &uninit_array;
// CHECK-NEXT: var global_ptr : [*]f32 = &global_array;
// CHECK-NEXT: const const_ptr : [*]const i32 = &const_array;
Expand Down
2 changes: 2 additions & 0 deletions xdsl/backend/csl/print_csl.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,8 @@ def attribute_value_to_str(self, attr: Attribute) -> str:
return str(val.data)
case StringAttr() as s:
return f'"{s.data}"'
case DenseIntOrFPElementsAttr(data=ArrayAttr(data=data), type=typ):
return f"{self.mlir_type_to_csl_type(typ)}{{{", ".join(self.attribute_value_to_str(d) for d in data)}}}"
case _:
return f"<!unknown value {attr}>"

Expand Down
Loading