[llvm-dev] Usage of base register other than ebp for array accesses

Gnanambikai Krishnakumar via llvm-dev llvm-dev at lists.llvm.org
Sun Sep 17 07:24:02 PDT 2017

Hello All,

    We want to write a transformation pass such that the array accesses use
a base register other than ebp (assuming that the code is compiled for x86
architecture). For example,

The below C code
->int a[5];
->a[2] = 2

by default, gets compiled to something like this:
->mov    dword ptr [ebp - 28], eax

However, we want our pass to emit the something similar to the following
->mov   ecx, "base of array"
->mov   dword ptr [ecx - "index from base of array a"], eax

Is there any way we could modify the llvm code so as to achieve the
required instruction format? Please let us know if there is some code that
already does this or if it is documented elsewhere.

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

More information about the llvm-dev mailing list