LLVM  3.7.0
SystemZConstantPoolValue.cpp
Go to the documentation of this file.
1 //===-- SystemZConstantPoolValue.cpp - SystemZ constant-pool value --------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
11 #include "llvm/ADT/FoldingSet.h"
12 #include "llvm/IR/DerivedTypes.h"
13 #include "llvm/IR/GlobalValue.h"
15 
16 using namespace llvm;
17 
21  : MachineConstantPoolValue(gv->getType()), GV(gv), Modifier(modifier) {}
22 
26  return new SystemZConstantPoolValue(GV, Modifier);
27 }
28 
30  switch (Modifier) {
31  case SystemZCP::TLSGD:
32  case SystemZCP::TLSLDM:
33  case SystemZCP::DTPOFF:
34  // May require a dynamic relocation.
35  return 2;
36  case SystemZCP::NTPOFF:
37  // May require a relocation, but the relocations are always resolved
38  // by the static linker.
39  return 1;
40  }
41  llvm_unreachable("Unknown modifier");
42 }
43 
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) {
51  auto *ZCPV =
52  static_cast<SystemZConstantPoolValue *>(Constants[I].Val.MachineCPVal);
53  if (ZCPV->GV == GV && ZCPV->Modifier == Modifier)
54  return I;
55  }
56  }
57  return -1;
58 }
59 
61  ID.AddPointer(GV);
62  ID.AddInteger(Modifier);
63 }
64 
66  O << GV << "@" << int(Modifier);
67 }
void AddPointer(const void *Ptr)
Add* - Add various data types to Bit data.
Definition: FoldingSet.cpp:52
The MachineConstantPool class keeps track of constants referenced by a function which must be spilled...
SystemZConstantPoolValue(const GlobalValue *GV, SystemZCP::SystemZCPModifier Modifier)
FunctionType * getType(LLVMContext &Context, ID id, ArrayRef< Type * > Tys=None)
Return the function type for an intrinsic.
Definition: Function.cpp:822
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:98
void addSelectionDAGCSEId(FoldingSetNodeID &ID) override
void AddInteger(signed I)
Definition: FoldingSet.cpp:60
unsigned getRelocationInfo() const override
getRelocationInfo - This method classifies the entry according to whether or not it may generate a re...
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
Definition: FoldingSet.h:297
int getExistingMachineCPValue(MachineConstantPool *CP, unsigned Alignment) override
Abstract base class for all machine specific constantpool value subclasses.
void print(raw_ostream &O) const override
print - Implement operator<<
#define I(x, y, z)
Definition: MD5.cpp:54
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:38
A SystemZ-specific constant pool value.
const std::vector< MachineConstantPoolEntry > & getConstants() const
static SystemZConstantPoolValue * Create(const GlobalValue *GV, SystemZCP::SystemZCPModifier Modifier)