ruby-llvm 16.0.1 → 17.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c6e1b8f07e635723694d6a987397f074c5433bcfad6867cb1832e71333c7a13e
4
- data.tar.gz: 730e751e566373dc30950c08b12eafa665403ac635ffa6d33bb5324b56cd906d
3
+ metadata.gz: 48dcc8621dc724981ca68f91f7daa86461fbe5a80c278d58d89645d3730f34cc
4
+ data.tar.gz: a196abfcc5891316857476db99e8b734207d5dab498715ad8cd69bc8a1b69810
5
5
  SHA512:
6
- metadata.gz: c1bbf9522c2c6a9782d46760138ff35ad5ed41b571bdd93425b3bc4d0d89992ec04cf904ec59fda21793a9edfa14ecb749128ccb4d03fa2a4b0801c5a22a61f9
7
- data.tar.gz: 917666ebfceda78a79299df2849bf653dfdd2d723615ba6e105bf56f54ab95f3580158903a8b9b4702ffd32e0764b79d246bd1aecac35faac12eabd049f2d54d
6
+ metadata.gz: 735a272ae85c2a2a2a1d9cf1f13211a5404dfe7a0e118870f2335395f3e610f45b95c1212ffc3eceabc71e9e68aeb4d8140a416b42bb5918bd73319be723479d
7
+ data.tar.gz: 11b93cfed8118fd90d0c885190c323dc2d61a404050385c62acb23fa900d8b7a39f8d5c61f78dd39be98979c9b7062f45b069c4185c8fec6a82337e8083a2d54
@@ -4,7 +4,7 @@ require 'ffi'
4
4
 
5
5
  module LLVM::C
6
6
  extend FFI::Library
7
- ffi_lib ["libLLVM-16.so.1", "libLLVM.so.16", "LLVM-16"]
7
+ ffi_lib ["libLLVM-17.so.1", "libLLVM.so.17", "LLVM-17"]
8
8
 
9
9
  def self.attach_function(name, *_)
10
10
  begin; super; rescue FFI::NotFoundError => e
@@ -4,7 +4,7 @@ require 'ffi'
4
4
 
5
5
  module LLVM::C
6
6
  extend FFI::Library
7
- ffi_lib ["libLLVM-16.so.1", "libLLVM.so.16", "LLVM-16"]
7
+ ffi_lib ["libLLVM-17.so.1", "libLLVM.so.17", "LLVM-17"]
8
8
 
9
9
  def self.attach_function(name, *_)
10
10
  begin; super; rescue FFI::NotFoundError => e
@@ -939,18 +939,18 @@ module LLVM
939
939
  end
940
940
 
941
941
  private def call2_infer_function_and_type(type, fun)
942
- fun = insert_block.parent.global_parent.functions[fun.to_s] unless fun.is_a?(LLVM::Value)
942
+ fun2 = fun.is_a?(LLVM::Value) ? fun : insert_block.parent.global_parent.functions[fun.to_s]
943
943
 
944
- msg = "Function provided to call instruction was neither a value nor a function name: #{fun.inspect}"
945
- raise ArgumentError, msg if fun.nil?
944
+ msg = "Function provided to call instruction was neither a value nor a function name:"
945
+ raise ArgumentError, "#{msg} #{fun}" if fun2.nil?
946
946
 
947
- msg = "Type must be provided to call2 when function argument is not a function type: #{fun.inspect}"
948
- raise ArgumentError, msg if !fun.is_a?(Function) && type.nil?
947
+ msg = "Type must be provided to call2 when function argument is not a function type:"
948
+ raise ArgumentError, "#{msg} #{fun}" if !fun2.is_a?(Function) && type.nil?
949
949
 
950
- type ||= fun.function_type
950
+ type ||= fun2.function_type
951
951
  must_be_type!(type)
952
952
 
953
- [type, fun]
953
+ [type, fun2]
954
954
  end
