From cfd3ff49b5ed8115b1b1d2d92c6b0b1499d37c65 Mon Sep 17 00:00:00 2001 From: jacobdweightman Date: Wed, 4 Sep 2024 20:35:54 -0500 Subject: [PATCH] Clang format; update generated code --- zirgen/Dialect/ZHLT/IR/TypeUtils.cpp | 4 +- zirgen/dsl/examples/calculator.cpp.inc | 47 ++++++------- zirgen/dsl/examples/calculator.ir | 93 +++++++++++++------------- zirgen/dsl/examples/calculator.rs.inc | 48 ++++++------- zirgen/dsl/passes/Passes.h | 3 +- 5 files changed, 102 insertions(+), 93 deletions(-) diff --git a/zirgen/Dialect/ZHLT/IR/TypeUtils.cpp b/zirgen/Dialect/ZHLT/IR/TypeUtils.cpp index 28a3a42d..57f18d94 100644 --- a/zirgen/Dialect/ZHLT/IR/TypeUtils.cpp +++ b/zirgen/Dialect/ZHLT/IR/TypeUtils.cpp @@ -163,7 +163,9 @@ Value coerceStructToSuper(TypedValue value, OpBuilder& builder) { } } -Value coerceArrayTo(TypedValue value, ArrayLikeTypeInterface goalType, OpBuilder& builder) { +Value coerceArrayTo(TypedValue value, + ArrayLikeTypeInterface goalType, + OpBuilder& builder) { Location loc = value.getLoc(); assert(value.getType().getSize() == goalType.getSize()); diff --git a/zirgen/dsl/examples/calculator.cpp.inc b/zirgen/dsl/examples/calculator.cpp.inc index 2c5b5a7e..ac2fe2af 100644 --- a/zirgen/dsl/examples/calculator.cpp.inc +++ b/zirgen/dsl/examples/calculator.cpp.inc @@ -200,44 +200,45 @@ TopStruct exec_Top(ExecContext ctx0, BoundLayout layout1) { NondetRegStruct x8 = exec_NondetReg(ctx0, x7._super, LAYOUT_LOOKUP(layout1, right)); // Top(zirgen/dsl/examples/calculator.zir:36) OneHotStruct x9 = exec_OneHot(ctx0, x4._super, LAYOUT_LOOKUP(layout1, _0)); - NondetRegStruct2Array x10 = x9._super; - BoundLayout x11 = LAYOUT_LOOKUP(x2, _super); - RegStruct x12; - if (to_size_t(x10[0]._super)) { + Val2Array x10 = map( + x9._super, std::function([&](NondetRegStruct2Array::value_type x11) { return x11._super; })); + BoundLayout x12 = LAYOUT_LOOKUP(x2, _super); + RegStruct x13; + if (to_size_t(x10[0])) { // Top(zirgen/dsl/examples/calculator.zir:37) - Val x13 = exec_Add(ctx0, x6._super, x8._super); - RegStruct x14 = exec_Reg(ctx0, x13, LAYOUT_LOOKUP(x2, arm0)); - x12 = x14; - } else if (to_size_t(x10[1]._super)) { + Val x14 = exec_Add(ctx0, x6._super, x8._super); + RegStruct x15 = exec_Reg(ctx0, x14, LAYOUT_LOOKUP(x2, arm0)); + x13 = x15; + } else if (to_size_t(x10[1])) { // Top(zirgen/dsl/examples/calculator.zir:38) - Val x15 = exec_Sub(ctx0, x6._super, x8._super); - RegStruct x16 = exec_Reg(ctx0, x15, LAYOUT_LOOKUP(x2, arm1)); - x12 = x16; + Val x16 = exec_Sub(ctx0, x6._super, x8._super); + RegStruct x17 = exec_Reg(ctx0, x16, LAYOUT_LOOKUP(x2, arm1)); + x13 = x17; } else { assert(0 && "Reached unreachable mux arm"); } // Top(zirgen/dsl/examples/calculator.zir:36) - RegStruct x17 = back_Reg(ctx0, 0, x11); + RegStruct x18 = back_Reg(ctx0, 0, x12); // Top(zirgen/dsl/examples/calculator.zir:40) - ComponentStruct x18 = - exec_Log(ctx0, "result = %u", std::initializer_list{x17._super._super}); + ComponentStruct x19 = + exec_Log(ctx0, "result = %u", std::initializer_list{x18._super._super}); // Top(zirgen/dsl/examples/calculator.zir:36) - RegStruct x19 = back_Reg(ctx0, 0, x11); + RegStruct x20 = back_Reg(ctx0, 0, x12); // Top(zirgen/dsl/examples/calculator.zir:41) - ComponentStruct x20 = exec_SetGlobalResult(ctx0, x19._super._super); + ComponentStruct x21 = exec_SetGlobalResult(ctx0, x20._super._super); // Top(zirgen/dsl/examples/calculator.zir:42) - RegStruct x21 = exec_GetGlobalResult(ctx0); + RegStruct x22 = exec_GetGlobalResult(ctx0); // Top(zirgen/dsl/examples/calculator.zir:36) - RegStruct x22 = back_Reg(ctx0, 0, x11); + RegStruct x23 = back_Reg(ctx0, 0, x12); // Top(zirgen/dsl/examples/calculator.zir:42) - EQZ((x21._super._super - x22._super._super), "Top(zirgen/dsl/examples/calculator.zir:42)"); + EQZ((x22._super._super - x23._super._super), "Top(zirgen/dsl/examples/calculator.zir:42)"); // Top(zirgen/dsl/examples/calculator.zir:36) - RegStruct x23 = back_Reg(ctx0, 0, x11); + RegStruct x24 = back_Reg(ctx0, 0, x12); // Top(zirgen/dsl/examples/calculator.zir:43) - ComponentStruct x24 = exec_OutputToUser(ctx0, x23._super._super); + ComponentStruct x25 = exec_OutputToUser(ctx0, x24._super._super); // Top(zirgen/dsl/examples/calculator.zir:32) - ComponentStruct x25 = exec_Component(ctx0); - return TopStruct{._super = x25, .op = x4, .left = x6, .right = x8, .result = x17}; + ComponentStruct x26 = exec_Component(ctx0); + return TopStruct{._super = x26, .op = x4, .left = x6, .right = x8, .result = x18}; } void step_Top(ExecContext ctx0) { BoundLayout x1 = BIND_LAYOUT(kLayout_Top, GET_BUFFER(ctx0, data)); diff --git a/zirgen/dsl/examples/calculator.ir b/zirgen/dsl/examples/calculator.ir index 48cbdd8c..91cdd2c1 100644 --- a/zirgen/dsl/examples/calculator.ir +++ b/zirgen/dsl/examples/calculator.ir @@ -82,14 +82,14 @@ module { %2 = zll.const 2 %3 = zstruct.lookup %layout["@super"] : (!zlayout$OneHot) -> !zstruct.layout_array %4 = zstruct.array[%1, %0 : !zll.val, !zll.val] - %5 = zstruct.map %4 : , 2>, %3 : !zstruct.layout_array -> !zstruct.array { + %5 = zstruct.map %4 : !zstruct.array, 2>, %3 : !zstruct.layout_array -> !zstruct.array { ^bb0(%arg1: !zll.val, %arg2: !zlayout$NondetReg): %13 = zhlt.call_exec @exec$Sub(%ctx, %arg1, %arg0) : (!zhlt.exec_context, !zll.val, !zll.val) -> !zll.val {callee_type = (!zhlt.exec_context, !zll.val, !zll.val) -> !zll.val, input_segment_sizes = array, operandSegmentSizes = array, result_segment_sizes = array} %14 = zhlt.call_exec @exec$Isz(%ctx, %13) : (!zhlt.exec_context, !zll.val) -> !zll.val {callee_type = (!zhlt.exec_context, !zll.val) -> !zll.val, input_segment_sizes = array, operandSegmentSizes = array, result_segment_sizes = array} %15 = zhlt.call_exec @exec$NondetReg(%ctx, %14, %arg2) : (!zhlt.exec_context, !zll.val, !zlayout$NondetReg) -> !zstruct$NondetReg {callee_type = (!zhlt.exec_context, !zll.val, !zlayout$NondetReg) -> !zstruct$NondetReg, input_segment_sizes = array, operandSegmentSizes = array, result_segment_sizes = array} zstruct.yield %15 : !zstruct$NondetReg } - %6 = zstruct.map %5 : -> !zstruct.array { + %6 = zstruct.map %5 : !zstruct.array -> !zstruct.array { ^bb0(%arg1: !zstruct$NondetReg): %13 = zstruct.lookup %arg1["@super"] : (!zstruct$NondetReg) -> !zll.val %14 = zhlt.call_exec @exec$Sub(%ctx, %0, %13) : (!zhlt.exec_context, !zll.val, !zll.val) -> !zll.val {callee_type = (!zhlt.exec_context, !zll.val, !zll.val) -> !zll.val, input_segment_sizes = array, operandSegmentSizes = array, result_segment_sizes = array} @@ -106,7 +106,7 @@ module { } %8 = zll.sub %7 : , %0 : zll.eqz %8 : - %9 = zstruct.map %4 : , 2> -> !zstruct.array { + %9 = zstruct.map %4 : !zstruct.array, 2> -> !zstruct.array { ^bb0(%arg1: !zll.val): %13 = zstruct.subscript %5[!zll.val %arg1] : (!zstruct.array) -> !zstruct$NondetReg %14 = zstruct.lookup %13["@super"] : (!zstruct$NondetReg) -> !zll.val @@ -163,50 +163,53 @@ module { %17 = zstruct.lookup %10["@super"] : (!zstruct$NondetReg) -> !zll.val %18 = zhlt.call_exec @exec$OneHot(%ctx, %17, %6) : (!zhlt.exec_context, !zll.val, !zlayout$OneHot) -> !zstruct$OneHot {callee_type = (!zhlt.exec_context, !zll.val, !zlayout$OneHot) -> !zstruct$OneHot, input_segment_sizes = array, operandSegmentSizes = array, result_segment_sizes = array} %19 = zstruct.lookup %18["@super"] : (!zstruct$OneHot) -> !zstruct.array - %20 = zstruct.subscript %19[!zll.val %2] : (!zstruct.array) -> !zstruct$NondetReg - %21 = zstruct.lookup %20["@super"] : (!zstruct$NondetReg) -> !zll.val - %22 = zstruct.subscript %19[!zll.val %1] : (!zstruct.array) -> !zstruct$NondetReg - %23 = zstruct.lookup %22["@super"] : (!zstruct$NondetReg) -> !zll.val - %24 = zstruct.lookup %7["@super"] : (!zlayout$Top_result) -> !zlayout$NondetReg - %25 = zstruct.lookup %7["arm0"] : (!zlayout$Top_result) -> !zlayout$NondetReg - %26 = zstruct.lookup %7["arm1"] : (!zlayout$Top_result) -> !zlayout$NondetReg - %27 = zstruct.switch %21, %23 : !zll.val, !zll.val : !zstruct$Reg -> { - %50 = zstruct.lookup %13["@super"] : (!zstruct$NondetReg) -> !zll.val - %51 = zstruct.lookup %16["@super"] : (!zstruct$NondetReg) -> !zll.val - %52 = zhlt.call_exec @exec$Add(%ctx, %50, %51) : (!zhlt.exec_context, !zll.val, !zll.val) -> !zll.val {callee_type = (!zhlt.exec_context, !zll.val, !zll.val) -> !zll.val, input_segment_sizes = array, operandSegmentSizes = array, result_segment_sizes = array} - %53 = zhlt.call_exec @exec$Reg(%ctx, %52, %25) : (!zhlt.exec_context, !zll.val, !zlayout$NondetReg) -> !zstruct$Reg {callee_type = (!zhlt.exec_context, !zll.val, !zlayout$NondetReg) -> !zstruct$Reg, input_segment_sizes = array, operandSegmentSizes = array, result_segment_sizes = array} - zstruct.yield %53 : !zstruct$Reg + %20 = zstruct.map %19 : !zstruct.array -> !zstruct.array, 2> { + ^bb0(%arg0: !zstruct$NondetReg): + %49 = zstruct.lookup %arg0["@super"] : (!zstruct$NondetReg) -> !zll.val + zstruct.yield %49 : !zll.val + } + %21 = zstruct.lookup %7["@super"] : (!zlayout$Top_result) -> !zlayout$NondetReg + %22 = zstruct.lookup %7["arm0"] : (!zlayout$Top_result) -> !zlayout$NondetReg + %23 = zstruct.lookup %7["arm1"] : (!zlayout$Top_result) -> !zlayout$NondetReg + %24 = zstruct.subscript %20[!zll.val %2] : (!zstruct.array, 2>) -> !zll.val + %25 = zstruct.subscript %20[!zll.val %1] : (!zstruct.array, 2>) -> !zll.val + %26 = zstruct.switch %24, %25 : !zll.val, !zll.val : !zstruct$Reg -> { + %49 = zstruct.lookup %13["@super"] : (!zstruct$NondetReg) -> !zll.val + %50 = zstruct.lookup %16["@super"] : (!zstruct$NondetReg) -> !zll.val + %51 = zhlt.call_exec @exec$Add(%ctx, %49, %50) : (!zhlt.exec_context, !zll.val, !zll.val) -> !zll.val {callee_type = (!zhlt.exec_context, !zll.val, !zll.val) -> !zll.val, input_segment_sizes = array, operandSegmentSizes = array, result_segment_sizes = array} + %52 = zhlt.call_exec @exec$Reg(%ctx, %51, %22) : (!zhlt.exec_context, !zll.val, !zlayout$NondetReg) -> !zstruct$Reg {callee_type = (!zhlt.exec_context, !zll.val, !zlayout$NondetReg) -> !zstruct$Reg, input_segment_sizes = array, operandSegmentSizes = array, result_segment_sizes = array} + zstruct.yield %52 : !zstruct$Reg }, { - %50 = zstruct.lookup %13["@super"] : (!zstruct$NondetReg) -> !zll.val - %51 = zstruct.lookup %16["@super"] : (!zstruct$NondetReg) -> !zll.val - %52 = zhlt.call_exec @exec$Sub(%ctx, %50, %51) : (!zhlt.exec_context, !zll.val, !zll.val) -> !zll.val {callee_type = (!zhlt.exec_context, !zll.val, !zll.val) -> !zll.val, input_segment_sizes = array, operandSegmentSizes = array, result_segment_sizes = array} - %53 = zhlt.call_exec @exec$Reg(%ctx, %52, %26) : (!zhlt.exec_context, !zll.val, !zlayout$NondetReg) -> !zstruct$Reg {callee_type = (!zhlt.exec_context, !zll.val, !zlayout$NondetReg) -> !zstruct$Reg, input_segment_sizes = array, operandSegmentSizes = array, result_segment_sizes = array} - zstruct.yield %53 : !zstruct$Reg + %49 = zstruct.lookup %13["@super"] : (!zstruct$NondetReg) -> !zll.val + %50 = zstruct.lookup %16["@super"] : (!zstruct$NondetReg) -> !zll.val + %51 = zhlt.call_exec @exec$Sub(%ctx, %49, %50) : (!zhlt.exec_context, !zll.val, !zll.val) -> !zll.val {callee_type = (!zhlt.exec_context, !zll.val, !zll.val) -> !zll.val, input_segment_sizes = array, operandSegmentSizes = array, result_segment_sizes = array} + %52 = zhlt.call_exec @exec$Reg(%ctx, %51, %23) : (!zhlt.exec_context, !zll.val, !zlayout$NondetReg) -> !zstruct$Reg {callee_type = (!zhlt.exec_context, !zll.val, !zlayout$NondetReg) -> !zstruct$Reg, input_segment_sizes = array, operandSegmentSizes = array, result_segment_sizes = array} + zstruct.yield %52 : !zstruct$Reg } {layoutType = !zlayout$Top_result} - %28 = zhlt.call_back @back$Reg(%ctx, %c0, %24) : (!zhlt.exec_context, index, !zlayout$NondetReg) -> !zstruct$Reg {callee_type = (!zhlt.exec_context, index, !zlayout$NondetReg) -> !zstruct$Reg, input_segment_sizes = array, result_segment_sizes = array} - %29 = zstruct.lookup %28["@super"] : (!zstruct$Reg) -> !zstruct$NondetReg - %30 = zstruct.lookup %29["@super"] : (!zstruct$NondetReg) -> !zll.val - %31 = zll.variadic_pack %30 : (!zll.val) -> !zll> - %32 = zhlt.call_exec @exec$Log(%ctx, %0, %31) : (!zhlt.exec_context, !zll.string, !zll>) -> !zstruct$Component {callee_type = (!zhlt.exec_context, !zll.string, !zll>) -> !zstruct$Component, input_segment_sizes = array, operandSegmentSizes = array, result_segment_sizes = array} - %33 = zhlt.call_back @back$Reg(%ctx, %c0, %24) : (!zhlt.exec_context, index, !zlayout$NondetReg) -> !zstruct$Reg {callee_type = (!zhlt.exec_context, index, !zlayout$NondetReg) -> !zstruct$Reg, input_segment_sizes = array, result_segment_sizes = array} - %34 = zstruct.lookup %33["@super"] : (!zstruct$Reg) -> !zstruct$NondetReg - %35 = zstruct.lookup %34["@super"] : (!zstruct$NondetReg) -> !zll.val - %36 = zhlt.call_exec @exec$SetGlobalResult(%ctx, %35) : (!zhlt.exec_context, !zll.val) -> !zstruct$Component {callee_type = (!zhlt.exec_context, !zll.val) -> !zstruct$Component, input_segment_sizes = array, operandSegmentSizes = array, result_segment_sizes = array} - %37 = zhlt.call_exec @exec$GetGlobalResult(%ctx) : (!zhlt.exec_context) -> !zstruct$Reg {callee_type = (!zhlt.exec_context) -> !zstruct$Reg, input_segment_sizes = array, operandSegmentSizes = array, result_segment_sizes = array} - %38 = zstruct.lookup %37["@super"] : (!zstruct$Reg) -> !zstruct$NondetReg - %39 = zstruct.lookup %38["@super"] : (!zstruct$NondetReg) -> !zll.val - %40 = zhlt.call_back @back$Reg(%ctx, %c0, %24) : (!zhlt.exec_context, index, !zlayout$NondetReg) -> !zstruct$Reg {callee_type = (!zhlt.exec_context, index, !zlayout$NondetReg) -> !zstruct$Reg, input_segment_sizes = array, result_segment_sizes = array} - %41 = zstruct.lookup %40["@super"] : (!zstruct$Reg) -> !zstruct$NondetReg - %42 = zstruct.lookup %41["@super"] : (!zstruct$NondetReg) -> !zll.val - %43 = zll.sub %39 : , %42 : - zll.eqz %43 : - %44 = zhlt.call_back @back$Reg(%ctx, %c0, %24) : (!zhlt.exec_context, index, !zlayout$NondetReg) -> !zstruct$Reg {callee_type = (!zhlt.exec_context, index, !zlayout$NondetReg) -> !zstruct$Reg, input_segment_sizes = array, result_segment_sizes = array} - %45 = zstruct.lookup %44["@super"] : (!zstruct$Reg) -> !zstruct$NondetReg - %46 = zstruct.lookup %45["@super"] : (!zstruct$NondetReg) -> !zll.val - %47 = zhlt.call_exec @exec$OutputToUser(%ctx, %46) : (!zhlt.exec_context, !zll.val) -> !zstruct$Component {callee_type = (!zhlt.exec_context, !zll.val) -> !zstruct$Component, input_segment_sizes = array, operandSegmentSizes = array, result_segment_sizes = array} - %48 = zhlt.call_exec @exec$Component(%ctx) : (!zhlt.exec_context) -> !zstruct$Component {callee_type = (!zhlt.exec_context) -> !zstruct$Component, input_segment_sizes = array, operandSegmentSizes = array, result_segment_sizes = array} - %49 = zstruct.pack(%48, %10, %13, %16, %28 : !zstruct$Component, !zstruct$NondetReg, !zstruct$NondetReg, !zstruct$NondetReg, !zstruct$Reg) : !zstruct$Top - zhlt.return %49 : !zstruct$Top + %27 = zhlt.call_back @back$Reg(%ctx, %c0, %21) : (!zhlt.exec_context, index, !zlayout$NondetReg) -> !zstruct$Reg {callee_type = (!zhlt.exec_context, index, !zlayout$NondetReg) -> !zstruct$Reg, input_segment_sizes = array, result_segment_sizes = array} + %28 = zstruct.lookup %27["@super"] : (!zstruct$Reg) -> !zstruct$NondetReg + %29 = zstruct.lookup %28["@super"] : (!zstruct$NondetReg) -> !zll.val + %30 = zll.variadic_pack %29 : (!zll.val) -> !zll> + %31 = zhlt.call_exec @exec$Log(%ctx, %0, %30) : (!zhlt.exec_context, !zll.string, !zll>) -> !zstruct$Component {callee_type = (!zhlt.exec_context, !zll.string, !zll>) -> !zstruct$Component, input_segment_sizes = array, operandSegmentSizes = array, result_segment_sizes = array} + %32 = zhlt.call_back @back$Reg(%ctx, %c0, %21) : (!zhlt.exec_context, index, !zlayout$NondetReg) -> !zstruct$Reg {callee_type = (!zhlt.exec_context, index, !zlayout$NondetReg) -> !zstruct$Reg, input_segment_sizes = array, result_segment_sizes = array} + %33 = zstruct.lookup %32["@super"] : (!zstruct$Reg) -> !zstruct$NondetReg + %34 = zstruct.lookup %33["@super"] : (!zstruct$NondetReg) -> !zll.val + %35 = zhlt.call_exec @exec$SetGlobalResult(%ctx, %34) : (!zhlt.exec_context, !zll.val) -> !zstruct$Component {callee_type = (!zhlt.exec_context, !zll.val) -> !zstruct$Component, input_segment_sizes = array, operandSegmentSizes = array, result_segment_sizes = array} + %36 = zhlt.call_exec @exec$GetGlobalResult(%ctx) : (!zhlt.exec_context) -> !zstruct$Reg {callee_type = (!zhlt.exec_context) -> !zstruct$Reg, input_segment_sizes = array, operandSegmentSizes = array, result_segment_sizes = array} + %37 = zstruct.lookup %36["@super"] : (!zstruct$Reg) -> !zstruct$NondetReg + %38 = zstruct.lookup %37["@super"] : (!zstruct$NondetReg) -> !zll.val + %39 = zhlt.call_back @back$Reg(%ctx, %c0, %21) : (!zhlt.exec_context, index, !zlayout$NondetReg) -> !zstruct$Reg {callee_type = (!zhlt.exec_context, index, !zlayout$NondetReg) -> !zstruct$Reg, input_segment_sizes = array, result_segment_sizes = array} + %40 = zstruct.lookup %39["@super"] : (!zstruct$Reg) -> !zstruct$NondetReg + %41 = zstruct.lookup %40["@super"] : (!zstruct$NondetReg) -> !zll.val + %42 = zll.sub %38 : , %41 : + zll.eqz %42 : + %43 = zhlt.call_back @back$Reg(%ctx, %c0, %21) : (!zhlt.exec_context, index, !zlayout$NondetReg) -> !zstruct$Reg {callee_type = (!zhlt.exec_context, index, !zlayout$NondetReg) -> !zstruct$Reg, input_segment_sizes = array, result_segment_sizes = array} + %44 = zstruct.lookup %43["@super"] : (!zstruct$Reg) -> !zstruct$NondetReg + %45 = zstruct.lookup %44["@super"] : (!zstruct$NondetReg) -> !zll.val + %46 = zhlt.call_exec @exec$OutputToUser(%ctx, %45) : (!zhlt.exec_context, !zll.val) -> !zstruct$Component {callee_type = (!zhlt.exec_context, !zll.val) -> !zstruct$Component, input_segment_sizes = array, operandSegmentSizes = array, result_segment_sizes = array} + %47 = zhlt.call_exec @exec$Component(%ctx) : (!zhlt.exec_context) -> !zstruct$Component {callee_type = (!zhlt.exec_context) -> !zstruct$Component, input_segment_sizes = array, operandSegmentSizes = array, result_segment_sizes = array} + %48 = zstruct.pack(%47, %10, %13, %16, %27 : !zstruct$Component, !zstruct$NondetReg, !zstruct$NondetReg, !zstruct$NondetReg, !zstruct$Reg) : !zstruct$Top + zhlt.return %48 : !zstruct$Top } zhlt.step_func @step$Top(%ctx: !zhlt.exec_context) attributes {input_segment_sizes = array, result_segment_sizes = array} { %0 = zstruct.get_buffer "data" : <6, mutable> diff --git a/zirgen/dsl/examples/calculator.rs.inc b/zirgen/dsl/examples/calculator.rs.inc index 527bb3f4..6cf69643 100644 --- a/zirgen/dsl/examples/calculator.rs.inc +++ b/zirgen/dsl/examples/calculator.rs.inc @@ -331,50 +331,52 @@ pub fn exec_top( let x8: NondetRegStruct = exec_nondet_reg(ctx0, x7._super, layout_lookup!(layout1, right))?; // Top(zirgen/dsl/examples/calculator.zir:36) let x9: OneHotStruct = exec_one_hot(ctx0, x4._super, layout_lookup!(layout1, _0))?; - let x10: NondetRegStruct2Array = x9._super; - let x11: BoundLayout = layout_lookup!(x2, _super); - let x12: RegStruct; - if is_nonzero(x10[0]._super) { + let x10: Val2Array = map(x9._super, |x11| { + return Ok(x11._super); + })?; + let x12: BoundLayout = layout_lookup!(x2, _super); + let x13: RegStruct; + if is_nonzero(x10[0]) { // Top(zirgen/dsl/examples/calculator.zir:37) - let x13: Val = exec_add(ctx0, x6._super, x8._super)?; - let x14: RegStruct = exec_reg(ctx0, x13, layout_lookup!(x2, arm0))?; - x12 = x14; - } else if is_nonzero(x10[1]._super) { + let x14: Val = exec_add(ctx0, x6._super, x8._super)?; + let x15: RegStruct = exec_reg(ctx0, x14, layout_lookup!(x2, arm0))?; + x13 = x15; + } else if is_nonzero(x10[1]) { // Top(zirgen/dsl/examples/calculator.zir:38) - let x15: Val = exec_sub(ctx0, x6._super, x8._super)?; - let x16: RegStruct = exec_reg(ctx0, x15, layout_lookup!(x2, arm1))?; - x12 = x16; + let x16: Val = exec_sub(ctx0, x6._super, x8._super)?; + let x17: RegStruct = exec_reg(ctx0, x16, layout_lookup!(x2, arm1))?; + x13 = x17; } else { bail!("Reached unreachable mux arm") } // Top(zirgen/dsl/examples/calculator.zir:36) - let x17: RegStruct = back_reg(ctx0, 0, x11)?; + let x18: RegStruct = back_reg(ctx0, 0, x12)?; // Top(zirgen/dsl/examples/calculator.zir:40) - let x18: ComponentStruct = exec_log(ctx0, "result = %u", &[x17._super._super])?; + let x19: ComponentStruct = exec_log(ctx0, "result = %u", &[x18._super._super])?; // Top(zirgen/dsl/examples/calculator.zir:36) - let x19: RegStruct = back_reg(ctx0, 0, x11)?; + let x20: RegStruct = back_reg(ctx0, 0, x12)?; // Top(zirgen/dsl/examples/calculator.zir:41) - let x20: ComponentStruct = exec_set_global_result(ctx0, x19._super._super)?; + let x21: ComponentStruct = exec_set_global_result(ctx0, x20._super._super)?; // Top(zirgen/dsl/examples/calculator.zir:42) - let x21: RegStruct = exec_get_global_result(ctx0)?; + let x22: RegStruct = exec_get_global_result(ctx0)?; // Top(zirgen/dsl/examples/calculator.zir:36) - let x22: RegStruct = back_reg(ctx0, 0, x11)?; + let x23: RegStruct = back_reg(ctx0, 0, x12)?; // Top(zirgen/dsl/examples/calculator.zir:42) eqz!( - (x21._super._super - x22._super._super), + (x22._super._super - x23._super._super), "Top(zirgen/dsl/examples/calculator.zir:42)" ); // Top(zirgen/dsl/examples/calculator.zir:36) - let x23: RegStruct = back_reg(ctx0, 0, x11)?; + let x24: RegStruct = back_reg(ctx0, 0, x12)?; // Top(zirgen/dsl/examples/calculator.zir:43) - let x24: ComponentStruct = exec_output_to_user(ctx0, x23._super._super)?; + let x25: ComponentStruct = exec_output_to_user(ctx0, x24._super._super)?; // Top(zirgen/dsl/examples/calculator.zir:32) - let x25: ComponentStruct = exec_component(ctx0)?; + let x26: ComponentStruct = exec_component(ctx0)?; return Ok(TopStruct { - _super: x25, + _super: x26, op: x4, left: x6, right: x8, - result: x17, + result: x18, }); } pub fn step_top(ctx0: &ExecContext) -> Result<()> { diff --git a/zirgen/dsl/passes/Passes.h b/zirgen/dsl/passes/Passes.h index ec8af57f..8646b68a 100644 --- a/zirgen/dsl/passes/Passes.h +++ b/zirgen/dsl/passes/Passes.h @@ -22,7 +22,8 @@ namespace zirgen { namespace dsl { // Pass constructors -std::unique_ptr> createEraseUnusedAspectsPass(bool forTests = false); +std::unique_ptr> +createEraseUnusedAspectsPass(bool forTests = false); std::unique_ptr> createGenerateBackPass(); std::unique_ptr> createGenerateExecPass(); std::unique_ptr> createGenerateLayoutPass();