Flow

From SDCC wiki
Revision as of 10:41, 4 December 2012 by Borutr (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

Flow of compilation in SDCC

  1. SDCPP traditional C preprocessing (macro expansion, ...?)
  2. 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)
    1. parsing: preprocessed code -> AST
    2. AST -> icode conversion
    3. target independent icode optimisation
    4. target dependent icode optimisation and register allocation
    5. assembly code generation: icode -> target-specific asm
    6. peephole optimisation
  3. assembling
  4. linking

some details on the "top level"

main = SDCC.EXE

source

  • sdcc/sdcc/src/SDCCmain.c

what does it do

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

Run SDCC with both "-V --verbose" to see some of these steps.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox