Corruption fixed in doc/llvm.core.Constant.rst (bottom of page needs work)

This commit is contained in:
David H Post 2013-04-11 02:36:00 -05:00
commit 66346ee507

View file

@ -26,333 +26,334 @@ some examples:
tr = Type.float() tr = Type.float()
r1 = Constant.real(tr, "3.141592") # create from a string r2 = r1 = Constant.real(tr, "3.141592") # create from a string
Constant.real(tr, 1.61803399) # create from a Python float {% r2 = Constant.real(tr, 1.61803399) # create from a Python float
endhighlight %}
# llvm.core.Constant
- This will become a table of contents (this text will be scraped).
{:toc}
Static factory methods # llvm.core.Constant
---------------------- - This will become a table of contents (this text will be scraped).
{:toc}
``null(ty)``
~~~~~~~~~~~~
A null value (all zeros) of type ``ty`` Static factory methods
----------------------
``all_ones(ty)`` ``null(ty)``
~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~
All 1's value of type ``ty`` A null value (all zeros) of type ``ty``
``undef(ty)`` ``all_ones(ty)``
~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
An undefined value of type ``ty`` All 1's value of type ``ty``
``int(ty, value)`` ``undef(ty)``
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~
Integer of type ``ty``, with value ``value`` (a Python int or long) An undefined value of type ``ty``
``int_signextend(ty, value)`` ``int(ty, value)``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
Integer of signed type ``ty`` (use for signed types) Integer of type ``ty``, with value ``value`` (a Python int or long)
``real(ty, value)`` ``int_signextend(ty, value)``
~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Floating point value of type ``ty``, with value ``value`` (a Python Integer of signed type ``ty`` (use for signed types)
float)
``stringz(value)`` ``real(ty, value)``
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
A null-terminated string. ``value`` is a Python string Floating point value of type ``ty``, with value ``value`` (a Python
float)
``string(value)`` ``stringz(value)``
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
As ``string(ty)``, but not null terminated A null-terminated string. ``value`` is a Python string
``array(ty, consts)`` ``string(value)``
~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
Array of type ``ty``, initialized with ``consts`` (an iterable yielding As ``string(ty)``, but not null terminated
``Constant`` objects of the appropriate type)
``struct(ty, consts)`` ``array(ty, consts)``
~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~
Struct (unpacked) of type ``ty``, initialized with ``consts`` (an Array of type ``ty``, initialized with ``consts`` (an iterable yielding
iterable yielding ``Constant`` objects of the appropriate type) ``Constant`` objects of the appropriate type)
``packed_struct(ty, consts)`` ``struct(ty, consts)``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~
As ``struct(ty, consts)`` but packed Struct (unpacked) of type ``ty``, initialized with ``consts`` (an
iterable yielding ``Constant`` objects of the appropriate type)
``vector(consts)`` ``packed_struct(ty, consts)``
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Vector, initialized with ``consts`` (an iterable yielding ``Constant`` As ``struct(ty, consts)`` but packed
objects of the appropriate type)
``sizeof(ty)`` ``vector(consts)``
~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
Constant value representing the sizeof the type ``ty`` Vector, initialized with ``consts`` (an iterable yielding ``Constant``
objects of the appropriate type)
Methods ``sizeof(ty)``
------- ~~~~~~~~~~~~~~
The following operations on constants are supported. For more details on Constant value representing the sizeof the type ``ty``
any operation, consult the `Constant
Expressions <http://www.llvm.org/docs/LangRef.html#constantexprs>`_
section of the LLVM Language Reference.
``k.neg()`` Methods
~~~~~~~~~~~ -------
negation, same as ``0 - k`` The following operations on constants are supported. For more details on
any operation, consult the `Constant
Expressions <http://www.llvm.org/docs/LangRef.html#constantexprs>`_
section of the LLVM Language Reference.
``k.not_()`` ``k.neg()``
~~~~~~~~~~~~ ~~~~~~~~~~~
1's complement of ``k``. Note trailing underscore. negation, same as ``0 - k``
``k.add(k2)`` ``k.not_()``
~~~~~~~~~~~~~ ~~~~~~~~~~~~
``k + k2``, where ``k`` and ``k2`` are integers. 1's complement of ``k``. Note trailing underscore.
``k.fadd(k2)`` ``k.add(k2)``
~~~~~~~~~~~~~~ ~~~~~~~~~~~~~
``k + k2``, where ``k`` and ``k2`` are floating-point. ``k + k2``, where ``k`` and ``k2`` are integers.
``k.sub(k2)`` ``k.fadd(k2)``
~~~~~~~~~~~~~ ~~~~~~~~~~~~~~
``k - k2``, where ``k`` and ``k2`` are integers. ``k + k2``, where ``k`` and ``k2`` are floating-point.
``k.fsub(k2)`` ``k.sub(k2)``
~~~~~~~~~~~~~~ ~~~~~~~~~~~~~
``k - k2``, where ``k`` and ``k2`` are floating-point. ``k - k2``, where ``k`` and ``k2`` are integers.
``k.mul(k2)`` ``k.fsub(k2)``
~~~~~~~~~~~~~ ~~~~~~~~~~~~~~
``k * k2``, where ``k`` and ``k2`` are integers. ``k - k2``, where ``k`` and ``k2`` are floating-point.
``k.fmul(k2)`` ``k.mul(k2)``
~~~~~~~~~~~~~~ ~~~~~~~~~~~~~
``k * k2``, where ``k`` and ``k2`` are floating-point. ``k * k2``, where ``k`` and ``k2`` are integers.
``k.udiv(k2)`` ``k.fmul(k2)``
~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~
Quotient of unsigned division of ``k`` with ``k2`` ``k * k2``, where ``k`` and ``k2`` are floating-point.
``k.sdiv(k2)`` ``k.udiv(k2)``
~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~
Quotient of signed division of ``k`` with ``k2`` Quotient of unsigned division of ``k`` with ``k2``
``k.fdiv(k2)`` ``k.sdiv(k2)``
~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~
Quotient of floating point division of ``k`` with ``k2`` Quotient of signed division of ``k`` with ``k2``
``k.urem(k2)`` ``k.fdiv(k2)``
~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~
Reminder of unsigned division of ``k`` with ``k2`` Quotient of floating point division of ``k`` with ``k2``
``k.srem(k2)`` ``k.urem(k2)``
~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~
Reminder of signed division of ``k`` with ``k2`` Reminder of unsigned division of ``k`` with ``k2``
``k.frem(k2)`` ``k.srem(k2)``
~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~
Reminder of floating point division of ``k`` with ``k2`` Reminder of signed division of ``k`` with ``k2``
``k.and_(k2)`` ``k.frem(k2)``
~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~
Bitwise and of ``k`` and ``k2``. Note trailing underscore. Reminder of floating point division of ``k`` with ``k2``
``k.or_(k2)`` ``k.and_(k2)``
~~~~~~~~~~~~~ ~~~~~~~~~~~~~~
Bitwise or of ``k`` and ``k2``. Note trailing underscore. Bitwise and of ``k`` and ``k2``. Note trailing underscore.
``k.xor(k2)`` ``k.or_(k2)``
~~~~~~~~~~~~~ ~~~~~~~~~~~~~
Bitwise exclusive-or of ``k`` and ``k2``. Bitwise or of ``k`` and ``k2``. Note trailing underscore.
``k.icmp(icmp, k2)`` ``k.xor(k2)``
~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~
Compare ``k`` with ``k2`` using the predicate ``icmp``. See Bitwise exclusive-or of ``k`` and ``k2``.
`here <comparision.html#icmp>`_ for list of predicates for integer
operands.
``k.fcmp(fcmp, k2)`` ``k.icmp(icmp, k2)``
~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~
Compare ``k`` with ``k2`` using the predicate ``fcmp``. See Compare ``k`` with ``k2`` using the predicate ``icmp``. See
`here <comparision.html#fcmp>`_ for list of predicates for real `here <comparision.html#icmp>`_ for list of predicates for integer
operands. operands.
``k.shl(k2)`` ``k.fcmp(fcmp, k2)``
~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~
Shift ``k`` left by ``k2`` bits. Compare ``k`` with ``k2`` using the predicate ``fcmp``. See
`here <comparision.html#fcmp>`_ for list of predicates for real
operands.
``k.lshr(k2)`` ``k.shl(k2)``
~~~~~~~~~~~~~~ ~~~~~~~~~~~~~
Shift ``k`` logically right by ``k2`` bits (new bits are 0s). Shift ``k`` left by ``k2`` bits.
``k.ashr(k2)`` ``k.lshr(k2)``
~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~
Shift ``k`` arithmetically right by ``k2`` bits (new bits are same as Shift ``k`` logically right by ``k2`` bits (new bits are 0s).
previous sign bit).
``k.gep(indices)`` ``k.ashr(k2)``
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~
GEP, see `LLVM docs <http://www.llvm.org/docs/GetElementPtr.html>`_. Shift ``k`` arithmetically right by ``k2`` bits (new bits are same as
previous sign bit).
``k.trunc(ty)`` ``k.gep(indices)``
~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
Truncate ``k`` to a type ``ty`` of lower bitwidth. GEP, see `LLVM docs <http://www.llvm.org/docs/GetElementPtr.html>`_.
``k.sext(ty)`` ``k.trunc(ty)``
~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~
Sign extend ``k`` to a type ``ty`` of higher bitwidth, while extending Truncate ``k`` to a type ``ty`` of lower bitwidth.
the sign bit.
``k.zext(ty)`` ``k.sext(ty)``
~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~
Sign extend ``k`` to a type ``ty`` of higher bitwidth, all new bits are Sign extend ``k`` to a type ``ty`` of higher bitwidth, while extending
0s. the sign bit.
``k.fptrunc(ty)`` ``k.zext(ty)``
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~
Truncate floating point constant ``k`` to floating point type ``ty`` of Sign extend ``k`` to a type ``ty`` of higher bitwidth, all new bits are
lower size than k's. 0s.
``k.fpext(ty)`` ``k.fptrunc(ty)``
~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
Extend floating point constant ``k`` to floating point type ``ty`` of Truncate floating point constant ``k`` to floating point type ``ty`` of
higher size than k's. lower size than k's.
``k.uitofp(ty)`` ``k.fpext(ty)``
~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~
Convert an unsigned integer constant ``k`` to floating point constant of Extend floating point constant ``k`` to floating point type ``ty`` of
type ``ty``. higher size than k's.
``k.sitofp(ty)`` ``k.uitofp(ty)``
~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
Convert a signed integer constant ``k`` to floating point constant of Convert an unsigned integer constant ``k`` to floating point constant of
type ``ty``. type ``ty``.
``k.fptoui(ty)`` ``k.sitofp(ty)``
~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
Convert a floating point constant ``k`` to an unsigned integer constant Convert a signed integer constant ``k`` to floating point constant of
of type ``ty``. type ``ty``.
``k.fptosi(ty)`` ``k.fptoui(ty)``
~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
Convert a floating point constant ``k`` to a signed integer constant of Convert a floating point constant ``k`` to an unsigned integer constant
type ``ty``. of type ``ty``.
``k.ptrtoint(ty)`` ``k.fptosi(ty)``
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
Convert a pointer constant ``k`` to an integer constant of type ``ty``. Convert a floating point constant ``k`` to a signed integer constant of
type ``ty``.
``k.inttoptr(ty)`` ``k.ptrtoint(ty)``
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
Convert an integer constant ``k`` to a pointer constant of type ``ty``. Convert a pointer constant ``k`` to an integer constant of type ``ty``.
``k.bitcast(ty)`` ``k.inttoptr(ty)``
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
Convert ``k`` to a (equal-width) constant of type ``ty``. Convert an integer constant ``k`` to a pointer constant of type ``ty``.
``k.select(cond,k2,k3)`` ``k.bitcast(ty)``
~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
Replace value with ``k2`` if the 1-bit integer constant ``cond`` is 1, Convert ``k`` to a (equal-width) constant of type ``ty``.
else with ``k3``.
``k.extract_element(idx)`` ``k.select(cond,k2,k3)``
~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~
Extract value at ``idx`` (integer constant) from a vector constant Replace value with ``k2`` if the 1-bit integer constant ``cond`` is 1,
``k``. else with ``k3``.
``k.insert_element(k2,idx)`` ``k.extract_element(idx)``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~
Insert value ``k2`` (scalar constant) at index ``idx`` (integer Extract value at ``idx`` (integer constant) from a vector constant
constant) of vector constant ``k``. ``k``.
``k.shuffle_vector(k2,mask)`` ``k.insert_element(k2,idx)``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Shuffle vector constant ``k`` based on vector constants ``k2`` and Insert value ``k2`` (scalar constant) at index ``idx`` (integer
``mask``. constant) of vector constant ``k``.
-------------- ``k.shuffle_vector(k2,mask)``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Other Constant Classes Shuffle vector constant ``k`` based on vector constants ``k2`` and
The following subclasses of ``Constant`` do not provide additional ``mask``.
methods, **they serve only to provide richer type information.**
Subclass \| LLVM C++ Class \| Remarks \| --------------
---------\|----------------\|---------\| ``ConstantExpr`` \|
``llvmConstantExpr`` \| A constant expression \|
``ConstantAggregateZero``\ \| ``llvmConstantAggregateZero``\ \| All-zero
constant \| ``ConstantInt``\ \| ``llvmConstantInt``\ \| An integer
constant \| ``ConstantFP``\ \| ``llvmConstantFP``\ \| A floating-point
constant \| ``ConstantArray``\ \| ``llvmConstantArray``\ \| An array
constant \| ``ConstantStruct``\ \| ``llvmConstantStruct``\ \| A
structure constant \| ``ConstantVector``\ \| ``llvmConstantVector``\ \|
A vector constant \| ``ConstantPointerNull``\ \|
``llvmConstantPointerNull``\ \| All-zero pointer constant \|
``UndefValue``\ \| ``llvmUndefValue``\ \| corresponds to ``undef`` of
LLVM IR \|
These types are helpful in ``isinstance`` checks, like so: # Other Constant Classes
The following subclasses of ``Constant`` do not provide additional
methods, **they serve only to provide richer type information.**
{% highlight python %} ti = Type.int(32) k1 = Constant.int(ti, 42) # Subclass \| LLVM C++ Class \| Remarks \|
int32_t k1 = 42; k2 = Constant.array(ti, [k1, k1]) # int32_t k2[] = { ---------\|----------------\|---------\| ``ConstantExpr`` \|
k1, k1 }; ``llvmConstantExpr`` \| A constant expression \|
``ConstantAggregateZero``\ \| ``llvmConstantAggregateZero``\ \| All-zero
constant \| ``ConstantInt``\ \| ``llvmConstantInt``\ \| An integer
constant \| ``ConstantFP``\ \| ``llvmConstantFP``\ \| A floating-point
constant \| ``ConstantArray``\ \| ``llvmConstantArray``\ \| An array
constant \| ``ConstantStruct``\ \| ``llvmConstantStruct``\ \| A
structure constant \| ``ConstantVector``\ \| ``llvmConstantVector``\ \|
A vector constant \| ``ConstantPointerNull``\ \|
``llvmConstantPointerNull``\ \| All-zero pointer constant \|
``UndefValue``\ \| ``llvmUndefValue``\ \| corresponds to ``undef`` of
LLVM IR \|
assert isinstance(k1, ConstantInt) assert isinstance(k2, ConstantArray) These types are helpful in ``isinstance`` checks, like so:
{% highlight python %} ti = Type.int(32) k1 = Constant.int(ti, 42) #
int32_t k1 = 42; k2 = Constant.array(ti, [k1, k1]) # int32_t k2[] = {
k1, k1 };
assert isinstance(k1, ConstantInt) assert isinstance(k2, ConstantArray)
Automatically Generated Documentation Automatically Generated Documentation