https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116483
--- Comment #9 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
(In reply to Xi Ruoyao from comment #8)
> Is there any pointer how to implement this instead?
It may be sufficient to change
(define_insn "@tablejump<mode>"
[(set (pc)
(match_operand:P 0 "register_operand" "e"))
(use (label_ref (match_operand 1 "" "")))]
""
"jr\t%0"
[(set_attr "type" "jump")
(set_attr "mode" "none")])
such that instead of providing the string template "jr\t%0" you instead do
{ return loongarch_output_tablejump(...); }
as already done for division, some moves, branches, ... and in that function
you emit .pushsection ... .popsection as necessary, in addition to "jr\t%0".
But are you sure it is really necessary? I see that objtool already has support
for inspecting relocations, and that seems sufficient for reaching the jump
table from the jump instruction on Loongarch.
I noticed that this will be a topic of discussion on the upcoming kernel BoF on
the GNU Cauldron, in context of objtool on arm64:
https://inbox.sourceware.org/gcc/[email protected]/T/
and was previously discussed on kernel mailing lists, with some particularly
illuminating responses from Michael Matz:
https://lore.kernel.org/linux-arm-kernel/[email protected]/T/#m10f5b79259ad7fe62129ac7db790fe53f7ed8d8e