Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
56
Добавлен:
14.04.2015
Размер:
1.37 Mб
Скачать

Keil Software — Cx51 Compiler User’s Guide

157

 

 

Optimizer

The Cx51 compiler is an optimizing compiler. This means that the compiler takes certain steps to ensure that the code generated and output to the object file is the most efficient (smallest and/or fastest) code possible. The compiler analyzes the generated code to produce more efficient instruction sequences. This ensures that your Cx51 compiler program runs as quickly as possible.

The Cx51 compiler provides several different levels of optimizing. Refer to “OPTIMIZE” on page 63 for detailed information.

General Optimizations

Optimization

Description

 

 

Constant Folding

Several constant values occurring in an expression or

 

 

 

address calculation are combined as a constant.

 

 

Jump Optimizing

Jumps are inverted or extended to the final target address

 

 

 

when the program efficiency is thereby increased.

 

 

Dead Code Elimination

Code which cannot be reached (dead code) is removed from

 

 

 

the program.

 

 

Register Variables

Automatic variables and function arguments are located in

 

 

 

registers when possible. Reservation of data memory for

 

 

 

these variables is omitted.

 

 

Parameter Passing Via Registers

A maximum of three function arguments can be passed in

 

 

 

registers.

 

 

Global Common Subexpression

Identical subexpressions or address calculations that occur

 

 

6

Elimination

multiple times in a function are recognized and calculated

 

 

only once when possible.

 

Reuse of Common Entry Code

When there are multiple calls to a single function, some of

 

 

the setup code can be reused, thereby reducing program

 

 

 

size.

 

 

 

 

Common Block Subroutines

Detects recurring instruction sequences and converts them

 

 

 

into subroutines. The compiler even rearranges code to

 

 

 

obtain larger recurring sequences.

 

 

 

 

 

 

158 Chapter 6. Advanced Programming Techniques

8051-Specific Optimizations

Optimization

Description

Peephole Optimization

Complex operations are replaced by simplified operations when

 

memory space or execution time can be saved as a result.

Extended Access Optimizing

Constants and variables are directly included in operations.

Data Overlaying

Data and bit segments of functions are identified as

 

OVERLAYABLE and are overlaid with other data and bit

 

segments by the BL51 Linker/Locator.

Case/Switch Optimizing

Optimize switch case statements by using a jump table or string

 

of jumps.

Options for Code Generation

Optimization

Description

OPTIMIZE(SIZE)

Common C operations are replaced by subprograms. Program code

 

is thereby reduced.

NOAREGS

The Cx51 compiler no longer uses absolute register access. Program

 

code is independent of the register bank.

NOREGPARMS

Parameter passing is always performed in local data segments. The

 

program code is compatible to earlier versions of Cx51.

6

Соседние файлы в папке HLP