From lattner at cs.uiuc.edu Mon Apr 26 09:02:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Apr 26 09:02:01 2004 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/InstCombine/div.ll Message-ID: <200404261401.JAA27614@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/InstCombine: div.ll updated: 1.7 -> 1.8 --- Log message: Add a new testcase for X/-1, fix bug that prevented tests from running right --- Diffs of the changes: (+6 -1) Index: llvm/test/Regression/Transforms/InstCombine/div.ll diff -u llvm/test/Regression/Transforms/InstCombine/div.ll:1.7 llvm/test/Regression/Transforms/InstCombine/div.ll:1.8 --- llvm/test/Regression/Transforms/InstCombine/div.ll:1.7 Tue Sep 16 10:29:34 2003 +++ llvm/test/Regression/Transforms/InstCombine/div.ll Mon Apr 26 09:01:47 2004 @@ -12,10 +12,15 @@ uint %test2(uint %A) { %B = div uint %A, 8 ; => Shift - ret int %B + ret uint %B } int %test3(int %A) { %B = div int 0, %A ; => 0, don't need to keep traps + ret int %B +} + +int %test4(int %A) { + %B = div int %A, -1 ; 0-A ret int %B } From lattner at cs.uiuc.edu Mon Apr 26 09:02:03 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Apr 26 09:02:03 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200404261402.JAA27623@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: InstructionCombining.cpp updated: 1.192 -> 1.193 --- Log message: Instcombine X/-1 --> 0-X --- Diffs of the changes: (+5 -1) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.192 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.193 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.192 Sat Apr 17 13:16:10 2004 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Mon Apr 26 09:01:59 2004 @@ -849,10 +849,14 @@ } Instruction *InstCombiner::visitDiv(BinaryOperator &I) { - // div X, 1 == X if (ConstantInt *RHS = dyn_cast(I.getOperand(1))) { + // div X, 1 == X if (RHS->equalsInt(1)) return ReplaceInstUsesWith(I, I.getOperand(0)); + + // div X, -1 == -X + if (RHS->isAllOnesValue()) + return BinaryOperator::createNeg(I.getOperand(0)); // Check to see if this is an unsigned division with an exact power of 2, // if so, convert to a right shift. From lattner at cs.uiuc.edu Mon Apr 26 09:44:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Apr 26 09:44:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/DataStructureAA.cpp Message-ID: <200404261444.JAA28182@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: DataStructureAA.cpp updated: 1.16 -> 1.17 --- Log message: If an object is not in the scalar map then it must be a global from another graph. --- Diffs of the changes: (+31 -31) Index: llvm/lib/Analysis/DataStructure/DataStructureAA.cpp diff -u llvm/lib/Analysis/DataStructure/DataStructureAA.cpp:1.16 llvm/lib/Analysis/DataStructure/DataStructureAA.cpp:1.17 --- llvm/lib/Analysis/DataStructure/DataStructureAA.cpp:1.16 Fri Mar 12 00:14:22 2004 +++ llvm/lib/Analysis/DataStructure/DataStructureAA.cpp Mon Apr 26 09:44:08 2004 @@ -111,45 +111,45 @@ const DSGraph::ScalarMapTy &GSM = G.getScalarMap(); DSGraph::ScalarMapTy::const_iterator I = GSM.find((Value*)V1); - if (I != GSM.end()) { - assert(I->second.getNode() && "Scalar map points to null node?"); - DSGraph::ScalarMapTy::const_iterator J = GSM.find((Value*)V2); - if (J != GSM.end()) { - assert(J->second.getNode() && "Scalar map points to null node?"); + if (I == GSM.end()) return NoAlias; - DSNode *N1 = I->second.getNode(), *N2 = J->second.getNode(); - unsigned O1 = I->second.getOffset(), O2 = J->second.getOffset(); + assert(I->second.getNode() && "Scalar map points to null node?"); + DSGraph::ScalarMapTy::const_iterator J = GSM.find((Value*)V2); + if (J == GSM.end()) return NoAlias; + + assert(J->second.getNode() && "Scalar map points to null node?"); + + DSNode *N1 = I->second.getNode(), *N2 = J->second.getNode(); + unsigned O1 = I->second.getOffset(), O2 = J->second.getOffset(); - // We can only make a judgment of one of the nodes is complete... - if (N1->isComplete() || N2->isComplete()) { - if (N1 != N2) - return NoAlias; // Completely different nodes. + // We can only make a judgment of one of the nodes is complete... + if (N1->isComplete() || N2->isComplete()) { + if (N1 != N2) + return NoAlias; // Completely different nodes. #if 0 // This does not correctly handle arrays! - // Both point to the same node and same offset, and there is only one - // physical memory object represented in the node, return must alias. - // - // FIXME: This isn't correct because we do not handle array indexing - // correctly. + // Both point to the same node and same offset, and there is only one + // physical memory object represented in the node, return must alias. + // + // FIXME: This isn't correct because we do not handle array indexing + // correctly. - if (O1 == O2 && isSinglePhysicalObject(N1)) - return MustAlias; // Exactly the same object & offset + if (O1 == O2 && isSinglePhysicalObject(N1)) + return MustAlias; // Exactly the same object & offset #endif - // See if they point to different offsets... if so, we may be able to - // determine that they do not alias... - if (O1 != O2) { - if (O2 < O1) { // Ensure that O1 <= O2 - std::swap(V1, V2); - std::swap(O1, O2); - std::swap(V1Size, V2Size); - } - - // FIXME: This is not correct because we do not handle array - // indexing correctly with this check! - //if (O1+V1Size <= O2) return NoAlias; - } + // See if they point to different offsets... if so, we may be able to + // determine that they do not alias... + if (O1 != O2) { + if (O2 < O1) { // Ensure that O1 <= O2 + std::swap(V1, V2); + std::swap(O1, O2); + std::swap(V1Size, V2Size); } + + // FIXME: This is not correct because we do not handle array + // indexing correctly with this check! + //if (O1+V1Size <= O2) return NoAlias; } } From gaeke at cs.uiuc.edu Mon Apr 26 11:26:04 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Mon Apr 26 11:26:04 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/CallGraph.h Message-ID: <200404261626.LAA31227@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: CallGraph.h updated: 1.35 -> 1.36 --- Log message: Fix a typo in a comment. --- Diffs of the changes: (+1 -1) Index: llvm/include/llvm/Analysis/CallGraph.h diff -u llvm/include/llvm/Analysis/CallGraph.h:1.35 llvm/include/llvm/Analysis/CallGraph.h:1.36 --- llvm/include/llvm/Analysis/CallGraph.h:1.35 Tue Apr 20 16:52:12 2004 +++ llvm/include/llvm/Analysis/CallGraph.h Mon Apr 26 11:26:21 2004 @@ -41,7 +41,7 @@ // transformations. // // The CallGraph class also attempts to figure out what the root of the -// CallGraph is, which is currently does by looking for a function named 'main'. +// CallGraph is, which it currently does by looking for a function named 'main'. // If no function named 'main' is found, the external node is used as the entry // node, reflecting the fact that any function without internal linkage could // be called into (which is common for libraries). From gaeke at cs.uiuc.edu Mon Apr 26 11:27:04 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Mon Apr 26 11:27:04 2004 Subject: [llvm-commits] CVS: llvm/lib/Analysis/CFGPrinter.cpp Message-ID: <200404261627.LAA31291@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: CFGPrinter.cpp updated: 1.5 -> 1.6 --- Log message: Add functions that return instances of these printer passes --- Diffs of the changes: (+10 -0) Index: llvm/lib/Analysis/CFGPrinter.cpp diff -u llvm/lib/Analysis/CFGPrinter.cpp:1.5 llvm/lib/Analysis/CFGPrinter.cpp:1.6 --- llvm/lib/Analysis/CFGPrinter.cpp:1.5 Thu Dec 11 15:48:18 2003 +++ llvm/lib/Analysis/CFGPrinter.cpp Mon Apr 26 11:27:08 2004 @@ -22,6 +22,7 @@ #include "llvm/Function.h" #include "llvm/iTerminators.h" #include "llvm/Assembly/Writer.h" +#include "llvm/Analysis/CFGPrinter.h" #include "llvm/Support/CFG.h" #include #include @@ -173,3 +174,12 @@ viewCFG(); CFGOnly = false; } + +FunctionPass *llvm::createCFGPrinterPass () { + return new CFGPrinter(); +} + +FunctionPass *llvm::createCFGOnlyPrinterPass () { + return new CFGOnlyPrinter(); +} + From gaeke at cs.uiuc.edu Mon Apr 26 11:28:02 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Mon Apr 26 11:28:02 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/CFGPrinter.h Message-ID: <200404261628.LAA31354@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: CFGPrinter.h added (r1.1) --- Log message: Because I like being able to instantiate the cfgprinter from external projects, this header file is born. --- Diffs of the changes: (+24 -0) Index: llvm/include/llvm/Analysis/CFGPrinter.h diff -c /dev/null llvm/include/llvm/Analysis/CFGPrinter.h:1.1 *** /dev/null Mon Apr 26 11:28:03 2004 --- llvm/include/llvm/Analysis/CFGPrinter.h Mon Apr 26 11:27:53 2004 *************** *** 0 **** --- 1,24 ---- + //===-- CFGPrinter.h - CFG printer external interface ------------*- 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 defines external functions that can be called to explicitly + // instantiate the CFG printer. + // + //===----------------------------------------------------------------------===// + + #ifndef LLVM_ANALYSIS_CFGPRINTER_H + #define LLVM_ANALYSIS_CFGPRINTER_H + + namespace llvm { + class FunctionPass; + FunctionPass *createCFGPrinterPass (); + FunctionPass *createCFGOnlyPrinterPass (); + } // End llvm namespace + + #endif From gaeke at cs.uiuc.edu Mon Apr 26 14:48:02 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Mon Apr 26 14:48:02 2004 Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp Message-ID: <200404261947.OAA01026@seraph.cs.uiuc.edu> Changes in directory reopt/lib/LightWtProfiling: UnpackTraceFunction.cpp updated: 1.57 -> 1.58 --- Log message: Make sure we have enough space for any register we want to save. Later on, we should try to compact the stack layout, and not take up so much space on every trace entry. --- Diffs of the changes: (+1 -1) Index: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp diff -u reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.57 reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.58 --- reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.57 Wed Apr 21 16:05:31 2004 +++ reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp Mon Apr 26 14:47:32 2004 @@ -266,7 +266,7 @@ DEBUG(std::cerr << " )\n"); // 2. Get some stack space: (Stack Frame Size + Space for Regs). - int Size = (stackSize + 32 * 8); + int Size = (stackSize + 104 * 8); E.push_back (BuildMI (V9::ADDi, 3).addMReg (sp).addSImm (-Size).addMReg (sp, MachineOperand::Def)); From gaeke at cs.uiuc.edu Mon Apr 26 14:48:12 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Mon Apr 26 14:48:12 2004 Subject: [llvm-commits] CVS: reopt/lib/TraceCache/InstrUtils.cpp Message-ID: <200404261947.OAA01033@seraph.cs.uiuc.edu> Changes in directory reopt/lib/TraceCache: InstrUtils.cpp updated: 1.16 -> 1.17 --- Log message: Add and/or edit a bunch of documentation, and rewrite the instructions for identifying SPARCv9 branches to make them readable. Move functions around in this file to match the logical organization of the code: get*Target functions are together, get*Inst functions are together, and is*Jump functions are together. --- Diffs of the changes: (+64 -34) Index: reopt/lib/TraceCache/InstrUtils.cpp diff -u reopt/lib/TraceCache/InstrUtils.cpp:1.16 reopt/lib/TraceCache/InstrUtils.cpp:1.17 --- reopt/lib/TraceCache/InstrUtils.cpp:1.16 Fri Apr 23 15:10:35 2004 +++ reopt/lib/TraceCache/InstrUtils.cpp Mon Apr 26 14:47:33 2004 @@ -11,6 +11,47 @@ namespace llvm { +//===----------------------------------------------------------------------===// +//===-------------- Instructions for identifying SPARCv9 branches ---------===// + +// Terminology: +// +// A NonDepJump refers to a "non-deprecated jump", i.e., one with prediction and +// annul bits and a 19-bit PC-relative branch-target field. +// +// A DepJump refers to a "deprecated jump", i.e., one *without* prediction or +// annul bits, and having a 22-bit PC-relative branch-target field. + +/// isNonDepJump - Returns true iff instr encodes a BPcc or FBPfcc instruction +/// (branch on integer or floating point condition codes, respectively, with +/// prediction and annul bits, with a 19-bit PC-relative branch target field). +/// See SPARCv9 manual sections A.5 and A.7. +/// +bool isNonDepJump (unsigned int instr) { + instr &= 0xc1c00000; + return (instr == 0x00400000 /* BPcc */ || instr == 0x01400000 /* FBPfcc */); +} + +/// isDepJump - Returns true iff instr encodes a Bicc or FBfcc instruction +/// (branch on integer or floating point condition codes, respectively, +/// *without* any prediction or annul bits, with a 22-bit PC-relative branch +/// target field). See SPARCv9 manual sections A.4 and A.6. +/// +bool isDepJump (unsigned int instr) { + instr &= 0xc1c00000; + return (instr == 0x00800000 /* Bicc */ || instr == 0x01800000 /* FBfcc */); +} + +/// isBPR - Returns true iff instr encodes a BPr (branch on integer register +/// with prediction) instruction. See SPARCv9 manual section A.3. +/// +bool isBPR (unsigned int instr) { + return (instr & 0xd1c00000) == 0x00c00000; +} + +//===----------------------------------------------------------------------===// +//===----- Instructions for extracting SPARCv9 branch target addresses ----===// + uint64_t getBranchTarget(unsigned br, uint64_t pc){ if(isNonDepJump(br)) return getNonDepJmpTarget(br, pc); @@ -25,6 +66,25 @@ } } +uint64_t getNonDepJmpTarget(unsigned int y, uint64_t oldAdd){ + return oldAdd + 4 * (((y&0x00040000)==0x00040000) + ? ((y&0x0007ffff)|0xfffffffffff80000ULL) + : (y&0x0007ffff)); +} + +uint64_t getDepJmpTarget(unsigned int y, uint64_t oldAdd){ + return oldAdd + 4 * (((y&0x00200000U)==0x00200000U) + ? ((y&0x003fffff)|0xffffffffffc00000ULL) + : (y&0x003fffff)); +} + +uint64_t getBPRTarget(unsigned int b, uint64_t oldAdd){ + return (oldAdd+4*(((b&2097152)==2097152)?(0xffffffffffff0000ULL|((b&3145728)>>6)|(b&16383)):(((b&3145728)>>6)|(b&16383)))); +} + +//===----------------------------------------------------------------------===// +//===----- Instructions for extracting SPARCv9 branch target addresses ----===// + unsigned getBranchInst(unsigned br, uint64_t to, uint64_t frm){ if(isNonDepJump(br)) return getUndepJumpInstr(br, to, frm); @@ -39,26 +99,6 @@ } } -bool isNonDepJump(unsigned int y){//int + floating point - return ((y & 0xc1c00000) == 4194304 || (y & 0xc1c00000) == 20971520); -} - -bool isDepJump(unsigned int y){ //integer+floatingpoint - return ((y & 0xc1c00000) == 8388608 || (y & 0xc1c00000) == 25165824); -} - -uint64_t getNonDepJmpTarget(unsigned int y, uint64_t oldAdd){ - return oldAdd + 4 * (((y&0x00040000)==0x00040000) - ? ((y&0x0007ffff)|0xfffffffffff80000ULL) - : (y&0x0007ffff)); -} - -uint64_t getDepJmpTarget(unsigned int y, uint64_t oldAdd){ - return oldAdd + 4 * (((y&0x00200000U)==0x00200000U) - ? ((y&0x003fffff)|0xffffffffffc00000ULL) - : (y&0x003fffff)); -} - unsigned int getUndepJumpInstr(unsigned int a, uint64_t to, uint64_t pc){ if(to>pc) assert((to-pc)/4<262144 && "Can't fit target!"); @@ -70,11 +110,10 @@ return ((a&0xfff80000U)|diff|sgn); } -/// 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. +/// 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 or FBfcc 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) @@ -91,10 +130,6 @@ return ((instr&0xffc00000)|diff|sgn); } -uint64_t getBPRTarget(unsigned int b, uint64_t oldAdd){ - return (oldAdd+4*(((b&2097152)==2097152)?(0xffffffffffff0000ULL|((b&3145728)>>6)|(b&16383)):(((b&3145728)>>6)|(b&16383)))); -} - unsigned int getBPRInstr(unsigned int b, uint64_t to, uint64_t frm){ if(to>frm) assert((to-frm)/4 < 32768 && "Target out of range!"); @@ -146,11 +181,6 @@ bool isBranchNever(unsigned int b){ return (((b & 0xc0000000) == 0) && (((b&0x1e000000)>>25) == 0) && (isDepJump(b) || isNonDepJump(b) || isBPR(b))); -} - -//BPR: (b&(2^22+2^23+2^24) == (2^22+2^23) -bool isBPR(unsigned int b){ - return ( (b&0x01c00000) == 0x00c00000); } bool isBranchInstr(unsigned int y){ From gaeke at cs.uiuc.edu Mon Apr 26 14:51:02 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Mon Apr 26 14:51:02 2004 Subject: [llvm-commits] CVS: reopt/lib/TraceCache/VirtualMem.cpp Message-ID: <200404261950.OAA03927@kain.cs.uiuc.edu> Changes in directory reopt/lib/TraceCache: VirtualMem.cpp updated: 1.16 -> 1.17 --- Log message: Document VirtualMem::writeBranchInstruction(). --- Diffs of the changes: (+7 -3) Index: reopt/lib/TraceCache/VirtualMem.cpp diff -u reopt/lib/TraceCache/VirtualMem.cpp:1.16 reopt/lib/TraceCache/VirtualMem.cpp:1.17 --- reopt/lib/TraceCache/VirtualMem.cpp:1.16 Fri Apr 23 16:25:10 2004 +++ reopt/lib/TraceCache/VirtualMem.cpp Mon Apr 26 14:49:59 2004 @@ -108,10 +108,14 @@ } } -//write branch inst, followed by a null inst in delay slot -// +/// writeBranchInstruction - Create a BA,A (Branch Always with Prediction +/// with Annul bit set) instruction from LOCATION to TARGET, and write it to +/// the address LOCATION. (The annul bit is set so that the branch's delay +/// slot instruction will be annulled.) +/// void VirtualMem::writeBranchInstruction(uint64_t location, uint64_t target){ - //create branch will annul bit set + // The first argument to getDepJumpInstr sets the annul bit and the "always" + // condition. unsigned int instToWrite = getDepJumpInstr(0x30800000, target, location); writeInstToVM(location, instToWrite); } From gaeke at cs.uiuc.edu Mon Apr 26 15:04:04 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Mon Apr 26 15:04:04 2004 Subject: [llvm-commits] CVS: reopt/lib/TraceCache/InstrUtils.cpp Message-ID: <200404262003.PAA03996@kain.cs.uiuc.edu> Changes in directory reopt/lib/TraceCache: InstrUtils.cpp updated: 1.17 -> 1.18 --- Log message: Reorganize and document isCallInstr(). Reorganize getCallTarget(). Document getUndepJumpInstr() and rename its operands. Edit getDepJumpInstr()'s comment. --- Diffs of the changes: (+31 -18) Index: reopt/lib/TraceCache/InstrUtils.cpp diff -u reopt/lib/TraceCache/InstrUtils.cpp:1.17 reopt/lib/TraceCache/InstrUtils.cpp:1.18 --- reopt/lib/TraceCache/InstrUtils.cpp:1.17 Mon Apr 26 14:47:33 2004 +++ reopt/lib/TraceCache/InstrUtils.cpp Mon Apr 26 15:02:59 2004 @@ -49,6 +49,13 @@ return (instr & 0xd1c00000) == 0x00c00000; } +/// isCallInstr - Returns true iff instr encodes a CALL instruction. +/// See SPARCv9 manual, section A.8. +/// +bool isCallInstr (unsigned int instr) { + return (instr & 0xc0000000) == 0x40000000; +} + //===----------------------------------------------------------------------===// //===----- Instructions for extracting SPARCv9 branch target addresses ----===// @@ -82,6 +89,12 @@ return (oldAdd+4*(((b&2097152)==2097152)?(0xffffffffffff0000ULL|((b&3145728)>>6)|(b&16383)):(((b&3145728)>>6)|(b&16383)))); } +uint64_t getCallTarget(unsigned int y, uint64_t oldAdd){ + return oldAdd + 4 * (((y&0x20000000) == 0x20000000) + ? (0xffffffffc0000000ULL | (y & 0x3fffffff)) + : (y & 0x3fffffff)); +} + //===----------------------------------------------------------------------===// //===----- Instructions for extracting SPARCv9 branch target addresses ----===// @@ -99,21 +112,31 @@ } } -unsigned int getUndepJumpInstr(unsigned int a, uint64_t to, uint64_t pc){ - if(to>pc) - assert((to-pc)/4<262144 && "Can't fit target!"); +/// getUndepJumpInstr - 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 BPcc or FBPfcc instruction (branch on integer +/// condition codes with prediction and annul bits), and FROM must be its +/// address in memory. +/// +unsigned int getUndepJumpInstr(unsigned int instr, uint64_t to, uint64_t from) { + if(to>from) + assert((to-from)/4<262144 && "Can't fit target!"); else - assert((pc-to)/4<262144 && "Can't fit target!"); + assert((from-to)/4<262144 && "Can't fit target!"); - unsigned int diff = (((to-pc)/4)&0x3ffff); - unsigned int sgn = ((to < pc) ? (1 << 21) : 0); - return ((a&0xfff80000U)|diff|sgn); + // Compute new 19-bit PC-relative branch target. + unsigned int diff = (((to-from)/4)&0x3ffff); + unsigned int sgn = ((to < from) ? (1 << 21) : 0); + + // Mask out the old branch target, OR in the new one, and return it. + return ((instr&0xfff80000U)|diff|sgn); } /// 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 or FBfcc instruction (branch on integer -/// condition codes with no prediction), and FROM must be its address in memory. +/// condition codes with no prediction bits), and FROM must be its address in +/// memory. /// unsigned int getDepJumpInstr(unsigned int instr, uint64_t to, uint64_t from) { if(to>from) @@ -147,16 +170,6 @@ //TODO: put assert to check branch destinations! //TODO: Take out sign bit in branch instr - -bool isCallInstr(unsigned int a){ - return ((a & 0xc0000000) == 0x40000000); -} - -uint64_t getCallTarget(unsigned int y, uint64_t oldAdd){ - return oldAdd + 4 * (((y&0x20000000) == 0x20000000) - ? (0xffffffffc0000000ULL | (y & 0x3fffffff)) - : (y & 0x3fffffff)); -} // pc is the "from" address unsigned int getCallInstr(uint64_t to , uint64_t pc){ From lattner at cs.uiuc.edu Tue Apr 27 10:12:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 27 10:12:02 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Support/InstIterator.h Message-ID: <200404271512.KAA12782@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Support: InstIterator.h updated: 1.9 -> 1.10 --- Log message: Changes to fix up the inst_iterator to pass to boost iterator checks. This patch was graciously contributed by Vladimir Prus. --- Diffs of the changes: (+18 -15) Index: llvm/include/llvm/Support/InstIterator.h diff -u llvm/include/llvm/Support/InstIterator.h:1.9 llvm/include/llvm/Support/InstIterator.h:1.10 --- llvm/include/llvm/Support/InstIterator.h:1.9 Tue Nov 11 16:41:31 2003 +++ llvm/include/llvm/Support/InstIterator.h Tue Apr 27 10:11:58 2004 @@ -33,15 +33,18 @@ typedef _BB_i_t BBIty; typedef _BI_t BIty; typedef _II_t IIty; - _BB_t &BBs; // BasicBlocksType + _BB_t *BBs; // BasicBlocksType _BB_i_t BB; // BasicBlocksType::iterator _BI_t BI; // BasicBlock::iterator public: typedef std::bidirectional_iterator_tag iterator_category; typedef IIty value_type; - typedef unsigned difference_type; - typedef BIty pointer; - typedef IIty reference; + typedef signed difference_type; + typedef IIty* pointer; + typedef IIty& reference; + + // Default constructor + InstIterator() {} // Copy constructor... template @@ -53,26 +56,26 @@ : BBs(II.BBs), BB(II.BB), BI(II.BI) {} template InstIterator(M &m) - : BBs(m.getBasicBlockList()), BB(BBs.begin()) { // begin ctor - if (BB != BBs.end()) { + : BBs(&m.getBasicBlockList()), BB(BBs->begin()) { // begin ctor + if (BB != BBs->end()) { BI = BB->begin(); advanceToNextBB(); } } template InstIterator(M &m, bool) - : BBs(m.getBasicBlockList()), BB(BBs.end()) { // end ctor + : BBs(&m.getBasicBlockList()), BB(BBs->end()) { // end ctor } // Accessors to get at the underlying iterators... inline BBIty &getBasicBlockIterator() { return BB; } inline BIty &getInstructionIterator() { return BI; } - inline IIty operator*() const { return BI; } - inline IIty operator->() const { return operator*(); } + inline reference operator*() const { return *BI; } + inline pointer operator->() const { return &operator*(); } inline bool operator==(const InstIterator &y) const { - return BB == y.BB && (BB == BBs.end() || BI == y.BI); + return BB == y.BB && (BB == BBs->end() || BI == y.BI); } inline bool operator!=(const InstIterator& y) const { return !operator==(y); @@ -88,7 +91,7 @@ } InstIterator& operator--() { - while (BB == BBs.end() || BI == BB->begin()) { + while (BB == BBs->end() || BI == BB->begin()) { --BB; BI = BB->end(); } @@ -99,7 +102,7 @@ InstIterator tmp = *this; --*this; return tmp; } - inline bool atEnd() const { return BB == BBs.end(); } + inline bool atEnd() const { return BB == BBs->end(); } private: inline void advanceToNextBB() { @@ -107,7 +110,7 @@ // the end() of the current BasicBlock and there are successor BBs. while (BI == BB->end()) { ++BB; - if (BB == BBs.end()) break; + if (BB == BBs->end()) break; BI = BB->begin(); } } @@ -116,11 +119,11 @@ typedef InstIterator, Function::iterator, BasicBlock::iterator, - Instruction*> inst_iterator; + Instruction> inst_iterator; typedef InstIterator, Function::const_iterator, BasicBlock::const_iterator, - const Instruction*> const_inst_iterator; + const Instruction> const_inst_iterator; inline inst_iterator inst_begin(Function *F) { return inst_iterator(*F); } inline inst_iterator inst_end(Function *F) { return inst_iterator(*F, true); } From lattner at cs.uiuc.edu Tue Apr 27 10:12:07 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 27 10:12:07 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/ConstantProp.cpp DCE.cpp InstructionCombining.cpp Message-ID: <200404271512.KAA12813@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: ConstantProp.cpp updated: 1.47 -> 1.48 DCE.cpp updated: 1.52 -> 1.53 InstructionCombining.cpp updated: 1.193 -> 1.194 --- Log message: Changes to fix up the inst_iterator to pass to boost iterator checks. This patch was graciously contributed by Vladimir Prus. --- Diffs of the changes: (+12 -3) Index: llvm/lib/Transforms/Scalar/ConstantProp.cpp diff -u llvm/lib/Transforms/Scalar/ConstantProp.cpp:1.47 llvm/lib/Transforms/Scalar/ConstantProp.cpp:1.48 --- llvm/lib/Transforms/Scalar/ConstantProp.cpp:1.47 Tue Apr 13 14:28:20 2004 +++ llvm/lib/Transforms/Scalar/ConstantProp.cpp Tue Apr 27 10:12:22 2004 @@ -49,7 +49,10 @@ bool ConstantPropagation::runOnFunction(Function &F) { // Initialize the worklist to all of the instructions ready to process... - std::set WorkList(inst_begin(F), inst_end(F)); + std::set WorkList; + for(inst_iterator i = inst_begin(F), e = inst_end(F); i != e; ++i) { + WorkList.insert(&*i); + } bool Changed = false; while (!WorkList.empty()) { Index: llvm/lib/Transforms/Scalar/DCE.cpp diff -u llvm/lib/Transforms/Scalar/DCE.cpp:1.52 llvm/lib/Transforms/Scalar/DCE.cpp:1.53 --- llvm/lib/Transforms/Scalar/DCE.cpp:1.52 Wed Apr 21 17:29:37 2004 +++ llvm/lib/Transforms/Scalar/DCE.cpp Tue Apr 27 10:12:23 2004 @@ -76,7 +76,10 @@ bool DCE::runOnFunction(Function &F) { // Start out with all of the instructions in the worklist... - std::vector WorkList(inst_begin(F), inst_end(F)); + std::vector WorkList; + for (inst_iterator i = inst_begin(F), e = inst_end(F); i != e; ++i) { + WorkList.push_back(&*i); + } std::set DeadInsts; // Loop over the worklist finding instructions that are dead. If they are Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.193 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.194 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.193 Mon Apr 26 09:01:59 2004 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Tue Apr 27 10:12:23 2004 @@ -2934,7 +2934,10 @@ bool Changed = false; TD = &getAnalysis(); - WorkList.insert(WorkList.end(), inst_begin(F), inst_end(F)); + for (inst_iterator i = inst_begin(F), e = inst_end(F); i != e; ++i) { + WorkList.push_back(&*i); + } + while (!WorkList.empty()) { Instruction *I = WorkList.back(); // Get an instruction from the worklist From lattner at cs.uiuc.edu Tue Apr 27 10:13:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 27 10:13:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Analysis/AliasAnalysisEvaluator.cpp AliasSetTracker.cpp ScalarEvolution.cpp Message-ID: <200404271512.KAA12837@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: AliasAnalysisEvaluator.cpp updated: 1.12 -> 1.13 AliasSetTracker.cpp updated: 1.14 -> 1.15 ScalarEvolution.cpp updated: 1.17 -> 1.18 --- Log message: Changes to fix up the inst_iterator to pass to boost iterator checks. This patch was graciously contributed by Vladimir Prus. --- Diffs of the changes: (+11 -11) Index: llvm/lib/Analysis/AliasAnalysisEvaluator.cpp diff -u llvm/lib/Analysis/AliasAnalysisEvaluator.cpp:1.12 llvm/lib/Analysis/AliasAnalysisEvaluator.cpp:1.13 --- llvm/lib/Analysis/AliasAnalysisEvaluator.cpp:1.12 Fri Mar 12 10:20:49 2004 +++ llvm/lib/Analysis/AliasAnalysisEvaluator.cpp Tue Apr 27 10:12:45 2004 @@ -83,15 +83,15 @@ Pointers.insert(I); for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) { - if (isa((*I)->getType())) // Add all pointer instructions - Pointers.insert(*I); - for (User::op_iterator OI = (*I)->op_begin(); OI != (*I)->op_end(); ++OI) + if (isa(I->getType())) // Add all pointer instructions + Pointers.insert(&*I); + for (User::op_iterator OI = (*I).op_begin(); OI != (*I).op_end(); ++OI) if (isa((*OI)->getType())) Pointers.insert(*OI); } for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) { - CallSite CS = CallSite::get(*I); + CallSite CS = CallSite::get(&*I); if (CS.getInstruction()) CallSites.insert(CS); } Index: llvm/lib/Analysis/AliasSetTracker.cpp diff -u llvm/lib/Analysis/AliasSetTracker.cpp:1.14 llvm/lib/Analysis/AliasSetTracker.cpp:1.15 --- llvm/lib/Analysis/AliasSetTracker.cpp:1.14 Wed Mar 17 17:22:04 2004 +++ llvm/lib/Analysis/AliasSetTracker.cpp Tue Apr 27 10:12:45 2004 @@ -366,7 +366,7 @@ Tracker = new AliasSetTracker(getAnalysis()); for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) - Tracker->add(*I); + Tracker->add(&*I); return false; } Index: llvm/lib/Analysis/ScalarEvolution.cpp diff -u llvm/lib/Analysis/ScalarEvolution.cpp:1.17 llvm/lib/Analysis/ScalarEvolution.cpp:1.18 --- llvm/lib/Analysis/ScalarEvolution.cpp:1.17 Fri Apr 23 16:29:03 2004 +++ llvm/lib/Analysis/ScalarEvolution.cpp Tue Apr 27 10:12:45 2004 @@ -2175,22 +2175,22 @@ OS << "Classifying expressions for: " << F.getName() << "\n"; for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) - if ((*I)->getType()->isInteger()) { - OS << **I; + if (I->getType()->isInteger()) { + OS << *I; OS << " --> "; - SCEVHandle SV = getSCEV(*I); + SCEVHandle SV = getSCEV(&*I); SV->print(OS); OS << "\t\t"; - if ((*I)->getType()->isIntegral()) { + if ((*I).getType()->isIntegral()) { ConstantRange Bounds = SV->getValueRange(); if (!Bounds.isFullSet()) OS << "Bounds: " << Bounds << " "; } - if (const Loop *L = LI.getLoopFor((*I)->getParent())) { + if (const Loop *L = LI.getLoopFor((*I).getParent())) { OS << "Exits: "; - SCEVHandle ExitValue = getSCEVAtScope(*I, L->getParentLoop()); + SCEVHandle ExitValue = getSCEVAtScope(&*I, L->getParentLoop()); if (isa(ExitValue)) { OS << "<>"; } else { From lattner at cs.uiuc.edu Tue Apr 27 10:13:06 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 27 10:13:06 2004 Subject: [llvm-commits] CVS: llvm/lib/Analysis/IPA/FindUnsafePointerTypes.cpp FindUsedTypes.cpp Message-ID: <200404271512.KAA12846@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/IPA: FindUnsafePointerTypes.cpp updated: 1.21 -> 1.22 FindUsedTypes.cpp updated: 1.24 -> 1.25 --- Log message: Changes to fix up the inst_iterator to pass to boost iterator checks. This patch was graciously contributed by Vladimir Prus. --- Diffs of the changes: (+6 -6) Index: llvm/lib/Analysis/IPA/FindUnsafePointerTypes.cpp diff -u llvm/lib/Analysis/IPA/FindUnsafePointerTypes.cpp:1.21 llvm/lib/Analysis/IPA/FindUnsafePointerTypes.cpp:1.22 --- llvm/lib/Analysis/IPA/FindUnsafePointerTypes.cpp:1.21 Tue Nov 11 16:41:32 2003 +++ llvm/lib/Analysis/IPA/FindUnsafePointerTypes.cpp Tue Apr 27 10:12:48 2004 @@ -42,8 +42,8 @@ PrintFailures("printunsafeptrinst", cl::Hidden, cl::desc("Print Unsafe Pointer Access Instructions")); -static inline bool isSafeInstruction(const Instruction *I) { - switch (I->getOpcode()) { +static inline bool isSafeInstruction(const Instruction &I) { + switch (I.getOpcode()) { case Instruction::Alloca: case Instruction::Malloc: case Instruction::Free: @@ -72,7 +72,7 @@ if (PrintFailures) { CachedWriter CW(F->getParent(), std::cerr); CW << "FindUnsafePointerTypes: Type '" << ITy - << "' marked unsafe in '" << F->getName() << "' by:\n" << **I; + << "' marked unsafe in '" << F->getName() << "' by:\n" << *I; } } } Index: llvm/lib/Analysis/IPA/FindUsedTypes.cpp diff -u llvm/lib/Analysis/IPA/FindUsedTypes.cpp:1.24 llvm/lib/Analysis/IPA/FindUsedTypes.cpp:1.25 --- llvm/lib/Analysis/IPA/FindUsedTypes.cpp:1.24 Tue Nov 11 16:41:32 2003 +++ llvm/lib/Analysis/IPA/FindUsedTypes.cpp Tue Apr 27 10:12:48 2004 @@ -79,11 +79,11 @@ // for (const_inst_iterator II = inst_begin(F), IE = inst_end(F); II != IE; ++II) { - const Instruction *I = *II; - const Type *Ty = I->getType(); + const Instruction &I = *II; + const Type *Ty = I.getType(); IncorporateType(Ty); // Incorporate the type of the instruction - for (User::const_op_iterator OI = I->op_begin(), OE = I->op_end(); + for (User::const_op_iterator OI = I.op_begin(), OE = I.op_end(); OI != OE; ++OI) IncorporateValue(*OI); // Insert inst operand types as well } From lattner at cs.uiuc.edu Tue Apr 27 10:13:13 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 27 10:13:13 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/SlotCalculator.cpp Message-ID: <200404271513.KAA12883@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: SlotCalculator.cpp updated: 1.52 -> 1.53 --- Log message: Changes to fix up the inst_iterator to pass to boost iterator checks. This patch was graciously contributed by Vladimir Prus. --- Diffs of the changes: (+2 -2) Index: llvm/lib/VMCore/SlotCalculator.cpp diff -u llvm/lib/VMCore/SlotCalculator.cpp:1.52 llvm/lib/VMCore/SlotCalculator.cpp:1.53 --- llvm/lib/VMCore/SlotCalculator.cpp:1.52 Sat Feb 14 23:55:15 2004 +++ llvm/lib/VMCore/SlotCalculator.cpp Tue Apr 27 10:13:09 2004 @@ -186,7 +186,7 @@ if (isa(I->getOperand(op))) getOrCreateSlot(I->getOperand(op)); getOrCreateSlot(I->getType()); - if (const VANextInst *VAN = dyn_cast(*I)) + if (const VANextInst *VAN = dyn_cast(&*I)) getOrCreateSlot(VAN->getArgType()); } processSymbolTableConstants(&F->getSymbolTable()); @@ -448,7 +448,7 @@ if (isa(I->getOperand(op)) || isa(I->getOperand(op))) getOrCreateCompactionTableSlot(I->getOperand(op)); - if (const VANextInst *VAN = dyn_cast(*I)) + if (const VANextInst *VAN = dyn_cast(&*I)) getOrCreateCompactionTableSlot(VAN->getArgType()); } From lattner at cs.uiuc.edu Tue Apr 27 10:13:16 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 27 10:13:16 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/CBackend/Writer.cpp Message-ID: <200404271513.KAA12890@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/CBackend: Writer.cpp updated: 1.168 -> 1.169 --- Log message: Changes to fix up the inst_iterator to pass to boost iterator checks. This patch was graciously contributed by Vladimir Prus. --- Diffs of the changes: (+5 -5) Index: llvm/lib/Target/CBackend/Writer.cpp diff -u llvm/lib/Target/CBackend/Writer.cpp:1.168 llvm/lib/Target/CBackend/Writer.cpp:1.169 --- llvm/lib/Target/CBackend/Writer.cpp:1.168 Wed Mar 31 23:28:26 2004 +++ llvm/lib/Target/CBackend/Writer.cpp Tue Apr 27 10:13:11 2004 @@ -955,19 +955,19 @@ // print local variable information for the function for (inst_iterator I = inst_begin(&F), E = inst_end(&F); I != E; ++I) - if (const AllocaInst *AI = isDirectAlloca(*I)) { + if (const AllocaInst *AI = isDirectAlloca(&*I)) { Out << " "; printType(Out, AI->getAllocatedType(), Mang->getValueName(AI)); Out << "; /* Address exposed local */\n"; - } else if ((*I)->getType() != Type::VoidTy && !isInlinableInst(**I)) { + } else if (I->getType() != Type::VoidTy && !isInlinableInst(*I)) { Out << " "; - printType(Out, (*I)->getType(), Mang->getValueName(*I)); + printType(Out, I->getType(), Mang->getValueName(&*I)); Out << ";\n"; if (isa(*I)) { // Print out PHI node temporaries as well... Out << " "; - printType(Out, (*I)->getType(), - Mang->getValueName(*I)+"__PHI_TEMPORARY"); + printType(Out, I->getType(), + Mang->getValueName(&*I)+"__PHI_TEMPORARY"); Out << ";\n"; } } From lattner at cs.uiuc.edu Tue Apr 27 10:14:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 27 10:14:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp Message-ID: <200404271513.KAA12910@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9/RegAlloc: PhyRegAlloc.cpp updated: 1.146 -> 1.147 --- Log message: Changes to fix up the inst_iterator to pass to boost iterator checks. This patch was graciously contributed by Vladimir Prus. --- Diffs of the changes: (+4 -4) Index: llvm/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp diff -u llvm/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp:1.146 llvm/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp:1.147 --- llvm/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp:1.146 Wed Mar 31 15:59:59 2004 +++ llvm/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp Tue Apr 27 10:13:33 2004 @@ -1167,9 +1167,9 @@ unsigned Insn = 0; // Instructions themselves encoded as operand # -1 for (const_inst_iterator II=inst_begin (Fn), IE=inst_end (Fn); II!=IE; ++II){ - saveStateForValue (state, (*II), Insn, -1); - for (unsigned i = 0; i < (*II)->getNumOperands (); ++i) { - const Value *V = (*II)->getOperand (i); + saveStateForValue (state, (&*II), Insn, -1); + for (unsigned i = 0; i < (*II).getNumOperands (); ++i) { + const Value *V = (*II).getOperand (i); // Don't worry about it unless it's something whose reg. we'll need. if (!isa (V) && !isa (V)) continue; @@ -1201,7 +1201,7 @@ } int Insn = 0; for (const_inst_iterator II=inst_begin (Fn), IE=inst_end (Fn); II!=IE; ++II) { - const Instruction *I = *II; + const Instruction *I = &*II; MachineCodeForInstruction &Instrs = MachineCodeForInstruction::get (I); std::cerr << "Instruction: " << *I << "MachineCodeForInstruction:\n"; From lattner at cs.uiuc.edu Tue Apr 27 13:22:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 27 13:22:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h Message-ID: <200404271822.NAA08874@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: ScalarEvolutionExpressions.h updated: 1.2 -> 1.3 --- Log message: Fix warning --- Diffs of the changes: (+1 -0) Index: llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h diff -u llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h:1.2 llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h:1.3 --- llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h:1.2 Fri Apr 23 16:28:25 2004 +++ llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h Tue Apr 27 13:21:56 2004 @@ -457,6 +457,7 @@ return ((SC*)this)->visitCouldNotCompute((SCEVCouldNotCompute*)S); default: assert(0 && "Unknown SCEV type!"); + abort(); } } From lattner at cs.uiuc.edu Tue Apr 27 13:25:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Apr 27 13:25:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/InstructionReader.cpp Message-ID: <200404271824.NAA10054@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: InstructionReader.cpp updated: 1.70 -> 1.71 --- Log message: Fix warning building in optimized mode --- Diffs of the changes: (+1 -0) Index: llvm/lib/Bytecode/Reader/InstructionReader.cpp diff -u llvm/lib/Bytecode/Reader/InstructionReader.cpp:1.70 llvm/lib/Bytecode/Reader/InstructionReader.cpp:1.71 --- llvm/lib/Bytecode/Reader/InstructionReader.cpp:1.70 Sun Apr 4 20:27:22 2004 +++ llvm/lib/Bytecode/Reader/InstructionReader.cpp Tue Apr 27 13:24:38 2004 @@ -319,6 +319,7 @@ IdxTy = Type::UIntTyID; else { switch (ValIdx & 3) { + default: case 0: IdxTy = Type::UIntTyID; break; case 1: IdxTy = Type::IntTyID; break; case 2: IdxTy = Type::ULongTyID; break; From gaeke at cs.uiuc.edu Tue Apr 27 13:35:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue Apr 27 13:35:01 2004 Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/ReoptimizerInternal.h Message-ID: <200404271834.NAA06875@seraph.cs.uiuc.edu> Changes in directory reopt/lib/LightWtProfiling: ReoptimizerInternal.h updated: 1.3 -> 1.4 --- Log message: Copy prototypes for functions exported from RuntimeOptimizations.cpp here. --- Diffs of the changes: (+5 -0) Index: reopt/lib/LightWtProfiling/ReoptimizerInternal.h diff -u reopt/lib/LightWtProfiling/ReoptimizerInternal.h:1.3 reopt/lib/LightWtProfiling/ReoptimizerInternal.h:1.4 --- reopt/lib/LightWtProfiling/ReoptimizerInternal.h:1.3 Tue Apr 13 16:29:41 2004 +++ reopt/lib/LightWtProfiling/ReoptimizerInternal.h Tue Apr 27 13:34:43 2004 @@ -155,6 +155,11 @@ MachineCodeEmitter *createTraceOptEmitter(const TargetData &TD); +// RuntimeOptimizations.cpp ///////////////////////////////////////////// + +void addGlobalMapping(const GlobalValue *GV, uint64_t Addr); +void optimizeTrace (std::vector &vBB, uint64_t a); + }; // end namespace llvm #endif // REOPTIMIZERINTERNAL_H From gaeke at cs.uiuc.edu Tue Apr 27 13:35:03 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue Apr 27 13:35:03 2004 Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp Message-ID: <200404271834.NAA06882@seraph.cs.uiuc.edu> Changes in directory reopt/lib/LightWtProfiling: RuntimeOptimizations.cpp updated: 1.29 -> 1.30 --- Log message: Get rid of commented-out debug emitter. Wrap long lines. Include reopt/VirtualMem.h and reopt/InstrUtils.h. Steal some code from the generic ExecutionEngine to use for keeping track of where TraceFns get their code generated to (like the JIT does). Try to add a branch from the instrumented code to the freshly-emitted reoptimized code. --- Diffs of the changes: (+34 -5) Index: reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp diff -u reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp:1.29 reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp:1.30 --- reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp:1.29 Fri Apr 23 15:35:53 2004 +++ reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp Tue Apr 27 13:34:44 2004 @@ -15,6 +15,8 @@ #include "ReoptimizerInternal.h" #include "TraceToFunction.h" +#include "reopt/VirtualMem.h" +#include "reopt/InstrUtils.h" #include "Support/Debug.h" #include "Support/StringExtras.h" #include "llvm/Analysis/Verifier.h" @@ -39,6 +41,30 @@ extern bool SaveStateToModule; extern bool SaveRegAllocState; +///==----- Machinery to keep track of where a TraceFunction's code is ------==// +// This deliberately mimics the code used by ExecutionEngine, in case we ever +// want to turn the Reoptimizer into an ExecutionEngine. + +/// GlobalAddressMap - A mapping between LLVM global values and their +/// actualized version... +std::map GlobalAddressMap; + +void addGlobalMapping(const GlobalValue *GV, uint64_t Addr) { + uint64_t &CurVal = GlobalAddressMap[GV]; + assert((CurVal == 0 || Addr == 0) && "GlobalMapping already established!"); + CurVal = Addr; +} + +/// getPointerToGlobalIfAvailable - This returns the address of the specified +/// global value if it is available, otherwise it returns null. +/// +uint64_t getPointerToGlobalIfAvailable(const GlobalValue *GV) { + std::map::iterator I = GlobalAddressMap.find(GV); + return I != GlobalAddressMap.end() ? I->second : 0; +} + +///==----------------------------------------------------------------------==/// + /// 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 the starting @@ -59,7 +85,6 @@ 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. @@ -83,17 +108,21 @@ PM.add (new TargetData (TD)); PM.add (createVerifierPass ()); Target->getJITInfo ()->addPassesToJITCompile (PM); - DEBUG(PM.add (createMachineFunctionPrinterPass (&std::cerr, "Before unpacking:\n"))); + DEBUG(PM.add (createMachineFunctionPrinterPass (&std::cerr, + "Before unpacking:\n"))); PM.add (createUnpackTraceFunctionPass (Target, TF)); - DEBUG(PM.add (createMachineFunctionPrinterPass (&std::cerr, "After unpacking:\n"))); + DEBUG(PM.add (createMachineFunctionPrinterPass (&std::cerr, + "After unpacking:\n"))); Target->addPassesToEmitMachineCode (PM, *MCE); PM.run (*TF->TraceFn); // 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. - - + uint64_t traceStartAddr = getPointerToGlobalIfAvailable (TF->TraceFn); + assert (traceStartAddr && "Address of code for TraceFn was NULL after JIT?!"); + vm->writeBranchInstruction(a, traceStartAddr); + doFlush (a, a + 4); } } // end namespace llvm From gaeke at cs.uiuc.edu Tue Apr 27 13:35:05 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue Apr 27 13:35:05 2004 Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/SecondTrigger.cpp Message-ID: <200404271834.NAA06889@seraph.cs.uiuc.edu> Changes in directory reopt/lib/LightWtProfiling: SecondTrigger.cpp updated: 1.28 -> 1.29 --- Log message: Delete prototypes for functions exported from RuntimeOptimizations.cpp from here. --- Diffs of the changes: (+0 -2) Index: reopt/lib/LightWtProfiling/SecondTrigger.cpp diff -u reopt/lib/LightWtProfiling/SecondTrigger.cpp:1.28 reopt/lib/LightWtProfiling/SecondTrigger.cpp:1.29 --- reopt/lib/LightWtProfiling/SecondTrigger.cpp:1.28 Fri Apr 9 13:15:51 2004 +++ reopt/lib/LightWtProfiling/SecondTrigger.cpp Tue Apr 27 13:34:45 2004 @@ -43,8 +43,6 @@ // pair counts the number of times a given trace is *not* selected: static std::map > backOffCounters; -extern void optimizeTrace (std::vector &vBB, uint64_t a); - std::map firstTriggerAddr; extern "C" void llvm_time_start(){ From gaeke at cs.uiuc.edu Tue Apr 27 13:35:07 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue Apr 27 13:35:07 2004 Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/TraceOptEmitter.cpp Message-ID: <200404271834.NAA06896@seraph.cs.uiuc.edu> Changes in directory reopt/lib/LightWtProfiling: TraceOptEmitter.cpp updated: 1.6 -> 1.7 --- Log message: Keep track of where TraceFns get their code generated to (like the JIT does). --- Diffs of the changes: (+3 -0) Index: reopt/lib/LightWtProfiling/TraceOptEmitter.cpp diff -u reopt/lib/LightWtProfiling/TraceOptEmitter.cpp:1.6 reopt/lib/LightWtProfiling/TraceOptEmitter.cpp:1.7 --- reopt/lib/LightWtProfiling/TraceOptEmitter.cpp:1.6 Fri Apr 23 16:40:57 2004 +++ reopt/lib/LightWtProfiling/TraceOptEmitter.cpp Tue Apr 27 13:34:46 2004 @@ -98,6 +98,9 @@ // Round up to a 64-bit word boundary. CurBlock = (unsigned char*)(((intptr_t)CurFunctionPtr + 7) & ~7); CurByte = CurBlock; + + // Remember where we started generating this function. + addGlobalMapping (F.getFunction (), (uint64_t) CurByte); } void TraceOptEmitter::finishFunction(MachineFunction &F) { From gaeke at cs.uiuc.edu Tue Apr 27 17:04:02 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue Apr 27 17:04:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/SparcV9RegisterInfo.h Message-ID: <200404272204.RAA15042@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9: SparcV9RegisterInfo.h updated: 1.1 -> 1.2 --- Log message: Integrate the rest of my random sparcv9 scribblings into this file --- Diffs of the changes: (+3 -2) Index: llvm/lib/Target/SparcV9/SparcV9RegisterInfo.h diff -u llvm/lib/Target/SparcV9/SparcV9RegisterInfo.h:1.1 llvm/lib/Target/SparcV9/SparcV9RegisterInfo.h:1.2 --- llvm/lib/Target/SparcV9/SparcV9RegisterInfo.h:1.1 Sun Apr 25 01:32:05 2004 +++ llvm/lib/Target/SparcV9/SparcV9RegisterInfo.h Tue Apr 27 17:04:03 2004 @@ -69,11 +69,12 @@ /* 5 */ o5, o7, l0, l1, l2, /* 10 */ l3, l4, l5, l6, l7, /* 15 */ i0, i1, i2, i3, i4, - /* 20 */ i5, i6, i7, g0, g1, + /* 20 */ i5, i6, i7, g0, g1, // i6 is frame ptr, i7 is ret addr, g0 is zero /* 25 */ g2, g3, g4, g5, g6, - /* 30 */ g7, o6, + /* 30 */ g7, o6, // o6 is stack ptr // SparcV9FloatRegClass(FloatRegClassID) + // - regs 32 .. 63 are FPSingleRegType, 64 .. 95 are FPDoubleRegType // - unified register numbers 32 ... 95 (64 regs) /* 32 */ f0, f1, f2, /* 35 */ f3, f4, f5, f6, f7, From gaeke at cs.uiuc.edu Tue Apr 27 21:17:02 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue Apr 27 21:17:02 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineBasicBlock.h Message-ID: <200404280216.VAA32256@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineBasicBlock.h updated: 1.24 -> 1.25 --- Log message: Add machine-code CFG support: MachineBasicBlocks may now have their own predecessors and successors --- Diffs of the changes: (+67 -0) Index: llvm/include/llvm/CodeGen/MachineBasicBlock.h diff -u llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.24 llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.25 --- llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.24 Wed Mar 31 16:43:12 2004 +++ llvm/include/llvm/CodeGen/MachineBasicBlock.h Tue Apr 27 21:16:33 2004 @@ -60,6 +60,9 @@ Instructions Insts; MachineBasicBlock *Prev, *Next; const BasicBlock *BB; + std::vector Predecessors; + std::vector Successors; + public: MachineBasicBlock(const BasicBlock *bb = 0) : Prev(0), Next(0), BB(bb) { Insts.parent = this; @@ -94,6 +97,70 @@ const_reverse_iterator rbegin() const { return Insts.rbegin(); } reverse_iterator rend () { return Insts.rend(); } const_reverse_iterator rend () const { return Insts.rend(); } + + // Machine-CFG iterators + typedef std::vector::iterator pred_iterator; + typedef std::vector::const_iterator const_pred_iterator; + typedef std::vector::iterator succ_iterator; + typedef std::vector::const_iterator const_succ_iterator; + + pred_iterator pred_begin() { return Predecessors.begin (); } + const_pred_iterator pred_begin() const { return Predecessors.begin (); } + pred_iterator pred_end() { return Predecessors.end (); } + const_pred_iterator pred_end() const { return Predecessors.end (); } + succ_iterator succ_begin() { return Successors.begin (); } + const_succ_iterator succ_begin() const { return Successors.begin (); } + succ_iterator succ_end() { return Successors.end (); } + const_succ_iterator succ_end() const { return Successors.end (); } + + // Machine-CFG mutators + + /// addSuccessor - Add succ as a successor of this MachineBasicBlock. + /// The Predecessors list of succ is automatically updated. + /// + void addSuccessor (MachineBasicBlock *succ) { + Successors.push_back (succ); + assert (std::find (Successors.begin (), Successors.end (), succ) + == Successors.end () + && "Trying to addSuccessor a MBB which is already my successor"); + succ->addPredecessor (this); + } + + /// removeSuccessor - Remove succ from the successors list of this + /// MachineBasicBlock. The Predecessors list of succ is automatically updated. + /// + void removeSuccessor (MachineBasicBlock *succ) { + succ->removePredecessor (this); + std::vector::iterator goner = + std::find (Successors.begin(), Successors.end (), succ); + assert (goner != Successors.end () + && "Trying to removeSuccessor a MBB which isn't my successor"); + Successors.erase (goner); + } + + /// addPredecessor - Remove pred as a predecessor of this MachineBasicBlock. + /// Don't do this unless you know what you're doing, because it doesn't + /// update pred's successors list. Use pred->addSuccessor instead. + /// + void addPredecessor (MachineBasicBlock *pred) { + Predecessors.push_back (pred); + assert(std::find (Predecessors.begin (), Predecessors.end (), pred) + == Predecessors.end () + && "Trying to addPredecessor a MBB which is already my predecessor"); + } + + /// removePredecessor - Remove pred as a predecessor of this + /// MachineBasicBlock. Don't do this unless you know what you're + /// doing, because it doesn't update pred's successors list. Use + /// pred->removeSuccessor instead. + /// + void removePredecessor (MachineBasicBlock *pred) { + std::vector::iterator goner = + std::find (Predecessors.begin(), Predecessors.end (), pred); + assert (goner != Predecessors.end () + && "Trying to removePredecessor a MBB which isn't my predecessor"); + Predecessors.erase (goner); + } /// getFirstTerminator - returns an iterator to the first terminator /// instruction of this basic block. If a terminator does not exist, From gaeke at cs.uiuc.edu Tue Apr 27 23:00:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue Apr 27 23:00:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineBasicBlock.h Message-ID: <200404280359.WAA00345@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineBasicBlock.h updated: 1.25 -> 1.26 --- Log message: Fix thinkos that Chris caught for me. Make pred mutators private. --- Diffs of the changes: (+4 -2) Index: llvm/include/llvm/CodeGen/MachineBasicBlock.h diff -u llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.25 llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.26 --- llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.25 Tue Apr 27 21:16:33 2004 +++ llvm/include/llvm/CodeGen/MachineBasicBlock.h Tue Apr 27 22:59:48 2004 @@ -119,10 +119,10 @@ /// The Predecessors list of succ is automatically updated. /// void addSuccessor (MachineBasicBlock *succ) { - Successors.push_back (succ); assert (std::find (Successors.begin (), Successors.end (), succ) == Successors.end () && "Trying to addSuccessor a MBB which is already my successor"); + Successors.push_back (succ); succ->addPredecessor (this); } @@ -138,15 +138,16 @@ Successors.erase (goner); } +private: /// addPredecessor - Remove pred as a predecessor of this MachineBasicBlock. /// Don't do this unless you know what you're doing, because it doesn't /// update pred's successors list. Use pred->addSuccessor instead. /// void addPredecessor (MachineBasicBlock *pred) { - Predecessors.push_back (pred); assert(std::find (Predecessors.begin (), Predecessors.end (), pred) == Predecessors.end () && "Trying to addPredecessor a MBB which is already my predecessor"); + Predecessors.push_back (pred); } /// removePredecessor - Remove pred as a predecessor of this @@ -162,6 +163,7 @@ Predecessors.erase (goner); } +public: /// getFirstTerminator - returns an iterator to the first terminator /// instruction of this basic block. If a terminator does not exist, /// it returns end() From gaeke at cs.uiuc.edu Tue Apr 27 23:15:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue Apr 27 23:15:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineBasicBlock.h Message-ID: <200404280415.XAA00524@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineBasicBlock.h updated: 1.26 -> 1.27 --- Log message: Move private methods to end of class decl at Chris's request --- Diffs of the changes: (+26 -26) Index: llvm/include/llvm/CodeGen/MachineBasicBlock.h diff -u llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.26 llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.27 --- llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.26 Tue Apr 27 22:59:48 2004 +++ llvm/include/llvm/CodeGen/MachineBasicBlock.h Tue Apr 27 23:15:06 2004 @@ -138,32 +138,6 @@ Successors.erase (goner); } -private: - /// addPredecessor - Remove pred as a predecessor of this MachineBasicBlock. - /// Don't do this unless you know what you're doing, because it doesn't - /// update pred's successors list. Use pred->addSuccessor instead. - /// - void addPredecessor (MachineBasicBlock *pred) { - assert(std::find (Predecessors.begin (), Predecessors.end (), pred) - == Predecessors.end () - && "Trying to addPredecessor a MBB which is already my predecessor"); - Predecessors.push_back (pred); - } - - /// removePredecessor - Remove pred as a predecessor of this - /// MachineBasicBlock. Don't do this unless you know what you're - /// doing, because it doesn't update pred's successors list. Use - /// pred->removeSuccessor instead. - /// - void removePredecessor (MachineBasicBlock *pred) { - std::vector::iterator goner = - std::find (Predecessors.begin(), Predecessors.end (), pred); - assert (goner != Predecessors.end () - && "Trying to removePredecessor a MBB which isn't my predecessor"); - Predecessors.erase (goner); - } - -public: /// getFirstTerminator - returns an iterator to the first terminator /// instruction of this basic block. If a terminator does not exist, /// it returns end() @@ -193,6 +167,32 @@ MachineBasicBlock *getNext() const { return Next; } void setPrev(MachineBasicBlock *P) { Prev = P; } void setNext(MachineBasicBlock *N) { Next = N; } + + // Machine-CFG mutators + + /// addPredecessor - Remove pred as a predecessor of this MachineBasicBlock. + /// Don't do this unless you know what you're doing, because it doesn't + /// update pred's successors list. Use pred->addSuccessor instead. + /// + void addPredecessor (MachineBasicBlock *pred) { + assert(std::find (Predecessors.begin (), Predecessors.end (), pred) + == Predecessors.end () + && "Trying to addPredecessor a MBB which is already my predecessor"); + Predecessors.push_back (pred); + } + + /// removePredecessor - Remove pred as a predecessor of this + /// MachineBasicBlock. Don't do this unless you know what you're + /// doing, because it doesn't update pred's successors list. Use + /// pred->removeSuccessor instead. + /// + void removePredecessor (MachineBasicBlock *pred) { + std::vector::iterator goner = + std::find (Predecessors.begin(), Predecessors.end (), pred); + assert (goner != Predecessors.end () + && "Trying to removePredecessor a MBB which isn't my predecessor"); + Predecessors.erase (goner); + } }; } // End llvm namespace From gaeke at cs.uiuc.edu Tue Apr 27 23:20:03 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue Apr 27 23:20:03 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/InstSelectSimple.cpp Message-ID: <200404280419.XAA00651@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: InstSelectSimple.cpp updated: 1.238 -> 1.239 --- Log message: Update the machine-CFG edges whenever we see a branch. --- Diffs of the changes: (+5 -0) Index: llvm/lib/Target/X86/InstSelectSimple.cpp diff -u llvm/lib/Target/X86/InstSelectSimple.cpp:1.238 llvm/lib/Target/X86/InstSelectSimple.cpp:1.239 --- llvm/lib/Target/X86/InstSelectSimple.cpp:1.238 Wed Apr 14 16:27:56 2004 +++ llvm/lib/Target/X86/InstSelectSimple.cpp Tue Apr 27 23:19:37 2004 @@ -1295,6 +1295,11 @@ /// just make a fall-through (but we don't currently). /// void ISel::visitBranchInst(BranchInst &BI) { + // Update machine-CFG edges + BB->addSuccessor (MBBMap[BI.getSuccessor(0)]); + if (BI.isConditional()) + BB->addSuccessor (MBBMap[BI.getSuccessor(1)]); + BasicBlock *NextBB = getBlockAfter(BI.getParent()); // BB after current one if (!BI.isConditional()) { // Unconditional branch? From gaeke at cs.uiuc.edu Tue Apr 27 23:34:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue Apr 27 23:34:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/InstSelectSimple.cpp Message-ID: <200404280434.XAA00815@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: InstSelectSimple.cpp updated: 1.239 -> 1.240 --- Log message: In InsertFPRegKills(), use the machine-CFG itself rather than the LLVM CFG when trying to find the successors of BB. --- Diffs of the changes: (+3 -3) Index: llvm/lib/Target/X86/InstSelectSimple.cpp diff -u llvm/lib/Target/X86/InstSelectSimple.cpp:1.239 llvm/lib/Target/X86/InstSelectSimple.cpp:1.240 --- llvm/lib/Target/X86/InstSelectSimple.cpp:1.239 Tue Apr 27 23:19:37 2004 +++ llvm/lib/Target/X86/InstSelectSimple.cpp Tue Apr 27 23:34:16 2004 @@ -743,9 +743,9 @@ // If we haven't found an FP register use or def in this basic block, check // to see if any of our successors has an FP PHI node, which will cause a // copy to be inserted into this block. - for (succ_const_iterator SI = succ_begin(BB->getBasicBlock()), - E = succ_end(BB->getBasicBlock()); SI != E; ++SI) { - MachineBasicBlock *SBB = MBBMap[*SI]; + for (MachineBasicBlock::const_succ_iterator SI = BB->succ_begin(), + SE = BB->succ_end(); SI != SE; ++SI) { + MachineBasicBlock *SBB = *SI; for (MachineBasicBlock::iterator I = SBB->begin(); I != SBB->end() && I->getOpcode() == X86::PHI; ++I) { if (RegMap.getRegClass(I->getOperand(0).getReg())->getSize() == 10) From gaeke at cs.uiuc.edu Tue Apr 27 23:46:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue Apr 27 23:46:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/InstSelectSimple.cpp Message-ID: <200404280446.XAA00973@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: InstSelectSimple.cpp updated: 1.240 -> 1.241 --- Log message: Make RequiresFPRegKill() take a MachineBasicBlock arg. In InsertFPRegKills(), just check the MachineBasicBlock for successors instead of its corresponding BasicBlock. --- Diffs of the changes: (+3 -3) Index: llvm/lib/Target/X86/InstSelectSimple.cpp diff -u llvm/lib/Target/X86/InstSelectSimple.cpp:1.240 llvm/lib/Target/X86/InstSelectSimple.cpp:1.241 --- llvm/lib/Target/X86/InstSelectSimple.cpp:1.240 Tue Apr 27 23:34:16 2004 +++ llvm/lib/Target/X86/InstSelectSimple.cpp Tue Apr 27 23:45:55 2004 @@ -684,8 +684,9 @@ /// Note that this kill instruction will eventually be eliminated when /// restrictions in the stackifier are relaxed. /// -static bool RequiresFPRegKill(const BasicBlock *BB) { +static bool RequiresFPRegKill(const MachineBasicBlock *MBB) { #if 0 + const BasicBlock *BB = MBB->getBasicBlock (); for (succ_const_iterator SI = succ_begin(BB), E = succ_end(BB); SI!=E; ++SI) { const BasicBlock *Succ = *SI; pred_const_iterator PI = pred_begin(Succ), PE = pred_end(Succ); @@ -756,8 +757,7 @@ UsesFPReg: // Okay, this block uses an FP register. If the block has successors (ie, // it's not an unwind/return), insert the FP_REG_KILL instruction. - if (BB->getBasicBlock()->getTerminator()->getNumSuccessors() && - RequiresFPRegKill(BB->getBasicBlock())) { + if (BB->succ_size () && RequiresFPRegKill(BB)) { BuildMI(*BB, BB->getFirstTerminator(), X86::FP_REG_KILL, 0); ++NumFPKill; } From gaeke at cs.uiuc.edu Tue Apr 27 23:47:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue Apr 27 23:47:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineBasicBlock.h Message-ID: <200404280446.XAA01088@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineBasicBlock.h updated: 1.27 -> 1.28 --- Log message: Add pred./succ. list size methods. --- Diffs of the changes: (+2 -0) Index: llvm/include/llvm/CodeGen/MachineBasicBlock.h diff -u llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.27 llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.28 --- llvm/include/llvm/CodeGen/MachineBasicBlock.h:1.27 Tue Apr 27 23:15:06 2004 +++ llvm/include/llvm/CodeGen/MachineBasicBlock.h Tue Apr 27 23:46:35 2004 @@ -108,10 +108,12 @@ const_pred_iterator pred_begin() const { return Predecessors.begin (); } pred_iterator pred_end() { return Predecessors.end (); } const_pred_iterator pred_end() const { return Predecessors.end (); } + unsigned pred_size() const { return Predecessors.size (); } succ_iterator succ_begin() { return Successors.begin (); } const_succ_iterator succ_begin() const { return Successors.begin (); } succ_iterator succ_end() { return Successors.end (); } const_succ_iterator succ_end() const { return Successors.end (); } + unsigned succ_size() const { return Successors.size (); } // Machine-CFG mutators From brukman at cs.uiuc.edu Wed Apr 28 10:31:01 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Wed Apr 28 10:31:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Assembly/CachedWriter.h Message-ID: <200404281530.KAA30234@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Assembly: CachedWriter.h updated: 1.13 -> 1.14 --- Log message: * Add ability to get and set the output stream * New feature: outputting a Type* as symbolic, controlled via the stream similarly to sending std::hex to change number format --- Diffs of the changes: (+23 -11) Index: llvm/include/llvm/Assembly/CachedWriter.h diff -u llvm/include/llvm/Assembly/CachedWriter.h:1.13 llvm/include/llvm/Assembly/CachedWriter.h:1.14 --- llvm/include/llvm/Assembly/CachedWriter.h:1.13 Thu Jan 8 16:21:58 2004 +++ llvm/include/llvm/Assembly/CachedWriter.h Wed Apr 28 10:30:33 2004 @@ -30,12 +30,20 @@ class CachedWriter { AssemblyWriter *AW; SlotCalculator *SC; + bool SymbolicTypes; public: - std::ostream &Out; + std::ostream *Out; + + enum TypeWriter { + SymTypeOn, + SymTypeOff + }; + public: - CachedWriter(std::ostream &O = std::cout) : AW(0), SC(0), Out(O) { } + CachedWriter(std::ostream &O = std::cout) + : AW(0), SC(0), SymbolicTypes(false), Out(&O) { } CachedWriter(const Module *M, std::ostream &O = std::cout) - : AW(0), SC(0), Out(O) { + : AW(0), SC(0), SymbolicTypes(false), Out(&O) { setModule(M); } ~CachedWriter(); @@ -66,22 +74,26 @@ inline CachedWriter &operator<<(const Constant *X) { return *this << (const Value*)X; } - inline CachedWriter &operator<<(const Type *X) { - return *this << (const Value*)X; - } - inline CachedWriter &operator<<(const PointerType *X) { - return *this << (const Value*)X; - } + CachedWriter &operator<<(const Type *X); + inline CachedWriter &operator<<(const PointerType *X); inline CachedWriter &operator<<(std::ostream &(&Manip)(std::ostream &)) { - Out << Manip; return *this; + *Out << Manip; return *this; } template inline CachedWriter &operator<<(const X &v) { - Out << v; + *Out << v; return *this; } + + inline CachedWriter &operator<<(enum TypeWriter tw) { + SymbolicTypes = (tw == SymTypeOn); + return *this; + } + + inline std::ostream& getStream() { return *Out; } + inline void setStream(std::ostream &os) { Out = &os; } }; } // End llvm namespace From brukman at cs.uiuc.edu Wed Apr 28 10:31:05 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Wed Apr 28 10:31:05 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/AsmWriter.cpp Message-ID: <200404281531.KAA30264@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: AsmWriter.cpp updated: 1.126 -> 1.127 --- Log message: * Add ability to print out type as symbolic * Add Module accessor to AssemblyWriter --- Diffs of the changes: (+15 -3) Index: llvm/lib/VMCore/AsmWriter.cpp diff -u llvm/lib/VMCore/AsmWriter.cpp:1.126 llvm/lib/VMCore/AsmWriter.cpp:1.127 --- llvm/lib/VMCore/AsmWriter.cpp:1.126 Thu Mar 11 23:53:14 2004 +++ llvm/lib/VMCore/AsmWriter.cpp Wed Apr 28 10:31:21 2004 @@ -26,8 +26,9 @@ #include "llvm/iPHINode.h" #include "llvm/iOther.h" #include "llvm/Module.h" -#include "llvm/Analysis/SlotCalculator.h" #include "llvm/SymbolTable.h" +#include "llvm/Analysis/SlotCalculator.h" +#include "llvm/Assembly/Writer.h" #include "llvm/Support/CFG.h" #include "Support/StringExtras.h" #include "Support/STLExtras.h" @@ -474,6 +475,8 @@ void writeOperand(const Value *Op, bool PrintType, bool PrintName = true); + const Module* getModule() { return TheModule; } + private : void printModule(const Module *M); void printSymbolTable(const SymbolTable &ST); @@ -1019,7 +1022,7 @@ delete SC; delete AW; if (M) { SC = new SlotCalculator(M, false); - AW = new AssemblyWriter(Out, *SC, M, 0); + AW = new AssemblyWriter(*Out, *SC, M, 0); } else { SC = 0; AW = 0; } @@ -1040,7 +1043,16 @@ case Value::BasicBlockVal: AW->write(cast(V)); break; case Value::FunctionVal: AW->write(cast(V)); break; case Value::GlobalVariableVal: AW->write(cast(V)); break; - default: Out << "getValueType() << ">"; break; + default: *Out << "getValueType() << ">"; break; } return *this; +} + +CachedWriter& CachedWriter::operator<<(const Type *X) { + if (SymbolicTypes) { + const Module *M = AW->getModule(); + if (M) WriteTypeSymbolic(*Out, X, M); + return *this; + } else + return *this << (const Value*)X; } From brukman at cs.uiuc.edu Wed Apr 28 10:32:02 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Wed Apr 28 10:32:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/InstructionReader.cpp Message-ID: <200404281532.KAA30296@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: InstructionReader.cpp updated: 1.71 -> 1.72 --- Log message: Squelch compile-time warning (profile build). --- Diffs of the changes: (+1 -1) Index: llvm/lib/Bytecode/Reader/InstructionReader.cpp diff -u llvm/lib/Bytecode/Reader/InstructionReader.cpp:1.71 llvm/lib/Bytecode/Reader/InstructionReader.cpp:1.72 --- llvm/lib/Bytecode/Reader/InstructionReader.cpp:1.71 Tue Apr 27 13:24:38 2004 +++ llvm/lib/Bytecode/Reader/InstructionReader.cpp Wed Apr 28 10:32:09 2004 @@ -310,7 +310,7 @@ if (!TopTy) throw std::string("Invalid getelementptr instruction!"); unsigned ValIdx = Args[i]; - unsigned IdxTy; + unsigned IdxTy = 0; if (!hasRestrictedGEPTypes) { // Struct indices are always uints, sequential type indices can be any // of the 32 or 64-bit integer types. The actual choice of type is From gaeke at cs.uiuc.edu Wed Apr 28 12:16:09 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Apr 28 12:16:09 2004 Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp Message-ID: <200404281715.MAA09736@zion.cs.uiuc.edu> Changes in directory reopt/lib/LightWtProfiling: UnpackTraceFunction.cpp updated: 1.58 -> 1.59 --- Log message: Fix usage of iterator --- Diffs of the changes: (+1 -1) Index: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp diff -u reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.58 reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.59 --- reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.58 Mon Apr 26 14:47:32 2004 +++ reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp Wed Apr 28 12:15:30 2004 @@ -364,7 +364,7 @@ DEBUG(std::cerr << "getSavedStateIndexOfInstruction(F = " << F->getName() << "(), I = " << *I << ")\n"); for (const_inst_iterator II=inst_begin (F), IE=inst_end (F); II!=IE; ++II) { - if (*II == I) { + if (&*II == I) { DEBUG(std::cerr << "--> returns " << Key << "\n"); return Key; } From gaeke at cs.uiuc.edu Wed Apr 28 12:24:02 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Apr 28 12:24:02 2004 Subject: [llvm-commits] CVS: reopt/lib/Inst/lib/InstManip.h Message-ID: <200404281723.MAA15814@zion.cs.uiuc.edu> Changes in directory reopt/lib/Inst/lib: InstManip.h updated: 1.19 -> 1.20 --- Log message: Include Support/DataTypes.h for uint64_t. --- Diffs of the changes: (+1 -0) Index: reopt/lib/Inst/lib/InstManip.h diff -u reopt/lib/Inst/lib/InstManip.h:1.19 reopt/lib/Inst/lib/InstManip.h:1.20 --- reopt/lib/Inst/lib/InstManip.h:1.19 Wed Nov 19 14:49:53 2003 +++ reopt/lib/Inst/lib/InstManip.h Wed Apr 28 12:23:32 2004 @@ -33,6 +33,7 @@ #define INSTMANIP_H #include "Phase1/Intraphase.h" +#include "Support/DataTypes.h" #include #include #include From gaeke at cs.uiuc.edu Wed Apr 28 12:24:08 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Apr 28 12:24:08 2004 Subject: [llvm-commits] CVS: reopt/lib/Inst/lib/Makefile Message-ID: <200404281723.MAA15821@zion.cs.uiuc.edu> Changes in directory reopt/lib/Inst/lib: Makefile updated: 1.5 -> 1.6 --- Log message: Make more of the reoptimizer compile on x86. --- Diffs of the changes: (+8 -0) Index: reopt/lib/Inst/lib/Makefile diff -u reopt/lib/Inst/lib/Makefile:1.5 reopt/lib/Inst/lib/Makefile:1.6 --- reopt/lib/Inst/lib/Makefile:1.5 Thu Aug 21 14:40:58 2003 +++ reopt/lib/Inst/lib/Makefile Wed Apr 28 12:23:33 2004 @@ -3,4 +3,12 @@ LIBRARYNAME = perfinst BUILD_ARCHIVE = 1 +include $(LEVEL)/Makefile.config + +ifneq ($(ARCH),Sparc) +Source := InstManip.cpp SparcInstManip.cpp +all :: + @echo "This code assumes an LP64 machine- please ignore ptr cast warnings!" +endif + include $(LEVEL)/Makefile.common From gaeke at cs.uiuc.edu Wed Apr 28 12:28:02 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Apr 28 12:28:02 2004 Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/Makefile Message-ID: <200404281727.MAA20931@zion.cs.uiuc.edu> Changes in directory reopt/lib/LightWtProfiling: Makefile updated: 1.4 -> 1.5 --- Log message: Make more of the reoptimizer compile under x86 (albeit with warnings) --- Diffs of the changes: (+9 -0) Index: reopt/lib/LightWtProfiling/Makefile diff -u reopt/lib/LightWtProfiling/Makefile:1.4 reopt/lib/LightWtProfiling/Makefile:1.5 --- reopt/lib/LightWtProfiling/Makefile:1.4 Thu Aug 21 14:40:59 2003 +++ reopt/lib/LightWtProfiling/Makefile Wed Apr 28 12:27:36 2004 @@ -2,4 +2,13 @@ LEVEL = ../.. LIBRARYNAME = firstTrigger +include $(LEVEL)/Makefile.config + +ifneq ($(ARCH),Sparc) +Source := Initialization.cpp RuntimeOptimizations.cpp SLI.cpp Trace.cpp TraceOptEmitter.cpp TraceToFunction.cpp UnpackTraceFunction.cpp scheduler.cpp +all :: + @echo "This code assumes an LP64 machine- please ignore ptr cast warnings!" +endif + + include $(LEVEL)/Makefile.common From gaeke at cs.uiuc.edu Wed Apr 28 12:28:07 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Apr 28 12:28:07 2004 Subject: [llvm-commits] CVS: reopt/lib/Makefile Message-ID: <200404281727.MAA20938@zion.cs.uiuc.edu> Changes in directory reopt/lib: Makefile updated: 1.18 -> 1.19 --- Log message: Make more of the reoptimizer compile under x86 (albeit with warnings) --- Diffs of the changes: (+1 -6) Index: reopt/lib/Makefile diff -u reopt/lib/Makefile:1.18 reopt/lib/Makefile:1.19 --- reopt/lib/Makefile:1.18 Wed Apr 7 00:08:15 2004 +++ reopt/lib/Makefile Wed Apr 28 12:27:36 2004 @@ -1,16 +1,11 @@ LEVEL = .. -DIRS := BinInterface Mapping TraceCache Trigger +DIRS := BinInterface Mapping TraceCache Trigger LightWtProfiling Inst include $(LEVEL)/Makefile.config # Mac OS X assembler doesn't love the dummy function. ifneq ($(ARCH),PowerPC) DIRS := $(DIRS) ScratchMemory -endif - -# These dirs contain files that don't currently compile under Linux/x86: -ifeq ($(ARCH),Sparc) -DIRS := $(DIRS) Inst LightWtProfiling endif include $(LEVEL)/Makefile.common From brukman at cs.uiuc.edu Wed Apr 28 13:53:01 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Wed Apr 28 13:53:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Analysis/IPA/FindUnsafePointerTypes.cpp Message-ID: <200404281852.NAA20061@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/IPA: FindUnsafePointerTypes.cpp updated: 1.22 -> 1.23 --- Log message: Send text and numbers directly to CachedWriter's contained ostream. --- Diffs of the changes: (+2 -1) Index: llvm/lib/Analysis/IPA/FindUnsafePointerTypes.cpp diff -u llvm/lib/Analysis/IPA/FindUnsafePointerTypes.cpp:1.22 llvm/lib/Analysis/IPA/FindUnsafePointerTypes.cpp:1.23 --- llvm/lib/Analysis/IPA/FindUnsafePointerTypes.cpp:1.22 Tue Apr 27 10:12:48 2004 +++ llvm/lib/Analysis/IPA/FindUnsafePointerTypes.cpp Wed Apr 28 13:52:43 2004 @@ -98,7 +98,8 @@ for (std::set::const_iterator I = getUnsafeTypes().begin(), E = getUnsafeTypes().end(); I != E; ++I, ++Counter) { - CW << " #" << Counter << ". " << (Value*)*I << "\n"; + o << " #" << Counter << ". "; + CW << (Value*)*I << "\n"; } } From brukman at cs.uiuc.edu Wed Apr 28 14:23:01 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Wed Apr 28 14:23:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Assembly/CachedWriter.h Message-ID: <200404281923.OAA29723@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Assembly: CachedWriter.h updated: 1.14 -> 1.15 --- Log message: * Make contained ostream not public. * Remove various print methods that called the Value* method, just have one that all subclasses of Value will use anyway. * Remove template for printing constant references * Add methods to print char* and strings * setStream now sets the stream on the contained AssemblyWriter --- Diffs of the changes: (+11 -26) Index: llvm/include/llvm/Assembly/CachedWriter.h diff -u llvm/include/llvm/Assembly/CachedWriter.h:1.14 llvm/include/llvm/Assembly/CachedWriter.h:1.15 --- llvm/include/llvm/Assembly/CachedWriter.h:1.14 Wed Apr 28 10:30:33 2004 +++ llvm/include/llvm/Assembly/CachedWriter.h Wed Apr 28 14:22:58 2004 @@ -31,15 +31,14 @@ AssemblyWriter *AW; SlotCalculator *SC; bool SymbolicTypes; -public: std::ostream *Out; +public: enum TypeWriter { SymTypeOn, SymTypeOff }; -public: CachedWriter(std::ostream &O = std::cout) : AW(0), SC(0), SymbolicTypes(false), Out(&O) { } CachedWriter(const Module *M, std::ostream &O = std::cout) @@ -53,27 +52,10 @@ CachedWriter &operator<<(const Value *V); - inline CachedWriter &operator<<(Value *X) { - return *this << (const Value*)X; - } - inline CachedWriter &operator<<(const GlobalVariable *X) { - return *this << (const Value*)X; - } - inline CachedWriter &operator<<(const Function *X) { - return *this << (const Value*)X; - } - inline CachedWriter &operator<<(const Argument *X) { - return *this << (const Value*)X; - } - inline CachedWriter &operator<<(const BasicBlock *X) { - return *this << (const Value*)X; - } - inline CachedWriter &operator<<(const Instruction *X) { - return *this << (const Value*)X; - } - inline CachedWriter &operator<<(const Constant *X) { - return *this << (const Value*)X; + inline CachedWriter &operator<<(const Value &X) { + return *this << &X; } + CachedWriter &operator<<(const Type *X); inline CachedWriter &operator<<(const PointerType *X); @@ -81,9 +63,12 @@ *Out << Manip; return *this; } - template - inline CachedWriter &operator<<(const X &v) { - *Out << v; + inline CachedWriter& operator<<(const char *X) { + *Out << X; + return *this; + } + inline CachedWriter& operator<<(const std::string &X) { + *Out << X; return *this; } @@ -93,7 +78,7 @@ } inline std::ostream& getStream() { return *Out; } - inline void setStream(std::ostream &os) { Out = &os; } + void setStream(std::ostream &os); }; } // End llvm namespace From brukman at cs.uiuc.edu Wed Apr 28 14:24:03 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Wed Apr 28 14:24:03 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/AsmWriter.cpp Message-ID: <200404281924.OAA29746@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: AsmWriter.cpp updated: 1.127 -> 1.128 --- Log message: class AssemblyWriter: * Make contained ostream pointer, not reference * Allow setting of that ostream via setStream() class CachedWriter: * setStream() in turn calls setStream() on the AssemblyWriter --- Diffs of the changes: (+109 -103) Index: llvm/lib/VMCore/AsmWriter.cpp diff -u llvm/lib/VMCore/AsmWriter.cpp:1.127 llvm/lib/VMCore/AsmWriter.cpp:1.128 --- llvm/lib/VMCore/AsmWriter.cpp:1.127 Wed Apr 28 10:31:21 2004 +++ llvm/lib/VMCore/AsmWriter.cpp Wed Apr 28 14:24:28 2004 @@ -449,7 +449,7 @@ namespace llvm { class AssemblyWriter { - std::ostream &Out; + std::ostream *Out; SlotCalculator &Table; const Module *TheModule; std::map TypeNames; @@ -457,7 +457,7 @@ public: inline AssemblyWriter(std::ostream &o, SlotCalculator &Tab, const Module *M, AssemblyAnnotationWriter *AAW) - : Out(o), Table(Tab), TheModule(M), AnnotationWriter(AAW) { + : Out(&o), Table(Tab), TheModule(M), AnnotationWriter(AAW) { // If the module has a symbol table, take all global types and stuff their // names into the TypeNames map. @@ -476,6 +476,7 @@ void writeOperand(const Value *Op, bool PrintType, bool PrintName = true); const Module* getModule() { return TheModule; } + void setStream(std::ostream &os) { Out = &os; } private : void printModule(const Module *M); @@ -491,7 +492,7 @@ // symbolic version of a type name. // std::ostream &printType(const Type *Ty) { - return printTypeInt(Out, Ty, TypeNames); + return printTypeInt(*Out, Ty, TypeNames); } // printTypeAtLeastOneLevel - Print out one level of the possibly complex type @@ -514,55 +515,55 @@ for (FunctionType::param_iterator I = FTy->param_begin(), E = FTy->param_end(); I != E; ++I) { if (I != FTy->param_begin()) - Out << ", "; + *Out << ", "; printType(*I); } if (FTy->isVarArg()) { - if (FTy->getNumParams()) Out << ", "; - Out << "..."; + if (FTy->getNumParams()) *Out << ", "; + *Out << "..."; } - Out << ")"; + *Out << ")"; } else if (const StructType *STy = dyn_cast(Ty)) { - Out << "{ "; + *Out << "{ "; for (StructType::element_iterator I = STy->element_begin(), E = STy->element_end(); I != E; ++I) { if (I != STy->element_begin()) - Out << ", "; + *Out << ", "; printType(*I); } - Out << " }"; + *Out << " }"; } else if (const PointerType *PTy = dyn_cast(Ty)) { printType(PTy->getElementType()) << "*"; } else if (const ArrayType *ATy = dyn_cast(Ty)) { - Out << "[" << ATy->getNumElements() << " x "; + *Out << "[" << ATy->getNumElements() << " x "; printType(ATy->getElementType()) << "]"; } else if (const OpaqueType *OTy = dyn_cast(Ty)) { - Out << "opaque"; + *Out << "opaque"; } else { if (!Ty->isPrimitiveType()) - Out << ""; + *Out << ""; printType(Ty); } - return Out; + return *Out; } void AssemblyWriter::writeOperand(const Value *Operand, bool PrintType, bool PrintName) { - if (PrintType) { Out << " "; printType(Operand->getType()); } - WriteAsOperandInternal(Out, Operand, PrintName, TypeNames, &Table); + if (PrintType) { *Out << " "; printType(Operand->getType()); } + WriteAsOperandInternal(*Out, Operand, PrintName, TypeNames, &Table); } void AssemblyWriter::printModule(const Module *M) { switch (M->getEndianness()) { - case Module::LittleEndian: Out << "target endian = little\n"; break; - case Module::BigEndian: Out << "target endian = big\n"; break; + case Module::LittleEndian: *Out << "target endian = little\n"; break; + case Module::BigEndian: *Out << "target endian = big\n"; break; case Module::AnyEndianness: break; } switch (M->getPointerSize()) { - case Module::Pointer32: Out << "target pointersize = 32\n"; break; - case Module::Pointer64: Out << "target pointersize = 64\n"; break; + case Module::Pointer32: *Out << "target pointersize = 32\n"; break; + case Module::Pointer64: *Out << "target pointersize = 64\n"; break; case Module::AnyPointerSize: break; } @@ -572,7 +573,7 @@ for (Module::const_giterator I = M->gbegin(), E = M->gend(); I != E; ++I) printGlobal(I); - Out << "\nimplementation ; Functions:\n"; + *Out << "\nimplementation ; Functions:\n"; // Output all of the functions... for (Module::const_iterator I = M->begin(), E = M->end(); I != E; ++I) @@ -580,27 +581,27 @@ } void AssemblyWriter::printGlobal(const GlobalVariable *GV) { - if (GV->hasName()) Out << getLLVMName(GV->getName()) << " = "; + if (GV->hasName()) *Out << getLLVMName(GV->getName()) << " = "; if (!GV->hasInitializer()) - Out << "external "; + *Out << "external "; else switch (GV->getLinkage()) { - case GlobalValue::InternalLinkage: Out << "internal "; break; - case GlobalValue::LinkOnceLinkage: Out << "linkonce "; break; - case GlobalValue::WeakLinkage: Out << "weak "; break; - case GlobalValue::AppendingLinkage: Out << "appending "; break; + case GlobalValue::InternalLinkage: *Out << "internal "; break; + case GlobalValue::LinkOnceLinkage: *Out << "linkonce "; break; + case GlobalValue::WeakLinkage: *Out << "weak "; break; + case GlobalValue::AppendingLinkage: *Out << "appending "; break; case GlobalValue::ExternalLinkage: break; } - Out << (GV->isConstant() ? "constant " : "global "); + *Out << (GV->isConstant() ? "constant " : "global "); printType(GV->getType()->getElementType()); if (GV->hasInitializer()) writeOperand(GV->getInitializer(), false, false); printInfoComment(*GV); - Out << "\n"; + *Out << "\n"; } @@ -618,7 +619,7 @@ printConstant(CPV); } else if (const Type *Ty = dyn_cast(V)) { assert(Ty->getType() == Type::TypeTy && TI->first == Type::TypeTy); - Out << "\t" << getLLVMName(I->first) << " = type "; + *Out << "\t" << getLLVMName(I->first) << " = type "; // Make sure we print out at least one level of the type structure, so // that we do not get %FILE = type %FILE @@ -637,40 +638,40 @@ if (!CPV->hasName()) return; // Print out name... - Out << "\t" << getLLVMName(CPV->getName()) << " ="; + *Out << "\t" << getLLVMName(CPV->getName()) << " ="; // Write the value out now... writeOperand(CPV, true, false); printInfoComment(*CPV); - Out << "\n"; + *Out << "\n"; } /// printFunction - Print all aspects of a function. /// void AssemblyWriter::printFunction(const Function *F) { // Print out the return type and name... - Out << "\n"; + *Out << "\n"; - if (AnnotationWriter) AnnotationWriter->emitFunctionAnnot(F, Out); + if (AnnotationWriter) AnnotationWriter->emitFunctionAnnot(F, *Out); if (F->isExternal()) - Out << "declare "; + *Out << "declare "; else switch (F->getLinkage()) { - case GlobalValue::InternalLinkage: Out << "internal "; break; - case GlobalValue::LinkOnceLinkage: Out << "linkonce "; break; - case GlobalValue::WeakLinkage: Out << "weak "; break; - case GlobalValue::AppendingLinkage: Out << "appending "; break; + case GlobalValue::InternalLinkage: *Out << "internal "; break; + case GlobalValue::LinkOnceLinkage: *Out << "linkonce "; break; + case GlobalValue::WeakLinkage: *Out << "weak "; break; + case GlobalValue::AppendingLinkage: *Out << "appending "; break; case GlobalValue::ExternalLinkage: break; } printType(F->getReturnType()) << " "; if (!F->getName().empty()) - Out << getLLVMName(F->getName()); + *Out << getLLVMName(F->getName()); else - Out << "\"\""; - Out << "("; + *Out << "\"\""; + *Out << "("; Table.incorporateFunction(F); // Loop over the arguments, printing them... @@ -681,21 +682,21 @@ // Finish printing arguments... if (FT->isVarArg()) { - if (FT->getNumParams()) Out << ", "; - Out << "..."; // Output varargs portion of signature! + if (FT->getNumParams()) *Out << ", "; + *Out << "..."; // Output varargs portion of signature! } - Out << ")"; + *Out << ")"; if (F->isExternal()) { - Out << "\n"; + *Out << "\n"; } else { - Out << " {"; + *Out << " {"; // Output all of its basic blocks... for the function for (Function::const_iterator I = F->begin(), E = F->end(); I != E; ++I) printBasicBlock(I); - Out << "}\n"; + *Out << "}\n"; } Table.purgeFunction(); @@ -706,62 +707,62 @@ /// void AssemblyWriter::printArgument(const Argument *Arg) { // Insert commas as we go... the first arg doesn't get a comma - if (Arg != &Arg->getParent()->afront()) Out << ", "; + if (Arg != &Arg->getParent()->afront()) *Out << ", "; // Output type... printType(Arg->getType()); // Output name, if available... if (Arg->hasName()) - Out << " " << getLLVMName(Arg->getName()); + *Out << " " << getLLVMName(Arg->getName()); else if (Table.getSlot(Arg) < 0) - Out << ""; + *Out << ""; } /// printBasicBlock - This member is called for each basic block in a method. /// void AssemblyWriter::printBasicBlock(const BasicBlock *BB) { if (BB->hasName()) { // Print out the label if it exists... - Out << "\n" << BB->getName() << ":"; + *Out << "\n" << BB->getName() << ":"; } else if (!BB->use_empty()) { // Don't print block # of no uses... int Slot = Table.getSlot(BB); - Out << "\n;