Immediate ranges (was: Empirical data on ISA...)

By: Marcus (m.delete@this.bitsnbites.eu), August 7, 2022 9:50 pm
Room: Moderated Discussions
Björn Ragnar Björnsson (bjorn.ragnar.delete@this.gmail.com) on August 7, 2022 5:14 pm wrote:
> Marcus (m.delete@this.bitsnbites.eu) on August 7, 2022 10:16 am wrote:
> > Adrian (a.delete@this.acm.org) on August 3, 2022 2:00 am wrote:
> > > Anon (no.delete@this.spam.com) on August 2, 2022 11:46 am wrote:
> > > >
> > > > Getting quality data is much harder than you think, unlike you I have seen a lot of empirical
> > > > data, often contradictory data, the problem is that the data depends on compiler technology,
> > > > the existing ISAs, the workload, etc, improve one side and the other becomes suboptimal.
> > > >
> > >
> > > [snip]
> > >
> > > After compiling the static frequencies from the entire set of programs can be gathered trivially for any
> > > instruction feature, e.g. to count the instructions with the same mnemonic and sort them by frequency:
> > >
> > > objdump -d /usr/bin/* | cut -f3 | grep -oE "^[a-z]+" | sort | uniq -c | sort -n
> > >
> > >
> > > This is just the simplest example. Classifying the immediate constants by
> > > size ranges would require more sophisticated parsing of the disassembly output,
> > > but that would still not be difficult for a Python/Perl/AWK script.
> > >
> >
> > I have found that you can cover more useful/common immediate
> > value ranges by using "clever" (non-linear) encodings.
> > E.g. in MRISC32 (a 32-bit RISC ISA with fixed instruction
> > word size) I have a 15-bit immediate field for regular
> > arithmetic and logical operations etc. I decided to use one of the 15 bits to signify HI (1) or LO (0), and
> > position the rest of the 14 bits accordingly in the actual
> > 32-bit value (constant operand). Thus the following
> > constants are possible to express with the 15-bit field of the instruction word:
> >
> > MUL R7,R1,#-42 // LO (sign extend)
> > AND R8,R2,#0x7F800000 // HI
> > XOR R9,R3,#0x000FFFFF // HI (bit-extend LSB into lower part)
> >
> > And there's a similar encoding trick for loading larger immediate values (1+20 bits immediate
> > field), that can be used for loading many binary32 FP constants too, for instance.
> >
> > My point is that just gathering statistics on immediate value ranges (e.g. a histogram
> > of log2(abs(x))) may not be optimal when designing an ISA. You really need to look into
> > different use cases (aritmetic, bitwise, memory offsets, floating-point, etc) and take
> > into account possible encoding variants for different instruction classes.
> >
> > /Marcus
> >
>
> I hadn't seen MRISC32 before. At first glance it looks pretty good, a very respectable start.
> Congrats on that Marcus. Probably good enough for embedded and IOT stuff. Lot's left to do
> to make it usable in a modern general purpose computer. You probably don't need my advice but
> I'll give it anyway. When completing the spec in the general purpose direction take special
> note of Linus' numerous and detailed notes on memory ordering here at realworldtech.
>
>

Thank you! That's good advice. I'm not sure how far I'll take MRISC32 in those directions - it's kind of a prototype for MRISC64 that should be more suitable as a GP CPU.
< Previous Post in ThreadNext Post in Thread >
TopicPosted ByDate
Empirical data on ISA design parametersNvaxPlus2022/08/02 08:45 AM
  Empirical data on ISA design parameters---2022/08/02 10:25 AM
    Empirical data on ISA design parametersRayla2022/08/02 10:29 AM
  Empirical data on ISA design parametersAnon2022/08/02 11:46 AM
    Empirical data on ISA design parametersAdrian2022/08/03 02:00 AM
      Immediate ranges (was: Empirical data on ISA...)Marcus2022/08/07 10:16 AM
        Immediate ranges (was: Empirical data on ISA...)Björn Ragnar Björnsson2022/08/07 05:14 PM
          Immediate ranges (was: Empirical data on ISA...)Marcus2022/08/07 09:50 PM
  I hope you find something, but there are challengesMark Roulo2022/08/02 06:48 PM
    I hope you find something, but there are challengesBrett2022/08/02 10:41 PM
      I hope you find something, but there are challengeshobold2022/08/03 03:17 AM
        I hope you find something, but there are challengesBrett2022/08/03 11:37 AM
    I hope you find something, but there are challengesvonk2022/08/03 12:22 AM
    I hope you find something, but there are challengesAdrian2022/08/03 02:19 AM
      I hope you find something, but there are challengesNoSpammer2022/08/03 07:55 AM
        I hope you find something, but there are challengesAnon2022/08/03 09:25 AM
          I hope you find something, but there are challengesLinus Torvalds2022/08/03 11:31 AM
          I hope you find something, but there are challengesNoSpammer2022/08/04 03:18 AM
            I hope you find something, but there are challengesAdrian2022/08/04 04:56 AM
              I hope you find something, but there are challengesLinus Torvalds2022/08/04 11:03 AM
                I hope you find something, but there are challengesMr. Camel2022/08/04 12:29 PM
              I hope you find something, but there are challengesNoSpammer2022/08/08 09:31 AM
            I hope you find something, but there are challengesAnon2022/08/04 02:54 PM
        I hope you find something, but there are challengesAdrian2022/08/03 11:33 AM
          I hope you find something, but there are challengesBrett2022/08/03 12:21 PM
          I hope you find something, but there are challenges---2022/08/03 02:55 PM
            I hope you find something, but there are challengesBrett2022/08/03 04:31 PM
              Rebirth of the 68k archBrett2022/08/05 01:17 PM
                Rebirth of the 68k archMarcus2022/08/06 04:36 AM
                  Rebirth of the 68k archMegol2022/08/07 02:01 PM
                    Rebirth of the 68k archMarcus2022/08/07 11:30 PM
                      Rebirth of the 68k archBrett2022/08/08 12:31 AM
                        Rebirth of the 68k archMarcus2022/08/08 01:46 AM
                  Rebirth of the 68k archAnon2022/08/07 02:57 PM
                    Rebirth of the 68k archBrett2022/08/07 05:37 PM
                      68K was not a kludgeMark Roulo2022/08/07 06:05 PM
                        68K was not a kludgeBrett2022/08/07 09:56 PM
                          68K was not a kludgenone2022/08/08 01:00 AM
                            rich man's VAX and more O.T.Michael S2022/08/08 02:44 AM
                              rich man's VAX and more O.T.none2022/08/08 02:51 AM
                Rebirth of the 68k archBrett2022/08/10 11:59 PM
                  Rebirth of the 68k archUngo2022/08/11 03:53 AM
                    Rebirth of the 68k archAnon42022/08/11 12:08 PM
                      Rebirth of the 68k archrwessel2022/08/11 01:02 PM
            I hope you find something, but there are challengesAdrian2022/08/04 12:07 AM
              I hope you find something, but there are challengesEtienne2022/08/04 05:15 AM
          I hope you find something, but there are challengesAnon2022/08/03 05:15 PM
        I hope you find something, but there are challengesblaine2022/08/03 12:03 PM
Reply to this Topic
Name:
Email:
Topic:
Body: No Text
How do you spell tangerine? 🍊