-switch


This option specifies the format in which the code of switch statements is to be output.

[Specification format]

-switch={ifelse|binary|abs_table|rel_table}

 

-

Interpretation when omitted

ccrl selects the optimum output format for each switch statement.

[Detailed description]

-

This option specifies the format in which the code of switch statements is to be output.

-

The parameters that can be specified are shown below.
An error will occur if any other parameter is specified.

ifelse

Outputs the code in a format in which the case labels are compared one by one. This item should be specified when there are not so many case statements.

binary

Outputs the code in the binary search format.

Searches for a matching case statement by using a binary search algorithm.

If this item is selected when many labels are used, any case statement can be found at almost the same speed.

abs_table

rel_table

Uses the case branch table in the switch statement to output a code.

A table indexed by the case value is referenced to obtain the location of each case label from the case value and a branch to the location is done. The branch speed is almost the same for all case labels. When the case values are not sequential, unused areas are generated in the table.

If the difference between the maximum and minimum case values in a switch statement exceeds 8192, this option setting is ignored and processing is done as described in "Interpretation when omitted".

When abs_table is specified, the absolute address of each case label location is stored in the table.

When rel_table is specified, the relative distance from a branch instruction to each case label location is stored in the table. However, if a relative distance exceeds 64 Kbytes, a linkage error will occur.

When a function including a switch statement is allocated to the near area, a code using an absolute addressing table is generated regardless of which parameter is specified.

-

An error will occur if the parameter is omitted.

[Example of use]

-

To output a code for the switch statement in the binary search format, describe as:

>ccrl -switch=binary -cpu=S2 -dev=dr5f100pj.dvf main.c