[LLVMdev] Address calculation

Villmow, Micah Micah.Villmow at amd.com
Mon Oct 6 09:03:48 PDT 2008


I am attempting to get indexing code generation working with my backend.
However, it seems that the addresses being calculated is being
multiplied by the width of the data type.

 

define void @ test_input_index_constant_int(i32 addrspace(11)* %input,
i32 addrspace(11)* %result) {

entry:

        %input.addr = alloca i32 addrspace(11)*         ; <i32
addrspace(11)**> [#uses=2]

        %result.addr = alloca i32 addrspace(11)*                ; <i32
addrspace(11)**> [#uses=2]

        store i32 addrspace(11)* %input, i32 addrspace(11)** %input.addr

        store i32 addrspace(11)* %result, i32 addrspace(11)**
%result.addr

        %tmp = load i32 addrspace(11)** %result.addr            ; <i32
addrspace(11)*> [#uses=1]

        %tmp1 = load i32 addrspace(11)** %input.addr            ; <i32
addrspace(11)*> [#uses=1]

        %arrayidx = getelementptr i32 addrspace(11)* %tmp1, i32 23
; <i32 addrspace(11)*> [#uses=1]

        %tmp2 = load i32 addrspace(11)* %arrayidx               ; <i32>
[#uses=1]

        store i32 %tmp2, i32 addrspace(11)* %tmp

        ret void

}

 

The value 23 in the getelementptr is being multiplied by 4 bytes and the
generated code is the value 96. However, I don't want this
multiplication to occur and I cannot figure out how to divide the
immediate by 4 when lowering the Add instruction that is linked to a
load/store operation.

 

So my question is, how do I modified a immediate constant value from an
SDValue struct? If that is not possible, what section of code do I need
to modify to get LLVM to stop multiplying the index by the data size.

 

Thanks,

Micah Villmow

Systems Engineer

Advanced Technology & Performance

Advanced Micro Devices Inc.

4555 Great America Pkwy,

Santa Clara, CA. 95054

P: 408-572-6219

F: 408-572-6596

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20081006/d2035c64/attachment.html>


More information about the llvm-dev mailing list