Skip to content

Commit

Permalink
feat(irdl): added some ops for check_sig.mlir
Browse files Browse the repository at this point in the history
  • Loading branch information
woxjro committed Oct 7, 2024
1 parent 7f59951 commit 9ccf17e
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
20 changes: 20 additions & 0 deletions examples/mlir/check_sig.mlir
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module {
func.func @smart_contract(%parameter: !michelson.key, %storage: !michelson.pair<!michelson.signature, !michelson.string>)
-> !michelson.pair<!michelson.list<!michelson.operation>, !michelson.pair<!michelson.signature, !michelson.string>> {

%signature = "michelson.get_fst"(%storage) : (!michelson.pair<!michelson.signature, !michelson.string>) -> !michelson.signature
%string = "michelson.get_snd"(%storage) : (!michelson.pair<!michelson.signature, !michelson.string>) -> !michelson.string
%bytes = "michelson.pack"(%string) : (!michelson.string) -> !michelson.bytes

%result = "michelson.check_signature"(%parameter, %signature, %bytes) : (!michelson.key, !michelson.signature, !michelson.bytes) -> !michelson.bool

"michelson.assert"(%result) : (!michelson.bool) -> ()

%nil = "michelson.make_list"() : () -> !michelson.list<!michelson.operation>
%pair = "michelson.make_pair"(%nil, %storage) :
(!michelson.list<!michelson.operation> , !michelson.pair<!michelson.signature, !michelson.string>)
-> !michelson.pair<!michelson.list<!michelson.operation>, !michelson.pair<!michelson.signature, !michelson.string>>

return %pair: !michelson.pair<!michelson.list<!michelson.operation>, !michelson.pair<!michelson.signature, !michelson.string>>
}
}
31 changes: 31 additions & 0 deletions mlir/dialect/irdl/michelson.irdl.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,30 @@ module {
irdl.results(%res)
}

irdl.operation @pack {
%arg = irdl.any
%res = irdl.any
irdl.operands(%arg)
irdl.results(%res)
}

irdl.operation @get_fst {
%fst = irdl.any
%snd = irdl.any
%pair = irdl.parametric @pair<%fst, %snd>

irdl.operands(%pair)
irdl.results(%fst)
}

irdl.operation @get_snd {
%pair = irdl.any
%snd = irdl.any

irdl.operands(%pair)
irdl.results(%snd)
}

irdl.operation @make_list {
%res = irdl.any

Expand Down Expand Up @@ -162,5 +186,12 @@ module {
irdl.operands(%op)
irdl.results(%inner)
}

irdl.operation @assert {
%bool = irdl.any

irdl.operands(%bool)
irdl.results()
}
}
}

0 comments on commit 9ccf17e

Please sign in to comment.