ruby-llvm 16.0.1 → 18.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/llvm/core_ffi.rb CHANGED
@@ -4,7 +4,7 @@ require 'ffi'
4
4
 
5
5
  module LLVM::C
6
6
  extend FFI::Library
7
- ffi_lib ["libLLVM-16.so.1", "libLLVM.so.16", "LLVM-16"]
7
+ ffi_lib ["libLLVM-18.so.1", "libLLVM.so.18", "LLVM-18"]
8
8
 
9
9
  def self.attach_function(name, *_)
10
10
  begin; super; rescue FFI::NotFoundError => e
@@ -3049,24 +3049,6 @@ module LLVM::C
3049
3049
  # @scope class
3050
3050
  attach_function :const_nuw_mul, :LLVMConstNUWMul, [:pointer, :pointer], :pointer
3051
3051
 
3052
- # (Not documented)
3053
- #
3054
- # @method const_and(lhs_constant, rhs_constant)
3055
- # @param [FFI::Pointer(ValueRef)] lhs_constant
3056
- # @param [FFI::Pointer(ValueRef)] rhs_constant
3057
- # @return [FFI::Pointer(ValueRef)]
3058
- # @scope class
3059
- attach_function :const_and, :LLVMConstAnd, [:pointer, :pointer], :pointer
3060
-
3061
- # (Not documented)
3062
- #
3063
- # @method const_or(lhs_constant, rhs_constant)
3064
- # @param [FFI::Pointer(ValueRef)] lhs_constant
3065
- # @param [FFI::Pointer(ValueRef)] rhs_constant
3066
- # @return [FFI::Pointer(ValueRef)]
3067
- # @scope class
3068
- attach_function :const_or, :LLVMConstOr, [:pointer, :pointer], :pointer
3069
-
3070
3052
  # (Not documented)
3071
3053
  #
3072
3054
  # @method const_xor(lhs_constant, rhs_constant)
@@ -3105,24 +3087,6 @@ module LLVM::C
3105
3087
  # @scope class
3106
3088
  attach_function :const_shl, :LLVMConstShl, [:pointer, :pointer], :pointer
3107
3089
 
3108
- # (Not documented)
3109
- #
3110
- # @method const_l_shr(lhs_constant, rhs_constant)
3111
- # @param [FFI::Pointer(ValueRef)] lhs_constant
3112
- # @param [FFI::Pointer(ValueRef)] rhs_constant
3113
- # @return [FFI::Pointer(ValueRef)]
3114
- # @scope class
3115
- attach_function :const_l_shr, :LLVMConstLShr, [:pointer, :pointer], :pointer
3116
-
3117
- # (Not documented)
3118
- #
3119
- # @method const_a_shr(lhs_constant, rhs_constant)
3120
- # @param [FFI::Pointer(ValueRef)] lhs_constant
3121
- # @param [FFI::Pointer(ValueRef)] rhs_constant
3122
- # @return [FFI::Pointer(ValueRef)]
3123
- # @scope class
3124
- attach_function :const_a_shr, :LLVMConstAShr, [:pointer, :pointer], :pointer
3125
-
3126
3090
  # (Not documented)
3127
3091
  #
3128
3092
  # @method const_gep(constant_val, constant_indices, num_indices)
@@ -3152,78 +3116,6 @@ module LLVM::C
3152
3116
  # @scope class
3153
3117
  attach_function :const_trunc, :LLVMConstTrunc, [:pointer, :pointer], :pointer
3154
3118
 
