<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hi Florian,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Yeah, sorry, I really made a mess of this one! I've now removed ARMComputeBlockSize.cpp and added the new file ARMBasicBlockInfo.cpp. Hopefully the builders will be happy again.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Cheers!</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="Signature">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255); font-family:Calibri,Arial,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<p style="margin-top: 0px; margin-bottom: 0px;"></p>
<p style="margin-top: 0px; margin-bottom: 0px;font-family:"Times New Roman""><span style="font-family:Calibri,Helvetica,sans-serif">Sam Parker</span></p>
<span style="font-family:Calibri,Helvetica,sans-serif"></span>
<p style="margin-top: 0px; margin-bottom: 0px;font-family:"Times New Roman""><span style="font-family:Calibri,Helvetica,sans-serif">Compilation Tools Engineer | Arm</span></p>
<span style="font-family:Calibri,Helvetica,sans-serif"></span>
<p style="margin-top: 0px; margin-bottom: 0px;font-family:"Times New Roman""><span style="font-family:Calibri,Helvetica,sans-serif">. . . . . . . . . . . . . . . . . . . . . . . . . . .</span></p>
<span style="font-family:Calibri,Helvetica,sans-serif"></span>
<p style="margin-top: 0px; margin-bottom: 0px;font-family:"Times New Roman""><span style="font-family:Calibri,Helvetica,sans-serif">Arm.com</span></p>
<p style="margin-top: 0px; margin-bottom: 0px;"></p>
</div>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> florian_hahn@apple.com <florian_hahn@apple.com> on behalf of Florian Hahn <florian_hahn@apple.com><br>
<b>Sent:</b> 17 June 2019 10:07<br>
<b>To:</b> Sam Parker<br>
<b>Cc:</b> llvm-commits@lists.llvm.org<br>
<b>Subject:</b> Re: [llvm] r363531 - [ARM] Add ARMBasicBlockInfo.cpp</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Hi Sam,<br>
<br>
It looks like this file needs adding to CMakeLists.txt<br>
<br>
CMake Error at cmake/modules/LLVMProcessSources.cmake:112 (message):<br>
<br>
  Found unknown source file ARMComputeBlockSize.cpp<br>
 Please update llvm/lib/Target/ARM/CMakeLists.txt<br>
<br>
 <a href="http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental/62410/console">http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental/62410/console</a><br>
