summaryrefslogtreecommitdiff
path: root/gcc/read-rtl.c
diff options
context:
space:
mode:
authormrs <mrs@138bc75d-0d04-0410-961f-82ee72b054a4>2013-08-13 20:41:07 +0000
committermrs <mrs@138bc75d-0d04-0410-961f-82ee72b054a4>2013-08-13 20:41:07 +0000
commite913b5cd5b6a9bd3a2ad58c65f9e3cd2bb55a28c (patch)
treef52a097017e3dcf89fad6525984e4591489f961e /gcc/read-rtl.c
parent9a5942c1d4d9116ab74b0741cfe3894a89fd17fb (diff)
downloadgcc-e913b5cd5b6a9bd3a2ad58c65f9e3cd2bb55a28c.tar.gz
Add wide-int branch.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/wide-int@201707 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/read-rtl.c')
-rw-r--r--gcc/read-rtl.c73
1 files changed, 73 insertions, 0 deletions
diff --git a/gcc/read-rtl.c b/gcc/read-rtl.c
index 10adf472a08..707ef3fd1cd 100644
--- a/gcc/read-rtl.c
+++ b/gcc/read-rtl.c
@@ -811,6 +811,29 @@ validate_const_int (const char *string)
fatal_with_file_and_line ("invalid decimal constant \"%s\"\n", string);
}
+static void
+validate_const_wide_int (const char *string)
+{
+ const char *cp;
+ int valid = 1;
+
+ cp = string;
+ while (*cp && ISSPACE (*cp))
+ cp++;
+ /* Skip the leading 0x. */
+ if (cp[0] == '0' || cp[1] == 'x')
+ cp += 2;
+ else
+ valid = 0;
+ if (*cp == 0)
+ valid = 0;
+ for (; *cp; cp++)
+ if (! ISXDIGIT (*cp))
+ valid = 0;
+ if (!valid)
+ fatal_with_file_and_line ("invalid hex constant \"%s\"\n", string);
+}
+
/* Record that PTR uses iterator ITERATOR. */
static void
@@ -1324,6 +1347,56 @@ read_rtx_code (const char *code_name)
gcc_unreachable ();
}
+ if (CONST_WIDE_INT_P (return_rtx))
+ {
+ read_name (&name);
+ validate_const_wide_int (name.string);
+ {
+ hwivec hwiv;
+ const char *s = name.string;
+ int len;
+ int index = 0;
+ int gs = HOST_BITS_PER_WIDE_INT/4;
+ int pos;
+ char * buf = XALLOCAVEC (char, gs + 1);
+ unsigned HOST_WIDE_INT wi;
+ int wlen;
+
+ /* Skip the leading spaces. */
+ while (*s && ISSPACE (*s))
+ s++;
+
+ /* Skip the leading 0x. */
+ gcc_assert (s[0] == '0');
+ gcc_assert (s[1] == 'x');
+ s += 2;
+
+ len = strlen (s);
+ pos = len - gs;
+ wlen = (len + gs - 1) / gs; /* Number of words needed */
+
+ return_rtx = const_wide_int_alloc (wlen);
+
+ hwiv = CONST_WIDE_INT_VEC (return_rtx);
+ while (pos > 0)
+ {
+#if HOST_BITS_PER_WIDE_INT == 64
+ sscanf (s + pos, "%16" HOST_WIDE_INT_PRINT "x", &wi);
+#else
+ sscanf (s + pos, "%8" HOST_WIDE_INT_PRINT "x", &wi);
+#endif
+ XHWIVEC_ELT (hwiv, index++) = wi;
+ pos -= gs;
+ }
+ strncpy (buf, s, gs - pos);
+ buf [gs - pos] = 0;
+ sscanf (buf, "%" HOST_WIDE_INT_PRINT "x", &wi);
+ XHWIVEC_ELT (hwiv, index++) = wi;
+ /* TODO: After reading, do we want to canonicalize with:
+ value = lookup_const_wide_int (value); ? */
+ }
+ }
+
c = read_skip_spaces ();
/* Syntactic sugar for AND and IOR, allowing Lisp-like
arbitrary number of arguments for them. */