ruby-llvm 3.0.0.beta → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/llvm/support.rb CHANGED
@@ -9,12 +9,12 @@ module LLVM
9
9
  '../',
10
10
  FFI.map_library_name('RubyLLVMSupport-3.0.0')))
11
11
  ffi_lib [support_lib]
12
- attach_function :LLVMLoadLibraryPermanently, [:string], :int
12
+ attach_function :load_library_permanently, :LLVMLoadLibraryPermanently, [:string], :int
13
13
  end
14
14
  end
15
15
 
16
16
  def load_library(libname)
17
- Support::C.LLVMLoadLibraryPermanently(libname)
17
+ Support::C.load_library_permanently(libname)
18
18
  nil
19
19
  end
20
20
 
data/lib/llvm/target.rb CHANGED
@@ -1,9 +1,7 @@
1
1
  require 'llvm'
2
2
  require 'llvm/core'
3
+ require 'llvm/target_ffi'
3
4
 
4
5
  module LLVM
5
- # @private
6
- module C
7
- attach_function :LLVMAddTargetData, [:pointer, :pointer], :void
8
- end
6
+ # nothing here
9
7
  end
@@ -0,0 +1,217 @@
1
+ # Generated by ffi_gen. Please do not change this file by hand.
2
+
3
+ require 'ffi'
4
+
5
+ module LLVM::C
6
+ extend FFI::Library
7
+ ffi_lib 'LLVM-3.0'
8
+
9
+ # (Not documented)
10
+ #
11
+ # === Options:
12
+ # :big ::
13
+ #
14
+ # :little ::
15
+ #
16
+ #
17
+ # @return [Array<Symbol>]
18
+ def self.byte_ordering_enum
19
+ [:big, :little]
20
+ end
21
+ enum :byte_ordering, [
22
+ :big,
23
+ :little
24
+ ]
25
+
26
+ # (Not documented)
27
+ #
28
+ # = Fields:
29
+ #
30
+ class OpaqueTargetData < FFI::Struct
31
+ end
32
+
33
+ # (Not documented)
34
+ #
35
+ # = Fields:
36
+ #
37
+ class OpaqueTargetLibraryInfotData < FFI::Struct
38
+ end
39
+
40
+ # (Not documented)
41
+ #
42
+ # = Fields:
43
+ #
44
+ class StructLayout < FFI::Struct
45
+ end
46
+
47
+ # Creates target data from a target layout string.
48
+ # See the constructor llvm::TargetData::TargetData.
49
+ #
50
+ # @method create_target_data(string_rep)
51
+ # @param [String] string_rep
52
+ # @return [FFI::Pointer(TargetDataRef)]
53
+ # @scope class
54
+ attach_function :create_target_data, :LLVMCreateTargetData, [:string], :pointer
55
+
56
+ # Adds target data information to a pass manager. This does not take ownership
57
+ # of the target data.
58
+ # See the method llvm::PassManagerBase::add.
59
+ #
60
+ # @method add_target_data(target_data_ref, pass_manager_ref)
61
+ # @param [FFI::Pointer(TargetDataRef)] target_data_ref
62
+ # @param [FFI::Pointer(PassManagerRef)] pass_manager_ref
63
+ # @return [nil]
64
+ # @scope class
65
+ attach_function :add_target_data, :LLVMAddTargetData, [:pointer, :pointer], :void
66
+
67
+ # Adds target library information to a pass manager. This does not take
68
+ # ownership of the target library info.
69
+ # See the method llvm::PassManagerBase::add.
70
+ #
71
+ # @method add_target_library_info(target_library_info_ref, pass_manager_ref)
72
+ # @param [FFI::Pointer(TargetLibraryInfoRef)] target_library_info_ref
73
+ # @param [FFI::Pointer(PassManagerRef)] pass_manager_ref
74
+ # @return [nil]
75
+ # @scope class
76
+ attach_function :add_target_library_info, :LLVMAddTargetLibraryInfo, [:pointer, :pointer], :void
77
+
78
+ # Converts target data to a target layout string. The string must be disposed
79
+ # with LLVMDisposeMessage.
80
+ # See the constructor llvm::TargetData::TargetData.
81
+ #
82
+ # @method copy_string_rep_of_target_data(target_data_ref)
83
+ # @param [FFI::Pointer(TargetDataRef)] target_data_ref
84
+ # @return [String]
85
+ # @scope class
86
+ attach_function :copy_string_rep_of_target_data, :LLVMCopyStringRepOfTargetData, [:pointer], :string
87
+
88
+ # Returns the byte order of a target, either LLVMBigEndian or
89
+ # LLVMLittleEndian.
90
+ # See the method llvm::TargetData::isLittleEndian.
91
+ #
92
+ # @method byte_order(target_data_ref)
93
+ # @param [FFI::Pointer(TargetDataRef)] target_data_ref
94
+ # @return [Symbol from byte_ordering_enum]
95
+ # @scope class
96
+ attach_function :byte_order, :LLVMByteOrder, [:pointer], :byte_ordering
97
+
98
+ # Returns the pointer size in bytes for a target.
99
+ # See the method llvm::TargetData::getPointerSize.
100
+ #
101
+ # @method pointer_size(target_data_ref)
102
+ # @param [FFI::Pointer(TargetDataRef)] target_data_ref
103
+ # @return [Integer]
104
+ # @scope class
105
+ attach_function :pointer_size, :LLVMPointerSize, [:pointer], :uint
106
+
107
+ # Returns the integer type that is the same size as a pointer on a target.
108
+ # See the method llvm::TargetData::getIntPtrType.
109
+ #
110
+ # @method int_ptr_type(target_data_ref)
111
+ # @param [FFI::Pointer(TargetDataRef)] target_data_ref
112
+ # @return [FFI::Pointer(TypeRef)]
113
+ # @scope class
114
+ attach_function :int_ptr_type, :LLVMIntPtrType, [:pointer], :pointer
115
+
116
+ # Computes the size of a type in bytes for a target.
117
+ # See the method llvm::TargetData::getTypeSizeInBits.
118
+ #
119
+ # @method size_of_type_in_bits(target_data_ref, type_ref)
120
+ # @param [FFI::Pointer(TargetDataRef)] target_data_ref
121
+ # @param [FFI::Pointer(TypeRef)] type_ref
122
+ # @return [Integer]
123
+ # @scope class
124
+ attach_function :size_of_type_in_bits, :LLVMSizeOfTypeInBits, [:pointer, :pointer], :ulong_long
125
+
126
+ # Computes the storage size of a type in bytes for a target.
127
+ # See the method llvm::TargetData::getTypeStoreSize.
128
+ #
129
+ # @method store_size_of_type(target_data_ref, type_ref)
130
+ # @param [FFI::Pointer(TargetDataRef)] target_data_ref
131
+ # @param [FFI::Pointer(TypeRef)] type_ref
132
+ # @return [Integer]
133
+ # @scope class
134
+ attach_function :store_size_of_type, :LLVMStoreSizeOfType, [:pointer, :pointer], :ulong_long
135
+
136
+ # Computes the ABI size of a type in bytes for a target.
137
+ # See the method llvm::TargetData::getTypeAllocSize.
138
+ #
139
+ # @method abi_size_of_type(target_data_ref, type_ref)
140
+ # @param [FFI::Pointer(TargetDataRef)] target_data_ref
141
+ # @param [FFI::Pointer(TypeRef)] type_ref
142
+ # @return [Integer]
143
+ # @scope class
144
+ attach_function :abi_size_of_type, :LLVMABISizeOfType, [:pointer, :pointer], :ulong_long
145
+
146
+ # Computes the ABI alignment of a type in bytes for a target.
147
+ # See the method llvm::TargetData::getTypeABISize.
148
+ #
149
+ # @method abi_alignment_of_type(target_data_ref, type_ref)
150
+ # @param [FFI::Pointer(TargetDataRef)] target_data_ref
151
+ # @param [FFI::Pointer(TypeRef)] type_ref
152
+ # @return [Integer]
153
+ # @scope class
154
+ attach_function :abi_alignment_of_type, :LLVMABIAlignmentOfType, [:pointer, :pointer], :uint
155
+
156
+ # Computes the call frame alignment of a type in bytes for a target.
157
+ # See the method llvm::TargetData::getTypeABISize.
158
+ #
159
+ # @method call_frame_alignment_of_type(target_data_ref, type_ref)
160
+ # @param [FFI::Pointer(TargetDataRef)] target_data_ref
161
+ # @param [FFI::Pointer(TypeRef)] type_ref
162
+ # @return [Integer]
163
+ # @scope class
164
+ attach_function :call_frame_alignment_of_type, :LLVMCallFrameAlignmentOfType, [:pointer, :pointer], :uint
165
+
166
+ # Computes the preferred alignment of a type in bytes for a target.
167
+ # See the method llvm::TargetData::getTypeABISize.
168
+ #
169
+ # @method preferred_alignment_of_type(target_data_ref, type_ref)
170
+ # @param [FFI::Pointer(TargetDataRef)] target_data_ref
171
+ # @param [FFI::Pointer(TypeRef)] type_ref
172
+ # @return [Integer]
173
+ # @scope class
174
+ attach_function :preferred_alignment_of_type, :LLVMPreferredAlignmentOfType, [:pointer, :pointer], :uint
175
+
176
+ # Computes the preferred alignment of a global variable in bytes for a target.
177
+ # See the method llvm::TargetData::getPreferredAlignment.
178
+ #
179
+ # @method preferred_alignment_of_global(target_data_ref, global_var)
180
+ # @param [FFI::Pointer(TargetDataRef)] target_data_ref
181
+ # @param [FFI::Pointer(ValueRef)] global_var
182
+ # @return [Integer]
183
+ # @scope class
184
+ attach_function :preferred_alignment_of_global, :LLVMPreferredAlignmentOfGlobal, [:pointer, :pointer], :uint
185
+
186
+ # Computes the structure element that contains the byte offset for a target.
187
+ # See the method llvm::StructLayout::getElementContainingOffset.
188
+ #
189
+ # @method element_at_offset(target_data_ref, struct_ty, offset)
190
+ # @param [FFI::Pointer(TargetDataRef)] target_data_ref
191
+ # @param [FFI::Pointer(TypeRef)] struct_ty
192
+ # @param [Integer] offset
193
+ # @return [Integer]
194
+ # @scope class
195
+ attach_function :element_at_offset, :LLVMElementAtOffset, [:pointer, :pointer, :ulong_long], :uint
196
+
197
+ # Computes the byte offset of the indexed struct element for a target.
198
+ # See the method llvm::StructLayout::getElementContainingOffset.
199
+ #
200
+ # @method offset_of_element(target_data_ref, struct_ty, element)
201
+ # @param [FFI::Pointer(TargetDataRef)] target_data_ref
202
+ # @param [FFI::Pointer(TypeRef)] struct_ty
203
+ # @param [Integer] element
204
+ # @return [Integer]
205
+ # @scope class
206
+ attach_function :offset_of_element, :LLVMOffsetOfElement, [:pointer, :pointer, :uint], :ulong_long
207
+
208
+ # Deallocates a TargetData.
209
+ # See the destructor llvm::TargetData::~TargetData.
210
+ #
211
+ # @method dispose_target_data(target_data_ref)
212
+ # @param [FFI::Pointer(TargetDataRef)] target_data_ref
213
+ # @return [nil]
214
+ # @scope class
215
+ attach_function :dispose_target_data, :LLVMDisposeTargetData, [:pointer], :void
216
+
217
+ end
@@ -1,23 +1,18 @@
1
1
  # Interprocedural optimization (IPO)
