Skip to content
LangRef.rst 273 KiB
Newer Older
7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000
"""""""""

The '``llvm.fabs.*``' intrinsics return the absolute value of the
operand.

Arguments:
""""""""""

The argument and return value are floating point numbers of the same
type.

Semantics:
""""""""""

This function returns the same values as the libm ``fabs`` functions
would, and handles error conditions in the same way.

'``llvm.floor.*``' Intrinsic
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Syntax:
"""""""

This is an overloaded intrinsic. You can use ``llvm.floor`` on any
floating point or vector of floating point type. Not all targets support
all types however.

::

      declare float     @llvm.floor.f32(float  %Val)
      declare double    @llvm.floor.f64(double %Val)
      declare x86_fp80  @llvm.floor.f80(x86_fp80  %Val)
      declare fp128     @llvm.floor.f128(fp128 %Val)
      declare ppc_fp128 @llvm.floor.ppcf128(ppc_fp128  %Val)

Overview:
"""""""""

The '``llvm.floor.*``' intrinsics return the floor of the operand.

Arguments:
""""""""""

The argument and return value are floating point numbers of the same
type.

Semantics:
""""""""""

This function returns the same values as the libm ``floor`` functions
would, and handles error conditions in the same way.

'``llvm.ceil.*``' Intrinsic
^^^^^^^^^^^^^^^^^^^^^^^^^^^

Syntax:
"""""""

This is an overloaded intrinsic. You can use ``llvm.ceil`` on any
floating point or vector of floating point type. Not all targets support
all types however.

::

      declare float     @llvm.ceil.f32(float  %Val)
      declare double    @llvm.ceil.f64(double %Val)
      declare x86_fp80  @llvm.ceil.f80(x86_fp80  %Val)
      declare fp128     @llvm.ceil.f128(fp128 %Val)
      declare ppc_fp128 @llvm.ceil.ppcf128(ppc_fp128  %Val)

Overview:
"""""""""

The '``llvm.ceil.*``' intrinsics return the ceiling of the operand.

Arguments:
""""""""""

The argument and return value are floating point numbers of the same
type.

Semantics:
""""""""""

This function returns the same values as the libm ``ceil`` functions
would, and handles error conditions in the same way.

'``llvm.trunc.*``' Intrinsic
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Syntax:
"""""""

This is an overloaded intrinsic. You can use ``llvm.trunc`` on any
floating point or vector of floating point type. Not all targets support
all types however.

::

      declare float     @llvm.trunc.f32(float  %Val)
      declare double    @llvm.trunc.f64(double %Val)
      declare x86_fp80  @llvm.trunc.f80(x86_fp80  %Val)
      declare fp128     @llvm.trunc.f128(fp128 %Val)
      declare ppc_fp128 @llvm.trunc.ppcf128(ppc_fp128  %Val)

Overview:
"""""""""

The '``llvm.trunc.*``' intrinsics returns the operand rounded to the
nearest integer not larger in magnitude than the operand.

Arguments:
""""""""""

The argument and return value are floating point numbers of the same
type.

Semantics:
""""""""""

This function returns the same values as the libm ``trunc`` functions
would, and handles error conditions in the same way.

'``llvm.rint.*``' Intrinsic
^^^^^^^^^^^^^^^^^^^^^^^^^^^

Syntax:
"""""""

This is an overloaded intrinsic. You can use ``llvm.rint`` on any
floating point or vector of floating point type. Not all targets support
all types however.

::

      declare float     @llvm.rint.f32(float  %Val)
      declare double    @llvm.rint.f64(double %Val)
      declare x86_fp80  @llvm.rint.f80(x86_fp80  %Val)
      declare fp128     @llvm.rint.f128(fp128 %Val)
      declare ppc_fp128 @llvm.rint.ppcf128(ppc_fp128  %Val)

Overview:
"""""""""

The '``llvm.rint.*``' intrinsics returns the operand rounded to the
nearest integer. It may raise an inexact floating-point exception if the
operand isn't an integer.

Arguments:
""""""""""

The argument and return value are floating point numbers of the same
type.

