#![allow(dead_code, unused_imports)]
pub mod analyzer;
pub mod int_set;
pub mod iter_affine_map;
pub use analyzer::*;
pub use int_set::*;
pub use iter_affine_map::*;
use crate::ir::expr::Expr;
use crate::ir::expr::Range;
use crate::ir::expr::Var;
use std::ops::Deref;
use std::ptr::addr_of_mut;
use tvm_ffi::Object;
use tvm_ffi::ObjectArc;
use tvm_ffi::ShallowCopy;
use tvm_ffi::UnsafeInit;
#[repr(C)]
#[derive(tvm_ffi::derive::Object)]
#[type_key = "sym.Constraint"]
pub struct ConstraintObj {
base: Object,
}
const _: () = {
assert!(::core::mem::size_of::<ConstraintObj>() == 24);
assert!(::core::mem::align_of::<ConstraintObj>() == 8);
};
#[repr(C)]
#[derive(tvm_ffi::derive::ObjectRef, Clone)]
pub struct Constraint {
base: ObjectArc<ConstraintObj>,
}
impl Deref for Constraint {
type Target = ConstraintObj;
fn deref(&self) -> &ConstraintObj {
&self.base
}
}
impl ConstraintObj {
pub fn new() -> Self {
let base = Object::new();
Self { base }
}
}
impl Constraint {
pub fn new() -> Self {
let obj = ConstraintObj::new();
Self { base: ObjectArc::new(obj) }
}
}
impl ShallowCopy for ConstraintObj {
fn shallow_copy(&self) -> Self {
Self { base: ShallowCopy::shallow_copy(&self.base) }
}
}
unsafe impl UnsafeInit for ConstraintObj {
unsafe fn drop_defined_fields(this: *mut Self) {
unsafe {
UnsafeInit::drop_defined_fields(addr_of_mut!((*this).base));
}
}
}
#[repr(C)]
#[derive(tvm_ffi::derive::Object)]
#[type_key = "sym.BindingConstraint"]
#[type_final]
pub struct BindingConstraintObj {
base: ConstraintObj,
pub var: Var,
pub value: Expr,
}
const _: () = {
assert!(::core::mem::size_of::<BindingConstraintObj>() == 40);
assert!(::core::mem::align_of::<BindingConstraintObj>() == 8);
};
#[repr(C)]
#[derive(tvm_ffi::derive::ObjectRef, Clone)]
pub struct BindingConstraint {
base: ObjectArc<BindingConstraintObj>,
}
impl Deref for BindingConstraint {
type Target = BindingConstraintObj;
fn deref(&self) -> &BindingConstraintObj {
&self.base
}
}
impl Deref for BindingConstraintObj {
type Target = ConstraintObj;
fn deref(&self) -> &ConstraintObj {
&self.base
}
}
impl BindingConstraintObj {
pub(crate) fn new(var: Var, value: Expr) -> Self {
let base = ConstraintObj::new();
Self { base, var, value }
}
}
impl BindingConstraint {
pub fn new(var: impl Into<Var>, value: impl Into<Expr>) -> Self {
let obj = BindingConstraintObj::new(var.into(), value.into());
Self { base: ObjectArc::new(obj) }
}
}
tvm_ffi::impl_object_upcast!(BindingConstraint => Constraint);
#[repr(C)]
#[derive(tvm_ffi::derive::Object)]
#[type_key = "sym.ConstraintContext"]
#[type_final]
pub struct ConstraintContextObj {
base: Object,
}
#[repr(C)]
#[derive(tvm_ffi::derive::ObjectRef, Clone)]
pub struct ConstraintContext {
base: ObjectArc<ConstraintContextObj>,
}
impl Deref for ConstraintContext {
type Target = ConstraintContextObj;
fn deref(&self) -> &ConstraintContextObj {
&self.base
}
}
#[repr(C)]
#[derive(tvm_ffi::derive::Object)]
#[type_key = "sym.PredicateConstraint"]
#[type_final]
pub struct PredicateConstraintObj {
base: ConstraintObj,
pub condition: Expr,
pub assume_always: bool,
}
const _: () = {
assert!(::core::mem::size_of::<PredicateConstraintObj>() == 40);
assert!(::core::mem::align_of::<PredicateConstraintObj>() == 8);
};
#[repr(C)]
#[derive(tvm_ffi::derive::ObjectRef, Clone)]
pub struct PredicateConstraint {
base: ObjectArc<PredicateConstraintObj>,
}
impl Deref for PredicateConstraint {
type Target = PredicateConstraintObj;
fn deref(&self) -> &PredicateConstraintObj {
&self.base
}
}
impl Deref for PredicateConstraintObj {
type Target = ConstraintObj;
fn deref(&self) -> &ConstraintObj {
&self.base
}
}
impl PredicateConstraintObj {
pub(crate) fn new(condition: Expr, assume_always: bool) -> Self {
let base = ConstraintObj::new();
Self { base, condition, assume_always }
}
}
impl PredicateConstraint {
pub fn new(condition: impl Into<Expr>, assume_always: bool) -> Self {
let obj = PredicateConstraintObj::new(condition.into(), assume_always);
Self { base: ObjectArc::new(obj) }
}
}
tvm_ffi::impl_object_upcast!(PredicateConstraint => Constraint);
#[repr(C)]
#[derive(tvm_ffi::derive::Object)]
#[type_key = "sym.RangeConstraint"]
#[type_final]
pub struct RangeConstraintObj {
base: ConstraintObj,
pub var: Var,
pub range: Range,
}
const _: () = {
assert!(::core::mem::size_of::<RangeConstraintObj>() == 40);
assert!(::core::mem::align_of::<RangeConstraintObj>() == 8);
};
#[repr(C)]
#[derive(tvm_ffi::derive::ObjectRef, Clone)]
pub struct RangeConstraint {
base: ObjectArc<RangeConstraintObj>,
}
impl Deref for RangeConstraint {
type Target = RangeConstraintObj;
fn deref(&self) -> &RangeConstraintObj {
&self.base
}
}
impl Deref for RangeConstraintObj {
type Target = ConstraintObj;
fn deref(&self) -> &ConstraintObj {
&self.base
}
}
impl RangeConstraintObj {
pub(crate) fn new(var: Var, range: Range) -> Self {
let base = ConstraintObj::new();
Self { base, var, range }
}
}
impl RangeConstraint {
pub fn new(var: impl Into<Var>, range: impl Into<Range>) -> Self {
let obj = RangeConstraintObj::new(var.into(), range.into());
Self { base: ObjectArc::new(obj) }
}
}
tvm_ffi::impl_object_upcast!(RangeConstraint => Constraint);