Class: LLVM::Instruction

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

Direct Known Subclasses

Alloca, CallInst, IndirectBr, Phi, SwitchInst

Instance Attribute Summary

Attributes included from PointerIdentity

#ptr

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 : (FFI::Pointer) -> (Value | Instruction)



1270
1271
1272
1273
# File 'lib/llvm/core/value.rb', line 1270

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



1336
1337
1338
1339
# File 'lib/llvm/core/value.rb', line 1336

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

#clear_nsw!Object

: -> self



1313
1314
1315
1316
# File 'lib/llvm/core/value.rb', line 1313

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

#clear_nuw!Object

: -> self



1325
1326
1327
1328
# File 'lib/llvm/core/value.rb', line 1325

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

#exact!Object

: -> self



1331
1332
1333
1334
# File 'lib/llvm/core/value.rb', line 1331

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

#inspectObject

: -> String



1302
1303
1304
# File 'lib/llvm/core/value.rb', line 1302

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

#nextObject

Returns the next instruction after this one. : -> LLVM::Instruction?



1284
1285
1286
1287
# File 'lib/llvm/core/value.rb', line 1284

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

#nsw!Object

: -> self



1307
1308
1309
1310
# File 'lib/llvm/core/value.rb', line 1307

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

#nuw!Object

: -> self



1319
1320
1321
1322
# File 'lib/llvm/core/value.rb', line 1319

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

#opcodeObject

: -> Integer



1297
1298
1299
# File 'lib/llvm/core/value.rb', line 1297

def opcode
  C.get_instruction_opcode(self)
end

#parentObject

Returns the parent of the instruction (a BasicBlock). : -> LLVM::BasicBlock?



1277
1278
1279
1280
# File 'lib/llvm/core/value.rb', line 1277

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. : -> LLVM::Instruction?



1291
1292
1293
1294
# File 'lib/llvm/core/value.rb', line 1291

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