Group
CODE GENERATION Scope
Compilation Unit Syntax
-Cs08 Arguments None Default
None Defines
__HCS08__
Pragmas None Description
Generates code for the HCS08 family. In addition, allows all new HCS08 operation-operand combinations in the HLI.
Example
__asm LDHX 2,X;
-CswMaxLF: Maximum Load Factor for Switch Tables
<number>: a number in the range of 0 to 100 denoting the maximum load factor.
Default
Allows changing the default strategy of the Compiler to use tables for switch statements.
NOTE This option is only available if the compiler supports switch tables.
Normally the Compiler uses a table for switches with more than about 8 labels if the table is filled between 80% (minimum load factor of 80) and 100% (maximum load factor of 100). If there are not enough labels for a table or the table is not filled, a branch tree is generated (tree of if-else-if-else). This branch tree is like an
‘unrolled’ binary search in a table which quickly evaluates the associated label for a switch expression.
Using a branch tree instead of a table improves code execution speed, but may increase code size. In addition, because the branch tree itself uses no special
runtime routine for switch expression evaluation, debugging may be more seamless.
Specifying a load factor means that tables are generated in specific ‘fuel’ status:
Listing 5.20
The above table is filled to 90% (labels for ‘0’ to ‘9’, except for ‘5’). Assumed that the minimum load factor is set to 50% and setting the maximum load factor for the above case to 80%, a branch tree is generated instead a table. But setting the maximum load factor to 95% will produce a table.
To guarantee that tables are generated for switches with full tables only, set the table minimum and maximum load factors to 100:
-CswMinLF100 -CswMaxLF100.
See also
Compiler options:
• -CswMinLB: Minimum Number of Labels for Switch Tables
• Option -CswMinSLB: Minimum Number of Labels for Search Switch Tables
• -CswMinLF: Minimum Load Factor for Switch Tables
-CswMinLB: Minimum Number of Labels for Switch Tables
<number>: a positive number denoting the number of labels.
Default
This option allows changing the default strategy of the Compiler using tables for switch statements.
NOTE This option is only available if the compiler supports switch tables.
Normally the Compiler uses a table for switches with more than about 8 labels (case entries) (actually this number is highly backend-dependent). If there are not enough labels for a table, a branch tree is generated (tree of if-else-if-else). This branch tree is like an ‘unrolled’ binary search in a table which evaluates very fast the associated label for a switch expression.
Using a branch tree instead of a table may increases the code execution speed, but it probably increases the code size. In addition, because the branch tree itself uses no special runtime routine for switch expression evaluation, debugging may be much easier.
To disable any tables for switch statements, just set the minimum number of labels needed for a table to a high value (e.g., 9999):
-CswMinLB9999 -CswMinSLB9999.
When disabling simple tables it usually makes sense also to disable search tables with the -CswMinSLB option.
See also
Compiler options:
• -CswMinLF: Minimum Load Factor for Switch Tables
• -CswMinSLB: Minimum Number of Labels for Search Switch Tables
• -CswMaxLF: Maximum Load Factor for Switch Tables
-CswMinLF: Minimum Load Factor for Switch Tables
<number>: a number in the range of 0 – 100 denoting the minimum load factor Default
Allows the Compiler to use tables for switch statements.
NOTE This option is only available if the compiler supports switch tables.
Normally the Compiler uses a table for switches with more than about 8 labels and if the table is filled between 80% (minimum load factor of 80) and 100%
(maximum load factor of 100). If there are not enough labels for a table or the table is not filled, a branch tree is generated (tree of if-else-if-else). This branch tree is like an ‘unrolled’ binary search in a table which quickly evaluates the associated label for a switch expression.
Using a branch tree instead of a table improves code execution speed, but may increase code size. In addition, because the branch tree itself uses no special runtime routine for switch expression evaluation, debugging is more seamless.
Specifying a load factor means that tables are generated in specific ‘fuel’ status:
Listing 5.21
The above table is filled to 90% (labels for ‘0’ to ‘9’, except for ‘5’). Assuming that the maximum load factor is set to 100% and the minimum load factor for the above case is set to 90%, this still generates a table. But setting the minimum load factor to 95% produces a branch tree.
To guarantee that tables are generated for switches with full tables only, set the minimum and maximum table load factors to 100: -CswMinLF100
-CswMaxLF100.
See also
Compiler options:
• -CswMinLB: Minimum Number of Labels for Switch Tables
• -CswMinSLB: Minimum Number of Labels for Search Switch Tables
• -CswMaxLF: Maximum Load Factor for Switch Tables
-CswMinSLB: Minimum Number of Labels for Search Switch Tables
<number>: a positive number denoting the number of labels Default
Allows the Compiler to use tables for switch statements.
NOTE This option is only available if the compiler supports search tables.
Switch tables are implemented in different ways. When almost all case entries in some range are given, a table containing only branch targets is used. Using such a dense table is efficient because only the correct entry is accessed. When large holes exist in some areas, a table form can still be used.
But now the case entry and its corresponding branch target are encoded in the table. This is called a search table. A complex runtime routine must be used to access a search table. This routine checks all entries until it finds the matching one.
Search tables execute slowly.
Using a search table improves code density, but the execution time increases.
Every time an entry in a search table must be found, all previous entries must be
checked first. For a dense table, the right offset is computed and accessed. In addition, note that all backends implement search tables (if at all) by using a complex runtime routine. This may make debugging more complex.
To disable search tables for switch statements, set the minimum number of labels needed for a table to a high value (e.g., 9999): -CswMinSLB9999.
See also
Compiler options:
• -CswMinLB: Minimum Number of Labels for Switch Tables
• -CswMinLF: Minimum Load Factor for Switch Tables
• -CswMaxLF: Maximum Load Factor for Switch Tables