summaryrefslogtreecommitdiff
path: root/gcc/config/mn10300/mn10300.c
diff options
context:
space:
mode:
authorlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>1997-10-30 20:34:59 +0000
committerlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>1997-10-30 20:34:59 +0000
commit9d3b5b5e7378e84236a97360b2862b767f3140de (patch)
treeb0a50279581c9c24ce476f9c45f602ae5bf5eba1 /gcc/config/mn10300/mn10300.c
parent990105041a94b01b22cdb62e116ea0436d7d4273 (diff)
downloadgcc-9d3b5b5e7378e84236a97360b2862b767f3140de.tar.gz
* mn10300.c (const_8bit_operand): New function.
(mask_ok_for_mem_btst): New funtion. * mn10300.md (btst patterns with mem operands): Use new functions to avoid creating btst instructions with invalid operands. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@16236 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/config/mn10300/mn10300.c')
-rw-r--r--gcc/config/mn10300/mn10300.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/gcc/config/mn10300/mn10300.c b/gcc/config/mn10300/mn10300.c
index 158cb2b34cd..201b51d1df2 100644
--- a/gcc/config/mn10300/mn10300.c
+++ b/gcc/config/mn10300/mn10300.c
@@ -990,6 +990,42 @@ impossible_plus_operand (op, mode)
return 0;
}
+/* Return 1 if X is a CONST_INT that is only 8 bits wide. This is used
+ for the btst insn which may examine memory or a register (the memory
+ variant only allows an unsigned 8 bit integer). */
+int
+const_8bit_operand (op, mode)
+ register rtx op;
+ enum machine_mode mode;
+{
+ return (GET_CODE (op) == CONST_INT
+ && INTVAL (op) >= 0
+ && INTVAL (op) < 256);
+}
+
+/* Similarly, but when using a zero_extract pattern for a btst where
+ the source operand might end up in memory. */
+int
+mask_ok_for_mem_btst (len, bit)
+ int len;
+ int bit;
+{
+ int mask = 0;
+
+ while (len > 0)
+ {
+ mask |= (1 << bit);
+ bit++;
+ len--;
+ }
+
+ /* MASK must bit into an 8bit value. */
+ return (((mask & 0xff) == mask)
+ || ((mask & 0xff00) == mask)
+ || ((mask & 0xff0000) == mask)
+ || ((mask & 0xff000000) == mask));
+}
+
/* Return 1 if X contains a symbolic expression. We know these
expressions will have one of a few well defined forms, so
we need only check those forms. */