Skip to content

Commit 6e8829d

Browse files
arichardsonresistor
authored andcommitted
[cheri_init_globals.h] Avoid using cgetaddr/cgetoffset in assembly
The upcoming standard no longer includes cgetoffset (and cgetaddr has been removed in ISAv9). For now the assembly code still accepts cgetaddr and converts it to a move, but use an intrinsic call instead as that can be optimized to a subregister read on next use rather the requiring an explicit move.
1 parent eb89624 commit 6e8829d

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

clang/lib/Headers/cheri_init_globals.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ __attribute__((weak)) extern void *__capability __cap_table_end;
7676
* position-dependent executables.
7777
*/
7878
#ifdef CHERI_INIT_GLOBALS_USE_OFFSET
79-
#define cgetaddr_or_offset "cgetoffset"
8079
#define csetaddr_or_offset "csetoffset"
80+
#define cheri_address_or_offset_get(_cap) __builtin_cheri_offset_get((_cap))
8181
#define cheri_address_or_offset_set(_cap, _val) \
8282
__builtin_cheri_offset_set((_cap), (_val))
8383
#else
84-
#define cgetaddr_or_offset "cgetaddr"
8584
#define csetaddr_or_offset "csetaddr"
85+
#define cheri_address_or_offset_get(_cap) __builtin_cheri_address_get((_cap))
8686
#define cheri_address_or_offset_set(_cap, _val) \
8787
__builtin_cheri_address_set((_cap), (_val))
8888
#endif
@@ -219,13 +219,11 @@ cheri_init_globals_3(void *__capability data_cap,
219219
"lla %1, __stop___cap_relocs\n\t"
220220
: "=r"(start_addr), "=r"(stop_addr));
221221
#else
222-
void *__capability tmp;
223-
__asm__ (
224-
"cllc %2, __start___cap_relocs\n\t"
225-
cgetaddr_or_offset " %0, %2\n\t"
226-
"cllc %2, __stop___cap_relocs\n\t"
227-
cgetaddr_or_offset " %1, %2\n\t"
228-
:"=r"(start_addr), "=r"(stop_addr), "=&C"(tmp));
222+
__asm__("cllc %0, __start___cap_relocs\n\t"
223+
"cllc %1, __stop___cap_relocs\n\t"
224+
: "=C"(start_relocs), "=C"(stop_relocs));
225+
start_addr = cheri_address_or_offset_get(start_relocs);
226+
stop_addr = cheri_address_or_offset_get(stop_relocs);
229227
#endif
230228
#else
231229
#error Unknown architecture

0 commit comments

Comments
 (0)