blob: 5a465203bc5ee3b5bd299ff9ce7061eb712ef068 [file] [log] [blame]
Brian Carlstrom7940e442013-07-12 13:46:57 -07001/*
2 * Copyright (C) 2011 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
Brian Carlstromfc0e3212013-07-17 14:40:12 -070017#ifndef ART_COMPILER_DEX_QUICK_X86_CODEGEN_X86_H_
18#define ART_COMPILER_DEX_QUICK_X86_CODEGEN_X86_H_
Brian Carlstrom7940e442013-07-12 13:46:57 -070019
Andreas Gampe0b9203e2015-01-22 20:39:27 -080020#include "base/logging.h"
21#include "dex/compiler_ir.h"
22#include "dex/mir_graph.h"
Andreas Gampe53c913b2014-08-12 23:19:23 -070023#include "dex/quick/mir_to_lir.h"
Brian Carlstrom7940e442013-07-12 13:46:57 -070024#include "x86_lir.h"
25
Dmitry Petrochenko58994cd2014-05-17 01:02:18 +070026#include <map>
Maxim Kazantsev6dccdc22014-08-18 18:43:55 +070027#include <vector>
Dmitry Petrochenko58994cd2014-05-17 01:02:18 +070028
Brian Carlstrom7940e442013-07-12 13:46:57 -070029namespace art {
30
Vladimir Marko1961b602015-04-08 20:51:48 +010031class X86Mir2Lir FINAL : public Mir2Lir {
Ian Rogers0f9b9c52014-06-09 01:32:12 -070032 protected:
Ian Rogers0f9b9c52014-06-09 01:32:12 -070033 class InToRegStorageX86_64Mapper : public InToRegStorageMapper {
34 public:
Serguei Katkov717a3e42014-11-13 17:19:42 +060035 explicit InToRegStorageX86_64Mapper(Mir2Lir* m2l)
36 : m2l_(m2l), cur_core_reg_(0), cur_fp_reg_(0) {}
37 virtual RegStorage GetNextReg(ShortyArg arg);
38 virtual void Reset() OVERRIDE {
39 cur_core_reg_ = 0;
40 cur_fp_reg_ = 0;
41 }
Chao-ying Fua77ee512014-07-01 17:43:41 -070042 protected:
Serguei Katkov717a3e42014-11-13 17:19:42 +060043 Mir2Lir* m2l_;
Serguei Katkov717a3e42014-11-13 17:19:42 +060044 size_t cur_core_reg_;
45 size_t cur_fp_reg_;
Ian Rogers0f9b9c52014-06-09 01:32:12 -070046 };
Dmitry Petrochenko58994cd2014-05-17 01:02:18 +070047
Mark P Mendell966c3ae2015-01-27 15:45:27 +000048 class InToRegStorageX86Mapper : public InToRegStorageX86_64Mapper {
Ian Rogers0f9b9c52014-06-09 01:32:12 -070049 public:
Mark P Mendell966c3ae2015-01-27 15:45:27 +000050 explicit InToRegStorageX86Mapper(Mir2Lir* m2l)
51 : InToRegStorageX86_64Mapper(m2l) { }
Serguei Katkov717a3e42014-11-13 17:19:42 +060052 virtual RegStorage GetNextReg(ShortyArg arg);
Ian Rogers0f9b9c52014-06-09 01:32:12 -070053 };
Dmitry Petrochenko58994cd2014-05-17 01:02:18 +070054
Serguei Katkov717a3e42014-11-13 17:19:42 +060055 InToRegStorageX86_64Mapper in_to_reg_storage_x86_64_mapper_;
56 InToRegStorageX86Mapper in_to_reg_storage_x86_mapper_;
57 InToRegStorageMapper* GetResetedInToRegStorageMapper() OVERRIDE {
58 InToRegStorageMapper* res;
59 if (cu_->target64) {
60 res = &in_to_reg_storage_x86_64_mapper_;
61 } else {
62 res = &in_to_reg_storage_x86_mapper_;
63 }
64 res->Reset();
65 return res;
66 }
67
Maxim Kazantsev6dccdc22014-08-18 18:43:55 +070068 class ExplicitTempRegisterLock {
69 public:
70 ExplicitTempRegisterLock(X86Mir2Lir* mir_to_lir, int n_regs, ...);
71 ~ExplicitTempRegisterLock();
72 protected:
73 std::vector<RegStorage> temp_regs_;
74 X86Mir2Lir* const mir_to_lir_;
75 };
76
Serguei Katkov717a3e42014-11-13 17:19:42 +060077 virtual int GenDalvikArgsBulkCopy(CallInfo* info, int first, int count) OVERRIDE;
78
Ian Rogers0f9b9c52014-06-09 01:32:12 -070079 public:
Elena Sayapinadd644502014-07-01 18:39:52 +070080 X86Mir2Lir(CompilationUnit* cu, MIRGraph* mir_graph, ArenaAllocator* arena);
Brian Carlstrom7940e442013-07-12 13:46:57 -070081
Ian Rogers0f9b9c52014-06-09 01:32:12 -070082 // Required for target - codegen helpers.
83 bool SmallLiteralDivRem(Instruction::Code dalvik_opcode, bool is_div, RegLocation rl_src,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +070084 RegLocation rl_dest, int lit) OVERRIDE;
Ian Rogers0f9b9c52014-06-09 01:32:12 -070085 bool EasyMultiply(RegLocation rl_src, RegLocation rl_dest, int lit) OVERRIDE;
Ningsheng Jian675e09b2014-10-23 13:48:36 +080086 void GenMultiplyByConstantFloat(RegLocation rl_dest, RegLocation rl_src1,
87 int32_t constant) OVERRIDE;
88 void GenMultiplyByConstantDouble(RegLocation rl_dest, RegLocation rl_src1,
89 int64_t constant) OVERRIDE;
Ian Rogers0f9b9c52014-06-09 01:32:12 -070090 LIR* CheckSuspendUsingLoad() OVERRIDE;
Andreas Gampe98430592014-07-27 19:44:50 -070091 RegStorage LoadHelper(QuickEntrypointEnum trampoline) OVERRIDE;
Ian Rogers0f9b9c52014-06-09 01:32:12 -070092 LIR* LoadBaseDisp(RegStorage r_base, int displacement, RegStorage r_dest,
Andreas Gampe3c12c512014-06-24 18:46:29 +000093 OpSize size, VolatileKind is_volatile) OVERRIDE;
Ian Rogers0f9b9c52014-06-09 01:32:12 -070094 LIR* LoadBaseIndexed(RegStorage r_base, RegStorage r_index, RegStorage r_dest, int scale,
Vladimir Marko3bf7c602014-05-07 14:55:43 +010095 OpSize size) OVERRIDE;
Ian Rogers0f9b9c52014-06-09 01:32:12 -070096 LIR* LoadConstantNoClobber(RegStorage r_dest, int value);
97 LIR* LoadConstantWide(RegStorage r_dest, int64_t value);
Yevgeny Rouban6af82062014-11-26 18:11:54 +060098 void GenLongToInt(RegLocation rl_dest, RegLocation rl_src);
Ian Rogers0f9b9c52014-06-09 01:32:12 -070099 LIR* StoreBaseDisp(RegStorage r_base, int displacement, RegStorage r_src,
Andreas Gampe3c12c512014-06-24 18:46:29 +0000100 OpSize size, VolatileKind is_volatile) OVERRIDE;
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700101 LIR* StoreBaseIndexed(RegStorage r_base, RegStorage r_index, RegStorage r_src, int scale,
102 OpSize size) OVERRIDE;
Vladimir Markobf535be2014-11-19 18:52:35 +0000103
104 /// @copydoc Mir2Lir::UnconditionallyMarkGCCard(RegStorage)
105 void UnconditionallyMarkGCCard(RegStorage tgt_addr_reg) OVERRIDE;
106
Vladimir Markodc56cc52015-03-27 18:18:36 +0000107 bool CanUseOpPcRelDexCacheArrayLoad() const OVERRIDE;
108 void OpPcRelDexCacheArrayLoad(const DexFile* dex_file, int offset, RegStorage r_dest) OVERRIDE;
109
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700110 void GenImplicitNullCheck(RegStorage reg, int opt_flags) OVERRIDE;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700111
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700112 // Required for target - register utilities.
Chao-ying Fua77ee512014-07-01 17:43:41 -0700113 RegStorage TargetReg(SpecialTargetRegister reg) OVERRIDE;
Andreas Gampeccc60262014-07-04 18:02:38 -0700114 RegStorage TargetReg(SpecialTargetRegister symbolic_reg, WideKind wide_kind) OVERRIDE {
115 if (wide_kind == kWide) {
116 if (cu_->target64) {
117 return As64BitReg(TargetReg32(symbolic_reg));
118 } else {
Mark P Mendell966c3ae2015-01-27 15:45:27 +0000119 if (symbolic_reg >= kFArg0 && symbolic_reg <= kFArg3) {
120 // We want an XMM, not a pair.
121 return As64BitReg(TargetReg32(symbolic_reg));
122 }
Andreas Gampeccc60262014-07-04 18:02:38 -0700123 // x86: construct a pair.
124 DCHECK((kArg0 <= symbolic_reg && symbolic_reg < kArg3) ||
Andreas Gampeccc60262014-07-04 18:02:38 -0700125 (kRet0 == symbolic_reg));
126 return RegStorage::MakeRegPair(TargetReg32(symbolic_reg),
127 TargetReg32(static_cast<SpecialTargetRegister>(symbolic_reg + 1)));
128 }
129 } else if (wide_kind == kRef && cu_->target64) {
130 return As64BitReg(TargetReg32(symbolic_reg));
Chao-ying Fua77ee512014-07-01 17:43:41 -0700131 } else {
Andreas Gampeccc60262014-07-04 18:02:38 -0700132 return TargetReg32(symbolic_reg);
Chao-ying Fua77ee512014-07-01 17:43:41 -0700133 }
134 }
Chao-ying Fua77ee512014-07-01 17:43:41 -0700135 RegStorage TargetPtrReg(SpecialTargetRegister symbolic_reg) OVERRIDE {
Andreas Gampeccc60262014-07-04 18:02:38 -0700136 return TargetReg(symbolic_reg, cu_->target64 ? kWide : kNotWide);
Chao-ying Fua77ee512014-07-01 17:43:41 -0700137 }
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700138
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700139 RegLocation GetReturnAlt() OVERRIDE;
140 RegLocation GetReturnWideAlt() OVERRIDE;
141 RegLocation LocCReturn() OVERRIDE;
142 RegLocation LocCReturnRef() OVERRIDE;
143 RegLocation LocCReturnDouble() OVERRIDE;
144 RegLocation LocCReturnFloat() OVERRIDE;
145 RegLocation LocCReturnWide() OVERRIDE;
146
Vladimir Marko8dea81c2014-06-06 14:50:36 +0100147 ResourceMask GetRegMaskCommon(const RegStorage& reg) const OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700148 void AdjustSpillMask() OVERRIDE;
149 void ClobberCallerSave() OVERRIDE;
150 void FreeCallTemps() OVERRIDE;
151 void LockCallTemps() OVERRIDE;
152
153 void CompilerInitializeRegAlloc() OVERRIDE;
154 int VectorRegisterSize() OVERRIDE;
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700155 int NumReservableVectorRegisters(bool long_or_fp) OVERRIDE;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700156
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700157 // Required for target - miscellaneous.
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700158 void AssembleLIR() OVERRIDE;
Vladimir Marko8dea81c2014-06-06 14:50:36 +0100159 void DumpResourceMask(LIR* lir, const ResourceMask& mask, const char* prefix) OVERRIDE;
160 void SetupTargetResourceMasks(LIR* lir, uint64_t flags,
161 ResourceMask* use_mask, ResourceMask* def_mask) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700162 const char* GetTargetInstFmt(int opcode) OVERRIDE;
163 const char* GetTargetInstName(int opcode) OVERRIDE;
164 std::string BuildInsnString(const char* fmt, LIR* lir, unsigned char* base_addr) OVERRIDE;
Vladimir Marko8dea81c2014-06-06 14:50:36 +0100165 ResourceMask GetPCUseDefEncoding() const OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700166 uint64_t GetTargetInstFlags(int opcode) OVERRIDE;
Ian Rogers5aa6e042014-06-13 16:38:24 -0700167 size_t GetInsnSize(LIR* lir) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700168 bool IsUnconditionalBranch(LIR* lir) OVERRIDE;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700169
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700170 // Get the register class for load/store of a field.
171 RegisterClass RegClassForFieldLoadStore(OpSize size, bool is_volatile) OVERRIDE;
Vladimir Marko674744e2014-04-24 15:18:26 +0100172
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700173 // Required for target - Dalvik-level generators.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700174 void GenArrayGet(int opt_flags, OpSize size, RegLocation rl_array, RegLocation rl_index,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700175 RegLocation rl_dest, int scale) OVERRIDE;
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700176 void GenArrayPut(int opt_flags, OpSize size, RegLocation rl_array,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700177 RegLocation rl_index, RegLocation rl_src, int scale, bool card_mark) OVERRIDE;
178
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700179 void GenArithOpDouble(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700180 RegLocation rl_src2) OVERRIDE;
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700181 void GenArithOpFloat(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700182 RegLocation rl_src2) OVERRIDE;
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700183 void GenCmpFP(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700184 RegLocation rl_src2) OVERRIDE;
185 void GenConversion(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src) OVERRIDE;
186
187 bool GenInlinedCas(CallInfo* info, bool is_long, bool is_object) OVERRIDE;
188 bool GenInlinedMinMax(CallInfo* info, bool is_min, bool is_long) OVERRIDE;
189 bool GenInlinedMinMaxFP(CallInfo* info, bool is_min, bool is_double) OVERRIDE;
Yixin Shou8c914c02014-07-28 14:17:09 -0400190 bool GenInlinedReverseBits(CallInfo* info, OpSize size) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700191 bool GenInlinedSqrt(CallInfo* info) OVERRIDE;
Yixin Shou7071c8d2014-03-05 06:07:48 -0500192 bool GenInlinedAbsFloat(CallInfo* info) OVERRIDE;
193 bool GenInlinedAbsDouble(CallInfo* info) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700194 bool GenInlinedPeek(CallInfo* info, OpSize size) OVERRIDE;
195 bool GenInlinedPoke(CallInfo* info, OpSize size) OVERRIDE;
Andreas Gampe98430592014-07-27 19:44:50 -0700196 bool GenInlinedCharAt(CallInfo* info) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700197
198 // Long instructions.
Andreas Gampec76c6142014-08-04 16:30:03 -0700199 void GenArithOpLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700200 RegLocation rl_src2, int flags) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700201 void GenArithImmOpLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700202 RegLocation rl_src2, int flags) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700203 void GenShiftImmOpLong(Instruction::Code opcode, RegLocation rl_dest,
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700204 RegLocation rl_src1, RegLocation rl_shift, int flags) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700205 void GenCmpLong(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2) OVERRIDE;
206 void GenIntToLong(RegLocation rl_dest, RegLocation rl_src) OVERRIDE;
207 void GenShiftOpLong(Instruction::Code opcode, RegLocation rl_dest,
208 RegLocation rl_src1, RegLocation rl_shift) OVERRIDE;
Razvan A Lupusoru3bc01742014-02-06 13:18:43 -0800209
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700210 /*
211 * @brief Generate a two address long operation with a constant value
212 * @param rl_dest location of result
213 * @param rl_src constant source operand
214 * @param op Opcode to be generated
215 * @return success or not
216 */
217 bool GenLongImm(RegLocation rl_dest, RegLocation rl_src, Instruction::Code op);
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700218
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700219 /*
220 * @brief Generate a three address long operation with a constant value
221 * @param rl_dest location of result
222 * @param rl_src1 source operand
223 * @param rl_src2 constant source operand
224 * @param op Opcode to be generated
225 * @return success or not
226 */
227 bool GenLongLongImm(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2,
228 Instruction::Code op);
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700229 /**
230 * @brief Generate a long arithmetic operation.
231 * @param rl_dest The destination.
232 * @param rl_src1 First operand.
233 * @param rl_src2 Second operand.
234 * @param op The DEX opcode for the operation.
235 * @param is_commutative The sources can be swapped if needed.
236 */
237 virtual void GenLongArith(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2,
238 Instruction::Code op, bool is_commutative);
Mark Mendelle02d48f2014-01-15 11:19:23 -0800239
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700240 /**
241 * @brief Generate a two operand long arithmetic operation.
242 * @param rl_dest The destination.
243 * @param rl_src Second operand.
244 * @param op The DEX opcode for the operation.
245 */
246 void GenLongArith(RegLocation rl_dest, RegLocation rl_src, Instruction::Code op);
Mark Mendelle02d48f2014-01-15 11:19:23 -0800247
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700248 /**
249 * @brief Generate a long operation.
250 * @param rl_dest The destination. Must be in a register
251 * @param rl_src The other operand. May be in a register or in memory.
252 * @param op The DEX opcode for the operation.
253 */
254 virtual void GenLongRegOrMemOp(RegLocation rl_dest, RegLocation rl_src, Instruction::Code op);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700255
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700256
257 // TODO: collapse reg_lo, reg_hi
258 RegLocation GenDivRem(RegLocation rl_dest, RegStorage reg_lo, RegStorage reg_hi, bool is_div)
259 OVERRIDE;
260 RegLocation GenDivRemLit(RegLocation rl_dest, RegStorage reg_lo, int lit, bool is_div) OVERRIDE;
261 void GenDivZeroCheckWide(RegStorage reg) OVERRIDE;
262 void GenEntrySequence(RegLocation* ArgLocs, RegLocation rl_method) OVERRIDE;
263 void GenExitSequence() OVERRIDE;
264 void GenSpecialExitSequence() OVERRIDE;
Vladimir Marko6ce3eba2015-02-16 13:05:59 +0000265 void GenSpecialEntryForSuspend() OVERRIDE;
266 void GenSpecialExitForSuspend() OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700267 void GenFusedFPCmpBranch(BasicBlock* bb, MIR* mir, bool gt_bias, bool is_double) OVERRIDE;
268 void GenFusedLongCmpBranch(BasicBlock* bb, MIR* mir) OVERRIDE;
269 void GenSelect(BasicBlock* bb, MIR* mir) OVERRIDE;
270 void GenSelectConst32(RegStorage left_op, RegStorage right_op, ConditionCode code,
271 int32_t true_val, int32_t false_val, RegStorage rs_dest,
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700272 RegisterClass dest_reg_class) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700273 bool GenMemBarrier(MemBarrierKind barrier_kind) OVERRIDE;
274 void GenMoveException(RegLocation rl_dest) OVERRIDE;
275 void GenMultiplyByTwoBitMultiplier(RegLocation rl_src, RegLocation rl_result, int lit,
276 int first_bit, int second_bit) OVERRIDE;
277 void GenNegDouble(RegLocation rl_dest, RegLocation rl_src) OVERRIDE;
278 void GenNegFloat(RegLocation rl_dest, RegLocation rl_src) OVERRIDE;
Andreas Gampe48971b32014-08-06 10:09:01 -0700279 void GenLargePackedSwitch(MIR* mir, DexOffset table_offset, RegLocation rl_src) OVERRIDE;
280 void GenLargeSparseSwitch(MIR* mir, DexOffset table_offset, RegLocation rl_src) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700281
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700282 /**
283 * @brief Implement instanceof a final class with x86 specific code.
284 * @param use_declaring_class 'true' if we can use the class itself.
285 * @param type_idx Type index to use if use_declaring_class is 'false'.
286 * @param rl_dest Result to be set to 0 or 1.
287 * @param rl_src Object to be tested.
288 */
289 void GenInstanceofFinal(bool use_declaring_class, uint32_t type_idx, RegLocation rl_dest,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700290 RegLocation rl_src) OVERRIDE;
Chao-ying Fua0147762014-06-06 18:38:49 -0700291
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700292 // Single operation generators.
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700293 LIR* OpUnconditionalBranch(LIR* target) OVERRIDE;
294 LIR* OpCmpBranch(ConditionCode cond, RegStorage src1, RegStorage src2, LIR* target) OVERRIDE;
295 LIR* OpCmpImmBranch(ConditionCode cond, RegStorage reg, int check_value, LIR* target) OVERRIDE;
296 LIR* OpCondBranch(ConditionCode cc, LIR* target) OVERRIDE;
297 LIR* OpDecAndBranch(ConditionCode c_code, RegStorage reg, LIR* target) OVERRIDE;
298 LIR* OpFpRegCopy(RegStorage r_dest, RegStorage r_src) OVERRIDE;
299 LIR* OpIT(ConditionCode cond, const char* guide) OVERRIDE;
300 void OpEndIT(LIR* it) OVERRIDE;
301 LIR* OpMem(OpKind op, RegStorage r_base, int disp) OVERRIDE;
Vladimir Markof6737f72015-03-23 17:05:14 +0000302 void OpPcRelLoad(RegStorage reg, LIR* target) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700303 LIR* OpReg(OpKind op, RegStorage r_dest_src) OVERRIDE;
304 void OpRegCopy(RegStorage r_dest, RegStorage r_src) OVERRIDE;
305 LIR* OpRegCopyNoInsert(RegStorage r_dest, RegStorage r_src) OVERRIDE;
306 LIR* OpRegImm(OpKind op, RegStorage r_dest_src1, int value) OVERRIDE;
307 LIR* OpRegReg(OpKind op, RegStorage r_dest_src1, RegStorage r_src2) OVERRIDE;
308 LIR* OpMovRegMem(RegStorage r_dest, RegStorage r_base, int offset, MoveType move_type) OVERRIDE;
309 LIR* OpMovMemReg(RegStorage r_base, int offset, RegStorage r_src, MoveType move_type) OVERRIDE;
310 LIR* OpCondRegReg(OpKind op, ConditionCode cc, RegStorage r_dest, RegStorage r_src) OVERRIDE;
311 LIR* OpRegRegImm(OpKind op, RegStorage r_dest, RegStorage r_src1, int value) OVERRIDE;
312 LIR* OpRegRegReg(OpKind op, RegStorage r_dest, RegStorage r_src1, RegStorage r_src2) OVERRIDE;
313 LIR* OpTestSuspend(LIR* target) OVERRIDE;
314 LIR* OpVldm(RegStorage r_base, int count) OVERRIDE;
315 LIR* OpVstm(RegStorage r_base, int count) OVERRIDE;
316 void OpRegCopyWide(RegStorage dest, RegStorage src) OVERRIDE;
317 bool GenInlinedCurrentThread(CallInfo* info) OVERRIDE;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700318
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700319 bool InexpensiveConstantInt(int32_t value) OVERRIDE;
320 bool InexpensiveConstantFloat(int32_t value) OVERRIDE;
321 bool InexpensiveConstantLong(int64_t value) OVERRIDE;
322 bool InexpensiveConstantDouble(int64_t value) OVERRIDE;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700323
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700324 /*
325 * @brief Should try to optimize for two address instructions?
326 * @return true if we try to avoid generating three operand instructions.
327 */
328 virtual bool GenerateTwoOperandInstructions() const { return true; }
Mark Mendelle87f9b52014-04-30 14:13:18 -0400329
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700330 /*
331 * @brief x86 specific codegen for int operations.
332 * @param opcode Operation to perform.
333 * @param rl_dest Destination for the result.
334 * @param rl_lhs Left hand operand.
335 * @param rl_rhs Right hand operand.
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700336 * @param flags The instruction optimization flags.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700337 */
338 void GenArithOpInt(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_lhs,
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700339 RegLocation rl_rhs, int flags) OVERRIDE;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800340
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700341 /*
342 * @brief Load the Method* of a dex method into the register.
343 * @param target_method The MethodReference of the method to be invoked.
344 * @param type How the method will be invoked.
345 * @param register that will contain the code address.
346 * @note register will be passed to TargetReg to get physical register.
347 */
348 void LoadMethodAddress(const MethodReference& target_method, InvokeType type,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700349 SpecialTargetRegister symbolic_reg) OVERRIDE;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800350
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700351 /*
352 * @brief Load the Class* of a Dex Class type into the register.
Fred Shihe7f82e22014-08-06 10:46:37 -0700353 * @param dex DexFile that contains the class type.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700354 * @param type How the method will be invoked.
355 * @param register that will contain the code address.
356 * @note register will be passed to TargetReg to get physical register.
357 */
Fred Shihe7f82e22014-08-06 10:46:37 -0700358 void LoadClassType(const DexFile& dex_file, uint32_t type_idx,
359 SpecialTargetRegister symbolic_reg) OVERRIDE;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800360
Vladimir Markof4da6752014-08-01 19:04:18 +0100361 NextCallInsn GetNextSDCallInsn() OVERRIDE;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800362
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700363 /*
364 * @brief Generate a relative call to the method that will be patched at link time.
365 * @param target_method The MethodReference of the method to be invoked.
366 * @param type How the method will be invoked.
367 * @returns Call instruction
368 */
Vladimir Markof4da6752014-08-01 19:04:18 +0100369 LIR* CallWithLinkerFixup(const MethodReference& target_method, InvokeType type);
370
371 /*
372 * @brief Generate the actual call insn based on the method info.
373 * @param method_info the lowering info for the method call.
374 * @returns Call instruction
375 */
376 LIR* GenCallInsn(const MirMethodLoweringInfo& method_info) OVERRIDE;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800377
Vladimir Marko1961b602015-04-08 20:51:48 +0100378 void AnalyzeMIR(RefCounts* core_counts, MIR* mir, uint32_t weight) OVERRIDE;
379 void CountRefs(RefCounts* core_counts, RefCounts* fp_counts, size_t num_regs) OVERRIDE;
380 void DoPromotion() OVERRIDE;
381
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700382 /*
383 * @brief Handle x86 specific literals
384 */
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700385 void InstallLiteralPools() OVERRIDE;
Mark Mendellae9fd932014-02-10 16:14:35 -0800386
Andreas Gampe98430592014-07-27 19:44:50 -0700387 LIR* InvokeTrampoline(OpKind op, RegStorage r_tgt, QuickEntrypointEnum trampoline) OVERRIDE;
388
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700389 protected:
Ian Rogersb28c1c02014-11-08 11:21:21 -0800390 RegStorage TargetReg32(SpecialTargetRegister reg) const;
Chao-ying Fua77ee512014-07-01 17:43:41 -0700391 // Casting of RegStorage
392 RegStorage As32BitReg(RegStorage reg) {
393 DCHECK(!reg.IsPair());
394 if ((kFailOnSizeError || kReportSizeError) && !reg.Is64Bit()) {
395 if (kFailOnSizeError) {
396 LOG(FATAL) << "Expected 64b register " << reg.GetReg();
397 } else {
398 LOG(WARNING) << "Expected 64b register " << reg.GetReg();
399 return reg;
400 }
401 }
402 RegStorage ret_val = RegStorage(RegStorage::k32BitSolo,
403 reg.GetRawBits() & RegStorage::kRegTypeMask);
404 DCHECK_EQ(GetRegInfo(reg)->FindMatchingView(RegisterInfo::k32SoloStorageMask)
405 ->GetReg().GetReg(),
406 ret_val.GetReg());
407 return ret_val;
408 }
409
410 RegStorage As64BitReg(RegStorage reg) {
411 DCHECK(!reg.IsPair());
412 if ((kFailOnSizeError || kReportSizeError) && !reg.Is32Bit()) {
413 if (kFailOnSizeError) {
414 LOG(FATAL) << "Expected 32b register " << reg.GetReg();
415 } else {
416 LOG(WARNING) << "Expected 32b register " << reg.GetReg();
417 return reg;
418 }
419 }
420 RegStorage ret_val = RegStorage(RegStorage::k64BitSolo,
421 reg.GetRawBits() & RegStorage::kRegTypeMask);
422 DCHECK_EQ(GetRegInfo(reg)->FindMatchingView(RegisterInfo::k64SoloStorageMask)
423 ->GetReg().GetReg(),
424 ret_val.GetReg());
425 return ret_val;
426 }
427
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700428 LIR* LoadBaseIndexedDisp(RegStorage r_base, RegStorage r_index, int scale, int displacement,
429 RegStorage r_dest, OpSize size);
430 LIR* StoreBaseIndexedDisp(RegStorage r_base, RegStorage r_index, int scale, int displacement,
Jean Christophe Beylerb5bce7c2014-07-25 12:32:18 -0700431 RegStorage r_src, OpSize size, int opt_flags = 0);
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700432
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700433 int AssignInsnOffsets();
434 void AssignOffsets();
Chao-ying Fuc4013ea2015-04-22 10:51:21 -0700435 AssemblerStatus AssembleInstructions(LIR* first_lir_insn, CodeOffset start_addr);
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700436
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700437 size_t ComputeSize(const X86EncodingMap* entry, int32_t raw_reg, int32_t raw_index,
Ian Rogers5aa6e042014-06-13 16:38:24 -0700438 int32_t raw_base, int32_t displacement);
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700439 void CheckValidByteRegister(const X86EncodingMap* entry, int32_t raw_reg);
440 void EmitPrefix(const X86EncodingMap* entry,
Ian Rogers5aa6e042014-06-13 16:38:24 -0700441 int32_t raw_reg_r, int32_t raw_reg_x, int32_t raw_reg_b);
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700442 void EmitOpcode(const X86EncodingMap* entry);
443 void EmitPrefixAndOpcode(const X86EncodingMap* entry,
Ian Rogers5aa6e042014-06-13 16:38:24 -0700444 int32_t reg_r, int32_t reg_x, int32_t reg_b);
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700445 void EmitDisp(uint8_t base, int32_t disp);
446 void EmitModrmThread(uint8_t reg_or_opcode);
447 void EmitModrmDisp(uint8_t reg_or_opcode, uint8_t base, int32_t disp);
448 void EmitModrmSibDisp(uint8_t reg_or_opcode, uint8_t base, uint8_t index, int scale,
449 int32_t disp);
450 void EmitImm(const X86EncodingMap* entry, int64_t imm);
451 void EmitNullary(const X86EncodingMap* entry);
452 void EmitOpRegOpcode(const X86EncodingMap* entry, int32_t raw_reg);
453 void EmitOpReg(const X86EncodingMap* entry, int32_t raw_reg);
454 void EmitOpMem(const X86EncodingMap* entry, int32_t raw_base, int32_t disp);
455 void EmitOpArray(const X86EncodingMap* entry, int32_t raw_base, int32_t raw_index, int scale,
456 int32_t disp);
457 void EmitMemReg(const X86EncodingMap* entry, int32_t raw_base, int32_t disp, int32_t raw_reg);
458 void EmitRegMem(const X86EncodingMap* entry, int32_t raw_reg, int32_t raw_base, int32_t disp);
459 void EmitRegArray(const X86EncodingMap* entry, int32_t raw_reg, int32_t raw_base,
460 int32_t raw_index, int scale, int32_t disp);
461 void EmitArrayReg(const X86EncodingMap* entry, int32_t raw_base, int32_t raw_index, int scale,
462 int32_t disp, int32_t raw_reg);
463 void EmitMemImm(const X86EncodingMap* entry, int32_t raw_base, int32_t disp, int32_t imm);
464 void EmitArrayImm(const X86EncodingMap* entry, int32_t raw_base, int32_t raw_index, int scale,
465 int32_t raw_disp, int32_t imm);
466 void EmitRegThread(const X86EncodingMap* entry, int32_t raw_reg, int32_t disp);
467 void EmitRegReg(const X86EncodingMap* entry, int32_t raw_reg1, int32_t raw_reg2);
468 void EmitRegRegImm(const X86EncodingMap* entry, int32_t raw_reg1, int32_t raw_reg2, int32_t imm);
469 void EmitRegMemImm(const X86EncodingMap* entry, int32_t raw_reg1, int32_t raw_base, int32_t disp,
470 int32_t imm);
471 void EmitMemRegImm(const X86EncodingMap* entry, int32_t base, int32_t disp, int32_t raw_reg1,
472 int32_t imm);
473 void EmitRegImm(const X86EncodingMap* entry, int32_t raw_reg, int32_t imm);
474 void EmitThreadImm(const X86EncodingMap* entry, int32_t disp, int32_t imm);
475 void EmitMovRegImm(const X86EncodingMap* entry, int32_t raw_reg, int64_t imm);
476 void EmitShiftRegImm(const X86EncodingMap* entry, int32_t raw_reg, int32_t imm);
477 void EmitShiftRegCl(const X86EncodingMap* entry, int32_t raw_reg, int32_t raw_cl);
478 void EmitShiftMemCl(const X86EncodingMap* entry, int32_t raw_base, int32_t disp, int32_t raw_cl);
Yixin Shouf40f8902014-08-14 14:10:32 -0400479 void EmitShiftRegRegCl(const X86EncodingMap* entry, int32_t raw_reg1, int32_t raw_reg2,
480 int32_t raw_cl);
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700481 void EmitShiftMemImm(const X86EncodingMap* entry, int32_t raw_base, int32_t disp, int32_t imm);
482 void EmitRegCond(const X86EncodingMap* entry, int32_t raw_reg, int32_t cc);
483 void EmitMemCond(const X86EncodingMap* entry, int32_t raw_base, int32_t disp, int32_t cc);
484 void EmitRegRegCond(const X86EncodingMap* entry, int32_t raw_reg1, int32_t raw_reg2, int32_t cc);
485 void EmitRegMemCond(const X86EncodingMap* entry, int32_t raw_reg1, int32_t raw_base, int32_t disp,
486 int32_t cc);
Razvan A Lupusorubd288c22013-12-20 17:27:23 -0800487
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700488 void EmitJmp(const X86EncodingMap* entry, int32_t rel);
489 void EmitJcc(const X86EncodingMap* entry, int32_t rel, int32_t cc);
490 void EmitCallMem(const X86EncodingMap* entry, int32_t raw_base, int32_t disp);
491 void EmitCallImmediate(const X86EncodingMap* entry, int32_t disp);
492 void EmitCallThread(const X86EncodingMap* entry, int32_t disp);
493 void EmitPcRel(const X86EncodingMap* entry, int32_t raw_reg, int32_t raw_base_or_table,
494 int32_t raw_index, int scale, int32_t table_or_disp);
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700495 void EmitUnimplemented(const X86EncodingMap* entry, LIR* lir);
496 void GenFusedLongCmpImmBranch(BasicBlock* bb, RegLocation rl_src1,
497 int64_t val, ConditionCode ccode);
498 void GenConstWide(RegLocation rl_dest, int64_t value);
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700499 void GenMultiplyVectorSignedByte(RegStorage rs_dest_src1, RegStorage rs_src2);
500 void GenMultiplyVectorLong(RegStorage rs_dest_src1, RegStorage rs_src2);
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700501 void GenShiftByteVector(MIR* mir);
Yixin Shouf40f8902014-08-14 14:10:32 -0400502 void AndMaskVectorRegister(RegStorage rs_src1, uint32_t m1, uint32_t m2, uint32_t m3,
503 uint32_t m4);
504 void MaskVectorRegister(X86OpCode opcode, RegStorage rs_src1, uint32_t m1, uint32_t m2,
505 uint32_t m3, uint32_t m4);
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700506 void AppendOpcodeWithConst(X86OpCode opcode, int reg, MIR* mir);
Mark Mendell0a1174e2014-09-11 14:51:02 -0400507 virtual void LoadVectorRegister(RegStorage rs_dest, RegStorage rs_src, OpSize opsize,
508 int op_mov);
Mark Mendell2637f2e2014-04-30 10:10:47 -0400509
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700510 static bool ProvidesFullMemoryBarrier(X86OpCode opcode);
Mark Mendelle02d48f2014-01-15 11:19:23 -0800511
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700512 /*
513 * @brief Ensure that a temporary register is byte addressable.
514 * @returns a temporary guarenteed to be byte addressable.
515 */
516 virtual RegStorage AllocateByteRegister();
Razvan A Lupusoru99ad7232014-02-25 17:41:08 -0800517
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700518 /*
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700519 * @brief Use a wide temporary as a 128-bit register
520 * @returns a 128-bit temporary register.
521 */
522 virtual RegStorage Get128BitRegister(RegStorage reg);
523
524 /*
Chao-ying Fu7e399fd2014-06-10 18:11:11 -0700525 * @brief Check if a register is byte addressable.
526 * @returns true if a register is byte addressable.
527 */
Ian Rogersb28c1c02014-11-08 11:21:21 -0800528 bool IsByteRegister(RegStorage reg) const;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700529
530 void GenDivRemLongLit(RegLocation rl_dest, RegLocation rl_src, int64_t imm, bool is_div);
531
DaniilSokolov70c4f062014-06-24 17:34:00 -0700532 bool GenInlinedArrayCopyCharArray(CallInfo* info) OVERRIDE;
Chao-ying Fu7e399fd2014-06-10 18:11:11 -0700533
534 /*
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700535 * @brief generate inline code for fast case of Strng.indexOf.
536 * @param info Call parameters
537 * @param zero_based 'true' if the index into the string is 0.
538 * @returns 'true' if the call was inlined, 'false' if a regular call needs to be
539 * generated.
540 */
541 bool GenInlinedIndexOf(CallInfo* info, bool zero_based);
Mark Mendelle87f9b52014-04-30 14:13:18 -0400542
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700543 /**
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700544 * @brief Used to reserve a range of vector registers.
545 * @see kMirOpReserveVectorRegisters
546 * @param mir The extended MIR for reservation.
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700547 */
548 void ReserveVectorRegisters(MIR* mir);
549
550 /**
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700551 * @brief Used to return a range of vector registers.
552 * @see kMirOpReturnVectorRegisters
553 * @param mir The extended MIR for returning vector regs.
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700554 */
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700555 void ReturnVectorRegisters(MIR* mir);
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700556
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700557 /*
558 * @brief Load 128 bit constant into vector register.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700559 * @param mir The MIR whose opcode is kMirConstVector
560 * @note vA is the TypeSize for the register.
561 * @note vB is the destination XMM register. arg[0..3] are 32 bit constant values.
562 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700563 void GenConst128(MIR* mir);
Mark Mendell4028a6c2014-02-19 20:06:20 -0800564
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700565 /*
566 * @brief MIR to move a vectorized register to another.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700567 * @param mir The MIR whose opcode is kMirConstVector.
568 * @note vA: TypeSize
569 * @note vB: destination
570 * @note vC: source
571 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700572 void GenMoveVector(MIR* mir);
Mark Mendelld65c51a2014-04-29 16:55:20 -0400573
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700574 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400575 * @brief Packed multiply of units in two vector registers: vB = vB .* @note vC using vA to know
576 * the type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700577 * @param mir The MIR whose opcode is kMirConstVector.
578 * @note vA: TypeSize
579 * @note vB: destination and source
580 * @note vC: source
581 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700582 void GenMultiplyVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400583
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700584 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400585 * @brief Packed addition of units in two vector registers: vB = vB .+ vC using vA to know the
586 * type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700587 * @param mir The MIR whose opcode is kMirConstVector.
588 * @note vA: TypeSize
589 * @note vB: destination and source
590 * @note vC: source
591 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700592 void GenAddVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400593
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700594 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400595 * @brief Packed subtraction of units in two vector registers: vB = vB .- vC using vA to know the
596 * type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700597 * @param mir The MIR whose opcode is kMirConstVector.
598 * @note vA: TypeSize
599 * @note vB: destination and source
600 * @note vC: source
601 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700602 void GenSubtractVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400603
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700604 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400605 * @brief Packed shift left of units in two vector registers: vB = vB .<< vC using vA to know the
606 * type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700607 * @param mir The MIR whose opcode is kMirConstVector.
608 * @note vA: TypeSize
609 * @note vB: destination and source
610 * @note vC: immediate
611 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700612 void GenShiftLeftVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400613
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700614 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400615 * @brief Packed signed shift right of units in two vector registers: vB = vB .>> vC using vA to
616 * know the type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700617 * @param mir The MIR whose opcode is kMirConstVector.
618 * @note vA: TypeSize
619 * @note vB: destination and source
620 * @note vC: immediate
621 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700622 void GenSignedShiftRightVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400623
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700624 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400625 * @brief Packed unsigned shift right of units in two vector registers: vB = vB .>>> vC using vA
626 * to know the type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700627 * @param mir The MIR whose opcode is kMirConstVector.
628 * @note vA: TypeSize
629 * @note vB: destination and source
630 * @note vC: immediate
631 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700632 void GenUnsignedShiftRightVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400633
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700634 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400635 * @brief Packed bitwise and of units in two vector registers: vB = vB .& vC using vA to know the
636 * type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700637 * @note vA: TypeSize
638 * @note vB: destination and source
639 * @note vC: source
640 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700641 void GenAndVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400642
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700643 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400644 * @brief Packed bitwise or of units in two vector registers: vB = vB .| vC using vA to know the
645 * type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700646 * @param mir The MIR whose opcode is kMirConstVector.
647 * @note vA: TypeSize
648 * @note vB: destination and source
649 * @note vC: source
650 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700651 void GenOrVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400652
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700653 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400654 * @brief Packed bitwise xor of units in two vector registers: vB = vB .^ vC using vA to know the
655 * type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700656 * @param mir The MIR whose opcode is kMirConstVector.
657 * @note vA: TypeSize
658 * @note vB: destination and source
659 * @note vC: source
660 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700661 void GenXorVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400662
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700663 /*
664 * @brief Reduce a 128-bit packed element into a single VR by taking lower bits
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700665 * @param mir The MIR whose opcode is kMirConstVector.
666 * @details Instruction does a horizontal addition of the packed elements and then adds it to VR.
667 * @note vA: TypeSize
668 * @note vB: destination and source VR (not vector register)
669 * @note vC: source (vector register)
670 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700671 void GenAddReduceVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400672
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700673 /*
674 * @brief Extract a packed element into a single VR.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700675 * @param mir The MIR whose opcode is kMirConstVector.
676 * @note vA: TypeSize
677 * @note vB: destination VR (not vector register)
678 * @note vC: source (vector register)
679 * @note arg[0]: The index to use for extraction from vector register (which packed element).
680 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700681 void GenReduceVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400682
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700683 /*
684 * @brief Create a vector value, with all TypeSize values equal to vC
685 * @param bb The basic block in which the MIR is from.
686 * @param mir The MIR whose opcode is kMirConstVector.
687 * @note vA: TypeSize.
688 * @note vB: destination vector register.
689 * @note vC: source VR (not vector register).
690 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700691 void GenSetVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400692
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700693 /**
694 * @brief Used to generate code for kMirOpPackedArrayGet.
695 * @param bb The basic block of MIR.
696 * @param mir The mir whose opcode is kMirOpPackedArrayGet.
697 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700698 void GenPackedArrayGet(BasicBlock* bb, MIR* mir);
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700699
700 /**
701 * @brief Used to generate code for kMirOpPackedArrayPut.
702 * @param bb The basic block of MIR.
703 * @param mir The mir whose opcode is kMirOpPackedArrayPut.
704 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700705 void GenPackedArrayPut(BasicBlock* bb, MIR* mir);
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700706
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700707 /*
708 * @brief Generate code for a vector opcode.
709 * @param bb The basic block in which the MIR is from.
710 * @param mir The MIR whose opcode is a non-standard opcode.
711 */
712 void GenMachineSpecificExtendedMethodMIR(BasicBlock* bb, MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400713
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700714 /*
715 * @brief Return the correct x86 opcode for the Dex operation
716 * @param op Dex opcode for the operation
717 * @param loc Register location of the operand
718 * @param is_high_op 'true' if this is an operation on the high word
719 * @param value Immediate value for the operation. Used for byte variants
720 * @returns the correct x86 opcode to perform the operation
721 */
722 X86OpCode GetOpcode(Instruction::Code op, RegLocation loc, bool is_high_op, int32_t value);
Mark Mendelld65c51a2014-04-29 16:55:20 -0400723
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700724 /*
725 * @brief Return the correct x86 opcode for the Dex operation
726 * @param op Dex opcode for the operation
727 * @param dest location of the destination. May be register or memory.
728 * @param rhs Location for the rhs of the operation. May be in register or memory.
729 * @param is_high_op 'true' if this is an operation on the high word
730 * @returns the correct x86 opcode to perform the operation
731 * @note at most one location may refer to memory
732 */
733 X86OpCode GetOpcode(Instruction::Code op, RegLocation dest, RegLocation rhs,
734 bool is_high_op);
Mark Mendelle02d48f2014-01-15 11:19:23 -0800735
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700736 /*
737 * @brief Is this operation a no-op for this opcode and value
738 * @param op Dex opcode for the operation
739 * @param value Immediate value for the operation.
740 * @returns 'true' if the operation will have no effect
741 */
742 bool IsNoOp(Instruction::Code op, int32_t value);
Mark Mendelle02d48f2014-01-15 11:19:23 -0800743
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700744 /**
745 * @brief Calculate magic number and shift for a given divisor
746 * @param divisor divisor number for calculation
747 * @param magic hold calculated magic number
748 * @param shift hold calculated shift
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700749 * @param is_long 'true' if divisor is jlong, 'false' for jint.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700750 */
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700751 void CalculateMagicAndShift(int64_t divisor, int64_t& magic, int& shift, bool is_long);
Mark Mendelle02d48f2014-01-15 11:19:23 -0800752
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700753 /*
754 * @brief Generate an integer div or rem operation.
755 * @param rl_dest Destination Location.
756 * @param rl_src1 Numerator Location.
757 * @param rl_src2 Divisor Location.
758 * @param is_div 'true' if this is a division, 'false' for a remainder.
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700759 * @param flags The instruction optimization flags. It can include information
760 * if exception check can be elided.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700761 */
762 RegLocation GenDivRem(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2,
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700763 bool is_div, int flags);
Mark Mendell2bf31e62014-01-23 12:13:40 -0800764
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700765 /*
766 * @brief Generate an integer div or rem operation by a literal.
767 * @param rl_dest Destination Location.
768 * @param rl_src Numerator Location.
769 * @param lit Divisor.
770 * @param is_div 'true' if this is a division, 'false' for a remainder.
771 */
772 RegLocation GenDivRemLit(RegLocation rl_dest, RegLocation rl_src, int lit, bool is_div);
Mark Mendell2bf31e62014-01-23 12:13:40 -0800773
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700774 /*
775 * Generate code to implement long shift operations.
776 * @param opcode The DEX opcode to specify the shift type.
777 * @param rl_dest The destination.
778 * @param rl_src The value to be shifted.
779 * @param shift_amount How much to shift.
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700780 * @param flags The instruction optimization flags.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700781 * @returns the RegLocation of the result.
782 */
783 RegLocation GenShiftImmOpLong(Instruction::Code opcode, RegLocation rl_dest,
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700784 RegLocation rl_src, int shift_amount, int flags);
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700785 /*
786 * Generate an imul of a register by a constant or a better sequence.
787 * @param dest Destination Register.
788 * @param src Source Register.
789 * @param val Constant multiplier.
790 */
791 void GenImulRegImm(RegStorage dest, RegStorage src, int val);
Mark Mendell4708dcd2014-01-22 09:05:18 -0800792
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700793 /*
794 * Generate an imul of a memory location by a constant or a better sequence.
795 * @param dest Destination Register.
796 * @param sreg Symbolic register.
797 * @param displacement Displacement on stack of Symbolic Register.
798 * @param val Constant multiplier.
799 */
800 void GenImulMemImm(RegStorage dest, int sreg, int displacement, int val);
Mark Mendellfeb2b4e2014-01-28 12:59:49 -0800801
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700802 /*
803 * @brief Compare memory to immediate, and branch if condition true.
804 * @param cond The condition code that when true will branch to the target.
805 * @param temp_reg A temporary register that can be used if compare memory is not
806 * supported by the architecture.
807 * @param base_reg The register holding the base address.
808 * @param offset The offset from the base.
809 * @param check_value The immediate to compare to.
Dave Allison69dfe512014-07-11 17:11:58 +0000810 * @param target branch target (or nullptr)
811 * @param compare output for getting LIR for comparison (or nullptr)
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700812 */
813 LIR* OpCmpMemImmBranch(ConditionCode cond, RegStorage temp_reg, RegStorage base_reg,
Dave Allison69dfe512014-07-11 17:11:58 +0000814 int offset, int check_value, LIR* target, LIR** compare);
Mark Mendell766e9292014-01-27 07:55:47 -0800815
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700816 void GenRemFP(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2, bool is_double);
817
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700818 /*
819 * Can this operation be using core registers without temporaries?
820 * @param rl_lhs Left hand operand.
821 * @param rl_rhs Right hand operand.
822 * @returns 'true' if the operation can proceed without needing temporary regs.
823 */
824 bool IsOperationSafeWithoutTemps(RegLocation rl_lhs, RegLocation rl_rhs);
Razvan A Lupusoru614c2b42014-01-28 17:05:21 -0800825
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700826 /**
827 * @brief Generates inline code for conversion of long to FP by using x87/
828 * @param rl_dest The destination of the FP.
829 * @param rl_src The source of the long.
830 * @param is_double 'true' if dealing with double, 'false' for float.
831 */
832 virtual void GenLongToFP(RegLocation rl_dest, RegLocation rl_src, bool is_double);
Mark Mendell67c39c42014-01-31 17:28:00 -0800833
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700834 void GenArrayBoundsCheck(RegStorage index, RegStorage array_base, int32_t len_offset);
835 void GenArrayBoundsCheck(int32_t index, RegStorage array_base, int32_t len_offset);
836
837 LIR* OpRegMem(OpKind op, RegStorage r_dest, RegStorage r_base, int offset);
838 LIR* OpRegMem(OpKind op, RegStorage r_dest, RegLocation value);
839 LIR* OpMemReg(OpKind op, RegLocation rl_dest, int value);
840 LIR* OpThreadMem(OpKind op, ThreadOffset<4> thread_offset);
841 LIR* OpThreadMem(OpKind op, ThreadOffset<8> thread_offset);
842 void OpRegThreadMem(OpKind op, RegStorage r_dest, ThreadOffset<4> thread_offset);
843 void OpRegThreadMem(OpKind op, RegStorage r_dest, ThreadOffset<8> thread_offset);
844 void OpTlsCmp(ThreadOffset<4> offset, int val);
845 void OpTlsCmp(ThreadOffset<8> offset, int val);
846
847 void OpLea(RegStorage r_base, RegStorage reg1, RegStorage reg2, int scale, int offset);
848
Andreas Gampec76c6142014-08-04 16:30:03 -0700849 // Try to do a long multiplication where rl_src2 is a constant. This simplified setup might fail,
850 // in which case false will be returned.
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700851 bool GenMulLongConst(RegLocation rl_dest, RegLocation rl_src1, int64_t val, int flags);
Andreas Gampec76c6142014-08-04 16:30:03 -0700852 void GenMulLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700853 RegLocation rl_src2, int flags);
Andreas Gampec76c6142014-08-04 16:30:03 -0700854 void GenNotLong(RegLocation rl_dest, RegLocation rl_src);
855 void GenNegLong(RegLocation rl_dest, RegLocation rl_src);
856 void GenDivRemLong(Instruction::Code, RegLocation rl_dest, RegLocation rl_src1,
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700857 RegLocation rl_src2, bool is_div, int flags);
Andreas Gampec76c6142014-08-04 16:30:03 -0700858
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700859 void SpillCoreRegs();
860 void UnSpillCoreRegs();
861 void UnSpillFPRegs();
862 void SpillFPRegs();
863
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700864 /*
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700865 * Mir2Lir's UpdateLoc() looks to see if the Dalvik value is currently live in any temp register
866 * without regard to data type. In practice, this can result in UpdateLoc returning a
867 * location record for a Dalvik float value in a core register, and vis-versa. For targets
868 * which can inexpensively move data between core and float registers, this can often be a win.
869 * However, for x86 this is generally not a win. These variants of UpdateLoc()
870 * take a register class argument - and will return an in-register location record only if
871 * the value is live in a temp register of the correct class. Additionally, if the value is in
872 * a temp register of the wrong register class, it will be clobbered.
873 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700874 RegLocation UpdateLocTyped(RegLocation loc);
875 RegLocation UpdateLocWideTyped(RegLocation loc);
Mark Mendell67c39c42014-01-31 17:28:00 -0800876
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700877 /*
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700878 * @brief Analyze one MIR float/double instruction
879 * @param opcode MIR instruction opcode.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700880 * @param mir Instruction to analyze.
Vladimir Marko1961b602015-04-08 20:51:48 +0100881 * @return true iff the instruction needs to load a literal using PC-relative addressing.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700882 */
Vladimir Marko1961b602015-04-08 20:51:48 +0100883 bool AnalyzeFPInstruction(int opcode, MIR* mir);
Mark Mendell67c39c42014-01-31 17:28:00 -0800884
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700885 /*
886 * @brief Analyze one use of a double operand.
887 * @param rl_use Double RegLocation for the operand.
Vladimir Marko1961b602015-04-08 20:51:48 +0100888 * @return true iff the instruction needs to load a literal using PC-relative addressing.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700889 */
Vladimir Marko1961b602015-04-08 20:51:48 +0100890 bool AnalyzeDoubleUse(RegLocation rl_use);
Mark Mendell67c39c42014-01-31 17:28:00 -0800891
Yixin Shou7071c8d2014-03-05 06:07:48 -0500892 /*
893 * @brief Analyze one invoke-static MIR instruction
Yixin Shou7071c8d2014-03-05 06:07:48 -0500894 * @param mir Instruction to analyze.
Vladimir Marko1961b602015-04-08 20:51:48 +0100895 * @return true iff the instruction needs to load a literal using PC-relative addressing.
Yixin Shou7071c8d2014-03-05 06:07:48 -0500896 */
Vladimir Marko1961b602015-04-08 20:51:48 +0100897 bool AnalyzeInvokeStaticIntrinsic(MIR* mir);
Yixin Shou7071c8d2014-03-05 06:07:48 -0500898
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700899 // Information derived from analysis of MIR
Dmitry Petrochenko9ee801f2014-05-12 11:31:37 +0700900
Vladimir Marko1961b602015-04-08 20:51:48 +0100901 // The base register for PC-relative addressing if promoted (32-bit only).
902 RegStorage pc_rel_base_reg_;
Mark Mendell67c39c42014-01-31 17:28:00 -0800903
Vladimir Marko1961b602015-04-08 20:51:48 +0100904 // Have we actually used the pc_rel_base_reg_?
905 bool pc_rel_base_reg_used_;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800906
Vladimir Marko1961b602015-04-08 20:51:48 +0100907 // Pointer to the "call +0" insn that sets up the promoted register for PC-relative addressing.
908 // The anchor "pop" insn is NEXT_LIR(setup_pc_rel_base_reg_). The whole "call +0; pop <reg>"
909 // sequence will be removed in AssembleLIR() if we do not actually use PC-relative addressing.
910 LIR* setup_pc_rel_base_reg_; // There are 2 chained insns (no reordering allowed).
Mark Mendell55d0eac2014-02-06 11:02:52 -0800911
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700912 // Instructions needing patching with Method* values.
Vladimir Markoe39c54e2014-09-22 14:50:02 +0100913 ArenaVector<LIR*> method_address_insns_;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800914
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700915 // Instructions needing patching with Class Type* values.
Vladimir Markoe39c54e2014-09-22 14:50:02 +0100916 ArenaVector<LIR*> class_type_address_insns_;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800917
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700918 // Instructions needing patching with PC relative code addresses.
Vladimir Markoe39c54e2014-09-22 14:50:02 +0100919 ArenaVector<LIR*> call_method_insns_;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800920
Vladimir Markodc56cc52015-03-27 18:18:36 +0000921 // Instructions needing patching with PC relative code addresses.
922 ArenaVector<LIR*> dex_cache_access_insns_;
923
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700924 // The list of const vector literals.
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700925 LIR* const_vectors_;
Mark Mendelld65c51a2014-04-29 16:55:20 -0400926
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700927 /*
928 * @brief Search for a matching vector literal
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700929 * @param constants An array of size 4 which contains all of 32-bit constants.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700930 * @returns pointer to matching LIR constant, or nullptr if not found.
931 */
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700932 LIR* ScanVectorLiteral(int32_t* constants);
Mark Mendelld65c51a2014-04-29 16:55:20 -0400933
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700934 /*
935 * @brief Add a constant vector literal
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700936 * @param constants An array of size 4 which contains all of 32-bit constants.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700937 */
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700938 LIR* AddVectorLiteral(int32_t* constants);
Mark Mendelld65c51a2014-04-29 16:55:20 -0400939
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700940 bool WideGPRsAreAliases() const OVERRIDE {
Serguei Katkov59a42af2014-07-05 00:55:46 +0700941 return cu_->target64; // On 64b, we have 64b GPRs.
942 }
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700943
944 bool WideFPRsAreAliases() const OVERRIDE {
Serguei Katkov59a42af2014-07-05 00:55:46 +0700945 return true; // xmm registers have 64b views even on x86.
946 }
947
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700948 /*
949 * @brief Dump a RegLocation using printf
950 * @param loc Register location to dump
951 */
952 static void DumpRegLocation(RegLocation loc);
953
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700954 private:
Yixin Shou8c914c02014-07-28 14:17:09 -0400955 void SwapBits(RegStorage result_reg, int shift, int32_t value);
956 void SwapBits64(RegStorage result_reg, int shift, int64_t value);
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700957
Vladimir Markodc56cc52015-03-27 18:18:36 +0000958 static int X86NextSDCallInsn(CompilationUnit* cu, CallInfo* info,
959 int state, const MethodReference& target_method,
960 uint32_t,
961 uintptr_t direct_code, uintptr_t direct_method,
962 InvokeType type);
963
Vladimir Marko1961b602015-04-08 20:51:48 +0100964 LIR* OpLoadPc(RegStorage r_dest);
965 RegStorage GetPcAndAnchor(LIR** anchor, RegStorage r_tmp = RegStorage::InvalidReg());
966
967 // When we don't know the proper offset for the value, pick one that will force
968 // 4 byte offset. We will fix this up in the assembler or linker later to have
969 // the right value.
970 static constexpr int kDummy32BitOffset = 256;
971
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700972 static const X86EncodingMap EncodingMap[kX86Last];
973
974 friend std::ostream& operator<<(std::ostream& os, const X86OpCode& rhs);
Chao-ying Fuc4013ea2015-04-22 10:51:21 -0700975 friend class QuickAssembleX86Test;
976 friend class QuickAssembleX86MacroTest;
977 friend class QuickAssembleX86LowLevelTest;
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700978
979 DISALLOW_COPY_AND_ASSIGN(X86Mir2Lir);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700980};
981
982} // namespace art
983
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700984#endif // ART_COMPILER_DEX_QUICK_X86_CODEGEN_X86_H_