2007-01-19 07:51:42 +00:00
|
|
|
//===- ARMConstantPoolValue.cpp - ARM constantpool value --------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:36:04 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2007-01-19 07:51:42 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file implements the ARM specific constantpool value class.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "ARMConstantPoolValue.h"
|
|
|
|
#include "llvm/ADT/FoldingSet.h"
|
|
|
|
#include "llvm/GlobalValue.h"
|
2007-01-30 20:37:08 +00:00
|
|
|
#include "llvm/Type.h"
|
2008-10-29 23:55:17 +00:00
|
|
|
#include "llvm/Support/Streams.h"
|
2008-08-23 22:23:09 +00:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2007-01-19 07:51:42 +00:00
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
ARMConstantPoolValue::ARMConstantPoolValue(GlobalValue *gv, unsigned id,
|
2007-01-30 20:37:08 +00:00
|
|
|
ARMCP::ARMCPKind k,
|
2007-04-22 00:04:12 +00:00
|
|
|
unsigned char PCAdj,
|
2007-04-27 13:54:47 +00:00
|
|
|
const char *Modif,
|
|
|
|
bool AddCA)
|
2007-01-19 07:51:42 +00:00
|
|
|
: MachineConstantPoolValue((const Type*)gv->getType()),
|
2007-04-22 00:04:12 +00:00
|
|
|
GV(gv), S(NULL), LabelId(id), Kind(k), PCAdjust(PCAdj),
|
2007-04-27 13:54:47 +00:00
|
|
|
Modifier(Modif), AddCurrentAddress(AddCA) {}
|
2007-01-30 20:37:08 +00:00
|
|
|
|
|
|
|
ARMConstantPoolValue::ARMConstantPoolValue(const char *s, unsigned id,
|
|
|
|
ARMCP::ARMCPKind k,
|
2007-04-22 00:04:12 +00:00
|
|
|
unsigned char PCAdj,
|
2007-04-27 13:54:47 +00:00
|
|
|
const char *Modif,
|
|
|
|
bool AddCA)
|
2007-01-30 20:37:08 +00:00
|
|
|
: MachineConstantPoolValue((const Type*)Type::Int32Ty),
|
2007-04-22 00:04:12 +00:00
|
|
|
GV(NULL), S(s), LabelId(id), Kind(k), PCAdjust(PCAdj),
|
2007-04-27 13:54:47 +00:00
|
|
|
Modifier(Modif), AddCurrentAddress(AddCA) {}
|
2007-04-22 00:04:12 +00:00
|
|
|
|
|
|
|
ARMConstantPoolValue::ARMConstantPoolValue(GlobalValue *gv,
|
|
|
|
ARMCP::ARMCPKind k,
|
|
|
|
const char *Modif)
|
|
|
|
: MachineConstantPoolValue((const Type*)Type::Int32Ty),
|
|
|
|
GV(gv), S(NULL), LabelId(0), Kind(k), PCAdjust(0),
|
|
|
|
Modifier(Modif) {}
|
2007-01-19 07:51:42 +00:00
|
|
|
|
|
|
|
int ARMConstantPoolValue::getExistingMachineCPValue(MachineConstantPool *CP,
|
|
|
|
unsigned Alignment) {
|
2009-03-13 07:51:59 +00:00
|
|
|
unsigned AlignMask = Alignment - 1;
|
2007-01-19 07:51:42 +00:00
|
|
|
const std::vector<MachineConstantPoolEntry> Constants = CP->getConstants();
|
|
|
|
for (unsigned i = 0, e = Constants.size(); i != e; ++i) {
|
|
|
|
if (Constants[i].isMachineConstantPoolEntry() &&
|
2009-03-13 07:51:59 +00:00
|
|
|
(Constants[i].getAlignment() & AlignMask) == 0) {
|
2007-01-19 07:51:42 +00:00
|
|
|
ARMConstantPoolValue *CPV =
|
|
|
|
(ARMConstantPoolValue *)Constants[i].Val.MachineCPVal;
|
2007-01-30 20:37:08 +00:00
|
|
|
if (CPV->GV == GV &&
|
|
|
|
CPV->S == S &&
|
|
|
|
CPV->LabelId == LabelId &&
|
|
|
|
CPV->Kind == Kind &&
|
|
|
|
CPV->PCAdjust == PCAdjust)
|
2007-01-19 07:51:42 +00:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ARMConstantPoolValue::AddSelectionDAGCSEId(FoldingSetNodeID &ID) {
|
|
|
|
ID.AddPointer(GV);
|
2007-01-30 20:37:08 +00:00
|
|
|
ID.AddPointer(S);
|
2007-01-19 07:51:42 +00:00
|
|
|
ID.AddInteger(LabelId);
|
2007-01-30 20:37:08 +00:00
|
|
|
ID.AddInteger((unsigned)Kind);
|
2007-01-19 07:51:42 +00:00
|
|
|
ID.AddInteger(PCAdjust);
|
|
|
|
}
|
|
|
|
|
2008-10-29 23:55:17 +00:00
|
|
|
void ARMConstantPoolValue::dump() const {
|
|
|
|
cerr << " " << *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ARMConstantPoolValue::print(std::ostream &O) const {
|
|
|
|
raw_os_ostream RawOS(O);
|
|
|
|
print(RawOS);
|
|
|
|
}
|
|
|
|
|
2008-08-23 22:23:09 +00:00
|
|
|
void ARMConstantPoolValue::print(raw_ostream &O) const {
|
2007-01-30 20:37:08 +00:00
|
|
|
if (GV)
|
|
|
|
O << GV->getName();
|
|
|
|
else
|
|
|
|
O << S;
|
|
|
|
if (isNonLazyPointer()) O << "$non_lazy_ptr";
|
|
|
|
else if (isStub()) O << "$stub";
|
2007-04-22 00:04:12 +00:00
|
|
|
if (Modifier) O << "(" << Modifier << ")";
|
2007-04-27 13:54:47 +00:00
|
|
|
if (PCAdjust != 0) {
|
2008-11-04 00:50:32 +00:00
|
|
|
O << "-(LPC" << LabelId << "+" << (unsigned)PCAdjust;
|
|
|
|
if (AddCurrentAddress) O << "-.";
|
2007-04-27 13:54:47 +00:00
|
|
|
O << ")";
|
|
|
|
}
|
2007-01-19 07:51:42 +00:00
|
|
|
}
|