Printf to llvm
printf_to_llvm
¶
i8 = builtin.IntegerType(8)
module-attribute
¶
PrintlnOpToPrintfCall
¶
Bases: RewritePattern
Source code in xdsl/transforms/printf_to_llvm.py
collected_global_symbs: dict[str, llvm.GlobalOp] = dict()
instance-attribute
¶
__init__()
¶
match_and_rewrite(op: printf.PrintFormatOp, rewriter: PatternRewriter)
¶
Source code in xdsl/transforms/printf_to_llvm.py
PrintfToLLVM
dataclass
¶
Bases: ModulePass
Source code in xdsl/transforms/printf_to_llvm.py
name = 'printf-to-llvm'
class-attribute
instance-attribute
¶
apply(ctx: Context, op: builtin.ModuleOp) -> None
¶
Source code in xdsl/transforms/printf_to_llvm.py
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!