Can anyone explain the compiler intermediate language and optimization easily?

Asked 2 years ago, Updated 2 years ago, 82 views

Am I right to think about what this middle language is like? Example) Using Hindi - Intermediate Language - Korean

The primitive program is divided into tokens through a lexical analyzer These tokens are generated in a hierarchical structure called a pastry through a parser.

The symbol table contains the types and properties of user-defined names during the compilation process It is used in semantic analysts and code generators.

The semantic analyzer checks for errors that the parser failed to catch if the type is correct, and if it is OK, Convert to intermediate language via intermediate code generator

This intermediate language goes through optimization and then

Convert to mechanical language via code generator

This object is a linker As executable...

Is this right?

compiler

2022-09-22 19:41

2 Answers

[Voiceover] Right.

If you are an undergraduate, you will learn a compiler course. In the past, I learned Dragon Book as a book with dragon drawings.I don't know about these days.

The compiler is largely divided into two types: the front end and the back end.

For example, if there is a C language source...First, use Lexer to tokenize it.

This tokenized thing is made into an abstract syntax tree (AST) using a parser.

The reason for doing this is simply to find grammar errors quickly. In other words, source c is just a text file and there will be various coding conventions for each person, so you can understand that it is a step that makes it easier for the machine to process.

You can usually think of it as a front-end role.

Convert to intermediate language with front-end result ast.

I don't think I understand the middle language.Think of the class file of Java.

Compiling with javac creates a class file, which is a typical intermediate language.

This is because it is easy to optimize and can be processed quickly when machine language is generated.

Then, perform Beckend as a result of the intermediate language to generate the obj file.

Here, optimization is literally optimization. It's a step like reducing redundant unnecessary operations or changing to logic with performance benefits.

In Java, jvm can be referred to as a beckend.

The llvm used by swift or trust is also a beckend.

You just have to create the ir (intermediate language) code that llvm understands, and you can use llvm to get a binary.

Likewise, jvm can operate in jvm by generating only intermediate classes. So the languages like scala and kotlin need to be developed only with a relatively easy pro-end.


2022-09-22 19:41

You can't program live TEXT. For programming, you can think of it as IR by expressing raw TEXT in the middle of the programming structure.


2022-09-22 19:41

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.