Data Layout

(From 1) layout specification: A module may specify a target specific data layout string that specifies how data is to be laid out in memory. The IR syntax for the data layout is simply:

target datalayout = "layout specification"

(From 2) The XXXTargetMachine constructor will specify a TargetDescription string that determines the data layout for the target machine, including characteristics such as pointer size, alignment, and endianness. For example, the constructor for SparcTargetMachine contains the following:

SparcTargetMachine::SparcTargetMachine(const Module &M, const std::string &FS)
  : DataLayout("E-p:32:32-f128:128:128"),
    Subtarget(M, FS), InstrInfo(Subtarget),
    FrameInfo(TargetFrameInfo::StackGrowsDown, 8, 0) {
}

In this example, the layout specification string is "E-p:32:32-f128:128:128":

  • “E” indicates big-endian target data model.
  • “p:” is followed by pointer information: size, ABI alignment, and preferred alignment. If only two figures follow “p:“, then the first value is pointer size, and the second value is both ABI and preferred alignment;
  • “i”, “f”, “v”, or “a” are letters for numeric type alignment (integer, floating point, vector, aggregate). “i”, “v”, “a” are followed by ABI alignment and preferred alignment; “f” is followed by three values: the first indicates the size of a long double, then ABI alignment, then ABI preferred alignment.

Class definition: DataLayout

Cite: relation between address spaces and physical memory locations

David Chisnall via llvm-dev llvm-dev at lists.llvm.org Wed Mar 23 05:34:32 PDT 2016

On 23 Mar 2016, at 12:33, Hongbin Zheng wrote: > > Hi, > > Is it feasible to assign different DataLayout to different address space in the same LLVM IR module?

DataLayout is per module and describes, among other things, the different size and alignment requirements of pointers to different address spaces.

David

Created Sep 30, 2019 // Last Updated Nov 1, 2019

If you could revise
the fundmental principles of
computer system design
to improve security...

... what would you change?