2
2
  require 'llvm'
3
3
  require 'llvm/core'
4
+ require 'llvm/transforms/ipo_ffi'
4
5
 
5
6
  module LLVM
6
- # @private
7
- module C
8
- attach_function :LLVMAddGlobalDCEPass, [:pointer], :void
9
- attach_function :LLVMAddFunctionInliningPass, [:pointer], :void
10
- end
11
-
12
7
  class PassManager
13
8
  # @LLVMpass gdce
14
9
  def gdce!
15
- C.LLVMAddGlobalDCEPass(self)
10
+ C.add_global_dce_pass(self)
16
11
  end
17
12
 
18
13
  # @LLVMpass inline
19
14
  def inline!
20
- C.LLVMAddFunctionInliningPass(self)
15
+ C.add_function_inlining_pass(self)
21
16
  end
22
17
  end
23
18
  end
@@ -0,0 +1,122 @@
1
+ # Generated by ffi_gen. Please do not change this file by hand.
2
+
3
+ require 'ffi'
4
+
5
+ module LLVM::C
6
+ extend FFI::Library
7
+ ffi_lib 'LLVM-3.0'
8
+
9
+ # (Not documented)
10
+ #
11
+ # @method add_argument_promotion_pass(pm)
12
+ # @param [FFI::Pointer(PassManagerRef)] pm
13
+ # @return [nil]
14
+ # @scope class
15
+ attach_function :add_argument_promotion_pass, :LLVMAddArgumentPromotionPass, [:pointer], :void
16
+
17
+ # See llvm::createConstantMergePass function.
18
+ #
19
+ # @method add_constant_merge_pass(pm)
20
+ # @param [FFI::Pointer(PassManagerRef)] pm
21
+ # @return [nil]
22
+ # @scope class
23
+ attach_function :add_constant_merge_pass, :LLVMAddConstantMergePass, [:pointer], :void
24
+
25
+ # See llvm::createDeadArgEliminationPass function.
26
+ #
27
+ # @method add_dead_arg_elimination_pass(pm)
28
+ # @param [FFI::Pointer(PassManagerRef)] pm
29
+ # @return [nil]
30
+ # @scope class
31
+ attach_function :add_dead_arg_elimination_pass, :LLVMAddDeadArgEliminationPass, [:pointer], :void
32
+
33
+ # See llvm::createFunctionAttrsPass function.
34
+ #
35
+ # @method add_function_attrs_pass(pm)
36
+ # @param [FFI::Pointer(PassManagerRef)] pm
37
+ # @return [nil]
38
+ # @scope class
39
+ attach_function :add_function_attrs_pass, :LLVMAddFunctionAttrsPass, [:pointer], :void
40
+
41
+ # See llvm::createFunctionInliningPass function.
42
+ #
43
+ # @method add_function_inlining_pass(pm)
44
+ # @param [FFI::Pointer(PassManagerRef)] pm
45
+ # @return [nil]
46
+ # @scope class
47
+ attach_function :add_function_inlining_pass, :LLVMAddFunctionInliningPass, [:pointer], :void
48
+
49
+ # See llvm::createAlwaysInlinerPass function.
50
+ #
51
+ # @method add_always_inliner_pass(pm)
52
+ # @param [FFI::Pointer(PassManagerRef)] pm
53
+ # @return [nil]
54
+ # @scope class
55
+ attach_function :add_always_inliner_pass, :LLVMAddAlwaysInlinerPass, [:pointer], :void
56
+
57
+ # See llvm::createGlobalDCEPass function.
58
+ #
59
+ # @method add_global_dce_pass(pm)
60
+ # @param [FFI::Pointer(PassManagerRef)] pm
61
+ # @return [nil]
62
+ # @scope class
63
+ attach_function :add_global_dce_pass, :LLVMAddGlobalDCEPass, [:pointer], :void
64
+
65
+ # See llvm::createGlobalOptimizerPass function.
66
+ #
67
+ # @method add_global_optimizer_pass(pm)
68
+ # @param [FFI::Pointer(PassManagerRef)] pm
69
+ # @return [nil]
70
+ # @scope class
71
+ attach_function :add_global_optimizer_pass, :LLVMAddGlobalOptimizerPass, [:pointer], :void
72
+
73
+ # See llvm::createIPConstantPropagationPass function.
74
+ #
75
+ # @method add_ip_constant_propagation_pass(pm)
76
+ # @param [FFI::Pointer(PassManagerRef)] pm
77
+ # @return [nil]
78
+ # @scope class
79
+ attach_function :add_ip_constant_propagation_pass, :LLVMAddIPConstantPropagationPass, [:pointer], :void
80
+
81
+ # See llvm::createPruneEHPass function.
82
+ #
83
+ # @method add_prune_eh_pass(pm)
84
+ # @param [FFI::Pointer(PassManagerRef)] pm
85
+ # @return [nil]
86
+ # @scope class
87
+ attach_function :add_prune_eh_pass, :LLVMAddPruneEHPass, [:pointer], :void
88
+
89
+ # See llvm::createIPSCCPPass function.
90
+ #
91
+ # @method add_ipsccp_pass(pm)
92
+ # @param [FFI::Pointer(PassManagerRef)] pm
93
+ # @return [nil]
94
+ # @scope class
95
+ attach_function :add_ipsccp_pass, :LLVMAddIPSCCPPass, [:pointer], :void
96
+
97
+ # See llvm::createInternalizePass function.
98
+ #
99
+ # @method add_internalize_pass(pass_manager_ref, all_but_main)
100
+ # @param [FFI::Pointer(PassManagerRef)] pass_manager_ref
101
+ # @param [Integer] all_but_main
102
+ # @return [nil]
103
+ # @scope class
104
+ attach_function :add_internalize_pass, :LLVMAddInternalizePass, [:pointer, :uint], :void
105
+
106
+ # See llvm::createStripDeadPrototypesPass function.
107
+ #
108
+ # @method add_strip_dead_prototypes_pass(pm)
109
+ # @param [FFI::Pointer(PassManagerRef)] pm
110
+ # @return [nil]
111
+ # @scope class
112
+ attach_function :add_strip_dead_prototypes_pass, :LLVMAddStripDeadPrototypesPass, [:pointer], :void
113
+
114
+ # See llvm::createStripSymbolsPass function.
115
+ #
116
+ # @method add_strip_symbols_pass(pm)
117
+ # @param [FFI::Pointer(PassManagerRef)] pm
118
+ # @return [nil]
119
+ # @scope class
120
+ attach_function :add_strip_symbols_pass, :LLVMAddStripSymbolsPass, [:pointer], :void
121
+
122
+ end
@@ -1,136 +1,112 @@
1
1
  require 'llvm'
