Printf
printf
i8 = builtin.IntegerType(8)
module-attribute
Printf = Dialect('printf', [PrintFormatOp, PrintCharOp, PrintIntOp], [])
module-attribute
PrintFormatOp
Bases: IRDLOperation
A string formatting and printing utility.
Can be though of as a printf equivalent but with python style format strings.
Example uses:
%42 = arith.constant 42 : i32
printf.print_format "The magic number is {}
", %42
Source code in xdsl/dialects/printf.py
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 | |
name = 'printf.print_format'
class-attribute
instance-attribute
format_str = attr_def(builtin.StringAttr)
class-attribute
instance-attribute
format_vals = var_operand_def()
class-attribute
instance-attribute
__init__(format_str: str, *vals: SSAValue | Operation)
Source code in xdsl/dialects/printf.py
35 36 37 38 | |
verify_() -> None
Source code in xdsl/dialects/printf.py
40 41 42 43 44 45 | |
print(printer: Printer)
Source code in xdsl/dialects/printf.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
parse(parser: Parser) -> PrintFormatOp
classmethod
Source code in xdsl/dialects/printf.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |
PrintCharOp
Bases: IRDLOperation
Print a single character
Equivalent to putchar in C, but uses signless bytes as input (instead of ui32). Unlike the C implementation, this op does not return anything.
Source code in xdsl/dialects/printf.py
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 | |
name = 'printf.print_char'
class-attribute
instance-attribute
char = operand_def(i8)
class-attribute
instance-attribute
__init__(char: SSAValue | Operation)
Source code in xdsl/dialects/printf.py
102 103 104 105 | |
from_constant_char(char: str) -> PrintCharOp
staticmethod
This constructor returns a PrintCharOp that prints the value supplied in "char" as a python char.
Source code in xdsl/dialects/printf.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
PrintIntOp
Bases: IRDLOperation
Print a single Integer
Source code in xdsl/dialects/printf.py
124 125 126 127 128 129 130 131 132 133 134 135 136 | |
name = 'printf.print_int'
class-attribute
instance-attribute
int = operand_def(builtin.IntegerType)
class-attribute
instance-attribute
__init__(integer: SSAValue | Operation)
Source code in xdsl/dialects/printf.py
133 134 135 136 | |