955
955
 
956
956
  def call2(type, fun, *args)
@@ -13,9 +13,8 @@ module LLVM
13
13
  #
14
14
  # @param [LLVM::ExecutionEngine, LLVM::TargetMachine] machine
15
15
  def initialize(machine = nil)
16
- if machine
17
- warn("[DEPRECATION] PassManager.new should be called without parameters")
18
- end
16
+ warn("[DEPRECATION] PassManager.new should be called without parameters") if machine
17
+
19
18
  @ptr = C.create_pass_manager()
20
19
  end
21
20
 
@@ -869,12 +869,16 @@ module LLVM
869
869
  attr_ref = case attr
870
870
  when Attribute
871
871
  attr
872
- when Symbol
872
+ when Symbol, String
873
873
  attr_kind_id = attribute_id(attr)
874
- ctx = Context.global
875
- C.create_enum_attribute(ctx, attr_kind_id, 0)
874
+ if attr_kind_id.is_a?(Integer)
875
+ ctx = Context.global
876
+ C.create_enum_attribute(ctx, attr_kind_id, 0)
877
+ else
878
+ attr_kind_id
879
+ end
876
880
  else
877
- raise "Adding unknown attribute type"
881
+ raise "Adding unknown attribute type: #{attr.inspect}"
878
882
  end
879
883
  C.add_attribute_at_index(@fun, @index, attr_ref)
880
884
  end
@@ -911,12 +915,31 @@ module LLVM
911
915
  end
912
916
 
913
917
  def attribute_id(attr_name)
918
+ upgrade = upgrade_attr(attr_name)
919
+ return upgrade if upgrade
920
+
914
921
  attr_mem = FFI::MemoryPointer.from_string(attribute_name(attr_name))
915
922
  attr_kind_id = C.get_enum_attribute_kind_for_name(attr_mem, attr_mem.size - 1)
916
923
 
917
924
  raise "No attribute named: #{attr_name}" if attr_kind_id.zero?
918
925
  attr_kind_id
919
926
  end
927
+
928
+ # Upgrade attributes from before LLVM 16
929
+ # readnone, readonly, writeonly
930
+ def upgrade_attr(attr)
931
+ case attr.to_sym
932
+ when :readnone
933
+ LLVM::Attribute.memory
934
+ when :readonly
935
+ LLVM::Attribute.memory(memory: :read)
936
+ when :writeonly
937
+ LLVM::Attribute.memory(memory: :write)
938
+ when :inaccessiblememonly
939
+ LLVM::Attribute.memory(inaccessiblemem: :readwrite)
940
+ end
941
+ end
942
+
920
943
  end
921
944
 
922
945
  # @private
data/lib/llvm/core.rb CHANGED
@@ -239,6 +239,7 @@ module LLVM
239
239
  require 'llvm/core/value'
240
240
  require 'llvm/core/builder'
241
241
  require 'llvm/core/pass_manager'
242
+ require 'llvm/transforms/pass_builder'
242
243
  require 'llvm/core/bitcode'
243
244
  require 'llvm/core/attribute'
244
245
  end
data/lib/llvm/core_ffi.rb CHANGED
@@ -4,7 +4,7 @@ require 'ffi'
4
4
 
5
5
  module LLVM::C
6
6
  extend FFI::Library
7
- ffi_lib ["libLLVM-16.so.1", "libLLVM.so.16", "LLVM-16"]
7
+ ffi_lib ["libLLVM-17.so.1", "libLLVM.so.17", "LLVM-17"]
8
8
 
9
9
  def self.attach_function(name, *_)
10
10
  begin; super; rescue FFI::NotFoundError => e
@@ -4,7 +4,7 @@ require 'ffi'
4
4
 
5
5
  module LLVM::C
6
6
  extend FFI::Library
