ruby-llvm 3.5.0 → 10.0.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.
Files changed (43) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +19 -4
  3. data/ext/ruby-llvm-support/Rakefile +15 -6
  4. data/lib/llvm/analysis_ffi.rb +27 -28
  5. data/lib/llvm/config.rb +4 -4
  6. data/lib/llvm/core.rb +45 -2
  7. data/lib/llvm/core/bitcode.rb +10 -10
  8. data/lib/llvm/core/bitcode_ffi.rb +89 -65
  9. data/lib/llvm/core/builder.rb +2 -3
  10. data/lib/llvm/core/context.rb +1 -1
  11. data/lib/llvm/core/pass_manager.rb +4 -2
  12. data/lib/llvm/core/type.rb +2 -2
  13. data/lib/llvm/core/value.rb +138 -24
  14. data/lib/llvm/core_ffi.rb +3863 -3730
  15. data/lib/llvm/execution_engine.rb +37 -35
  16. data/lib/llvm/execution_engine_ffi.rb +238 -276
  17. data/lib/llvm/linker.rb +1 -14
  18. data/lib/llvm/linker_ffi.rb +22 -26
  19. data/lib/llvm/target.rb +9 -15
  20. data/lib/llvm/target_ffi.rb +301 -293
  21. data/lib/llvm/transforms/builder.rb +1 -1
  22. data/lib/llvm/transforms/builder_ffi.rb +57 -58
  23. data/lib/llvm/transforms/ipo.rb +1 -1
  24. data/lib/llvm/transforms/ipo_ffi.rb +59 -60
  25. data/lib/llvm/transforms/scalar_ffi.rb +199 -143
  26. data/lib/llvm/transforms/vectorize_ffi.rb +15 -16
  27. data/lib/llvm/version.rb +3 -2
  28. data/test/basic_block_test.rb +0 -1
  29. data/test/bitcode_test.rb +1 -2
  30. data/test/call_test.rb +1 -1
  31. data/test/double_test.rb +8 -7
  32. data/test/equality_test.rb +2 -4
  33. data/test/function_test.rb +27 -0
  34. data/test/generic_value_test.rb +1 -1
  35. data/test/instruction_test.rb +0 -2
  36. data/test/ipo_test.rb +1 -1
  37. data/test/linker_test.rb +0 -9
  38. data/test/mcjit_test.rb +3 -3
  39. data/test/module_test.rb +16 -1
  40. data/test/pass_manager_builder_test.rb +1 -2
  41. data/test/target_test.rb +3 -20
  42. data/test/test_helper.rb +4 -1
  43. metadata +55 -37
@@ -9,21 +9,8 @@ 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
- C.link_modules(other, self, :preserve_source, msg)
12
+ C.link_modules2(other, self)
13
13
  end
14
14
  end
15
-
16
- # Link the current module into +other+, and dispose the current module.
17
- #
18
- # @return [nil, String] human-readable error if linking has failed
19
- def link_into_and_destroy(other)
20
- result = LLVM.with_message_output do |msg|
21
- C.link_modules(other, self, :destroy_source, msg)
22
- end
23
-
24
- @ptr = nil
25
-
26
- result
27
- end
28
15
  end
29
16
  end
@@ -4,45 +4,41 @@ require 'ffi'
4
4
 
5
5
  module LLVM::C
6
6
  extend FFI::Library
7
- ffi_lib ["libLLVM-3.5.so.1", "LLVM-3.5"]
8
-
7
+ ffi_lib ["libLLVM-10.so.1", "LLVM-10"]
8
+
9
9
  def self.attach_function(name, *_)
10
10
  begin; super; rescue FFI::NotFoundError => e
11
11
  (class << self; self; end).class_eval { define_method(name) { |*_| raise e } }
12
12
  end
13
13
  end
14
-
15
- # (Not documented)
16
- #
14
+
15
+ # This enum is provided for backwards-compatibility only. It has no effect.
16
+ #
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
20
  # :destroy_source ::
21
- #
22
- # :preserve_source ::
23
- # Allow source module to be destroyed.
24
- #
21
+ #
22
+ # :preserve_source_removed ::
23
+ # This is the default behavior.
24
+ #
25
25
  # @method _enum_linker_mode_
26
26
  # @return [Symbol]
27
27
  # @scope class
28
28
  enum :linker_mode, [
29
29
  :destroy_source, 0,
30
- :preserve_source, 1
30
+ :preserve_source_removed, 1
31
31
  ]
32
-
33
- # Links the source module into the destination module, taking ownership
34
- # of the source module away from the caller. Optionally returns a
35
- # human-readable description of any errors that occurred in linking.
36
- # OutMessage must be disposed with LLVMDisposeMessage. The return value
37
- # is true if an error occurred, false otherwise.
38
- #
39
- # @method link_modules(dest, src, mode, out_message)
40
- # @param [FFI::Pointer(ModuleRef)] dest
41
- # @param [FFI::Pointer(ModuleRef)] src
42
- # @param [Symbol from _enum_linker_mode_] mode
43
- # @param [FFI::Pointer(**CharS)] out_message
44
- # @return [Integer]
32
+
33
+ # Links the source module into the destination module. The source module is
34
+ # destroyed.
35
+ # The return value is true if an error occurred, false otherwise.
36
+ # Use the diagnostic handler to get any diagnostic message.
37
+ #
38
+ # @method link_modules2(dest, src)
39
+ # @param [FFI::Pointer(ModuleRef)] dest
40
+ # @param [FFI::Pointer(ModuleRef)] src
41
+ # @return [Integer]
45
42
  # @scope class
