<div dir="ltr">Hello,<div><br></div><div>I have added a new function in register allocation stage (AllocationOrder.h) file to define the physical register allocation order. There i require the information of instructions dependency.</div><div><br></div><div>For example:</div><div><br></div><div>if my register allocationorder is {R_0_Reg_0, R_0_Reg_1, R_0_Reg_2, R_0_Reg_3, R_0_Reg_4, R_0_Reg_5, R_0_Reg_6, R_0_Reg_7, R_1_Reg_0, R_1_Reg_1, R_1_Reg_2, R_1_Reg_3, R_1_Reg_4, R_1_Reg_5, R_1_Reg_6, R_1_Reg_7.....................................R_31_Reg_7}</div><div><br></div><div>then my algorithm should do;</div><div><br></div><div><span style="font-size:12.8px">if there exists dependency between instruction (or if 2 independent instructions are predecessors of another instruction)  then </span></div><div><span style="font-size:12.8px">PhysReg=(PhysReg+1) mod 8. </span></div><div><span style="font-size:12.8px">otherwise, if there is no dependency then PhysReg=(PhysReg+8) mod 32 i.e new R</span><br></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">for now i make this function in AllocationOrder.h</span></div><div><span style="font-size:12.8px"><br></span></div><div><div><span style="font-size:12.8px">unsigned nextP(int count) {</span></div><div><span style="font-size:12.8px"> <span style="white-space:pre">  </span> </span></div><div><span style="font-size:12.8px"> <span style="white-space:pre">      </span> unsigned Limit = 0;</span></div><div><span style="font-size:12.8px"> <span style="white-space:pre">    </span> int Prev;</span></div><div><span style="font-size:12.8px"> <span style="white-space:pre">      </span> <span style="white-space:pre">    </span> Prev=Pos;</span></div><div><span style="font-size:12.8px">    if (Pos < 0)</span></div><div><span style="font-size:12.8px">    <span style="white-space:pre">  </span>{ </span></div><div><span style="font-size:12.8px">    <span style="white-space:pre"> </span></span></div><div><span style="font-size:12.8px">    <span style="white-space:pre">            </span> if (count%2==0)   ///here i need the dependency information</span></div><div><span style="font-size:12.8px">    <span style="white-space:pre">               </span>{ </span></div><div><span style="font-size:12.8px">    <span style="white-space:pre">                 </span></span></div><div><span style="font-size:12.8px">    <span style="white-space:pre">                    </span>Pos=Pos+8;</span></div><div><span style="font-size:12.8px">    <span style="white-space:pre">          </span>}</span></div><div><span style="font-size:12.8px">    </span></div><div><span style="font-size:12.8px">    else </span></div><div><span style="font-size:12.8px">    {</span></div><div><span style="font-size:12.8px">      Pos=Pos-7;</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">}</span></div><div><span style="font-size:12.8px">  return Hints.end()[Prev];}</span></div><div><span style="font-size:12.8px">    if (!Limit)</span></div><div><span style="font-size:12.8px">      Limit = Order.size();</span></div><div><span style="font-size:12.8px">    while (Pos < int(Limit)) {</span></div><div><span style="font-size:12.8px">    <span style="white-space:pre">              </span> if (count%2==0)</span></div><div><span style="font-size:12.8px">    <span style="white-space:pre">            </span>{ </span></div><div><span style="font-size:12.8px">    <span style="white-space:pre">                 </span></span></div><div><span style="font-size:12.8px">    <span style="white-space:pre">                    </span>Pos=Pos+8;</span></div><div><span style="font-size:12.8px">    <span style="white-space:pre">          </span>}</span></div><div><span style="font-size:12.8px">    </span></div><div><span style="font-size:12.8px">    else </span></div><div><span style="font-size:12.8px">    {</span></div><div><span style="font-size:12.8px">      Pos=Pos-7;</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">}</span></div><div><span style="font-size:12.8px">      unsigned Reg = Order[Prev];</span></div><div><span style="font-size:12.8px">      if (!isHint(Reg))</span></div><div><span style="font-size:12.8px">        return Reg;</span></div><div><span style="font-size:12.8px">    }</span></div><div><span style="font-size:12.8px">    return 0;</span></div><div><span style="font-size:12.8px">  }</span></div></div><div><span style="font-size:12.8px">This is called in RegAllocGreedy.cpp. </span></div><div><span style="font-size:12.8px"><br></span></div><div><div><span style="font-size:12.8px"> while ((PhysReg = Order.nextP(count)))</span></div><div><span style="font-size:12.8px">{      </span></div><div><span style="font-size:12.8px">count++;</span></div><div><span style="font-size:12.8px"><span style="white-space:pre">     </span>if (!Matrix->checkInterference(VirtReg, PhysReg))</span></div><div><span style="font-size:12.8px">      break;</span></div><div><span style="font-size:12.8px">      </span></div><div><span style="font-size:12.8px">  }</span></div></div><div><br></div><div>so after correct implementation my emitted assembly should be;</div><div><br></div><div><div><span style="white-space:pre"> </span>1. P_256B_LOAD_DWORD<span style="white-space:pre"> </span>R_0_Reg_0, Pword ptr [rip + b] </div><div><span style="white-space:pre">      </span>2. P_256B_LOAD_DWORD<span style="white-space:pre"> </span>R_1_Reg_0, Pword ptr [rip + b+256] //  instruction 2 is not dependent on instruction 1 here increment order index by 8 and get R_1</div><div><span style="white-space:pre">   </span>3. P_256B_LOAD_DWORD<span style="white-space:pre"> </span>R_0_Reg_1, Pword ptr [rip + c] // //  instruction 3 is not dependent on instruction 1 but both will contribute towards ADD so here increment order index by 1 and get Reg_1</div><div><span style="white-space:pre">  </span>4. P_256B_LOAD_DWORD<span style="white-space:pre"> </span>R_1_Reg_1, Pword ptr [rip + c+256] //  instruction 4 is not dependent on instruction 2 but both will contribute towards ADD so here increment order index by 1 and get Reg_1</div><div><span style="white-space:pre"> </span>5. P_256B_VADD<span style="white-space:pre">       </span>R_0_Reg_0, R_0_Reg_1, R_0_Reg_0 //  instruction 5 is  dependent on instruction 1 and 3 here keep R_0</div><div><span style="white-space:pre">        </span>6. P_256B_VADD<span style="white-space:pre">       </span>R_1_Reg_0, R_1_Reg_1, R_1_Reg_0 //  instruction 6 is  dependent on instruction 2 and 4 here keep R_1</div></div><div><br></div><div><br></div><div>I think I am close the only information i need is instruction dependency information such that instruction 1, 3, 5 lie in 1 group while 2, 4, 6 lie in another.</div><div><br></div><div>Can someone point me any data structure, function? that i can use at this point to get dependency information??</div><div><br></div><div>Please help.</div><div><br></div><div>Thank You</div><div><br></div><div><br></div><div><br></div><div><br></div></div>