parameters: (tyctx, val, viewty)
return_statement: return sig, codegen
docstring: Bitcast a scalar 'val' to the given type 'viewty'.
docstring_summary: Bitcast a scalar 'val' to the given type 'viewty'.
docstring_tokens: Bitcast a scalar val to the given type viewty .
function: def viewer(tyctx, val, viewty):
      """ Bitcast a scalar 'val' to the given type 'viewty'. """
      bits = val.bitwidth
      if isinstance(viewty.dtype, types.Integer):
          bitcastty = ir.IntType(bits)
      elif isinstance(viewty.dtype, types.Float):
          bitcastty = ir.FloatType() if bits == 32 else ir.DoubleType()
      else:
          assert 0, "unreachable"
  
      def codegen(cgctx, builder, typ, args):
          flt = args[0]
          return builder.bitcast(flt, bitcastty)
      retty = viewty.dtype
      sig = retty(val, viewty)
      return sig, codegen
function_tokens: def viewer ( tyctx , val , viewty ) : bits = val . bitwidth if isinstance ( viewty . dtype , types . Integer ) : bitcastty = ir . IntType ( bits ) elif isinstance ( viewty . dtype , types . Float ) : bitcastty = ir . FloatType ( ) if bits == 32 else ir . DoubleType ( ) else : assert 0 , "unreachable" def codegen ( cgctx , builder , typ , args ) : flt = args [ 0 ] return builder . bitcast ( flt , bitcastty ) retty = viewty . dtype sig = retty ( val , viewty ) return sig , codegen