1 /* Copyright 1994, LongView Technologies L.L.C. $Revision: 1.5 $ */
2 /* Copyright (c) 2006, Sun Microsystems, Inc.
5 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
6 following conditions are met:
8 * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
10 disclaimer in the documentation and/or other materials provided with the distribution.
11 * Neither the name of Sun Microsystems nor the names of its contributors may be used to endorse or promote products derived
12 from this software without specific prior written permission.
14 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
15 NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
16 THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
17 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
18 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
19 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
24 // A RegisterMask tells the scavenger which registers / stack locs are
25 // live. (One bit per location.)
27 # ifdef DELTA_COMPILER_unused
29 inline RegisterMask
& allocate(RegisterMask
& s1
, RegisterMask s2
) {
34 inline bool isAllocated(RegisterMask s
, Location l
) {
36 // return isSet(s, l);
40 inline RegisterMask
& deallocate(RegisterMask
& s1
, RegisterMask s2
) {
45 inline RegisterMask
& allocateRegister(RegisterMask
& s
, Location r
) {
47 // if (isRegister(r)) setNth(s, r);
51 inline RegisterMask
& deallocateRegister(RegisterMask
& s1
, Location r
) {
53 // assert(isRegister(r), "not a register");
58 Location
pick(RegisterMask
& alloc
, RegisterMask mask
= ~0);
60 void printRegister(Location r
);
61 void printAllocated(RegisterMask r
);
63 // like a RegisterMask, but has arbitrary length (i.e., bits for
64 // stack temps and regs)
66 class LongRegisterMask
: ResourceObj
{
70 void allocate (Location l
);
71 void deallocate(Location l
);
72 bool isAllocated(Location l
);
73 RegisterMask
regs(); // returns mask for registers
78 friend int findFirstUnused(LongRegisterMask
** masks
, int len
,
82 Location
findFirstUnusedTemp(LongRegisterMask
** masks
, int len
);