7
- ffi_lib ["libLLVM-16.so.1", "libLLVM.so.16", "LLVM-16"]
7
+ ffi_lib ["libLLVM-17.so.1", "libLLVM.so.17", "LLVM-17"]
8
8
 
9
9
  def self.attach_function(name, *_)
10
10
  begin; super; rescue FFI::NotFoundError => e
@@ -4,7 +4,7 @@ require 'ffi'
4
4
 
5
5
  module LLVM::C
6
6
  extend FFI::Library
7
- ffi_lib ["libLLVM-16.so.1", "libLLVM.so.16", "LLVM-16"]
7
+ ffi_lib ["libLLVM-17.so.1", "libLLVM.so.17", "LLVM-17"]
8
8
 
9
9
  def self.attach_function(name, *_)
10
10
  begin; super; rescue FFI::NotFoundError => e
data/lib/llvm/target.rb CHANGED
@@ -25,7 +25,7 @@ module LLVM
25
25
 
26
26
  module TargetModule
27
27
  extend FFI::Library
28
- ffi_lib ["libLLVM-16.so.1", "libLLVM.so.16", "LLVM-16"]
28
+ ffi_lib ["libLLVM-17.so.1", "libLLVM.so.17", "LLVM-17"]
29
29
 
30
30
  def self.safe_attach_function(*args)
31
31
  attach_function(*args)
@@ -4,7 +4,7 @@ require 'ffi'
4
4
 
5
5
  module LLVM::C
6
6
  extend FFI::Library
7
- ffi_lib ["libLLVM-16.so.1", "libLLVM.so.16", "LLVM-16"]
7
+ ffi_lib ["libLLVM-17.so.1", "libLLVM.so.17", "LLVM-17"]
8
8
 
9
9
  def self.attach_function(name, *_)
10
10
  begin; super; rescue FFI::NotFoundError => e
@@ -3,122 +3,116 @@
3
3
  # Interprocedural optimization (IPO)
4
4
  require 'llvm'
5
5
  require 'llvm/core'
6
- require 'llvm/transforms/ipo_ffi'
7
6
 
8
7
  module LLVM
9
8
  class PassManager
10
9
  # @LLVMpass arg_promotion
11
10
  def arg_promote!
12
- warn('arg_promote! / LLVMAddArgumentPromotionPass was removed from LLVM')
11
+ raise DeprecationError
13
12
  end
14
13
 
15
14
  # @LLVMpass const_merge
16
15
  # /** See llvm::createConstantMergePass function. */
17
16
  # void LLVMAddConstantMergePass(LLVMPassManagerRef PM);
18
17
  def const_merge!
19
- C.add_constant_merge_pass(self)
18
+ raise DeprecationError
20
19
  end
21
20
 
22
21
  # @LLVMpass mergefunc
23
22
  # /** See llvm::createMergeFunctionsPass function. */
24
23
  # void LLVMAddMergeFunctionsPass(LLVMPassManagerRef PM);
25
24
  def mergefunc!
26
- C.add_merge_functions_pass(self)
25
+ raise DeprecationError
27
26
  end
28
27
 
29
28
  # @LLVMpass called-value-propagation
30
29
  # /** See llvm::createCalledValuePropagationPass function. */
31
30
  # void LLVMAddCalledValuePropagationPass(LLVMPassManagerRef PM);
32
31
  def called_value_propagation!
33
- C.add_called_value_propagation_pass(self)
32
+ raise DeprecationError
34
33
  end
35
34
 
36
35
  # @LLVMpass dae
37
36
  # /** See llvm::createDeadArgEliminationPass function. */
38
37
  # void LLVMAddDeadArgEliminationPass(LLVMPassManagerRef PM);
39
38
  def dae!
40
- C.add_dead_arg_elimination_pass(self)
39
+ raise DeprecationError
41
40
  end
42
41
 
43
42
  # @LLVMpass function_attrs
44
43
  # /** See llvm::createFunctionAttrsPass function. */
