Class: LLVM::Constant
Direct Known Subclasses
ConstantArray, ConstantExpr, ConstantInt, ConstantReal, ConstantStruct, ConstantVector, GlobalValue
Class Method Summary collapse
-
.null(type) ⇒ Object
Creates a null constant of Type.
-
.null_ptr(type) ⇒ Object
Creates a null pointer constant of Type.
-
.undef(type) ⇒ Object
Creates a undefined constant of Type.
Instance Method Summary collapse
-
#bitcast_to(type) ⇒ Object
Bitcast this constant to Type.
-
#gep(*indices) ⇒ Object
Returns the element pointer at the given indices of the constant.
Methods inherited from User
Methods inherited from Value
#==, #add_attribute, #constant?, #dump, #eql?, from_ptr, #initialize, #name, #name=, #null?, to_ptr, #to_ptr, type, #type, #undefined?
Constructor Details
This class inherits a constructor from LLVM::Value
Class Method Details
.null(type) ⇒ Object
Creates a null constant of Type.
226 227 228 |
# File 'lib/llvm/core/value.rb', line 226 def self.null(type) from_ptr(C.LLVMConstNull(type)) end |
.null_ptr(type) ⇒ Object
Creates a null pointer constant of Type.
236 237 238 |
# File 'lib/llvm/core/value.rb', line 236 def self.null_ptr(type) from_ptr(C.LLVMConstPointerNull(type)) end |
.undef(type) ⇒ Object
Creates a undefined constant of Type.
231 232 233 |
# File 'lib/llvm/core/value.rb', line 231 def self.undef(type) from_ptr(C.LLVMGetUndef(type)) end |
Instance Method Details
#bitcast_to(type) ⇒ Object
Bitcast this constant to Type.
241 242 243 |
# File 'lib/llvm/core/value.rb', line 241 def bitcast_to(type) ConstantExpr.from_ptr(C.LLVMConstBitCast(self, type)) end |
#gep(*indices) ⇒ Object
Returns the element pointer at the given indices of the constant. For more information on gep go to: llvm.org/docs/GetElementPtr.html
247 248 249 250 251 252 253 254 |
# File 'lib/llvm/core/value.rb', line 247 def gep(*indices) indices = Array(indices) FFI::MemoryPointer.new(FFI.type_size(:pointer) * indices.size) do |indices_ptr| indices_ptr.write_array_of_pointer(indices) return ConstantExpr.from_ptr( C.LLVMConstGEP(self, indices_ptr, indices.size)) end end |