def printf(builder, format, *args):
 assert isinstance(format, str)
 mod = builder.module
 cstring = voidptr_t
 fmt_bytes = make_bytearray((format + '\x00').encode('ascii'))
 global_fmt = global_constant(mod, 'printf_format', fmt_bytes)
 fnty = ir.FunctionType(int32_t, [cstring], var_arg=True)
 fn = mod.get_global('printf')
 if (fn is None):
  fn = ir.Function(mod, fnty, name='printf')
 ptr_fmt = builder.bitcast(global_fmt, cstring)
 return builder.call(fn, ([ptr_fmt] + list(args)))

def printf ( builder , format , * args ) : assert isinstance ( format , str ) mod = builder . module cstring = voidptr_t fmt_bytes = make_bytearray ( ( format + '\x00' ) . encode ( 'ascii' ) ) global_fmt = global_constant ( mod , 'printf_format' , fmt_bytes ) fnty = ir . FunctionType ( int32_t , [ cstring ] , var_arg = True ) fn = mod . get_global ( 'printf' ) if ( fn is None ) : fn = ir . Function ( mod , fnty , name = 'printf' ) ptr_fmt = builder . bitcast ( global_fmt , cstring ) return builder . call ( fn , ( [ ptr_fmt ] + list ( args ) ) )
calls printf() .