diff options
author | Evan Cheng <evan.cheng@apple.com> | 2007-01-19 07:51:42 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2007-01-19 07:51:42 +0000 |
commit | 10043e215bcfd6d2b09a6ce3ad461fd686f686b8 (patch) | |
tree | f9b3ebcddb8683310866f912f1e3e61ba565235f /llvm/lib/Target/ARM/ARMConstantPoolValue.cpp | |
parent | 28c5b8618a58a8fdc7a7f2505a7aa367b35fc129 (diff) | |
download | bcm5719-llvm-10043e215bcfd6d2b09a6ce3ad461fd686f686b8.tar.gz bcm5719-llvm-10043e215bcfd6d2b09a6ce3ad461fd686f686b8.zip |
ARM backend contribution from Apple.
llvm-svn: 33353
Diffstat (limited to 'llvm/lib/Target/ARM/ARMConstantPoolValue.cpp')
-rw-r--r-- | llvm/lib/Target/ARM/ARMConstantPoolValue.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/llvm/lib/Target/ARM/ARMConstantPoolValue.cpp b/llvm/lib/Target/ARM/ARMConstantPoolValue.cpp new file mode 100644 index 00000000000..97cca07d33f --- /dev/null +++ b/llvm/lib/Target/ARM/ARMConstantPoolValue.cpp @@ -0,0 +1,55 @@ +//===- ARMConstantPoolValue.cpp - ARM constantpool value --------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by Evan Cheng and is distributed under the +// University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements the ARM specific constantpool value class. +// +//===----------------------------------------------------------------------===// + +#include "ARMConstantPoolValue.h" +#include "llvm/ADT/FoldingSet.h" +#include "llvm/GlobalValue.h" +using namespace llvm; + +ARMConstantPoolValue::ARMConstantPoolValue(GlobalValue *gv, unsigned id, + bool isNonLazy, unsigned char PCAdj) + : MachineConstantPoolValue((const Type*)gv->getType()), + GV(gv), LabelId(id), isNonLazyPtr(isNonLazy), PCAdjust(PCAdj) {} + +int ARMConstantPoolValue::getExistingMachineCPValue(MachineConstantPool *CP, + unsigned Alignment) { + unsigned AlignMask = (1 << Alignment)-1; + const std::vector<MachineConstantPoolEntry> Constants = CP->getConstants(); + for (unsigned i = 0, e = Constants.size(); i != e; ++i) { + if (Constants[i].isMachineConstantPoolEntry() && + (Constants[i].Offset & AlignMask) == 0) { + ARMConstantPoolValue *CPV = + (ARMConstantPoolValue *)Constants[i].Val.MachineCPVal; + if (CPV->GV == GV && CPV->LabelId == LabelId && + CPV->isNonLazyPtr == isNonLazyPtr) + return i; + } + } + + return -1; +} + +void +ARMConstantPoolValue::AddSelectionDAGCSEId(FoldingSetNodeID &ID) { + ID.AddPointer(GV); + ID.AddInteger(LabelId); + ID.AddInteger((unsigned)isNonLazyPtr); + ID.AddInteger(PCAdjust); +} + +void ARMConstantPoolValue::print(std::ostream &O) const { + O << GV->getName(); + if (isNonLazyPtr) O << "$non_lazy_ptr"; + if (PCAdjust != 0) O << "-(LPIC" << LabelId << "+" + << (unsigned)PCAdjust << ")"; +} |