Skip to content

Commit

Permalink
backend: (csl) allow get_dir to be inlined (#3202)
Browse files Browse the repository at this point in the history
Using `_print_or_promote_to_inline_expr` instead of `print`
  • Loading branch information
dk949 authored Sep 23, 2024
1 parent 57c9fa2 commit 5d9837e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
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

0 comments on commit 5d9837e

Please sign in to comment.