Compiler Development Series-Ocelot language 7. intermediate code, compiler-ocelot

Source: Internet
Author: User

Compiler Development Series-Ocelot language 7. intermediate code, compiler-ocelot

Ocelot's intermediate code is designed in accordance with the intermediate code named Tree used in the foreign Compiler-related book Modern Compiler Implementation. As the name suggests, Tree is a Tree structure with simple features and easy conversion to machine language.

For example, the following code:

int main(int argc, char** argv){return ++argc;}

Will be converted into the following intermediate code:

<IR> (G: \ Compilation Principle \ homemade compiler \ source code \ test \ hello_ir.cb: 1) variables: functions: <DefinedFunction> (G: \ Compilation Principle \ homemade compiler \ source code \ test \ hello_ir.cb: 1) name: main isPrivate: false type: int (int, char **) body: <Assign> (G: \ Compilation Principle \ homemade compiler \ source code \ test \ hello_ir.cb: 3) lhs: <Addr> type: INT32 entity: argc rhs: <Bin> type: INT32 op: ADD left: <Var> type: INT32 entity: argc right: <Int> type: INT32 value: 1 <Return> (G: \ Compilation Principle \ homemade compiler \ source code \ test \ hello_ir.cb: 3) expr: <Var> type: INT32 entity: argc

The classes that constitute the intermediate code are shown in table 11.1.

All statement nodes are inherited from the Stmt class, and the expression nodes are inherited from the Expr class.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.