Flow - roybaer/sdcc-wiki GitHub Wiki
- SDCPP traditional C preprocessing (macro expansion, ...?)
- compiling (after reaching the end of the source file, the initializers for any non-const global or static variables also go through these same steps)
- parsing: preprocessed code -> AST
- AST -> icode conversion
- target independent icode optimisation
- target dependent icode optimisation and register allocation
- assembly code generation: icode -> target-specific asm
- peephole optimisation
- assembling
- linking
main = SDCC.EXE
- sdcc/sdcc/src/SDCCmain.c
See the tree on top for links to pages with info on each step:
- based on command line establishes which port is to be used
- initialises this port
- parses command line options
- passes the relevant options to the port
- calls the preprocessor SDCPP.EXE
- feeds the output into the parser "character by character"
- via a pipe - preprocessing is completely separate from other parts, there are no common data - it could be run standalone, output into a temporary file and feed that into the lexer part of compiler)
- parser calls the subsequent steps - function by function
- once the parser recognizes that a function is complete, createFunction() (in src/SDCCast.c) is called, which has the AST annotated (probably via decorateType()), has it turned it into iCode (iCodeFromAst() calling ast2iCode()), and lets the backend emit appropriate code (via eBBlockFromiCode() in port->assignRegisters, which maps to, e.g.src/mcs51/ralloc.c, mcs51_assignRegisters())
- eBBlockFromiCode(): cseAllBlocks(), killDeadCode(), loopOptimizations(), all src/SDCCopt.c
- calls the assembler
- calls the linker