Expose storage allocators to users of the storage code.
[smatch.git] / storage.h
blob33c8655968dcfc047870991740740b2a9184b7a7
1 #ifndef STORAGE_H
2 #define STORAGE_H
4 /*
5 * The "storage" that underlies an incoming/outgoing pseudo. It's
6 * basically the backing store for a pseudo, and may be a real hw
7 * register, a stack slot or a static symbol. Or nothing at all,
8 * since some pseudos can just be recalculated on the fly.
9 */
10 enum storage_type {
11 REG_UDEF,
12 REG_REG,
13 REG_STACK,
14 REG_SYM,
15 REG_ARG,
16 REG_BAD,
19 enum inout_enum {
20 STOR_IN,
21 STOR_OUT
24 struct storage;
25 DECLARE_PTR_LIST(storage_ptr_list, struct storage *);
27 struct storage {
28 enum storage_type type;
29 pseudo_t pseudo;
30 struct storage_ptr_list *users;
31 union {
32 int regno;
33 int offset;
34 struct symbol *sym;
38 DECLARE_PTR_LIST(storage_list, struct storage);
40 struct storage_hash {
41 struct basic_block *bb;
42 pseudo_t pseudo;
43 enum inout_enum inout;
44 struct storage *storage;
47 DECLARE_PTR_LIST(storage_hash_list, struct storage_hash);
49 extern struct storage_hash_list *gather_storage(struct basic_block *, enum inout_enum);
50 extern void free_storage(void);
51 extern const char *show_storage(struct storage *);
52 extern void set_up_storage(struct entrypoint *);
54 DECLARE_ALLOCATOR(storage);
55 DECLARE_ALLOCATOR(storage_hash);
57 static inline struct storage *alloc_storage(void)
59 return __alloc_storage(0);
62 static inline struct storage_hash *alloc_storage_hash(struct storage *s)
64 struct storage_hash *entry = __alloc_storage_hash(0);
65 struct storage **usep = &entry->storage;
67 *usep = s;
68 add_ptr_list(&s->users, usep);
69 return entry;
72 #endif /* STORAGE_H */