ruby-llvm 3.4.2 → 3.5.0

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.
@@ -49,6 +49,13 @@ module LLVM
49
49
  TargetDataLayout.from_ptr(C.get_execution_engine_target_data(self))
50
50
  end
51
51
 
52
+ # Get the associated target machine.
53
+ #
54
+ # @return [TargetMachine]
55
+ def target_machine
56
+ TargetMachine.from_ptr(C.get_execution_engine_target_machine(self))
57
+ end
58
+
52
59
  # Execute the given LLVM::Function with the supplied args (as
53
60
  # GenericValues).
54
61
  # Important: Call #dispose on the returned GenericValue to
@@ -166,7 +173,7 @@ module LLVM
166
173
  #
167
174
  # @param [LLVM::Module] mod module
168
175
  # @param [Hash{Symbol => Object}] options options
169
- # @option options [Integer] :opt_level (3) Optimization level
176
+ # @option options [Integer] :opt_level (3) Optimization level
170
177
  # @return [ExecutionEngine] Execution engine
171
178
  def initialize(mod, options = {})
172
179
  # Prior to ruby-llvm 3.4.0, signature is initialize(mod, opt_level = 3)
@@ -196,7 +203,7 @@ module LLVM
196
203
  #
197
204
  # @param [LLVM::Module] mod module
198
205
  # @param [Hash{Symbol => Object}] options options
199
- # @option options [Integer] :opt_level (2) Optimization level
206
+ # @option options [Integer] :opt_level (2) Optimization level
200
207
  # @option options [Integer] :code_model (0) Code model types
201
208
  # @option options [Boolean] :no_frame_pointer_elim (false) Disable frame pointer elimination optimization
202
209
  # @option options [Boolean] :enable_fast_i_sel (false) Enables fast-path instruction selection
@@ -4,7 +4,7 @@ require 'ffi'
4
4
 
5
5
  module LLVM::C
6
6
  extend FFI::Library
7
- ffi_lib 'LLVM-3.4'
7
+ ffi_lib ["libLLVM-3.5.so.1", "LLVM-3.5"]
8
8
 
9
9
  def self.attach_function(name, *_)
10
10
  begin; super; rescue FFI::NotFoundError => e
@@ -12,7 +12,10 @@ module LLVM::C
12
12
  end
13
13
  end
14
14
 
15
- # (Not documented)
15
+ # @defgroup LLVMCExecutionEngine Execution Engine
16
+ # @ingroup LLVMC
17
+ #
18
+ # @{
16
19
  #
17
20
  # @method link_in_jit()
18
21
  # @return [nil]
@@ -358,6 +361,14 @@ module LLVM::C
358
361
  # @scope class
359
362
  attach_function :get_execution_engine_target_data, :LLVMGetExecutionEngineTargetData, [OpaqueExecutionEngine], :pointer
360
363
 
364
+ # (Not documented)
365
+ #
366
+ # @method get_execution_engine_target_machine(ee)
367
+ # @param [OpaqueExecutionEngine] ee
368
+ # @return [FFI::Pointer(TargetMachineRef)]
369
+ # @scope class
370
+ attach_function :get_execution_engine_target_machine, :LLVMGetExecutionEngineTargetMachine, [OpaqueExecutionEngine], :pointer
371
+
361
372
  # (Not documented)
362
373
  #
363
374
  # @method add_global_mapping(ee, global, addr)
@@ -9,11 +9,7 @@ module LLVM
9
9
  # @return [nil, String] human-readable error if linking has failed
10
10
  def link_into(other)
11
11
  LLVM.with_message_output do |msg|
12
- # HACK ALERT: ffi-gen missed LLVMLinkerPreserveSource enumeration for
13
- # some reason. It is inlined as a constant here.
14
-
15
- # C.link_modules(mod, self, :linker_preserve_source, msg)
16
- C.link_modules(other, self, 1, msg)
12
+ C.link_modules(other, self, :preserve_source, msg)
17
13
  end
18
14
  end
19
15
 
@@ -22,7 +18,7 @@ module LLVM
22
18
  # @return [nil, String] human-readable error if linking has failed
23
19
  def link_into_and_destroy(other)
24
20
  result = LLVM.with_message_output do |msg|
25
- C.link_modules(other, self, :linker_destroy_source, msg)
21
+ C.link_modules(other, self, :destroy_source, msg)
26
22
  end
27
23
 
28
24
  @ptr = nil
@@ -30,4 +26,4 @@ module LLVM
30
26
  result
31
27
  end
32
28
  end
33
- end
29
+ end
@@ -4,7 +4,7 @@ require 'ffi'
4
4
 
5
5
  module LLVM::C
6
6
  extend FFI::Library
7
- ffi_lib 'LLVM-3.4'
7
+ ffi_lib ["libLLVM-3.5.so.1", "LLVM-3.5"]
8
8
 
9
9
  def self.attach_function(name, *_)
10
10
  begin; super; rescue FFI::NotFoundError => e
@@ -17,14 +17,17 @@ module LLVM::C
17
17
  # <em>This entry is only for documentation and no real method. The FFI::Enum can be accessed via #enum_type(:linker_mode).</em>
18
18
  #
19
19
  # === Options:
20
- # :linker_destroy_source ::
20
+ # :destroy_source ::
21
21
  #
22
+ # :preserve_source ::
23
+ # Allow source module to be destroyed.
22
24
  #
23
25
  # @method _enum_linker_mode_
24
26
  # @return [Symbol]
25
27
  # @scope class
26
28
  enum :linker_mode, [
27
- :linker_destroy_source, 0
29
+ :destroy_source, 0,
30
+ :preserve_source, 1
28
31
  ]
29
32
 
30
33
  # Links the source module into the destination module, taking ownership
@@ -1,5 +1,4 @@
1
1
  require 'llvm/core_ffi'
2
- require 'llvm/support_ffi'
3
2
 
4
3
  module LLVM
5
4
 
@@ -9,17 +8,10 @@ module LLVM
9
8
  module C
10
9
  extend FFI::Library
11
10
 
12
- OpaqueValue = LLVM::C::OpaqueValue
13
- OpaqueType = LLVM::C::OpaqueType
14
- OpaqueModule = LLVM::C::OpaqueModule
15
-
16
11
  lib_name = FFI.map_library_name("RubyLLVMSupport-#{LLVM_VERSION}")
17
12
  lib_path = File.expand_path("../../ext/ruby-llvm-support/#{lib_name}", File.dirname(__FILE__))
18
13
  ffi_lib [lib_path]
19
14
 
20
- attach_function :has_unnamed_addr, :LLVMHasUnnamedAddr, [OpaqueValue], :int
21
- attach_function :set_unnamed_addr, :LLVMSetUnnamedAddr, [OpaqueValue, :int], :void
22
-
23
15
  attach_function :initialize_all_target_infos,
24
16
  :LLVMInitializeAllTargetInfos, [], :void
25
17
  attach_function :initialize_all_targets,
@@ -4,7 +4,7 @@ require 'ffi'
4
4
 
5
5
  module LLVM::C
6
6
  extend FFI::Library
7
- ffi_lib 'LLVM-3.4'
7
+ ffi_lib ["libLLVM-3.5.so.1", "LLVM-3.5"]
8
8
 
9
9
  def self.attach_function(name, *_)
10
10
  begin; super; rescue FFI::NotFoundError => e
@@ -47,89 +47,70 @@ module LLVM::C
47
47
  # @scope class
48
48
  attach_function :initialize_all_target_infos, :LLVMInitializeAllTargetInfos, [], :void
49
49
 
50
- # LLVMInitializeAllTargets - The main program should call this function if it
51
- # wants to link in all available targets that LLVM is configured to
52
- # support.
50
+ # (Not documented)
53
51
  #
54
52
  # @method initialize_all_targets()
55
53
  # @return [nil]
56
54
  # @scope class
57
55
  attach_function :initialize_all_targets, :LLVMInitializeAllTargets, [], :void
58
56
 
59
- # LLVMInitializeAllTargetMCs - The main program should call this function if
60
- # it wants access to all available target MC that LLVM is configured to
61
- # support.
57
+ # (Not documented)
62
58
  #
