When multiple control registers are updated continuously by a store instruction of the RH850, the order in which the control registers are updated may not match the order in which they were written to the source file. Synchronization processing needs to be inserted in order to control the order in which the control registers are updated.
CC-RH is capable of detecting writing to control registers and displaying information on the writing process, as well as inserting synchronization processing of a fixed form.
Code indicating access to control registers will be detected when all of the following conditions are satisfied.
An expression shall cast a single integer constant to a pointer to a volatile qualifier and indirectly reference it with the unary * operator or -> operator. |
In this case, the integer constant indicates the address of the control register.
An expression including a variable instead of a constant integer or an expression including multiple casts may not be detected.
Specify the address range and group information of control registers with #pragma register_group.
Specify #pragma register_group in the following format.
Specify the start address and end address with unsigned integers. An octal, decimal, or hexadecimal integer can be used. |
The end address is treated as its address belongs to the group.
The usable characters for the group-ID are only alphabetic characters (a-z or A-Z; case-sensitive), numbers (0-9), and underscore (_).
The length of the group-ID is not limited.
To specify the same group which is not continuous in the address space, the same group-ID can be specified in more than one #pragma register_group directive. |
The group-ID can be omitted. If omitted, writing to that area is treated as an operation that is not continuous with any other write operations. |
When the address ranges specified in multiple #pragma register_group directives overlap with each other |
How to detect writing to control registers and insert synchronization processing is described below, based on the following example of input source code.
If the above example is compiled with the -store_reg=list option specified, write operations are determined as shown below and a message indicating that writing was performed is output to the standard error output.
Since REG1 and REG2 belong to the same group, synchronization processing does not need to be applied to writing to REG1. |
Since REG2 and REG_Z belong to different groups, synchronization processing needs to be applied to writing to REG2. |
Since whether there is writing to the same group after writing to REG_Z is not clear, synchronization processing needs to be applied to writing to REG_Z. |
src.c(10):M0536001:control register is written.(id=CPU, 0xfedf0001) src.c(11):M0536001:control register is written.(id=0, 0xfee00000) |
Note that synchronization processing is determined to be necessary even in cases where writing to a control register is followed by a function call or access to an unknown address in memory that cannot be detected as writing to a control register.
If the same example is compiled with the -store_reg=list_all option specified, a message is output for writing to all of the control registers specified by #pragma register_group without determining whether continuous writing to the same group is performed.
If the same example is compiled with the -store_reg=sync option specified, write operations are determined in the same manner as (a) and synchronization processing is inserted in the output code instead of a message being output. In synchronization processing, a combination of loading from the same control register and syncp instruction is output.
When #pragma register_group is used with the -Xmerge_file option at the same time, even though a #pragma register_group directive that is incompatible between source files is specified, an error will not occur and the result may be unintended. It is recommended to include #pragma register_group in the include file and share it between source files. |
If there is a possibility that an exception will occur between writing to a control register and the synchronization processing, manually write the synchronization processing in the exception handler as necessary. |