1 //===- ARMConstantPoolValue.cpp - ARM constantpool value --------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by Evan Cheng and is distributed under the
6 // University of Illinois Open Source 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"
19 ARMConstantPoolValue::ARMConstantPoolValue(GlobalValue *gv, unsigned id,
20 bool isNonLazy, unsigned char PCAdj)
21 : MachineConstantPoolValue((const Type*)gv->getType()),
22 GV(gv), LabelId(id), isNonLazyPtr(isNonLazy), PCAdjust(PCAdj) {}
24 int ARMConstantPoolValue::getExistingMachineCPValue(MachineConstantPool *CP,
26 unsigned AlignMask = (1 << Alignment)-1;
27 const std::vector<MachineConstantPoolEntry> Constants = CP->getConstants();
28 for (unsigned i = 0, e = Constants.size(); i != e; ++i) {
29 if (Constants[i].isMachineConstantPoolEntry() &&
30 (Constants[i].Offset & AlignMask) == 0) {
31 ARMConstantPoolValue *CPV =
32 (ARMConstantPoolValue *)Constants[i].Val.MachineCPVal;
33 if (CPV->GV == GV && CPV->LabelId == LabelId &&
34 CPV->isNonLazyPtr == isNonLazyPtr)
43 ARMConstantPoolValue::AddSelectionDAGCSEId(FoldingSetNodeID &ID) {
45 ID.AddInteger(LabelId);
46 ID.AddInteger((unsigned)isNonLazyPtr);
47 ID.AddInteger(PCAdjust);
50 void ARMConstantPoolValue::print(std::ostream &O) const {
52 if (isNonLazyPtr) O << "$non_lazy_ptr";
53 if (PCAdjust != 0) O << "-(LPIC" << LabelId << "+"
54 << (unsigned)PCAdjust << ")";