This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: SIMPLE: A language-independent tree IR

> Joe Buck <jbuck@synopsys.COM> writes:
> > Perhaps this is best handled in a framework like SIMPLE by using different
> > OPs.  That is, if lang-1 says that overflow of signed integer arithmetic
> > is undefined but lang-2 requires an exception to be thrown, then a
> > different OP would be used; alternatively, the latter could be defined in
> > terms of the former plus extra code.
> The operator approach has the disadvantage that one day, there might
> be a front end which requires detailed overflow checking in integer
> calculations.  Ada is rather harmless in this regard because integer
> arithmetic is performed in the base range of a given type, so you can
> use just a few of these base types (usually four).

It might be possible to do things in a general way by composing two operators:
a mathematically ideal arithmetic operation and a conversion operation.
Possible conversions would include:

1. modulo 2^n (for unsigned)
2. convert-to-type, don't care about overflows (for C int or Fortran INTEGER)
   (a backend on a two's complement machine would probably implement this
   as two's complement modulo)
3. convert-to-type, execute given code (in some tree) on overflow
4. saturation arithmetic (could be just a special case of the previous one)

Something similar could be done for floating point.  One difficulty is
that trees could arise that backends aren't prepared to handle (bare
arbitrary precision value without a conversion).

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]