63
59
  # @method initialize_all_target_m_cs()
64
60
  # @return [nil]
65
61
  # @scope class
66
62
  attach_function :initialize_all_target_m_cs, :LLVMInitializeAllTargetMCs, [], :void
67
63
 
68
- # LLVMInitializeAllAsmPrinters - The main program should call this function if
69
- # it wants all asm printers that LLVM is configured to support, to make them
70
- # available via the TargetRegistry.
64
+ # (Not documented)
71
65
  #
72
66
  # @method initialize_all_asm_printers()
73
67
  # @return [nil]
74
68
  # @scope class
75
69
  attach_function :initialize_all_asm_printers, :LLVMInitializeAllAsmPrinters, [], :void
76
70
 
77
- # LLVMInitializeAllAsmParsers - The main program should call this function if
78
- # it wants all asm parsers that LLVM is configured to support, to make them
79
- # available via the TargetRegistry.
71
+ # (Not documented)
80
72
  #
81
73
  # @method initialize_all_asm_parsers()
82
74
  # @return [nil]
83
75
  # @scope class
84
76
  attach_function :initialize_all_asm_parsers, :LLVMInitializeAllAsmParsers, [], :void
85
77
 
86
- # LLVMInitializeAllDisassemblers - The main program should call this function
87
- # if it wants all disassemblers that LLVM is configured to support, to make
88
- # them available via the TargetRegistry.
78
+ # (Not documented)
89
79
  #
90
80
  # @method initialize_all_disassemblers()
91
81
  # @return [nil]
92
82
  # @scope class
93
83
  attach_function :initialize_all_disassemblers, :LLVMInitializeAllDisassemblers, [], :void
94
84
 
95
- # LLVMInitializeNativeTarget - The main program should call this function to
96
- # initialize the native target corresponding to the host. This is useful
97
- # for JIT applications to ensure that the target gets linked in correctly.
85
+ # (Not documented)
98
86
  #
99
87
  # @method initialize_native_target()
100
88
  # @return [Integer]
101
89
  # @scope class
102
90
  attach_function :initialize_native_target, :LLVMInitializeNativeTarget, [], :int
103
91
 
104
- # LLVMInitializeNativeTargetAsmParser - The main program should call this
105
- # function to initialize the parser for the native target corresponding to the
106
- # host.
92
+ # (Not documented)
107
93
  #
108
94
  # @method initialize_native_asm_parser()
109
95
  # @return [Integer]
110
96
  # @scope class
111
97
  attach_function :initialize_native_asm_parser, :LLVMInitializeNativeAsmParser, [], :int
112
98
 
113
- # LLVMInitializeNativeTargetAsmPrinter - The main program should call this
114
- # function to initialize the printer for the native target corresponding to
115
- # the host.
99
+ # (Not documented)
116
100
  #
117
101
  # @method initialize_native_asm_printer()
118
102
  # @return [Integer]
119
103
  # @scope class
120
104
  attach_function :initialize_native_asm_printer, :LLVMInitializeNativeAsmPrinter, [], :int
121
105
 
122
- # LLVMInitializeNativeTargetDisassembler - The main program should call this
123
- # function to initialize the disassembler for the native target corresponding
124
- # to the host.
106
+ # (Not documented)
125
107
  #
126
108
  # @method initialize_native_disassembler()
127
109
  # @return [Integer]
128
110
  # @scope class
129
111
  attach_function :initialize_native_disassembler, :LLVMInitializeNativeDisassembler, [], :int
130
112
 
131
- # Creates target data from a target layout string.
132
- # See the constructor llvm::DataLayout::DataLayout.
113
+ # (Not documented)
133
114
  #
134
115
  # @method create_target_data(string_rep)
135
116
  # @param [String] string_rep
@@ -137,9 +118,7 @@ module LLVM::C
137
118
  # @scope class
138
119
  attach_function :create_target_data, :LLVMCreateTargetData, [:string], OpaqueTargetData
139
120
 
140
- # Adds target data information to a pass manager. This does not take ownership
141
- # of the target data.
142
- # See the method llvm::PassManagerBase::add.
121
+ # (Not documented)
143
122
  #
