Hubbry Logo
search button
Sign in
Three-address code
Three-address code
Comunity Hub
History
arrow-down
starMore
arrow-down
bob

Bob

Have a question related to this hub?

bob

Alice

Got something to say related to this hub?
Share it here.

#general is a chat channel to discuss anything related to the hub.
Hubbry Logo
search button
Sign in
Three-address code
Community hub for the Wikipedia article
logoWikipedian hub
Welcome to the community hub built on top of the Three-address code Wikipedia article. Here, you can discuss, collect, and organize anything related to Three-address code. The purpose of the hub is to con...
Add your contribution
Three-address code

In computer science, three-address code[1] (often abbreviated to TAC or 3AC) is an intermediate code used by optimizing compilers to aid in the implementation of code-improving transformations. Each TAC instruction has at most three operands and is typically a combination of assignment and a binary operator. For example, t1 := t2 + t3. The name derives from the use of three operands in these statements even though instructions with fewer operands may occur.

Since three-address code is used as an intermediate language within compilers, the operands will most likely not be concrete memory addresses or processor registers, but rather symbolic addresses that will be translated into actual addresses during register allocation. It is also not uncommon that operand names are numbered sequentially since three-address code is typically generated by the compiler.

A refinement of three-address code is A-normal form (ANF).

Examples

[edit]

In three-address code, this would be broken down into several separate instructions. These instructions translate more easily to assembly language. It is also easier to detect common sub-expressions for shortening the code. In the following example, one calculation is composed of several smaller ones:

Three-address code may have conditional and unconditional jumps and methods of accessing memory. It may also have methods of calling functions, or it may reduce these to jumps. In this way, three-address code may be useful in control-flow analysis. In the following C-like example, a loop stores the squares of the numbers between 0 and 9:

See also

[edit]

References

[edit]
  1. ^ V., Aho, Alfred (1986). Compilers, principles, techniques, and tools. Sethi, Ravi., Ullman, Jeffrey D., 1942-. Reading, Mass.: Addison-Wesley Pub. Co. pp. 466. ISBN 0201100886. OCLC 12285707.{{cite book}}: CS1 maint: multiple names: authors list (link)