mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-05 13:26:55 +00:00
Change the .ll syntax for comdats and add a syntactic sugar.
In order to make comdats always explicit in the IR, we decided to make the syntax a bit more compact for the case of a GlobalObject in a comdat with the same name. Just dropping the $name causes problems for @foo = globabl i32 0, comdat $bar = comdat ... and declare void @foo() comdat $bar = comdat ... So the syntax is changed to @g1 = globabl i32 0, comdat($c1) @g2 = globabl i32 0, comdat and declare void @foo() comdat($c1) declare void @foo() comdat git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225302 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -596,7 +596,8 @@ Syntax::
|
||||
[@<GlobalVarName> =] [Linkage] [Visibility] [DLLStorageClass] [ThreadLocal]
|
||||
[unnamed_addr] [AddrSpace] [ExternallyInitialized]
|
||||
<global | constant> <Type> [<InitializerConstant>]
|
||||
[, section "name"] [, align <Alignment>]
|
||||
[, section "name"] [, comdat [($name)]]
|
||||
[, align <Alignment>]
|
||||
|
||||
For example, the following defines a global in a numbered address space
|
||||
with an initializer, section, and alignment:
|
||||
@@ -681,7 +682,7 @@ Syntax::
|
||||
define [linkage] [visibility] [DLLStorageClass]
|
||||
[cconv] [ret attrs]
|
||||
<ResultType> @<FunctionName> ([argument list])
|
||||
[unnamed_addr] [fn Attrs] [section "name"] [comdat $<ComdatName>]
|
||||
[unnamed_addr] [fn Attrs] [section "name"] [comdat [($name)]]
|
||||
[align N] [gc] [prefix Constant] [prologue Constant] { ... }
|
||||
|
||||
The argument list is a comma seperated sequence of arguments where each
|
||||
@@ -775,12 +776,21 @@ the COMDAT key's section is the largest:
|
||||
.. code-block:: llvm
|
||||
|
||||
$foo = comdat largest
|
||||
@foo = global i32 2, comdat $foo
|
||||
@foo = global i32 2, comdat($foo)
|
||||
|
||||
define void @bar() comdat $foo {
|
||||
define void @bar() comdat($foo) {
|
||||
ret void
|
||||
}
|
||||
|
||||
As a syntactic sugar the ``$name`` can be omitted if the name is the same as
|
||||
the global name:
|
||||
|
||||
.. code-block:: llvm
|
||||
|
||||
$foo = comdat any
|
||||
@foo = global i32 2, comdat
|
||||
|
||||
|
||||
In a COFF object file, this will create a COMDAT section with selection kind
|
||||
``IMAGE_COMDAT_SELECT_LARGEST`` containing the contents of the ``@foo`` symbol
|
||||
and another COMDAT section with selection kind
|
||||
@@ -803,8 +813,8 @@ For example:
|
||||
|
||||
$foo = comdat any
|
||||
$bar = comdat any
|
||||
@g1 = global i32 42, section "sec", comdat $foo
|
||||
@g2 = global i32 42, section "sec", comdat $bar
|
||||
@g1 = global i32 42, section "sec", comdat($foo)
|
||||
@g2 = global i32 42, section "sec", comdat($bar)
|
||||
|
||||
From the object file perspective, this requires the creation of two sections
|
||||
with the same name. This is necessary because both globals belong to different
|
||||
|
Reference in New Issue
Block a user