144
123
  # @method add_target_data(td, pm)
145
124
  # @param [OpaqueTargetData] td
@@ -148,9 +127,7 @@ module LLVM::C
148
127
  # @scope class
149
128
  attach_function :add_target_data, :LLVMAddTargetData, [OpaqueTargetData, :pointer], :void
150
129
 
151
- # Adds target library information to a pass manager. This does not take
152
- # ownership of the target library info.
153
- # See the method llvm::PassManagerBase::add.
130
+ # (Not documented)
154
131
  #
155
132
  # @method add_target_library_info(tli, pm)
156
133
  # @param [OpaqueTargetLibraryInfotData] tli
@@ -159,9 +136,7 @@ module LLVM::C
159
136
  # @scope class
160
137
  attach_function :add_target_library_info, :LLVMAddTargetLibraryInfo, [OpaqueTargetLibraryInfotData, :pointer], :void
161
138
 
162
- # Converts target data to a target layout string. The string must be disposed
163
- # with LLVMDisposeMessage.
164
- # See the constructor llvm::DataLayout::DataLayout.
139
+ # (Not documented)
165
140
  #
166
141
  # @method copy_string_rep_of_target_data(td)
167
142
  # @param [OpaqueTargetData] td
@@ -169,9 +144,7 @@ module LLVM::C
169
144
  # @scope class
170
145
  attach_function :copy_string_rep_of_target_data, :LLVMCopyStringRepOfTargetData, [OpaqueTargetData], :string
171
146
 
172
- # Returns the byte order of a target, either LLVMBigEndian or
173
- # LLVMLittleEndian.
174
- # See the method llvm::DataLayout::isLittleEndian.
147
+ # (Not documented)
175
148
  #
176
149
  # @method byte_order(td)
177
150
  # @param [OpaqueTargetData] td
@@ -179,8 +152,7 @@ module LLVM::C
179
152
  # @scope class
180
153
  attach_function :byte_order, :LLVMByteOrder, [OpaqueTargetData], :byte_ordering
181
154
 
182
- # Returns the pointer size in bytes for a target.
183
- # See the method llvm::DataLayout::getPointerSize.
155
+ # (Not documented)
184
156
  #
185
157
  # @method pointer_size(td)
186
158
  # @param [OpaqueTargetData] td
@@ -188,9 +160,7 @@ module LLVM::C
188
160
  # @scope class
189
161
  attach_function :pointer_size, :LLVMPointerSize, [OpaqueTargetData], :uint
190
162
 
191
- # Returns the pointer size in bytes for a target for a specified
192
- # address space.
193
- # See the method llvm::DataLayout::getPointerSize.
163
+ # (Not documented)
194
164
  #
195
165
  # @method pointer_size_for_as(td, as)
196
166
  # @param [OpaqueTargetData] td
@@ -199,8 +169,7 @@ module LLVM::C
199
169
  # @scope class
200
170
  attach_function :pointer_size_for_as, :LLVMPointerSizeForAS, [OpaqueTargetData, :uint], :uint
201
171
 
202
- # Returns the integer type that is the same size as a pointer on a target.
203
- # See the method llvm::DataLayout::getIntPtrType.
172
+ # (Not documented)
204
173
  #
205
174
  # @method int_ptr_type(td)
206
175
  # @param [OpaqueTargetData] td
@@ -208,9 +177,7 @@ module LLVM::C
208
177
  # @scope class
209
178
  attach_function :int_ptr_type, :LLVMIntPtrType, [OpaqueTargetData], :pointer
210
179
 
211
- # Returns the integer type that is the same size as a pointer on a target.
212
- # This version allows the address space to be specified.
213
- # See the method llvm::DataLayout::getIntPtrType.
180
+ # (Not documented)
214
181
  #
215
182
  # @method int_ptr_type_for_as(td, as)
216
183
  # @param [OpaqueTargetData] td
@@ -219,8 +186,7 @@ module LLVM::C
219
186
  # @scope class
220
187
  attach_function :int_ptr_type_for_as, :LLVMIntPtrTypeForAS, [OpaqueTargetData, :uint], :pointer
