[LLVMdev] FW: Proposal: New IR instruction for casting between address spaces
Micah.Villmow at amd.com
Tue Sep 11 13:03:16 PDT 2012
From: Villmow, Micah
Sent: Tuesday, September 11, 2012 12:51 PM
To: llvm-commits at cs.uiuc.edu
Subject: Proposal: New IR instruction for casting between address spaces
Bit casting between pointers of different address spaces only works if all address space pointers are the same size. With changes from email chain , support for different pointer sizes breaks the bitcast instruction since there is no guarantee that the pointer size for the address space is on the source and destination arguments are of the same size.
Remove the ability of bitcast to cast between pointers of different address spaces and replace with an instruction that handles this case explicitely.
* Add restriction to the verifier on the bitcast instruction making bitcasting between address spaces illegal.
* Change documentation to state the bitcast to pointers of different address spaces is illegal.
* Add in a new IR node, addrspacecast, that allows conversions between address spaces
* Updated the reader/writer to handle these cases
* Update the documentation to insert the new IR node.
* Add the following documentation:
'addrspacecast .. to' Instruction
<result> = addrspacecast <ty> <value> to <ty2> ; yields ty2
The ' addrspacecast ' instruction converts value to type ty2 without changing any bits.
The ' addrspacecast ' instruction takes a value to cast, which must be a non-aggregate first class value with a pointer type, and a type to cast it to, which must also be a pointer type. The pointer types of value and the destination type, ty2, must be identical, except for the address space.
The ' addrspacecast ' instruction converts value to type ty2. It converts the type to the type that is implied by the address space of the destination pointer. If the destination pointer is smaller than the source pointer, the upper bits are truncated. If the inverse is true, the upper bits are sign extended, otherwise the operation is a no-op.
%X = addrspacecast i8 addrspace(1) 255 to i8* addrspace(2) ; yields i8* addrspace(2) :-1
%Y = addrspacecast i32* %x to sint* addrspace(31) ; yields sint* addrspace(31):%x
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev