





















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






















Project 3
» Get started building openimpact!! » Make sure you get the environment variables
set up before trying to install
Reading
» 10.
l_code.h: Core Lcode Data Structures (cont)
L_Flow – control flow edges for CFG
» src_cb, dst_cb, weight » Connected in doubly linked list (prev/next)
L_Func – function
» First/last cbs, weight » Oper and cb hash tables (id -> L_Oper/L_Cb)
L_Attr – extra information
» L_Oper, L_Cb, and L_Func have attributes » Name, array of L_Operands
Example Opti: Local Constant Propagation
for (opA = cb->first_op; opA != NULL; opA = opA->next_op) {
/* Match pattern */ if (!L_move_opcode (opA)) continue; if (!L_is_constant (opA->src[0])) continue; for (opB = opA->next_op; opB != NULL; opB = opB->next_op) {
if (!L_is_src_operand (opA->dest[0], opB)) continue; if (!L_can_change_src_operand (opB, opA->dest[0])) continue; if (!L_no_defs_between (opA->dest[0], opA, opB)) continue; macro_flag = L_is_fragile_macro (opA->dest[0]); load_flag = 0; store_flag = 0; if (!L_no_danger (macro_flag, load_flag, store_flag, opA, opB))
break; /* Replace pattern */ for (i = 0; i < L_max_src_operand; i++) {
if (L_same_operand (opA->dest[0], opB->src[i])) {
opB->src[i] = L_copy_operand (opA->src[0]); }
}
} }
Running Things Manually, Debugging - cont
Running Lemulate manually
Compile the .c files with gcc
»
gcc –g *.c $IMPACT_REL_PATH/platform/x86lin_gcc/impact_lemul_lib.o –lm
Debugging – gdb
Goals
Type 1 – compile-time constant trip count
Type 2 – counted, but trip count unknown atcompile time
Type 3 – non-counted
j = itripcount = 100 – jtripcount = tripcount / 1remainder = tc % 2final = remainder * 1 final = final + j / I forgot this on the*
*unroll 2 slide /
Remloop:while (j < final) {
A[j++]--; } Unrolledloop:while (j < 100) {
A[j]--;A[j+1]--j+=2; }
Unravel first P iterations of a loop
Loop:r1 = MEM[r2 + 0]r4 = r1 * r5r6 = r4 << 2MEM[r3 + 0] = r6r2 = r2 + 1blt r2 100 Loop
r1 = MEM[r2 + 0]r4 = r1 * r5r6 = r4 << 2MEM[r3 + 0] = r6r2 = r2 + 1bge r2 100 Done
.. .L1: if (a < b) goto L2 L2:...
entry
bb
bb
bb
bb
bb
Algorithm
L1: if (a < b) goto L11L2: goto L7L3: goto L4L4: stuff4L5: if (c < d) goto L15L6: goto L2L7: if (c < d) goto L13L8: goto L12L9: stuff 9L10: if (a < c) goto L3L11:goto L9L12: goto L2L13: stuff 13L14: if (e < f) goto L11L15: stuff 15L16: rts
20 (side exit) 10 (side exit)
10 (entry count)
90 (entry/ exit count)
10 (exit count)
20 (side entrance) 10 (side entrance)
trace1 trace 2 trace 3 The rest
Intraprocedural code placement Procedure positioning Procedure splitting