46
- attach_function :link_modules, :LLVMLinkModules, [:pointer, :pointer, :linker_mode, :pointer], :int
47
-
43
+ attach_function :link_modules2, :LLVMLinkModules2, [:pointer, :pointer], :int
48
44
  end
@@ -20,7 +20,7 @@ module LLVM
20
20
  #
21
21
  # @param [String] target Target name in LLVM format, e.g. "X86", "ARM" or "PowerPC".
22
22
  # @param [true, false] asm_printer Initialize corresponding AsmPrinter.
23
- def self.init(target, asm_printer=false)
23
+ def self.init(target, asm_printer = false)
24
24
  C.module_eval do
25
25
  attach_function :"initialize_target_info_#{target}",
26
26
  :"LLVMInitialize#{target}TargetInfo", [], :void
@@ -57,7 +57,7 @@ module LLVM
57
57
  # Initializes all available targets.
58
58
  #
59
59
  # @param [true, false] asm_printer Initialize corresponding AsmPrinters.
60
- def self.init_all(asm_printer=false)
60
+ def self.init_all(asm_printer = false)
61
61
  Support::C.initialize_all_target_infos
62
62
  Support::C.initialize_all_targets
63
63
  Support::C.initialize_all_target_mcs
@@ -68,7 +68,8 @@ module LLVM
68
68
  # Initializes native target. Useful for JIT applications.
69
69
  #
70
70
  # @param [true, false] asm_printer Initialize corresponding AsmPrinter.
71
- def self.init_native(asm_printer=false)
71
+ # True by default, as this is required for MCJIT to function.
72
+ def self.init_native(asm_printer = true)
72
73
  Support::C.initialize_native_target
73
74
 
74
75
  Support::C.initialize_native_asm_printer if asm_printer
@@ -144,8 +145,8 @@ module LLVM
144
145
  # @param [Symbol] reloc :default, :static, :pic, :dynamic_no_pic
145
146
  # @param [Symbol] code_model :default, :jit_default, :small, :kernel, :medium, :large
146
147
  # @return [TargetMachine]
147
- def create_machine(triple, cpu="", features="",
148
- opt_level=:default, reloc=:default, code_model=:default)
148
+ def create_machine(triple, cpu = "", features = "",
149
+ opt_level = :default, reloc = :default, code_model = :default)
149
150
  TargetMachine.from_ptr(C.create_target_machine(self,
150
151
  triple, cpu, features, opt_level, reloc, code_model))
151
152
  end
@@ -191,17 +192,10 @@ module LLVM
191
192
  C.get_target_machine_feature_string(self)
192
193
  end
193
194
 
194
- # Returns the data layout used for this target machine.
195
- #
196
- # @return [TargetDataLayout]
197
- def data_layout
198
- TargetDataLayout.from_ptr(C.get_target_machine_data(self))
199
- end
200
-
201
195
  # Emits an asm or object file for the given module.
202
196
  #
203
197
  # @param [Symbol] codegen :assembly, :object
204
- def emit(mod, filename, codegen=:assembly)
198
+ def emit(mod, filename, codegen = :assembly)
205
199
  LLVM.with_error_output do |err|
206
200
  C.target_machine_emit_to_file(self, mod, filename.to_s, codegen, err)
207
201
  end
@@ -262,14 +256,14 @@ module LLVM
262
256
  # Returns the pointer size in bytes for a target.
263
257
  #
264
258
  # @param [Integer] addr_space address space number
265
- def pointer_size(addr_space=0)
259
+ def pointer_size(addr_space = 0)
266
260
  C.pointer_size_for_as(self, addr_space)
267
261
  end
268
262
 
269
263
  # Returns the integer type that is the same size as a pointer on a target.
270
264
  #
271
265
  # @param [Integer] addr_space address space number
272
- def int_ptr_type(addr_space=0)
266
+ def int_ptr_type(addr_space = 0)
273
267
  Type.from_ptr(C.int_ptr_type_for_as(self, addr_space), :integer)
274
268
  end
275
269
 
@@ -4,24 +4,24 @@ require 'ffi'
4
4
 
5
5
  module LLVM::C
6
6
  extend FFI::Library
7
- ffi_lib ["libLLVM-3.5.so.1", "LLVM-3.5"]
8
-
7
+ ffi_lib ["libLLVM-10.so.1", "LLVM-10"]
8
+
9
9
  def self.attach_function(name, *_)
10
10
  begin; super; rescue FFI::NotFoundError => e
11
11
  (class << self; self; end).class_eval { define_method(name) { |*_| raise e } }
12
12
  end
13
13
  end
14
-
14
+
15
15
  # (Not documented)
16
- #
16
+ #
17
17
  # <em>This entry is only for documentation and no real method. The FFI::Enum can be accessed via #enum_type(:byte_ordering).</em>
18
- #
18
+ #
19
19
  # === Options:
20
20
  # :big_endian ::
21
- #
21
+ #
22
22
  # :little_endian ::
23
- #
24
- #
23
+ #
24
+ #
25
25
  # @method _enum_byte_ordering_
26
26
  # @return [Symbol]
27
27
  # @scope class
@@ -29,315 +29,323 @@ module LLVM::C
29
29
  :big_endian, 0,
30
30
  :little_endian, 1
31
31
  ]
32
-
32
+
33
33
  # (Not documented)
34
34
  class OpaqueTargetData < FFI::Struct
35
35
  layout :dummy, :char
36
36
  end
37
-
37
+
38
38
  # (Not documented)
39
39
  class OpaqueTargetLibraryInfotData < FFI::Struct
40
40
  layout :dummy, :char
41
41
  end
