Skip to content

Commit

Permalink
minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
jackalcooper committed Dec 13, 2023
1 parent 78159b8 commit 622e5e8
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lib/beaver/slang.ex
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,15 @@ defmodule Beaver.Slang do
transform_arg(ast, i, :constrain)
end)

region_constrains =
if opts[:regions_block] do
quote do
unquote(opts[:regions_block])
|> List.wrap()
|> Enum.map(&Beaver.Slang.gen_region(&1, opts[:block], opts[:ctx]))
end
end

quote do
Module.put_attribute(__MODULE__, unquote(attr_name), unquote(name))
@__slang__creator__ {unquote(op), __MODULE__, unquote(creator)}
Expand All @@ -278,13 +287,7 @@ defmodule Beaver.Slang do

mlir block: opts[:block], ctx: opts[:ctx] do
unquote_splicing(input_constrains)

if unquote(opts[:regions_block]) do
unquote(opts[:regions_block])
|> List.wrap()
|> Enum.map(&Beaver.Slang.gen_region(&1, opts[:block], opts[:ctx]))
end

unquote(region_constrains)
{[unquote_splicing(args_var_ast)], unquote(do_block)}
end
end,
Expand Down

0 comments on commit 622e5e8

Please sign in to comment.