221
188
 
222
- # Returns the integer type that is the same size as a pointer on a target.
223
- # See the method llvm::DataLayout::getIntPtrType.
189
+ # (Not documented)
224
190
  #
225
191
  # @method int_ptr_type_in_context(c, td)
226
192
  # @param [FFI::Pointer(ContextRef)] c
@@ -229,9 +195,7 @@ module LLVM::C
229
195
  # @scope class
230
196
  attach_function :int_ptr_type_in_context, :LLVMIntPtrTypeInContext, [:pointer, OpaqueTargetData], :pointer
231
197
 
232
- # Returns the integer type that is the same size as a pointer on a target.
233
- # This version allows the address space to be specified.
234
- # See the method llvm::DataLayout::getIntPtrType.
198
+ # (Not documented)
235
199
  #
236
200
  # @method int_ptr_type_for_as_in_context(c, td, as)
237
201
  # @param [FFI::Pointer(ContextRef)] c
@@ -241,8 +205,7 @@ module LLVM::C
241
205
  # @scope class
242
206
  attach_function :int_ptr_type_for_as_in_context, :LLVMIntPtrTypeForASInContext, [:pointer, OpaqueTargetData, :uint], :pointer
243
207
 
244
- # Computes the size of a type in bytes for a target.
245
- # See the method llvm::DataLayout::getTypeSizeInBits.
208
+ # (Not documented)
246
209
  #
247
210
  # @method size_of_type_in_bits(td, ty)
248
211
  # @param [OpaqueTargetData] td
@@ -251,8 +214,7 @@ module LLVM::C
251
214
  # @scope class
252
215
  attach_function :size_of_type_in_bits, :LLVMSizeOfTypeInBits, [OpaqueTargetData, :pointer], :ulong_long
253
216
 
254
- # Computes the storage size of a type in bytes for a target.
255
- # See the method llvm::DataLayout::getTypeStoreSize.
217
+ # (Not documented)
256
218
  #
257
219
  # @method store_size_of_type(td, ty)
258
220
  # @param [OpaqueTargetData] td
@@ -261,8 +223,7 @@ module LLVM::C
261
223
  # @scope class
262
224
  attach_function :store_size_of_type, :LLVMStoreSizeOfType, [OpaqueTargetData, :pointer], :ulong_long
263
225
 
264
- # Computes the ABI size of a type in bytes for a target.
265
- # See the method llvm::DataLayout::getTypeAllocSize.
226
+ # (Not documented)
266
227
  #
267
228
  # @method abi_size_of_type(td, ty)
268
229
  # @param [OpaqueTargetData] td
@@ -271,8 +232,7 @@ module LLVM::C
271
232
  # @scope class
272
233
  attach_function :abi_size_of_type, :LLVMABISizeOfType, [OpaqueTargetData, :pointer], :ulong_long
273
234
 
274
- # Computes the ABI alignment of a type in bytes for a target.
275
- # See the method llvm::DataLayout::getTypeABISize.
235
+ # (Not documented)
276
236
  #
277
237
  # @method abi_alignment_of_type(td, ty)
278
238
  # @param [OpaqueTargetData] td
@@ -281,8 +241,7 @@ module LLVM::C
281
241
  # @scope class
282
242
  attach_function :abi_alignment_of_type, :LLVMABIAlignmentOfType, [OpaqueTargetData, :pointer], :uint
283
243
 
284
- # Computes the call frame alignment of a type in bytes for a target.
285
- # See the method llvm::DataLayout::getTypeABISize.
244
+ # (Not documented)
286
245
  #
287
246
  # @method call_frame_alignment_of_type(td, ty)
288
247
  # @param [OpaqueTargetData] td
@@ -291,8 +250,7 @@ module LLVM::C
291
250
  # @scope class
292
251
  attach_function :call_frame_alignment_of_type, :LLVMCallFrameAlignmentOfType, [OpaqueTargetData, :pointer], :uint
293
252
 
294
- # Computes the preferred alignment of a type in bytes for a target.
295
- # See the method llvm::DataLayout::getTypeABISize.
253
+ # (Not documented)
296
254
  #
