[LLVMdev] Target specific type modifications

Villmow, Micah Micah.Villmow at amd.com
Thu Oct 7 14:53:21 PDT 2010


Is there a way to modify the LLVM-IR type of a pointer, cascading the change to all uses, without causing code duplication?

For example,
define void @test (i32 addrspace(1)* nocapture %a, i32 addrspace(1)* nocapture %b) nounwind {
entry:
  %0 = tail call <4 x i32> @__amdil_id_int() nounwind ; <<4 x i32>> [#uses=1]
  %1 = extractelement <4 x i32> %0, i32 0         ; <i32> [#uses=2]
  %arrayidx = getelementptr i32 addrspace(1)* %a, i32 %1 ; <i32 addrspace(1)*> [#uses=1]
  %arrayidx4 = getelementptr i32 addrspace(1)* %b, i32 %1 ; <i32 addrspace(1)*> [#uses=1]
  %tmp5 = load i32 addrspace(1)* %arrayidx4       ; <i32> [#uses=1]
  store i32 %tmp5, i32 addrspace(1)* %arrayidx
  ret void
}

I want to change the address space on %a from 1 to N, where N is not 1.

This is for device specific optimizations where a and b are non-aliased and can go to different hardware memory.

The only way I know how to do this currently would be to duplicate the test function with a new type for A.
Any idea's or feedback?
Thanks,
Micah
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20101007/a65c7032/attachment.html>


More information about the llvm-dev mailing list