mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-15 22:03:26 +00:00
A bunch of changes required to fix problems in code generation for
Estimated hours taken: 24 A bunch of changes required to fix problems in code generation for model_det and model_semi disjunctions. simplify.m: Don't convert all model_det and model_semi disjunctions into if-then-elses, because that doesn't work if the disjuncts have output variables, which can happen (e.g. with cc_nondet disjunctions) disj_gen.m: Fix a bug in the code generation for semidet disjunctions: don't forget to jump to the end of the disjunction after each disjunct! liveness.m, live_vars.m, store_alloc.m, disj_gen.m: Treat backtracking in model_det and model_semi disjunctions as shallow backtracking rather than deep backtracking. This means that rather than pushing all live variables onto the stack at the start of a model_det/semi disjunction, and using the nondet_lives to keep track of them, we instead treat these disjunctions a bit more like an if-then-else and use the ordinary liveness/deadness to keep track of them. code_aux.m: Change code_aux__pre_goal_update so that it only applies the post-deaths if the goal is atomic. Applying the *post*-deaths to the set of live variables in the *pre*-goal update only makes sense for atomic goals. (I think previously we only ever generated post-deaths for atomic goals, but now we generate them also for goals inside model_det or model_semi disjunctions.) code_gen.pp, middle_rec.m: Pass an is-atomic flag to code_aux__pre_goal_update. hlds_goal.m: Add some comments. goal_util.m: Fix bugs in goal_util__name_apart_goalinfo. It wasn't applying the substitution to all the appropriate fields. code_exprn.m: Improve the error message for one of the internal errors. hlds_out.m: Print the stack slot allocations in the HLDS dump again.
This commit is contained in:
@@ -51,6 +51,7 @@ store_alloc_in_proc(ProcInfo0, ModuleInfo, ProcInfo) :-
|
||||
|
||||
store_alloc_in_goal(Goal0 - GoalInfo0, Liveness0, ModuleInfo,
|
||||
Goal - GoalInfo0, Liveness) :-
|
||||
goal_info_get_code_model(GoalInfo0, CodeModel),
|
||||
goal_info_pre_delta_liveness(GoalInfo0, PreDelta),
|
||||
PreDelta = PreBirths - PreDeaths,
|
||||
goal_info_post_delta_liveness(GoalInfo0, PostDelta),
|
||||
@@ -68,14 +69,18 @@ store_alloc_in_goal(Goal0 - GoalInfo0, Liveness0, ModuleInfo,
|
||||
(
|
||||
Goal1 = disj(Disjuncts, FollowVars)
|
||||
->
|
||||
% For disjunctions, we only want to allocate registers
|
||||
% For nondet disjunctions, we only want to allocate registers
|
||||
% for the variables that are generated by the disjunction
|
||||
% (the outputs). For the inputs, the first disjunct will
|
||||
% use whichever registers they happen to be in,
|
||||
% and for subsequent disjuncts these variables need to be
|
||||
% put in framevars.
|
||||
set__difference(Liveness, Liveness0, OutputVars),
|
||||
set__to_sorted_list(OutputVars, LiveVarList),
|
||||
( CodeModel = model_non ->
|
||||
set__difference(Liveness, Liveness0, OutputVars),
|
||||
set__to_sorted_list(OutputVars, LiveVarList)
|
||||
;
|
||||
set__to_sorted_list(Liveness, LiveVarList)
|
||||
),
|
||||
store_alloc_allocate_storage(LiveVarList, 1, FollowVars,
|
||||
StoreMap),
|
||||
Goal = disj(Disjuncts, StoreMap)
|
||||
|
||||
Reference in New Issue
Block a user