<br>
Cheers,<br>
Florian<br>
<br>
> On Jun 17, 2019, at 10:05, Sam Parker via llvm-commits <llvm-commits@lists.llvm.org> wrote:<br>
> <br>
> Author: sam_parker<br>
> Date: Mon Jun 17 02:05:43 2019<br>
> New Revision: 363531<br>
> <br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=363531&view=rev">http://llvm.org/viewvc/llvm-project?rev=363531&view=rev</a><br>
> Log:<br>
> [ARM] Add ARMBasicBlockInfo.cpp<br>
> <br>
> Forgot to add file!<br>
> <br>
> Added:<br>
>    llvm/trunk/lib/Target/ARM/ARMBasicBlockInfo.cpp<br>
> <br>
> Added: llvm/trunk/lib/Target/ARM/ARMBasicBlockInfo.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBasicBlockInfo.cpp?rev=363531&view=auto">
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBasicBlockInfo.cpp?rev=363531&view=auto</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/Target/ARM/ARMBasicBlockInfo.cpp (added)<br>
> +++ llvm/trunk/lib/Target/ARM/ARMBasicBlockInfo.cpp Mon Jun 17 02:05:43 2019<br>
> @@ -0,0 +1,146 @@<br>
> +//===--- ARMBasicBlockInfo.cpp - Utilities for block sizes ---------------===//<br>
> +//<br>
> +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.<br>
> +// See <a href="https://llvm.org/LICENSE.txt">https://llvm.org/LICENSE.txt</a> for license information.<br>
> +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception<br>
> +//<br>
> +//===----------------------------------------------------------------------===//<br>
> +<br>
> +#include "ARM.h"<br>
> +#include "ARMBaseInstrInfo.h"<br>
> +#include "ARMBasicBlockInfo.h"<br>
> +#include "ARMMachineFunctionInfo.h"<br>
> +#include "llvm/CodeGen/MachineBasicBlock.h"<br>
> +#include "llvm/CodeGen/MachineFunction.h"<br>
> +#include "llvm/CodeGen/MachineInstr.h"<br>
> +#include "llvm/CodeGen/TargetSubtargetInfo.h"<br>
> +#include <vector><br>
> +<br>
> +#define DEBUG_TYPE "arm-bb-utils"<br>
> +<br>
> +using namespace llvm;<br>
> +<br>
> +namespace llvm {<br>
> +<br>
> +// mayOptimizeThumb2Instruction - Returns true if optimizeThumb2Instructions<br>
> +// below may shrink MI.<br>
> +static bool<br>
> +mayOptimizeThumb2Instruction(const MachineInstr *MI) {<br>
> +  switch(MI->getOpcode()) {<br>
> +    // optimizeThumb2Instructions.<br>
> +    case ARM::t2LEApcrel:<br>
> +    case ARM::t2LDRpci:<br>
> +    // optimizeThumb2Branches.<br>
> +    case ARM::t2B:<br>
> +    case ARM::t2Bcc:<br>
> +    case ARM::tBcc:<br>
> +    // optimizeThumb2JumpTables.<br>
> +    case ARM::t2BR_JT:<br>
> +    case ARM::tBR_JTr:<br>
> +      return true;<br>
> +  }<br>
> +  return false;<br>
> +}<br>
> +<br>
> +void ARMBasicBlockUtils::computeBlockSize(MachineBasicBlock *MBB) {<br>
> +  LLVM_DEBUG(dbgs() << "computeBlockSize: " << MBB->getName() << "\n");<br>
> +  BasicBlockInfo &BBI = BBInfo[MBB->getNumber()];<br>
> +  BBI.Size = 0;<br>
> +  BBI.Unalign = 0;<br>
> +  BBI.PostAlign = 0;<br>
> +<br>
> +  for (MachineInstr &I : *MBB) {<br>
> +    BBI.Size += TII->getInstSizeInBytes(I);<br>
> +    // For inline asm, getInstSizeInBytes returns a conservative estimate.<br>
> +    // The actual size may be smaller, but still a multiple of the instr size.<br>
> +    if (I.isInlineAsm())<br>
> +      BBI.Unalign = isThumb ? 1 : 2;<br>
> +    // Also consider instructions that may be shrunk later.<br>
> +    else if (isThumb && mayOptimizeThumb2Instruction(&I))<br>
> +      BBI.Unalign = 1;<br>
> +  }<br>
> +<br>
> +  // tBR_JTr contains a .align 2 directive.<br>
> +  if (!MBB->empty() && MBB->back().getOpcode() == ARM::tBR_JTr) {<br>
> +    BBI.PostAlign = 2;<br>
> +    MBB->getParent()->ensureAlignment(2);<br>
> +  }<br>
> +}<br>
> +<br>
> +/// getOffsetOf - Return the current offset of the specified machine instruction<br>
> +/// from the start of the function.  This offset changes as stuff is moved<br>
> +/// around inside the function.<br>
> +unsigned ARMBasicBlockUtils::getOffsetOf(MachineInstr *MI) const {<br>
> +  const MachineBasicBlock *MBB = MI->getParent();<br>
> +<br>
> +  // The offset is composed of two things: the sum of the sizes of all MBB's<br>
> +  // before this instruction's block, and the offset from the start of the block<br>
> +  // it is in.<br>
> +  unsigned Offset = BBInfo[MBB->getNumber()].Offset;<br>
> +<br>
> +  // Sum instructions before MI in MBB.<br>
> +  for (MachineBasicBlock::const_iterator I = MBB->begin(); &*I != MI; ++I) {<br>
> +    assert(I != MBB->end() && "Didn't find MI in its own basic block?");<br>
> +    Offset += TII->getInstSizeInBytes(*I);<br>
> +  }<br>
> +  return Offset;<br>
> +}<br>
> +<br>
> +/// isBBInRange - Returns true if the distance between specific MI and<br>
> +/// specific BB can fit in MI's displacement field.<br>
> +bool ARMBasicBlockUtils::isBBInRange(MachineInstr *MI,<br>
> +                                     MachineBasicBlock *DestBB,<br>
> +                                     unsigned MaxDisp) const {<br>
> +  unsigned PCAdj      = isThumb ? 4 : 8;<br>
> +  unsigned BrOffset   = getOffsetOf(MI) + PCAdj;<br>
> +  unsigned DestOffset = BBInfo[DestBB->getNumber()].Offset;<br>
> +<br>
> +  LLVM_DEBUG(dbgs() << "Branch of destination " << printMBBReference(*DestBB)<br>
> +                    << " from " << printMBBReference(*MI->getParent())<br>
> +                    << " max delta=" << MaxDisp << " from " << getOffsetOf(MI)<br>
> +                    << " to " << DestOffset << " offset "<br>
> +                    << int(DestOffset - BrOffset) << "\t" << *MI);<br>
> +<br>
> +  if (BrOffset <= DestOffset) {<br>
> +    // Branch before the Dest.<br>
> +    if (DestOffset-BrOffset <= MaxDisp)<br>
> +      return true;<br>
> +  } else {<br>
> +    if (BrOffset-DestOffset <= MaxDisp)<br>
> +      return true;<br>
> +  }<br>
> +  return false;<br>
> +}<br>
> +<br>
> +void ARMBasicBlockUtils::adjustBBOffsetsAfter(MachineBasicBlock *BB) {<br>
> +  assert(BB->getParent() == &MF &&<br>
> +         "Basic block is not a child of the current function.\n");<br>
> +<br>
> +  unsigned BBNum = BB->getNumber();<br>
> +  LLVM_DEBUG(dbgs() << "Adjust block:\n"<br>
> +             << " - name: " << BB->getName() << "\n"<br>
> +             << " - number: " << BB->getNumber() << "\n"<br>
> +             << " - function: " << MF.getName() << "\n"<br>
> +             << "   - blocks: " << MF.getNumBlockIDs() << "\n");<br>
> +<br>
> +  for(unsigned i = BBNum + 1, e = MF.getNumBlockIDs(); i < e; ++i) {<br>
> +    // Get the offset and known bits at the end of the layout predecessor.<br>
> +    // Include the alignment of the current block.<br>
> +    unsigned LogAlign = MF.getBlockNumbered(i)->getAlignment();<br>
> +    unsigned Offset = BBInfo[i - 1].postOffset(LogAlign);<br>
> +    unsigned KnownBits = BBInfo[i - 1].postKnownBits(LogAlign);<br>
> +<br>
> +    // This is where block i begins.  Stop if the offset is already correct,<br>
> +    // and we have updated 2 blocks.  This is the maximum number of blocks<br>
> +    // changed before calling this function.<br>
> +    if (i > BBNum + 2 &&<br>
> +        BBInfo[i].Offset == Offset &&<br>
> +        BBInfo[i].KnownBits == KnownBits)<br>
> +      break;<br>
> +<br>
> +    BBInfo[i].Offset = Offset;<br>
> +    BBInfo[i].KnownBits = KnownBits;<br>
> +  }<br>
> +}<br>
> +<br>
> +} // end namespace llvm<br>
> <br>
> <br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> llvm-commits@lists.llvm.org<br>
> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
<br>
</div>
</span></font></div>
</body>
</html>