patch to fix constant math - 4th patch - the wide-int class - patch ping for the next stage 1
Kenneth Zadeck
zadeck@naturalbridge.com
Wed Apr 17 00:49:00 GMT 2013
Richard,
I made major changes to wide-int along the lines you suggested. Each of
the binary operations is now a template.
There are 5 possible implementations of those operations, one for each
of HWI, unsigned HWI, wide-int, rtl, and tree. Note that this is not
exactly as you suggested, but it is along the same lines.
The HWI template sign extends the value to the precision of the first
operand, the unsigned HWI is the same except that it is an unsigned
extension. The wide-int version is used as before, but is in truth
rarely used. The rtl and tree "logically" convert the value to a
wide-int but in practice do something more efficient than converting to
the wide-int. What they do is look inside the rtl or the tree and pass
a pointer to the data and a length to the binary operation. This is
perfectly safe in the position of a second operand to the binary
operation because the lifetime is guaranteed to be very short. The
wide-int implementation was also modified to do the same pointer trick
allowing all 5 templates to share the same use of the data.
Note that currently the tree code is more crufty than one would like.
This will clean up nicely when the tree-cst is changed to represent the
value with an array and a length field.
So now, at least for the second operand of binary operations, the
storage is never copied. I do not believe that there is a good
similar trick for the first operand. i did not consider something like
wide_int::add (a, b) to be a viable option; it seems to mis the point of
using an object oriented language. So I think that you really have to
copy the data into an instance of a wide int.
However, while all of this avoids ever having to pass a precision into
the second operand, this patch does preserve the finite math
implementation of wide-int. Finite math is really what people expect
an optimizer to do, because it seamlessly matches what the machine is
going to do.
I hope at this point, i can get a comprehensive review on these patches.
I believe that I have done what is required.
There are two other patches that will be submitted in the next few
minutes. The first one is an updated version of the rtl level patch.
The only changes from what you have seen before are that the binary
operations now use the templated binary operations. The second one is
the first of the tree level patches. It converts builtins.c to use
both use wide-int and it removes all assumptions that tree-csts are
built with two HWIs.
Once builtins.c is accepted, i will convert the rest of the middle end
patches. They will all be converted in a similar way.
Kenny
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p4-6.diff
Type: text/x-patch
Size: 152258 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20130417/bb369551/attachment.bin>
-------------- next part --------------
2013-04-16 Kenneth Zadeck <zadeck@naturalbridge.com>
* Makefile.in (wide-int.c, wide-int.h): New files.
* wide-int.c: New file containing implementation of wide_int class.
* wide-int.h: New file containing public spec for wide_int class.
More information about the Gcc-patches
mailing list