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, #allocated_type?, #constant?, #dump, from_ptr_kind, #gep_source_element_type, #gep_source_element_type?, #global_parent, #kind, #name, #name=, #null?, #poison?, #remove_attribute, to_ptr, #to_s, #type, type, #undef?

Methods included from PointerIdentity

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

Class Method Details

.from_ptr(ptr) ⇒ Object

Create Instruction from pointer to value many places where this is called, the instruction may be a constant, so create those instead



1193
1194
1195
1196
# File 'lib/llvm/core/value.rb', line 1193

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

Instance Method Details

#clear_exact!Object



1249
1250
1251
1252
# File 'lib/llvm/core/value.rb', line 1249

def clear_exact!
  C.set_exact(self, false)
  self
end

#clear_nsw!Object



1229
1230
1231
1232
# File 'lib/llvm/core/value.rb', line 1229

def clear_nsw!
  C.set_nsw(self, false)
  self
end

#clear_nuw!Object



1239
1240
1241
1242
# File 'lib/llvm/core/value.rb', line 1239

def clear_nuw!
  C.set_nuw(self, false)
  self
end

#exact!Object



1244
1245
1246
1247
# File 'lib/llvm/core/value.rb', line 1244

def exact!
  C.set_exact(self, true)
  self
end

#inspectObject



1220
1221
1222
# File 'lib/llvm/core/value.rb', line 1220

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

#nextObject

Returns the next instruction after this one.



1205
1206
1207
1208
# File 'lib/llvm/core/value.rb', line 1205

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

#nsw!Object



1224
1225
1226
1227
# File 'lib/llvm/core/value.rb', line 1224

def nsw!
  C.set_nsw(self, true)
  self
end

#nuw!Object



1234
1235
1236
1237
# File 'lib/llvm/core/value.rb', line 1234

def nuw!
  C.set_nuw(self, true)
  self
end

#opcodeObject



1216
1217
1218
# File 'lib/llvm/core/value.rb', line 1216

def opcode
  C.get_instruction_opcode(self)
end

#parentObject

Returns the parent of the instruction (a BasicBlock).



1199
1200
1201
1202
# File 'lib/llvm/core/value.rb', line 1199

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.



1211
1212
1213
1214
# File 'lib/llvm/core/value.rb', line 1211

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