Class: LLVM::Instruction

Inherits:
User show all
Defined in:
lib/llvm/core/value.rb

Direct Known Subclasses

CallInst, IndirectBr, Phi, SwitchInst

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from User

#operands

Methods inherited from Value

#add_attribute, #allocated_type, #constant?, #dump, from_ptr_kind, #global_parent, #kind, #name, #name=, #null?, #remove_attribute, to_ptr, #to_s, #type, type, #undefined?

Methods included from PointerIdentity

#==, #eql?, #hash, #to_ptr

Class Method Details

.from_ptr(ptr) ⇒ Object



1153
1154
1155
1156
# File 'lib/llvm/core/value.rb', line 1153

def self.from_ptr(ptr)
  kind = C.get_value_kind(ptr)
  kind == :instruction ? super : LLVM::Value.from_ptr_kind(ptr)
end

Instance Method Details

#inspectObject



1180
1181
1182
# File 'lib/llvm/core/value.rb', line 1180

def inspect
  { self.class.name => { opcode: opcode, ptr: @ptr } }.to_s
end

#nextObject

Returns the next instruction after this one.



1165
1166
1167
1168
# File 'lib/llvm/core/value.rb', line 1165

def next
  ptr = C.get_next_instruction(self)
  LLVM::Instruction.from_ptr(ptr) unless ptr.null?
end

#opcodeObject



1176
1177
1178
# File 'lib/llvm/core/value.rb', line 1176

def opcode
  C.get_instruction_opcode(self)
end

#parentObject

Returns the parent of the instruction (a BasicBlock).



1159
1160
1161
1162
# File 'lib/llvm/core/value.rb', line 1159

def parent
  ptr = C.get_instruction_parent(self)
  LLVM::BasicBlock.from_ptr(ptr) unless ptr.null?
end

#previousObject

Returns the previous instruction before this one.



1171
1172
1173
1174
# File 'lib/llvm/core/value.rb', line 1171

def previous
  ptr = C.get_previous_instruction(self)
  LLVM::Instruction.from_ptr(ptr) unless ptr.null?
end