Printf to llvm
printf_to_llvm
i8 = builtin.IntegerType(8)
module-attribute
PrintlnOpToPrintfCall
Bases: RewritePattern
Source code in xdsl/transforms/printf_to_llvm.py
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 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
collected_global_symbs: dict[str, llvm.GlobalOp] = dict()
instance-attribute
__init__()
Source code in xdsl/transforms/printf_to_llvm.py
89 90 | |
match_and_rewrite(op: printf.PrintFormatOp, rewriter: PatternRewriter)
Source code in xdsl/transforms/printf_to_llvm.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
PrintfToLLVM
dataclass
Bases: ModulePass
Source code in xdsl/transforms/printf_to_llvm.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
name = 'printf-to-llvm'
class-attribute
instance-attribute
apply(ctx: Context, op: builtin.ModuleOp) -> None
Source code in xdsl/transforms/printf_to_llvm.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
legalize_str_for_symbol_name(val: str)
Takes any string and legalizes it to be a global llvm symbol. (for the strictest possible interpretation of this)
- Replaces all whitespaces and dots with _
- Deletes all non ascii alphanumerical characters
- Strips all underscores from the start and end of the string
The resulting string consists only of ascii letters, underscores and digits.
This is a surjective mapping, meaning that multiple inputs will produce the same output. This function alone cannot be used to get a uniquely identifying global symbol name for a string!
Source code in xdsl/transforms/printf_to_llvm.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | |