Size of enumerations/subranges in Modula-2

Rick Pelleg <taux01!taux02.uucp!rick@nsc.uucp>
11 Aug 88 10:09:14 GMT

          From comp.compilers

Related articles
Size of enumerations/subranges in Modula-2 taux01!taux02.uucp!rick@nsc.uucp (Rick Pelleg) (1988-08-11)
| List of all articles for this month |

Posted-Date: 11 Aug 88 10:09:14 GMT
From: Rick Pelleg <taux01!taux02.uucp!rick@nsc.uucp>
Newsgroups: comp.lang.modula2,comp.compilers
Keywords: enumeration, subrange, speed vs. space
Date: 11 Aug 88 10:09:14 GMT
Organization: National Semiconductor (IC) Ltd, Israel

We have written a Modula-2 compiler which produces code for the NS32000
family of CPUs. One problematic implementation issue is that of the size
of enumeration types and subrange types.


The two possibilities are:
    1. An enumeration/subrange occupies the least possible amount of bytes (the
          NS32000 are byte addressable machines).
    2. An enumeration/subrange always occupies four bytes (a double-word). This
          is the "natural" size on the NS32000.


The issue is the usual "speed vs. space" tradeoff. The first possibility of
course saves space, but is slower whenever doing mixed sized calculations
or array indexing, because of the conversions that must be done.


Any opinions about this issue? In particular, I am interested in the following
two questions:
    1. How do Modula-2 compilers you know implement enumerated types and
          subranges?
    2. How would you like to see them implemented?


I'll summarize any interesting email I receive on the subject.


Thanks,
--
--- Rick Pelleg
National Semiconductor (Israel)
6 Maskit st. P.O.B. 3007, Herzlia 46104, Israel Tel. (972)52-522264
rick%taux01@nsc.com @{hplabs,pyramid,sun,decwrl}
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.