1 //===- ARMConstantPoolValue.cpp - ARM constantpool value --------*- C++ -*-===//
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 // This file implements the ARM specific constantpool value class.
12 //===----------------------------------------------------------------------===//
14 #include "ARMConstantPoolValue.h"
15 #include "llvm/ADT/FoldingSet.h"
16 #include "llvm/GlobalValue.h"
17 #include "llvm/Type.h"
18 #include "llvm/Support/raw_ostream.h"
21 ARMConstantPoolValue::ARMConstantPoolValue(GlobalValue *gv, unsigned id,
26 : MachineConstantPoolValue((const Type*)gv->getType()),
27 GV(gv), S(NULL), LabelId(id), Kind(k), PCAdjust(PCAdj),
28 Modifier(Modif), AddCurrentAddress(AddCA) {}
30 ARMConstantPoolValue::ARMConstantPoolValue(const char *s, unsigned id,
35 : MachineConstantPoolValue((const Type*)Type::Int32Ty),
36 GV(NULL), S(s), LabelId(id), Kind(k), PCAdjust(PCAdj),
37 Modifier(Modif), AddCurrentAddress(AddCA) {}
39 ARMConstantPoolValue::ARMConstantPoolValue(GlobalValue *gv,
42 : MachineConstantPoolValue((const Type*)Type::Int32Ty),
43 GV(gv), S(NULL), LabelId(0), Kind(k), PCAdjust(0),
46 int ARMConstantPoolValue::getExistingMachineCPValue(MachineConstantPool *CP,
48 unsigned AlignMask = (1 << Alignment)-1;
49 const std::vector<MachineConstantPoolEntry> Constants = CP->getConstants();
50 for (unsigned i = 0, e = Constants.size(); i != e; ++i) {
51 if (Constants[i].isMachineConstantPoolEntry() &&
52 (Constants[i].Offset & AlignMask) == 0) {
53 ARMConstantPoolValue *CPV =
54 (ARMConstantPoolValue *)Constants[i].Val.MachineCPVal;
57 CPV->LabelId == LabelId &&
59 CPV->PCAdjust == PCAdjust)
68 ARMConstantPoolValue::AddSelectionDAGCSEId(FoldingSetNodeID &ID) {
71 ID.AddInteger(LabelId);
72 ID.AddInteger((unsigned)Kind);
73 ID.AddInteger(PCAdjust);
76 void ARMConstantPoolValue::print(raw_ostream &O) const {
81 if (isNonLazyPointer()) O << "$non_lazy_ptr";
82 else if (isStub()) O << "$stub";
83 if (Modifier) O << "(" << Modifier << ")";
85 O << "-(LPIC" << LabelId << "+"
86 << (unsigned)PCAdjust;
87 if (AddCurrentAddress)