Semantics:
""""""""""

This function returns the same values as the libm ``rint`` functions
would, and handles error conditions in the same way.

'``llvm.nearbyint.*``' Intrinsic
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Syntax:
"""""""

This is an overloaded intrinsic. You can use ``llvm.nearbyint`` on any
floating point or vector of floating point type. Not all targets support
all types however.

::

      declare float     @llvm.nearbyint.f32(float  %Val)
      declare double    @llvm.nearbyint.f64(double %Val)
      declare x86_fp80  @llvm.nearbyint.f80(x86_fp80  %Val)
      declare fp128     @llvm.nearbyint.f128(fp128 %Val)
      declare ppc_fp128 @llvm.nearbyint.ppcf128(ppc_fp128  %Val)

Overview:
"""""""""

The '``llvm.nearbyint.*``' intrinsics returns the operand rounded to the
nearest integer.

Arguments:
""""""""""

The argument and return value are floating point numbers of the same
type.

Semantics:
""""""""""

This function returns the same values as the libm ``nearbyint``
functions would, and handles error conditions in the same way.

Bit Manipulation Intrinsics
---------------------------

LLVM provides intrinsics for a few important bit manipulation
operations. These allow efficient code generation for some algorithms.

'``llvm.bswap.*``' Intrinsics
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Syntax:
"""""""

This is an overloaded intrinsic function. You can use bswap on any
integer type that is an even number of bytes (i.e. BitWidth % 16 == 0).

::

      declare i16 @llvm.bswap.i16(i16 <id>)
      declare i32 @llvm.bswap.i32(i32 <id>)
      declare i64 @llvm.bswap.i64(i64 <id>)

Overview:
"""""""""

The '``llvm.bswap``' family of intrinsics is used to byte swap integer
values with an even number of bytes (positive multiple of 16 bits).
These are useful for performing operations on data that is not in the
target's native byte order.

Semantics:
""""""""""

The ``llvm.bswap.i16`` intrinsic returns an i16 value that has the high
and low byte of the input i16 swapped. Similarly, the ``llvm.bswap.i32``
intrinsic returns an i32 value that has the four bytes of the input i32
swapped, so that if the input bytes are numbered 0, 1, 2, 3 then the
returned i32 will have its bytes in 3, 2, 1, 0 order. The
``llvm.bswap.i48``, ``llvm.bswap.i64`` and other intrinsics extend this
concept to additional even-byte lengths (6 bytes, 8 bytes and more,
respectively).

'``llvm.ctpop.*``' Intrinsic
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Syntax:
"""""""

This is an overloaded intrinsic. You can use llvm.ctpop on any integer
bit width, or on any vector with integer elements. Not all targets
support all bit widths or vector types, however.

::

      declare i8 @llvm.ctpop.i8(i8  <src>)
      declare i16 @llvm.ctpop.i16(i16 <src>)
      declare i32 @llvm.ctpop.i32(i32 <src>)
      declare i64 @llvm.ctpop.i64(i64 <src>)
      declare i256 @llvm.ctpop.i256(i256 <src>)
      declare <2 x i32> @llvm.ctpop.v2i32(<2 x i32> <src>)

Overview:
"""""""""

The '``llvm.ctpop``' family of intrinsics counts the number of bits set
in a value.

Arguments:
""""""""""

The only argument is the value to be counted. The argument may be of any
integer type, or a vector with integer elements. The return type must
match the argument type.

Semantics:
""""""""""

The '``llvm.ctpop``' intrinsic counts the 1's in a variable, or within
each element of a vector.

'``llvm.ctlz.*``' Intrinsic
^^^^^^^^^^^^^^^^^^^^^^^^^^^

Syntax:
"""""""

This is an overloaded intrinsic. You can use ``llvm.ctlz`` on any
integer bit width, or any vector whose elements are integers. Not all
targets support all bit widths or vector types, however.

::

      declare i8   @llvm.ctlz.i8  (i8   <src>, i1 <is_zero_undef>)
      declare i16  @llvm.ctlz.i16 (i16  <src>, i1 <is_zero_undef>)
      declare i32  @llvm.ctlz.i32 (i32  <src>, i1 <is_zero_undef>)
      declare i64  @llvm.ctlz.i64 (i64  <src>, i1 <is_zero_undef>)
      declare i256 @llvm.ctlz.i256(i256 <src>, i1 <is_zero_undef>)
      declase <2 x i32> @llvm.ctlz.v2i32(<2 x i32> <src>, i1 <is_zero_undef>)

Overview:
"""""""""

