aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2017-12-20 12:52:04 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2017-12-20 12:52:04 +0000
commitf8832fe1a7611c0458ebf45140c099eb7bf5d0c8 (patch)
tree454adbe03c8aa8c6dd94e3a936168631193be885
parentdc3f38050535e8904dce2fd02c6efb6cf91eea3d (diff)
downloadgcc-f8832fe1a7611c0458ebf45140c099eb7bf5d0c8.zip
gcc-f8832fe1a7611c0458ebf45140c099eb7bf5d0c8.tar.gz
gcc-f8832fe1a7611c0458ebf45140c099eb7bf5d0c8.tar.bz2
poly_int: create_integer_operand
This patch generalises create_integer_operand so that it accepts poly_int64s rather than HOST_WIDE_INTs. 2017-12-20 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * optabs.h (expand_operand): Add an int_value field. (create_expand_operand): Add an int_value parameter and use it to initialize the new expand_operand field. (create_integer_operand): Replace with a declaration of a function that accepts poly_int64s. Move the implementation to... * optabs.c (create_integer_operand): ...here. (maybe_legitimize_operand): For EXPAND_INTEGER, check whether the mode preserves the value of int_value, instead of calling const_int_operand on the rtx. Use gen_int_mode to generate the new rtx. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r255865
-rw-r--r--gcc/ChangeLog15
-rw-r--r--gcc/optabs.c23
-rw-r--r--gcc/optabs.h19
3 files changed, 42 insertions, 15 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 4822066..5f26d1b 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -2,6 +2,21 @@
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
+ * optabs.h (expand_operand): Add an int_value field.
+ (create_expand_operand): Add an int_value parameter and use it
+ to initialize the new expand_operand field.
+ (create_integer_operand): Replace with a declaration of a function
+ that accepts poly_int64s. Move the implementation to...
+ * optabs.c (create_integer_operand): ...here.
+ (maybe_legitimize_operand): For EXPAND_INTEGER, check whether
+ the mode preserves the value of int_value, instead of calling
+ const_int_operand on the rtx. Use gen_int_mode to generate
+ the new rtx.
+
+2017-12-20 Richard Sandiford <richard.sandiford@linaro.org>
+ Alan Hayward <alan.hayward@arm.com>
+ David Sherwood <david.sherwood@arm.com>
+
* dumpfile.h (dump_dec): Declare.
* dumpfile.c (dump_dec): New function.
* pretty-print.h (pp_wide_integer): Turn into a function and
diff --git a/gcc/optabs.c b/gcc/optabs.c
index b0d82af..9fd0f82 100644
--- a/gcc/optabs.c
+++ b/gcc/optabs.c
@@ -6979,6 +6979,20 @@ valid_multiword_target_p (rtx target)
return true;
}
+/* Make OP describe an input operand that has value INTVAL and that has
+ no inherent mode. This function should only be used for operands that
+ are always expand-time constants. The backend may request that INTVAL
+ be copied into a different kind of rtx, but it must specify the mode
+ of that rtx if so. */
+
+void
+create_integer_operand (struct expand_operand *op, poly_int64 intval)
+{
+ create_expand_operand (op, EXPAND_INTEGER,
+ gen_int_mode (intval, MAX_MODE_INT),
+ VOIDmode, false, intval);
+}
+
/* Like maybe_legitimize_operand, but do not change the code of the
current rtx value. */
@@ -7091,8 +7105,13 @@ maybe_legitimize_operand (enum insn_code icode, unsigned int opno,
case EXPAND_INTEGER:
mode = insn_data[(int) icode].operand[opno].mode;
- if (mode != VOIDmode && const_int_operand (op->value, mode))
- goto input;
+ if (mode != VOIDmode
+ && known_eq (trunc_int_for_mode (op->int_value, mode),
+ op->int_value))
+ {
+ op->value = gen_int_mode (op->int_value, mode);
+ goto input;
+ }
break;
}
return insn_operand_matches (icode, opno, op->value);
diff --git a/gcc/optabs.h b/gcc/optabs.h
index 4bb8cca..388f828 100644
--- a/gcc/optabs.h
+++ b/gcc/optabs.h
@@ -60,6 +60,9 @@ struct expand_operand {
/* The value of the operand. */
rtx value;
+
+ /* The value of an EXPAND_INTEGER operand. */
+ poly_int64 int_value;
};
/* Initialize OP with the given fields. Initialise the other fields
@@ -69,13 +72,14 @@ static inline void
create_expand_operand (struct expand_operand *op,
enum expand_operand_type type,
rtx value, machine_mode mode,
- bool unsigned_p)
+ bool unsigned_p, poly_int64 int_value = 0)
{
op->type = type;
op->unsigned_p = unsigned_p;
op->unused = 0;
op->mode = mode;
op->value = value;
+ op->int_value = int_value;
}
/* Make OP describe an operand that must use rtx X, even if X is volatile. */
@@ -142,18 +146,7 @@ create_address_operand (struct expand_operand *op, rtx value)
create_expand_operand (op, EXPAND_ADDRESS, value, Pmode, false);
}
-/* Make OP describe an input operand that has value INTVAL and that has
- no inherent mode. This function should only be used for operands that
- are always expand-time constants. The backend may request that INTVAL
- be copied into a different kind of rtx, but it must specify the mode
- of that rtx if so. */
-
-static inline void
-create_integer_operand (struct expand_operand *op, HOST_WIDE_INT intval)
-{
- create_expand_operand (op, EXPAND_INTEGER, GEN_INT (intval), VOIDmode, false);
-}
-
+extern void create_integer_operand (struct expand_operand *, poly_int64);
/* Passed to expand_simple_binop and expand_binop to say which options
to try to use if the requested operation can't be open-coded on the