3155
- # (Not documented)
3156
- #
3157
- # @method const_s_ext(constant_val, to_type)
3158
- # @param [FFI::Pointer(ValueRef)] constant_val
3159
- # @param [FFI::Pointer(TypeRef)] to_type
3160
- # @return [FFI::Pointer(ValueRef)]
3161
- # @scope class
3162
- attach_function :const_s_ext, :LLVMConstSExt, [:pointer, :pointer], :pointer
3163
-
3164
- # (Not documented)
3165
- #
3166
- # @method const_z_ext(constant_val, to_type)
3167
- # @param [FFI::Pointer(ValueRef)] constant_val
3168
- # @param [FFI::Pointer(TypeRef)] to_type
3169
- # @return [FFI::Pointer(ValueRef)]
3170
- # @scope class
3171
- attach_function :const_z_ext, :LLVMConstZExt, [:pointer, :pointer], :pointer
3172
-
3173
- # (Not documented)
3174
- #
3175
- # @method const_fp_trunc(constant_val, to_type)
3176
- # @param [FFI::Pointer(ValueRef)] constant_val
3177
- # @param [FFI::Pointer(TypeRef)] to_type
3178
- # @return [FFI::Pointer(ValueRef)]
3179
- # @scope class
3180
- attach_function :const_fp_trunc, :LLVMConstFPTrunc, [:pointer, :pointer], :pointer
3181
-
3182
- # (Not documented)
3183
- #
3184
- # @method const_fp_ext(constant_val, to_type)
3185
- # @param [FFI::Pointer(ValueRef)] constant_val
3186
- # @param [FFI::Pointer(TypeRef)] to_type
3187
- # @return [FFI::Pointer(ValueRef)]
3188
- # @scope class
3189
- attach_function :const_fp_ext, :LLVMConstFPExt, [:pointer, :pointer], :pointer
3190
-
3191
- # (Not documented)
3192
- #
3193
- # @method const_ui_to_fp(constant_val, to_type)
3194
- # @param [FFI::Pointer(ValueRef)] constant_val
3195
- # @param [FFI::Pointer(TypeRef)] to_type
3196
- # @return [FFI::Pointer(ValueRef)]
3197
- # @scope class
3198
- attach_function :const_ui_to_fp, :LLVMConstUIToFP, [:pointer, :pointer], :pointer
3199
-
3200
- # (Not documented)
3201
- #
3202
- # @method const_si_to_fp(constant_val, to_type)
3203
- # @param [FFI::Pointer(ValueRef)] constant_val
3204
- # @param [FFI::Pointer(TypeRef)] to_type
3205
- # @return [FFI::Pointer(ValueRef)]
3206
- # @scope class
3207
- attach_function :const_si_to_fp, :LLVMConstSIToFP, [:pointer, :pointer], :pointer
3208
-
3209
- # (Not documented)
3210
- #
3211
- # @method const_fp_to_ui(constant_val, to_type)
3212
- # @param [FFI::Pointer(ValueRef)] constant_val
3213
- # @param [FFI::Pointer(TypeRef)] to_type
3214
- # @return [FFI::Pointer(ValueRef)]
3215
- # @scope class
3216
- attach_function :const_fp_to_ui, :LLVMConstFPToUI, [:pointer, :pointer], :pointer
3217
-
3218
- # (Not documented)
3219
- #
3220
- # @method const_fp_to_si(constant_val, to_type)
3221
- # @param [FFI::Pointer(ValueRef)] constant_val
3222
- # @param [FFI::Pointer(TypeRef)] to_type
3223
- # @return [FFI::Pointer(ValueRef)]
3224
- # @scope class
3225
- attach_function :const_fp_to_si, :LLVMConstFPToSI, [:pointer, :pointer], :pointer
3226
-
3227
3119
  # (Not documented)
3228
3120
  #
3229
3121
  # @method const_ptr_to_int(constant_val, to_type)
@@ -3260,24 +3152,6 @@ module LLVM::C
3260
3152
  # @scope class
3261
3153
  attach_function :const_addr_space_cast, :LLVMConstAddrSpaceCast, [:pointer, :pointer], :pointer
3262
3154
 
3263
- # (Not documented)
3264
- #
3265
- # @method const_z_ext_or_bit_cast(constant_val, to_type)
3266
- # @param [FFI::Pointer(ValueRef)] constant_val
3267
- # @param [FFI::Pointer(TypeRef)] to_type
3268
- # @return [FFI::Pointer(ValueRef)]
3269
- # @scope class
3270
- attach_function :const_z_ext_or_bit_cast, :LLVMConstZExtOrBitCast, [:pointer, :pointer], :pointer
3271
-
3272
- # (Not documented)
3273
- #
3274
- # @method const_s_ext_or_bit_cast(constant_val, to_type)
3275
- # @param [FFI::Pointer(ValueRef)] constant_val
3276
- # @param [FFI::Pointer(TypeRef)] to_type
3277
- # @return [FFI::Pointer(ValueRef)]
3278
- # @scope class
3279
- attach_function :const_s_ext_or_bit_cast, :LLVMConstSExtOrBitCast, [:pointer, :pointer], :pointer
3280
-
3281
3155
  # (Not documented)
