Skip to main content

IAR Embedded Workbench for RISC-V 3.40

Code models (RV64 only)

In this section:

Use code models to specify how functions are called on RV64 devices. Technically, the code models control the following:

  • Where in memory functions can be stored

  • The instruction sequences used for generating addresses for global symbols

  • The size of function pointers.

Your project can only use one code model at a time, and all user modules and all library modules must be code model compatible—if you mix Medlow and Medany modules in your project, you must link all modules to the Medlow area.

These code models are available:

Code model name

Memory placement

Medlow

2 Gbytes between -0x8000'0000 and +0x8000'0000

Medany (default)

2 Gbytes anywhere in memory

Table 52. Code models


Both code models restrict the generated code to be 2 Gbytes or less. Additionally, both code models require that global symbols reside within ± 2 Gbytes (a 32-bit signed offset) from the generated code. If you do not specify a code model, the compiler will use the Medany code model as default.

Warning

See Code Generation for information about specifying a code model in the IDE.

Caution

Use the ‑‑code_model option to specify the code model for your project; see ‑‑code_model.