blob: b212958ddb5697862743b623278c4a85c13f35c4 [file] [log] [blame]
Andreas Gampe57b34292015-01-14 15:45:59 -08001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ART_COMPILER_UTILS_MIPS64_ASSEMBLER_MIPS64_H_
18#define ART_COMPILER_UTILS_MIPS64_ASSEMBLER_MIPS64_H_
19
Alexey Frunze19f6c692016-11-30 19:19:55 -080020#include <deque>
Alexey Frunzea0e87b02015-09-24 22:57:20 -070021#include <utility>
Andreas Gampe57b34292015-01-14 15:45:59 -080022#include <vector>
23
Goran Jakovljevic27af9372017-03-15 15:31:34 +010024#include "arch/mips64/instruction_set_features_mips64.h"
Alexey Frunze19f6c692016-11-30 19:19:55 -080025#include "base/arena_containers.h"
Andreas Gampe3b165bc2016-08-01 22:07:04 -070026#include "base/enums.h"
Andreas Gampe57b34292015-01-14 15:45:59 -080027#include "base/macros.h"
28#include "constants_mips64.h"
29#include "globals.h"
30#include "managed_register_mips64.h"
Andreas Gampe57b34292015-01-14 15:45:59 -080031#include "offsets.h"
Alexey Frunzea0e87b02015-09-24 22:57:20 -070032#include "utils/assembler.h"
Andreas Gampe3b165bc2016-08-01 22:07:04 -070033#include "utils/jni_macro_assembler.h"
Alexey Frunzea0e87b02015-09-24 22:57:20 -070034#include "utils/label.h"
Andreas Gampe57b34292015-01-14 15:45:59 -080035
36namespace art {
37namespace mips64 {
38
Chris Larsenc733dca2016-05-13 16:11:47 -070039enum LoadConst64Path {
40 kLoadConst64PathZero = 0x0,
41 kLoadConst64PathOri = 0x1,
42 kLoadConst64PathDaddiu = 0x2,
43 kLoadConst64PathLui = 0x4,
44 kLoadConst64PathLuiOri = 0x8,
45 kLoadConst64PathOriDahi = 0x10,
46 kLoadConst64PathOriDati = 0x20,
47 kLoadConst64PathLuiDahi = 0x40,
48 kLoadConst64PathLuiDati = 0x80,
49 kLoadConst64PathDaddiuDsrlX = 0x100,
50 kLoadConst64PathOriDsllX = 0x200,
51 kLoadConst64PathDaddiuDsllX = 0x400,
52 kLoadConst64PathLuiOriDsllX = 0x800,
53 kLoadConst64PathOriDsllXOri = 0x1000,
54 kLoadConst64PathDaddiuDsllXOri = 0x2000,
55 kLoadConst64PathDaddiuDahi = 0x4000,
56 kLoadConst64PathDaddiuDati = 0x8000,
57 kLoadConst64PathDinsu1 = 0x10000,
58 kLoadConst64PathDinsu2 = 0x20000,
59 kLoadConst64PathCatchAll = 0x40000,
60 kLoadConst64PathAllPaths = 0x7ffff,
61};
62
63template <typename Asm>
64void TemplateLoadConst32(Asm* a, GpuRegister rd, int32_t value) {
65 if (IsUint<16>(value)) {
66 // Use OR with (unsigned) immediate to encode 16b unsigned int.
67 a->Ori(rd, ZERO, value);
68 } else if (IsInt<16>(value)) {
69 // Use ADD with (signed) immediate to encode 16b signed int.
70 a->Addiu(rd, ZERO, value);
71 } else {
72 // Set 16 most significant bits of value. The "lui" instruction
73 // also clears the 16 least significant bits to zero.
74 a->Lui(rd, value >> 16);
75 if (value & 0xFFFF) {
76 // If the 16 least significant bits are non-zero, set them
77 // here.
78 a->Ori(rd, rd, value);
79 }
80 }
81}
82
83static inline int InstrCountForLoadReplicatedConst32(int64_t value) {
84 int32_t x = Low32Bits(value);
85 int32_t y = High32Bits(value);
86
87 if (x == y) {
88 return (IsUint<16>(x) || IsInt<16>(x) || ((x & 0xFFFF) == 0 && IsInt<16>(value >> 16))) ? 2 : 3;
89 }
90
91 return INT_MAX;
92}
93
94template <typename Asm, typename Rtype, typename Vtype>
95void TemplateLoadConst64(Asm* a, Rtype rd, Vtype value) {
96 int bit31 = (value & UINT64_C(0x80000000)) != 0;
97 int rep32_count = InstrCountForLoadReplicatedConst32(value);
98
99 // Loads with 1 instruction.
100 if (IsUint<16>(value)) {
101 // 64-bit value can be loaded as an unsigned 16-bit number.
102 a->RecordLoadConst64Path(kLoadConst64PathOri);
103 a->Ori(rd, ZERO, value);
104 } else if (IsInt<16>(value)) {
105 // 64-bit value can be loaded as an signed 16-bit number.
106 a->RecordLoadConst64Path(kLoadConst64PathDaddiu);
107 a->Daddiu(rd, ZERO, value);
108 } else if ((value & 0xFFFF) == 0 && IsInt<16>(value >> 16)) {
109 // 64-bit value can be loaded as an signed 32-bit number which has all
110 // of its 16 least significant bits set to zero.
111 a->RecordLoadConst64Path(kLoadConst64PathLui);
112 a->Lui(rd, value >> 16);
113 } else if (IsInt<32>(value)) {
114 // Loads with 2 instructions.
115 // 64-bit value can be loaded as an signed 32-bit number which has some
116 // or all of its 16 least significant bits set to one.
117 a->RecordLoadConst64Path(kLoadConst64PathLuiOri);
118 a->Lui(rd, value >> 16);
119 a->Ori(rd, rd, value);
120 } else if ((value & 0xFFFF0000) == 0 && IsInt<16>(value >> 32)) {
121 // 64-bit value which consists of an unsigned 16-bit value in its
122 // least significant 32-bits, and a signed 16-bit value in its
123 // most significant 32-bits.
124 a->RecordLoadConst64Path(kLoadConst64PathOriDahi);
125 a->Ori(rd, ZERO, value);
126 a->Dahi(rd, value >> 32);
127 } else if ((value & UINT64_C(0xFFFFFFFF0000)) == 0) {
128 // 64-bit value which consists of an unsigned 16-bit value in its
129 // least significant 48-bits, and a signed 16-bit value in its
130 // most significant 16-bits.
131 a->RecordLoadConst64Path(kLoadConst64PathOriDati);
132 a->Ori(rd, ZERO, value);
133 a->Dati(rd, value >> 48);
134 } else if ((value & 0xFFFF) == 0 &&
135 (-32768 - bit31) <= (value >> 32) && (value >> 32) <= (32767 - bit31)) {
136 // 16 LSBs (Least Significant Bits) all set to zero.
137 // 48 MSBs (Most Significant Bits) hold a signed 32-bit value.
138 a->RecordLoadConst64Path(kLoadConst64PathLuiDahi);
139 a->Lui(rd, value >> 16);
140 a->Dahi(rd, (value >> 32) + bit31);
141 } else if ((value & 0xFFFF) == 0 && ((value >> 31) & 0x1FFFF) == ((0x20000 - bit31) & 0x1FFFF)) {
142 // 16 LSBs all set to zero.
143 // 48 MSBs hold a signed value which can't be represented by signed
144 // 32-bit number, and the middle 16 bits are all zero, or all one.
145 a->RecordLoadConst64Path(kLoadConst64PathLuiDati);
146 a->Lui(rd, value >> 16);
147 a->Dati(rd, (value >> 48) + bit31);
148 } else if (IsInt<16>(static_cast<int32_t>(value)) &&
149 (-32768 - bit31) <= (value >> 32) && (value >> 32) <= (32767 - bit31)) {
150 // 32 LSBs contain an unsigned 16-bit number.
151 // 32 MSBs contain a signed 16-bit number.
152 a->RecordLoadConst64Path(kLoadConst64PathDaddiuDahi);
153 a->Daddiu(rd, ZERO, value);
154 a->Dahi(rd, (value >> 32) + bit31);
155 } else if (IsInt<16>(static_cast<int32_t>(value)) &&
156 ((value >> 31) & 0x1FFFF) == ((0x20000 - bit31) & 0x1FFFF)) {
157 // 48 LSBs contain an unsigned 16-bit number.
158 // 16 MSBs contain a signed 16-bit number.
159 a->RecordLoadConst64Path(kLoadConst64PathDaddiuDati);
160 a->Daddiu(rd, ZERO, value);
161 a->Dati(rd, (value >> 48) + bit31);
162 } else if (IsPowerOfTwo(value + UINT64_C(1))) {
163 // 64-bit values which have their "n" MSBs set to one, and their
164 // "64-n" LSBs set to zero. "n" must meet the restrictions 0 < n < 64.
165 int shift_cnt = 64 - CTZ(value + UINT64_C(1));
166 a->RecordLoadConst64Path(kLoadConst64PathDaddiuDsrlX);
167 a->Daddiu(rd, ZERO, -1);
168 if (shift_cnt < 32) {
169 a->Dsrl(rd, rd, shift_cnt);
170 } else {
171 a->Dsrl32(rd, rd, shift_cnt & 31);
172 }
173 } else {
174 int shift_cnt = CTZ(value);
175 int64_t tmp = value >> shift_cnt;
176 a->RecordLoadConst64Path(kLoadConst64PathOriDsllX);
177 if (IsUint<16>(tmp)) {
178 // Value can be computed by loading a 16-bit unsigned value, and
179 // then shifting left.
180 a->Ori(rd, ZERO, tmp);
181 if (shift_cnt < 32) {
182 a->Dsll(rd, rd, shift_cnt);
183 } else {
184 a->Dsll32(rd, rd, shift_cnt & 31);
185 }
186 } else if (IsInt<16>(tmp)) {
187 // Value can be computed by loading a 16-bit signed value, and
188 // then shifting left.
189 a->RecordLoadConst64Path(kLoadConst64PathDaddiuDsllX);
190 a->Daddiu(rd, ZERO, tmp);
191 if (shift_cnt < 32) {
192 a->Dsll(rd, rd, shift_cnt);
193 } else {
194 a->Dsll32(rd, rd, shift_cnt & 31);
195 }
196 } else if (rep32_count < 3) {
197 // Value being loaded has 32 LSBs equal to the 32 MSBs, and the
198 // value loaded into the 32 LSBs can be loaded with a single
199 // MIPS instruction.
200 a->LoadConst32(rd, value);
201 a->Dinsu(rd, rd, 32, 32);
202 a->RecordLoadConst64Path(kLoadConst64PathDinsu1);
203 } else if (IsInt<32>(tmp)) {
204 // Loads with 3 instructions.
205 // Value can be computed by loading a 32-bit signed value, and
206 // then shifting left.
207 a->RecordLoadConst64Path(kLoadConst64PathLuiOriDsllX);
208 a->Lui(rd, tmp >> 16);
209 a->Ori(rd, rd, tmp);
210 if (shift_cnt < 32) {
211 a->Dsll(rd, rd, shift_cnt);
212 } else {
213 a->Dsll32(rd, rd, shift_cnt & 31);
214 }
215 } else {
216 shift_cnt = 16 + CTZ(value >> 16);
217 tmp = value >> shift_cnt;
218 if (IsUint<16>(tmp)) {
219 // Value can be computed by loading a 16-bit unsigned value,
220 // shifting left, and "or"ing in another 16-bit unsigned value.
221 a->RecordLoadConst64Path(kLoadConst64PathOriDsllXOri);
222 a->Ori(rd, ZERO, tmp);
223 if (shift_cnt < 32) {
224 a->Dsll(rd, rd, shift_cnt);
225 } else {
226 a->Dsll32(rd, rd, shift_cnt & 31);
227 }
228 a->Ori(rd, rd, value);
229 } else if (IsInt<16>(tmp)) {
230 // Value can be computed by loading a 16-bit signed value,
231 // shifting left, and "or"ing in a 16-bit unsigned value.
232 a->RecordLoadConst64Path(kLoadConst64PathDaddiuDsllXOri);
233 a->Daddiu(rd, ZERO, tmp);
234 if (shift_cnt < 32) {
235 a->Dsll(rd, rd, shift_cnt);
236 } else {
237 a->Dsll32(rd, rd, shift_cnt & 31);
238 }
239 a->Ori(rd, rd, value);
240 } else if (rep32_count < 4) {
241 // Value being loaded has 32 LSBs equal to the 32 MSBs, and the
242 // value in the 32 LSBs requires 2 MIPS instructions to load.
243 a->LoadConst32(rd, value);
244 a->Dinsu(rd, rd, 32, 32);
245 a->RecordLoadConst64Path(kLoadConst64PathDinsu2);
246 } else {
247 // Loads with 3-4 instructions.
248 // Catch-all case to get any other 64-bit values which aren't
249 // handled by special cases above.
250 uint64_t tmp2 = value;
251 a->RecordLoadConst64Path(kLoadConst64PathCatchAll);
252 a->LoadConst32(rd, value);
253 if (bit31) {
254 tmp2 += UINT64_C(0x100000000);
255 }
256 if (((tmp2 >> 32) & 0xFFFF) != 0) {
257 a->Dahi(rd, tmp2 >> 32);
258 }
259 if (tmp2 & UINT64_C(0x800000000000)) {
260 tmp2 += UINT64_C(0x1000000000000);
261 }
262 if ((tmp2 >> 48) != 0) {
263 a->Dati(rd, tmp2 >> 48);
264 }
265 }
266 }
267 }
268}
269
Goran Jakovljevic5a9e51d2017-03-16 16:11:43 +0000270static constexpr size_t kMips64HalfwordSize = 2;
Lazar Trsicd9672662015-09-03 17:33:01 +0200271static constexpr size_t kMips64WordSize = 4;
272static constexpr size_t kMips64DoublewordSize = 8;
Alexey Frunzea0e87b02015-09-24 22:57:20 -0700273
Andreas Gampe57b34292015-01-14 15:45:59 -0800274enum LoadOperandType {
275 kLoadSignedByte,
276 kLoadUnsignedByte,
277 kLoadSignedHalfword,
278 kLoadUnsignedHalfword,
279 kLoadWord,
Douglas Leungd90957f2015-04-30 19:22:49 -0700280 kLoadUnsignedWord,
Goran Jakovljevicd8b6a532017-04-20 11:42:30 +0200281 kLoadDoubleword,
282 kLoadQuadword
Andreas Gampe57b34292015-01-14 15:45:59 -0800283};
284
285enum StoreOperandType {
286 kStoreByte,
287 kStoreHalfword,
288 kStoreWord,
Goran Jakovljevicd8b6a532017-04-20 11:42:30 +0200289 kStoreDoubleword,
290 kStoreQuadword
Andreas Gampe57b34292015-01-14 15:45:59 -0800291};
292
Chris Larsen14500822015-10-01 11:35:18 -0700293// Used to test the values returned by ClassS/ClassD.
294enum FPClassMaskType {
295 kSignalingNaN = 0x001,
296 kQuietNaN = 0x002,
297 kNegativeInfinity = 0x004,
298 kNegativeNormal = 0x008,
299 kNegativeSubnormal = 0x010,
300 kNegativeZero = 0x020,
301 kPositiveInfinity = 0x040,
302 kPositiveNormal = 0x080,
303 kPositiveSubnormal = 0x100,
304 kPositiveZero = 0x200,
305};
306
Alexey Frunzea0e87b02015-09-24 22:57:20 -0700307class Mips64Label : public Label {
308 public:
309 Mips64Label() : prev_branch_id_plus_one_(0) {}
310
311 Mips64Label(Mips64Label&& src)
312 : Label(std::move(src)), prev_branch_id_plus_one_(src.prev_branch_id_plus_one_) {}
313
314 private:
315 uint32_t prev_branch_id_plus_one_; // To get distance from preceding branch, if any.
316
317 friend class Mips64Assembler;
318 DISALLOW_COPY_AND_ASSIGN(Mips64Label);
319};
320
Alexey Frunze19f6c692016-11-30 19:19:55 -0800321// Assembler literal is a value embedded in code, retrieved using a PC-relative load.
322class Literal {
323 public:
324 static constexpr size_t kMaxSize = 8;
325
326 Literal(uint32_t size, const uint8_t* data)
327 : label_(), size_(size) {
328 DCHECK_LE(size, Literal::kMaxSize);
329 memcpy(data_, data, size);
330 }
331
332 template <typename T>
333 T GetValue() const {
334 DCHECK_EQ(size_, sizeof(T));
335 T value;
336 memcpy(&value, data_, sizeof(T));
337 return value;
338 }
339
340 uint32_t GetSize() const {
341 return size_;
342 }
343
344 const uint8_t* GetData() const {
345 return data_;
346 }
347
348 Mips64Label* GetLabel() {
349 return &label_;
350 }
351
352 const Mips64Label* GetLabel() const {
353 return &label_;
354 }
355
356 private:
357 Mips64Label label_;
358 const uint32_t size_;
359 uint8_t data_[kMaxSize];
360
361 DISALLOW_COPY_AND_ASSIGN(Literal);
362};
363
Alexey Frunze0960ac52016-12-20 17:24:59 -0800364// Jump table: table of labels emitted after the code and before the literals. Similar to literals.
365class JumpTable {
366 public:
367 explicit JumpTable(std::vector<Mips64Label*>&& labels)
368 : label_(), labels_(std::move(labels)) {
369 }
370
371 size_t GetSize() const {
372 return labels_.size() * sizeof(uint32_t);
373 }
374
375 const std::vector<Mips64Label*>& GetData() const {
376 return labels_;
377 }
378
379 Mips64Label* GetLabel() {
380 return &label_;
381 }
382
383 const Mips64Label* GetLabel() const {
384 return &label_;
385 }
386
387 private:
388 Mips64Label label_;
389 std::vector<Mips64Label*> labels_;
390
391 DISALLOW_COPY_AND_ASSIGN(JumpTable);
392};
393
Alexey Frunzea0e87b02015-09-24 22:57:20 -0700394// Slowpath entered when Thread::Current()->_exception is non-null.
395class Mips64ExceptionSlowPath {
396 public:
397 explicit Mips64ExceptionSlowPath(Mips64ManagedRegister scratch, size_t stack_adjust)
398 : scratch_(scratch), stack_adjust_(stack_adjust) {}
399
400 Mips64ExceptionSlowPath(Mips64ExceptionSlowPath&& src)
401 : scratch_(src.scratch_),
402 stack_adjust_(src.stack_adjust_),
403 exception_entry_(std::move(src.exception_entry_)) {}
404
405 private:
406 Mips64Label* Entry() { return &exception_entry_; }
407 const Mips64ManagedRegister scratch_;
408 const size_t stack_adjust_;
409 Mips64Label exception_entry_;
410
411 friend class Mips64Assembler;
412 DISALLOW_COPY_AND_ASSIGN(Mips64ExceptionSlowPath);
413};
414
Andreas Gampe3b165bc2016-08-01 22:07:04 -0700415class Mips64Assembler FINAL : public Assembler, public JNIMacroAssembler<PointerSize::k64> {
Andreas Gampe57b34292015-01-14 15:45:59 -0800416 public:
Igor Murashkinae7ff922016-10-06 14:59:19 -0700417 using JNIBase = JNIMacroAssembler<PointerSize::k64>;
418
Goran Jakovljevic27af9372017-03-15 15:31:34 +0100419 explicit Mips64Assembler(ArenaAllocator* arena,
420 const Mips64InstructionSetFeatures* instruction_set_features = nullptr)
Vladimir Marko93205e32016-04-13 11:59:46 +0100421 : Assembler(arena),
422 overwriting_(false),
Alexey Frunzea0e87b02015-09-24 22:57:20 -0700423 overwrite_location_(0),
Alexey Frunze19f6c692016-11-30 19:19:55 -0800424 literals_(arena->Adapter(kArenaAllocAssembler)),
425 long_literals_(arena->Adapter(kArenaAllocAssembler)),
Alexey Frunze0960ac52016-12-20 17:24:59 -0800426 jump_tables_(arena->Adapter(kArenaAllocAssembler)),
Alexey Frunzea0e87b02015-09-24 22:57:20 -0700427 last_position_adjustment_(0),
428 last_old_position_(0),
Goran Jakovljevic27af9372017-03-15 15:31:34 +0100429 last_branch_id_(0),
430 has_msa_(instruction_set_features != nullptr ? instruction_set_features->HasMsa() : false) {
Alexey Frunzea0e87b02015-09-24 22:57:20 -0700431 cfi().DelayEmittingAdvancePCs();
432 }
433
434 virtual ~Mips64Assembler() {
435 for (auto& branch : branches_) {
436 CHECK(branch.IsResolved());
437 }
438 }
Andreas Gampe57b34292015-01-14 15:45:59 -0800439
Andreas Gampe3b165bc2016-08-01 22:07:04 -0700440 size_t CodeSize() const OVERRIDE { return Assembler::CodeSize(); }
441 DebugFrameOpCodeWriterForAssembler& cfi() { return Assembler::cfi(); }
442
Andreas Gampe57b34292015-01-14 15:45:59 -0800443 // Emit Machine Instructions.
Andreas Gampe57b34292015-01-14 15:45:59 -0800444 void Addu(GpuRegister rd, GpuRegister rs, GpuRegister rt);
445 void Addiu(GpuRegister rt, GpuRegister rs, uint16_t imm16);
Alexey Frunze4dda3372015-06-01 18:31:49 -0700446 void Daddu(GpuRegister rd, GpuRegister rs, GpuRegister rt); // MIPS64
447 void Daddiu(GpuRegister rt, GpuRegister rs, uint16_t imm16); // MIPS64
Andreas Gampe57b34292015-01-14 15:45:59 -0800448 void Subu(GpuRegister rd, GpuRegister rs, GpuRegister rt);
Alexey Frunze4dda3372015-06-01 18:31:49 -0700449 void Dsubu(GpuRegister rd, GpuRegister rs, GpuRegister rt); // MIPS64
450
Alexey Frunzec857c742015-09-23 15:12:39 -0700451 void MulR6(GpuRegister rd, GpuRegister rs, GpuRegister rt);
452 void MuhR6(GpuRegister rd, GpuRegister rs, GpuRegister rt);
453 void DivR6(GpuRegister rd, GpuRegister rs, GpuRegister rt);
454 void ModR6(GpuRegister rd, GpuRegister rs, GpuRegister rt);
455 void DivuR6(GpuRegister rd, GpuRegister rs, GpuRegister rt);
456 void ModuR6(GpuRegister rd, GpuRegister rs, GpuRegister rt);
457 void Dmul(GpuRegister rd, GpuRegister rs, GpuRegister rt); // MIPS64
458 void Dmuh(GpuRegister rd, GpuRegister rs, GpuRegister rt); // MIPS64
459 void Ddiv(GpuRegister rd, GpuRegister rs, GpuRegister rt); // MIPS64
460 void Dmod(GpuRegister rd, GpuRegister rs, GpuRegister rt); // MIPS64
461 void Ddivu(GpuRegister rd, GpuRegister rs, GpuRegister rt); // MIPS64
462 void Dmodu(GpuRegister rd, GpuRegister rs, GpuRegister rt); // MIPS64
Andreas Gampe57b34292015-01-14 15:45:59 -0800463
464 void And(GpuRegister rd, GpuRegister rs, GpuRegister rt);
465 void Andi(GpuRegister rt, GpuRegister rs, uint16_t imm16);
466 void Or(GpuRegister rd, GpuRegister rs, GpuRegister rt);
467 void Ori(GpuRegister rt, GpuRegister rs, uint16_t imm16);
468 void Xor(GpuRegister rd, GpuRegister rs, GpuRegister rt);
469 void Xori(GpuRegister rt, GpuRegister rs, uint16_t imm16);
470 void Nor(GpuRegister rd, GpuRegister rs, GpuRegister rt);
471
Alexey Frunzec857c742015-09-23 15:12:39 -0700472 void Bitswap(GpuRegister rd, GpuRegister rt);
Alexey Frunze19f6c692016-11-30 19:19:55 -0800473 void Dbitswap(GpuRegister rd, GpuRegister rt); // MIPS64
Alexey Frunzec857c742015-09-23 15:12:39 -0700474 void Seb(GpuRegister rd, GpuRegister rt);
475 void Seh(GpuRegister rd, GpuRegister rt);
Alexey Frunze19f6c692016-11-30 19:19:55 -0800476 void Dsbh(GpuRegister rd, GpuRegister rt); // MIPS64
477 void Dshd(GpuRegister rd, GpuRegister rt); // MIPS64
Lazar Trsicd9672662015-09-03 17:33:01 +0200478 void Dext(GpuRegister rs, GpuRegister rt, int pos, int size); // MIPS64
479 void Dinsu(GpuRegister rt, GpuRegister rs, int pos, int size); // MIPS64
Chris Larsene3660592016-11-09 11:13:42 -0800480 void Lsa(GpuRegister rd, GpuRegister rs, GpuRegister rt, int saPlusOne);
481 void Dlsa(GpuRegister rd, GpuRegister rs, GpuRegister rt, int saPlusOne); // MIPS64
Chris Larsen2fadd7b2015-08-14 14:56:10 -0700482 void Wsbh(GpuRegister rd, GpuRegister rt);
483 void Sc(GpuRegister rt, GpuRegister base, int16_t imm9 = 0);
Alexey Frunze19f6c692016-11-30 19:19:55 -0800484 void Scd(GpuRegister rt, GpuRegister base, int16_t imm9 = 0); // MIPS64
Chris Larsen2fadd7b2015-08-14 14:56:10 -0700485 void Ll(GpuRegister rt, GpuRegister base, int16_t imm9 = 0);
Alexey Frunze19f6c692016-11-30 19:19:55 -0800486 void Lld(GpuRegister rt, GpuRegister base, int16_t imm9 = 0); // MIPS64
Alexey Frunze4dda3372015-06-01 18:31:49 -0700487
488 void Sll(GpuRegister rd, GpuRegister rt, int shamt);
489 void Srl(GpuRegister rd, GpuRegister rt, int shamt);
Chris Larsen2fadd7b2015-08-14 14:56:10 -0700490 void Rotr(GpuRegister rd, GpuRegister rt, int shamt);
Alexey Frunze4dda3372015-06-01 18:31:49 -0700491 void Sra(GpuRegister rd, GpuRegister rt, int shamt);
492 void Sllv(GpuRegister rd, GpuRegister rt, GpuRegister rs);
493 void Srlv(GpuRegister rd, GpuRegister rt, GpuRegister rs);
Chris Larsen9aebff22015-09-22 17:54:15 -0700494 void Rotrv(GpuRegister rd, GpuRegister rt, GpuRegister rs);
Alexey Frunze4dda3372015-06-01 18:31:49 -0700495 void Srav(GpuRegister rd, GpuRegister rt, GpuRegister rs);
496 void Dsll(GpuRegister rd, GpuRegister rt, int shamt); // MIPS64
497 void Dsrl(GpuRegister rd, GpuRegister rt, int shamt); // MIPS64
Alexey Frunze19f6c692016-11-30 19:19:55 -0800498 void Drotr(GpuRegister rd, GpuRegister rt, int shamt); // MIPS64
Alexey Frunze4dda3372015-06-01 18:31:49 -0700499 void Dsra(GpuRegister rd, GpuRegister rt, int shamt); // MIPS64
500 void Dsll32(GpuRegister rd, GpuRegister rt, int shamt); // MIPS64
501 void Dsrl32(GpuRegister rd, GpuRegister rt, int shamt); // MIPS64
Chris Larsen9aebff22015-09-22 17:54:15 -0700502 void Drotr32(GpuRegister rd, GpuRegister rt, int shamt); // MIPS64
Alexey Frunze4dda3372015-06-01 18:31:49 -0700503 void Dsra32(GpuRegister rd, GpuRegister rt, int shamt); // MIPS64
504 void Dsllv(GpuRegister rd, GpuRegister rt, GpuRegister rs); // MIPS64
505 void Dsrlv(GpuRegister rd, GpuRegister rt, GpuRegister rs); // MIPS64
Chris Larsen9aebff22015-09-22 17:54:15 -0700506 void Drotrv(GpuRegister rd, GpuRegister rt, GpuRegister rs); // MIPS64
Alexey Frunze4dda3372015-06-01 18:31:49 -0700507 void Dsrav(GpuRegister rd, GpuRegister rt, GpuRegister rs); // MIPS64
Andreas Gampe57b34292015-01-14 15:45:59 -0800508
509 void Lb(GpuRegister rt, GpuRegister rs, uint16_t imm16);
510 void Lh(GpuRegister rt, GpuRegister rs, uint16_t imm16);
511 void Lw(GpuRegister rt, GpuRegister rs, uint16_t imm16);
Alexey Frunze4dda3372015-06-01 18:31:49 -0700512 void Ld(GpuRegister rt, GpuRegister rs, uint16_t imm16); // MIPS64
Andreas Gampe57b34292015-01-14 15:45:59 -0800513 void Lbu(GpuRegister rt, GpuRegister rs, uint16_t imm16);
514 void Lhu(GpuRegister rt, GpuRegister rs, uint16_t imm16);
Alexey Frunze4dda3372015-06-01 18:31:49 -0700515 void Lwu(GpuRegister rt, GpuRegister rs, uint16_t imm16); // MIPS64
Alexey Frunze19f6c692016-11-30 19:19:55 -0800516 void Lwpc(GpuRegister rs, uint32_t imm19);
517 void Lwupc(GpuRegister rs, uint32_t imm19); // MIPS64
518 void Ldpc(GpuRegister rs, uint32_t imm18); // MIPS64
Andreas Gampe57b34292015-01-14 15:45:59 -0800519 void Lui(GpuRegister rt, uint16_t imm16);
Alexey Frunze0960ac52016-12-20 17:24:59 -0800520 void Aui(GpuRegister rt, GpuRegister rs, uint16_t imm16);
Alexey Frunzec061de12017-02-14 13:27:23 -0800521 void Daui(GpuRegister rt, GpuRegister rs, uint16_t imm16); // MIPS64
Alexey Frunzec857c742015-09-23 15:12:39 -0700522 void Dahi(GpuRegister rs, uint16_t imm16); // MIPS64
523 void Dati(GpuRegister rs, uint16_t imm16); // MIPS64
Alexey Frunze4dda3372015-06-01 18:31:49 -0700524 void Sync(uint32_t stype);
Andreas Gampe57b34292015-01-14 15:45:59 -0800525
526 void Sb(GpuRegister rt, GpuRegister rs, uint16_t imm16);
527 void Sh(GpuRegister rt, GpuRegister rs, uint16_t imm16);
528 void Sw(GpuRegister rt, GpuRegister rs, uint16_t imm16);
Alexey Frunze4dda3372015-06-01 18:31:49 -0700529 void Sd(GpuRegister rt, GpuRegister rs, uint16_t imm16); // MIPS64
Andreas Gampe57b34292015-01-14 15:45:59 -0800530
531 void Slt(GpuRegister rd, GpuRegister rs, GpuRegister rt);
532 void Sltu(GpuRegister rd, GpuRegister rs, GpuRegister rt);
533 void Slti(GpuRegister rt, GpuRegister rs, uint16_t imm16);
534 void Sltiu(GpuRegister rt, GpuRegister rs, uint16_t imm16);
Chris Larsen2fadd7b2015-08-14 14:56:10 -0700535 void Seleqz(GpuRegister rd, GpuRegister rs, GpuRegister rt);
536 void Selnez(GpuRegister rd, GpuRegister rs, GpuRegister rt);
537 void Clz(GpuRegister rd, GpuRegister rs);
538 void Clo(GpuRegister rd, GpuRegister rs);
Alexey Frunze19f6c692016-11-30 19:19:55 -0800539 void Dclz(GpuRegister rd, GpuRegister rs); // MIPS64
540 void Dclo(GpuRegister rd, GpuRegister rs); // MIPS64
Andreas Gampe57b34292015-01-14 15:45:59 -0800541
Alexey Frunze4dda3372015-06-01 18:31:49 -0700542 void Jalr(GpuRegister rd, GpuRegister rs);
Andreas Gampe57b34292015-01-14 15:45:59 -0800543 void Jalr(GpuRegister rs);
Alexey Frunze4dda3372015-06-01 18:31:49 -0700544 void Jr(GpuRegister rs);
Alexey Frunzec857c742015-09-23 15:12:39 -0700545 void Auipc(GpuRegister rs, uint16_t imm16);
Alexey Frunzea0e87b02015-09-24 22:57:20 -0700546 void Addiupc(GpuRegister rs, uint32_t imm19);
547 void Bc(uint32_t imm26);
Alexey Frunze19f6c692016-11-30 19:19:55 -0800548 void Balc(uint32_t imm26);
Alexey Frunzec857c742015-09-23 15:12:39 -0700549 void Jic(GpuRegister rt, uint16_t imm16);
550 void Jialc(GpuRegister rt, uint16_t imm16);
551 void Bltc(GpuRegister rs, GpuRegister rt, uint16_t imm16);
552 void Bltzc(GpuRegister rt, uint16_t imm16);
553 void Bgtzc(GpuRegister rt, uint16_t imm16);
554 void Bgec(GpuRegister rs, GpuRegister rt, uint16_t imm16);
555 void Bgezc(GpuRegister rt, uint16_t imm16);
556 void Blezc(GpuRegister rt, uint16_t imm16);
557 void Bltuc(GpuRegister rs, GpuRegister rt, uint16_t imm16);
558 void Bgeuc(GpuRegister rs, GpuRegister rt, uint16_t imm16);
559 void Beqc(GpuRegister rs, GpuRegister rt, uint16_t imm16);
560 void Bnec(GpuRegister rs, GpuRegister rt, uint16_t imm16);
561 void Beqzc(GpuRegister rs, uint32_t imm21);
562 void Bnezc(GpuRegister rs, uint32_t imm21);
Alexey Frunze299a9392015-12-08 16:08:02 -0800563 void Bc1eqz(FpuRegister ft, uint16_t imm16);
564 void Bc1nez(FpuRegister ft, uint16_t imm16);
Andreas Gampe57b34292015-01-14 15:45:59 -0800565
566 void AddS(FpuRegister fd, FpuRegister fs, FpuRegister ft);
567 void SubS(FpuRegister fd, FpuRegister fs, FpuRegister ft);
568 void MulS(FpuRegister fd, FpuRegister fs, FpuRegister ft);
569 void DivS(FpuRegister fd, FpuRegister fs, FpuRegister ft);
570 void AddD(FpuRegister fd, FpuRegister fs, FpuRegister ft);
571 void SubD(FpuRegister fd, FpuRegister fs, FpuRegister ft);
572 void MulD(FpuRegister fd, FpuRegister fs, FpuRegister ft);
573 void DivD(FpuRegister fd, FpuRegister fs, FpuRegister ft);
Chris Larsen2fadd7b2015-08-14 14:56:10 -0700574 void SqrtS(FpuRegister fd, FpuRegister fs);
575 void SqrtD(FpuRegister fd, FpuRegister fs);
576 void AbsS(FpuRegister fd, FpuRegister fs);
577 void AbsD(FpuRegister fd, FpuRegister fs);
Andreas Gampe57b34292015-01-14 15:45:59 -0800578 void MovS(FpuRegister fd, FpuRegister fs);
579 void MovD(FpuRegister fd, FpuRegister fs);
Alexey Frunze4dda3372015-06-01 18:31:49 -0700580 void NegS(FpuRegister fd, FpuRegister fs);
581 void NegD(FpuRegister fd, FpuRegister fs);
Chris Larsen2fadd7b2015-08-14 14:56:10 -0700582 void RoundLS(FpuRegister fd, FpuRegister fs);
583 void RoundLD(FpuRegister fd, FpuRegister fs);
584 void RoundWS(FpuRegister fd, FpuRegister fs);
585 void RoundWD(FpuRegister fd, FpuRegister fs);
Alexey Frunzebaf60b72015-12-22 15:15:03 -0800586 void TruncLS(FpuRegister fd, FpuRegister fs);
587 void TruncLD(FpuRegister fd, FpuRegister fs);
588 void TruncWS(FpuRegister fd, FpuRegister fs);
589 void TruncWD(FpuRegister fd, FpuRegister fs);
Chris Larsen2fadd7b2015-08-14 14:56:10 -0700590 void CeilLS(FpuRegister fd, FpuRegister fs);
591 void CeilLD(FpuRegister fd, FpuRegister fs);
592 void CeilWS(FpuRegister fd, FpuRegister fs);
593 void CeilWD(FpuRegister fd, FpuRegister fs);
594 void FloorLS(FpuRegister fd, FpuRegister fs);
595 void FloorLD(FpuRegister fd, FpuRegister fs);
596 void FloorWS(FpuRegister fd, FpuRegister fs);
597 void FloorWD(FpuRegister fd, FpuRegister fs);
598 void SelS(FpuRegister fd, FpuRegister fs, FpuRegister ft);
599 void SelD(FpuRegister fd, FpuRegister fs, FpuRegister ft);
600 void RintS(FpuRegister fd, FpuRegister fs);
601 void RintD(FpuRegister fd, FpuRegister fs);
602 void ClassS(FpuRegister fd, FpuRegister fs);
603 void ClassD(FpuRegister fd, FpuRegister fs);
604 void MinS(FpuRegister fd, FpuRegister fs, FpuRegister ft);
605 void MinD(FpuRegister fd, FpuRegister fs, FpuRegister ft);
606 void MaxS(FpuRegister fd, FpuRegister fs, FpuRegister ft);
607 void MaxD(FpuRegister fd, FpuRegister fs, FpuRegister ft);
Alexey Frunze299a9392015-12-08 16:08:02 -0800608 void CmpUnS(FpuRegister fd, FpuRegister fs, FpuRegister ft);
609 void CmpEqS(FpuRegister fd, FpuRegister fs, FpuRegister ft);
610 void CmpUeqS(FpuRegister fd, FpuRegister fs, FpuRegister ft);
611 void CmpLtS(FpuRegister fd, FpuRegister fs, FpuRegister ft);
612 void CmpUltS(FpuRegister fd, FpuRegister fs, FpuRegister ft);
613 void CmpLeS(FpuRegister fd, FpuRegister fs, FpuRegister ft);
614 void CmpUleS(FpuRegister fd, FpuRegister fs, FpuRegister ft);
615 void CmpOrS(FpuRegister fd, FpuRegister fs, FpuRegister ft);
616 void CmpUneS(FpuRegister fd, FpuRegister fs, FpuRegister ft);
617 void CmpNeS(FpuRegister fd, FpuRegister fs, FpuRegister ft);
618 void CmpUnD(FpuRegister fd, FpuRegister fs, FpuRegister ft);
619 void CmpEqD(FpuRegister fd, FpuRegister fs, FpuRegister ft);
620 void CmpUeqD(FpuRegister fd, FpuRegister fs, FpuRegister ft);
621 void CmpLtD(FpuRegister fd, FpuRegister fs, FpuRegister ft);
622 void CmpUltD(FpuRegister fd, FpuRegister fs, FpuRegister ft);
623 void CmpLeD(FpuRegister fd, FpuRegister fs, FpuRegister ft);
624 void CmpUleD(FpuRegister fd, FpuRegister fs, FpuRegister ft);
625 void CmpOrD(FpuRegister fd, FpuRegister fs, FpuRegister ft);
626 void CmpUneD(FpuRegister fd, FpuRegister fs, FpuRegister ft);
627 void CmpNeD(FpuRegister fd, FpuRegister fs, FpuRegister ft);
Alexey Frunze4dda3372015-06-01 18:31:49 -0700628
629 void Cvtsw(FpuRegister fd, FpuRegister fs);
630 void Cvtdw(FpuRegister fd, FpuRegister fs);
631 void Cvtsd(FpuRegister fd, FpuRegister fs);
632 void Cvtds(FpuRegister fd, FpuRegister fs);
Chris Larsen51417632015-10-02 13:24:25 -0700633 void Cvtsl(FpuRegister fd, FpuRegister fs);
Chris Larsen2fadd7b2015-08-14 14:56:10 -0700634 void Cvtdl(FpuRegister fd, FpuRegister fs);
Andreas Gampe57b34292015-01-14 15:45:59 -0800635
636 void Mfc1(GpuRegister rt, FpuRegister fs);
Lazar Trsicd9672662015-09-03 17:33:01 +0200637 void Mfhc1(GpuRegister rt, FpuRegister fs);
Alexey Frunze4dda3372015-06-01 18:31:49 -0700638 void Mtc1(GpuRegister rt, FpuRegister fs);
Lazar Trsicd9672662015-09-03 17:33:01 +0200639 void Mthc1(GpuRegister rt, FpuRegister fs);
Alexey Frunze4dda3372015-06-01 18:31:49 -0700640 void Dmfc1(GpuRegister rt, FpuRegister fs); // MIPS64
641 void Dmtc1(GpuRegister rt, FpuRegister fs); // MIPS64
Andreas Gampe57b34292015-01-14 15:45:59 -0800642 void Lwc1(FpuRegister ft, GpuRegister rs, uint16_t imm16);
643 void Ldc1(FpuRegister ft, GpuRegister rs, uint16_t imm16);
644 void Swc1(FpuRegister ft, GpuRegister rs, uint16_t imm16);
645 void Sdc1(FpuRegister ft, GpuRegister rs, uint16_t imm16);
646
647 void Break();
648 void Nop();
Alexey Frunze4dda3372015-06-01 18:31:49 -0700649 void Move(GpuRegister rd, GpuRegister rs);
650 void Clear(GpuRegister rd);
651 void Not(GpuRegister rd, GpuRegister rs);
Andreas Gampe57b34292015-01-14 15:45:59 -0800652
Goran Jakovljevic5a9e51d2017-03-16 16:11:43 +0000653 // MSA instructions.
654 void AndV(VectorRegister wd, VectorRegister ws, VectorRegister wt);
655 void OrV(VectorRegister wd, VectorRegister ws, VectorRegister wt);
656 void NorV(VectorRegister wd, VectorRegister ws, VectorRegister wt);
657 void XorV(VectorRegister wd, VectorRegister ws, VectorRegister wt);
658
659 void AddvB(VectorRegister wd, VectorRegister ws, VectorRegister wt);
660 void AddvH(VectorRegister wd, VectorRegister ws, VectorRegister wt);
661 void AddvW(VectorRegister wd, VectorRegister ws, VectorRegister wt);
662 void AddvD(VectorRegister wd, VectorRegister ws, VectorRegister wt);
663 void SubvB(VectorRegister wd, VectorRegister ws, VectorRegister wt);
664 void SubvH(VectorRegister wd, VectorRegister ws, VectorRegister wt);
665 void SubvW(VectorRegister wd, VectorRegister ws, VectorRegister wt);
666 void SubvD(VectorRegister wd, VectorRegister ws, VectorRegister wt);
667 void MulvB(VectorRegister wd, VectorRegister ws, VectorRegister wt);
668 void MulvH(VectorRegister wd, VectorRegister ws, VectorRegister wt);
669 void MulvW(VectorRegister wd, VectorRegister ws, VectorRegister wt);
670 void MulvD(VectorRegister wd, VectorRegister ws, VectorRegister wt);
671 void Div_sB(VectorRegister wd, VectorRegister ws, VectorRegister wt);
672 void Div_sH(VectorRegister wd, VectorRegister ws, VectorRegister wt);
673 void Div_sW(VectorRegister wd, VectorRegister ws, VectorRegister wt);
674 void Div_sD(VectorRegister wd, VectorRegister ws, VectorRegister wt);
675 void Div_uB(VectorRegister wd, VectorRegister ws, VectorRegister wt);
676 void Div_uH(VectorRegister wd, VectorRegister ws, VectorRegister wt);
677 void Div_uW(VectorRegister wd, VectorRegister ws, VectorRegister wt);
678 void Div_uD(VectorRegister wd, VectorRegister ws, VectorRegister wt);
679 void Mod_sB(VectorRegister wd, VectorRegister ws, VectorRegister wt);
680 void Mod_sH(VectorRegister wd, VectorRegister ws, VectorRegister wt);
681 void Mod_sW(VectorRegister wd, VectorRegister ws, VectorRegister wt);
682 void Mod_sD(VectorRegister wd, VectorRegister ws, VectorRegister wt);
683 void Mod_uB(VectorRegister wd, VectorRegister ws, VectorRegister wt);
684 void Mod_uH(VectorRegister wd, VectorRegister ws, VectorRegister wt);
685 void Mod_uW(VectorRegister wd, VectorRegister ws, VectorRegister wt);
686 void Mod_uD(VectorRegister wd, VectorRegister ws, VectorRegister wt);
Goran Jakovljevic80248d72017-04-20 11:55:47 +0200687 void Add_aB(VectorRegister wd, VectorRegister ws, VectorRegister wt);
688 void Add_aH(VectorRegister wd, VectorRegister ws, VectorRegister wt);
689 void Add_aW(VectorRegister wd, VectorRegister ws, VectorRegister wt);
690 void Add_aD(VectorRegister wd, VectorRegister ws, VectorRegister wt);
691 void Ave_sB(VectorRegister wd, VectorRegister ws, VectorRegister wt);
692 void Ave_sH(VectorRegister wd, VectorRegister ws, VectorRegister wt);
693 void Ave_sW(VectorRegister wd, VectorRegister ws, VectorRegister wt);
694 void Ave_sD(VectorRegister wd, VectorRegister ws, VectorRegister wt);
695 void Ave_uB(VectorRegister wd, VectorRegister ws, VectorRegister wt);
696 void Ave_uH(VectorRegister wd, VectorRegister ws, VectorRegister wt);
697 void Ave_uW(VectorRegister wd, VectorRegister ws, VectorRegister wt);
698 void Ave_uD(VectorRegister wd, VectorRegister ws, VectorRegister wt);
699 void Aver_sB(VectorRegister wd, VectorRegister ws, VectorRegister wt);
700 void Aver_sH(VectorRegister wd, VectorRegister ws, VectorRegister wt);
701 void Aver_sW(VectorRegister wd, VectorRegister ws, VectorRegister wt);
702 void Aver_sD(VectorRegister wd, VectorRegister ws, VectorRegister wt);
703 void Aver_uB(VectorRegister wd, VectorRegister ws, VectorRegister wt);
704 void Aver_uH(VectorRegister wd, VectorRegister ws, VectorRegister wt);
705 void Aver_uW(VectorRegister wd, VectorRegister ws, VectorRegister wt);
706 void Aver_uD(VectorRegister wd, VectorRegister ws, VectorRegister wt);
Goran Jakovljevic658263e2017-06-07 09:35:53 +0200707 void Max_sB(VectorRegister wd, VectorRegister ws, VectorRegister wt);
708 void Max_sH(VectorRegister wd, VectorRegister ws, VectorRegister wt);
709 void Max_sW(VectorRegister wd, VectorRegister ws, VectorRegister wt);
710 void Max_sD(VectorRegister wd, VectorRegister ws, VectorRegister wt);
711 void Max_uB(VectorRegister wd, VectorRegister ws, VectorRegister wt);
712 void Max_uH(VectorRegister wd, VectorRegister ws, VectorRegister wt);
713 void Max_uW(VectorRegister wd, VectorRegister ws, VectorRegister wt);
714 void Max_uD(VectorRegister wd, VectorRegister ws, VectorRegister wt);
715 void Min_sB(VectorRegister wd, VectorRegister ws, VectorRegister wt);
716 void Min_sH(VectorRegister wd, VectorRegister ws, VectorRegister wt);
717 void Min_sW(VectorRegister wd, VectorRegister ws, VectorRegister wt);
718 void Min_sD(VectorRegister wd, VectorRegister ws, VectorRegister wt);
719 void Min_uB(VectorRegister wd, VectorRegister ws, VectorRegister wt);
720 void Min_uH(VectorRegister wd, VectorRegister ws, VectorRegister wt);
721 void Min_uW(VectorRegister wd, VectorRegister ws, VectorRegister wt);
722 void Min_uD(VectorRegister wd, VectorRegister ws, VectorRegister wt);
Goran Jakovljevic5a9e51d2017-03-16 16:11:43 +0000723
724 void FaddW(VectorRegister wd, VectorRegister ws, VectorRegister wt);
725 void FaddD(VectorRegister wd, VectorRegister ws, VectorRegister wt);
726 void FsubW(VectorRegister wd, VectorRegister ws, VectorRegister wt);
727 void FsubD(VectorRegister wd, VectorRegister ws, VectorRegister wt);
728 void FmulW(VectorRegister wd, VectorRegister ws, VectorRegister wt);
729 void FmulD(VectorRegister wd, VectorRegister ws, VectorRegister wt);
730 void FdivW(VectorRegister wd, VectorRegister ws, VectorRegister wt);
731 void FdivD(VectorRegister wd, VectorRegister ws, VectorRegister wt);
Goran Jakovljevic658263e2017-06-07 09:35:53 +0200732 void FmaxW(VectorRegister wd, VectorRegister ws, VectorRegister wt);
733 void FmaxD(VectorRegister wd, VectorRegister ws, VectorRegister wt);
734 void FminW(VectorRegister wd, VectorRegister ws, VectorRegister wt);
735 void FminD(VectorRegister wd, VectorRegister ws, VectorRegister wt);
Goran Jakovljevic5a9e51d2017-03-16 16:11:43 +0000736
737 void Ffint_sW(VectorRegister wd, VectorRegister ws);
738 void Ffint_sD(VectorRegister wd, VectorRegister ws);
739 void Ftint_sW(VectorRegister wd, VectorRegister ws);
740 void Ftint_sD(VectorRegister wd, VectorRegister ws);
741
742 void SllB(VectorRegister wd, VectorRegister ws, VectorRegister wt);
743 void SllH(VectorRegister wd, VectorRegister ws, VectorRegister wt);
744 void SllW(VectorRegister wd, VectorRegister ws, VectorRegister wt);
745 void SllD(VectorRegister wd, VectorRegister ws, VectorRegister wt);
746 void SraB(VectorRegister wd, VectorRegister ws, VectorRegister wt);
747 void SraH(VectorRegister wd, VectorRegister ws, VectorRegister wt);
748 void SraW(VectorRegister wd, VectorRegister ws, VectorRegister wt);
749 void SraD(VectorRegister wd, VectorRegister ws, VectorRegister wt);
750 void SrlB(VectorRegister wd, VectorRegister ws, VectorRegister wt);
751 void SrlH(VectorRegister wd, VectorRegister ws, VectorRegister wt);
752 void SrlW(VectorRegister wd, VectorRegister ws, VectorRegister wt);
753 void SrlD(VectorRegister wd, VectorRegister ws, VectorRegister wt);
754
755 // Immediate shift instructions, where shamtN denotes shift amount (must be between 0 and 2^N-1).
756 void SlliB(VectorRegister wd, VectorRegister ws, int shamt3);
757 void SlliH(VectorRegister wd, VectorRegister ws, int shamt4);
758 void SlliW(VectorRegister wd, VectorRegister ws, int shamt5);
759 void SlliD(VectorRegister wd, VectorRegister ws, int shamt6);
760 void SraiB(VectorRegister wd, VectorRegister ws, int shamt3);
761 void SraiH(VectorRegister wd, VectorRegister ws, int shamt4);
762 void SraiW(VectorRegister wd, VectorRegister ws, int shamt5);
763 void SraiD(VectorRegister wd, VectorRegister ws, int shamt6);
764 void SrliB(VectorRegister wd, VectorRegister ws, int shamt3);
765 void SrliH(VectorRegister wd, VectorRegister ws, int shamt4);
766 void SrliW(VectorRegister wd, VectorRegister ws, int shamt5);
767 void SrliD(VectorRegister wd, VectorRegister ws, int shamt6);
768
769 void MoveV(VectorRegister wd, VectorRegister ws);
770 void SplatiB(VectorRegister wd, VectorRegister ws, int n4);
771 void SplatiH(VectorRegister wd, VectorRegister ws, int n3);
772 void SplatiW(VectorRegister wd, VectorRegister ws, int n2);
773 void SplatiD(VectorRegister wd, VectorRegister ws, int n1);
774 void FillB(VectorRegister wd, GpuRegister rs);
775 void FillH(VectorRegister wd, GpuRegister rs);
776 void FillW(VectorRegister wd, GpuRegister rs);
777 void FillD(VectorRegister wd, GpuRegister rs);
778
Goran Jakovljevic3f444032017-03-31 14:38:20 +0200779 void LdiB(VectorRegister wd, int imm8);
780 void LdiH(VectorRegister wd, int imm10);
781 void LdiW(VectorRegister wd, int imm10);
782 void LdiD(VectorRegister wd, int imm10);
Goran Jakovljevic5a9e51d2017-03-16 16:11:43 +0000783 void LdB(VectorRegister wd, GpuRegister rs, int offset);
784 void LdH(VectorRegister wd, GpuRegister rs, int offset);
785 void LdW(VectorRegister wd, GpuRegister rs, int offset);
786 void LdD(VectorRegister wd, GpuRegister rs, int offset);
787 void StB(VectorRegister wd, GpuRegister rs, int offset);
788 void StH(VectorRegister wd, GpuRegister rs, int offset);
789 void StW(VectorRegister wd, GpuRegister rs, int offset);
790 void StD(VectorRegister wd, GpuRegister rs, int offset);
791
Goran Jakovljevic38370112017-05-10 14:30:28 +0200792 void IlvrB(VectorRegister wd, VectorRegister ws, VectorRegister wt);
793 void IlvrH(VectorRegister wd, VectorRegister ws, VectorRegister wt);
794 void IlvrW(VectorRegister wd, VectorRegister ws, VectorRegister wt);
795 void IlvrD(VectorRegister wd, VectorRegister ws, VectorRegister wt);
796
Goran Jakovljevic19680d32017-05-11 10:38:36 +0200797 // Helper for replicating floating point value in all destination elements.
798 void ReplicateFPToVectorRegister(VectorRegister dst, FpuRegister src, bool is_double);
799
Alexey Frunzea0e87b02015-09-24 22:57:20 -0700800 // Higher level composite instructions.
Chris Larsenc733dca2016-05-13 16:11:47 -0700801 int InstrCountForLoadReplicatedConst32(int64_t);
Alexey Frunze4dda3372015-06-01 18:31:49 -0700802 void LoadConst32(GpuRegister rd, int32_t value);
803 void LoadConst64(GpuRegister rd, int64_t value); // MIPS64
804
Chris Larsenc733dca2016-05-13 16:11:47 -0700805 // This function is only used for testing purposes.
806 void RecordLoadConst64Path(int value);
807
Alexey Frunze0960ac52016-12-20 17:24:59 -0800808 void Addiu32(GpuRegister rt, GpuRegister rs, int32_t value);
Alexey Frunze4dda3372015-06-01 18:31:49 -0700809 void Daddiu64(GpuRegister rt, GpuRegister rs, int64_t value, GpuRegister rtmp = AT); // MIPS64
810
Alexey Frunzec061de12017-02-14 13:27:23 -0800811 //
812 // Heap poisoning.
813 //
814
815 // Poison a heap reference contained in `src` and store it in `dst`.
816 void PoisonHeapReference(GpuRegister dst, GpuRegister src) {
817 // dst = -src.
818 // Negate the 32-bit ref.
819 Dsubu(dst, ZERO, src);
820 // And constrain it to 32 bits (zero-extend into bits 32 through 63) as on Arm64 and x86/64.
821 Dext(dst, dst, 0, 32);
822 }
823 // Poison a heap reference contained in `reg`.
824 void PoisonHeapReference(GpuRegister reg) {
825 // reg = -reg.
826 PoisonHeapReference(reg, reg);
827 }
828 // Unpoison a heap reference contained in `reg`.
829 void UnpoisonHeapReference(GpuRegister reg) {
830 // reg = -reg.
831 // Negate the 32-bit ref.
832 Dsubu(reg, ZERO, reg);
833 // And constrain it to 32 bits (zero-extend into bits 32 through 63) as on Arm64 and x86/64.
834 Dext(reg, reg, 0, 32);
835 }
836 // Poison a heap reference contained in `reg` if heap poisoning is enabled.
837 void MaybePoisonHeapReference(GpuRegister reg) {
838 if (kPoisonHeapReferences) {
839 PoisonHeapReference(reg);
840 }
841 }
842 // Unpoison a heap reference contained in `reg` if heap poisoning is enabled.
843 void MaybeUnpoisonHeapReference(GpuRegister reg) {
844 if (kPoisonHeapReferences) {
845 UnpoisonHeapReference(reg);
846 }
847 }
848
Alexey Frunzea0e87b02015-09-24 22:57:20 -0700849 void Bind(Label* label) OVERRIDE {
850 Bind(down_cast<Mips64Label*>(label));
Andreas Gampe85b62f22015-09-09 13:15:38 -0700851 }
Alexey Frunzea0e87b02015-09-24 22:57:20 -0700852 void Jump(Label* label ATTRIBUTE_UNUSED) OVERRIDE {
853 UNIMPLEMENTED(FATAL) << "Do not use Jump for MIPS64";
854 }
855
856 void Bind(Mips64Label* label);
Igor Murashkinae7ff922016-10-06 14:59:19 -0700857
858 // Don't warn about a different virtual Bind/Jump in the base class.
859 using JNIBase::Bind;
860 using JNIBase::Jump;
861
862 // Create a new label that can be used with Jump/Bind calls.
863 std::unique_ptr<JNIMacroLabel> CreateLabel() OVERRIDE {
864 LOG(FATAL) << "Not implemented on MIPS64";
865 UNREACHABLE();
866 }
867 // Emit an unconditional jump to the label.
868 void Jump(JNIMacroLabel* label ATTRIBUTE_UNUSED) OVERRIDE {
869 LOG(FATAL) << "Not implemented on MIPS64";
870 UNREACHABLE();
871 }
872 // Emit a conditional jump to the label by applying a unary condition test to the register.
873 void Jump(JNIMacroLabel* label ATTRIBUTE_UNUSED,
874 JNIMacroUnaryCondition cond ATTRIBUTE_UNUSED,
875 ManagedRegister test ATTRIBUTE_UNUSED) OVERRIDE {
876 LOG(FATAL) << "Not implemented on MIPS64";
877 UNREACHABLE();
878 }
879
880 // Code at this offset will serve as the target for the Jump call.
881 void Bind(JNIMacroLabel* label ATTRIBUTE_UNUSED) OVERRIDE {
882 LOG(FATAL) << "Not implemented on MIPS64";
883 UNREACHABLE();
884 }
885
Alexey Frunze19f6c692016-11-30 19:19:55 -0800886 // Create a new literal with a given value.
887 // NOTE: Force the template parameter to be explicitly specified.
888 template <typename T>
889 Literal* NewLiteral(typename Identity<T>::type value) {
890 static_assert(std::is_integral<T>::value, "T must be an integral type.");
891 return NewLiteral(sizeof(value), reinterpret_cast<const uint8_t*>(&value));
892 }
893
894 // Load label address using PC-relative loads. To be used with data labels in the literal /
895 // jump table area only and not with regular code labels.
896 void LoadLabelAddress(GpuRegister dest_reg, Mips64Label* label);
897
898 // Create a new literal with the given data.
899 Literal* NewLiteral(size_t size, const uint8_t* data);
900
901 // Load literal using PC-relative loads.
902 void LoadLiteral(GpuRegister dest_reg, LoadOperandType load_type, Literal* literal);
903
Alexey Frunze0960ac52016-12-20 17:24:59 -0800904 // Create a jump table for the given labels that will be emitted when finalizing.
905 // When the table is emitted, offsets will be relative to the location of the table.
906 // The table location is determined by the location of its label (the label precedes
907 // the table data) and should be loaded using LoadLabelAddress().
908 JumpTable* CreateJumpTable(std::vector<Mips64Label*>&& labels);
909
Alexey Frunzea0e87b02015-09-24 22:57:20 -0700910 void Bc(Mips64Label* label);
Alexey Frunze19f6c692016-11-30 19:19:55 -0800911 void Balc(Mips64Label* label);
Alexey Frunzea0e87b02015-09-24 22:57:20 -0700912 void Bltc(GpuRegister rs, GpuRegister rt, Mips64Label* label);
913 void Bltzc(GpuRegister rt, Mips64Label* label);
914 void Bgtzc(GpuRegister rt, Mips64Label* label);
915 void Bgec(GpuRegister rs, GpuRegister rt, Mips64Label* label);
916 void Bgezc(GpuRegister rt, Mips64Label* label);
917 void Blezc(GpuRegister rt, Mips64Label* label);
918 void Bltuc(GpuRegister rs, GpuRegister rt, Mips64Label* label);
919 void Bgeuc(GpuRegister rs, GpuRegister rt, Mips64Label* label);
920 void Beqc(GpuRegister rs, GpuRegister rt, Mips64Label* label);
921 void Bnec(GpuRegister rs, GpuRegister rt, Mips64Label* label);
922 void Beqzc(GpuRegister rs, Mips64Label* label);
923 void Bnezc(GpuRegister rs, Mips64Label* label);
Alexey Frunze299a9392015-12-08 16:08:02 -0800924 void Bc1eqz(FpuRegister ft, Mips64Label* label);
925 void Bc1nez(FpuRegister ft, Mips64Label* label);
Andreas Gampe57b34292015-01-14 15:45:59 -0800926
927 void EmitLoad(ManagedRegister m_dst, GpuRegister src_register, int32_t src_offset, size_t size);
Chris Larsenc3fec0c2016-12-15 11:44:14 -0800928 void AdjustBaseAndOffset(GpuRegister& base, int32_t& offset, bool is_doubleword);
Goran Jakovljevicd8b6a532017-04-20 11:42:30 +0200929 // If element_size_shift is negative at entry, its value will be calculated based on the offset.
930 void AdjustBaseOffsetAndElementSizeShift(GpuRegister& base,
931 int32_t& offset,
932 int& element_size_shift);
Tijana Jakovljevic57433862017-01-17 16:59:03 +0100933
934 private:
935 // This will be used as an argument for loads/stores
936 // when there is no need for implicit null checks.
937 struct NoImplicitNullChecker {
938 void operator()() const {}
939 };
940
941 public:
942 template <typename ImplicitNullChecker = NoImplicitNullChecker>
Tijana Jakovljevicba89c342017-03-10 13:36:08 +0100943 void StoreConstToOffset(StoreOperandType type,
944 int64_t value,
945 GpuRegister base,
946 int32_t offset,
947 GpuRegister temp,
948 ImplicitNullChecker null_checker = NoImplicitNullChecker()) {
949 // We permit `base` and `temp` to coincide (however, we check that neither is AT),
950 // in which case the `base` register may be overwritten in the process.
951 CHECK_NE(temp, AT); // Must not use AT as temp, so as not to overwrite the adjusted base.
Chris Larsenc3fec0c2016-12-15 11:44:14 -0800952 AdjustBaseAndOffset(base, offset, /* is_doubleword */ (type == kStoreDoubleword));
Tijana Jakovljevicba89c342017-03-10 13:36:08 +0100953 GpuRegister reg;
954 // If the adjustment left `base` unchanged and equal to `temp`, we can't use `temp`
955 // to load and hold the value but we can use AT instead as AT hasn't been used yet.
956 // Otherwise, `temp` can be used for the value. And if `temp` is the same as the
957 // original `base` (that is, `base` prior to the adjustment), the original `base`
958 // register will be overwritten.
959 if (base == temp) {
960 temp = AT;
961 }
962
963 if (type == kStoreDoubleword && IsAligned<kMips64DoublewordSize>(offset)) {
964 if (value == 0) {
965 reg = ZERO;
966 } else {
967 reg = temp;
968 LoadConst64(reg, value);
969 }
970 Sd(reg, base, offset);
971 null_checker();
972 } else {
973 uint32_t low = Low32Bits(value);
974 uint32_t high = High32Bits(value);
975 if (low == 0) {
976 reg = ZERO;
977 } else {
978 reg = temp;
979 LoadConst32(reg, low);
980 }
981 switch (type) {
982 case kStoreByte:
983 Sb(reg, base, offset);
984 break;
985 case kStoreHalfword:
986 Sh(reg, base, offset);
987 break;
988 case kStoreWord:
989 Sw(reg, base, offset);
990 break;
991 case kStoreDoubleword:
992 // not aligned to kMips64DoublewordSize
993 CHECK_ALIGNED(offset, kMips64WordSize);
994 Sw(reg, base, offset);
995 null_checker();
996 if (high == 0) {
997 reg = ZERO;
998 } else {
999 reg = temp;
1000 if (high != low) {
1001 LoadConst32(reg, high);
1002 }
1003 }
1004 Sw(reg, base, offset + kMips64WordSize);
1005 break;
1006 default:
1007 LOG(FATAL) << "UNREACHABLE";
1008 }
1009 if (type != kStoreDoubleword) {
1010 null_checker();
1011 }
1012 }
1013 }
1014
1015 template <typename ImplicitNullChecker = NoImplicitNullChecker>
Tijana Jakovljevic57433862017-01-17 16:59:03 +01001016 void LoadFromOffset(LoadOperandType type,
1017 GpuRegister reg,
1018 GpuRegister base,
1019 int32_t offset,
1020 ImplicitNullChecker null_checker = NoImplicitNullChecker()) {
Chris Larsenc3fec0c2016-12-15 11:44:14 -08001021 AdjustBaseAndOffset(base, offset, /* is_doubleword */ (type == kLoadDoubleword));
Tijana Jakovljevic57433862017-01-17 16:59:03 +01001022
1023 switch (type) {
1024 case kLoadSignedByte:
1025 Lb(reg, base, offset);
1026 break;
1027 case kLoadUnsignedByte:
1028 Lbu(reg, base, offset);
1029 break;
1030 case kLoadSignedHalfword:
1031 Lh(reg, base, offset);
1032 break;
1033 case kLoadUnsignedHalfword:
1034 Lhu(reg, base, offset);
1035 break;
1036 case kLoadWord:
1037 CHECK_ALIGNED(offset, kMips64WordSize);
1038 Lw(reg, base, offset);
1039 break;
1040 case kLoadUnsignedWord:
1041 CHECK_ALIGNED(offset, kMips64WordSize);
1042 Lwu(reg, base, offset);
1043 break;
1044 case kLoadDoubleword:
1045 if (!IsAligned<kMips64DoublewordSize>(offset)) {
1046 CHECK_ALIGNED(offset, kMips64WordSize);
1047 Lwu(reg, base, offset);
1048 null_checker();
1049 Lwu(TMP2, base, offset + kMips64WordSize);
1050 Dinsu(reg, TMP2, 32, 32);
1051 } else {
1052 Ld(reg, base, offset);
1053 null_checker();
1054 }
1055 break;
Goran Jakovljevicd8b6a532017-04-20 11:42:30 +02001056 default:
1057 LOG(FATAL) << "UNREACHABLE";
Tijana Jakovljevic57433862017-01-17 16:59:03 +01001058 }
1059 if (type != kLoadDoubleword) {
1060 null_checker();
1061 }
1062 }
1063
1064 template <typename ImplicitNullChecker = NoImplicitNullChecker>
1065 void LoadFpuFromOffset(LoadOperandType type,
1066 FpuRegister reg,
1067 GpuRegister base,
1068 int32_t offset,
1069 ImplicitNullChecker null_checker = NoImplicitNullChecker()) {
Goran Jakovljevicd8b6a532017-04-20 11:42:30 +02001070 int element_size_shift = -1;
1071 if (type != kLoadQuadword) {
1072 AdjustBaseAndOffset(base, offset, /* is_doubleword */ (type == kLoadDoubleword));
1073 } else {
1074 AdjustBaseOffsetAndElementSizeShift(base, offset, element_size_shift);
1075 }
Tijana Jakovljevic57433862017-01-17 16:59:03 +01001076
1077 switch (type) {
1078 case kLoadWord:
1079 CHECK_ALIGNED(offset, kMips64WordSize);
1080 Lwc1(reg, base, offset);
1081 null_checker();
1082 break;
1083 case kLoadDoubleword:
1084 if (!IsAligned<kMips64DoublewordSize>(offset)) {
1085 CHECK_ALIGNED(offset, kMips64WordSize);
1086 Lwc1(reg, base, offset);
1087 null_checker();
1088 Lw(TMP2, base, offset + kMips64WordSize);
1089 Mthc1(TMP2, reg);
1090 } else {
1091 Ldc1(reg, base, offset);
1092 null_checker();
1093 }
1094 break;
Goran Jakovljevicd8b6a532017-04-20 11:42:30 +02001095 case kLoadQuadword:
1096 switch (element_size_shift) {
1097 case TIMES_1: LdB(static_cast<VectorRegister>(reg), base, offset); break;
1098 case TIMES_2: LdH(static_cast<VectorRegister>(reg), base, offset); break;
1099 case TIMES_4: LdW(static_cast<VectorRegister>(reg), base, offset); break;
1100 case TIMES_8: LdD(static_cast<VectorRegister>(reg), base, offset); break;
1101 default:
1102 LOG(FATAL) << "UNREACHABLE";
1103 }
1104 null_checker();
1105 break;
Tijana Jakovljevic57433862017-01-17 16:59:03 +01001106 default:
1107 LOG(FATAL) << "UNREACHABLE";
1108 }
1109 }
1110
1111 template <typename ImplicitNullChecker = NoImplicitNullChecker>
1112 void StoreToOffset(StoreOperandType type,
1113 GpuRegister reg,
1114 GpuRegister base,
1115 int32_t offset,
1116 ImplicitNullChecker null_checker = NoImplicitNullChecker()) {
Chris Larsenc3fec0c2016-12-15 11:44:14 -08001117 // Must not use AT as `reg`, so as not to overwrite the value being stored
1118 // with the adjusted `base`.
1119 CHECK_NE(reg, AT);
1120 AdjustBaseAndOffset(base, offset, /* is_doubleword */ (type == kStoreDoubleword));
Tijana Jakovljevic57433862017-01-17 16:59:03 +01001121
1122 switch (type) {
1123 case kStoreByte:
1124 Sb(reg, base, offset);
1125 break;
1126 case kStoreHalfword:
1127 Sh(reg, base, offset);
1128 break;
1129 case kStoreWord:
1130 CHECK_ALIGNED(offset, kMips64WordSize);
1131 Sw(reg, base, offset);
1132 break;
1133 case kStoreDoubleword:
1134 if (!IsAligned<kMips64DoublewordSize>(offset)) {
1135 CHECK_ALIGNED(offset, kMips64WordSize);
1136 Sw(reg, base, offset);
1137 null_checker();
1138 Dsrl32(TMP2, reg, 0);
1139 Sw(TMP2, base, offset + kMips64WordSize);
1140 } else {
1141 Sd(reg, base, offset);
1142 null_checker();
1143 }
1144 break;
1145 default:
1146 LOG(FATAL) << "UNREACHABLE";
1147 }
1148 if (type != kStoreDoubleword) {
1149 null_checker();
1150 }
1151 }
1152
1153 template <typename ImplicitNullChecker = NoImplicitNullChecker>
1154 void StoreFpuToOffset(StoreOperandType type,
1155 FpuRegister reg,
1156 GpuRegister base,
1157 int32_t offset,
1158 ImplicitNullChecker null_checker = NoImplicitNullChecker()) {
Goran Jakovljevicd8b6a532017-04-20 11:42:30 +02001159 int element_size_shift = -1;
1160 if (type != kStoreQuadword) {
1161 AdjustBaseAndOffset(base, offset, /* is_doubleword */ (type == kStoreDoubleword));
1162 } else {
1163 AdjustBaseOffsetAndElementSizeShift(base, offset, element_size_shift);
1164 }
Tijana Jakovljevic57433862017-01-17 16:59:03 +01001165
1166 switch (type) {
1167 case kStoreWord:
1168 CHECK_ALIGNED(offset, kMips64WordSize);
1169 Swc1(reg, base, offset);
1170 null_checker();
1171 break;
1172 case kStoreDoubleword:
1173 if (!IsAligned<kMips64DoublewordSize>(offset)) {
1174 CHECK_ALIGNED(offset, kMips64WordSize);
1175 Mfhc1(TMP2, reg);
1176 Swc1(reg, base, offset);
1177 null_checker();
1178 Sw(TMP2, base, offset + kMips64WordSize);
1179 } else {
1180 Sdc1(reg, base, offset);
1181 null_checker();
1182 }
1183 break;
Goran Jakovljevicd8b6a532017-04-20 11:42:30 +02001184 case kStoreQuadword:
1185 switch (element_size_shift) {
1186 case TIMES_1: StB(static_cast<VectorRegister>(reg), base, offset); break;
1187 case TIMES_2: StH(static_cast<VectorRegister>(reg), base, offset); break;
1188 case TIMES_4: StW(static_cast<VectorRegister>(reg), base, offset); break;
1189 case TIMES_8: StD(static_cast<VectorRegister>(reg), base, offset); break;
1190 default:
1191 LOG(FATAL) << "UNREACHABLE";
1192 }
1193 null_checker();
1194 break;
Tijana Jakovljevic57433862017-01-17 16:59:03 +01001195 default:
1196 LOG(FATAL) << "UNREACHABLE";
1197 }
1198 }
1199
Andreas Gampe57b34292015-01-14 15:45:59 -08001200 void LoadFromOffset(LoadOperandType type, GpuRegister reg, GpuRegister base, int32_t offset);
1201 void LoadFpuFromOffset(LoadOperandType type, FpuRegister reg, GpuRegister base, int32_t offset);
1202 void StoreToOffset(StoreOperandType type, GpuRegister reg, GpuRegister base, int32_t offset);
1203 void StoreFpuToOffset(StoreOperandType type, FpuRegister reg, GpuRegister base, int32_t offset);
1204
1205 // Emit data (e.g. encoded instruction or immediate) to the instruction stream.
Alexey Frunze4dda3372015-06-01 18:31:49 -07001206 void Emit(uint32_t value);
Andreas Gampe57b34292015-01-14 15:45:59 -08001207
1208 //
Alexey Frunzea0e87b02015-09-24 22:57:20 -07001209 // Overridden common assembler high-level functionality.
Andreas Gampe57b34292015-01-14 15:45:59 -08001210 //
1211
Alexey Frunzea0e87b02015-09-24 22:57:20 -07001212 // Emit code that will create an activation on the stack.
Vladimir Marko32248382016-05-19 10:37:24 +01001213 void BuildFrame(size_t frame_size,
1214 ManagedRegister method_reg,
1215 ArrayRef<const ManagedRegister> callee_save_regs,
Andreas Gampe57b34292015-01-14 15:45:59 -08001216 const ManagedRegisterEntrySpills& entry_spills) OVERRIDE;
1217
Alexey Frunzea0e87b02015-09-24 22:57:20 -07001218 // Emit code that will remove an activation from the stack.
Vladimir Marko32248382016-05-19 10:37:24 +01001219 void RemoveFrame(size_t frame_size, ArrayRef<const ManagedRegister> callee_save_regs) OVERRIDE;
Andreas Gampe57b34292015-01-14 15:45:59 -08001220
1221 void IncreaseFrameSize(size_t adjust) OVERRIDE;
1222 void DecreaseFrameSize(size_t adjust) OVERRIDE;
1223
Alexey Frunzea0e87b02015-09-24 22:57:20 -07001224 // Store routines.
Andreas Gampe57b34292015-01-14 15:45:59 -08001225 void Store(FrameOffset offs, ManagedRegister msrc, size_t size) OVERRIDE;
1226 void StoreRef(FrameOffset dest, ManagedRegister msrc) OVERRIDE;
1227 void StoreRawPtr(FrameOffset dest, ManagedRegister msrc) OVERRIDE;
1228
1229 void StoreImmediateToFrame(FrameOffset dest, uint32_t imm, ManagedRegister mscratch) OVERRIDE;
1230
Andreas Gampe3b165bc2016-08-01 22:07:04 -07001231 void StoreStackOffsetToThread(ThreadOffset64 thr_offs,
1232 FrameOffset fr_offs,
1233 ManagedRegister mscratch) OVERRIDE;
Andreas Gampe57b34292015-01-14 15:45:59 -08001234
Andreas Gampe3b165bc2016-08-01 22:07:04 -07001235 void StoreStackPointerToThread(ThreadOffset64 thr_offs) OVERRIDE;
Andreas Gampe57b34292015-01-14 15:45:59 -08001236
1237 void StoreSpanning(FrameOffset dest, ManagedRegister msrc, FrameOffset in_off,
1238 ManagedRegister mscratch) OVERRIDE;
1239
Alexey Frunzea0e87b02015-09-24 22:57:20 -07001240 // Load routines.
Andreas Gampe57b34292015-01-14 15:45:59 -08001241 void Load(ManagedRegister mdest, FrameOffset src, size_t size) OVERRIDE;
1242
Andreas Gampe3b165bc2016-08-01 22:07:04 -07001243 void LoadFromThread(ManagedRegister mdest, ThreadOffset64 src, size_t size) OVERRIDE;
Andreas Gampe57b34292015-01-14 15:45:59 -08001244
Mathieu Chartiere401d142015-04-22 13:56:20 -07001245 void LoadRef(ManagedRegister dest, FrameOffset src) OVERRIDE;
Andreas Gampe57b34292015-01-14 15:45:59 -08001246
Mathieu Chartiere401d142015-04-22 13:56:20 -07001247 void LoadRef(ManagedRegister mdest, ManagedRegister base, MemberOffset offs,
Roland Levillain4d027112015-07-01 15:41:14 +01001248 bool unpoison_reference) OVERRIDE;
Andreas Gampe57b34292015-01-14 15:45:59 -08001249
1250 void LoadRawPtr(ManagedRegister mdest, ManagedRegister base, Offset offs) OVERRIDE;
1251
Andreas Gampe3b165bc2016-08-01 22:07:04 -07001252 void LoadRawPtrFromThread(ManagedRegister mdest, ThreadOffset64 offs) OVERRIDE;
Andreas Gampe57b34292015-01-14 15:45:59 -08001253
Alexey Frunzea0e87b02015-09-24 22:57:20 -07001254 // Copying routines.
Andreas Gampe57b34292015-01-14 15:45:59 -08001255 void Move(ManagedRegister mdest, ManagedRegister msrc, size_t size) OVERRIDE;
1256
Andreas Gampe3b165bc2016-08-01 22:07:04 -07001257 void CopyRawPtrFromThread(FrameOffset fr_offs,
1258 ThreadOffset64 thr_offs,
Andreas Gampe57b34292015-01-14 15:45:59 -08001259 ManagedRegister mscratch) OVERRIDE;
1260
Andreas Gampe3b165bc2016-08-01 22:07:04 -07001261 void CopyRawPtrToThread(ThreadOffset64 thr_offs,
1262 FrameOffset fr_offs,
1263 ManagedRegister mscratch) OVERRIDE;
1264
Andreas Gampe57b34292015-01-14 15:45:59 -08001265 void CopyRef(FrameOffset dest, FrameOffset src, ManagedRegister mscratch) OVERRIDE;
1266
1267 void Copy(FrameOffset dest, FrameOffset src, ManagedRegister mscratch, size_t size) OVERRIDE;
1268
1269 void Copy(FrameOffset dest, ManagedRegister src_base, Offset src_offset, ManagedRegister mscratch,
1270 size_t size) OVERRIDE;
1271
1272 void Copy(ManagedRegister dest_base, Offset dest_offset, FrameOffset src,
1273 ManagedRegister mscratch, size_t size) OVERRIDE;
1274
1275 void Copy(FrameOffset dest, FrameOffset src_base, Offset src_offset, ManagedRegister mscratch,
1276 size_t size) OVERRIDE;
1277
1278 void Copy(ManagedRegister dest, Offset dest_offset, ManagedRegister src, Offset src_offset,
1279 ManagedRegister mscratch, size_t size) OVERRIDE;
1280
1281 void Copy(FrameOffset dest, Offset dest_offset, FrameOffset src, Offset src_offset,
1282 ManagedRegister mscratch, size_t size) OVERRIDE;
1283
1284 void MemoryBarrier(ManagedRegister) OVERRIDE;
1285
Alexey Frunzea0e87b02015-09-24 22:57:20 -07001286 // Sign extension.
Andreas Gampe57b34292015-01-14 15:45:59 -08001287 void SignExtend(ManagedRegister mreg, size_t size) OVERRIDE;
1288
Alexey Frunzea0e87b02015-09-24 22:57:20 -07001289 // Zero extension.
Andreas Gampe57b34292015-01-14 15:45:59 -08001290 void ZeroExtend(ManagedRegister mreg, size_t size) OVERRIDE;
1291
Alexey Frunzea0e87b02015-09-24 22:57:20 -07001292 // Exploit fast access in managed code to Thread::Current().
Andreas Gampe57b34292015-01-14 15:45:59 -08001293 void GetCurrentThread(ManagedRegister tr) OVERRIDE;
1294 void GetCurrentThread(FrameOffset dest_offset, ManagedRegister mscratch) OVERRIDE;
1295
Mathieu Chartier2cebb242015-04-21 16:50:40 -07001296 // Set up out_reg to hold a Object** into the handle scope, or to be null if the
Andreas Gampe57b34292015-01-14 15:45:59 -08001297 // value is null and null_allowed. in_reg holds a possibly stale reference
1298 // that can be used to avoid loading the handle scope entry to see if the value is
Mathieu Chartier2cebb242015-04-21 16:50:40 -07001299 // null.
Andreas Gampe57b34292015-01-14 15:45:59 -08001300 void CreateHandleScopeEntry(ManagedRegister out_reg, FrameOffset handlescope_offset,
1301 ManagedRegister in_reg, bool null_allowed) OVERRIDE;
1302
Mathieu Chartier2cebb242015-04-21 16:50:40 -07001303 // Set up out_off to hold a Object** into the handle scope, or to be null if the
Andreas Gampe57b34292015-01-14 15:45:59 -08001304 // value is null and null_allowed.
1305 void CreateHandleScopeEntry(FrameOffset out_off, FrameOffset handlescope_offset, ManagedRegister
1306 mscratch, bool null_allowed) OVERRIDE;
1307
Alexey Frunzea0e87b02015-09-24 22:57:20 -07001308 // src holds a handle scope entry (Object**) load this into dst.
Andreas Gampe57b34292015-01-14 15:45:59 -08001309 void LoadReferenceFromHandleScope(ManagedRegister dst, ManagedRegister src) OVERRIDE;
1310
1311 // Heap::VerifyObject on src. In some cases (such as a reference to this) we
1312 // know that src may not be null.
1313 void VerifyObject(ManagedRegister src, bool could_be_null) OVERRIDE;
1314 void VerifyObject(FrameOffset src, bool could_be_null) OVERRIDE;
1315
Alexey Frunzea0e87b02015-09-24 22:57:20 -07001316 // Call to address held at [base+offset].
Andreas Gampe57b34292015-01-14 15:45:59 -08001317 void Call(ManagedRegister base, Offset offset, ManagedRegister mscratch) OVERRIDE;
1318 void Call(FrameOffset base, Offset offset, ManagedRegister mscratch) OVERRIDE;
Andreas Gampe3b165bc2016-08-01 22:07:04 -07001319 void CallFromThread(ThreadOffset64 offset, ManagedRegister mscratch) OVERRIDE;
Andreas Gampe57b34292015-01-14 15:45:59 -08001320
1321 // Generate code to check if Thread::Current()->exception_ is non-null
1322 // and branch to a ExceptionSlowPath if it is.
1323 void ExceptionPoll(ManagedRegister mscratch, size_t stack_adjust) OVERRIDE;
1324
Alexey Frunzea0e87b02015-09-24 22:57:20 -07001325 // Emit slow paths queued during assembly and promote short branches to long if needed.
1326 void FinalizeCode() OVERRIDE;
1327
1328 // Emit branches and finalize all instructions.
1329 void FinalizeInstructions(const MemoryRegion& region);
1330
1331 // Returns the (always-)current location of a label (can be used in class CodeGeneratorMIPS64,
1332 // must be used instead of Mips64Label::GetPosition()).
Alexey Frunze19f6c692016-11-30 19:19:55 -08001333 uint32_t GetLabelLocation(const Mips64Label* label) const;
Alexey Frunzea0e87b02015-09-24 22:57:20 -07001334
1335 // Get the final position of a label after local fixup based on the old position
1336 // recorded before FinalizeCode().
1337 uint32_t GetAdjustedPosition(uint32_t old_position);
1338
Alexey Frunze19f6c692016-11-30 19:19:55 -08001339 // Note that PC-relative literal loads are handled as pseudo branches because they need very
1340 // similar relocation and may similarly expand in size to accomodate for larger offsets relative
1341 // to PC.
Alexey Frunzea0e87b02015-09-24 22:57:20 -07001342 enum BranchCondition {
1343 kCondLT,
1344 kCondGE,
1345 kCondLE,
1346 kCondGT,
1347 kCondLTZ,
1348 kCondGEZ,
1349 kCondLEZ,
1350 kCondGTZ,
1351 kCondEQ,
1352 kCondNE,
1353 kCondEQZ,
1354 kCondNEZ,
1355 kCondLTU,
1356 kCondGEU,
Alexey Frunze299a9392015-12-08 16:08:02 -08001357 kCondF, // Floating-point predicate false.
1358 kCondT, // Floating-point predicate true.
Alexey Frunzea0e87b02015-09-24 22:57:20 -07001359 kUncond,
1360 };
1361 friend std::ostream& operator<<(std::ostream& os, const BranchCondition& rhs);
1362
Andreas Gampe57b34292015-01-14 15:45:59 -08001363 private:
Alexey Frunzea0e87b02015-09-24 22:57:20 -07001364 class Branch {
1365 public:
1366 enum Type {
1367 // Short branches.
1368 kUncondBranch,
1369 kCondBranch,
1370 kCall,
Alexey Frunze19f6c692016-11-30 19:19:55 -08001371 // Near label.
1372 kLabel,
1373 // Near literals.
1374 kLiteral,
1375 kLiteralUnsigned,
1376 kLiteralLong,
Alexey Frunzea0e87b02015-09-24 22:57:20 -07001377 // Long branches.
1378 kLongUncondBranch,
1379 kLongCondBranch,
1380 kLongCall,
Alexey Frunze19f6c692016-11-30 19:19:55 -08001381 // Far label.
1382 kFarLabel,
1383 // Far literals.
1384 kFarLiteral,
1385 kFarLiteralUnsigned,
1386 kFarLiteralLong,
Alexey Frunzea0e87b02015-09-24 22:57:20 -07001387 };
1388
1389 // Bit sizes of offsets defined as enums to minimize chance of typos.
1390 enum OffsetBits {
1391 kOffset16 = 16,
1392 kOffset18 = 18,
1393 kOffset21 = 21,
1394 kOffset23 = 23,
1395 kOffset28 = 28,
1396 kOffset32 = 32,
1397 };
1398
1399 static constexpr uint32_t kUnresolved = 0xffffffff; // Unresolved target_
1400 static constexpr int32_t kMaxBranchLength = 32;
1401 static constexpr int32_t kMaxBranchSize = kMaxBranchLength * sizeof(uint32_t);
1402
1403 struct BranchInfo {
1404 // Branch length as a number of 4-byte-long instructions.
1405 uint32_t length;
1406 // Ordinal number (0-based) of the first (or the only) instruction that contains the branch's
1407 // PC-relative offset (or its most significant 16-bit half, which goes first).
1408 uint32_t instr_offset;
1409 // Different MIPS instructions with PC-relative offsets apply said offsets to slightly
1410 // different origins, e.g. to PC or PC+4. Encode the origin distance (as a number of 4-byte
1411 // instructions) from the instruction containing the offset.
1412 uint32_t pc_org;
1413 // How large (in bits) a PC-relative offset can be for a given type of branch (kCondBranch is
1414 // an exception: use kOffset23 for beqzc/bnezc).
1415 OffsetBits offset_size;
1416 // Some MIPS instructions with PC-relative offsets shift the offset by 2. Encode the shift
1417 // count.
1418 int offset_shift;
1419 };
1420 static const BranchInfo branch_info_[/* Type */];
1421
Alexey Frunze19f6c692016-11-30 19:19:55 -08001422 // Unconditional branch or call.
1423 Branch(uint32_t location, uint32_t target, bool is_call);
Alexey Frunzea0e87b02015-09-24 22:57:20 -07001424 // Conditional branch.
1425 Branch(uint32_t location,
1426 uint32_t target,
1427 BranchCondition condition,
1428 GpuRegister lhs_reg,
Alexey Frunze19f6c692016-11-30 19:19:55 -08001429 GpuRegister rhs_reg);
1430 // Label address (in literal area) or literal.
1431 Branch(uint32_t location, GpuRegister dest_reg, Type label_or_literal_type);
Alexey Frunzea0e87b02015-09-24 22:57:20 -07001432
1433 // Some conditional branches with lhs = rhs are effectively NOPs, while some
1434 // others are effectively unconditional. MIPSR6 conditional branches require lhs != rhs.
1435 // So, we need a way to identify such branches in order to emit no instructions for them
1436 // or change them to unconditional.
1437 static bool IsNop(BranchCondition condition, GpuRegister lhs, GpuRegister rhs);
1438 static bool IsUncond(BranchCondition condition, GpuRegister lhs, GpuRegister rhs);
1439
1440 static BranchCondition OppositeCondition(BranchCondition cond);
1441
1442 Type GetType() const;
1443 BranchCondition GetCondition() const;
1444 GpuRegister GetLeftRegister() const;
1445 GpuRegister GetRightRegister() const;
1446 uint32_t GetTarget() const;
1447 uint32_t GetLocation() const;
1448 uint32_t GetOldLocation() const;
1449 uint32_t GetLength() const;
1450 uint32_t GetOldLength() const;
1451 uint32_t GetSize() const;
1452 uint32_t GetOldSize() const;
1453 uint32_t GetEndLocation() const;
1454 uint32_t GetOldEndLocation() const;
1455 bool IsLong() const;
1456 bool IsResolved() const;
1457
1458 // Returns the bit size of the signed offset that the branch instruction can handle.
1459 OffsetBits GetOffsetSize() const;
1460
1461 // Calculates the distance between two byte locations in the assembler buffer and
1462 // returns the number of bits needed to represent the distance as a signed integer.
1463 //
1464 // Branch instructions have signed offsets of 16, 19 (addiupc), 21 (beqzc/bnezc),
1465 // and 26 (bc) bits, which are additionally shifted left 2 positions at run time.
1466 //
1467 // Composite branches (made of several instructions) with longer reach have 32-bit
1468 // offsets encoded as 2 16-bit "halves" in two instructions (high half goes first).
1469 // The composite branches cover the range of PC + ~+/-2GB. The range is not end-to-end,
1470 // however. Consider the following implementation of a long unconditional branch, for
1471 // example:
1472 //
1473 // auipc at, offset_31_16 // at = pc + sign_extend(offset_31_16) << 16
1474 // jic at, offset_15_0 // pc = at + sign_extend(offset_15_0)
1475 //
1476 // Both of the above instructions take 16-bit signed offsets as immediate operands.
1477 // When bit 15 of offset_15_0 is 1, it effectively causes subtraction of 0x10000
1478 // due to sign extension. This must be compensated for by incrementing offset_31_16
1479 // by 1. offset_31_16 can only be incremented by 1 if it's not 0x7FFF. If it is
1480 // 0x7FFF, adding 1 will overflow the positive offset into the negative range.
1481 // Therefore, the long branch range is something like from PC - 0x80000000 to
1482 // PC + 0x7FFF7FFF, IOW, shorter by 32KB on one side.
1483 //
1484 // The returned values are therefore: 18, 21, 23, 28 and 32. There's also a special
1485 // case with the addiu instruction and a 16 bit offset.
1486 static OffsetBits GetOffsetSizeNeeded(uint32_t location, uint32_t target);
1487
1488 // Resolve a branch when the target is known.
1489 void Resolve(uint32_t target);
1490
1491 // Relocate a branch by a given delta if needed due to expansion of this or another
1492 // branch at a given location by this delta (just changes location_ and target_).
1493 void Relocate(uint32_t expand_location, uint32_t delta);
1494
1495 // If the branch is short, changes its type to long.
1496 void PromoteToLong();
1497
1498 // If necessary, updates the type by promoting a short branch to a long branch
1499 // based on the branch location and target. Returns the amount (in bytes) by
1500 // which the branch size has increased.
1501 // max_short_distance caps the maximum distance between location_ and target_
1502 // that is allowed for short branches. This is for debugging/testing purposes.
1503 // max_short_distance = 0 forces all short branches to become long.
1504 // Use the implicit default argument when not debugging/testing.
1505 uint32_t PromoteIfNeeded(uint32_t max_short_distance = std::numeric_limits<uint32_t>::max());
1506
1507 // Returns the location of the instruction(s) containing the offset.
1508 uint32_t GetOffsetLocation() const;
1509
1510 // Calculates and returns the offset ready for encoding in the branch instruction(s).
1511 uint32_t GetOffset() const;
1512
1513 private:
1514 // Completes branch construction by determining and recording its type.
Alexey Frunze19f6c692016-11-30 19:19:55 -08001515 void InitializeType(Type initial_type);
Alexey Frunzea0e87b02015-09-24 22:57:20 -07001516 // Helper for the above.
1517 void InitShortOrLong(OffsetBits ofs_size, Type short_type, Type long_type);
1518
1519 uint32_t old_location_; // Offset into assembler buffer in bytes.
1520 uint32_t location_; // Offset into assembler buffer in bytes.
1521 uint32_t target_; // Offset into assembler buffer in bytes.
1522
1523 GpuRegister lhs_reg_; // Left-hand side register in conditional branches or
Alexey Frunze19f6c692016-11-30 19:19:55 -08001524 // destination register in literals.
Alexey Frunzea0e87b02015-09-24 22:57:20 -07001525 GpuRegister rhs_reg_; // Right-hand side register in conditional branches.
1526 BranchCondition condition_; // Condition for conditional branches.
1527
1528 Type type_; // Current type of the branch.
1529 Type old_type_; // Initial type of the branch.
1530 };
1531 friend std::ostream& operator<<(std::ostream& os, const Branch::Type& rhs);
1532 friend std::ostream& operator<<(std::ostream& os, const Branch::OffsetBits& rhs);
1533
Andreas Gampe57b34292015-01-14 15:45:59 -08001534 void EmitR(int opcode, GpuRegister rs, GpuRegister rt, GpuRegister rd, int shamt, int funct);
Chris Larsen2fadd7b2015-08-14 14:56:10 -07001535 void EmitRsd(int opcode, GpuRegister rs, GpuRegister rd, int shamt, int funct);
1536 void EmitRtd(int opcode, GpuRegister rt, GpuRegister rd, int shamt, int funct);
Andreas Gampe57b34292015-01-14 15:45:59 -08001537 void EmitI(int opcode, GpuRegister rs, GpuRegister rt, uint16_t imm);
Alexey Frunze4dda3372015-06-01 18:31:49 -07001538 void EmitI21(int opcode, GpuRegister rs, uint32_t imm21);
Alexey Frunzea0e87b02015-09-24 22:57:20 -07001539 void EmitI26(int opcode, uint32_t imm26);
Andreas Gampe57b34292015-01-14 15:45:59 -08001540 void EmitFR(int opcode, int fmt, FpuRegister ft, FpuRegister fs, FpuRegister fd, int funct);
1541 void EmitFI(int opcode, int fmt, FpuRegister rt, uint16_t imm);
Alexey Frunzea0e87b02015-09-24 22:57:20 -07001542 void EmitBcondc(BranchCondition cond, GpuRegister rs, GpuRegister rt, uint32_t imm16_21);
Goran Jakovljevic5a9e51d2017-03-16 16:11:43 +00001543 void EmitMsa3R(int operation,
1544 int df,
1545 VectorRegister wt,
1546 VectorRegister ws,
1547 VectorRegister wd,
1548 int minor_opcode);
1549 void EmitMsaBIT(int operation, int df_m, VectorRegister ws, VectorRegister wd, int minor_opcode);
1550 void EmitMsaELM(int operation, int df_n, VectorRegister ws, VectorRegister wd, int minor_opcode);
1551 void EmitMsaMI10(int s10, GpuRegister rs, VectorRegister wd, int minor_opcode, int df);
Goran Jakovljevic3f444032017-03-31 14:38:20 +02001552 void EmitMsaI10(int operation, int df, int i10, VectorRegister wd, int minor_opcode);
Goran Jakovljevic5a9e51d2017-03-16 16:11:43 +00001553 void EmitMsa2R(int operation, int df, VectorRegister ws, VectorRegister wd, int minor_opcode);
1554 void EmitMsa2RF(int operation, int df, VectorRegister ws, VectorRegister wd, int minor_opcode);
Alexey Frunzea0e87b02015-09-24 22:57:20 -07001555
1556 void Buncond(Mips64Label* label);
1557 void Bcond(Mips64Label* label,
1558 BranchCondition condition,
1559 GpuRegister lhs,
1560 GpuRegister rhs = ZERO);
Alexey Frunze19f6c692016-11-30 19:19:55 -08001561 void Call(Mips64Label* label);
Alexey Frunzea0e87b02015-09-24 22:57:20 -07001562 void FinalizeLabeledBranch(Mips64Label* label);
1563
1564 Branch* GetBranch(uint32_t branch_id);
1565 const Branch* GetBranch(uint32_t branch_id) const;
1566
Alexey Frunze19f6c692016-11-30 19:19:55 -08001567 void EmitLiterals();
Alexey Frunze0960ac52016-12-20 17:24:59 -08001568 void ReserveJumpTableSpace();
1569 void EmitJumpTables();
Alexey Frunzea0e87b02015-09-24 22:57:20 -07001570 void PromoteBranches();
1571 void EmitBranch(Branch* branch);
1572 void EmitBranches();
1573 void PatchCFI();
1574
1575 // Emits exception block.
1576 void EmitExceptionPoll(Mips64ExceptionSlowPath* exception);
1577
Goran Jakovljevic27af9372017-03-15 15:31:34 +01001578 bool HasMsa() const {
1579 return has_msa_;
1580 }
1581
Alexey Frunzea0e87b02015-09-24 22:57:20 -07001582 // List of exception blocks to generate at the end of the code cache.
1583 std::vector<Mips64ExceptionSlowPath> exception_blocks_;
1584
1585 std::vector<Branch> branches_;
1586
1587 // Whether appending instructions at the end of the buffer or overwriting the existing ones.
1588 bool overwriting_;
1589 // The current overwrite location.
1590 uint32_t overwrite_location_;
1591
Alexey Frunze19f6c692016-11-30 19:19:55 -08001592 // Use std::deque<> for literal labels to allow insertions at the end
1593 // without invalidating pointers and references to existing elements.
1594 ArenaDeque<Literal> literals_;
1595 ArenaDeque<Literal> long_literals_; // 64-bit literals separated for alignment reasons.
1596
Alexey Frunze0960ac52016-12-20 17:24:59 -08001597 // Jump table list.
1598 ArenaDeque<JumpTable> jump_tables_;
1599
Alexey Frunzea0e87b02015-09-24 22:57:20 -07001600 // Data for AdjustedPosition(), see the description there.
1601 uint32_t last_position_adjustment_;
1602 uint32_t last_old_position_;
1603 uint32_t last_branch_id_;
Andreas Gampe57b34292015-01-14 15:45:59 -08001604
Goran Jakovljevic27af9372017-03-15 15:31:34 +01001605 const bool has_msa_;
1606
Andreas Gampe57b34292015-01-14 15:45:59 -08001607 DISALLOW_COPY_AND_ASSIGN(Mips64Assembler);
1608};
1609
Andreas Gampe57b34292015-01-14 15:45:59 -08001610} // namespace mips64
1611} // namespace art
1612
1613#endif // ART_COMPILER_UTILS_MIPS64_ASSEMBLER_MIPS64_H_