3282
3156
  #
3283
3157
  # @method const_trunc_or_bit_cast(constant_val, to_type)
@@ -3296,25 +3170,6 @@ module LLVM::C
3296
3170
  # @scope class
3297
3171
  attach_function :const_pointer_cast, :LLVMConstPointerCast, [:pointer, :pointer], :pointer
3298
3172
 
3299
- # (Not documented)
3300
- #
3301
- # @method const_int_cast(constant_val, to_type, is_signed)
3302
- # @param [FFI::Pointer(ValueRef)] constant_val
3303
- # @param [FFI::Pointer(TypeRef)] to_type
3304
- # @param [Integer] is_signed
3305
- # @return [FFI::Pointer(ValueRef)]
3306
- # @scope class
3307
- attach_function :const_int_cast, :LLVMConstIntCast, [:pointer, :pointer, :int], :pointer
3308
-
3309
- # (Not documented)
3310
- #
3311
- # @method const_fp_cast(constant_val, to_type)
3312
- # @param [FFI::Pointer(ValueRef)] constant_val
3313
- # @param [FFI::Pointer(TypeRef)] to_type
3314
- # @return [FFI::Pointer(ValueRef)]
3315
- # @scope class
3316
- attach_function :const_fp_cast, :LLVMConstFPCast, [:pointer, :pointer], :pointer
3317
-
3318
3173
  # (Not documented)
3319
3174
  #
3320
3175
  # @method const_select(constant_condition, constant_if_true, constant_if_false)
@@ -4,7 +4,7 @@ require 'ffi'
4
4
 
5
5
  module LLVM::C
6
6
  extend FFI::Library
7
- ffi_lib ["libLLVM-16.so.1", "libLLVM.so.16", "LLVM-16"]
7
+ ffi_lib ["libLLVM-18.so.1", "libLLVM.so.18", "LLVM-18"]
8
8
 
9
9
  def self.attach_function(name, *_)
10
10
  begin; super; rescue FFI::NotFoundError => e
@@ -4,7 +4,7 @@ require 'ffi'
4
4
 
5
5
  module LLVM::C
6
6
  extend FFI::Library
7
- ffi_lib ["libLLVM-16.so.1", "libLLVM.so.16", "LLVM-16"]
7
+ ffi_lib ["libLLVM-18.so.1", "libLLVM.so.18", "LLVM-18"]
8
8
 
9
9
  def self.attach_function(name, *_)
10
10
  begin; super; rescue FFI::NotFoundError => e
