Charm Compiler Ideas #55
Replies: 0 comments 15 replies
-
Instead of building something that fully replaces the Erlang VM, I was thinking of an embedded language in Elixir that compiles to a NIF. The Mojo folks explain why they went with a separate language instead of an embedded DSL but I think Elixir will be both more powerful for embedding and the Erlang VM has a stronger and more isolated runtime to allow us to ship an embedded language. This also means the language can be a bit simpler (i.e. it doesn't have to worry about implementing concurrency). Think of it as Cython (but not really) but compiling to MLIR. The Koka programming languages also has interesting ideas which we could explore if we decide to keep a more functional nature. WDYT? |
Beta Was this translation helpful? Give feedback.
-
I think the macro-based approach could really work. I am refactoring Beaver DSL into a macro-based one, whose form is closer to vanilla elixir. So when we have the C DSL, it would become a purer Elixir-to-Elixir AST transform, instead of worrying about MLIR CAPI calls. The C DSL's compiler's main jobs become clearer:
defm some_func2() do
v0 = 0
cond0 = true
if cond0 do
v1 = 0
v1 + v1
else
v2 = 0
v0 + v2
end
end
Func.func some_func2(function_type: Type.function([], [Type.i(32)])) do
region do
block bb_entry() do
v0 = Arith.constant(value: Attribute.integer(Type.i(32), 0)) when is(v0, Type.i(32))
cond0 = Arith.constant(true) when is(cond0, Type.i(32))
cond_br(cond0) do
bb1()
else
bb2(v0)
end
end
block bb1() do
v1 = Arith.constant(value: Attribute.integer(Type.i(32), 0)) when is(v1, Type.i(32))
add = Arith.addi(v0, v0) when is(add, Type.i(1))
bb2(v1)
end
block bb2(arg) when is(arg, Type.i(32)) do
v2 = Arith.constant(value: Attribute.integer(Type.i(32), 0)) when is(v2, Type.i(32))
add = Arith.addi(arg, v2) when is(add, Type.i(32))
Func.return(add)
end
end
end |
Beta Was this translation helpful? Give feedback.
-
Following the expander POC snippet, refactor the prototype with Elixir 1.17's new functions in Some pleasant changes after the refactor:
change doesn't land: remove the
|
Beta Was this translation helpful? Give feedback.
-
Charm Compiler
The case for a Mojo for Elixir?
Compared to VM-based implementation of Erlang
New library or bindings could be enabled
Reference
Beta Was this translation helpful? Give feedback.
All reactions