Last active
September 22, 2023 14:20
-
-
Save jackalcooper/ffdd0cb06842fdfec582bc9c7904cddc to your computer and use it in GitHub Desktop.
first class dialect definition support in beaver
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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())) | |
results(any()) | |
end | |
defop mul do | |
c = complex(any_of([Type.f32(), Type.f64()])) | |
operands([c, c]) | |
results(c) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module { | |
irdl.dialect @cmath { | |
irdl.type @complex { | |
%0 = irdl.is f32 | |
%1 = irdl.is f64 | |
%2 = irdl.any_of(%0, %1) | |
irdl.parameters(%2) | |
} | |
irdl.operation @norm { | |
%0 = irdl.any | |
%1 = irdl.parametric @complex<%0> | |
irdl.operands(%1) | |
irdl.results(%0) | |
} | |
irdl.operation @mul { | |
%0 = irdl.is f32 | |
%1 = irdl.is f64 | |
%2 = irdl.any_of(%0, %1) | |
%3 = irdl.parametric @complex<%2> | |
irdl.operands(%3, %3) | |
irdl.results(%3) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment