1*e4b17023SJohn Marino /* Define regsets. 2*e4b17023SJohn Marino Copyright (C) 1987, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 3*e4b17023SJohn Marino 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. 4*e4b17023SJohn Marino 5*e4b17023SJohn Marino This file is part of GCC. 6*e4b17023SJohn Marino 7*e4b17023SJohn Marino GCC is free software; you can redistribute it and/or modify it under 8*e4b17023SJohn Marino the terms of the GNU General Public License as published by the Free 9*e4b17023SJohn Marino Software Foundation; either version 3, or (at your option) any later 10*e4b17023SJohn Marino version. 11*e4b17023SJohn Marino 12*e4b17023SJohn Marino GCC is distributed in the hope that it will be useful, but WITHOUT ANY 13*e4b17023SJohn Marino WARRANTY; without even the implied warranty of MERCHANTABILITY or 14*e4b17023SJohn Marino FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15*e4b17023SJohn Marino for more details. 16*e4b17023SJohn Marino 17*e4b17023SJohn Marino You should have received a copy of the GNU General Public License 18*e4b17023SJohn Marino along with GCC; see the file COPYING3. If not see 19*e4b17023SJohn Marino <http://www.gnu.org/licenses/>. */ 20*e4b17023SJohn Marino 21*e4b17023SJohn Marino #ifndef GCC_REGSET_H 22*e4b17023SJohn Marino #define GCC_REGSET_H 23*e4b17023SJohn Marino 24*e4b17023SJohn Marino /* TODO: regset is just a bitmap in its implementation. The compiler does 25*e4b17023SJohn Marino not consistently use one or the other, i.e. sometimes variables are 26*e4b17023SJohn Marino declared as bitmap but they are actually regsets and regset accessors 27*e4b17023SJohn Marino are used, and vice versa, or mixed (see e.g. spilled_regs in IRA). 28*e4b17023SJohn Marino 29*e4b17023SJohn Marino This should be cleaned up, either by just dropping the regset type, or 30*e4b17023SJohn Marino by changing all bitmaps that are really regsets to the regset type. For 31*e4b17023SJohn Marino the latter option, a good start would be to change everything allocated 32*e4b17023SJohn Marino on the reg_obstack to regset. */ 33*e4b17023SJohn Marino 34*e4b17023SJohn Marino #include "bitmap.h" /* For bitmap_iterator. */ 35*e4b17023SJohn Marino #include "hard-reg-set.h" 36*e4b17023SJohn Marino 37*e4b17023SJohn Marino /* Head of register set linked list. */ 38*e4b17023SJohn Marino typedef bitmap_head regset_head; 39*e4b17023SJohn Marino 40*e4b17023SJohn Marino /* A pointer to a regset_head. */ 41*e4b17023SJohn Marino typedef bitmap regset; 42*e4b17023SJohn Marino 43*e4b17023SJohn Marino /* Allocate a register set with oballoc. */ 44*e4b17023SJohn Marino #define ALLOC_REG_SET(OBSTACK) BITMAP_ALLOC (OBSTACK) 45*e4b17023SJohn Marino 46*e4b17023SJohn Marino /* Do any cleanup needed on a regset when it is no longer used. */ 47*e4b17023SJohn Marino #define FREE_REG_SET(REGSET) BITMAP_FREE (REGSET) 48*e4b17023SJohn Marino 49*e4b17023SJohn Marino /* Initialize a new regset. */ 50*e4b17023SJohn Marino #define INIT_REG_SET(HEAD) bitmap_initialize (HEAD, ®_obstack) 51*e4b17023SJohn Marino 52*e4b17023SJohn Marino /* Clear a register set by freeing up the linked list. */ 53*e4b17023SJohn Marino #define CLEAR_REG_SET(HEAD) bitmap_clear (HEAD) 54*e4b17023SJohn Marino 55*e4b17023SJohn Marino /* Copy a register set to another register set. */ 56*e4b17023SJohn Marino #define COPY_REG_SET(TO, FROM) bitmap_copy (TO, FROM) 57*e4b17023SJohn Marino 58*e4b17023SJohn Marino /* Compare two register sets. */ 59*e4b17023SJohn Marino #define REG_SET_EQUAL_P(A, B) bitmap_equal_p (A, B) 60*e4b17023SJohn Marino 61*e4b17023SJohn Marino /* `and' a register set with a second register set. */ 62*e4b17023SJohn Marino #define AND_REG_SET(TO, FROM) bitmap_and_into (TO, FROM) 63*e4b17023SJohn Marino 64*e4b17023SJohn Marino /* `and' the complement of a register set with a register set. */ 65*e4b17023SJohn Marino #define AND_COMPL_REG_SET(TO, FROM) bitmap_and_compl_into (TO, FROM) 66*e4b17023SJohn Marino 67*e4b17023SJohn Marino /* Inclusive or a register set with a second register set. */ 68*e4b17023SJohn Marino #define IOR_REG_SET(TO, FROM) bitmap_ior_into (TO, FROM) 69*e4b17023SJohn Marino 70*e4b17023SJohn Marino /* Exclusive or a register set with a second register set. */ 71*e4b17023SJohn Marino #define XOR_REG_SET(TO, FROM) bitmap_xor_into (TO, FROM) 72*e4b17023SJohn Marino 73*e4b17023SJohn Marino /* Or into TO the register set FROM1 `and'ed with the complement of FROM2. */ 74*e4b17023SJohn Marino #define IOR_AND_COMPL_REG_SET(TO, FROM1, FROM2) \ 75*e4b17023SJohn Marino bitmap_ior_and_compl_into (TO, FROM1, FROM2) 76*e4b17023SJohn Marino 77*e4b17023SJohn Marino /* Clear a single register in a register set. */ 78*e4b17023SJohn Marino #define CLEAR_REGNO_REG_SET(HEAD, REG) bitmap_clear_bit (HEAD, REG) 79*e4b17023SJohn Marino 80*e4b17023SJohn Marino /* Set a single register in a register set. */ 81*e4b17023SJohn Marino #define SET_REGNO_REG_SET(HEAD, REG) bitmap_set_bit (HEAD, REG) 82*e4b17023SJohn Marino 83*e4b17023SJohn Marino /* Return true if a register is set in a register set. */ 84*e4b17023SJohn Marino #define REGNO_REG_SET_P(TO, REG) bitmap_bit_p (TO, REG) 85*e4b17023SJohn Marino 86*e4b17023SJohn Marino /* Copy the hard registers in a register set to the hard register set. */ 87*e4b17023SJohn Marino extern void reg_set_to_hard_reg_set (HARD_REG_SET *, const_bitmap); 88*e4b17023SJohn Marino #define REG_SET_TO_HARD_REG_SET(TO, FROM) \ 89*e4b17023SJohn Marino do { \ 90*e4b17023SJohn Marino CLEAR_HARD_REG_SET (TO); \ 91*e4b17023SJohn Marino reg_set_to_hard_reg_set (&TO, FROM); \ 92*e4b17023SJohn Marino } while (0) 93*e4b17023SJohn Marino 94*e4b17023SJohn Marino typedef bitmap_iterator reg_set_iterator; 95*e4b17023SJohn Marino 96*e4b17023SJohn Marino /* Loop over all registers in REGSET, starting with MIN, setting REGNUM to the 97*e4b17023SJohn Marino register number and executing CODE for all registers that are set. */ 98*e4b17023SJohn Marino #define EXECUTE_IF_SET_IN_REG_SET(REGSET, MIN, REGNUM, RSI) \ 99*e4b17023SJohn Marino EXECUTE_IF_SET_IN_BITMAP (REGSET, MIN, REGNUM, RSI) 100*e4b17023SJohn Marino 101*e4b17023SJohn Marino /* Loop over all registers in REGSET1 and REGSET2, starting with MIN, setting 102*e4b17023SJohn Marino REGNUM to the register number and executing CODE for all registers that are 103*e4b17023SJohn Marino set in the first regset and not set in the second. */ 104*e4b17023SJohn Marino #define EXECUTE_IF_AND_COMPL_IN_REG_SET(REGSET1, REGSET2, MIN, REGNUM, RSI) \ 105*e4b17023SJohn Marino EXECUTE_IF_AND_COMPL_IN_BITMAP (REGSET1, REGSET2, MIN, REGNUM, RSI) 106*e4b17023SJohn Marino 107*e4b17023SJohn Marino /* Loop over all registers in REGSET1 and REGSET2, starting with MIN, setting 108*e4b17023SJohn Marino REGNUM to the register number and executing CODE for all registers that are 109*e4b17023SJohn Marino set in both regsets. */ 110*e4b17023SJohn Marino #define EXECUTE_IF_AND_IN_REG_SET(REGSET1, REGSET2, MIN, REGNUM, RSI) \ 111*e4b17023SJohn Marino EXECUTE_IF_AND_IN_BITMAP (REGSET1, REGSET2, MIN, REGNUM, RSI) \ 112*e4b17023SJohn Marino 113*e4b17023SJohn Marino /* Same information as REGS_INVALIDATED_BY_CALL but in regset form to be used 114*e4b17023SJohn Marino in dataflow more conveniently. */ 115*e4b17023SJohn Marino 116*e4b17023SJohn Marino extern regset regs_invalidated_by_call_regset; 117*e4b17023SJohn Marino 118*e4b17023SJohn Marino /* Same information as FIXED_REG_SET but in regset form. */ 119*e4b17023SJohn Marino extern regset fixed_reg_set_regset; 120*e4b17023SJohn Marino 121*e4b17023SJohn Marino /* An obstack for regsets. */ 122*e4b17023SJohn Marino extern bitmap_obstack reg_obstack; 123*e4b17023SJohn Marino 124*e4b17023SJohn Marino /* In cfg.c */ 125*e4b17023SJohn Marino extern void dump_regset (regset, FILE *); 126*e4b17023SJohn Marino extern void debug_regset (regset); 127*e4b17023SJohn Marino 128*e4b17023SJohn Marino #endif /* GCC_REGSET_H */ 129