data/lib/llvm/lljit.rb ADDED
@@ -0,0 +1,106 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'llvm/core'
4
+
5
+ module LLVM
6
+ # wrapper around LLVMOrcLLJITRef
7
+ class LLJit
8
+
9
+ # create lljit
10
+ # does not automatically dispose of lljit
11
+ # if lljit was disposed, that would dispose of builder
12
+ def initialize
13
+ builder = C.create_lljit_builder
14
+ FFI::MemoryPointer.new(FFI.type_size(:pointer)) do |ptr|
15
+ error = C.create_lljit(ptr, builder)
16
+ if error.null?
17
+ @ptr = ptr.read_pointer
18
+ else
19
+ message = C.get_error_message(error)
20
+ raise message
21
+ end
22
+ end
23
+ end
24
+
25
+ def triple_string
26
+ C.get_triple_string(ptr)
27
+ end
28
+
29
+ def data_layout
30
+ C.get_data_layout_str(ptr)
31
+ end
32
+
33
+ def global_prefix
34
+ gp = C.get_global_prefix(ptr)
35
+ gp.zero? ? "" : gp.chr
36
+ end
37
+
38
+ private
39
+
40
+ attr_reader :ptr
41
+
42
+ # currently returners pointer
43
+ def main_jit_dylib
44
+ C.main_jit_dylib(ptr)
45
+ end
46
+
47
+ module C
48
+ extend FFI::Library
49
+ ffi_lib_flags(:lazy, :global)
50
+ ffi_lib ["libLLVM-18.so.1", "libLLVM.so.18", "LLVM-18"]
51
+
52
+ attach_function :create_lljit_builder, :LLVMOrcCreateLLJITBuilder, [], :pointer
53
+ attach_function :dispose_lljit_builder, :LLVMOrcDisposeLLJITBuilder, [:pointer], :void
54
+
55
+ # LLVMErrorRef LLVMOrcCreateLLJIT(LLVMOrcLLJITRef *Result, LLVMOrcLLJITBuilderRef Builder);
56
+ attach_function :create_lljit, :LLVMOrcCreateLLJIT, [:pointer, :pointer], :pointer
57
+
58
+ # LLVMErrorRef LLVMOrcDisposeLLJIT(LLVMOrcLLJITRef J);
59
+ attach_function :dispose_lljit, :LLVMOrcDisposeLLJIT, [:pointer], :pointer
60
+
61
+ # const char *LLVMOrcLLJITGetTripleString(LLVMOrcLLJITRef J);
62
+ attach_function :get_triple_string, :LLVMOrcLLJITGetTripleString, [:pointer], :string
63
+
64
+ # const char *LLVMOrcLLJITGetDataLayoutStr(LLVMOrcLLJITRef J);
65
+ attach_function :get_data_layout_str, :LLVMOrcLLJITGetDataLayoutStr, [:pointer], :string
66
+
67
+ # char LLVMOrcLLJITGetGlobalPrefix(LLVMOrcLLJITRef J);
68
+ attach_function :get_global_prefix, :LLVMOrcLLJITGetGlobalPrefix, [:pointer], :char
69
+
70
+ # LLVMOrcJITDylibRef LLVMOrcLLJITGetMainJITDylib(LLVMOrcLLJITRef J);
71
+ attach_function :get_main_jit_dylib, :LLVMOrcLLJITGetMainJITDylib, [:pointer], :pointer
72
+
73
+ # LLVMOrcResourceTrackerRef
74
+ # LLVMOrcJITDylibCreateResourceTracker(LLVMOrcJITDylibRef JD);
75
+ attach_function :dylib_create_resource_tracker, :LLVMOrcJITDylibCreateResourceTracker,
76
+ [:pointer], :pointer
77
+
78
+ # LLVMOrcThreadSafeContextRef LLVMOrcCreateNewThreadSafeContext(void);
79
+ attach_function :create_new_thread_safe_context, :LLVMOrcCreateNewThreadSafeContext,
80
+ [], :pointer
81
+
82
+ # LLVMOrcThreadSafeModuleRef
83
+ # LLVMOrcCreateNewThreadSafeModule(LLVMModuleRef M,
84
+ # LLVMOrcThreadSafeContextRef TSCtx);
85
+ attach_function :create_new_thread_safe_module, :LLVMOrcCreateNewThreadSafeContext,
86
+ [:pointer, :pointer], :pointer
87
+
88
+ # LLVMErrorRef LLVMOrcLLJITAddLLVMIRModule(LLVMOrcLLJITRef J,
89
+ # LLVMOrcJITDylibRef JD,
90
+ # LLVMOrcThreadSafeModuleRef TSM);
91
+ attach_function :add_llvm_ir_module, :LLVMOrcLLJITAddLLVMIRModule,
92
+ [:pointer, :pointer, :pointer], :pointer
93
+
94
+ # LLVMErrorRef LLVMOrcLLJITAddLLVMIRModuleWithRT(LLVMOrcLLJITRef J,
95
+ # LLVMOrcResourceTrackerRef JD,
96
+ # LLVMOrcThreadSafeModuleRef TSM);
97
+ attach_function :add_llvm_ir_module_with_rt, :LLVMOrcLLJITAddLLVMIRModuleWithRT,
98
+ [:pointer, :pointer, :pointer], :pointer
99
+
100
+ # TODO: extract and combine with PassBuilder
101
+ attach_function(:get_error_message, :LLVMGetErrorMessage, [:pointer], :string)
102
+
103
+ attach_function(:dispose_error_message, :LLVMDisposeErrorMessage, [:string], :void)
104
+ end
105
+ end
106
+ end
data/lib/llvm/support.rb CHANGED
@@ -29,6 +29,7 @@ module LLVM
29
29
  :LLVMInitializeNativeAsmPrinter, [], :void