The '``llvm.ctlz``' family of intrinsic functions counts the number of
leading zeros in a variable.

Arguments:
""""""""""

The first argument is the value to be counted. This argument may be of
any integer type, or a vectory with integer element type. The return
type must match the first argument type.

The second argument must be a constant and is a flag to indicate whether
the intrinsic should ensure that a zero as the first argument produces a
defined result. Historically some architectures did not provide a
defined result for zero values as efficiently, and many algorithms are
now predicated on avoiding zero-value inputs.

Semantics:
""""""""""

The '``llvm.ctlz``' intrinsic counts the leading (most significant)
zeros in a variable, or within each element of the vector. If
``src == 0`` then the result is the size in bits of the type of ``src``
if ``is_zero_undef == 0`` and ``undef`` otherwise. For example,
``llvm.ctlz(i32 2) = 30``.

'``llvm.cttz.*``' Intrinsic
^^^^^^^^^^^^^^^^^^^^^^^^^^^

Syntax:
"""""""

This is an overloaded intrinsic. You can use ``llvm.cttz`` on any
integer bit width, or any vector of integer elements. Not all targets
support all bit widths or vector types, however.

::

      declare i8   @llvm.cttz.i8  (i8   <src>, i1 <is_zero_undef>)
      declare i16  @llvm.cttz.i16 (i16  <src>, i1 <is_zero_undef>)
      declare i32  @llvm.cttz.i32 (i32  <src>, i1 <is_zero_undef>)
      declare i64  @llvm.cttz.i64 (i64  <src>, i1 <is_zero_undef>)
      declare i256 @llvm.cttz.i256(i256 <src>, i1 <is_zero_undef>)
      declase <2 x i32> @llvm.cttz.v2i32(<2 x i32> <src>, i1 <is_zero_undef>)

Overview:
"""""""""

The '``llvm.cttz``' family of intrinsic functions counts the number of
trailing zeros.

Arguments:
""""""""""

The first argument is the value to be counted. This argument may be of
any integer type, or a vectory with integer element type. The return
type must match the first argument type.

The second argument must be a constant and is a flag to indicate whether
the intrinsic should ensure that a zero as the first argument produces a
defined result. Historically some architectures did not provide a
defined result for zero values as efficiently, and many algorithms are
now predicated on avoiding zero-value inputs.

Semantics:
""""""""""

The '``llvm.cttz``' intrinsic counts the trailing (least significant)
zeros in a variable, or within each element of a vector. If ``src == 0``
then the result is the size in bits of the type of ``src`` if
``is_zero_undef == 0`` and ``undef`` otherwise. For example,
``llvm.cttz(2) = 1``.

Arithmetic with Overflow Intrinsics
-----------------------------------

LLVM provides intrinsics for some arithmetic with overflow operations.

'``llvm.sadd.with.overflow.*``' Intrinsics
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Syntax:
"""""""

This is an overloaded intrinsic. You can use ``llvm.sadd.with.overflow``
on any integer bit width.

::

      declare {i16, i1} @llvm.sadd.with.overflow.i16(i16 %a, i16 %b)
      declare {i32, i1} @llvm.sadd.with.overflow.i32(i32 %a, i32 %b)
      declare {i64, i1} @llvm.sadd.with.overflow.i64(i64 %a, i64 %b)

Overview:
"""""""""

The '``llvm.sadd.with.overflow``' family of intrinsic functions perform
a signed addition of the two arguments, and indicate whether an overflow
occurred during the signed summation.

Arguments:
""""""""""

The arguments (%a and %b) and the first element of the result structure
may be of integer types of any bit width, but they must have the same
bit width. The second element of the result structure must be of type
``i1``. ``%a`` and ``%b`` are the two values that will undergo signed
addition.

Semantics:
""""""""""

The '``llvm.sadd.with.overflow``' family of intrinsic functions perform
a signed addition of the two variables. They return a structure — the
first element of which is the signed summation, and the second element
of which is a bit specifying if the signed summation resulted in an
overflow.

