melior/ir/operation/
printing_flags.rs1use mlir_sys::{
2 mlirOpPrintingFlagsCreate, mlirOpPrintingFlagsDestroy,
3 mlirOpPrintingFlagsElideLargeElementsAttrs, mlirOpPrintingFlagsEnableDebugInfo,
4 mlirOpPrintingFlagsPrintGenericOpForm, mlirOpPrintingFlagsUseLocalScope, MlirOpPrintingFlags,
5};
6
7#[derive(Debug)]
9pub struct OperationPrintingFlags(MlirOpPrintingFlags);
10
11impl OperationPrintingFlags {
12 pub fn new() -> Self {
14 Self(unsafe { mlirOpPrintingFlagsCreate() })
15 }
16
17 pub fn elide_large_elements_attributes(self, limit: usize) -> Self {
19 unsafe { mlirOpPrintingFlagsElideLargeElementsAttrs(self.0, limit as isize) }
20
21 self
22 }
23
24 pub fn enable_debug_info(self, enabled: bool, pretty_form: bool) -> Self {
26 unsafe { mlirOpPrintingFlagsEnableDebugInfo(self.0, enabled, pretty_form) }
27
28 self
29 }
30
31 pub fn print_generic_operation_form(self) -> Self {
33 unsafe { mlirOpPrintingFlagsPrintGenericOpForm(self.0) }
34
35 self
36 }
37
38 pub fn use_local_scope(self) -> Self {
40 unsafe { mlirOpPrintingFlagsUseLocalScope(self.0) }
41
42 self
43 }
44
45 pub const fn to_raw(&self) -> MlirOpPrintingFlags {
47 self.0
48 }
49}
50
51impl Drop for OperationPrintingFlags {
52 fn drop(&mut self) {
53 unsafe { mlirOpPrintingFlagsDestroy(self.0) }
54 }
55}
56
57impl Default for OperationPrintingFlags {
58 fn default() -> Self {
59 Self::new()
60 }
61}