-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Hello,
I am extending the RISC-V GNU toolchain to add a new memory handling mechanism that requires the compiler to use custom load and store instructions for specific variables allocated in a particular memory region.
Context
I’ve implemented a set of custom load/store instructions in the RISC-V backend and verified that the assembler and simulator recognize them.
The next step is to connect these instructions with certain variable types or attributes so that when such variables are accessed in C/C++ source code, the compiler automatically emits the corresponding custom load/store instructions instead of the standard ones.
In addition, these variables should be allocated in a dedicated data section (for example, .custom_data) that the linker maps to a defined region in memory.
Goal
I’d like to integrate this feature cleanly into GCC so that:
- Variables annotated with a specific attribute (or type) use the custom load/store instructions.
- These variables are automatically placed in a designated section (e.g. .custom_data).
- The compiler enforces simple separation between normal variables and those requiring the custom memory access instructions.
Questions
- Which GCC front-end and back-end source files are best suited for implementing such type- or attribute-based instruction selection?
- Is there an existing mechanism (target hooks, machine attributes, or storage class specifiers) that could support this use case without fully introducing a new data type?
- Are there examples of other GCC targets that implement specialized load/store paths for non-standard memory regions?
Thanks in advance for your help and time!