Actually richi, this code is "correct" for some broken definition of
correct.
If all that is done is to convert the rtl parts of the compiler, then
this code is the best you can do (of course an assertion that the length
is not greater than 2 would be a useful addition).
The code that is in the follow on patch which converts the insides of a
tree cst to look like a const wide int, i.e. an array of HWIs. When
that happens, this code looks completely different. But if you only
convert the rtl level, at some point there is going to be an impedance
mismatch and it is buried here.
I will point out that this is the fall out of trying to split things
into a bunch of smaller patches that could in theory go in separately.
kenny
+/* Constructs tree in type TYPE from with value given by CST. Signedness
+ of CST is assumed to be the same as the signedness of TYPE. */
+
+tree
+wide_int_to_tree (tree type, const wide_int &cst)
+{
+ wide_int v;
+ if (TYPE_UNSIGNED (type))
+ v = cst.zext (TYPE_PRECISION (type));
+ else
+ v = cst.sext (TYPE_PRECISION (type));
+
+ return build_int_cst_wide (type, v.elt (0), v.elt (1));
+}
is surely broken. A wide-int does not fit a double-int. How are you
going to "fix" this?
Thanks,
Richard.
kenny