gcc extended asm compressed register constraint

97 views
Skip to first unread message

josema...@gmail.com

unread,
Aug 7, 2021, 3:03:14 PM8/7/21
to RISC-V SW Dev
I'm wondering if there is an extended asm constraint (can't find it in gcc's docs) for specifying the subset of registers allowed on C extension instructions. I want be able to define a function to inline a compressed load/store. For example:

static inline void c_sd(uintptr_t addr, uint64_t value){
    asm volatile(
        "c.sd %0, 0(%1)\n\t"
        :: "?"(value), "?"(addr): "memory"
    );
}

Jose

Tommy Murphy

unread,
Aug 7, 2021, 5:37:49 PM8/7/21
to josema...@gmail.com, RISC-V SW Dev
Does gcc extended inline asm help at all?


From: josema...@gmail.com <josema...@gmail.com>
Sent: Saturday, August 7, 2021 8:03:14 PM
To: RISC-V SW Dev <sw-...@groups.riscv.org>
Subject: [sw-dev] gcc extended asm compressed register constraint
 
--
You received this message because you are subscribed to the Google Groups "RISC-V SW Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sw-dev+un...@groups.riscv.org.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/b3b18e49-542c-4446-812e-6b1204271d28n%40groups.riscv.org.

Jose Martins

unread,
Aug 9, 2021, 5:56:50 AM8/9/21
to Tommy Murphy, RISC-V SW Dev
Hey Tommy, thanks for replying. I don't know if I understood your point, but inline asm was exactly what I was referring to. Specifically, I was looking for a RISC-V specific way to constraint a register field to the compressed extension registers. There are similar constraints, for example, for csr instruction immediates: https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html#Machine-Constraints 

Michael Chapman

unread,
Aug 9, 2021, 6:19:53 AM8/9/21
to Jose Martins, Tommy Murphy, RISC-V SW Dev

There is no such constraint in GCC at the moment.
However, it is very easy to add.

Mike

Jose Martins

unread,
Aug 9, 2021, 1:25:04 PM8/9/21
to Michael Chapman, Tommy Murphy, RISC-V SW Dev
Thanks Mike. I'll just force specific registers and add them to the clobber list.
Reply all
Reply to author
Forward
0 new messages