Skip to main content

def_attribute

Attribute Macro def_attribute 

Source
#[def_attribute]
Expand description

#[def_attribute(...)]: Annotate a Rust struct as a new IR attribute.

Note: It is suggested to use the pliron_attr macro instead of using this macro directly. The documention here is useful though, because pliron_attr’s name field expands to this macro.

The argument to the macro is the fully qualified name of the attribute in the form of "dialect.attribute_name".

The macro will leave the struct definition unchanged, but it will generate an implementation of the pliron::Attribute trait and implements other internal traits and types resources required to use the IR attribute.

Note: pre-requisite traits for Attribute must already be implemented. Additionaly, Eq and Hash must be implemented by the type.

Usage:

use pliron::derive::{def_attribute, format_attribute, verify_succ};

#[verify_succ]
#[def_attribute("my_dialect.attribute")]
#[format_attribute]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct StringAttr(String);