Specifying a data model
Three data models are implemented: Near, Far, and Huge. These models are controlled by the --data_model option. Each model has a default memory type. If you do not specify a data model option, the compiler will use the Far data model.
Your project can only use one data model at a time, and the same model must be used by all user modules and all library modules. However, you can override the default memory type for individual data objects by explicitly specifying a memory attribute, see Using data memory attributes.
This table summarizes the data models:
Data model name | Default memory attribute | Pointer attribute | Placement of data |
|---|---|---|---|
Near |
|
| Low 32 Kbytes or high 32 Kbytes |
Far (default) |
|
| Low 8 Mbytes or high 8 Mbytes |
Huge |
|
| The entire 4 Gbytes of memory |
Caution
See the IDE Project Management and Building documentation for information about setting options in the IDE.
Danger
Use the ‑‑data_model option to specify the data model for your project; see --data_model.
The impact of the different data models on the code size depends on the amount of data with static duration. There is no principal difference in the generated code. On higher optimization levels the difference is even smaller, because of the global clustering optimization.
The RXmicrocontroller has no mode for direct addressing. This means that addresses of static objects must be loaded into a register before the data can be read from memory. The size of these address loads will increase if you change to a larger data model. However, on high optimization levels, the compiler will use a base address to all objects with static duration data in the module, and use relative addressing to access them.
For this reason, the size of the generated code does not depend very much on your choice of data model, but you should nevertheless always use the smallest data model that you need.