@@ -134,7 +134,16 @@ void Assembler::adrp(Register reg1, const Address &dest, uint64_t &byte_offset)
134
134
135
135
#undef __
136
136
137
- #define starti Instruction_aarch64 do_not_use (this ); set_current(&do_not_use)
137
+ #define starti Instruction_aarch64 current_insn (this );
138
+
139
+ #define f current_insn.f
140
+ #define sf current_insn.sf
141
+ #define rf current_insn.rf
142
+ #define srf current_insn.srf
143
+ #define zrf current_insn.zrf
144
+ #define prf current_insn.prf
145
+ #define pgrf current_insn.pgrf
146
+ #define fixed current_insn.fixed
138
147
139
148
void Assembler::adr (Register Rd, address adr) {
140
149
intptr_t offset = adr - pc ();
@@ -156,6 +165,53 @@ void Assembler::adrp(Register reg1, const Address &dest, uint64_t &byte_offset)
156
165
rf (Rd, 0 );
157
166
}
158
167
168
+ // An "all-purpose" add/subtract immediate, per ARM documentation:
169
+ // A "programmer-friendly" assembler may accept a negative immediate
170
+ // between -(2^24 -1) and -1 inclusive, causing it to convert a
171
+ // requested ADD operation to a SUB, or vice versa, and then encode
172
+ // the absolute value of the immediate as for uimm24.
173
+ void Assembler::add_sub_immediate (Instruction_aarch64 ¤t_insn,
174
+ Register Rd, Register Rn, unsigned uimm, int op,
175
+ int negated_op) {
176
+ bool sets_flags = op & 1 ; // this op sets flags
177
+ union {
178
+ unsigned u;
179
+ int imm;
180
+ };
181
+ u = uimm;
182
+ bool shift = false ;
183
+ bool neg = imm < 0 ;
184
+ if (neg) {
185
+ imm = -imm;
186
+ op = negated_op;
187
+ }
188
+ assert (Rd != sp || imm % 16 == 0 , " misaligned stack" );
189
+ if (imm >= (1 << 11 )
190
+ && ((imm >> 12 ) << 12 == imm)) {
191
+ imm >>= 12 ;
192
+ shift = true ;
193
+ }
194
+ f (op, 31 , 29 ), f (0b10001 , 28 , 24 ), f (shift, 23 , 22 ), f (imm, 21 , 10 );
195
+
196
+ // add/subtract immediate ops with the S bit set treat r31 as zr;
197
+ // with S unset they use sp.
198
+ if (sets_flags)
199
+ zrf (Rd, 0 );
200
+ else
201
+ srf (Rd, 0 );
202
+
203
+ srf (Rn, 5 );
204
+ }
205
+
206
+ #undef f
207
+ #undef sf
208
+ #undef rf
209
+ #undef srf
210
+ #undef zrf
211
+ #undef prf
212
+ #undef pgrf
213
+ #undef fixed
214
+
159
215
#undef starti
160
216
161
217
Address::Address (address target, relocInfo::relocType rtype) : _mode(literal){
@@ -260,43 +316,6 @@ void Assembler::wrap_label(Label &L, prfop op, prefetch_insn insn) {
260
316
}
261
317
}
262
318
263
- // An "all-purpose" add/subtract immediate, per ARM documentation:
264
- // A "programmer-friendly" assembler may accept a negative immediate
265
- // between -(2^24 -1) and -1 inclusive, causing it to convert a
266
- // requested ADD operation to a SUB, or vice versa, and then encode
267
- // the absolute value of the immediate as for uimm24.
268
- void Assembler::add_sub_immediate (Register Rd, Register Rn, unsigned uimm, int op,
269
- int negated_op) {
270
- bool sets_flags = op & 1 ; // this op sets flags
271
- union {
272
- unsigned u;
273
- int imm;
274
- };
275
- u = uimm;
276
- bool shift = false ;
277
- bool neg = imm < 0 ;
278
- if (neg) {
279
- imm = -imm;
280
- op = negated_op;
281
- }
282
- assert (Rd != sp || imm % 16 == 0 , " misaligned stack" );
283
- if (imm >= (1 << 11 )
284
- && ((imm >> 12 ) << 12 == imm)) {
285
- imm >>= 12 ;
286
- shift = true ;
287
- }
288
- f (op, 31 , 29 ), f (0b10001 , 28 , 24 ), f (shift, 23 , 22 ), f (imm, 21 , 10 );
289
-
290
- // add/subtract immediate ops with the S bit set treat r31 as zr;
291
- // with S unset they use sp.
292
- if (sets_flags)
293
- zrf (Rd, 0 );
294
- else
295
- srf (Rd, 0 );
296
-
297
- srf (Rn, 5 );
298
- }
299
-
300
319
bool Assembler::operand_valid_for_add_sub_immediate (int64_t imm) {
301
320
bool shift = false ;
302
321
uint64_t uimm = (uint64_t )uabs ((jlong)imm);
0 commit comments