by buttproblem · 11y ago · 0 comments
LLVM variables are sometimes called registers but they are machine independent. The bit width is arbitrary (e.g., you can create a 129-bit integer). The use of the term register is a misleading analogy; often LLVM-IR is compared to assembly language so the use of the term register was also used.
I do not know GIMPLE and couldn't find a good description of the IR instructions. But, it seems that LLVM IR is somewhat similar to low GIMPLE.
Gimple variables have types comparable with C types - you get pointers, arrays.
For example:
int sum10(int values[10]) {
int i;
int sum = 0;
for(i=0;i<10;++i) { sum += values[i]; }
values[0] = 342;
return sum;
}
is compiled down to: sum10 (int * values)
{
long unsigned int D.1598;
long unsigned int D.1599;
int * D.1600;
int D.1601;
int D.1602;
int i;
int sum;
sum = 0;
i = 0;
goto <D.1595>;
<D.1594>:
D.1598 = (long unsigned int) i;
D.1599 = D.1598 * 4;
D.1600 = values + D.1599;
D.1601 = *D.1600;
sum = D.1601 + sum;
i = i + 1;
<D.1595>:
if (i <= 9) goto <D.1594>; else goto <D.1596>;
<D.1596>:
*values = 342;
D.1602 = sum;
return D.1602;
}