8 * Basic helper routine descriptions for 'sparse'.
10 * Copyright (C) 2003 Transmeta Corp.
14 * Licensed under the Open Software License version 1.1
20 extern int verbose
, optimize
, optimize_size
, preprocessing
;
21 extern int die_if_error
;
22 extern int repeat_phase
, merge_phi_sources
;
23 extern int gcc_major
, gcc_minor
, gcc_patchlevel
;
25 extern unsigned int hexval(unsigned int c
);
37 struct cmdline_include
{
42 extern struct cmdline_include cmdline_include
[];
43 extern int cmdline_include_nr
;
57 DECLARE_PTR_LIST(symbol_list
, struct symbol
);
58 DECLARE_PTR_LIST(statement_list
, struct statement
);
59 DECLARE_PTR_LIST(expression_list
, struct expression
);
60 DECLARE_PTR_LIST(basic_block_list
, struct basic_block
);
61 DECLARE_PTR_LIST(instruction_list
, struct instruction
);
62 DECLARE_PTR_LIST(multijmp_list
, struct multijmp
);
63 DECLARE_PTR_LIST(pseudo_list
, struct pseudo
);
64 DECLARE_PTR_LIST(string_list
, char);
66 typedef struct pseudo
*pseudo_t
;
68 struct token
*skip_to(struct token
*, int);
69 struct token
*expect(struct token
*, int, const char *);
71 #define FORMAT_ATTR(pos) __attribute__ ((__format__ (__printf__, pos, pos+1)))
72 #define NORETURN_ATTR __attribute__ ((__noreturn__))
73 #define SENTINEL_ATTR __attribute__ ((__sentinel__))
75 #define FORMAT_ATTR(pos)
79 extern void die(const char *, ...) FORMAT_ATTR(1) NORETURN_ATTR
;
80 extern void info(struct position
, const char *, ...) FORMAT_ATTR(2);
81 extern void warning(struct position
, const char *, ...) FORMAT_ATTR(2);
82 extern void sparse_error(struct position
, const char *, ...) FORMAT_ATTR(2);
83 extern void error_die(struct position
, const char *, ...) FORMAT_ATTR(2) NORETURN_ATTR
;
84 extern void expression_error(struct expression
*, const char *, ...) FORMAT_ATTR(2);
86 extern void add_pre_buffer(const char *fmt
, ...) FORMAT_ATTR(1);
88 extern int preprocess_only
;
90 extern int Waddress_space
;
92 extern int Wcast_to_as
;
93 extern int Wcast_truncate
;
96 extern int Wdefault_bitfield_sign
;
98 extern int Wenum_mismatch
;
99 extern int Wnon_pointer_null
;
100 extern int Wold_initializer
;
101 extern int Wone_bit_signed_bitfield
;
102 extern int Wparen_string
;
103 extern int Wptr_subtraction_blows
;
104 extern int Wreturn_void
;
106 extern int Wtransparent_union
;
107 extern int Wtypesign
;
109 extern int Wuninitialized
;
110 extern int Wdeclarationafterstatement
;
112 extern int dbg_entry
;
115 extern void declare_builtin_functions(void);
116 extern void create_builtin_stream(void);
117 extern struct symbol_list
*sparse_initialize(int argc
, char **argv
, struct string_list
**files
);
118 extern struct symbol_list
*__sparse(char *filename
);
119 extern struct symbol_list
*sparse_keep_tokens(char *filename
);
120 extern struct symbol_list
*sparse(char *filename
);
122 static inline int symbol_list_size(struct symbol_list
*list
)
124 return ptr_list_size((struct ptr_list
*)(list
));
127 static inline int statement_list_size(struct statement_list
*list
)
129 return ptr_list_size((struct ptr_list
*)(list
));
132 static inline int expression_list_size(struct expression_list
*list
)
134 return ptr_list_size((struct ptr_list
*)(list
));
137 static inline int instruction_list_size(struct instruction_list
*list
)
139 return ptr_list_size((struct ptr_list
*)(list
));
142 static inline int pseudo_list_size(struct pseudo_list
*list
)
144 return ptr_list_size((struct ptr_list
*)(list
));
147 static inline int bb_list_size(struct basic_block_list
*list
)
149 return ptr_list_size((struct ptr_list
*)(list
));
152 static inline void free_instruction_list(struct instruction_list
**head
)
154 free_ptr_list((struct ptr_list
**)head
);
157 static inline struct instruction
* delete_last_instruction(struct instruction_list
**head
)
159 return undo_ptr_list_last((struct ptr_list
**)head
);
162 static inline struct basic_block
* delete_last_basic_block(struct basic_block_list
**head
)
164 return delete_ptr_list_last((struct ptr_list
**)head
);
167 static inline struct basic_block
*first_basic_block(struct basic_block_list
*head
)
169 return first_ptr_list((struct ptr_list
*)head
);
171 static inline struct instruction
*last_instruction(struct instruction_list
*head
)
173 return last_ptr_list((struct ptr_list
*)head
);
176 static inline struct instruction
*first_instruction(struct instruction_list
*head
)
178 return first_ptr_list((struct ptr_list
*)head
);
181 static inline pseudo_t
first_pseudo(struct pseudo_list
*head
)
183 return first_ptr_list((struct ptr_list
*)head
);
186 static inline void concat_symbol_list(struct symbol_list
*from
, struct symbol_list
**to
)
188 concat_ptr_list((struct ptr_list
*)from
, (struct ptr_list
**)to
);
191 static inline void concat_basic_block_list(struct basic_block_list
*from
, struct basic_block_list
**to
)
193 concat_ptr_list((struct ptr_list
*)from
, (struct ptr_list
**)to
);
196 static inline void concat_instruction_list(struct instruction_list
*from
, struct instruction_list
**to
)
198 concat_ptr_list((struct ptr_list
*)from
, (struct ptr_list
**)to
);
201 static inline void add_symbol(struct symbol_list
**list
, struct symbol
*sym
)
203 add_ptr_list(list
, sym
);
206 static inline void add_statement(struct statement_list
**list
, struct statement
*stmt
)
208 add_ptr_list(list
, stmt
);
211 static inline void add_expression(struct expression_list
**list
, struct expression
*expr
)
213 add_ptr_list(list
, expr
);
216 #define hashval(x) ((unsigned long)(x))