<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">On 12/4/2018 4:56 PM, Bruce Hoult
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAP8PnuRtxvkCpzZmvh5fcrnhmHaPBq_XdFy_LZJr1gQcsyfuyg@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">
<div class="gmail_quote">
<div dir="ltr">On Tue, Dec 4, 2018 at 12:13 PM Friedman, Eli
via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org"
moz-do-not-send="true">llvm-dev@lists.llvm.org</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">On
12/3/2018 2:45 PM, Paolo via llvm-dev wrote:<br>
> Hi all,<br>
><br>
> I'm trying to implement the same branch relaxation
mechanism implemented<br>
> in CodeGen in the MC layer of RISCV.<br>
><br>
> beqz t1, L1<br>
><br>
> =><br>
><br>
> bnez t1, L2<br>
><br>
> j L1<br>
><br>
> That's because LLVM does not apply the CodeGen
optimizations when<br>
> compiling directly from assembly code.<br>
><br>
> What I'd like to do would be to add a pass that does
that on the MC<br>
> instructions or at least to find a way to implement
this relaxation in<br>
> the MC assembler.<br>
><br>
> Any suggestions on where/how to do it? Or any existing
fixes?<br>
<br>
The RISCV assembler already has code for similar transforms;
see <br>
RISCVAsmBackend::mayNeedRelaxation and <br>
RISCVAsmBackend::relaxInstruction. The only tricky bit is
that the <br>
relaxation interface doesn't expect one instruction to be
relaxed to two <br>
instructions... probably not too hard to change, though, if
necessary.</blockquote>
<div><br>
</div>
<div>Note that it is *extremely* important that RISC-V
relaxations only ever make the code shorter, never longer.</div>
<div><br>
</div>
<div>If the instructions stay the same size, it can not be
permitted to replace one instruction with two.</div>
<div><br>
</div>
<div>Changing a 32 bit instruction to two 16 bit instructions
could be ok, but I'm struggling to think of an example when
that would be beneficial. </div>
</div>
</div>
</blockquote>
<p>We're talking about assembler "relaxations" (basically, the
assembler trying to resolve an ambiguous branch instruction), not
RISCV linker relaxations.</p>
<p>-Eli<br>
</p>
<pre class="moz-signature" cols="72">--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project</pre>
</body>
</html>