<div dir="ltr">

<p class="gmail-MsoPlainText">Hi all,</p>

<p class="gmail-MsoPlainText"> </p>

<p class="gmail-MsoPlainText">I'm trying to make an LLVM backend for the Adapteva's
Epiphany E16 CPU (used in Parallella board), using CPU0 and some other backends
as examples, and I've got stuck with branching. </p>

<p class="gmail-MsoPlainText">When I'm printing out asm, all branch labels are
printed as they should be. But when I'm trying to generate obj file, I'm
getting zeros instead of PC-related offset in all branch instructions.<br></p>

<p class="gmail-MsoPlainText">In short, what I'm doing:</p>

<p class="gmail-MsoPlainText">- Pattern (br bb:$addr) is selected using
EpiphanyInstrInfo.td as BNONE32(ins jmptarget:$addr), Branch32 class</p>

<p class="gmail-MsoPlainText">- Branch32 class is defined in EpiphanyInstrFormats.td
with bits<24> addr, which should go into bits{31-8} of the MC
instruction. Those bits remain zeros after relaxation for some reason.<br></p>

<p class="gmail-MsoPlainText">- jmptarget operand has type OPERAND_PCREL, and uses
EncoderMethod "getJumpTargetOpValue" defined in EpiphanyMCCodeEmitter.
If this method gets MCExpr, it creates fixup, and I can see this fixup in
debug.</p>

<p class="gmail-MsoPlainText">- Fixup is called fixup_Epiphany_PCREL24, and is defined
in EpiphanyFixupKinds and EpiphanyAsmBackend, with FKF_IsPCRel flag.</p>

<p class="gmail-MsoPlainText"> </p>

<p class="gmail-MsoPlainText">Can someone please tell me if I am missing something?</p>

<p class="gmail-MsoPlainText">The source itself can be found at <a href="https://github.com/upcFrost/Epiphany/tree/Call_support">https://github.com/upcFrost/Epiphany/tree/Call_support</a>
</p>

<p class="gmail-MsoPlainText">Debug output on pastebin: <a href="http://pastebin.com/8uKRv0qK">http://pastebin.com/8uKRv0qK</a> </p>

<p class="gmail-MsoPlainText"> </p>

<p class="gmail-MsoPlainText">Thanks,</p>

<p class="gmail-MsoPlainText">Petr</p>

<p class="gmail-MsoPlainText"> </p>

<p class="gmail-MsoPlainText">P.S. sorry for messy code, I knew nothing about LLVM
backends when I started, so the code have copy-paste in more than one place.</p>

</div>