Three address code

Three address code

In computer science, three-address code (often abbreviated to TAC or 3AC) is a form of representing intermediate code used by compilers to aid in the implementation of code-improving transformations. Each instruction in three-address code can be described as a 4-tuple: (operator, operand1, operand2, result).

Each statement has the general form of:


x := y , operatorname{op} , z,

where "x", "y" and "z" are variables, constants or temporary variables generated by the compiler. "op" represents any operator, "e.g." an arithmetic operator.

Expressions containing more than one fundamental operation, such as:


p := x + y imes z,

are not representable in three-address code as a single instruction. Instead, they are decomposed into an equivalent series of instructions, such as


t_1 := y imes z,

p := x + t_1,

The term "three-address code" is still used even if some instructions use more or fewer than two operands. The key features of three-address code are that every instruction implements exactly one fundamental operation, and that the source and destination may refer to any available register.

A refinement of three-address code is static single assignment form (SSA).

Example

int main(void) { int i; int b [10] ; for (i = 0; i < 10; ++i) { b [i] = i*i; } }The preceding C program, translated into three-address code, might look something like the following: i := 0 ; assignment L1: if i < 10 goto L2 ; conditional jump goto L3 ; unconditional jump L2: t0 := i*i t1 := &b ; address-of operation t2 := t1 + i ; t2 holds the address of b [i] *t2 := t0 ; store through pointer i := i + 1 goto L1 L3:

ee also

*Intermediate language
*Reduced instruction set computer

External links

* [http://cs.wwc.edu/~aabyan/464/Quads.html Three-Address Code and Register Allocation]
* [http://www.cs.arizona.edu/classes/cs453/fall07/DOCS/intcode.html CSc 453: A Three-Address Intermediate Code Instruction Set for C--]


Wikimedia Foundation. 2010.

Игры ⚽ Нужен реферат?

Look at other dictionaries:

  • Code generation (compiler) — In computer science, code generation is the process by which a compiler s code generator converts some intermediate representation of source code into a form (e.g., machine code) that can be readily executed by a machine (often a computer).… …   Wikipedia

  • Address space — In computing, an address space defines a range of discrete addresses, each of which may correspond to a physical or virtual memory register, a network host, peripheral device, disk sector or other logical or physical entity. A memory address… …   Wikipedia

  • Code of Personal Status (Tunisia) — The Code of Personal Status (CPS) (Arabic: مجلة الأحوال الشخصية‎) is a series of progressive Tunisian laws aiming at the institution of equality between women and men in a number of areas. It was promulgated by beylical decree on August 13, 1956… …   Wikipedia

  • Three Fathom Harbour, Nova Scotia — Three Fathom Harbour is a fishing community on the Eastern Shore of the Halifax Regional Municipality Nova Scotia on the shore of Atlantic Ocean off Route 207 on Three Fathom Harbour Road . The harhour has its own authority .Communications* The… …   Wikipedia

  • Address (geography) — An address is a collection of information, presented in a mostly fixed format, used for describing the location of a building, apartment, or other structure or a plot of land, generally using political boundaries and street names as references,… …   Wikipedia

  • Code Pink — For the hospital emergency code, see Hospital emergency codes. Code Pink: Women for Peace Code Pink activists demonstrate in front of the White House on July 4, 2006. Formation …   Wikipedia

  • Code word (figure of speech) — For other uses, see code word (disambiguation). A code word is a word or a phrase designed to convey a predetermined meaning to a receptive audience, while remaining inconspicuous to the uninitiated. Contents 1 Medical 2 Commercial 3 Fiction …   Wikipedia

  • Code (metadata) — In metadata, the representation term code refers to, and is used in the name of, data elements whose allowable values can be represented as enumerated lists. Each enumerated value is a string that for brevity represents a specific meaning. For… …   Wikipedia

  • Three Secrets of Fátima — Statue of Our Lady of Fátima The Three Secrets of Fátima consist of a series of visions and prophecies given by an apparition of the Blessed Virgin Mary to three young Portuguese shepherds, Lúcia Santos and her cousins Jacinta and Francisco Marto …   Wikipedia

  • ZIP code — Mr. ZIP promoted the use of ZIP codes for the USPS during the 1960s and 1970s. ZIP codes are a system of postal codes used by the United States Postal Service (USPS) since 1963. The term ZIP, an acronym for Zone Improvement Plan,[1] is properly… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”