/src/wrappers/llvm/library/factories/llvm_value_wrapper_factory.e
Specman e | 139 lines | 39 code | 3 blank | 97 comment | 2 complexity | c1c71e3c5016b738692dbc171f3e18a0 MD5 | raw file
1deferred class LLVM_VALUE_WRAPPER_FACTORY 2-- A factory of values 3 4inherit 5 WRAPPER_FACTORY[LLVM_VALUE] 6 rename 7 wrapper as value_wrapper, 8 wrapper_or_void as value_wrapper_or_void 9 end 10insert 11 CORE_EXTERNALS 12 EXCEPTIONS undefine copy, is_equal end 13 14feature {WRAPPER, WRAPPER_HANDLER} 15 value_wrapper (p: POINTER): LLVM_VALUE 16 local type: LLVMTYPE_KIND_ENUM 17 do 18 debug 19 std_error.put_string("Not all heirs of LLVM_VALUE taken in count in value factory%N") 20 end 21 -- Note: of course the following if elseif chain should be 22 -- substituted by an inspect instruction, if only inspect allowed 23 -- compound values like type.void_type_kind_low_level as when 24 -- values. 25 if type.is_void_type_kind then 26 debug 27 std_error.put_string("What's the correct value of a Void type? Creating a plain LLVM_VALUE.%N") 28 std_output.flush 29 end 30 create {LLVM_VALUE} Result.from_external_pointer(p) 31 elseif type.is_double_type_kind then create {LLVM_CONSTANT_FP} Result.from_external_pointer(p) 32 elseif type.is_x86_fp80type_kind then create {LLVM_CONSTANT_FP} Result.from_external_pointer(p) 33 elseif type.is_fp128type_kind then create {LLVM_CONSTANT_FP} Result.from_external_pointer(p) 34 elseif type.is_ppc_fp128type_kind then create {LLVM_CONSTANT_FP} Result.from_external_pointer(p) 35 elseif type.is_label_type_kind then create {LLVM_LABEL} Result.from_external_pointer(p) 36 elseif type.is_integer_type_kind then create {LLVM_CONSTANT_INT} Result.from_external_pointer(p) 37 elseif type.is_function_type_kind then create {LLVM_FUNCTION} Result.from_external_pointer(p) 38 elseif type.is_struct_type_kind then raise("struct not_yet_implemented") 39 elseif type.is_array_type_kind then create {LLVM_ARRAY} Result.from_external_pointer(p) 40 elseif type.is_pointer_type_kind then raise ("not_yet_implemented") 41 elseif type.is_vector_type_kind then raise ("not_yet_implemented") 42 elseif type.is_metadata_type_kind then raise ("not_yet_implemented") 43 else not_yet_implemented 44 end 45 end 46 -- TODO: This alternative implementation (also O(n) - with n the number of effective classes inheriting from 47 -- LLVM_VALUE) is based on the C interface 48 -- local type_ptr, res: POINTER 49 -- - res := llvmis_abasic_block(p) 50 -- if res.is_not_null then create {LLVM_BASIC_BLOCK} Result.from_external_pointer(res) 51 -- elseif llvmis_aglobal_alias(p).to_boolean then create {IS_AGLOBAL_ALIAS} Result.from_external_pointer(p) 52 -- elseif llvmis_acall_inst(p).to_boolean then create {IS_ACALL_INST} Result.from_external_pointer(p) 53 -- elseif llvmis_aconstant_pointer_null(p).to_boolean then create {IS_ACONSTANT_POINTER_NULL} Result.from_external_pointer(p) 54 -- elseif llvmis_afpto_uiinst(p).to_boolean then create {IS_AFPTO_UIINST} Result.from_external_pointer(p) 55 -- elseif llvmis_asito_fpinst(p).to_boolean then create {IS_ASITO_FPINST} Result.from_external_pointer(p) 56 -- elseif llvmis_atrunc_inst(p).to_boolean then create {IS_ATRUNC_INST} Result.from_external_pointer(p) 57 -- elseif llvmis_abit_cast_inst(p).to_boolean then create {IS_ABIT_CAST_INST} Result.from_external_pointer(p) 58 -- elseif llvmis_aconstant_struct(p).to_boolean then create {IS_ACONSTANT_STRUCT} Result.from_external_pointer(p) 59 -- elseif llvmis_aterminator_inst(p).to_boolean then create {IS_ATERMINATOR_INST} Result.from_external_pointer(p) 60 -- elseif llvmis_abranch_inst(p).to_boolean then create {IS_ABRANCH_INST} Result.from_external_pointer(p) 61 -- elseif llvmis_aint_to_ptr_inst(p).to_boolean then create {IS_AINT_TO_PTR_INST} Result.from_external_pointer(p) 62 -- elseif llvmis_aconstant(p).to_boolean then create {IS_ACONSTANT} Result.from_external_pointer(p) 63 -- elseif llvmis_adbg_region_end_inst(p).to_boolean then create {IS_ADBG_REGION_END_INST} Result.from_external_pointer(p) 64 -- elseif llvmis_ainstruction(p).to_boolean then create {IS_AINSTRUCTION} Result.from_external_pointer(p) 65 -- elseif llvmis_auser(p).to_boolean then create {IS_AUSER} Result.from_external_pointer(p) 66 -- elseif llvmis_aphinode(p).to_boolean then create {IS_APHINODE} Result.from_external_pointer(p) 67 -- elseif llvmis_afptrunc_inst(p).to_boolean then create {IS_AFPTRUNC_INST} Result.from_external_pointer(p) 68 -- elseif llvmis_aconstant_array(p).to_boolean then create {IS_ACONSTANT_ARRAY} Result.from_external_pointer(p) 69 -- elseif llvmis_aintrinsic_inst(p).to_boolean then create {IS_AINTRINSIC_INST} Result.from_external_pointer(p) 70 -- elseif llvmis_amem_cpy_inst(p).to_boolean then create {IS_AMEM_CPY_INST} Result.from_external_pointer(p) 71 -- elseif llvmis_azext_inst(p).to_boolean then create {IS_AZEXT_INST} Result.from_external_pointer(p) 72 -- elseif llvmis_aget_element_ptr_inst(p).to_boolean then create {IS_AGET_ELEMENT_PTR_INST} Result.from_external_pointer(p) 73 -- elseif llvmis_aselect_inst(p).to_boolean then create {IS_ASELECT_INST} Result.from_external_pointer(p) 74 -- elseif llvmis_amem_move_inst(p).to_boolean then create {IS_AMEM_MOVE_INST} Result.from_external_pointer(p) 75 -- elseif llvmis_ainvoke_inst(p).to_boolean then create {IS_AINVOKE_INST} Result.from_external_pointer(p) 76 -- elseif llvmis_amem_set_inst(p).to_boolean then create {IS_AMEM_SET_INST} Result.from_external_pointer(p) 77 -- elseif llvmis_adbg_stop_point_inst(p).to_boolean then create {IS_ADBG_STOP_POINT_INST} Result.from_external_pointer(p) 78 -- elseif llvmis_aptr_to_int_inst(p).to_boolean then create {IS_APTR_TO_INT_INST} Result.from_external_pointer(p) 79 -- elseif llvmis_adbg_func_start_inst(p).to_boolean then create {IS_ADBG_FUNC_START_INST} Result.from_external_pointer(p) 80 -- elseif llvmis_aicmp_inst(p).to_boolean then create {IS_AICMP_INST} Result.from_external_pointer(p) 81 -- elseif llvmis_acast_inst(p).to_boolean then create {IS_ACAST_INST} Result.from_external_pointer(p) 82 -- elseif llvmis_aglobal_variable(p).to_boolean then create {IS_AGLOBAL_VARIABLE} Result.from_external_pointer(p) 83 -- elseif llvmis_avaarg_inst(p).to_boolean then create {IS_AVAARG_INST} Result.from_external_pointer(p) 84 -- elseif llvmis_aundef_value(p).to_boolean then create {IS_AUNDEF_VALUE} Result.from_external_pointer(p) 85 -- elseif llvmis_areturn_inst(p).to_boolean then create {IS_ARETURN_INST} Result.from_external_pointer(p) 86 -- elseif llvmis_aargument(p).to_boolean then create {IS_AARGUMENT} Result.from_external_pointer(p) 87 -- elseif llvmis_ainsert_element_inst(p).to_boolean then create {IS_AINSERT_ELEMENT_INST} Result.from_external_pointer(p) 88 -- elseif llvmis_astore_inst(p).to_boolean then create {IS_ASTORE_INST} Result.from_external_pointer(p) 89 -- elseif llvmis_aallocation_inst(p).to_boolean then create {IS_AALLOCATION_INST} Result.from_external_pointer(p) 90 -- elseif llvmis_aextract_element_inst(p).to_boolean then create {IS_AEXTRACT_ELEMENT_INST} Result.from_external_pointer(p) 91 -- elseif llvmis_aconstant_vector(p).to_boolean then create {IS_ACONSTANT_VECTOR} Result.from_external_pointer(p) 92 -- elseif llvmis_acmp_inst(p).to_boolean then create {IS_ACMP_INST} Result.from_external_pointer(p) 93 -- elseif llvmis_aunwind_inst(p).to_boolean then create {IS_AUNWIND_INST} Result.from_external_pointer(p) 94 -- elseif llvmis_aglobal_value(p).to_boolean then create {IS_AGLOBAL_VALUE} Result.from_external_pointer(p) 95 -- elseif llvmis_amalloc_inst(p).to_boolean then create {IS_AMALLOC_INST} Result.from_external_pointer(p) 96 -- elseif llvmis_adbg_declare_inst(p).to_boolean then create {IS_ADBG_DECLARE_INST} Result.from_external_pointer(p) 97 -- elseif llvmis_afcmp_inst(p).to_boolean then create {IS_AFCMP_INST} Result.from_external_pointer(p) 98 -- elseif llvmis_ainline_asm(p).to_boolean then create {IS_AINLINE_ASM} Result.from_external_pointer(p) 99 -- elseif llvmis_afree_inst(p).to_boolean then create {IS_AFREE_INST} Result.from_external_pointer(p) 100 -- elseif llvmis_aunary_instruction(p).to_boolean then create {IS_AUNARY_INSTRUCTION} Result.from_external_pointer(p) 101 -- elseif llvmis_aconstant_fp(p).to_boolean then create {IS_ACONSTANT_FP} Result.from_external_pointer(p) 102 -- elseif llvmis_aextract_value_inst(p).to_boolean then create {IS_AEXTRACT_VALUE_INST} Result.from_external_pointer(p) 103 -- elseif llvmis_abinary_operator(p).to_boolean then create {IS_ABINARY_OPERATOR} Result.from_external_pointer(p) 104 -- elseif llvmis_amem_intrinsic(p).to_boolean then create {IS_AMEM_INTRINSIC} Result.from_external_pointer(p) 105 -- elseif llvmis_afunction(p).to_boolean then create {IS_AFUNCTION} Result.from_external_pointer(p) 106 -- elseif llvmis_aunreachable_inst(p).to_boolean then create {IS_AUNREACHABLE_INST} Result.from_external_pointer(p) 107 -- elseif llvmis_adbg_info_intrinsic(p).to_boolean then create {IS_ADBG_INFO_INTRINSIC} Result.from_external_pointer(p) 108 -- elseif llvmis_ainsert_value_inst(p).to_boolean then create {IS_AINSERT_VALUE_INST} Result.from_external_pointer(p) 109 -- elseif llvmis_aload_inst(p).to_boolean then create {IS_ALOAD_INST} Result.from_external_pointer(p) 110 -- elseif llvmis_aalloca_inst(p).to_boolean then create {IS_AALLOCA_INST} Result.from_external_pointer(p) 111 -- elseif llvmis_auito_fpinst(p).to_boolean then create {IS_AUITO_FPINST} Result.from_external_pointer(p) 112 -- elseif llvmis_afpext_inst(p).to_boolean then create {IS_AFPEXT_INST} Result.from_external_pointer(p) 113 -- elseif llvmis_aehselector_inst(p).to_boolean then create {IS_AEHSELECTOR_INST} Result.from_external_pointer(p) 114 -- elseif llvmis_adbg_region_start_inst(p).to_boolean then create {IS_ADBG_REGION_START_INST} Result.from_external_pointer(p) 115 -- elseif llvmis_afpto_siinst(p).to_boolean then create {IS_AFPTO_SIINST} Result.from_external_pointer(p) 116 -- elseif llvmis_aconstant_int(p).to_boolean then create {IS_ACONSTANT_INT} Result.from_external_pointer(p) 117 -- elseif llvmis_aconstant_aggregate_zero(p).to_boolean then create {IS_ACONSTANT_AGGREGATE_ZERO} Result.from_external_pointer(p) 118 -- elseif llvmis_aswitch_inst(p).to_boolean then create {IS_ASWITCH_INST} Result.from_external_pointer(p) 119 -- elseif llvmis_aconstant_expr(p).to_boolean then create {IS_ACONSTANT_EXPR} Result.from_external_pointer(p) 120 -- elseif llvmis_asext_inst(p).to_boolean then create {IS_ASEXT_INST} Result.from_external_pointer(p) 121 -- elseif llvmis_ashuffle_vector_inst(p).to_boolean then create {IS_ASHUFFLE_VECTOR_INST} Result.from_external_pointer(p) 122 -- end 123end -- class LLVM_VALUE_WRAPPER_FACTORY 124 125-- Copyright (C) 2009-2017: Paolo Redaelli 126-- This file is part of LLVM wrappers for Liberty Eiffel. 127-- 128-- This library is free software: you can redistribute it and/or modify 129-- it under the terms of the GNU Lesser General Public License as published by 130-- the Free Software Foundation, version 3 of the License. 131-- 132-- Liberty Eiffel is distributed in the hope that it will be useful, 133-- but WITHOUT ANY WARRANTY; without even the implied warranty of 134-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 135-- GNU General Public License for more details. 136-- 137-- You should have received a copy of the GNU General Public License 138-- along with Liberty Eiffel. If not, see <http://www.gnu.org/licenses/>. 139--