4.57

    A.

    consider load/use hazard

    1. E_icode in { IMRMOVQ, IPOPQ } && E_dstM in { d_srcA, d_srcB };
    situation 1 2 3 4
    E_dstM == d_srcA 1 1 0 0
    E_dstM == d_srcB 1 0 1 0

    situation 4:

    normal, no hazard happens

    situation 1,2,3:

    load/use hazard happens

    if E_icode in { IMRMOVQ, IPOPQ }, then E_dstM must not be RNONE

    consider situation 1 and 3, E_dstM == d_srcB, then d_srcB is not RNONE and must
    be used in phase E, so load-forward can’t work. load-forward only work in situation 2!

    consider all the instructions that d_srcA is not RNONE

    instructions d_srcA valA used in phase E? load-forward works?
    rrmovq rA Y N
    rmmovq rA N Y
    opq rA Y N
    pushq rA N Y
    ret rsp N N
    popq rsp N N

    ret and popq can’t work because d_srcA == d_srcB == %rsp, that’s not in
    situation 2!!

    finally, load/use only work in condition:

    1. E_icode in { IMRMOVQ, IPOPQ } &&
    2. (
    3. E_dstM == d_srcB ||
    4. (
    5. E_dstM == d_srcA && !(D_icode in { IRMMOVQ, IPUSHQ })
    6. )
    7. );

    B.

    check file ./chapter4/code/sim/pipe/pipe-lf.hcl

    only watch changes with origin pipe-lf.hcl

    1. (cd ./chapter4/code/sim/pipe; diff -u origin-pipe-lf.hcl pipe-lf.hcl)
    1. !INCLUDE './code/sim/pipe/pipe-lf.diff'