tvm_tirx

Macro def_expr_op_over_loads

Source
macro_rules! def_expr_op_over_loads {
    (crate::$($ty:ident)::+ $(,)?) => { ... };
    (self::$($ty:ident)::+ $(,)?) => { ... };
    (super::$($ty:ident)::+ $(,)?) => { ... };
    (::$($ty:ident)::+ $(,)?) => { ... };
    ($($ty:ident)::+ $(,)?) => { ... };
    (@impl $ty:ty) => { ... };
    (@binary $ty:ty; $($trait:ident::$method:ident),+ $(,)?) => { ... };
    (@literal $ty:ty, $trait:ident::$method:ident; $($literal:ty),+ $(,)?) => { ... };
    (@unary $ty:ty; $($trait:ident::$method:ident),+ $(,)?) => { ... };
}
Expand description

Add primitive-expression operators to an existing reference wrapper.

Pass a module-scope path to a type implementing Clone and Into<Expr>. Define its object layout, reference wrapper and ancestor upcasts separately, using tvm_ffi::def_object_ref! or generated bindings. For a deeper parent, also provide the upcast to Expr.

Owned operands move their handle; borrowed operands clone the handle. Operators return ExprResult, preserving contextual literal typing and the first construction error. Import PrimOps for named operations such as floordiv and less. Assignment operators apply only to ExprResult.

tvm_ffi::def_object_ref!(pub MyExpr, Expr, MyExprObj);
tvm_tirx::def_expr_op_over_loads!(MyExpr);