Class: LLVM::TargetDataLayout

Inherits:
Object
  • Object
show all
Defined in:
lib/llvm/target.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(representation) ⇒ TargetDataLayout

Creates a target data layout from a string representation.



236
237
238
# File 'lib/llvm/target.rb', line 236

def initialize(representation)
  @ptr = C.create_target_data(representation.to_s)
end

Class Method Details

.from_ptr(ptr) ⇒ Object



241
242
243
244
245
# File 'lib/llvm/target.rb', line 241

def self.from_ptr(ptr)
  target = allocate
  target.instance_variable_set :@ptr, ptr
  target
end

Instance Method Details

#abi_alignment_of(type) ⇒ Object

Computes the ABI alignment of a type in bytes for a target.



307
308
309
# File 'lib/llvm/target.rb', line 307

def abi_alignment_of(type)
  C.abi_alignment_of_type(self, type)
end

#abi_size_of(type) ⇒ Object

Computes the ABI size of a type in bytes for a target.



302
303
304
# File 'lib/llvm/target.rb', line 302

def abi_size_of(type)
  C.abi_size_of_type(self, type)
end

#bit_size_of(type) ⇒ Object

Computes the size of a type in bits for a target.



292
293
294
# File 'lib/llvm/target.rb', line 292

def bit_size_of(type)
  C.size_of_type_in_bits(self, type)
end

#byte_orderObject

Returns the byte order of a target, either :big_endian or :little_endian.



272
273
274
# File 'lib/llvm/target.rb', line 272

def byte_order
  C.byte_order(self)
end

#call_frame_alignment_of(type) ⇒ Object

Computes the call frame alignment of a type in bytes for a target.



312
313
314
# File 'lib/llvm/target.rb', line 312

def call_frame_alignment_of(type)
  C.call_frame_alignment_of_type(self, type)
end

#disposeObject

Destroys this instance of TargetDataLayout.



253
254
255
256
257
258
# File 'lib/llvm/target.rb', line 253

def dispose
  return if ptr.nil?

  C.dispose_target_data(self)
  @ptr = nil
end

#element_at_offset(type, offset) ⇒ Object

Computes the structure element that contains the byte offset for a target.



330
331
332
# File 'lib/llvm/target.rb', line 330

def element_at_offset(type, offset)
  C.element_at_offset(self, type, offset)
end

#int_ptr_type(address_space: 0) ⇒ Object

Returns the integer type that is the same size as a pointer on a target.

(?address_space: Integer) -> Type



287
288
289
# File 'lib/llvm/target.rb', line 287

def int_ptr_type(address_space: 0)
  Type.from_ptr(C.int_ptr_type_for_as(self, address_space), kind: :integer)
end

#offset_of_element(type, element) ⇒ Object

Computes the byte offset of the indexed struct element for a target.



335
336
337
# File 'lib/llvm/target.rb', line 335

def offset_of_element(type, element)
  C.offset_of_element(self, type, element)
end

#pointer_size(addr_space = 0) ⇒ Object

Returns the pointer size in bytes for a target.



279
280
281
# File 'lib/llvm/target.rb', line 279

def pointer_size(addr_space = 0)
  C.pointer_size_for_as(self, addr_space)
end

#preferred_alignment_of(entity) ⇒ Object

Computes the preferred alignment of a type or a global variable in bytes for a target.



320
321
322
323
324
325
326
327
# File 'lib/llvm/target.rb', line 320

def preferred_alignment_of(entity)
  case entity
  when LLVM::Type
    C.preferred_alignment_of_type(self, entity)
  when LLVM::GlobalValue
    C.preferred_alignment_of_global(self, entity)
  end
end

#storage_size_of(type) ⇒ Object

Computes the storage size of a type in bytes for a target.



297
298
299
# File 'lib/llvm/target.rb', line 297

def storage_size_of(type)
  C.store_size_of_type(self, type)
end

#to_ptrObject



248
249
250
# File 'lib/llvm/target.rb', line 248

def to_ptr
  @ptr
end

#to_sString

Returns string representation of target data layout.



263
264
265
266
267
268
269
# File 'lib/llvm/target.rb', line 263

def to_s
  string_ptr = C.copy_string_rep_of_target_data(self)
  string = string_ptr.read_string
  C.dispose_message(string_ptr)

  string
end