class
Crystal::CodeGenVisitor
Included Modules
Defined in:
compiler/crystal/codegen/asm.crcompiler/crystal/codegen/call.cr
compiler/crystal/codegen/cast.cr
compiler/crystal/codegen/class_var.cr
compiler/crystal/codegen/codegen.cr
compiler/crystal/codegen/cond.cr
compiler/crystal/codegen/const.cr
compiler/crystal/codegen/context.cr
compiler/crystal/codegen/debug.cr
compiler/crystal/codegen/dump_type_info.cr
compiler/crystal/codegen/exception.cr
compiler/crystal/codegen/fun.cr
compiler/crystal/codegen/match.cr
compiler/crystal/codegen/once.cr
compiler/crystal/codegen/phi.cr
compiler/crystal/codegen/primitives.cr
compiler/crystal/codegen/type_id.cr
compiler/crystal/codegen/unions.cr
Constant Summary
-
DW_OP_plus_uconst =
35 -
see also the other DWARF enums in
crystal/dwarf/abbrev.cr(note that LLVM defines several custom opcodes outside the user extension range) -
ONCE_STATE =
"~ONCE_STATE" -
SYMBOL_TABLE_NAME =
":symbol_table"
Constructors
Instance Method Summary
- #abi_info(external : Def, node : Call)
- #abi_info(external : Def)
- #accept(node)
- #accept_control_expression(node)
- #add_typed_fun(mod : LLVM::Module, name : String, type : LLVM::Type) : LLVMTypedFunction
-
#aggregate_index(type : LLVM::Type, ptr : LLVM::Value, index : Int32)
type is the pointee type of ptr (not the type of the returned element)
- #alloca(type, name = "")
- #alloca_block : LLVM::BasicBlock
- #alloca_non_closured_vars(vars, obj = nil, args = nil, reset_nilable_vars = true)
- #alloca_vars(vars, obj = nil, args = nil, parent_context = nil, reset_nilable_vars = true)
- #allocate_aggregate(type)
- #allocate_tuple(type, &)
- #array_malloc(type, count)
- #array_malloc_atomic(type, count)
- #assign(target_pointer, target_type, value_type, value)
- #assign_distinct(target_pointer, target_type : NilableType, value_type : Type, value)
- #assign_distinct(target_pointer, target_type : ReferenceUnionType, value_type : ReferenceUnionType, value)
- #assign_distinct(target_pointer, target_type : ReferenceUnionType, value_type : VirtualType, value)
- #assign_distinct(target_pointer, target_type : ReferenceUnionType, value_type : Type, value)
- #assign_distinct(target_pointer, target_type : NilableReferenceUnionType, value_type : Type, value)
- #assign_distinct(target_pointer, target_type : MixedUnionType, value_type : MixedUnionType, value)
- #assign_distinct(target_pointer, target_type : MixedUnionType, value_type : NilableType, value)
- #assign_distinct(target_pointer, target_type : MixedUnionType, value_type : VoidType, value)
- #assign_distinct(target_pointer, target_type : MixedUnionType, value_type : BoolType, value)
- #assign_distinct(target_pointer, target_type : MixedUnionType, value_type : NilType, value)
- #assign_distinct(target_pointer, target_type : MixedUnionType, value_type : Type, value)
- #assign_distinct(target_pointer, target_type : VirtualType, value_type : MixedUnionType, value)
- #assign_distinct(target_pointer, target_type : VirtualType, value_type : Type, value)
- #assign_distinct(target_pointer, target_type : VirtualMetaclassType, value_type : MetaclassType | GenericClassInstanceMetaclassType | GenericModuleInstanceMetaclassType | VirtualMetaclassType, value)
- #assign_distinct(target_pointer, target_type : VirtualMetaclassType, value_type : UnionType, value)
- #assign_distinct(target_pointer, target_type : NilableProcType, value_type : NilType, value)
- #assign_distinct(target_pointer, target_type : NilableProcType, value_type : ProcInstanceType, value)
- #assign_distinct(target_pointer, target_type : NilableProcType, value_type : TypeDefType, value)
- #assign_distinct(target_pointer, target_type : TupleInstanceType, value_type : TupleInstanceType, value)
- #assign_distinct(target_pointer, target_type : NamedTupleInstanceType, value_type : NamedTupleInstanceType, value)
- #assign_distinct(target_pointer, target_type : ProcInstanceType, value_type : ProcInstanceType, value)
- #assign_distinct(target_pointer, target_type : ProcInstanceType, value_type : MixedUnionType, value)
- #assign_distinct(target_pointer, target_type : Type, value_type : Type, value)
- #assign_distinct_union_types(to_pointer, to_type, from_type, from_pointer)
- #atomic_ordering_get_const(node, llvm_arg)
- #atomicrwm_bin_op_get_const(node, llvm_arg)
- #bool_from_bool_literal(node)
- #bound_to_mod_nil?(var)
- #br_block_chain(*blocks)
- #br_from_alloca_to_entry
- #build_string_constant(str, name = "str", *, llvm_mod = @llvm_mod, llvm_typer = @llvm_typer)
- #builder : CrystalLLVMBuilder
- #c_malloc_fun
- #c_realloc_fun
- #call_abi_info(target_def, node)
- #cant_pass_closure_to_c_exception_call
- #check_assign_to_special_var_in_block(target, value)
- #check_atomic_call(call, target_def)
- #check_c_fun(type, value)
- #check_main_fun(name, func : LLVMTypedFunction) : LLVMTypedFunction
- #check_mod_fun(mod, name, func : LLVMTypedFunction) : LLVMTypedFunction
- #check_proc_is_not_closure(value, type)
- #class_var_global_initialized_name(class_var : MetaTypeVar)
- #class_var_global_name(class_var : MetaTypeVar)
- #clear_current_debug_location
- #closured_vars(vars, obj = nil)
- #codegen_addsub_same_signedness_with_overflow(op, t1, t2, p1, p2)
- #codegen_addsub_with_overflow(op, t1, t2, p1, p2)
- #codegen_assign(target : Underscore, value, node)
- #codegen_assign(target : Path, value, node)
- #codegen_assign(target, value, node)
- #codegen_binary_extend_int(t1, t2, p1, p2)
- #codegen_binary_op(op, t1 : BoolType, t2 : BoolType, p1, p2)
- #codegen_binary_op(op, t1 : CharType, t2 : CharType, p1, p2)
- #codegen_binary_op(op, t1 : SymbolType, t2 : SymbolType, p1, p2)
- #codegen_binary_op(op, t1 : IntegerType, t2 : IntegerType, p1, p2)
- #codegen_binary_op(op, t1 : IntegerType, t2 : FloatType, p1, p2)
- #codegen_binary_op(op, t1 : FloatType, t2 : IntegerType, p1, p2)
- #codegen_binary_op(op, t1 : FloatType, t2 : FloatType, p1, p2)
- #codegen_binary_op(op, t1 : TypeDefType, t2, p1, p2)
- #codegen_binary_op(op, t1, t2 : TypeDefType, p1, p2)
- #codegen_binary_op(op, t1, t2, p1, p2)
- #codegen_binary_op_eq(t1, t2, p1, p2)
- #codegen_binary_op_gt(t1, t2, p1, p2)
- #codegen_binary_op_gte(t1, t2, p1, p2)
- #codegen_binary_op_lt(t1, t2, p1, p2)
- #codegen_binary_op_lte(t1, t2, p1, p2)
- #codegen_binary_op_ne(t1, t2, p1, p2)
- #codegen_call(node, target_def, self_type, call_args)
- #codegen_call_or_invoke(node, target_def, self_type, func, call_args, raises, type, is_closure = false, fun_type = nil)
- #codegen_call_with_block(node, block, self_type, call_args)
- #codegen_call_with_block_as_fun_literal(node, fun_literal, self_type, call_args)
- #codegen_cast(from_type, to_type, arg)
- #codegen_cond(node : ASTNode)
- #codegen_cond(type)
- #codegen_cond_branch(node_cond, then_block, else_block)
- #codegen_convert(from_type : IntegerType, to_type : IntegerType, arg, *, checked : Bool)
- #codegen_convert(from_type : IntegerType, to_type : FloatType, arg, *, checked : Bool)
- #codegen_convert(from_type : FloatType, to_type : IntegerType, arg, *, checked : Bool)
- #codegen_convert(from_type : FloatType, to_type : FloatType, arg, *, checked : Bool)
- #codegen_convert(from_type : IntegerType, to_type : CharType, arg, *, checked : Bool)
- #codegen_convert(from_type : CharType, to_type : IntegerType, arg, *, checked : Bool)
- #codegen_convert(from_type : SymbolType, to_type : IntegerType, arg, *, checked : Bool)
- #codegen_convert(from_type : TypeDefType, to_type, arg, *, checked : Bool)
- #codegen_convert(from_type, to_type, arg, *, checked : Bool)
- #codegen_direct_abi_call(call_arg_type, call_arg, abi_arg_type)
- #codegen_dispatch(node, target_defs)
- #codegen_extern_primitive_proc_call(target_def, args, fun_ptr)
- #codegen_fun(mangled_name, target_def, self_type, is_exported_fun = false, fun_module_info = type_module(self_type), is_fun_literal = false, is_closure = false)
- #codegen_fun_signature(mangled_name, target_def, self_type, is_fun_literal, is_closure)
- #codegen_fun_signature_external(mangled_name, target_def)
- #codegen_fun_signature_non_external(mangled_name, target_def, self_type, is_fun_literal, is_closure)
- #codegen_if_branch(phi, node, branch_block, last)
-
#codegen_indirect_abi_call(call_arg, abi_arg_type)
For an indirect argument we need to make a copy of the value in the stack and replace the call argument by a pointer to the allocated memory
- #codegen_mul_same_signedness_with_overflow(t1, t2, p1, p2)
- #codegen_mul_signed_unsigned_with_overflow(t1, t2, p1, p2)
- #codegen_mul_unsigned_signed_with_overflow(t1, t2, p1, p2)
- #codegen_mul_with_overflow(t1, t2, p1, p2)
- #codegen_primitive(call, node, target_def, call_args)
- #codegen_primitive_allocate(node, target_def, call_args)
- #codegen_primitive_atomicrmw(call, node, target_def, call_args)
- #codegen_primitive_binary(node, target_def, call_args)
- #codegen_primitive_class(node, target_def, call_args)
- #codegen_primitive_class_crystal_instance_type_id(node, target_def, call_args)
- #codegen_primitive_class_with_type(type : VirtualType, value)
- #codegen_primitive_class_with_type(type : Type, value)
- #codegen_primitive_cmpxchg(call, node, target_def, call_args)
- #codegen_primitive_convert(node, target_def, call_args, *, checked : Bool)
- #codegen_primitive_external_var_get(node, target_def, call_args)
- #codegen_primitive_external_var_set(node, target_def, call_args)
- #codegen_primitive_fence(call, node, target_def, call_args)
- #codegen_primitive_load_atomic(call, node, target_def, call_args)
- #codegen_primitive_object_crystal_type_id(node, target_def, call_args)
- #codegen_primitive_object_id(node, external, call_args)
- #codegen_primitive_pointer_add(node, target_def, call_args)
- #codegen_primitive_pointer_address(node, target_def, call_args)
- #codegen_primitive_pointer_diff(node, target_def, call_args)
- #codegen_primitive_pointer_get(node, target_def, call_args)
- #codegen_primitive_pointer_malloc(node, target_def, call_args)
- #codegen_primitive_pointer_new(node, target_def, call_args)
- #codegen_primitive_pointer_realloc(node, target_def, call_args)
- #codegen_primitive_pointer_set(node, target_def, call_args)
- #codegen_primitive_pre_initialize(node, target_def, call_args)
- #codegen_primitive_proc_call(node, target_def, call_args)
- #codegen_primitive_store_atomic(call, node, target_def, call_args)
- #codegen_primitive_struct_or_union_set(node, target_def, call_args)
- #codegen_primitive_symbol_to_s(node, target_def, call_args)
- #codegen_primitive_tuple_indexer_known_index(node, target_def, call_args)
- #codegen_raise_cast_failed(value, type_id, obj_type, to_type, node)
- #codegen_re_raise(node, unwind_ex_obj)
- #codegen_return(type : NoReturnType | Nil)
- #codegen_return(type : Type)
- #codegen_return(target_def : Def)
- #codegen_return_node(node, node_type)
-
#codegen_trunc_binary_op_result(t1, t2, result)
Ensures the result is returned in the type of the left hand side operand t1.
- #codegen_tuple_indexer(type, value, index : Range)
- #codegen_tuple_indexer(type, value, index : Int32)
- #codegen_type_filter(node, &)
- #codegen_va_arg(call, node, target_def, call_args)
- #codegen_well_known_functions(node)
- #configure_module(llvm_mod)
- #context : Context
- #create_check_proc_is_not_closure_fun(fun_name)
- #create_debug_type(type : NilType, original_type : Type)
- #create_debug_type(type : VoidType, original_type : Type)
- #create_debug_type(type : CharType, original_type : Type)
- #create_debug_type(type : IntegerType, original_type : Type)
- #create_debug_type(type : SymbolType, original_type : Type)
- #create_debug_type(type : FloatType, original_type : Type)
- #create_debug_type(type : BoolType, original_type : Type)
- #create_debug_type(type : EnumType, original_type : Type)
- #create_debug_type(type : PointerInstanceType, original_type : Type)
- #create_debug_type(type : StaticArrayInstanceType, original_type : Type)
- #create_debug_type(type : TupleInstanceType, original_type : Type)
- #create_debug_type(type : NamedTupleInstanceType, original_type : Type)
- #create_debug_type(type : ProcInstanceType, original_type : Type)
- #create_debug_type(type : InstanceVarContainer, original_type : Type)
- #create_debug_type(type : MixedUnionType, original_type : Type)
- #create_debug_type(type : NilableReferenceUnionType | ReferenceUnionType, original_type : Type)
- #create_debug_type(type : NilableType, original_type : Type)
- #create_debug_type(type : TypeDefType, original_type : Type)
- #create_debug_type(type : NilableProcType, original_type : Type)
-
#create_debug_type(type : NonGenericModuleType | GenericClassInstanceMetaclassType | MetaclassType | VirtualMetaclassType, original_type : Type)
This is a sinkhole for debug types that most likely does not need to be implemented
- #create_debug_type(type, original_type : Type)
- #create_initialize_class_var_function(class_var, initializer)
- #create_initialize_const_function(fun_name, const)
- #create_local_copy_of_arg(target_def, target_def_vars, arg, value, index)
- #create_local_copy_of_block_args(target_def, self_type, call_args, args_base_index)
- #create_local_copy_of_block_self(self_type, call_args)
- #create_local_copy_of_fun_args(target_def, self_type, args, is_fun_literal, is_closure)
- #create_metaclass_fun(name)
- #create_read_class_var_function(class_var, initializer)
- #create_read_const_function(fun_name, const)
- #create_read_virtual_class_var_ptr_function(fun_name, class_var, owner)
- #create_read_virtual_metaclass_var_ptr_function(fun_name, class_var, owner)
- #create_type_id_to_class_name_map
- #crystal_malloc_atomic_fun
- #crystal_malloc_fun
- #crystal_raise_cast_failed_fun
- #crystal_raise_overflow_fun
- #crystal_realloc_fun
-
#debug_codegen_log(file = __FILE__, line = __LINE__, &)
Emits a debug message that shows the current llvm basic block name, the location within the codegen that was used to emit this log.
-
#debug_codegen_log(file = __FILE__, line = __LINE__)
Emits a debug message that shows the current llvm basic block name, the location within the codegen that was used to emit this log.
- #debug_files_cache
- #debug_type_cache
- #declare_class_var(class_var : MetaTypeVar)
- #declare_class_var_and_initialized_flag(class_var : MetaTypeVar)
- #declare_class_var_and_initialized_flag_in_this_module(class_var : MetaTypeVar)
- #declare_class_var_initialized_flag(class_var : MetaTypeVar)
- #declare_const(const)
- #declare_const_and_initialized_flag(const)
- #declare_const_initialized_flag(const)
- #declare_debug_for_function_argument(arg_name, arg_type, arg_no, alloca, location)
- #declare_fun(mangled_name, func : LLVMTypedFunction) : LLVMTypedFunction
- #declare_lib_var(name, type, thread_local)
- #declare_parameter(arg_name, arg_type, arg_no, alloca, location)
- #declare_var(var)
- #declare_variable(var_name, var_type, alloca, location, basic_block : LLVM::BasicBlock | Nil = nil, offset : Int = 0)
- #define_main_function(name, arg_types : Array(LLVM::Type), return_type : LLVM::Type, needs_alloca : Bool = false, &)
- #define_main_function(name, type : LLVM::Type, needs_alloca : Bool = false, &)
- #define_slice_constant(info : Program::ConstSliceInfo)
- #define_symbol_table(llvm_mod, llvm_typer)
- #di_builder(llvm_module = @llvm_mod || @main_mod)
- #discard_value(node : ASTNode)
- #downcast(value, to_type, from_type : VoidType, already_loaded, *, extern = false)
-
#downcast(value, to_type, from_type : Type, already_loaded, *, extern = false)
extern is only used in
CodeGenVisitor#read_instance_var, and it is irrelevant wheneveralready_loaded == true - #downcast_distinct(value, to_type : NilType, from_type : Type)
- #downcast_distinct(value, to_type, from_type : MetaclassType | GenericClassInstanceMetaclassType | GenericModuleInstanceMetaclassType | VirtualMetaclassType)
- #downcast_distinct(value, to_type : VirtualType, from_type : VirtualType)
- #downcast_distinct(value, to_type : ReferenceUnionType, from_type : VirtualType)
- #downcast_distinct(value, to_type : NonGenericClassType | GenericClassInstanceType, from_type : VirtualType)
- #downcast_distinct(value, to_type : VirtualType, from_type : NilableType)
- #downcast_distinct(value, to_type : Type, from_type : NilableType)
- #downcast_distinct(value, to_type : ProcInstanceType, from_type : NilableProcType)
- #downcast_distinct(value, to_type : TypeDefType, from_type : NilableProcType)
- #downcast_distinct(value, to_type : PointerInstanceType, from_type : PointerInstanceType)
- #downcast_distinct(value, to_type : ReferenceUnionType, from_type : ReferenceUnionType)
- #downcast_distinct(value, to_type : VirtualType, from_type : ReferenceUnionType)
- #downcast_distinct(value, to_type : Type, from_type : ReferenceUnionType)
- #downcast_distinct(value, to_type : VirtualType, from_type : NilableReferenceUnionType)
- #downcast_distinct(value, to_type : ReferenceUnionType, from_type : NilableReferenceUnionType)
- #downcast_distinct(value, to_type : NilableType, from_type : NilableReferenceUnionType)
- #downcast_distinct(value, to_type : Type, from_type : NilableReferenceUnionType)
- #downcast_distinct(value, to_type : MixedUnionType, from_type : MixedUnionType)
- #downcast_distinct(value, to_type : NilableType, from_type : MixedUnionType)
- #downcast_distinct(value, to_type : BoolType, from_type : MixedUnionType)
- #downcast_distinct(value, to_type : Type, from_type : MixedUnionType)
- #downcast_distinct(value, to_type : ProcInstanceType, from_type : ProcInstanceType)
- #downcast_distinct(value, to_type : TupleInstanceType, from_type : TupleInstanceType)
- #downcast_distinct(value, to_type : NamedTupleInstanceType, from_type : NamedTupleInstanceType)
-
#downcast_distinct(value, to_type : IntegerType, from_type : IntegerType)
This is the case of the automatic cast between integer types
-
#downcast_distinct(value, to_type : FloatType, from_type : IntegerType)
This is the case of the automatic cast between integer type and float type
-
#downcast_distinct(value, to_type : FloatType, from_type : FloatType)
This is the case of the automatic cast between float types
-
#downcast_distinct(value, to_type : EnumType, from_type : SymbolType)
This is the case of the automatic cast between symbol and enum
- #downcast_distinct(value, to_type : Type, from_type : Type)
- #downcast_distinct_union_types(value, to_type : MixedUnionType, from_type : MixedUnionType)
- #emit_def_debug_metadata(target_def)
- #emit_fun_debug_metadata(func, fun_name, location, *, debug_types = [] of LibLLVM::MetadataRef, is_optimized = false)
-
#emit_vars_debug_info(vars)
Emit debug info for toplevel variables.
- #end_visit(node : ReadInstanceVar)
- #ensure_class_var_in_this_module(global, class_var)
- #ensure_class_var_initialized_flag_in_this_module(initialized_flag, class_var)
- #entry_block : LLVM::BasicBlock
- #execute_ensures_until(node)
- #extern_to_lhs(value, type)
- #extern_to_rhs(value, type)
- #external_constant(type, name)
- #fetch_typed_fun(mod : LLVM::Module, name : String, & : -> LLVM::Type) : LLVMTypedFunction
- #file_and_dir(filename)
- #finish
- #fun_literal_name(node : ProcLiteral)
- #fun_metadata_type(debug_types = [] of LibLLVM::MetadataRef)
- #fun_metadatas
- #generic_array_malloc(type, count, &)
- #generic_malloc(type, &)
- #get_class_var_global(class_var)
- #get_current_debug_scope(location)
- #get_debug_type(type, original_type : Type)
- #get_debug_type(type)
- #get_external_var(external)
- #get_global(name, type, real_var, initial_value = nil)
- #get_global_var(name, type, real_var, initial_value = nil)
- #get_thread_local(name, type, real_var)
- #in_alloca_block(&)
- #in_main(&)
- #initialize_class_var(class_var : MetaTypeVar, initializer : ClassVarInitializer)
- #initialize_class_var(class_var : ClassVar)
- #initialize_class_var(class_var : MetaTypeVar)
- #initialize_const(const)
- #initialize_no_init_flag_const(const)
-
#initialize_predefined_constants
The special constants ARGC_UNSAFE and ARGV_UNSAFE (and others) need to be initialized as soon as the program starts, because we have access to argc and argv in the main function.
- #initialize_simple_const(const)
-
#initialize_simple_constants
Here we only initialize simple constants, those that has simple values like 1, "foo" and other literals.
- #inline_call_return_value(target_def, body)
- #instance_var_ptr(type, name, pointer)
- #last : LLVM::Value
- #last=(last : LLVM::Value)
- #lazy_initialize_class_var(node, init_func, global, initialized_flag)
- #llvm_context : LLVM::Context
- #llvm_mod : LLVM::Module
- #llvm_self(type = context.type)
- #llvm_self_ptr
- #llvm_typer : LLVMTyper
- #main : LLVM::Function
- #main_fun(name)
- #make_fun(type, fun_ptr, ctx_ptr)
- #make_nilable_fun(type)
- #malloc(type)
- #malloc_atomic(type)
- #malloc_closure(closure_vars, current_context, parent_context = nil, self_closured = false)
- #match_any_type_id(type, type_id)
- #match_type_id(type, restriction, type_id)
- #memcpy(dest, src, len, align, volatile, *, src_align = align)
- #memset(pointer, value, size)
- #modules : Hash(String, ModuleInfo)
- #needs_value_cast_inside_union?(value_type, union_type)
- #new_block(name = "")
- #new_blocks(*names)
- #new_builder(llvm_context)
- #new_entry_block
- #new_entry_block_chain(*names)
- #once_init
- #personality_name : String
- #pre_initialize_aggregate(type, struct_type, ptr : LLVM::Value)
- #prepare_call_args(node, owner)
- #prepare_call_args_external(node, target_def, owner)
- #prepare_call_args_non_external(node, target_def, owner)
- #printf(format, args = [] of LLVM::Value)
- #process_finished_hooks
- #push_debug_info_metadata(mod)
- #read_class_var(node : ClassVar)
- #read_class_var(class_var : MetaTypeVar)
- #read_class_var_ptr(node : ClassVar)
- #read_class_var_ptr(class_var : MetaTypeVar)
- #read_const(const, node)
- #read_const_pointer(const)
- #read_instance_var(node_type, type, name, value)
- #read_virtual_class_var_ptr(class_var, owner)
- #read_virtual_metaclass_class_var_ptr(class_var, owner)
- #realloc(buffer, size)
- #request_value(request : Bool = true, &)
- #request_value(node : ASTNode)
-
#reset_nilable_vars(node)
Sets to nil any variable in node that is nilable.
- #run_instance_vars_initializers(real_type, type : ClassType | GenericClassInstanceType, type_ptr)
- #run_instance_vars_initializers(real_type, type : Type, type_ptr)
- #run_instance_vars_initializers_non_recursive(real_type, type, type_ptr)
- #run_once(flag, func : LLVMTypedFunction)
- #set_aggregate_field(node, target_def, call_args, &)
- #set_alignment(inst, type)
- #set_call_attributes(node : Call, target_def, self_type, is_closure, fun_type)
-
#set_call_attributes(node, target_def, self_type, is_closure, fun_type)
This is for function pointer calls and exception handler re-raise
- #set_call_attributes_external(node, target_def)
- #set_current_debug_location(node : ASTNode)
- #set_current_debug_location(location)
- #set_ensure_exception_handler(node)
-
#set_internal_fun_debug_location(func, name, location = nil)
used for generated internal functions like
~metaclassand~match - #setup_closure_vars(target_def, closure_vars, context, closure_type, closure_ptr)
- #setup_context_fun(mangled_name, target_def, llvm_args_types, llvm_return_type) : Nil
- #sret?(abi_info)
- #store_bool_in_union(target_type, union_pointer, value)
- #store_in_union(union_type, union_pointer, value_type, value)
- #store_nil_in_union(target_type, union_pointer)
-
#store_union_in_union(union_type, union_pointer, value_type, value)
this is needed if
union_typeandvalue_typehave different alignments, i.e. - #store_void_in_union(target_type, union_pointer)
- #struct_field_ptr(type, field_name, pointer)
- #sub_image_base(value)
- #target_def_fun(target_def, self_type) : LLVMTypedFunction
- #to_lhs(value, type)
- #to_rhs(value, type)
-
#try_inline_call(target_def, body, self_type, call_args)
If a method's body is just a simple literal, "self", or an instance variable, we always inline it: less code generated, easier job for LLVM to optimize, and avoid a call in non-release builds.
- #type
-
#type_cast_exception_call(from_type, to_type, node, var_name)
fallback for stdlib before 1.16.2 when using a 1.16.2 or later compiler
- #type_id(value, type)
- #type_id(type)
- #type_id_to_class_name(type_id)
- #type_module(type)
- #typed_fun?(mod : LLVM::Module, name : String) : LLVMTypedFunction | Nil
- #undef_vars(vars, obj)
- #union_field_ptr(union_type, field_type, pointer)
- #union_type_and_value_pointer(union_pointer, type : MixedUnionType)
- #union_type_and_value_pointer(union_pointer, type : UnionType)
- #union_type_id(struct_type, union_pointer)
- #union_value(struct_type, union_pointer)
- #unreachable(file = __FILE__, line = __LINE__)
- #upcast(value, to_type, from_type)
- #upcast_distinct(value, to_type : MetaclassType | GenericClassInstanceMetaclassType | GenericModuleInstanceMetaclassType | VirtualMetaclassType, from_type)
- #upcast_distinct(value, to_type : VirtualType, from_type)
- #upcast_distinct(value, to_type : NilableType, from_type : NilType | Nil)
- #upcast_distinct(value, to_type : NilableType, from_type : Type)
- #upcast_distinct(value, to_type : NilableReferenceUnionType, from_type : NilType | Nil)
- #upcast_distinct(value, to_type : NilableReferenceUnionType, from_type : Type)
- #upcast_distinct(value, to_type : NilableProcType, from_type : NilType)
- #upcast_distinct(value, to_type : NilableProcType, from_type : ProcInstanceType)
- #upcast_distinct(value, to_type : NilableProcType, from_type : TypeDefType)
- #upcast_distinct(value, to_type : ReferenceUnionType, from_type)
- #upcast_distinct(value, to_type : MixedUnionType, from_type : MixedUnionType)
- #upcast_distinct(value, to_type : MixedUnionType, from_type : VoidType)
- #upcast_distinct(value, to_type : MixedUnionType, from_type : BoolType)
- #upcast_distinct(value, to_type : MixedUnionType, from_type : NilType)
- #upcast_distinct(value, to_type : MixedUnionType, from_type : Type)
- #upcast_distinct(value, to_type : EnumType, from_type : Type)
- #upcast_distinct(value, to_type : TupleInstanceType, from_type : TupleInstanceType)
- #upcast_distinct(value, to_type : NamedTupleInstanceType, from_type : NamedTupleInstanceType)
- #upcast_distinct(value, to_type : GenericClassInstanceType, from_type : Type)
- #upcast_distinct(value, to_type : Type, from_type : Type)
- #upcast_distinct_union_types(value, to_type : MixedUnionType, from_type : MixedUnionType)
- #validate_atomic_cmpxchg_ordering(success_node, success_ordering, failure_node, failure_ordering)
- #visit(node : Annotation)
- #visit(node : FunDef)
- #visit(node : FileNode)
- #visit(node : Nop)
- #visit(node : NilLiteral)
- #visit(node : BoolLiteral)
- #visit(node : CharLiteral)
- #visit(node : NumberLiteral)
- #visit(node : StringLiteral)
- #visit(node : SymbolLiteral)
- #visit(node : TupleLiteral)
- #visit(node : NamedTupleLiteral)
- #visit(node : PointerOf)
- #visit(node : ProcLiteral)
- #visit(node : ProcPointer)
- #visit(node : Expressions)
- #visit(node : Return)
- #visit(node : ClassDef)
- #visit(node : ModuleDef)
- #visit(node : LibDef)
- #visit(node : CStructOrUnionDef)
- #visit(node : EnumDef)
- #visit(node : ExternalVar)
- #visit(node : TypeDef)
- #visit(node : Alias)
- #visit(node : TypeOf)
- #visit(node : SizeOf)
- #visit(node : InstanceSizeOf)
- #visit(node : AlignOf)
- #visit(node : InstanceAlignOf)
- #visit(node : Include)
- #visit(node : Extend)
- #visit(node : If)
- #visit(node : While)
- #visit(node : Not)
- #visit(node : Break)
- #visit(node : Next)
- #visit(node : Assign)
- #visit(node : TypeDeclaration)
- #visit(node : UninitializedVar)
- #visit(node : Var)
- #visit(node : Global)
- #visit(node : ClassVar)
- #visit(node : InstanceVar)
- #visit(node : Cast)
- #visit(node : NilableCast)
- #visit(node : IsA)
- #visit(node : RespondsTo)
- #visit(node : Def)
- #visit(node : Macro)
- #visit(node : Path)
- #visit(node : Generic)
- #visit(node : Yield)
- #visit(node : Unreachable)
- #visit(node : ExpandableNode)
- #visit(node : Call)
- #visit(node : ExceptionHandler)
-
#visit(node : Primitive)
Can only happen in a Const or as an argument cast.
- #visit(node : Asm)
- #visit(node : ASTNode)
- #visit_any(node)
- #void_ptr_throwinfo
- #void_ptr_type_descriptor
- #with_cloned_context(new_context = @context, &)
- #with_context(new_context : Crystal::CodeGenVisitor::Context, &)
- #wrap_builder(builder)
Instance methods inherited from module Crystal::LLVMBuilderHelper
and(*args, **options)and(*args, **options, &) and, bit_cast(*args, **options)
bit_cast(*args, **options, &) bit_cast, br(*args, **options)
br(*args, **options, &) br, call(func : LLVMTypedFunction, name : String = "")
call(func : LLVMTypedFunction, arg : LLVM::Value, name : String = "")
call(func : LLVMTypedFunction, args : Array(LLVM::Value), name : String = "") call, cast_to(value : LLVM::ValueMethods, type : Type) cast_to, cast_to_pointer(value : LLVM::ValueMethods, type : Type) cast_to_pointer, cast_to_void_pointer(pointer : LLVM::ValueMethods) cast_to_void_pointer, cond(*args, **options)
cond(*args, **options, &) cond, equal?(value1, value2) equal?, extend_float(to_type, value) extend_float, extend_int(from_type, to_type, value) extend_int, extract_value(*args, **options)
extract_value(*args, **options, &) extract_value, float(value, type) float, float32(value) float32, float64(value) float64, float_to_int(from_type, to_type, value) float_to_int, gep(ptr : LLVM::Value, index0 : Int32, index1 : Int32, name = "")
gep(type : LLVM::Type, ptr : LLVM::Value, index0 : Int32, index1 : Int32, name = "")
gep(type : LLVM::Type, ptr : LLVM::Value, index0 : LLVM::Value, index1 : LLVM::Value, name = "")
gep(ptr : LLVM::Value, index0 : Int32, name = "")
gep(ptr : LLVM::Value, index0 : LLVM::Value, index1 : LLVM::Value, name = "")
gep(ptr : LLVM::Value, index0 : LLVM::Value, name = "")
gep(type : LLVM::Type, ptr : LLVM::Value, index0 : Int32, name = "")
gep(type : LLVM::Type, ptr : LLVM::Value, index0 : LLVM::Value, name = "") gep, insert_block(*args, **options)
insert_block(*args, **options, &) insert_block, int(n, type)
int(n) int, int1(n) int1, int128(n) int128, int16(n) int16, int2ptr(*args, **options)
int2ptr(*args, **options, &) int2ptr, int32(n) int32, int64(n) int64, int8(n) int8, int_to_float(from_type, to_type, value) int_to_float, invoke(func : LLVMTypedFunction, args : Array(LLVM::Value), a_then, a_catch, name : String = "") invoke, llvm_alignment(type) llvm_alignment, llvm_arg_type(*args, **options)
llvm_arg_type(*args, **options, &) llvm_arg_type, llvm_c_return_type(*args, **options)
llvm_c_return_type(*args, **options, &) llvm_c_return_type, llvm_c_type(*args, **options)
llvm_c_type(*args, **options, &) llvm_c_type, llvm_closure_type(type) llvm_closure_type, llvm_embedded_c_type(*args, **options)
llvm_embedded_c_type(*args, **options, &) llvm_embedded_c_type, llvm_embedded_type(*args, **options)
llvm_embedded_type(*args, **options, &) llvm_embedded_type, llvm_false llvm_false, llvm_intrinsic_return_type(*args, **options)
llvm_intrinsic_return_type(*args, **options, &) llvm_intrinsic_return_type, llvm_nil llvm_nil, llvm_proc_type(type) llvm_proc_type, llvm_return_type(*args, **options)
llvm_return_type(*args, **options, &) llvm_return_type, llvm_size(type) llvm_size, llvm_struct_alignment(type) llvm_struct_alignment, llvm_struct_size(type) llvm_struct_size, llvm_struct_type(*args, **options)
llvm_struct_type(*args, **options, &) llvm_struct_type, llvm_true llvm_true, llvm_type(*args, **options)
llvm_type(*args, **options, &) llvm_type, load(*args, **options)
load(*args, **options, &) load, load_volatile(*args, **options)
load_volatile(*args, **options, &) load_volatile, not(*args, **options)
not(*args, **options, &) not, not_equal?(value1, value2) not_equal?, not_null_pointer?(value) not_null_pointer?, null_pointer?(value) null_pointer?, or(*args, **options)
or(*args, **options, &) or, phi(*args, **options)
phi(*args, **options, &) phi, position_at_end(*args, **options)
position_at_end(*args, **options, &) position_at_end, ptr2int(*args, **options)
ptr2int(*args, **options, &) ptr2int, ret(value : Nil)
ret(value)
ret ret, size_t(value : LLVM::Value)
size_t(n)
size_t size_t, store(*args, **options)
store(*args, **options, &) store, store_volatile(*args, **options)
store_volatile(*args, **options, &) store_volatile, switch(*args, **options)
switch(*args, **options, &) switch, trunc(*args, **options)
trunc(*args, **options, &) trunc, trunc_float(to_type, value) trunc_float
Macros inherited from module Crystal::LLVMBuilderHelper
pointer_cast(value, type)
pointer_cast
Instance methods inherited from class Crystal::Visitor
accept(node)
accept,
end_visit(node)
end_visit,
end_visit_any(node)
end_visit_any,
visit_any(node)
visit_any
Instance methods inherited from class Reference
==(other : self)==(other : JSON::Any)
==(other : YAML::Any)
==(other) ==, dup dup, hash(hasher) hash, initialize initialize, inspect(io : IO) : Nil inspect, object_id : UInt64 object_id, pretty_print(pp) : Nil pretty_print, same?(other : Reference) : Bool
same?(other : Nil) same?, to_s(io : IO) : Nil to_s
Constructor methods inherited from class Reference
new
new,
unsafe_construct(address : Pointer, *args, **opts) : self
unsafe_construct
Class methods inherited from class Reference
pre_initialize(address : Pointer)
pre_initialize
Instance methods inherited from class Object
! : Bool
!,
!=(other)
!=,
!~(other)
!~,
==(other)
==,
===(other : JSON::Any)===(other : YAML::Any)
===(other) ===, =~(other) =~, as(type : Class) as, as?(type : Class) as?, class class, dup dup, hash(hasher)
hash hash, in?(collection : Object) : Bool
in?(*values : Object) : Bool in?, inspect(io : IO) : Nil
inspect : String inspect, is_a?(type : Class) : Bool is_a?, itself itself, nil? : Bool nil?, not_nil!(message)
not_nil! not_nil!, pretty_inspect(width = 79, newline = "\n", indent = 0) : String pretty_inspect, pretty_print(pp : PrettyPrint) : Nil pretty_print, responds_to?(name : Symbol) : Bool responds_to?, tap(&) tap, to_json(io : IO) : Nil
to_json : String to_json, to_pretty_json(indent : String = " ") : String
to_pretty_json(io : IO, indent : String = " ") : Nil to_pretty_json, to_s(io : IO) : Nil
to_s : String to_s, to_yaml(io : IO) : Nil
to_yaml : String to_yaml, try(&) try, unsafe_as(type : T.class) forall T unsafe_as
Class methods inherited from class Object
from_json(string_or_io : String | IO, root : String)from_json(string_or_io : String | IO) from_json, from_yaml(string_or_io : String | IO) from_yaml
Macros inherited from class Object
class_getter(*names, &block)
class_getter,
class_getter!(*names)
class_getter!,
class_getter?(*names, &block)
class_getter?,
class_property(*names, &block)
class_property,
class_property!(*names)
class_property!,
class_property?(*names, &block)
class_property?,
class_setter(*names)
class_setter,
def_clone
def_clone,
def_equals(*fields)
def_equals,
def_equals_and_hash(*fields)
def_equals_and_hash,
def_hash(*fields)
def_hash,
delegate(*methods, to object)
delegate,
forward_missing_to(delegate)
forward_missing_to,
getter(*names, &block)
getter,
getter!(*names)
getter!,
getter?(*names, &block)
getter?,
property(*names, &block)
property,
property!(*names)
property!,
property?(*names, &block)
property?,
setter(*names)
setter
Constructor Detail
Instance Method Detail
type is the pointee type of ptr (not the type of the returned element)
For an indirect argument we need to make a copy of the value in the stack and replace the call argument by a pointer to the allocated memory
Ensures the result is returned in the type of the left hand side operand t1. This is only needed if the operation was carried in the realm of t2 because it was of higher rank
This is a sinkhole for debug types that most likely does not need to be implemented
Emits a debug message that shows the current llvm basic block name, the location within the codegen that was used to emit this log.
The message is only generated if CRYSTAL_DEBUG_CODEGEN is set
The block given to this method should yield #printf arguments to show
additional information. The following forms are all valid and helps to
allocate the arguments only if the message is to be generated.
debug_codegen_log
debug_codegen_log { }
debug_codegen_log { "Lorem" }
debug_codegen_log { {"Lorem"} }
debug_codegen_log { {"Lorem %d", [an_int_llvm_value] of LLVM::Value} }
Emits a debug message that shows the current llvm basic block name, the location within the codegen that was used to emit this log.
The message is only generated if CRYSTAL_DEBUG_CODEGEN is set
The block given to this method should yield #printf arguments to show
additional information. The following forms are all valid and helps to
allocate the arguments only if the message is to be generated.
debug_codegen_log
debug_codegen_log { }
debug_codegen_log { "Lorem" }
debug_codegen_log { {"Lorem"} }
debug_codegen_log { {"Lorem %d", [an_int_llvm_value] of LLVM::Value} }
extern is only used in CodeGenVisitor#read_instance_var, and it is
irrelevant whenever already_loaded == true
This is the case of the automatic cast between integer types
This is the case of the automatic cast between integer type and float type
This is the case of the automatic cast between float types
This is the case of the automatic cast between symbol and enum
Emit debug info for toplevel variables. Used for the main module and all required files.
The special constants ARGC_UNSAFE and ARGV_UNSAFE (and others) need to be initialized as soon as the program starts, because we have access to argc and argv in the main function.
Here we only initialize simple constants, those that has simple values like 1, "foo" and other literals.
This is for function pointer calls and exception handler re-raise
used for generated internal functions like ~metaclass and ~match
this is needed if union_type and value_type have different alignments,
i.e. their #union_values do not have the same offsets
If a method's body is just a simple literal, "self", or an instance variable, we always inline it: less code generated, easier job for LLVM to optimize, and avoid a call in non-release builds.
Do this even in debug mode, because there's not much use in stepping to read a constant value or the value of an instance variable. Additionally, not inlining instance variable getters changes the semantic a program, so we must always inline these.
fallback for stdlib before 1.16.2 when using a 1.16.2 or later compiler