42
-
42
+
43
43
  # (Not documented)
44
- #
44
+ #
45
45
  # @method initialize_all_target_infos()
46
- # @return [nil]
46
+ # @return [nil]
47
47
  # @scope class
48
48
  attach_function :initialize_all_target_infos, :LLVMInitializeAllTargetInfos, [], :void
49
-
49
+
50
50
  # (Not documented)
51
- #
51
+ #
52
52
  # @method initialize_all_targets()
53
- # @return [nil]
53
+ # @return [nil]
54
54
  # @scope class
55
55
  attach_function :initialize_all_targets, :LLVMInitializeAllTargets, [], :void
56
-
56
+
57
57
  # (Not documented)
58
- #
58
+ #
59
59
  # @method initialize_all_target_m_cs()
60
- # @return [nil]
60
+ # @return [nil]
61
61
  # @scope class
62
62
  attach_function :initialize_all_target_m_cs, :LLVMInitializeAllTargetMCs, [], :void
63
-
63
+
64
64
  # (Not documented)
65
- #
65
+ #
66
66
  # @method initialize_all_asm_printers()
67
- # @return [nil]
67
+ # @return [nil]
68
68
  # @scope class
69
69
  attach_function :initialize_all_asm_printers, :LLVMInitializeAllAsmPrinters, [], :void
70
-
70
+
71
71
  # (Not documented)
72
- #
72
+ #
73
73
  # @method initialize_all_asm_parsers()
74
- # @return [nil]
74
+ # @return [nil]
75
75
  # @scope class
76
76
  attach_function :initialize_all_asm_parsers, :LLVMInitializeAllAsmParsers, [], :void
77
-
77
+
78
78
  # (Not documented)
79
- #
79
+ #
80
80
  # @method initialize_all_disassemblers()
81
- # @return [nil]
81
+ # @return [nil]
82
82
  # @scope class
83
83
  attach_function :initialize_all_disassemblers, :LLVMInitializeAllDisassemblers, [], :void
84
-
84
+
85
85
  # (Not documented)
86
- #
86
+ #
87
87
  # @method initialize_native_target()
88
- # @return [Integer]
88
+ # @return [Integer]
89
89
  # @scope class
90
90
  attach_function :initialize_native_target, :LLVMInitializeNativeTarget, [], :int
91
-
91
+
92
92
  # (Not documented)
93
- #
93
+ #
94
94
  # @method initialize_native_asm_parser()
95
- # @return [Integer]
95
+ # @return [Integer]
96
96
  # @scope class
97
97
  attach_function :initialize_native_asm_parser, :LLVMInitializeNativeAsmParser, [], :int
98
-
98
+
99
99
  # (Not documented)
100
- #
100
+ #
101
101
  # @method initialize_native_asm_printer()
102
- # @return [Integer]
102
+ # @return [Integer]
103
103
  # @scope class
104
104
  attach_function :initialize_native_asm_printer, :LLVMInitializeNativeAsmPrinter, [], :int
105
-
105
+
106
106
  # (Not documented)
107
- #
107
+ #
108
108
  # @method initialize_native_disassembler()
109
- # @return [Integer]
109
+ # @return [Integer]
110
110
  # @scope class
111
111
  attach_function :initialize_native_disassembler, :LLVMInitializeNativeDisassembler, [], :int
112
-
112
+
113
113
  # (Not documented)
114
- #
114
+ #
115
+ # @method get_module_data_layout(m)
116
+ # @param [FFI::Pointer(ModuleRef)] m
117
+ # @return [OpaqueTargetData]
118
+ # @scope class
119
+ attach_function :get_module_data_layout, :LLVMGetModuleDataLayout, [:pointer], OpaqueTargetData
120
+
121
+ # (Not documented)
122
+ #
123
+ # @method set_module_data_layout(m, dl)
124
+ # @param [FFI::Pointer(ModuleRef)] m
125
+ # @param [OpaqueTargetData] dl
126
+ # @return [nil]
127
+ # @scope class
128
+ attach_function :set_module_data_layout, :LLVMSetModuleDataLayout, [:pointer, OpaqueTargetData], :void
129
+
130
+ # (Not documented)
131
+ #
115
132
  # @method create_target_data(string_rep)
116
- # @param [String] string_rep
117
- # @return [OpaqueTargetData]
133
+ # @param [String] string_rep
134
+ # @return [OpaqueTargetData]
118
135
  # @scope class
119
136
  attach_function :create_target_data, :LLVMCreateTargetData, [:string], OpaqueTargetData
120
-
137
+
121
138
  # (Not documented)
122
- #
123
- # @method add_target_data(td, pm)
124
- # @param [OpaqueTargetData] td
125
- # @param [FFI::Pointer(PassManagerRef)] pm
126
- # @return [nil]
139
+ #
140
+ # @method dispose_target_data(td)
141
+ # @param [OpaqueTargetData] td
142
+ # @return [nil]
127
143
  # @scope class
128
- attach_function :add_target_data, :LLVMAddTargetData, [OpaqueTargetData, :pointer], :void
129
-
144
+ attach_function :dispose_target_data, :LLVMDisposeTargetData, [OpaqueTargetData], :void
145
+
130
146
  # (Not documented)
131
- #
147
+ #
132
148
  # @method add_target_library_info(tli, pm)
133
- # @param [OpaqueTargetLibraryInfotData] tli
134
- # @param [FFI::Pointer(PassManagerRef)] pm
135
- # @return [nil]
149
+ # @param [OpaqueTargetLibraryInfotData] tli
150
+ # @param [FFI::Pointer(PassManagerRef)] pm
151
+ # @return [nil]
136
152
  # @scope class
