summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorNico Rieck <nico.rieck@gmail.com>2014-01-14 11:55:03 +0000
committerNico Rieck <nico.rieck@gmail.com>2014-01-14 11:55:03 +0000
commitbce07a0c3bb907488e75bcabe0d7c6a8fb9c7132 (patch)
treee2d9d6de6bafcbf303219d701a015e3e78a0388a /docs
parent1b1321f0805d74481af18c1bdefd6ed7ef2b60e6 (diff)
downloadllvm-bce07a0c3bb907488e75bcabe0d7c6a8fb9c7132.tar.gz
llvm-bce07a0c3bb907488e75bcabe0d7c6a8fb9c7132.tar.bz2
llvm-bce07a0c3bb907488e75bcabe0d7c6a8fb9c7132.tar.xz
Decouple dllexport/dllimport from linkage
Representing dllexport/dllimport as distinct linkage types prevents using these attributes on templates and inline functions. Instead of introducing further mixed linkage types to include linkonce and weak ODR, the old import/export linkage types are replaced with a new separate visibility-like specifier: define available_externally dllimport void @f() {} @Var = dllexport global i32 1, align 4 Linkage for dllexported globals and functions is now equal to their linkage without dllexport. Imported globals and functions must be either declarations with external linkage, or definitions with AvailableExternallyLinkage. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199204 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs')
-rw-r--r--docs/BitCodeFormat.rst18
-rw-r--r--docs/LangRef.rst64
2 files changed, 53 insertions, 29 deletions
diff --git a/docs/BitCodeFormat.rst b/docs/BitCodeFormat.rst
index 89531dcfea..9363a62d08 100644
--- a/docs/BitCodeFormat.rst
+++ b/docs/BitCodeFormat.rst
@@ -658,7 +658,7 @@ for each library name referenced.
MODULE_CODE_GLOBALVAR Record
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-``[GLOBALVAR, pointer type, isconst, initid, linkage, alignment, section, visibility, threadlocal, unnamed_addr]``
+``[GLOBALVAR, pointer type, isconst, initid, linkage, alignment, section, visibility, threadlocal, unnamed_addr, dllstorageclass]``
The ``GLOBALVAR`` record (code 7) marks the declaration or definition of a
global variable. The operand fields are:
@@ -713,12 +713,20 @@ global variable. The operand fields are:
* *unnamed_addr*: If present and non-zero, indicates that the variable has
``unnamed_addr``
+.. _dllstorageclass:
+
+* *dllstorageclass*: If present, an encoding of the DLL storage class of this variable:
+
+ * ``default``: code 0
+ * ``dllimport``: code 1
+ * ``dllexport``: code 2
+
.. _FUNCTION:
MODULE_CODE_FUNCTION Record
^^^^^^^^^^^^^^^^^^^^^^^^^^^
-``[FUNCTION, type, callingconv, isproto, linkage, paramattr, alignment, section, visibility, gc, prefix]``
+``[FUNCTION, type, callingconv, isproto, linkage, paramattr, alignment, section, visibility, gc, prefix, dllstorageclass]``
The ``FUNCTION`` record (code 8) marks the declaration or definition of a
function. The operand fields are:
@@ -762,10 +770,12 @@ function. The operand fields are:
* *prefix*: If non-zero, the value index of the prefix data for this function,
plus 1.
+* *dllstorageclass*: An encoding of the `dllstorageclass`_ of this function
+
MODULE_CODE_ALIAS Record
^^^^^^^^^^^^^^^^^^^^^^^^
-``[ALIAS, alias type, aliasee val#, linkage, visibility]``
+``[ALIAS, alias type, aliasee val#, linkage, visibility, dllstorageclass]``
The ``ALIAS`` record (code 9) marks the definition of an alias. The operand
fields are
@@ -778,6 +788,8 @@ fields are
* *visibility*: If present, an encoding of the `visibility`_ of the alias
+* *dllstorageclass*: If present, an encoding of the `dllstorageclass`_ of the alias
+
MODULE_CODE_PURGEVALS Record
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/docs/LangRef.rst b/docs/LangRef.rst
index ffe3f09d83..3540bdec8a 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 <dllstorageclass>`.
+
+Syntax::
+
+ [@<GlobalVarName> =] [Linkage] [Visibility] [DLLStorageClass] [ThreadLocal]
+ [AddrSpace] [unnamed_addr] [ExternallyInitialized]
+ <global | constant> <Type>
+ [, section "name"] [, align <Alignment>]
+
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 <linkage>`, an optional :ref:`visibility
-style <visibility>`, an optional :ref:`calling convention <callingconv>`,
+style <visibility>`, an optional :ref:`DLL storage class <dllstorageclass>`,
+an optional :ref:`calling convention <callingconv>`,
an optional ``unnamed_addr`` attribute, a return type, an optional
:ref:`parameter attribute <paramattrs>` 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 <linkage>`, an optional :ref:`visibility
-style <visibility>`, an optional :ref:`calling convention <callingconv>`,
+style <visibility>`, an optional :ref:`DLL storage class <dllstorageclass>`,
+an optional :ref:`calling convention <callingconv>`,
an optional ``unnamed_addr`` attribute, a return type, an optional
:ref:`parameter attribute <paramattrs>` 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]
<ResultType> @<FunctionName> ([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 <linkage>`, and an optional
-:ref:`visibility style <visibility>`.
+Aliases may have an optional :ref:`linkage type <linkage>`, an optional
+:ref:`visibility style <visibility>`, and an optional :ref:`DLL storage class
+<dllstorageclass>`.
Syntax::
- @<Name> = alias [Linkage] [Visibility] <AliaseeTy> @<Aliasee>
+ @<Name> = [Visibility] [DLLStorageClass] alias [Linkage] <AliaseeTy> @<Aliasee>
The linkage must be one of ``private``, ``linker_private``,
``linker_private_weak``, ``internal``, ``linkonce``, ``weak``,