|
|
Line 1: |
Line 1: |
| Considere a seguinte função em C:
| | #REDIRECT [[ist:Optimization Topics/Exercise 01]] |
| # Que optimizações independentes da máquina são possíveis?
| |
| # Traduza-a para Postfix optimizado. | |
| | |
| <c>
| |
| int *fun(int *a, int *b) {
| |
| int *c = (int *)malloc(160 * 4), i, j;
| |
| for (j = 0; j < 40; ++j)
| |
| for (i = 0; i < 4; ++i)
| |
| c[i+j*4] = a[i+j*4] + b[i*40+j] + 100*j;
| |
| return c;
| |
| }
| |
| </c>
| |
| | |
| Instruções Postfix:
| |
| | |
| <text>
| |
| directivas: text data rodata bss align label extrn globl const str char id byte double
| |
| acesso: addr addra addrv local loca locv load load2 ldchr store store2 stchr
| |
| alloc dup swap push pop int sp
| |
| aritmética/lógica: add dadd sub dsub mul dmul div ddiv mod neg gt ge lt le eq ne cmp
| |
| bit a bit: rotl rotr shtl shtru shtrs and or not xor
| |
| funções/saltos: call ret start enter leave trash jmp jz jnz branch leap
| |
| </text>
| |