{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# 03-05threeAddressCode - Code Generation Part 1 Generating...

This preview shows pages 1–3. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
2 CSE 450: Compilers K. Stirewalt 3-address instructions (continued) Procedure calls: involve a combination of three kinds of instruction: param x stores the contents of address x on the system stack call p, n invokes procedure p using the last n elements on the stack as actual parameters y = call p, n is same except with the ability to store a returned value into address y return y returns to caller, optionally passing y as a return value. CSE 450: Compilers K. Stirewalt Example of a procedure call Consider function foo of two integer parameters that returns an integer. We could translate a SpartanAda statement of the form: y := foo(x, y); into the 3 -address instructions: param x param y y = call foo, 2 CSE 450: Compilers K. Stirewalt Example Consider the C - language statement: do i = i+1; while (a[i] < v); We could translate this into: L: t 1 = i + 1 i = t 1 t 2 = i * 8 t 3 = a[t 2 ] if t 3 < v goto L The multiplication of i by 8 accounts for the elements of a each taking 8 bytes of space CSE 450: Compilers K. Stirewalt Formally defining translations To define the translation described by the previous example we must develop an SDD Problem: The translation is subtle and complex Solution: – Define the translation one language feature at a time – Requires careful design of a framework of
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 8

03-05threeAddressCode - Code Generation Part 1 Generating...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online