Skip to content

Instantly share code, notes, and snippets.

View jackalcooper's full-sized avatar

Shenghang Tsai jackalcooper

View GitHub Profile
defmodule Manx.Lowering do
alias Beaver.MLIR
import MLIR.Sigils
import MLIR.{Transforms, Conversion}
alias Beaver.MLIR.Dialect.GPU
def tosa_vulkan(op) do
op
|> MLIR.Operation.verify!(dump_if_fail: true)
|> canonicalize
defmodule Kinda.Parser do
import NimbleParsec
# *** Tokens ***
container_doc_comment =
string("//!") |> repeat(ascii_char([?^, ?\n])) |> repeat([?\s, ?\n]) |> times(min: 1)
doc_comment =
string("///") |> repeat(ascii_char([?^, ?\n])) |> repeat([?\s, ?\n]) |> times(min: 1)
defmodule Kinda.ParserHelper do
@moduledoc false
@doc """
define a parser combinator and variable with same name
"""
defmacro defcv(name, expr) do
quote do
defcombinatorp(unquote(name), unquote(expr))
Kernel.var!(unquote({name, [], nil})) = parsec(unquote(name))
_ = Kernel.var!(unquote({name, [], nil}))
@jackalcooper
jackalcooper / ex-comp.diff
Created June 7, 2023 03:33
add handler for passes after core
diff --git a/lib/elixir/src/elixir_erl_compiler.erl b/lib/elixir/src/elixir_erl_compiler.erl
index a299ab4c2d..98462f7148 100644
--- a/lib/elixir/src/elixir_erl_compiler.erl
+++ b/lib/elixir/src/elixir_erl_compiler.erl
@@ -50,7 +50,16 @@ compile(Forms, File, Opts) when is_list(Forms), is_list(Opts), is_binary(File) -
format_warnings(Opts, CoreWarnings),
CompileOpts = [no_spawn_compiler_process, from_core, no_core_prepare,
no_auto_import, return, {source, Source} | Opts],
-
+ case compile:noenv_forms(CoreForms, [dprecg|CompileOpts]) of
@jackalcooper
jackalcooper / 1.define_a_dialect.ex
Last active September 22, 2023 14:20
first class dialect definition support in beaver
defmodule Cmath do
alias Beaver.MLIR.Type
use Beaver.Dialect, name: "cmath"
deftype complex(t = any_of(t, [Type.f32(), Type.f64()])) do
parameters(t)
end
defop norm do
operands(complex(any()))