Skip to content

Commit 8530f62

Browse files
raghav198Raghav Malik
authored andcommitted
Refactor to make struct inlining available on demand (#212)
1 parent c2a569d commit 8530f62

File tree

3 files changed

+309
-281
lines changed

3 files changed

+309
-281
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
changed:
2+
- Refactored LLZKInlineStructs pass to allow inlining on demand
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//===-- LLZKInlineStructsPass.h ---------------------------------*- C++ -*-===//
2+
//
3+
// Part of the LLZK Project, under the Apache License v2.0.
4+
// See LICENSE.txt for license information.
5+
// Copyright 2025 Veridise Inc.
6+
// SPDX-License-Identifier: Apache-2.0
7+
//
8+
//===----------------------------------------------------------------------===//
9+
10+
#pragma once
11+
12+
#include <llzk/Dialect/Struct/IR/Ops.h>
13+
14+
#include <mlir/IR/SymbolTable.h>
15+
#include <mlir/Support/LogicalResult.h>
16+
17+
/// Maps caller struct to callees that should be inlined. The outer SmallVector preserves the
18+
/// ordering from the bottom-up traversal that builds the InliningPlan so performing inlining
19+
/// in the order given will not lose any or require doing any more than once.
20+
/// Note: Applying in the opposite direction would reduce making repeated clones of the ops within
21+
/// the inlined struct functions (as they are inlined further and further up the tree) but that
22+
/// would require updating some mapping in the plan along the way to ensure it's done properly.
23+
using InliningPlan = mlir::SmallVector<
24+
std::pair<llzk::component::StructDefOp, mlir::SmallVector<llzk::component::StructDefOp>>>;
25+
26+
mlir::LogicalResult performInlining(mlir::SymbolTableCollection &tables, InliningPlan &plan);

0 commit comments

Comments
 (0)