ruby-llvm 2.9.0 → 2.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +4 -5
- data/lib/llvm.rb +1 -0
- data/lib/llvm/analysis.rb +1 -0
- data/lib/llvm/core.rb +1 -0
- data/lib/llvm/core/builder.rb +161 -19
- data/lib/llvm/core/context.rb +7 -4
- data/lib/llvm/core/module.rb +42 -15
- data/lib/llvm/core/pass_manager.rb +7 -1
- data/lib/llvm/core/type.rb +27 -3
- data/lib/llvm/core/value.rb +130 -16
- data/lib/llvm/execution_engine.rb +24 -7
- data/lib/llvm/target.rb +1 -0
- data/lib/llvm/transforms/ipo.rb +2 -0
- data/lib/llvm/transforms/scalar.rb +22 -0
- metadata +5 -21
@@ -4,6 +4,7 @@ require 'llvm/target'
|
|
4
4
|
require 'llvm/analysis'
|
5
5
|
|
6
6
|
module LLVM
|
7
|
+
# @private
|
7
8
|
module C
|
8
9
|
# Generic values
|
9
10
|
attach_function :LLVMCreateGenericValueOfInt, [:pointer, :long_long, :int], :pointer
|
@@ -54,14 +55,17 @@ module LLVM
|
|
54
55
|
class ExecutionEngine
|
55
56
|
private_class_method :new
|
56
57
|
|
57
|
-
|
58
|
+
# @private
|
59
|
+
def initialize(ptr)
|
58
60
|
@ptr = ptr
|
59
61
|
end
|
60
62
|
|
61
|
-
|
63
|
+
# @private
|
64
|
+
def to_ptr
|
62
65
|
@ptr
|
63
66
|
end
|
64
67
|
|
68
|
+
# Create a JIT compiler with an LLVM::Module.
|
65
69
|
def self.create_jit_compiler(mod, opt_level = 3)
|
66
70
|
FFI::MemoryPointer.new(FFI.type_size(:pointer)) do |ptr|
|
67
71
|
error = FFI::MemoryPointer.new(FFI.type_size(:pointer))
|
@@ -79,6 +83,8 @@ module LLVM
|
|
79
83
|
end
|
80
84
|
end
|
81
85
|
|
86
|
+
# Execute the given LLVM::Function with the supplied args (as
|
87
|
+
# GenericValues).
|
82
88
|
def run_function(fun, *args)
|
83
89
|
FFI::MemoryPointer.new(FFI.type_size(:pointer) * args.size) do |args_ptr|
|
84
90
|
args_ptr.write_array_of_pointer(args.map { |arg| LLVM.GenericValue(arg).to_ptr })
|
@@ -87,6 +93,7 @@ module LLVM
|
|
87
93
|
end
|
88
94
|
end
|
89
95
|
|
96
|
+
# Obtain an FFI::Pointer to a global within the current module.
|
90
97
|
def pointer_to_global(global)
|
91
98
|
C.LLVMGetPointerToGlobal(self, global)
|
92
99
|
end
|
@@ -95,46 +102,57 @@ module LLVM
|
|
95
102
|
class GenericValue
|
96
103
|
private_class_method :new
|
97
104
|
|
98
|
-
|
105
|
+
# @private
|
106
|
+
def initialize(ptr)
|
99
107
|
@ptr = ptr
|
100
108
|
end
|
101
109
|
|
102
|
-
|
110
|
+
# @private
|
111
|
+
def to_ptr
|
103
112
|
@ptr
|
104
113
|
end
|
105
114
|
|
115
|
+
# Creates a Generic Value from an integer. Type is the size of integer to
|
116
|
+
# create (ex. Int32, Int8, etc.)
|
106
117
|
def self.from_i(i, type = LLVM::Int, signed = true)
|
107
118
|
new(C.LLVMCreateGenericValueOfInt(type, i, signed ? 1 : 0))
|
108
119
|
end
|
109
120
|
|
121
|
+
# Creates a Generic Value from a Float.
|
110
122
|
def self.from_f(f)
|
111
123
|
type = LLVM::Float.type
|
112
124
|
new(C.LLVMCreateGenericValueOfFloat(type, f))
|
113
125
|
end
|
114
126
|
|
127
|
+
# Creates a GenericValue from a Ruby boolean.
|
115
128
|
def self.from_b(b)
|
116
129
|
from_i(b ? 1 : 0, LLVM::Int1, false)
|
117
130
|
end
|
118
131
|
|
132
|
+
# Creates a GenericValue from an FFI::Pointer.
|
119
133
|
def self.from_ptr(ptr)
|
120
134
|
new(ptr)
|
121
135
|
end
|
122
136
|
|
137
|
+
# Converts a GenericValue to a Ruby Integer.
|
123
138
|
def to_i(signed = true)
|
124
139
|
C.LLVMGenericValueToInt(self, signed ? 1 : 0)
|
125
140
|
end
|
126
141
|
|
142
|
+
# Converts a GenericValue to a Ruby Float.
|
127
143
|
def to_f(type = LLVM::Float.type)
|
128
144
|
C.LLVMGenericValueToFloat(type, self)
|
129
145
|
end
|
130
146
|
|
147
|
+
# Converts a GenericValue to a Ruby boolean.
|
131
148
|
def to_b
|
132
149
|
to_i(false) != 0
|
133
150
|
end
|
134
|
-
|
135
151
|
end
|
136
152
|
|
137
|
-
|
153
|
+
# Creates a GenericValue from an object (GenericValue, Integer, Float, true,
|
154
|
+
# false).
|
155
|
+
def LLVM.GenericValue(val)
|
138
156
|
case val
|
139
157
|
when GenericValue then val
|
140
158
|
when ::Integer then GenericValue.from_i(val)
|
@@ -143,5 +161,4 @@ module LLVM
|
|
143
161
|
when ::FalseClass then GenericValue.from_b(false)
|
144
162
|
end
|
145
163
|
end
|
146
|
-
module_function :GenericValue
|
147
164
|
end
|
data/lib/llvm/target.rb
CHANGED
data/lib/llvm/transforms/ipo.rb
CHANGED
@@ -2,6 +2,7 @@ require 'llvm'
|
|
2
2
|
require 'llvm/core'
|
3
3
|
|
4
4
|
module LLVM
|
5
|
+
# @private
|
5
6
|
module C
|
6
7
|
attach_function :LLVMAddAggressiveDCEPass, [:pointer], :void
|
7
8
|
attach_function :LLVMAddCFGSimplificationPass, [:pointer], :void
|
@@ -27,86 +28,107 @@ module LLVM
|
|
27
28
|
end
|
28
29
|
|
29
30
|
class PassManager
|
31
|
+
# @LLVMpass adce
|
30
32
|
def adce!
|
31
33
|
C.LLVMAddAggressiveDCEPass(self)
|
32
34
|
end
|
33
35
|
|
36
|
+
# @LLVMpass simplifycfg
|
34
37
|
def simplifycfg!
|
35
38
|
C.LLVMAddCFGSimplificationPass(self)
|
36
39
|
end
|
37
40
|
|
41
|
+
# @LLVMpass dse
|
38
42
|
def dse!
|
39
43
|
C.LLVMAddDeadStoreEliminationPass(self)
|
40
44
|
end
|
41
45
|
|
46
|
+
# @LLVMpass gvn
|
42
47
|
def gvn!
|
43
48
|
C.LLVMAddGVNPass(self)
|
44
49
|
end
|
45
50
|
|
51
|
+
# @LLVMpass indvars
|
46
52
|
def indvars!
|
47
53
|
C.LLVMAddIndVarSimplifyPass(self)
|
48
54
|
end
|
49
55
|
|
56
|
+
# @LLVMpass instcombine
|
50
57
|
def instcombine!
|
51
58
|
C.LLVMAddInstructionCombiningPass(self)
|
52
59
|
end
|
53
60
|
|
61
|
+
# @LLVMpass jump-threading
|
54
62
|
def jump_threading!
|
55
63
|
C.LLVMAddJumpThreadingPass(self)
|
56
64
|
end
|
57
65
|
|
66
|
+
# @LLVMpass licm
|
58
67
|
def licm!
|
59
68
|
C.LLVMAddLICMPass(self)
|
60
69
|
end
|
61
70
|
|
71
|
+
# @LLVMpass loop-deletion
|
62
72
|
def loop_deletion!
|
63
73
|
C.LLVMAddLoopDeletionPass(self)
|
64
74
|
end
|
65
75
|
|
76
|
+
# @LLVMpass loop-rotate
|
66
77
|
def loop_rotate!
|
67
78
|
C.LLVMAddLoopRotatePass(self)
|
68
79
|
end
|
69
80
|
|
81
|
+
# @LLVMpass loop-unroll
|
70
82
|
def loop_unroll!
|
71
83
|
C.LLVMAddLoopUnrollPass(self)
|
72
84
|
end
|
73
85
|
|
86
|
+
# @LLVMpass loop-unswitch
|
74
87
|
def loop_unswitch!
|
75
88
|
C.LLVMAddLoopUnswitchPass(self)
|
76
89
|
end
|
77
90
|
|
91
|
+
# @LLVMpass memcpyopt
|
78
92
|
def memcpyopt!
|
79
93
|
C.LLVMAddMemCpyOptPass(self)
|
80
94
|
end
|
81
95
|
|
96
|
+
# @LLVMpass mem2reg
|
82
97
|
def mem2reg!
|
83
98
|
C.LLVMAddPromoteMemoryToRegisterPass(self)
|
84
99
|
end
|
85
100
|
|
101
|
+
# @LLVMpass reassociate
|
86
102
|
def reassociate!
|
87
103
|
C.LLVMAddReassociatePass(self)
|
88
104
|
end
|
89
105
|
|
106
|
+
# @LLVMpass sccp
|
90
107
|
def sccp!
|
91
108
|
C.LLVMAddSCCPPass(self)
|
92
109
|
end
|
93
110
|
|
111
|
+
# @LLVMpass scalarrepl
|
94
112
|
def scalarrepl!
|
95
113
|
C.LLVMAddScalarReplAggregatesPass(self)
|
96
114
|
end
|
97
115
|
|
116
|
+
# @LLVMpass simplify-libcalls
|
98
117
|
def simplify_libcalls!
|
99
118
|
C.LLVMAddSimplifyLibCallsPass(self)
|
100
119
|
end
|
101
120
|
|
121
|
+
# @LLVMpass tailcallelim
|
102
122
|
def tailcallelim!
|
103
123
|
C.LLVMAddTailCallEliminationPass(self)
|
104
124
|
end
|
105
125
|
|
126
|
+
# @LLVMpass constprop
|
106
127
|
def constprop!
|
107
128
|
C.LLVMAddConstantPropagationPass(self)
|
108
129
|
end
|
109
130
|
|
131
|
+
# @LLVMpass reg2mem
|
110
132
|
def reg2mem!
|
111
133
|
C.LLVMAddDemoteMemoryToRegisterPass(self)
|
112
134
|
end
|
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-llvm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
segments:
|
7
|
-
- 2
|
8
|
-
- 9
|
9
|
-
- 0
|
10
|
-
version: 2.9.0
|
4
|
+
prerelease:
|
5
|
+
version: 2.9.1
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- Jeremy Voorhis
|
@@ -15,7 +10,7 @@ autorequire:
|
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
12
|
|
18
|
-
date: 2011-04-
|
13
|
+
date: 2011-04-23 00:00:00 -07:00
|
19
14
|
default_executable:
|
20
15
|
dependencies:
|
21
16
|
- !ruby/object:Gem::Dependency
|
@@ -26,12 +21,7 @@ dependencies:
|
|
26
21
|
requirements:
|
27
22
|
- - ">="
|
28
23
|
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
- 5
|
33
|
-
- 4
|
34
|
-
version: 0.5.4
|
24
|
+
version: 1.0.0
|
35
25
|
type: :runtime
|
36
26
|
version_requirements: *id001
|
37
27
|
description:
|
@@ -71,23 +61,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
71
61
|
requirements:
|
72
62
|
- - ">="
|
73
63
|
- !ruby/object:Gem::Version
|
74
|
-
hash: 3
|
75
|
-
segments:
|
76
|
-
- 0
|
77
64
|
version: "0"
|
78
65
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
66
|
none: false
|
80
67
|
requirements:
|
81
68
|
- - ">="
|
82
69
|
- !ruby/object:Gem::Version
|
83
|
-
hash: 3
|
84
|
-
segments:
|
85
|
-
- 0
|
86
70
|
version: "0"
|
87
71
|
requirements: []
|
88
72
|
|
89
73
|
rubyforge_project:
|
90
|
-
rubygems_version: 1.
|
74
|
+
rubygems_version: 1.6.0
|
91
75
|
signing_key:
|
92
76
|
specification_version: 3
|
93
77
|
summary: LLVM bindings for Ruby
|