summaryrefslogtreecommitdiffstats
path: root/devel/mipsel-linux-binutils/files/patch-cc-loaddelay-2
blob: e7d77c107ad60cc51ac6d4d8f9d25d2ef87ea332 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
--- ../cambridge-src/binutils-2.8.1/gas/config/tc-mips.c	Thu Sep  9 00:09:29 1999
+++ binutils-2.8.1/gas/config/tc-mips.c	Fri Nov 10 20:28:11 2000
@@ -3079,12 +3079,14 @@
   else if (mips_pic == SVR4_PIC && ! mips_big_got)
     {
       expressionS ex;
+      /* If we're at mips2 or higher, we don't need nops after loads */
+      int use_load_delay = mips_opts.isa < 2;
 
       /* If this is a reference to an external symbol, we want
 	   lw		$reg,<sym>($gp)		(BFD_RELOC_MIPS_GOT16)
 	 Otherwise we want
 	   lw		$reg,<sym>($gp)		(BFD_RELOC_MIPS_GOT16)
-	   nop
+	   nop	       (if mips1)
 	   addiu	$reg,$reg,<sym>		(BFD_RELOC_LO16)
 	 If there is a constant, it must be added in after.  */
       ex.X_add_number = ep->X_add_number;
@@ -3093,9 +3095,11 @@
       macro_build ((char *) NULL, counter, ep,
 		   mips_opts.isa < 3 ? "lw" : "ld",
 		   "t,o(b)", reg, (int) BFD_RELOC_MIPS_GOT16, GP);
-      macro_build ((char *) NULL, counter, (expressionS *) NULL, "nop", "");
+      if (use_load_delay)
+        macro_build ((char *) NULL, counter, (expressionS *) NULL, "nop", "");
       p = frag_var (rs_machine_dependent, 4, 0,
-		    RELAX_ENCODE (0, 4, -8, 0, 0, mips_opts.warn_about_macros),
+		    RELAX_ENCODE (0, 4, use_load_delay ? -8 : -4, 0, 0, 
+				  mips_opts.warn_about_macros),
 		    ep->X_add_symbol, (offsetT) 0, (char *) NULL);
       macro_build (p, counter, ep,
 		   mips_opts.isa < 3 ? "addiu" : "daddiu",
@@ -3955,13 +3959,13 @@
 	       lw	$tempreg,<sym>($gp)	(BFD_RELOC_MIPS_GOT16)
 	     For a local symbol, we want
 	       lw	$tempreg,<sym>($gp)	(BFD_RELOC_MIPS_GOT16)
-	       nop
+	       nop	       (if mips1)
 	       addiu	$tempreg,$tempreg,<sym>	(BFD_RELOC_LO16)
 
 	     If we have a small constant, and this is a reference to
 	     an external symbol, we want
 	       lw	$tempreg,<sym>($gp)	(BFD_RELOC_MIPS_GOT16)
-	       nop
+	       nop	       (if mips1)
 	       addiu	$tempreg,$tempreg,<constant>
 	     For a local symbol, we want the same instruction
 	     sequence, but we output a BFD_RELOC_LO16 reloc on the
@@ -3976,6 +3980,10 @@
 	     For a local symbol, we want the same instruction
 	     sequence, but we output a BFD_RELOC_LO16 reloc on the
 	     addiu instruction.  */
+
+	  /* If we're at mips2 or higher, we don't need nops after loads */
+	  int use_load_delay = mips_opts.isa < 2;
+
 	  expr1.X_add_number = offset_expr.X_add_number;
 	  offset_expr.X_add_number = 0;
 	  frag_grow (32);
@@ -3986,7 +3994,7 @@
 	    {
 	      int off;
 
-	      if (breg == 0)
+	      if (breg == 0 || !use_load_delay)
 		off = 0;
 	      else
 		{
@@ -3997,14 +4005,19 @@
 			       "nop", "");
 		  off = 4;
 		}
-	      p = frag_var (rs_machine_dependent, 8 - off, 0,
-			    RELAX_ENCODE (0, 8 - off, -4 - off, 4 - off, 0,
+	      p = frag_var (rs_machine_dependent, 
+			    (use_load_delay ? 8 : 4) - off, 0,
+			    RELAX_ENCODE (0, 
+					  (use_load_delay ? 8 : 4) - off,
+					  -4 - off, 
+					  (use_load_delay ? 4 : 0) - off, 
+					  0,
 					  (breg == 0
 					   ? mips_opts.warn_about_macros
 					   : 0)),
 			    offset_expr.X_add_symbol, (offsetT) 0,
 			    (char *) NULL);
-	      if (breg == 0)
+	      if (breg == 0 && use_load_delay)
 		{
 		  macro_build (p, &icnt, (expressionS *) NULL, "nop", "");
 		  p += 4;
@@ -4019,13 +4032,14 @@
 	  else if (expr1.X_add_number >= -0x8000
 		   && expr1.X_add_number < 0x8000)
 	    {
-	      macro_build ((char *) NULL, &icnt, (expressionS *) NULL,
+	      if (use_load_delay) 
+		macro_build ((char *) NULL, &icnt, (expressionS *) NULL,
 			   "nop", "");
 	      macro_build ((char *) NULL, &icnt, &expr1,
 			   mips_opts.isa < 3 ? "addiu" : "daddiu",
 			   "t,r,j", tempreg, tempreg, (int) BFD_RELOC_LO16);
 	      (void) frag_var (rs_machine_dependent, 0, 0,
-			       RELAX_ENCODE (0, 0, -12, -4, 0, 0),
+			       RELAX_ENCODE (0, 0, (use_load_delay ? -12 : -8), -4, 0, 0),
 			       offset_expr.X_add_symbol, (offsetT) 0,
 			       (char *) NULL);
 	    }
@@ -4044,14 +4058,19 @@
 		off1 = 0;
 	      else
 		{
-		  macro_build ((char *) NULL, &icnt, (expressionS *) NULL,
-			       "nop", "");
+		  off1 = 0;
+		  if (mips_opts.isa < 2) 
+		    {
+		      macro_build ((char *) NULL, &icnt, (expressionS *) NULL,
+				   "nop", "");
+		      off1 -= 4;
+		    }
 		  macro_build ((char *) NULL, &icnt, (expressionS *) NULL,
 			       mips_opts.isa < 3 ? "addu" : "daddu",
 			       "d,v,t", treg, AT, breg);
+		  off1 -= 4;
 		  breg = 0;
 		  tempreg = treg;
-		  off1 = -8;
 		}
 
 	      /* Set mips_optimize around the lui instruction to avoid
@@ -4355,7 +4374,7 @@
 	  /* If this is a reference to an external symbol, and we are
 	     using a small GOT, we want
 	       lw	$25,<sym>($gp)		(BFD_RELOC_MIPS_CALL16)
-	       nop
+	       nop	       (if mips1)
 	       jalr	$25
 	       nop
 	       lw	$gp,cprestore($sp)
@@ -4370,7 +4389,7 @@
 	       lw	$gp,cprestore($sp)
 	     If the symbol is not external, we want
 	       lw	$25,<sym>($gp)		(BFD_RELOC_MIPS_GOT16)
-	       nop
+	       nop	       (if mips1)
 	       addiu	$25,$25,<sym>		(BFD_RELOC_LO16)
 	       jalr	$25
 	       nop
@@ -4378,14 +4397,18 @@
 	  frag_grow (40);
 	  if (! mips_big_got)
 	    {
+              int use_load_delay = mips_opts.isa < 2;
+
 	      macro_build ((char *) NULL, &icnt, &offset_expr,
 			   mips_opts.isa < 3 ? "lw" : "ld",
 			   "t,o(b)", PIC_CALL_REG,
 			   (int) BFD_RELOC_MIPS_CALL16, GP);
-	      macro_build ((char *) NULL, &icnt, (expressionS *) NULL,
-			   "nop", "");
+	      if (use_load_delay)
+		macro_build ((char *) NULL, &icnt, (expressionS *) NULL,
+			     "nop", "");
 	      p = frag_var (rs_machine_dependent, 4, 0,
-			    RELAX_ENCODE (0, 4, -8, 0, 0, 0),
+			    RELAX_ENCODE (0, 4, use_load_delay ? -8 : -4, 
+					  0, 0, 0),
 			    offset_expr.X_add_symbol, (offsetT) 0,
 			    (char *) NULL);
 	    }
@@ -4711,11 +4734,11 @@
 	{
 	  /* If this is a reference to an external symbol, we want
 	       lw	$tempreg,<sym>($gp)	(BFD_RELOC_MIPS_GOT16)
-	       nop
+	       nop	       (if mips1)
 	       <op>	$treg,0($tempreg)
 	     Otherwise we want
 	       lw	$tempreg,<sym>($gp)	(BFD_RELOC_MIPS_GOT16)
-	       nop
+	       nop	       (if mips1)
 	       addiu	$tempreg,$tempreg,<sym>	(BFD_RELOC_LO16)
 	       <op>	$treg,0($tempreg)
 	     If there is a base register, we add it to $tempreg before
@@ -4724,6 +4747,10 @@
 	     16 bits, because we have no way to load the upper 16 bits
 	     (actually, we could handle them for the subset of cases
 	     in which we are not using $at).  */
+
+	  /* If we're at mips2 or higher, we don't need nops after loads */
+	  int use_load_delay = mips_opts.isa < 2;
+
 	  assert (offset_expr.X_op == O_symbol);
 	  expr1.X_add_number = offset_expr.X_add_number;
 	  offset_expr.X_add_number = 0;
@@ -4734,9 +4761,10 @@
 	  macro_build ((char *) NULL, &icnt, &offset_expr,
 		       mips_opts.isa < 3 ? "lw" : "ld",
 		       "t,o(b)", tempreg, (int) BFD_RELOC_MIPS_GOT16, GP);
-	  macro_build ((char *) NULL, &icnt, (expressionS *) NULL, "nop", "");
+	  if (use_load_delay)
+	    macro_build ((char *) NULL, &icnt, (expressionS *) NULL, "nop", "");
 	  p = frag_var (rs_machine_dependent, 4, 0, 
-			RELAX_ENCODE (0, 4, -8, 0, 0, 0),
+			RELAX_ENCODE (0, 4, use_load_delay ? -8 : -4, 0, 0, 0),
 			offset_expr.X_add_symbol, (offsetT) 0,
 			(char *) NULL);
 	  macro_build (p, &icnt, &offset_expr,
@@ -5184,15 +5212,17 @@
       else if (mips_pic == SVR4_PIC && ! mips_big_got)
 	{
 	  int off;
+	  /* If we're at mips2 or higher, we don't need nops after loads */
+	  int use_load_delay = mips_opts.isa < 2;
 
 	  /* If this is a reference to an external symbol, we want
 	       lw	$at,<sym>($gp)		(BFD_RELOC_MIPS_GOT16)
-	       nop
+	       nop	       (if mips1)
 	       <op>	$treg,0($at)
 	       <op>	$treg+1,4($at)
 	     Otherwise we want
 	       lw	$at,<sym>($gp)		(BFD_RELOC_MIPS_GOT16)
-	       nop
+	       nop	       (if mips1)
 	       <op>	$treg,<sym>($at)	(BFD_RELOC_LO16)
 	       <op>	$treg+1,<sym>+4($at)	(BFD_RELOC_LO16)
 	     If there is a base register we add it to $at before the
@@ -5204,7 +5234,7 @@
 	  if (expr1.X_add_number < -0x8000
 	      || expr1.X_add_number >= 0x8000 - 4)
 	    as_bad ("PIC code offset overflow (max 16 signed bits)");
-	  if (breg == 0)
+	  if (breg == 0 || !use_load_delay)
 	    off = 0;
 	  else
 	    off = 4;
@@ -5212,7 +5242,8 @@
 	  macro_build ((char *) NULL, &icnt, &offset_expr,
 		       mips_opts.isa < 3 ? "lw" : "ld",
 		       "t,o(b)", AT, (int) BFD_RELOC_MIPS_GOT16, GP);
-	  macro_build ((char *) NULL, &icnt, (expressionS *) NULL, "nop", "");
+	  if (use_load_delay)
+	    macro_build ((char *) NULL, &icnt, (expressionS *) NULL, "nop", "");
 	  if (breg != 0)
 	    macro_build ((char *) NULL, &icnt, (expressionS *) NULL,
 			 mips_opts.isa < 3 ? "addu" : "daddu",
@@ -5234,7 +5265,7 @@
 	  mips_optimize = hold_mips_optimize;
 
 	  (void) frag_var (rs_machine_dependent, 0, 0,
-			   RELAX_ENCODE (0, 0, -16 - off, -8, 1, 0),
+			   RELAX_ENCODE (0, 0, -16 - off, use_load_delay ? -8 : -4, 1, 0),
 			   offset_expr.X_add_symbol, (offsetT) 0,
 			   (char *) NULL);
 	}
OpenPOWER on IntegriCloud