defUse.hpp

Go to the documentation of this file.
00001 /* Copyright 1994, LongView Technologies L.L.C. $Revision: 1.11 $ */
00002 /* Copyright (c) 2006, Sun Microsystems, Inc.
00003 All rights reserved.
00004 
00005 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the 
00006 following conditions are met:
00007 
00008     * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
00009     * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following 
00010           disclaimer in the documentation and/or other materials provided with the distribution.
00011     * Neither the name of Sun Microsystems nor the names of its contributors may be used to endorse or promote products derived 
00012           from this software without specific prior written permission.
00013 
00014 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT 
00015 NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 
00016 THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
00017 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
00018 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
00019 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
00020 
00021 
00022 */
00023 
00024 // Defs represent PReg definitions, Uses the uses.  Each basic block
00025 // has a list of the defs and uses it contains, and a PReg has a list
00026 // of the BBs it is used/defined in.
00027 
00028 # ifdef DELTA_COMPILER
00029 
00030   class DefUse : public PrintableResourceObj {          // abstract
00031    public:
00032     NonTrivialNode* node;
00033     DefUse(NonTrivialNode* n) { node = n; }
00034 
00035   };
00036 
00037   class Def : public DefUse {
00038    public:
00039     Def(NonTrivialNode* n) : DefUse(n) { }
00040 
00041     void print();
00042   };
00043 
00044   class Use : public DefUse {
00045    public:
00046     Use(NonTrivialNode* n) : DefUse(n) { }
00047     virtual bool isSoft() const         { return false; }
00048     void print();
00049   };
00050 
00051   class PSoftUse : public Use {
00052     // a debugger-related use; doesn't prevent block elimination
00053    public:
00054     PSoftUse(NonTrivialNode* n) : Use(n) { }
00055     bool isSoft() const         { return true; }
00056     void print();
00057   };
00058 
00059   class DUInfo : public PrintableResourceObj {// represents PReg's defs/uses within BB
00060    public:
00061     PReg* reg;
00062     SList<Use*> uses;   // uses (in order of nodes within BB)
00063     SList<Def*> defs;
00064     DUInfo(PReg* r) { reg = r; }
00065 
00066     void getLiveRange(int& firstNodeID, int& lastNodeId);
00067     void propagateTo(BB* bb, const PReg* r, const Def* def, Use* use, const bool global);
00068     void propagateTo(BB* useBB, Use* use, const NonTrivialNode* fromNode, PReg* src,
00069                      NonTrivialNode* toNode, const bool global);
00070     void print_short();
00071     void print();
00072   };
00073 
00074   class DUInfoList;
00075 
00076   // a BBDUTable contains all defs and uses of a BB
00077   class BBDUTable : public PrintableResourceObj {       
00078    public:
00079     GrowableArray<DUInfo*>* info;               // one element per PReg used/defd
00080     BBDUTable() { info = NULL; }
00081 
00082     void print_short() { lprintf("BBDUTable %#lx", this); }
00083     void print();    
00084   };
00085 
00086   // a PRegBBIndex is an index into a particular element of a BBDUTable
00087   class PRegBBIndex : public PrintableResourceObj {
00088    public:
00089     BB* bb;             // BB containing some of PReg's defs/uses
00090     int index;          // index into BB's BBDUTable
00091 
00092     PRegBBIndex(BB* b, int i, PReg* pr) { Unused(pr);  bb = b; index = i; }
00093     void print_short();
00094     void print();
00095   };
00096 
00097   class CPInfo : public PrintableResourceObj {
00098     // keeps track of effects of copy propagation
00099    public:                      // (for debugging info)
00100     NonTrivialNode* def;        // eliminated definition
00101     PReg* r;                    // equivalent PReg
00102 
00103     CPInfo(NonTrivialNode* d, PReg* r1) { def = d; r = r1; }
00104     bool isConstant() const;
00105     oop  constant() const;
00106     void print();
00107    protected:
00108     CPInfo(NonTrivialNode* def);
00109     friend CPInfo* new_CPInfo(NonTrivialNode* def);
00110   };
00111 
00112   CPInfo* new_CPInfo(NonTrivialNode* def); // may return NULL if def isn't suitable
00113   void forAllDefsDo(const GrowableArray<PRegBBIndex*>* l, Closure<Def*>* f);
00114   void forAllUsesDo(const GrowableArray<PRegBBIndex*>* l, Closure<Use*>* f);
00115   void printDefsAndUses(const GrowableArray<PRegBBIndex*>* l);  // for debugging
00116 # endif

Generated on Mon Oct 9 13:37:08 2006 for Strongtalk VM by  doxygen 1.4.7