2
2
  require 'llvm/core'
3
+ require 'llvm/transforms/scalar_ffi'
3
4
 
4
5
  module LLVM
5
- # @private
6
- module C
7
- attach_function :LLVMAddAggressiveDCEPass, [:pointer], :void
8
- attach_function :LLVMAddCFGSimplificationPass, [:pointer], :void
9
- attach_function :LLVMAddDeadStoreEliminationPass, [:pointer], :void
10
- attach_function :LLVMAddGVNPass, [:pointer], :void
11
- attach_function :LLVMAddIndVarSimplifyPass, [:pointer], :void
12
- attach_function :LLVMAddInstructionCombiningPass, [:pointer], :void
13
- attach_function :LLVMAddJumpThreadingPass, [:pointer], :void
14
- attach_function :LLVMAddLICMPass, [:pointer], :void
15
- attach_function :LLVMAddLoopDeletionPass, [:pointer], :void
16
- attach_function :LLVMAddLoopRotatePass, [:pointer], :void
17
- attach_function :LLVMAddLoopUnrollPass, [:pointer], :void
18
- attach_function :LLVMAddLoopUnswitchPass, [:pointer], :void
19
- attach_function :LLVMAddMemCpyOptPass, [:pointer], :void
20
- attach_function :LLVMAddPromoteMemoryToRegisterPass, [:pointer], :void
21
- attach_function :LLVMAddReassociatePass, [:pointer], :void
22
- attach_function :LLVMAddSCCPPass, [:pointer], :void
23
- attach_function :LLVMAddScalarReplAggregatesPass, [:pointer], :void
24
- attach_function :LLVMAddSimplifyLibCallsPass, [:pointer], :void
25
- attach_function :LLVMAddTailCallEliminationPass, [:pointer], :void
26
- attach_function :LLVMAddConstantPropagationPass, [:pointer], :void
27
- attach_function :LLVMAddDemoteMemoryToRegisterPass, [:pointer], :void
28
- end
29
-
30
6
  class PassManager
31
7
  # @LLVMpass adce
32
8
  def adce!
33
- C.LLVMAddAggressiveDCEPass(self)
9
+ C.add_aggressive_dce_pass(self)
34
10
  end
35
11
 
36
12
  # @LLVMpass simplifycfg
37
13
  def simplifycfg!
38
- C.LLVMAddCFGSimplificationPass(self)
14
+ C.add_cfg_simplification_pass(self)
39
15
  end
40
16
 
41
17
  # @LLVMpass dse
42
18
  def dse!
43
- C.LLVMAddDeadStoreEliminationPass(self)
19
+ C.add_dead_store_elimination_pass(self)
44
20
  end
45
21
 
46
22
  # @LLVMpass gvn
47
23
  def gvn!
48
- C.LLVMAddGVNPass(self)
24
+ C.add_gvn_pass(self)
49
25
  end
50
26
 
51
27
  # @LLVMpass indvars
52
28
  def indvars!
53
- C.LLVMAddIndVarSimplifyPass(self)
29
+ C.add_ind_var_simplify_pass(self)
54
30
  end
55
31
 
56
32
  # @LLVMpass instcombine
57
33
  def instcombine!
58
- C.LLVMAddInstructionCombiningPass(self)
34
+ C.add_instruction_combining_pass(self)
59
35
  end
