From lattner at cs.uiuc.edu Mon Apr 19 13:07:05 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Apr 19 13:07:05 2004 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/LoopUnswitch/ Message-ID: <200404191806.NAA27124@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/LoopUnswitch: --- Log message: Directory /home/vadve/shared/PublicCVS/llvm/test/Regression/Transforms/LoopUnswitch added to the repository --- Diffs of the changes: (+0 -0) From lattner at cs.uiuc.edu Mon Apr 19 13:07:10 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Apr 19 13:07:10 2004 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/LoopUnswitch/basictest.ll Message-ID: <200404191806.NAA27134@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/LoopUnswitch: basictest.ll added (r1.1) --- Log message: New testcase --- Diffs of the changes: (+35 -0) Index: llvm/test/Regression/Transforms/LoopUnswitch/basictest.ll diff -c /dev/null llvm/test/Regression/Transforms/LoopUnswitch/basictest.ll:1.1 *** /dev/null Mon Apr 19 13:06:44 2004 --- llvm/test/Regression/Transforms/LoopUnswitch/basictest.ll Mon Apr 19 13:06:34 2004 *************** *** 0 **** --- 1,35 ---- + ; RUN: llvm-as < %s | opt -loop-unswitch -disable-output + implementation ; Functions: + + int %test(int* %A, bool %C) { + entry: + br label %no_exit + + no_exit: ; preds = %entry, %no_exit.backedge + %i.0.0 = phi uint [ 0, %entry ], [ %i.0.0.be, %no_exit.backedge ] ; [#uses=3] + %tmp.7 = getelementptr int* %A, uint %i.0.0 ; [#uses=4] + %tmp.13 = load int* %tmp.7 ; [#uses=1] + %tmp.14 = add int %tmp.13, 1 ; [#uses=1] + store int %tmp.14, int* %tmp.7 + br bool %C, label %then, label %endif + + then: ; preds = %no_exit + %tmp.29 = load int* %tmp.7 ; [#uses=1] + %tmp.30 = add int %tmp.29, 2 ; [#uses=1] + store int %tmp.30, int* %tmp.7 + %inc9 = add uint %i.0.0, 1 ; [#uses=2] + %tmp.112 = setlt uint %inc9, 100000 ; [#uses=1] + br bool %tmp.112, label %no_exit.backedge, label %return + + no_exit.backedge: ; preds = %then, %endif + %i.0.0.be = phi uint [ %inc9, %then ], [ %inc, %endif ] ; [#uses=1] + br label %no_exit + + endif: ; preds = %no_exit + %inc = add uint %i.0.0, 1 ; [#uses=2] + %tmp.1 = setlt uint %inc, 100000 ; [#uses=1] + br bool %tmp.1, label %no_exit.backedge, label %return + + return: ; preds = %then, %endif + ret int %tmp.13 + } From lattner at cs.uiuc.edu Mon Apr 19 13:07:12 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Apr 19 13:07:12 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopUnswitch.cpp Message-ID: <200404191807.NAA27143@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: LoopUnswitch.cpp added (r1.1) --- Log message: Initial checkin of a simple loop unswitching pass. It still needs work, but it's a start, and seems to do it's basic job. --- Diffs of the changes: (+357 -0) Index: llvm/lib/Transforms/Scalar/LoopUnswitch.cpp diff -c /dev/null llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.1 *** /dev/null Mon Apr 19 13:07:12 2004 --- llvm/lib/Transforms/Scalar/LoopUnswitch.cpp Mon Apr 19 13:07:02 2004 *************** *** 0 **** --- 1,357 ---- + //===-- LoopUnswitch.cpp - Hoist loop-invariant conditionals in loop ------===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This pass transforms loops that contain branches on loop-invariant conditions + // to have multiple loops. For example, it turns the left into the right code: + // + // for (...) if (lic) + // A for (...) + // if (lic) A; B; C + // B else + // C for (...) + // A; C + // + // This can increase the size of the code exponentially (doubling it every time + // a loop is unswitched) so we only unswitch if the resultant code will be + // smaller than a threshold. + // + // This pass expects LICM to be run before it to hoist invariant conditions out + // of the loop, to make the unswitching opportunity obvious. + // + //===----------------------------------------------------------------------===// + + #define DEBUG_TYPE "loop-unswitch" + #include "llvm/Transforms/Scalar.h" + #include "llvm/Constants.h" + #include "llvm/Function.h" + #include "llvm/Instructions.h" + #include "llvm/Analysis/Dominators.h" + #include "llvm/Analysis/LoopInfo.h" + #include "llvm/Transforms/Utils/Cloning.h" + #include "llvm/Transforms/Utils/Local.h" + #include "Support/Debug.h" + #include "Support/Statistic.h" + using namespace llvm; + + namespace { + Statistic<> NumUnswitched("loop-unswitch", "Number of loops unswitched"); + + class LoopUnswitch : public FunctionPass { + LoopInfo *LI; // Loop information + DominatorSet *DS; + public: + virtual bool runOnFunction(Function &F); + bool visitLoop(Loop *L); + + /// This transformation requires natural loop information & requires that + /// loop preheaders be inserted into the CFG... + /// + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.addRequiredID(LoopSimplifyID); + //AU.addRequired(); + AU.addRequired(); + AU.addPreserved(); + } + + private: + void VersionLoop(Value *LIC, Loop *L); + BasicBlock *SplitBlock(BasicBlock *BB, bool SplitAtTop); + void RewriteLoopBodyWithConditionConstant(Loop *L, Value *LIC, bool Val); + }; + RegisterOpt X("loop-unswitch", "Unswitch loops"); + } + + FunctionPass *createLoopUnswitchPass() { return new LoopUnswitch(); } + + bool LoopUnswitch::runOnFunction(Function &F) { + bool Changed = false; + LI = &getAnalysis(); + DS = 0; //&getAnalysis(); + + // Transform all the top-level loops. Copy the loop list so that the child + // can update the loop tree if it needs to delete the loop. + std::vector SubLoops(LI->begin(), LI->end()); + for (unsigned i = 0, e = SubLoops.size(); i != e; ++i) + Changed |= visitLoop(SubLoops[i]); + + return Changed; + } + + bool LoopUnswitch::visitLoop(Loop *L) { + bool Changed = false; + + // Recurse through all subloops before we process this loop. Copy the loop + // list so that the child can update the loop tree if it needs to delete the + // loop. + std::vector SubLoops(L->begin(), L->end()); + for (unsigned i = 0, e = SubLoops.size(); i != e; ++i) + Changed |= visitLoop(SubLoops[i]); + + // Loop over all of the basic blocks in the loop. If we find an interior + // block that is branching on a loop-invariant condition, we can unswitch this + // loop. + for (Loop::block_iterator I = L->block_begin(), E = L->block_end(); + I != E; ++I) { + TerminatorInst *TI = (*I)->getTerminator(); + if (SwitchInst *SI = dyn_cast(TI)) { + if (!isa(SI) && L->isLoopInvariant(SI->getCondition())) + DEBUG(std::cerr << "Can't unswitching 'switch' loop %" + << L->getHeader()->getName() << ", cost = " + << L->getBlocks().size() << "\n" << **I); + } else if (BranchInst *BI = dyn_cast(TI)) + if (BI->isConditional() && !isa(BI->getCondition()) && + L->isLoopInvariant(BI->getCondition())) { + // Check to see if it would be profitable to unswitch this loop. + if (L->getBlocks().size() > 10) { + DEBUG(std::cerr << "NOT unswitching loop %" + << L->getHeader()->getName() << ", cost too high: " + << L->getBlocks().size() << "\n"); + } else { + // FIXME: check for profitability. + //std::cerr << "BEFORE:\n"; LI->dump(); + + VersionLoop(BI->getCondition(), L); + + //std::cerr << "AFTER:\n"; LI->dump(); + return true; + } + } + } + + return Changed; + } + + /// SplitBlock - Split the specified basic block into two pieces. If SplitAtTop + /// is false, this splits the block so the second half only has an unconditional + /// branch. If SplitAtTop is true, it makes it so the first half of the block + /// only has an unconditional branch in it. + /// + /// This method updates the LoopInfo for this function to correctly reflect the + /// CFG changes made. + BasicBlock *LoopUnswitch::SplitBlock(BasicBlock *BB, bool SplitAtTop) { + BasicBlock::iterator SplitPoint; + if (!SplitAtTop) + SplitPoint = BB->getTerminator(); + else { + SplitPoint = BB->begin(); + while (isa(SplitPoint)) ++SplitPoint; + } + + BasicBlock *New = BB->splitBasicBlock(SplitPoint, BB->getName()+".tail"); + // New now lives in whichever loop that BB used to. + if (Loop *L = LI->getLoopFor(BB)) + L->addBasicBlockToLoop(New, *LI); + return SplitAtTop ? BB : New; + } + + + // RemapInstruction - Convert the instruction operands from referencing the + // current values into those specified by ValueMap. + // + static inline void RemapInstruction(Instruction *I, + std::map &ValueMap) { + for (unsigned op = 0, E = I->getNumOperands(); op != E; ++op) { + Value *Op = I->getOperand(op); + std::map::iterator It = ValueMap.find(Op); + if (It != ValueMap.end()) Op = It->second; + I->setOperand(op, Op); + } + } + + /// CloneLoop - Recursively clone the specified loop and all of its children, + /// mapping the blocks with the specified map. + static Loop *CloneLoop(Loop *L, Loop *PL, std::map &VM, + LoopInfo *LI) { + Loop *New = new Loop(); + + if (PL) + PL->addChildLoop(New); + else + LI->addTopLevelLoop(New); + + // Add all of the blocks in L to the new loop. + for (Loop::block_iterator I = L->block_begin(), E = L->block_end(); + I != E; ++I) + if (LI->getLoopFor(*I) == L) + New->addBasicBlockToLoop(cast(VM[*I]), *LI); + + // Add all of the subloops to the new loop. + for (Loop::iterator I = L->begin(), E = L->end(); I != E; ++I) + CloneLoop(*I, New, VM, LI); + + return New; + } + + + /// InsertPHINodesForUsesOutsideLoop - If this instruction is used outside of + /// the specified loop, insert a PHI node in the appropriate exit block to merge + /// the values in the two different loop versions. + /// + /// Most values are not used outside of the loop they are defined in, so be + /// efficient for this case. + /// + static AllocaInst * + InsertPHINodesForUsesOutsideLoop(Instruction *OI, Instruction *NI, + DominatorSet &DS, Loop *OL, Loop *NL, + std::vector &OldExitBlocks, + std::map &ValueMap) { + assert(OI->getType() == NI->getType() && OI->getOpcode() == NI->getOpcode() && + "Hrm, should be mapping between identical instructions!"); + for (Value::use_iterator UI = OI->use_begin(), E = OI->use_end(); UI != E; + ++UI) + if (!OL->contains(cast(*UI)->getParent()) && + !NL->contains(cast(*UI)->getParent())) + goto UsedOutsideOfLoop; + return 0; + + UsedOutsideOfLoop: + // Okay, this instruction is used outside of the current loop. Insert a PHI + // nodes for the instruction merging the values together. + + // FIXME: For now we just spill the object to the stack, assuming that a + // subsequent mem2reg pass will clean up after us. This should be improved in + // two ways: + // 1. If there is only one exit block, trivially insert the PHI nodes + // 2. Once we update domfrontier, we should do the promotion after everything + // is stable again. + AllocaInst *Result = DemoteRegToStack(*OI); + + // Store to the stack location right after the new instruction. + BasicBlock::iterator InsertPoint = NI; + if (InvokeInst *II = dyn_cast(NI)) + InsertPoint = II->getNormalDest()->begin(); + else + ++InsertPoint; + while (isa(InsertPoint)) ++InsertPoint; + new StoreInst(NI, Result, InsertPoint); + return Result; + } + + + + /// VersionLoop - We determined that the loop is profitable to unswitch and + /// contains a branch on a loop invariant condition. Split it into loop + /// versions and test the condition outside of either loop. + void LoopUnswitch::VersionLoop(Value *LIC, Loop *L) { + Function *F = L->getHeader()->getParent(); + + DEBUG(std::cerr << "loop-unswitch: Unswitching loop %" + << L->getHeader()->getName() << " [" << L->getBlocks().size() + << " blocks] in Function " << F->getName() + << " on cond:" << *LIC << "\n"); + + std::vector LoopBlocks; + + // First step, split the preheader and exit blocks, and add these blocks to + // the LoopBlocks list. + BasicBlock *OrigPreheader = L->getLoopPreheader(); + LoopBlocks.push_back(SplitBlock(OrigPreheader, false)); + + // We want the loop to come after the preheader, but before the exit blocks. + LoopBlocks.insert(LoopBlocks.end(), L->block_begin(), L->block_end()); + + std::vector ExitBlocks; + L->getExitBlocks(ExitBlocks); + std::sort(ExitBlocks.begin(), ExitBlocks.end()); + ExitBlocks.erase(std::unique(ExitBlocks.begin(), ExitBlocks.end()), + ExitBlocks.end()); + for (unsigned i = 0, e = ExitBlocks.size(); i != e; ++i) + LoopBlocks.push_back(ExitBlocks[i] = SplitBlock(ExitBlocks[i], true)); + + // Next step, clone all of the basic blocks that make up the loop (including + // the loop preheader and exit blocks), keeping track of the mapping between + // the instructions and blocks. + std::vector NewBlocks; + NewBlocks.reserve(LoopBlocks.size()); + std::map ValueMap; + for (unsigned i = 0, e = LoopBlocks.size(); i != e; ++i) { + NewBlocks.push_back(CloneBasicBlock(LoopBlocks[i], ValueMap, ".us", F)); + ValueMap[LoopBlocks[i]] = NewBlocks.back(); // Keep the BB mapping. + } + + // Splice the newly inserted blocks into the function right before the + // original preheader. + F->getBasicBlockList().splice(LoopBlocks[0], F->getBasicBlockList(), + NewBlocks[0], F->end()); + + // Now we create the new Loop object for the versioned loop. + Loop *NewLoop = CloneLoop(L, L->getParentLoop(), ValueMap, LI); + if (Loop *Parent = L->getParentLoop()) { + // Make sure to add the cloned preheader and exit blocks to the parent loop + // as well. + Parent->addBasicBlockToLoop(NewBlocks[0], *LI); + for (unsigned i = 0, e = ExitBlocks.size(); i != e; ++i) + Parent->addBasicBlockToLoop(cast(ValueMap[ExitBlocks[i]]), + *LI); + } + + // Rewrite the code to refer to itself. + for (unsigned i = 0, e = NewBlocks.size(); i != e; ++i) + for (BasicBlock::iterator I = NewBlocks[i]->begin(), + E = NewBlocks[i]->end(); I != E; ++I) + RemapInstruction(I, ValueMap); + + // If the instructions are used outside of the loop, insert a PHI node in any + // exit blocks dominated by the instruction. + for (unsigned i = 0, e = NewBlocks.size(); i != e; ++i) + for (BasicBlock::iterator OI = LoopBlocks[i]->begin(), + E = LoopBlocks[i]->end(); OI != E; ++OI) + if (!OI->use_empty()) { + std::map::iterator OII = ValueMap.find(OI); + // The PHINode rewriting stuff can insert stores that are not in the + // mapping. Don't mess around with them. + if (OII != ValueMap.end()) { + Instruction *NI = cast(OII->second); + InsertPHINodesForUsesOutsideLoop(OI, NI, *DS, L, NewLoop, + ExitBlocks, ValueMap); + } + } + + // Rewrite the original preheader to select between versions of the loop. + assert(isa(OrigPreheader->getTerminator()) && + cast(OrigPreheader->getTerminator())->isUnconditional() && + OrigPreheader->getTerminator()->getSuccessor(0) == LoopBlocks[0] && + "Preheader splitting did not work correctly!"); + // Remove the unconditional branch to LoopBlocks[0]. + OrigPreheader->getInstList().pop_back(); + + // Insert a conditional branch on LIC to the two preheaders. The original + // code is the true version and the new code is the false version. + new BranchInst(LoopBlocks[0], NewBlocks[0], LIC, OrigPreheader); + + // Now we rewrite the original code to know that the condition is true and the + // new code to know that the condition is false. + RewriteLoopBodyWithConditionConstant(L, LIC, true); + RewriteLoopBodyWithConditionConstant(NewLoop, LIC, false); + ++NumUnswitched; + + // Try to unswitch each of our new loops now! + visitLoop(L); + visitLoop(NewLoop); + } + + // RewriteLoopBodyWithConditionConstant - We know that the boolean value LIC has + // the value specified by Val in the specified loop. Rewrite any uses of LIC or + // of properties correlated to it. + void LoopUnswitch::RewriteLoopBodyWithConditionConstant(Loop *L, Value *LIC, + bool Val) { + // FIXME: Support correlated properties, like: + // for (...) + // if (li1 < li2) + // ... + // if (li1 > li2) + // ... + ConstantBool *BoolVal = ConstantBool::get(Val); + + std::vector Users(LIC->use_begin(), LIC->use_end()); + for (unsigned i = 0, e = Users.size(); i != e; ++i) + if (Instruction *U = dyn_cast(Users[i])) + if (L->contains(U->getParent())) + U->replaceUsesOfWith(LIC, BoolVal); + } From gaeke at cs.uiuc.edu Mon Apr 19 14:10:10 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Mon Apr 19 14:10:10 2004 Subject: [llvm-commits] CVS: llvm/utils/fpcmp/fpcmp.cpp Message-ID: <200404191909.OAA11083@zion.cs.uiuc.edu> Changes in directory llvm/utils/fpcmp: fpcmp.cpp updated: 1.2 -> 1.3 --- Log message: Fix typo. --- Diffs of the changes: (+1 -1) Index: llvm/utils/fpcmp/fpcmp.cpp diff -u llvm/utils/fpcmp/fpcmp.cpp:1.2 llvm/utils/fpcmp/fpcmp.cpp:1.3 --- llvm/utils/fpcmp/fpcmp.cpp:1.2 Tue Apr 13 16:48:43 2004 +++ llvm/utils/fpcmp/fpcmp.cpp Mon Apr 19 14:09:24 2004 @@ -92,7 +92,7 @@ if (Diff > RelTolerance) { std::cerr << "Compared: " << V1 << " and " << V2 << ": diff = " << Diff << "\n"; - std::cerr << "Out of tolerence: rel/abs: " << RelTolerance + std::cerr << "Out of tolerance: rel/abs: " << RelTolerance << "/" << AbsTolerance << "\n"; exit(1); } From gaeke at cs.uiuc.edu Mon Apr 19 14:13:02 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Mon Apr 19 14:13:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/SparcV9RegInfo.cpp Message-ID: <200404191912.OAA20010@seraph.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9: SparcV9RegInfo.cpp updated: 1.122 -> 1.123 --- Log message: Make it legal to request a load or store of %fsr. --- Diffs of the changes: (+2 -0) Index: llvm/lib/Target/SparcV9/SparcV9RegInfo.cpp diff -u llvm/lib/Target/SparcV9/SparcV9RegInfo.cpp:1.122 llvm/lib/Target/SparcV9/SparcV9RegInfo.cpp:1.123 --- llvm/lib/Target/SparcV9/SparcV9RegInfo.cpp:1.122 Mon Apr 19 13:53:43 2004 +++ llvm/lib/Target/SparcV9/SparcV9RegInfo.cpp Mon Apr 19 14:12:12 2004 @@ -808,6 +808,7 @@ cpReg2MemMI(mvec, scratchReg, PtrReg, Offset, IntRegType); return; + case SpecialRegType: // used only for %fsr itself. case FloatCCRegType: { unsigned fsrReg = getUnifiedRegNum(SparcV9RegInfo::SpecialRegClassID, SparcV9SpecialRegClass::fsr); @@ -898,6 +899,7 @@ SparcV9IntCCRegClass::ccr), MachineOperand::Def)); break; + case SpecialRegType: // used only for %fsr itself case FloatCCRegType: { unsigned fsrRegNum = getUnifiedRegNum(SparcV9RegInfo::SpecialRegClassID, SparcV9SpecialRegClass::fsr); From lattner at cs.uiuc.edu Tue Apr 20 11:44:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 20 11:44:01 2004 Subject: [llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp Interpreter.h Message-ID: <200404201643.LAA15435@zion.cs.uiuc.edu> Changes in directory llvm/lib/ExecutionEngine/Interpreter: Execution.cpp updated: 1.125 -> 1.126 Interpreter.h updated: 1.63 -> 1.64 --- Log message: Add support for the select instruction --- Diffs of the changes: (+24 -2) Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.125 llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.126 --- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.125 Fri Mar 12 18:23:29 2004 +++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp Tue Apr 20 11:43:21 2004 @@ -66,7 +66,9 @@ const Type *Ty); static GenericValue executeShrInst(GenericValue Src1, GenericValue Src2, const Type *Ty); - +static GenericValue executeSelectInst(GenericValue Src1, GenericValue Src2, + GenericValue Src3); + GenericValue Interpreter::getConstantExprValue (ConstantExpr *CE, ExecutionContext &SF) { switch (CE->getOpcode()) { @@ -139,7 +141,10 @@ return executeShrInst(getOperandValue(CE->getOperand(0), SF), getOperandValue(CE->getOperand(1), SF), CE->getOperand(0)->getType()); - + case Instruction::Select: + return executeSelectInst(getOperandValue(CE->getOperand(0), SF), + getOperandValue(CE->getOperand(1), SF), + getOperandValue(CE->getOperand(2), SF)); default: std::cerr << "Unhandled ConstantExpr: " << CE << "\n"; abort(); @@ -517,6 +522,21 @@ SetValue(&I, R, SF); } + +static GenericValue executeSelectInst(GenericValue Src1, GenericValue Src2, + GenericValue Src3) { + return Src1.BoolVal ? Src2 : Src3; +} + +void Interpreter::visitSelectInst(SelectInst &I) { + ExecutionContext &SF = ECStack.back(); + GenericValue Src1 = getOperandValue(I.getOperand(0), SF); + GenericValue Src2 = getOperandValue(I.getOperand(1), SF); + GenericValue Src3 = getOperandValue(I.getOperand(2), SF); + GenericValue R = executeSelectInst(Src1, Src2, Src3); + SetValue(&I, R, SF); +} + //===----------------------------------------------------------------------===// // Terminator Instruction Implementations Index: llvm/lib/ExecutionEngine/Interpreter/Interpreter.h diff -u llvm/lib/ExecutionEngine/Interpreter/Interpreter.h:1.63 llvm/lib/ExecutionEngine/Interpreter/Interpreter.h:1.64 --- llvm/lib/ExecutionEngine/Interpreter/Interpreter.h:1.63 Sun Apr 4 14:47:06 2004 +++ llvm/lib/ExecutionEngine/Interpreter/Interpreter.h Tue Apr 20 11:43:21 2004 @@ -137,6 +137,8 @@ void visitGetElementPtrInst(GetElementPtrInst &I); void visitPHINode(PHINode &PN) { assert(0 && "PHI nodes already handled!"); } void visitCastInst(CastInst &I); + void visitSelectInst(SelectInst &I); + void visitCallSite(CallSite CS); void visitCallInst(CallInst &I) { visitCallSite (CallSite (&I)); } From gaeke at cs.uiuc.edu Tue Apr 20 13:19:00 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue Apr 20 13:19:00 2004 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200404201818.NAA27995@kain.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.165 -> 1.166 --- Log message: Add some PRs which were fixed, but not previously mentioned in the rel. notes. --- Diffs of the changes: (+14 -3) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.165 llvm/docs/ReleaseNotes.html:1.166 --- llvm/docs/ReleaseNotes.html:1.165 Sun Apr 18 22:01:01 2004 +++ llvm/docs/ReleaseNotes.html Tue Apr 20 13:18:46 2004 @@ -88,7 +88,8 @@
  1. The LLVM select instruction is -now fully implemented and supported by all targets.
  2. +now fully implemented and supported by all targets, including +interpreter support.
  3. Bugpoint can now narrow down code-generation bugs to a loop nest, where before it could only narrow them down to a function being miscompiled.
@@ -126,7 +127,7 @@
    -
  1. +
  2. Minor configure bugs with -disable/enable-povray and -disable-spec
@@ -211,6 +212,16 @@ + +
+In this release, the following portability problems were fixed: +
+ +
    +
  1. warnings compiling Stacker compiler on Mac OS X
  2. +
  3. getObjectType doesn't understand abbreviated names in headers
  4. +
+
Known Problems @@ -600,7 +611,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
- Last modified: $Date: 2004/04/19 03:01:01 $ + Last modified: $Date: 2004/04/20 18:18:46 $ From gaeke at cs.uiuc.edu Tue Apr 20 15:14:03 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue Apr 20 15:14:03 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/SparcV9RegInfo.cpp Message-ID: <200404202013.PAA03771@kain.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9: SparcV9RegInfo.cpp updated: 1.123 -> 1.124 --- Log message: Make it legal to ask for the type of a specialreg --- Diffs of the changes: (+2 -0) Index: llvm/lib/Target/SparcV9/SparcV9RegInfo.cpp diff -u llvm/lib/Target/SparcV9/SparcV9RegInfo.cpp:1.123 llvm/lib/Target/SparcV9/SparcV9RegInfo.cpp:1.124 --- llvm/lib/Target/SparcV9/SparcV9RegInfo.cpp:1.123 Mon Apr 19 14:12:12 2004 +++ llvm/lib/Target/SparcV9/SparcV9RegInfo.cpp Tue Apr 20 15:12:57 2004 @@ -260,6 +260,8 @@ return FloatCCRegType; else if (unifiedRegNum < (64+32+4+2)) return IntCCRegType; + else if (unifiedRegNum < (64+32+4+2+1)) + return SpecialRegType; else assert(0 && "Invalid unified register number in getRegType"); return 0; From lattner at cs.uiuc.edu Tue Apr 20 15:15:05 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 20 15:15:05 2004 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/Inline/2004-04-20-InlineLinkOnce.llx Message-ID: <200404202015.PAA24925@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/Inline: 2004-04-20-InlineLinkOnce.llx added (r1.1) --- Log message: New testcase, distilled from PR324: http://llvm.cs.uiuc.edu/PR324 --- Diffs of the changes: (+12 -0) Index: llvm/test/Regression/Transforms/Inline/2004-04-20-InlineLinkOnce.llx diff -c /dev/null llvm/test/Regression/Transforms/Inline/2004-04-20-InlineLinkOnce.llx:1.1 *** /dev/null Tue Apr 20 15:15:11 2004 --- llvm/test/Regression/Transforms/Inline/2004-04-20-InlineLinkOnce.llx Tue Apr 20 15:15:01 2004 *************** *** 0 **** --- 1,12 ---- + ; RUN: llvm-as < %s | opt -inline -prune-eh -disable-output + + implementation + + linkonce void %caller() { + call void %callee() + ret void + } + + linkonce void %callee() { + ret void + } From lattner at cs.uiuc.edu Tue Apr 20 15:21:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 20 15:21:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/Inliner.cpp Message-ID: <200404202021.PAA25725@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: Inliner.cpp updated: 1.9 -> 1.10 --- Log message: Fix PR324: http://llvm.cs.uiuc.edu/PR324 and testcase: Inline/2004-04-20-InlineLinkOnce.llx --- Diffs of the changes: (+7 -3) Index: llvm/lib/Transforms/IPO/Inliner.cpp diff -u llvm/lib/Transforms/IPO/Inliner.cpp:1.9 llvm/lib/Transforms/IPO/Inliner.cpp:1.10 --- llvm/lib/Transforms/IPO/Inliner.cpp:1.9 Mon Apr 12 00:37:29 2004 +++ llvm/lib/Transforms/IPO/Inliner.cpp Tue Apr 20 15:20:59 2004 @@ -120,13 +120,17 @@ (Callee->hasInternalLinkage() || Callee->hasLinkOnceLinkage())) { DEBUG(std::cerr << " -> Deleting dead function: " << Callee->getName() << "\n"); - std::set::iterator I = SCCFunctions.find(Callee); - if (I != SCCFunctions.end()) // Remove function from this SCC. - SCCFunctions.erase(I); + SCCFunctions.erase(Callee); // Remove function from this SCC. // Remove any call graph edges from the callee to its callees. while (CalleeNode->begin() != CalleeNode->end()) CalleeNode->removeCallEdgeTo(*(CalleeNode->end()-1)); + + // If the function has external linkage (basically if it's a + // linkonce function) remove the edge from the external node to the + // callee node. + if (!Callee->hasInternalLinkage()) + CG.getExternalCallingNode()->removeCallEdgeTo(CalleeNode); // Removing the node for callee from the call graph and delete it. delete CG.removeFunctionFromModule(CalleeNode); From lattner at cs.uiuc.edu Tue Apr 20 15:26:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 20 15:26:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopUnroll.cpp Message-ID: <200404202026.PAA26829@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: LoopUnroll.cpp updated: 1.8 -> 1.9 --- Log message: Fix PR325: http://llvm.cs.uiuc.edu/PR325 --- Diffs of the changes: (+1 -1) Index: llvm/lib/Transforms/Scalar/LoopUnroll.cpp diff -u llvm/lib/Transforms/Scalar/LoopUnroll.cpp:1.8 llvm/lib/Transforms/Scalar/LoopUnroll.cpp:1.9 --- llvm/lib/Transforms/Scalar/LoopUnroll.cpp:1.8 Sun Apr 18 22:01:23 2004 +++ llvm/lib/Transforms/Scalar/LoopUnroll.cpp Tue Apr 20 15:26:03 2004 @@ -132,7 +132,7 @@ if (!TripCountC) return Changed; // Must have constant trip count! unsigned TripCount = TripCountC->getRawValue(); - if (TripCount != TripCountC->getRawValue()) + if (TripCount != TripCountC->getRawValue() || TripCount == 0) return Changed; // More than 2^32 iterations??? unsigned LoopSize = ApproximateLoopSize(L); From lattner at cs.uiuc.edu Tue Apr 20 16:31:17 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 20 16:31:17 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/CallGraphSCCPass.h Message-ID: <200404202130.QAA18289@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: CallGraphSCCPass.h updated: 1.3 -> 1.4 --- Log message: Add the ability for SCC passes to initialize and finalize themselves --- Diffs of the changes: (+13 -0) Index: llvm/include/llvm/CallGraphSCCPass.h diff -u llvm/include/llvm/CallGraphSCCPass.h:1.3 llvm/include/llvm/CallGraphSCCPass.h:1.4 --- llvm/include/llvm/CallGraphSCCPass.h:1.3 Tue Nov 11 16:41:29 2003 +++ llvm/include/llvm/CallGraphSCCPass.h Tue Apr 20 16:29:57 2004 @@ -26,15 +26,28 @@ namespace llvm { class CallGraphNode; +class Module; struct CallGraphSCCPass : public Pass { + /// doInitialization - This method is called before the SCC's of the program + /// has been processed, allowing the pass to do initialization as necessary. + virtual bool doInitialization(Module &M) { + return false; + } + /// runOnSCC - This method should be implemented by the subclass to perform /// whatever action is necessary for the specified SCC. Note that /// non-recursive (or only self-recursive) functions will have an SCC size of /// 1, where recursive portions of the call graph will have SCC size > 1. /// virtual bool runOnSCC(const std::vector &SCC) = 0; + + /// doFinalization - This method is called after the SCC's of the program has + /// been processed, allowing the pass to do final cleanup as necessary. + virtual bool doFinalization(Module &M) { + return false; + } /// run - Run this pass, returning true if a modification was made to the /// module argument. This is implemented in terms of the runOnSCC method. From lattner at cs.uiuc.edu Tue Apr 20 16:31:19 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 20 16:31:19 2004 Subject: [llvm-commits] CVS: llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp Message-ID: <200404202130.QAA18296@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/IPA: CallGraphSCCPass.cpp updated: 1.5 -> 1.6 --- Log message: Add the ability for SCC passes to initialize and finalize themselves --- Diffs of the changes: (+3 -6) Index: llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp diff -u llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp:1.5 llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp:1.6 --- llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp:1.5 Tue Nov 11 16:41:32 2003 +++ llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp Tue Apr 20 16:30:06 2004 @@ -18,8 +18,7 @@ #include "llvm/CallGraphSCCPass.h" #include "llvm/Analysis/CallGraph.h" #include "Support/SCCIterator.h" - -namespace llvm { +using namespace llvm; /// getAnalysisUsage - For this class, we declare that we require and preserve /// the call graph. If the derived class implements this method, it should @@ -31,11 +30,9 @@ bool CallGraphSCCPass::run(Module &M) { CallGraph &CG = getAnalysis(); - bool Changed = false; + bool Changed = doInitialization(M); for (scc_iterator I = scc_begin(&CG), E = scc_end(&CG); I != E; ++I) Changed = runOnSCC(*I); - return Changed; + return Changed | doFinalization(M); } - -} // End llvm namespace From lattner at cs.uiuc.edu Tue Apr 20 16:52:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 20 16:52:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/CallGraphSCCPass.h Message-ID: <200404202152.QAA19933@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: CallGraphSCCPass.h updated: 1.4 -> 1.5 --- Log message: Change it to take a callgraph, from which we can get a module --- Diffs of the changes: (+3 -3) Index: llvm/include/llvm/CallGraphSCCPass.h diff -u llvm/include/llvm/CallGraphSCCPass.h:1.4 llvm/include/llvm/CallGraphSCCPass.h:1.5 --- llvm/include/llvm/CallGraphSCCPass.h:1.4 Tue Apr 20 16:29:57 2004 +++ llvm/include/llvm/CallGraphSCCPass.h Tue Apr 20 16:52:07 2004 @@ -26,13 +26,13 @@ namespace llvm { class CallGraphNode; -class Module; +class CallGraph; struct CallGraphSCCPass : public Pass { /// doInitialization - This method is called before the SCC's of the program /// has been processed, allowing the pass to do initialization as necessary. - virtual bool doInitialization(Module &M) { + virtual bool doInitialization(CallGraph &CG) { return false; } @@ -45,7 +45,7 @@ /// doFinalization - This method is called after the SCC's of the program has /// been processed, allowing the pass to do final cleanup as necessary. - virtual bool doFinalization(Module &M) { + virtual bool doFinalization(CallGraph &CG) { return false; } From lattner at cs.uiuc.edu Tue Apr 20 16:52:03 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 20 16:52:03 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/CallGraph.h Message-ID: <200404202152.QAA19943@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: CallGraph.h updated: 1.34 -> 1.35 --- Log message: Allow getting the module from a call graph --- Diffs of the changes: (+4 -0) Index: llvm/include/llvm/Analysis/CallGraph.h diff -u llvm/include/llvm/Analysis/CallGraph.h:1.34 llvm/include/llvm/Analysis/CallGraph.h:1.35 --- llvm/include/llvm/Analysis/CallGraph.h:1.34 Mon Apr 12 00:36:22 2004 +++ llvm/include/llvm/Analysis/CallGraph.h Tue Apr 20 16:52:12 2004 @@ -100,6 +100,10 @@ CallGraphNode *getRoot() { return Root; } const CallGraphNode *getRoot() const { return Root; } + /// getModule - Return the module the call graph corresponds to. + /// + Module &getModule() const { return *Mod; } + inline iterator begin() { return FunctionMap.begin(); } inline iterator end() { return FunctionMap.end(); } inline const_iterator begin() const { return FunctionMap.begin(); } From lattner at cs.uiuc.edu Tue Apr 20 16:53:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 20 16:53:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp Message-ID: <200404202152.QAA20229@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/IPA: CallGraphSCCPass.cpp updated: 1.6 -> 1.7 --- Log message: Pass the callgraph not the module --- Diffs of the changes: (+2 -2) Index: llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp diff -u llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp:1.6 llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp:1.7 --- llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp:1.6 Tue Apr 20 16:30:06 2004 +++ llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp Tue Apr 20 16:52:26 2004 @@ -30,9 +30,9 @@ bool CallGraphSCCPass::run(Module &M) { CallGraph &CG = getAnalysis(); - bool Changed = doInitialization(M); + bool Changed = doInitialization(CG); for (scc_iterator I = scc_begin(&CG), E = scc_end(&CG); I != E; ++I) Changed = runOnSCC(*I); - return Changed | doFinalization(M); + return Changed | doFinalization(CG); } From lattner at cs.uiuc.edu Tue Apr 20 17:07:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 20 17:07:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/Inliner.cpp Inliner.h Message-ID: <200404202207.RAA23500@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: Inliner.cpp updated: 1.10 -> 1.11 Inliner.h updated: 1.5 -> 1.6 --- Log message: REALLY fix PR324: http://llvm.cs.uiuc.edu/PR324 : don't delete linkonce functions until after the SCC traversal is done, which avoids invalidating iterators in the SCC traversal routines --- Diffs of the changes: (+33 -7) Index: llvm/lib/Transforms/IPO/Inliner.cpp diff -u llvm/lib/Transforms/IPO/Inliner.cpp:1.10 llvm/lib/Transforms/IPO/Inliner.cpp:1.11 --- llvm/lib/Transforms/IPO/Inliner.cpp:1.10 Tue Apr 20 15:20:59 2004 +++ llvm/lib/Transforms/IPO/Inliner.cpp Tue Apr 20 17:06:53 2004 @@ -117,7 +117,7 @@ // If we inlined the last possible call site to the function, // delete the function body now. if (Callee->use_empty() && Callee != Caller && - (Callee->hasInternalLinkage() || Callee->hasLinkOnceLinkage())) { + Callee->hasInternalLinkage()) { DEBUG(std::cerr << " -> Deleting dead function: " << Callee->getName() << "\n"); SCCFunctions.erase(Callee); // Remove function from this SCC. @@ -126,12 +126,6 @@ while (CalleeNode->begin() != CalleeNode->end()) CalleeNode->removeCallEdgeTo(*(CalleeNode->end()-1)); - // If the function has external linkage (basically if it's a - // linkonce function) remove the edge from the external node to the - // callee node. - if (!Callee->hasInternalLinkage()) - CG.getExternalCallingNode()->removeCallEdgeTo(CalleeNode); - // Removing the node for callee from the call graph and delete it. delete CG.removeFunctionFromModule(CalleeNode); ++NumDeleted; @@ -145,3 +139,30 @@ return Changed; } +// doFinalization - Remove now-dead linkonce functions at the end of +// processing to avoid breaking the SCC traversal. +bool Inliner::doFinalization(CallGraph &CG) { + bool Changed = false; + for (CallGraph::iterator I = CG.begin(), E = CG.end(); I != E; ) { + CallGraphNode *CGN = (++I)->second; + Function *F = CGN ? CGN->getFunction() : 0; + if (F && (F->hasLinkOnceLinkage() || F->hasInternalLinkage()) && + F->use_empty()) { + // Remove any call graph edges from the callee to its callees. + while (CGN->begin() != CGN->end()) + CGN->removeCallEdgeTo(*(CGN->end()-1)); + + // If the function has external linkage (basically if it's a + // linkonce function) remove the edge from the external node to the + // callee node. + if (!F->hasInternalLinkage()) + CG.getExternalCallingNode()->removeCallEdgeTo(CGN); + + // Removing the node for callee from the call graph and delete it. + delete CG.removeFunctionFromModule(CGN); + ++NumDeleted; + Changed = true; + } + } + return Changed; +} Index: llvm/lib/Transforms/IPO/Inliner.h diff -u llvm/lib/Transforms/IPO/Inliner.h:1.5 llvm/lib/Transforms/IPO/Inliner.h:1.6 --- llvm/lib/Transforms/IPO/Inliner.h:1.5 Thu Apr 8 01:34:31 2004 +++ llvm/lib/Transforms/IPO/Inliner.h Tue Apr 20 17:06:53 2004 @@ -35,6 +35,11 @@ // Pass class. virtual bool runOnSCC(const std::vector &SCC); + // doFinalization - Remove now-dead linkonce functions at the end of + // processing to avoid breaking the SCC traversal. + virtual bool doFinalization(CallGraph &CG); + + /// This method returns the value specified by the -inline-threshold value, /// specified on the command line. This is typically not directly needed. /// From lattner at cs.uiuc.edu Wed Apr 21 09:24:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 21 09:24:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/Inliner.cpp Message-ID: <200404211423.JAA00927@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: Inliner.cpp updated: 1.11 -> 1.12 --- Log message: Fix typeo --- Diffs of the changes: (+1 -1) Index: llvm/lib/Transforms/IPO/Inliner.cpp diff -u llvm/lib/Transforms/IPO/Inliner.cpp:1.11 llvm/lib/Transforms/IPO/Inliner.cpp:1.12 --- llvm/lib/Transforms/IPO/Inliner.cpp:1.11 Tue Apr 20 17:06:53 2004 +++ llvm/lib/Transforms/IPO/Inliner.cpp Wed Apr 21 09:23:18 2004 @@ -144,7 +144,7 @@ bool Inliner::doFinalization(CallGraph &CG) { bool Changed = false; for (CallGraph::iterator I = CG.begin(), E = CG.end(); I != E; ) { - CallGraphNode *CGN = (++I)->second; + CallGraphNode *CGN = (I++)->second; Function *F = CGN ? CGN->getFunction() : 0; if (F && (F->hasLinkOnceLinkage() || F->hasInternalLinkage()) && F->use_empty()) { From alkis at cs.uiuc.edu Wed Apr 21 11:11:01 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed Apr 21 11:11:01 2004 Subject: [llvm-commits] CVS: llvm/include/Support/BitSetVector.h Message-ID: <200404211610.LAA13004@zion.cs.uiuc.edu> Changes in directory llvm/include/Support: BitSetVector.h updated: 1.11 -> 1.12 --- Log message: Declare iterator as public since it is defined as such (gcc-3.4 fix) --- Diffs of the changes: (+1 -1) Index: llvm/include/Support/BitSetVector.h diff -u llvm/include/Support/BitSetVector.h:1.11 llvm/include/Support/BitSetVector.h:1.12 --- llvm/include/Support/BitSetVector.h:1.11 Tue Nov 11 16:41:29 2003 +++ llvm/include/Support/BitSetVector.h Wed Apr 21 11:10:40 2004 @@ -38,7 +38,6 @@ // Types used internal to the representation typedef std::bitset bitword; typedef bitword::reference reference; - class iterator; // Data used in the representation std::vector bitsetVec; @@ -67,6 +66,7 @@ BitSetVector(); // do not implement! public: + class iterator; /// /// Constructor: create a set of the maximum size maxSetSize. /// The set is initialized to empty. From alkis at cs.uiuc.edu Wed Apr 21 11:12:01 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed Apr 21 11:12:01 2004 Subject: [llvm-commits] CVS: llvm/tools/llvm-nm/llvm-nm.cpp Message-ID: <200404211611.LAA13117@zion.cs.uiuc.edu> Changes in directory llvm/tools/llvm-nm: llvm-nm.cpp updated: 1.12 -> 1.13 --- Log message: Include cerrno (gcc-3.4 fix) --- Diffs of the changes: (+1 -0) Index: llvm/tools/llvm-nm/llvm-nm.cpp diff -u llvm/tools/llvm-nm/llvm-nm.cpp:1.12 llvm/tools/llvm-nm/llvm-nm.cpp:1.13 --- llvm/tools/llvm-nm/llvm-nm.cpp:1.12 Thu Feb 19 14:32:12 2004 +++ llvm/tools/llvm-nm/llvm-nm.cpp Wed Apr 21 11:11:40 2004 @@ -22,6 +22,7 @@ #include "Support/FileUtilities.h" #include "Support/Signals.h" #include +#include #include using namespace llvm; From alkis at cs.uiuc.edu Wed Apr 21 11:12:05 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed Apr 21 11:12:05 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/Local.cpp Message-ID: <200404211611.LAA13110@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: Local.cpp updated: 1.21 -> 1.22 --- Log message: Include cerrno (gcc-3.4 fix) --- Diffs of the changes: (+1 -0) Index: llvm/lib/Transforms/Utils/Local.cpp diff -u llvm/lib/Transforms/Utils/Local.cpp:1.21 llvm/lib/Transforms/Utils/Local.cpp:1.22 --- llvm/lib/Transforms/Utils/Local.cpp:1.21 Fri Apr 16 17:35:33 2004 +++ llvm/lib/Transforms/Utils/Local.cpp Wed Apr 21 11:11:40 2004 @@ -15,6 +15,7 @@ #include "llvm/Transforms/Utils/Local.h" #include "llvm/Constants.h" #include "llvm/Instructions.h" +#include #include using namespace llvm; From alkis at cs.uiuc.edu Wed Apr 21 11:33:01 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed Apr 21 11:33:01 2004 Subject: [llvm-commits] CVS: llvm-java/autoconf/configure.ac Message-ID: <200404211632.LAA18076@zion.cs.uiuc.edu> Changes in directory llvm-java/autoconf: configure.ac updated: 1.4 -> 1.5 --- Log message: Quote arguments --- Diffs of the changes: (+6 -4) Index: llvm-java/autoconf/configure.ac diff -u llvm-java/autoconf/configure.ac:1.4 llvm-java/autoconf/configure.ac:1.5 --- llvm-java/autoconf/configure.ac:1.4 Thu Apr 15 23:37:54 2004 +++ llvm-java/autoconf/configure.ac Wed Apr 21 11:32:31 2004 @@ -54,14 +54,16 @@ dnl ************************************************************************** dnl Location of LLVM source code -AC_ARG_WITH(llvmsrc, - AC_HELP_STRING(--with-llvmsrc,Location of LLVM Source Code), +AC_ARG_WITH([llvmsrc], + AC_HELP_STRING([--with-llvmsrc], + [Location of LLVM Source Code]), AC_SUBST(LLVM_SRC,$withval), AC_SUBST(LLVM_SRC,`cd ${srcdir}/../..; pwd`)) dnl Location of LLVM object code -AC_ARG_WITH(llvmobj, - AC_HELP_STRING(--with-llvmobj,Location of LLVM Object Code), +AC_ARG_WITH([llvmobj], + AC_HELP_STRING([--with-llvmobj], + [Location of LLVM Object Code]), AC_SUBST(LLVM_OBJ,$withval), AC_SUBST(LLVM_OBJ,`cd ../..; pwd`)) From alkis at cs.uiuc.edu Wed Apr 21 11:34:02 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed Apr 21 11:34:02 2004 Subject: [llvm-commits] CVS: llvm-java/Makefile.rules Makefile.common.in Message-ID: <200404211633.LAA18155@zion.cs.uiuc.edu> Changes in directory llvm-java: Makefile.rules added (r1.1) Makefile.common.in updated: 1.1 -> 1.2 --- Log message: Add rule to compile java subtree --- Diffs of the changes: (+27 -0) Index: llvm-java/Makefile.rules diff -c /dev/null llvm-java/Makefile.rules:1.1 *** /dev/null Wed Apr 21 11:33:58 2004 --- llvm-java/Makefile.rules Wed Apr 21 11:33:48 2004 *************** *** 0 **** --- 1,16 ---- + #===-- Makefile.rules - Common make rules for LLVM -------*- makefile -*--==== + # + # The LLVM Compiler Infrastructure + # + # This file was developed by the LLVM research group and is distributed under + # the University of Illinois Open Source License. See LICENSE.TXT for details. + # + ##===----------------------------------------------------------------------===## + + ifdef BUILD_JAVA_SOURCE + all:: .class-stamp + .class-stamp: $(shell find . -name '*.java') + $(JIKES) --bootclasspath $(BOOTCLASSPATH) $? + touch .class-stamp + endif + Index: llvm-java/Makefile.common.in diff -u llvm-java/Makefile.common.in:1.1 llvm-java/Makefile.common.in:1.2 --- llvm-java/Makefile.common.in:1.1 Thu Apr 15 16:00:49 2004 +++ llvm-java/Makefile.common.in Wed Apr 21 11:33:48 2004 @@ -25,6 +25,17 @@ BUILD_SRC_DIR := $(subst //,/,$(BUILD_SRC_ROOT)/$(patsubst $(BUILD_OBJ_ROOT)%,%, $(BUILD_OBJ_DIR))) # +# Additional utilities +# +JIKES=@JIKES@ + +# # Include LLVM's build rules. # include $(LLVM_SRC_ROOT)/Makefile.rules + +# +# Include local build rules. +# +include $(LEVEL)/Makefile.rules + From alkis at cs.uiuc.edu Wed Apr 21 11:34:05 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed Apr 21 11:34:05 2004 Subject: [llvm-commits] CVS: llvm-java/test/ClassFile/ Message-ID: <200404211634.LAA18179@zion.cs.uiuc.edu> Changes in directory llvm-java/test/ClassFile: --- Log message: Directory /home/vadve/shared/PublicCVS/llvm-java/test/ClassFile added to the repository --- Diffs of the changes: (+0 -0) From alkis at cs.uiuc.edu Wed Apr 21 11:36:02 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed Apr 21 11:36:02 2004 Subject: [llvm-commits] CVS: llvm-java/test/ClassFile/Hello.java Simple.java Message-ID: <200404211636.LAA18261@zion.cs.uiuc.edu> Changes in directory llvm-java/test/ClassFile: Hello.java added (r1.1) Simple.java added (r1.1) --- Log message: Add simple test cases --- Diffs of the changes: (+15 -0) Index: llvm-java/test/ClassFile/Hello.java diff -c /dev/null llvm-java/test/ClassFile/Hello.java:1.1 *** /dev/null Wed Apr 21 11:36:14 2004 --- llvm-java/test/ClassFile/Hello.java Wed Apr 21 11:36:04 2004 *************** *** 0 **** --- 1,8 ---- + public class Hello + { + public static int main(String[] args) { + System.out.println("Hello world"); + return 0; + } + } + Index: llvm-java/test/ClassFile/Simple.java diff -c /dev/null llvm-java/test/ClassFile/Simple.java:1.1 *** /dev/null Wed Apr 21 11:36:14 2004 --- llvm-java/test/ClassFile/Simple.java Wed Apr 21 11:36:04 2004 *************** *** 0 **** --- 1,7 ---- + public class Simple + { + public static int main(String[] args) { + return 0; + } + } + From gaeke at cs.uiuc.edu Wed Apr 21 12:55:05 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Apr 21 12:55:05 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/SparcV9RegInfo.cpp Message-ID: <200404211754.MAA24995@kain.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9: SparcV9RegInfo.cpp updated: 1.124 -> 1.125 --- Log message: Make SparcV9RegInfo::getRegType() return the right answer for registers of IntCC, FloatCC, and Special types. Make SparcV9RegInfo::getRegClassIDOfRegType() return the right answer if you ask for the class corresponding to SpecialRegType. --- Diffs of the changes: (+6 -5) Index: llvm/lib/Target/SparcV9/SparcV9RegInfo.cpp diff -u llvm/lib/Target/SparcV9/SparcV9RegInfo.cpp:1.124 llvm/lib/Target/SparcV9/SparcV9RegInfo.cpp:1.125 --- llvm/lib/Target/SparcV9/SparcV9RegInfo.cpp:1.124 Tue Apr 20 15:12:57 2004 +++ llvm/lib/Target/SparcV9/SparcV9RegInfo.cpp Wed Apr 21 12:53:58 2004 @@ -256,11 +256,11 @@ return FPSingleRegType; else if (unifiedRegNum < (64 + 32)) return FPDoubleRegType; - else if (unifiedRegNum < (64+32+4)) - return FloatCCRegType; - else if (unifiedRegNum < (64+32+4+2)) - return IntCCRegType; - else if (unifiedRegNum < (64+32+4+2+1)) + else if (unifiedRegNum < (64+32+3)) + return IntCCRegType; + else if (unifiedRegNum < (64+32+3+4)) + return FloatCCRegType; + else if (unifiedRegNum < (64+32+3+4+1)) return SpecialRegType; else assert(0 && "Invalid unified register number in getRegType"); @@ -300,6 +300,7 @@ case FPDoubleRegType: return FloatRegClassID; case IntCCRegType: return IntCCRegClassID; case FloatCCRegType: return FloatCCRegClassID; + case SpecialRegType: return SpecialRegClassID; default: assert(0 && "Invalid register type in getRegClassIDOfRegType"); return 0; From brukman at cs.uiuc.edu Wed Apr 21 13:28:03 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Wed Apr 21 13:28:03 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Module.cpp Message-ID: <200404211828.NAA11608@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Module.cpp updated: 1.48 -> 1.49 --- Log message: I'm allergic to the word `stuff'. --- Diffs of the changes: (+1 -1) Index: llvm/lib/VMCore/Module.cpp diff -u llvm/lib/VMCore/Module.cpp:1.48 llvm/lib/VMCore/Module.cpp:1.49 --- llvm/lib/VMCore/Module.cpp:1.48 Mon Mar 8 00:16:10 2004 +++ llvm/lib/VMCore/Module.cpp Wed Apr 21 13:27:56 2004 @@ -24,7 +24,7 @@ using namespace llvm; //===----------------------------------------------------------------------===// -// Stuff to implement the globals and functions lists. +// Methods to implement the globals and functions lists. // Function *ilist_traits::createNode() { From brukman at cs.uiuc.edu Wed Apr 21 13:37:02 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Wed Apr 21 13:37:02 2004 Subject: [llvm-commits] CVS: llvm/tools/bugpoint/Miscompilation.cpp Message-ID: <200404211836.NAA12723@zion.cs.uiuc.edu> Changes in directory llvm/tools/bugpoint: Miscompilation.cpp updated: 1.41 -> 1.42 --- Log message: Add doxygenified comments to functions. --- Diffs of the changes: (+18 -0) Index: llvm/tools/bugpoint/Miscompilation.cpp diff -u llvm/tools/bugpoint/Miscompilation.cpp:1.41 llvm/tools/bugpoint/Miscompilation.cpp:1.42 --- llvm/tools/bugpoint/Miscompilation.cpp:1.41 Sun Apr 18 22:36:47 2004 +++ llvm/tools/bugpoint/Miscompilation.cpp Wed Apr 21 13:36:43 2004 @@ -42,6 +42,9 @@ }; } +/// TestResult - After passes have been split into a test group and a control +/// group, see if they still break the program. +/// ReduceMiscompilingPasses::TestResult ReduceMiscompilingPasses::doTest(std::vector &Prefix, std::vector &Suffix) { @@ -159,6 +162,7 @@ /// matches, return false, otherwise return true. If the DeleteInputs argument /// is set to true then this function deletes both input modules before it /// returns. +/// static bool TestMergedProgram(BugDriver &BD, Module *M1, Module *M2, bool DeleteInputs) { // Link the two portions of the program back to together. @@ -183,6 +187,10 @@ return Broken; } +/// TestFuncs - split functions in a Module into two groups: those that are +/// under consideration for miscompilation vs. those that are not, and test +/// accordingly. Each group of functions becomes a separate Module. +/// bool ReduceMiscompilingFunctions::TestFuncs(const std::vector&Funcs){ // Test to see if the function is misoptimized if we ONLY run it on the // functions listed in Funcs. @@ -201,6 +209,9 @@ return TestFn(BD, ToOptimize, ToNotOptimize); } +/// DisambiguateGlobalSymbols - Mangle symbols to guarantee uniqueness by +/// modifying predominantly internal symbols rather than external ones. +/// static void DisambiguateGlobalSymbols(Module *M) { // Try not to cause collisions by minimizing chances of renaming an // already-external symbol, so take in external globals and functions as-is. @@ -217,6 +228,7 @@ /// ExtractLoops - Given a reduced list of functions that still exposed the bug, /// check to see if we can extract the loops in the region without obscuring the /// bug. If so, it reduces the amount of code identified. +/// static bool ExtractLoops(BugDriver &BD, bool (*TestFn)(BugDriver &, Module *, Module *), std::vector &MiscompiledFunctions) { @@ -306,6 +318,7 @@ /// DebugAMiscompilation - This is a generic driver to narrow down /// miscompilations, either in an optimization or a code generator. +/// static std::vector DebugAMiscompilation(BugDriver &BD, bool (*TestFn)(BugDriver &, Module *, Module *)) { @@ -355,6 +368,7 @@ /// TestOptimizer - This is the predicate function used to check to see if the /// "Test" portion of the program is misoptimized. If so, return true. In any /// case, both module arguments are deleted. +/// static bool TestOptimizer(BugDriver &BD, Module *Test, Module *Safe) { // Run the optimization passes on ToOptimize, producing a transformed version // of the functions being tested. @@ -412,6 +426,7 @@ /// CleanupAndPrepareModules - Get the specified modules ready for code /// generator testing. +/// static void CleanupAndPrepareModules(BugDriver &BD, Module *&Test, Module *Safe) { // Clean up the modules, removing extra cruft that we don't need anymore... @@ -551,6 +566,7 @@ /// TestCodeGenerator - This is the predicate function used to check to see if /// the "Test" portion of the program is miscompiled by the code generator under /// test. If so, return true. In any case, both module arguments are deleted. +/// static bool TestCodeGenerator(BugDriver &BD, Module *Test, Module *Safe) { CleanupAndPrepareModules(BD, Test, Safe); @@ -587,6 +603,8 @@ } +/// debugCodeGenerator - debug errors in LLC, LLI, or CBE. +/// bool BugDriver::debugCodeGenerator() { if ((void*)cbe == (void*)Interpreter) { std::string Result = executeProgramWithCBE("bugpoint.cbe.out"); From lattner at cs.uiuc.edu Wed Apr 21 13:49:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 21 13:49:02 2004 Subject: [llvm-commits] CVS: llvm-gcc/gcc/llvm-types.c Message-ID: <200404211849.NAA13824@zion.cs.uiuc.edu> Changes in directory llvm-gcc/gcc: llvm-types.c updated: 1.2 -> 1.3 --- Log message: Fix PR326: http://llvm.cs.uiuc.edu/PR326 : [llvmgcc] Crash on use of undeclared enum type --- Diffs of the changes: (+11 -0) Index: llvm-gcc/gcc/llvm-types.c diff -u llvm-gcc/gcc/llvm-types.c:1.2 llvm-gcc/gcc/llvm-types.c:1.3 --- llvm-gcc/gcc/llvm-types.c:1.2 Wed Mar 10 13:38:33 2004 +++ llvm-gcc/gcc/llvm-types.c Wed Apr 21 13:48:53 2004 @@ -1349,6 +1349,17 @@ case BOOLEAN_TYPE: return BoolTy; case ENUMERAL_TYPE: + if (TYPE_SIZE(type) == 0) { + const char *Name; + if (TREE_CODE(TYPE_NAME(type)) == IDENTIFIER_NODE) + Name = IDENTIFIER_POINTER(TYPE_NAME(type)); + else + Name = IDENTIFIER_POINTER(DECL_NAME(TYPE_NAME(type))); + + return llvm_type_create_opaque(get_type_name(Name, "enum.", + TYPE_CONTEXT(type))); + } + /* FALL THROUGH */ case INTEGER_TYPE: return llvm_type_get_integer(TREE_INT_CST_LOW(TYPE_SIZE(type)), TREE_UNSIGNED(type)); From lattner at cs.uiuc.edu Wed Apr 21 13:50:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 21 13:50:01 2004 Subject: [llvm-commits] CVS: llvm/test/Regression/CFrontend/2004-05-21-IncompleteEnum.c Message-ID: <200404211849.NAA13841@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/CFrontend: 2004-05-21-IncompleteEnum.c added (r1.1) --- Log message: new testcase for PR326: http://llvm.cs.uiuc.edu/PR326 --- Diffs of the changes: (+3 -0) Index: llvm/test/Regression/CFrontend/2004-05-21-IncompleteEnum.c diff -c /dev/null llvm/test/Regression/CFrontend/2004-05-21-IncompleteEnum.c:1.1 *** /dev/null Wed Apr 21 13:49:45 2004 --- llvm/test/Regression/CFrontend/2004-05-21-IncompleteEnum.c Wed Apr 21 13:49:35 2004 *************** *** 0 **** --- 1,3 ---- + void test(enum foo *X) { + } + From lattner at cs.uiuc.edu Wed Apr 21 13:52:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 21 13:52:02 2004 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200404211852.NAA14432@zion.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.166 -> 1.167 --- Log message: bug fixed --- Diffs of the changes: (+2 -2) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.166 llvm/docs/ReleaseNotes.html:1.167 --- llvm/docs/ReleaseNotes.html:1.166 Tue Apr 20 13:18:46 2004 +++ llvm/docs/ReleaseNotes.html Wed Apr 21 13:52:06 2004 @@ -188,7 +188,7 @@

Bugs in the C/C++ front-end:

    -
  1. +
  2. [llvmgcc] Crash on use of undeclared enum type
@@ -611,7 +611,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
- Last modified: $Date: 2004/04/20 18:18:46 $ + Last modified: $Date: 2004/04/21 18:52:06 $ From lattner at cs.uiuc.edu Wed Apr 21 13:52:04 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 21 13:52:04 2004 Subject: [llvm-commits] CVS: llvm-www/releases/1.2/docs/ReleaseNotes.html Message-ID: <200404211852.NAA14961@zion.cs.uiuc.edu> Changes in directory llvm-www/releases/1.2/docs: ReleaseNotes.html updated: 1.8 -> 1.9 --- Log message: Bug found --- Diffs of the changes: (+5 -1) Index: llvm-www/releases/1.2/docs/ReleaseNotes.html diff -u llvm-www/releases/1.2/docs/ReleaseNotes.html:1.8 llvm-www/releases/1.2/docs/ReleaseNotes.html:1.9 --- llvm-www/releases/1.2/docs/ReleaseNotes.html:1.8 Tue Apr 6 14:48:55 2004 +++ llvm-www/releases/1.2/docs/ReleaseNotes.html Wed Apr 21 13:52:19 2004 @@ -382,6 +382,10 @@
  • [llvm-gcc] Error when an implicitly external function is re-declared as static
  • +Bugs in 1.2 fixed in 1.3: @@ -671,7 +675,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/04/06 19:48:55 $ + Last modified: $Date: 2004/04/21 18:52:19 $ From lattner at cs.uiuc.edu Wed Apr 21 13:58:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 21 13:58:02 2004 Subject: [llvm-commits] CVS: llvm-gcc/gcc/llvm-expand.c Message-ID: <200404211858.NAA15065@zion.cs.uiuc.edu> Changes in directory llvm-gcc/gcc: llvm-expand.c updated: 1.32 -> 1.33 --- Log message: Give a *MUCH* nicer error message when we run across a nested function --- Diffs of the changes: (+6 -0) Index: llvm-gcc/gcc/llvm-expand.c diff -u llvm-gcc/gcc/llvm-expand.c:1.32 llvm-gcc/gcc/llvm-expand.c:1.33 --- llvm-gcc/gcc/llvm-expand.c:1.32 Mon Mar 29 15:08:39 2004 +++ llvm-gcc/gcc/llvm-expand.c Wed Apr 21 13:57:57 2004 @@ -2553,9 +2553,15 @@ } } else if (TREE_CODE (decl) == LABEL_DECL && C_DECLARED_LABEL_FLAG (decl)) { + error("nested functions are not supported!"); + exit(1); LLVM_TODO_TREE(decl); declare_nonlocal_label (decl); } else if (lang_expand_decl_stmt) { + if (TREE_CODE(decl) == FUNCTION_DECL) { + error("nested functions are not supported!"); + exit(1); + } LLVM_TODO_TREE(t); (*lang_expand_decl_stmt) (t); } From lattner at cs.uiuc.edu Wed Apr 21 13:58:05 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 21 13:58:05 2004 Subject: [llvm-commits] CVS: llvm-gcc/gcc/llvm-types.c Message-ID: <200404211858.NAA15072@zion.cs.uiuc.edu> Changes in directory llvm-gcc/gcc: llvm-types.c updated: 1.3 -> 1.4 --- Log message: Add a comment --- Diffs of the changes: (+1 -0) Index: llvm-gcc/gcc/llvm-types.c diff -u llvm-gcc/gcc/llvm-types.c:1.3 llvm-gcc/gcc/llvm-types.c:1.4 --- llvm-gcc/gcc/llvm-types.c:1.3 Wed Apr 21 13:48:53 2004 +++ llvm-gcc/gcc/llvm-types.c Wed Apr 21 13:57:43 2004 @@ -1350,6 +1350,7 @@ case ENUMERAL_TYPE: if (TYPE_SIZE(type) == 0) { + /* Use of an enum that is only forward declared. */ const char *Name; if (TREE_CODE(TYPE_NAME(type)) == IDENTIFIER_NODE) Name = IDENTIFIER_POINTER(TYPE_NAME(type)); From gaeke at cs.uiuc.edu Wed Apr 21 15:33:02 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Apr 21 15:33:02 2004 Subject: [llvm-commits] CVS: reopt/lib/TraceCache/VirtualMem.cpp Message-ID: <200404212032.PAA26666@kain.cs.uiuc.edu> Changes in directory reopt/lib/TraceCache: VirtualMem.cpp updated: 1.14 -> 1.15 --- Log message: Add better comments, including doxygen comments. Throw exception in constructor if open() fails. Other minor cleanups. Make the more complex versions of VirtualMem::readInstrFrmVm() call the simple one, instead of duplicating its functionality. Make changeBranchTarget() and getBranchTarget() look as much alike as possible. --- Diffs of the changes: (+42 -62) Index: reopt/lib/TraceCache/VirtualMem.cpp diff -u reopt/lib/TraceCache/VirtualMem.cpp:1.14 reopt/lib/TraceCache/VirtualMem.cpp:1.15 --- reopt/lib/TraceCache/VirtualMem.cpp:1.14 Wed Nov 19 16:51:52 2003 +++ reopt/lib/TraceCache/VirtualMem.cpp Wed Apr 21 15:32:47 2004 @@ -10,22 +10,26 @@ #include "reopt/TraceCache.h" #include "reopt/GetTraceTime.h" #include +#include +#include using namespace llvm; -VirtualMem::VirtualMem(){ - //open file pointer +VirtualMem::VirtualMem() { + // I/O into the process's address space is accomplished by reading + // and writing the /proc//as file exported by SVR4 procfs. + // Get a file descriptor open to that file now. char ctr[25]; - int pid = getpid(); - sprintf(ctr, "/proc/%d/as",pid); + sprintf(ctr, "/proc/%d/as", (int) getpid ()); fp = open(ctr, O_RDWR); - assert(fp>=0 && "Error opening file!"); + if (fp < 0) + throw std::string ("Error opening address space file in procfs."); } +/// Emit the instruction words in TRACE to memory starting at address traceStartAddr. +/// void VirtualMem::copyToVM(std::vector &trace, uint64_t traceStartAddr){ - //copy sz instructions starting from - //location trace to virtual memory address traceStartAddr lseek(fp, traceStartAddr, SEEK_SET); for(int i=0, sz = trace.size(); igetAddr(frm); - if(instr) - return instr; - - lseek(fp, frm, SEEK_SET); - - read(fp, &instr, 4); - return instr; + unsigned int instr = tr->getAddr(frm); + if (instr) + return instr; + return readInstrFrmVm (frm); } unsigned int VirtualMem::readInstrFrmVm(uint64_t frm, TraceCache *tr, TraceCache *tr2){ - unsigned int instr=0; - - instr = tr->getAddr(frm); - if(instr) - return instr; - + unsigned int instr = tr->getAddr(frm); + if (instr) + return instr; instr = tr2->getAddr(frm); - if(instr) + if (instr) return instr; - - lseek(fp, frm, SEEK_SET); - - read(fp, &instr, 4); - return instr; + return readInstrFrmVm (frm); } void VirtualMem::writeInstToVM(uint64_t dest, unsigned int newInstr){ @@ -77,64 +68,53 @@ write(fp, &newInstr, 4); } -//two kinds of branches being handled for now -//BIcc, and BPcc instructions -//(sparcV9 manual, pg 146-150) -// +/// changeBranchTarget - Handles two kinds of branches for now, namely, +/// BIcc and BPcc instructions. (see the SPARC-V9 manual, pg 146-150). +/// void VirtualMem::changeBranchTarget(uint64_t frm, uint64_t to){ unsigned int instr = readInstrFrmVm(frm); - //std::cerr<<"Instruction at: "<<(void *)frm<<" Is:"<<(void *)instr<<"\n"; - //check if instr is a jump - assert(isBranchInstr(instr) && "Not a jump instruction"); + // Check if instr is a jump/branch instruction. + assert(isBranchInstr(instr) && "Not a jump/branch instruction"); - //std::cerr<<"\t frm Address: "<<(void *)frm<<"\n"; - //std::cerr<<"\t to address: "<<(void *)to<<"\n"; - - if(isNonDepJump(instr)){ + if (isNonDepJump(instr)) { unsigned int newInstr = getUndepJumpInstr(instr, to, frm); writeInstToVM(frm, newInstr); - //std::cerr<<"New instruction:"<<(void *)newInstr<<"\n"; - } - - else if(isDepJump(instr)){ + } else if (isDepJump(instr)) { unsigned int newInstr = getDepJumpInstr(instr, to, frm); writeInstToVM(frm, newInstr); - //std::cerr<<"New instruction:"<<(void *)newInstr<<"\n"; - } - - else{ - //std::cerr<<(void *) instr<<"\n"; + } else { assert(0 && "This jump/branch not yet handled!"); } } +/// getBranchTarget - Handles two kinds of branches for now, namely, +/// BIcc and BPcc instructions. (see the SPARC-V9 manual, pg 146-150). +/// Reads the branch instruction from the second half of the given pair. +/// uint64_t VirtualMem::getBranchTarget(const std::pair &n){ + uint64_t frm = n.second; + unsigned int instr = readInstrFrmVm(frm); - unsigned int instr = readInstrFrmVm(n.second); - - assert(isBranchInstr(instr) && "Not a branch Instr"); + // Check if instr is a jump/branch instruction. + assert(isBranchInstr(instr) && "Not a jump/branch instruction"); - //only handles BIcc and BPcc instructions for now - //(sparcV9 manual, pg 146-150) - if(isNonDepJump(instr)) + if (isNonDepJump(instr)) { return getNonDepJmpTarget(instr, n.first); - else if(isDepJump(instr)) + } else if(isDepJump(instr)) { return getDepJmpTarget(instr, n.first); - - //std::cerr<<(void *) instr<<"\n"; - assert(0 && "This branch type is not yet handled!"); - return 0; + } else { + assert(0 && "This jump/branch not yet handled!"); + return 0; + } } //write branch inst, followed by a null inst in delay slot // void VirtualMem::writeBranchInstruction(uint64_t location, uint64_t target){ - //uint64_t instToWrite = getDepJumpInstr(0x10800000, target, location); //create branch will annul bit set unsigned int instToWrite = getDepJumpInstr(0x30800000, target, location); writeInstToVM(location, instToWrite); - //writeInstToVM(location+4, 0x01000000); } #ifdef GET_TRACE_TIME From lattner at cs.uiuc.edu Wed Apr 21 15:45:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 21 15:45:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/Inliner.cpp Message-ID: <200404212044.PAA28925@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: Inliner.cpp updated: 1.12 -> 1.13 --- Log message: Fix an incredibly nasty iterator invalidation problem. I am too spoiled by ilists :) Eventually it would be nice if CallGraph maintained an ilist of CallGraphNode's instead of a vector of pointers to them, but today is not that day. --- Diffs of the changes: (+38 -18) Index: llvm/lib/Transforms/IPO/Inliner.cpp diff -u llvm/lib/Transforms/IPO/Inliner.cpp:1.12 llvm/lib/Transforms/IPO/Inliner.cpp:1.13 --- llvm/lib/Transforms/IPO/Inliner.cpp:1.12 Wed Apr 21 09:23:18 2004 +++ llvm/lib/Transforms/IPO/Inliner.cpp Wed Apr 21 15:44:33 2004 @@ -105,14 +105,6 @@ for (CallGraphNode::iterator I = CalleeNode->begin(), E = CalleeNode->end(); I != E; ++I) CallerNode->addCalledFunction(*I); - - // If the only remaining use of the function is a dead constant - // pointer ref, remove it. - if (Callee->hasOneUse()) - if (ConstantPointerRef *CPR = - dyn_cast(Callee->use_back())) - if (CPR->use_empty()) - CPR->destroyConstant(); // If we inlined the last possible call site to the function, // delete the function body now. @@ -142,27 +134,55 @@ // doFinalization - Remove now-dead linkonce functions at the end of // processing to avoid breaking the SCC traversal. bool Inliner::doFinalization(CallGraph &CG) { - bool Changed = false; - for (CallGraph::iterator I = CG.begin(), E = CG.end(); I != E; ) { - CallGraphNode *CGN = (I++)->second; + std::set FunctionsToRemove; + + // Scan for all of the functions, looking for ones that should now be removed + // from the program. Insert the dead ones in the FunctionsToRemove set. + for (CallGraph::iterator I = CG.begin(), E = CG.end(); I != E; ++I) { + CallGraphNode *CGN = I->second; Function *F = CGN ? CGN->getFunction() : 0; + + // If the only remaining use of the function is a dead constant + // pointer ref, remove it. + if (F && F->hasOneUse()) + if (ConstantPointerRef *CPR = dyn_cast(F->use_back())) + if (CPR->use_empty()) { + CPR->destroyConstant(); + if (F->hasInternalLinkage()) { + // There *MAY* be an edge from the external call node to this + // function. If so, remove it. + CallGraphNode *EN = CG.getExternalCallingNode(); + CallGraphNode::iterator I = std::find(EN->begin(), EN->end(), CGN); + if (I != EN->end()) EN->removeCallEdgeTo(CGN); + } + } + if (F && (F->hasLinkOnceLinkage() || F->hasInternalLinkage()) && F->use_empty()) { - // Remove any call graph edges from the callee to its callees. + // Remove any call graph edges from the function to its callees. while (CGN->begin() != CGN->end()) CGN->removeCallEdgeTo(*(CGN->end()-1)); - // If the function has external linkage (basically if it's a - // linkonce function) remove the edge from the external node to the - // callee node. + // If the function has external linkage (basically if it's a linkonce + // function) remove the edge from the external node to the callee node. if (!F->hasInternalLinkage()) CG.getExternalCallingNode()->removeCallEdgeTo(CGN); // Removing the node for callee from the call graph and delete it. - delete CG.removeFunctionFromModule(CGN); - ++NumDeleted; - Changed = true; + FunctionsToRemove.insert(CGN); } } + + // Now that we know which functions to delete, do so. We didn't want to do + // this inline, because that would invalidate our CallGraph::iterator + // objects. :( + bool Changed = false; + for (std::set::iterator I = FunctionsToRemove.begin(), + E = FunctionsToRemove.end(); I != E; ++I) { + delete CG.removeFunctionFromModule(*I); + ++NumDeleted; + Changed = true; + } + return Changed; } From gaeke at cs.uiuc.edu Wed Apr 21 16:06:02 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Apr 21 16:06:02 2004 Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp Message-ID: <200404212105.QAA27220@kain.cs.uiuc.edu> Changes in directory reopt/lib/LightWtProfiling: RuntimeOptimizations.cpp updated: 1.26 -> 1.27 --- Log message: Correct a major copy-and-paste-o. addPassesToJITCompile should not be run twice. --- Diffs of the changes: (+0 -1) Index: reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp diff -u reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp:1.26 reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp:1.27 --- reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp:1.26 Wed Apr 14 12:18:42 2004 +++ reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp Wed Apr 21 16:05:30 2004 @@ -85,7 +85,6 @@ DEBUG(PM.add (createMachineFunctionPrinterPass (&std::cerr, "Before unpacking:\n"))); PM.add (createUnpackTraceFunctionPass (Target, TF)); DEBUG(PM.add (createMachineFunctionPrinterPass (&std::cerr, "After unpacking:\n"))); - Target->getJITInfo ()->addPassesToJITCompile (PM); Target->addPassesToEmitMachineCode (PM, *MCE); PM.run (*TF->TraceFn); From gaeke at cs.uiuc.edu Wed Apr 21 16:06:05 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Apr 21 16:06:05 2004 Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp Message-ID: <200404212105.QAA27227@kain.cs.uiuc.edu> Changes in directory reopt/lib/LightWtProfiling: UnpackTraceFunction.cpp updated: 1.56 -> 1.57 --- Log message: Rename regSet to regsUsed. Cache it in the UnpackTraceFunction pass object. Rename getRegsUsedInFunction() to UnpackTraceFunction::findRegsUsedInFunction(). If it sees intCC or floatCC regs, then it inserts ccr or fsr (respectively) instead of the CC reg(s) it actually saw, so that we only save & restore the CCs once per trace entry/exit. rewriteProlog and rewriteEpilog are now using getUnifiedRegNum() to get the register numbers they use in instructions. Register operands that I put in SPARC MachineInstrs must use unified register numbers. Print out the types and classes of registers when I save them, for debugging. When saving and reloading registers, pick a G register, and use it for scratch space. This is necessary to save and reload the CC regs. Disable epilog rewriting for now until I can fix it... but many of the rewriteProlog fixes mentioned above also apply to rewriteEpilog. --- Diffs of the changes: (+87 -42) Index: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp diff -u reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.56 reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.57 --- reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.56 Fri Apr 9 15:10:25 2004 +++ reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp Wed Apr 21 16:05:31 2004 @@ -40,7 +40,12 @@ TargetMachine *TM; TraceFunction *TF; + /// Registers clobbered in the trace. Filled in by findRegsUsedInFunction (). + /// + std::set regsUsed; + unsigned getStaticStackSize (MachineFunction &MF); + void findRegsUsedInFunction (MachineFunction &MF); void insertCopyMachineInstrs (AllocInfo &Source, AllocInfo &Target, MachineBasicBlock &B, const Type *Ty); void insertBranchMachineInstrs (uint64_t Target, MachineBasicBlock &B); @@ -184,30 +189,60 @@ static AllocInfo getValueAllocStateFromModule (Function *F, Value *V); static AllocInfo getValueAllocStateFromGlobal (Function *F, Value *V); -/// Return the set of registers used in this function. Registers are +/// Fill in the set of registers used in this function, which is kept in +/// 'regsUsed' in the UnpackTraceFunction Pass object, and is used by +/// rewriteProlog() and rewriteEpilog(). Registers are /// represented by their 'unified register numbers' as used in the SPARCv9 /// back-end. /// -static std::set getRegsUsedInFunction (MachineFunction &MF) { - std::set regSet; +void +UnpackTraceFunction::findRegsUsedInFunction (MachineFunction &MF) { + const TargetRegInfo &TRI = TM->getRegInfo (); + bool intCCRegSeen = false, floatCCRegSeen = false; for (MachineFunction::iterator fi = MF.begin (), fe = MF.end (); fi != fe; ++fi) for (MachineBasicBlock::iterator bi = fi->begin (), be = fi->end (); bi != be; ++bi) - for (unsigned oi = 0, oe = bi->getNumOperands (); oi != oe; ++oi) - if (bi->getOperand (oi).isDef ()) - regSet.insert (bi->getOperand (oi).getReg ()); - return regSet; + for (unsigned oi = 0, oe = bi->getNumOperands (); oi != oe; ++oi) { + const MachineOperand &MO = bi->getOperand (oi); + if (MO.isDef ()) { + unsigned regNo = MO.getReg (); + if (TRI.getRegType(regNo) == SparcV9RegInfo::IntCCRegType) { + intCCRegSeen = true; + } else if (TRI.getRegType(regNo) == SparcV9RegInfo::FloatCCRegType + || TRI.getRegType(regNo) == SparcV9RegInfo::SpecialRegType) { + floatCCRegSeen = true; + } else { + regsUsed.insert (MO.getReg ()); + } + } + } + + // Deal with some sparc lunacy: If any of the floatcc regs are used, then we + // only put %fsr in the set, not the floatcc regs which were actually used. + // If the intcc regs are used, then we only put %ccr in the + // set, not the individual intcc regs. + if (floatCCRegSeen) { + unsigned fsrReg = TRI.getUnifiedRegNum(SparcV9RegInfo::SpecialRegClassID, + SparcV9SpecialRegClass::fsr); + regsUsed.insert (fsrReg); + } + if (intCCRegSeen) { + unsigned ccrReg = TRI.getUnifiedRegNum(SparcV9RegInfo::IntCCRegClassID, + SparcV9IntCCRegClass::ccr); + regsUsed.insert (ccrReg); + } } void UnpackTraceFunction::rewriteProlog (MachineFunction &MF, MachineBasicBlock &E) { const TargetRegInfo &TRI = TM->getRegInfo (); static const unsigned - fp = SparcV9IntRegClass::i6, - sp = SparcV9IntRegClass::o6, - g0 = SparcV9IntRegClass::g0, - g1 = SparcV9IntRegClass::g1; +fp = TRI.getUnifiedRegNum(SparcV9RegInfo::IntRegClassID,SparcV9IntRegClass::i6), +sp = TRI.getUnifiedRegNum(SparcV9RegInfo::IntRegClassID,SparcV9IntRegClass::o6), +g0 = TRI.getUnifiedRegNum(SparcV9RegInfo::IntRegClassID,SparcV9IntRegClass::g0), +g1 = TRI.getUnifiedRegNum(SparcV9RegInfo::IntRegClassID,SparcV9IntRegClass::g1), +g2 = TRI.getUnifiedRegNum(SparcV9RegInfo::IntRegClassID,SparcV9IntRegClass::g2); // UTF prolog: start out by clearing everything out of the entry basic block // (FIXME: may not work once we start doing optimizations!!! We will probably @@ -218,16 +253,16 @@ E.push_back (BuildMI (V9::ORr, 3).addMReg (sp).addZImm (0).addMReg (g1, MachineOperand::UseAndDef)); - // 1. Initialize regSet with the set of registers used in this function. - std::set regSet = getRegsUsedInFunction (MF); + // 1. Initialize regsUsed with the set of registers used in this function. + findRegsUsedInFunction (MF); unsigned stackSize = getStaticStackSize (MF); DEBUG(std::cerr << "rewriteProlog: Static stack size is " << stackSize << "\n" - << "rewriteProlog: Reg set (size " << regSet.size () + << "rewriteProlog: Reg set (size " << regsUsed.size () << ") contains: ("); - DEBUG(for (std::set::iterator i = regSet.begin (), - e = regSet.end (); i != e; ++i) { std::cerr << *i << " "; }); + DEBUG(for (std::set::iterator i = regsUsed.begin (), + e = regsUsed.end (); i != e; ++i) { std::cerr << *i << " "; }); DEBUG(std::cerr << " )\n"); // 2. Get some stack space: (Stack Frame Size + Space for Regs). @@ -238,20 +273,31 @@ // 3. Save used registers onto the stack. std::vector mvec; int RegType; - for (std::set::iterator i = regSet.begin (), e = regSet.end (); + for (std::set::iterator i = regsUsed.begin (), e = regsUsed.end (); i != e; ++i) { mvec.clear (); unsigned R = *i; unsigned RegType = TRI.getRegType (R); + static const char *RegTypeStrings[] = { "IntRegType", + "FPSingleRegType", "FPDoubleRegType", "IntCCRegType", + "FloatCCRegType", "SpecialRegType" }; + static const char *RegClassStrings[] = { "IntRegClassID", + "FloatRegClassID", "IntCCRegClassID", "FloatCCRegClassID", + "SpecialRegClassID" }; DEBUG (std::cerr << "rewriteProlog: Saving reg#" << R << ", type = " - << RegType << ", " << "Class = " - << TRI.getRegClassIDOfRegType(RegType) << "\n"); - TRI.cpReg2MemMI (mvec, R, sp, stackSize + R * 8, RegType); + << RegType << " (" << RegTypeStrings[RegType] + << "), Class = " << TRI.getRegClassIDOfRegType(RegType) + << " (" + << RegClassStrings[TRI.getRegClassIDOfRegType(RegType)] + << ")\n"); + TRI.cpReg2MemMI (mvec, R, sp, stackSize + R * 8, RegType, g2); // Add whatever the TargetRegInfo gave us to the MachineBasicBlock we are // working on. for (std::vector::iterator vi = mvec.begin (), - ve = mvec.end (); vi != ve; ++vi) + ve = mvec.end (); vi != ve; ++vi) { + DEBUG (std::cerr << "rewriteProlog: Insns: " << **vi); E.push_back (*vi); + } } // 4. Insert copies from each live-in variable's reg. in the matrix fn. @@ -430,12 +476,14 @@ void UnpackTraceFunction::rewriteEpilog (MachineFunction &MF, MachineBasicBlock &MBB) { + return; // FIXME - disabling epilog rewriting for now const TargetRegInfo &TRI = TM->getRegInfo (); static const unsigned - fp = SparcV9IntRegClass::i6, - sp = SparcV9IntRegClass::o6, - g0 = SparcV9IntRegClass::g0, - g1 = SparcV9IntRegClass::g1; +fp = TRI.getUnifiedRegNum(SparcV9RegInfo::IntRegClassID,SparcV9IntRegClass::i6), +sp = TRI.getUnifiedRegNum(SparcV9RegInfo::IntRegClassID,SparcV9IntRegClass::o6), +g0 = TRI.getUnifiedRegNum(SparcV9RegInfo::IntRegClassID,SparcV9IntRegClass::g0), +g1 = TRI.getUnifiedRegNum(SparcV9RegInfo::IntRegClassID,SparcV9IntRegClass::g1), +g2 = TRI.getUnifiedRegNum(SparcV9RegInfo::IntRegClassID,SparcV9IntRegClass::g2); Function *TraceF = TF->TraceFn, *MatrixF = TF->MatrixFn; LiveVariableSet &So = TF->LiveOutSet; @@ -445,7 +493,15 @@ MBB.clear (); // Restore old FP. - // FIXME + std::vector mvec; + unsigned stackSize = getStaticStackSize (MF); + TRI.cpMem2RegMI (mvec, sp, stackSize + fp * 8, fp, TRI.getRegType(fp), g2); + + // Add whatever the TargetRegInfo gave us to the MachineBasicBlock we are + // working on. + for (std::vector::iterator vi = mvec.begin (), + ve = mvec.end (); vi != ve; ++vi) + MBB.push_back (*vi); // Insert copies from each live-out variable's reg. in the trace // to its reg. in the matrix function. @@ -460,22 +516,10 @@ } // Get the set of registers used in this function which we saved in - // rewriteProlog, earlier. - std::set regSet = getRegsUsedInFunction (MF); - - unsigned stackSize = getStaticStackSize (MF); - DEBUG(std::cerr << "rewriteEpilog: Static stack size is " - << stackSize << "\n" - << "rewriteEpilog: Reg set (size " << regSet.size () - << ") contains: ("); - DEBUG(for (std::set::iterator i = regSet.begin (), - e = regSet.end (); i != e; ++i) { std::cerr << *i << " "; }); - DEBUG(std::cerr << " )\n"); - - // Restore all used registers from stack except SP. - std::vector mvec; + // rewriteProlog, earlier, and restore all used registers from stack + // except SP. int RegType; - for (std::set::iterator i = regSet.begin (), e = regSet.end (); + for (std::set::iterator i = regsUsed.begin (), e = regsUsed.end (); i != e; ++i) { mvec.clear (); unsigned R = *i; @@ -483,7 +527,8 @@ DEBUG (std::cerr << "rewriteEpilog: Reloading reg#" << R << ", type = " << RegType << ", " << "Class = " << TRI.getRegClassIDOfRegType(RegType) << "\n"); - TRI.cpMem2RegMI (mvec, sp, stackSize + R * 8, R, RegType); + TRI.cpMem2RegMI (mvec, sp, stackSize + R * 8, R, RegType, g2); + // Add whatever the TargetRegInfo gave us to the MachineBasicBlock we are // working on. for (std::vector::iterator vi = mvec.begin (), From lattner at cs.uiuc.edu Wed Apr 21 17:22:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 21 17:22:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/IndVarSimplify.cpp Message-ID: <200404212222.RAA22675@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: IndVarSimplify.cpp updated: 1.59 -> 1.60 --- Log message: Implement a fixme. The helps loops that have induction variables of different types in them. Instead of creating an induction variable for all types, it creates a single induction variable and casts to the other sizes. This generates this code: no_exit: ; preds = %entry, %no_exit %indvar = phi uint [ %indvar.next, %no_exit ], [ 0, %entry ] ; [#uses=4] *** %j.0.0 = cast uint %indvar to short ; [#uses=1] %indvar = cast uint %indvar to int ; [#uses=1] %tmp.7 = getelementptr short* %P, uint %indvar ; [#uses=1] store short %j.0.0, short* %tmp.7 %inc.0 = add int %indvar, 1 ; [#uses=2] %tmp.2 = setlt int %inc.0, %N ; [#uses=1] %indvar.next = add uint %indvar, 1 ; [#uses=1] br bool %tmp.2, label %no_exit, label %loopexit instead of: no_exit: ; preds = %entry, %no_exit %indvar = phi ushort [ %indvar.next, %no_exit ], [ 0, %entry ] ; [#uses=2] *** %indvar = phi uint [ %indvar.next, %no_exit ], [ 0, %entry ] ; [#uses=3] %indvar = cast uint %indvar to int ; [#uses=1] %indvar = cast ushort %indvar to short ; [#uses=1] %tmp.7 = getelementptr short* %P, uint %indvar ; [#uses=1] store short %indvar, short* %tmp.7 %inc.0 = add int %indvar, 1 ; [#uses=2] %tmp.2 = setlt int %inc.0, %N ; [#uses=1] %indvar.next = add uint %indvar, 1 *** %indvar.next = add ushort %indvar, 1 br bool %tmp.2, label %no_exit, label %loopexit This is an improvement in register pressure, but probably doesn't happen that often. The more important fix will be to get rid of the redundant add. --- Diffs of the changes: (+20 -17) Index: llvm/lib/Transforms/Scalar/IndVarSimplify.cpp diff -u llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.59 llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.60 --- llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.59 Sun Apr 18 17:14:10 2004 +++ llvm/lib/Transforms/Scalar/IndVarSimplify.cpp Wed Apr 21 17:22:01 2004 @@ -390,10 +390,8 @@ // Compute the type of the largest recurrence expression. // const Type *LargestType = IndVars[0].first->getType(); - bool DifferingSizes = false; for (unsigned i = 1, e = IndVars.size(); i != e; ++i) { const Type *Ty = IndVars[i].first->getType(); - DifferingSizes |= Ty->getPrimitiveSize() != LargestType->getPrimitiveSize(); if (Ty->getPrimitiveSize() > LargestType->getPrimitiveSize()) LargestType = Ty; } @@ -411,30 +409,35 @@ if (!isa(IterationCount)) LinearFunctionTestReplace(L, IterationCount, Rewriter); -#if 0 - // If there were induction variables of other sizes, cast the primary - // induction variable to the right size for them, avoiding the need for the - // code evaluation methods to insert induction variables of different sizes. - // FIXME! - if (DifferingSizes) { - std::map InsertedSizes; - for (unsigned i = 0, e = IndVars.size(); i != e; ++i) { - } - } -#endif - // Now that we have a canonical induction variable, we can rewrite any // recurrences in terms of the induction variable. Start with the auxillary // induction variables, and recursively rewrite any of their uses. BasicBlock::iterator InsertPt = Header->begin(); while (isa(InsertPt)) ++InsertPt; + // If there were induction variables of other sizes, cast the primary + // induction variable to the right size for them, avoiding the need for the + // code evaluation methods to insert induction variables of different sizes. + std::map InsertedSizes; + InsertedSizes[LargestType->getPrimitiveSize()] = IndVar; while (!IndVars.empty()) { PHINode *PN = IndVars.back().first; - Value *NewVal = Rewriter.ExpandCodeFor(IndVars.back().second, InsertPt, - PN->getType()); + + const Type *Ty = PN->getType()->getUnsignedVersion(); + Value *&IV = InsertedSizes[Ty->getPrimitiveSize()]; + if (IV == 0) { + // Insert a new cast instruction, which will hold this recurrence. + std::string Name = PN->getName(); + PN->setName(""); + IV = new CastInst(IndVar, Ty, Name, InsertPt); + } + + Value *V = IV; + if (PN->getType() != Ty) + V = new CastInst(V, PN->getType(), V->getName(), InsertPt); + // Replace the old PHI Node with the inserted computation. - PN->replaceAllUsesWith(NewVal); + PN->replaceAllUsesWith(V); DeadInsts.insert(PN); IndVars.pop_back(); ++NumRemoved; From lattner at cs.uiuc.edu Wed Apr 21 17:30:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 21 17:30:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/DCE.cpp Message-ID: <200404212229.RAA23190@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: DCE.cpp updated: 1.51 -> 1.52 --- Log message: This code really wants to iterate over the OPERANDS of an instruction, not over its USES. If it's dead it doesn't have any uses! :) Thanks to the fabulous and mysterious Bill Wendling for pointing this out. :) --- Diffs of the changes: (+2 -3) Index: llvm/lib/Transforms/Scalar/DCE.cpp diff -u llvm/lib/Transforms/Scalar/DCE.cpp:1.51 llvm/lib/Transforms/Scalar/DCE.cpp:1.52 --- llvm/lib/Transforms/Scalar/DCE.cpp:1.51 Fri Jan 9 00:02:20 2004 +++ llvm/lib/Transforms/Scalar/DCE.cpp Wed Apr 21 17:29:37 2004 @@ -92,9 +92,8 @@ // instructions being used, add them to the worklist, because they might // go dead after this one is removed. // - for (User::use_iterator UI = I->use_begin(), UE = I->use_end(); - UI != UE; ++UI) - if (Instruction *Used = dyn_cast(*UI)) + for (User::op_iterator OI = I->op_begin(), E = I->op_end(); OI != E; ++OI) + if (Instruction *Used = dyn_cast(*OI)) WorkList.push_back(Used); // Tell the instruction to let go of all of the values it uses... From lattner at cs.uiuc.edu Wed Apr 21 18:36:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Apr 21 18:36:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/IndVarSimplify.cpp Message-ID: <200404212336.SAA25044@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: IndVarSimplify.cpp updated: 1.60 -> 1.61 --- Log message: Implement a todo, rewriting all possible scev expressions inside of the loop. This eliminates the extra add from the previous case, but it's not clear that this will be a performance win overall. Tommorows test results will tell. :) --- Diffs of the changes: (+18 -8) Index: llvm/lib/Transforms/Scalar/IndVarSimplify.cpp diff -u llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.60 llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.61 --- llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.60 Wed Apr 21 17:22:01 2004 +++ llvm/lib/Transforms/Scalar/IndVarSimplify.cpp Wed Apr 21 18:36:08 2004 @@ -444,21 +444,31 @@ Changed = true; } - DeleteTriviallyDeadInstructions(DeadInsts); - - // TODO: In the future we could replace all instructions in the loop body with - // simpler expressions. It's not clear how useful this would be though or if - // the code expansion cost would be worth it! We probably shouldn't do this - // until we have a way to reuse expressions already in the code. -#if 0 + // Now replace all derived expressions in the loop body with simpler + // expressions. for (unsigned i = 0, e = L->getBlocks().size(); i != e; ++i) if (LI->getLoopFor(L->getBlocks()[i]) == L) { // Not in a subloop... BasicBlock *BB = L->getBlocks()[i]; for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) if (I->getType()->isInteger() && // Is an integer instruction + !I->use_empty() && !Rewriter.isInsertedInstruction(I)) { SCEVHandle SH = SE->getSCEV(I); + Value *V = Rewriter.ExpandCodeFor(SH, I, I->getType()); + if (V != I) { + if (isa(V)) { + std::string Name = I->getName(); + I->setName(""); + V->setName(Name); + } + I->replaceAllUsesWith(V); + DeadInsts.insert(I); + ++NumRemoved; + Changed = true; + } } } -#endif + + + DeleteTriviallyDeadInstructions(DeadInsts); } From lattner at cs.uiuc.edu Thu Apr 22 09:57:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 22 09:57:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/ScalarEvolution.h Message-ID: <200404221457.JAA26714@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: ScalarEvolution.h updated: 1.2 -> 1.3 --- Log message: Add a method --- Diffs of the changes: (+8 -0) Index: llvm/include/llvm/Analysis/ScalarEvolution.h diff -u llvm/include/llvm/Analysis/ScalarEvolution.h:1.2 llvm/include/llvm/Analysis/ScalarEvolution.h:1.3 --- llvm/include/llvm/Analysis/ScalarEvolution.h:1.2 Fri Apr 2 14:46:26 2004 +++ llvm/include/llvm/Analysis/ScalarEvolution.h Thu Apr 22 09:56:51 2004 @@ -250,6 +250,14 @@ /// starts at zero and steps by one on each iteration. Value *GetOrInsertCanonicalInductionVariable(const Loop *L, const Type *Ty); + + /// addInsertedValue - Remember the specified instruction as being the + /// canonical form for the specified SCEV. + void addInsertedValue(Instruction *I, SCEV *S) { + InsertedExpressions[S] = I; + InsertedInstructions.insert(I); + } + /// ExpandCodeFor - Insert code to directly compute the specified SCEV /// expression into the program. The inserted code is inserted into the /// specified block. From lattner at cs.uiuc.edu Thu Apr 22 10:00:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 22 10:00:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/IndVarSimplify.cpp Message-ID: <200404221459.JAA27336@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: IndVarSimplify.cpp updated: 1.61 -> 1.62 --- Log message: Fix an extremely serious thinko I made in revision 1.60 of this file. --- Diffs of the changes: (+25 -16) Index: llvm/lib/Transforms/Scalar/IndVarSimplify.cpp diff -u llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.61 llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.62 --- llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.61 Wed Apr 21 18:36:08 2004 +++ llvm/lib/Transforms/Scalar/IndVarSimplify.cpp Thu Apr 22 09:59:40 2004 @@ -390,8 +390,10 @@ // Compute the type of the largest recurrence expression. // const Type *LargestType = IndVars[0].first->getType(); + bool DifferingSizes = false; for (unsigned i = 1, e = IndVars.size(); i != e; ++i) { const Type *Ty = IndVars[i].first->getType(); + DifferingSizes |= Ty->getPrimitiveSize() != LargestType->getPrimitiveSize(); if (Ty->getPrimitiveSize() > LargestType->getPrimitiveSize()) LargestType = Ty; } @@ -418,26 +420,34 @@ // If there were induction variables of other sizes, cast the primary // induction variable to the right size for them, avoiding the need for the // code evaluation methods to insert induction variables of different sizes. + if (DifferingSizes) { + bool InsertedSizes[17] = { false }; + InsertedSizes[LargestType->getPrimitiveSize()] = true; + for (unsigned i = 0, e = IndVars.size(); i != e; ++i) + if (!InsertedSizes[IndVars[i].first->getType()->getPrimitiveSize()]) { + PHINode *PN = IndVars[i].first; + InsertedSizes[PN->getType()->getPrimitiveSize()] = true; + Instruction *New = new CastInst(IndVar, + PN->getType()->getUnsignedVersion(), + "indvar", InsertPt); + Rewriter.addInsertedValue(New, SE->getSCEV(New)); + } + } + + // If there were induction variables of other sizes, cast the primary + // induction variable to the right size for them, avoiding the need for the + // code evaluation methods to insert induction variables of different sizes. std::map InsertedSizes; - InsertedSizes[LargestType->getPrimitiveSize()] = IndVar; while (!IndVars.empty()) { PHINode *PN = IndVars.back().first; - - const Type *Ty = PN->getType()->getUnsignedVersion(); - Value *&IV = InsertedSizes[Ty->getPrimitiveSize()]; - if (IV == 0) { - // Insert a new cast instruction, which will hold this recurrence. - std::string Name = PN->getName(); - PN->setName(""); - IV = new CastInst(IndVar, Ty, Name, InsertPt); - } - - Value *V = IV; - if (PN->getType() != Ty) - V = new CastInst(V, PN->getType(), V->getName(), InsertPt); + Value *NewVal = Rewriter.ExpandCodeFor(IndVars.back().second, InsertPt, + PN->getType()); + std::string Name = PN->getName(); + PN->setName(""); + NewVal->setName(Name); // Replace the old PHI Node with the inserted computation. - PN->replaceAllUsesWith(V); + PN->replaceAllUsesWith(NewVal); DeadInsts.insert(PN); IndVars.pop_back(); ++NumRemoved; @@ -468,7 +478,6 @@ } } } - DeleteTriviallyDeadInstructions(DeadInsts); } From lattner at cs.uiuc.edu Thu Apr 22 10:01:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 22 10:01:02 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/ScalarEvolution.h Message-ID: <200404221500.KAA28109@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: ScalarEvolution.h updated: 1.3 -> 1.4 --- Log message: Add an ugly cast --- Diffs of the changes: (+1 -1) Index: llvm/include/llvm/Analysis/ScalarEvolution.h diff -u llvm/include/llvm/Analysis/ScalarEvolution.h:1.3 llvm/include/llvm/Analysis/ScalarEvolution.h:1.4 --- llvm/include/llvm/Analysis/ScalarEvolution.h:1.3 Thu Apr 22 09:56:51 2004 +++ llvm/include/llvm/Analysis/ScalarEvolution.h Thu Apr 22 10:00:36 2004 @@ -254,7 +254,7 @@ /// addInsertedValue - Remember the specified instruction as being the /// canonical form for the specified SCEV. void addInsertedValue(Instruction *I, SCEV *S) { - InsertedExpressions[S] = I; + InsertedExpressions[S] = (Value*)I; InsertedInstructions.insert(I); } From lattner at cs.uiuc.edu Thu Apr 22 10:13:03 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Apr 22 10:13:03 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/IndVarSimplify.cpp Message-ID: <200404221512.KAA29851@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: IndVarSimplify.cpp updated: 1.62 -> 1.63 --- Log message: Disable a previous patch that was causing indvars to loop infinitely :( --- Diffs of the changes: (+2 -0) Index: llvm/lib/Transforms/Scalar/IndVarSimplify.cpp diff -u llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.62 llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.63 --- llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.62 Thu Apr 22 09:59:40 2004 +++ llvm/lib/Transforms/Scalar/IndVarSimplify.cpp Thu Apr 22 10:12:36 2004 @@ -454,6 +454,7 @@ Changed = true; } +#if 0 // Now replace all derived expressions in the loop body with simpler // expressions. for (unsigned i = 0, e = L->getBlocks().size(); i != e; ++i) @@ -478,6 +479,7 @@ } } } +#endif DeleteTriviallyDeadInstructions(DeadInsts); } From brukman at cs.uiuc.edu Thu Apr 22 15:02:02 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Thu Apr 22 15:02:02 2004 Subject: [llvm-commits] CVS: llvm/tools/bugpoint/Miscompilation.cpp Message-ID: <200404222002.PAA05143@zion.cs.uiuc.edu> Changes in directory llvm/tools/bugpoint: Miscompilation.cpp updated: 1.42 -> 1.43 --- Log message: Add a space before result for readability on the command line. --- Diffs of the changes: (+7 -7) Index: llvm/tools/bugpoint/Miscompilation.cpp diff -u llvm/tools/bugpoint/Miscompilation.cpp:1.42 llvm/tools/bugpoint/Miscompilation.cpp:1.43 --- llvm/tools/bugpoint/Miscompilation.cpp:1.42 Wed Apr 21 13:36:43 2004 +++ llvm/tools/bugpoint/Miscompilation.cpp Thu Apr 22 15:02:09 2004 @@ -64,10 +64,10 @@ // Check to see if the finished program matches the reference output... if (BD.diffProgram(BytecodeResult, "", true /*delete bytecode*/)) { - std::cout << "nope.\n"; - return KeepSuffix; // Miscompilation detected! + std::cout << " nope.\n"; + return KeepSuffix; // Miscompilation detected! } - std::cout << "yup.\n"; // No miscompilation! + std::cout << " yup.\n"; // No miscompilation! if (Prefix.empty()) return NoFailure; @@ -92,11 +92,11 @@ // If the prefix maintains the predicate by itself, only keep the prefix! if (BD.diffProgram(BytecodeResult)) { - std::cout << "nope.\n"; + std::cout << " nope.\n"; removeFile(BytecodeResult); return KeepPrefix; } - std::cout << "yup.\n"; // No miscompilation! + std::cout << " yup.\n"; // No miscompilation! // Ok, so now we know that the prefix passes work, try running the suffix // passes on the result of the prefix passes. @@ -124,13 +124,13 @@ // Run the result... if (BD.diffProgram(BytecodeResult, "", true/*delete bytecode*/)) { - std::cout << "nope.\n"; + std::cout << " nope.\n"; delete OriginalInput; // We pruned down the original input... return KeepSuffix; } // Otherwise, we must not be running the bad pass anymore. - std::cout << "yup.\n"; // No miscompilation! + std::cout << " yup.\n"; // No miscompilation! delete BD.swapProgramIn(OriginalInput); // Restore orig program & free test return NoFailure; } From brukman at cs.uiuc.edu Thu Apr 22 17:52:01 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Thu Apr 22 17:52:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Transforms/IPO.h Message-ID: <200404222251.RAA14058@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Transforms: IPO.h updated: 1.30 -> 1.31 --- Log message: Add a boolean flag to delete this function from module, leaving the rest behind. Useful in manual debugging when bugpoint isn't quite up to snuff. --- Diffs of the changes: (+4 -3) Index: llvm/include/llvm/Transforms/IPO.h diff -u llvm/include/llvm/Transforms/IPO.h:1.30 llvm/include/llvm/Transforms/IPO.h:1.31 --- llvm/include/llvm/Transforms/IPO.h:1.30 Sun Mar 14 14:00:37 2004 +++ llvm/include/llvm/Transforms/IPO.h Thu Apr 22 17:51:37 2004 @@ -66,10 +66,11 @@ //===----------------------------------------------------------------------===// -/// createFunctionExtractionPass - This pass deletes as much of the module as -/// possible, except for the function specified. +/// createFunctionExtractionPass - If isolateFn is true, this pass deletes as +/// much of the module as possible, except for the function specified. +/// Otherwise, it deletes the given function, leaving everything else intact. /// -Pass *createFunctionExtractionPass(Function *F); +Pass *createFunctionExtractionPass(Function *F, bool isolateFn = true); //===----------------------------------------------------------------------===// From brukman at cs.uiuc.edu Thu Apr 22 17:52:06 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Thu Apr 22 17:52:06 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/ExtractFunction.cpp Message-ID: <200404222252.RAA14076@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: ExtractFunction.cpp updated: 1.7 -> 1.8 --- Log message: Add a flag to choose between isolating a function or deleting the function from the Module. The default behavior keeps functionality as before: the chosen function is the one that remains. --- Diffs of the changes: (+29 -6) Index: llvm/lib/Transforms/IPO/ExtractFunction.cpp diff -u llvm/lib/Transforms/IPO/ExtractFunction.cpp:1.7 llvm/lib/Transforms/IPO/ExtractFunction.cpp:1.8 --- llvm/lib/Transforms/IPO/ExtractFunction.cpp:1.7 Fri Nov 21 15:54:22 2003 +++ llvm/lib/Transforms/IPO/ExtractFunction.cpp Thu Apr 22 17:52:22 2004 @@ -6,17 +6,27 @@ // the University of Illinois Open Source License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// +// +// This pass extracts +// +//===----------------------------------------------------------------------===// -#include "llvm/Transforms/IPO.h" -#include "llvm/Pass.h" #include "llvm/Module.h" +#include "llvm/Pass.h" +#include "llvm/Transforms/IPO.h" using namespace llvm; namespace { class FunctionExtractorPass : public Pass { Function *Named; + bool isolateFunc; public: - FunctionExtractorPass(Function *F = 0) : Named(F) {} + /// FunctionExtractorPass - ctor for the pass. If isolateFn is true, then + /// the named function is the only thing left in the Module (default + /// behavior), otherwise the function is the thing deleted. + /// + FunctionExtractorPass(Function *F = 0, bool isolateFn = true) + : Named(F), isolateFunc(isolateFn) {} bool run(Module &M) { if (Named == 0) { @@ -24,6 +34,20 @@ if (Named == 0) return false; // No function to extract } + if (isolateFunc) + return isolateFunction(M); + else + return deleteFunction(); + } + + bool deleteFunction() { + Named->setLinkage(GlobalValue::ExternalLinkage); + Named->deleteBody(); + assert(Named->isExternal() && "This didn't make the function external!"); + return true; + } + + bool isolateFunction(Module &M) { // Make sure our result is globally accessible... Named->setLinkage(GlobalValue::ExternalLinkage); @@ -37,7 +61,6 @@ // All of the functions may be used by global variables or the named // function. Loop through them and create a new, external functions that // can be "used", instead of ones with bodies. - // std::vector NewFunctions; Function *Last = &M.back(); // Figure out where the last real fn is... @@ -89,6 +112,6 @@ RegisterPass X("extract", "Function Extractor"); } -Pass *llvm::createFunctionExtractionPass(Function *F) { - return new FunctionExtractorPass(F); +Pass *llvm::createFunctionExtractionPass(Function *F, bool isolateFn) { + return new FunctionExtractorPass(F, isolateFn); } From brukman at cs.uiuc.edu Thu Apr 22 18:00:02 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Thu Apr 22 18:00:02 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Transforms/IPO.h Message-ID: <200404222300.SAA14134@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Transforms: IPO.h updated: 1.31 -> 1.32 --- Log message: Clarify the logic: the flag is renamed to `deleteFn' to signify it will delete the function instead of isolating it. This also means the condition is reversed. --- Diffs of the changes: (+4 -4) Index: llvm/include/llvm/Transforms/IPO.h diff -u llvm/include/llvm/Transforms/IPO.h:1.31 llvm/include/llvm/Transforms/IPO.h:1.32 --- llvm/include/llvm/Transforms/IPO.h:1.31 Thu Apr 22 17:51:37 2004 +++ llvm/include/llvm/Transforms/IPO.h Thu Apr 22 18:00:17 2004 @@ -66,11 +66,11 @@ //===----------------------------------------------------------------------===// -/// createFunctionExtractionPass - If isolateFn is true, this pass deletes as -/// much of the module as possible, except for the function specified. -/// Otherwise, it deletes the given function, leaving everything else intact. +/// createFunctionExtractionPass - If deleteFn is true, this pass deletes as +/// the specified function. Otherwise, it deletes as much of the module as +/// possible, except for the function specified. /// -Pass *createFunctionExtractionPass(Function *F, bool isolateFn = true); +Pass *createFunctionExtractionPass(Function *F, bool deleteFn = false); //===----------------------------------------------------------------------===// From brukman at cs.uiuc.edu Thu Apr 22 18:01:02 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Thu Apr 22 18:01:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/ExtractFunction.cpp Message-ID: <200404222301.SAA14168@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: ExtractFunction.cpp updated: 1.8 -> 1.9 --- Log message: Clarify the logic: the flag is renamed to `deleteFn' to signify it will delete the function instead of isolating it. This also means the condition is reversed. --- Diffs of the changes: (+11 -11) Index: llvm/lib/Transforms/IPO/ExtractFunction.cpp diff -u llvm/lib/Transforms/IPO/ExtractFunction.cpp:1.8 llvm/lib/Transforms/IPO/ExtractFunction.cpp:1.9 --- llvm/lib/Transforms/IPO/ExtractFunction.cpp:1.8 Thu Apr 22 17:52:22 2004 +++ llvm/lib/Transforms/IPO/ExtractFunction.cpp Thu Apr 22 18:00:51 2004 @@ -19,14 +19,14 @@ namespace { class FunctionExtractorPass : public Pass { Function *Named; - bool isolateFunc; + bool deleteFunc; public: - /// FunctionExtractorPass - ctor for the pass. If isolateFn is true, then - /// the named function is the only thing left in the Module (default - /// behavior), otherwise the function is the thing deleted. + /// FunctionExtractorPass - If deleteFn is true, this pass deletes as the + /// specified function. Otherwise, it deletes as much of the module as + /// possible, except for the function specified. /// - FunctionExtractorPass(Function *F = 0, bool isolateFn = true) - : Named(F), isolateFunc(isolateFn) {} + FunctionExtractorPass(Function *F = 0, bool deleteFn = true) + : Named(F), deleteFunc(deleteFn) {} bool run(Module &M) { if (Named == 0) { @@ -34,10 +34,10 @@ if (Named == 0) return false; // No function to extract } - if (isolateFunc) - return isolateFunction(M); - else + if (deleteFunc) return deleteFunction(); + else + return isolateFunction(M); } bool deleteFunction() { @@ -112,6 +112,6 @@ RegisterPass X("extract", "Function Extractor"); } -Pass *llvm::createFunctionExtractionPass(Function *F, bool isolateFn) { - return new FunctionExtractorPass(F, isolateFn); +Pass *llvm::createFunctionExtractionPass(Function *F, bool deleteFn) { + return new FunctionExtractorPass(F, deleteFn); } From brukman at cs.uiuc.edu Thu Apr 22 18:08:01 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Thu Apr 22 18:08:01 2004 Subject: [llvm-commits] CVS: llvm/tools/extract/extract.cpp Message-ID: <200404222307.SAA26405@zion.cs.uiuc.edu> Changes in directory llvm/tools/extract: extract.cpp updated: 1.21 -> 1.22 --- Log message: Add command-line option to select whether to isolate or delete function from module. Default is `isolate' as before. --- Diffs of the changes: (+5 -1) Index: llvm/tools/extract/extract.cpp diff -u llvm/tools/extract/extract.cpp:1.21 llvm/tools/extract/extract.cpp:1.22 --- llvm/tools/extract/extract.cpp:1.21 Thu Feb 19 14:32:39 2004 +++ llvm/tools/extract/extract.cpp Thu Apr 22 18:07:39 2004 @@ -36,6 +36,9 @@ static cl::opt Force("f", cl::desc("Overwrite output files")); +static cl::opt +DeleteFn("delete", cl::desc("Delete specified function from Module")); + // ExtractFunc - The function to extract from the module... defaults to main. static cl::opt ExtractFunc("func", cl::desc("Specify function to extract"), cl::init("main"), @@ -64,7 +67,8 @@ // PassManager Passes; Passes.add(new TargetData("extract", M.get())); // Use correct TargetData - Passes.add(createFunctionExtractionPass(F)); // Extract the function + // Either isolate the function or delete it from the Module + Passes.add(createFunctionExtractionPass(F, DeleteFn)); Passes.add(createGlobalDCEPass()); // Delete unreachable globals Passes.add(createFunctionResolvingPass()); // Delete prototypes Passes.add(createDeadTypeEliminationPass()); // Remove dead types... From brukman at cs.uiuc.edu Fri Apr 23 11:55:02 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Fri Apr 23 11:55:02 2004 Subject: [llvm-commits] [parallel] CVS: llvm/test/Regression/Transforms/Parallel/20040422-ImplicitPbr.c Message-ID: <200404231654.LAA05422@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/Parallel: 20040422-ImplicitPbr.c added (r1.1.2.1) --- Log message: Test case to convert implicit parallelism (in C) to use pbr. --- Diffs of the changes: (+16 -0) Index: llvm/test/Regression/Transforms/Parallel/20040422-ImplicitPbr.c diff -c /dev/null llvm/test/Regression/Transforms/Parallel/20040422-ImplicitPbr.c:1.1.2.1 *** /dev/null Fri Apr 23 11:54:51 2004 --- llvm/test/Regression/Transforms/Parallel/20040422-ImplicitPbr.c Fri Apr 23 11:54:41 2004 *************** *** 0 **** --- 1,16 ---- + void* __llvm_pbr(void); + void __llvm_join(void*); + + void bar(void); + void quux(void); + + void foo() { + void* p = __llvm_pbr(); + if (p) + bar(); + else + quux(); + + __llvm_join(p); + + } From brukman at cs.uiuc.edu Fri Apr 23 11:55:05 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Fri Apr 23 11:55:05 2004 Subject: [llvm-commits] [parallel] CVS: llvm/lib/Transforms/Parallel/PbrInjector.cpp Message-ID: <200404231655.LAA05445@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Parallel: PbrInjector.cpp added (r1.1.2.1) --- Log message: Pass to convert hand-coded parallelism to use `pbr' and intrinsic `llvm.join' --- Diffs of the changes: (+111 -0) Index: llvm/lib/Transforms/Parallel/PbrInjector.cpp diff -c /dev/null llvm/lib/Transforms/Parallel/PbrInjector.cpp:1.1.2.1 *** /dev/null Fri Apr 23 11:55:23 2004 --- llvm/lib/Transforms/Parallel/PbrInjector.cpp Fri Apr 23 11:55:13 2004 *************** *** 0 **** --- 1,111 ---- + //===- PbrInjector.cpp - Convert hand-parallel code to use `pbr' ---------===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This pass converts hand-annotated parallel code regions to use `pbr' + // + //===----------------------------------------------------------------------===// + + #include "llvm/DerivedTypes.h" + #include "llvm/Instructions.h" + #include "llvm/Module.h" + #include "llvm/Pass.h" + #include "llvm/Type.h" + #include + using namespace llvm; + + namespace { + + struct Parallelize : public FunctionPass { + Parallelize() {} + virtual bool runOnFunction(Function &F); + private: + Function* getPbrFunc(Module *M); + Function* getJoinFunc(Module *M); + Function* getJoinIntrinsic(Module *M); + }; + + RegisterOpt X("pbr-inject", "Convert `parallel' code to `pbr'"); + + } // End anonymous namespace + + + /// runOnFunction - convert uses of the parallelizer function to uses of pbr + /// + bool Parallelize::runOnFunction(Function &F) { + bool Changed = false; + Function *ParallelFn = getPbrFunc(F.getParent()); + if (ParallelFn->use_begin() == ParallelFn->use_end()) + return Changed; + + std::vector Users(ParallelFn->use_begin(), ParallelFn->use_end()); + for (std::vector::iterator u = Users.begin(), e = Users.end(); + u != e; ++u) { + // Check for the pattern as follows: + // %a = call int %__llvm_parallel() + // %b = seteq int %a, 0 + // br %b, %label_1, %label_2 + // + // Rewrite to: + // pbr %label_1, %label_2 + if (CallInst *CI = dyn_cast(*u)) { + if (SetCondInst *SCI = dyn_cast(*CI->use_begin())) { + if (BranchInst *BI = dyn_cast(*SCI->use_begin())) { + // Rewrite as above + BasicBlock *BB = BI->getParent(); + ParaBrInst *pbr = + new ParaBrInst(BI->getSuccessor(0), BI->getSuccessor(1), BB); + + // Before we erase the call, add a join instruction to match the `pbr' + + // Delete condition and branch instructions + BB->getInstList().erase(BI); + BB->getInstList().erase(SCI); + + // Convert calls to __llvm_join(%x = __llvm_pbr()) to + // uses of the %llvm.join intrinsic + std::vector PbrCallUsers(CI->use_begin(), CI->use_end()); + for (std::vector::iterator cu = PbrCallUsers.begin(), + cue = PbrCallUsers.end(); cu != cue; ++cu) { + if (CallInst *CJ = dyn_cast(*cu)) { + if (CJ->getCalledFunction()->getName() == "__llvm_join") { + Function *Join = getJoinIntrinsic(F.getParent()); + new CallInst(Join, pbr, "", CJ); + CJ->getParent()->getInstList().erase(CJ); + } + } + } + + BB->getInstList().erase(CI); + + Changed = true; + } + } + } + } + + return Changed; + } + + /// getParallelizer - find the function in the Module that marks parallel + /// regions + /// + Function* Parallelize::getPbrFunc(Module *M) { + return M->getOrInsertFunction("__llvm_pbr", PointerType::get(Type::SByteTy), + 0); + } + + Function* Parallelize::getJoinFunc(Module *M) { + return M->getOrInsertFunction("__llvm_join", Type::VoidTy, + PointerType::get(Type::SByteTy), 0); + } + + Function* Parallelize::getJoinIntrinsic(Module *M) { + return M->getOrInsertFunction("llvm.join", Type::VoidTy, + PointerType::get(Type::SByteTy), 0); + } From gaeke at cs.uiuc.edu Fri Apr 23 12:12:03 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Apr 23 12:12:03 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineCodeEmitter.h Message-ID: <200404231711.MAA12849@seraph.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineCodeEmitter.h updated: 1.16 -> 1.17 --- Log message: Add emitWordAt() - a quick and dirty interface that the machine-dependent emitters can use to emit "relocations". --- Diffs of the changes: (+6 -0) Index: llvm/include/llvm/CodeGen/MachineCodeEmitter.h diff -u llvm/include/llvm/CodeGen/MachineCodeEmitter.h:1.16 llvm/include/llvm/CodeGen/MachineCodeEmitter.h:1.17 --- llvm/include/llvm/CodeGen/MachineCodeEmitter.h:1.16 Tue Nov 11 16:41:31 2003 +++ llvm/include/llvm/CodeGen/MachineCodeEmitter.h Fri Apr 23 12:11:12 2004 @@ -63,6 +63,12 @@ /// virtual void emitByte(unsigned char B) {} + /// emitWordAt - This callback is invoked when a word needs to be written to + /// the output stream at a different position than the current PC (for + /// instance, when performing relocations). + /// + virtual void emitWordAt(unsigned W, unsigned *Ptr) {} + /// emitWord - This callback is invoked when a word needs to be written to the /// output stream. /// From gaeke at cs.uiuc.edu Fri Apr 23 12:12:07 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Apr 23 12:12:07 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/MachineCodeEmitter.cpp Message-ID: <200404231711.MAA12856@seraph.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: MachineCodeEmitter.cpp updated: 1.15 -> 1.16 --- Log message: Implement emitWordAt() for the debug emitter and the file printer emitter. (I am not so sure about the file printer emitter, but the debug emitter change should be harmless.) --- Diffs of the changes: (+7 -0) Index: llvm/lib/CodeGen/MachineCodeEmitter.cpp diff -u llvm/lib/CodeGen/MachineCodeEmitter.cpp:1.15 llvm/lib/CodeGen/MachineCodeEmitter.cpp:1.16 --- llvm/lib/CodeGen/MachineCodeEmitter.cpp:1.15 Mon Feb 23 12:38:20 2004 +++ llvm/lib/CodeGen/MachineCodeEmitter.cpp Fri Apr 23 12:11:13 2004 @@ -40,6 +40,10 @@ void emitWord(unsigned W) { std::cout << "0x" << std::hex << W << std::dec << " "; } + void emitWordAt(unsigned W, unsigned *Ptr) { + std::cout << "0x" << std::hex << W << std::dec << " (at " + << (void*) Ptr << ") "; + } uint64_t getGlobalValueAddress(GlobalValue *V) { return 0; } uint64_t getGlobalValueAddress(const std::string &Name) { return 0; } @@ -135,6 +139,9 @@ void emitWord(unsigned W) { MCE.emitWord(W); + } + void emitWordAt(unsigned W, unsigned *Ptr) { + MCE.emitWordAt(W, Ptr); } uint64_t getGlobalValueAddress(GlobalValue *V) { return MCE.getGlobalValueAddress(V); From gaeke at cs.uiuc.edu Fri Apr 23 12:12:11 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Apr 23 12:12:11 2004 Subject: [llvm-commits] CVS: llvm/lib/ExecutionEngine/JIT/Emitter.cpp Message-ID: <200404231711.MAA12863@seraph.cs.uiuc.edu> Changes in directory llvm/lib/ExecutionEngine/JIT: Emitter.cpp updated: 1.39 -> 1.40 --- Log message: Implement emitWordAt() for the JIT emitter. --- Diffs of the changes: (+5 -0) Index: llvm/lib/ExecutionEngine/JIT/Emitter.cpp diff -u llvm/lib/ExecutionEngine/JIT/Emitter.cpp:1.39 llvm/lib/ExecutionEngine/JIT/Emitter.cpp:1.40 --- llvm/lib/ExecutionEngine/JIT/Emitter.cpp:1.39 Sun Feb 8 13:33:07 2004 +++ llvm/lib/ExecutionEngine/JIT/Emitter.cpp Fri Apr 23 12:11:14 2004 @@ -150,6 +150,7 @@ virtual void* finishFunctionStub(const Function &F); virtual void emitByte(unsigned char B); virtual void emitWord(unsigned W); + virtual void emitWordAt(unsigned W, unsigned *Ptr); virtual uint64_t getGlobalValueAddress(GlobalValue *V); virtual uint64_t getGlobalValueAddress(const std::string &Name); @@ -242,6 +243,10 @@ // a JIT this can't happen though. :) *(unsigned*)CurByte = W; CurByte += sizeof(unsigned); +} + +void Emitter::emitWordAt(unsigned W, unsigned *Ptr) { + *Ptr = W; } uint64_t Emitter::getGlobalValueAddress(GlobalValue *V) { From gaeke at cs.uiuc.edu Fri Apr 23 12:12:14 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Apr 23 12:12:14 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/SparcV9CodeEmitter.cpp Message-ID: <200404231711.MAA12870@seraph.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9: SparcV9CodeEmitter.cpp updated: 1.58 -> 1.59 --- Log message: Emit SPARC machine code a word at a time instead of a byte at a time. Use emitWordAt() to emit forward-branch fixups. --- Diffs of the changes: (+5 -1) Index: llvm/lib/Target/SparcV9/SparcV9CodeEmitter.cpp diff -u llvm/lib/Target/SparcV9/SparcV9CodeEmitter.cpp:1.58 llvm/lib/Target/SparcV9/SparcV9CodeEmitter.cpp:1.59 --- llvm/lib/Target/SparcV9/SparcV9CodeEmitter.cpp:1.58 Wed Feb 25 12:44:15 2004 +++ llvm/lib/Target/SparcV9/SparcV9CodeEmitter.cpp Fri Apr 23 12:11:15 2004 @@ -468,12 +468,16 @@ } void SparcV9CodeEmitter::emitWord(unsigned Val) { +#if 0 // I think this was used when the Sparc JIT was being tested on X86: // Output the constant in big endian byte order... unsigned byteVal; for (int i = 3; i >= 0; --i) { byteVal = Val >> 8*i; MCE.emitByte(byteVal & 255); } +#else + MCE.emitWord(Val); +#endif } unsigned @@ -763,7 +767,7 @@ else if (hiBits64) { MI->setOperandHi64(ii); } DEBUG(std::cerr << "Rewrote BB ref: "); unsigned fixedInstr = SparcV9CodeEmitter::getBinaryCodeForInstr(*MI); - *Ref = fixedInstr; + MCE.emitWordAt (fixedInstr, Ref); break; } } From gaeke at cs.uiuc.edu Fri Apr 23 12:12:18 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Apr 23 12:12:18 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86CodeEmitter.cpp Message-ID: <200404231711.MAA12877@seraph.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86CodeEmitter.cpp updated: 1.58 -> 1.59 --- Log message: Use emitWordAt() to emit forward-branch fixups. --- Diffs of the changes: (+1 -1) Index: llvm/lib/Target/X86/X86CodeEmitter.cpp diff -u llvm/lib/Target/X86/X86CodeEmitter.cpp:1.58 llvm/lib/Target/X86/X86CodeEmitter.cpp:1.59 --- llvm/lib/Target/X86/X86CodeEmitter.cpp:1.58 Tue Apr 13 12:18:51 2004 +++ llvm/lib/Target/X86/X86CodeEmitter.cpp Fri Apr 23 12:11:16 2004 @@ -240,7 +240,7 @@ for (unsigned i = 0, e = BBRefs.size(); i != e; ++i) { unsigned Location = BasicBlockAddrs[BBRefs[i].first]; unsigned Ref = BBRefs[i].second; - *(unsigned*)(intptr_t)Ref = Location-Ref-4; + MCE.emitWordAt (Location-Ref-4, (unsigned*)(intptr_t)Ref); } BBRefs.clear(); BasicBlockAddrs.clear(); From gaeke at cs.uiuc.edu Fri Apr 23 12:12:22 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Apr 23 12:12:22 2004 Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp Message-ID: <200404231711.MAA12901@seraph.cs.uiuc.edu> Changes in directory reopt/lib/LightWtProfiling: RuntimeOptimizations.cpp updated: 1.27 -> 1.28 --- Log message: Go back to using the TraceOptEmitter. --- Diffs of the changes: (+1 -0) Index: reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp diff -u reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp:1.27 reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp:1.28 --- reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp:1.27 Wed Apr 21 16:05:30 2004 +++ reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp Fri Apr 23 12:11:40 2004 @@ -59,6 +59,7 @@ if (!Target) Target = allocateSparcV9TargetMachine (*MP->getModule (), IL); const TargetData &TD = Target->getTargetData (); if (!MCE) MCE = createTraceOptEmitter (TD); + //if (!MCE) MCE = MachineCodeEmitter::createDebugEmitter (); // Turn the vector of basic blocks into a Trace, and then turn the Trace into // a TraceFunction. From gaeke at cs.uiuc.edu Fri Apr 23 12:12:26 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Apr 23 12:12:26 2004 Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/TraceOptEmitter.cpp Message-ID: <200404231711.MAA12908@seraph.cs.uiuc.edu> Changes in directory reopt/lib/LightWtProfiling: TraceOptEmitter.cpp updated: 1.3 -> 1.4 --- Log message: Interface the TraceOptEmitter to Anand's VirtualMem i/o class. Turn emitByte() into a runtime error. Implement emitWordAt() for it. Add debugging printouts. --- Diffs of the changes: (+17 -2) Index: reopt/lib/LightWtProfiling/TraceOptEmitter.cpp diff -u reopt/lib/LightWtProfiling/TraceOptEmitter.cpp:1.3 reopt/lib/LightWtProfiling/TraceOptEmitter.cpp:1.4 --- reopt/lib/LightWtProfiling/TraceOptEmitter.cpp:1.3 Wed Apr 14 12:18:42 2004 +++ reopt/lib/LightWtProfiling/TraceOptEmitter.cpp Fri Apr 23 12:11:41 2004 @@ -22,6 +22,8 @@ //===----------------------------------------------------------------------===// #include "reopt/ScratchMemory.h" +#include "reopt/VirtualMem.h" +#include "ReoptimizerInternal.h" #include "llvm/Constant.h" #include "llvm/Module.h" #include "llvm/CodeGen/MachineCodeEmitter.h" @@ -67,6 +69,7 @@ } virtual void emitByte(unsigned char B); virtual void emitWord(unsigned W); + virtual void emitWordAt(unsigned W, unsigned *Ptr); virtual uint64_t getGlobalValueAddress(GlobalValue *V); virtual uint64_t getGlobalValueAddress(const std::string &Name); @@ -148,14 +151,26 @@ } void TraceOptEmitter::emitByte(unsigned char B) { - *CurByte++ = B; // Write the byte to memory + std::cerr << "TraceOptEmitter: attempt to emit a single byte: 0x" << std::hex << (unsigned)B << std::dec << " at cursor: " << (unsigned)(uintptr_t)CurByte << "\n"; + abort (); + // *CurByte = W; + ++CurByte; } void TraceOptEmitter::emitWord(unsigned W) { // This won't work if the endianness of the host and target don't agree! (For // a JIT this can't happen though. :) - *(unsigned*)CurByte = W; + std::cerr << "TraceOptEmitter: emitting word 0x" << std::hex << W + << " at cursor: " << (uint64_t)(uintptr_t)CurByte << std::dec + << "\n"; + vm->writeInstToVM (W, (uint64_t) CurByte); // does: *(unsigned*)CurByte = W; CurByte += sizeof(unsigned); +} + +void TraceOptEmitter::emitWordAt(unsigned W, unsigned *Ptr) { + std::cerr << "TraceOptEmitter: emitting word 0x" << std::hex << W + << std::dec << " at pointer: " << Ptr << "\n"; + vm->writeInstToVM (W, (uint64_t) Ptr); // does: *Ptr = W; } uint64_t TraceOptEmitter::getGlobalValueAddress(GlobalValue *V) { From gaeke at cs.uiuc.edu Fri Apr 23 12:12:29 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Apr 23 12:12:29 2004 Subject: [llvm-commits] CVS: reopt/lib/ScratchMemory/ScratchMemory.cpp Message-ID: <200404231711.MAA12915@seraph.cs.uiuc.edu> Changes in directory reopt/lib/ScratchMemory: ScratchMemory.cpp updated: 1.1 -> 1.2 --- Log message: Now that we know what dummyFunction2 is for, give it a more-descriptive name. --- Diffs of the changes: (+1 -1) Index: reopt/lib/ScratchMemory/ScratchMemory.cpp diff -u reopt/lib/ScratchMemory/ScratchMemory.cpp:1.1 reopt/lib/ScratchMemory/ScratchMemory.cpp:1.2 --- reopt/lib/ScratchMemory/ScratchMemory.cpp:1.1 Wed Aug 6 16:47:19 2003 +++ reopt/lib/ScratchMemory/ScratchMemory.cpp Fri Apr 23 12:11:42 2004 @@ -10,6 +10,6 @@ asm (".skip 17*8192"); // 17 empty 8KB pages } -extern "C" void dummyFunction2 () { +extern "C" void OptimizedTraceTextArea () { asm (".skip 17*8192"); // 17 more empty 8KB pages } From gaeke at cs.uiuc.edu Fri Apr 23 12:38:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Apr 23 12:38:01 2004 Subject: [llvm-commits] CVS: llvm/utils/fpcmp/fpcmp.cpp Message-ID: <200404231738.MAA12937@zion.cs.uiuc.edu> Changes in directory llvm/utils/fpcmp: fpcmp.cpp updated: 1.3 -> 1.4 --- Log message: mmap of a zero length file returns null on some platforms, so hack around it. --- Diffs of the changes: (+6 -0) Index: llvm/utils/fpcmp/fpcmp.cpp diff -u llvm/utils/fpcmp/fpcmp.cpp:1.3 llvm/utils/fpcmp/fpcmp.cpp:1.4 --- llvm/utils/fpcmp/fpcmp.cpp:1.3 Mon Apr 19 14:09:24 2004 +++ llvm/utils/fpcmp/fpcmp.cpp Fri Apr 23 12:38:17 2004 @@ -50,6 +50,12 @@ std::cerr << "Error: cannot open file '" << Filename << "'\n"; exit(2); } + + // If mmap decided that the files were empty, it might have returned a + // null pointer. If so, make a new, fake pointer -- it shouldn't matter + // what it contains, because Len is 0, and it should never be read. + if (BufPtr == 0 && Len == 0) + BufPtr = new char[1]; } static bool isNumberChar(char C) { From gaeke at cs.uiuc.edu Fri Apr 23 13:06:03 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Apr 23 13:06:03 2004 Subject: [llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp Message-ID: <200404231805.NAA15798@zion.cs.uiuc.edu> Changes in directory llvm/lib/ExecutionEngine/Interpreter: Execution.cpp updated: 1.126 -> 1.127 --- Log message: Go back to the interpreter main loop after performing intrinsic lowering, because 1) the first instruction might not be a call site, and 2) CS and SF.Caller were not getting set to point to the new call site anyway (resulting in a crash on e.g. call %llvm.memset). --- Diffs of the changes: (+1 -0) Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.126 llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.127 --- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.126 Tue Apr 20 11:43:21 2004 +++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp Fri Apr 23 13:05:28 2004 @@ -822,6 +822,7 @@ SF.CurInst = Prev; ++SF.CurInst; } + return; } SF.Caller = CS; From gaeke at cs.uiuc.edu Fri Apr 23 13:10:09 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Apr 23 13:10:09 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/SingleSource/Benchmarks/Shootout/Makefile Message-ID: <200404231809.NAA16589@zion.cs.uiuc.edu> Changes in directory llvm/test/Programs/SingleSource/Benchmarks/Shootout: Makefile updated: 1.3 -> 1.4 --- Log message: Enable some very simple testing of the Interpreter, to help in the fight against Interpreter bit rot. The Shootout tests should always all pass in the Interpreter, and it only takes about 8 1/2 seconds to run them on the ppc. And what's more, this would have caught the recent intrinsic lowering bug! --- Diffs of the changes: (+1 -0) Index: llvm/test/Programs/SingleSource/Benchmarks/Shootout/Makefile diff -u llvm/test/Programs/SingleSource/Benchmarks/Shootout/Makefile:1.3 llvm/test/Programs/SingleSource/Benchmarks/Shootout/Makefile:1.4 --- llvm/test/Programs/SingleSource/Benchmarks/Shootout/Makefile:1.3 Thu Sep 11 12:58:26 2003 +++ llvm/test/Programs/SingleSource/Benchmarks/Shootout/Makefile Fri Apr 23 13:09:29 2004 @@ -1,4 +1,5 @@ LEVEL = ../../../../.. LDFLAGS += -lm +ENABLE_LLI = 1 include $(LEVEL)/test/Programs/SingleSource/Makefile.singlesrc From gaeke at cs.uiuc.edu Fri Apr 23 13:11:03 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Apr 23 13:11:03 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/SparcV9CodeEmitter.cpp Message-ID: <200404231810.NAA16607@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9: SparcV9CodeEmitter.cpp updated: 1.59 -> 1.60 --- Log message: Get rid of the old byte-at-a-time emission code used when the Sparc JIT was being tested on X86, as per Chris's request. --- Diffs of the changes: (+0 -9) Index: llvm/lib/Target/SparcV9/SparcV9CodeEmitter.cpp diff -u llvm/lib/Target/SparcV9/SparcV9CodeEmitter.cpp:1.59 llvm/lib/Target/SparcV9/SparcV9CodeEmitter.cpp:1.60 --- llvm/lib/Target/SparcV9/SparcV9CodeEmitter.cpp:1.59 Fri Apr 23 12:11:15 2004 +++ llvm/lib/Target/SparcV9/SparcV9CodeEmitter.cpp Fri Apr 23 13:10:38 2004 @@ -468,16 +468,7 @@ } void SparcV9CodeEmitter::emitWord(unsigned Val) { -#if 0 // I think this was used when the Sparc JIT was being tested on X86: - // Output the constant in big endian byte order... - unsigned byteVal; - for (int i = 3; i >= 0; --i) { - byteVal = Val >> 8*i; - MCE.emitByte(byteVal & 255); - } -#else MCE.emitWord(Val); -#endif } unsigned From gaeke at cs.uiuc.edu Fri Apr 23 13:16:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Apr 23 13:16:01 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/InstrSched/SchedGraph.cpp Message-ID: <200404231815.NAA19074@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/InstrSched: SchedGraph.cpp updated: 1.59 -> 1.60 --- Log message: Include SparcV9RegInfo.h instead of TargetRegInfo.h. This serves as a bit of documentation that this module needs to be made independent of the register file description of the current target. --- Diffs of the changes: (+1 -1) Index: llvm/lib/CodeGen/InstrSched/SchedGraph.cpp diff -u llvm/lib/CodeGen/InstrSched/SchedGraph.cpp:1.59 llvm/lib/CodeGen/InstrSched/SchedGraph.cpp:1.60 --- llvm/lib/CodeGen/InstrSched/SchedGraph.cpp:1.59 Wed Feb 18 10:43:51 2004 +++ llvm/lib/CodeGen/InstrSched/SchedGraph.cpp Fri Apr 23 13:15:46 2004 @@ -20,7 +20,7 @@ #include "llvm/CodeGen/MachineFunction.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetMachine.h" -#include "llvm/Target/TargetRegInfo.h" +#include "../../Target/SparcV9/SparcV9RegInfo.h" #include "Support/STLExtras.h" namespace llvm { From gaeke at cs.uiuc.edu Fri Apr 23 13:16:05 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Apr 23 13:16:05 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/MachineInstrAnnot.h SparcV9FrameInfo.h SparcV9Internals.h SparcV9RegClassInfo.h Message-ID: <200404231815.NAA19093@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9: MachineInstrAnnot.h updated: 1.13 -> 1.14 SparcV9FrameInfo.h updated: 1.2 -> 1.3 SparcV9Internals.h updated: 1.112 -> 1.113 SparcV9RegClassInfo.h updated: 1.25 -> 1.26 --- Log message: Include SparcV9RegInfo.h instead of TargetRegInfo.h. --- Diffs of the changes: (+4 -4) Index: llvm/lib/Target/SparcV9/MachineInstrAnnot.h diff -u llvm/lib/Target/SparcV9/MachineInstrAnnot.h:1.13 llvm/lib/Target/SparcV9/MachineInstrAnnot.h:1.14 --- llvm/lib/Target/SparcV9/MachineInstrAnnot.h:1.13 Tue Nov 11 16:41:31 2003 +++ llvm/lib/Target/SparcV9/MachineInstrAnnot.h Fri Apr 23 13:15:47 2004 @@ -15,7 +15,7 @@ #define MACHINE_INSTR_ANNOT_h #include "llvm/CodeGen/MachineInstr.h" -#include "llvm/Target/TargetRegInfo.h" +#include "SparcV9RegInfo.h" namespace llvm { Index: llvm/lib/Target/SparcV9/SparcV9FrameInfo.h diff -u llvm/lib/Target/SparcV9/SparcV9FrameInfo.h:1.2 llvm/lib/Target/SparcV9/SparcV9FrameInfo.h:1.3 --- llvm/lib/Target/SparcV9/SparcV9FrameInfo.h:1.2 Wed Feb 25 12:44:15 2004 +++ llvm/lib/Target/SparcV9/SparcV9FrameInfo.h Fri Apr 23 13:15:47 2004 @@ -18,7 +18,7 @@ #include "llvm/Target/TargetFrameInfo.h" #include "llvm/Target/TargetMachine.h" -#include "llvm/Target/TargetRegInfo.h" +#include "SparcV9RegInfo.h" namespace llvm { Index: llvm/lib/Target/SparcV9/SparcV9Internals.h diff -u llvm/lib/Target/SparcV9/SparcV9Internals.h:1.112 llvm/lib/Target/SparcV9/SparcV9Internals.h:1.113 --- llvm/lib/Target/SparcV9/SparcV9Internals.h:1.112 Mon Mar 1 00:43:29 2004 +++ llvm/lib/Target/SparcV9/SparcV9Internals.h Fri Apr 23 13:15:47 2004 @@ -19,7 +19,7 @@ #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetSchedInfo.h" #include "llvm/Target/TargetFrameInfo.h" -#include "llvm/Target/TargetRegInfo.h" +#include "SparcV9RegInfo.h" #include "llvm/Type.h" #include "SparcV9RegClassInfo.h" #include "Config/sys/types.h" Index: llvm/lib/Target/SparcV9/SparcV9RegClassInfo.h diff -u llvm/lib/Target/SparcV9/SparcV9RegClassInfo.h:1.25 llvm/lib/Target/SparcV9/SparcV9RegClassInfo.h:1.26 --- llvm/lib/Target/SparcV9/SparcV9RegClassInfo.h:1.25 Mon Apr 19 13:53:42 2004 +++ llvm/lib/Target/SparcV9/SparcV9RegClassInfo.h Fri Apr 23 13:15:47 2004 @@ -14,7 +14,7 @@ #ifndef SPARCV9REGCLASSINFO_H #define SPARCV9REGCLASSINFO_H -#include "llvm/Target/TargetRegInfo.h" +#include "SparcV9RegInfo.h" namespace llvm { From gaeke at cs.uiuc.edu Fri Apr 23 13:16:08 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Apr 23 13:16:08 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp PhyRegAlloc.h RegClass.cpp RegClass.h Message-ID: <200404231815.NAA19117@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9/RegAlloc: LiveRangeInfo.cpp updated: 1.51 -> 1.52 PhyRegAlloc.h updated: 1.64 -> 1.65 RegClass.cpp updated: 1.28 -> 1.29 RegClass.h updated: 1.21 -> 1.22 --- Log message: Include SparcV9RegInfo.h instead of TargetRegInfo.h. --- Diffs of the changes: (+4 -4) Index: llvm/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp diff -u llvm/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp:1.51 llvm/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp:1.52 --- llvm/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp:1.51 Fri Feb 13 15:01:19 2004 +++ llvm/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp Fri Apr 23 13:15:47 2004 @@ -20,7 +20,7 @@ #include "llvm/CodeGen/MachineFunction.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetInstrInfo.h" -#include "llvm/Target/TargetRegInfo.h" +#include "../SparcV9RegInfo.h" #include "Support/SetOperations.h" namespace llvm { Index: llvm/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.h diff -u llvm/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.h:1.64 llvm/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.h:1.65 --- llvm/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.h:1.64 Thu Mar 11 00:45:52 2004 +++ llvm/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.h Fri Apr 23 13:15:47 2004 @@ -28,7 +28,7 @@ #include "llvm/Pass.h" #include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/Target/TargetMachine.h" -#include "llvm/Target/TargetRegInfo.h" +#include "../SparcV9RegInfo.h" #include namespace llvm { Index: llvm/lib/Target/SparcV9/RegAlloc/RegClass.cpp diff -u llvm/lib/Target/SparcV9/RegAlloc/RegClass.cpp:1.28 llvm/lib/Target/SparcV9/RegAlloc/RegClass.cpp:1.29 --- llvm/lib/Target/SparcV9/RegAlloc/RegClass.cpp:1.28 Tue Nov 11 16:41:33 2003 +++ llvm/lib/Target/SparcV9/RegAlloc/RegClass.cpp Fri Apr 23 13:15:47 2004 @@ -14,7 +14,7 @@ #include "IGNode.h" #include "RegAllocCommon.h" #include "RegClass.h" -#include "llvm/Target/TargetRegInfo.h" +#include "../SparcV9RegInfo.h" namespace llvm { Index: llvm/lib/Target/SparcV9/RegAlloc/RegClass.h diff -u llvm/lib/Target/SparcV9/RegAlloc/RegClass.h:1.21 llvm/lib/Target/SparcV9/RegAlloc/RegClass.h:1.22 --- llvm/lib/Target/SparcV9/RegAlloc/RegClass.h:1.21 Tue Nov 11 16:41:33 2003 +++ llvm/lib/Target/SparcV9/RegAlloc/RegClass.h Fri Apr 23 13:15:47 2004 @@ -17,7 +17,7 @@ #ifndef REGCLASS_H #define REGCLASS_H -#include "llvm/Target/TargetRegInfo.h" +#include "../SparcV9RegInfo.h" #include "InterferenceGraph.h" #include From gaeke at cs.uiuc.edu Fri Apr 23 13:16:11 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Apr 23 13:16:11 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp InstrSelectionSupport.cpp Message-ID: <200404231815.NAA19103@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9/InstrSelection: InstrSelection.cpp updated: 1.71 -> 1.72 InstrSelectionSupport.cpp updated: 1.66 -> 1.67 --- Log message: Include SparcV9RegInfo.h instead of TargetRegInfo.h. --- Diffs of the changes: (+2 -2) Index: llvm/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp diff -u llvm/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp:1.71 llvm/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp:1.72 --- llvm/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp:1.71 Wed Apr 7 15:55:32 2004 +++ llvm/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp Fri Apr 23 13:15:47 2004 @@ -24,7 +24,7 @@ #include "llvm/CodeGen/MachineCodeForInstruction.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/Target/TargetMachine.h" -#include "llvm/Target/TargetRegInfo.h" +#include "../SparcV9RegInfo.h" #include "Support/CommandLine.h" #include "Support/LeakDetector.h" Index: llvm/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp diff -u llvm/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp:1.66 llvm/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp:1.67 --- llvm/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp:1.66 Wed Apr 7 15:38:56 2004 +++ llvm/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp Fri Apr 23 13:15:47 2004 @@ -17,7 +17,7 @@ #include "llvm/CodeGen/MachineCodeForInstruction.h" #include "llvm/CodeGen/InstrForest.h" #include "llvm/Target/TargetMachine.h" -#include "llvm/Target/TargetRegInfo.h" +#include "../SparcV9RegInfo.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Constants.h" #include "llvm/BasicBlock.h" From gaeke at cs.uiuc.edu Fri Apr 23 13:16:14 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Apr 23 13:16:14 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/SparcV9RegInfo.h Message-ID: <200404231815.NAA19143@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9: SparcV9RegInfo.h updated: 1.11 -> 1.12 --- Log message: Merge TargetRegInfo.h into SparcV9RegInfo.h, which is its only subclass. This prepares us to be able to de-virtualize and de-abstract it, and take the register allocator bits out and move them into the register allocator proper... --- Diffs of the changes: (+280 -5) Index: llvm/lib/Target/SparcV9/SparcV9RegInfo.h diff -u llvm/lib/Target/SparcV9/SparcV9RegInfo.h:1.11 llvm/lib/Target/SparcV9/SparcV9RegInfo.h:1.12 --- llvm/lib/Target/SparcV9/SparcV9RegInfo.h:1.11 Mon Apr 19 13:53:44 2004 +++ llvm/lib/Target/SparcV9/SparcV9RegInfo.h Fri Apr 23 13:15:48 2004 @@ -1,4 +1,4 @@ -//===-- SparcV9RegInfo.h - Define TargetRegInfo for SparcV9 ---------*- C++ -*-===// +//===-- SparcV9RegInfo.h - SparcV9 Target Register Info ---------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,19 +7,294 @@ // //===----------------------------------------------------------------------===// // -// This class implements the virtual class TargetRegInfo for SparcV9. +// This file is used to describe the register file of the SparcV9 target to +// its register allocator. // -//---------------------------------------------------------------------------- +//===----------------------------------------------------------------------===// #ifndef SPARCV9REGINFO_H #define SPARCV9REGINFO_H -#include "llvm/Target/TargetRegInfo.h" +#include "Support/hash_map" +#include +#include namespace llvm { +class TargetMachine; +class IGNode; +class Type; +class Value; +class LiveRangeInfo; +class Function; +class LiveRange; +class AddedInstrns; +class MachineInstr; +class BasicBlock; class SparcV9TargetMachine; + +///---------------------------------------------------------------------------- +/// Interface to description of machine register class (e.g., int reg class +/// float reg class etc) +/// +class TargetRegClassInfo { +protected: + const unsigned RegClassID; // integer ID of a reg class + const unsigned NumOfAvailRegs; // # of avail for coloring -without SP etc. + const unsigned NumOfAllRegs; // # of all registers -including SP,g0 etc. + +public: + inline unsigned getRegClassID() const { return RegClassID; } + inline unsigned getNumOfAvailRegs() const { return NumOfAvailRegs; } + inline unsigned getNumOfAllRegs() const { return NumOfAllRegs; } + + // This method marks the registers used for a given register number. + // This defaults to marking a single register but may mark multiple + // registers when a single number denotes paired registers. + // + virtual void markColorsUsed(unsigned RegInClass, + int UserRegType, + int RegTypeWanted, + std::vector &IsColorUsedArr) const { + assert(RegInClass < NumOfAllRegs && RegInClass < IsColorUsedArr.size()); + assert(UserRegType == RegTypeWanted && + "Default method is probably incorrect for class with multiple types."); + IsColorUsedArr[RegInClass] = true; + } + + // This method finds unused registers of the specified register type, + // using the given "used" flag array IsColorUsedArr. It defaults to + // checking a single entry in the array directly, but that can be overridden + // for paired registers and other such silliness. + // It returns -1 if no unused color is found. + // + virtual int findUnusedColor(int RegTypeWanted, + const std::vector &IsColorUsedArr) const { + // find first unused color in the IsColorUsedArr directly + unsigned NC = this->getNumOfAvailRegs(); + assert(IsColorUsedArr.size() >= NC && "Invalid colors-used array"); + for (unsigned c = 0; c < NC; c++) + if (!IsColorUsedArr[c]) + return c; + return -1; + } + + // This method should find a color which is not used by neighbors + // (i.e., a false position in IsColorUsedArr) and + virtual void colorIGNode(IGNode *Node, + const std::vector &IsColorUsedArr) const = 0; + + // Check whether a specific register is volatile, i.e., whether it is not + // preserved across calls + virtual bool isRegVolatile(int Reg) const = 0; + + // Check whether a specific register is modified as a side-effect of the + // call instruction itself, + virtual bool modifiedByCall(int Reg) const {return false; } + + virtual const char* const getRegName(unsigned reg) const = 0; + + TargetRegClassInfo(unsigned ID, unsigned NVR, unsigned NAR) + : RegClassID(ID), NumOfAvailRegs(NVR), NumOfAllRegs(NAR) {} +}; + + +//--------------------------------------------------------------------------- +/// TargetRegInfo - Interface to register info of target machine +/// +class TargetRegInfo { + TargetRegInfo(const TargetRegInfo &); // DO NOT IMPLEMENT + void operator=(const TargetRegInfo &); // DO NOT IMPLEMENT +protected: + // A vector of all machine register classes + // + std::vector MachineRegClassArr; + +public: + const TargetMachine ⌖ + + // A register can be initialized to an invalid number. That number can + // be obtained using this method. + // + static int getInvalidRegNum() { return -1; } + + TargetRegInfo(const TargetMachine& tgt) : target(tgt) { } + virtual ~TargetRegInfo() { + for (unsigned i = 0, e = MachineRegClassArr.size(); i != e; ++i) + delete MachineRegClassArr[i]; + } + + // According the definition of a MachineOperand class, a Value in a + // machine instruction can go into either a normal register or a + // condition code register. If isCCReg is true below, the ID of the condition + // code register class will be returned. Otherwise, the normal register + // class (eg. int, float) must be returned. + virtual unsigned getRegClassIDOfType (const Type *type, + bool isCCReg = false) const = 0; + virtual unsigned getRegClassIDOfRegType(int regType) const = 0; + + unsigned getRegClassIDOfReg(int unifiedRegNum) const { + unsigned classId = 0; + (void) getClassRegNum(unifiedRegNum, classId); + return classId; + } + + unsigned int getNumOfRegClasses() const { + return MachineRegClassArr.size(); + } + + const TargetRegClassInfo *getMachineRegClass(unsigned i) const { + return MachineRegClassArr[i]; + } + + // returns the register that is hardwired to zero if any (-1 if none) + // + virtual unsigned getZeroRegNum() const = 0; + + // Number of registers used for passing int args (usually 6: %o0 - %o5) + // and float args (usually 32: %f0 - %f31) + // + virtual unsigned const getNumOfIntArgRegs() const = 0; + virtual unsigned const getNumOfFloatArgRegs() const = 0; + + // The following methods are used to color special live ranges (e.g. + // method args and return values etc.) with specific hardware registers + // as required. See SparcRegInfo.cpp for the implementation for Sparc. + // + virtual void suggestRegs4MethodArgs(const Function *Func, + LiveRangeInfo& LRI) const = 0; + + virtual void suggestRegs4CallArgs(MachineInstr *CallI, + LiveRangeInfo& LRI) const = 0; + + virtual void suggestReg4RetValue(MachineInstr *RetI, + LiveRangeInfo& LRI) const = 0; + + virtual void colorMethodArgs(const Function *Func, + LiveRangeInfo &LRI, + std::vector& InstrnsBefore, + std::vector& InstrnsAfter) const = 0; + + // The following methods are used to generate "copy" machine instructions + // for an architecture. Currently they are used in TargetRegClass + // interface. However, they can be moved to TargetInstrInfo interface if + // necessary. + // + // The function regTypeNeedsScratchReg() can be used to check whether a + // scratch register is needed to copy a register of type `regType' to + // or from memory. If so, such a scratch register can be provided by + // the caller (e.g., if it knows which regsiters are free); otherwise + // an arbitrary one will be chosen and spilled by the copy instructions. + // If a scratch reg is needed, the reg. type that must be used + // for scratch registers is returned in scratchRegType. + // + virtual bool regTypeNeedsScratchReg(int RegType, + int& scratchRegType) const = 0; + + virtual void cpReg2RegMI(std::vector& mvec, + unsigned SrcReg, unsigned DestReg, + int RegType) const = 0; + + virtual void cpReg2MemMI(std::vector& mvec, + unsigned SrcReg, unsigned DestPtrReg, int Offset, + int RegType, int scratchReg = -1) const=0; + + virtual void cpMem2RegMI(std::vector& mvec, + unsigned SrcPtrReg, int Offset, unsigned DestReg, + int RegType, int scratchReg = -1) const=0; + + virtual void cpValue2Value(Value *Src, Value *Dest, + std::vector& mvec) const = 0; + + // Check whether a specific register is volatile, i.e., whether it is not + // preserved across calls + inline virtual bool isRegVolatile(int RegClassID, int Reg) const { + return MachineRegClassArr[RegClassID]->isRegVolatile(Reg); + } + + // Check whether a specific register is modified as a side-effect of the + // call instruction itself, + inline virtual bool modifiedByCall(int RegClassID, int Reg) const { + return MachineRegClassArr[RegClassID]->modifiedByCall(Reg); + } + + // Returns the reg used for pushing the address when a method is called. + // This can be used for other purposes between calls + // + virtual unsigned getCallAddressReg() const = 0; + + // Returns the register containing the return address. + //It should be made sure that this + // register contains the return value when a return instruction is reached. + // + virtual unsigned getReturnAddressReg() const = 0; + + + // Each register class has a separate space for register IDs. To convert + // a regId in a register class to a common Id, or vice versa, + // we use the folloing two methods. + // + // This method converts from class reg. number to unified register number. + int getUnifiedRegNum(unsigned regClassID, int reg) const { + if (reg == getInvalidRegNum()) { return getInvalidRegNum(); } + assert(regClassID < getNumOfRegClasses() && "Invalid register class"); + int totalRegs = 0; + for (unsigned rcid = 0; rcid < regClassID; ++rcid) + totalRegs += MachineRegClassArr[rcid]->getNumOfAllRegs(); + return reg + totalRegs; + } + + // This method converts the unified number to the number in its class, + // and returns the class ID in regClassID. + int getClassRegNum(int uRegNum, unsigned& regClassID) const { + if (uRegNum == getInvalidRegNum()) { return getInvalidRegNum(); } + + int totalRegs = 0, rcid = 0, NC = getNumOfRegClasses(); + while (rcid < NC && + uRegNum>= totalRegs+(int)MachineRegClassArr[rcid]->getNumOfAllRegs()) + { + totalRegs += MachineRegClassArr[rcid]->getNumOfAllRegs(); + rcid++; + } + if (rcid == NC) { + assert(0 && "getClassRegNum(): Invalid register number"); + return getInvalidRegNum(); + } + regClassID = rcid; + return uRegNum - totalRegs; + } + + // Returns the assembly-language name of the specified machine register. + // + const char * const getUnifiedRegName(int UnifiedRegNum) const { + unsigned regClassID = getNumOfRegClasses(); // initialize to invalid value + int regNumInClass = getClassRegNum(UnifiedRegNum, regClassID); + return MachineRegClassArr[regClassID]->getRegName(regNumInClass); + } + + // Get the register type for a register identified different ways. + // Note that getRegTypeForLR(LR) != getRegTypeForDataType(LR->getType())! + // The reg class of a LR depends both on the Value types in it and whether + // they are CC registers or not (for example). + virtual int getRegTypeForDataType(const Type* type) const = 0; + virtual int getRegTypeForLR(const LiveRange *LR) const = 0; + virtual int getRegType(int unifiedRegNum) const = 0; + + // The following methods are used to get the frame/stack pointers + // + virtual unsigned getFramePointer() const = 0; + virtual unsigned getStackPointer() const = 0; + + // This method gives the the number of bytes of stack spaceallocated + // to a register when it is spilled to the stack. + // + virtual int getSpilledRegSize(int RegType) const = 0; +}; + + +/// This class implements the virtual class TargetRegInfo for SparcV9. +/// class SparcV9RegInfo : public TargetRegInfo { private: // Number of registers used for passing int args (usually 6: %o0 - %o5) @@ -188,4 +463,4 @@ } // End llvm namespace -#endif +#endif // SPARCV9REGINFO_H From gaeke at cs.uiuc.edu Fri Apr 23 13:17:02 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Apr 23 13:17:02 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Target/TargetRegInfo.h Message-ID: <200404231817.NAA19483@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Target: TargetRegInfo.h (r1.48) removed --- Log message: Merged this file into the SparcV9 target. --- Diffs of the changes: (+0 -0) From lattner at cs.uiuc.edu Fri Apr 23 14:22:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Apr 23 14:22:01 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/Makefile.spec Message-ID: <200404231922.OAA07161@zion.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC: Makefile.spec updated: 1.29 -> 1.30 --- Log message: Fix the print-profile target for spec, add OPTPASSES debugging support --- Diffs of the changes: (+2 -1) Index: llvm/test/Programs/External/SPEC/Makefile.spec diff -u llvm/test/Programs/External/SPEC/Makefile.spec:1.29 llvm/test/Programs/External/SPEC/Makefile.spec:1.30 --- llvm/test/Programs/External/SPEC/Makefile.spec:1.29 Fri Mar 5 11:13:49 2004 +++ llvm/test/Programs/External/SPEC/Makefile.spec Fri Apr 23 14:22:06 2004 @@ -145,7 +145,7 @@ Output/%.bugpoint-gccld: Output/%.noopt-llvm.bc $(LBUGPOINT) \ Output/gccld-pass-args Output/%.out-nat $(SPEC_SANDBOX) bugpoint-$(RUN_TYPE) $@ $(REF_IN_DIR) \ - $(LBUGPOINT) ../../$< `cat Output/gccld-pass-args` $(BUGPOINT_OPTIONS) + $(LBUGPOINT) ../../$< `cat Output/gccld-pass-args` $(OPTPASSES) $(BUGPOINT_OPTIONS) @echo "===> Leaving Output/bugpoint-$(RUN_TYPE)" $(PROGRAMS_TO_TEST:%=Output/%.bugpoint-llc): \ @@ -172,6 +172,7 @@ -fake-argv0 '../$*.llvm.bc' -load ../../$(LIBPROFILESO) ../../$< -llvmprof-output ../../$@ $(RUN_OPTIONS) -(cd Output/profile-$(RUN_TYPE); cat $(LOCAL_OUTPUTS)) > Output/$*.out-prof -cp Output/profile-$(RUN_TYPE)/$(STDOUT_FILENAME).time $@.time + -cp Output/profile-$(RUN_TYPE)/llvmprof.out $@ @cmp -s Output/$*.out-prof Output/$*.out-nat || \ printf "***\n***\n*** WARNING: Output of profiled program (Output/$*.out-prof)\n*** doesn't match the output of the native program (Output/$*.out-nat)!\n***\n***\n"; From lattner at cs.uiuc.edu Fri Apr 23 14:22:21 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Apr 23 14:22:21 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/Makefile.programs Message-ID: <200404231922.OAA07178@zion.cs.uiuc.edu> Changes in directory llvm/test/Programs: Makefile.programs updated: 1.128 -> 1.129 --- Log message: Add OPTPASSES debugging support --- Diffs of the changes: (+1 -1) Index: llvm/test/Programs/Makefile.programs diff -u llvm/test/Programs/Makefile.programs:1.128 llvm/test/Programs/Makefile.programs:1.129 --- llvm/test/Programs/Makefile.programs:1.128 Sat Apr 17 18:24:42 2004 +++ llvm/test/Programs/Makefile.programs Fri Apr 23 14:22:21 2004 @@ -384,7 +384,7 @@ $(PROGRAMS_TO_TEST:%=Output/%.bugpoint-gccld): \ Output/%.bugpoint-gccld: Output/%.nogccldopt-llvm.bc $(LBUGPOINT) \ Output/gccld-pass-args Output/%.out-nat - $(LBUGPOINT) $< `cat Output/gccld-pass-args` $(BUGPOINT_OPTIONS) + $(LBUGPOINT) $< `cat Output/gccld-pass-args` $(OPTPASSES) $(BUGPOINT_OPTIONS) $(PROGRAMS_TO_TEST:%=Output/%.bugpoint-llc): \ Output/%.bugpoint-llc: Output/%.llvm.bc $(LBUGPOINT) Output/%.out-nat From brukman at cs.uiuc.edu Fri Apr 23 14:27:03 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Fri Apr 23 14:27:03 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/Makefile.spec Message-ID: <200404231926.OAA07793@zion.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC: Makefile.spec updated: 1.30 -> 1.31 --- Log message: Wrap long lines. --- Diffs of the changes: (+4 -2) Index: llvm/test/Programs/External/SPEC/Makefile.spec diff -u llvm/test/Programs/External/SPEC/Makefile.spec:1.30 llvm/test/Programs/External/SPEC/Makefile.spec:1.31 --- llvm/test/Programs/External/SPEC/Makefile.spec:1.30 Fri Apr 23 14:22:06 2004 +++ llvm/test/Programs/External/SPEC/Makefile.spec Fri Apr 23 14:26:29 2004 @@ -138,14 +138,16 @@ Output/%.bugpoint-gccas: Output/%.noopt-llvm.bc $(LBUGPOINT) \ Output/gccas-pass-args Output/%.out-nat $(SPEC_SANDBOX) bugpoint-$(RUN_TYPE) $@ $(REF_IN_DIR) \ - $(LBUGPOINT) ../../$< `cat Output/gccas-pass-args` $(BUGPOINT_OPTIONS) + $(LBUGPOINT) ../../$< `cat Output/gccas-pass-args` $(OPTPASSES) \ + $(BUGPOINT_OPTIONS) @echo "===> Leaving Output/bugpoint-$(RUN_TYPE)" $(PROGRAMS_TO_TEST:%=Output/%.bugpoint-gccld): \ Output/%.bugpoint-gccld: Output/%.noopt-llvm.bc $(LBUGPOINT) \ Output/gccld-pass-args Output/%.out-nat $(SPEC_SANDBOX) bugpoint-$(RUN_TYPE) $@ $(REF_IN_DIR) \ - $(LBUGPOINT) ../../$< `cat Output/gccld-pass-args` $(OPTPASSES) $(BUGPOINT_OPTIONS) + $(LBUGPOINT) ../../$< `cat Output/gccld-pass-args` $(OPTPASSES) \ + $(BUGPOINT_OPTIONS) @echo "===> Leaving Output/bugpoint-$(RUN_TYPE)" $(PROGRAMS_TO_TEST:%=Output/%.bugpoint-llc): \ From gaeke at cs.uiuc.edu Fri Apr 23 14:43:02 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Apr 23 14:43:02 2004 Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/TraceOptEmitter.cpp Message-ID: <200404231942.OAA16355@seraph.cs.uiuc.edu> Changes in directory reopt/lib/LightWtProfiling: TraceOptEmitter.cpp updated: 1.4 -> 1.5 --- Log message: Use the doFlush() utility to try to make sure that bytes are actually written to the address space. This is what the other Reoptimizer components do, so it probably works... we'll find out. --- Diffs of the changes: (+3 -0) Index: reopt/lib/LightWtProfiling/TraceOptEmitter.cpp diff -u reopt/lib/LightWtProfiling/TraceOptEmitter.cpp:1.4 reopt/lib/LightWtProfiling/TraceOptEmitter.cpp:1.5 --- reopt/lib/LightWtProfiling/TraceOptEmitter.cpp:1.4 Fri Apr 23 12:11:41 2004 +++ reopt/lib/LightWtProfiling/TraceOptEmitter.cpp Fri Apr 23 14:42:30 2004 @@ -23,6 +23,7 @@ #include "reopt/ScratchMemory.h" #include "reopt/VirtualMem.h" +#include "reopt/InstrUtils.h" #include "ReoptimizerInternal.h" #include "llvm/Constant.h" #include "llvm/Module.h" @@ -164,6 +165,7 @@ << " at cursor: " << (uint64_t)(uintptr_t)CurByte << std::dec << "\n"; vm->writeInstToVM (W, (uint64_t) CurByte); // does: *(unsigned*)CurByte = W; + doFlush ((uint64_t) CurByte, (uint64_t) CurByte + sizeof (unsigned)); CurByte += sizeof(unsigned); } @@ -171,6 +173,7 @@ std::cerr << "TraceOptEmitter: emitting word 0x" << std::hex << W << std::dec << " at pointer: " << Ptr << "\n"; vm->writeInstToVM (W, (uint64_t) Ptr); // does: *Ptr = W; + doFlush ((uint64_t) Ptr, (uint64_t) Ptr + sizeof (unsigned)); } uint64_t TraceOptEmitter::getGlobalValueAddress(GlobalValue *V) { From gaeke at cs.uiuc.edu Fri Apr 23 15:11:03 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Apr 23 15:11:03 2004 Subject: [llvm-commits] CVS: reopt/lib/TraceCache/InstrUtils.cpp Message-ID: <200404232010.PAA16520@seraph.cs.uiuc.edu> Changes in directory reopt/lib/TraceCache: InstrUtils.cpp updated: 1.15 -> 1.16 --- Log message: Make doFlush() round down addresses to the next doubleword boundary correctly. Document getDepJumpInstr(). --- Diffs of the changes: (+19 -9) Index: reopt/lib/TraceCache/InstrUtils.cpp diff -u reopt/lib/TraceCache/InstrUtils.cpp:1.15 reopt/lib/TraceCache/InstrUtils.cpp:1.16 --- reopt/lib/TraceCache/InstrUtils.cpp:1.15 Wed Nov 19 16:51:51 2003 +++ reopt/lib/TraceCache/InstrUtils.cpp Fri Apr 23 15:10:35 2004 @@ -70,15 +70,25 @@ return ((a&0xfff80000U)|diff|sgn); } -unsigned int getDepJumpInstr(unsigned int a, uint64_t to, uint64_t pc){ - if(to>pc) - assert((to-pc)/4<2097152 && "Can't fit target!"); +/// getDepJumpInstr - Returns a PC-relative branch instruction from +/// address FROM to address TO of the same conditionality (BA, BN, BNE, BE, +/// BG...) as INSTR. INSTR must be a Bicc instruction (branch on integer +/// condition codes with no prediction), and FROM must be its address in +/// memory. +/// +unsigned int getDepJumpInstr(unsigned int instr, uint64_t to, uint64_t from) { + if(to>from) + assert((to-from)/4<2097152 && "Can't fit target!"); else - assert((pc-to)/4<2097152 && "Can't fit target!"); + assert((from-to)/4<2097152 && "Can't fit target!"); - unsigned int diff = (((to-pc)/4)&0x1fffff); - unsigned int sgn = ((to < pc) ? (1 << 21) : 0); - return ((a&0xffc00000)|diff|sgn); + // Compute new 22-bit PC-relative branch target. + unsigned int diff = ((to - from) / 4) & 0x1fffff; + unsigned int sgn = ((to < from) ? (1 << 21) : 0); + + // Mask out the instruction's old branch target, OR in the new one, + // and return it. + return ((instr&0xffc00000)|diff|sgn); } uint64_t getBPRTarget(unsigned int b, uint64_t oldAdd){ @@ -149,8 +159,8 @@ void doFlush(uint64_t st_addr, uint64_t end_addr){ #ifdef __sparc__ - if(st_addr%8 != 0) - st_addr -=4; + if(st_addr % 8 != 0) + st_addr &= ~7; // Round down to the next lower doubleword boundary for(uint64_t i = st_addr; i<=end_addr; i+=8){ asm("flush %0"::"r" (i)); } From gaeke at cs.uiuc.edu Fri Apr 23 15:35:08 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Apr 23 15:35:08 2004 Subject: [llvm-commits] CVS: reopt/lib/TraceCache/MemoryManager.cpp Message-ID: <200404232034.PAA16956@seraph.cs.uiuc.edu> Changes in directory reopt/lib/TraceCache: MemoryManager.cpp updated: 1.13 -> 1.14 --- Log message: Refactor redundant code into the initialize() method. Make all three constructors share it. --- Diffs of the changes: (+18 -34) Index: reopt/lib/TraceCache/MemoryManager.cpp diff -u reopt/lib/TraceCache/MemoryManager.cpp:1.13 reopt/lib/TraceCache/MemoryManager.cpp:1.14 --- reopt/lib/TraceCache/MemoryManager.cpp:1.13 Wed Nov 19 16:51:51 2003 +++ reopt/lib/TraceCache/MemoryManager.cpp Fri Apr 23 15:34:01 2004 @@ -30,47 +30,31 @@ using namespace llvm; -MemoryManager::MemoryManager(){ - uint64_t memAlign = (uint64_t)(intptr_t)&FirstTraceFunction; - if(memAlign % 32){ - memAlign -= (memAlign % 32); - memAlign += 32; +void MemoryManager::initialize () { + uint64_t unalignedStart = (uint64_t)(intptr_t)startOfMemoryArea; + memStart = unalignedStart; + // Align it to a 32-byte boundary + if (memStart % 32) { + memStart -= (memStart % 32); + memStart += 32; } - - memStart = memAlign; - memEnd = (uint64_t)(intptr_t)&FirstTraceFunction+globalMemSize*4; - - memorySize = globalMemSize; - + memEnd = unalignedStart + memorySize * 4; freeMemList.push_back(std::make_pair(memStart, memEnd)); } -MemoryManager::MemoryManager(unsigned int memSize){ - uint64_t memAlign = (uint64_t)(intptr_t)&FirstTraceFunction; - if(memAlign % 32){ - memAlign -= (memAlign % 32); - memAlign += 32; - } - - memorySize = memSize; - - memStart = memAlign; - memEnd = (uint64_t)(intptr_t)&FirstTraceFunction+memSize*4; - freeMemList.push_back(std::make_pair(memStart, memEnd)); +MemoryManager::MemoryManager () + : memorySize (globalMemSize), startOfMemoryArea (FirstTraceFunction) { + initialize (); } -MemoryManager::MemoryManager(void (*dfunc)(), unsigned int memSize){ - uint64_t memAlign = (uint64_t)(intptr_t)dfunc; - if(memAlign % 32){ - memAlign -= (memAlign % 32); - memAlign += 32; - } - - memorySize = memSize; +MemoryManager::MemoryManager (unsigned int memSize) + : memorySize (memSize), startOfMemoryArea (FirstTraceFunction) { + initialize (); +} - memStart = memAlign; - memEnd = (uint64_t)(intptr_t)dfunc+memSize*4; - freeMemList.push_back(std::make_pair(memStart, memEnd)); +MemoryManager::MemoryManager (void (*dummyFunctionPtr) (), unsigned int memSize) + : memorySize (memSize), startOfMemoryArea (dummyFunctionPtr) { + initialize (); } //allocate the first free memory From gaeke at cs.uiuc.edu Fri Apr 23 15:37:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Apr 23 15:37:01 2004 Subject: [llvm-commits] CVS: reopt/include/reopt/MemoryManager.h Message-ID: <200404232036.PAA16976@seraph.cs.uiuc.edu> Changes in directory reopt/include/reopt: MemoryManager.h updated: 1.6 -> 1.7 --- Log message: Spiff this header file up, with documentation and whatnot. Add the private initialize() method and startOfMemoryArea pointer. --- Diffs of the changes: (+51 -13) Index: reopt/include/reopt/MemoryManager.h diff -u reopt/include/reopt/MemoryManager.h:1.6 reopt/include/reopt/MemoryManager.h:1.7 --- reopt/include/reopt/MemoryManager.h:1.6 Wed Nov 19 16:51:42 2003 +++ reopt/include/reopt/MemoryManager.h Fri Apr 23 15:35:52 2004 @@ -31,28 +31,66 @@ namespace llvm { +/// This is the assumed size of the FirstTraceFunction in words. +/// static const int globalMemSize = 10000; +/// MemoryManager - Performs simple memory management for the trace cache. +/// class MemoryManager{ private: + /// memStart, memEnd - Start and end addresses (respectively) of the + /// area managed by this memory manager. + /// uint64_t memStart, memEnd; + + /// memorySize - Total size in 32-bit words of the area managed by + /// this memory manager. + /// unsigned int memorySize; + std::list > freeMemList; + /// "Dummy function" pointer pointing to space in the text section reserved + /// for use by *this* MemoryManager. + /// + void (*startOfMemoryArea)(); + + /// Common constructor code lives in this function. + /// + void initialize (); + public: - //Memory management - //Ctor: using default memory manager function as space - MemoryManager(); //Constructor - //make sure memsize is < number of instructions in dumyFunc - MemoryManager(unsigned int memSize); //Constructor - - //Ctor: Using user provided function for space. The size of memory - //is assumed as memSize. Must ensure the provided function >= memSize bytes - MemoryManager(void (*dfunc)(), unsigned int memSize); - - int getMemSize(){ return memorySize; } - uint64_t getMemory(int sz); //return a pointer to memory of size sz - void freeTraceMemory(uint64_t toRemove, int size);//size is no if instructions + /// Constructor - using default dummy function ("FirstTraceFunction") + /// as space. + /// + MemoryManager (); + + /// Constructor - using default dummy function ("FirstTraceFunction") + /// as space. Make sure memSize is less than the number of 32-bit + /// words available in the dummy function. + /// + MemoryManager (unsigned int memSize); + + /// Constructor - using user-provided function for space. Make sure + /// memSize is less than the number of 32-bit words available in the + /// dummy function. + /// + MemoryManager (void (*dummyFunctionPtr) (), unsigned int memSize); + + /// getMemSize - returns the total size in 32-bit words of the area + /// managed by this memory manager. + /// + int getMemSize() { return memorySize; } + + /// getMemory - Return a pointer to memory of size sz. sz is + /// expressed as a number of 32-bit words. + /// + uint64_t getMemory (int sz); + + /// freeTraceMemory - size is expressed as a number of 32-bit words. + /// + void freeTraceMemory (uint64_t toRemove, int size); }; } // end namespace llvm From gaeke at cs.uiuc.edu Fri Apr 23 15:37:05 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Apr 23 15:37:05 2004 Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp Message-ID: <200404232036.PAA16983@seraph.cs.uiuc.edu> Changes in directory reopt/lib/LightWtProfiling: RuntimeOptimizations.cpp updated: 1.28 -> 1.29 --- Log message: Update comments. --- Diffs of the changes: (+4 -3) Index: reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp diff -u reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp:1.28 reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp:1.29 --- reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp:1.28 Fri Apr 23 12:11:40 2004 +++ reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp Fri Apr 23 15:35:53 2004 @@ -41,8 +41,8 @@ /// This method is called when we have finally constructed a /// trace. The first parameter is the vector of basic blocks that form -/// the trace; the second parameter is presumably one of the starting -/// addresses for the trace. +/// the trace; the second parameter is the starting +/// address for the trace. /// void optimizeTrace (std::vector &vBB, uint64_t a) { static std::set alreadyDone; @@ -89,9 +89,10 @@ Target->addPassesToEmitMachineCode (PM, *MCE); PM.run (*TF->TraceFn); - // Add a branch from the entry basic block of the trace in the MatrixFn to the + // Add a branch from address A (the parameter to this method) to the // entry basic block of the unpacked TraceFn. Future executions of the trace // will proceed from the optimized version of the code. + } From lattner at cs.uiuc.edu Fri Apr 23 15:37:09 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Apr 23 15:37:09 2004 Subject: [llvm-commits] CVS: llvm/tools/bugpoint/Miscompilation.cpp Message-ID: <200404232037.PAA23694@zion.cs.uiuc.edu> Changes in directory llvm/tools/bugpoint: Miscompilation.cpp updated: 1.43 -> 1.44 --- Log message: Teach bugpoint to be a little bit smarter and avoid repeating work --- Diffs of the changes: (+5 -1) Index: llvm/tools/bugpoint/Miscompilation.cpp diff -u llvm/tools/bugpoint/Miscompilation.cpp:1.43 llvm/tools/bugpoint/Miscompilation.cpp:1.44 --- llvm/tools/bugpoint/Miscompilation.cpp:1.43 Thu Apr 22 15:02:09 2004 +++ llvm/tools/bugpoint/Miscompilation.cpp Fri Apr 23 15:36:51 2004 @@ -108,7 +108,11 @@ exit(1); } removeFile(BytecodeResult); // No longer need the file on disk - + + // Don't check if there are no passes in the suffix. + if (Suffix.empty()) + return NoFailure; + std::cout << "Checking to see if '" << getPassesString(Suffix) << "' passes compile correctly after the '" << getPassesString(Prefix) << "' passes: "; From gaeke at cs.uiuc.edu Fri Apr 23 16:26:02 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Apr 23 16:26:02 2004 Subject: [llvm-commits] CVS: reopt/include/reopt/VirtualMem.h Message-ID: <200404232125.QAA19318@seraph.cs.uiuc.edu> Changes in directory reopt/include/reopt: VirtualMem.h updated: 1.12 -> 1.13 --- Log message: copyToVM has been renamed to writeTraceToVM. Its arguments have been reordered for consistency with writeInstToVM. Document writeInstToVM and writeTraceToVM. --- Diffs of the changes: (+8 -4) Index: reopt/include/reopt/VirtualMem.h diff -u reopt/include/reopt/VirtualMem.h:1.12 reopt/include/reopt/VirtualMem.h:1.13 --- reopt/include/reopt/VirtualMem.h:1.12 Wed Nov 19 16:51:42 2003 +++ reopt/include/reopt/VirtualMem.h Fri Apr 23 16:25:11 2004 @@ -26,9 +26,6 @@ public: //constructor VirtualMem(); - //reading/modifying process space VM - void copyToVM(std::vector &trace, - uint64_t traceStartAddr); void changeBranchTarget(uint64_t frm, uint64_t to); uint64_t getBranchTarget(const std::pair &n); @@ -37,7 +34,14 @@ unsigned int readInstrFrmVm(uint64_t frm, TraceCache *tr); unsigned int readInstrFrmVm(uint64_t frm, TraceCache *tr, TraceCache *tr2); - void writeInstToVM(uint64_t dest, unsigned newInstr); + /// writeInstToVM - Emit the word newInstr to memory at address destAddr. + /// + void writeInstToVM (uint64_t destAddr, unsigned int newInstr); + + /// writeTraceToVM - Emit the words in newInstrs to memory starting at + /// address destAddr. + /// + void writeTraceToVM (uint64_t destAddr, std::vector &newInstrs); void writeBranchInstruction(uint64_t location, uint64_t target); From gaeke at cs.uiuc.edu Fri Apr 23 16:26:06 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Apr 23 16:26:06 2004 Subject: [llvm-commits] CVS: reopt/lib/TraceCache/VirtualMem.cpp Message-ID: <200404232125.QAA19315@seraph.cs.uiuc.edu> Changes in directory reopt/lib/TraceCache: VirtualMem.cpp updated: 1.15 -> 1.16 --- Log message: copyToVM has been renamed to writeTraceToVM. Its arguments have been reordered for consistency with writeInstToVM. Also, it now uses a single write() system call instead of one per word, for efficiency. Use sizeof(unsigned int) instead of hardcoding 4 all over the place. Document writeInstToVM and writeTraceToVM. --- Diffs of the changes: (+15 -16) Index: reopt/lib/TraceCache/VirtualMem.cpp diff -u reopt/lib/TraceCache/VirtualMem.cpp:1.15 reopt/lib/TraceCache/VirtualMem.cpp:1.16 --- reopt/lib/TraceCache/VirtualMem.cpp:1.15 Wed Apr 21 15:32:47 2004 +++ reopt/lib/TraceCache/VirtualMem.cpp Fri Apr 23 16:25:10 2004 @@ -26,22 +26,10 @@ throw std::string ("Error opening address space file in procfs."); } -/// Emit the instruction words in TRACE to memory starting at address traceStartAddr. -/// -void VirtualMem::copyToVM(std::vector &trace, - uint64_t traceStartAddr){ - lseek(fp, traceStartAddr, SEEK_SET); - - for(int i=0, sz = trace.size(); i &newInstrs) { + lseek (fp, destAddr, SEEK_SET); + write (fp, &newInstrs[0], newInstrs.size () * sizeof (unsigned int)); } /// changeBranchTarget - Handles two kinds of branches for now, namely, From gaeke at cs.uiuc.edu Fri Apr 23 16:26:09 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Apr 23 16:26:09 2004 Subject: [llvm-commits] CVS: reopt/lib/TraceCache/TraceCache.cpp Message-ID: <200404232125.QAA19327@seraph.cs.uiuc.edu> Changes in directory reopt/lib/TraceCache: TraceCache.cpp updated: 1.19 -> 1.20 --- Log message: copyToVM has been renamed to writeTraceToVM. Its arguments have been reordered for consistency with writeInstToVM. --- Diffs of the changes: (+4 -4) Index: reopt/lib/TraceCache/TraceCache.cpp diff -u reopt/lib/TraceCache/TraceCache.cpp:1.19 reopt/lib/TraceCache/TraceCache.cpp:1.20 --- reopt/lib/TraceCache/TraceCache.cpp:1.19 Wed Nov 19 16:51:52 2003 +++ reopt/lib/TraceCache/TraceCache.cpp Fri Apr 23 16:25:12 2004 @@ -158,7 +158,7 @@ if(traceStartAddr == 0) return false; //could not allocate space! //copy trace to the memory - vm->copyToVM(trace, traceStartAddr); + vm->writeTraceToVM(traceStartAddr, trace); traces[instAddr] = traceStartAddr; endAddress[instAddr] = endAddr; @@ -307,8 +307,8 @@ if(traceStartAddr == 0) return false; //could not allocate space! //copy trace to the memory - vm->copyToVM(*exitStubs, traceStartAddr); - vm->copyToVM(trace, traceStartAddr+exitStubs->size()*4); + vm->writeTraceToVM(traceStartAddr, *exitStubs); + vm->writeTraceToVM(traceStartAddr+exitStubs->size()*4, trace); traces[instAddr] = traceStartAddr; traceId[traceUniqId] = traceStartAddr; @@ -470,7 +470,7 @@ if(traceStartAddr == 0) return false; //could not allocate space! //copy trace to the memory - vm->copyToVM(trace, traceStartAddr); + vm->writeTraceToVM(traceStartAddr, trace); traces[instAddr] = traceStartAddr; endAddress[instAddr] = endAddr; From lattner at cs.uiuc.edu Fri Apr 23 16:29:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Apr 23 16:29:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/ScalarEvolution.h ScalarEvolutionExpressions.h Message-ID: <200404232128.QAA05684@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: ScalarEvolution.h updated: 1.4 -> 1.5 ScalarEvolutionExpressions.h updated: 1.1 -> 1.2 --- Log message: Remove the SCEV::expandCodeFor method, add a new SCEVVisitor class. --- Diffs of the changes: (+40 -86) Index: llvm/include/llvm/Analysis/ScalarEvolution.h diff -u llvm/include/llvm/Analysis/ScalarEvolution.h:1.4 llvm/include/llvm/Analysis/ScalarEvolution.h:1.5 --- llvm/include/llvm/Analysis/ScalarEvolution.h:1.4 Thu Apr 22 10:00:36 2004 +++ llvm/include/llvm/Analysis/ScalarEvolution.h Fri Apr 23 16:28:25 2004 @@ -31,7 +31,6 @@ class Loop; class LoopInfo; class SCEVHandle; - class ScalarEvolutionRewriter; /// SCEV - This class represent an analyzed expression in the program. These /// are reference counted opaque objects that the client is not allowed to @@ -75,13 +74,6 @@ /// virtual const Type *getType() const = 0; - /// expandCodeFor - Given a rewriter object, expand this SCEV into a closed - /// form expression and return a Value corresponding to the expression in - /// question. - virtual Value *expandCodeFor(ScalarEvolutionRewriter &SER, - Instruction *InsertPt) = 0; - - /// print - Print out the internal representation of this scalar to the /// specified stream. This should really only be used for debugging /// purposes. @@ -109,7 +101,6 @@ virtual bool isLoopInvariant(const Loop *L) const; virtual const Type *getType() const; virtual bool hasComputableLoopEvolution(const Loop *L) const; - virtual Value *expandCodeFor(ScalarEvolutionRewriter &, Instruction *); virtual void print(std::ostream &OS) const; @@ -218,54 +209,6 @@ virtual void releaseMemory(); virtual void getAnalysisUsage(AnalysisUsage &AU) const; virtual void print(std::ostream &OS) const; - }; - - /// ScalarEvolutionRewriter - This class uses information about analyze - /// scalars to rewrite expressions in canonical form. This can be used for - /// induction variable substitution, strength reduction, or loop exit value - /// replacement. - /// - /// Clients should create an instance of this class when rewriting is needed, - /// and destroying it when finished to allow the release of the associated - /// memory. - class ScalarEvolutionRewriter { - ScalarEvolution &SE; - LoopInfo &LI; - std::map InsertedExpressions; - std::set InsertedInstructions; - public: - ScalarEvolutionRewriter(ScalarEvolution &se, LoopInfo &li) - : SE(se), LI(li) {} - - /// isInsertedInstruction - Return true if the specified instruction was - /// inserted by the code rewriter. If so, the client should not modify the - /// instruction. - bool isInsertedInstruction(Instruction *I) const { - return InsertedInstructions.count(I); - } - - /// GetOrInsertCanonicalInductionVariable - This method returns the - /// canonical induction variable of the specified type for the specified - /// loop (inserts one if there is none). A canonical induction variable - /// starts at zero and steps by one on each iteration. - Value *GetOrInsertCanonicalInductionVariable(const Loop *L, const Type *Ty); - - - /// addInsertedValue - Remember the specified instruction as being the - /// canonical form for the specified SCEV. - void addInsertedValue(Instruction *I, SCEV *S) { - InsertedExpressions[S] = (Value*)I; - InsertedInstructions.insert(I); - } - - /// ExpandCodeFor - Insert code to directly compute the specified SCEV - /// expression into the program. The inserted code is inserted into the - /// specified block. - /// - /// If a particular value sign is required, a type may be specified for the - /// result. - Value *ExpandCodeFor(SCEVHandle SH, Instruction *InsertPt, - const Type *Ty = 0); }; } Index: llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h diff -u llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h:1.1 llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h:1.2 --- llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h:1.1 Thu Apr 15 10:06:59 2004 +++ llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h Fri Apr 23 16:28:25 2004 @@ -56,11 +56,6 @@ virtual const Type *getType() const; - Value *expandCodeFor(ScalarEvolutionRewriter &SER, - Instruction *InsertPt) { - return (Value*)getValue(); - } - virtual void print(std::ostream &OS) const; /// Methods for support type inquiry through isa, cast, and dyn_cast: @@ -99,9 +94,6 @@ /// known to have. This method is only valid on integer SCEV objects. virtual ConstantRange getValueRange() const; - Value *expandCodeFor(ScalarEvolutionRewriter &SER, - Instruction *InsertPt); - virtual void print(std::ostream &OS) const; /// Methods for support type inquiry through isa, cast, and dyn_cast: @@ -140,9 +132,6 @@ /// known to have. This method is only valid on integer SCEV objects. virtual ConstantRange getValueRange() const; - Value *expandCodeFor(ScalarEvolutionRewriter &SER, - Instruction *InsertPt); - virtual void print(std::ostream &OS) const; /// Methods for support type inquiry through isa, cast, and dyn_cast: @@ -236,9 +225,6 @@ virtual const char *getOperationStr() const { return " + "; } - Value *expandCodeFor(ScalarEvolutionRewriter &SER, - Instruction *InsertPt); - /// Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const SCEVAddExpr *S) { return true; } static inline bool classof(const SCEV *S) { @@ -266,9 +252,6 @@ virtual const char *getOperationStr() const { return " * "; } - Value *expandCodeFor(ScalarEvolutionRewriter &SER, - Instruction *InsertPt); - /// Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const SCEVMulExpr *S) { return true; } static inline bool classof(const SCEV *S) { @@ -305,9 +288,6 @@ virtual const Type *getType() const; - Value *expandCodeFor(ScalarEvolutionRewriter &SER, - Instruction *InsertPt); - void print(std::ostream &OS) const; /// Methods for support type inquiry through isa, cast, and dyn_cast: @@ -376,10 +356,6 @@ virtual const Type *getType() const { return Operands[0]->getType(); } - Value *expandCodeFor(ScalarEvolutionRewriter &SER, - Instruction *InsertPt); - - /// isAffine - Return true if this is an affine AddRec (i.e., it represents /// an expressions A+B*x where A and B are loop invariant values. bool isAffine() const { @@ -433,12 +409,11 @@ /// SCEVUnknown. static SCEVHandle get(Value *V); - Value *getValue() const { return V; } + /// getIntegerSCEV - Given an integer or FP type, create a constant for the + /// specified signed integer value and return a SCEV for the constant. + static SCEVHandle getIntegerSCEV(int Val, const Type *Ty); - Value *expandCodeFor(ScalarEvolutionRewriter &SER, - Instruction *InsertPt) { - return V; - } + Value *getValue() const { return V; } virtual bool isLoopInvariant(const Loop *L) const; virtual bool hasComputableLoopEvolution(const Loop *QL) const { @@ -453,6 +428,42 @@ static inline bool classof(const SCEVUnknown *S) { return true; } static inline bool classof(const SCEV *S) { return S->getSCEVType() == scUnknown; + } + }; + + /// SCEVVisitor - This class defines a simple visitor class that may be used + /// for various SCEV analysis purposes. + template + struct SCEVVisitor { + RetVal visit(SCEV *S) { + switch (S->getSCEVType()) { + case scConstant: + return ((SC*)this)->visitConstant((SCEVConstant*)S); + case scTruncate: + return ((SC*)this)->visitTruncateExpr((SCEVTruncateExpr*)S); + case scZeroExtend: + return ((SC*)this)->visitZeroExtendExpr((SCEVZeroExtendExpr*)S); + case scAddExpr: + return ((SC*)this)->visitAddExpr((SCEVAddExpr*)S); + case scMulExpr: + return ((SC*)this)->visitMulExpr((SCEVMulExpr*)S); + case scUDivExpr: + return ((SC*)this)->visitUDivExpr((SCEVUDivExpr*)S); + case scAddRecExpr: + return ((SC*)this)->visitAddRecExpr((SCEVAddRecExpr*)S); + case scUnknown: + return ((SC*)this)->visitUnknown((SCEVUnknown*)S); + case scCouldNotCompute: + return ((SC*)this)->visitCouldNotCompute((SCEVCouldNotCompute*)S); + default: + assert(0 && "Unknown SCEV type!"); + } + } + + RetVal visitCouldNotCompute(SCEVCouldNotCompute *S) { + assert(0 && "Invalid use of SCEVCouldNotCompute!"); + abort(); + return RetVal(); } }; } From lattner at cs.uiuc.edu Fri Apr 23 16:29:07 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Apr 23 16:29:07 2004 Subject: [llvm-commits] CVS: llvm/lib/Analysis/ScalarEvolution.cpp Message-ID: <200404232129.QAA06378@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: ScalarEvolution.cpp updated: 1.16 -> 1.17 --- Log message: Eliminate all of the SCEV Expansion code which is really part of the IndVars pass, not part of SCEV *analysis*. --- Diffs of the changes: (+9 -213) Index: llvm/lib/Analysis/ScalarEvolution.cpp diff -u llvm/lib/Analysis/ScalarEvolution.cpp:1.16 llvm/lib/Analysis/ScalarEvolution.cpp:1.17 --- llvm/lib/Analysis/ScalarEvolution.cpp:1.16 Sun Apr 18 22:42:32 2004 +++ llvm/lib/Analysis/ScalarEvolution.cpp Fri Apr 23 16:29:03 2004 @@ -33,10 +33,6 @@ // higher-level code, such as the code that recognizes PHI nodes of various // types, computes the execution count of a loop, etc. // -// Orthogonal to the analysis of code above, this file also implements the -// ScalarEvolutionRewriter class, which is used to emit code that represents the -// various recurrences present in a loop, in canonical forms. -// // TODO: We should use these routines and value representations to implement // dependence analysis! // @@ -160,13 +156,6 @@ return false; } -Value *SCEVCouldNotCompute::expandCodeFor(ScalarEvolutionRewriter &SER, - Instruction *InsertPt) { - assert(0 && "Attempt to use a SCEVCouldNotCompute object!"); - return 0; -} - - void SCEVCouldNotCompute::print(std::ostream &OS) const { OS << "***COULDNOTCOMPUTE***"; } @@ -358,7 +347,7 @@ /// getIntegerSCEV - Given an integer or FP type, create a constant for the /// specified signed integer value and return a SCEV for the constant. -static SCEVHandle getIntegerSCEV(int Val, const Type *Ty) { +SCEVHandle SCEVUnknown::getIntegerSCEV(int Val, const Type *Ty) { Constant *C; if (Val == 0) C = Constant::getNullValue(Ty); @@ -393,7 +382,7 @@ if (SCEVConstant *VC = dyn_cast(V)) return SCEVUnknown::get(ConstantExpr::getNeg(VC->getValue())); - return SCEVMulExpr::get(V, getIntegerSCEV(-1, V->getType())); + return SCEVMulExpr::get(V, SCEVUnknown::getIntegerSCEV(-1, V->getType())); } /// getMinusSCEV - Return a SCEV corresponding to LHS - RHS. @@ -438,11 +427,12 @@ const Type *Ty = V->getType(); if (NumSteps == 0) - return getIntegerSCEV(1, Ty); + return SCEVUnknown::getIntegerSCEV(1, Ty); SCEVHandle Result = V; for (unsigned i = 1; i != NumSteps; ++i) - Result = SCEVMulExpr::get(Result, getMinusSCEV(V, getIntegerSCEV(i, Ty))); + Result = SCEVMulExpr::get(Result, getMinusSCEV(V, + SCEVUnknown::getIntegerSCEV(i, Ty))); return Result; } @@ -465,7 +455,7 @@ SCEVHandle BC = PartialFact(It, i); Divisor *= i; SCEVHandle Val = SCEVUDivExpr::get(SCEVMulExpr::get(BC, getOperand(i)), - getIntegerSCEV(Divisor, Ty)); + SCEVUnknown::getIntegerSCEV(Divisor,Ty)); Result = SCEVAddExpr::get(Result, Val); } return Result; @@ -558,7 +548,7 @@ if (Ops[i] == Ops[i+1]) { // X + Y + Y --> X + Y*2 // Found a match, merge the two values into a multiply, and add any // remaining values to the result. - SCEVHandle Two = getIntegerSCEV(2, Ty); + SCEVHandle Two = SCEVUnknown::getIntegerSCEV(2, Ty); SCEVHandle Mul = SCEVMulExpr::get(Ops[i], Two); if (Ops.size() == 2) return Mul; @@ -609,7 +599,7 @@ MulOps.erase(MulOps.begin()+MulOp); InnerMul = SCEVMulExpr::get(MulOps); } - SCEVHandle One = getIntegerSCEV(1, Ty); + SCEVHandle One = SCEVUnknown::getIntegerSCEV(1, Ty); SCEVHandle AddOne = SCEVAddExpr::get(InnerMul, One); SCEVHandle OuterMul = SCEVMulExpr::get(AddOne, Ops[AddOp]); if (Ops.size() == 2) return OuterMul; @@ -977,137 +967,6 @@ //===----------------------------------------------------------------------===// -// Non-trivial closed-form SCEV Expanders -//===----------------------------------------------------------------------===// - -Value *SCEVTruncateExpr::expandCodeFor(ScalarEvolutionRewriter &SER, - Instruction *InsertPt) { - Value *V = SER.ExpandCodeFor(getOperand(), InsertPt); - return new CastInst(V, getType(), "tmp.", InsertPt); -} - -Value *SCEVZeroExtendExpr::expandCodeFor(ScalarEvolutionRewriter &SER, - Instruction *InsertPt) { - Value *V = SER.ExpandCodeFor(getOperand(), InsertPt, - getOperand()->getType()->getUnsignedVersion()); - return new CastInst(V, getType(), "tmp.", InsertPt); -} - -Value *SCEVAddExpr::expandCodeFor(ScalarEvolutionRewriter &SER, - Instruction *InsertPt) { - const Type *Ty = getType(); - Value *V = SER.ExpandCodeFor(getOperand(getNumOperands()-1), InsertPt, Ty); - - // Emit a bunch of add instructions - for (int i = getNumOperands()-2; i >= 0; --i) - V = BinaryOperator::create(Instruction::Add, V, - SER.ExpandCodeFor(getOperand(i), InsertPt, Ty), - "tmp.", InsertPt); - return V; -} - -Value *SCEVMulExpr::expandCodeFor(ScalarEvolutionRewriter &SER, - Instruction *InsertPt) { - const Type *Ty = getType(); - int FirstOp = 0; // Set if we should emit a subtract. - if (SCEVConstant *SC = dyn_cast(getOperand(0))) - if (SC->getValue()->isAllOnesValue()) - FirstOp = 1; - - int i = getNumOperands()-2; - Value *V = SER.ExpandCodeFor(getOperand(i+1), InsertPt, Ty); - - // Emit a bunch of multiply instructions - for (; i >= FirstOp; --i) - V = BinaryOperator::create(Instruction::Mul, V, - SER.ExpandCodeFor(getOperand(i), InsertPt, Ty), - "tmp.", InsertPt); - // -1 * ... ---> 0 - ... - if (FirstOp == 1) - V = BinaryOperator::create(Instruction::Sub, Constant::getNullValue(Ty), V, - "tmp.", InsertPt); - return V; -} - -Value *SCEVUDivExpr::expandCodeFor(ScalarEvolutionRewriter &SER, - Instruction *InsertPt) { - const Type *Ty = getType(); - Value *LHS = SER.ExpandCodeFor(getLHS(), InsertPt, Ty); - Value *RHS = SER.ExpandCodeFor(getRHS(), InsertPt, Ty); - return BinaryOperator::create(Instruction::Div, LHS, RHS, "tmp.", InsertPt); -} - -Value *SCEVAddRecExpr::expandCodeFor(ScalarEvolutionRewriter &SER, - Instruction *InsertPt) { - const Type *Ty = getType(); - // We cannot yet do fp recurrences, e.g. the xform of {X,+,F} --> X+{0,+,F} - assert(Ty->isIntegral() && "Cannot expand fp recurrences yet!"); - - // {X,+,F} --> X + {0,+,F} - if (!isa(getStart()) || - !cast(getStart())->getValue()->isNullValue()) { - Value *Start = SER.ExpandCodeFor(getStart(), InsertPt, Ty); - std::vector NewOps(op_begin(), op_end()); - NewOps[0] = getIntegerSCEV(0, getType()); - Value *Rest = SER.ExpandCodeFor(SCEVAddRecExpr::get(NewOps, getLoop()), - InsertPt, getType()); - - // FIXME: look for an existing add to use. - return BinaryOperator::create(Instruction::Add, Rest, Start, "tmp.", - InsertPt); - } - - // {0,+,1} --> Insert a canonical induction variable into the loop! - if (getNumOperands() == 2 && getOperand(1) == getIntegerSCEV(1, getType())) { - // Create and insert the PHI node for the induction variable in the - // specified loop. - BasicBlock *Header = getLoop()->getHeader(); - PHINode *PN = new PHINode(Ty, "indvar", Header->begin()); - PN->addIncoming(Constant::getNullValue(Ty), L->getLoopPreheader()); - - pred_iterator HPI = pred_begin(Header); - assert(HPI != pred_end(Header) && "Loop with zero preds???"); - if (!getLoop()->contains(*HPI)) ++HPI; - assert(HPI != pred_end(Header) && getLoop()->contains(*HPI) && - "No backedge in loop?"); - - // Insert a unit add instruction right before the terminator corresponding - // to the back-edge. - Constant *One = Ty->isFloatingPoint() ? (Constant*)ConstantFP::get(Ty, 1.0) - : (Constant*)ConstantInt::get(Ty, 1); - Instruction *Add = BinaryOperator::create(Instruction::Add, PN, One, - "indvar.next", - (*HPI)->getTerminator()); - - pred_iterator PI = pred_begin(Header); - if (*PI == L->getLoopPreheader()) - ++PI; - PN->addIncoming(Add, *PI); - return PN; - } - - // Get the canonical induction variable I for this loop. - Value *I = SER.GetOrInsertCanonicalInductionVariable(getLoop(), Ty); - - if (getNumOperands() == 2) { // {0,+,F} --> i*F - Value *F = SER.ExpandCodeFor(getOperand(1), InsertPt, Ty); - return BinaryOperator::create(Instruction::Mul, I, F, "tmp.", InsertPt); - } - - // If this is a chain of recurrences, turn it into a closed form, using the - // folders, then expandCodeFor the closed form. This allows the folders to - // simplify the expression without having to build a bunch of special code - // into this folder. - SCEVHandle IH = SCEVUnknown::get(I); // Get I as a "symbolic" SCEV. - - SCEVHandle V = evaluateAtIteration(IH); - //std::cerr << "Evaluated: " << *this << "\n to: " << *V << "\n"; - - return SER.ExpandCodeFor(V, InsertPt, Ty); -} - - -//===----------------------------------------------------------------------===// // ScalarEvolutionsImpl Definition and Implementation //===----------------------------------------------------------------------===// // @@ -2099,7 +1958,7 @@ if (SCEVConstant *SC = dyn_cast(getStart())) if (!SC->getValue()->isNullValue()) { std::vector Operands(op_begin(), op_end()); - Operands[0] = getIntegerSCEV(0, SC->getType()); + Operands[0] = SCEVUnknown::getIntegerSCEV(0, SC->getType()); SCEVHandle Shifted = SCEVAddRecExpr::get(Operands, getLoop()); if (SCEVAddRecExpr *ShiftedAddRec = dyn_cast(Shifted)) return ShiftedAddRec->getNumIterationsInRange( @@ -2348,66 +2207,3 @@ PrintLoopInfo(OS, this, *I); } -//===----------------------------------------------------------------------===// -// ScalarEvolutionRewriter Class Implementation -//===----------------------------------------------------------------------===// - -Value *ScalarEvolutionRewriter:: -GetOrInsertCanonicalInductionVariable(const Loop *L, const Type *Ty) { - assert((Ty->isInteger() || Ty->isFloatingPoint()) && - "Can only insert integer or floating point induction variables!"); - - // Check to see if we already inserted one. - SCEVHandle H = SCEVAddRecExpr::get(getIntegerSCEV(0, Ty), - getIntegerSCEV(1, Ty), L); - return ExpandCodeFor(H, 0, Ty); -} - -/// ExpandCodeFor - Insert code to directly compute the specified SCEV -/// expression into the program. The inserted code is inserted into the -/// specified block. -Value *ScalarEvolutionRewriter::ExpandCodeFor(SCEVHandle SH, - Instruction *InsertPt, - const Type *Ty) { - std::map::iterator ExistVal =InsertedExpressions.find(SH); - Value *V; - if (ExistVal != InsertedExpressions.end()) { - V = ExistVal->second; - } else { - // Ask the recurrence object to expand the code for itself. - V = SH->expandCodeFor(*this, InsertPt); - // Cache the generated result. - InsertedExpressions.insert(std::make_pair(SH, V)); - } - - if (Ty == 0 || V->getType() == Ty) - return V; - if (Constant *C = dyn_cast(V)) - return ConstantExpr::getCast(C, Ty); - else if (Instruction *I = dyn_cast(V)) { - // Check to see if there is already a cast. If there is, use it. - for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); - UI != E; ++UI) { - if ((*UI)->getType() == Ty) - if (CastInst *CI = dyn_cast(cast(*UI))) { - BasicBlock::iterator It = I; ++It; - while (isa(It)) ++It; - if (It != BasicBlock::iterator(CI)) { - // Splice the cast immediately after the operand in question. - I->getParent()->getInstList().splice(It, - CI->getParent()->getInstList(), - CI); - } - return CI; - } - } - BasicBlock::iterator IP = I; ++IP; - if (InvokeInst *II = dyn_cast(I)) - IP = II->getNormalDest()->begin(); - while (isa(IP)) ++IP; - return new CastInst(V, Ty, V->getName(), IP); - } else { - // FIXME: check to see if there is already a cast! - return new CastInst(V, Ty, V->getName(), InsertPt); - } -} From lattner at cs.uiuc.edu Fri Apr 23 16:30:15 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Apr 23 16:30:15 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/IndVarSimplify.cpp Message-ID: <200404232129.QAA06707@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: IndVarSimplify.cpp updated: 1.63 -> 1.64 --- Log message: Move the scev expansion code into this pass, where it belongs. There is still room for cleanup, but at least the code modification is out of the analysis now. --- Diffs of the changes: (+252 -12) Index: llvm/lib/Transforms/Scalar/IndVarSimplify.cpp diff -u llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.63 llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.64 --- llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.63 Thu Apr 22 10:12:36 2004 +++ llvm/lib/Transforms/Scalar/IndVarSimplify.cpp Fri Apr 23 16:29:48 2004 @@ -51,6 +51,247 @@ using namespace llvm; namespace { + /// SCEVExpander - This class uses information about analyze scalars to + /// rewrite expressions in canonical form. + /// + /// Clients should create an instance of this class when rewriting is needed, + /// and destroying it when finished to allow the release of the associated + /// memory. + struct SCEVExpander : public SCEVVisitor { + ScalarEvolution &SE; + LoopInfo &LI; + std::map InsertedExpressions; + std::set InsertedInstructions; + + Instruction *InsertPt; + + friend class SCEVVisitor; + public: + SCEVExpander(ScalarEvolution &se, LoopInfo &li) : SE(se), LI(li) {} + + /// isInsertedInstruction - Return true if the specified instruction was + /// inserted by the code rewriter. If so, the client should not modify the + /// instruction. + bool isInsertedInstruction(Instruction *I) const { + return InsertedInstructions.count(I); + } + + /// getOrInsertCanonicalInductionVariable - This method returns the + /// canonical induction variable of the specified type for the specified + /// loop (inserting one if there is none). A canonical induction variable + /// starts at zero and steps by one on each iteration. + Value *getOrInsertCanonicalInductionVariable(const Loop *L, const Type *Ty){ + assert((Ty->isInteger() || Ty->isFloatingPoint()) && + "Can only insert integer or floating point induction variables!"); + SCEVHandle H = SCEVAddRecExpr::get(SCEVUnknown::getIntegerSCEV(0, Ty), + SCEVUnknown::getIntegerSCEV(1, Ty), L); + return expand(H); + } + + /// addInsertedValue - Remember the specified instruction as being the + /// canonical form for the specified SCEV. + void addInsertedValue(Instruction *I, SCEV *S) { + InsertedExpressions[S] = (Value*)I; + InsertedInstructions.insert(I); + } + + /// expandCodeFor - Insert code to directly compute the specified SCEV + /// expression into the program. The inserted code is inserted into the + /// specified block. + /// + /// If a particular value sign is required, a type may be specified for the + /// result. + Value *expandCodeFor(SCEVHandle SH, Instruction *IP, const Type *Ty = 0) { + // Expand the code for this SCEV. + this->InsertPt = IP; + return expandInTy(SH, Ty); + } + + protected: + Value *expand(SCEV *S) { + // Check to see if we already expanded this. + std::map::iterator I = InsertedExpressions.find(S); + if (I != InsertedExpressions.end()) + return I->second; + + Value *V = visit(S); + InsertedExpressions[S] = V; + return V; + } + + Value *expandInTy(SCEV *S, const Type *Ty) { + Value *V = expand(S); + if (Ty && V->getType() != Ty) { + // FIXME: keep track of the cast instruction. + if (Constant *C = dyn_cast(V)) + return ConstantExpr::getCast(C, Ty); + else if (Instruction *I = dyn_cast(V)) { + // Check to see if there is already a cast. If there is, use it. + for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); + UI != E; ++UI) { + if ((*UI)->getType() == Ty) + if (CastInst *CI = dyn_cast(cast(*UI))) { + BasicBlock::iterator It = I; ++It; + while (isa(It)) ++It; + if (It != BasicBlock::iterator(CI)) { + // Splice the cast immediately after the operand in question. + I->getParent()->getInstList().splice(It, + CI->getParent()->getInstList(), + CI); + } + return CI; + } + } + BasicBlock::iterator IP = I; ++IP; + if (InvokeInst *II = dyn_cast(I)) + IP = II->getNormalDest()->begin(); + while (isa(IP)) ++IP; + return new CastInst(V, Ty, V->getName(), IP); + } else { + // FIXME: check to see if there is already a cast! + return new CastInst(V, Ty, V->getName(), InsertPt); + } + } + return V; + } + + Value *visitConstant(SCEVConstant *S) { + return S->getValue(); + } + + Value *visitTruncateExpr(SCEVTruncateExpr *S) { + Value *V = expand(S->getOperand()); + return new CastInst(V, S->getType(), "tmp.", InsertPt); + } + + Value *visitZeroExtendExpr(SCEVZeroExtendExpr *S) { + Value *V = expandInTy(S->getOperand(),V->getType()->getUnsignedVersion()); + return new CastInst(V, S->getType(), "tmp.", InsertPt); + } + + Value *visitAddExpr(SCEVAddExpr *S) { + const Type *Ty = S->getType(); + Value *V = expandInTy(S->getOperand(S->getNumOperands()-1), Ty); + + // Emit a bunch of add instructions + for (int i = S->getNumOperands()-2; i >= 0; --i) + V = BinaryOperator::create(Instruction::Add, V, + expandInTy(S->getOperand(i), Ty), + "tmp.", InsertPt); + return V; + } + + Value *visitMulExpr(SCEVMulExpr *S); + + Value *visitUDivExpr(SCEVUDivExpr *S) { + const Type *Ty = S->getType(); + Value *LHS = expandInTy(S->getLHS(), Ty); + Value *RHS = expandInTy(S->getRHS(), Ty); + return BinaryOperator::create(Instruction::Div, LHS, RHS, "tmp.", + InsertPt); + } + + Value *visitAddRecExpr(SCEVAddRecExpr *S); + + Value *visitUnknown(SCEVUnknown *S) { + return S->getValue(); + } + }; +} + +Value *SCEVExpander::visitMulExpr(SCEVMulExpr *S) { + const Type *Ty = S->getType(); + int FirstOp = 0; // Set if we should emit a subtract. + if (SCEVConstant *SC = dyn_cast(S->getOperand(0))) + if (SC->getValue()->isAllOnesValue()) + FirstOp = 1; + + int i = S->getNumOperands()-2; + Value *V = expandInTy(S->getOperand(i+1), Ty); + + // Emit a bunch of multiply instructions + for (; i >= FirstOp; --i) + V = BinaryOperator::create(Instruction::Mul, V, + expandInTy(S->getOperand(i), Ty), + "tmp.", InsertPt); + // -1 * ... ---> 0 - ... + if (FirstOp == 1) + V = BinaryOperator::create(Instruction::Sub, Constant::getNullValue(Ty), + V, "tmp.", InsertPt); + return V; +} + +Value *SCEVExpander::visitAddRecExpr(SCEVAddRecExpr *S) { + const Type *Ty = S->getType(); + const Loop *L = S->getLoop(); + // We cannot yet do fp recurrences, e.g. the xform of {X,+,F} --> X+{0,+,F} + assert(Ty->isIntegral() && "Cannot expand fp recurrences yet!"); + + // {X,+,F} --> X + {0,+,F} + if (!isa(S->getStart()) || + !cast(S->getStart())->getValue()->isNullValue()) { + Value *Start = expandInTy(S->getStart(), Ty); + std::vector NewOps(S->op_begin(), S->op_end()); + NewOps[0] = SCEVUnknown::getIntegerSCEV(0, Ty); + Value *Rest = expandInTy(SCEVAddRecExpr::get(NewOps, L), Ty); + + // FIXME: look for an existing add to use. + return BinaryOperator::create(Instruction::Add, Rest, Start, "tmp.", + InsertPt); + } + + // {0,+,1} --> Insert a canonical induction variable into the loop! + if (S->getNumOperands() == 2 && + S->getOperand(1) == SCEVUnknown::getIntegerSCEV(1, Ty)) { + // Create and insert the PHI node for the induction variable in the + // specified loop. + BasicBlock *Header = L->getHeader(); + PHINode *PN = new PHINode(Ty, "indvar", Header->begin()); + PN->addIncoming(Constant::getNullValue(Ty), L->getLoopPreheader()); + + pred_iterator HPI = pred_begin(Header); + assert(HPI != pred_end(Header) && "Loop with zero preds???"); + if (!L->contains(*HPI)) ++HPI; + assert(HPI != pred_end(Header) && L->contains(*HPI) && + "No backedge in loop?"); + + // Insert a unit add instruction right before the terminator corresponding + // to the back-edge. + Constant *One = Ty->isFloatingPoint() ? (Constant*)ConstantFP::get(Ty, 1.0) + : ConstantInt::get(Ty, 1); + Instruction *Add = BinaryOperator::create(Instruction::Add, PN, One, + "indvar.next", + (*HPI)->getTerminator()); + + pred_iterator PI = pred_begin(Header); + if (*PI == L->getLoopPreheader()) + ++PI; + PN->addIncoming(Add, *PI); + return PN; + } + + // Get the canonical induction variable I for this loop. + Value *I = getOrInsertCanonicalInductionVariable(L, Ty); + + if (S->getNumOperands() == 2) { // {0,+,F} --> i*F + Value *F = expandInTy(S->getOperand(1), Ty); + return BinaryOperator::create(Instruction::Mul, I, F, "tmp.", InsertPt); + } + + // If this is a chain of recurrences, turn it into a closed form, using the + // folders, then expandCodeFor the closed form. This allows the folders to + // simplify the expression without having to build a bunch of special code + // into this folder. + SCEVHandle IH = SCEVUnknown::get(I); // Get I as a "symbolic" SCEV. + + SCEVHandle V = S->evaluateAtIteration(IH); + //std::cerr << "Evaluated: " << *this << "\n to: " << *V << "\n"; + + return expandInTy(V, Ty); +} + + +namespace { Statistic<> NumRemoved ("indvars", "Number of aux indvars removed"); Statistic<> NumPointer ("indvars", "Number of pointer indvars promoted"); Statistic<> NumInserted("indvars", "Number of canonical indvars added"); @@ -85,7 +326,7 @@ void EliminatePointerRecurrence(PHINode *PN, BasicBlock *Preheader, std::set &DeadInsts); void LinearFunctionTestReplace(Loop *L, SCEV *IterationCount, - ScalarEvolutionRewriter &RW); + SCEVExpander &RW); void RewriteLoopExitValues(Loop *L); void DeleteTriviallyDeadInstructions(std::set &Insts); @@ -97,7 +338,6 @@ return new IndVarSimplify(); } - /// DeleteTriviallyDeadInstructions - If any of the instructions is the /// specified set are trivially dead, delete them and see if this makes any of /// their operands subsequently dead. @@ -182,7 +422,7 @@ /// SCEV analysis can determine a loop-invariant trip count of the loop, which /// is actually a much broader range than just linear tests. void IndVarSimplify::LinearFunctionTestReplace(Loop *L, SCEV *IterationCount, - ScalarEvolutionRewriter &RW) { + SCEVExpander &RW) { // Find the exit block for the loop. We can currently only handle loops with // a single exit. std::vector ExitBlocks; @@ -237,7 +477,7 @@ // Expand the code for the iteration count into the preheader of the loop. BasicBlock *Preheader = L->getLoopPreheader(); - Value *ExitCnt = RW.ExpandCodeFor(TripCount, Preheader->getTerminator(), + Value *ExitCnt = RW.expandCodeFor(TripCount, Preheader->getTerminator(), IndVar->getType()); // Insert a new setne or seteq instruction before the branch. @@ -266,7 +506,7 @@ // Scan all of the instructions in the loop, looking at those that have // extra-loop users and which are recurrences. - ScalarEvolutionRewriter Rewriter(*SE, *LI); + SCEVExpander Rewriter(*SE, *LI); // We insert the code into the preheader of the loop if the loop contains // multiple exit blocks, or in the exit block if there is exactly one. @@ -307,7 +547,7 @@ if (!isa(ExitValue)) { Changed = true; ++NumReplaced; - Value *NewVal = Rewriter.ExpandCodeFor(ExitValue, InsertPt, + Value *NewVal = Rewriter.expandCodeFor(ExitValue, InsertPt, I->getType()); // Rewrite any users of the computed value outside of the loop @@ -379,8 +619,8 @@ // Actually, if we know how many times the loop iterates, lets insert a // canonical induction variable to help subsequent passes. if (!isa(IterationCount)) { - ScalarEvolutionRewriter Rewriter(*SE, *LI); - Rewriter.GetOrInsertCanonicalInductionVariable(L, + SCEVExpander Rewriter(*SE, *LI); + Rewriter.getOrInsertCanonicalInductionVariable(L, IterationCount->getType()); LinearFunctionTestReplace(L, IterationCount, Rewriter); } @@ -399,12 +639,12 @@ } // Create a rewriter object which we'll use to transform the code with. - ScalarEvolutionRewriter Rewriter(*SE, *LI); + SCEVExpander Rewriter(*SE, *LI); // Now that we know the largest of of the induction variables in this loop, // insert a canonical induction variable of the largest size. LargestType = LargestType->getUnsignedVersion(); - Value *IndVar = Rewriter.GetOrInsertCanonicalInductionVariable(L,LargestType); + Value *IndVar = Rewriter.getOrInsertCanonicalInductionVariable(L,LargestType); ++NumInserted; Changed = true; @@ -440,7 +680,7 @@ std::map InsertedSizes; while (!IndVars.empty()) { PHINode *PN = IndVars.back().first; - Value *NewVal = Rewriter.ExpandCodeFor(IndVars.back().second, InsertPt, + Value *NewVal = Rewriter.expandCodeFor(IndVars.back().second, InsertPt, PN->getType()); std::string Name = PN->getName(); PN->setName(""); @@ -465,7 +705,7 @@ !I->use_empty() && !Rewriter.isInsertedInstruction(I)) { SCEVHandle SH = SE->getSCEV(I); - Value *V = Rewriter.ExpandCodeFor(SH, I, I->getType()); + Value *V = Rewriter.expandCodeFor(SH, I, I->getType()); if (V != I) { if (isa(V)) { std::string Name = I->getName(); From gaeke at cs.uiuc.edu Fri Apr 23 16:42:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Apr 23 16:42:01 2004 Subject: [llvm-commits] CVS: reopt/include/reopt/ScratchMemory.h Message-ID: <200404232141.QAA19873@seraph.cs.uiuc.edu> Changes in directory reopt/include/reopt: ScratchMemory.h updated: 1.1 -> 1.2 --- Log message: dummyFunction2 has been renamed to OptimizedTraceTextArea. --- Diffs of the changes: (+1 -1) Index: reopt/include/reopt/ScratchMemory.h diff -u reopt/include/reopt/ScratchMemory.h:1.1 reopt/include/reopt/ScratchMemory.h:1.2 --- reopt/include/reopt/ScratchMemory.h:1.1 Mon Oct 27 13:00:19 2003 +++ reopt/include/reopt/ScratchMemory.h Fri Apr 23 16:40:57 2004 @@ -15,7 +15,7 @@ /// Function used as space for the second-level instrumentation trace cache: /// - void dummyFunction2 (); + void OptimizedTraceTextArea (); } #endif // REOPT_SCRATCHMEMORY_H From gaeke at cs.uiuc.edu Fri Apr 23 16:42:05 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Apr 23 16:42:05 2004 Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/Initialization.cpp TraceOptEmitter.cpp Message-ID: <200404232141.QAA19882@seraph.cs.uiuc.edu> Changes in directory reopt/lib/LightWtProfiling: Initialization.cpp updated: 1.15 -> 1.16 TraceOptEmitter.cpp updated: 1.5 -> 1.6 --- Log message: dummyFunction2 has been renamed to OptimizedTraceTextArea. --- Diffs of the changes: (+2 -2) Index: reopt/lib/LightWtProfiling/Initialization.cpp diff -u reopt/lib/LightWtProfiling/Initialization.cpp:1.15 reopt/lib/LightWtProfiling/Initialization.cpp:1.16 --- reopt/lib/LightWtProfiling/Initialization.cpp:1.15 Fri Jan 16 11:02:00 2004 +++ reopt/lib/LightWtProfiling/Initialization.cpp Fri Apr 23 16:40:57 2004 @@ -77,7 +77,7 @@ " llvm dynamic optimizer"); vm = new VirtualMem(); tr = new TraceCache(InstTraceCacheSize, vm); - tr2 = new TraceCache(dummyFunction2, OptTraceCacheSize, vm); + tr2 = new TraceCache(OptimizedTraceTextArea, OptTraceCacheSize, vm); LEVEL_TWO_EXITS = THRESHOLD_LEVEL_2/3; Index: reopt/lib/LightWtProfiling/TraceOptEmitter.cpp diff -u reopt/lib/LightWtProfiling/TraceOptEmitter.cpp:1.5 reopt/lib/LightWtProfiling/TraceOptEmitter.cpp:1.6 --- reopt/lib/LightWtProfiling/TraceOptEmitter.cpp:1.5 Fri Apr 23 14:42:30 2004 +++ reopt/lib/LightWtProfiling/TraceOptEmitter.cpp Fri Apr 23 16:40:57 2004 @@ -54,7 +54,7 @@ TraceOptEmitter (const TargetData &_TD) : TD (_TD) { // Re-use the existing DummyFunction area for code emission in the // Reoptimizer. No memory is reserved for stubs. - FunctionBase = (unsigned char *) dummyFunction2; + FunctionBase = (unsigned char *) OptimizedTraceTextArea; // Allocate functions forward from the function base. CurFunctionPtr = FunctionBase; } From gaeke at cs.uiuc.edu Fri Apr 23 16:45:02 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Apr 23 16:45:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/SparcV9RegInfo.h Message-ID: <200404232145.QAA11500@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9: SparcV9RegInfo.h updated: 1.12 -> 1.13 --- Log message: Fix a typo. --- Diffs of the changes: (+1 -2) Index: llvm/lib/Target/SparcV9/SparcV9RegInfo.h diff -u llvm/lib/Target/SparcV9/SparcV9RegInfo.h:1.12 llvm/lib/Target/SparcV9/SparcV9RegInfo.h:1.13 --- llvm/lib/Target/SparcV9/SparcV9RegInfo.h:1.12 Fri Apr 23 13:15:48 2004 +++ llvm/lib/Target/SparcV9/SparcV9RegInfo.h Fri Apr 23 16:45:02 2004 @@ -230,7 +230,6 @@ // virtual unsigned getReturnAddressReg() const = 0; - // Each register class has a separate space for register IDs. To convert // a regId in a register class to a common Id, or vice versa, // we use the folloing two methods. @@ -286,7 +285,7 @@ virtual unsigned getFramePointer() const = 0; virtual unsigned getStackPointer() const = 0; - // This method gives the the number of bytes of stack spaceallocated + // This method gives the the number of bytes of stack space allocated // to a register when it is spilled to the stack. // virtual int getSpilledRegSize(int RegType) const = 0; From brukman at cs.uiuc.edu Fri Apr 23 18:54:02 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Fri Apr 23 18:54:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/CodeExtractor.cpp Message-ID: <200404232354.SAA28851@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: CodeExtractor.cpp updated: 1.16 -> 1.17 --- Log message: * Allow aggregating extracted function arguments (controlled by flag) * Commandline option (for now) controls that flag that is passed in --- Diffs of the changes: (+197 -45) Index: llvm/lib/Transforms/Utils/CodeExtractor.cpp diff -u llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.16 llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.17 --- llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.16 Wed Mar 17 23:56:32 2004 +++ llvm/lib/Transforms/Utils/CodeExtractor.cpp Fri Apr 23 18:54:17 2004 @@ -23,22 +23,35 @@ #include "llvm/Analysis/LoopInfo.h" #include "llvm/Analysis/Verifier.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" +#include "Support/CommandLine.h" #include "Support/Debug.h" #include "Support/StringExtras.h" #include #include using namespace llvm; +// Provide a command-line option to aggregate function arguments into a struct +// for functions produced by the code extrator. This is useful when converting +// extracted functions to pthread-based code, as only one argument (void*) can +// be passed in to pthread_create(). +static cl::opt +AggregateArgsOpt("aggregate-extracted-args", cl::Hidden, + cl::desc("Aggregate arguments to code-extracted functions")); + namespace { class CodeExtractor { typedef std::vector Values; std::set BlocksToExtract; DominatorSet *DS; + bool AggregateArgs; public: - CodeExtractor(DominatorSet *ds = 0) : DS(ds) {} + CodeExtractor(DominatorSet *ds = 0, bool AggArgs = false) + : DS(ds), AggregateArgs(AggregateArgsOpt) {} Function *ExtractCodeRegion(const std::vector &code); + bool isEligible(const std::vector &code); + private: void findInputsOutputs(Values &inputs, Values &outputs, BasicBlock *newHeader, @@ -135,15 +148,22 @@ for (Values::const_iterator I = outputs.begin(), E = outputs.end(); I != E; ++I) { DEBUG(std::cerr << "instr used in func: " << *I << "\n"); - paramTy.push_back(PointerType::get((*I)->getType())); + if (AggregateArgs) + paramTy.push_back((*I)->getType()); + else + paramTy.push_back(PointerType::get((*I)->getType())); } DEBUG(std::cerr << "Function type: " << retTy << " f("); - for (std::vector::iterator i = paramTy.begin(), - e = paramTy.end(); i != e; ++i) - DEBUG(std::cerr << *i << ", "); + DEBUG(for (std::vector::iterator i = paramTy.begin(), + e = paramTy.end(); i != e; ++i) std::cerr << *i << ", "); DEBUG(std::cerr << ")\n"); + if (AggregateArgs && (inputs.size() + outputs.size() > 0)) { + PointerType *StructPtr = PointerType::get(StructType::get(paramTy)); + paramTy.clear(); + paramTy.push_back(StructPtr); + } const FunctionType *funcType = FunctionType::get(retTy, paramTy, false); // Create the new function @@ -156,21 +176,36 @@ Function::aiterator AI = newFunction->abegin(); // Rewrite all users of the inputs in the extracted region to use the - // arguments instead. - for (unsigned i = 0, e = inputs.size(); i != e; ++i, ++AI) { - AI->setName(inputs[i]->getName()); + // arguments (or appropriate addressing into struct) instead. + for (unsigned i = 0, e = inputs.size(); i != e; ++i) { + Value *RewriteVal; + if (AggregateArgs) { + std::vector Indices; + Indices.push_back(Constant::getNullValue(Type::UIntTy)); + Indices.push_back(ConstantUInt::get(Type::UIntTy, i)); + std::string GEPname = "gep_" + inputs[i]->getName(); + TerminatorInst *TI = newFunction->begin()->getTerminator(); + GetElementPtrInst *GEP = new GetElementPtrInst(AI, Indices, GEPname, TI); + RewriteVal = new LoadInst(GEP, "load" + GEPname, TI); + } else + RewriteVal = AI++; + std::vector Users(inputs[i]->use_begin(), inputs[i]->use_end()); for (std::vector::iterator use = Users.begin(), useE = Users.end(); use != useE; ++use) if (Instruction* inst = dyn_cast(*use)) if (BlocksToExtract.count(inst->getParent())) - inst->replaceUsesOfWith(inputs[i], AI); + inst->replaceUsesOfWith(inputs[i], RewriteVal); } - // Set names for all of the output arguments. - for (unsigned i = 0, e = outputs.size(); i != e; ++i, ++AI) - AI->setName(outputs[i]->getName()+".out"); - + // Set names for input and output arguments. + if (!AggregateArgs) { + AI = newFunction->abegin(); + for (unsigned i = 0, e = inputs.size(); i != e; ++i, ++AI) + AI->setName(inputs[i]->getName()); + for (unsigned i = 0, e = outputs.size(); i != e; ++i, ++AI) + AI->setName(outputs[i]->getName()+".out"); + } // Rewrite branches to basic blocks outside of the loop to new dummy blocks // within the new function. This must be done before we lose track of which @@ -207,23 +242,84 @@ BasicBlock *codeReplacer, Values &inputs, Values &outputs) { - // Emit a call to the new function, passing allocated memory for outputs and - // just plain inputs for non-scalars - std::vector params(inputs); - // Get an iterator to the first output argument. + // Emit a call to the new function, passing in: + // *pointer to struct (if aggregating parameters), or + // plan inputs and allocated memory for outputs + std::vector params, StructValues, ReloadOutputs; + + // Add inputs as params, or to be filled into the struct + for (Values::iterator i = inputs.begin(), e = inputs.end(); i != e; ++i) + if (AggregateArgs) + StructValues.push_back(*i); + else + params.push_back(*i); + + // Create allocas for the outputs + for (Values::iterator i = outputs.begin(), e = outputs.end(); i != e; ++i) { + if (AggregateArgs) { + StructValues.push_back(*i); + } else { + AllocaInst *alloca = + new AllocaInst((*i)->getType(), 0, (*i)->getName()+".loc", + codeReplacer->getParent()->begin()->begin()); + ReloadOutputs.push_back(alloca); + params.push_back(alloca); + } + } + + AllocaInst *Struct = 0; + if (AggregateArgs && (inputs.size() + outputs.size() > 0)) { + std::vector ArgTypes; + for (Values::iterator v = StructValues.begin(), + ve = StructValues.end(); v != ve; ++v) + ArgTypes.push_back((*v)->getType()); + + // Allocate a struct at the beginning of this function + Type *StructArgTy = StructType::get(ArgTypes); + Struct = + new AllocaInst(StructArgTy, 0, "structArg", + codeReplacer->getParent()->begin()->begin()); + params.push_back(Struct); + + for (unsigned i = 0, e = inputs.size(); i != e; ++i) { + std::vector Indices; + Indices.push_back(Constant::getNullValue(Type::UIntTy)); + Indices.push_back(ConstantUInt::get(Type::UIntTy, i)); + GetElementPtrInst *GEP = + new GetElementPtrInst(Struct, Indices, + "gep_" + StructValues[i]->getName(), 0); + codeReplacer->getInstList().push_back(GEP); + StoreInst *SI = new StoreInst(StructValues[i], GEP); + codeReplacer->getInstList().push_back(SI); + } + } + + // Emit the call to the function + CallInst *call = new CallInst(newFunction, params, "targetBlock"); + codeReplacer->getInstList().push_back(call); + Function::aiterator OutputArgBegin = newFunction->abegin(); - std::advance(OutputArgBegin, inputs.size()); + unsigned FirstOut = inputs.size(); + if (!AggregateArgs) + std::advance(OutputArgBegin, inputs.size()); + // Reload the outputs passed in by reference for (unsigned i = 0, e = outputs.size(); i != e; ++i) { - Value *Output = outputs[i]; - // Create allocas for scalar outputs - AllocaInst *alloca = - new AllocaInst(outputs[i]->getType(), 0, Output->getName()+".loc", - codeReplacer->getParent()->begin()->begin()); - params.push_back(alloca); - - LoadInst *load = new LoadInst(alloca, Output->getName()+".reload"); + Value *Output = 0; + if (AggregateArgs) { + std::vector Indices; + Indices.push_back(Constant::getNullValue(Type::UIntTy)); + Indices.push_back(ConstantUInt::get(Type::UIntTy, FirstOut + i)); + GetElementPtrInst *GEP + = new GetElementPtrInst(Struct, Indices, + "gep_reload_" + outputs[i]->getName(), 0); + codeReplacer->getInstList().push_back(GEP); + Output = GEP; + } else { + Output = ReloadOutputs[i]; + } + LoadInst *load = new LoadInst(Output, outputs[i]->getName()+".reload"); codeReplacer->getInstList().push_back(load); std::vector Users(outputs[i]->use_begin(), outputs[i]->use_end()); for (unsigned u = 0, e = Users.size(); u != e; ++u) { @@ -233,9 +329,6 @@ } } - CallInst *call = new CallInst(newFunction, params, "targetBlock"); - codeReplacer->getInstList().push_front(call); - // Now we can emit a switch statement using the call as a value. SwitchInst *TheSwitch = new SwitchInst(call, codeReplacer, codeReplacer); @@ -268,13 +361,28 @@ TheSwitch->addCase(brVal, OldTarget); // Restore values just before we exit - // FIXME: Use a GetElementPtr to bunch the outputs in a struct Function::aiterator OAI = OutputArgBegin; - for (unsigned out = 0, e = outputs.size(); out != e; ++out, ++OAI) - if (!DS || - DS->dominates(cast(outputs[out])->getParent(), - TI->getParent())) - new StoreInst(outputs[out], OAI, NTRet); + for (unsigned out = 0, e = outputs.size(); out != e; ++out) { + // For an invoke, the normal destination is the only one that is + // dominated by the result of the invocation + BasicBlock *DefBlock = cast(outputs[out])->getParent(); + if (InvokeInst *Invoke = dyn_cast(outputs[out])) + DefBlock = Invoke->getNormalDest(); + if (!DS || DS->dominates(DefBlock, TI->getParent())) + if (AggregateArgs) { + std::vector Indices; + Indices.push_back(Constant::getNullValue(Type::UIntTy)); + Indices.push_back(ConstantUInt::get(Type::UIntTy,FirstOut+out)); + GetElementPtrInst *GEP = + new GetElementPtrInst(OAI, Indices, + "gep_" + outputs[out]->getName(), + NTRet); + new StoreInst(outputs[out], GEP, NTRet); + } else + new StoreInst(outputs[out], OAI, NTRet); + // Advance output iterator even if we don't emit a store + if (!AggregateArgs) ++OAI; + } } // rewrite the original branch instruction with this new target @@ -283,11 +391,39 @@ } // Now that we've done the deed, make the default destination of the switch - // instruction be one of the exit blocks of the region. + // instruction be a block with a call to abort() -- since this path should not + // be taken, this will abort sooner rather than later. if (TheSwitch->getNumSuccessors() > 1) { - // FIXME: this is broken w.r.t. PHI nodes, but the old code was more broken. - // This edge is not traversable. - TheSwitch->setSuccessor(0, TheSwitch->getSuccessor(1)); + Function *container = codeReplacer->getParent(); + BasicBlock *abortBB = new BasicBlock("abortBlock", container); + std::vector paramTypes; + FunctionType *abortTy = FunctionType::get(Type::VoidTy, paramTypes, false); + Function *abortFunc = + container->getParent()->getOrInsertFunction("abort", abortTy); + abortBB->getInstList().push_back(new CallInst(abortFunc)); + Function *ParentFunc = TheSwitch->getParent()->getParent(); + if (ParentFunc->getReturnType() == Type::VoidTy) + new ReturnInst(0, abortBB); + else + new ReturnInst(Constant::getNullValue(ParentFunc->getReturnType()), + abortBB); + TheSwitch->setSuccessor(0, abortBB); + } else { + // There is only 1 successor (the block containing the switch itself), which + // means that previously this was the last part of the function, and hence + // this should be rewritten as a `ret' + + // Check if the function should return a value + if (TheSwitch->getParent()->getParent()->getReturnType() != Type::VoidTy && + TheSwitch->getParent()->getParent()->getReturnType() == + TheSwitch->getCondition()->getType()) + // return what we have + new ReturnInst(TheSwitch->getCondition(), TheSwitch); + else + // just return + new ReturnInst(0, TheSwitch); + + TheSwitch->getParent()->getInstList().erase(TheSwitch); } } @@ -310,6 +446,9 @@ /// Function *CodeExtractor::ExtractCodeRegion(const std::vector &code) { + if (!isEligible(code)) + return 0; + // 1) Find inputs, outputs // 2) Construct new function // * Add allocas for defs, pass as args by reference @@ -393,24 +532,37 @@ return newFunction; } +bool CodeExtractor::isEligible(const std::vector &code) { + // Deny code region if it contains allocas + for (std::vector::const_iterator BB = code.begin(), e=code.end(); + BB != e; ++BB) + for (BasicBlock::const_iterator I = (*BB)->begin(), Ie = (*BB)->end(); + I != Ie; ++I) + if (isa(*I)) + return false; + return true; +} + + /// ExtractCodeRegion - slurp a sequence of basic blocks into a brand new /// function /// Function* llvm::ExtractCodeRegion(DominatorSet &DS, - const std::vector &code) { - return CodeExtractor(&DS).ExtractCodeRegion(code); + const std::vector &code, + bool AggregateArgs) { + return CodeExtractor(&DS, AggregateArgs).ExtractCodeRegion(code); } /// ExtractBasicBlock - slurp a natural loop into a brand new function /// -Function* llvm::ExtractLoop(DominatorSet &DS, Loop *L) { - return CodeExtractor(&DS).ExtractCodeRegion(L->getBlocks()); +Function* llvm::ExtractLoop(DominatorSet &DS, Loop *L, bool AggregateArgs) { + return CodeExtractor(&DS, AggregateArgs).ExtractCodeRegion(L->getBlocks()); } /// ExtractBasicBlock - slurp a basic block into a brand new function /// -Function* llvm::ExtractBasicBlock(BasicBlock *BB) { +Function* llvm::ExtractBasicBlock(BasicBlock *BB, bool AggregateArgs) { std::vector Blocks; Blocks.push_back(BB); - return CodeExtractor().ExtractCodeRegion(Blocks); + return CodeExtractor(0, AggregateArgs).ExtractCodeRegion(Blocks); } From brukman at cs.uiuc.edu Fri Apr 23 18:55:01 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Fri Apr 23 18:55:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Transforms/Utils/FunctionUtils.h Message-ID: <200404232354.SAA28868@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Transforms/Utils: FunctionUtils.h updated: 1.5 -> 1.6 --- Log message: Aggregating function arguments is now an option. Default is `no', as before. --- Diffs of the changes: (+5 -3) Index: llvm/include/llvm/Transforms/Utils/FunctionUtils.h diff -u llvm/include/llvm/Transforms/Utils/FunctionUtils.h:1.5 llvm/include/llvm/Transforms/Utils/FunctionUtils.h:1.6 --- llvm/include/llvm/Transforms/Utils/FunctionUtils.h:1.5 Wed Mar 17 21:47:46 2004 +++ llvm/include/llvm/Transforms/Utils/FunctionUtils.h Fri Apr 23 18:54:34 2004 @@ -25,15 +25,17 @@ /// ExtractCodeRegion - rip out a sequence of basic blocks into a new function /// Function* ExtractCodeRegion(DominatorSet &DS, - const std::vector &code); + const std::vector &code, + bool AggregateArgs = false); /// ExtractLoop - rip out a natural loop into a new function /// - Function* ExtractLoop(DominatorSet &DS, Loop *L); + Function* ExtractLoop(DominatorSet &DS, Loop *L, + bool AggregateArgs = false); /// ExtractBasicBlock - rip out a basic block into a new function /// - Function* ExtractBasicBlock(BasicBlock *BB); + Function* ExtractBasicBlock(BasicBlock *BB, bool AggregateArgs = false); } #endif From brukman at cs.uiuc.edu Fri Apr 23 19:11:01 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Fri Apr 23 19:11:01 2004 Subject: [llvm-commits] CVS: llvm/Makefile Makefile.common Makefile.config.in Makefile.rules Message-ID: <200404240011.TAA13808@zion.cs.uiuc.edu> Changes in directory llvm: Makefile updated: 1.23 -> 1.24 Makefile.common updated: 1.133 -> 1.134 Makefile.config.in updated: 1.25 -> 1.26 Makefile.rules updated: 1.180 -> 1.181 --- Log message: Standardize header comments of top-level Makefiles. --- Diffs of the changes: (+16 -9) Index: llvm/Makefile diff -u llvm/Makefile:1.23 llvm/Makefile:1.24 --- llvm/Makefile:1.23 Fri Apr 16 10:57:02 2004 +++ llvm/Makefile Fri Apr 23 19:10:56 2004 @@ -1,11 +1,11 @@ -##===- ./Makefile ------------------------------------------*- Makefile -*-===## +#===- ./Makefile -------------------------------------------*- Makefile -*--===# # # The LLVM Compiler Infrastructure # # This file was developed by the LLVM research group and is distributed under # the University of Illinois Open Source License. See LICENSE.TXT for details. # -##===----------------------------------------------------------------------===## +#===------------------------------------------------------------------------===# LEVEL = . DIRS = lib/Support utils lib tools Index: llvm/Makefile.common diff -u llvm/Makefile.common:1.133 llvm/Makefile.common:1.134 --- llvm/Makefile.common:1.133 Tue Oct 21 09:33:46 2003 +++ llvm/Makefile.common Fri Apr 23 19:10:56 2004 @@ -1,11 +1,11 @@ -#===-- Makefile.common - Common make rules for LLVM -------*- makefile -*--==== +#===-- Makefile.common - Common make rules for LLVM --------*- Makefile -*--===# # # The LLVM Compiler Infrastructure # # This file was developed by the LLVM research group and is distributed under # the University of Illinois Open Source License. See LICENSE.TXT for details. # -##===----------------------------------------------------------------------===## +#===------------------------------------------------------------------------===# # # This file is included by all of the LLVM makefiles. This file defines common # rules to do things like compile a .cpp file or generate dependency info. Index: llvm/Makefile.config.in diff -u llvm/Makefile.config.in:1.25 llvm/Makefile.config.in:1.26 --- llvm/Makefile.config.in:1.25 Wed Mar 10 11:37:50 2004 +++ llvm/Makefile.config.in Fri Apr 23 19:10:56 2004 @@ -1,9 +1,16 @@ -#===-- Makefile.config - Local configuration for LLVM ------*- makefile -*--==== +#===-- Makefile.config - Local configuration for LLVM ------*- Makefile -*--===# +# +# The LLVM Compiler Infrastructure +# +# This file was developed by the LLVM research group and is distributed under +# the University of Illinois Open Source License. See LICENSE.TXT for details. +# +#===------------------------------------------------------------------------===# # # This file is included by Makefile.common. It defines paths and other # values specific to a particular installation of LLVM. # -#===-----------------------------------------------------------------------==== +#===------------------------------------------------------------------------===# # Target operating system for which LLVM will be compiled. OS=@OS@ Index: llvm/Makefile.rules diff -u llvm/Makefile.rules:1.180 llvm/Makefile.rules:1.181 --- llvm/Makefile.rules:1.180 Wed Mar 10 11:38:01 2004 +++ llvm/Makefile.rules Fri Apr 23 19:10:56 2004 @@ -1,11 +1,11 @@ -#===-- Makefile.rules - Common make rules for LLVM -------*- makefile -*--==== -# +#===-- Makefile.rules - Common make rules for LLVM ---------*- Makefile -*--===# +# # The LLVM Compiler Infrastructure # # This file was developed by the LLVM research group and is distributed under # the University of Illinois Open Source License. See LICENSE.TXT for details. # -##===----------------------------------------------------------------------===## +#===------------------------------------------------------------------------===# # # This file is included by all of the LLVM makefiles. This file defines common # rules to do things like compile a .cpp file or generate dependency info. From brukman at cs.uiuc.edu Fri Apr 23 19:28:02 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Fri Apr 23 19:28:02 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/CINT2000/176.gcc/Makefile Message-ID: <200404240028.TAA18500@zion.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC/CINT2000/176.gcc: Makefile updated: 1.7 -> 1.8 --- Log message: Make makefile more readable by breaking logical sections with spaces. --- Diffs of the changes: (+3 -0) Index: llvm/test/Programs/External/SPEC/CINT2000/176.gcc/Makefile diff -u llvm/test/Programs/External/SPEC/CINT2000/176.gcc/Makefile:1.7 llvm/test/Programs/External/SPEC/CINT2000/176.gcc/Makefile:1.8 --- llvm/test/Programs/External/SPEC/CINT2000/176.gcc/Makefile:1.7 Sun Feb 29 18:59:18 2004 +++ llvm/test/Programs/External/SPEC/CINT2000/176.gcc/Makefile Fri Apr 23 19:28:07 2004 @@ -1,11 +1,14 @@ LEVEL = ../../../../../.. + ifeq ($(RUN_TYPE),test) RUN_OPTIONS = cccp.i -o cccp.s else RUN_OPTIONS = cp-decl.i -o cp-decl.s endif STDOUT_FILENAME = cccp.out + include ../../Makefile.spec2000 + ifeq ($(ARCH),Sparc) ## SPEC portability note for GCC says to use these flags and cross fingers: CPPFLAGS += -DHOST_WORDS_BIG_ENDIAN -DSPEC_CPU2000_LP64 From gaeke at cs.uiuc.edu Sun Apr 25 01:32:02 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Sun Apr 25 01:32:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/SparcV9RegisterInfo.h SparcV9RegisterInfo.cpp Message-ID: <200404250632.BAA29018@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9: SparcV9RegisterInfo.h added (r1.1) SparcV9RegisterInfo.cpp added (r1.1) --- Log message: Add MRegisterInfo subclass for the SparcV9 target (containing only stub functions for now). This automatically turns on the printing of machine registers using their own real names, instead of goofy things like %mreg(42), and allows us to migrate code incrementally to the new interface as we see fit. The register file description it uses is hand-written, so that the register numbers will match the ones that the SparcV9 target already uses. Perhaps someday we'll tablegen it. --- Diffs of the changes: (+420 -0) Index: llvm/lib/Target/SparcV9/SparcV9RegisterInfo.h diff -c /dev/null llvm/lib/Target/SparcV9/SparcV9RegisterInfo.h:1.1 *** /dev/null Sun Apr 25 01:32:15 2004 --- llvm/lib/Target/SparcV9/SparcV9RegisterInfo.h Sun Apr 25 01:32:05 2004 *************** *** 0 **** --- 1,108 ---- + //===- SparcV9RegisterInfo.h - SparcV9 Register Information Impl -*- C++ -*-==// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This file contains the SparcV9 implementation of the MRegisterInfo class. + // It also contains stuff needed to instantiate that class, which would + // ordinarily be provided by TableGen. + // + //===----------------------------------------------------------------------===// + + #ifndef SPARCV9REGISTERINFO_H + #define SPARCV9REGISTERINFO_H + + #include "llvm/Target/MRegisterInfo.h" + + namespace llvm { + + struct SparcV9RegisterInfo : public MRegisterInfo { + SparcV9RegisterInfo (); + const unsigned *getCalleeSaveRegs() const; + + // The rest of these are stubs... for now. + int storeRegToStackSlot (MachineBasicBlock &MBB, + MachineBasicBlock::iterator MI, + unsigned SrcReg, int FrameIndex, + const TargetRegisterClass *RC) const; + int loadRegFromStackSlot (MachineBasicBlock &MBB, + MachineBasicBlock::iterator MI, + unsigned DestReg, int FrameIndex, + const TargetRegisterClass *RC) const; + int copyRegToReg (MachineBasicBlock &MBB, + MachineBasicBlock::iterator MI, + unsigned DestReg, unsigned SrcReg, + const TargetRegisterClass *RC) const; + void eliminateFrameIndex (MachineFunction &MF, + MachineBasicBlock::iterator MI) const; + void emitPrologue (MachineFunction &MF) const; + void emitEpilogue (MachineFunction &MF, MachineBasicBlock &MBB) const; + }; + + } // End llvm namespace + + //===----------------------------------------------------------------------===// + // + // The second section of this file (immediately following) contains + // a *handwritten* SparcV9 unified register number enumeration, which + // provides a flat namespace containing all the SparcV9 unified + // register numbers. + // + // It would ordinarily be contained in the file SparcV9GenRegisterNames.inc + // if we were using TableGen to generate the register file description + // automatically. + // + //===----------------------------------------------------------------------===// + + namespace llvm { + namespace SparcV9 { + enum { + // FIXME - Register 0 is not a "non-register" like it is on other targets!! + + // SparcV9IntRegClass(IntRegClassID) + // - unified register numbers 0 ... 31 (32 regs) + /* 0 */ o0, o1, o2, o3, o4, + /* 5 */ o5, o7, l0, l1, l2, + /* 10 */ l3, l4, l5, l6, l7, + /* 15 */ i0, i1, i2, i3, i4, + /* 20 */ i5, i6, i7, g0, g1, + /* 25 */ g2, g3, g4, g5, g6, + /* 30 */ g7, o6, + + // SparcV9FloatRegClass(FloatRegClassID) + // - unified register numbers 32 ... 95 (64 regs) + /* 32 */ f0, f1, f2, + /* 35 */ f3, f4, f5, f6, f7, + /* 40 */ f8, f9, f10, f11, f12, + /* 45 */ f13, f14, f15, f16, f17, + /* 50 */ f18, f19, f20, f21, f22, + /* 55 */ f23, f24, f25, f26, f27, + /* 60 */ f28, f29, f30, f31, f32, + /* 65 */ f33, f34, f35, f36, f37, + /* 70 */ f38, f39, f40, f41, f42, + /* 75 */ f43, f44, f45, f46, f47, + /* 80 */ f48, f49, f50, f51, f52, + /* 85 */ f53, f54, f55, f56, f57, + /* 90 */ f58, f59, f60, f61, f62, + /* 95 */ f63, + + // SparcV9IntCCRegClass(IntCCRegClassID) + // - unified register numbers 96 ... 98 (3 regs) + /* 96 */ xcc, icc, ccr, + + // SparcV9FloatCCRegClass(FloatCCRegClassID) + // - unified register numbers 99 ... 102 (4 regs) + /* 99 */ fcc0, fcc1, fcc2, fcc3, + + // SparcV9SpecialRegClass(SpecialRegClassID) + // - unified register number 103 (1 reg) + /* 103 */ fsr + }; + } // end namespace SparcV9 + } // end namespace llvm + + #endif // SPARCV9REGISTERINFO_H Index: llvm/lib/Target/SparcV9/SparcV9RegisterInfo.cpp diff -c /dev/null llvm/lib/Target/SparcV9/SparcV9RegisterInfo.cpp:1.1 *** /dev/null Sun Apr 25 01:32:15 2004 --- llvm/lib/Target/SparcV9/SparcV9RegisterInfo.cpp Sun Apr 25 01:32:05 2004 *************** *** 0 **** --- 1,312 ---- + //===- SparcV9RegisterInfo.cpp - SparcV9 Register Information ---*- C++ -*-===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This file contains the SparcV9 implementation of the MRegisterInfo class. + // It also contains stuff needed to instantiate that class, which would + // ordinarily be provided by TableGen. + // + // This is NOT used by the SparcV9 backend to do register allocation, yet. + // + //===----------------------------------------------------------------------===// + // + // The first section of this file (immediately following) is what + // you would find in SparcV9GenRegisterInfo.inc, if we were using + // TableGen to generate the register file description automatically. + // It consists of register classes and register class instances + // for the SparcV9 target. + // + // FIXME: the alignments listed here are wild guesses. + // + //===----------------------------------------------------------------------===// + + #include "SparcV9RegisterInfo.h" + #include "llvm/CodeGen/MachineFunction.h" + using namespace llvm; + + namespace llvm { + + namespace { + // IR Register Class... + const unsigned IR[] = { + SparcV9::o0, SparcV9::o1, SparcV9::o2, SparcV9::o3, SparcV9::o4, + SparcV9::o5, SparcV9::o7, SparcV9::l0, SparcV9::l1, SparcV9::l2, + SparcV9::l3, SparcV9::l4, SparcV9::l5, SparcV9::l6, SparcV9::l7, + SparcV9::i0, SparcV9::i1, SparcV9::i2, SparcV9::i3, SparcV9::i4, + SparcV9::i5, SparcV9::i6, SparcV9::i7, SparcV9::g0, SparcV9::g1, + SparcV9::g2, SparcV9::g3, SparcV9::g4, SparcV9::g5, SparcV9::g6, + SparcV9::g7, SparcV9::o6 + }; + struct IRClass : public TargetRegisterClass { + IRClass() : TargetRegisterClass(8, 8, IR, IR + 32) {} + } IRInstance; + + + // FR Register Class... + const unsigned FR[] = { + SparcV9::f0, SparcV9::f1, SparcV9::f2, SparcV9::f3, SparcV9::f4, + SparcV9::f5, SparcV9::f6, SparcV9::f7, SparcV9::f8, SparcV9::f9, + SparcV9::f10, SparcV9::f11, SparcV9::f12, SparcV9::f13, + SparcV9::f14, SparcV9::f15, SparcV9::f16, SparcV9::f17, + SparcV9::f18, SparcV9::f19, SparcV9::f20, SparcV9::f21, + SparcV9::f22, SparcV9::f23, SparcV9::f24, SparcV9::f25, + SparcV9::f26, SparcV9::f27, SparcV9::f28, SparcV9::f29, + SparcV9::f30, SparcV9::f31, SparcV9::f32, SparcV9::f33, + SparcV9::f34, SparcV9::f35, SparcV9::f36, SparcV9::f37, + SparcV9::f38, SparcV9::f39, SparcV9::f40, SparcV9::f41, + SparcV9::f42, SparcV9::f43, SparcV9::f44, SparcV9::f45, + SparcV9::f46, SparcV9::f47, SparcV9::f48, SparcV9::f49, + SparcV9::f50, SparcV9::f51, SparcV9::f52, SparcV9::f53, + SparcV9::f54, SparcV9::f55, SparcV9::f56, SparcV9::f57, + SparcV9::f58, SparcV9::f59, SparcV9::f60, SparcV9::f61, + SparcV9::f62, SparcV9::f63 + }; + // FIXME: The size is correct for the first 32 registers. The + // latter 32 do not all really exist; you can only access every other + // one (32, 34, ...), and they must contain double-fp or quad-fp + // values... see below about the aliasing problems. + struct FRClass : public TargetRegisterClass { + FRClass() : TargetRegisterClass(4, 8, FR, FR + 64) {} + } FRInstance; + + + // ICCR Register Class... + const unsigned ICCR[] = { + SparcV9::xcc, SparcV9::icc, SparcV9::ccr + }; + struct ICCRClass : public TargetRegisterClass { + ICCRClass() : TargetRegisterClass(1, 8, ICCR, ICCR + 3) {} + } ICCRInstance; + + + // FCCR Register Class... + const unsigned FCCR[] = { + SparcV9::fcc0, SparcV9::fcc1, SparcV9::fcc2, SparcV9::fcc3 + }; + struct FCCRClass : public TargetRegisterClass { + FCCRClass() : TargetRegisterClass(1, 8, FCCR, FCCR + 4) {} + } FCCRInstance; + + + // SR Register Class... + const unsigned SR[] = { + SparcV9::fsr + }; + struct SRClass : public TargetRegisterClass { + SRClass() : TargetRegisterClass(8, 8, SR, SR + 1) {} + } SRInstance; + + + // Register Classes... + const TargetRegisterClass* const RegisterClasses[] = { + &IRInstance, + &FRInstance, + &ICCRInstance, + &FCCRInstance, + &SRInstance + }; + + + // Register Alias Sets... + // FIXME: Note that the SparcV9 backend does not currently abstract + // very well over the way that double-fp and quad-fp values may alias + // single-fp values in registers. Therefore those aliases are NOT + // reflected here. + const unsigned Empty_AliasSet[] = { 0 }; + const unsigned fcc3_AliasSet[] = { SparcV9::fsr, 0 }; + const unsigned fcc2_AliasSet[] = { SparcV9::fsr, 0 }; + const unsigned fcc1_AliasSet[] = { SparcV9::fsr, 0 }; + const unsigned fcc0_AliasSet[] = { SparcV9::fsr, 0 }; + const unsigned fsr_AliasSet[] = { SparcV9::fcc3, SparcV9::fcc2, + SparcV9::fcc1, SparcV9::fcc0, 0 }; + const unsigned xcc_AliasSet[] = { SparcV9::ccr, 0 }; + const unsigned icc_AliasSet[] = { SparcV9::ccr, 0 }; + const unsigned ccr_AliasSet[] = { SparcV9::xcc, SparcV9::icc, 0 }; + + const MRegisterDesc RegisterDescriptors[] = { // Descriptors + { "o0", Empty_AliasSet, 0, 0 }, + { "o1", Empty_AliasSet, 0, 0 }, + { "o2", Empty_AliasSet, 0, 0 }, + { "o3", Empty_AliasSet, 0, 0 }, + { "o4", Empty_AliasSet, 0, 0 }, + { "o5", Empty_AliasSet, 0, 0 }, + { "o7", Empty_AliasSet, 0, 0 }, + { "l0", Empty_AliasSet, 0, 0 }, + { "l1", Empty_AliasSet, 0, 0 }, + { "l2", Empty_AliasSet, 0, 0 }, + { "l3", Empty_AliasSet, 0, 0 }, + { "l4", Empty_AliasSet, 0, 0 }, + { "l5", Empty_AliasSet, 0, 0 }, + { "l6", Empty_AliasSet, 0, 0 }, + { "l7", Empty_AliasSet, 0, 0 }, + { "i0", Empty_AliasSet, 0, 0 }, + { "i1", Empty_AliasSet, 0, 0 }, + { "i2", Empty_AliasSet, 0, 0 }, + { "i3", Empty_AliasSet, 0, 0 }, + { "i4", Empty_AliasSet, 0, 0 }, + { "i5", Empty_AliasSet, 0, 0 }, + { "i6", Empty_AliasSet, 0, 0 }, + { "i7", Empty_AliasSet, 0, 0 }, + { "g0", Empty_AliasSet, 0, 0 }, + { "g1", Empty_AliasSet, 0, 0 }, + { "g2", Empty_AliasSet, 0, 0 }, + { "g3", Empty_AliasSet, 0, 0 }, + { "g4", Empty_AliasSet, 0, 0 }, + { "g5", Empty_AliasSet, 0, 0 }, + { "g6", Empty_AliasSet, 0, 0 }, + { "g7", Empty_AliasSet, 0, 0 }, + { "o6", Empty_AliasSet, 0, 0 }, + { "f0", Empty_AliasSet, 0, 0 }, + { "f1", Empty_AliasSet, 0, 0 }, + { "f2", Empty_AliasSet, 0, 0 }, + { "f3", Empty_AliasSet, 0, 0 }, + { "f4", Empty_AliasSet, 0, 0 }, + { "f5", Empty_AliasSet, 0, 0 }, + { "f6", Empty_AliasSet, 0, 0 }, + { "f7", Empty_AliasSet, 0, 0 }, + { "f8", Empty_AliasSet, 0, 0 }, + { "f9", Empty_AliasSet, 0, 0 }, + { "f10", Empty_AliasSet, 0, 0 }, + { "f11", Empty_AliasSet, 0, 0 }, + { "f12", Empty_AliasSet, 0, 0 }, + { "f13", Empty_AliasSet, 0, 0 }, + { "f14", Empty_AliasSet, 0, 0 }, + { "f15", Empty_AliasSet, 0, 0 }, + { "f16", Empty_AliasSet, 0, 0 }, + { "f17", Empty_AliasSet, 0, 0 }, + { "f18", Empty_AliasSet, 0, 0 }, + { "f19", Empty_AliasSet, 0, 0 }, + { "f20", Empty_AliasSet, 0, 0 }, + { "f21", Empty_AliasSet, 0, 0 }, + { "f22", Empty_AliasSet, 0, 0 }, + { "f23", Empty_AliasSet, 0, 0 }, + { "f24", Empty_AliasSet, 0, 0 }, + { "f25", Empty_AliasSet, 0, 0 }, + { "f26", Empty_AliasSet, 0, 0 }, + { "f27", Empty_AliasSet, 0, 0 }, + { "f28", Empty_AliasSet, 0, 0 }, + { "f29", Empty_AliasSet, 0, 0 }, + { "f30", Empty_AliasSet, 0, 0 }, + { "f31", Empty_AliasSet, 0, 0 }, + { "f32", Empty_AliasSet, 0, 0 }, + { "f33", Empty_AliasSet, 0, 0 }, + { "f34", Empty_AliasSet, 0, 0 }, + { "f35", Empty_AliasSet, 0, 0 }, + { "f36", Empty_AliasSet, 0, 0 }, + { "f37", Empty_AliasSet, 0, 0 }, + { "f38", Empty_AliasSet, 0, 0 }, + { "f39", Empty_AliasSet, 0, 0 }, + { "f40", Empty_AliasSet, 0, 0 }, + { "f41", Empty_AliasSet, 0, 0 }, + { "f42", Empty_AliasSet, 0, 0 }, + { "f43", Empty_AliasSet, 0, 0 }, + { "f44", Empty_AliasSet, 0, 0 }, + { "f45", Empty_AliasSet, 0, 0 }, + { "f46", Empty_AliasSet, 0, 0 }, + { "f47", Empty_AliasSet, 0, 0 }, + { "f48", Empty_AliasSet, 0, 0 }, + { "f49", Empty_AliasSet, 0, 0 }, + { "f50", Empty_AliasSet, 0, 0 }, + { "f51", Empty_AliasSet, 0, 0 }, + { "f52", Empty_AliasSet, 0, 0 }, + { "f53", Empty_AliasSet, 0, 0 }, + { "f54", Empty_AliasSet, 0, 0 }, + { "f55", Empty_AliasSet, 0, 0 }, + { "f56", Empty_AliasSet, 0, 0 }, + { "f57", Empty_AliasSet, 0, 0 }, + { "f58", Empty_AliasSet, 0, 0 }, + { "f59", Empty_AliasSet, 0, 0 }, + { "f60", Empty_AliasSet, 0, 0 }, + { "f61", Empty_AliasSet, 0, 0 }, + { "f62", Empty_AliasSet, 0, 0 }, + { "f63", Empty_AliasSet, 0, 0 }, + { "xcc", xcc_AliasSet, 0, 0 }, + { "icc", icc_AliasSet, 0, 0 }, + { "ccr", ccr_AliasSet, 0, 0 }, + { "fcc0", fcc0_AliasSet, 0, 0 }, + { "fcc1", fcc1_AliasSet, 0, 0 }, + { "fcc2", fcc2_AliasSet, 0, 0 }, + { "fcc3", fcc3_AliasSet, 0, 0 }, + { "fsr", fsr_AliasSet, 0, 0 }, + }; + + } // end anonymous namespace + + namespace SparcV9 { // Register classes + TargetRegisterClass *IRRegisterClass = &IRInstance; + TargetRegisterClass *FRRegisterClass = &FRInstance; + TargetRegisterClass *ICCRRegisterClass = &ICCRInstance; + TargetRegisterClass *FCCRRegisterClass = &FCCRInstance; + TargetRegisterClass *SRRegisterClass = &SRInstance; + } // end namespace SparcV9 + + const unsigned *SparcV9RegisterInfo::getCalleeSaveRegs() const { + // FIXME: This should be verified against the SparcV9 ABI at some point. + // These are the registers which the SparcV9 backend considers + // "non-volatile". + static const unsigned CalleeSaveRegs[] = { + SparcV9::l0, SparcV9::l1, SparcV9::l2, SparcV9::l3, SparcV9::l4, + SparcV9::l5, SparcV9::l6, SparcV9::l7, SparcV9::i0, SparcV9::i1, + SparcV9::i2, SparcV9::i3, SparcV9::i4, SparcV9::i5, SparcV9::i6, + SparcV9::i7, SparcV9::g0, SparcV9::g1, SparcV9::g2, SparcV9::g3, + SparcV9::g4, SparcV9::g5, SparcV9::g6, SparcV9::g7, SparcV9::o6, + 0 + }; + return CalleeSaveRegs; + } + + } // end namespace llvm + + //===----------------------------------------------------------------------===// + // + // The second section of this file (immediately following) contains the + // SparcV9 implementation of the MRegisterInfo class. It currently consists + // entirely of stub functions, because the SparcV9 target does not use the + // same register allocator that the X86 target uses. + // + //===----------------------------------------------------------------------===// + + SparcV9RegisterInfo::SparcV9RegisterInfo () + : MRegisterInfo (RegisterDescriptors, 104, RegisterClasses, + RegisterClasses + 5) { + } + + int SparcV9RegisterInfo::storeRegToStackSlot(MachineBasicBlock &MBB, + MachineBasicBlock::iterator MI, + unsigned SrcReg, int FrameIndex, + const TargetRegisterClass *RC) const { + abort (); + } + + int SparcV9RegisterInfo::loadRegFromStackSlot(MachineBasicBlock &MBB, + MachineBasicBlock::iterator MI, + unsigned DestReg, int FrameIndex, + const TargetRegisterClass *RC) const { + abort (); + } + + int SparcV9RegisterInfo::copyRegToReg(MachineBasicBlock &MBB, + MachineBasicBlock::iterator MI, + unsigned DestReg, unsigned SrcReg, + const TargetRegisterClass *RC) const { + abort (); + } + + void SparcV9RegisterInfo::eliminateFrameIndex(MachineFunction &MF, + MachineBasicBlock::iterator MI) const { + abort (); + } + + void SparcV9RegisterInfo::emitPrologue(MachineFunction &MF) const { + abort (); + } + + void SparcV9RegisterInfo::emitEpilogue(MachineFunction &MF, + MachineBasicBlock &MBB) const { + abort (); + } From gaeke at cs.uiuc.edu Sun Apr 25 01:32:07 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Sun Apr 25 01:32:07 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/SparcV9InstrInfo.h Message-ID: <200404250632.BAA29058@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9: SparcV9InstrInfo.h updated: 1.4 -> 1.5 --- Log message: Regularize file header comment and include guard. Include SparcV9RegisterInfo.h. Add a getRegisterInfo() accessor and SparcV9RegisterInfo instance, just like on the X86 target. --- Diffs of the changes: (+12 -3) Index: llvm/lib/Target/SparcV9/SparcV9InstrInfo.h diff -u llvm/lib/Target/SparcV9/SparcV9InstrInfo.h:1.4 llvm/lib/Target/SparcV9/SparcV9InstrInfo.h:1.5 --- llvm/lib/Target/SparcV9/SparcV9InstrInfo.h:1.4 Sat Feb 28 23:58:16 2004 +++ llvm/lib/Target/SparcV9/SparcV9InstrInfo.h Sun Apr 25 01:32:16 2004 @@ -1,4 +1,4 @@ -//===-- SparcV9InstrInfo.h - Define TargetInstrInfo for SparcV9 -----*- C++ -*-===// +//===-- SparcV9InstrInfo.h - Define TargetInstrInfo for SparcV9 -*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -14,17 +14,26 @@ // //===----------------------------------------------------------------------===// -#ifndef SPARC_INSTRINFO_H -#define SPARC_INSTRINFO_H +#ifndef SPARCV9INSTRINFO_H +#define SPARCV9INSTRINFO_H #include "llvm/Target/TargetInstrInfo.h" #include "llvm/CodeGen/MachineInstr.h" #include "SparcV9Internals.h" +#include "SparcV9RegisterInfo.h" namespace llvm { struct SparcV9InstrInfo : public TargetInstrInfo { + const SparcV9RegisterInfo RI; +public: SparcV9InstrInfo(); + + /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As + /// such, whenever a client has an instance of instruction info, it should + /// always be able to get register info as well (through this method). + /// + virtual const MRegisterInfo &getRegisterInfo() const { return RI; } // All immediate constants are in position 1 except the // store instructions and SETxx. From gaeke at cs.uiuc.edu Sun Apr 25 01:33:02 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Sun Apr 25 01:33:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/SparcV9TargetMachine.h Message-ID: <200404250632.BAA29099@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9: SparcV9TargetMachine.h updated: 1.6 -> 1.7 --- Log message: Add a getRegisterInfo() accessor just like on the X86 target. --- Diffs of the changes: (+3 -0) Index: llvm/lib/Target/SparcV9/SparcV9TargetMachine.h diff -u llvm/lib/Target/SparcV9/SparcV9TargetMachine.h:1.6 llvm/lib/Target/SparcV9/SparcV9TargetMachine.h:1.7 --- llvm/lib/Target/SparcV9/SparcV9TargetMachine.h:1.6 Mon Mar 1 00:43:29 2004 +++ llvm/lib/Target/SparcV9/SparcV9TargetMachine.h Sun Apr 25 01:32:28 2004 @@ -39,6 +39,9 @@ virtual const TargetRegInfo &getRegInfo() const { return regInfo; } virtual const TargetFrameInfo &getFrameInfo() const { return frameInfo; } virtual TargetJITInfo *getJITInfo() { return &jitInfo; } + virtual const MRegisterInfo *getRegisterInfo() const { + return &instrInfo.getRegisterInfo(); + } virtual bool addPassesToEmitAssembly(PassManager &PM, std::ostream &Out); virtual bool addPassesToEmitMachineCode(FunctionPassManager &PM, From gaeke at cs.uiuc.edu Sun Apr 25 02:05:02 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Sun Apr 25 02:05:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/EmitBytecodeToAssembly.cpp MachineInstrAnnot.h Makefile MappingInfo.cpp MappingInfo.h SparcV9.td SparcV9AsmPrinter.cpp SparcV9FrameInfo.cpp SparcV9FrameInfo.h SparcV9Instr.def SparcV9InstrInfo.cpp SparcV9InstrInfo.h SparcV9InstrSelection.cpp SparcV9InstrSelectionSupport.h SparcV9Internals.h SparcV9JITInfo.h SparcV9PeepholeOpts.cpp SparcV9PreSelection.cpp SparcV9PrologEpilogInserter.cpp SparcV9RegClassInfo.cpp SparcV9RegClassInfo.h SparcV9RegInfo.cpp SparcV9SchedInfo.cpp SparcV9StackSlots.cpp SparcV9TargetMachine.cpp SparcV9TargetMachine.h SparcV9_F2.td SparcV9_F3.td SparcV9_F4.td SparcV9_Reg.td Message-ID: <200404250704.CAA29428@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9: EmitBytecodeToAssembly.cpp updated: 1.13 -> 1.14 MachineInstrAnnot.h updated: 1.14 -> 1.15 Makefile updated: 1.41 -> 1.42 MappingInfo.cpp updated: 1.16 -> 1.17 MappingInfo.h updated: 1.7 -> 1.8 SparcV9.td updated: 1.30 -> 1.31 SparcV9AsmPrinter.cpp updated: 1.109 -> 1.110 SparcV9FrameInfo.cpp updated: 1.2 -> 1.3 SparcV9FrameInfo.h updated: 1.3 -> 1.4 SparcV9Instr.def updated: 1.25 -> 1.26 SparcV9InstrInfo.cpp updated: 1.62 -> 1.63 SparcV9InstrInfo.h updated: 1.5 -> 1.6 SparcV9InstrSelection.cpp updated: 1.139 -> 1.140 SparcV9InstrSelectionSupport.h updated: 1.15 -> 1.16 SparcV9Internals.h updated: 1.113 -> 1.114 SparcV9JITInfo.h updated: 1.4 -> 1.5 SparcV9PeepholeOpts.cpp updated: 1.22 -> 1.23 SparcV9PreSelection.cpp updated: 1.32 -> 1.33 SparcV9PrologEpilogInserter.cpp updated: 1.37 -> 1.38 SparcV9RegClassInfo.cpp updated: 1.35 -> 1.36 SparcV9RegClassInfo.h updated: 1.26 -> 1.27 SparcV9RegInfo.cpp updated: 1.125 -> 1.126 SparcV9SchedInfo.cpp updated: 1.11 -> 1.12 SparcV9StackSlots.cpp updated: 1.10 -> 1.11 SparcV9TargetMachine.cpp updated: 1.109 -> 1.110 SparcV9TargetMachine.h updated: 1.7 -> 1.8 SparcV9_F2.td updated: 1.9 -> 1.10 SparcV9_F3.td updated: 1.18 -> 1.19 SparcV9_F4.td updated: 1.11 -> 1.12 SparcV9_Reg.td updated: 1.8 -> 1.9 --- Log message: Fix file header comments and include guards -- many files have been moved or renamed since they were last spiffed up, or they just never had proper comments in the first place. --- Diffs of the changes: (+67 -54) Index: llvm/lib/Target/SparcV9/EmitBytecodeToAssembly.cpp diff -u llvm/lib/Target/SparcV9/EmitBytecodeToAssembly.cpp:1.13 llvm/lib/Target/SparcV9/EmitBytecodeToAssembly.cpp:1.14 --- llvm/lib/Target/SparcV9/EmitBytecodeToAssembly.cpp:1.13 Wed Feb 25 12:44:15 2004 +++ llvm/lib/Target/SparcV9/EmitBytecodeToAssembly.cpp Sun Apr 25 02:04:49 2004 @@ -1,4 +1,4 @@ -//===-- EmitBytecodeToAssembly.cpp - Emit bytecode to SparcV9 .s File --------==// +//===-- EmitBytecodeToAssembly.cpp - Emit bytecode to SparcV9 .s File ------==// // // The LLVM Compiler Infrastructure // Index: llvm/lib/Target/SparcV9/MachineInstrAnnot.h diff -u llvm/lib/Target/SparcV9/MachineInstrAnnot.h:1.14 llvm/lib/Target/SparcV9/MachineInstrAnnot.h:1.15 --- llvm/lib/Target/SparcV9/MachineInstrAnnot.h:1.14 Fri Apr 23 13:15:47 2004 +++ llvm/lib/Target/SparcV9/MachineInstrAnnot.h Sun Apr 25 02:04:49 2004 @@ -1,4 +1,4 @@ -//===-- llvm/CodeGen/MachineInstrAnnot.h ------------------------*- C++ -*-===// +//===-- MachineInstrAnnot.h -------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,12 +7,12 @@ // //===----------------------------------------------------------------------===// // -// Annotations used to pass information between code generation phases. +// Annotations used to pass information between SparcV9 code generation phases. // //===----------------------------------------------------------------------===// -#ifndef MACHINE_INSTR_ANNOT_h -#define MACHINE_INSTR_ANNOT_h +#ifndef MACHINEINSTRANNOT_H +#define MACHINEINSTRANNOT_H #include "llvm/CodeGen/MachineInstr.h" #include "SparcV9RegInfo.h" Index: llvm/lib/Target/SparcV9/Makefile diff -u llvm/lib/Target/SparcV9/Makefile:1.41 llvm/lib/Target/SparcV9/Makefile:1.42 --- llvm/lib/Target/SparcV9/Makefile:1.41 Wed Feb 25 12:44:15 2004 +++ llvm/lib/Target/SparcV9/Makefile Sun Apr 25 02:04:49 2004 @@ -1,4 +1,4 @@ -##===- lib/Target/SparcV9/Makefile ---------------------------*- Makefile -*-===## +##===- lib/Target/SparcV9/Makefile -------------------------*- Makefile -*-===## # # The LLVM Compiler Infrastructure # Index: llvm/lib/Target/SparcV9/MappingInfo.cpp diff -u llvm/lib/Target/SparcV9/MappingInfo.cpp:1.16 llvm/lib/Target/SparcV9/MappingInfo.cpp:1.17 --- llvm/lib/Target/SparcV9/MappingInfo.cpp:1.16 Wed Feb 11 20:27:09 2004 +++ llvm/lib/Target/SparcV9/MappingInfo.cpp Sun Apr 25 02:04:49 2004 @@ -1,4 +1,4 @@ -//===- MappingInfo.cpp - create LLVM info and output to .s file ---------===// +//===- MappingInfo.cpp - create LLVM info and output to .s file -----------===// // // The LLVM Compiler Infrastructure // Index: llvm/lib/Target/SparcV9/MappingInfo.h diff -u llvm/lib/Target/SparcV9/MappingInfo.h:1.7 llvm/lib/Target/SparcV9/MappingInfo.h:1.8 --- llvm/lib/Target/SparcV9/MappingInfo.h:1.7 Wed Feb 25 12:44:15 2004 +++ llvm/lib/Target/SparcV9/MappingInfo.h Sun Apr 25 02:04:49 2004 @@ -1,4 +1,4 @@ -//===- lib/Target/SparcV9/MappingInfo.h ---------------------------*- C++ -*-===// +//===- lib/Target/SparcV9/MappingInfo.h -------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // Index: llvm/lib/Target/SparcV9/SparcV9.td diff -u llvm/lib/Target/SparcV9/SparcV9.td:1.30 llvm/lib/Target/SparcV9/SparcV9.td:1.31 --- llvm/lib/Target/SparcV9/SparcV9.td:1.30 Wed Feb 25 12:44:15 2004 +++ llvm/lib/Target/SparcV9/SparcV9.td Sun Apr 25 02:04:49 2004 @@ -1,4 +1,4 @@ -//===- SparcV9.td - Target Description for SparcV9 V9 Target ----------------===// +//===- SparcV9.td - Target Description for SparcV9 Target -----------------===// // // The LLVM Compiler Infrastructure // @@ -7,7 +7,8 @@ // //===----------------------------------------------------------------------===// // -// TODO: Need a description here. +// TableGen target description file for the SparcV9. This is currently used +// primarily to generate part of the SparcV9CodeEmitter automatically. // //===----------------------------------------------------------------------===// Index: llvm/lib/Target/SparcV9/SparcV9AsmPrinter.cpp diff -u llvm/lib/Target/SparcV9/SparcV9AsmPrinter.cpp:1.109 llvm/lib/Target/SparcV9/SparcV9AsmPrinter.cpp:1.110 --- llvm/lib/Target/SparcV9/SparcV9AsmPrinter.cpp:1.109 Mon Mar 1 00:43:28 2004 +++ llvm/lib/Target/SparcV9/SparcV9AsmPrinter.cpp Sun Apr 25 02:04:49 2004 @@ -1,4 +1,4 @@ -//===-- EmitAssembly.cpp - Emit SparcV9 Specific .s File ---------------------==// +//===-- EmitAssembly.cpp - Emit SparcV9 Specific .s File -------------------==// // // The LLVM Compiler Infrastructure // Index: llvm/lib/Target/SparcV9/SparcV9FrameInfo.cpp diff -u llvm/lib/Target/SparcV9/SparcV9FrameInfo.cpp:1.2 llvm/lib/Target/SparcV9/SparcV9FrameInfo.cpp:1.3 --- llvm/lib/Target/SparcV9/SparcV9FrameInfo.cpp:1.2 Wed Feb 25 12:44:15 2004 +++ llvm/lib/Target/SparcV9/SparcV9FrameInfo.cpp Sun Apr 25 02:04:49 2004 @@ -1,4 +1,4 @@ -//===-- SparcV9.cpp - General implementation file for the SparcV9 Target ------===// +//===-- SparcV9FrameInfo.cpp - Stack frame layout info for SparcV9 --------===// // // The LLVM Compiler Infrastructure // Index: llvm/lib/Target/SparcV9/SparcV9FrameInfo.h diff -u llvm/lib/Target/SparcV9/SparcV9FrameInfo.h:1.3 llvm/lib/Target/SparcV9/SparcV9FrameInfo.h:1.4 --- llvm/lib/Target/SparcV9/SparcV9FrameInfo.h:1.3 Fri Apr 23 13:15:47 2004 +++ llvm/lib/Target/SparcV9/SparcV9FrameInfo.h Sun Apr 25 02:04:49 2004 @@ -1,4 +1,4 @@ -//===-- SparcV9FrameInfo.h - Define TargetFrameInfo for SparcV9 -----*- C++ -*-===// +//===-- SparcV9FrameInfo.h - Define TargetFrameInfo for SparcV9 -*- C++ -*-===// // // The LLVM Compiler Infrastructure // Index: llvm/lib/Target/SparcV9/SparcV9Instr.def diff -u llvm/lib/Target/SparcV9/SparcV9Instr.def:1.25 llvm/lib/Target/SparcV9/SparcV9Instr.def:1.26 --- llvm/lib/Target/SparcV9/SparcV9Instr.def:1.25 Mon Mar 1 09:05:17 2004 +++ llvm/lib/Target/SparcV9/SparcV9Instr.def Sun Apr 25 02:04:49 2004 @@ -1,4 +1,4 @@ -//===-- SparcInstr.def - Sparc Instruction Information -----------*- C++ -*-==// +//===-- SparcV9Instr.def - SparcV9 Instruction Information -------*- C++ -*-==// // // The LLVM Compiler Infrastructure // Index: llvm/lib/Target/SparcV9/SparcV9InstrInfo.cpp diff -u llvm/lib/Target/SparcV9/SparcV9InstrInfo.cpp:1.62 llvm/lib/Target/SparcV9/SparcV9InstrInfo.cpp:1.63 --- llvm/lib/Target/SparcV9/SparcV9InstrInfo.cpp:1.62 Wed Apr 7 15:38:56 2004 +++ llvm/lib/Target/SparcV9/SparcV9InstrInfo.cpp Sun Apr 25 02:04:49 2004 @@ -1,4 +1,4 @@ -//===-- SparcV9InstrInfo.cpp ------------------------------------------------===// +//===-- SparcV9InstrInfo.cpp - SparcV9 Instr. Selection Support Methods ---===// // // The LLVM Compiler Infrastructure // @@ -6,6 +6,10 @@ // the University of Illinois Open Source License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// +// +// This file contains various methods of the class SparcV9InstrInfo, many of +// which appear to build canned sequences of MachineInstrs, and are +// used in instruction selection. // //===----------------------------------------------------------------------===// Index: llvm/lib/Target/SparcV9/SparcV9InstrInfo.h diff -u llvm/lib/Target/SparcV9/SparcV9InstrInfo.h:1.5 llvm/lib/Target/SparcV9/SparcV9InstrInfo.h:1.6 --- llvm/lib/Target/SparcV9/SparcV9InstrInfo.h:1.5 Sun Apr 25 01:32:16 2004 +++ llvm/lib/Target/SparcV9/SparcV9InstrInfo.h Sun Apr 25 02:04:49 2004 @@ -8,7 +8,8 @@ //===----------------------------------------------------------------------===// // // This class contains information about individual instructions. -// Most information is stored in the SparcV9MachineInstrDesc array above. +// Also see the SparcV9MachineInstrDesc array, which can be found in +// SparcV9TargetMachine.cpp. // Other information is computed on demand, and most such functions // default to member functions in base class TargetInstrInfo. // Index: llvm/lib/Target/SparcV9/SparcV9InstrSelection.cpp diff -u llvm/lib/Target/SparcV9/SparcV9InstrSelection.cpp:1.139 llvm/lib/Target/SparcV9/SparcV9InstrSelection.cpp:1.140 --- llvm/lib/Target/SparcV9/SparcV9InstrSelection.cpp:1.139 Wed Apr 7 15:55:32 2004 +++ llvm/lib/Target/SparcV9/SparcV9InstrSelection.cpp Sun Apr 25 02:04:49 2004 @@ -1,4 +1,4 @@ -//===-- SparcV9InstrSelection.cpp -------------------------------------------===// +//===-- SparcV9InstrSelection.cpp -----------------------------------------===// // // The LLVM Compiler Infrastructure // Index: llvm/lib/Target/SparcV9/SparcV9InstrSelectionSupport.h diff -u llvm/lib/Target/SparcV9/SparcV9InstrSelectionSupport.h:1.15 llvm/lib/Target/SparcV9/SparcV9InstrSelectionSupport.h:1.16 --- llvm/lib/Target/SparcV9/SparcV9InstrSelectionSupport.h:1.15 Wed Apr 7 15:38:57 2004 +++ llvm/lib/Target/SparcV9/SparcV9InstrSelectionSupport.h Sun Apr 25 02:04:49 2004 @@ -1,4 +1,4 @@ -//===-- llvm/CodeGen/SparcV9InstrSelectionSupport.h ---------------*- C++ -*-===// +//===-- SparcV9InstrSelectionSupport.h --------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,12 +7,12 @@ // //===----------------------------------------------------------------------===// // -// TODO: Need a description here. +// More instruction selection support routines for the SparcV9 target. // //===----------------------------------------------------------------------===// -#ifndef SPARC_INSTR_SELECTION_SUPPORT_h -#define SPARC_INSTR_SELECTION_SUPPORT_h +#ifndef SPARCV9INSTRSELECTIONSUPPORT_H +#define SPARCV9INSTRSELECTIONSUPPORT_H #include "llvm/DerivedTypes.h" #include "SparcV9Internals.h" Index: llvm/lib/Target/SparcV9/SparcV9Internals.h diff -u llvm/lib/Target/SparcV9/SparcV9Internals.h:1.113 llvm/lib/Target/SparcV9/SparcV9Internals.h:1.114 --- llvm/lib/Target/SparcV9/SparcV9Internals.h:1.113 Fri Apr 23 13:15:47 2004 +++ llvm/lib/Target/SparcV9/SparcV9Internals.h Sun Apr 25 02:04:49 2004 @@ -1,4 +1,4 @@ -//===-- SparcV9Internals.h ----------------------------------------*- C++ -*-===// +//===-- SparcV9Internals.h --------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -12,8 +12,8 @@ // //===----------------------------------------------------------------------===// -#ifndef SPARC_INTERNALS_H -#define SPARC_INTERNALS_H +#ifndef SPARCV9INTERNALS_H +#define SPARCV9INTERNALS_H #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/Target/TargetMachine.h" Index: llvm/lib/Target/SparcV9/SparcV9JITInfo.h diff -u llvm/lib/Target/SparcV9/SparcV9JITInfo.h:1.4 llvm/lib/Target/SparcV9/SparcV9JITInfo.h:1.5 --- llvm/lib/Target/SparcV9/SparcV9JITInfo.h:1.4 Wed Feb 25 12:44:15 2004 +++ llvm/lib/Target/SparcV9/SparcV9JITInfo.h Sun Apr 25 02:04:49 2004 @@ -1,4 +1,4 @@ -//===- SparcV9JITInfo.h - SparcV9 implementation of the JIT interface -*-C++-*-===// +//===- SparcV9JITInfo.h - SparcV9 Target JIT interface ----------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,12 +7,14 @@ // //===----------------------------------------------------------------------===// // -// This file contains the SparcV9 implementation of the TargetJITInfo class. +// This file contains the SparcV9 implementation of the TargetJITInfo class, +// which makes target-specific hooks available to the target-independent +// LLVM JIT compiler. // //===----------------------------------------------------------------------===// -#ifndef SPARCJITINFO_H -#define SPARCJITINFO_H +#ifndef SPARCV9JITINFO_H +#define SPARCV9JITINFO_H #include "llvm/Target/TargetJITInfo.h" Index: llvm/lib/Target/SparcV9/SparcV9PeepholeOpts.cpp diff -u llvm/lib/Target/SparcV9/SparcV9PeepholeOpts.cpp:1.22 llvm/lib/Target/SparcV9/SparcV9PeepholeOpts.cpp:1.23 --- llvm/lib/Target/SparcV9/SparcV9PeepholeOpts.cpp:1.22 Wed Feb 25 12:44:15 2004 +++ llvm/lib/Target/SparcV9/SparcV9PeepholeOpts.cpp Sun Apr 25 02:04:49 2004 @@ -1,4 +1,4 @@ -//===-- PeepholeOpts.cpp --------------------------------------------------===// +//===-- SparcV9PeepholeOpts.cpp -------------------------------------------===// // // The LLVM Compiler Infrastructure // Index: llvm/lib/Target/SparcV9/SparcV9PreSelection.cpp diff -u llvm/lib/Target/SparcV9/SparcV9PreSelection.cpp:1.32 llvm/lib/Target/SparcV9/SparcV9PreSelection.cpp:1.33 --- llvm/lib/Target/SparcV9/SparcV9PreSelection.cpp:1.32 Wed Apr 7 13:31:47 2004 +++ llvm/lib/Target/SparcV9/SparcV9PreSelection.cpp Sun Apr 25 02:04:49 2004 @@ -1,4 +1,4 @@ -//===- PreSelection.cpp - Specialize LLVM code for target machine ---------===// +//===- SparcV9PreSelection.cpp - Specialize LLVM code for SparcV9 ---------===// // // The LLVM Compiler Infrastructure // @@ -7,10 +7,10 @@ // //===----------------------------------------------------------------------===// // -// This file defines the PreSelection pass which specializes LLVM code for a -// target machine, while remaining in legal portable LLVM form and -// preserving type information and type safety. This is meant to enable -// dataflow optimizations on target-specific operations such as accesses to +// This file defines the PreSelection pass which specializes LLVM code for +// the SparcV9 instruction selector, while remaining in legal portable LLVM +// form and preserving type information and type safety. This is meant to enable +// dataflow optimizations on SparcV9-specific operations such as accesses to // constants, globals, and array indexing. // //===----------------------------------------------------------------------===// @@ -34,7 +34,7 @@ namespace { //===--------------------------------------------------------------------===// - // PreSelection Pass - Specialize LLVM code for the current target machine. + // PreSelection Pass - Specialize LLVM code for the SparcV9 instr. selector. // class PreSelection : public FunctionPass, public InstVisitor { const TargetInstrInfo &instrInfo; Index: llvm/lib/Target/SparcV9/SparcV9PrologEpilogInserter.cpp diff -u llvm/lib/Target/SparcV9/SparcV9PrologEpilogInserter.cpp:1.37 llvm/lib/Target/SparcV9/SparcV9PrologEpilogInserter.cpp:1.38 --- llvm/lib/Target/SparcV9/SparcV9PrologEpilogInserter.cpp:1.37 Wed Mar 31 14:58:37 2004 +++ llvm/lib/Target/SparcV9/SparcV9PrologEpilogInserter.cpp Sun Apr 25 02:04:49 2004 @@ -1,4 +1,4 @@ -//===-- PrologEpilogCodeInserter.cpp - Insert Prolog & Epilog code for fn -===// +//===-- SparcV9PrologEpilogCodeInserter.cpp - Insert Fn Prolog & Epilog ---===// // // The LLVM Compiler Infrastructure // Index: llvm/lib/Target/SparcV9/SparcV9RegClassInfo.cpp diff -u llvm/lib/Target/SparcV9/SparcV9RegClassInfo.cpp:1.35 llvm/lib/Target/SparcV9/SparcV9RegClassInfo.cpp:1.36 --- llvm/lib/Target/SparcV9/SparcV9RegClassInfo.cpp:1.35 Wed Feb 25 12:44:15 2004 +++ llvm/lib/Target/SparcV9/SparcV9RegClassInfo.cpp Sun Apr 25 02:04:49 2004 @@ -1,4 +1,4 @@ -//===-- SparcV9RegClassInfo.cpp - Register class def'ns for SparcV9 -----------===// +//===-- SparcV9RegClassInfo.cpp - Register class def'ns for SparcV9 -------===// // // The LLVM Compiler Infrastructure // @@ -7,7 +7,9 @@ // //===----------------------------------------------------------------------===// // -// This file defines the register classes used by the SparcV9 target description. +// This file defines the methods used by the SparcV9 register allocator +// to pick registers of various classes. Most of this code should be +// considered part of the register allocator. // //===----------------------------------------------------------------------===// Index: llvm/lib/Target/SparcV9/SparcV9RegClassInfo.h diff -u llvm/lib/Target/SparcV9/SparcV9RegClassInfo.h:1.26 llvm/lib/Target/SparcV9/SparcV9RegClassInfo.h:1.27 --- llvm/lib/Target/SparcV9/SparcV9RegClassInfo.h:1.26 Fri Apr 23 13:15:47 2004 +++ llvm/lib/Target/SparcV9/SparcV9RegClassInfo.h Sun Apr 25 02:04:49 2004 @@ -1,4 +1,4 @@ -//===-- SparcV9RegClassInfo.h - Register class def'ns for SparcV9 ---*- C++ -*-===// +//===-- SparcV9RegClassInfo.h - Register class def'ns for SparcV9 -*- C++ -*-=// // // The LLVM Compiler Infrastructure // @@ -7,7 +7,10 @@ // //===----------------------------------------------------------------------===// // -// This file defines the register classes used by the SparcV9 target description. +// This file defines the register classes used by the SparcV9 target. It +// implicitly defines (using enums) the "class register numbers" used in +// the SparcV9 target, which are converted using a formula in the TargetRegInfo +// class to "unified register numbers". // //===----------------------------------------------------------------------===// Index: llvm/lib/Target/SparcV9/SparcV9RegInfo.cpp diff -u llvm/lib/Target/SparcV9/SparcV9RegInfo.cpp:1.125 llvm/lib/Target/SparcV9/SparcV9RegInfo.cpp:1.126 --- llvm/lib/Target/SparcV9/SparcV9RegInfo.cpp:1.125 Wed Apr 21 12:53:58 2004 +++ llvm/lib/Target/SparcV9/SparcV9RegInfo.cpp Sun Apr 25 02:04:49 2004 @@ -1,4 +1,4 @@ -//===-- SparcV9RegInfo.cpp - SparcV9 Target Register Information --------------===// +//===-- SparcV9RegInfo.cpp - SparcV9 Target Register Information ----------===// // // The LLVM Compiler Infrastructure // @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// This file contains implementation of SparcV9 specific helper methods +// This file contains implementations of SparcV9 specific helper methods // used for register allocation. // //===----------------------------------------------------------------------===// Index: llvm/lib/Target/SparcV9/SparcV9SchedInfo.cpp diff -u llvm/lib/Target/SparcV9/SparcV9SchedInfo.cpp:1.11 llvm/lib/Target/SparcV9/SparcV9SchedInfo.cpp:1.12 --- llvm/lib/Target/SparcV9/SparcV9SchedInfo.cpp:1.11 Sun Feb 29 02:40:02 2004 +++ llvm/lib/Target/SparcV9/SparcV9SchedInfo.cpp Sun Apr 25 02:04:49 2004 @@ -1,4 +1,4 @@ -//===-- UltraSparcV9SchedInfo.cpp -------------------------------------------===// +//===-- SparcV9SchedInfo.cpp ----------------------------------------------===// // // The LLVM Compiler Infrastructure // @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// Describe the scheduling characteristics of the UltraSparcV9 +// Describe the scheduling characteristics of the UltraSparc IIi. // //===----------------------------------------------------------------------===// Index: llvm/lib/Target/SparcV9/SparcV9StackSlots.cpp diff -u llvm/lib/Target/SparcV9/SparcV9StackSlots.cpp:1.10 llvm/lib/Target/SparcV9/SparcV9StackSlots.cpp:1.11 --- llvm/lib/Target/SparcV9/SparcV9StackSlots.cpp:1.10 Wed Feb 25 13:08:11 2004 +++ llvm/lib/Target/SparcV9/SparcV9StackSlots.cpp Sun Apr 25 02:04:49 2004 @@ -1,4 +1,4 @@ -//===- StackSlots.cpp - Specialize LLVM code for target machine ----------===// +//===- SparcV9StackSlots.cpp - Add empty stack slots to functions ---------===// // // The LLVM Compiler Infrastructure // Index: llvm/lib/Target/SparcV9/SparcV9TargetMachine.cpp diff -u llvm/lib/Target/SparcV9/SparcV9TargetMachine.cpp:1.109 llvm/lib/Target/SparcV9/SparcV9TargetMachine.cpp:1.110 --- llvm/lib/Target/SparcV9/SparcV9TargetMachine.cpp:1.109 Mon Apr 12 16:46:31 2004 +++ llvm/lib/Target/SparcV9/SparcV9TargetMachine.cpp Sun Apr 25 02:04:49 2004 @@ -1,4 +1,4 @@ -//===-- SparcV9.cpp - General implementation file for the SparcV9 Target ------===// +//===-- SparcV9TargetMachine.cpp - SparcV9 Target Machine Implementation --===// // // The LLVM Compiler Infrastructure // Index: llvm/lib/Target/SparcV9/SparcV9TargetMachine.h diff -u llvm/lib/Target/SparcV9/SparcV9TargetMachine.h:1.7 llvm/lib/Target/SparcV9/SparcV9TargetMachine.h:1.8 --- llvm/lib/Target/SparcV9/SparcV9TargetMachine.h:1.7 Sun Apr 25 01:32:28 2004 +++ llvm/lib/Target/SparcV9/SparcV9TargetMachine.h Sun Apr 25 02:04:49 2004 @@ -1,4 +1,4 @@ -//===-- SparcV9TargetMachine.h - Define TargetMachine for SparcV9 ---*- C++ -*-===// +//===-- SparcV9TargetMachine.h - Define TargetMachine for SparcV9 -*- C++ -*-=// // // The LLVM Compiler Infrastructure // @@ -7,12 +7,12 @@ // //===----------------------------------------------------------------------===// // -// This file declares the top-level UltraSPARC target machine. +// This file declares the top-level SparcV9 target machine. // //===----------------------------------------------------------------------===// -#ifndef SPARC_TARGETMACHINE_H -#define SPARC_TARGETMACHINE_H +#ifndef SPARCV9TARGETMACHINE_H +#define SPARCV9TARGETMACHINE_H #include "llvm/Target/TargetFrameInfo.h" #include "llvm/Target/TargetMachine.h" Index: llvm/lib/Target/SparcV9/SparcV9_F2.td diff -u llvm/lib/Target/SparcV9/SparcV9_F2.td:1.9 llvm/lib/Target/SparcV9/SparcV9_F2.td:1.10 --- llvm/lib/Target/SparcV9/SparcV9_F2.td:1.9 Wed Feb 25 12:44:15 2004 +++ llvm/lib/Target/SparcV9/SparcV9_F2.td Sun Apr 25 02:04:49 2004 @@ -1,4 +1,4 @@ -//===- SparcV9_F2.td - Format 2 instructions: SparcV9 V9 Target -------------===// +//===- SparcV9_F2.td - Format 2 instructions: SparcV9 Target --------------===// // // The LLVM Compiler Infrastructure // Index: llvm/lib/Target/SparcV9/SparcV9_F3.td diff -u llvm/lib/Target/SparcV9/SparcV9_F3.td:1.18 llvm/lib/Target/SparcV9/SparcV9_F3.td:1.19 --- llvm/lib/Target/SparcV9/SparcV9_F3.td:1.18 Wed Feb 25 12:44:15 2004 +++ llvm/lib/Target/SparcV9/SparcV9_F3.td Sun Apr 25 02:04:49 2004 @@ -1,4 +1,4 @@ -//===- SparcV9_F3.td - Format 3 Instructions: SparcV9 V9 Target -------------===// +//===- SparcV9_F3.td - Format 3 Instructions: SparcV9 Target --------------===// // // The LLVM Compiler Infrastructure // Index: llvm/lib/Target/SparcV9/SparcV9_F4.td diff -u llvm/lib/Target/SparcV9/SparcV9_F4.td:1.11 llvm/lib/Target/SparcV9/SparcV9_F4.td:1.12 --- llvm/lib/Target/SparcV9/SparcV9_F4.td:1.11 Wed Feb 25 12:44:15 2004 +++ llvm/lib/Target/SparcV9/SparcV9_F4.td Sun Apr 25 02:04:49 2004 @@ -1,4 +1,4 @@ -//===- SparcV9_F4.td - Format 4 instructions: SparcV9 V9 Target -------------===// +//===- SparcV9_F4.td - Format 4 instructions: SparcV9 Target --------------===// // // The LLVM Compiler Infrastructure // Index: llvm/lib/Target/SparcV9/SparcV9_Reg.td diff -u llvm/lib/Target/SparcV9/SparcV9_Reg.td:1.8 llvm/lib/Target/SparcV9/SparcV9_Reg.td:1.9 --- llvm/lib/Target/SparcV9/SparcV9_Reg.td:1.8 Wed Feb 25 12:44:15 2004 +++ llvm/lib/Target/SparcV9/SparcV9_Reg.td Sun Apr 25 02:04:49 2004 @@ -1,4 +1,4 @@ -//===- SparcV9_Reg.td - SparcV9 V9 Register definitions ---------------------===// +//===- SparcV9_Reg.td - SparcV9 Register definitions ----------------------===// // // The LLVM Compiler Infrastructure //