Examples:
"""""""""

.. code-block:: llvm

      %res = call {i32, i1} @llvm.sadd.with.overflow.i32(i32 %a, i32 %b)
      %sum = extractvalue {i32, i1} %res, 0
      %obit = extractvalue {i32, i1} %res, 1
      br i1 %obit, label %overflow, label %normal

'``llvm.uadd.with.overflow.*``' Intrinsics
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Syntax:
"""""""

This is an overloaded intrinsic. You can use ``llvm.uadd.with.overflow``
on any integer bit width.

::

      declare {i16, i1} @llvm.uadd.with.overflow.i16(i16 %a, i16 %b)
      declare {i32, i1} @llvm.uadd.with.overflow.i32(i32 %a, i32 %b)
      declare {i64, i1} @llvm.uadd.with.overflow.i64(i64 %a, i64 %b)

Overview:
"""""""""

The '``llvm.uadd.with.overflow``' family of intrinsic functions perform
an unsigned addition of the two arguments, and indicate whether a carry
occurred during the unsigned summation.

Arguments:
""""""""""

The arguments (%a and %b) and the first element of the result structure
may be of integer types of any bit width, but they must have the same
bit width. The second element of the result structure must be of type
``i1``. ``%a`` and ``%b`` are the two values that will undergo unsigned
addition.

Semantics:
""""""""""

The '``llvm.uadd.with.overflow``' family of intrinsic functions perform
an unsigned addition of the two arguments. They return a structure — the
first element of which is the sum, and the second element of which is a
bit specifying if the unsigned summation resulted in a carry.

Examples:
"""""""""

.. code-block:: llvm

      %res = call {i32, i1} @llvm.uadd.with.overflow.i32(i32 %a, i32 %b)
      %sum = extractvalue {i32, i1} %res, 0
      %obit = extractvalue {i32, i1} %res, 1
      br i1 %obit, label %carry, label %normal

'``llvm.ssub.with.overflow.*``' Intrinsics
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Syntax:
"""""""

This is an overloaded intrinsic. You can use ``llvm.ssub.with.overflow``
on any integer bit width.

::

      declare {i16, i1} @llvm.ssub.with.overflow.i16(i16 %a, i16 %b)
      declare {i32, i1} @llvm.ssub.with.overflow.i32(i32 %a, i32 %b)
      declare {i64, i1} @llvm.ssub.with.overflow.i64(i64 %a, i64 %b)

Overview:
"""""""""

The '``llvm.ssub.with.overflow``' family of intrinsic functions perform
a signed subtraction of the two arguments, and indicate whether an
overflow occurred during the signed subtraction.

Arguments:
""""""""""

The arguments (%a and %b) and the first element of the result structure
may be of integer types of any bit width, but they must have the same
bit width. The second element of the result structure must be of type
``i1``. ``%a`` and ``%b`` are the two values that will undergo signed
subtraction.

Semantics:
""""""""""

The '``llvm.ssub.with.overflow``' family of intrinsic functions perform
a signed subtraction of the two arguments. They return a structure — the
first element of which is the subtraction, and the second element of
which is a bit specifying if the signed subtraction resulted in an
overflow.

Examples:
"""""""""

.. code-block:: llvm

      %res = call {i32, i1} @llvm.ssub.with.overflow.i32(i32 %a, i32 %b)
      %sum = extractvalue {i32, i1} %res, 0
      %obit = extractvalue {i32, i1} %res, 1
      br i1 %obit, label %overflow, label %normal

'``llvm.usub.with.overflow.*``' Intrinsics
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Syntax:
"""""""

This is an overloaded intrinsic. You can use ``llvm.usub.with.overflow``
on any integer bit width.

::

      declare {i16, i1} @llvm.usub.with.overflow.i16(i16 %a, i16 %b)
      declare {i32, i1} @llvm.usub.with.overflow.i32(i32 %a, i32 %b)
      declare {i64, i1} @llvm.usub.with.overflow.i64(i64 %a, i64 %b)

Overview:
"""""""""

The '``llvm.usub.with.overflow``' family of intrinsic functions perform
an unsigned subtraction of the two arguments, and indicate whether an
overflow occurred during the unsigned subtraction.

