Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/Target/XCore/XCoreMachineFunctionInfo.cpp
Line
Count
Source (jump to first uncovered line)
1
//===-- XCoreMachineFunctionInfo.cpp - XCore machine function info --------===//
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 "XCoreMachineFunctionInfo.h"
10
#include "XCoreInstrInfo.h"
11
#include "llvm/CodeGen/TargetSubtargetInfo.h"
12
#include "llvm/IR/Function.h"
13
14
using namespace llvm;
15
16
0
void XCoreFunctionInfo::anchor() { }
17
18
560
bool XCoreFunctionInfo::isLargeFrame(const MachineFunction &MF) const {
19
560
  if (CachedEStackSize == -1) {
20
280
    CachedEStackSize = MF.getFrameInfo().estimateStackSize(MF);
21
280
  }
22
560
  // isLargeFrame() is used when deciding if spill slots should be added to
23
560
  // allow eliminateFrameIndex() to scavenge registers.
24
560
  // This is only required when there is no FP and offsets are greater than
25
560
  // ~256KB (~64Kwords). Thus only for code run on the emulator!
26
560
  //
27
560
  // The arbitrary value of 0xf000 allows frames of up to ~240KB before spill
28
560
  // slots are added for the use of eliminateFrameIndex() register scavenging.
29
560
  // For frames less than 240KB, it is assumed that there will be less than
30
560
  // 16KB of function arguments.
31
560
  return CachedEStackSize > 0xf000;
32
560
}
33
34
86
int XCoreFunctionInfo::createLRSpillSlot(MachineFunction &MF) {
35
86
  if (LRSpillSlotSet) {
36
3
    return LRSpillSlot;
37
3
  }
38
83
  const TargetRegisterClass &RC = XCore::GRRegsRegClass;
39
83
  const TargetRegisterInfo &TRI = *MF.getSubtarget().getRegisterInfo();
40
83
  MachineFrameInfo &MFI = MF.getFrameInfo();
41
83
  if (! MF.getFunction().isVarArg()) {
42
81
    // A fixed offset of 0 allows us to save / restore LR using entsp / retsp.
43
81
    LRSpillSlot = MFI.CreateFixedObject(TRI.getSpillSize(RC), 0, true);
44
81
  } else {
45
2
    LRSpillSlot = MFI.CreateStackObject(TRI.getSpillSize(RC),
46
2
                                        TRI.getSpillAlignment(RC), true);
47
2
  }
48
83
  LRSpillSlotSet = true;
49
83
  return LRSpillSlot;
50
83
}
51
52
20
int XCoreFunctionInfo::createFPSpillSlot(MachineFunction &MF) {
53
20
  if (FPSpillSlotSet) {
54
0
    return FPSpillSlot;
55
0
  }
56
20
  const TargetRegisterClass &RC = XCore::GRRegsRegClass;
57
20
  const TargetRegisterInfo &TRI = *MF.getSubtarget().getRegisterInfo();
58
20
  MachineFrameInfo &MFI = MF.getFrameInfo();
59
20
  FPSpillSlot = MFI.CreateStackObject(TRI.getSpillSize(RC),
60
20
                                      TRI.getSpillAlignment(RC), true);
61
20
  FPSpillSlotSet = true;
62
20
  return FPSpillSlot;
63
20
}
64
65
12
const int* XCoreFunctionInfo::createEHSpillSlot(MachineFunction &MF) {
66
12
  if (EHSpillSlotSet) {
67
0
    return EHSpillSlot;
68
0
  }
69
12
  const TargetRegisterClass &RC = XCore::GRRegsRegClass;
70
12
  const TargetRegisterInfo &TRI = *MF.getSubtarget().getRegisterInfo();
71
12
  MachineFrameInfo &MFI = MF.getFrameInfo();
72
12
  unsigned Size = TRI.getSpillSize(RC);
73
12
  unsigned Align = TRI.getSpillAlignment(RC);
74
12
  EHSpillSlot[0] = MFI.CreateStackObject(Size, Align, true);
75
12
  EHSpillSlot[1] = MFI.CreateStackObject(Size, Align, true);
76
12
  EHSpillSlotSet = true;
77
12
  return EHSpillSlot;
78
12
}
79