This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Problem of inline assembly for branch instruction
- From: "Naveen H. S" <Naveen dot S at kpitcummins dot com>
- To: "gcc-help at gcc dot gnu dot org" <gcc-help at gcc dot gnu dot org>
- Date: Wed, 7 Sep 2011 13:16:36 +0000
- Subject: Problem of inline assembly for branch instruction
Hi,
We are implementing a special branch instruction for offsets between
0 and 32 bytes in CR16 port.
=======================================================================
if (get_attr_length (insn) == 2)
return \"beq0<tIsa>\t%0,%l1\";
else
return \"cmp<tIsa>\t$0, %0\;beq\t%l1\";
}"
[(set (attr "length")
(if_then_else
(and (ge (minus (match_dup 1) (pc)) (const_int 2))
(le (minus (match_dup 1) (pc)) (const_int 32)))
(const_int 2)
(const_int 6)))]
=======================================================================
The branch instruction has been implemented and working as expected.
However, it resulted in error while testing an application with inline
assembly. In the application, the linker calculated length of offset
from current location to the branch as 24. However, due to some inline
assembly in between PC and branch location, the offset is more than 32.
Hence, the linker generates error while linking application.
However, we could not find any solution to handling inline assembly in
such scenarios.
Please let us know if the compiler could be informed not to generate
special branch instruction for code with inline assembly.
Also let us know if the inline assembly length attribute could be
passed to linker so that it can calculate the exact offset.
Thanks & Regards,
Naveen