mlir/
interfaces.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// Copyright 2024-2025, Giordano Salvador
// SPDX-License-Identifier: BSD-3-Clause

#![allow(dead_code)]

use std::fmt;

#[derive(Clone, Copy, PartialEq)]
pub enum Interface {
    AffineMapAccessInterface,
    AffineReadOpInterface,
    AffineWriteOpInterface,
    ArithFastMathInterface,
    ArithIntegerOverflowFlagsInterface,
    ArithRoundingModeInterface,
    BranchOpInterface,
    CallOpInterface,
    CallableOpInterface,
    CastOpInterface,
    ConditionallySpeculatable,
    CopyOpInterface,
    DestinationStyleOpInterface,
    DestructurableAllocationOpInterface,
    FunctionOpInterface,
    InferIntRangeInterface,
    InferTypeOpInterface,
    LinalgContractionOpInterface,
    LinalgStructuredInterface,
    LoopLikeOpInterface,
    MaskableOpInterface,
    MemoryEffect(MemoryEffectOpInterface),
    OffsetSizeAndStrideOpInterface,
    OpAsmOpInterface,
    ParallelCombiningOpInterface,
    PromotableAllocationOpInterface,
    RegionBranchOpInterface,
    RegionBranchTerminatorOpInterface,
    RegionKindInterface,
    ReifyRankedShapeTypeOpInterface,
    SelectLikeOpInterface,
    ShapedDimOpInterface,
    Symbol,
    SymbolUserOpInterface,
    VectorTransferOpInterface,
    VectorUnrollOpInterface,
    ViewLikeOpInterface,
}

#[derive(Clone, Copy, PartialEq)]
pub enum MemoryEffectOpInterface {
    NoMemoryEffect,
    MemoryEffect,
    RecursiveMemoryEffects,
    UndefinedMemoryEffect,
}

impl fmt::Display for Interface {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "{}", match self {
            Interface::AffineMapAccessInterface => "affine_map_access_interface".to_string(),
            Interface::AffineReadOpInterface => "affine_read_op_interface".to_string(),
            Interface::AffineWriteOpInterface => "affine_write_op_interface".to_string(),
            Interface::ArithFastMathInterface => "arith_fast_math_interface".to_string(),
            Interface::ArithIntegerOverflowFlagsInterface => {
                "arith_integer_overflow_flags_interface".to_string()
            }
            Interface::ArithRoundingModeInterface => "arith_rounding_mode_interface".to_string(),
            Interface::BranchOpInterface => "branch_op_interface".to_string(),
            Interface::CallOpInterface => "call_op_interface".to_string(),
            Interface::CallableOpInterface => "callable_op_interface".to_string(),
            Interface::CastOpInterface => "cast_op_interface".to_string(),
            Interface::ConditionallySpeculatable => "conditionally_speculatable".to_string(),
            Interface::CopyOpInterface => "copy_op_interface".to_string(),
            Interface::DestinationStyleOpInterface => "destination_style_op_interface".to_string(),
            Interface::DestructurableAllocationOpInterface => {
                "destructurable_allocation_op_interface".to_string()
            }
            Interface::FunctionOpInterface => "function_op_interface".to_string(),
            Interface::InferIntRangeInterface => "infer_int_range_interface".to_string(),
            Interface::InferTypeOpInterface => "infer_type_op_interface".to_string(),
            Interface::LinalgContractionOpInterface => {
                "linalg_contraction_op_interface".to_string()
            }
            Interface::LinalgStructuredInterface => "linalg_structured_interface".to_string(),
            Interface::LoopLikeOpInterface => "loop_like_op_interface".to_string(),
            Interface::MaskableOpInterface => "maskable_op_interface".to_string(),
            Interface::MemoryEffect(e) => format!("memory_effect_op_interface({})", e),
            Interface::OffsetSizeAndStrideOpInterface => {
                "offset_size_and_stride_op_interface".to_string()
            }
            Interface::OpAsmOpInterface => "op_asm_op_interface".to_string(),
            Interface::ParallelCombiningOpInterface => {
                "parallel_combining_op_interface".to_string()
            }
            Interface::PromotableAllocationOpInterface => {
                "promotable_allocation_op_interface".to_string()
            }
            Interface::RegionBranchOpInterface => "region_branch_op_interface".to_string(),
            Interface::RegionBranchTerminatorOpInterface => {
                "region_branch_terminator_op_interface".to_string()
            }
            Interface::RegionKindInterface => "region_kind_interface".to_string(),
            Interface::ReifyRankedShapeTypeOpInterface => {
                "reify_ranked_shape_type_op_interface".to_string()
            }
            Interface::SelectLikeOpInterface => "select_like_op_interface".to_string(),
            Interface::ShapedDimOpInterface => "shaped_dim_op_interface".to_string(),
            Interface::Symbol => "symbol".to_string(),
            Interface::SymbolUserOpInterface => "symbol_user_op_interface".to_string(),
            Interface::VectorTransferOpInterface => "vector_transfer_op_interface".to_string(),
            Interface::VectorUnrollOpInterface => "vector_unroll_op_interface".to_string(),
            Interface::ViewLikeOpInterface => "view_like_op_interface".to_string(),
        })
    }
}

impl fmt::Display for MemoryEffectOpInterface {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "{}", match self {
            MemoryEffectOpInterface::NoMemoryEffect => "no_memory_effect",
            MemoryEffectOpInterface::MemoryEffect => "memory_effect",
            MemoryEffectOpInterface::RecursiveMemoryEffects => "recursive_memory_effects",
            MemoryEffectOpInterface::UndefinedMemoryEffect => "undefined_memory_effect",
        })
    }
}