blob: dfdb479cd58068da40dc13531f663dc703d8754c [file] [log] [blame]
Andrew Geisslera9ff2b32020-10-16 10:11:54 -05001From 341bf8ad4e55693d00d4d8c916f4c347e7186dd4 Mon Sep 17 00:00:00 2001
Brad Bishop286d45c2018-10-02 15:21:57 -04002From: Mahesh Bodapati <mbodapat@xilinx.com>
Brad Bishop26bdd442019-08-16 17:08:17 -04003Date: Wed, 18 Jan 2017 12:14:51 +0530
Andrew Geisslera9ff2b32020-10-16 10:11:54 -05004Subject: [PATCH 29/58] [Patch, microblaze]: Add new bit-field instructions
5
6This patches adds new bsefi and bsifi instructions.
7BSEFI- The instruction shall extract a bit field from a
8register and place it right-adjusted in the destination register.
9The other bits in the destination register shall be set to zero
10BSIFI- The instruction shall insert a right-adjusted bit field
11from a register at another position in the destination register.
12The rest of the bits in the destination register shall be unchanged
Brad Bishop286d45c2018-10-02 15:21:57 -040013
Brad Bishop26bdd442019-08-16 17:08:17 -040014Signed-off-by :Nagaraju Mekala <nmekala@xilix.com>
Brad Bishop286d45c2018-10-02 15:21:57 -040015
16ChangeLog:
Brad Bishop26bdd442019-08-16 17:08:17 -040017 2016-02-03 Nagaraju Mekala <nmekala@xilix.com>
Brad Bishop286d45c2018-10-02 15:21:57 -040018
Brad Bishop26bdd442019-08-16 17:08:17 -040019 *microblaze.md (Update): Added new patterns
Brad Bishop286d45c2018-10-02 15:21:57 -040020---
Andrew Geisslera9ff2b32020-10-16 10:11:54 -050021 gcc/config/microblaze/microblaze.h | 2 +
22 gcc/config/microblaze/microblaze.md | 73 +++++++++++++++++++++++++++++
23 2 files changed, 75 insertions(+)
Brad Bishop286d45c2018-10-02 15:21:57 -040024
Andrew Geisslera9ff2b32020-10-16 10:11:54 -050025diff --git a/gcc/config/microblaze/microblaze.h b/gcc/config/microblaze/microblaze.h
26index 8b0db2c1718..b5b7b22cec9 100644
27--- a/gcc/config/microblaze/microblaze.h
28+++ b/gcc/config/microblaze/microblaze.h
29@@ -44,6 +44,7 @@ extern int microblaze_dbx_regno[];
30
31 extern int microblaze_no_unsafe_delay;
32 extern int microblaze_has_clz;
33+extern int microblaze_has_bitfield;
34 extern enum pipeline_type microblaze_pipe;
35
36 #define OBJECT_FORMAT_ELF
37@@ -62,6 +63,7 @@ extern enum pipeline_type microblaze_pipe;
38
39 /* Do we have CLZ? */
40 #define TARGET_HAS_CLZ (TARGET_PATTERN_COMPARE && microblaze_has_clz)
41+#define TARGET_HAS_BITFIELD (TARGET_BARREL_SHIFT && microblaze_has_bitfield)
42
43 /* The default is to support PIC. */
44 #define TARGET_SUPPORTS_PIC 1
Brad Bishop286d45c2018-10-02 15:21:57 -040045diff --git a/gcc/config/microblaze/microblaze.md b/gcc/config/microblaze/microblaze.md
Andrew Geisslera9ff2b32020-10-16 10:11:54 -050046index c407a81c51e..fa6aabdb9d4 100644
Brad Bishop286d45c2018-10-02 15:21:57 -040047--- a/gcc/config/microblaze/microblaze.md
48+++ b/gcc/config/microblaze/microblaze.md
Andrew Geissler84ad7c52020-06-27 00:00:16 -050049@@ -982,6 +982,8 @@
Brad Bishop286d45c2018-10-02 15:21:57 -040050 (set_attr "mode" "DI")
51 (set_attr "length" "20,20,20")])
52
53+
54+
55 ;;----------------------------------------------------------------
56 ;; Data movement
57 ;;----------------------------------------------------------------
Andrew Geissler84ad7c52020-06-27 00:00:16 -050058@@ -1776,6 +1778,7 @@
Brad Bishop286d45c2018-10-02 15:21:57 -040059 (set_attr "length" "28")]
60 )
61
62+
63 ;;----------------------------------------------------------------
64 ;; Setting a register from an integer comparison.
65 ;;----------------------------------------------------------------
Andrew Geissler84ad7c52020-06-27 00:00:16 -050066@@ -2489,4 +2492,74 @@
Brad Bishop286d45c2018-10-02 15:21:57 -040067 DONE;
68 }")
69
70+(define_expand "extvsi"
71+ [(set (match_operand:SI 0 "register_operand" "r")
72+ (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
73+ (match_operand:SI 2 "immediate_operand" "I")
74+ (match_operand:SI 3 "immediate_operand" "I")))]
75+"TARGET_HAS_BITFIELD"
76+"
77+{
78+ unsigned HOST_WIDE_INT len = UINTVAL (operands[2]);
79+ unsigned HOST_WIDE_INT pos = UINTVAL (operands[3]);
80+
81+ if ((len == 0) || (pos + len > 32) )
82+ FAIL;
83+
84+ ;;if (!register_operand (operands[1], VOIDmode))
85+ ;; FAIL;
86+ if (operands[0] == operands[1])
87+ FAIL;
88+ if (GET_CODE (operands[1]) == ASHIFT)
89+ FAIL;
90+;; operands[2] = GEN_INT(INTVAL(operands[2])+1 );
91+ emit_insn (gen_extv_32 (operands[0], operands[1],
92+ operands[2], operands[3]));
93+ DONE;
94+}")
95+
96+(define_insn "extv_32"
97+ [(set (match_operand:SI 0 "register_operand" "=r")
98+ (zero_extract:SI (match_operand:SI 1 "register_operand" "r")
99+ (match_operand:SI 2 "immediate_operand" "I")
100+ (match_operand:SI 3 "immediate_operand" "I")))]
101+ "TARGET_HAS_BITFIELD && (UINTVAL (operands[2]) > 0)
102+ && ((UINTVAL (operands[2]) + UINTVAL (operands[3])) <= 32)"
103+ "bsefi %0,%1,%2,%3"
104+ [(set_attr "type" "bshift")
105+ (set_attr "length" "4")])
106+
107+(define_expand "insvsi"
108+ [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
109+ (match_operand:SI 1 "immediate_operand" "I")
110+ (match_operand:SI 2 "immediate_operand" "I"))
111+ (match_operand:SI 3 "register_operand" "r"))]
112+ "TARGET_HAS_BITFIELD"
113+ "
114+{
115+ unsigned HOST_WIDE_INT len = UINTVAL (operands[1]);
116+ unsigned HOST_WIDE_INT pos = UINTVAL (operands[2]);
117+
118+ if (len <= 0 || pos + len > 32)
119+ FAIL;
120+
121+ ;;if (!register_operand (operands[0], VOIDmode))
122+ ;; FAIL;
123+
124+ emit_insn (gen_insv_32 (operands[0], operands[1],
125+ operands[2], operands[3]));
126+ DONE;
127+}")
128+
129+(define_insn "insv_32"
130+ [(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+r")
131+ (match_operand:SI 1 "immediate_operand" "I")
132+ (match_operand:SI 2 "immediate_operand" "I"))
133+ (match_operand:SI 3 "register_operand" "r"))]
134+ "TARGET_HAS_BITFIELD && UINTVAL (operands[1]) > 0
135+ && UINTVAL (operands[1]) + UINTVAL (operands[2]) <= 32"
136+ "bsifi %0, %3, %1, %2"
137+ [(set_attr "type" "bshift")
138+ (set_attr "length" "4")])
139+
140 (include "sync.md")
141--
Andrew Geisslera9ff2b32020-10-16 10:11:54 -05001422.17.1
Brad Bishop286d45c2018-10-02 15:21:57 -0400143