Class: LLVM::Function
- Inherits:
-
GlobalValue
- Object
- Value
- User
- Constant
- GlobalValue
- LLVM::Function
- Defined in:
- lib/llvm/analysis.rb,
lib/llvm/core/value.rb
Defined Under Namespace
Classes: AttributeCollection, BasicBlockCollection, ParameterCollection
Instance Method Summary collapse
-
#add_attribute(attr, index = -1)) ⇒ Object
Adds attr to this value’s attributes.
- #attribute_count ⇒ Object
- #attributes ⇒ Object
-
#basic_blocks ⇒ Object
Returns an Enumerable of the BasicBlocks in this function.
-
#call_conv ⇒ Object
gets the calling convention of the function.
-
#call_conv=(conv) ⇒ Object
Sets the function’s calling convention and returns it.
- #function_attributes ⇒ Object
- #function_type ⇒ Object
- #gc ⇒ Object
- #gc=(name) ⇒ Object
- #inspect ⇒ Object
- #param_attributes(index) ⇒ Object
-
#params ⇒ Object
Returns an Enumerable of the parameters in the function.
- #readnone? ⇒ Boolean
- #readonly? ⇒ Boolean
-
#remove_attribute(attr, index = -1)) ⇒ Object
Removes the given attribute from the function.
- #return_attributes ⇒ Object
- #return_type ⇒ Object
-
#type ⇒ Object
In LLVM 15, not overriding this yields a pointer type instead of a function type.
- #valid? ⇒ Boolean
-
#verify ⇒ true, false
Verify that a function is valid.
-
#verify! ⇒ true, false
Verify that a function is valid, and abort the process if not.
- #writeonly? ⇒ Boolean
Methods inherited from GlobalValue
#alignment, #alignment=, #declaration?, #dll_storage_class, #dll_storage_class=, #global_constant=, #global_constant?, #initializer, #initializer=, #linkage, #linkage=, #section, #section=, #unnamed_addr=, #unnamed_addr?, #visibility, #visibility=
Methods inherited from Constant
#bitcast_to, #gep, null, null_ptr, #ptr_to_int, undef
Methods inherited from User
Methods inherited from Value
#allocated_type, #constant?, #dump, from_ptr, from_ptr_kind, #global_parent, #kind, #name, #name=, #null?, to_ptr, #to_s, type, #undefined?
Methods included from PointerIdentity
Instance Method Details
#add_attribute(attr, index = -1)) ⇒ Object
Adds attr to this value’s attributes.
882 883 884 |
# File 'lib/llvm/core/value.rb', line 882 def add_attribute(attr, index = -1) AttributeCollection.new(self, index).add(attr) end |
#attribute_count ⇒ Object
891 892 893 |
# File 'lib/llvm/core/value.rb', line 891 def attribute_count function_attributes.count end |
#attributes ⇒ Object
895 896 897 |
# File 'lib/llvm/core/value.rb', line 895 def attributes function_attributes.to_a end |
#basic_blocks ⇒ Object
Returns an Enumerable of the BasicBlocks in this function.
864 865 866 |
# File 'lib/llvm/core/value.rb', line 864 def basic_blocks @basic_block_collection ||= BasicBlockCollection.new(self) end |
#call_conv ⇒ Object
gets the calling convention of the function
859 860 861 |
# File 'lib/llvm/core/value.rb', line 859 def call_conv C.get_function_call_conv(self) end |
#call_conv=(conv) ⇒ Object
Sets the function’s calling convention and returns it.
853 854 855 856 |
# File 'lib/llvm/core/value.rb', line 853 def call_conv=(conv) C.set_function_call_conv(self, conv) conv end |
#function_attributes ⇒ Object
911 912 913 |
# File 'lib/llvm/core/value.rb', line 911 def function_attributes AttributeCollection.new(self, -1) end |
#function_type ⇒ Object
868 869 870 |
# File 'lib/llvm/core/value.rb', line 868 def function_type Type.from_ptr(C.get_element_type(self), :function) end |
#gc=(name) ⇒ Object
1091 1092 1093 |
# File 'lib/llvm/core/value.rb', line 1091 def gc=(name) C.set_gc(self, name) end |
#inspect ⇒ Object
1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 |
# File 'lib/llvm/core/value.rb', line 1099 def inspect { signature: to_s.lines[attribute_count == 0 ? 0 : 1], type: type.to_s, attributes: attribute_count, valid: valid?, blocks: basic_blocks.size, lines: to_s.lines.size, }.to_s end |
#param_attributes(index) ⇒ Object
919 920 921 |
# File 'lib/llvm/core/value.rb', line 919 def param_attributes(index) AttributeCollection.new(self, index) end |
#params ⇒ Object
Returns an Enumerable of the parameters in the function.
1058 1059 1060 |
# File 'lib/llvm/core/value.rb', line 1058 def params @parameter_collection ||= ParameterCollection.new(self) end |
#readnone? ⇒ Boolean
899 900 901 |
# File 'lib/llvm/core/value.rb', line 899 def readnone? attributes.detect(&:readnone?) end |
#readonly? ⇒ Boolean
903 904 905 |
# File 'lib/llvm/core/value.rb', line 903 def readonly? attributes.detect(&:readonly?) end |
#remove_attribute(attr, index = -1)) ⇒ Object
Removes the given attribute from the function.
887 888 889 |
# File 'lib/llvm/core/value.rb', line 887 def remove_attribute(attr, index = -1) AttributeCollection.new(self, index).remove(attr) end |
#return_attributes ⇒ Object
915 916 917 |
# File 'lib/llvm/core/value.rb', line 915 def return_attributes AttributeCollection.new(self, 0) end |
#return_type ⇒ Object
877 878 879 |
# File 'lib/llvm/core/value.rb', line 877 def return_type type.return_type end |
#type ⇒ Object
In LLVM 15, not overriding this yields a pointer type instead of a function type
873 874 875 |
# File 'lib/llvm/core/value.rb', line 873 def type function_type end |
#valid? ⇒ Boolean
49 50 51 |
# File 'lib/llvm/analysis.rb', line 49 def valid? verify end |
#verify ⇒ true, false
Verify that a function is valid.
39 40 41 |
# File 'lib/llvm/analysis.rb', line 39 def verify do_verification(:return_status) end |
#verify! ⇒ true, false
Verify that a function is valid, and abort the process if not.
45 46 47 |
# File 'lib/llvm/analysis.rb', line 45 def verify! do_verification(:abort_process) end |
#writeonly? ⇒ Boolean
907 908 909 |
# File 'lib/llvm/core/value.rb', line 907 def writeonly? attributes.detect(&:writeonly?) end |