Again freestudy9 comes with an interesting topic related to Symbol table. The symbol table is vital for further steps of compilation. Additionally, we have pointed to point information about it.
- Definition: Symbol table is a data structure used by the compiler to keep track of semantic symbol of a variable. That means symbol table stores the information about the scope and binding information about names.
- So A symbol table built in lexical and syntax analysis phases.
Symbol Table Entries
- The items to be stored in the symbol table are: into
1) Variable names
3) Procedure names
4) Function names
5) Literal constants and strings
6) Compiler-generated temporaries
7) Labels in the source language
- Compiler use following types of information from the symbol table:
- Data type
- Declaring procedure
- Offset in storage
- If structure or record then the pointer to structure table
- For parameters, whether parameter passing is by value or reference?
- Number and type of arguments passed to the function
- Base address
How to Store Names in the Symbol Table
There are two types of representation:
1. Fixed length name
- A fixed space for each name allocated in a symbol table. In this type of storage if a name is too small, then there is wastage of space.
- The name referred by the pointer to symbol table entry.referred NameAttribute
2. Variable length name
- The amount of space required by string used to store the names. The name stored with the help of the starting index and length of each title.
Global Data Flow Analysis
- Data flow equations are the equations representing the expressions that are appearing in the flow graph.
- Data flow information is collected by setting up and solving systems of equations that relate information at various points in a program.
- The data flow equation written in a form of equation such that, out [S] = gen[S] U (in[S] -kill[S])
- And can be read as “the information at the end of a statement either generated within a statement or enters at the beginning and is not killed as control flows through the statement.”
- The details of how data flow equations are set up and solved depend on three factors.
- So The notions of generating and killing depend on the desired information, i.e., on the data flow analysis problem to be solved. Moreover, for some issues, instead of proceeding along with a flow of control and defining out[s] regarding in[s], we need to continue backward and define in[s] regarding out[out[s].
- Since data flows along control paths, data flow analysis affected by the construct data-flow in a program. In fact, when we write out[s] we implicitly assume that there is different endpoint where control leaves the statement; in general, equations set up at the level of basic blocks rather than comments, because blocks do have unique and statements, points.
- Similarly, Some subtleties go along with such statements as procedure calls, assignments through pointer variables, and even assignments to array variable variables.