blob: 26641f8d59e8378dd88f4786a0fb50cc0c310d6d [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
20#include "dex/compiler_internals.h"
Andreas Gampe53c913b2014-08-12 23:19:23 -070021#include "dex/quick/mir_to_lir.h"
Brian Carlstrom7940e442013-07-12 13:46:57 -070022#include "x86_lir.h"
23
Dmitry Petrochenko58994cd2014-05-17 01:02:18 +070024#include <map>
Maxim Kazantsev6dccdc22014-08-18 18:43:55 +070025#include <vector>
Dmitry Petrochenko58994cd2014-05-17 01:02:18 +070026
Brian Carlstrom7940e442013-07-12 13:46:57 -070027namespace art {
28
Mark Mendelle87f9b52014-04-30 14:13:18 -040029class X86Mir2Lir : public Mir2Lir {
Ian Rogers0f9b9c52014-06-09 01:32:12 -070030 protected:
31 class InToRegStorageMapper {
32 public:
Serguei Katkov407a9d22014-07-05 03:09:32 +070033 virtual RegStorage GetNextReg(bool is_double_or_float, bool is_wide, bool is_ref) = 0;
Ian Rogers0f9b9c52014-06-09 01:32:12 -070034 virtual ~InToRegStorageMapper() {}
35 };
Dmitry Petrochenko58994cd2014-05-17 01:02:18 +070036
Ian Rogers0f9b9c52014-06-09 01:32:12 -070037 class InToRegStorageX86_64Mapper : public InToRegStorageMapper {
38 public:
Chao-ying Fua77ee512014-07-01 17:43:41 -070039 explicit InToRegStorageX86_64Mapper(Mir2Lir* ml) : ml_(ml), cur_core_reg_(0), cur_fp_reg_(0) {}
Ian Rogers0f9b9c52014-06-09 01:32:12 -070040 virtual ~InToRegStorageX86_64Mapper() {}
Serguei Katkov407a9d22014-07-05 03:09:32 +070041 virtual RegStorage GetNextReg(bool is_double_or_float, bool is_wide, bool is_ref);
Chao-ying Fua77ee512014-07-01 17:43:41 -070042 protected:
43 Mir2Lir* ml_;
Ian Rogers0f9b9c52014-06-09 01:32:12 -070044 private:
45 int cur_core_reg_;
46 int cur_fp_reg_;
47 };
Dmitry Petrochenko58994cd2014-05-17 01:02:18 +070048
Ian Rogers0f9b9c52014-06-09 01:32:12 -070049 class InToRegStorageMapping {
50 public:
51 InToRegStorageMapping() : max_mapped_in_(0), is_there_stack_mapped_(false),
52 initialized_(false) {}
53 void Initialize(RegLocation* arg_locs, int count, InToRegStorageMapper* mapper);
54 int GetMaxMappedIn() { return max_mapped_in_; }
55 bool IsThereStackMapped() { return is_there_stack_mapped_; }
56 RegStorage Get(int in_position);
57 bool IsInitialized() { return initialized_; }
58 private:
59 std::map<int, RegStorage> mapping_;
60 int max_mapped_in_;
61 bool is_there_stack_mapped_;
62 bool initialized_;
63 };
Dmitry Petrochenko58994cd2014-05-17 01:02:18 +070064
Maxim Kazantsev6dccdc22014-08-18 18:43:55 +070065 class ExplicitTempRegisterLock {
66 public:
67 ExplicitTempRegisterLock(X86Mir2Lir* mir_to_lir, int n_regs, ...);
68 ~ExplicitTempRegisterLock();
69 protected:
70 std::vector<RegStorage> temp_regs_;
71 X86Mir2Lir* const mir_to_lir_;
72 };
73
Ian Rogers0f9b9c52014-06-09 01:32:12 -070074 public:
Elena Sayapinadd644502014-07-01 18:39:52 +070075 X86Mir2Lir(CompilationUnit* cu, MIRGraph* mir_graph, ArenaAllocator* arena);
Brian Carlstrom7940e442013-07-12 13:46:57 -070076
Ian Rogers0f9b9c52014-06-09 01:32:12 -070077 // Required for target - codegen helpers.
78 bool SmallLiteralDivRem(Instruction::Code dalvik_opcode, bool is_div, RegLocation rl_src,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +070079 RegLocation rl_dest, int lit) OVERRIDE;
Ian Rogers0f9b9c52014-06-09 01:32:12 -070080 bool EasyMultiply(RegLocation rl_src, RegLocation rl_dest, int lit) OVERRIDE;
Ningsheng Jian675e09b2014-10-23 13:48:36 +080081 void GenMultiplyByConstantFloat(RegLocation rl_dest, RegLocation rl_src1,
82 int32_t constant) OVERRIDE;
83 void GenMultiplyByConstantDouble(RegLocation rl_dest, RegLocation rl_src1,
84 int64_t constant) OVERRIDE;
Ian Rogers0f9b9c52014-06-09 01:32:12 -070085 LIR* CheckSuspendUsingLoad() OVERRIDE;
Andreas Gampe98430592014-07-27 19:44:50 -070086 RegStorage LoadHelper(QuickEntrypointEnum trampoline) OVERRIDE;
Ian Rogers0f9b9c52014-06-09 01:32:12 -070087 LIR* LoadBaseDisp(RegStorage r_base, int displacement, RegStorage r_dest,
Andreas Gampe3c12c512014-06-24 18:46:29 +000088 OpSize size, VolatileKind is_volatile) OVERRIDE;
Ian Rogers0f9b9c52014-06-09 01:32:12 -070089 LIR* LoadBaseIndexed(RegStorage r_base, RegStorage r_index, RegStorage r_dest, int scale,
Vladimir Marko3bf7c602014-05-07 14:55:43 +010090 OpSize size) OVERRIDE;
Ian Rogers0f9b9c52014-06-09 01:32:12 -070091 LIR* LoadConstantNoClobber(RegStorage r_dest, int value);
92 LIR* LoadConstantWide(RegStorage r_dest, int64_t value);
Ian Rogers0f9b9c52014-06-09 01:32:12 -070093 LIR* StoreBaseDisp(RegStorage r_base, int displacement, RegStorage r_src,
Andreas Gampe3c12c512014-06-24 18:46:29 +000094 OpSize size, VolatileKind is_volatile) OVERRIDE;
Ian Rogers0f9b9c52014-06-09 01:32:12 -070095 LIR* StoreBaseIndexed(RegStorage r_base, RegStorage r_index, RegStorage r_src, int scale,
96 OpSize size) OVERRIDE;
Vladimir Markobf535be2014-11-19 18:52:35 +000097
98 /// @copydoc Mir2Lir::UnconditionallyMarkGCCard(RegStorage)
99 void UnconditionallyMarkGCCard(RegStorage tgt_addr_reg) OVERRIDE;
100
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700101 void GenImplicitNullCheck(RegStorage reg, int opt_flags) OVERRIDE;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700102
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700103 // Required for target - register utilities.
Chao-ying Fua77ee512014-07-01 17:43:41 -0700104 RegStorage TargetReg(SpecialTargetRegister reg) OVERRIDE;
Andreas Gampeccc60262014-07-04 18:02:38 -0700105 RegStorage TargetReg(SpecialTargetRegister symbolic_reg, WideKind wide_kind) OVERRIDE {
106 if (wide_kind == kWide) {
107 if (cu_->target64) {
108 return As64BitReg(TargetReg32(symbolic_reg));
109 } else {
110 // x86: construct a pair.
111 DCHECK((kArg0 <= symbolic_reg && symbolic_reg < kArg3) ||
112 (kFArg0 <= symbolic_reg && symbolic_reg < kFArg3) ||
113 (kRet0 == symbolic_reg));
114 return RegStorage::MakeRegPair(TargetReg32(symbolic_reg),
115 TargetReg32(static_cast<SpecialTargetRegister>(symbolic_reg + 1)));
116 }
117 } else if (wide_kind == kRef && cu_->target64) {
118 return As64BitReg(TargetReg32(symbolic_reg));
Chao-ying Fua77ee512014-07-01 17:43:41 -0700119 } else {
Andreas Gampeccc60262014-07-04 18:02:38 -0700120 return TargetReg32(symbolic_reg);
Chao-ying Fua77ee512014-07-01 17:43:41 -0700121 }
122 }
Chao-ying Fua77ee512014-07-01 17:43:41 -0700123 RegStorage TargetPtrReg(SpecialTargetRegister symbolic_reg) OVERRIDE {
Andreas Gampeccc60262014-07-04 18:02:38 -0700124 return TargetReg(symbolic_reg, cu_->target64 ? kWide : kNotWide);
Chao-ying Fua77ee512014-07-01 17:43:41 -0700125 }
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700126
127 RegStorage GetArgMappingToPhysicalReg(int arg_num) OVERRIDE;
128
129 RegLocation GetReturnAlt() OVERRIDE;
130 RegLocation GetReturnWideAlt() OVERRIDE;
131 RegLocation LocCReturn() OVERRIDE;
132 RegLocation LocCReturnRef() OVERRIDE;
133 RegLocation LocCReturnDouble() OVERRIDE;
134 RegLocation LocCReturnFloat() OVERRIDE;
135 RegLocation LocCReturnWide() OVERRIDE;
136
Vladimir Marko8dea81c2014-06-06 14:50:36 +0100137 ResourceMask GetRegMaskCommon(const RegStorage& reg) const OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700138 void AdjustSpillMask() OVERRIDE;
139 void ClobberCallerSave() OVERRIDE;
140 void FreeCallTemps() OVERRIDE;
141 void LockCallTemps() OVERRIDE;
142
143 void CompilerInitializeRegAlloc() OVERRIDE;
144 int VectorRegisterSize() OVERRIDE;
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700145 int NumReservableVectorRegisters(bool long_or_fp) OVERRIDE;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700146
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700147 // Required for target - miscellaneous.
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700148 void AssembleLIR() OVERRIDE;
Vladimir Marko8dea81c2014-06-06 14:50:36 +0100149 void DumpResourceMask(LIR* lir, const ResourceMask& mask, const char* prefix) OVERRIDE;
150 void SetupTargetResourceMasks(LIR* lir, uint64_t flags,
151 ResourceMask* use_mask, ResourceMask* def_mask) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700152 const char* GetTargetInstFmt(int opcode) OVERRIDE;
153 const char* GetTargetInstName(int opcode) OVERRIDE;
154 std::string BuildInsnString(const char* fmt, LIR* lir, unsigned char* base_addr) OVERRIDE;
Vladimir Marko8dea81c2014-06-06 14:50:36 +0100155 ResourceMask GetPCUseDefEncoding() const OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700156 uint64_t GetTargetInstFlags(int opcode) OVERRIDE;
Ian Rogers5aa6e042014-06-13 16:38:24 -0700157 size_t GetInsnSize(LIR* lir) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700158 bool IsUnconditionalBranch(LIR* lir) OVERRIDE;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700159
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700160 // Get the register class for load/store of a field.
161 RegisterClass RegClassForFieldLoadStore(OpSize size, bool is_volatile) OVERRIDE;
Vladimir Marko674744e2014-04-24 15:18:26 +0100162
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700163 // Required for target - Dalvik-level generators.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700164 void GenArrayGet(int opt_flags, OpSize size, RegLocation rl_array, RegLocation rl_index,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700165 RegLocation rl_dest, int scale) OVERRIDE;
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700166 void GenArrayPut(int opt_flags, OpSize size, RegLocation rl_array,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700167 RegLocation rl_index, RegLocation rl_src, int scale, bool card_mark) OVERRIDE;
168
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700169 void GenArithOpDouble(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700170 RegLocation rl_src2) OVERRIDE;
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700171 void GenArithOpFloat(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700172 RegLocation rl_src2) OVERRIDE;
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700173 void GenCmpFP(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700174 RegLocation rl_src2) OVERRIDE;
175 void GenConversion(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src) OVERRIDE;
176
177 bool GenInlinedCas(CallInfo* info, bool is_long, bool is_object) OVERRIDE;
178 bool GenInlinedMinMax(CallInfo* info, bool is_min, bool is_long) OVERRIDE;
179 bool GenInlinedMinMaxFP(CallInfo* info, bool is_min, bool is_double) OVERRIDE;
Yixin Shou8c914c02014-07-28 14:17:09 -0400180 bool GenInlinedReverseBits(CallInfo* info, OpSize size) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700181 bool GenInlinedSqrt(CallInfo* info) OVERRIDE;
Yixin Shou7071c8d2014-03-05 06:07:48 -0500182 bool GenInlinedAbsFloat(CallInfo* info) OVERRIDE;
183 bool GenInlinedAbsDouble(CallInfo* info) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700184 bool GenInlinedPeek(CallInfo* info, OpSize size) OVERRIDE;
185 bool GenInlinedPoke(CallInfo* info, OpSize size) OVERRIDE;
Andreas Gampe98430592014-07-27 19:44:50 -0700186 bool GenInlinedCharAt(CallInfo* info) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700187
188 // Long instructions.
Andreas Gampec76c6142014-08-04 16:30:03 -0700189 void GenArithOpLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700190 RegLocation rl_src2, int flags) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700191 void GenArithImmOpLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700192 RegLocation rl_src2, int flags) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700193 void GenShiftImmOpLong(Instruction::Code opcode, RegLocation rl_dest,
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700194 RegLocation rl_src1, RegLocation rl_shift, int flags) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700195 void GenCmpLong(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2) OVERRIDE;
196 void GenIntToLong(RegLocation rl_dest, RegLocation rl_src) OVERRIDE;
197 void GenShiftOpLong(Instruction::Code opcode, RegLocation rl_dest,
198 RegLocation rl_src1, RegLocation rl_shift) OVERRIDE;
Razvan A Lupusoru3bc01742014-02-06 13:18:43 -0800199
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700200 /*
201 * @brief Generate a two address long operation with a constant value
202 * @param rl_dest location of result
203 * @param rl_src constant source operand
204 * @param op Opcode to be generated
205 * @return success or not
206 */
207 bool GenLongImm(RegLocation rl_dest, RegLocation rl_src, Instruction::Code op);
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700208
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700209 /*
210 * @brief Generate a three address long operation with a constant value
211 * @param rl_dest location of result
212 * @param rl_src1 source operand
213 * @param rl_src2 constant source operand
214 * @param op Opcode to be generated
215 * @return success or not
216 */
217 bool GenLongLongImm(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2,
218 Instruction::Code op);
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700219 /**
220 * @brief Generate a long arithmetic operation.
221 * @param rl_dest The destination.
222 * @param rl_src1 First operand.
223 * @param rl_src2 Second operand.
224 * @param op The DEX opcode for the operation.
225 * @param is_commutative The sources can be swapped if needed.
226 */
227 virtual void GenLongArith(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2,
228 Instruction::Code op, bool is_commutative);
Mark Mendelle02d48f2014-01-15 11:19:23 -0800229
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700230 /**
231 * @brief Generate a two operand long arithmetic operation.
232 * @param rl_dest The destination.
233 * @param rl_src Second operand.
234 * @param op The DEX opcode for the operation.
235 */
236 void GenLongArith(RegLocation rl_dest, RegLocation rl_src, Instruction::Code op);
Mark Mendelle02d48f2014-01-15 11:19:23 -0800237
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700238 /**
239 * @brief Generate a long operation.
240 * @param rl_dest The destination. Must be in a register
241 * @param rl_src The other operand. May be in a register or in memory.
242 * @param op The DEX opcode for the operation.
243 */
244 virtual void GenLongRegOrMemOp(RegLocation rl_dest, RegLocation rl_src, Instruction::Code op);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700245
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700246
247 // TODO: collapse reg_lo, reg_hi
248 RegLocation GenDivRem(RegLocation rl_dest, RegStorage reg_lo, RegStorage reg_hi, bool is_div)
249 OVERRIDE;
250 RegLocation GenDivRemLit(RegLocation rl_dest, RegStorage reg_lo, int lit, bool is_div) OVERRIDE;
251 void GenDivZeroCheckWide(RegStorage reg) OVERRIDE;
252 void GenEntrySequence(RegLocation* ArgLocs, RegLocation rl_method) OVERRIDE;
253 void GenExitSequence() OVERRIDE;
254 void GenSpecialExitSequence() OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700255 void GenFusedFPCmpBranch(BasicBlock* bb, MIR* mir, bool gt_bias, bool is_double) OVERRIDE;
256 void GenFusedLongCmpBranch(BasicBlock* bb, MIR* mir) OVERRIDE;
257 void GenSelect(BasicBlock* bb, MIR* mir) OVERRIDE;
258 void GenSelectConst32(RegStorage left_op, RegStorage right_op, ConditionCode code,
259 int32_t true_val, int32_t false_val, RegStorage rs_dest,
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700260 RegisterClass dest_reg_class) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700261 bool GenMemBarrier(MemBarrierKind barrier_kind) OVERRIDE;
262 void GenMoveException(RegLocation rl_dest) OVERRIDE;
263 void GenMultiplyByTwoBitMultiplier(RegLocation rl_src, RegLocation rl_result, int lit,
264 int first_bit, int second_bit) OVERRIDE;
265 void GenNegDouble(RegLocation rl_dest, RegLocation rl_src) OVERRIDE;
266 void GenNegFloat(RegLocation rl_dest, RegLocation rl_src) OVERRIDE;
Andreas Gampe48971b32014-08-06 10:09:01 -0700267 void GenLargePackedSwitch(MIR* mir, DexOffset table_offset, RegLocation rl_src) OVERRIDE;
268 void GenLargeSparseSwitch(MIR* mir, DexOffset table_offset, RegLocation rl_src) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700269
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700270 /**
271 * @brief Implement instanceof a final class with x86 specific code.
272 * @param use_declaring_class 'true' if we can use the class itself.
273 * @param type_idx Type index to use if use_declaring_class is 'false'.
274 * @param rl_dest Result to be set to 0 or 1.
275 * @param rl_src Object to be tested.
276 */
277 void GenInstanceofFinal(bool use_declaring_class, uint32_t type_idx, RegLocation rl_dest,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700278 RegLocation rl_src) OVERRIDE;
Chao-ying Fua0147762014-06-06 18:38:49 -0700279
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700280 // Single operation generators.
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700281 LIR* OpUnconditionalBranch(LIR* target) OVERRIDE;
282 LIR* OpCmpBranch(ConditionCode cond, RegStorage src1, RegStorage src2, LIR* target) OVERRIDE;
283 LIR* OpCmpImmBranch(ConditionCode cond, RegStorage reg, int check_value, LIR* target) OVERRIDE;
284 LIR* OpCondBranch(ConditionCode cc, LIR* target) OVERRIDE;
285 LIR* OpDecAndBranch(ConditionCode c_code, RegStorage reg, LIR* target) OVERRIDE;
286 LIR* OpFpRegCopy(RegStorage r_dest, RegStorage r_src) OVERRIDE;
287 LIR* OpIT(ConditionCode cond, const char* guide) OVERRIDE;
288 void OpEndIT(LIR* it) OVERRIDE;
289 LIR* OpMem(OpKind op, RegStorage r_base, int disp) OVERRIDE;
290 LIR* OpPcRelLoad(RegStorage reg, LIR* target) OVERRIDE;
291 LIR* OpReg(OpKind op, RegStorage r_dest_src) OVERRIDE;
292 void OpRegCopy(RegStorage r_dest, RegStorage r_src) OVERRIDE;
293 LIR* OpRegCopyNoInsert(RegStorage r_dest, RegStorage r_src) OVERRIDE;
294 LIR* OpRegImm(OpKind op, RegStorage r_dest_src1, int value) OVERRIDE;
295 LIR* OpRegReg(OpKind op, RegStorage r_dest_src1, RegStorage r_src2) OVERRIDE;
296 LIR* OpMovRegMem(RegStorage r_dest, RegStorage r_base, int offset, MoveType move_type) OVERRIDE;
297 LIR* OpMovMemReg(RegStorage r_base, int offset, RegStorage r_src, MoveType move_type) OVERRIDE;
298 LIR* OpCondRegReg(OpKind op, ConditionCode cc, RegStorage r_dest, RegStorage r_src) OVERRIDE;
299 LIR* OpRegRegImm(OpKind op, RegStorage r_dest, RegStorage r_src1, int value) OVERRIDE;
300 LIR* OpRegRegReg(OpKind op, RegStorage r_dest, RegStorage r_src1, RegStorage r_src2) OVERRIDE;
301 LIR* OpTestSuspend(LIR* target) OVERRIDE;
302 LIR* OpVldm(RegStorage r_base, int count) OVERRIDE;
303 LIR* OpVstm(RegStorage r_base, int count) OVERRIDE;
304 void OpRegCopyWide(RegStorage dest, RegStorage src) OVERRIDE;
305 bool GenInlinedCurrentThread(CallInfo* info) OVERRIDE;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700306
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700307 bool InexpensiveConstantInt(int32_t value) OVERRIDE;
308 bool InexpensiveConstantFloat(int32_t value) OVERRIDE;
309 bool InexpensiveConstantLong(int64_t value) OVERRIDE;
310 bool InexpensiveConstantDouble(int64_t value) OVERRIDE;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700311
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700312 /*
313 * @brief Should try to optimize for two address instructions?
314 * @return true if we try to avoid generating three operand instructions.
315 */
316 virtual bool GenerateTwoOperandInstructions() const { return true; }
Mark Mendelle87f9b52014-04-30 14:13:18 -0400317
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700318 /*
319 * @brief x86 specific codegen for int operations.
320 * @param opcode Operation to perform.
321 * @param rl_dest Destination for the result.
322 * @param rl_lhs Left hand operand.
323 * @param rl_rhs Right hand operand.
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700324 * @param flags The instruction optimization flags.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700325 */
326 void GenArithOpInt(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_lhs,
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700327 RegLocation rl_rhs, int flags) OVERRIDE;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800328
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700329 /*
330 * @brief Load the Method* of a dex method into the register.
331 * @param target_method The MethodReference of the method to be invoked.
332 * @param type How the method will be invoked.
333 * @param register that will contain the code address.
334 * @note register will be passed to TargetReg to get physical register.
335 */
336 void LoadMethodAddress(const MethodReference& target_method, InvokeType type,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700337 SpecialTargetRegister symbolic_reg) OVERRIDE;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800338
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700339 /*
340 * @brief Load the Class* of a Dex Class type into the register.
Fred Shihe7f82e22014-08-06 10:46:37 -0700341 * @param dex DexFile that contains the class type.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700342 * @param type How the method will be invoked.
343 * @param register that will contain the code address.
344 * @note register will be passed to TargetReg to get physical register.
345 */
Fred Shihe7f82e22014-08-06 10:46:37 -0700346 void LoadClassType(const DexFile& dex_file, uint32_t type_idx,
347 SpecialTargetRegister symbolic_reg) OVERRIDE;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800348
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700349 void FlushIns(RegLocation* ArgLocs, RegLocation rl_method) OVERRIDE;
Dmitry Petrochenko58994cd2014-05-17 01:02:18 +0700350
Vladimir Markof4da6752014-08-01 19:04:18 +0100351 NextCallInsn GetNextSDCallInsn() OVERRIDE;
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700352 int GenDalvikArgsNoRange(CallInfo* info, int call_state, LIR** pcrLabel,
Dmitry Petrochenko58994cd2014-05-17 01:02:18 +0700353 NextCallInsn next_call_insn,
354 const MethodReference& target_method,
355 uint32_t vtable_idx,
356 uintptr_t direct_code, uintptr_t direct_method, InvokeType type,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700357 bool skip_this) OVERRIDE;
Dmitry Petrochenko58994cd2014-05-17 01:02:18 +0700358
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700359 int GenDalvikArgsRange(CallInfo* info, int call_state, LIR** pcrLabel,
360 NextCallInsn next_call_insn,
361 const MethodReference& target_method,
362 uint32_t vtable_idx,
363 uintptr_t direct_code, uintptr_t direct_method, InvokeType type,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700364 bool skip_this) OVERRIDE;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800365
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700366 /*
367 * @brief Generate a relative call to the method that will be patched at link time.
368 * @param target_method The MethodReference of the method to be invoked.
369 * @param type How the method will be invoked.
370 * @returns Call instruction
371 */
Vladimir Markof4da6752014-08-01 19:04:18 +0100372 LIR* CallWithLinkerFixup(const MethodReference& target_method, InvokeType type);
373
374 /*
375 * @brief Generate the actual call insn based on the method info.
376 * @param method_info the lowering info for the method call.
377 * @returns Call instruction
378 */
379 LIR* GenCallInsn(const MirMethodLoweringInfo& method_info) OVERRIDE;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800380
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700381 /*
382 * @brief Handle x86 specific literals
383 */
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700384 void InstallLiteralPools() OVERRIDE;
Mark Mendellae9fd932014-02-10 16:14:35 -0800385
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700386 /*
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700387 * @brief Generate the debug_frame FDE information.
388 * @returns pointer to vector containing CFE information
389 */
Tong Shen547cdfd2014-08-05 01:54:19 -0700390 std::vector<uint8_t>* ReturnFrameDescriptionEntry() OVERRIDE;
Razvan A Lupusorubd288c22013-12-20 17:27:23 -0800391
Andreas Gampe98430592014-07-27 19:44:50 -0700392 LIR* InvokeTrampoline(OpKind op, RegStorage r_tgt, QuickEntrypointEnum trampoline) OVERRIDE;
393
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700394 protected:
Ian Rogersb28c1c02014-11-08 11:21:21 -0800395 RegStorage TargetReg32(SpecialTargetRegister reg) const;
Chao-ying Fua77ee512014-07-01 17:43:41 -0700396 // Casting of RegStorage
397 RegStorage As32BitReg(RegStorage reg) {
398 DCHECK(!reg.IsPair());
399 if ((kFailOnSizeError || kReportSizeError) && !reg.Is64Bit()) {
400 if (kFailOnSizeError) {
401 LOG(FATAL) << "Expected 64b register " << reg.GetReg();
402 } else {
403 LOG(WARNING) << "Expected 64b register " << reg.GetReg();
404 return reg;
405 }
406 }
407 RegStorage ret_val = RegStorage(RegStorage::k32BitSolo,
408 reg.GetRawBits() & RegStorage::kRegTypeMask);
409 DCHECK_EQ(GetRegInfo(reg)->FindMatchingView(RegisterInfo::k32SoloStorageMask)
410 ->GetReg().GetReg(),
411 ret_val.GetReg());
412 return ret_val;
413 }
414
415 RegStorage As64BitReg(RegStorage reg) {
416 DCHECK(!reg.IsPair());
417 if ((kFailOnSizeError || kReportSizeError) && !reg.Is32Bit()) {
418 if (kFailOnSizeError) {
419 LOG(FATAL) << "Expected 32b register " << reg.GetReg();
420 } else {
421 LOG(WARNING) << "Expected 32b register " << reg.GetReg();
422 return reg;
423 }
424 }
425 RegStorage ret_val = RegStorage(RegStorage::k64BitSolo,
426 reg.GetRawBits() & RegStorage::kRegTypeMask);
427 DCHECK_EQ(GetRegInfo(reg)->FindMatchingView(RegisterInfo::k64SoloStorageMask)
428 ->GetReg().GetReg(),
429 ret_val.GetReg());
430 return ret_val;
431 }
432
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700433 LIR* LoadBaseIndexedDisp(RegStorage r_base, RegStorage r_index, int scale, int displacement,
434 RegStorage r_dest, OpSize size);
435 LIR* StoreBaseIndexedDisp(RegStorage r_base, RegStorage r_index, int scale, int displacement,
Jean Christophe Beylerb5bce7c2014-07-25 12:32:18 -0700436 RegStorage r_src, OpSize size, int opt_flags = 0);
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700437
Ian Rogersb28c1c02014-11-08 11:21:21 -0800438 RegStorage GetCoreArgMappingToPhysicalReg(int core_arg_num) const;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700439
440 int AssignInsnOffsets();
441 void AssignOffsets();
442 AssemblerStatus AssembleInstructions(CodeOffset start_addr);
443
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700444 size_t ComputeSize(const X86EncodingMap* entry, int32_t raw_reg, int32_t raw_index,
Ian Rogers5aa6e042014-06-13 16:38:24 -0700445 int32_t raw_base, int32_t displacement);
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700446 void CheckValidByteRegister(const X86EncodingMap* entry, int32_t raw_reg);
447 void EmitPrefix(const X86EncodingMap* entry,
Ian Rogers5aa6e042014-06-13 16:38:24 -0700448 int32_t raw_reg_r, int32_t raw_reg_x, int32_t raw_reg_b);
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700449 void EmitOpcode(const X86EncodingMap* entry);
450 void EmitPrefixAndOpcode(const X86EncodingMap* entry,
Ian Rogers5aa6e042014-06-13 16:38:24 -0700451 int32_t reg_r, int32_t reg_x, int32_t reg_b);
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700452 void EmitDisp(uint8_t base, int32_t disp);
453 void EmitModrmThread(uint8_t reg_or_opcode);
454 void EmitModrmDisp(uint8_t reg_or_opcode, uint8_t base, int32_t disp);
455 void EmitModrmSibDisp(uint8_t reg_or_opcode, uint8_t base, uint8_t index, int scale,
456 int32_t disp);
457 void EmitImm(const X86EncodingMap* entry, int64_t imm);
458 void EmitNullary(const X86EncodingMap* entry);
459 void EmitOpRegOpcode(const X86EncodingMap* entry, int32_t raw_reg);
460 void EmitOpReg(const X86EncodingMap* entry, int32_t raw_reg);
461 void EmitOpMem(const X86EncodingMap* entry, int32_t raw_base, int32_t disp);
462 void EmitOpArray(const X86EncodingMap* entry, int32_t raw_base, int32_t raw_index, int scale,
463 int32_t disp);
464 void EmitMemReg(const X86EncodingMap* entry, int32_t raw_base, int32_t disp, int32_t raw_reg);
465 void EmitRegMem(const X86EncodingMap* entry, int32_t raw_reg, int32_t raw_base, int32_t disp);
466 void EmitRegArray(const X86EncodingMap* entry, int32_t raw_reg, int32_t raw_base,
467 int32_t raw_index, int scale, int32_t disp);
468 void EmitArrayReg(const X86EncodingMap* entry, int32_t raw_base, int32_t raw_index, int scale,
469 int32_t disp, int32_t raw_reg);
470 void EmitMemImm(const X86EncodingMap* entry, int32_t raw_base, int32_t disp, int32_t imm);
471 void EmitArrayImm(const X86EncodingMap* entry, int32_t raw_base, int32_t raw_index, int scale,
472 int32_t raw_disp, int32_t imm);
473 void EmitRegThread(const X86EncodingMap* entry, int32_t raw_reg, int32_t disp);
474 void EmitRegReg(const X86EncodingMap* entry, int32_t raw_reg1, int32_t raw_reg2);
475 void EmitRegRegImm(const X86EncodingMap* entry, int32_t raw_reg1, int32_t raw_reg2, int32_t imm);
476 void EmitRegMemImm(const X86EncodingMap* entry, int32_t raw_reg1, int32_t raw_base, int32_t disp,
477 int32_t imm);
478 void EmitMemRegImm(const X86EncodingMap* entry, int32_t base, int32_t disp, int32_t raw_reg1,
479 int32_t imm);
480 void EmitRegImm(const X86EncodingMap* entry, int32_t raw_reg, int32_t imm);
481 void EmitThreadImm(const X86EncodingMap* entry, int32_t disp, int32_t imm);
482 void EmitMovRegImm(const X86EncodingMap* entry, int32_t raw_reg, int64_t imm);
483 void EmitShiftRegImm(const X86EncodingMap* entry, int32_t raw_reg, int32_t imm);
484 void EmitShiftRegCl(const X86EncodingMap* entry, int32_t raw_reg, int32_t raw_cl);
485 void EmitShiftMemCl(const X86EncodingMap* entry, int32_t raw_base, int32_t disp, int32_t raw_cl);
Yixin Shouf40f8902014-08-14 14:10:32 -0400486 void EmitShiftRegRegCl(const X86EncodingMap* entry, int32_t raw_reg1, int32_t raw_reg2,
487 int32_t raw_cl);
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700488 void EmitShiftMemImm(const X86EncodingMap* entry, int32_t raw_base, int32_t disp, int32_t imm);
489 void EmitRegCond(const X86EncodingMap* entry, int32_t raw_reg, int32_t cc);
490 void EmitMemCond(const X86EncodingMap* entry, int32_t raw_base, int32_t disp, int32_t cc);
491 void EmitRegRegCond(const X86EncodingMap* entry, int32_t raw_reg1, int32_t raw_reg2, int32_t cc);
492 void EmitRegMemCond(const X86EncodingMap* entry, int32_t raw_reg1, int32_t raw_base, int32_t disp,
493 int32_t cc);
Razvan A Lupusorubd288c22013-12-20 17:27:23 -0800494
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700495 void EmitJmp(const X86EncodingMap* entry, int32_t rel);
496 void EmitJcc(const X86EncodingMap* entry, int32_t rel, int32_t cc);
497 void EmitCallMem(const X86EncodingMap* entry, int32_t raw_base, int32_t disp);
498 void EmitCallImmediate(const X86EncodingMap* entry, int32_t disp);
499 void EmitCallThread(const X86EncodingMap* entry, int32_t disp);
500 void EmitPcRel(const X86EncodingMap* entry, int32_t raw_reg, int32_t raw_base_or_table,
501 int32_t raw_index, int scale, int32_t table_or_disp);
502 void EmitMacro(const X86EncodingMap* entry, int32_t raw_reg, int32_t offset);
503 void EmitUnimplemented(const X86EncodingMap* entry, LIR* lir);
504 void GenFusedLongCmpImmBranch(BasicBlock* bb, RegLocation rl_src1,
505 int64_t val, ConditionCode ccode);
506 void GenConstWide(RegLocation rl_dest, int64_t value);
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700507 void GenMultiplyVectorSignedByte(RegStorage rs_dest_src1, RegStorage rs_src2);
508 void GenMultiplyVectorLong(RegStorage rs_dest_src1, RegStorage rs_src2);
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700509 void GenShiftByteVector(MIR* mir);
Yixin Shouf40f8902014-08-14 14:10:32 -0400510 void AndMaskVectorRegister(RegStorage rs_src1, uint32_t m1, uint32_t m2, uint32_t m3,
511 uint32_t m4);
512 void MaskVectorRegister(X86OpCode opcode, RegStorage rs_src1, uint32_t m1, uint32_t m2,
513 uint32_t m3, uint32_t m4);
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700514 void AppendOpcodeWithConst(X86OpCode opcode, int reg, MIR* mir);
Mark Mendell0a1174e2014-09-11 14:51:02 -0400515 virtual void LoadVectorRegister(RegStorage rs_dest, RegStorage rs_src, OpSize opsize,
516 int op_mov);
Mark Mendell2637f2e2014-04-30 10:10:47 -0400517
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700518 static bool ProvidesFullMemoryBarrier(X86OpCode opcode);
Mark Mendelle02d48f2014-01-15 11:19:23 -0800519
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700520 /*
521 * @brief Ensure that a temporary register is byte addressable.
522 * @returns a temporary guarenteed to be byte addressable.
523 */
524 virtual RegStorage AllocateByteRegister();
Razvan A Lupusoru99ad7232014-02-25 17:41:08 -0800525
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700526 /*
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700527 * @brief Use a wide temporary as a 128-bit register
528 * @returns a 128-bit temporary register.
529 */
530 virtual RegStorage Get128BitRegister(RegStorage reg);
531
532 /*
Chao-ying Fu7e399fd2014-06-10 18:11:11 -0700533 * @brief Check if a register is byte addressable.
534 * @returns true if a register is byte addressable.
535 */
Ian Rogersb28c1c02014-11-08 11:21:21 -0800536 bool IsByteRegister(RegStorage reg) const;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700537
538 void GenDivRemLongLit(RegLocation rl_dest, RegLocation rl_src, int64_t imm, bool is_div);
539
DaniilSokolov70c4f062014-06-24 17:34:00 -0700540 bool GenInlinedArrayCopyCharArray(CallInfo* info) OVERRIDE;
Chao-ying Fu7e399fd2014-06-10 18:11:11 -0700541
542 /*
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700543 * @brief generate inline code for fast case of Strng.indexOf.
544 * @param info Call parameters
545 * @param zero_based 'true' if the index into the string is 0.
546 * @returns 'true' if the call was inlined, 'false' if a regular call needs to be
547 * generated.
548 */
549 bool GenInlinedIndexOf(CallInfo* info, bool zero_based);
Mark Mendelle87f9b52014-04-30 14:13:18 -0400550
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700551 /**
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700552 * @brief Used to reserve a range of vector registers.
553 * @see kMirOpReserveVectorRegisters
554 * @param mir The extended MIR for reservation.
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700555 */
556 void ReserveVectorRegisters(MIR* mir);
557
558 /**
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700559 * @brief Used to return a range of vector registers.
560 * @see kMirOpReturnVectorRegisters
561 * @param mir The extended MIR for returning vector regs.
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700562 */
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700563 void ReturnVectorRegisters(MIR* mir);
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700564
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700565 /*
566 * @brief Load 128 bit constant into vector register.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700567 * @param mir The MIR whose opcode is kMirConstVector
568 * @note vA is the TypeSize for the register.
569 * @note vB is the destination XMM register. arg[0..3] are 32 bit constant values.
570 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700571 void GenConst128(MIR* mir);
Mark Mendell4028a6c2014-02-19 20:06:20 -0800572
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700573 /*
574 * @brief MIR to move a vectorized register to another.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700575 * @param mir The MIR whose opcode is kMirConstVector.
576 * @note vA: TypeSize
577 * @note vB: destination
578 * @note vC: source
579 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700580 void GenMoveVector(MIR* mir);
Mark Mendelld65c51a2014-04-29 16:55:20 -0400581
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700582 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400583 * @brief Packed multiply of units in two vector registers: vB = vB .* @note vC using vA to know
584 * the type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700585 * @param mir The MIR whose opcode is kMirConstVector.
586 * @note vA: TypeSize
587 * @note vB: destination and source
588 * @note vC: source
589 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700590 void GenMultiplyVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400591
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700592 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400593 * @brief Packed addition of units in two vector registers: vB = vB .+ vC using vA to know the
594 * type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700595 * @param mir The MIR whose opcode is kMirConstVector.
596 * @note vA: TypeSize
597 * @note vB: destination and source
598 * @note vC: source
599 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700600 void GenAddVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400601
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700602 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400603 * @brief Packed subtraction of units in two vector registers: vB = vB .- vC using vA to know the
604 * type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700605 * @param mir The MIR whose opcode is kMirConstVector.
606 * @note vA: TypeSize
607 * @note vB: destination and source
608 * @note vC: source
609 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700610 void GenSubtractVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400611
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700612 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400613 * @brief Packed shift left of units in two vector registers: vB = vB .<< vC using vA to know the
614 * type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700615 * @param mir The MIR whose opcode is kMirConstVector.
616 * @note vA: TypeSize
617 * @note vB: destination and source
618 * @note vC: immediate
619 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700620 void GenShiftLeftVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400621
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700622 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400623 * @brief Packed signed shift right of units in two vector registers: vB = vB .>> vC using vA to
624 * know the type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700625 * @param mir The MIR whose opcode is kMirConstVector.
626 * @note vA: TypeSize
627 * @note vB: destination and source
628 * @note vC: immediate
629 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700630 void GenSignedShiftRightVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400631
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700632 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400633 * @brief Packed unsigned shift right of units in two vector registers: vB = vB .>>> vC using vA
634 * to know the type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700635 * @param mir The MIR whose opcode is kMirConstVector.
636 * @note vA: TypeSize
637 * @note vB: destination and source
638 * @note vC: immediate
639 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700640 void GenUnsignedShiftRightVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400641
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700642 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400643 * @brief Packed bitwise and of units in two vector registers: vB = vB .& vC using vA to know the
644 * type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700645 * @note vA: TypeSize
646 * @note vB: destination and source
647 * @note vC: source
648 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700649 void GenAndVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400650
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700651 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400652 * @brief Packed bitwise or of units in two vector registers: vB = vB .| vC using vA to know the
653 * type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700654 * @param mir The MIR whose opcode is kMirConstVector.
655 * @note vA: TypeSize
656 * @note vB: destination and source
657 * @note vC: source
658 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700659 void GenOrVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400660
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700661 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400662 * @brief Packed bitwise xor of units in two vector registers: vB = vB .^ vC using vA to know the
663 * type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700664 * @param mir The MIR whose opcode is kMirConstVector.
665 * @note vA: TypeSize
666 * @note vB: destination and source
667 * @note vC: source
668 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700669 void GenXorVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400670
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700671 /*
672 * @brief Reduce a 128-bit packed element into a single VR by taking lower bits
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700673 * @param mir The MIR whose opcode is kMirConstVector.
674 * @details Instruction does a horizontal addition of the packed elements and then adds it to VR.
675 * @note vA: TypeSize
676 * @note vB: destination and source VR (not vector register)
677 * @note vC: source (vector register)
678 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700679 void GenAddReduceVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400680
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700681 /*
682 * @brief Extract a packed element into a single VR.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700683 * @param mir The MIR whose opcode is kMirConstVector.
684 * @note vA: TypeSize
685 * @note vB: destination VR (not vector register)
686 * @note vC: source (vector register)
687 * @note arg[0]: The index to use for extraction from vector register (which packed element).
688 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700689 void GenReduceVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400690
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700691 /*
692 * @brief Create a vector value, with all TypeSize values equal to vC
693 * @param bb The basic block in which the MIR is from.
694 * @param mir The MIR whose opcode is kMirConstVector.
695 * @note vA: TypeSize.
696 * @note vB: destination vector register.
697 * @note vC: source VR (not vector register).
698 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700699 void GenSetVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400700
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700701 /**
702 * @brief Used to generate code for kMirOpPackedArrayGet.
703 * @param bb The basic block of MIR.
704 * @param mir The mir whose opcode is kMirOpPackedArrayGet.
705 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700706 void GenPackedArrayGet(BasicBlock* bb, MIR* mir);
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700707
708 /**
709 * @brief Used to generate code for kMirOpPackedArrayPut.
710 * @param bb The basic block of MIR.
711 * @param mir The mir whose opcode is kMirOpPackedArrayPut.
712 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700713 void GenPackedArrayPut(BasicBlock* bb, MIR* mir);
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700714
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700715 /*
716 * @brief Generate code for a vector opcode.
717 * @param bb The basic block in which the MIR is from.
718 * @param mir The MIR whose opcode is a non-standard opcode.
719 */
720 void GenMachineSpecificExtendedMethodMIR(BasicBlock* bb, MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400721
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700722 /*
723 * @brief Return the correct x86 opcode for the Dex operation
724 * @param op Dex opcode for the operation
725 * @param loc Register location of the operand
726 * @param is_high_op 'true' if this is an operation on the high word
727 * @param value Immediate value for the operation. Used for byte variants
728 * @returns the correct x86 opcode to perform the operation
729 */
730 X86OpCode GetOpcode(Instruction::Code op, RegLocation loc, bool is_high_op, int32_t value);
Mark Mendelld65c51a2014-04-29 16:55:20 -0400731
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700732 /*
733 * @brief Return the correct x86 opcode for the Dex operation
734 * @param op Dex opcode for the operation
735 * @param dest location of the destination. May be register or memory.
736 * @param rhs Location for the rhs of the operation. May be in register or memory.
737 * @param is_high_op 'true' if this is an operation on the high word
738 * @returns the correct x86 opcode to perform the operation
739 * @note at most one location may refer to memory
740 */
741 X86OpCode GetOpcode(Instruction::Code op, RegLocation dest, RegLocation rhs,
742 bool is_high_op);
Mark Mendelle02d48f2014-01-15 11:19:23 -0800743
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700744 /*
745 * @brief Is this operation a no-op for this opcode and value
746 * @param op Dex opcode for the operation
747 * @param value Immediate value for the operation.
748 * @returns 'true' if the operation will have no effect
749 */
750 bool IsNoOp(Instruction::Code op, int32_t value);
Mark Mendelle02d48f2014-01-15 11:19:23 -0800751
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700752 /**
753 * @brief Calculate magic number and shift for a given divisor
754 * @param divisor divisor number for calculation
755 * @param magic hold calculated magic number
756 * @param shift hold calculated shift
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700757 * @param is_long 'true' if divisor is jlong, 'false' for jint.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700758 */
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700759 void CalculateMagicAndShift(int64_t divisor, int64_t& magic, int& shift, bool is_long);
Mark Mendelle02d48f2014-01-15 11:19:23 -0800760
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700761 /*
762 * @brief Generate an integer div or rem operation.
763 * @param rl_dest Destination Location.
764 * @param rl_src1 Numerator Location.
765 * @param rl_src2 Divisor Location.
766 * @param is_div 'true' if this is a division, 'false' for a remainder.
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700767 * @param flags The instruction optimization flags. It can include information
768 * if exception check can be elided.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700769 */
770 RegLocation GenDivRem(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2,
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700771 bool is_div, int flags);
Mark Mendell2bf31e62014-01-23 12:13:40 -0800772
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700773 /*
774 * @brief Generate an integer div or rem operation by a literal.
775 * @param rl_dest Destination Location.
776 * @param rl_src Numerator Location.
777 * @param lit Divisor.
778 * @param is_div 'true' if this is a division, 'false' for a remainder.
779 */
780 RegLocation GenDivRemLit(RegLocation rl_dest, RegLocation rl_src, int lit, bool is_div);
Mark Mendell2bf31e62014-01-23 12:13:40 -0800781
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700782 /*
783 * Generate code to implement long shift operations.
784 * @param opcode The DEX opcode to specify the shift type.
785 * @param rl_dest The destination.
786 * @param rl_src The value to be shifted.
787 * @param shift_amount How much to shift.
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700788 * @param flags The instruction optimization flags.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700789 * @returns the RegLocation of the result.
790 */
791 RegLocation GenShiftImmOpLong(Instruction::Code opcode, RegLocation rl_dest,
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700792 RegLocation rl_src, int shift_amount, int flags);
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700793 /*
794 * Generate an imul of a register by a constant or a better sequence.
795 * @param dest Destination Register.
796 * @param src Source Register.
797 * @param val Constant multiplier.
798 */
799 void GenImulRegImm(RegStorage dest, RegStorage src, int val);
Mark Mendell4708dcd2014-01-22 09:05:18 -0800800
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700801 /*
802 * Generate an imul of a memory location by a constant or a better sequence.
803 * @param dest Destination Register.
804 * @param sreg Symbolic register.
805 * @param displacement Displacement on stack of Symbolic Register.
806 * @param val Constant multiplier.
807 */
808 void GenImulMemImm(RegStorage dest, int sreg, int displacement, int val);
Mark Mendellfeb2b4e2014-01-28 12:59:49 -0800809
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700810 /*
811 * @brief Compare memory to immediate, and branch if condition true.
812 * @param cond The condition code that when true will branch to the target.
813 * @param temp_reg A temporary register that can be used if compare memory is not
814 * supported by the architecture.
815 * @param base_reg The register holding the base address.
816 * @param offset The offset from the base.
817 * @param check_value The immediate to compare to.
Dave Allison69dfe512014-07-11 17:11:58 +0000818 * @param target branch target (or nullptr)
819 * @param compare output for getting LIR for comparison (or nullptr)
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700820 */
821 LIR* OpCmpMemImmBranch(ConditionCode cond, RegStorage temp_reg, RegStorage base_reg,
Dave Allison69dfe512014-07-11 17:11:58 +0000822 int offset, int check_value, LIR* target, LIR** compare);
Mark Mendell766e9292014-01-27 07:55:47 -0800823
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700824 void GenRemFP(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2, bool is_double);
825
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700826 /*
827 * Can this operation be using core registers without temporaries?
828 * @param rl_lhs Left hand operand.
829 * @param rl_rhs Right hand operand.
830 * @returns 'true' if the operation can proceed without needing temporary regs.
831 */
832 bool IsOperationSafeWithoutTemps(RegLocation rl_lhs, RegLocation rl_rhs);
Razvan A Lupusoru614c2b42014-01-28 17:05:21 -0800833
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700834 /**
835 * @brief Generates inline code for conversion of long to FP by using x87/
836 * @param rl_dest The destination of the FP.
837 * @param rl_src The source of the long.
838 * @param is_double 'true' if dealing with double, 'false' for float.
839 */
840 virtual void GenLongToFP(RegLocation rl_dest, RegLocation rl_src, bool is_double);
Mark Mendell67c39c42014-01-31 17:28:00 -0800841
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700842 void GenArrayBoundsCheck(RegStorage index, RegStorage array_base, int32_t len_offset);
843 void GenArrayBoundsCheck(int32_t index, RegStorage array_base, int32_t len_offset);
844
845 LIR* OpRegMem(OpKind op, RegStorage r_dest, RegStorage r_base, int offset);
846 LIR* OpRegMem(OpKind op, RegStorage r_dest, RegLocation value);
847 LIR* OpMemReg(OpKind op, RegLocation rl_dest, int value);
848 LIR* OpThreadMem(OpKind op, ThreadOffset<4> thread_offset);
849 LIR* OpThreadMem(OpKind op, ThreadOffset<8> thread_offset);
850 void OpRegThreadMem(OpKind op, RegStorage r_dest, ThreadOffset<4> thread_offset);
851 void OpRegThreadMem(OpKind op, RegStorage r_dest, ThreadOffset<8> thread_offset);
852 void OpTlsCmp(ThreadOffset<4> offset, int val);
853 void OpTlsCmp(ThreadOffset<8> offset, int val);
854
855 void OpLea(RegStorage r_base, RegStorage reg1, RegStorage reg2, int scale, int offset);
856
Andreas Gampec76c6142014-08-04 16:30:03 -0700857 // Try to do a long multiplication where rl_src2 is a constant. This simplified setup might fail,
858 // in which case false will be returned.
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700859 bool GenMulLongConst(RegLocation rl_dest, RegLocation rl_src1, int64_t val, int flags);
Andreas Gampec76c6142014-08-04 16:30:03 -0700860 void GenMulLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700861 RegLocation rl_src2, int flags);
Andreas Gampec76c6142014-08-04 16:30:03 -0700862 void GenNotLong(RegLocation rl_dest, RegLocation rl_src);
863 void GenNegLong(RegLocation rl_dest, RegLocation rl_src);
864 void GenDivRemLong(Instruction::Code, RegLocation rl_dest, RegLocation rl_src1,
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700865 RegLocation rl_src2, bool is_div, int flags);
Andreas Gampec76c6142014-08-04 16:30:03 -0700866
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700867 void SpillCoreRegs();
868 void UnSpillCoreRegs();
869 void UnSpillFPRegs();
870 void SpillFPRegs();
871
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700872 /*
873 * @brief Perform MIR analysis before compiling method.
874 * @note Invokes Mir2LiR::Materialize after analysis.
875 */
876 void Materialize();
Razvan A Lupusoru614c2b42014-01-28 17:05:21 -0800877
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700878 /*
879 * Mir2Lir's UpdateLoc() looks to see if the Dalvik value is currently live in any temp register
880 * without regard to data type. In practice, this can result in UpdateLoc returning a
881 * location record for a Dalvik float value in a core register, and vis-versa. For targets
882 * which can inexpensively move data between core and float registers, this can often be a win.
883 * However, for x86 this is generally not a win. These variants of UpdateLoc()
884 * take a register class argument - and will return an in-register location record only if
885 * the value is live in a temp register of the correct class. Additionally, if the value is in
886 * a temp register of the wrong register class, it will be clobbered.
887 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700888 RegLocation UpdateLocTyped(RegLocation loc);
889 RegLocation UpdateLocWideTyped(RegLocation loc);
Mark Mendell67c39c42014-01-31 17:28:00 -0800890
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700891 /*
892 * @brief Analyze MIR before generating code, to prepare for the code generation.
893 */
894 void AnalyzeMIR();
buzbee30adc732014-05-09 15:10:18 -0700895
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700896 /*
897 * @brief Analyze one basic block.
898 * @param bb Basic block to analyze.
899 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700900 void AnalyzeBB(BasicBlock* bb);
Mark Mendell67c39c42014-01-31 17:28:00 -0800901
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700902 /*
903 * @brief Analyze one extended MIR instruction
904 * @param opcode MIR instruction opcode.
905 * @param bb Basic block containing instruction.
906 * @param mir Extended instruction to analyze.
907 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700908 void AnalyzeExtendedMIR(int opcode, BasicBlock* bb, MIR* mir);
Mark Mendell67c39c42014-01-31 17:28:00 -0800909
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700910 /*
911 * @brief Analyze one MIR instruction
912 * @param opcode MIR instruction opcode.
913 * @param bb Basic block containing instruction.
914 * @param mir Instruction to analyze.
915 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700916 virtual void AnalyzeMIR(int opcode, BasicBlock* bb, MIR* mir);
Mark Mendell67c39c42014-01-31 17:28:00 -0800917
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700918 /*
919 * @brief Analyze one MIR float/double instruction
920 * @param opcode MIR instruction opcode.
921 * @param bb Basic block containing instruction.
922 * @param mir Instruction to analyze.
923 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700924 virtual void AnalyzeFPInstruction(int opcode, BasicBlock* bb, MIR* mir);
Mark Mendell67c39c42014-01-31 17:28:00 -0800925
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700926 /*
927 * @brief Analyze one use of a double operand.
928 * @param rl_use Double RegLocation for the operand.
929 */
930 void AnalyzeDoubleUse(RegLocation rl_use);
Mark Mendell67c39c42014-01-31 17:28:00 -0800931
Yixin Shou7071c8d2014-03-05 06:07:48 -0500932 /*
933 * @brief Analyze one invoke-static MIR instruction
934 * @param opcode MIR instruction opcode.
935 * @param bb Basic block containing instruction.
936 * @param mir Instruction to analyze.
937 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700938 void AnalyzeInvokeStatic(int opcode, BasicBlock* bb, MIR* mir);
Yixin Shou7071c8d2014-03-05 06:07:48 -0500939
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700940 // Information derived from analysis of MIR
Dmitry Petrochenko9ee801f2014-05-12 11:31:37 +0700941
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700942 // The compiler temporary for the code address of the method.
943 CompilerTemp *base_of_code_;
Mark Mendell67c39c42014-01-31 17:28:00 -0800944
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700945 // Have we decided to compute a ptr to code and store in temporary VR?
946 bool store_method_addr_;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800947
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700948 // Have we used the stored method address?
949 bool store_method_addr_used_;
Mark Mendell67c39c42014-01-31 17:28:00 -0800950
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700951 // Instructions to remove if we didn't use the stored method address.
952 LIR* setup_method_address_[2];
Mark Mendell55d0eac2014-02-06 11:02:52 -0800953
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700954 // Instructions needing patching with Method* values.
Vladimir Markoe39c54e2014-09-22 14:50:02 +0100955 ArenaVector<LIR*> method_address_insns_;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800956
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700957 // Instructions needing patching with Class Type* values.
Vladimir Markoe39c54e2014-09-22 14:50:02 +0100958 ArenaVector<LIR*> class_type_address_insns_;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800959
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700960 // Instructions needing patching with PC relative code addresses.
Vladimir Markoe39c54e2014-09-22 14:50:02 +0100961 ArenaVector<LIR*> call_method_insns_;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800962
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700963 // Prologue decrement of stack pointer.
964 LIR* stack_decrement_;
Mark Mendellae9fd932014-02-10 16:14:35 -0800965
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700966 // Epilogue increment of stack pointer.
967 LIR* stack_increment_;
Mark Mendellae9fd932014-02-10 16:14:35 -0800968
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700969 // The list of const vector literals.
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700970 LIR* const_vectors_;
Mark Mendelld65c51a2014-04-29 16:55:20 -0400971
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700972 /*
973 * @brief Search for a matching vector literal
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700974 * @param constants An array of size 4 which contains all of 32-bit constants.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700975 * @returns pointer to matching LIR constant, or nullptr if not found.
976 */
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700977 LIR* ScanVectorLiteral(int32_t* constants);
Mark Mendelld65c51a2014-04-29 16:55:20 -0400978
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700979 /*
980 * @brief Add a constant vector literal
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700981 * @param constants An array of size 4 which contains all of 32-bit constants.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700982 */
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700983 LIR* AddVectorLiteral(int32_t* constants);
Mark Mendelld65c51a2014-04-29 16:55:20 -0400984
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700985 bool WideGPRsAreAliases() const OVERRIDE {
Serguei Katkov59a42af2014-07-05 00:55:46 +0700986 return cu_->target64; // On 64b, we have 64b GPRs.
987 }
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700988
989 bool WideFPRsAreAliases() const OVERRIDE {
Serguei Katkov59a42af2014-07-05 00:55:46 +0700990 return true; // xmm registers have 64b views even on x86.
991 }
992
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700993 /*
994 * @brief Dump a RegLocation using printf
995 * @param loc Register location to dump
996 */
997 static void DumpRegLocation(RegLocation loc);
998
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700999 InToRegStorageMapping in_to_reg_storage_mapping_;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +07001000
Udayan Banerji60bfe7b2014-07-08 19:59:43 -07001001 private:
Yixin Shou8c914c02014-07-28 14:17:09 -04001002 void SwapBits(RegStorage result_reg, int shift, int32_t value);
1003 void SwapBits64(RegStorage result_reg, int shift, int64_t value);
Ian Rogers6a3c1fc2014-10-31 00:33:20 -07001004
1005 static const X86EncodingMap EncodingMap[kX86Last];
1006
1007 friend std::ostream& operator<<(std::ostream& os, const X86OpCode& rhs);
1008
1009 DISALLOW_COPY_AND_ASSIGN(X86Mir2Lir);
Brian Carlstrom7940e442013-07-12 13:46:57 -07001010};
1011
1012} // namespace art
1013
Brian Carlstromfc0e3212013-07-17 14:40:12 -07001014#endif // ART_COMPILER_DEX_QUICK_X86_CODEGEN_X86_H_