Arguments:
""""""""""

The arguments (%a and %b) and the first element of the result structure
may be of integer types of any bit width, but they must have the same
bit width. The second element of the result structure must be of type
``i1``. ``%a`` and ``%b`` are the two values that will undergo unsigned
subtraction.

Semantics:
""""""""""

The '``llvm.usub.with.overflow``' family of intrinsic functions perform
an unsigned subtraction of the two arguments. They return a structure —
the first element of which is the subtraction, and the second element of
which is a bit specifying if the unsigned subtraction resulted in an
overflow.

Examples:
"""""""""

.. code-block:: llvm

      %res = call {i32, i1} @llvm.usub.with.overflow.i32(i32 %a, i32 %b)
      %sum = extractvalue {i32, i1} %res, 0
      %obit = extractvalue {i32, i1} %res, 1
      br i1 %obit, label %overflow, label %normal

'``llvm.smul.with.overflow.*``' Intrinsics
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Syntax:
"""""""

This is an overloaded intrinsic. You can use ``llvm.smul.with.overflow``
on any integer bit width.

::

      declare {i16, i1} @llvm.smul.with.overflow.i16(i16 %a, i16 %b)
      declare {i32, i1} @llvm.smul.with.overflow.i32(i32 %a, i32 %b)
      declare {i64, i1} @llvm.smul.with.overflow.i64(i64 %a, i64 %b)

Overview:
"""""""""

The '``llvm.smul.with.overflow``' family of intrinsic functions perform
a signed multiplication of the two arguments, and indicate whether an
overflow occurred during the signed multiplication.

Arguments:
""""""""""

The arguments (%a and %b) and the first element of the result structure
may be of integer types of any bit width, but they must have the same
bit width. The second element of the result structure must be of type
``i1``. ``%a`` and ``%b`` are the two values that will undergo signed
multiplication.

Semantics:
""""""""""

The '``llvm.smul.with.overflow``' family of intrinsic functions perform
a signed multiplication of the two arguments. They return a structure —
the first element of which is the multiplication, and the second element
of which is a bit specifying if the signed multiplication resulted in an
overflow.

Examples:
"""""""""

.. code-block:: llvm

      %res = call {i32, i1} @llvm.smul.with.overflow.i32(i32 %a, i32 %b)
      %sum = extractvalue {i32, i1} %res, 0
      %obit = extractvalue {i32, i1} %res, 1
      br i1 %obit, label %overflow, label %normal

'``llvm.umul.with.overflow.*``' Intrinsics
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Syntax:
"""""""

This is an overloaded intrinsic. You can use ``llvm.umul.with.overflow``
on any integer bit width.

::

      declare {i16, i1} @llvm.umul.with.overflow.i16(i16 %a, i16 %b)
      declare {i32, i1} @llvm.umul.with.overflow.i32(i32 %a, i32 %b)
      declare {i64, i1} @llvm.umul.with.overflow.i64(i64 %a, i64 %b)

Overview:
"""""""""

The '``llvm.umul.with.overflow``' family of intrinsic functions perform
a unsigned multiplication of the two arguments, and indicate whether an
overflow occurred during the unsigned multiplication.

Arguments:
""""""""""

The arguments (%a and %b) and the first element of the result structure
may be of integer types of any bit width, but they must have the same
bit width. The second element of the result structure must be of type
``i1``. ``%a`` and ``%b`` are the two values that will undergo unsigned
multiplication.

Semantics:
""""""""""

The '``llvm.umul.with.overflow``' family of intrinsic functions perform
an unsigned multiplication of the two arguments. They return a structure
— the first element of which is the multiplication, and the second
element of which is a bit specifying if the unsigned multiplication
resulted in an overflow.

Examples:
"""""""""

.. code-block:: llvm

      %res = call {i32, i1} @llvm.umul.with.overflow.i32(i32 %a, i32 %b)
      %sum = extractvalue {i32, i1} %res, 0
      %obit = extractvalue {i32, i1} %res, 1
      br i1 %obit, label %overflow, label %normal

Specialised Arithmetic Intrinsics
---------------------------------

'``llvm.fmuladd.*``' Intrinsic
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Syntax:
"""""""

::

      declare float @llvm.fmuladd.f32(float %a, float %b, float %c)
      declare double @llvm.fmuladd.f64(double %a, double %b, double %c)

Overview:
"""""""""

