ruby-llvm 2.7.0 → 2.9.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.
@@ -9,77 +9,76 @@ module LLVM
9
9
  attach_function :LLVMCreateGenericValueOfInt, [:pointer, :long_long, :int], :pointer
10
10
  attach_function :LLVMCreateGenericValueOfPointer, [:pointer], :pointer
11
11
  attach_function :LLVMCreateGenericValueOfFloat, [:pointer, :double], :pointer
12
-
12
+
13
13
  attach_function :LLVMGenericValueIntWidth, [:pointer], :uint
14
-
14
+
15
15
  attach_function :LLVMGenericValueToInt, [:pointer, :int], :long_long
16
16
  attach_function :LLVMGenericValueToPointer, [:pointer], :pointer
17
17
  attach_function :LLVMGenericValueToFloat, [:pointer, :pointer], :double
18
18
  attach_function :LLVMDisposeGenericValue, [:pointer], :void
19
-
19
+
20
20
  # Execution engines
21
21
  attach_function :LLVMCreateExecutionEngineForModule, [:pointer, :pointer, :pointer], :int
22
22
  attach_function :LLVMCreateInterpreterForModule, [:pointer, :pointer, :pointer], :int
23
23
  attach_function :LLVMCreateJITCompilerForModule, [:pointer, :pointer, :uint, :pointer], :int
24
24
  attach_function :LLVMDisposeExecutionEngine, [:pointer], :void
25
-
25
+
26
26
  attach_function :LLVMRunStaticConstructors, [:pointer], :void
27
27
  attach_function :LLVMRunStaticDestructors, [:pointer], :void
28
-
28
+
29
29
  attach_function :LLVMRunFunctionAsMain, [:pointer, :pointer, :uint, :pointer, :pointer], :int
30
30
  attach_function :LLVMRunFunction, [:pointer, :pointer, :uint, :pointer], :pointer
31
-
31
+
32
32
  attach_function :LLVMFreeMachineCodeForFunction, [:pointer, :pointer], :void
33
33
  attach_function :LLVMAddModuleProvider, [:pointer, :pointer], :void
34
34
  attach_function :LLVMRemoveModuleProvider, [:pointer, :pointer, :pointer, :pointer], :int
35
-
35
+
36
36
  attach_function :LLVMFindFunction, [:pointer, :pointer, :pointer, :pointer], :int
37
-
37
+
38
38
  attach_function :LLVMGetExecutionEngineTargetData, [:pointer], :pointer
39
-
39
+
40
40
  attach_function :LLVMAddGlobalMapping, [:pointer, :pointer, :pointer], :void
41
-
41
+
42
42
  attach_function :LLVMGetPointerToGlobal, [:pointer, :pointer], :pointer
43
-
43
+
44
44
  attach_function :LLVMInitializeX86TargetInfo, [], :void
45
-
45
+
46
46
  attach_function :LLVMInitializeX86Target, [], :void
47
47
  end
48
-
48
+
49
49
  def LLVM.init_x86
50
50
  LLVM::C.LLVMInitializeX86Target
51
51
  LLVM::C.LLVMInitializeX86TargetInfo
52
52
  end
53
-
53
+
54
54
  class ExecutionEngine
55
- class << self
56
- private :new
57
- end
58
-
55
+ private_class_method :new
56
+
59
57
  def initialize(ptr) # :nodoc:
60
58
  @ptr = ptr
61
59
  end
62
-
60
+
63
61
  def to_ptr # :nodoc:
64
62
  @ptr
65
63
  end
66
-
64
+
67
65
  def self.create_jit_compiler(mod, opt_level = 3)
68
66
  FFI::MemoryPointer.new(FFI.type_size(:pointer)) do |ptr|
69
67
  error = FFI::MemoryPointer.new(FFI.type_size(:pointer))
70
68
  status = C.LLVMCreateJITCompilerForModule(ptr, mod, opt_level, error)
71
69
  errorp = error.read_pointer
72
70
  message = errorp.read_string unless errorp.null?
73
-
71
+
74
72
  if status.zero?
75
73
  return new(ptr.read_pointer)
76
74
  else
77
75
  C.LLVMDisposeMessage(error)
76
+ error.autorelease=false
78
77
  raise RuntimeError, "Error creating JIT compiler: #{message}"
79
78
  end
80
79
  end
81
80
  end
82
-
81
+
83
82
  def run_function(fun, *args)
84
83
  FFI::MemoryPointer.new(FFI.type_size(:pointer) * args.size) do |args_ptr|
85
84
  args_ptr.write_array_of_pointer(args.map { |arg| LLVM.GenericValue(arg).to_ptr })
@@ -87,52 +86,61 @@ module LLVM
87
86
  C.LLVMRunFunction(self, fun, args.size, args_ptr))
88
87
  end
89
88
  end
90
-
89
+
91
90
  def pointer_to_global(global)
92
91
  C.LLVMGetPointerToGlobal(self, global)
93
92
  end
94
93
  end
95
-
94
+
96
95
  class GenericValue
97
- class << self
98
- private :new
99
- end
100
-
96
+ private_class_method :new
97
+
101
98
  def initialize(ptr) # :nodoc:
102
99
  @ptr = ptr
103
100
  end
104
-
101
+
105
102
  def to_ptr # :nodoc:
106
103
  @ptr
107
104
  end
108
-
105
+
109
106
  def self.from_i(i, type = LLVM::Int, signed = true)
110
107
  new(C.LLVMCreateGenericValueOfInt(type, i, signed ? 1 : 0))
