1.1 --- a/docs/optimisations.txt Sun Sep 07 00:35:03 2008 +0200
1.2 +++ b/docs/optimisations.txt Sun Sep 07 00:47:20 2008 +0200
1.3 @@ -2,44 +2,38 @@
1.4 ------------ ------------------------
1.5
1.6 constant_storage value instruction references a constant;
1.7 - storage instruction references a constant;
1.8 - remove both instructions (currently a single merged instruction)
1.9 +(elimination) storage instruction references a constant;
1.10 + remove both instructions (currently a single
1.11 + merged instruction)
1.12
1.13 source_storage source instruction is a simple input operation;
1.14 - source instruction is the last instruction;
1.15 +(elimination) source instruction is the last instruction;
1.16 remove the source instruction
1.17
1.18 known_target value instruction references a constant;
1.19 - target and context are provided (no instructions removed)
1.20 +(guidance) target and context are provided (no instructions removed)
1.21
1.22 self_access value instruction references "self" in a method;
1.23 - specified attribute name always has the same position;
1.24 +(guidance) specified attribute name always has the same position;
1.25 appropriate instruction generated
1.26
1.27 temp_storage value instruction is a simple input operation;
1.28 - value instruction is the last instruction;
1.29 - remove the value instruction, provide the value
1.30 +(elimination) value instruction is the last instruction;
1.31 +(guidance) remove the value instruction, provide the value
1.32 instruction in place of a temporary storage
1.33 reference
1.34
1.35 load_operations value instruction is a simple input operation;
1.36 - value instruction is the last instruction;
1.37 +(merge) value instruction is the last instruction;
1.38 current instruction uses simple input;
1.39 remove the value instruction, make the value
1.40 instruction the input to the current instruction
1.41
1.42 no_operations input to the current instruction loads from the
1.43 - destination of the current instruction;
1.44 +(elimination) destination of the current instruction;
1.45 omit the current instruction
1.46
1.47 unused_results value instruction is a simple input operation;
1.48 - value instruction is the final instruction of a
1.49 +(elimination) value instruction is the final instruction of a
1.50 discarded expression;
1.51 remove the value instruction
1.52 -
1.53 -superfluous_temp_operations source instruction writes to temporary storage;
1.54 - current instruction reads from the same storage;
1.55 - source instruction is the last instruction;
1.56 - remove the source instruction, make the current
1.57 - instruction use the input of the source
1.58 - instruction
2.1 --- a/micropython/ast.py Sun Sep 07 00:35:03 2008 +0200
2.2 +++ b/micropython/ast.py Sun Sep 07 00:47:20 2008 +0200
2.3 @@ -31,8 +31,7 @@
2.4
2.5 supported_optimisations = [
2.6 "constant_storage", "source_storage", "known_target", "self_access",
2.7 - "temp_storage", "load_operations", "no_operations", "unused_results",
2.8 - "superfluous_temp_operations"
2.9 + "temp_storage", "load_operations", "no_operations", "unused_results"
2.10 ]
2.11
2.12 def __init__(self, translation, optimisations=None):
2.13 @@ -69,9 +68,6 @@
2.14 def should_optimise_away_no_operations(self):
2.15 return "no_operations" in self.optimisations
2.16
2.17 - def should_optimise_away_superfluous_temp_operations(self):
2.18 - return "superfluous_temp_operations" in self.optimisations
2.19 -
2.20 def should_optimise_unused_results(self):
2.21 return "unused_results" in self.optimisations
2.22
2.23 @@ -132,18 +128,6 @@
2.24 isinstance(instruction.input, LoadResult) and isinstance(instruction, StoreResult)
2.25 )
2.26
2.27 - def is_superfluous_temp_operation(self, instruction):
2.28 -
2.29 - """
2.30 - Return whether 'instruction' merely loads its input from a recent
2.31 - temporary storage operation.
2.32 - """
2.33 -
2.34 - return (
2.35 - isinstance(instruction.source, LoadTemp) and isinstance(self.translation.active_source, StoreTemp) and
2.36 - instruction.source.attr == self.translation.active_source.attr
2.37 - )
2.38 -
2.39 def is_input(self, instruction):
2.40
2.41 "Return whether 'instruction' provides an input."
2.42 @@ -377,20 +361,6 @@
2.43 else:
2.44 return 0
2.45
2.46 - def optimise_away_superfluous_temp_operations(self, instruction):
2.47 -
2.48 - """
2.49 - Optimise away operations which just store temporary values for
2.50 - immediate retrieval.
2.51 - """
2.52 -
2.53 - if self.should_optimise_away_superfluous_temp_operations() and \
2.54 - self.is_superfluous_temp_operation(instruction) and \
2.55 - self.translation.active_source == self.translation.active:
2.56 -
2.57 - instruction.source = self.translation.active_source.input
2.58 - self.translation.remove_op()
2.59 -
2.60 def optimise_unused_results(self):
2.61
2.62 "Discard results which will not be used."
2.63 @@ -701,7 +671,6 @@
2.64 self.optimiser.optimise_load_operations(op)
2.65 if self.optimiser.optimise_away_no_operations(op):
2.66 return
2.67 - self.optimiser.optimise_away_superfluous_temp_operations(op)
2.68
2.69 self.code.append(op)
2.70 self.active = op