comparison docs/BitCodeFormat.rst @ 83:60c9769439b8 LLVM3.7

LLVM 3.7
author Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
date Wed, 18 Feb 2015 14:55:36 +0900
parents 54457678186b
children afa8332a0e37
comparison
equal deleted inserted replaced
78:af83660cff7b 83:60c9769439b8
26 structures, and you can parse the file without having to understand the tags. 26 structures, and you can parse the file without having to understand the tags.
27 Unlike XML, the bitstream format is a binary encoding, and unlike XML it 27 Unlike XML, the bitstream format is a binary encoding, and unlike XML it
28 provides a mechanism for the file to self-describe "abbreviations", which are 28 provides a mechanism for the file to self-describe "abbreviations", which are
29 effectively size optimizations for the content. 29 effectively size optimizations for the content.
30 30
31 LLVM IR files may be optionally embedded into a `wrapper`_ structure that makes 31 LLVM IR files may be optionally embedded into a `wrapper`_ structure, or in a
32 it easy to embed extra data along with LLVM IR files. 32 `native object file`_. Both of these mechanisms make it easy to embed extra
33 data along with LLVM IR files.
33 34
34 This document first describes the LLVM bitstream format, describes the wrapper 35 This document first describes the LLVM bitstream format, describes the wrapper
35 format, then describes the record structure used by LLVM IR files. 36 format, then describes the record structure used by LLVM IR files.
36 37
37 .. _bitstream container format: 38 .. _bitstream container format:
458 the version is currently always ``0``. The Offset field is the offset in bytes 459 the version is currently always ``0``. The Offset field is the offset in bytes
459 to the start of the bitcode stream in the file, and the Size field is the size 460 to the start of the bitcode stream in the file, and the Size field is the size
460 in bytes of the stream. CPUType is a target-specific value that can be used to 461 in bytes of the stream. CPUType is a target-specific value that can be used to
461 encode the CPU of the target. 462 encode the CPU of the target.
462 463
464 .. _native object file:
465
466 Native Object File Wrapper Format
467 =================================
468
469 Bitcode files for LLVM IR may also be wrapped in a native object file
470 (i.e. ELF, COFF, Mach-O). The bitcode must be stored in a section of the
471 object file named ``.llvmbc``. This wrapper format is useful for accommodating
472 LTO in compilation pipelines where intermediate objects must be native object
473 files which contain metadata in other sections.
474
475 Not all tools support this format.
476
463 .. _encoding of LLVM IR: 477 .. _encoding of LLVM IR:
464 478
465 LLVM IR Encoding 479 LLVM IR Encoding
466 ================ 480 ================
467 481
656 for each library name referenced. 670 for each library name referenced.
657 671
658 MODULE_CODE_GLOBALVAR Record 672 MODULE_CODE_GLOBALVAR Record
659 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 673 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
660 674
661 ``[GLOBALVAR, pointer type, isconst, initid, linkage, alignment, section, visibility, threadlocal, unnamed_addr, dllstorageclass]`` 675 ``[GLOBALVAR, pointer type, isconst, initid, linkage, alignment, section, visibility, threadlocal, unnamed_addr, externally_initialized, dllstorageclass, comdat]``
662 676
663 The ``GLOBALVAR`` record (code 7) marks the declaration or definition of a 677 The ``GLOBALVAR`` record (code 7) marks the declaration or definition of a
664 global variable. The operand fields are: 678 global variable. The operand fields are:
665 679
666 * *pointer type*: The type index of the pointer type used to point to this 680 * *pointer type*: The type index of the pointer type used to point to this
712 * ``localexec``: code 4 726 * ``localexec``: code 4
713 727
714 * *unnamed_addr*: If present and non-zero, indicates that the variable has 728 * *unnamed_addr*: If present and non-zero, indicates that the variable has
715 ``unnamed_addr`` 729 ``unnamed_addr``
716 730
717 .. _dllstorageclass: 731 .. _bcdllstorageclass:
718 732
719 * *dllstorageclass*: If present, an encoding of the DLL storage class of this variable: 733 * *dllstorageclass*: If present, an encoding of the DLL storage class of this variable:
720 734
721 * ``default``: code 0 735 * ``default``: code 0
722 * ``dllimport``: code 1 736 * ``dllimport``: code 1
725 .. _FUNCTION: 739 .. _FUNCTION:
726 740
727 MODULE_CODE_FUNCTION Record 741 MODULE_CODE_FUNCTION Record
728 ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 742 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
729 743
730 ``[FUNCTION, type, callingconv, isproto, linkage, paramattr, alignment, section, visibility, gc, prefix, dllstorageclass]`` 744 ``[FUNCTION, type, callingconv, isproto, linkage, paramattr, alignment, section, visibility, gc, prologuedata, dllstorageclass, comdat, prefixdata]``
731 745
732 The ``FUNCTION`` record (code 8) marks the declaration or definition of a 746 The ``FUNCTION`` record (code 8) marks the declaration or definition of a
733 function. The operand fields are: 747 function. The operand fields are:
734 748
735 * *type*: The type index of the function type describing this function 749 * *type*: The type index of the function type describing this function
768 of `MODULE_CODE_GCNAME`_ entries. 782 of `MODULE_CODE_GCNAME`_ entries.
769 783
770 * *unnamed_addr*: If present and non-zero, indicates that the function has 784 * *unnamed_addr*: If present and non-zero, indicates that the function has
771 ``unnamed_addr`` 785 ``unnamed_addr``
772 786
773 * *prefix*: If non-zero, the value index of the prefix data for this function, 787 * *prologuedata*: If non-zero, the value index of the prologue data for this function,
774 plus 1. 788 plus 1.
775 789
776 * *dllstorageclass*: An encoding of the `dllstorageclass`_ of this function 790 * *dllstorageclass*: An encoding of the
791 :ref:`dllstorageclass<bcdllstorageclass>` of this function
792
793 * *comdat*: An encoding of the COMDAT of this function
794
795 * *prefixdata*: If non-zero, the value index of the prefix data for this function,
796 plus 1.
797
777 798
778 MODULE_CODE_ALIAS Record 799 MODULE_CODE_ALIAS Record
779 ^^^^^^^^^^^^^^^^^^^^^^^^ 800 ^^^^^^^^^^^^^^^^^^^^^^^^
780 801
781 ``[ALIAS, alias type, aliasee val#, linkage, visibility, dllstorageclass]`` 802 ``[ALIAS, alias type, aliasee val#, linkage, visibility, dllstorageclass]``
789 810
790 * *linkage*: An encoding of the `linkage type`_ for this alias 811 * *linkage*: An encoding of the `linkage type`_ for this alias
791 812
792 * *visibility*: If present, an encoding of the `visibility`_ of the alias 813 * *visibility*: If present, an encoding of the `visibility`_ of the alias
793 814
794 * *dllstorageclass*: If present, an encoding of the `dllstorageclass`_ of the alias 815 * *dllstorageclass*: If present, an encoding of the
816 :ref:`dllstorageclass<bcdllstorageclass>` of the alias
795 817
796 MODULE_CODE_PURGEVALS Record 818 MODULE_CODE_PURGEVALS Record
797 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 819 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
798 820
799 ``[PURGEVALS, numvals]`` 821 ``[PURGEVALS, numvals]``