111
108
  end
112
-
109
+
113
110
  def self.from_f(f)
114
111
  type = LLVM::Float.type
115
112
  new(C.LLVMCreateGenericValueOfFloat(type, f))
116
113
  end
117
114
 
115
+ def self.from_b(b)
116
+ from_i(b ? 1 : 0, LLVM::Int1, false)
117
+ end
118
+
118
119
  def self.from_ptr(ptr)
119
120
  new(ptr)
120
121
  end
121
-
122
+
122
123
  def to_i(signed = true)
123
124
  C.LLVMGenericValueToInt(self, signed ? 1 : 0)
124
125
  end
126
+
127
+ def to_f(type = LLVM::Float.type)
128
+ C.LLVMGenericValueToFloat(type, self)
129
+ end
125
130
 
126
- def to_f
127
- C.LLVMGenericValueToFloat(LLVM::Float.type, self)
131
+ def to_b
132
+ to_i(false) != 0
128
133
  end
134
+
129
135
  end
130
-
136
+
131
137
  def GenericValue(val)
132
138
  case val
133
139
  when GenericValue then val
134
- when Integer then GenericValue.from_i(val)
135
- when Float then GenericValue.from_f(val)
140
+ when ::Integer then GenericValue.from_i(val)
141
+ when ::Float then GenericValue.from_f(val)
142
+ when ::TrueClass then GenericValue.from_b(true)
143
+ when ::FalseClass then GenericValue.from_b(false)
136
144
  end
137
145
  end
138
146
  module_function :GenericValue
@@ -0,0 +1,15 @@
1
+ # Interprocedural optimization (IPO)
2
+ require 'llvm'
3
+ require 'llvm/core'
4
+
5
+ module LLVM
6
+ module C
7
+ attach_function :LLVMAddGlobalDCEPass, [:pointer], :void
8
+ end
9
+
10
+ class PassManager
11
+ def gdce!
12
+ C.LLVMAddGlobalDCEPass(self)
13
+ end
14
+ end
15
+ end
@@ -12,7 +12,6 @@ module LLVM
12
12
  attach_function :LLVMAddJumpThreadingPass, [:pointer], :void
13
13
  attach_function :LLVMAddLICMPass, [:pointer], :void
14
14
  attach_function :LLVMAddLoopDeletionPass, [:pointer], :void
15
- attach_function :LLVMAddLoopIndexSplitPass, [:pointer], :void
16
15
  attach_function :LLVMAddLoopRotatePass, [:pointer], :void
17
16
  attach_function :LLVMAddLoopUnrollPass, [:pointer], :void
18
17
  attach_function :LLVMAddLoopUnswitchPass, [:pointer], :void
@@ -64,10 +63,6 @@ module LLVM
64
63
  C.LLVMAddLoopDeletionPass(self)
65
64
  end
66
65
 
67
- def loop_index_split!
68
- C.LLVMAddLoopIndexSplitPass(self)
69
- end
70
-
71
66
  def loop_rotate!
72
67
  C.LLVMAddLoopRotatePass(self)
73
68
  end
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-llvm
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.0
4
+ hash: 43
5
+ prerelease: false
6
+ segments:
7
+ - 2
8
+ - 9
9
+ - 0
10
+ version: 2.9.0
5
11
  platform: ruby
6
12
  authors:
7
13
  - Jeremy Voorhis
@@ -9,19 +15,25 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2010-06-10 00:00:00 -07:00
18
+ date: 2011-04-19 00:00:00 -07:00
13
19
  default_executable:
14
20
  dependencies:
15
21
  - !ruby/object:Gem::Dependency
16
22
  name: ffi
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
20
26
  requirements:
21
27
  - - ">="
22
28
  - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ - 5
33
+ - 4
23
34
  version: 0.5.4
24
- version:
35
+ type: :runtime
36
+ version_requirements: *id001
25
37
  description:
26
38
  email: jvoorhis@gmail.com
27
39
  executables: []
@@ -41,34 +53,43 @@ files:
41
53
  - lib/llvm/core.rb
42
54
  - lib/llvm/execution_engine.rb
43
55
  - lib/llvm/target.rb
56
+ - lib/llvm/transforms/ipo.rb
44
57
  - lib/llvm/transforms/scalar.rb
45
58
  - lib/llvm.rb
46
59
  - README.rdoc
47
60
  has_rdoc: true
48
61
  homepage: http://github.com/jvoorhis/ruby-llvm
62
+ licenses: []
63
+
49
64
  post_install_message:
50
65
  rdoc_options: []
51
66
 
52
67
  require_paths:
53
68
  - lib
54
69
  required_ruby_version: !ruby/object:Gem::Requirement
70
+ none: false
55
71
  requirements:
56
72
  - - ">="
57
73
  - !ruby/object:Gem::Version
74
+ hash: 3
75
+ segments:
76
+ - 0
58
77
  version: "0"
59
- version:
60
78
  required_rubygems_version: !ruby/object:Gem::Requirement
79
+ none: false
61
80
  requirements:
62
81
  - - ">="
63
82
  - !ruby/object:Gem::Version
83
+ hash: 3
84
+ segments:
85
+ - 0
64
86
  version: "0"
65
- version:
66
87
  requirements: []
67
88
 
68
89
  rubyforge_project:
69
- rubygems_version: 1.3.1
90
+ rubygems_version: 1.3.7
70
91
  signing_key:
71
- specification_version: 2
92
+ specification_version: 3
72
93
  summary: LLVM bindings for Ruby
73
94
  test_files: []
74
95