137
153
  attach_function :add_target_library_info, :LLVMAddTargetLibraryInfo, [OpaqueTargetLibraryInfotData, :pointer], :void
138
-
154
+
139
155
  # (Not documented)
140
- #
156
+ #
141
157
  # @method copy_string_rep_of_target_data(td)
142
- # @param [OpaqueTargetData] td
143
- # @return [String]
158
+ # @param [OpaqueTargetData] td
159
+ # @return [String]
144
160
  # @scope class
145
161
  attach_function :copy_string_rep_of_target_data, :LLVMCopyStringRepOfTargetData, [OpaqueTargetData], :string
146
-
162
+
147
163
  # (Not documented)
148
- #
164
+ #
149
165
  # @method byte_order(td)
150
- # @param [OpaqueTargetData] td
151
- # @return [Symbol from _enum_byte_ordering_]
166
+ # @param [OpaqueTargetData] td
167
+ # @return [Symbol from _enum_byte_ordering_]
152
168
  # @scope class
153
169
  attach_function :byte_order, :LLVMByteOrder, [OpaqueTargetData], :byte_ordering
154
-
170
+
155
171
  # (Not documented)
156
- #
172
+ #
157
173
  # @method pointer_size(td)
158
- # @param [OpaqueTargetData] td
159
- # @return [Integer]
174
+ # @param [OpaqueTargetData] td
175
+ # @return [Integer]
160
176
  # @scope class
161
177
  attach_function :pointer_size, :LLVMPointerSize, [OpaqueTargetData], :uint
162
-
178
+
163
179
  # (Not documented)
164
- #
180
+ #
165
181
  # @method pointer_size_for_as(td, as)
166
- # @param [OpaqueTargetData] td
167
- # @param [Integer] as
168
- # @return [Integer]
182
+ # @param [OpaqueTargetData] td
183
+ # @param [Integer] as
184
+ # @return [Integer]
169
185
  # @scope class
170
186
  attach_function :pointer_size_for_as, :LLVMPointerSizeForAS, [OpaqueTargetData, :uint], :uint
171
-
187
+
172
188
  # (Not documented)
173
- #
189
+ #
174
190
  # @method int_ptr_type(td)
175
- # @param [OpaqueTargetData] td
176
- # @return [FFI::Pointer(TypeRef)]
191
+ # @param [OpaqueTargetData] td
192
+ # @return [FFI::Pointer(TypeRef)]
177
193
  # @scope class
178
194
  attach_function :int_ptr_type, :LLVMIntPtrType, [OpaqueTargetData], :pointer
179
-
195
+
180
196
  # (Not documented)
181
- #
197
+ #
182
198
  # @method int_ptr_type_for_as(td, as)
183
- # @param [OpaqueTargetData] td
184
- # @param [Integer] as
185
- # @return [FFI::Pointer(TypeRef)]
199
+ # @param [OpaqueTargetData] td
200
+ # @param [Integer] as
201
+ # @return [FFI::Pointer(TypeRef)]
186
202
  # @scope class
187
203
  attach_function :int_ptr_type_for_as, :LLVMIntPtrTypeForAS, [OpaqueTargetData, :uint], :pointer
188
-
204
+
189
205
  # (Not documented)
190
- #
206
+ #
191
207
  # @method int_ptr_type_in_context(c, td)
192
- # @param [FFI::Pointer(ContextRef)] c
193
- # @param [OpaqueTargetData] td
194
- # @return [FFI::Pointer(TypeRef)]
208
+ # @param [FFI::Pointer(ContextRef)] c
209
+ # @param [OpaqueTargetData] td
210
+ # @return [FFI::Pointer(TypeRef)]
195
211
  # @scope class
196
212
  attach_function :int_ptr_type_in_context, :LLVMIntPtrTypeInContext, [:pointer, OpaqueTargetData], :pointer
197
-
213
+
198
214
  # (Not documented)
199
- #
215
+ #
200
216
  # @method int_ptr_type_for_as_in_context(c, td, as)
201
- # @param [FFI::Pointer(ContextRef)] c
202
- # @param [OpaqueTargetData] td
203
- # @param [Integer] as
204
- # @return [FFI::Pointer(TypeRef)]
217
+ # @param [FFI::Pointer(ContextRef)] c
218
+ # @param [OpaqueTargetData] td
219
+ # @param [Integer] as
220
+ # @return [FFI::Pointer(TypeRef)]
205
221
  # @scope class
206
222
  attach_function :int_ptr_type_for_as_in_context, :LLVMIntPtrTypeForASInContext, [:pointer, OpaqueTargetData, :uint], :pointer
207
-
223
+
208
224
  # (Not documented)
209
- #
225
+ #
210
226
  # @method size_of_type_in_bits(td, ty)
211
- # @param [OpaqueTargetData] td
212
- # @param [FFI::Pointer(TypeRef)] ty
213
- # @return [Integer]
227
+ # @param [OpaqueTargetData] td
228
+ # @param [FFI::Pointer(TypeRef)] ty
229
+ # @return [Integer]
214
230
  # @scope class
215
231
  attach_function :size_of_type_in_bits, :LLVMSizeOfTypeInBits, [OpaqueTargetData, :pointer], :ulong_long
216
-
232
+
217
233
  # (Not documented)
218
- #
234
+ #
219
235
  # @method store_size_of_type(td, ty)
220
- # @param [OpaqueTargetData] td
221
- # @param [FFI::Pointer(TypeRef)] ty
222
- # @return [Integer]
236
+ # @param [OpaqueTargetData] td
237
+ # @param [FFI::Pointer(TypeRef)] ty
238
+ # @return [Integer]
223
239
  # @scope class
