ICD-C Compiler Framework Dr. Heiko Falk. - 2 - H. Falk, ICD/ES, 2008 ICD-C Compiler Framework...

17
ICD-C Compiler Framework Dr. Heiko Falk

Transcript of ICD-C Compiler Framework Dr. Heiko Falk. - 2 - H. Falk, ICD/ES, 2008 ICD-C Compiler Framework...

ICD-C Compiler Framework

Dr. Heiko Falk

- 2 - H. Falk, ICD/ES, 2008

ICD-C Compiler Framework

1. Highlights and Features

2. Basic Concepts

3. Extensions

4. Use Cases

5. Availability

- 3 - H. Falk, ICD/ES, 2008

Highlights and Features of ICD-C

• ANSI-C Compiler Frontend C89 + C99 Standards GNU Inline Assembler

• Intuitive Internal Structures and Concepts C++ Class Design & Linkable Libraries

• Powerful Analyses & Optimizations Control Flow, Data Flow & Loop Analyses

21 Built-In Standard Optimizations• Flexible Usage

Pre-Pass Source-Level Optimizer High-Level IR(*) in stand-alone Compiler

(*) IR = Intermediate Representation

- 4 - H. Falk, ICD/ES, 2008

ICD-C Compiler Framework

1. Highlights and Features

2. Basic Concepts– Class Hierarchy

– Documentation and Testing

3. Extensions

4. Use Cases

5. Availability

- 5 - H. Falk, ICD/ES, 2008

ICD-C Class Hierarchy

CompilationUnit

IR

Function

Statement

Expression

Loop Statements (for, do-while, while-do) Selection Statements (if, if-else, switch) Jump Statements (return, break, continue, …) … Binary & Unary Expressions (+, -, *, /, …) Assignment Expressions (=, +=, -=, …) Index & Component Accesses (a[x], a.x, …) …

Global ST

File ST

Funct. ST

Local ST

BasicBlock

- 6 - H. Falk, ICD/ES, 2008

Documentation & Testing

• Documentation User’s and Developer Manual Browsable HTML Reference Manual

• Testing Built-In & External Testbenches

• > 3,100 ANSI-C Test Files • > 700,000 Lines of ANSI-C Test Code

Fully Automated Test Procedures• Various Test Environments

(Sun Sparc Solaris, SuSE Linux, TriCore 1.3, …)

- 7 - H. Falk, ICD/ES, 2008

ICD-C Compiler Framework

1. Highlights and Features

2. Basic Concepts

3. Extensions– Analyses & Optimizations

– Backend-Interface

– Retargetability

4. Use Cases

5. Availability

- 8 - H. Falk, ICD/ES, 2008

Built-In Analyses

Control Flow Analyses• Basic Block & Statement Level • Domination / Post-Domination • Reachability Analysis • Function Call Graph Analysis

Data Flow Analyses• DEF / USE Analysis • Def & Use Chains • Address Taken Analysis

Loop Analyses• Induction Variable Analysis • Number of Loop Iterations

- 9 - H. Falk, ICD/ES, 2008

ICD-C Optimizations

LocalCSE

ValuePropagation

Dead CodeElimination

UnusedSymbols

SimplifyCode

ConstantFolding

FunctionArguments

UnusedSymbols

FunctionExit Points

ValuePropagation

Dead CodeElimination

SimplifyCode

ConstantFolding

LoopUnswitch.

Head-Ctrl.Loops

StructScalarizat.

Life RangeSplitting

RedundantLoad El.

Return Val.Elimination

StringConstants

LoopCollapsing

LoopDeindexing

TailRecursion

FunctionInlining

FunctionSpecializat.

LoopUnrolling

-O1

-O2

-O3

- 10 - H. Falk, ICD/ES, 2008

ICD-C Compiler Backend Interface

reg: tpm_BinaryExpPLUS(reg, reg) { $cost[0] = $cost[2] + $cost[3] + COST_ADD;} = { cout << “add “ << target << “,” << $action[2]() << “,” << $action[3]() << endl;};

ICD-CGTechnology

CodeSelector

ICD-CCore

Library

ICD-CTPM

Library

C++ Compiler

int sumdiff( int a, int b ){ return a + b;};

sumdiff: add R1, R2, R3 ret

- 11 - H. Falk, ICD/ES, 2008

Retargetability of ICD-C

• Configurable Target Architecture Parameters Bit Widths & Memory Alignments Configuration of ANSI-C Fuzzyness

• Arithmetic vs. Logic Right Shifts • Signedness of Type char

Transformation for Auto-Increment Addressing Optimization: Speed vs. Code Size

• Supported Target Architectures ARM7 TriCore 1.3 PP32 V2 Sun Sparc, x86

- 12 - H. Falk, ICD/ES, 2008

ICD-C Compiler Framework

1. Highlights and Features

2. Basic Concepts

3. Extensions

4. Use Cases– Source-Level Multi-Process Scratchpad Allocation

– Real-Time Compiler WCC

5. Availability

- 13 - H. Falk, ICD/ES, 2008

Use Case 1: Source-Level Memory Optimizer

Profit values / Allocation hints

App. 2App. 2

App. 1App. 1

App. nApp. n AllocationManager

AllocationManager

Standard Compiler(GCC)

Standard Compiler(GCC)

OperatingSystem

OperatingSystem

Compile-timeTransformations

Compile-timeTransformations

© R. Pyka [Operating system integrated energy aware scratchpad allocation, SCOPES ‘07]

CCode

CCode Prepared CPrepared CLockGen /

etc.

LockGen /etc. Adapted CAdapted CProfit

Annotator

ProfitAnnotator

Opt Sys. ImageOpt Sys. Image

RTEMS.oRTEMS.o SPMM.oSPMM.o

GCCGCC

ICD-CTechnology

- 14 - H. Falk, ICD/ES, 2008

Use Case 2: Real-Time Compiler WCC

LLIR

ConversionLLIR2CRL

ConversionCRL2LLIR

ICD-CParser

High-LevelICD-C

LLIR CodeSelector

CodeGenerator

aiT WCETAnalysis

CRL2 withWCET

Estimates

GeneratedCRL2

AnalysesOptimizations

ANSI-CSource

WCET-OptimizedAssembly

© H. Falk, P. Lokuciejewski [Design of a WCET-Aware C Compiler, ESTIMedia ‘06]

ICD-CTechnology

ICD-LLIRTechnology

- 15 - H. Falk, ICD/ES, 2008

ICD-C Compiler Framework

1. Highlights and Features

2. Basic Concepts

3. Extensions

4. Use Cases

5. Availability– Supported Host Platforms

– Licensing Schemes

- 16 - H. Falk, ICD/ES, 2008

Technical Availability of ICD-C

• Supported Host Platforms Sparc Sun Solaris 5.8 – 5.10 x86 SuSE Linux 9.x – 10.x x86 Debian Linux x86 Microsoft Windows 2000, XP x86 Microsoft 2003 Server

- 17 - H. Falk, ICD/ES, 2008

ICD-C Software Licenses

• Supported Licensing Schemes Restricted Evaluation License Academic Research License Commercial License

• Binary License w/o Optimizations • Binary License with Optimizations • Full Source Code License