60
36
 
61
37
  # @LLVMpass jump-threading
62
38
  def jump_threading!
63
- C.LLVMAddJumpThreadingPass(self)
39
+ C.add_jump_threading_pass(self)
64
40
  end
65
41
 
66
42
  # @LLVMpass licm
67
43
  def licm!
68
- C.LLVMAddLICMPass(self)
44
+ C.add_licm_pass(self)
69
45
  end
70
46
 
71
47
  # @LLVMpass loop-deletion
72
48
  def loop_deletion!
73
- C.LLVMAddLoopDeletionPass(self)
49
+ C.add_loop_deletion_pass(self)
74
50
  end
75
51
 
76
52
  # @LLVMpass loop-rotate
77
53
  def loop_rotate!
78
- C.LLVMAddLoopRotatePass(self)
54
+ C.add_loop_rotate_pass(self)
79
55
  end
80
56
 
81
57
  # @LLVMpass loop-unroll
82
58
  def loop_unroll!
83
- C.LLVMAddLoopUnrollPass(self)
59
+ C.add_loop_unroll_pass(self)
84
60
  end
85
61
 
86
62
  # @LLVMpass loop-unswitch
87
63
  def loop_unswitch!
88
- C.LLVMAddLoopUnswitchPass(self)
64
+ C.add_loop_unswitch_pass(self)
89
65
  end
