Skip to content

Commit

Permalink
Update capi.ex
Browse files Browse the repository at this point in the history
  • Loading branch information
jackalcooper committed Dec 20, 2024
1 parent 29b03e3 commit edcdc31
Showing 1 changed file with 9 additions and 33 deletions.
42 changes: 9 additions & 33 deletions lib/beaver/mlir/capi.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ defmodule Beaver.MLIR.CAPI do
- `mlirPassManagerRunOnOp`: the MLIR pass implemented in Elixir.
- `mlirOperationVerify`, `mlirAttributeParseGet`, `mlirTypeParseGet`, `mlirModuleCreateParse`: the diagnostic handler implemented in Elixir.
"""
@nifs use Kinda.CodeGen,
with: Beaver.MLIR.CAPI.CodeGen,
root: __MODULE__,
forward: Beaver.Native
use Kinda.CodeGen,
with: Beaver.MLIR.CAPI.CodeGen,
root: __MODULE__,
forward: Beaver.Native

@on_load :load_nif

Expand Down Expand Up @@ -56,8 +56,7 @@ defmodule Beaver.MLIR.CAPI do
def beaver_raw_registered_ops(_ctx), do: :erlang.nif_error(:not_loaded)
def beaver_raw_registered_dialects(_ctx), do: :erlang.nif_error(:not_loaded)

@nifs @nifs ++
(for f <- ~w{
for f <- ~w{
StringRef
Attribute
Type
Expand All @@ -72,10 +71,10 @@ defmodule Beaver.MLIR.CAPI do
Identifier
Diagnostic
} do
f = :"beaver_raw_to_string_#{f}"
def unquote(f)(_), do: :erlang.nif_error(:not_loaded)
{f, 1}
end)
f = :"beaver_raw_to_string_#{f}"
def unquote(f)(_), do: :erlang.nif_error(:not_loaded)
{f, 1}
end

def beaver_raw_get_string_ref(_), do: :erlang.nif_error(:not_loaded)
def beaver_raw_read_opaque_ptr(_, _), do: :erlang.nif_error(:not_loaded)
Expand All @@ -96,27 +95,4 @@ defmodule Beaver.MLIR.CAPI do
def beaver_raw_mlir_type_of_enif_obj(_ctx, _obj), do: :erlang.nif_error(:not_loaded)
def beaver_raw_string_printer_callback(), do: :erlang.nif_error(:not_loaded)
def beaver_raw_string_printer_flush(_sp), do: :erlang.nif_error(:not_loaded)

@nifs @nifs ++
[
beaver_raw_create_mlir_pass: 5,
beaver_raw_logical_mutex_token_signal_success: 1,
beaver_raw_logical_mutex_token_signal_failure: 1,
beaver_raw_registered_ops: 1,
beaver_raw_registered_dialects: 1,
beaver_raw_get_string_ref: 1,
beaver_raw_read_opaque_ptr: 2,
beaver_raw_deallocate_opaque_ptr: 1,
beaver_raw_get_null_ptr: 0,
beaver_raw_context_attach_diagnostic_handler: 2,
beaver_raw_jit_invoke_with_terms: 3,
beaver_raw_jit_invoke_with_terms_cpu_bound: 3,
beaver_raw_jit_invoke_with_terms_io_bound: 3,
beaver_raw_jit_register_enif: 1,
beaver_raw_enif_signatures: 1,
beaver_raw_enif_functions: 0,
beaver_raw_mlir_type_of_enif_obj: 2,
beaver_raw_string_printer_callback: 0,
beaver_raw_string_printer_flush: 1
]
end

0 comments on commit edcdc31

Please sign in to comment.