The '``llvm.fmuladd.*``' intrinsic functions represent multiply-add
expressions that can be fused if the code generator determines that the
fused expression would be legal and efficient.

Arguments:
""""""""""

The '``llvm.fmuladd.*``' intrinsics each take three arguments: two
multiplicands, a and b, and an addend c.

Semantics:
""""""""""

The expression:

::

      %0 = call float @llvm.fmuladd.f32(%a, %b, %c)

is equivalent to the expression a \* b + c, except that rounding will
not be performed between the multiplication and addition steps if the
code generator fuses the operations. Fusion is not guaranteed, even if
the target platform supports it. If a fused multiply-add is required the
corresponding llvm.fma.\* intrinsic function should be used instead.

Examples:
"""""""""

.. code-block:: llvm

      %r2 = call float @llvm.fmuladd.f32(float %a, float %b, float %c) ; yields {float}:r2 = (a * b) + c

Half Precision Floating Point Intrinsics
----------------------------------------

For most target platforms, half precision floating point is a
storage-only format. This means that it is a dense encoding (in memory)
but does not support computation in the format.

This means that code must first load the half-precision floating point
value as an i16, then convert it to float with
:ref:`llvm.convert.from.fp16 <int_convert_from_fp16>`. Computation can
then be performed on the float value (including extending to double
etc). To store the value back to memory, it is first converted to float
if needed, then converted to i16 with
:ref:`llvm.convert.to.fp16 <int_convert_to_fp16>`, then storing as an
i16 value.

.. _int_convert_to_fp16:

'``llvm.convert.to.fp16``' Intrinsic
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Syntax:
"""""""

::

      declare i16 @llvm.convert.to.fp16(f32 %a)

Overview:
"""""""""

The '``llvm.convert.to.fp16``' intrinsic function performs a conversion
from single precision floating point format to half precision floating
point format.

Arguments:
""""""""""

The intrinsic function contains single argument - the value to be
converted.

Semantics:
""""""""""

The '``llvm.convert.to.fp16``' intrinsic function performs a conversion
from single precision floating point format to half precision floating
point format. The return value is an ``i16`` which contains the
converted number.

Examples:
"""""""""

.. code-block:: llvm

      %res = call i16 @llvm.convert.to.fp16(f32 %a)
      store i16 %res, i16* @x, align 2

.. _int_convert_from_fp16:

'``llvm.convert.from.fp16``' Intrinsic
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Syntax:
"""""""

::

      declare f32 @llvm.convert.from.fp16(i16 %a)

Overview:
"""""""""

The '``llvm.convert.from.fp16``' intrinsic function performs a
conversion from half precision floating point format to single precision
floating point format.

Arguments:
""""""""""

The intrinsic function contains single argument - the value to be
converted.

Semantics:
""""""""""

The '``llvm.convert.from.fp16``' intrinsic function performs a
conversion from half single precision floating point format to single
precision floating point format. The input half-float value is
represented by an ``i16`` value.

Examples:
"""""""""

.. code-block:: llvm

      %a = load i16* @x, align 2
      %res = call f32 @llvm.convert.from.fp16(i16 %a)

Debugger Intrinsics
-------------------

The LLVM debugger intrinsics (which all start with ``llvm.dbg.``
prefix), are described in the `LLVM Source Level
Debugging <SourceLevelDebugging.html#format_common_intrinsics>`_
document.

Exception Handling Intrinsics
-----------------------------

The LLVM exception handling intrinsics (which all start with
``llvm.eh.`` prefix), are described in the `LLVM Exception
Handling <ExceptionHandling.html#format_common_intrinsics>`_ document.

.. _int_trampoline:

Trampoline Intrinsics
---------------------

These intrinsics make it possible to excise one parameter, marked with
the :ref:`nest <nest>` attribute, from a function. The result is a
callable function pointer lacking the nest parameter - the caller does
not need to provide a value for it. Instead, the value to use is stored
in advance in a "trampoline", a block of memory usually allocated on the
stack, which also contains code to splice the nest value into the
argument list. This is used to implement the GCC nested function address
extension.

For example, if the function is ``i32 f(i8* nest %c, i32 %x, i32 %y)``
then the resulting function pointer has signature ``i32 (i32, i32)*``.
It can be created as follows:

.. code-block:: llvm

      %tramp = alloca [10 x i8], align 4 ; size and alignment only correct for X86
      %tramp1 = getelementptr [10 x i8]* %tramp, i32 0, i32 0
      call i8* @llvm.init.trampoline(i8* %tramp1, i8* bitcast (i32 (i8*, i32, i32)* @f to i8*), i8* %nval)
      %p = call i8* @llvm.adjust.trampoline(i8* %tramp1)
      %fp = bitcast i8* %p to i32 (i32, i32)*

The call ``%val = call i32 %fp(i32 %x, i32 %y)`` is then equivalent to
``%val = call i32 %f(i8* %nval, i32 %x, i32 %y)``.

.. _int_it:

'``llvm.init.trampoline``' Intrinsic
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Syntax:
"""""""

::

      declare void @llvm.init.trampoline(i8* <tramp>, i8* <func>, i8* <nval>)

Overview:
"""""""""

