Request for peephole help/insight

Help
Anonymous
2012-06-12
2013-03-12

  • Anonymous
    2012-06-12

    For benefit of others, default rules (8051 target) are here:

        http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/src/mcs51/peeph.def

    I couldn't find a rule which is looked to be responsible for bug 3534523 (but that doesn't mean it isn't there).

    This is my first stab at a definition file to workaround the two bugs. It seems to work on the testcase files attached to the bugs - can anyone spot any flaws/side effects I've missed? Do I need to add 'restart' or any of the conditional functions?

    replace {
        mov r%1,%2
        anl ar%1,#%3
        mov %2,r%1
    } by {
        ; Custom peephole rule to work around SDCC bug 3486135.
        ; Masking a register should be atomic.
        anl %2,#%3
    }
    replace {
        mov a,dpl
        movx    @dptr,a
        inc dptr
        mov a,dph
        movx    @dptr,a
    } by {
        ; Custom peephole rule to work around SDCC bug 3534523.
        ; Save dph before incrementing dptr.
        mov a,dpl
        movx    @dptr,a
        mov a,dph
        inc dptr
        movx    @dptr,a
    }
    
     

  • Anonymous
    2012-06-12

    Also seems to need:

    replace {
        mov ar%1,r%2
        anl ar%1,#%3
        mov ar%2,r%1
    } by {
        ; Custom peephole rule to work around SDCC bug 3486135.
        ; Masking a register (indirect) should be atomic.
        anl ar%2,#%3
    }
    

    Its feeling more like a kludge - the problem is in the code generation so that's where the fix ought to be.