Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/Target/AMDGPU/R600FrameLowering.cpp
Line
Count
Source
1
//===----------------------- R600FrameLowering.cpp ------------------------===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//==-----------------------------------------------------------------------===//
8
9
#include "R600FrameLowering.h"
10
#include "AMDGPUSubtarget.h"
11
#include "R600RegisterInfo.h"
12
#include "llvm/CodeGen/MachineFrameInfo.h"
13
#include "llvm/CodeGen/MachineFunction.h"
14
#include "llvm/Support/MathExtras.h"
15
16
using namespace llvm;
17
18
289
R600FrameLowering::~R600FrameLowering() = default;
19
20
/// \returns The number of registers allocated for \p FI.
21
int R600FrameLowering::getFrameIndexReference(const MachineFunction &MF,
22
                                              int FI,
23
2.79k
                                              unsigned &FrameReg) const {
24
2.79k
  const MachineFrameInfo &MFI = MF.getFrameInfo();
25
2.79k
  const R600RegisterInfo *RI
26
2.79k
    = MF.getSubtarget<R600Subtarget>().getRegisterInfo();
27
2.79k
28
2.79k
  // Fill in FrameReg output argument.
29
2.79k
  FrameReg = RI->getFrameRegister(MF);
30
2.79k
31
2.79k
  // Start the offset at 2 so we don't overwrite work group information.
32
2.79k
  // FIXME: We should only do this when the shader actually uses this
33
2.79k
  // information.
34
2.79k
  unsigned OffsetBytes = 2 * (getStackWidth(MF) * 4);
35
2.79k
  int UpperBound = FI == -1 ? 
MFI.getNumObjects()1.19k
:
FI1.59k
;
36
2.79k
37
13.9k
  for (int i = MFI.getObjectIndexBegin(); i < UpperBound; 
++i11.1k
) {
38
11.1k
    OffsetBytes = alignTo(OffsetBytes, MFI.getObjectAlignment(i));
39
11.1k
    OffsetBytes += MFI.getObjectSize(i);
40
11.1k
    // Each register holds 4 bytes, so we must always align the offset to at
41
11.1k
    // least 4 bytes, so that 2 frame objects won't share the same register.
42
11.1k
    OffsetBytes = alignTo(OffsetBytes, 4);
43
11.1k
  }
44
2.79k
45
2.79k
  if (FI != -1)
46
1.59k
    OffsetBytes = alignTo(OffsetBytes, MFI.getObjectAlignment(FI));
47
2.79k
48
2.79k
  return OffsetBytes / (getStackWidth(MF) * 4);
49
2.79k
}