1
//===-- SystemZConstantPoolValue.cpp - SystemZ constant-pool value --------===//
3
// The LLVM Compiler Infrastructure
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
8
//===----------------------------------------------------------------------===//
10
#include "SystemZConstantPoolValue.h"
11
#include "llvm/ADT/FoldingSet.h"
12
#include "llvm/IR/DerivedTypes.h"
13
#include "llvm/IR/GlobalValue.h"
14
#include "llvm/Support/raw_ostream.h"
18
SystemZConstantPoolValue::
19
SystemZConstantPoolValue(const GlobalValue *gv,
20
SystemZCP::SystemZCPModifier modifier)
21
: MachineConstantPoolValue(gv->getType()), GV(gv), Modifier(modifier) {}
23
SystemZConstantPoolValue *
24
SystemZConstantPoolValue::Create(const GlobalValue *GV,
25
SystemZCP::SystemZCPModifier Modifier) {
26
return new SystemZConstantPoolValue(GV, Modifier);
29
unsigned SystemZConstantPoolValue::getRelocationInfo() const {
31
case SystemZCP::TLSGD:
32
case SystemZCP::TLSLDM:
33
case SystemZCP::DTPOFF:
34
// May require a dynamic relocation.
36
case SystemZCP::NTPOFF:
37
// May require a relocation, but the relocations are always resolved
38
// by the static linker.
41
llvm_unreachable("Unknown modifier");
44
int SystemZConstantPoolValue::
45
getExistingMachineCPValue(MachineConstantPool *CP, unsigned Alignment) {
46
unsigned AlignMask = Alignment - 1;
47
const std::vector<MachineConstantPoolEntry> &Constants = CP->getConstants();
48
for (unsigned I = 0, E = Constants.size(); I != E; ++I) {
49
if (Constants[I].isMachineConstantPoolEntry() &&
50
(Constants[I].getAlignment() & AlignMask) == 0) {
52
static_cast<SystemZConstantPoolValue *>(Constants[I].Val.MachineCPVal);
53
if (ZCPV->GV == GV && ZCPV->Modifier == Modifier)
60
void SystemZConstantPoolValue::addSelectionDAGCSEId(FoldingSetNodeID &ID) {
62
ID.AddInteger(Modifier);
65
void SystemZConstantPoolValue::print(raw_ostream &O) const {
66
O << GV << "@" << int(Modifier);