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"
22 ARMConstantPoolValue::ARMConstantPoolValue(GlobalValue *gv, unsigned id,
27 : MachineConstantPoolValue((const Type*)gv->getType()),
28 GV(gv), S(NULL), LabelId(id), Kind(k), PCAdjust(PCAdj),
29 Modifier(Modif), AddCurrentAddress(AddCA) {}
31 ARMConstantPoolValue::ARMConstantPoolValue(const char *s, unsigned id,
36 : MachineConstantPoolValue((const Type*)Type::Int32Ty),
37 GV(NULL), S(s), LabelId(id), Kind(k), PCAdjust(PCAdj),
38 Modifier(Modif), AddCurrentAddress(AddCA) {}
40 ARMConstantPoolValue::ARMConstantPoolValue(GlobalValue *gv,
43 : MachineConstantPoolValue((const Type*)Type::Int32Ty),
44 GV(gv), S(NULL), LabelId(0), Kind(k), PCAdjust(0),
47 int ARMConstantPoolValue::getExistingMachineCPValue(MachineConstantPool *CP,
49 unsigned AlignMask = Alignment - 1;
50 const std::vector<MachineConstantPoolEntry> Constants = CP->getConstants();
51 for (unsigned i = 0, e = Constants.size(); i != e; ++i) {
52 if (Constants[i].isMachineConstantPoolEntry() &&
53 (Constants[i].getAlignment() & AlignMask) == 0) {
54 ARMConstantPoolValue *CPV =
55 (ARMConstantPoolValue *)Constants[i].Val.MachineCPVal;
58 CPV->LabelId == LabelId &&
60 CPV->PCAdjust == PCAdjust)
69 ARMConstantPoolValue::AddSelectionDAGCSEId(FoldingSetNodeID &ID) {
72 ID.AddInteger(LabelId);
73 ID.AddInteger((unsigned)Kind);
74 ID.AddInteger(PCAdjust);
77 void ARMConstantPoolValue::dump() const {
81 void ARMConstantPoolValue::print(std::ostream &O) const {
82 raw_os_ostream RawOS(O);
86 void ARMConstantPoolValue::print(raw_ostream &O) const {
91 if (isNonLazyPointer()) O << "$non_lazy_ptr";
92 else if (isStub()) O << "$stub";
93 if (Modifier) O << "(" << Modifier << ")";
95 O << "-(LPC" << LabelId << "+" << (unsigned)PCAdjust;
96 if (AddCurrentAddress) O << "-.";