Usage of base register other than ebp for array accesses

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 instead:

->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.



There are two ways that I can see to do this: I think the more interesting question is why you want to do this. What is your end goal? Regards, John Criswell