blob: 9cb0bf53e6523561af28e44cbceffac90ce7b39f [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);
Yevgeny Rouban6af82062014-11-26 18:11:54 +060093 void GenLongToInt(RegLocation rl_dest, RegLocation rl_src);
Ian Rogers0f9b9c52014-06-09 01:32:12 -070094 LIR* StoreBaseDisp(RegStorage r_base, int displacement, RegStorage r_src,
Andreas Gampe3c12c512014-06-24 18:46:29 +000095 OpSize size, VolatileKind is_volatile) OVERRIDE;
Ian Rogers0f9b9c52014-06-09 01:32:12 -070096 LIR* StoreBaseIndexed(RegStorage r_base, RegStorage r_index, RegStorage r_src, int scale,
97 OpSize size) OVERRIDE;
Vladimir Markobf535be2014-11-19 18:52:35 +000098
99 /// @copydoc Mir2Lir::UnconditionallyMarkGCCard(RegStorage)
100 void UnconditionallyMarkGCCard(RegStorage tgt_addr_reg) OVERRIDE;
101
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700102 void GenImplicitNullCheck(RegStorage reg, int opt_flags) OVERRIDE;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700103
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700104 // Required for target - register utilities.
Chao-ying Fua77ee512014-07-01 17:43:41 -0700105 RegStorage TargetReg(SpecialTargetRegister reg) OVERRIDE;
Andreas Gampeccc60262014-07-04 18:02:38 -0700106 RegStorage TargetReg(SpecialTargetRegister symbolic_reg, WideKind wide_kind) OVERRIDE {
107 if (wide_kind == kWide) {
108 if (cu_->target64) {
109 return As64BitReg(TargetReg32(symbolic_reg));
110 } else {
111 // x86: construct a pair.
112 DCHECK((kArg0 <= symbolic_reg && symbolic_reg < kArg3) ||
113 (kFArg0 <= symbolic_reg && symbolic_reg < kFArg3) ||
114 (kRet0 == symbolic_reg));
115 return RegStorage::MakeRegPair(TargetReg32(symbolic_reg),
116 TargetReg32(static_cast<SpecialTargetRegister>(symbolic_reg + 1)));
117 }
118 } else if (wide_kind == kRef && cu_->target64) {
119 return As64BitReg(TargetReg32(symbolic_reg));
Chao-ying Fua77ee512014-07-01 17:43:41 -0700120 } else {
Andreas Gampeccc60262014-07-04 18:02:38 -0700121 return TargetReg32(symbolic_reg);
Chao-ying Fua77ee512014-07-01 17:43:41 -0700122 }
123 }
Chao-ying Fua77ee512014-07-01 17:43:41 -0700124 RegStorage TargetPtrReg(SpecialTargetRegister symbolic_reg) OVERRIDE {
Andreas Gampeccc60262014-07-04 18:02:38 -0700125 return TargetReg(symbolic_reg, cu_->target64 ? kWide : kNotWide);
Chao-ying Fua77ee512014-07-01 17:43:41 -0700126 }
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700127
128 RegStorage GetArgMappingToPhysicalReg(int arg_num) OVERRIDE;
129
130 RegLocation GetReturnAlt() OVERRIDE;
131 RegLocation GetReturnWideAlt() OVERRIDE;
132 RegLocation LocCReturn() OVERRIDE;
133 RegLocation LocCReturnRef() OVERRIDE;
134 RegLocation LocCReturnDouble() OVERRIDE;
135 RegLocation LocCReturnFloat() OVERRIDE;
136 RegLocation LocCReturnWide() OVERRIDE;
137
Vladimir Marko8dea81c2014-06-06 14:50:36 +0100138 ResourceMask GetRegMaskCommon(const RegStorage& reg) const OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700139 void AdjustSpillMask() OVERRIDE;
140 void ClobberCallerSave() OVERRIDE;
141 void FreeCallTemps() OVERRIDE;
142 void LockCallTemps() OVERRIDE;
143
144 void CompilerInitializeRegAlloc() OVERRIDE;
145 int VectorRegisterSize() OVERRIDE;
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700146 int NumReservableVectorRegisters(bool long_or_fp) OVERRIDE;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700147
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700148 // Required for target - miscellaneous.
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700149 void AssembleLIR() OVERRIDE;
Vladimir Marko8dea81c2014-06-06 14:50:36 +0100150 void DumpResourceMask(LIR* lir, const ResourceMask& mask, const char* prefix) OVERRIDE;
151 void SetupTargetResourceMasks(LIR* lir, uint64_t flags,
152 ResourceMask* use_mask, ResourceMask* def_mask) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700153 const char* GetTargetInstFmt(int opcode) OVERRIDE;
154 const char* GetTargetInstName(int opcode) OVERRIDE;
155 std::string BuildInsnString(const char* fmt, LIR* lir, unsigned char* base_addr) OVERRIDE;
Vladimir Marko8dea81c2014-06-06 14:50:36 +0100156 ResourceMask GetPCUseDefEncoding() const OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700157 uint64_t GetTargetInstFlags(int opcode) OVERRIDE;
Ian Rogers5aa6e042014-06-13 16:38:24 -0700158 size_t GetInsnSize(LIR* lir) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700159 bool IsUnconditionalBranch(LIR* lir) OVERRIDE;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700160
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700161 // Get the register class for load/store of a field.
162 RegisterClass RegClassForFieldLoadStore(OpSize size, bool is_volatile) OVERRIDE;
Vladimir Marko674744e2014-04-24 15:18:26 +0100163
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700164 // Required for target - Dalvik-level generators.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700165 void GenArrayGet(int opt_flags, OpSize size, RegLocation rl_array, RegLocation rl_index,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700166 RegLocation rl_dest, int scale) OVERRIDE;
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700167 void GenArrayPut(int opt_flags, OpSize size, RegLocation rl_array,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700168 RegLocation rl_index, RegLocation rl_src, int scale, bool card_mark) OVERRIDE;
169
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700170 void GenArithOpDouble(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700171 RegLocation rl_src2) OVERRIDE;
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700172 void GenArithOpFloat(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700173 RegLocation rl_src2) OVERRIDE;
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700174 void GenCmpFP(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700175 RegLocation rl_src2) OVERRIDE;
176 void GenConversion(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src) OVERRIDE;
177
178 bool GenInlinedCas(CallInfo* info, bool is_long, bool is_object) OVERRIDE;
179 bool GenInlinedMinMax(CallInfo* info, bool is_min, bool is_long) OVERRIDE;
180 bool GenInlinedMinMaxFP(CallInfo* info, bool is_min, bool is_double) OVERRIDE;
Yixin Shou8c914c02014-07-28 14:17:09 -0400181 bool GenInlinedReverseBits(CallInfo* info, OpSize size) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700182 bool GenInlinedSqrt(CallInfo* info) OVERRIDE;
Yixin Shou7071c8d2014-03-05 06:07:48 -0500183 bool GenInlinedAbsFloat(CallInfo* info) OVERRIDE;
184 bool GenInlinedAbsDouble(CallInfo* info) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700185 bool GenInlinedPeek(CallInfo* info, OpSize size) OVERRIDE;
186 bool GenInlinedPoke(CallInfo* info, OpSize size) OVERRIDE;
Andreas Gampe98430592014-07-27 19:44:50 -0700187 bool GenInlinedCharAt(CallInfo* info) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700188
189 // Long instructions.
Andreas Gampec76c6142014-08-04 16:30:03 -0700190 void GenArithOpLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700191 RegLocation rl_src2, int flags) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700192 void GenArithImmOpLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700193 RegLocation rl_src2, int flags) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700194 void GenShiftImmOpLong(Instruction::Code opcode, RegLocation rl_dest,
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700195 RegLocation rl_src1, RegLocation rl_shift, int flags) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700196 void GenCmpLong(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2) OVERRIDE;
197 void GenIntToLong(RegLocation rl_dest, RegLocation rl_src) OVERRIDE;
198 void GenShiftOpLong(Instruction::Code opcode, RegLocation rl_dest,
199 RegLocation rl_src1, RegLocation rl_shift) OVERRIDE;
Razvan A Lupusoru3bc01742014-02-06 13:18:43 -0800200
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700201 /*
202 * @brief Generate a two address long operation with a constant value
203 * @param rl_dest location of result
204 * @param rl_src constant source operand
205 * @param op Opcode to be generated
206 * @return success or not
207 */
208 bool GenLongImm(RegLocation rl_dest, RegLocation rl_src, Instruction::Code op);
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700209
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700210 /*
211 * @brief Generate a three address long operation with a constant value
212 * @param rl_dest location of result
213 * @param rl_src1 source operand
214 * @param rl_src2 constant source operand
215 * @param op Opcode to be generated
216 * @return success or not
217 */
218 bool GenLongLongImm(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2,
219 Instruction::Code op);
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700220 /**
221 * @brief Generate a long arithmetic operation.
222 * @param rl_dest The destination.
223 * @param rl_src1 First operand.
224 * @param rl_src2 Second operand.
225 * @param op The DEX opcode for the operation.
226 * @param is_commutative The sources can be swapped if needed.
227 */
228 virtual void GenLongArith(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2,
229 Instruction::Code op, bool is_commutative);
Mark Mendelle02d48f2014-01-15 11:19:23 -0800230
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700231 /**
232 * @brief Generate a two operand long arithmetic operation.
233 * @param rl_dest The destination.
234 * @param rl_src Second operand.
235 * @param op The DEX opcode for the operation.
236 */
237 void GenLongArith(RegLocation rl_dest, RegLocation rl_src, Instruction::Code op);
Mark Mendelle02d48f2014-01-15 11:19:23 -0800238
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700239 /**
240 * @brief Generate a long operation.
241 * @param rl_dest The destination. Must be in a register
242 * @param rl_src The other operand. May be in a register or in memory.
243 * @param op The DEX opcode for the operation.
244 */
245 virtual void GenLongRegOrMemOp(RegLocation rl_dest, RegLocation rl_src, Instruction::Code op);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700246
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700247
248 // TODO: collapse reg_lo, reg_hi
249 RegLocation GenDivRem(RegLocation rl_dest, RegStorage reg_lo, RegStorage reg_hi, bool is_div)
250 OVERRIDE;
251 RegLocation GenDivRemLit(RegLocation rl_dest, RegStorage reg_lo, int lit, bool is_div) OVERRIDE;
252 void GenDivZeroCheckWide(RegStorage reg) OVERRIDE;
253 void GenEntrySequence(RegLocation* ArgLocs, RegLocation rl_method) OVERRIDE;
254 void GenExitSequence() OVERRIDE;
255 void GenSpecialExitSequence() OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700256 void GenFusedFPCmpBranch(BasicBlock* bb, MIR* mir, bool gt_bias, bool is_double) OVERRIDE;
257 void GenFusedLongCmpBranch(BasicBlock* bb, MIR* mir) OVERRIDE;
258 void GenSelect(BasicBlock* bb, MIR* mir) OVERRIDE;
259 void GenSelectConst32(RegStorage left_op, RegStorage right_op, ConditionCode code,
260 int32_t true_val, int32_t false_val, RegStorage rs_dest,
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700261 RegisterClass dest_reg_class) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700262 bool GenMemBarrier(MemBarrierKind barrier_kind) OVERRIDE;
263 void GenMoveException(RegLocation rl_dest) OVERRIDE;
264 void GenMultiplyByTwoBitMultiplier(RegLocation rl_src, RegLocation rl_result, int lit,
265 int first_bit, int second_bit) OVERRIDE;
266 void GenNegDouble(RegLocation rl_dest, RegLocation rl_src) OVERRIDE;
267 void GenNegFloat(RegLocation rl_dest, RegLocation rl_src) OVERRIDE;
Chao-ying Fuda96aed2014-10-27 14:42:00 -0700268 const uint16_t* ConvertPackedSwitchTable(MIR* mir, const uint16_t* table);
Andreas Gampe48971b32014-08-06 10:09:01 -0700269 void GenLargePackedSwitch(MIR* mir, DexOffset table_offset, RegLocation rl_src) OVERRIDE;
270 void GenLargeSparseSwitch(MIR* mir, DexOffset table_offset, RegLocation rl_src) OVERRIDE;
Chao-ying Fuda96aed2014-10-27 14:42:00 -0700271 LIR* InsertCaseLabel(DexOffset vaddr, int keyVal) OVERRIDE;
272 void MarkPackedCaseLabels(Mir2Lir::SwitchTable* tab_rec) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700273
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700274 /**
275 * @brief Implement instanceof a final class with x86 specific code.
276 * @param use_declaring_class 'true' if we can use the class itself.
277 * @param type_idx Type index to use if use_declaring_class is 'false'.
278 * @param rl_dest Result to be set to 0 or 1.
279 * @param rl_src Object to be tested.
280 */
281 void GenInstanceofFinal(bool use_declaring_class, uint32_t type_idx, RegLocation rl_dest,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700282 RegLocation rl_src) OVERRIDE;
Chao-ying Fua0147762014-06-06 18:38:49 -0700283
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700284 // Single operation generators.
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700285 LIR* OpUnconditionalBranch(LIR* target) OVERRIDE;
286 LIR* OpCmpBranch(ConditionCode cond, RegStorage src1, RegStorage src2, LIR* target) OVERRIDE;
287 LIR* OpCmpImmBranch(ConditionCode cond, RegStorage reg, int check_value, LIR* target) OVERRIDE;
288 LIR* OpCondBranch(ConditionCode cc, LIR* target) OVERRIDE;
289 LIR* OpDecAndBranch(ConditionCode c_code, RegStorage reg, LIR* target) OVERRIDE;
290 LIR* OpFpRegCopy(RegStorage r_dest, RegStorage r_src) OVERRIDE;
291 LIR* OpIT(ConditionCode cond, const char* guide) OVERRIDE;
292 void OpEndIT(LIR* it) OVERRIDE;
293 LIR* OpMem(OpKind op, RegStorage r_base, int disp) OVERRIDE;
294 LIR* OpPcRelLoad(RegStorage reg, LIR* target) OVERRIDE;
295 LIR* OpReg(OpKind op, RegStorage r_dest_src) OVERRIDE;
296 void OpRegCopy(RegStorage r_dest, RegStorage r_src) OVERRIDE;
297 LIR* OpRegCopyNoInsert(RegStorage r_dest, RegStorage r_src) OVERRIDE;
298 LIR* OpRegImm(OpKind op, RegStorage r_dest_src1, int value) OVERRIDE;
299 LIR* OpRegReg(OpKind op, RegStorage r_dest_src1, RegStorage r_src2) OVERRIDE;
300 LIR* OpMovRegMem(RegStorage r_dest, RegStorage r_base, int offset, MoveType move_type) OVERRIDE;
301 LIR* OpMovMemReg(RegStorage r_base, int offset, RegStorage r_src, MoveType move_type) OVERRIDE;
302 LIR* OpCondRegReg(OpKind op, ConditionCode cc, RegStorage r_dest, RegStorage r_src) OVERRIDE;
303 LIR* OpRegRegImm(OpKind op, RegStorage r_dest, RegStorage r_src1, int value) OVERRIDE;
304 LIR* OpRegRegReg(OpKind op, RegStorage r_dest, RegStorage r_src1, RegStorage r_src2) OVERRIDE;
305 LIR* OpTestSuspend(LIR* target) OVERRIDE;
306 LIR* OpVldm(RegStorage r_base, int count) OVERRIDE;
307 LIR* OpVstm(RegStorage r_base, int count) OVERRIDE;
308 void OpRegCopyWide(RegStorage dest, RegStorage src) OVERRIDE;
309 bool GenInlinedCurrentThread(CallInfo* info) OVERRIDE;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700310
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700311 bool InexpensiveConstantInt(int32_t value) OVERRIDE;
312 bool InexpensiveConstantFloat(int32_t value) OVERRIDE;
313 bool InexpensiveConstantLong(int64_t value) OVERRIDE;
314 bool InexpensiveConstantDouble(int64_t value) OVERRIDE;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700315
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700316 /*
317 * @brief Should try to optimize for two address instructions?
318 * @return true if we try to avoid generating three operand instructions.
319 */
320 virtual bool GenerateTwoOperandInstructions() const { return true; }
Mark Mendelle87f9b52014-04-30 14:13:18 -0400321
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700322 /*
323 * @brief x86 specific codegen for int operations.
324 * @param opcode Operation to perform.
325 * @param rl_dest Destination for the result.
326 * @param rl_lhs Left hand operand.
327 * @param rl_rhs Right hand operand.
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700328 * @param flags The instruction optimization flags.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700329 */
330 void GenArithOpInt(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_lhs,
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700331 RegLocation rl_rhs, int flags) OVERRIDE;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800332
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700333 /*
334 * @brief Load the Method* of a dex method into the register.
335 * @param target_method The MethodReference of the method to be invoked.
336 * @param type How the method will be invoked.
337 * @param register that will contain the code address.
338 * @note register will be passed to TargetReg to get physical register.
339 */
340 void LoadMethodAddress(const MethodReference& target_method, InvokeType type,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700341 SpecialTargetRegister symbolic_reg) OVERRIDE;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800342
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700343 /*
344 * @brief Load the Class* of a Dex Class type into the register.
Fred Shihe7f82e22014-08-06 10:46:37 -0700345 * @param dex DexFile that contains the class type.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700346 * @param type How the method will be invoked.
347 * @param register that will contain the code address.
348 * @note register will be passed to TargetReg to get physical register.
349 */
Fred Shihe7f82e22014-08-06 10:46:37 -0700350 void LoadClassType(const DexFile& dex_file, uint32_t type_idx,
351 SpecialTargetRegister symbolic_reg) OVERRIDE;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800352
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700353 void FlushIns(RegLocation* ArgLocs, RegLocation rl_method) OVERRIDE;
Dmitry Petrochenko58994cd2014-05-17 01:02:18 +0700354
Vladimir Markof4da6752014-08-01 19:04:18 +0100355 NextCallInsn GetNextSDCallInsn() OVERRIDE;
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700356 int GenDalvikArgsNoRange(CallInfo* info, int call_state, LIR** pcrLabel,
Dmitry Petrochenko58994cd2014-05-17 01:02:18 +0700357 NextCallInsn next_call_insn,
358 const MethodReference& target_method,
359 uint32_t vtable_idx,
360 uintptr_t direct_code, uintptr_t direct_method, InvokeType type,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700361 bool skip_this) OVERRIDE;
Dmitry Petrochenko58994cd2014-05-17 01:02:18 +0700362
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700363 int GenDalvikArgsRange(CallInfo* info, int call_state, LIR** pcrLabel,
364 NextCallInsn next_call_insn,
365 const MethodReference& target_method,
366 uint32_t vtable_idx,
367 uintptr_t direct_code, uintptr_t direct_method, InvokeType type,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700368 bool skip_this) OVERRIDE;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800369
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700370 /*
371 * @brief Generate a relative call to the method that will be patched at link time.
372 * @param target_method The MethodReference of the method to be invoked.
373 * @param type How the method will be invoked.
374 * @returns Call instruction
375 */
Vladimir Markof4da6752014-08-01 19:04:18 +0100376 LIR* CallWithLinkerFixup(const MethodReference& target_method, InvokeType type);
377
378 /*
379 * @brief Generate the actual call insn based on the method info.
380 * @param method_info the lowering info for the method call.
381 * @returns Call instruction
382 */
383 LIR* GenCallInsn(const MirMethodLoweringInfo& method_info) OVERRIDE;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800384
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700385 /*
386 * @brief Handle x86 specific literals
387 */
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700388 void InstallLiteralPools() OVERRIDE;
Mark Mendellae9fd932014-02-10 16:14:35 -0800389
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700390 /*
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700391 * @brief Generate the debug_frame FDE information.
392 * @returns pointer to vector containing CFE information
393 */
Tong Shen547cdfd2014-08-05 01:54:19 -0700394 std::vector<uint8_t>* ReturnFrameDescriptionEntry() OVERRIDE;
Razvan A Lupusorubd288c22013-12-20 17:27:23 -0800395
Andreas Gampe98430592014-07-27 19:44:50 -0700396 LIR* InvokeTrampoline(OpKind op, RegStorage r_tgt, QuickEntrypointEnum trampoline) OVERRIDE;
397
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700398 protected:
Ian Rogersb28c1c02014-11-08 11:21:21 -0800399 RegStorage TargetReg32(SpecialTargetRegister reg) const;
Chao-ying Fua77ee512014-07-01 17:43:41 -0700400 // Casting of RegStorage
401 RegStorage As32BitReg(RegStorage reg) {
402 DCHECK(!reg.IsPair());
403 if ((kFailOnSizeError || kReportSizeError) && !reg.Is64Bit()) {
404 if (kFailOnSizeError) {
405 LOG(FATAL) << "Expected 64b register " << reg.GetReg();
406 } else {
407 LOG(WARNING) << "Expected 64b register " << reg.GetReg();
408 return reg;
409 }
410 }
411 RegStorage ret_val = RegStorage(RegStorage::k32BitSolo,
412 reg.GetRawBits() & RegStorage::kRegTypeMask);
413 DCHECK_EQ(GetRegInfo(reg)->FindMatchingView(RegisterInfo::k32SoloStorageMask)
414 ->GetReg().GetReg(),
415 ret_val.GetReg());
416 return ret_val;
417 }
418
419 RegStorage As64BitReg(RegStorage reg) {
420 DCHECK(!reg.IsPair());
421 if ((kFailOnSizeError || kReportSizeError) && !reg.Is32Bit()) {
422 if (kFailOnSizeError) {
423 LOG(FATAL) << "Expected 32b register " << reg.GetReg();
424 } else {
425 LOG(WARNING) << "Expected 32b register " << reg.GetReg();
426 return reg;
427 }
428 }
429 RegStorage ret_val = RegStorage(RegStorage::k64BitSolo,
430 reg.GetRawBits() & RegStorage::kRegTypeMask);
431 DCHECK_EQ(GetRegInfo(reg)->FindMatchingView(RegisterInfo::k64SoloStorageMask)
432 ->GetReg().GetReg(),
433 ret_val.GetReg());
434 return ret_val;
435 }
436
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700437 LIR* LoadBaseIndexedDisp(RegStorage r_base, RegStorage r_index, int scale, int displacement,
438 RegStorage r_dest, OpSize size);
439 LIR* StoreBaseIndexedDisp(RegStorage r_base, RegStorage r_index, int scale, int displacement,
Jean Christophe Beylerb5bce7c2014-07-25 12:32:18 -0700440 RegStorage r_src, OpSize size, int opt_flags = 0);
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700441
Ian Rogersb28c1c02014-11-08 11:21:21 -0800442 RegStorage GetCoreArgMappingToPhysicalReg(int core_arg_num) const;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700443
444 int AssignInsnOffsets();
445 void AssignOffsets();
446 AssemblerStatus AssembleInstructions(CodeOffset start_addr);
447
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700448 size_t ComputeSize(const X86EncodingMap* entry, int32_t raw_reg, int32_t raw_index,
Ian Rogers5aa6e042014-06-13 16:38:24 -0700449 int32_t raw_base, int32_t displacement);
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700450 void CheckValidByteRegister(const X86EncodingMap* entry, int32_t raw_reg);
451 void EmitPrefix(const X86EncodingMap* entry,
Ian Rogers5aa6e042014-06-13 16:38:24 -0700452 int32_t raw_reg_r, int32_t raw_reg_x, int32_t raw_reg_b);
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700453 void EmitOpcode(const X86EncodingMap* entry);
454 void EmitPrefixAndOpcode(const X86EncodingMap* entry,
Ian Rogers5aa6e042014-06-13 16:38:24 -0700455 int32_t reg_r, int32_t reg_x, int32_t reg_b);
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700456 void EmitDisp(uint8_t base, int32_t disp);
457 void EmitModrmThread(uint8_t reg_or_opcode);
458 void EmitModrmDisp(uint8_t reg_or_opcode, uint8_t base, int32_t disp);
459 void EmitModrmSibDisp(uint8_t reg_or_opcode, uint8_t base, uint8_t index, int scale,
460 int32_t disp);
461 void EmitImm(const X86EncodingMap* entry, int64_t imm);
462 void EmitNullary(const X86EncodingMap* entry);
463 void EmitOpRegOpcode(const X86EncodingMap* entry, int32_t raw_reg);
464 void EmitOpReg(const X86EncodingMap* entry, int32_t raw_reg);
465 void EmitOpMem(const X86EncodingMap* entry, int32_t raw_base, int32_t disp);
466 void EmitOpArray(const X86EncodingMap* entry, int32_t raw_base, int32_t raw_index, int scale,
467 int32_t disp);
468 void EmitMemReg(const X86EncodingMap* entry, int32_t raw_base, int32_t disp, int32_t raw_reg);
469 void EmitRegMem(const X86EncodingMap* entry, int32_t raw_reg, int32_t raw_base, int32_t disp);
470 void EmitRegArray(const X86EncodingMap* entry, int32_t raw_reg, int32_t raw_base,
471 int32_t raw_index, int scale, int32_t disp);
472 void EmitArrayReg(const X86EncodingMap* entry, int32_t raw_base, int32_t raw_index, int scale,
473 int32_t disp, int32_t raw_reg);
474 void EmitMemImm(const X86EncodingMap* entry, int32_t raw_base, int32_t disp, int32_t imm);
475 void EmitArrayImm(const X86EncodingMap* entry, int32_t raw_base, int32_t raw_index, int scale,
476 int32_t raw_disp, int32_t imm);
477 void EmitRegThread(const X86EncodingMap* entry, int32_t raw_reg, int32_t disp);
478 void EmitRegReg(const X86EncodingMap* entry, int32_t raw_reg1, int32_t raw_reg2);
479 void EmitRegRegImm(const X86EncodingMap* entry, int32_t raw_reg1, int32_t raw_reg2, int32_t imm);
480 void EmitRegMemImm(const X86EncodingMap* entry, int32_t raw_reg1, int32_t raw_base, int32_t disp,
481 int32_t imm);
482 void EmitMemRegImm(const X86EncodingMap* entry, int32_t base, int32_t disp, int32_t raw_reg1,
483 int32_t imm);
484 void EmitRegImm(const X86EncodingMap* entry, int32_t raw_reg, int32_t imm);
485 void EmitThreadImm(const X86EncodingMap* entry, int32_t disp, int32_t imm);
486 void EmitMovRegImm(const X86EncodingMap* entry, int32_t raw_reg, int64_t imm);
487 void EmitShiftRegImm(const X86EncodingMap* entry, int32_t raw_reg, int32_t imm);
488 void EmitShiftRegCl(const X86EncodingMap* entry, int32_t raw_reg, int32_t raw_cl);
489 void EmitShiftMemCl(const X86EncodingMap* entry, int32_t raw_base, int32_t disp, int32_t raw_cl);
Yixin Shouf40f8902014-08-14 14:10:32 -0400490 void EmitShiftRegRegCl(const X86EncodingMap* entry, int32_t raw_reg1, int32_t raw_reg2,
491 int32_t raw_cl);
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700492 void EmitShiftMemImm(const X86EncodingMap* entry, int32_t raw_base, int32_t disp, int32_t imm);
493 void EmitRegCond(const X86EncodingMap* entry, int32_t raw_reg, int32_t cc);
494 void EmitMemCond(const X86EncodingMap* entry, int32_t raw_base, int32_t disp, int32_t cc);
495 void EmitRegRegCond(const X86EncodingMap* entry, int32_t raw_reg1, int32_t raw_reg2, int32_t cc);
496 void EmitRegMemCond(const X86EncodingMap* entry, int32_t raw_reg1, int32_t raw_base, int32_t disp,
497 int32_t cc);
Razvan A Lupusorubd288c22013-12-20 17:27:23 -0800498
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700499 void EmitJmp(const X86EncodingMap* entry, int32_t rel);
500 void EmitJcc(const X86EncodingMap* entry, int32_t rel, int32_t cc);
501 void EmitCallMem(const X86EncodingMap* entry, int32_t raw_base, int32_t disp);
502 void EmitCallImmediate(const X86EncodingMap* entry, int32_t disp);
503 void EmitCallThread(const X86EncodingMap* entry, int32_t disp);
504 void EmitPcRel(const X86EncodingMap* entry, int32_t raw_reg, int32_t raw_base_or_table,
505 int32_t raw_index, int scale, int32_t table_or_disp);
506 void EmitMacro(const X86EncodingMap* entry, int32_t raw_reg, int32_t offset);
507 void EmitUnimplemented(const X86EncodingMap* entry, LIR* lir);
508 void GenFusedLongCmpImmBranch(BasicBlock* bb, RegLocation rl_src1,
509 int64_t val, ConditionCode ccode);
510 void GenConstWide(RegLocation rl_dest, int64_t value);
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700511 void GenMultiplyVectorSignedByte(RegStorage rs_dest_src1, RegStorage rs_src2);
512 void GenMultiplyVectorLong(RegStorage rs_dest_src1, RegStorage rs_src2);
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700513 void GenShiftByteVector(MIR* mir);
Yixin Shouf40f8902014-08-14 14:10:32 -0400514 void AndMaskVectorRegister(RegStorage rs_src1, uint32_t m1, uint32_t m2, uint32_t m3,
515 uint32_t m4);
516 void MaskVectorRegister(X86OpCode opcode, RegStorage rs_src1, uint32_t m1, uint32_t m2,
517 uint32_t m3, uint32_t m4);
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700518 void AppendOpcodeWithConst(X86OpCode opcode, int reg, MIR* mir);
Mark Mendell0a1174e2014-09-11 14:51:02 -0400519 virtual void LoadVectorRegister(RegStorage rs_dest, RegStorage rs_src, OpSize opsize,
520 int op_mov);
Mark Mendell2637f2e2014-04-30 10:10:47 -0400521
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700522 static bool ProvidesFullMemoryBarrier(X86OpCode opcode);
Mark Mendelle02d48f2014-01-15 11:19:23 -0800523
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700524 /*
525 * @brief Ensure that a temporary register is byte addressable.
526 * @returns a temporary guarenteed to be byte addressable.
527 */
528 virtual RegStorage AllocateByteRegister();
Razvan A Lupusoru99ad7232014-02-25 17:41:08 -0800529
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700530 /*
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700531 * @brief Use a wide temporary as a 128-bit register
532 * @returns a 128-bit temporary register.
533 */
534 virtual RegStorage Get128BitRegister(RegStorage reg);
535
536 /*
Chao-ying Fu7e399fd2014-06-10 18:11:11 -0700537 * @brief Check if a register is byte addressable.
538 * @returns true if a register is byte addressable.
539 */
Ian Rogersb28c1c02014-11-08 11:21:21 -0800540 bool IsByteRegister(RegStorage reg) const;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700541
542 void GenDivRemLongLit(RegLocation rl_dest, RegLocation rl_src, int64_t imm, bool is_div);
543
DaniilSokolov70c4f062014-06-24 17:34:00 -0700544 bool GenInlinedArrayCopyCharArray(CallInfo* info) OVERRIDE;
Chao-ying Fu7e399fd2014-06-10 18:11:11 -0700545
546 /*
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700547 * @brief generate inline code for fast case of Strng.indexOf.
548 * @param info Call parameters
549 * @param zero_based 'true' if the index into the string is 0.
550 * @returns 'true' if the call was inlined, 'false' if a regular call needs to be
551 * generated.
552 */
553 bool GenInlinedIndexOf(CallInfo* info, bool zero_based);
Mark Mendelle87f9b52014-04-30 14:13:18 -0400554
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700555 /**
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700556 * @brief Used to reserve a range of vector registers.
557 * @see kMirOpReserveVectorRegisters
558 * @param mir The extended MIR for reservation.
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700559 */
560 void ReserveVectorRegisters(MIR* mir);
561
562 /**
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700563 * @brief Used to return a range of vector registers.
564 * @see kMirOpReturnVectorRegisters
565 * @param mir The extended MIR for returning vector regs.
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700566 */
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700567 void ReturnVectorRegisters(MIR* mir);
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700568
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700569 /*
570 * @brief Load 128 bit constant into vector register.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700571 * @param mir The MIR whose opcode is kMirConstVector
572 * @note vA is the TypeSize for the register.
573 * @note vB is the destination XMM register. arg[0..3] are 32 bit constant values.
574 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700575 void GenConst128(MIR* mir);
Mark Mendell4028a6c2014-02-19 20:06:20 -0800576
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700577 /*
578 * @brief MIR to move a vectorized register to another.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700579 * @param mir The MIR whose opcode is kMirConstVector.
580 * @note vA: TypeSize
581 * @note vB: destination
582 * @note vC: source
583 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700584 void GenMoveVector(MIR* mir);
Mark Mendelld65c51a2014-04-29 16:55:20 -0400585
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700586 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400587 * @brief Packed multiply of units in two vector registers: vB = vB .* @note vC using vA to know
588 * the type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700589 * @param mir The MIR whose opcode is kMirConstVector.
590 * @note vA: TypeSize
591 * @note vB: destination and source
592 * @note vC: source
593 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700594 void GenMultiplyVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400595
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700596 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400597 * @brief Packed addition of units in two vector registers: vB = vB .+ vC using vA to know the
598 * type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700599 * @param mir The MIR whose opcode is kMirConstVector.
600 * @note vA: TypeSize
601 * @note vB: destination and source
602 * @note vC: source
603 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700604 void GenAddVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400605
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700606 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400607 * @brief Packed subtraction of units in two vector registers: vB = vB .- vC using vA to know the
608 * type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700609 * @param mir The MIR whose opcode is kMirConstVector.
610 * @note vA: TypeSize
611 * @note vB: destination and source
612 * @note vC: source
613 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700614 void GenSubtractVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400615
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700616 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400617 * @brief Packed shift left of units in two vector registers: vB = vB .<< vC using vA to know the
618 * type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700619 * @param mir The MIR whose opcode is kMirConstVector.
620 * @note vA: TypeSize
621 * @note vB: destination and source
622 * @note vC: immediate
623 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700624 void GenShiftLeftVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400625
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700626 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400627 * @brief Packed signed shift right of units in two vector registers: vB = vB .>> vC using vA to
628 * know the type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700629 * @param mir The MIR whose opcode is kMirConstVector.
630 * @note vA: TypeSize
631 * @note vB: destination and source
632 * @note vC: immediate
633 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700634 void GenSignedShiftRightVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400635
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700636 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400637 * @brief Packed unsigned shift right of units in two vector registers: vB = vB .>>> vC using vA
638 * to know the type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700639 * @param mir The MIR whose opcode is kMirConstVector.
640 * @note vA: TypeSize
641 * @note vB: destination and source
642 * @note vC: immediate
643 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700644 void GenUnsignedShiftRightVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400645
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700646 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400647 * @brief Packed bitwise and of units in two vector registers: vB = vB .& vC using vA to know the
648 * type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700649 * @note vA: TypeSize
650 * @note vB: destination and source
651 * @note vC: source
652 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700653 void GenAndVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400654
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700655 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400656 * @brief Packed bitwise or of units in two vector registers: vB = vB .| vC using vA to know the
657 * type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700658 * @param mir The MIR whose opcode is kMirConstVector.
659 * @note vA: TypeSize
660 * @note vB: destination and source
661 * @note vC: source
662 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700663 void GenOrVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400664
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700665 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400666 * @brief Packed bitwise xor of units in two vector registers: vB = vB .^ vC using vA to know the
667 * type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700668 * @param mir The MIR whose opcode is kMirConstVector.
669 * @note vA: TypeSize
670 * @note vB: destination and source
671 * @note vC: source
672 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700673 void GenXorVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400674
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700675 /*
676 * @brief Reduce a 128-bit packed element into a single VR by taking lower bits
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700677 * @param mir The MIR whose opcode is kMirConstVector.
678 * @details Instruction does a horizontal addition of the packed elements and then adds it to VR.
679 * @note vA: TypeSize
680 * @note vB: destination and source VR (not vector register)
681 * @note vC: source (vector register)
682 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700683 void GenAddReduceVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400684
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700685 /*
686 * @brief Extract a packed element into a single VR.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700687 * @param mir The MIR whose opcode is kMirConstVector.
688 * @note vA: TypeSize
689 * @note vB: destination VR (not vector register)
690 * @note vC: source (vector register)
691 * @note arg[0]: The index to use for extraction from vector register (which packed element).
692 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700693 void GenReduceVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400694
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700695 /*
696 * @brief Create a vector value, with all TypeSize values equal to vC
697 * @param bb The basic block in which the MIR is from.
698 * @param mir The MIR whose opcode is kMirConstVector.
699 * @note vA: TypeSize.
700 * @note vB: destination vector register.
701 * @note vC: source VR (not vector register).
702 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700703 void GenSetVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400704
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700705 /**
706 * @brief Used to generate code for kMirOpPackedArrayGet.
707 * @param bb The basic block of MIR.
708 * @param mir The mir whose opcode is kMirOpPackedArrayGet.
709 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700710 void GenPackedArrayGet(BasicBlock* bb, MIR* mir);
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700711
712 /**
713 * @brief Used to generate code for kMirOpPackedArrayPut.
714 * @param bb The basic block of MIR.
715 * @param mir The mir whose opcode is kMirOpPackedArrayPut.
716 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700717 void GenPackedArrayPut(BasicBlock* bb, MIR* mir);
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700718
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700719 /*
720 * @brief Generate code for a vector opcode.
721 * @param bb The basic block in which the MIR is from.
722 * @param mir The MIR whose opcode is a non-standard opcode.
723 */
724 void GenMachineSpecificExtendedMethodMIR(BasicBlock* bb, MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400725
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700726 /*
727 * @brief Return the correct x86 opcode for the Dex operation
728 * @param op Dex opcode for the operation
729 * @param loc Register location of the operand
730 * @param is_high_op 'true' if this is an operation on the high word
731 * @param value Immediate value for the operation. Used for byte variants
732 * @returns the correct x86 opcode to perform the operation
733 */
734 X86OpCode GetOpcode(Instruction::Code op, RegLocation loc, bool is_high_op, int32_t value);
Mark Mendelld65c51a2014-04-29 16:55:20 -0400735
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700736 /*
737 * @brief Return the correct x86 opcode for the Dex operation
738 * @param op Dex opcode for the operation
739 * @param dest location of the destination. May be register or memory.
740 * @param rhs Location for the rhs of the operation. May be in register or memory.
741 * @param is_high_op 'true' if this is an operation on the high word
742 * @returns the correct x86 opcode to perform the operation
743 * @note at most one location may refer to memory
744 */
745 X86OpCode GetOpcode(Instruction::Code op, RegLocation dest, RegLocation rhs,
746 bool is_high_op);
Mark Mendelle02d48f2014-01-15 11:19:23 -0800747
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700748 /*
749 * @brief Is this operation a no-op for this opcode and value
750 * @param op Dex opcode for the operation
751 * @param value Immediate value for the operation.
752 * @returns 'true' if the operation will have no effect
753 */
754 bool IsNoOp(Instruction::Code op, int32_t value);
Mark Mendelle02d48f2014-01-15 11:19:23 -0800755
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700756 /**
757 * @brief Calculate magic number and shift for a given divisor
758 * @param divisor divisor number for calculation
759 * @param magic hold calculated magic number
760 * @param shift hold calculated shift
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700761 * @param is_long 'true' if divisor is jlong, 'false' for jint.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700762 */
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700763 void CalculateMagicAndShift(int64_t divisor, int64_t& magic, int& shift, bool is_long);
Mark Mendelle02d48f2014-01-15 11:19:23 -0800764
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700765 /*
766 * @brief Generate an integer div or rem operation.
767 * @param rl_dest Destination Location.
768 * @param rl_src1 Numerator Location.
769 * @param rl_src2 Divisor Location.
770 * @param is_div 'true' if this is a division, 'false' for a remainder.
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700771 * @param flags The instruction optimization flags. It can include information
772 * if exception check can be elided.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700773 */
774 RegLocation GenDivRem(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2,
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700775 bool is_div, int flags);
Mark Mendell2bf31e62014-01-23 12:13:40 -0800776
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700777 /*
778 * @brief Generate an integer div or rem operation by a literal.
779 * @param rl_dest Destination Location.
780 * @param rl_src Numerator Location.
781 * @param lit Divisor.
782 * @param is_div 'true' if this is a division, 'false' for a remainder.
783 */
784 RegLocation GenDivRemLit(RegLocation rl_dest, RegLocation rl_src, int lit, bool is_div);
Mark Mendell2bf31e62014-01-23 12:13:40 -0800785
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700786 /*
787 * Generate code to implement long shift operations.
788 * @param opcode The DEX opcode to specify the shift type.
789 * @param rl_dest The destination.
790 * @param rl_src The value to be shifted.
791 * @param shift_amount How much to shift.
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700792 * @param flags The instruction optimization flags.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700793 * @returns the RegLocation of the result.
794 */
795 RegLocation GenShiftImmOpLong(Instruction::Code opcode, RegLocation rl_dest,
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700796 RegLocation rl_src, int shift_amount, int flags);
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700797 /*
798 * Generate an imul of a register by a constant or a better sequence.
799 * @param dest Destination Register.
800 * @param src Source Register.
801 * @param val Constant multiplier.
802 */
803 void GenImulRegImm(RegStorage dest, RegStorage src, int val);
Mark Mendell4708dcd2014-01-22 09:05:18 -0800804
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700805 /*
806 * Generate an imul of a memory location by a constant or a better sequence.
807 * @param dest Destination Register.
808 * @param sreg Symbolic register.
809 * @param displacement Displacement on stack of Symbolic Register.
810 * @param val Constant multiplier.
811 */
812 void GenImulMemImm(RegStorage dest, int sreg, int displacement, int val);
Mark Mendellfeb2b4e2014-01-28 12:59:49 -0800813
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700814 /*
815 * @brief Compare memory to immediate, and branch if condition true.
816 * @param cond The condition code that when true will branch to the target.
817 * @param temp_reg A temporary register that can be used if compare memory is not
818 * supported by the architecture.
819 * @param base_reg The register holding the base address.
820 * @param offset The offset from the base.
821 * @param check_value The immediate to compare to.
Dave Allison69dfe512014-07-11 17:11:58 +0000822 * @param target branch target (or nullptr)
823 * @param compare output for getting LIR for comparison (or nullptr)
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700824 */
825 LIR* OpCmpMemImmBranch(ConditionCode cond, RegStorage temp_reg, RegStorage base_reg,
Dave Allison69dfe512014-07-11 17:11:58 +0000826 int offset, int check_value, LIR* target, LIR** compare);
Mark Mendell766e9292014-01-27 07:55:47 -0800827
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700828 void GenRemFP(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2, bool is_double);
829
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700830 /*
831 * Can this operation be using core registers without temporaries?
832 * @param rl_lhs Left hand operand.
833 * @param rl_rhs Right hand operand.
834 * @returns 'true' if the operation can proceed without needing temporary regs.
835 */
836 bool IsOperationSafeWithoutTemps(RegLocation rl_lhs, RegLocation rl_rhs);
Razvan A Lupusoru614c2b42014-01-28 17:05:21 -0800837
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700838 /**
839 * @brief Generates inline code for conversion of long to FP by using x87/
840 * @param rl_dest The destination of the FP.
841 * @param rl_src The source of the long.
842 * @param is_double 'true' if dealing with double, 'false' for float.
843 */
844 virtual void GenLongToFP(RegLocation rl_dest, RegLocation rl_src, bool is_double);
Mark Mendell67c39c42014-01-31 17:28:00 -0800845
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700846 void GenArrayBoundsCheck(RegStorage index, RegStorage array_base, int32_t len_offset);
847 void GenArrayBoundsCheck(int32_t index, RegStorage array_base, int32_t len_offset);
848
849 LIR* OpRegMem(OpKind op, RegStorage r_dest, RegStorage r_base, int offset);
850 LIR* OpRegMem(OpKind op, RegStorage r_dest, RegLocation value);
851 LIR* OpMemReg(OpKind op, RegLocation rl_dest, int value);
852 LIR* OpThreadMem(OpKind op, ThreadOffset<4> thread_offset);
853 LIR* OpThreadMem(OpKind op, ThreadOffset<8> thread_offset);
854 void OpRegThreadMem(OpKind op, RegStorage r_dest, ThreadOffset<4> thread_offset);
855 void OpRegThreadMem(OpKind op, RegStorage r_dest, ThreadOffset<8> thread_offset);
856 void OpTlsCmp(ThreadOffset<4> offset, int val);
857 void OpTlsCmp(ThreadOffset<8> offset, int val);
858
859 void OpLea(RegStorage r_base, RegStorage reg1, RegStorage reg2, int scale, int offset);
860
Andreas Gampec76c6142014-08-04 16:30:03 -0700861 // Try to do a long multiplication where rl_src2 is a constant. This simplified setup might fail,
862 // in which case false will be returned.
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700863 bool GenMulLongConst(RegLocation rl_dest, RegLocation rl_src1, int64_t val, int flags);
Andreas Gampec76c6142014-08-04 16:30:03 -0700864 void GenMulLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700865 RegLocation rl_src2, int flags);
Andreas Gampec76c6142014-08-04 16:30:03 -0700866 void GenNotLong(RegLocation rl_dest, RegLocation rl_src);
867 void GenNegLong(RegLocation rl_dest, RegLocation rl_src);
868 void GenDivRemLong(Instruction::Code, RegLocation rl_dest, RegLocation rl_src1,
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700869 RegLocation rl_src2, bool is_div, int flags);
Andreas Gampec76c6142014-08-04 16:30:03 -0700870
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700871 void SpillCoreRegs();
872 void UnSpillCoreRegs();
873 void UnSpillFPRegs();
874 void SpillFPRegs();
875
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700876 /*
877 * @brief Perform MIR analysis before compiling method.
878 * @note Invokes Mir2LiR::Materialize after analysis.
879 */
880 void Materialize();
Razvan A Lupusoru614c2b42014-01-28 17:05:21 -0800881
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700882 /*
883 * Mir2Lir's UpdateLoc() looks to see if the Dalvik value is currently live in any temp register
884 * without regard to data type. In practice, this can result in UpdateLoc returning a
885 * location record for a Dalvik float value in a core register, and vis-versa. For targets
886 * which can inexpensively move data between core and float registers, this can often be a win.
887 * However, for x86 this is generally not a win. These variants of UpdateLoc()
888 * take a register class argument - and will return an in-register location record only if
889 * the value is live in a temp register of the correct class. Additionally, if the value is in
890 * a temp register of the wrong register class, it will be clobbered.
891 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700892 RegLocation UpdateLocTyped(RegLocation loc);
893 RegLocation UpdateLocWideTyped(RegLocation loc);
Mark Mendell67c39c42014-01-31 17:28:00 -0800894
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700895 /*
896 * @brief Analyze MIR before generating code, to prepare for the code generation.
897 */
898 void AnalyzeMIR();
buzbee30adc732014-05-09 15:10:18 -0700899
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700900 /*
901 * @brief Analyze one basic block.
902 * @param bb Basic block to analyze.
903 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700904 void AnalyzeBB(BasicBlock* bb);
Mark Mendell67c39c42014-01-31 17:28:00 -0800905
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700906 /*
907 * @brief Analyze one extended MIR instruction
908 * @param opcode MIR instruction opcode.
909 * @param bb Basic block containing instruction.
910 * @param mir Extended instruction to analyze.
911 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700912 void AnalyzeExtendedMIR(int opcode, BasicBlock* bb, MIR* mir);
Mark Mendell67c39c42014-01-31 17:28:00 -0800913
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700914 /*
915 * @brief Analyze one MIR instruction
916 * @param opcode MIR instruction opcode.
917 * @param bb Basic block containing instruction.
918 * @param mir Instruction to analyze.
919 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700920 virtual void AnalyzeMIR(int opcode, BasicBlock* bb, MIR* mir);
Mark Mendell67c39c42014-01-31 17:28:00 -0800921
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700922 /*
923 * @brief Analyze one MIR float/double instruction
924 * @param opcode MIR instruction opcode.
925 * @param bb Basic block containing instruction.
926 * @param mir Instruction to analyze.
927 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700928 virtual void AnalyzeFPInstruction(int opcode, BasicBlock* bb, MIR* mir);
Mark Mendell67c39c42014-01-31 17:28:00 -0800929
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700930 /*
931 * @brief Analyze one use of a double operand.
932 * @param rl_use Double RegLocation for the operand.
933 */
934 void AnalyzeDoubleUse(RegLocation rl_use);
Mark Mendell67c39c42014-01-31 17:28:00 -0800935
Yixin Shou7071c8d2014-03-05 06:07:48 -0500936 /*
937 * @brief Analyze one invoke-static MIR instruction
938 * @param opcode MIR instruction opcode.
939 * @param bb Basic block containing instruction.
940 * @param mir Instruction to analyze.
941 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700942 void AnalyzeInvokeStatic(int opcode, BasicBlock* bb, MIR* mir);
Yixin Shou7071c8d2014-03-05 06:07:48 -0500943
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700944 // Information derived from analysis of MIR
Dmitry Petrochenko9ee801f2014-05-12 11:31:37 +0700945
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700946 // The compiler temporary for the code address of the method.
947 CompilerTemp *base_of_code_;
Mark Mendell67c39c42014-01-31 17:28:00 -0800948
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700949 // Have we decided to compute a ptr to code and store in temporary VR?
950 bool store_method_addr_;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800951
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700952 // Have we used the stored method address?
953 bool store_method_addr_used_;
Mark Mendell67c39c42014-01-31 17:28:00 -0800954
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700955 // Instructions to remove if we didn't use the stored method address.
956 LIR* setup_method_address_[2];
Mark Mendell55d0eac2014-02-06 11:02:52 -0800957
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700958 // Instructions needing patching with Method* values.
Vladimir Markoe39c54e2014-09-22 14:50:02 +0100959 ArenaVector<LIR*> method_address_insns_;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800960
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700961 // Instructions needing patching with Class Type* values.
Vladimir Markoe39c54e2014-09-22 14:50:02 +0100962 ArenaVector<LIR*> class_type_address_insns_;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800963
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700964 // Instructions needing patching with PC relative code addresses.
Vladimir Markoe39c54e2014-09-22 14:50:02 +0100965 ArenaVector<LIR*> call_method_insns_;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800966
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700967 // Prologue decrement of stack pointer.
968 LIR* stack_decrement_;
Mark Mendellae9fd932014-02-10 16:14:35 -0800969
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700970 // Epilogue increment of stack pointer.
971 LIR* stack_increment_;
Mark Mendellae9fd932014-02-10 16:14:35 -0800972
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700973 // The list of const vector literals.
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700974 LIR* const_vectors_;
Mark Mendelld65c51a2014-04-29 16:55:20 -0400975
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700976 /*
977 * @brief Search for a matching vector literal
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700978 * @param constants An array of size 4 which contains all of 32-bit constants.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700979 * @returns pointer to matching LIR constant, or nullptr if not found.
980 */
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700981 LIR* ScanVectorLiteral(int32_t* constants);
Mark Mendelld65c51a2014-04-29 16:55:20 -0400982
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700983 /*
984 * @brief Add a constant vector literal
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700985 * @param constants An array of size 4 which contains all of 32-bit constants.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700986 */
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700987 LIR* AddVectorLiteral(int32_t* constants);
Mark Mendelld65c51a2014-04-29 16:55:20 -0400988
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700989 bool WideGPRsAreAliases() const OVERRIDE {
Serguei Katkov59a42af2014-07-05 00:55:46 +0700990 return cu_->target64; // On 64b, we have 64b GPRs.
991 }
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700992
993 bool WideFPRsAreAliases() const OVERRIDE {
Serguei Katkov59a42af2014-07-05 00:55:46 +0700994 return true; // xmm registers have 64b views even on x86.
995 }
996
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700997 /*
998 * @brief Dump a RegLocation using printf
999 * @param loc Register location to dump
1000 */
1001 static void DumpRegLocation(RegLocation loc);
1002
Ian Rogers6a3c1fc2014-10-31 00:33:20 -07001003 InToRegStorageMapping in_to_reg_storage_mapping_;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +07001004
Udayan Banerji60bfe7b2014-07-08 19:59:43 -07001005 private:
Yixin Shou8c914c02014-07-28 14:17:09 -04001006 void SwapBits(RegStorage result_reg, int shift, int32_t value);
1007 void SwapBits64(RegStorage result_reg, int shift, int64_t value);
Ian Rogers6a3c1fc2014-10-31 00:33:20 -07001008
1009 static const X86EncodingMap EncodingMap[kX86Last];
1010
1011 friend std::ostream& operator<<(std::ostream& os, const X86OpCode& rhs);
1012
1013 DISALLOW_COPY_AND_ASSIGN(X86Mir2Lir);
Brian Carlstrom7940e442013-07-12 13:46:57 -07001014};
1015
1016} // namespace art
1017
Brian Carlstromfc0e3212013-07-17 14:40:12 -07001018#endif // ART_COMPILER_DEX_QUICK_X86_CODEGEN_X86_H_