summaryrefslogtreecommitdiffstats
path: root/polly/lib/External/isl/isl_val_sioimath.c
diff options
context:
space:
mode:
authorMichael Kruse <llvm@meinersbur.de>2015-06-18 16:45:40 +0000
committerMichael Kruse <llvm@meinersbur.de>2015-06-18 16:45:40 +0000
commitc59f22c5567ad237b0478d26a95c4b48f8715f2f (patch)
tree192026e7325a911cdb4e41552590abb22f3da3eb /polly/lib/External/isl/isl_val_sioimath.c
parent5578e44df8e63152e891189ce35005dcf5fcf396 (diff)
downloadbcm5719-llvm-c59f22c5567ad237b0478d26a95c4b48f8715f2f.tar.gz
bcm5719-llvm-c59f22c5567ad237b0478d26a95c4b48f8715f2f.zip
Update ISL to isl-0.15-3-g532568a
This version adds small integer optimization, but is not active by default. It will be enabled in a later commit. The schedule-fuse=min/max option has been replaced by the serialize-sccs option. Adapting Polly was necessary, but retaining the name polly-opt-fusion=min/max. Differential Revision: http://reviews.llvm.org/D10505 Reviewers: grosser llvm-svn: 240027
Diffstat (limited to 'polly/lib/External/isl/isl_val_sioimath.c')
-rw-r--r--polly/lib/External/isl/isl_val_sioimath.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/polly/lib/External/isl/isl_val_sioimath.c b/polly/lib/External/isl/isl_val_sioimath.c
new file mode 100644
index 00000000000..008f899ed18
--- /dev/null
+++ b/polly/lib/External/isl/isl_val_sioimath.c
@@ -0,0 +1,68 @@
+#include <isl_val_private.h>
+
+/* Return a reference to an isl_val representing the unsigned
+ * integer value stored in the "n" chunks of size "size" at "chunks".
+ * The least significant chunk is assumed to be stored first.
+ */
+__isl_give isl_val *isl_val_int_from_chunks(isl_ctx *ctx, size_t n,
+ size_t size, const void *chunks)
+{
+ isl_val *v;
+
+ v = isl_val_alloc(ctx);
+ if (!v)
+ return NULL;
+
+ impz_import(isl_sioimath_reinit_big(&v->n), n, -1, size, 0, 0, chunks);
+ isl_sioimath_try_demote(&v->n);
+ isl_int_set_si(v->d, 1);
+
+ return v;
+}
+
+/* Store a representation of the absolute value of the numerator of "v"
+ * in terms of chunks of size "size" at "chunks".
+ * The least significant chunk is stored first.
+ * The number of chunks in the result can be obtained by calling
+ * isl_val_n_abs_num_chunks. The user is responsible for allocating
+ * enough memory to store the results.
+ *
+ * In the special case of a zero value, isl_val_n_abs_num_chunks will
+ * return one, while impz_export will not fill in any chunks. We therefore
+ * do it ourselves.
+ */
+int isl_val_get_abs_num_chunks(__isl_keep isl_val *v, size_t size,
+ void *chunks)
+{
+ isl_sioimath_scratchspace_t scratch;
+
+ if (!v || !chunks)
+ return -1;
+
+ if (!isl_val_is_rat(v))
+ isl_die(isl_val_get_ctx(v), isl_error_invalid,
+ "expecting rational value", return -1);
+
+ impz_export(chunks, NULL, -1, size, 0, 0,
+ isl_sioimath_bigarg_src(v->n, &scratch));
+ if (isl_val_is_zero(v))
+ memset(chunks, 0, size);
+
+ return 0;
+}
+
+/* Return the number of chunks of size "size" required to
+ * store the absolute value of the numerator of "v".
+ */
+size_t isl_val_n_abs_num_chunks(__isl_keep isl_val *v, size_t size)
+{
+ if (!v)
+ return 0;
+
+ if (!isl_val_is_rat(v))
+ isl_die(isl_val_get_ctx(v), isl_error_invalid,
+ "expecting rational value", return 0);
+
+ size *= 8;
+ return (isl_sioimath_sizeinbase(v->n, 2) + size - 1) / size;
+}
OpenPOWER on IntegriCloud