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/Streams.h"
19 #include "llvm/Support/raw_ostream.h"
23 ARMConstantPoolValue::ARMConstantPoolValue(GlobalValue *gv, unsigned id,
28 : MachineConstantPoolValue((const Type*)gv->getType()),
29 GV(gv), S(NULL), LabelId(id), Kind(k), PCAdjust(PCAdj),
30 Modifier(Modif), AddCurrentAddress(AddCA) {}
32 ARMConstantPoolValue::ARMConstantPoolValue(const char *s, unsigned id,
37 : MachineConstantPoolValue((const Type*)Type::Int32Ty),
38 GV(NULL), S(s), LabelId(id), Kind(k), PCAdjust(PCAdj),
39 Modifier(Modif), AddCurrentAddress(AddCA) {}
41 ARMConstantPoolValue::ARMConstantPoolValue(GlobalValue *gv,
44 : MachineConstantPoolValue((const Type*)Type::Int32Ty),
45 GV(gv), S(NULL), LabelId(0), Kind(k), PCAdjust(0),
48 int ARMConstantPoolValue::getExistingMachineCPValue(MachineConstantPool *CP,
50 unsigned AlignMask = (1 << Alignment)-1;
51 const std::vector<MachineConstantPoolEntry> Constants = CP->getConstants();
52 for (unsigned i = 0, e = Constants.size(); i != e; ++i) {
53 if (Constants[i].isMachineConstantPoolEntry() &&
54 (Constants[i].Offset & AlignMask) == 0) {
55 ARMConstantPoolValue *CPV =
56 (ARMConstantPoolValue *)Constants[i].Val.MachineCPVal;
59 CPV->LabelId == LabelId &&
61 CPV->PCAdjust == PCAdjust)
70 ARMConstantPoolValue::AddSelectionDAGCSEId(FoldingSetNodeID &ID) {
73 ID.AddInteger(LabelId);
74 ID.AddInteger((unsigned)Kind);
75 ID.AddInteger(PCAdjust);
78 void ARMConstantPoolValue::dump() const {
82 void ARMConstantPoolValue::print(std::ostream &O) const {
83 raw_os_ostream RawOS(O);
87 void ARMConstantPoolValue::print(raw_ostream &O) const {
92 if (isNonLazyPointer()) O << "$non_lazy_ptr";
93 else if (isStub()) O << "$stub";
94 if (Modifier) O << "(" << Modifier << ")";
96 O << "-(LPC" << LabelId << "+" << (unsigned)PCAdjust;
97 if (AddCurrentAddress) O << "-.";