30
30
 
31
31
  attach_function :get_enum_attribute_name_for_kind, :LLVMGetEnumAttributeNameForKind, [:uint], :string
32
+ attach_function :get_attribute_as_string, :LLVMGetAttributeAsString, [:pointer], :string
32
33
  end
33
34
  end
34
35
 
data/lib/llvm/target.rb CHANGED
@@ -25,7 +25,7 @@ module LLVM
25
25
 
26
26
  module TargetModule
27
27
  extend FFI::Library
28
- ffi_lib ["libLLVM-16.so.1", "libLLVM.so.16", "LLVM-16"]
28
+ ffi_lib ["libLLVM-18.so.1", "libLLVM.so.18", "LLVM-18"]
29
29
 
30
30
  def self.safe_attach_function(*args)
31
31
  attach_function(*args)
@@ -4,7 +4,7 @@ require 'ffi'
4
4
 
5
5
  module LLVM::C
6
6
  extend FFI::Library
7
- ffi_lib ["libLLVM-16.so.1", "libLLVM.so.16", "LLVM-16"]
7
+ ffi_lib ["libLLVM-18.so.1", "libLLVM.so.18", "LLVM-18"]
8
8
 
9
9
  def self.attach_function(name, *_)
10
10
  begin; super; rescue FFI::NotFoundError => e
@@ -3,122 +3,116 @@
3
3
  # Interprocedural optimization (IPO)
4
4
  require 'llvm'
5
5
  require 'llvm/core'
6
- require 'llvm/transforms/ipo_ffi'
7
6
 
8
7
  module LLVM
9
8
  class PassManager
10
9
  # @LLVMpass arg_promotion
11
10
  def arg_promote!
12
- warn('arg_promote! / LLVMAddArgumentPromotionPass was removed from LLVM')
11
+ raise DeprecationError
13
12
  end
14
13
 
15
14
  # @LLVMpass const_merge
16
15
  # /** See llvm::createConstantMergePass function. */
17
16
  # void LLVMAddConstantMergePass(LLVMPassManagerRef PM);
18
17
  def const_merge!
19
- C.add_constant_merge_pass(self)
18
+ raise DeprecationError
20
19
  end
21
20
 
22
21
  # @LLVMpass mergefunc
23
22
  # /** See llvm::createMergeFunctionsPass function. */
24
23
  # void LLVMAddMergeFunctionsPass(LLVMPassManagerRef PM);
25
24
  def mergefunc!
26
- C.add_merge_functions_pass(self)
25
+ raise DeprecationError
27
26
  end
28
27
 
29
28
  # @LLVMpass called-value-propagation
30
29
  # /** See llvm::createCalledValuePropagationPass function. */
31
30
  # void LLVMAddCalledValuePropagationPass(LLVMPassManagerRef PM);
32
31
  def called_value_propagation!
33
- C.add_called_value_propagation_pass(self)
32
+ raise DeprecationError
34
33
  end
35
34
 
36
35
  # @LLVMpass dae
37
36
  # /** See llvm::createDeadArgEliminationPass function. */
38
37
  # void LLVMAddDeadArgEliminationPass(LLVMPassManagerRef PM);
39
38
  def dae!
40
- C.add_dead_arg_elimination_pass(self)
39
+ raise DeprecationError
41
40
  end
42
41
 
43
42
  # @LLVMpass function_attrs
44
43
  # /** See llvm::createFunctionAttrsPass function. */
