llvm.org GIT mirror llvm / f7f74c2
Remove the notion of primitive types. They were out of place since the introduction of arbitrary precision integer types. This also synchronizes the documentation to Types.h, so it refers to first class types and single value types. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196661 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 6 years ago
5 changed file(s) with 324 addition(s) and 388 deletion(s). Raw diff Collapse all Expand all
33
44 .. contents::
55 :local:
6 :depth: 3
6 :depth: 4
77
88 Abstract
99 ========
14751475 generated code and enables novel analyses and transformations that are
14761476 not feasible to perform on normal three address code representations.
14771477
1478 .. _typeclassifications:
1479
1480 Type Classifications
1481 --------------------
1482
1483 The types fall into a few useful classifications:
1484
1485
1486 .. list-table::
1487 :header-rows: 1
1488
1489 * - Classification
1490 - Types
1491
1492 * - :ref:`integer `
1493 - ``i1``, ``i2``, ``i3``, ... ``i8``, ... ``i16``, ... ``i32``, ...
1494 ``i64``, ...
1495
1496 * - :ref:`floating point `
1497 - ``half``, ``float``, ``double``, ``x86_fp80``, ``fp128``,
1498 ``ppc_fp128``
1499
1500
1501 * - first class
1502
1503 .. _t_firstclass:
1504
1505 - :ref:`integer `, :ref:`floating point `,
1506 :ref:`pointer `, :ref:`vector `,
1507 :ref:`structure `, :ref:`array `,
1508 :ref:`label `, :ref:`metadata `.
1509
1510 * - :ref:`primitive `
1511 - :ref:`label `,
1512 :ref:`void `,
1513 :ref:`integer `,
1514 :ref:`floating point `,
1515 :ref:`x86mmx `,
1516 :ref:`metadata `.
1517
1518 * - :ref:`derived `
1519 - :ref:`array `,
1520 :ref:`function `,
1521 :ref:`pointer `,
1522 :ref:`structure `,
1523 :ref:`vector `,
1524 :ref:`opaque `.
1525
1526 The :ref:`first class ` types are perhaps the most important.
1527 Values of these types are the only ones which can be produced by
1528 instructions.
1529
1530 .. _t_primitive:
1531
1532 Primitive Types
1533 ---------------
1534
1535 The primitive types are the fundamental building blocks of the LLVM
1536 system.
1537
1538 .. _t_integer:
1539
1540 Integer Type
1541 ^^^^^^^^^^^^
1542
1543 Overview:
1544 """""""""
1545
1546 The integer type is a very simple type that simply specifies an
1547 arbitrary bit width for the integer type desired. Any bit width from 1
1548 bit to 2\ :sup:`23`\ -1 (about 8 million) can be specified.
1549
1550 Syntax:
1551 """""""
1552
1553 ::
1554
1555 iN
1556
1557 The number of bits the integer will occupy is specified by the ``N``
1558 value.
1559
1560 Examples:
1561 """""""""
1562
1563 +----------------+------------------------------------------------+
1564 | ``i1`` | a single-bit integer. |
1565 +----------------+------------------------------------------------+
1566 | ``i32`` | a 32-bit integer. |
1567 +----------------+------------------------------------------------+
1568 | ``i1942652`` | a really big integer of over 1 million bits. |
1569 +----------------+------------------------------------------------+
1570
1571 .. _t_floating:
1572
1573 Floating Point Types
1574 ^^^^^^^^^^^^^^^^^^^^
1575
1576 .. list-table::
1577 :header-rows: 1
1578
1579 * - Type
1580 - Description
1581
1582 * - ``half``
1583 - 16-bit floating point value
1584
1585 * - ``float``
1586 - 32-bit floating point value
1587
1588 * - ``double``
1589 - 64-bit floating point value
1590
1591 * - ``fp128``
1592 - 128-bit floating point value (112-bit mantissa)
1593
1594 * - ``x86_fp80``
1595 - 80-bit floating point value (X87)
1596
1597 * - ``ppc_fp128``
1598 - 128-bit floating point value (two 64-bits)
1599
1600 .. _t_x86mmx:
1601
1602 X86mmx Type
1603 ^^^^^^^^^^^
1604
1605 Overview:
1606 """""""""
1607
1608 The x86mmx type represents a value held in an MMX register on an x86
1609 machine. The operations allowed on it are quite limited: parameters and
1610 return values, load and store, and bitcast. User-specified MMX
1611 instructions are represented as intrinsic or asm calls with arguments
1612 and/or results of this type. There are no arrays, vectors or constants
1613 of this type.
1614
1615 Syntax:
1616 """""""
1617
1618 ::
1619
1620 x86mmx
1621
16221478 .. _t_void:
16231479
16241480 Void Type
1481 ---------
1482
1483 Overview:
16251484 ^^^^^^^^^
16261485
1627 Overview:
1628 """""""""
1629
16301486 The void type does not represent any value and has no size.
16311487
16321488 Syntax:
1633 """""""
1489 ^^^^^^^
16341490
16351491 ::
16361492
16371493 void
16381494
1639 .. _t_label:
1640
1641 Label Type
1642 ^^^^^^^^^^
1643
1644 Overview:
1645 """""""""
1646
1647 The label type represents code labels.
1648
1649 Syntax:
1650 """""""
1651
1652 ::
1653
1654 label
1655
1656 .. _t_metadata:
1657
1658 Metadata Type
1659 ^^^^^^^^^^^^^
1660
1661 Overview:
1662 """""""""
1663
1664 The metadata type represents embedded metadata. No derived types may be
1665 created from metadata except for :ref:`function ` arguments.
1666
1667 Syntax:
1668 """""""
1669
1670 ::
1671
1672 metadata
1673
1674 .. _t_derived:
1675
1676 Derived Types
1495
1496 .. _t_function:
1497
1498 Function Type
16771499 -------------
16781500
1679 The real power in LLVM comes from the derived types in the system. This
1680 is what allows a programmer to represent arrays, functions, pointers,
1681 and other useful types. Each of these types contain one or more element
1682 types which may be a primitive type, or another derived type. For
1683 example, it is possible to have a two dimensional array, using an array
1684 as the element type of another array.
1685
1686 .. _t_aggregate:
1687
1688 Aggregate Types
1689 ^^^^^^^^^^^^^^^
1690
1691 Aggregate Types are a subset of derived types that can contain multiple
1692 member types. :ref:`Arrays ` and :ref:`structs ` are
1693 aggregate types. :ref:`Vectors ` are not considered to be
1694 aggregate types.
1695
1696 .. _t_array:
1697
1698 Array Type
1699 ^^^^^^^^^^
1700
1701 Overview:
1702 """""""""
1703
1704 The array type is a very simple derived type that arranges elements
1705 sequentially in memory. The array type requires a size (number of
1706 elements) and an underlying data type.
1707
1708 Syntax:
1709 """""""
1710
1711 ::
1712
1713 [<# elements> x ]
1714
1715 The number of elements is a constant integer value; ``elementtype`` may
1716 be any type with a size.
1717
1718 Examples:
1719 """""""""
1720
1721 +------------------+--------------------------------------+
1722 | ``[40 x i32]`` | Array of 40 32-bit integer values. |
1723 +------------------+--------------------------------------+
1724 | ``[41 x i32]`` | Array of 41 32-bit integer values. |
1725 +------------------+--------------------------------------+
1726 | ``[4 x i8]`` | Array of 4 8-bit integer values. |
1727 +------------------+--------------------------------------+
1728
1729 Here are some examples of multidimensional arrays:
1730
1731 +-----------------------------+----------------------------------------------------------+
1732 | ``[3 x [4 x i32]]`` | 3x4 array of 32-bit integer values. |
1733 +-----------------------------+----------------------------------------------------------+
1734 | ``[12 x [10 x float]]`` | 12x10 array of single precision floating point values. |
1735 +-----------------------------+----------------------------------------------------------+
1736 | ``[2 x [3 x [4 x i16]]]`` | 2x3x4 array of 16-bit integer values. |
1737 +-----------------------------+----------------------------------------------------------+
1738
1739 There is no restriction on indexing beyond the end of the array implied
1740 by a static type (though there are restrictions on indexing beyond the
1741 bounds of an allocated object in some cases). This means that
1742 single-dimension 'variable sized array' addressing can be implemented in
1743 LLVM with a zero length array type. An implementation of 'pascal style
1744 arrays' in LLVM could use the type "``{ i32, [0 x float]}``", for
1745 example.
1746
1747 .. _t_function:
1748
1749 Function Type
1750 ^^^^^^^^^^^^^
1751
1752 Overview:
1753 """""""""
1501 Overview:
1502 ^^^^^^^^^
17541503
17551504 The function type can be thought of as a function signature. It consists of a
17561505 return type and a list of formal parameter types. The return type of a function
17581507 and :ref:`metadata ` types.
17591508
17601509 Syntax:
1761 """""""
1510 ^^^^^^^
17621511
17631512 ::
17641513
17721521 except :ref:`label ` and :ref:`metadata `.
17731522
17741523 Examples:
1775 """""""""
1524 ^^^^^^^^^
17761525
17771526 +---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
17781527 | ``i32 (i32)`` | function taking an ``i32``, returning an ``i32`` |
17841533 | ``{i32, i32} (i32)`` | A function taking an ``i32``, returning a :ref:`structure ` containing two ``i32`` values |
17851534 +---------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
17861535
1787 .. _t_struct:
1788
1789 Structure Type
1790 ^^^^^^^^^^^^^^
1791
1792 Overview:
1793 """""""""
1794
1795 The structure type is used to represent a collection of data members
1796 together in memory. The elements of a structure may be any type that has
1797 a size.
1798
1799 Structures in memory are accessed using '``load``' and '``store``' by
1800 getting a pointer to a field with the '``getelementptr``' instruction.
1801 Structures in registers are accessed using the '``extractvalue``' and
1802 '``insertvalue``' instructions.
1803
1804 Structures may optionally be "packed" structures, which indicate that
1805 the alignment of the struct is one byte, and that there is no padding
1806 between the elements. In non-packed structs, padding between field types
1807 is inserted as defined by the DataLayout string in the module, which is
1808 required to match what the underlying code generator expects.
1809
1810 Structures can either be "literal" or "identified". A literal structure
1811 is defined inline with other types (e.g. ``{i32, i32}*``) whereas
1812 identified types are always defined at the top level with a name.
1813 Literal types are uniqued by their contents and can never be recursive
1814 or opaque since there is no way to write one. Identified types can be
1815 recursive, can be opaqued, and are never uniqued.
1816
1817 Syntax:
1818 """""""
1819
1820 ::
1821
1822 %T1 = type { } ; Identified normal struct type
1823 %T2 = type <{ }> ; Identified packed struct type
1536 .. _t_firstclass:
1537
1538 First Class Types
1539 -----------------
1540
1541 The :ref:`first class ` types are perhaps the most important.
1542 Values of these types are the only ones which can be produced by
1543 instructions.
1544
1545 .. _t_single_value:
1546
1547 Single Value Types
1548 ^^^^^^^^^^^^^^^^^^
1549
1550 These are the types that are valid in registers from CodeGen's perspective.
1551
1552 .. _t_integer:
1553
1554 Integer Type
1555 """"""""""""
1556
1557 Overview:
1558 *********
1559
1560 The integer type is a very simple type that simply specifies an
1561 arbitrary bit width for the integer type desired. Any bit width from 1
1562 bit to 2\ :sup:`23`\ -1 (about 8 million) can be specified.
1563
1564 Syntax:
1565 *******
1566
1567 ::
1568
1569 iN
1570
1571 The number of bits the integer will occupy is specified by the ``N``
1572 value.
18241573
18251574 Examples:
1826 """""""""
1827
1828 +------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1829 | ``{ i32, i32, i32 }`` | A triple of three ``i32`` values |
1830 +------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1831 | ``{ float, i32 (i32) * }`` | A pair, where the first element is a ``float`` and the second element is a :ref:`pointer ` to a :ref:`function ` that takes an ``i32``, returning an ``i32``. |
1832 +------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1833 | ``<{ i8, i32 }>`` | A packed struct known to be 5 bytes in size. |
1834 +------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1835
1836 .. _t_opaque:
1837
1838 Opaque Structure Types
1839 ^^^^^^^^^^^^^^^^^^^^^^
1840
1841 Overview:
1842 """""""""
1843
1844 Opaque structure types are used to represent named structure types that
1845 do not have a body specified. This corresponds (for example) to the C
1846 notion of a forward declared structure.
1847
1848 Syntax:
1849 """""""
1850
1851 ::
1852
1853 %X = type opaque
1854 %52 = type opaque
1855
1856 Examples:
1857 """""""""
1858
1859 +--------------+-------------------+
1860 | ``opaque`` | An opaque type. |
1861 +--------------+-------------------+
1575 *********
1576
1577 +----------------+------------------------------------------------+
1578 | ``i1`` | a single-bit integer. |
1579 +----------------+------------------------------------------------+
1580 | ``i32`` | a 32-bit integer. |
1581 +----------------+------------------------------------------------+
1582 | ``i1942652`` | a really big integer of over 1 million bits. |
1583 +----------------+------------------------------------------------+
1584
1585 .. _t_floating:
1586
1587 Floating Point Types
1588 """"""""""""""""""""
1589
1590 .. list-table::
1591 :header-rows: 1
1592
1593 * - Type
1594 - Description
1595
1596 * - ``half``
1597 - 16-bit floating point value
1598
1599 * - ``float``
1600 - 32-bit floating point value
1601
1602 * - ``double``
1603 - 64-bit floating point value
1604
1605 * - ``fp128``
1606 - 128-bit floating point value (112-bit mantissa)
1607
1608 * - ``x86_fp80``
1609 - 80-bit floating point value (X87)
1610
1611 * - ``ppc_fp128``
1612 - 128-bit floating point value (two 64-bits)
1613
1614 .. _t_x86mmx:
1615
1616 X86mmx Type
1617 """""""""""
1618
1619 Overview:
1620 *********
1621
1622 The x86mmx type represents a value held in an MMX register on an x86
1623 machine. The operations allowed on it are quite limited: parameters and
1624 return values, load and store, and bitcast. User-specified MMX
1625 instructions are represented as intrinsic or asm calls with arguments
1626 and/or results of this type. There are no arrays, vectors or constants
1627 of this type.
1628
1629 Syntax:
1630 *******
1631
1632 ::
1633
1634 x86mmx
1635
18621636
18631637 .. _t_pointer:
18641638
18651639 Pointer Type
1866 ^^^^^^^^^^^^
1867
1868 Overview:
1869 """""""""
1640 """"""""""""
1641
1642 Overview:
1643 *********
18701644
18711645 The pointer type is used to specify memory locations. Pointers are
18721646 commonly used to reference objects in memory.
18801654 permit pointers to labels (``label*``). Use ``i8*`` instead.
18811655
18821656 Syntax:
1883 """""""
1657 *******
18841658
18851659 ::
18861660
18871661 *
18881662
18891663 Examples:
1890 """""""""
1664 *********
18911665
18921666 +-------------------------+--------------------------------------------------------------------------------------------------------------+
18931667 | ``[4 x i32]*`` | A :ref:`pointer ` to :ref:`array ` of four ``i32`` values. |
19001674 .. _t_vector:
19011675
19021676 Vector Type
1903 ^^^^^^^^^^^
1904
1905 Overview:
1906 """""""""
1677 """""""""""
1678
1679 Overview:
1680 *********
19071681
19081682 A vector type is a simple derived type that represents a vector of
19091683 elements. Vector types are used when multiple primitive data are
19121686 type. Vector types are considered :ref:`first class `.
19131687
19141688 Syntax:
1915 """""""
1689 *******
19161690
19171691 ::
19181692
19231697 these types. Vectors of size zero are not allowed.
19241698
19251699 Examples:
1926 """""""""
1700 *********
19271701
19281702 +-------------------+--------------------------------------------------+
19291703 | ``<4 x i32>`` | Vector of 4 32-bit integer values. |
19341708 +-------------------+--------------------------------------------------+
19351709 | ``<4 x i64*>`` | Vector of 4 pointers to 64-bit integer values. |
19361710 +-------------------+--------------------------------------------------+
1711
1712 .. _t_label:
1713
1714 Label Type
1715 ^^^^^^^^^^
1716
1717 Overview:
1718 """""""""
1719
1720 The label type represents code labels.
1721
1722 Syntax:
1723 """""""
1724
1725 ::
1726
1727 label
1728
1729 .. _t_metadata:
1730
1731 Metadata Type
1732 ^^^^^^^^^^^^^
1733
1734 Overview:
1735 """""""""
1736
1737 The metadata type represents embedded metadata. No derived types may be
1738 created from metadata except for :ref:`function ` arguments.
1739
1740 Syntax:
1741 """""""
1742
1743 ::
1744
1745 metadata
1746
1747 .. _t_aggregate:
1748
1749 Aggregate Types
1750 ^^^^^^^^^^^^^^^
1751
1752 Aggregate Types are a subset of derived types that can contain multiple
1753 member types. :ref:`Arrays ` and :ref:`structs ` are
1754 aggregate types. :ref:`Vectors ` are not considered to be
1755 aggregate types.
1756
1757 .. _t_array:
1758
1759 Array Type
1760 """"""""""
1761
1762 Overview:
1763 *********
1764
1765 The array type is a very simple derived type that arranges elements
1766 sequentially in memory. The array type requires a size (number of
1767 elements) and an underlying data type.
1768
1769 Syntax:
1770 *******
1771
1772 ::
1773
1774 [<# elements> x ]
1775
1776 The number of elements is a constant integer value; ``elementtype`` may
1777 be any type with a size.
1778
1779 Examples:
1780 *********
1781
1782 +------------------+--------------------------------------+
1783 | ``[40 x i32]`` | Array of 40 32-bit integer values. |
1784 +------------------+--------------------------------------+
1785 | ``[41 x i32]`` | Array of 41 32-bit integer values. |
1786 +------------------+--------------------------------------+
1787 | ``[4 x i8]`` | Array of 4 8-bit integer values. |
1788 +------------------+--------------------------------------+
1789
1790 Here are some examples of multidimensional arrays:
1791
1792 +-----------------------------+----------------------------------------------------------+
1793 | ``[3 x [4 x i32]]`` | 3x4 array of 32-bit integer values. |
1794 +-----------------------------+----------------------------------------------------------+
1795 | ``[12 x [10 x float]]`` | 12x10 array of single precision floating point values. |
1796 +-----------------------------+----------------------------------------------------------+
1797 | ``[2 x [3 x [4 x i16]]]`` | 2x3x4 array of 16-bit integer values. |
1798 +-----------------------------+----------------------------------------------------------+
1799
1800 There is no restriction on indexing beyond the end of the array implied
1801 by a static type (though there are restrictions on indexing beyond the
1802 bounds of an allocated object in some cases). This means that
1803 single-dimension 'variable sized array' addressing can be implemented in
1804 LLVM with a zero length array type. An implementation of 'pascal style
1805 arrays' in LLVM could use the type "``{ i32, [0 x float]}``", for
1806 example.
1807
1808 .. _t_struct:
1809
1810 Structure Type
1811 """"""""""""""
1812
1813 Overview:
1814 *********
1815
1816 The structure type is used to represent a collection of data members
1817 together in memory. The elements of a structure may be any type that has
1818 a size.
1819
1820 Structures in memory are accessed using '``load``' and '``store``' by
1821 getting a pointer to a field with the '``getelementptr``' instruction.
1822 Structures in registers are accessed using the '``extractvalue``' and
1823 '``insertvalue``' instructions.
1824
1825 Structures may optionally be "packed" structures, which indicate that
1826 the alignment of the struct is one byte, and that there is no padding
1827 between the elements. In non-packed structs, padding between field types
1828 is inserted as defined by the DataLayout string in the module, which is
1829 required to match what the underlying code generator expects.
1830
1831 Structures can either be "literal" or "identified". A literal structure
1832 is defined inline with other types (e.g. ``{i32, i32}*``) whereas
1833 identified types are always defined at the top level with a name.
1834 Literal types are uniqued by their contents and can never be recursive
1835 or opaque since there is no way to write one. Identified types can be
1836 recursive, can be opaqued, and are never uniqued.
1837
1838 Syntax:
1839 *******
1840
1841 ::
1842
1843 %T1 = type { } ; Identified normal struct type
1844 %T2 = type <{ }> ; Identified packed struct type
1845
1846 Examples:
1847 *********
1848
1849 +------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1850 | ``{ i32, i32, i32 }`` | A triple of three ``i32`` values |
1851 +------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1852 | ``{ float, i32 (i32) * }`` | A pair, where the first element is a ``float`` and the second element is a :ref:`pointer ` to a :ref:`function ` that takes an ``i32``, returning an ``i32``. |
1853 +------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1854 | ``<{ i8, i32 }>`` | A packed struct known to be 5 bytes in size. |
1855 +------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1856
1857 .. _t_opaque:
1858
1859 Opaque Structure Types
1860 """"""""""""""""""""""
1861
1862 Overview:
1863 *********
1864
1865 Opaque structure types are used to represent named structure types that
1866 do not have a body specified. This corresponds (for example) to the C
1867 notion of a forward declared structure.
1868
1869 Syntax:
1870 *******
1871
1872 ::
1873
1874 %X = type opaque
1875 %52 = type opaque
1876
1877 Examples:
1878 *********
1879
1880 +--------------+-------------------+
1881 | ``opaque`` | An opaque type. |
1882 +--------------+-------------------+
19371883
19381884 Constants
19391885 =========
7070 StructTyID, ///< 12: Structures
7171 ArrayTyID, ///< 13: Arrays
7272 PointerTyID, ///< 14: Pointers
73 VectorTyID, ///< 15: SIMD 'packed' format, or other vector type
74
75 LastPrimitiveTyID = X86_MMXTyID,
76 FirstDerivedTyID = IntegerTyID
73 VectorTyID ///< 15: SIMD 'packed' format, or other vector type
7774 };
7875
7976 private:
238235 /// elements or all its elements are empty.
239236 bool isEmptyTy() const;
240237
241 /// Here are some useful little methods to query what type derived types are
242 /// Note that all other types can just compare to see if this == Type::xxxTy;
243 ///
244 bool isPrimitiveType() const { return getTypeID() <= LastPrimitiveTyID; }
245 bool isDerivedType() const { return getTypeID() >= FirstDerivedTyID; }
246
247238 /// isFirstClassType - Return true if the type is "first class", meaning it
248239 /// is a valid type for a Value.
249240 ///
256247 /// and array types.
257248 ///
258249 bool isSingleValueType() const {
259 return (getTypeID() != VoidTyID && isPrimitiveType()) ||
260 getTypeID() == IntegerTyID || getTypeID() == PointerTyID ||
261 getTypeID() == VectorTyID;
250 return isFloatingPointTy() || isX86_MMXTy() || isIntegerTy() ||
251 isPointerTy() || isVectorTy();
262252 }
263253
264254 /// isAggregateType - Return true if the type is an aggregate type. This
360360 }
361361
362362 std::string CppWriter::getCppName(Type* Ty) {
363 // First, handle the primitive types .. easy
364 if (Ty->isPrimitiveType() || Ty->isIntegerTy()) {
365 switch (Ty->getTypeID()) {
366 case Type::VoidTyID: return "Type::getVoidTy(mod->getContext())";
367 case Type::IntegerTyID: {
368 unsigned BitWidth = cast(Ty)->getBitWidth();
369 return "IntegerType::get(mod->getContext(), " + utostr(BitWidth) + ")";
370 }
371 case Type::X86_FP80TyID: return "Type::getX86_FP80Ty(mod->getContext())";
372 case Type::FloatTyID: return "Type::getFloatTy(mod->getContext())";
373 case Type::DoubleTyID: return "Type::getDoubleTy(mod->getContext())";
374 case Type::LabelTyID: return "Type::getLabelTy(mod->getContext())";
375 case Type::X86_MMXTyID: return "Type::getX86_MMXTy(mod->getContext())";
376 default:
377 error("Invalid primitive type");
378 break;
379 }
380 // shouldn't be returned, but make it sensible
363 switch (Ty->getTypeID()) {
364 default:
365 break;
366 case Type::VoidTyID:
381367 return "Type::getVoidTy(mod->getContext())";
368 case Type::IntegerTyID: {
369 unsigned BitWidth = cast(Ty)->getBitWidth();
370 return "IntegerType::get(mod->getContext(), " + utostr(BitWidth) + ")";
371 }
372 case Type::X86_FP80TyID:
373 return "Type::getX86_FP80Ty(mod->getContext())";
374 case Type::FloatTyID:
375 return "Type::getFloatTy(mod->getContext())";
376 case Type::DoubleTyID:
377 return "Type::getDoubleTy(mod->getContext())";
378 case Type::LabelTyID:
379 return "Type::getLabelTy(mod->getContext())";
380 case Type::X86_MMXTyID:
381 return "Type::getX86_MMXTy(mod->getContext())";
382382 }
383383
384384 // Now, see if we've seen the type before and return that
536536
537537 void CppWriter::printType(Type* Ty) {
538538 // We don't print definitions for primitive types
539 if (Ty->isPrimitiveType() || Ty->isIntegerTy())
539 if (Ty->isFloatingPointTy() || Ty->isX86_MMXTy() || Ty->isIntegerTy() ||
540 Ty->isLabelTy() || Ty->isMetadataTy() || Ty->isVoidTy())
540541 return;
541542
542543 // If we already defined this type, we don't need to define it again.
429429 O << " (";
430430
431431 if (isABI) {
432 if (Ty->isPrimitiveType() || Ty->isIntegerTy()) {
432 if (Ty->isFloatingPointTy() || Ty->isIntegerTy()) {
433433 unsigned size = 0;
434434 if (const IntegerType *ITy = dyn_cast(Ty)) {
435435 size = ITy->getBitWidth();
12061206 else
12071207 O << " .align " << GVar->getAlignment();
12081208
1209 if (ETy->isPrimitiveType() || ETy->isIntegerTy() || isa(ETy)) {
1209 if (ETy->isSingleValueType()) {
12101210 O << " .";
12111211 // Special case: ABI requires that we use .u8 for predicates
12121212 if (ETy->isIntegerTy(1))
13771377 else
13781378 O << " .align " << GVar->getAlignment();
13791379
1380 if (ETy->isPrimitiveType() || ETy->isIntegerTy() || isa(ETy)) {
1380 if (ETy->isSingleValueType()) {
13811381 O << " .";
13821382 O << getPTXFundamentalTypeStr(ETy);
13831383 O << " ";
14091409 }
14101410
14111411 static unsigned int getOpenCLAlignment(const DataLayout *TD, Type *Ty) {
1412 if (Ty->isPrimitiveType() || Ty->isIntegerTy() || isa(Ty))
1412 if (Ty->isSingleValueType())
14131413 return TD->getPrefTypeAlignment(Ty);
14141414
14151415 const ArrayType *ATy = dyn_cast(Ty);
360360 O << "()";
361361 } else {
362362 O << "(";
363 if (retTy->isPrimitiveType() || retTy->isIntegerTy()) {
363 if (retTy->isFloatingPointTy() || retTy->isIntegerTy()) {
364364 unsigned size = 0;
365365 if (const IntegerType *ITy = dyn_cast(retTy)) {
366366 size = ITy->getBitWidth();
855855 // .param .align 16 .b8 retval0[], or
856856 // .param .b retval0
857857 unsigned resultsz = TD->getTypeAllocSizeInBits(retTy);
858 if (retTy->isPrimitiveType() || retTy->isIntegerTy() ||
859 retTy->isPointerTy()) {
858 if (retTy->isSingleValueType()) {
860859 // Scalar needs to be at least 32bit wide
861860 if (resultsz < 32)
862861 resultsz = 32;