From 59d3ae6cdc4316ad338cd848251f33a236ccb36c Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Fri, 15 Nov 2013 01:34:59 +0000 Subject: Add addrspacecast instruction. Patch by Michele Scandale! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194760 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/LangRef.rst | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 3 deletions(-) (limited to 'docs') diff --git a/docs/LangRef.rst b/docs/LangRef.rst index 9c033ed..58bba1b 100644 --- a/docs/LangRef.rst +++ b/docs/LangRef.rst @@ -2382,6 +2382,10 @@ The following is the syntax for constant expressions: Convert a constant, CST, to another TYPE. The constraints of the operands are the same as those for the :ref:`bitcast instruction `. +``addrspacecast (CST to TYPE)`` + Convert a constant pointer or constant vector of pointer, CST, to another + TYPE in a different address space. The constraints of the operands are the + same as those for the :ref:`addrspacecast instruction `. ``getelementptr (CSTPTR, IDX0, IDX1, ...)``, ``getelementptr inbounds (CSTPTR, IDX0, IDX1, ...)`` Perform the :ref:`getelementptr operation ` on constants. As with the :ref:`getelementptr ` @@ -5726,9 +5730,9 @@ is always a *no-op cast* because no bits change with this conversion. The conversion is done as if the ``value`` had been stored to memory and read back as type ``ty2``. Pointer (or vector of pointers) types may only be converted to other pointer (or vector of -pointers) types with this instruction if the pointer sizes are -equal. To convert pointers to other types, use the :ref:`inttoptr -` or :ref:`ptrtoint ` instructions first. +pointers) types with the same address space through this instruction. +To convert pointers to other types, use the :ref:`inttoptr ` +or :ref:`ptrtoint ` instructions first. Example: """""""" @@ -5740,6 +5744,51 @@ Example: %Z = bitcast <2 x int> %V to i64; ; yields i64: %V %Z = bitcast <2 x i32*> %V to <2 x i64*> ; yields <2 x i64*> +.. _i_addrspacecast: + +'``addrspacecast .. to``' Instruction +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Syntax: +""""""" + +:: + + = addrspacecast to ; yields pty2 + +Overview: +""""""""" + +The '``addrspacecast``' instruction converts ``ptrval`` from ``pty`` in +address space ``n`` to type ``pty2`` in address space ``m``. + +Arguments: +"""""""""" + +The '``addrspacecast``' instruction takes a pointer or vector of pointer value +to cast and a pointer type to cast it to, which must have a different +address space. + +Semantics: +"""""""""" + +The '``addrspacecast``' instruction converts the pointer value +``ptrval`` to type ``pty2``. It can be a *no-op cast* or a complex +value modification, depending on the target and the address spaces +pair. Pointers conversion within the same address space must be +performed with ``bitcast`` instruction. Note that if the address space +conversion is legal then both result and operand refer to the same memory +location. + +Example: +"""""""" + +.. code-block:: llvm + + %X = addrspacecast i32* %x to addrspace(1) i32* ; yields addrspace(1) i32*:%x + %Y = addrspacecast addrspace(1) <2 x i32>* %y to addrspace(2) i64* ; yields addrspace(2) i32*:%y + %Z = addrspacecast <4 x i32*> %z to <4 x float addrspace(3)*> ; yelds <4 x float addrspace(3)*>:%z + .. _otherops: Other Operations -- cgit v1.1