Mercurial > hg > CbC > CbC_llvm
comparison docs/BitCodeFormat.rst @ 121:803732b1fca8
LLVM 5.0
author | kono |
---|---|
date | Fri, 27 Oct 2017 17:07:41 +0900 |
parents | 1172e4bd9c6f |
children | 3a76565eade5 |
comparison
equal
deleted
inserted
replaced
120:1172e4bd9c6f | 121:803732b1fca8 |
---|---|
548 * 16 --- `METADATA_ATTACHMENT`_ --- This contains records associating metadata | 548 * 16 --- `METADATA_ATTACHMENT`_ --- This contains records associating metadata |
549 with function instruction values. | 549 with function instruction values. |
550 | 550 |
551 * 17 --- `TYPE_BLOCK`_ --- This describes all of the types in the module. | 551 * 17 --- `TYPE_BLOCK`_ --- This describes all of the types in the module. |
552 | 552 |
553 * 23 --- `STRTAB_BLOCK`_ --- The bitcode file's string table. | |
554 | |
553 .. _MODULE_BLOCK: | 555 .. _MODULE_BLOCK: |
554 | 556 |
555 MODULE_BLOCK Contents | 557 MODULE_BLOCK Contents |
556 --------------------- | 558 --------------------- |
557 | 559 |
575 ^^^^^^^^^^^^^^^^^^^^^^^^^^ | 577 ^^^^^^^^^^^^^^^^^^^^^^^^^^ |
576 | 578 |
577 ``[VERSION, version#]`` | 579 ``[VERSION, version#]`` |
578 | 580 |
579 The ``VERSION`` record (code 1) contains a single value indicating the format | 581 The ``VERSION`` record (code 1) contains a single value indicating the format |
580 version. Versions 0 and 1 are supported at this time. The difference between | 582 version. Versions 0, 1 and 2 are supported at this time. The difference between |
581 version 0 and 1 is in the encoding of instruction operands in | 583 version 0 and 1 is in the encoding of instruction operands in |
582 each `FUNCTION_BLOCK`_. | 584 each `FUNCTION_BLOCK`_. |
583 | 585 |
584 In version 0, each value defined by an instruction is assigned an ID | 586 In version 0, each value defined by an instruction is assigned an ID |
585 unique to the function. Function-level value IDs are assigned starting from | 587 unique to the function. Function-level value IDs are assigned starting from |
618 This can be inefficient, as operands are normally encoded | 620 This can be inefficient, as operands are normally encoded |
619 as unsigned VBRs. However, forward references are rare, except in the | 621 as unsigned VBRs. However, forward references are rare, except in the |
620 case of phi instructions. For phi instructions, operands are encoded as | 622 case of phi instructions. For phi instructions, operands are encoded as |
621 `Signed VBRs`_ to deal with forward references. | 623 `Signed VBRs`_ to deal with forward references. |
622 | 624 |
625 In version 2, the meaning of module records ``FUNCTION``, ``GLOBALVAR``, | |
626 ``ALIAS``, ``IFUNC`` and ``COMDAT`` change such that the first two operands | |
627 specify an offset and size of a string in a string table (see `STRTAB_BLOCK | |
628 Contents`_), the function name is removed from the ``FNENTRY`` record in the | |
629 value symbol table, and the top-level ``VALUE_SYMTAB_BLOCK`` may only contain | |
630 ``FNENTRY`` records. | |
623 | 631 |
624 MODULE_CODE_TRIPLE Record | 632 MODULE_CODE_TRIPLE Record |
625 ^^^^^^^^^^^^^^^^^^^^^^^^^ | 633 ^^^^^^^^^^^^^^^^^^^^^^^^^ |
626 | 634 |
627 ``[TRIPLE, ...string...]`` | 635 ``[TRIPLE, ...string...]`` |
671 for each library name referenced. | 679 for each library name referenced. |
672 | 680 |
673 MODULE_CODE_GLOBALVAR Record | 681 MODULE_CODE_GLOBALVAR Record |
674 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | 682 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
675 | 683 |
676 ``[GLOBALVAR, pointer type, isconst, initid, linkage, alignment, section, visibility, threadlocal, unnamed_addr, externally_initialized, dllstorageclass, comdat]`` | 684 ``[GLOBALVAR, strtab offset, strtab size, pointer type, isconst, initid, linkage, alignment, section, visibility, threadlocal, unnamed_addr, externally_initialized, dllstorageclass, comdat, attributes, preemptionspecifier]`` |
677 | 685 |
678 The ``GLOBALVAR`` record (code 7) marks the declaration or definition of a | 686 The ``GLOBALVAR`` record (code 7) marks the declaration or definition of a |
679 global variable. The operand fields are: | 687 global variable. The operand fields are: |
688 | |
689 * *strtab offset*, *strtab size*: Specifies the name of the global variable. | |
690 See `STRTAB_BLOCK Contents`_. | |
680 | 691 |
681 * *pointer type*: The type index of the pointer type used to point to this | 692 * *pointer type*: The type index of the pointer type used to point to this |
682 global variable | 693 global variable |
683 | 694 |
684 * *isconst*: Non-zero if the variable is treated as constant within the module, | 695 * *isconst*: Non-zero if the variable is treated as constant within the module, |
748 * ``dllimport``: code 1 | 759 * ``dllimport``: code 1 |
749 * ``dllexport``: code 2 | 760 * ``dllexport``: code 2 |
750 | 761 |
751 * *comdat*: An encoding of the COMDAT of this function | 762 * *comdat*: An encoding of the COMDAT of this function |
752 | 763 |
764 * *attributes*: If nonzero, the 1-based index into the table of AttributeLists. | |
765 | |
766 .. _bcpreemptionspecifier: | |
767 | |
768 * *preemptionspecifier*: If present, an encoding of the runtime preemption specifier of this variable: | |
769 | |
770 * ``dso_preemptable``: code 0 | |
771 * ``dso_local``: code 1 | |
772 | |
753 .. _FUNCTION: | 773 .. _FUNCTION: |
754 | 774 |
755 MODULE_CODE_FUNCTION Record | 775 MODULE_CODE_FUNCTION Record |
756 ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | 776 ^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
757 | 777 |
758 ``[FUNCTION, type, callingconv, isproto, linkage, paramattr, alignment, section, visibility, gc, prologuedata, dllstorageclass, comdat, prefixdata, personalityfn]`` | 778 ``[FUNCTION, strtab offset, strtab size, type, callingconv, isproto, linkage, paramattr, alignment, section, visibility, gc, prologuedata, dllstorageclass, comdat, prefixdata, personalityfn, preemptionspecifier]`` |
759 | 779 |
760 The ``FUNCTION`` record (code 8) marks the declaration or definition of a | 780 The ``FUNCTION`` record (code 8) marks the declaration or definition of a |
761 function. The operand fields are: | 781 function. The operand fields are: |
782 | |
783 * *strtab offset*, *strtab size*: Specifies the name of the function. | |
784 See `STRTAB_BLOCK Contents`_. | |
762 | 785 |
763 * *type*: The type index of the function type describing this function | 786 * *type*: The type index of the function type describing this function |
764 | 787 |
765 * *callingconv*: The calling convention number: | 788 * *callingconv*: The calling convention number: |
766 * ``ccc``: code 0 | 789 * ``ccc``: code 0 |
812 plus 1. | 835 plus 1. |
813 | 836 |
814 * *personalityfn*: If non-zero, the value index of the personality function for this function, | 837 * *personalityfn*: If non-zero, the value index of the personality function for this function, |
815 plus 1. | 838 plus 1. |
816 | 839 |
840 * *preemptionspecifier*: If present, an encoding of the :ref:`runtime preemption specifier<bcpreemptionspecifier>` of this function. | |
841 | |
817 MODULE_CODE_ALIAS Record | 842 MODULE_CODE_ALIAS Record |
818 ^^^^^^^^^^^^^^^^^^^^^^^^ | 843 ^^^^^^^^^^^^^^^^^^^^^^^^ |
819 | 844 |
820 ``[ALIAS, alias type, aliasee val#, linkage, visibility, dllstorageclass, threadlocal, unnamed_addr]`` | 845 ``[ALIAS, strtab offset, strtab size, alias type, aliasee val#, linkage, visibility, dllstorageclass, threadlocal, unnamed_addr, preemptionspecifier]`` |
821 | 846 |
822 The ``ALIAS`` record (code 9) marks the definition of an alias. The operand | 847 The ``ALIAS`` record (code 9) marks the definition of an alias. The operand |
823 fields are | 848 fields are |
824 | 849 |
850 * *strtab offset*, *strtab size*: Specifies the name of the alias. | |
851 See `STRTAB_BLOCK Contents`_. | |
852 | |
825 * *alias type*: The type index of the alias | 853 * *alias type*: The type index of the alias |
826 | 854 |
827 * *aliasee val#*: The value index of the aliased value | 855 * *aliasee val#*: The value index of the aliased value |
828 | 856 |
829 * *linkage*: An encoding of the `linkage type`_ for this alias | 857 * *linkage*: An encoding of the `linkage type`_ for this alias |
837 :ref:`thread local property<bcthreadlocal>` of the alias | 865 :ref:`thread local property<bcthreadlocal>` of the alias |
838 | 866 |
839 * *unnamed_addr*: If present, an encoding of the | 867 * *unnamed_addr*: If present, an encoding of the |
840 :ref:`unnamed_addr<bcunnamedaddr>` attribute of this alias | 868 :ref:`unnamed_addr<bcunnamedaddr>` attribute of this alias |
841 | 869 |
842 MODULE_CODE_PURGEVALS Record | 870 * *preemptionspecifier*: If present, an encoding of the :ref:`runtime preemption specifier<bcpreemptionspecifier>` of this alias. |
843 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
844 | |
845 ``[PURGEVALS, numvals]`` | |
846 | |
847 The ``PURGEVALS`` record (code 10) resets the module-level value list to the | |
848 size given by the single operand value. Module-level value list items are added | |
849 by ``GLOBALVAR``, ``FUNCTION``, and ``ALIAS`` records. After a ``PURGEVALS`` | |
850 record is seen, new value indices will start from the given *numvals* value. | |
851 | 871 |
852 .. _MODULE_CODE_GCNAME: | 872 .. _MODULE_CODE_GCNAME: |
853 | 873 |
854 MODULE_CODE_GCNAME Record | 874 MODULE_CODE_GCNAME Record |
855 ^^^^^^^^^^^^^^^^^^^^^^^^^ | 875 ^^^^^^^^^^^^^^^^^^^^^^^^^ |
1308 | 1328 |
1309 METADATA_ATTACHMENT Contents | 1329 METADATA_ATTACHMENT Contents |
1310 ---------------------------- | 1330 ---------------------------- |
1311 | 1331 |
1312 The ``METADATA_ATTACHMENT`` block (id 16) ... | 1332 The ``METADATA_ATTACHMENT`` block (id 16) ... |
1333 | |
1334 .. _STRTAB_BLOCK: | |
1335 | |
1336 STRTAB_BLOCK Contents | |
1337 --------------------- | |
1338 | |
1339 The ``STRTAB`` block (id 23) contains a single record (``STRTAB_BLOB``, id 1) | |
1340 with a single blob operand containing the bitcode file's string table. | |
1341 | |
1342 Strings in the string table are not null terminated. A record's *strtab | |
1343 offset* and *strtab size* operands specify the byte offset and size of a | |
1344 string within the string table. | |
1345 | |
1346 The string table is used by all preceding blocks in the bitcode file that are | |
1347 not succeeded by another intervening ``STRTAB`` block. Normally a bitcode | |
1348 file will have a single string table, but it may have more than one if it | |
1349 was created by binary concatenation of multiple bitcode files. |