X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=docs%2FLangRef.rst;h=3540bdec8acef3b54790081a1113fb588d8b6213;hb=38f68c5a2e3993a3ae51421d82e57ccca8f6ec38;hp=cc932515d247a3431e805ae90aa29113e59a07ec;hpb=4432a618e5b7c31ccdbe0efc0384a6c86c23c8d9;p=oota-llvm.git diff --git a/docs/LangRef.rst b/docs/LangRef.rst index cc932515d24..3540bdec8ac 100644 --- a/docs/LangRef.rst +++ b/docs/LangRef.rst @@ -274,27 +274,8 @@ linkage: visible, meaning that it participates in linkage and can be used to resolve external symbol references. -The next two types of linkage are targeted for Microsoft Windows -platform only. They are designed to support importing (exporting) -symbols from (to) DLLs (Dynamic Link Libraries). - -``dllimport`` - "``dllimport``" linkage causes the compiler to reference a function - or variable via a global pointer to a pointer that is set up by the - DLL exporting the symbol. On Microsoft Windows targets, the pointer - name is formed by combining ``__imp_`` and the function or variable - name. -``dllexport`` - "``dllexport``" linkage causes the compiler to provide a global - pointer to a pointer in a DLL, so that it can be referenced with the - ``dllimport`` attribute. On Microsoft Windows targets, the pointer - name is formed by combining ``__imp_`` and the function or variable - name. Since this linkage exists for defining a dll interface, the - compiler, assembler and linker know it is externally referenced and - must refrain from deleting the symbol. - It is illegal for a function *declaration* to have any linkage type -other than ``external``, ``dllimport`` or ``extern_weak``. +other than ``external`` or ``extern_weak``. .. _callingconv: @@ -416,6 +397,25 @@ styles: .. _namedtypes: +DLL Storage Classes +------------------- + +All Global Variables, Functions and Aliases can have one of the following +DLL storage class: + +``dllimport`` + "``dllimport``" causes the compiler to reference a function or variable via + a global pointer to a pointer that is set up by the DLL exporting the + symbol. On Microsoft Windows targets, the pointer name is formed by + combining ``__imp_`` and the function or variable name. +``dllexport`` + "``dllexport``" causes the compiler to provide a global pointer to a pointer + in a DLL, so that it can be referenced with the ``dllimport`` attribute. On + Microsoft Windows targets, the pointer name is formed by combining + ``__imp_`` and the function or variable name. Since this storage class + exists for defining a dll interface, the compiler, assembler and linker know + it is externally referenced and must refrain from deleting the symbol. + Named Types ----------- @@ -529,6 +529,15 @@ assume that the globals are densely packed in their section and try to iterate over them as an array, alignment padding would break this iteration. +Globals can also have a :ref:`DLL storage class `. + +Syntax:: + + [@ =] [Linkage] [Visibility] [DLLStorageClass] [ThreadLocal] + [AddrSpace] [unnamed_addr] [ExternallyInitialized] + + [, section "name"] [, align ] + For example, the following defines a global in a numbered address space with an initializer, section, and alignment: @@ -556,7 +565,8 @@ Functions LLVM function definitions consist of the "``define``" keyword, an optional :ref:`linkage type `, an optional :ref:`visibility -style `, an optional :ref:`calling convention `, +style `, an optional :ref:`DLL storage class `, +an optional :ref:`calling convention `, an optional ``unnamed_addr`` attribute, a return type, an optional :ref:`parameter attribute ` for the return type, a function name, a (possibly empty) argument list (each with optional :ref:`parameter @@ -567,7 +577,8 @@ curly brace, a list of basic blocks, and a closing curly brace. LLVM function declarations consist of the "``declare``" keyword, an optional :ref:`linkage type `, an optional :ref:`visibility -style `, an optional :ref:`calling convention `, +style `, an optional :ref:`DLL storage class `, +an optional :ref:`calling convention `, an optional ``unnamed_addr`` attribute, a return type, an optional :ref:`parameter attribute ` for the return type, a function name, a possibly empty list of arguments, an optional alignment, an optional @@ -603,7 +614,7 @@ be significant and two identical functions can be merged. Syntax:: - define [linkage] [visibility] + define [linkage] [visibility] [DLLStorageClass] [cconv] [ret attrs] @ ([argument list]) [fn Attrs] [section "name"] [align N] @@ -616,12 +627,13 @@ Aliases Aliases act as "second name" for the aliasee value (which can be either function, global variable, another alias or bitcast of global value). -Aliases may have an optional :ref:`linkage type `, and an optional -:ref:`visibility style `. +Aliases may have an optional :ref:`linkage type `, an optional +:ref:`visibility style `, and an optional :ref:`DLL storage class +`. Syntax:: - @ = alias [Linkage] [Visibility] @ + @ = [Visibility] [DLLStorageClass] alias [Linkage] @ The linkage must be one of ``private``, ``linker_private``, ``linker_private_weak``, ``internal``, ``linkonce``, ``weak``, @@ -1141,10 +1153,9 @@ as follows: ``p[n]:::`` This specifies the *size* of a pointer and its ```` and ````\erred alignments for address space ``n``. All sizes are in - bits. Specifying the ```` alignment is optional. If omitted, the - preceding ``:`` should be omitted too. The address space, ``n`` is - optional, and if not specified, denotes the default address space 0. - The value of ``n`` must be in the range [1,2^23). + bits. The address space, ``n`` is optional, and if not specified, + denotes the default address space 0. The value of ``n`` must be + in the range [1,2^23). ``i::`` This specifies the alignment for an integer type of a given bit ````. The value of ```` must be in the range [1,2^23). @@ -1157,9 +1168,8 @@ as follows: will work. 32 (float) and 64 (double) are supported on all targets; 80 or 128 (different flavors of long double) are also supported on some targets. -``a::`` - This specifies the alignment for an aggregate type of a given bit - ````. +``a::`` + This specifies the alignment for an object of aggregate type. ``m:`` If prerest, specifies that llvm names are mangled in the output. The options are @@ -1167,7 +1177,7 @@ as follows: * ``m``: Mips mangling: Private symbols get a ``$`` prefix. * ``o``: Mach-O mangling: Private symbols get ``L`` prefix. Other symbols get a ``_`` prefix. - * ``c``: COFF prefix: Similar to Mach-O, but stdcall and fastcall + * ``w``: Windows COFF prefix: Similar to Mach-O, but stdcall and fastcall functions also get a suffix based on the frame size. ``n::...`` This specifies a set of native integer widths for the target CPU in @@ -1176,6 +1186,10 @@ as follows: this set are considered to support most general arithmetic operations efficiently. +On every specification that takes a ``:``, specifying the +```` alignment is optional. If omitted, the preceding ``:`` +should be omitted too and ```` will be equal to ````. + When constructing the data layout for a given target, LLVM starts with a default set of specifications which are then (possibly) overridden by the specifications in the ``datalayout`` keyword. The default