This fills the memory pointed to by ``tramp`` with executable code,
turning it into a trampoline.

Arguments:
""""""""""

The ``llvm.init.trampoline`` intrinsic takes three arguments, all
pointers. The ``tramp`` argument must point to a sufficiently large and
sufficiently aligned block of memory; this memory is written to by the
intrinsic. Note that the size and the alignment are target-specific -
LLVM currently provides no portable way of determining them, so a
front-end that generates this intrinsic needs to have some
target-specific knowledge. The ``func`` argument must hold a function
bitcast to an ``i8*``.

Semantics:
""""""""""

The block of memory pointed to by ``tramp`` is filled with target
dependent code, turning it into a function. Then ``tramp`` needs to be
passed to :ref:`llvm.adjust.trampoline <int_at>` to get a pointer which can
be :ref:`bitcast (to a new function) and called <int_trampoline>`. The new
function's signature is the same as that of ``func`` with any arguments
marked with the ``nest`` attribute removed. At most one such ``nest``
argument is allowed, and it must be of pointer type. Calling the new
function is equivalent to calling ``func`` with the same argument list,
but with ``nval`` used for the missing ``nest`` argument. If, after
calling ``llvm.init.trampoline``, the memory pointed to by ``tramp`` is
modified, then the effect of any later call to the returned function
pointer is undefined.

.. _int_at:

'``llvm.adjust.trampoline``' Intrinsic
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Syntax:
"""""""

::

      declare i8* @llvm.adjust.trampoline(i8* <tramp>)

Overview:
"""""""""

This performs any required machine-specific adjustment to the address of
a trampoline (passed as ``tramp``).

Arguments:
""""""""""

``tramp`` must point to a block of memory which already has trampoline
code filled in by a previous call to
:ref:`llvm.init.trampoline <int_it>`.

Semantics:
""""""""""

On some architectures the address of the code to be executed needs to be
different to the address where the trampoline is actually stored. This
intrinsic returns the executable address corresponding to ``tramp``
after performing the required machine specific adjustments. The pointer
returned can then be :ref:`bitcast and executed <int_trampoline>`.

Memory Use Markers
------------------

This class of intrinsics exists to information about the lifetime of
memory objects and ranges where variables are immutable.

'``llvm.lifetime.start``' Intrinsic
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Syntax:
"""""""

::

      declare void @llvm.lifetime.start(i64 <size>, i8* nocapture <ptr>)

Overview:
"""""""""

The '``llvm.lifetime.start``' intrinsic specifies the start of a memory
object's lifetime.

Arguments:
""""""""""

The first argument is a constant integer representing the size of the
object, or -1 if it is variable sized. The second argument is a pointer
to the object.

Semantics:
""""""""""

This intrinsic indicates that before this point in the code, the value
of the memory pointed to by ``ptr`` is dead. This means that it is known
to never be used and has an undefined value. A load from the pointer
that precedes this intrinsic can be replaced with ``'undef'``.

'``llvm.lifetime.end``' Intrinsic
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Syntax:
"""""""

::

      declare void @llvm.lifetime.end(i64 <size>, i8* nocapture <ptr>)

Overview:
"""""""""

The '``llvm.lifetime.end``' intrinsic specifies the end of a memory
object's lifetime.

Arguments:
""""""""""