summaryrefslogtreecommitdiffstats
path: root/meta-microblaze/recipes-devtools/binutils/binutils/0008-Add-new-bit-field-instructions.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-microblaze/recipes-devtools/binutils/binutils/0008-Add-new-bit-field-instructions.patch')
-rw-r--r--meta-microblaze/recipes-devtools/binutils/binutils/0008-Add-new-bit-field-instructions.patch245
1 files changed, 0 insertions, 245 deletions
diff --git a/meta-microblaze/recipes-devtools/binutils/binutils/0008-Add-new-bit-field-instructions.patch b/meta-microblaze/recipes-devtools/binutils/binutils/0008-Add-new-bit-field-instructions.patch
deleted file mode 100644
index d2e6424b..00000000
--- a/meta-microblaze/recipes-devtools/binutils/binutils/0008-Add-new-bit-field-instructions.patch
+++ /dev/null
@@ -1,245 +0,0 @@
1From c02813b6a27e6eed281609e5d696bb67ac74c804 Mon Sep 17 00:00:00 2001
2From: Nagaraju Mekala <nmekala@xilix.com>
3Date: Mon, 18 Jul 2016 12:24:28 +0530
4Subject: [PATCH 08/34] 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
13
14Signed-off-by :Nagaraju Mekala <nmekala@xilix.com>
15
16Conflicts:
17 opcodes/microblaze-dis.c
18
19Conflicts:
20 gas/config/tc-microblaze.c
21 opcodes/microblaze-opc.h
22Upstream-Status: Pending
23
24Signed-off-by: Mark Hatle <mark.hatle@amd.com>
25
26---
27 gas/config/tc-microblaze.c | 71 +++++++++++++++++++++++++++++++++++++-
28 opcodes/microblaze-dis.c | 20 +++++++++--
29 opcodes/microblaze-opc.h | 12 ++++++-
30 opcodes/microblaze-opcm.h | 6 +++-
31 4 files changed, 104 insertions(+), 5 deletions(-)
32
33diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
34index 8018d1f5686..1cb9b2519c3 100644
35--- a/gas/config/tc-microblaze.c
36+++ b/gas/config/tc-microblaze.c
37@@ -917,7 +917,7 @@ md_assemble (char * str)
38 unsigned reg2;
39 unsigned reg3;
40 unsigned isize;
41- unsigned int immed = 0, temp;
42+ unsigned int immed = 0, immed2 = 0, temp;
43 expressionS exp;
44 char name[20];
45
46@@ -1178,7 +1178,76 @@ md_assemble (char * str)
47 inst |= (reg2 << RA_LOW) & RA_MASK;
48 inst |= (immed << IMM_LOW) & IMM5_MASK;
49 break;
50+ case INST_TYPE_RD_R1_IMM5_IMM5:
51+ if (strcmp (op_end, ""))
52+ op_end = parse_reg (op_end + 1, &reg1); /* Get rd. */
53+ else
54+ {
55+ as_fatal (_("Error in statement syntax"));
56+ reg1 = 0;
57+ }
58+ if (strcmp (op_end, ""))
59+ op_end = parse_reg (op_end + 1, &reg2); /* Get r1. */
60+ else
61+ {
62+ as_fatal (_("Error in statement syntax"));
63+ reg2 = 0;
64+ }
65+
66+ /* Check for spl registers. */
67+ if (check_spl_reg (&reg1))
68+ as_fatal (_("Cannot use special register with this instruction"));
69+ if (check_spl_reg (&reg2))
70+ as_fatal (_("Cannot use special register with this instruction"));
71
72+ /* Width immediate value. */
73+ if (strcmp (op_end, ""))
74+ op_end = parse_imm (op_end + 1, &exp, MIN_IMM_WIDTH, MAX_IMM_WIDTH);
75+ else
76+ as_fatal (_("Error in statement syntax"));
77+ if (exp.X_op != O_constant)
78+ {
79+ as_warn (_("Symbol used as immediate width value for bit field instruction"));
80+ immed = 1;
81+ }
82+ else
83+ immed = exp.X_add_number;
84+ if (opcode->instr == bsefi && immed > 31)
85+ as_fatal (_("Width value must be less than 32"));
86+
87+ /* Shift immediate value. */
88+ if (strcmp (op_end, ""))
89+ op_end = parse_imm (op_end + 1, &exp, MIN_IMM, MAX_IMM);
90+ else
91+ as_fatal (_("Error in statement syntax"));
92+ if (exp.X_op != O_constant)
93+ {
94+ as_warn (_("Symbol used as immediate shift value for bit field instruction"));
95+ immed2 = 0;
96+ }
97+ else
98+ {
99+ output = frag_more (isize);
100+ immed2 = exp.X_add_number;
101+ }
102+ if (immed2 != (immed2 % 32))
103+ {
104+ as_warn (_("Shift value greater than 32. using <value %% 32>"));
105+ immed2 = immed2 % 32;
106+ }
107+
108+ /* Check combined value. */
109+ if (immed + immed2 > 32)
110+ as_fatal (_("Width value + shift value must not be greater than 32"));
111+
112+ inst |= (reg1 << RD_LOW) & RD_MASK;
113+ inst |= (reg2 << RA_LOW) & RA_MASK;
114+ if (opcode->instr == bsefi)
115+ inst |= (immed & IMM5_MASK) << IMM_WIDTH_LOW; /* bsefi */
116+ else
117+ inst |= ((immed + immed2 - 1) & IMM5_MASK) << IMM_WIDTH_LOW; /* bsifi */
118+ inst |= (immed2 << IMM_LOW) & IMM5_MASK;
119+ break;
120 case INST_TYPE_R1_R2:
121 if (strcmp (op_end, ""))
122 op_end = parse_reg (op_end + 1, &reg1); /* Get r1. */
123diff --git a/opcodes/microblaze-dis.c b/opcodes/microblaze-dis.c
124index b057492ba93..f57b98fc9f7 100644
125--- a/opcodes/microblaze-dis.c
126+++ b/opcodes/microblaze-dis.c
127@@ -91,7 +91,19 @@ get_field_imm5_mbar (struct string_buf *buf, long instr)
128 }
129
130 static char *
131-get_field_rfsl (struct string_buf *buf, long instr)
132+get_field_imm5width (struct string_buf *buf, long instr)
133+{
134+ char *p = strbuf (buf);
135+
136+ if (instr & 0x00004000)
137+ sprintf (p, "%d", (short)(((instr & IMM5_WIDTH_MASK) >> IMM_WIDTH_LOW))); /* bsefi */
138+ else
139+ sprintf (p, "%d", (short)(((instr & IMM5_WIDTH_MASK) >> IMM_WIDTH_LOW) - ((instr & IMM5_MASK) >> IMM_LOW) + 1)); /* bsifi */
140+ return p;
141+}
142+
143+static char *
144+get_field_rfsl (struct string_buf *buf,long instr)
145 {
146 char *p = strbuf (buf);
147
148@@ -427,7 +439,11 @@ print_insn_microblaze (bfd_vma memaddr, struct disassemble_info * info)
149 /* For mbar 16 or sleep insn. */
150 case INST_TYPE_NONE:
151 break;
152- /* For tuqula instruction */
153+ /* For bit field insns. */
154+ case INST_TYPE_RD_R1_IMM5_IMM5:
155+ print_func (stream, "\t%s, %s, %s, %s", get_field_rd (&buf, inst),get_field_r1(&buf, inst),get_field_imm5width (&buf, inst), get_field_imm5 (&buf, inst));
156+ break;
157+ /* For tuqula instruction */
158 case INST_TYPE_RD:
159 print_func (stream, "\t%s", get_field_rd (&buf, inst));
160 break;
161diff --git a/opcodes/microblaze-opc.h b/opcodes/microblaze-opc.h
162index d3f8e36199e..825c639a41e 100644
163--- a/opcodes/microblaze-opc.h
164+++ b/opcodes/microblaze-opc.h
165@@ -59,6 +59,9 @@
166 /* For mbar. */
167 #define INST_TYPE_IMM5 20
168
169+/* For bsefi and bsifi */
170+#define INST_TYPE_RD_R1_IMM5_IMM5 21
171+
172 #define INST_TYPE_NONE 25
173
174
175@@ -89,7 +92,9 @@
176 #define OPCODE_MASK_H124 0xFFFF07FF /* High 16, and low 11 bits. */
177 #define OPCODE_MASK_H1234 0xFFFFFFFF /* All 32 bits. */
178 #define OPCODE_MASK_H3 0xFC000600 /* High 6 bits and bits 21, 22. */
179+#define OPCODE_MASK_H3B 0xFC00C600 /* High 6 bits and bits 16, 17, 21, 22. */
180 #define OPCODE_MASK_H32 0xFC00FC00 /* High 6 bits and bit 16-21. */
181+#define OPCODE_MASK_H32B 0xFC00C000 /* High 6 bits and bit 16, 17. */
182 #define OPCODE_MASK_H34B 0xFC0000FF /* High 6 bits and low 8 bits. */
183 #define OPCODE_MASK_H35B 0xFC0004FF /* High 6 bits and low 9 bits. */
184 #define OPCODE_MASK_H34C 0xFC0007E0 /* High 6 bits and bits 21-26. */
185@@ -102,7 +107,7 @@
186 #define DELAY_SLOT 1
187 #define NO_DELAY_SLOT 0
188
189-#define MAX_OPCODES 291
190+#define MAX_OPCODES 301
191
192 const struct op_code_struct
193 {
194@@ -159,6 +164,8 @@ const struct op_code_struct
195 {"bslli", INST_TYPE_RD_R1_IMM5, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000400, OPCODE_MASK_H3, bslli, barrel_shift_inst },
196 {"bsrai", INST_TYPE_RD_R1_IMM5, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000200, OPCODE_MASK_H3, bsrai, barrel_shift_inst },
197 {"bsrli", INST_TYPE_RD_R1_IMM5, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000000, OPCODE_MASK_H3, bsrli, barrel_shift_inst },
198+ {"bsefi", INST_TYPE_RD_R1_IMM5_IMM5, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64004000, OPCODE_MASK_H32B, bsefi, barrel_shift_inst },
199+ {"bsifi", INST_TYPE_RD_R1_IMM5_IMM5, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64008000, OPCODE_MASK_H32B, bsifi, barrel_shift_inst },
200 {"or", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x80000000, OPCODE_MASK_H4, microblaze_or, logical_inst },
201 {"and", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x84000000, OPCODE_MASK_H4, microblaze_and, logical_inst },
202 {"xor", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x88000000, OPCODE_MASK_H4, microblaze_xor, logical_inst },
203@@ -438,5 +445,8 @@ char pvr_register_prefix[] = "rpvr";
204 #define MIN_IMM5 ((int) 0x00000000)
205 #define MAX_IMM5 ((int) 0x0000001f)
206
207+#define MIN_IMM_WIDTH ((int) 0x00000001)
208+#define MAX_IMM_WIDTH ((int) 0x00000020)
209+
210 #endif /* MICROBLAZE_OPC */
211
212diff --git a/opcodes/microblaze-opcm.h b/opcodes/microblaze-opcm.h
213index ad964560c17..aa3401610d9 100644
214--- a/opcodes/microblaze-opcm.h
215+++ b/opcodes/microblaze-opcm.h
216@@ -29,7 +29,7 @@ enum microblaze_instr
217 addi, rsubi, addic, rsubic, addik, rsubik, addikc, rsubikc, mul,
218 mulh, mulhu, mulhsu,swapb,swaph,
219 idiv, idivu, bsll, bsra, bsrl, get, put, nget, nput, cget, cput,
220- ncget, ncput, muli, bslli, bsrai, bsrli, mului,
221+ ncget, ncput, muli, bslli, bsrai, bsrli, bsefi, bsifi, mului,
222 /* 'or/and/xor' are C++ keywords. */
223 microblaze_or, microblaze_and, microblaze_xor,
224 andn, pcmpbf, pcmpbc, pcmpeq, pcmpne, sra, src, srl, sext8, sext16,
225@@ -130,6 +130,7 @@ enum microblaze_instr_type
226 #define RB_LOW 11 /* Low bit for RB. */
227 #define IMM_LOW 0 /* Low bit for immediate. */
228 #define IMM_MBAR 21 /* low bit for mbar instruction. */
229+#define IMM_WIDTH_LOW 6 /* Low bit for immediate width */
230
231 #define RD_MASK 0x03E00000
232 #define RA_MASK 0x001F0000
233@@ -142,6 +143,9 @@ enum microblaze_instr_type
234 /* Imm mask for mbar. */
235 #define IMM5_MBAR_MASK 0x03E00000
236
237+/* Imm mask for extract/insert width. */
238+#define IMM5_WIDTH_MASK 0x000007C0
239+
240 /* FSL imm mask for get, put instructions. */
241 #define RFSL_MASK 0x000000F
242
243--
2442.37.1 (Apple Git-137.1)
245