Derive Macro orzir_macros::Op
source · #[derive(Op)]
{
// Attributes available to this derive:
#[mnemonic]
#[verifiers]
#[interfaces]
#[metadata]
}
Expand description
Implement an Op for the given struct.
This will first generate a new constructor for the struct, which returns
an ArenaPtr<OpObj> object.
The #[mnemonic = "..."] attribute is used to specify the mnemonic of the
operation. The mnemonic string will be split by the first dot character. The
first part will be used as the dialect mnemonic, and the second part will be
used as the operation mnemonic.
The #[interfaces(...)] and #[verifiers(...)] attributes are used to
implement/register the interfaces and verifiers for the operation.
By specifying the verifiers, the corresponding traits will be implemented
automatically. and the trait casters will be registered in the context when
calling Op::register. Also, the
VerifyInterfaces trait will be implemented
for the operation, by calling all the verify function in the verifier
traits.
The registering process of interfaces will also be generated by specifying
the interfaces attribute. However, they will not be implemented
automatically.
The verifiers can only be implemented when deriving the Op trait. But the
interfaces can be implemented in a plug-in manner. This can be done by
calling the register_caster macro in the register function of any
dialect.
To make a struct valid for the Op derive, the #[metadata] attribute must
be specified for the metadata field of the struct, which contains the
self_ptr and parent_block fields.
For an Op trait to be valid, the following traits must
be implemented:
They can be derived or implemented manually.