From de151948393534b6f3ed9c2540d80256605a4103 Mon Sep 17 00:00:00 2001
From: Reid Spencer
Date: Mon, 19 Feb 2007 23:54:10 +0000
Subject: [PATCH] Add a section on the target datalayout syntax and describe
the defaults and rules used by LLVM to construct the target's layout rules.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34433 91177308-0d34-0410-b5e6-96231b3b80d8
---
docs/LangRef.html | 81 +++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 79 insertions(+), 2 deletions(-)
diff --git a/docs/LangRef.html b/docs/LangRef.html
index adf6e7f085f..b6f6f47256c 100644
--- a/docs/LangRef.html
+++ b/docs/LangRef.html
@@ -26,6 +26,7 @@
Functions
Parameter Attributes
Module-Level Inline Assembly
+ Data Layout
Type System
@@ -771,6 +772,82 @@ desired. The syntax is very simple:
+
+
+
A module may specify a target specific data layout string that specifies how
+data is to be laid out in memory. The syntax for the data layout is simply:
+
target datalayout = "layout specification"
+
+The
layout specification consists of a list of specifications separated
+by the minus sign character ('-'). Each specification starts with a letter
+and may include other information after the letter to define some aspect of the
+data layout. The specifications accepted are as follows:
+
+ - E
+ - Specifies that the target lays out data in big-endian form. That is, the
+ bits with the most significance have the lowest address location.
+ - e
+ - Specifies that hte target lays out data in little-endian form. That is,
+ the bits with the least significance have the lowest address location.
+ - p:size:abi:pref
+ - This specifies the size of a pointer and its abi and
+ preferred alignments. All sizes are in bits. Specifying the pref
+ alignment is optional. If omitted, the preceding : should be omitted
+ too.
+ - isize:abi:pref
+ - This specifies the alignment for an integer type of a given bit
+ size. The value of size must be in the range [1,2^23).
+ - vsize:abi:pref
+ - This specifies the alignment for a vector type of a given bit
+ size.
+ - fsize:abi:pref
+ - This specifies the alignment for a floating point type of a given bit
+ size. The value of size must be either 32 (float) or 64
+ (double).
+ - asize:abi:pref
+ - This specifies the alignment for an aggregate type of a given bit
+ size.
+
+
When constructing the data layout for a given target, LLVM starts with a
+default set of specifications which are then (possibly) overriden by the
+specifications in the datalayout keyword. The default specifications
+are given in this list:
+
+ - E - big endian
+ - p:32:64:64 - 32-bit pointers with 64-bit alignment
+ - i1:8:8 - i1 is 8-bit (byte) aligned
+ - i8:8:8 - i8 is 8-bit (byte) aligned
+ - i16:16:16 - i16 is 16-bit aligned
+ - i32:32:32 - i32 is 32-bit aligned
+ - i64:32:64 - i64 has abi alignment of 32-bits but preferred
+ alignment of 64-bits
+ - f32:32:32 - float is 32-bit aligned
+ - f64:64:64 - double is 64-bit aligned
+ - v64:64:64 - 64-bit vector is 64-bit aligned
+ - v128:128:128 - 128-bit vector is 128-bit aligned
+ - a0:0:1 - aggregates are 8-bit aligned
+
+
When llvm is determining the alignment for a given type, it uses the
+following rules:
+
+ - If the type sought is an exact match for one of the specifications, that
+ specification is used.
+ - If no match is found, and the type sought is an integer type, then the
+ smallest integer type that is larger than the bitwidth of the sought type is
+ used. If none of the specifications are larger than the bitwidth then the the
+ largest integer type is used. For example, given the default specifications
+ above, the i7 type will use the alignment of i8 (next largest) while both
+ i65 and i256 will use the alignment of i64 (largest specified).
+ - If no match is found, and the type sought is a vector type, then the
+ largest vector type that is smaller than the sought vector type will be used
+ as a fall back. This happens because <128 x double> can be implemented in
+ terms of 64 <2 x double>, for example.
+
+