aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2006-01-31 22:23:14 +0000
committerEvan Cheng <evan.cheng@apple.com>2006-01-31 22:23:14 +0000
commitb8973bd8f50d7321635e1e07b81a880a0828d185 (patch)
tree452842927ad6a1c0969372cef9b984007ac68328 /lib
parent259e97cc725011a3c138563d421a4654b082a64c (diff)
downloadexternal_llvm-b8973bd8f50d7321635e1e07b81a880a0828d185.zip
external_llvm-b8973bd8f50d7321635e1e07b81a880a0828d185.tar.gz
external_llvm-b8973bd8f50d7321635e1e07b81a880a0828d185.tar.bz2
Allow the specification of explicit alignments for constant pool entries.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25855 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/AsmPrinter.cpp14
-rw-r--r--lib/CodeGen/MachineFunction.cpp7
-rw-r--r--lib/CodeGen/SelectionDAG/ScheduleDAG.cpp3
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAG.cpp22
-rw-r--r--lib/ExecutionEngine/JIT/JITEmitter.cpp10
-rw-r--r--lib/Target/Alpha/AlphaISelLowering.cpp5
-rw-r--r--lib/Target/IA64/IA64ISelDAGToDAG.cpp6
-rw-r--r--lib/Target/PowerPC/PPCISelLowering.cpp5
-rw-r--r--lib/Target/Sparc/SparcISelDAGToDAG.cpp3
-rw-r--r--lib/Target/SparcV8/SparcV8ISelDAGToDAG.cpp3
-rw-r--r--lib/Target/SparcV9/SparcV9AsmPrinter.cpp13
11 files changed, 58 insertions, 33 deletions
diff --git a/lib/CodeGen/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter.cpp
index ab0465d..df00f47 100644
--- a/lib/CodeGen/AsmPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter.cpp
@@ -103,7 +103,7 @@ void AsmPrinter::SetupMachineFunction(MachineFunction &MF) {
/// the code generator.
///
void AsmPrinter::EmitConstantPool(MachineConstantPool *MCP) {
- const std::vector<Constant*> &CP = MCP->getConstants();
+ const std::vector<std::pair<Constant*, unsigned> > &CP = MCP->getConstants();
if (CP.empty()) return;
const TargetData &TD = TM.getTargetData();
@@ -111,13 +111,17 @@ void AsmPrinter::EmitConstantPool(MachineConstantPool *MCP) {
for (unsigned i = 0, e = CP.size(); i != e; ++i) {
// FIXME: force doubles to be naturally aligned. We should handle this
// more correctly in the future.
- unsigned Alignment = TD.getTypeAlignmentShift(CP[i]->getType());
- if (CP[i]->getType() == Type::DoubleTy && Alignment < 3) Alignment = 3;
+ unsigned Alignment = CP[i].second;
+ if (Alignment == 0) {
+ Alignment = TD.getTypeAlignmentShift(CP[i].first->getType());
+ if (CP[i].first->getType() == Type::DoubleTy && Alignment < 3)
+ Alignment = 3;
+ }
EmitAlignment(Alignment);
O << PrivateGlobalPrefix << "CPI" << getFunctionNumber() << '_' << i
- << ":\t\t\t\t\t" << CommentString << *CP[i] << '\n';
- EmitGlobalConstant(CP[i]);
+ << ":\t\t\t\t\t" << CommentString << *CP[i].first << '\n';
+ EmitGlobalConstant(CP[i].first);
}
}
diff --git a/lib/CodeGen/MachineFunction.cpp b/lib/CodeGen/MachineFunction.cpp
index f0ece6b..3c41dbe 100644
--- a/lib/CodeGen/MachineFunction.cpp
+++ b/lib/CodeGen/MachineFunction.cpp
@@ -346,8 +346,11 @@ void MachineFrameInfo::dump(const MachineFunction &MF) const {
//===----------------------------------------------------------------------===//
void MachineConstantPool::print(std::ostream &OS) const {
- for (unsigned i = 0, e = Constants.size(); i != e; ++i)
- OS << " <cp #" << i << "> is" << *(Value*)Constants[i] << "\n";
+ for (unsigned i = 0, e = Constants.size(); i != e; ++i) {
+ OS << " <cp #" << i << "> is" << *(Value*)Constants[i].first;
+ if (Constants[i].second != 0) OS << " , align=" << Constants[i].second;
+ OS << "\n";
+ }
}
void MachineConstantPool::dump() const { print(std::cerr); }
diff --git a/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp b/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
index 9f285d5..c0fd397 100644
--- a/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
@@ -194,7 +194,8 @@ void ScheduleDAG::EmitNode(NodeInfo *NI) {
MI->addFrameIndexOperand(FI->getIndex());
} else if (ConstantPoolSDNode *CP =
dyn_cast<ConstantPoolSDNode>(Node->getOperand(i))) {
- unsigned Idx = ConstPool->getConstantPoolIndex(CP->get());
+ unsigned Idx = ConstPool->getConstantPoolIndex(CP->get(),
+ CP->getAlignment());
MI->addConstantPoolIndexOperand(Idx);
} else if (ExternalSymbolSDNode *ES =
dyn_cast<ExternalSymbolSDNode>(Node->getOperand(i))) {
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index aa9ea63..6f1a263 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -310,10 +310,14 @@ void SelectionDAG::RemoveNodeFromCSEMaps(SDNode *N) {
Erased = TargetFrameIndices.erase(cast<FrameIndexSDNode>(N)->getIndex());
break;
case ISD::ConstantPool:
- Erased = ConstantPoolIndices.erase(cast<ConstantPoolSDNode>(N)->get());
+ Erased = ConstantPoolIndices.
+ erase(std::make_pair(cast<ConstantPoolSDNode>(N)->get(),
+ cast<ConstantPoolSDNode>(N)->getAlignment()));
break;
case ISD::TargetConstantPool:
- Erased =TargetConstantPoolIndices.erase(cast<ConstantPoolSDNode>(N)->get());
+ Erased = TargetConstantPoolIndices.
+ erase(std::make_pair(cast<ConstantPoolSDNode>(N)->get(),
+ cast<ConstantPoolSDNode>(N)->getAlignment()));
break;
case ISD::BasicBlock:
Erased = BBNodes.erase(cast<BasicBlockSDNode>(N)->getBasicBlock());
@@ -655,18 +659,20 @@ SDOperand SelectionDAG::getTargetFrameIndex(int FI, MVT::ValueType VT) {
return SDOperand(N, 0);
}
-SDOperand SelectionDAG::getConstantPool(Constant *C, MVT::ValueType VT) {
- SDNode *&N = ConstantPoolIndices[C];
+SDOperand SelectionDAG::getConstantPool(Constant *C, MVT::ValueType VT,
+ unsigned Alignment) {
+ SDNode *&N = ConstantPoolIndices[std::make_pair(C, Alignment)];
if (N) return SDOperand(N, 0);
- N = new ConstantPoolSDNode(C, VT, false);
+ N = new ConstantPoolSDNode(C, VT, Alignment, false);
AllNodes.push_back(N);
return SDOperand(N, 0);
}
-SDOperand SelectionDAG::getTargetConstantPool(Constant *C, MVT::ValueType VT) {
- SDNode *&N = TargetConstantPoolIndices[C];
+SDOperand SelectionDAG::getTargetConstantPool(Constant *C, MVT::ValueType VT,
+ unsigned Alignment) {
+ SDNode *&N = TargetConstantPoolIndices[std::make_pair(C, Alignment)];
if (N) return SDOperand(N, 0);
- N = new ConstantPoolSDNode(C, VT, true);
+ N = new ConstantPoolSDNode(C, VT, Alignment, true);
AllNodes.push_back(N);
return SDOperand(N, 0);
}
diff --git a/lib/ExecutionEngine/JIT/JITEmitter.cpp b/lib/ExecutionEngine/JIT/JITEmitter.cpp
index fb20471..d2f943f 100644
--- a/lib/ExecutionEngine/JIT/JITEmitter.cpp
+++ b/lib/ExecutionEngine/JIT/JITEmitter.cpp
@@ -566,16 +566,18 @@ void JITEmitter::finishFunction(MachineFunction &F) {
}
void JITEmitter::emitConstantPool(MachineConstantPool *MCP) {
- const std::vector<Constant*> &Constants = MCP->getConstants();
+ const std::vector<std::pair<Constant*,unsigned> > &Constants = MCP->getConstants();
if (Constants.empty()) return;
for (unsigned i = 0, e = Constants.size(); i != e; ++i) {
- const Type *Ty = Constants[i]->getType();
+ const Type *Ty = Constants[i].first->getType();
unsigned Size = (unsigned)TheJIT->getTargetData().getTypeSize(Ty);
- unsigned Alignment = TheJIT->getTargetData().getTypeAlignment(Ty);
+ unsigned Alignment = (Constants[i].second == 0)
+ ? TheJIT->getTargetData().getTypeAlignment(Ty)
+ : Constants[i].second;
void *Addr = MemMgr.allocateConstant(Size, Alignment);
- TheJIT->InitializeMemory(Constants[i], Addr);
+ TheJIT->InitializeMemory(Constants[i].first, Addr);
ConstantPoolAddresses.push_back(Addr);
}
}
diff --git a/lib/Target/Alpha/AlphaISelLowering.cpp b/lib/Target/Alpha/AlphaISelLowering.cpp
index 517ffae..2990146 100644
--- a/lib/Target/Alpha/AlphaISelLowering.cpp
+++ b/lib/Target/Alpha/AlphaISelLowering.cpp
@@ -482,8 +482,9 @@ SDOperand AlphaTargetLowering::LowerOperation(SDOperand Op, SelectionDAG &DAG) {
}
}
case ISD::ConstantPool: {
- Constant *C = cast<ConstantPoolSDNode>(Op)->get();
- SDOperand CPI = DAG.getTargetConstantPool(C, MVT::i64);
+ ConstantPoolSDNode *CP = cast<ConstantPoolSDNode>(Op);
+ Constant *C = CP->get();
+ SDOperand CPI = DAG.getTargetConstantPool(C, MVT::i64, CP->getAlignment());
SDOperand Hi = DAG.getNode(AlphaISD::GPRelHi, MVT::i64, CPI,
DAG.getNode(AlphaISD::GlobalBaseReg, MVT::i64));
diff --git a/lib/Target/IA64/IA64ISelDAGToDAG.cpp b/lib/Target/IA64/IA64ISelDAGToDAG.cpp
index 072b55b..2b817bb 100644
--- a/lib/Target/IA64/IA64ISelDAGToDAG.cpp
+++ b/lib/Target/IA64/IA64ISelDAGToDAG.cpp
@@ -442,8 +442,10 @@ SDOperand IA64DAGToDAGISel::Select(SDOperand Op) {
case ISD::ConstantPool: { // TODO: nuke the constant pool
// (ia64 doesn't need one)
- Constant *C = cast<ConstantPoolSDNode>(N)->get();
- SDOperand CPI = CurDAG->getTargetConstantPool(C, MVT::i64);
+ ConstantPoolSDNode *CP = cast<ConstantPoolSDNode>(N);
+ Constant *C = CP->get();
+ SDOperand CPI = CurDAG->getTargetConstantPool(C, MVT::i64,
+ CP->getAlignment());
return CurDAG->getTargetNode(IA64::ADDL_GA, MVT::i64, // ?
CurDAG->getRegister(IA64::r1, MVT::i64), CPI);
}
diff --git a/lib/Target/PowerPC/PPCISelLowering.cpp b/lib/Target/PowerPC/PPCISelLowering.cpp
index 8b5546d..28beeaf 100644
--- a/lib/Target/PowerPC/PPCISelLowering.cpp
+++ b/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -389,8 +389,9 @@ SDOperand PPCTargetLowering::LowerOperation(SDOperand Op, SelectionDAG &DAG) {
return DAG.getNode(ISD::BUILD_PAIR, MVT::i64, OutLo, OutHi);
}
case ISD::ConstantPool: {
- Constant *C = cast<ConstantPoolSDNode>(Op)->get();
- SDOperand CPI = DAG.getTargetConstantPool(C, MVT::i32);
+ ConstantPoolSDNode *CP = cast<ConstantPoolSDNode>(Op);
+ Constant *C = CP->get();
+ SDOperand CPI = DAG.getTargetConstantPool(C, MVT::i32, CP->getAlignment());
SDOperand Zero = DAG.getConstant(0, MVT::i32);
if (PPCGenerateStaticCode) {
diff --git a/lib/Target/Sparc/SparcISelDAGToDAG.cpp b/lib/Target/Sparc/SparcISelDAGToDAG.cpp
index 38f3c15..c274105 100644
--- a/lib/Target/Sparc/SparcISelDAGToDAG.cpp
+++ b/lib/Target/Sparc/SparcISelDAGToDAG.cpp
@@ -693,7 +693,8 @@ LowerOperation(SDOperand Op, SelectionDAG &DAG) {
}
case ISD::ConstantPool: {
Constant *C = cast<ConstantPoolSDNode>(Op)->get();
- SDOperand CP = DAG.getTargetConstantPool(C, MVT::i32);
+ SDOperand CP = DAG.getTargetConstantPool(C, MVT::i32,
+ cast<ConstantPoolSDNode>(Op)->getAlignment());
SDOperand Hi = DAG.getNode(V8ISD::Hi, MVT::i32, CP);
SDOperand Lo = DAG.getNode(V8ISD::Lo, MVT::i32, CP);
return DAG.getNode(ISD::ADD, MVT::i32, Lo, Hi);
diff --git a/lib/Target/SparcV8/SparcV8ISelDAGToDAG.cpp b/lib/Target/SparcV8/SparcV8ISelDAGToDAG.cpp
index 38f3c15..c274105 100644
--- a/lib/Target/SparcV8/SparcV8ISelDAGToDAG.cpp
+++ b/lib/Target/SparcV8/SparcV8ISelDAGToDAG.cpp
@@ -693,7 +693,8 @@ LowerOperation(SDOperand Op, SelectionDAG &DAG) {
}
case ISD::ConstantPool: {
Constant *C = cast<ConstantPoolSDNode>(Op)->get();
- SDOperand CP = DAG.getTargetConstantPool(C, MVT::i32);
+ SDOperand CP = DAG.getTargetConstantPool(C, MVT::i32,
+ cast<ConstantPoolSDNode>(Op)->getAlignment());
SDOperand Hi = DAG.getNode(V8ISD::Hi, MVT::i32, CP);
SDOperand Lo = DAG.getNode(V8ISD::Lo, MVT::i32, CP);
return DAG.getNode(ISD::ADD, MVT::i32, Lo, Hi);
diff --git a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp
index 564c7ed..638a699 100644
--- a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp
+++ b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp
@@ -209,11 +209,14 @@ namespace {
// Print a constant (which may be an aggregate) prefixed by all the
// appropriate directives. Uses printConstantValueOnly() to print the
// value or values.
- void printConstant(const Constant* CV, std::string valID = "") {
+ void printConstant(const Constant* CV, unsigned Alignment,
+ std::string valID = "") {
if (valID.length() == 0)
valID = getID(CV);
- O << "\t.align\t" << ConstantToAlignment(CV, TM) << "\n";
+ if (Alignment == 0)
+ Alignment = ConstantToAlignment(CV, TM);
+ O << "\t.align\t" << Alignment << "\n";
// Print .size and .type only if it is not a string.
if (const ConstantArray *CVA = dyn_cast<ConstantArray>(CV))
@@ -721,12 +724,12 @@ void SparcV9AsmPrinter::emitFunction(const Function &F) {
// Emit constant pool for this function
const MachineConstantPool *MCP = MF.getConstantPool();
- const std::vector<Constant*> &CP = MCP->getConstants();
+ const std::vector<std::pair<Constant*, unsigned> > &CP = MCP->getConstants();
enterSection(ReadOnlyData);
for (unsigned i = 0, e = CP.size(); i != e; ++i) {
std::string cpiName = ".CPI_" + CurrentFnName + "_" + utostr(i);
- printConstant(CP[i], cpiName);
+ printConstant(CP[i].first, CP[i].second, cpiName);
}
enterSection(Text);
@@ -755,7 +758,7 @@ void SparcV9AsmPrinter::printGlobalVariable(const GlobalVariable* GV) {
if (GV->hasInitializer() &&
!(GV->getInitializer()->isNullValue() ||
isa<UndefValue>(GV->getInitializer()))) {
- printConstant(GV->getInitializer(), getID(GV));
+ printConstant(GV->getInitializer(), 0, getID(GV));
} else {
O << "\t.align\t" << TypeToAlignment(GV->getType()->getElementType(),
TM) << "\n";