ruby-llvm 15.0.1 → 15.0.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.
- checksums.yaml +4 -4
- data/ext/ruby-llvm-support/Rakefile +1 -1
- data/lib/llvm/core/builder.rb +8 -8
- data/lib/llvm/core/pass_manager.rb +5 -0
- data/lib/llvm/core/type.rb +40 -3
- data/lib/llvm/core/value.rb +2 -2
- data/lib/llvm/core.rb +32 -0
- data/lib/llvm/core_ffi.rb +0 -20
- data/lib/llvm/transforms/ipo.rb +48 -4
- data/lib/llvm/transforms/ipo_ffi.rb +0 -16
- data/lib/llvm/transforms/scalar.rb +177 -15
- data/lib/llvm/transforms/scalar_ffi.rb +0 -24
- data/lib/llvm/transforms/utils.rb +34 -0
- data/lib/llvm/transforms/vectorize.rb +6 -1
- data/lib/llvm/version.rb +1 -1
- metadata +3 -3
- data/lib/llvm/core/opaque_pointer_builder.rb +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97fcfaf90ca0b317eef7e65c6b9da2429b0660c6b44f4758a88c4a13e8c5358f
|
4
|
+
data.tar.gz: ab7fd16b1a16d13992c7e697fba953304d9080869312656a558a5a4c4c3b9880
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be57e114f0c66e4cd720526258ccc9e5b0245d6f608d804b3aad877d74a21e8aaecfc74d9b0936cadefc9c4c09ae9feb6ed570b9f264e82ccd700e96386e0e3c
|
7
|
+
data.tar.gz: 80350a8cc8d9a6a34d338fb167604f1e44f2c7c6ea4aaee760f6fe818af08f90c9e8c750fcdc462f460a9a1137ec30e404ad9e9a5f3591a2ed2c2590b7f61cb6
|
@@ -77,7 +77,7 @@ desc "Build the shared library and config module"
|
|
77
77
|
task :default => [SUPPORT_LIB, CONFIG_MOD]
|
78
78
|
|
79
79
|
file SUPPORT_LIB => %w(support.cpp) do |task|
|
80
|
-
clang_stdlib = CXX
|
80
|
+
clang_stdlib = CXX.match?(/^clang++/) ? "-stdlib=libc++" : ""
|
81
81
|
sh "#{CXX} -O3 -shared #{task.prerequisites.join(' ')} -l#{llvm_lib_name} " \
|
82
82
|
"#{invoke_llvm_config('--cxxflags --ldflags')} -fPIC #{clang_stdlib} -o #{SUPPORT_LIB}"
|
83
83
|
end
|
data/lib/llvm/core/builder.rb
CHANGED
@@ -1070,20 +1070,20 @@ module LLVM
|
|
1070
1070
|
|
1071
1071
|
private
|
1072
1072
|
|
1073
|
-
|
1073
|
+
def must_be_value!(value)
|
1074
1074
|
raise "must be a Value, got #{value.class.name}" unless Value === value
|
1075
1075
|
end
|
1076
1076
|
|
1077
|
-
|
1077
|
+
def must_be_type!(type)
|
1078
1078
|
type2 = LLVM.Type(type)
|
1079
1079
|
raise "must be a Type (LLVMTypeRef), got #{type2.class.name}" unless Type === type2
|
1080
1080
|
end
|
1081
1081
|
|
1082
|
-
|
1082
|
+
def must_infer_type!(value)
|
1083
1083
|
infer_type(value)
|
1084
1084
|
end
|
1085
1085
|
|
1086
|
-
|
1086
|
+
def infer_type(ptr)
|
1087
1087
|
case ptr
|
1088
1088
|
when GlobalVariable
|
1089
1089
|
Type.from_ptr(C.global_get_value_type(ptr))
|
@@ -1094,7 +1094,7 @@ module LLVM
|
|
1094
1094
|
end
|
1095
1095
|
end
|
1096
1096
|
|
1097
|
-
|
1097
|
+
def must_infer_instruction_type!(ptr)
|
1098
1098
|
case ptr.opcode
|
1099
1099
|
when :get_element_ptr
|
1100
1100
|
must_infer_gep!(ptr)
|
@@ -1107,7 +1107,7 @@ module LLVM
|
|
1107
1107
|
end
|
1108
1108
|
end
|
1109
1109
|
|
1110
|
-
|
1110
|
+
def must_infer_gep!(ptr)
|
1111
1111
|
source_type = Type.from_ptr(C.get_gep_source_element_type(ptr))
|
1112
1112
|
case source_type.kind
|
1113
1113
|
when :integer
|
@@ -1121,7 +1121,7 @@ module LLVM
|
|
1121
1121
|
end
|
1122
1122
|
end
|
1123
1123
|
|
1124
|
-
|
1124
|
+
def element_error(vector, idx)
|
1125
1125
|
if !vector.is_a?(LLVM::Value)
|
1126
1126
|
"non-value: #{vector.inspect}"
|
1127
1127
|
elsif vector.type.kind != :vector
|
@@ -1131,7 +1131,7 @@ module LLVM
|
|
1131
1131
|
end
|
1132
1132
|
end
|
1133
1133
|
|
1134
|
-
|
1134
|
+
def value_error(aggregate, idx)
|
1135
1135
|
if !aggregate.is_a?(LLVM::Value)
|
1136
1136
|
"non-value: #{aggregate.inspect}"
|
1137
1137
|
# TODO: fix this
|
@@ -1,5 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "llvm/transforms/ipo"
|
4
|
+
require "llvm/transforms/scalar"
|
5
|
+
require "llvm/transforms/utils"
|
6
|
+
require "llvm/transforms/vectorize"
|
7
|
+
|
3
8
|
module LLVM
|
4
9
|
# The PassManager runs a queue of passes on a module. See
|
5
10
|
# http://llvm.org/docs/Passes.html for the list of available passes.
|
data/lib/llvm/core/type.rb
CHANGED
@@ -79,18 +79,47 @@ module LLVM
|
|
79
79
|
[:struct, :array].include?(kind)
|
80
80
|
end
|
81
81
|
|
82
|
+
def opaque_struct?
|
83
|
+
C.is_opaque_struct(self)
|
84
|
+
end
|
85
|
+
|
86
|
+
def packed_struct?
|
87
|
+
C.is_packed_struct(self)
|
88
|
+
end
|
89
|
+
|
90
|
+
def literal_struct?
|
91
|
+
C.is_literal_struct(self)
|
92
|
+
end
|
93
|
+
|
82
94
|
# Creates an array type of Type with the given size.
|
95
|
+
# arrays can be size >= 0, https://llvm.org/docs/LangRef.html#array-type
|
83
96
|
def self.array(ty, sz = 0)
|
97
|
+
sz = sz.to_i
|
98
|
+
raise ArgumentError, "LLVM Array size must be >= 0" if sz.negative?
|
99
|
+
|
84
100
|
from_ptr(C.array_type(LLVM::Type(ty), sz), :array)
|
85
101
|
end
|
86
102
|
|
87
103
|
# Creates the pointer type of Type with the given address space.
|
88
|
-
def self.pointer(ty, address_space = 0)
|
89
|
-
|
104
|
+
def self.pointer(ty = nil, address_space = 0)
|
105
|
+
if ty
|
106
|
+
from_ptr(C.pointer_type(LLVM::Type(ty), address_space), :pointer)
|
107
|
+
else
|
108
|
+
ptr(address_space)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
# opaque pointer
|
113
|
+
def self.ptr(address_space = 0)
|
114
|
+
from_ptr(C.pointer_type(void, address_space), :pointer)
|
90
115
|
end
|
91
116
|
|
92
117
|
# Creates a vector type of Type with the given element count.
|
118
|
+
# vectors can be size > 0, https://llvm.org/docs/LangRef.html#vector-type
|
93
119
|
def self.vector(ty, element_count)
|
120
|
+
element_count = element_count.to_i
|
121
|
+
raise ArgumentError, "LLVM Vector size must be > 0" unless element_count.positive?
|
122
|
+
|
94
123
|
from_ptr(C.vector_type(LLVM::Type(ty), element_count), :vector)
|
95
124
|
end
|
96
125
|
|
@@ -117,6 +146,14 @@ module LLVM
|
|
117
146
|
end
|
118
147
|
end
|
119
148
|
|
149
|
+
def self.opaque_struct(name)
|
150
|
+
from_ptr(C.struct_create_named(Context.global, name.to_s), :struct)
|
151
|
+
end
|
152
|
+
|
153
|
+
def self.named(name)
|
154
|
+
from_ptr(C.get_type_by_name2(Context.global, name.to_s), nil)
|
155
|
+
end
|
156
|
+
|
120
157
|
# Creates a void type.
|
121
158
|
def self.void
|
122
159
|
from_ptr(C.void_type, :void)
|
@@ -217,7 +254,7 @@ module LLVM
|
|
217
254
|
end
|
218
255
|
|
219
256
|
# Shortcut to Type.pointer.
|
220
|
-
def Pointer(ty)
|
257
|
+
def Pointer(ty = nil)
|
221
258
|
LLVM::Type.pointer(ty)
|
222
259
|
end
|
223
260
|
|
data/lib/llvm/core/value.rb
CHANGED
@@ -291,7 +291,7 @@ module LLVM
|
|
291
291
|
module Support
|
292
292
|
def allocate_pointers(size_or_values, &block)
|
293
293
|
if size_or_values.is_a?(Integer)
|
294
|
-
raise ArgumentError, 'block not given' unless
|
294
|
+
raise ArgumentError, 'block not given' unless block
|
295
295
|
size = size_or_values
|
296
296
|
values = (0...size).map { |i| yield i }
|
297
297
|
else
|
@@ -832,7 +832,7 @@ module LLVM
|
|
832
832
|
|
833
833
|
def attribute_name(attr_name)
|
834
834
|
attr_name = attr_name.to_s
|
835
|
-
if
|
835
|
+
if /_attribute$/.match?(attr_name)
|
836
836
|
attr_name.chomp('_attribute').tr('_', '')
|
837
837
|
else
|
838
838
|
attr_name
|
data/lib/llvm/core.rb
CHANGED
@@ -102,6 +102,38 @@ module LLVM
|
|
102
102
|
|
103
103
|
# LLVMValueRef LLVMGetAggregateElement(LLVMValueRef C, unsigned Idx);
|
104
104
|
attach_function :get_aggregate_element, :LLVMGetAggregateElement, [:pointer, :int], :pointer
|
105
|
+
|
106
|
+
attach_function :get_type_by_name2, :LLVMGetTypeByName2, [:pointer, :string], :pointer
|
107
|
+
|
108
|
+
# Determine whether a structure is packed.
|
109
|
+
#
|
110
|
+
# @see llvm::StructType::isPacked()
|
111
|
+
#
|
112
|
+
# @method is_packed_struct(struct_ty)
|
113
|
+
# @param [FFI::Pointer(TypeRef)] struct_ty
|
114
|
+
# @return [Bool]
|
115
|
+
# @scope class
|
116
|
+
attach_function :is_packed_struct, :LLVMIsPackedStruct, [:pointer], :bool
|
117
|
+
|
118
|
+
# Determine whether a structure is opaque.
|
119
|
+
#
|
120
|
+
# @see llvm::StructType::isOpaque()
|
121
|
+
#
|
122
|
+
# @method is_opaque_struct(struct_ty)
|
123
|
+
# @param [FFI::Pointer(TypeRef)] struct_ty
|
124
|
+
# @return [Bool]
|
125
|
+
# @scope class
|
126
|
+
attach_function :is_opaque_struct, :LLVMIsOpaqueStruct, [:pointer], :bool
|
127
|
+
|
128
|
+
# Determine whether a structure is literal.
|
129
|
+
#
|
130
|
+
# @see llvm::StructType::isLiteral()
|
131
|
+
#
|
132
|
+
# @method is_literal_struct(struct_ty)
|
133
|
+
# @param [FFI::Pointer(TypeRef)] struct_ty
|
134
|
+
# @return [Bool]
|
135
|
+
# @scope class
|
136
|
+
attach_function :is_literal_struct, :LLVMIsLiteralStruct, [:pointer], :bool
|
105
137
|
end
|
106
138
|
|
107
139
|
# Yields a pointer suitable for storing an LLVM output message.
|
data/lib/llvm/core_ffi.rb
CHANGED
@@ -1651,26 +1651,6 @@ module LLVM::C
|
|
1651
1651
|
# @scope class
|
1652
1652
|
attach_function :struct_get_type_at_index, :LLVMStructGetTypeAtIndex, [:pointer, :uint], :pointer
|
1653
1653
|
|
1654
|
-
# Determine whether a structure is packed.
|
1655
|
-
#
|
1656
|
-
# @see llvm::StructType::isPacked()
|
1657
|
-
#
|
1658
|
-
# @method is_packed_struct(struct_ty)
|
1659
|
-
# @param [FFI::Pointer(TypeRef)] struct_ty
|
1660
|
-
# @return [Integer]
|
1661
|
-
# @scope class
|
1662
|
-
attach_function :is_packed_struct, :LLVMIsPackedStruct, [:pointer], :int
|
1663
|
-
|
1664
|
-
# Determine whether a structure is opaque.
|
1665
|
-
#
|
1666
|
-
# @see llvm::StructType::isOpaque()
|
1667
|
-
#
|
1668
|
-
# @method is_opaque_struct(struct_ty)
|
1669
|
-
# @param [FFI::Pointer(TypeRef)] struct_ty
|
1670
|
-
# @return [Integer]
|
1671
|
-
# @scope class
|
1672
|
-
attach_function :is_opaque_struct, :LLVMIsOpaqueStruct, [:pointer], :int
|
1673
|
-
|
1674
1654
|
# Obtain the type of elements within a sequential type.
|
1675
1655
|
#
|
1676
1656
|
# This works on array, vector, and pointer types.
|
data/lib/llvm/transforms/ipo.rb
CHANGED
@@ -9,72 +9,116 @@ module LLVM
|
|
9
9
|
class PassManager
|
10
10
|
# @LLVMpass arg_promotion
|
11
11
|
def arg_promote!
|
12
|
-
|
12
|
+
warn('arg_promote! / LLVMAddArgumentPromotionPass was removed from LLVM')
|
13
13
|
end
|
14
14
|
|
15
15
|
# @LLVMpass const_merge
|
16
|
+
# /** See llvm::createConstantMergePass function. */
|
17
|
+
# void LLVMAddConstantMergePass(LLVMPassManagerRef PM);
|
16
18
|
def const_merge!
|
17
19
|
C.add_constant_merge_pass(self)
|
18
20
|
end
|
19
21
|
|
22
|
+
# @LLVMpass mergefunc
|
23
|
+
# /** See llvm::createMergeFunctionsPass function. */
|
24
|
+
# void LLVMAddMergeFunctionsPass(LLVMPassManagerRef PM);
|
25
|
+
def mergefunc!
|
26
|
+
C.add_merge_functions_pass(self)
|
27
|
+
end
|
28
|
+
|
29
|
+
# @LLVMpass called-value-propagation
|
30
|
+
# /** See llvm::createCalledValuePropagationPass function. */
|
31
|
+
# void LLVMAddCalledValuePropagationPass(LLVMPassManagerRef PM);
|
32
|
+
def called_value_propagation!
|
33
|
+
C.add_called_value_propagation_pass(self)
|
34
|
+
end
|
35
|
+
|
20
36
|
# @LLVMpass dae
|
37
|
+
# /** See llvm::createDeadArgEliminationPass function. */
|
38
|
+
# void LLVMAddDeadArgEliminationPass(LLVMPassManagerRef PM);
|
21
39
|
def dae!
|
22
|
-
C.
|
40
|
+
C.add_dead_arg_elimination_pass(self)
|
23
41
|
end
|
24
42
|
|
25
43
|
# @LLVMpass function_attrs
|
44
|
+
# /** See llvm::createFunctionAttrsPass function. */
|
45
|
+
# void LLVMAddFunctionAttrsPass(LLVMPassManagerRef PM);
|
26
46
|
def fun_attrs!
|
27
47
|
C.add_function_attrs_pass(self)
|
28
48
|
end
|
29
49
|
|
30
50
|
# @LLVMpass inline
|
51
|
+
# /** See llvm::createFunctionInliningPass function. */
|
52
|
+
# void LLVMAddFunctionInliningPass(LLVMPassManagerRef PM);
|
31
53
|
def inline!
|
32
54
|
C.add_function_inlining_pass(self)
|
33
55
|
end
|
34
56
|
|
35
57
|
# @LLVMpass always_inline
|
58
|
+
# /** See llvm::createAlwaysInlinerPass function. */
|
59
|
+
# void LLVMAddAlwaysInlinerPass(LLVMPassManagerRef PM);
|
36
60
|
def always_inline!
|
37
61
|
C.add_always_inliner_pass(self)
|
38
62
|
end
|
39
63
|
|
40
64
|
# @LLVMpass gdce
|
65
|
+
# /** See llvm::createGlobalDCEPass function. */
|
66
|
+
# void LLVMAddGlobalDCEPass(LLVMPassManagerRef PM);
|
41
67
|
def gdce!
|
42
68
|
C.add_global_dce_pass(self)
|
43
69
|
end
|
44
70
|
|
45
71
|
# @LLVMpass global_opt
|
72
|
+
# /** See llvm::createGlobalOptimizerPass function. */
|
73
|
+
# void LLVMAddGlobalOptimizerPass(LLVMPassManagerRef PM);
|
46
74
|
def global_opt!
|
47
75
|
C.add_global_optimizer_pass(self)
|
48
76
|
end
|
49
77
|
|
50
78
|
# @LLVMpass ipcp
|
51
79
|
def ipcp!
|
52
|
-
|
80
|
+
warn('ipcp! / LLVMAddIPConstantPropagationPass was removed from LLVM')
|
53
81
|
end
|
54
82
|
|
55
83
|
# @LLVMpass prune_eh
|
84
|
+
# /** See llvm::createPruneEHPass function. */
|
85
|
+
# void LLVMAddPruneEHPass(LLVMPassManagerRef PM);
|
56
86
|
def prune_eh!
|
57
87
|
C.add_prune_eh_pass(self)
|
58
88
|
end
|
59
89
|
|
60
90
|
# @LLVMpass ipsccp
|
91
|
+
# /** See llvm::createIPSCCPPass function. */
|
92
|
+
# void LLVMAddIPSCCPPass(LLVMPassManagerRef PM);
|
61
93
|
def ipsccp!
|
62
94
|
C.add_ipsccp_pass(self)
|
63
95
|
end
|
64
96
|
|
65
97
|
# @LLVMpass internalize
|
98
|
+
# /** See llvm::createInternalizePass function. */
|
99
|
+
# void LLVMAddInternalizePass(LLVMPassManagerRef, unsigned AllButMain);
|
66
100
|
def internalize!(all_but_main = true)
|
67
|
-
C.add_internalize_pass(self, all_but_main)
|
101
|
+
C.add_internalize_pass(self, all_but_main ? 1 : 0)
|
68
102
|
end
|
69
103
|
|
70
104
|
# @LLVMpass sdp
|
105
|
+
# /** See llvm::createStripDeadPrototypesPass function. */
|
106
|
+
# void LLVMAddStripDeadPrototypesPass(LLVMPassManagerRef PM);
|
71
107
|
def sdp!
|
72
108
|
C.add_strip_dead_prototypes_pass(self)
|
73
109
|
end
|
74
110
|
|
75
111
|
# @LLVMpass strip
|
112
|
+
# /** See llvm::createStripSymbolsPass function. */
|
113
|
+
# void LLVMAddStripSymbolsPass(LLVMPassManagerRef PM);
|
76
114
|
def strip!
|
77
115
|
C.add_strip_symbols_pass(self)
|
78
116
|
end
|
117
|
+
|
118
|
+
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
|
79
123
|
end
|
80
124
|
end
|
@@ -12,14 +12,6 @@ module LLVM::C
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
# See llvm::createArgumentPromotionPass function.
|
16
|
-
#
|
17
|
-
# @method add_argument_promotion_pass(pm)
|
18
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
19
|
-
# @return [nil]
|
20
|
-
# @scope class
|
21
|
-
attach_function :add_argument_promotion_pass, :LLVMAddArgumentPromotionPass, [:pointer], :void
|
22
|
-
|
23
15
|
# See llvm::createConstantMergePass function.
|
24
16
|
#
|
25
17
|
# @method add_constant_merge_pass(pm)
|
@@ -76,14 +68,6 @@ module LLVM::C
|
|
76
68
|
# @scope class
|
77
69
|
attach_function :add_global_optimizer_pass, :LLVMAddGlobalOptimizerPass, [:pointer], :void
|
78
70
|
|
79
|
-
# See llvm::createIPConstantPropagationPass function.
|
80
|
-
#
|
81
|
-
# @method add_ip_constant_propagation_pass(pm)
|
82
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
83
|
-
# @return [nil]
|
84
|
-
# @scope class
|
85
|
-
attach_function :add_ip_constant_propagation_pass, :LLVMAddIPConstantPropagationPass, [:pointer], :void
|
86
|
-
|
87
71
|
# See llvm::createPruneEHPass function.
|
88
72
|
#
|
89
73
|
# @method add_prune_eh_pass(pm)
|
@@ -7,158 +7,320 @@ require 'llvm/transforms/scalar_ffi'
|
|
7
7
|
module LLVM
|
8
8
|
class PassManager
|
9
9
|
# @LLVMpass adce
|
10
|
+
# /** See llvm::createAggressiveDCEPass function. */
|
11
|
+
# void LLVMAddAggressiveDCEPass(LLVMPassManagerRef PM);
|
10
12
|
def adce!
|
11
13
|
C.add_aggressive_dce_pass(self)
|
12
14
|
end
|
13
15
|
|
16
|
+
# @LLVMpass dce
|
17
|
+
# /** See llvm::createDeadCodeEliminationPass function. */
|
18
|
+
# void LLVMAddDCEPass(LLVMPassManagerRef PM);
|
19
|
+
def dce!
|
20
|
+
C.add_dce_pass(self)
|
21
|
+
end
|
22
|
+
|
23
|
+
# @LLVMpass bdce
|
24
|
+
# /** See llvm::createBitTrackingDCEPass function. */
|
25
|
+
# void LLVMAddBitTrackingDCEPass(LLVMPassManagerRef PM);
|
26
|
+
def bdce!
|
27
|
+
C.add_bit_tracking_dce_pass(self)
|
28
|
+
end
|
29
|
+
|
30
|
+
# @LLVMpass alignment_from_assumptions
|
31
|
+
# /** See llvm::createAlignmentFromAssumptionsPass function. */
|
32
|
+
# void LLVMAddAlignmentFromAssumptionsPass(LLVMPassManagerRef PM);
|
33
|
+
def alignment_from_assumptions!
|
34
|
+
C.add_alignment_from_assumptions_pass(self)
|
35
|
+
end
|
36
|
+
|
14
37
|
# @LLVMpass simplifycfg
|
38
|
+
# /** See llvm::createCFGSimplificationPass function. */
|
39
|
+
# void LLVMAddCFGSimplificationPass(LLVMPassManagerRef PM);
|
15
40
|
def simplifycfg!
|
16
41
|
C.add_cfg_simplification_pass(self)
|
17
42
|
end
|
18
43
|
|
19
44
|
# @LLVMpass dse
|
45
|
+
# /** See llvm::createDeadStoreEliminationPass function. */
|
46
|
+
# void LLVMAddDeadStoreEliminationPass(LLVMPassManagerRef PM);
|
20
47
|
def dse!
|
21
48
|
C.add_dead_store_elimination_pass(self)
|
22
49
|
end
|
23
50
|
|
51
|
+
# @LLVMPass scalarizer
|
52
|
+
# /** See llvm::createScalarizerPass function. */
|
53
|
+
# void LLVMAddScalarizerPass(LLVMPassManagerRef PM);
|
54
|
+
def scalarizer!
|
55
|
+
C.add_scalarizer_pass(self)
|
56
|
+
end
|
57
|
+
|
58
|
+
# @LLVMpass mldst-motion
|
59
|
+
# /** See llvm::createMergedLoadStoreMotionPass function. */
|
60
|
+
# void LLVMAddMergedLoadStoreMotionPass(LLVMPassManagerRef PM);
|
61
|
+
def mldst_motion!
|
62
|
+
C.add_merged_load_store_motion_pass(self)
|
63
|
+
end
|
64
|
+
|
24
65
|
# @LLVMpass gvn
|
66
|
+
# /** See llvm::createGVNPass function. */
|
67
|
+
# void LLVMAddGVNPass(LLVMPassManagerRef PM);
|
25
68
|
def gvn!
|
26
69
|
C.add_gvn_pass(self)
|
27
70
|
end
|
28
71
|
|
72
|
+
# @LLVMpass newgvn
|
73
|
+
# /** See llvm::createGVNPass function. */
|
74
|
+
# void LLVMAddNewGVNPass(LLVMPassManagerRef PM);
|
75
|
+
def newgvn!
|
76
|
+
C.add_new_gvn_pass(self)
|
77
|
+
end
|
78
|
+
|
29
79
|
# @LLVMpass indvars
|
80
|
+
# /** See llvm::createIndVarSimplifyPass function. */
|
81
|
+
# void LLVMAddIndVarSimplifyPass(LLVMPassManagerRef PM);
|
30
82
|
def indvars!
|
31
83
|
C.add_ind_var_simplify_pass(self)
|
32
84
|
end
|
33
85
|
|
34
86
|
# @LLVMpass instcombine
|
87
|
+
# /** See llvm::createInstructionCombiningPass function. */
|
88
|
+
# void LLVMAddInstructionCombiningPass(LLVMPassManagerRef PM);
|
35
89
|
def instcombine!
|
36
90
|
C.add_instruction_combining_pass(self)
|
37
91
|
end
|
38
92
|
|
93
|
+
# @LLVMpass instsimplify
|
94
|
+
# /** See llvm::createInstSimplifyLegacyPass function. */
|
95
|
+
# void LLVMAddInstructionSimplifyPass(LLVMPassManagerRef PM);
|
96
|
+
def instsimplify!
|
97
|
+
C.add_instruction_simplify_pass(self)
|
98
|
+
end
|
99
|
+
|
39
100
|
# @LLVMpass jump-threading
|
101
|
+
# /** See llvm::createJumpThreadingPass function. */
|
102
|
+
# void LLVMAddJumpThreadingPass(LLVMPassManagerRef PM);
|
40
103
|
def jump_threading!
|
41
104
|
C.add_jump_threading_pass(self)
|
42
105
|
end
|
43
106
|
|
44
107
|
# @LLVMpass licm
|
108
|
+
# /** See llvm::createLICMPass function. */
|
109
|
+
# void LLVMAddLICMPass(LLVMPassManagerRef PM);
|
45
110
|
def licm!
|
46
111
|
C.add_licm_pass(self)
|
47
112
|
end
|
48
113
|
|
49
114
|
# @LLVMpass loop-deletion
|
115
|
+
# /** See llvm::createLoopDeletionPass function. */
|
116
|
+
# void LLVMAddLoopDeletionPass(LLVMPassManagerRef PM);
|
50
117
|
def loop_deletion!
|
51
118
|
C.add_loop_deletion_pass(self)
|
52
119
|
end
|
53
120
|
|
54
121
|
# @LLVMpass loop-idiom
|
122
|
+
# /** See llvm::createLoopIdiomPass function */
|
123
|
+
# void LLVMAddLoopIdiomPass(LLVMPassManagerRef PM);
|
55
124
|
def loop_idiom!
|
56
125
|
C.add_loop_idiom_pass(self)
|
57
126
|
end
|
58
127
|
|
59
128
|
# @LLVMpass loop-rotate
|
129
|
+
# /** See llvm::createLoopRotatePass function. */
|
130
|
+
# void LLVMAddLoopRotatePass(LLVMPassManagerRef PM);
|
60
131
|
def loop_rotate!
|
61
132
|
C.add_loop_rotate_pass(self)
|
62
133
|
end
|
63
134
|
|
135
|
+
# @LLVMpass loop-reroll
|
136
|
+
# /** See llvm::createLoopRerollPass function. */
|
137
|
+
# void LLVMAddLoopRerollPass(LLVMPassManagerRef PM);
|
138
|
+
def loop_reroll!
|
139
|
+
C.add_loop_reroll_pass(self)
|
140
|
+
end
|
141
|
+
|
64
142
|
# @LLVMpass loop-unroll
|
143
|
+
# /** See llvm::createLoopUnrollPass function. */
|
144
|
+
# void LLVMAddLoopUnrollPass(LLVMPassManagerRef PM);
|
65
145
|
def loop_unroll!
|
66
146
|
C.add_loop_unroll_pass(self)
|
67
147
|
end
|
68
148
|
|
149
|
+
# @LLVMpass loop-unroll-and-jam
|
150
|
+
# /** See llvm::createLoopUnrollAndJamPass function. */
|
151
|
+
# void LLVMAddLoopUnrollAndJamPass(LLVMPassManagerRef PM);
|
152
|
+
def loop_unroll_and_jam!
|
153
|
+
C.add_loop_unroll_and_jam_pass(self)
|
154
|
+
end
|
155
|
+
|
69
156
|
# @LLVMpass loop-unswitch
|
70
157
|
def loop_unswitch!
|
71
|
-
|
158
|
+
warn('loop_unswitch! / LLVMAddLoopUnswitchPass was removed in LLVM 15')
|
159
|
+
end
|
160
|
+
|
161
|
+
# @LLVMpass loweratomic
|
162
|
+
# /** See llvm::createLowerAtomicPass function. */
|
163
|
+
# void LLVMAddLowerAtomicPass(LLVMPassManagerRef PM);
|
164
|
+
def loweratomic!
|
165
|
+
C.add_lower_atomic_pass(self)
|
72
166
|
end
|
73
167
|
|
74
168
|
# @LLVMpass memcpyopt
|
169
|
+
# /** See llvm::createMemCpyOptPass function. */
|
170
|
+
# void LLVMAddMemCpyOptPass(LLVMPassManagerRef PM);
|
75
171
|
def memcpyopt!
|
76
172
|
C.add_mem_cpy_opt_pass(self)
|
77
173
|
end
|
78
174
|
|
79
|
-
# @LLVMpass
|
80
|
-
|
81
|
-
|
175
|
+
# @LLVMpass partially-inline-libcalls
|
176
|
+
# /** See llvm::createPartiallyInlineLibCallsPass function. */
|
177
|
+
# void LLVMAddPartiallyInlineLibCallsPass(LLVMPassManagerRef PM);
|
178
|
+
def partially_inline_libcalls!
|
179
|
+
C.add_partially_inline_lib_calls_pass(self)
|
82
180
|
end
|
83
181
|
|
84
182
|
# @LLVMpass reassociate
|
183
|
+
# /** See llvm::createReassociatePass function. */
|
184
|
+
# void LLVMAddReassociatePass(LLVMPassManagerRef PM);
|
85
185
|
def reassociate!
|
86
186
|
C.add_reassociate_pass(self)
|
87
187
|
end
|
88
188
|
|
89
189
|
# @LLVMpass sccp
|
190
|
+
# /** See llvm::createSCCPPass function. */
|
191
|
+
# void LLVMAddSCCPPass(LLVMPassManagerRef PM);
|
90
192
|
def sccp!
|
91
193
|
C.add_sccp_pass(self)
|
92
194
|
end
|
93
195
|
|
94
|
-
# @LLVMpass
|
196
|
+
# @LLVMpass sroa
|
197
|
+
# /** See llvm::createSROAPass function. */
|
198
|
+
# void LLVMAddScalarReplAggregatesPass(LLVMPassManagerRef PM);
|
95
199
|
def scalarrepl!
|
96
200
|
C.add_scalar_repl_aggregates_pass(self)
|
97
201
|
end
|
98
202
|
|
99
|
-
# @LLVMpass
|
203
|
+
# @LLVMpass sroa
|
204
|
+
# /** See llvm::createSROAPass function. */
|
205
|
+
# void LLVMAddScalarReplAggregatesPassSSA(LLVMPassManagerRef PM);
|
100
206
|
def scalarrepl_ssa!
|
101
207
|
C.add_scalar_repl_aggregates_pass_ssa(self)
|
102
208
|
end
|
103
209
|
|
104
|
-
# @LLVMpass
|
105
|
-
|
106
|
-
|
210
|
+
# @LLVMpass sroa
|
211
|
+
# /** See llvm::createSROAPass function. */
|
212
|
+
# void LLVMAddScalarReplAggregatesPassWithThreshold(LLVMPassManagerRef PM,
|
213
|
+
# int Threshold);
|
214
|
+
# threshold appears unused: https://llvm.org/doxygen/Scalar_8cpp_source.html#l00211
|
215
|
+
def scalarrepl_threshold!(threshold = 0)
|
216
|
+
C.add_scalar_repl_aggregates_pass_with_threshold(self, threshold)
|
107
217
|
end
|
108
218
|
|
109
219
|
# @LLVMpass simplify-libcalls
|
220
|
+
# /** See llvm::createSimplifyLibCallsPass function. */
|
221
|
+
# void LLVMAddSimplifyLibCallsPass(LLVMPassManagerRef PM);
|
222
|
+
# removed: https://llvm.org/doxygen/Scalar_8cpp_source.html#l00211
|
110
223
|
def simplify_libcalls!
|
111
|
-
|
224
|
+
warn('simplify_libcalls! / LLVMAddSimplifyLibCallsPass was removed from LLVM')
|
112
225
|
end
|
113
226
|
|
114
227
|
# @LLVMpass tailcallelim
|
228
|
+
# /** See llvm::createTailCallEliminationPass function. */
|
229
|
+
# void LLVMAddTailCallEliminationPass(LLVMPassManagerRef PM);
|
115
230
|
def tailcallelim!
|
116
231
|
C.add_tail_call_elimination_pass(self)
|
117
232
|
end
|
118
233
|
|
119
234
|
# @LLVMpass constprop
|
120
235
|
def constprop!
|
121
|
-
|
236
|
+
warn('constprop! / LLVMAddConstantPropagationPass was removed from LLVM')
|
122
237
|
end
|
123
238
|
|
124
239
|
# @LLVMpass reg2mem
|
240
|
+
# /** See llvm::demotePromoteMemoryToRegisterPass function. */
|
241
|
+
# void LLVMAddDemoteMemoryToRegisterPass(LLVMPassManagerRef PM);
|
125
242
|
def reg2mem!
|
126
243
|
C.add_demote_memory_to_register_pass(self)
|
127
244
|
end
|
128
245
|
|
246
|
+
# @LLVMpass verify
|
247
|
+
# /** See llvm::createVerifierPass function. */
|
248
|
+
# void LLVMAddVerifierPass(LLVMPassManagerRef PM);
|
249
|
+
def verify!
|
250
|
+
C.add_verifier_pass(self)
|
251
|
+
end
|
252
|
+
|
129
253
|
# @LLVMpass cvprop
|
254
|
+
# /** See llvm::createCorrelatedValuePropagationPass function */
|
255
|
+
# void LLVMAddCorrelatedValuePropagationPass(LLVMPassManagerRef PM);
|
130
256
|
def cvprop!
|
131
257
|
C.add_correlated_value_propagation_pass(self)
|
132
258
|
end
|
133
259
|
|
134
260
|
# @LLVMpass early-cse
|
261
|
+
# /** See llvm::createEarlyCSEPass function */
|
262
|
+
# void LLVMAddEarlyCSEPass(LLVMPassManagerRef PM);
|
135
263
|
def early_cse!
|
136
264
|
C.add_early_cse_pass(self)
|
137
265
|
end
|
138
266
|
|
267
|
+
# @LLVMpass early-cse-memssa
|
268
|
+
# /** See llvm::createEarlyCSEPass function */
|
269
|
+
# void LLVMAddEarlyCSEMemSSAPass(LLVMPassManagerRef PM);
|
270
|
+
def early_cse_memssa!
|
271
|
+
C.add_early_cse_mem_ssa_pass(self)
|
272
|
+
end
|
273
|
+
|
139
274
|
# @LLVMpass lower-expect
|
275
|
+
# /** See llvm::createLowerExpectIntrinsicPass function */
|
276
|
+
# void LLVMAddLowerExpectIntrinsicPass(LLVMPassManagerRef PM);
|
140
277
|
def lower_expect!
|
141
278
|
C.add_lower_expect_intrinsic_pass(self)
|
142
279
|
end
|
143
280
|
|
281
|
+
# @LLVMPass lower-constant-intrinsics
|
282
|
+
# /** See llvm::createLowerConstantIntrinsicsPass function */
|
283
|
+
# void LLVMAddLowerConstantIntrinsicsPass(LLVMPassManagerRef PM);
|
284
|
+
def lower_constant_intrinsics!
|
285
|
+
C.add_lower_constant_intrinsics_pass(self)
|
286
|
+
end
|
287
|
+
|
144
288
|
# @LLVMpass tbaa
|
289
|
+
# /** See llvm::createTypeBasedAliasAnalysisPass function */
|
290
|
+
# void LLVMAddTypeBasedAliasAnalysisPass(LLVMPassManagerRef PM);
|
145
291
|
def tbaa!
|
146
292
|
C.add_type_based_alias_analysis_pass(self)
|
147
293
|
end
|
148
294
|
|
295
|
+
# @ LLVMPass scoped-noalias-aa
|
296
|
+
# /** See llvm::createScopedNoAliasAAPass function */
|
297
|
+
# void LLVMAddScopedNoAliasAAPass(LLVMPassManagerRef PM);
|
298
|
+
def scoped_noalias_aa!
|
299
|
+
C.add_scoped_no_alias_aa_pass(self)
|
300
|
+
end
|
301
|
+
|
149
302
|
# @LLVMpass basicaa
|
303
|
+
# /** See llvm::createBasicAliasAnalysisPass function */
|
304
|
+
# void LLVMAddBasicAliasAnalysisPass(LLVMPassManagerRef PM);
|
150
305
|
def basicaa!
|
151
306
|
C.add_basic_alias_analysis_pass(self)
|
152
307
|
end
|
153
308
|
|
154
|
-
# @LLVMpass
|
155
|
-
|
156
|
-
|
309
|
+
# @LLVMpass mergereturn
|
310
|
+
# /** See llvm::createUnifyFunctionExitNodesPass function */
|
311
|
+
# void LLVMAddUnifyFunctionExitNodesPass(LLVMPassManagerRef PM);
|
312
|
+
def mergereturn!
|
313
|
+
C.add_unify_function_exit_nodes_pass(self)
|
157
314
|
end
|
158
315
|
|
159
316
|
end
|
160
317
|
|
161
318
|
module C
|
162
|
-
attach_function :
|
319
|
+
attach_function :add_dce_pass, :LLVMAddDCEPass, [:pointer], :void
|
320
|
+
attach_function :add_instruction_simplify_pass, :LLVMAddInstructionSimplifyPass, [:pointer], :void
|
321
|
+
attach_function :add_loop_unroll_and_jam_pass, :LLVMAddLoopUnrollAndJamPass, [:pointer], :void
|
322
|
+
attach_function :add_lower_atomic_pass, :LLVMAddLowerAtomicPass, [:pointer], :void
|
323
|
+
attach_function :add_lower_constant_intrinsics_pass, :LLVMAddLowerConstantIntrinsicsPass, [:pointer], :void
|
324
|
+
attach_function :add_unify_function_exit_nodes_pass, :LLVMAddUnifyFunctionExitNodesPass, [:pointer], :void
|
163
325
|
end
|
164
326
|
end
|
@@ -164,14 +164,6 @@ module LLVM::C
|
|
164
164
|
# @scope class
|
165
165
|
attach_function :add_loop_unroll_pass, :LLVMAddLoopUnrollPass, [:pointer], :void
|
166
166
|
|
167
|
-
# See llvm::createLoopUnswitchPass function.
|
168
|
-
#
|
169
|
-
# @method add_loop_unswitch_pass(pm)
|
170
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
171
|
-
# @return [nil]
|
172
|
-
# @scope class
|
173
|
-
attach_function :add_loop_unswitch_pass, :LLVMAddLoopUnswitchPass, [:pointer], :void
|
174
|
-
|
175
167
|
# See llvm::createMemCpyOptPass function.
|
176
168
|
#
|
177
169
|
# @method add_mem_cpy_opt_pass(pm)
|
@@ -245,14 +237,6 @@ module LLVM::C
|
|
245
237
|
# @scope class
|
246
238
|
attach_function :add_scalar_repl_aggregates_pass_with_threshold, :LLVMAddScalarReplAggregatesPassWithThreshold, [:pointer, :int], :void
|
247
239
|
|
248
|
-
# See llvm::createSimplifyLibCallsPass function.
|
249
|
-
#
|
250
|
-
# @method add_simplify_lib_calls_pass(pm)
|
251
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
252
|
-
# @return [nil]
|
253
|
-
# @scope class
|
254
|
-
attach_function :add_simplify_lib_calls_pass, :LLVMAddSimplifyLibCallsPass, [:pointer], :void
|
255
|
-
|
256
240
|
# See llvm::createTailCallEliminationPass function.
|
257
241
|
#
|
258
242
|
# @method add_tail_call_elimination_pass(pm)
|
@@ -261,14 +245,6 @@ module LLVM::C
|
|
261
245
|
# @scope class
|
262
246
|
attach_function :add_tail_call_elimination_pass, :LLVMAddTailCallEliminationPass, [:pointer], :void
|
263
247
|
|
264
|
-
# See llvm::createConstantPropagationPass function.
|
265
|
-
#
|
266
|
-
# @method add_constant_propagation_pass(pm)
|
267
|
-
# @param [FFI::Pointer(PassManagerRef)] pm
|
268
|
-
# @return [nil]
|
269
|
-
# @scope class
|
270
|
-
attach_function :add_constant_propagation_pass, :LLVMAddConstantPropagationPass, [:pointer], :void
|
271
|
-
|
272
248
|
# See llvm::demotePromoteMemoryToRegisterPass function.
|
273
249
|
#
|
274
250
|
# @method add_demote_memory_to_register_pass(pm)
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'llvm'
|
4
|
+
require 'llvm/core'
|
5
|
+
|
6
|
+
module LLVM
|
7
|
+
class PassManager
|
8
|
+
|
9
|
+
# @LLVMpass lowerswitch
|
10
|
+
# /** See llvm::createLowerSwitchPass function. */
|
11
|
+
# void LLVMAddLowerSwitchPass(LLVMPassManagerRef PM);
|
12
|
+
def lowerswitch!
|
13
|
+
C.add_lower_switch_pass(self)
|
14
|
+
end
|
15
|
+
|
16
|
+
# @LLVMpass mem2reg
|
17
|
+
# /** See llvm::createPromoteMemoryToRegisterPass function. */
|
18
|
+
# void LLVMAddPromoteMemoryToRegisterPass(LLVMPassManagerRef PM);
|
19
|
+
def mem2reg!
|
20
|
+
C.add_promote_memory_to_register_pass(self)
|
21
|
+
end
|
22
|
+
|
23
|
+
# @LLVMpass add-discriminators
|
24
|
+
# /** See llvm::createAddDiscriminatorsPass function. */
|
25
|
+
# void LLVMAddAddDiscriminatorsPass(LLVMPassManagerRef PM);
|
26
|
+
def add_discriminators!
|
27
|
+
C.add_add_discriminators_pass(self)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
module C
|
32
|
+
attach_function :add_add_discriminators_pass, :LLVMAddAddDiscriminatorsPass, [:pointer], :void
|
33
|
+
end
|
34
|
+
end
|
@@ -8,15 +8,20 @@ module LLVM
|
|
8
8
|
class PassManager
|
9
9
|
# @LLVMpass bb_vectorize
|
10
10
|
def bb_vectorize!
|
11
|
-
|
11
|
+
warn('bb_vectorize! / LLVMAddBBVectorizePass was removed from LLVM - replace with slp_vectorize!')
|
12
|
+
slp_vectorize!
|
12
13
|
end
|
13
14
|
|
14
15
|
# @LLVMpass loop_vectorize
|
16
|
+
# /** See llvm::createLoopVectorizePass function. */
|
17
|
+
# void LLVMAddLoopVectorizePass(LLVMPassManagerRef PM);
|
15
18
|
def loop_vectorize!
|
16
19
|
C.add_loop_vectorize_pass(self)
|
17
20
|
end
|
18
21
|
|
19
22
|
# @LLVMpass slp_vectorize
|
23
|
+
# /** See llvm::createSLPVectorizerPass function. */
|
24
|
+
# void LLVMAddSLPVectorizePass(LLVMPassManagerRef PM);
|
20
25
|
def slp_vectorize!
|
21
26
|
C.add_slp_vectorize_pass(self)
|
22
27
|
end
|
data/lib/llvm/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-llvm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 15.0.
|
4
|
+
version: 15.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jesse Johnson
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2023-02-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ffi
|
@@ -197,7 +197,6 @@ files:
|
|
197
197
|
- lib/llvm/core/builder.rb
|
198
198
|
- lib/llvm/core/context.rb
|
199
199
|
- lib/llvm/core/module.rb
|
200
|
-
- lib/llvm/core/opaque_pointer_builder.rb
|
201
200
|
- lib/llvm/core/pass_manager.rb
|
202
201
|
- lib/llvm/core/type.rb
|
203
202
|
- lib/llvm/core/value.rb
|
@@ -215,6 +214,7 @@ files:
|
|
215
214
|
- lib/llvm/transforms/ipo_ffi.rb
|
216
215
|
- lib/llvm/transforms/scalar.rb
|
217
216
|
- lib/llvm/transforms/scalar_ffi.rb
|
217
|
+
- lib/llvm/transforms/utils.rb
|
218
218
|
- lib/llvm/transforms/vectorize.rb
|
219
219
|
- lib/llvm/transforms/vectorize_ffi.rb
|
220
220
|
- lib/llvm/version.rb
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# unmodule LLVM
|
2
|
-
# module OpaquePointerBuilder
|
3
|
-
# # Builds a struct getelementptr Instruction.
|
4
|
-
# #
|
5
|
-
# # @param [LLVM::Value] pointer A pointer to a structure
|
6
|
-
# # @param [LLVM::Value] idx Unsigned integer representing the index of a
|
7
|
-
# # structure member
|
8
|
-
# # @param [String] name The name of the result in LLVM IR
|
9
|
-
# # @return [LLVM::Instruction] The resulting pointer
|
10
|
-
# # @LLVMinst gep
|
11
|
-
# # @see http://llvm.org/docs/GetElementPtr.html
|
12
|
-
# def struct_gep1(pointer, idx, name = "")
|
13
|
-
# Instruction.from_ptr(C.build_struct_gep(self, pointer, idx, name))
|
14
|
-
# end
|
15
|
-
#
|
16
|
-
# private def struct_gep2(type, pointer, idx, name)
|
17
|
-
# Instruction.from_ptr(C.build_struct_gep2(self, type, pointer, idx, name))
|
18
|
-
# end
|
19
|
-
#
|
20
|
-
# def struct_gep(pointer, idx, name = "", type = nil)
|
21
|
-
# type2 = type || must_infer_type(pointer)
|
22
|
-
# struct_gep2(types2, pointer, idx, name)
|
23
|
-
# end
|
24
|
-
# end
|
25
|
-
# end
|