90
66
 
91
67
  # @LLVMpass memcpyopt
92
68
  def memcpyopt!
93
- C.LLVMAddMemCpyOptPass(self)
69
+ C.add_mem_cpy_opt_pass(self)
94
70
  end
95
71
 
96
72
  # @LLVMpass mem2reg
97
73
  def mem2reg!
98
- C.LLVMAddPromoteMemoryToRegisterPass(self)
74
+ C.add_promote_memory_to_register_pass(self)
99
75
  end
100
76
 
101
77
  # @LLVMpass reassociate
102
78
  def reassociate!
103
- C.LLVMAddReassociatePass(self)
79
+ C.add_reassociate_pass(self)
104
80
  end
105
81
 
106
82
  # @LLVMpass sccp
107
83
  def sccp!
108
- C.LLVMAddSCCPPass(self)
84
+ C.add_sccp_pass(self)
109
85
  end
110
86
 
111
87
  # @LLVMpass scalarrepl
112
88
  def scalarrepl!
113
- C.LLVMAddScalarReplAggregatesPass(self)
89
+ C.add_scalar_repl_aggregates_pass(self)
114
90
  end
115
91
 
116
92
  # @LLVMpass simplify-libcalls
117
93
  def simplify_libcalls!
118
- C.LLVMAddSimplifyLibCallsPass(self)
94
+ C.add_simplify_lib_calls_pass(self)
119
95
  end
120
96
 
121
97
  # @LLVMpass tailcallelim
122
98
  def tailcallelim!
123
- C.LLVMAddTailCallEliminationPass(self)
99
+ C.add_tail_call_elimination_pass(self)
124
100
  end
125
101
 
126
102
  # @LLVMpass constprop
127
103
  def constprop!
128
- C.LLVMAddConstantPropagationPass(self)
104
+ C.add_constant_propagation_pass(self)
129
105
  end
130
106
 
131
107
  # @LLVMpass reg2mem
132
108
  def reg2mem!
133
- C.LLVMAddDemoteMemoryToRegisterPass(self)
109
+ C.add_demote_memory_to_register_pass(self)
134
110
  end
135
111
  end
136
112
  end