From 5d9837e3b8272ea432456a8f2b24e7ede2ce6cf2 Mon Sep 17 00:00:00 2001 From: David K Date: Mon, 23 Sep 2024 11:59:23 +0100 Subject: [PATCH] backend: (csl) allow `get_dir` to be inlined (#3202) Using `_print_or_promote_to_inline_expr` instead of `print` --- tests/filecheck/backend/csl/print_csl.mlir | 6 +++++- xdsl/backend/csl/print_csl.py | 3 +-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/filecheck/backend/csl/print_csl.mlir b/tests/filecheck/backend/csl/print_csl.mlir index e5c9aab3f9..c18499ca86 100644 --- a/tests/filecheck/backend/csl/print_csl.mlir +++ b/tests/filecheck/backend/csl/print_csl.mlir @@ -222,6 +222,8 @@ %ptr_1_fn = "csl.addressof_fn"() <{fn_name = @args_no_return}> : () -> !csl.ptr<(i32, i32) -> (), #csl, #csl> %ptr_2_fn = "csl.addressof_fn"() <{fn_name = @no_args_return}> : () -> !csl.ptr<() -> (f32), #csl, #csl> %dir_test = "csl.get_dir"() <{"dir" = #csl}> : () -> !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 @@ -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: } diff --git a/xdsl/backend/csl/print_csl.py b/xdsl/backend/csl/print_csl.py index ccd57e539f..036c587301 100644 --- a/xdsl/backend/csl/print_csl.py +++ b/xdsl/backend/csl/print_csl.py @@ -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}"'