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) allow get_dir to be inlined #3202

Merged
merged 3 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 5 additions & 1 deletion tests/filecheck/backend/csl/print_csl.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@
%ptr_1_fn = "csl.addressof_fn"() <{fn_name = @args_no_return}> : () -> !csl.ptr<(i32, i32) -> (), #csl<ptr_kind single>, #csl<ptr_const const>>
%ptr_2_fn = "csl.addressof_fn"() <{fn_name = @no_args_return}> : () -> !csl.ptr<() -> (f32), #csl<ptr_kind single>, #csl<ptr_const const>>
%dir_test = "csl.get_dir"() <{"dir" = #csl<dir_kind north>}> : () -> !csl.direction
// putting dir_test in a struct to make sure it gets correctly inlined
%struct_with_dir = "csl.const_struct"(%dir_test) <{ssa_fields = ["dir"]}> : (!csl.direction) -> !csl.comptime_struct



Expand Down Expand Up @@ -655,7 +657,9 @@ csl.func @builtins() {
// CHECK-NEXT: const ptr_to_val : *const i16 = &const27;
// CHECK-NEXT: const ptr_1_fn : *const fn(i32, i32) void = &args_no_return;
// CHECK-NEXT: const ptr_2_fn : *const fn() f32 = &no_args_return;
// CHECK-NEXT: const dir_test : direction = NORTH;
// CHECK-NEXT: const struct_with_dir : comptime_struct = .{
// CHECK-NEXT: .dir = NORTH,
// CHECK-NEXT: };
// CHECK-NEXT: comptime {
// CHECK-NEXT: @export_symbol(global_ptr, "ptr_name");
// CHECK-NEXT: }
Expand Down
3 changes: 1 addition & 2 deletions xdsl/backend/csl/print_csl.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,8 +684,7 @@ def print_block(self, body: Block):
use = self._var_use(res, ty.constness.data.value)
self.print(f"{use} = &{name.string_value()};")
case csl.DirectionOp(dir=d, res=res):
use = self._var_use(res)
self.print(f"{use} = {str.upper(d.data)};")
self._print_or_promote_to_inline_expr(res, str.upper(d.data))
case csl.SymbolExportOp(value=val, type=ty) as exp:
name = exp.get_name()
q_name = f'"{name}"'
Expand Down
Loading