Опубликован: 12.07.2012 | Доступ: свободный | Студентов: 354 / 25 | Оценка: 4.00 / 4.20 | Длительность: 11:07:00
Тема: Программирование
Специальности: Программист
Теги:
Лекция 3:
Optimizing compiler Scalar optimizations
Front End
Parsing is the process of input characters analysis, usually in accordance with a given formal grammar.
During parsing the source code is converted into a data structure. Usually it is a tree that reflects the syntax structure of the input sequence and is well suited for further processing.
Typically, parsing is divided into two levels:
- lexical analysis - the input stream of characters partitioned into a linear sequence of tokens - "qwords" of language (eg, integers, identifiers, string constants, etc.);
- semantic analysis - token are converted into statements and expressions of used language, according to grammatical rules.
At the output we get FE related tables, which are called the internal representation of the program. The usual practice is to share one internal representation for the various high-level languages.
The statements are usually presented in a list and can be linked in two ways:
struct Stmt { common_members: int type; Stmt * pred; Stmt *succ; Basic_Block bblock; … }
Some simple scalar optimizations based on walking through the list of statements to find some specific statements and process them:
For_All_Subroutine_Stmt(subroutine,stmt) { if(Stmt_type(stmt) == Stmt_Assign { //assignment processing } }