45
44
  # void LLVMAddFunctionAttrsPass(LLVMPassManagerRef PM);
46
45
  def fun_attrs!
47
- C.add_function_attrs_pass(self)
46
+ raise DeprecationError
48
47
  end
49
48
 
50
49
  # @LLVMpass inline
51
50
  # /** See llvm::createFunctionInliningPass function. */
52
51
  # void LLVMAddFunctionInliningPass(LLVMPassManagerRef PM);
53
52
  def inline!
54
- C.add_function_inlining_pass(self)
53
+ raise DeprecationError
55
54
  end
56
55
 
57
56
  # @LLVMpass always_inline
58
57
  # /** See llvm::createAlwaysInlinerPass function. */
59
58
  # void LLVMAddAlwaysInlinerPass(LLVMPassManagerRef PM);
60
59
  def always_inline!
61
- C.add_always_inliner_pass(self)
60
+ raise DeprecationError
62
61
  end
63
62
 
64
63
  # @LLVMpass gdce
65
64
  # /** See llvm::createGlobalDCEPass function. */
66
65
  # void LLVMAddGlobalDCEPass(LLVMPassManagerRef PM);
67
66
  def gdce!
68
- C.add_global_dce_pass(self)
67
+ raise DeprecationError
69
68
  end
70
69
 
71
70
  # @LLVMpass global_opt
72
71
  # /** See llvm::createGlobalOptimizerPass function. */
73
72
  # void LLVMAddGlobalOptimizerPass(LLVMPassManagerRef PM);
74
73
  def global_opt!
75
- C.add_global_optimizer_pass(self)
74
+ raise DeprecationError
76
75
  end
77
76
 
78
77
  # @LLVMpass ipcp
79
78
  def ipcp!
80
- warn('ipcp! / LLVMAddIPConstantPropagationPass was removed from LLVM')
79
+ raise DeprecationError
81
80
  end
82
81
 
83
82
  # @LLVMpass prune_eh
84
83
  # /** See llvm::createPruneEHPass function. */
85
84
  # void LLVMAddPruneEHPass(LLVMPassManagerRef PM);
86
85
  def prune_eh!
87
- warn('prune_eh! / LLVMAddPruneEHPass was removed in LLVM 16')
86
+ raise DeprecationError
88
87
  end
89
88
 
90
89
  # @LLVMpass ipsccp
91
90
  # /** See llvm::createIPSCCPPass function. */
92
91
  # void LLVMAddIPSCCPPass(LLVMPassManagerRef PM);
93
92
  def ipsccp!
94
- C.add_ipsccp_pass(self)
93
+ raise DeprecationError
95
94
  end
96
95
 
97
96
  # @LLVMpass internalize
98
97
  # /** See llvm::createInternalizePass function. */
99
98
  # void LLVMAddInternalizePass(LLVMPassManagerRef, unsigned AllButMain);
100
- def internalize!(all_but_main = true)
101
- C.add_internalize_pass(self, all_but_main ? 1 : 0)
99
+ def internalize!(_all_but_main = true)
100
+ raise DeprecationError
102
101
  end
103
102
 
104
103
  # @LLVMpass sdp
105
104
  # /** See llvm::createStripDeadPrototypesPass function. */
106
105
  # void LLVMAddStripDeadPrototypesPass(LLVMPassManagerRef PM);
107
106
  def sdp!
108
- C.add_strip_dead_prototypes_pass(self)
107
+ raise DeprecationError
109
108
  end
110
109
 
111
110
  # @LLVMpass strip
112
111
  # /** See llvm::createStripSymbolsPass function. */
113
112
  # void LLVMAddStripSymbolsPass(LLVMPassManagerRef PM);
114
113
  def strip!
115
- C.add_strip_symbols_pass(self)
114
+ raise DeprecationError
116
115
  end
117
116
 
118
117
  end
119
-
120
- module C
121
- attach_function :add_merge_functions_pass, :LLVMAddMergeFunctionsPass, [:pointer], :void
122
- attach_function :add_called_value_propagation_pass, :LLVMAddCalledValuePropagationPass, [:pointer], :void
123
- end
124
118
  end