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