mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-16 22:35:41 +00:00
Add a new option, --branch-delay-slot, intended for use by mc on
Estimated hours taken: 3 options: Add a new option, --branch-delay-slot, intended for use by mc on the basis of the configuattion script. It says whether the machine architecture has delays slots on branches. The setting of option should affect whether we set --optimize-delay-slots at -O2, but this doesn't work yet. hlds_goal: Add an extra field to hold follow_vars infromation to disjunctions, switches and if-then-elses. I intend to use this information to generate better code. *.m: Changes to accommodate the extra field.
This commit is contained in:
@@ -132,15 +132,16 @@ detect_switches_in_goal_1(Goal0 - GoalInfo, InstMap0, VarTypes, ModuleInfo,
|
||||
map(var, type), module_info, hlds__goal_expr).
|
||||
:- mode detect_switches_in_goal_2(in, in, in, in, in, out) is det.
|
||||
|
||||
detect_switches_in_goal_2(disj(Goals0), GoalInfo, InstMap0,
|
||||
detect_switches_in_goal_2(disj(Goals0, FV), GoalInfo, InstMap0,
|
||||
VarTypes, ModuleInfo, Goal) :-
|
||||
( Goals0 = [] ->
|
||||
Goal = disj([])
|
||||
Goal = disj([], FV)
|
||||
;
|
||||
goal_info_get_nonlocals(GoalInfo, NonLocals),
|
||||
set__to_sorted_list(NonLocals, NonLocalsList),
|
||||
detect_switches_in_disj(NonLocalsList, Goals0, GoalInfo,
|
||||
InstMap0, VarTypes, NonLocalsList, ModuleInfo, [], Goal)
|
||||
FV, InstMap0, VarTypes, NonLocalsList, ModuleInfo,
|
||||
[], Goal)
|
||||
).
|
||||
|
||||
detect_switches_in_goal_2(conj(Goals0), _GoalInfo, InstMap0,
|
||||
@@ -151,9 +152,9 @@ detect_switches_in_goal_2(not(Goal0), _GoalInfo, InstMap0,
|
||||
VarTypes, ModuleInfo, not(Goal)) :-
|
||||
detect_switches_in_goal(Goal0, InstMap0, VarTypes, ModuleInfo, Goal).
|
||||
|
||||
detect_switches_in_goal_2(if_then_else(Vars, Cond0, Then0, Else0), _GoalInfo,
|
||||
InstMap0, VarTypes, ModuleInfo,
|
||||
if_then_else(Vars, Cond, Then, Else)) :-
|
||||
detect_switches_in_goal_2(if_then_else(Vars, Cond0, Then0, Else0, FV),
|
||||
_GoalInfo, InstMap0, VarTypes, ModuleInfo,
|
||||
if_then_else(Vars, Cond, Then, Else, FV)) :-
|
||||
detect_switches_in_goal_1(Cond0, InstMap0, VarTypes, ModuleInfo, Cond,
|
||||
InstMap1),
|
||||
detect_switches_in_goal(Then0, InstMap1, VarTypes, ModuleInfo, Then),
|
||||
@@ -176,8 +177,8 @@ detect_switches_in_goal_2(unify(A,RHS0,C,D,E), __GoalInfo, InstMap0,
|
||||
RHS = RHS0
|
||||
).
|
||||
|
||||
detect_switches_in_goal_2(switch(Var, CanFail, Cases0), _, InstMap,
|
||||
VarTypes, ModuleInfo, switch(Var, CanFail, Cases)) :-
|
||||
detect_switches_in_goal_2(switch(Var, CanFail, Cases0, FV), _, InstMap,
|
||||
VarTypes, ModuleInfo, switch(Var, CanFail, Cases, FV)) :-
|
||||
detect_switches_in_cases(Cases0, InstMap, VarTypes, ModuleInfo, Cases).
|
||||
|
||||
detect_switches_in_goal_2(pragma_c_code(A,B,C,D,E), _, _, _, _,
|
||||
@@ -201,11 +202,11 @@ detect_switches_in_goal_2(pragma_c_code(A,B,C,D,E), _, _, _, _,
|
||||
:- type again ---> again(var, list(hlds__goal), sorted_case_list).
|
||||
|
||||
:- pred detect_switches_in_disj(list(var), list(hlds__goal), hlds__goal_info,
|
||||
instmap, map(var, type), list(var), module_info, list(again),
|
||||
hlds__goal_expr).
|
||||
:- mode detect_switches_in_disj(in, in, in, in, in, in, in, in, out) is det.
|
||||
follow_vars, instmap, map(var, type), list(var), module_info,
|
||||
list(again), hlds__goal_expr).
|
||||
:- mode detect_switches_in_disj(in, in, in, in, in, in, in, in, in, out) is det.
|
||||
|
||||
detect_switches_in_disj([Var | Vars], Goals0, GoalInfo, InstMap,
|
||||
detect_switches_in_disj([Var | Vars], Goals0, GoalInfo, FV, InstMap,
|
||||
VarTypes, AllVars, ModuleInfo, Again0, Goal) :-
|
||||
% can we do at least a partial switch on this variable?
|
||||
(
|
||||
@@ -218,18 +219,18 @@ detect_switches_in_disj([Var | Vars], Goals0, GoalInfo, InstMap,
|
||||
Left = []
|
||||
->
|
||||
cases_to_switch(CasesList, Var, VarTypes, GoalInfo,
|
||||
InstMap, ModuleInfo, Goal)
|
||||
FV, InstMap, ModuleInfo, Goal)
|
||||
;
|
||||
detect_switches_in_disj(Vars, Goals0, GoalInfo,
|
||||
InstMap, VarTypes, AllVars, ModuleInfo,
|
||||
FV, InstMap, VarTypes, AllVars, ModuleInfo,
|
||||
[again(Var, Left, CasesList) | Again0], Goal)
|
||||
)
|
||||
;
|
||||
detect_switches_in_disj(Vars, Goals0, GoalInfo, InstMap,
|
||||
detect_switches_in_disj(Vars, Goals0, GoalInfo, FV, InstMap,
|
||||
VarTypes, AllVars, ModuleInfo, Again0, Goal)
|
||||
).
|
||||
detect_switches_in_disj([], Goals0, GoalInfo, InstMap,
|
||||
VarTypes, AllVars, ModuleInfo, AgainList0, disj(Goals)) :-
|
||||
detect_switches_in_disj([], Goals0, GoalInfo, FV, InstMap,
|
||||
VarTypes, AllVars, ModuleInfo, AgainList0, disj(Goals, FV)) :-
|
||||
(
|
||||
AgainList0 = [],
|
||||
detect_sub_switches_in_disj(Goals0, InstMap, VarTypes,
|
||||
@@ -238,9 +239,9 @@ detect_switches_in_disj([], Goals0, GoalInfo, InstMap,
|
||||
AgainList0 = [Again | AgainList1],
|
||||
select_best_switch(AgainList1, Again, BestAgain),
|
||||
BestAgain = again(Var, Left0, CasesList),
|
||||
cases_to_switch(CasesList, Var, VarTypes, GoalInfo, InstMap,
|
||||
cases_to_switch(CasesList, Var, VarTypes, GoalInfo, FV, InstMap,
|
||||
ModuleInfo, SwitchGoal),
|
||||
detect_switches_in_disj(AllVars, Left0, GoalInfo, InstMap,
|
||||
detect_switches_in_disj(AllVars, Left0, GoalInfo, FV, InstMap,
|
||||
VarTypes, AllVars, ModuleInfo, [], Left),
|
||||
goal_to_disj_list(Left - GoalInfo, LeftList),
|
||||
Goals = [SwitchGoal - GoalInfo | LeftList]
|
||||
@@ -438,11 +439,10 @@ interpret_unify(_X, lambda_goal(_LambdaVars, _Modes, _Det, _Goal),
|
||||
Subst = Subst0.
|
||||
|
||||
:- pred cases_to_switch(sorted_case_list, var, map(var, type), hlds__goal_info,
|
||||
instmap, module_info, hlds__goal_expr).
|
||||
% :- mode cases_to_switch(di, in, in, in, in, in, uo) is det.
|
||||
:- mode cases_to_switch(in, in, in, in, in, in, out) is det.
|
||||
follow_vars, instmap, module_info, hlds__goal_expr).
|
||||
:- mode cases_to_switch(in, in, in, in, in, in, in, out) is det.
|
||||
|
||||
cases_to_switch(CasesList, Var, VarTypes, GoalInfo, InstMap, ModuleInfo,
|
||||
cases_to_switch(CasesList, Var, VarTypes, GoalInfo, FV, InstMap, ModuleInfo,
|
||||
Goal) :-
|
||||
instmap_lookup_var(InstMap, Var, VarInst),
|
||||
( inst_is_bound_to_functors(ModuleInfo, VarInst, Functors) ->
|
||||
@@ -465,7 +465,7 @@ cases_to_switch(CasesList, Var, VarTypes, GoalInfo, InstMap, ModuleInfo,
|
||||
),
|
||||
fix_case_list(CasesList1, GoalInfo, Cases0),
|
||||
detect_switches_in_cases(Cases0, InstMap, VarTypes, ModuleInfo, Cases),
|
||||
Goal = switch(Var, CanFail, Cases).
|
||||
Goal = switch(Var, CanFail, Cases, FV).
|
||||
|
||||
:- pred delete_unreachable_cases(sorted_case_list, list(cons_id),
|
||||
sorted_case_list).
|
||||
|
||||
Reference in New Issue
Block a user