Coverage Report

Created: 2024-01-17 10:31

/src/llvm-project/llvm/lib/Target/SystemZ/SystemZConstantPoolValue.cpp
Line
Count
Source (jump to first uncovered line)
1
//===-- SystemZConstantPoolValue.cpp - SystemZ constant-pool value --------===//
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 "SystemZConstantPoolValue.h"
10
#include "llvm/ADT/FoldingSet.h"
11
#include "llvm/IR/DerivedTypes.h"
12
#include "llvm/IR/GlobalValue.h"
13
#include "llvm/Support/raw_ostream.h"
14
15
using namespace llvm;
16
17
SystemZConstantPoolValue::
18
SystemZConstantPoolValue(const GlobalValue *gv,
19
                         SystemZCP::SystemZCPModifier modifier)
20
0
  : MachineConstantPoolValue(gv->getType()), GV(gv), Modifier(modifier) {}
21
22
SystemZConstantPoolValue *
23
SystemZConstantPoolValue::Create(const GlobalValue *GV,
24
0
                                 SystemZCP::SystemZCPModifier Modifier) {
25
0
  return new SystemZConstantPoolValue(GV, Modifier);
26
0
}
27
28
int SystemZConstantPoolValue::getExistingMachineCPValue(MachineConstantPool *CP,
29
0
                                                        Align Alignment) {
30
0
  const std::vector<MachineConstantPoolEntry> &Constants = CP->getConstants();
31
0
  for (unsigned I = 0, E = Constants.size(); I != E; ++I) {
32
0
    if (Constants[I].isMachineConstantPoolEntry() &&
33
0
        Constants[I].getAlign() >= Alignment) {
34
0
      auto *ZCPV =
35
0
        static_cast<SystemZConstantPoolValue *>(Constants[I].Val.MachineCPVal);
36
0
      if (ZCPV->GV == GV && ZCPV->Modifier == Modifier)
37
0
        return I;
38
0
    }
39
0
  }
40
0
  return -1;
41
0
}
42
43
0
void SystemZConstantPoolValue::addSelectionDAGCSEId(FoldingSetNodeID &ID) {
44
0
  ID.AddPointer(GV);
45
0
  ID.AddInteger(Modifier);
46
0
}
47
48
0
void SystemZConstantPoolValue::print(raw_ostream &O) const {
49
0
  O << GV << "@" << int(Modifier);
50
0
}