297
255
  # @method preferred_alignment_of_type(td, ty)
298
256
  # @param [OpaqueTargetData] td
@@ -301,8 +259,7 @@ module LLVM::C
301
259
  # @scope class
302
260
  attach_function :preferred_alignment_of_type, :LLVMPreferredAlignmentOfType, [OpaqueTargetData, :pointer], :uint
303
261
 
304
- # Computes the preferred alignment of a global variable in bytes for a target.
305
- # See the method llvm::DataLayout::getPreferredAlignment.
262
+ # (Not documented)
306
263
  #
307
264
  # @method preferred_alignment_of_global(td, global_var)
308
265
  # @param [OpaqueTargetData] td
@@ -311,8 +268,7 @@ module LLVM::C
311
268
  # @scope class
312
269
  attach_function :preferred_alignment_of_global, :LLVMPreferredAlignmentOfGlobal, [OpaqueTargetData, :pointer], :uint
313
270
 
314
- # Computes the structure element that contains the byte offset for a target.
315
- # See the method llvm::StructLayout::getElementContainingOffset.
271
+ # (Not documented)
316
272
  #
317
273
  # @method element_at_offset(td, struct_ty, offset)
318
274
  # @param [OpaqueTargetData] td
@@ -322,8 +278,7 @@ module LLVM::C
322
278
  # @scope class
323
279
  attach_function :element_at_offset, :LLVMElementAtOffset, [OpaqueTargetData, :pointer, :ulong_long], :uint
324
280
 
325
- # Computes the byte offset of the indexed struct element for a target.
326
- # See the method llvm::StructLayout::getElementContainingOffset.
281
+ # (Not documented)
327
282
  #
328
283
  # @method offset_of_element(td, struct_ty, element)
329
284
  # @param [OpaqueTargetData] td
@@ -333,8 +288,7 @@ module LLVM::C
333
288
  # @scope class
334
289
  attach_function :offset_of_element, :LLVMOffsetOfElement, [OpaqueTargetData, :pointer, :uint], :ulong_long
335
290
 
336
- # Deallocates a TargetData.
337
- # See the destructor llvm::DataLayout::~DataLayout.
291
+ # (Not documented)
338
292
  #
339
293
  # @method dispose_target_data(td)
340
294
  # @param [OpaqueTargetData] td
@@ -349,14 +303,17 @@ module LLVM::C
349
303
 
350
304
  # (Not documented)
351
305
  module TargetWrappers
306
+ # @return [Integer]
352
307
  def has_jit()
353
308
  LLVM::C.target_has_jit(self)
354
309
  end
355
310
 
311
+ # @return [Integer]
356
312
  def has_target_machine()
357
313
  LLVM::C.target_has_target_machine(self)
358
314
  end
359
315
 
316
+ # @return [Integer]
360
317
  def has_asm_backend()
361
318
  LLVM::C.target_has_asm_backend(self)
362
319
  end
@@ -478,7 +435,7 @@ module LLVM::C
478
435
  # @scope class
479
436
  attach_function :get_next_target, :LLVMGetNextTarget, [Target], Target
480
437
 
481
- # Finds the target corresponding to the given name and stores it in \p T.
438
+ # Finds the target corresponding to the given name and stores it in \p T.
482
439
  # Returns 0 on success.
483
440
  #
484
441
  # @method get_target_from_name(name)
@@ -651,4 +608,13 @@ module LLVM::C
651
608
  # @scope class
652
609
  attach_function :get_default_target_triple, :LLVMGetDefaultTargetTriple, [], :string
653
610
 
611
+ # Adds the target-specific analysis passes to the pass manager.
612
+ #
613
+ # @method add_analysis_passes(t, pm)
614
+ # @param [OpaqueTargetMachine] t
615
+ # @param [FFI::Pointer(PassManagerRef)] pm
616
+ # @return [nil]
617
+ # @scope class
618
+ attach_function :add_analysis_passes, :LLVMAddAnalysisPasses, [OpaqueTargetMachine, :pointer], :void
619
+
654
620
  end