On Fri, Dec 16, 2016 at 4:47 AM, Травкин Роман <ramon13...@yandex.ru> wrote:
> Is this rule correct? In PM0044 STM8 CPU Programming manual popw only gets
> 16bit registers (X, Y)
>
> replace restart {
>     popw    a
>     popw    a
> } by {
>     popw    x
>     ; peephole 14a merged pop a into popw x
> } if notUsed('a'), notUsed('x')
>
> This rule is from file
> https://sourceforge.net/p/sdcc/code/HEAD/tree/trunk/sdcc/src/stm8/peeph.def#l412
>

Unfortunately the mailing list is not very active; hardware
familiarity might be a bit much to expect. If the definitions in the
distribution aren't right it is up to you to recognize any error.

On Fri, Dec 16, 2016 at 4:25 AM, Травкин Роман <ramon13...@yandex.ru> wrote:
> I've loocked at this file (as I mentioned earlier). Some moments push me to
> ask questions. There are parameters like
>
> notUsed('a'),
> notSame(%2 'push' 'pop'),
> notSame(%1 'xl' 'xh' 'yl' 'yh'),
> immdInRange(0 255 '+' %1 %2 %9),
> labelIsUncondJump(),
> labelRefCountChange
> and many others. i can look at examples and make my own like a monkey, but
> it's not best practice.
>
> Tried too lokk at sources of sdcc, but my sw skill isn't enough to
> understand code.
> And second. Some params of peep riules are numbered in series like %1, %2,
> %3 etc,
> and some like %1, %5, %9. Why is it so?
>

I am not sure if wikipedia.ru is as up-to-date as the English
equivalent. In any case:

A peephole optimizer applies a set of hand picked rules against a
moving window of code. The numbered parameters are variables. They are
able to assume values of an instruction or any of its arguments; when
in the argument position, addressing mode sigils constrain the
instruction to be matched.

The predicates you listed constrain the replacement rule. notUsed
checks to see if a register contains user assigned data. notSame
checks to see if an instruction or register is the same as one
provided. immdInRange checks to see if an immediate value (a constant)
is within the range specified. The rest should be relatively
self-explanatory. I wasn't able to find a list of all predicates
available, but you should look for one.

You can refer to http://sdcc.sourceforge.net/doc/sdccman.pdf, but I
admit it isn't very descriptive. Reading through SDCCpeeph.h and
SDCCpeep.c will have little benefit. I suggest getting a copy of the
processor manual and reading through the section on instruction
representation and addressing modes. Once you have done so the
peephole rules should make more sense.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to