45
44
  # void LLVMAddFunctionAttrsPass(LLVMPassManagerRef PM);
46
45
  def fun_attrs!
47
- C.add_function_attrs_pass(self)
46
+ raise DeprecationError
48
47
  end
49
48
 
50
49
  # @LLVMpass inline
51
50
  # /** See llvm::createFunctionInliningPass function. */
52
51
  # void LLVMAddFunctionInliningPass(LLVMPassManagerRef PM);
53
52
  def inline!
54
- C.add_function_inlining_pass(self)
53
+ raise DeprecationError
55
54
  end
56
55
 
57
56
  # @LLVMpass always_inline
58
57
  # /** See llvm::createAlwaysInlinerPass function. */
59
58
  # void LLVMAddAlwaysInlinerPass(LLVMPassManagerRef PM);
60
59
  def always_inline!
61
- C.add_always_inliner_pass(self)
60
+ raise DeprecationError
62
61
  end
63
62
 
64
63
  # @LLVMpass gdce
65
64
  # /** See llvm::createGlobalDCEPass function. */
66
65
  # void LLVMAddGlobalDCEPass(LLVMPassManagerRef PM);
67
66
  def gdce!
68
- C.add_global_dce_pass(self)
67
+ raise DeprecationError
69
68
  end
70
69
 
71
70
  # @LLVMpass global_opt
72
71
  # /** See llvm::createGlobalOptimizerPass function. */
73
72
  # void LLVMAddGlobalOptimizerPass(LLVMPassManagerRef PM);
74
73
  def global_opt!
75
- C.add_global_optimizer_pass(self)
74
+ raise DeprecationError
76
75
  end
77
76
 
78
77
  # @LLVMpass ipcp
79
78
  def ipcp!
80
- warn('ipcp! / LLVMAddIPConstantPropagationPass was removed from LLVM')
79
+ raise DeprecationError
81
80
  end
82
81
 
83
82
  # @LLVMpass prune_eh
84
83
  # /** See llvm::createPruneEHPass function. */
85
84
  # void LLVMAddPruneEHPass(LLVMPassManagerRef PM);
86
85
  def prune_eh!
87
- warn('prune_eh! / LLVMAddPruneEHPass was removed in LLVM 16')
86
+ raise DeprecationError
88
87
  end
89
88
 
90
89
  # @LLVMpass ipsccp
91
90
  # /** See llvm::createIPSCCPPass function. */
92
91
  # void LLVMAddIPSCCPPass(LLVMPassManagerRef PM);
93
92
  def ipsccp!
94
- C.add_ipsccp_pass(self)
93
+ raise DeprecationError
95
94
  end
96
95
 
97
96
  # @LLVMpass internalize
98
97
  # /** See llvm::createInternalizePass function. */
99
98
  # void LLVMAddInternalizePass(LLVMPassManagerRef, unsigned AllButMain);
100
- def internalize!(all_but_main = true)
101
- C.add_internalize_pass(self, all_but_main ? 1 : 0)
99
+ def internalize!(_all_but_main = true)
100
+ raise DeprecationError
102
101
  end
103
102
 
104
103
  # @LLVMpass sdp
105
104
  # /** See llvm::createStripDeadPrototypesPass function. */
106
105
  # void LLVMAddStripDeadPrototypesPass(LLVMPassManagerRef PM);
107
106
  def sdp!
108
- C.add_strip_dead_prototypes_pass(self)
107
+ raise DeprecationError
109
108
  end
110
109
 
111
110
  # @LLVMpass strip
112
111
  # /** See llvm::createStripSymbolsPass function. */
113
112
  # void LLVMAddStripSymbolsPass(LLVMPassManagerRef PM);
114
113
  def strip!
115
- C.add_strip_symbols_pass(self)
114
+ raise DeprecationError
116
115
  end
117
116
 
118
117
  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
123
- end
124
118
  end