1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
|
Simplification steps:
Scope/type/declaration related:
* simplify_name_structunionenum:
All structs/unions/enums get names.
* simplify_split_structunion_decl:
A declaration using type specifier defining a struct/union
might be converted into one typedef declaration of the
struct/union and a declaration using the newly defined
struct/union.
Works only if struct/union has a name.
* simplify_split_vardecl_init:
"auto" and "register" declarations using an initializer
might be splitted into a declaration without an initializer
and a new statement assigning the initial value to the
variable.
Works only in functions and blocks within functions and
only if variable is not declared "const".
* simplify_split_vardecl_list:
Declarations containing two or more declarators
might be splitted into separate declarations with
only one declarator each.
Works only if type specifier is simple type, user type
or struct/union without declarations.
* simplify_remove_empty_declarations:
Declarations containing no declarators might be deleted.
Works only if type specifier is simple type or user type.
* simplify_enum_expr:
Add initializers to all enumerators not having one.
* Enum definitions might be converted into constant
definitions and int variables.
* simplify_merge_declarations_of_blocks:
Register and auto variable definitions in sub-scopes
of functions might be moved to function scope. Same
with type definitions.
Rename variable/type in old scope and its sub-scopes.
Works only if variables has no initializers and type
is visible in outer scope, too.
* Static variables from functions and blocks within
functions might be moved to top scope if initializer
is known constant.
Rename variables in old scope and its sub-scopes.
* Type definitions from functions and blocks within
functions might be moved to top scope.
Rename type in old scope and its sub-scopes.
* A declaration using a complex declarator might be
changed into a typedef declaration defining the
type and a variable declaration using the newly defined
type. The type specifier must be a simple one.
* Register and auto variable definitions with initializers
in functions and its sub-scopes might be splitted into
variable definitions without initializers and statements
containing assignment of initializer to variable.
* Type definitions using a simple type specifier and
a simple declarator might be removed.
Change places where the declared type is used to use
the simple type specifier directly.
Function related:
* For loops might be translated into goto and if-goto
statements.
Change continue and break statements accordingly
using goto statements.
* While loops might be translated into goto and if-goto
statements.
Change continue and break statements accordingly
using goto statements.
* Do-while loops might be translated into goto and if-goto
statements.
Change continue and break statements accordingly
using goto statements.
* Switch statements might be translated into simple
switch statements containing only a list of case-goto
and default-goto statements.
Change break statements accordingly using goto statements.
* If-else statements might be translated into goto
and if-goto statements.
* simplify_rename_labels:
Rename user-named labels by labels with unique name.
* simplify_remove_labels:
Remove labels with no corresponding goto.
If consecutive labels exist redirect all gotos to first
label to go to second label and remove first label.
* simplify_goto:
Goto statements with goto-statement as target might
be replace by goto statement to second target.
Goto or if-then-goto statements with the next statement as
target might be removed or converted into null statements.
(Keep epression of if-then-goto statements!)
An if-goto statement jumping over a following goto statement
might be replaced by a single if-goto statement with a negated
condition.
* simplify_remove_unreachable_stmts:
Unreachable code might be removed.
* simplify_returns:
Return statements not at the end of a function
might be replaced by variable assignment and a
goto statement to end of function.
* simplify_rename_labels:
An user-defined label might be replaced by a temporary one to
omit "redefined" errors.
Change corresponding goto statements accordingly.
* simplify_split_exprs:
Expressions containing sub-expressions might be
translated into several statements with expressions
using temporary variables.
Comma separated expressions might be translated
into several statements containing one expression
each.
Expressions related:
* simplify_constant_folding:
sizeof expressions might be replaced by a constant.
Operations only using constants as operands might be replaced
by only one constant.
* simplify_split_exprs:
Replace complex expressions by expressions only using one
operator. Use temporary variables.
Replace pre-dec/inc operator expressions by first
decrementing/incrementing the variable before using it
in an expression.
Replace post-dec/inc operator expressions by first
assigning the current value to a temporary variable and
then decrementing/incrementing the original variable. Use
the temporary variable in the expression instead of the
original one.
Move up commas in expressions.
* Expressions with implicit type conversion should
be replaced by expressions using explicit type
conversions.
|