llvm.org GIT mirror llvm / 3389e10
Revert broken pieces of r179373. You can't copy an OwningPtr, and move semantics aren't available in C++98. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179374 91177308-0d34-0410-b5e6-96231b3b80d8 Benjamin Kramer 6 years ago
3 changed file(s) with 37 addition(s) and 35 deletion(s). Raw diff Collapse all Expand all
1616 #define LLVM_CODEGEN_REGALLOCPBQP_H
1717
1818 #include "llvm/ADT/DenseMap.h"
19 #include "llvm/ADT/OwningPtr.h"
2019 #include "llvm/CodeGen/MachineFunctionPass.h"
2120 #include "llvm/CodeGen/PBQP/Graph.h"
2221 #include "llvm/CodeGen/PBQP/Solution.h"
123122
124123 /// Build a PBQP instance to represent the register allocation problem for
125124 /// the given MachineFunction.
126 virtual OwningPtr build(MachineFunction *mf,
127 const LiveIntervals *lis,
128 const MachineLoopInfo *loopInfo,
129 const RegSet &vregs);
125 virtual std::auto_ptr build(
126 MachineFunction *mf,
127 const LiveIntervals *lis,
128 const MachineLoopInfo *loopInfo,
129 const RegSet &vregs);
130130 private:
131131
132132 void addSpillCosts(PBQP::Vector &costVec, PBQP::PBQPNum spillCost);
143143
144144 /// Build a PBQP instance to represent the register allocation problem for
145145 /// the given MachineFunction.
146 virtual OwningPtr build(MachineFunction *mf,
147 const LiveIntervals *lis,
148 const MachineLoopInfo *loopInfo,
149 const RegSet &vregs);
146 virtual std::auto_ptr build(
147 MachineFunction *mf,
148 const LiveIntervals *lis,
149 const MachineLoopInfo *loopInfo,
150 const RegSet &vregs);
150151
151152 private:
152153
159160 PBQP::PBQPNum benefit);
160161 };
161162
162 FunctionPass* createPBQPRegisterAllocator(OwningPtr builder,
163 FunctionPass* createPBQPRegisterAllocator(std::auto_ptr builder,
163164 char *customPassID=0);
164165 }
165166
8888 static char ID;
8989
9090 /// Construct a PBQP register allocator.
91 RegAllocPBQP(OwningPtr b, char *cPassID=0)
92 : MachineFunctionPass(ID), builder(b.take()), customPassID(cPassID) {
91 RegAllocPBQP(std::auto_ptr b, char *cPassID=0)
92 : MachineFunctionPass(ID), builder(b), customPassID(cPassID) {
9393 initializeSlotIndexesPass(*PassRegistry::getPassRegistry());
9494 initializeLiveIntervalsPass(*PassRegistry::getPassRegistry());
9595 initializeCalculateSpillWeightsPass(*PassRegistry::getPassRegistry());
120120 typedef std::set RegSet;
121121
122122
123 OwningPtr builder;
123 std::auto_ptr builder;
124124
125125 char *customPassID;
126126
131131 const MachineLoopInfo *loopInfo;
132132 MachineRegisterInfo *mri;
133133
134 OwningPtr spiller;
134 std::auto_ptr spiller;
135135 LiveIntervals *lis;
136136 LiveStacks *lss;
137137 VirtRegMap *vrm;
185185 return allowedSet[option - 1];
186186 }
187187
188 OwningPtr PBQPBuilder::build(MachineFunction *mf,
189 const LiveIntervals *lis,
190 const MachineLoopInfo *loopInfo,
191 const RegSet &vregs) {
188 std::auto_ptr PBQPBuilder::build(MachineFunction *mf,
189 const LiveIntervals *lis,
190 const MachineLoopInfo *loopInfo,
191 const RegSet &vregs) {
192192
193193 LiveIntervals *LIS = const_cast(lis);
194194 MachineRegisterInfo *mri = &mf->getRegInfo();
195195 const TargetRegisterInfo *tri = mf->getTarget().getRegisterInfo();
196196
197 OwningPtr p(new PBQPRAProblem());
197 std::auto_ptr p(new PBQPRAProblem());
198198 PBQP::Graph &g = p->getGraph();
199199 RegSet pregs;
200200
310310 }
311311 }
312312
313 OwningPtr PBQPBuilderWithCoalescing::build(
313 std::auto_ptr PBQPBuilderWithCoalescing::build(
314314 MachineFunction *mf,
315315 const LiveIntervals *lis,
316316 const MachineLoopInfo *loopInfo,
317317 const RegSet &vregs) {
318318
319 OwningPtr p = PBQPBuilder::build(mf, lis, loopInfo, vregs);
319 std::auto_ptr p = PBQPBuilder::build(mf, lis, loopInfo, vregs);
320320 PBQP::Graph &g = p->getGraph();
321321
322322 const TargetMachine &tm = mf->getTarget();
583583 while (!pbqpAllocComplete) {
584584 DEBUG(dbgs() << " PBQP Regalloc round " << round << ":\n");
585585
586 OwningPtr problem =
586 std::auto_ptr problem =
587587 builder->build(mf, lis, loopInfo, vregsToAlloc);
588588
589589 #ifndef NDEBUG
620620 }
621621
622622 FunctionPass* llvm::createPBQPRegisterAllocator(
623 OwningPtr builder,
623 std::auto_ptr builder,
624624 char *customPassID) {
625 return new RegAllocPBQP(OwningPtr(builder.take()), customPassID);
625 return new RegAllocPBQP(builder, customPassID);
626626 }
627627
628628 FunctionPass* llvm::createDefaultPBQPRegisterAllocator() {
629629 if (pbqpCoalescing) {
630630 return createPBQPRegisterAllocator(
631 OwningPtr(new PBQPBuilderWithCoalescing()));
631 std::auto_ptr(new PBQPBuilderWithCoalescing()));
632632 } // else
633633 return createPBQPRegisterAllocator(
634 OwningPtr(new PBQPBuilder()));
634 std::auto_ptr(new PBQPBuilder()));
635635 }
636636
637637 #undef DEBUG_TYPE
5252 // LoadFile - Read the specified bitcode file in and return it. This routine
5353 // searches the link path for the specified file to try to find it...
5454 //
55 static inline OwningPtr LoadFile(const char *argv0,
56 const std::string &FN,
57 LLVMContext& Context) {
55 static inline std::auto_ptr LoadFile(const char *argv0,
56 const std::string &FN,
57 LLVMContext& Context) {
5858 sys::Path Filename;
5959 if (!Filename.set(FN)) {
6060 errs() << "Invalid file name: '" << FN << "'\n";
61 return OwningPtr();
61 return std::auto_ptr();
6262 }
6363
6464 SMDiagnostic Err;
6767
6868 const std::string &FNStr = Filename.str();
6969 Result = ParseIRFile(FNStr, Err, Context);
70 if (Result) return OwningPtr(Result); // Load successful!
70 if (Result) return std::auto_ptr(Result); // Load successful!
7171
7272 Err.print(argv0, errs());
73 return OwningPtr();
73 return std::auto_ptr();
7474 }
7575
7676 int main(int argc, char **argv) {
8585 unsigned BaseArg = 0;
8686 std::string ErrorMessage;
8787
88 OwningPtr Composite(LoadFile(argv[0],
89 InputFilenames[BaseArg], Context));
88 std::auto_ptr Composite(LoadFile(argv[0],
89 InputFilenames[BaseArg], Context));
9090 if (Composite.get() == 0) {
9191 errs() << argv[0] << ": error loading file '"
9292 << InputFilenames[BaseArg] << "'\n";
9494 }
9595
9696 for (unsigned i = BaseArg+1; i < InputFilenames.size(); ++i) {
97 OwningPtr M(LoadFile(argv[0], InputFilenames[i], Context));
97 std::auto_ptr M(LoadFile(argv[0],
98 InputFilenames[i], Context));
9899 if (M.get() == 0) {
99100 errs() << argv[0] << ": error loading file '" <
100101 return 1;