224
240
  attach_function :store_size_of_type, :LLVMStoreSizeOfType, [OpaqueTargetData, :pointer], :ulong_long
225
-
241
+
226
242
  # (Not documented)
227
- #
243
+ #
228
244
  # @method abi_size_of_type(td, ty)
229
- # @param [OpaqueTargetData] td
230
- # @param [FFI::Pointer(TypeRef)] ty
231
- # @return [Integer]
245
+ # @param [OpaqueTargetData] td
246
+ # @param [FFI::Pointer(TypeRef)] ty
247
+ # @return [Integer]
232
248
  # @scope class
233
249
  attach_function :abi_size_of_type, :LLVMABISizeOfType, [OpaqueTargetData, :pointer], :ulong_long
234
-
250
+
235
251
  # (Not documented)
236
- #
252
+ #
237
253
  # @method abi_alignment_of_type(td, ty)
238
- # @param [OpaqueTargetData] td
239
- # @param [FFI::Pointer(TypeRef)] ty
240
- # @return [Integer]
254
+ # @param [OpaqueTargetData] td
255
+ # @param [FFI::Pointer(TypeRef)] ty
256
+ # @return [Integer]
241
257
  # @scope class
242
258
  attach_function :abi_alignment_of_type, :LLVMABIAlignmentOfType, [OpaqueTargetData, :pointer], :uint
243
-
259
+
244
260
  # (Not documented)
245
- #
261
+ #
246
262
  # @method call_frame_alignment_of_type(td, ty)
247
- # @param [OpaqueTargetData] td
248
- # @param [FFI::Pointer(TypeRef)] ty
249
- # @return [Integer]
263
+ # @param [OpaqueTargetData] td
264
+ # @param [FFI::Pointer(TypeRef)] ty
265
+ # @return [Integer]
250
266
  # @scope class
251
267
  attach_function :call_frame_alignment_of_type, :LLVMCallFrameAlignmentOfType, [OpaqueTargetData, :pointer], :uint
252
-
268
+
253
269
  # (Not documented)
254
- #
270
+ #
255
271
  # @method preferred_alignment_of_type(td, ty)
256
- # @param [OpaqueTargetData] td
257
- # @param [FFI::Pointer(TypeRef)] ty
258
- # @return [Integer]
272
+ # @param [OpaqueTargetData] td
273
+ # @param [FFI::Pointer(TypeRef)] ty
274
+ # @return [Integer]
259
275
  # @scope class
260
276
  attach_function :preferred_alignment_of_type, :LLVMPreferredAlignmentOfType, [OpaqueTargetData, :pointer], :uint
261
-
277
+
262
278
  # (Not documented)
263
- #
279
+ #
264
280
  # @method preferred_alignment_of_global(td, global_var)
265
- # @param [OpaqueTargetData] td
266
- # @param [FFI::Pointer(ValueRef)] global_var
267
- # @return [Integer]
281
+ # @param [OpaqueTargetData] td
282
+ # @param [FFI::Pointer(ValueRef)] global_var
283
+ # @return [Integer]
268
284
  # @scope class
269
285
  attach_function :preferred_alignment_of_global, :LLVMPreferredAlignmentOfGlobal, [OpaqueTargetData, :pointer], :uint
270
-
286
+
271
287
  # (Not documented)
272
- #
288
+ #
273
289
  # @method element_at_offset(td, struct_ty, offset)
274
- # @param [OpaqueTargetData] td
275
- # @param [FFI::Pointer(TypeRef)] struct_ty
276
- # @param [Integer] offset
277
- # @return [Integer]
290
+ # @param [OpaqueTargetData] td
291
+ # @param [FFI::Pointer(TypeRef)] struct_ty
292
+ # @param [Integer] offset
293
+ # @return [Integer]
278
294
  # @scope class
279
295
  attach_function :element_at_offset, :LLVMElementAtOffset, [OpaqueTargetData, :pointer, :ulong_long], :uint
280
-
296
+
281
297
  # (Not documented)
282
- #
298
+ #
283
299
  # @method offset_of_element(td, struct_ty, element)
284
- # @param [OpaqueTargetData] td
285
- # @param [FFI::Pointer(TypeRef)] struct_ty
286
- # @param [Integer] element
287
- # @return [Integer]
300
+ # @param [OpaqueTargetData] td
301
+ # @param [FFI::Pointer(TypeRef)] struct_ty
302
+ # @param [Integer] element
303
+ # @return [Integer]
288
304
  # @scope class
289
305
  attach_function :offset_of_element, :LLVMOffsetOfElement, [OpaqueTargetData, :pointer, :uint], :ulong_long
290
-
291
- # (Not documented)
292
- #
293
- # @method dispose_target_data(td)
294
- # @param [OpaqueTargetData] td
295
- # @return [nil]
296
- # @scope class
297
- attach_function :dispose_target_data, :LLVMDisposeTargetData, [OpaqueTargetData], :void
298
-
306
+
299
307
  # (Not documented)
300
308
  class OpaqueTargetMachine < FFI::Struct
301
309
  layout :dummy, :char
302
310
  end
303
-
311
+
304
312
  # (Not documented)
305
313
  module TargetWrappers
306
- # @return [Integer]
314
+ # @return [Integer]
307
315
  def has_jit()
308
316
  LLVM::C.target_has_jit(self)
309
317
  end
310
-
311
- # @return [Integer]
318
+
319
+ # @return [Integer]
312
320
  def has_target_machine()
313
321
  LLVM::C.target_has_target_machine(self)
