<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">On 12/5/2018 1:05 PM, Stefan Pintilie
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:OF6630EC83.D61F9673-ON0025835A.0071A99C-8525835A.0073DFB9@notes.na.collabserv.com">
<meta http-equiv="content-type" content="text/html;
charset=windows-1252">
<font size="2" face="sans-serif">Hi,</font><br>
<br>
<font size="2" face="sans-serif">This discussion caught my eye
because
we are also looking at a very similar problem on PowerPC. </font><br>
<font size="2" face="sans-serif">We have a situation where we want
to
align a given instruction to a 64 byte boundary. If it's not
already aligned
we just add nops until it is aligned (We plan to do this in a
custom PPCStreamer).
If the branch and the target of that branch are far enough away
adding
a few nops in-between may actually overflow the 14 bits we have
to represent
the offset in the branch instruction and in that case we have to
do something
special and replace the branch with something else that, once
again, is
not a single instruction.</font><br>
<br>
<font size="2" face="sans-serif">If </font><tt><font size="2">mayNeedRelaxation</font></tt><font
size="2" face="sans-serif"> and relaxInstruction are not the way
to do this is there any other
better way?</font><br>
</blockquote>
<p>That's normally something you'd handle in code generation.
There's a target-independent pass in
lib/CodeGen/BranchRelaxation.cpp, but it looks like PowerPC uses
its own implementation in lib/Target/PowerPC/PPCBranchSelector.cpp
. Either way, the key is to ensure that the size of each
instruction is computed conservatively (so it should treat your
"aligned" instruction as a 64-byte instruction, since there will
be 60 bytes of padding in the worst case).<br>
</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>