1 #ifndef STORAGE_H
   2 #define STORAGE_H
   3 
   4 #include "allocate.h"
   5 #include "lib.h"
   6 
   7 /*
   8  * The "storage" that underlies an incoming/outgoing pseudo. It's
   9  * basically the backing store for a pseudo, and may be a real hardware
  10  * register, a stack slot or a static symbol. Or nothing at all,
  11  * since some pseudos can just be recalculated on the fly.
  12  */
  13 enum storage_type {
  14         REG_UDEF,
  15         REG_REG,
  16         REG_STACK,
  17         REG_FRAME,
  18         REG_SYM,
  19         REG_ARG,
  20         REG_BAD,
  21 };
  22 
  23 enum inout_enum {
  24         STOR_IN,
  25         STOR_OUT
  26 };
  27 
  28 struct storage;
  29 DECLARE_PTR_LIST(storage_ptr_list, struct storage *);
  30 
  31 struct storage {
  32         enum storage_type type;
  33         int name;
  34         struct storage_ptr_list *users;
  35         union {
  36                 int regno;
  37                 int offset;
  38                 struct symbol *sym;
  39         };
  40 };
  41 
  42 DECLARE_PTR_LIST(storage_list, struct storage);
  43 
  44 struct storage_hash {
  45         struct basic_block *bb;
  46         pseudo_t pseudo;
  47         enum inout_enum inout;
  48         struct storage *storage;
  49         unsigned long flags;
  50 };
  51 
  52 DECLARE_PTR_LIST(storage_hash_list, struct storage_hash);
  53 
  54 extern struct storage_hash_list *gather_storage(struct basic_block *, enum inout_enum);
  55 extern void free_storage(void);
  56 extern const char *show_storage(struct storage *);
  57 extern void set_up_storage(struct entrypoint *);
  58 struct storage *lookup_storage(struct basic_block *, pseudo_t, enum inout_enum);
  59 void add_storage(struct storage *, struct basic_block *, pseudo_t, enum inout_enum);
  60 
  61 DECLARE_ALLOCATOR(storage);
  62 DECLARE_ALLOCATOR(storage_hash);
  63 
  64 static inline struct storage *alloc_storage(void)
  65 {
  66         return __alloc_storage(0);
  67 }
  68 
  69 static inline struct storage_hash *alloc_storage_hash(struct storage *s)
  70 {
  71         struct storage_hash *entry = __alloc_storage_hash(0);
  72         struct storage **usep = &entry->storage;
  73 
  74         *usep = s;
  75         add_ptr_list(&s->users, usep);
  76         return entry;
  77 }
  78 
  79 #endif /* STORAGE_H */