314
322
  end
315
-
316
- # @return [Integer]
323
+
324
+ # @return [Integer]
317
325
  def has_asm_backend()
318
326
  LLVM::C.target_has_asm_backend(self)
319
327
  end
320
328
  end
321
-
329
+
322
330
  class Target < FFI::Struct
323
331
  include TargetWrappers
324
332
  layout :dummy, :char
325
333
  end
326
-
334
+
327
335
  # (Not documented)
328
- #
336
+ #
329
337
  # <em>This entry is only for documentation and no real method. The FFI::Enum can be accessed via #enum_type(:code_gen_opt_level).</em>
330
- #
338
+ #
331
339
  # === Options:
332
340
  # :none ::
333
- #
341
+ #
334
342
  # :less ::
335
- #
343
+ #
336
344
  # :default ::
337
- #
345
+ #
338
346
  # :aggressive ::
339
- #
340
- #
347
+ #
348
+ #
341
349
  # @method _enum_code_gen_opt_level_
342
350
  # @return [Symbol]
343
351
  # @scope class
@@ -347,21 +355,21 @@ module LLVM::C
347
355
  :default, 2,
348
356
  :aggressive, 3
349
357
  ]
350
-
358
+
351
359
  # (Not documented)
352
- #
360
+ #
353
361
  # <em>This entry is only for documentation and no real method. The FFI::Enum can be accessed via #enum_type(:reloc_mode).</em>
354
- #
362
+ #
355
363
  # === Options:
356
364
  # :default ::
357
- #
365
+ #
358
366
  # :static ::
359
- #
367
+ #
360
368
  # :pic ::
361
- #
369
+ #
362
370
  # :dynamic_no_pic ::
363
- #
364
- #
371
+ #
372
+ #
365
373
  # @method _enum_reloc_mode_
366
374
  # @return [Symbol]
367
375
  # @scope class
@@ -371,25 +379,25 @@ module LLVM::C
371
379
  :pic, 2,
372
380
  :dynamic_no_pic, 3
373
381
  ]
374
-
382
+
375
383
  # (Not documented)
376
- #
384
+ #
377
385
  # <em>This entry is only for documentation and no real method. The FFI::Enum can be accessed via #enum_type(:code_model).</em>
378
- #
386
+ #
379
387
  # === Options:
380
388
  # :default ::
381
- #
389
+ #
382
390
  # :jit_default ::
383
- #
391
+ #
384
392
  # :small ::
385
- #
393
+ #
386
394
  # :kernel ::
387
- #
395
+ #
388
396
  # :medium ::
389
- #
397
+ #
390
398
  # :large ::
391
- #
392
- #
399
+ #
400
+ #
393
401
  # @method _enum_code_model_
394
402
  # @return [Symbol]
395
403
  # @scope class
@@ -401,17 +409,17 @@ module LLVM::C
401
409
  :medium, 4,
402
410
  :large, 5
403
411
  ]
404
-
412
+
405
413
  # (Not documented)
406
- #
414
+ #
407
415
  # <em>This entry is only for documentation and no real method. The FFI::Enum can be accessed via #enum_type(:code_gen_file_type).</em>
408
- #
416
+ #
409
417
  # === Options:
410
418
  # :assembly ::
411
- #
419
+ #
412
420
  # :object ::
413
- #
414
- #
421
+ #
422
+ #
415
423
  # @method _enum_code_gen_file_type_
416
424
  # @return [Symbol]
417
425
  # @scope class
@@ -419,202 +427,202 @@ module LLVM::C
419
427
  :assembly, 0,
420
428
  :object, 1
421
429
  ]
422
-
430
+
423
431
  # Returns the first llvm::Target in the registered targets list.
424
- #
432
+ #
425
433
  # @method get_first_target()
426
- # @return [Target]
434
+ # @return [Target]
427
435
  # @scope class
428
436
  attach_function :get_first_target, :LLVMGetFirstTarget, [], Target
429
-
437
+
430
438
  # Returns the next llvm::Target given a previous one (or null if there's none)
431
- #
439
+ #
432
440
  # @method get_next_target(t)
433
- # @param [Target] t
434
- # @return [Target]
441
+ # @param [Target] t
442
+ # @return [Target]
435
443
  # @scope class
436
444
  attach_function :get_next_target, :LLVMGetNextTarget, [Target], Target
437
-
445
+
438
446
  # Finds the target corresponding to the given name and stores it in \p T.
439
447
  # Returns 0 on success.
440
- #
448
+ #
441
449
  # @method get_target_from_name(name)
442
- # @param [String] name
443
- # @return [Target]
450
+ # @param [String] name
451
+ # @return [Target]
444
452
  # @scope class
445
453
  attach_function :get_target_from_name, :LLVMGetTargetFromName, [:string], Target
446
-
454
+
447
455
  # Finds the target corresponding to the given triple and stores it in \p T.
448
456
  # Returns 0 on success. Optionally returns any error in ErrorMessage.
449
457
  # Use LLVMDisposeMessage to dispose the message.
450
- #
458
+ #
451
459
  # @method get_target_from_triple(triple, t, error_message)
452
- # @param [String] triple
453
- # @param [FFI::Pointer(*TargetRef)] t
454
- # @param [FFI::Pointer(**CharS)] error_message
455
- # @return [Integer]
460
+ # @param [String] triple
461
+ # @param [FFI::Pointer(*TargetRef)] t
462
+ # @param [FFI::Pointer(**CharS)] error_message
463
+ # @return [Integer]
456
464
  # @scope class
457
465
  attach_function :get_target_from_triple, :LLVMGetTargetFromTriple, [:string, :pointer, :pointer], :int
