[Edinburgh-pm] DaliBug

Miles Gould miles at assyrian.org.uk
Mon Aug 2 15:52:31 PDT 2010

... got it.

Here's the offending code:

  gcg_create_mpyint(gcg_expand, rs1,
                    UnivInt_to_int(p.Value), rd);

and here's what it should have been:

  gcg_create_mpyintimm(gcg_expand, rs1,
                       UnivInt_to_int(p.Value), rd);

This meant that instead of emitting code to multiply register r1 by the
immediate value 10, it was emitting code to multiply r1 by r9 (which
was, of course, uninitialised).

The typesystem-inclined will note that this could and should have been
detected at compile-time: the problem is that virtual registers (rs1 and
rd) are represented as integers, much like UnivInt_to_int(p.Value). What
I probably should have done was made the mpyintimm constructor take
whatever kind of thing p is. Now I need to work out how to get the
C generation system to output that...

Ideally I'd represent registers some other way too, but I don't think
that's possible with the system as it is.

I'm treating this as a learning experience.


Sure, it could contribute to the breakdown of society. But isn't the
breakdown of a decent party just as much of a tragedy?
  -- Robert Colvile

More information about the Edinburgh-pm mailing list