diff options
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/AsmPrinter.cpp | 14 | ||||
-rw-r--r-- | lib/CodeGen/MachineFunction.cpp | 7 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/ScheduleDAG.cpp | 3 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 22 |
4 files changed, 30 insertions, 16 deletions
diff --git a/lib/CodeGen/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter.cpp index ab0465df1c..df00f47f29 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 f0ece6b3db..3c41dbe4bb 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 9f285d5c9c..c0fd397564 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 aa9ea638f8..6f1a263048 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); } |