458
-
466
+
459
467
  # Returns the name of a target. See llvm::Target::getName
460
- #
468
+ #
461
469
  # @method get_target_name(t)
462
- # @param [Target] t
463
- # @return [String]
470
+ # @param [Target] t
471
+ # @return [String]
464
472
  # @scope class
465
473
  attach_function :get_target_name, :LLVMGetTargetName, [Target], :string
466
-
474
+
467
475
  # Returns the description of a target. See llvm::Target::getDescription
468
- #
476
+ #
469
477
  # @method get_target_description(t)
470
- # @param [Target] t
471
- # @return [String]
478
+ # @param [Target] t
479
+ # @return [String]
472
480
  # @scope class
473
481
  attach_function :get_target_description, :LLVMGetTargetDescription, [Target], :string
474
-
482
+
475
483
  # Returns if the target has a JIT
476
- #
484
+ #
477
485
  # @method target_has_jit(t)
478
- # @param [Target] t
479
- # @return [Integer]
486
+ # @param [Target] t
487
+ # @return [Integer]
480
488
  # @scope class
481
489
  attach_function :target_has_jit, :LLVMTargetHasJIT, [Target], :int
482
-
490
+
483
491
  # Returns if the target has a TargetMachine associated
484
- #
492
+ #
485
493
  # @method target_has_target_machine(t)
486
- # @param [Target] t
487
- # @return [Integer]
494
+ # @param [Target] t
495
+ # @return [Integer]
488
496
  # @scope class
489
497
  attach_function :target_has_target_machine, :LLVMTargetHasTargetMachine, [Target], :int
490
-
498
+
491
499
  # Returns if the target as an ASM backend (required for emitting output)
492
- #
500
+ #
493
501
  # @method target_has_asm_backend(t)
494
- # @param [Target] t
495
- # @return [Integer]
502
+ # @param [Target] t
503
+ # @return [Integer]
496
504
  # @scope class
497
505
  attach_function :target_has_asm_backend, :LLVMTargetHasAsmBackend, [Target], :int
498
-
506
+
499
507
  # Creates a new llvm::TargetMachine. See llvm::Target::createTargetMachine
500
- #
508
+ #
501
509
  # @method create_target_machine(t, triple, cpu, features, level, reloc, code_model)
502
- # @param [Target] t
503
- # @param [String] triple
504
- # @param [String] cpu
505
- # @param [String] features
506
- # @param [Symbol from _enum_code_gen_opt_level_] level
507
- # @param [Symbol from _enum_reloc_mode_] reloc
508
- # @param [Symbol from _enum_code_model_] code_model
509
- # @return [OpaqueTargetMachine]
510
+ # @param [Target] t
511
+ # @param [String] triple
512
+ # @param [String] cpu
513
+ # @param [String] features
514
+ # @param [Symbol from _enum_code_gen_opt_level_] level
515
+ # @param [Symbol from _enum_reloc_mode_] reloc
516
+ # @param [Symbol from _enum_code_model_] code_model
517
+ # @return [OpaqueTargetMachine]
510
518
  # @scope class
511
519
  attach_function :create_target_machine, :LLVMCreateTargetMachine, [Target, :string, :string, :string, :code_gen_opt_level, :reloc_mode, :code_model], OpaqueTargetMachine
512
-
520
+
513
521
  # Dispose the LLVMTargetMachineRef instance generated by
514
522
  # LLVMCreateTargetMachine.
515
- #
523
+ #
516
524
  # @method dispose_target_machine(t)
517
- # @param [OpaqueTargetMachine] t
518
- # @return [nil]
525
+ # @param [OpaqueTargetMachine] t
526
+ # @return [nil]
519
527
  # @scope class
520
528
  attach_function :dispose_target_machine, :LLVMDisposeTargetMachine, [OpaqueTargetMachine], :void
521
-
529
+
522
530
  # Returns the Target used in a TargetMachine
523
- #
531
+ #
524
532
  # @method get_target_machine_target(t)
525
- # @param [OpaqueTargetMachine] t
526
- # @return [Target]
533
+ # @param [OpaqueTargetMachine] t
534
+ # @return [Target]
527
535
  # @scope class
528
536
  attach_function :get_target_machine_target, :LLVMGetTargetMachineTarget, [OpaqueTargetMachine], Target
529
-
537
+
530
538
  # Returns the triple used creating this target machine. See
531
539
  # llvm::TargetMachine::getTriple. The result needs to be disposed with
532
540
  # LLVMDisposeMessage.
533
- #
541
+ #
534
542
  # @method get_target_machine_triple(t)
535
- # @param [OpaqueTargetMachine] t
536
- # @return [String]
543
+ # @param [OpaqueTargetMachine] t
544
+ # @return [String]
537
545
  # @scope class
538
546
  attach_function :get_target_machine_triple, :LLVMGetTargetMachineTriple, [OpaqueTargetMachine], :string
539
-
547
+
540
548
  # Returns the cpu used creating this target machine. See
541
549
  # llvm::TargetMachine::getCPU. The result needs to be disposed with
542
550
  # LLVMDisposeMessage.
543
- #
551
+ #
544
552
  # @method get_target_machine_cpu(t)
545
- # @param [OpaqueTargetMachine] t
546
- # @return [String]
553
+ # @param [OpaqueTargetMachine] t
554
+ # @return [String]
547
555
  # @scope class
548
556
  attach_function :get_target_machine_cpu, :LLVMGetTargetMachineCPU, [OpaqueTargetMachine], :string
549
-
557
+
550
558
  # Returns the feature string used creating this target machine. See
