To explain it, I will make use of the âmove insnâ example pointed in the previous email.
First of all I do not change anything in the 2 automatons (aut1 and aut2); they are correctly built by the genautomata.
Next to the original
(define_reservation "move" "( (unit1_aut1, unit1_aut2) |
(unit2_aut1, unit2_aut2) )
I define two separate fake move instructions (i.e., âmove_fake1â and âmove_fake2â) of which semantic does play any role; each of them
having a unit reservation one of the alternatives of the âmoveâ:
(define_reservation "move_fake1" "( (unit1_aut1, unit1_aut2)), and
(define_reservation "move_fake2" "( (unit2_aut1, unit2_aut2) ).
Those two extra moves are then used during the sched2 target hook TARGET_SCHED_DFA_NEW_CYCLE to decide which of the move alternative unit reservations can be correctly claimed.
Suppose the ready instruction is a âmoveâ.
First I make 2 copies of the current state: temp_state1 and temp_state2.
Then I check which of the two fake moves ( âmove_fake1â and âmove_fake2â) with different unit occupation can be issued at the current state:
cost_move_fake1 = internal_state_transition (insn_code_move_fake1, temp_state1);
cost_move_fake2 = internal_state_transition (insn_code_move_fake2, temp_state2);
Once I find the correct choice (suppose cost_move_fake1 <0), I set dfa_insn_codes[] of the ready instruction to the one of move_fake1.
int uid = INSN_UID (ready);
if (uid >= dfa_insn_codes_length)
dfa_insn_code_enlarge (uid);
dfa_insn_codes[uid] = internal_dfa_insn_code (insn_code_move_fake1);
In this way when the scheduler calls internal_state_transition, the ready instruction has been already set its dfa_insn_codes to a unit reservation schedulable in the current state.