Skip to content

Add Op registration to symbol table inside OpBuilder #4

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

Open
wants to merge 80 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
4be32d5
Add a SymbolTableRef to Component so that it will be used as build ar…
lima-limon-inc May 19, 2025
80f0805
Add a quoted macro to the operation builder. Curren tly expands corre…
lima-limon-inc May 19, 2025
6c3e62d
Add jamon field to OperationFieldAttrs. Now it gets parsed :partying_…
lima-limon-inc May 19, 2025
93a609a
WIP: Checkpoint
lima-limon-inc May 20, 2025
3b1e541
Checkpoint 2: Code is generated when using the #[jamon] decorator
lima-limon-inc May 20, 2025
15f4723
Checkpoint 3: The member variable name is expanded correctly
lima-limon-inc May 20, 2025
35116e0
Remove unsafe from macro as it is not currently needed
lima-limon-inc May 20, 2025
9e9f4d0
Save reference in macro
lima-limon-inc May 20, 2025
613c9e1
Extend BuildOp to use with_jamon
lima-limon-inc May 20, 2025
4404ad0
WARNING: This doesn't compile, this is the macro we need, but has bor…
lima-limon-inc May 20, 2025
2c4c5d2
Basic macro structure seems to be in place, mutability is missing
lima-limon-inc May 20, 2025
7402678
Checkpoint: Fideos trait in place. Better alternative?
lima-limon-inc May 20, 2025
557f75f
Create Custom field mandioca for pareny symbol table
lima-limon-inc May 20, 2025
a7315bd
De-comment call to insert map
lima-limon-inc May 20, 2025
db07c41
Checkpoint: It compiles but it's missing a casting implementation
lima-limon-inc May 21, 2025
b7816a8
Try doing an unsafe cast
lima-limon-inc May 21, 2025
bf2b41b
Comment out dbg!
lima-limon-inc May 21, 2025
0e0dc1e
Add lifetime parameters to variable
lima-limon-inc May 21, 2025
80bd170
Create a lifetime + remove call to get_symbol_manager_mut
lima-limon-inc May 21, 2025
fcb87a8
Revert "Create a lifetime + remove call to get_symbol_manager_mut"
lima-limon-inc May 21, 2025
a309e25
Revert "Add lifetime parameters to variable"
lima-limon-inc May 21, 2025
422adfe
Add comment with explanation
lima-limon-inc May 21, 2025
1b5b7f1
Add new comment explaining fix
lima-limon-inc May 21, 2025
202a8b8
Add assert code in auto-generated after adding an item to the symbol …
lima-limon-inc May 22, 2025
ea15723
Remove unused OperationFieldType since now belonging to a symbol tabl…
lima-limon-inc May 22, 2025
c0343dc
WIP: Rename variables and remove deleted code
lima-limon-inc May 22, 2025
7a395a5
Remove un-usued struct decorator, since now a trait is used.
lima-limon-inc May 22, 2025
9d7e716
Added Option to the SymbolTableRef
lima-limon-inc May 22, 2025
68b4023
Added Fideos trait to Function, all test passing
lima-limon-inc May 22, 2025
86a97da
Added Fideos trait to module
lima-limon-inc May 22, 2025
788fec6
Add Fideos trait to global trait
lima-limon-inc May 22, 2025
9bdb574
Make assert string generic
lima-limon-inc May 22, 2025
7137690
Remove dbg prints
lima-limon-inc May 22, 2025
d1b3e4d
Remove commented out code
lima-limon-inc May 22, 2025
3699b3d
Remove the decorator parsing
lima-limon-inc May 22, 2025
2ee35bf
Rename parent_jamon to belongs_in_symbol_table and change it to a boo…
lima-limon-inc May 22, 2025
e7dd21b
Add some documentation regarding the belong_in_symbol_table member
lima-limon-inc May 22, 2025
1c4a29c
Rename trait to BelongsInSymbolTable
lima-limon-inc May 22, 2025
76940fa
Add documentation regarding the proc macro
lima-limon-inc May 22, 2025
4d9b8b0
Rename to OpCreateParamType::Mandioca to OpCreateParamType::BuildOnly…
lima-limon-inc May 22, 2025
5cdf314
Remove old asserts, now in macro
lima-limon-inc May 22, 2025
16026fe
Remove match in favor of if true
lima-limon-inc May 22, 2025
bbbad14
Decouple the current BuildOp into BuildOP + ModifyOp + ReturnOp
lima-limon-inc May 22, 2025
d2a0dc5
Remove unused code/structs and re-enable -Wwarning
lima-limon-inc May 22, 2025
2dd21ec
Rename tmp to symbol_table
lima-limon-inc May 22, 2025
6cad13c
Merge branch 'next' into fabrizioorsi/op-builder-symbol-table
lima-limon-inc May 23, 2025
a390f2e
Remove unused function
lima-limon-inc May 23, 2025
2ce7040
fix: replace in place str with call to stringify!
lima-limon-inc May 23, 2025
c074344
Remove Option from parent symbol table type
lima-limon-inc May 23, 2025
0573c5a
WIP: SymbolTableHolder
lima-limon-inc May 26, 2025
80ac362
WIP: Gotem?
lima-limon-inc May 26, 2025
4f1bd7c
cfg_to_scf test
lima-limon-inc May 26, 2025
40e55ec
WIP: Fix tests
lima-limon-inc May 26, 2025
892f20f
WIP: Fix tests
lima-limon-inc May 26, 2025
3b7a751
WIP: Fix test
lima-limon-inc May 26, 2025
1eaa233
WIP: Fix tests
lima-limon-inc May 26, 2025
e7bff1d
WIP: fix tests
lima-limon-inc May 26, 2025
7fef782
WIP: Fix tests
lima-limon-inc May 26, 2025
7d93ff6
WIP: Fix tests
lima-limon-inc May 26, 2025
1543549
WIP: Fix tests
lima-limon-inc May 26, 2025
af36091
WIP: Fix tests
lima-limon-inc May 26, 2025
7c38701
chore: update OperationBuilder documentation now that an Option is no…
lima-limon-inc May 26, 2025
619d838
Remove Option parse_quote now that A symbol table reference is always…
lima-limon-inc May 26, 2025
c918d40
chore: Remove commented out code
lima-limon-inc May 26, 2025
1883c0f
Replace inline str "SymbolTableRef" with call to stringify! and the t…
lima-limon-inc May 26, 2025
21eab6e
WIP: Change World in favor of SymbolTableHolder in tests
lima-limon-inc May 26, 2025
5c13e5d
WIP: Change World in favor of SymbolTableHolder
lima-limon-inc May 26, 2025
edf7a65
WIP: Replace World in favor of SymbolTableHolder
lima-limon-inc May 26, 2025
bdefabe
WIP: Replace World in favor of SymbolTableHolder
lima-limon-inc May 26, 2025
7f1ffa4
Remove SymbolTableHolderl from constants file
lima-limon-inc May 26, 2025
1df638b
De-comment #[deny(warning)]s
lima-limon-inc May 27, 2025
64358ec
Remove unused traits from SymbolTableHolder struct
lima-limon-inc May 27, 2025
e224ec1
De-comment #[deny(warning)]s
lima-limon-inc May 27, 2025
72dd12c
Revert "WIP: Replace World in favor of SymbolTableHolder"
lima-limon-inc May 27, 2025
8340482
Revert "WIP: Replace World in favor of SymbolTableHolder"
lima-limon-inc May 27, 2025
f69e539
Revert "WIP: Change World in favor of SymbolTableHolder"
lima-limon-inc May 27, 2025
8290c78
Revert "WIP: Change World in favor of SymbolTableHolder in tests"
lima-limon-inc May 27, 2025
50e8faa
Remove calls to SymbolTableHolder
lima-limon-inc May 27, 2025
8f650da
Update as_symbol_table_ref documentation
lima-limon-inc May 27, 2025
9bca3c3
Merge branch 'next' into fabrizioorsi/op-builder-symbol-table
lima-limon-inc May 28, 2025
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
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
public builtin.function @test(v0: u32, v1: u32) -> u32 {
^block0(v0: u32, v1: u32):
^block1(v0: u32, v1: u32):
v2 = scf.index_switch v0 : u32
case 0 {
^block1:
^block2:
v3 = arith.constant 0 : u32;
scf.yield v3;
}
default {
^block2:
^block3:
v4 = arith.mul v0, v1 : u32 #[overflow = checked];
scf.yield v4;
Comment on lines 1 to 12
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests got updated because now they contain a WorldBuilder which wasn't there before. The only thing that (should)'ve changed is the block number (which increased by one).

};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
public builtin.function @test(v0: u32, v1: u32) -> u32 {
^block0(v0: u32, v1: u32):
^block1(v0: u32, v1: u32):
v2 = scf.index_switch v0 : u32
case 0 {
^block1:
^block2:
v3 = arith.constant 0 : u32;
scf.yield v3;
}
case 1 {
^block2:
^block3:
v4 = arith.constant 1 : u32;
scf.yield v4;
}
default {
^block3:
^block4:
v5 = arith.mul v0, v1 : u32 #[overflow = checked];
scf.yield v5;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
public builtin.function @test(v0: u32, v1: u32) -> u32 {
^block0(v0: u32, v1: u32):
^block1(v0: u32, v1: u32):
v2 = scf.index_switch v0 : u32
case 0 {
^block1:
^block2:
v3 = arith.constant 0 : u32;
scf.yield v3;
}
case 1 {
^block2:
^block3:
v4 = arith.constant 1 : u32;
scf.yield v4;
}
case 2 {
^block3:
^block4:
v5 = arith.constant 2 : u32;
scf.yield v5;
}
default {
^block4:
^block5:
v6 = arith.mul v0, v1 : u32 #[overflow = checked];
scf.yield v6;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
public builtin.function @test(v0: u32, v1: u32) -> u32 {
^block0(v0: u32, v1: u32):
^block1(v0: u32, v1: u32):
v2 = scf.index_switch v0 : u32
case 0 {
^block1:
^block2:
v3 = arith.constant 0 : u32;
scf.yield v3;
}
case 1 {
^block2:
^block3:
v4 = arith.constant 1 : u32;
scf.yield v4;
}
case 2 {
^block3:
^block4:
v5 = arith.constant 2 : u32;
scf.yield v5;
}
case 3 {
^block4:
^block5:
v6 = arith.constant 3 : u32;
scf.yield v6;
}
default {
^block5:
^block6:
v7 = arith.mul v0, v1 : u32 #[overflow = checked];
scf.yield v7;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
public builtin.function @test(v0: u32, v1: u32) -> u32 {
^block0(v0: u32, v1: u32):
^block1(v0: u32, v1: u32):
v2 = scf.index_switch v0 : u32
case 0 {
^block1:
^block2:
v3 = arith.constant 0 : u32;
scf.yield v3;
}
case 1 {
^block2:
^block3:
v4 = arith.constant 1 : u32;
scf.yield v4;
}
case 2 {
^block3:
^block4:
v5 = arith.constant 2 : u32;
scf.yield v5;
}
case 3 {
^block4:
^block5:
v6 = arith.constant 3 : u32;
scf.yield v6;
}
case 4 {
^block5:
^block6:
v7 = arith.constant 4 : u32;
scf.yield v7;
}
default {
^block6:
^block7:
v8 = arith.mul v0, v1 : u32 #[overflow = checked];
scf.yield v8;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
public builtin.function @test(v0: u32, v1: u32) -> u32 {
^block0(v0: u32, v1: u32):
^block1(v0: u32, v1: u32):
v2 = scf.index_switch v0 : u32
case 0 {
^block1:
^block2:
v3 = arith.constant 0 : u32;
scf.yield v3;
}
case 1 {
^block2:
^block3:
v4 = arith.constant 1 : u32;
scf.yield v4;
}
case 2 {
^block3:
^block4:
v5 = arith.constant 2 : u32;
scf.yield v5;
}
case 3 {
^block4:
^block5:
v6 = arith.constant 3 : u32;
scf.yield v6;
}
case 4 {
^block5:
^block6:
v7 = arith.constant 4 : u32;
scf.yield v7;
}
case 5 {
^block6:
^block7:
v8 = arith.constant 5 : u32;
scf.yield v8;
}
case 6 {
^block7:
^block8:
v9 = arith.constant 6 : u32;
scf.yield v9;
}
default {
^block8:
^block9:
v10 = arith.mul v0, v1 : u32 #[overflow = checked];
scf.yield v10;
};
Expand Down
6 changes: 3 additions & 3 deletions codegen/masm/src/lower/expected/utils_emit_if.hir
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
public builtin.function @test(v0: u32, v1: u32) -> u32 {
^block0(v0: u32, v1: u32):
^block1(v0: u32, v1: u32):
v2 = arith.constant 0 : u32;
v3 = arith.eq v0, v1 : i1;
v4 = scf.if v3 : u32 {
^block1:
^block2:
v5 = arith.constant 1 : u32;
scf.yield v5;
} else {
^block2:
^block3:
v6 = arith.mul v0, v2 : u32 #[overflow = checked];
scf.yield v6;
};
Expand Down
10 changes: 5 additions & 5 deletions codegen/masm/src/lower/expected/utils_emit_if_nested.hir
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
public builtin.function @test(v0: u32, v1: u32) -> u32 {
^block0(v0: u32, v1: u32):
^block1(v0: u32, v1: u32):
v2 = arith.eq v0, v1 : i1;
v3 = scf.if v2 : u32 {
^block1:
^block2:
v4 = arith.constant 1 : u32;
scf.yield v4;
} else {
^block2:
^block3:
v5 = arith.lt v0, v1 : i1;
v6 = scf.if v5 : u32 {
^block3:
^block4:
v7 = arith.constant 2 : u32;
scf.yield v7;
} else {
^block4:
^block5:
v8 = arith.mul v0, v1 : u32 #[overflow = checked];
scf.yield v8;
};
Expand Down
22 changes: 20 additions & 2 deletions codegen/masm/src/lower/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -493,11 +493,11 @@ mod tests {
use midenc_dialect_scf::StructuredControlFlowOpBuilder;
use midenc_expect_test::expect_file;
use midenc_hir::{
dialects::builtin::{self, BuiltinOpBuilder, FunctionBuilder, FunctionRef},
dialects::builtin::{self, BuiltinOpBuilder, FunctionBuilder, FunctionRef, WorldBuilder},
formatter::PrettyPrint,
pass::AnalysisManager,
version::Version,
AbiParam, Context, Ident, OpBuilder, Signature, Type,
AbiParam, BuilderExt, Context, Ident, OpBuilder, Signature, SymbolTable, Type,
};
use midenc_hir_analysis::analyses::LivenessAnalysis;

Expand All @@ -511,12 +511,18 @@ mod tests {

let mut builder = OpBuilder::new(context.clone());

let world_ref = builder.create::<builtin::World, ()>(Default::default())()
.expect("Error unrelated to test: Failed to build world.");
let mut world_builder = WorldBuilder::new(world_ref);
let world = &mut world_builder.world.borrow_mut().as_symbol_table_ref();

let function_ref = builder.create_function(
Ident::with_empty_span("test".into()),
Signature::new(
[AbiParam::new(Type::U32), AbiParam::new(Type::U32)],
[AbiParam::new(Type::U32)],
),
world,
)?;

let (a, b) = {
Expand Down Expand Up @@ -597,12 +603,18 @@ mod tests {

let mut builder = OpBuilder::new(context.clone());

let world_ref = builder.create::<builtin::World, ()>(Default::default())()
.expect("Error unrelated to test: Failed to build world.");
let mut world_builder = WorldBuilder::new(world_ref);
let world = &mut world_builder.world.borrow_mut().as_symbol_table_ref();

let function_ref = builder.create_function(
Ident::with_empty_span("test".into()),
Signature::new(
[AbiParam::new(Type::U32), AbiParam::new(Type::U32)],
[AbiParam::new(Type::U32)],
),
world,
)?;

let (a, b) = {
Expand Down Expand Up @@ -826,12 +838,18 @@ mod tests {
) -> Result<(FunctionRef, masm::Block), Report> {
let mut builder = OpBuilder::new(context.clone());

let world_ref = builder.create::<builtin::World, ()>(Default::default())()
.expect("Error unrelated to test: Failed to build world.");
let mut world_builder = WorldBuilder::new(world_ref);
let world = &mut world_builder.world.borrow_mut().as_symbol_table_ref();

let function_ref = builder.create_function(
Ident::with_empty_span("test".into()),
Signature::new(
[AbiParam::new(Type::U32), AbiParam::new(Type::U32)],
[AbiParam::new(Type::U32)],
),
world,
)?;

let (a, b) = {
Expand Down
Loading