551
559
  # llvm::TargetMachine::getFeatureString. The result needs to be disposed with
552
560
  # LLVMDisposeMessage.
553
- #
561
+ #
554
562
  # @method get_target_machine_feature_string(t)
555
- # @param [OpaqueTargetMachine] t
556
- # @return [String]
563
+ # @param [OpaqueTargetMachine] t
564
+ # @return [String]
557
565
  # @scope class
558
566
  attach_function :get_target_machine_feature_string, :LLVMGetTargetMachineFeatureString, [OpaqueTargetMachine], :string
559
-
560
- # Returns the llvm::DataLayout used for this llvm:TargetMachine.
561
- #
562
- # @method get_target_machine_data(t)
563
- # @param [OpaqueTargetMachine] t
564
- # @return [OpaqueTargetData]
565
- # @scope class
566
- attach_function :get_target_machine_data, :LLVMGetTargetMachineData, [OpaqueTargetMachine], OpaqueTargetData
567
-
567
+
568
+ # Create a DataLayout based on the targetMachine.
569
+ #
570
+ # @method create_target_data_layout(t)
571
+ # @param [OpaqueTargetMachine] t
572
+ # @return [OpaqueTargetData]
573
+ # @scope class
574
+ attach_function :create_target_data_layout, :LLVMCreateTargetDataLayout, [OpaqueTargetMachine], OpaqueTargetData
575
+
568
576
  # Set the target machine's ASM verbosity.
569
- #
577
+ #
570
578
  # @method set_target_machine_asm_verbosity(t, verbose_asm)
571
- # @param [OpaqueTargetMachine] t
572
- # @param [Integer] verbose_asm
573
- # @return [nil]
579
+ # @param [OpaqueTargetMachine] t
580
+ # @param [Integer] verbose_asm
581
+ # @return [nil]
574
582
  # @scope class
575
583
  attach_function :set_target_machine_asm_verbosity, :LLVMSetTargetMachineAsmVerbosity, [OpaqueTargetMachine, :int], :void
576
-
584
+
577
585
  # Emits an asm or object file for the given module to the filename. This
578
586
  # wraps several c++ only classes (among them a file stream). Returns any
579
587
  # error in ErrorMessage. Use LLVMDisposeMessage to dispose the message.
580
- #
588
+ #
581
589
  # @method target_machine_emit_to_file(t, m, filename, codegen, error_message)
582
- # @param [OpaqueTargetMachine] t
583
- # @param [FFI::Pointer(ModuleRef)] m
584
- # @param [String] filename
585
- # @param [Symbol from _enum_code_gen_file_type_] codegen
586
- # @param [FFI::Pointer(**CharS)] error_message
587
- # @return [Integer]
590
+ # @param [OpaqueTargetMachine] t
591
+ # @param [FFI::Pointer(ModuleRef)] m
592
+ # @param [String] filename
593
+ # @param [Symbol from _enum_code_gen_file_type_] codegen
594
+ # @param [FFI::Pointer(**CharS)] error_message
595
+ # @return [Integer]
588
596
  # @scope class
589
597
  attach_function :target_machine_emit_to_file, :LLVMTargetMachineEmitToFile, [OpaqueTargetMachine, :pointer, :string, :code_gen_file_type, :pointer], :int
590
-
598
+
591
599
  # Compile the LLVM IR stored in \p M and store the result in \p OutMemBuf.
592
- #
600
+ #
593
601
  # @method target_machine_emit_to_memory_buffer(t, m, codegen, error_message, out_mem_buf)
594
- # @param [OpaqueTargetMachine] t
595
- # @param [FFI::Pointer(ModuleRef)] m
596
- # @param [Symbol from _enum_code_gen_file_type_] codegen
597
- # @param [FFI::Pointer(**CharS)] error_message
598
- # @param [FFI::Pointer(*MemoryBufferRef)] out_mem_buf
599
- # @return [Integer]
602
+ # @param [OpaqueTargetMachine] t
603
+ # @param [FFI::Pointer(ModuleRef)] m
604
+ # @param [Symbol from _enum_code_gen_file_type_] codegen
605
+ # @param [FFI::Pointer(**CharS)] error_message
606
+ # @param [FFI::Pointer(*MemoryBufferRef)] out_mem_buf
607
+ # @return [Integer]
600
608
  # @scope class
601
609
  attach_function :target_machine_emit_to_memory_buffer, :LLVMTargetMachineEmitToMemoryBuffer, [OpaqueTargetMachine, :pointer, :code_gen_file_type, :pointer, :pointer], :int
602
-
610
+
603
611
  # Get a triple for the host machine as a string. The result needs to be
604
612
  # disposed with LLVMDisposeMessage.
605
- #
613
+ #
606
614
  # @method get_default_target_triple()
607
- # @return [String]
615
+ # @return [String]
608
616
  # @scope class
609
617
  attach_function :get_default_target_triple, :LLVMGetDefaultTargetTriple, [], :string
610
-
618
+
611
619
  # Adds the target-specific analysis passes to the pass manager.
612
- #
620
+ #
613
621
  # @method add_analysis_passes(t, pm)
614
- # @param [OpaqueTargetMachine] t
615
- # @param [FFI::Pointer(PassManagerRef)] pm
616
- # @return [nil]
622
+ # @param [OpaqueTargetMachine] t
623
+ # @param [FFI::Pointer(PassManagerRef)] pm
624
+ # @return [nil]
617
625
  # @scope class
618
626
  attach_function :add_analysis_passes, :LLVMAddAnalysisPasses, [OpaqueTargetMachine, :pointer], :void
619
-
627
+
620
628
  end