blob: d57dffb01dba5b6aafd2f4bd33595d5d8a7ed749 [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;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +070097 void MarkGCCard(RegStorage val_reg, RegStorage tgt_addr_reg) OVERRIDE;
98 void GenImplicitNullCheck(RegStorage reg, int opt_flags) OVERRIDE;
Brian Carlstrom7940e442013-07-12 13:46:57 -070099
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700100 // Required for target - register utilities.
Chao-ying Fua77ee512014-07-01 17:43:41 -0700101 RegStorage TargetReg(SpecialTargetRegister reg) OVERRIDE;
Andreas Gampeccc60262014-07-04 18:02:38 -0700102 RegStorage TargetReg(SpecialTargetRegister symbolic_reg, WideKind wide_kind) OVERRIDE {
103 if (wide_kind == kWide) {
104 if (cu_->target64) {
105 return As64BitReg(TargetReg32(symbolic_reg));
106 } else {
107 // x86: construct a pair.
108 DCHECK((kArg0 <= symbolic_reg && symbolic_reg < kArg3) ||
109 (kFArg0 <= symbolic_reg && symbolic_reg < kFArg3) ||
110 (kRet0 == symbolic_reg));
111 return RegStorage::MakeRegPair(TargetReg32(symbolic_reg),
112 TargetReg32(static_cast<SpecialTargetRegister>(symbolic_reg + 1)));
113 }
114 } else if (wide_kind == kRef && cu_->target64) {
115 return As64BitReg(TargetReg32(symbolic_reg));
Chao-ying Fua77ee512014-07-01 17:43:41 -0700116 } else {
Andreas Gampeccc60262014-07-04 18:02:38 -0700117 return TargetReg32(symbolic_reg);
Chao-ying Fua77ee512014-07-01 17:43:41 -0700118 }
119 }
Chao-ying Fua77ee512014-07-01 17:43:41 -0700120 RegStorage TargetPtrReg(SpecialTargetRegister symbolic_reg) OVERRIDE {
Andreas Gampeccc60262014-07-04 18:02:38 -0700121 return TargetReg(symbolic_reg, cu_->target64 ? kWide : kNotWide);
Chao-ying Fua77ee512014-07-01 17:43:41 -0700122 }
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700123
124 RegStorage GetArgMappingToPhysicalReg(int arg_num) OVERRIDE;
125
126 RegLocation GetReturnAlt() OVERRIDE;
127 RegLocation GetReturnWideAlt() OVERRIDE;
128 RegLocation LocCReturn() OVERRIDE;
129 RegLocation LocCReturnRef() OVERRIDE;
130 RegLocation LocCReturnDouble() OVERRIDE;
131 RegLocation LocCReturnFloat() OVERRIDE;
132 RegLocation LocCReturnWide() OVERRIDE;
133
Vladimir Marko8dea81c2014-06-06 14:50:36 +0100134 ResourceMask GetRegMaskCommon(const RegStorage& reg) const OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700135 void AdjustSpillMask() OVERRIDE;
136 void ClobberCallerSave() OVERRIDE;
137 void FreeCallTemps() OVERRIDE;
138 void LockCallTemps() OVERRIDE;
139
140 void CompilerInitializeRegAlloc() OVERRIDE;
141 int VectorRegisterSize() OVERRIDE;
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700142 int NumReservableVectorRegisters(bool long_or_fp) OVERRIDE;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700143
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700144 // Required for target - miscellaneous.
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700145 void AssembleLIR() OVERRIDE;
Vladimir Marko8dea81c2014-06-06 14:50:36 +0100146 void DumpResourceMask(LIR* lir, const ResourceMask& mask, const char* prefix) OVERRIDE;
147 void SetupTargetResourceMasks(LIR* lir, uint64_t flags,
148 ResourceMask* use_mask, ResourceMask* def_mask) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700149 const char* GetTargetInstFmt(int opcode) OVERRIDE;
150 const char* GetTargetInstName(int opcode) OVERRIDE;
151 std::string BuildInsnString(const char* fmt, LIR* lir, unsigned char* base_addr) OVERRIDE;
Vladimir Marko8dea81c2014-06-06 14:50:36 +0100152 ResourceMask GetPCUseDefEncoding() const OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700153 uint64_t GetTargetInstFlags(int opcode) OVERRIDE;
Ian Rogers5aa6e042014-06-13 16:38:24 -0700154 size_t GetInsnSize(LIR* lir) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700155 bool IsUnconditionalBranch(LIR* lir) OVERRIDE;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700156
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700157 // Get the register class for load/store of a field.
158 RegisterClass RegClassForFieldLoadStore(OpSize size, bool is_volatile) OVERRIDE;
Vladimir Marko674744e2014-04-24 15:18:26 +0100159
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700160 // Required for target - Dalvik-level generators.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700161 void GenArrayGet(int opt_flags, OpSize size, RegLocation rl_array, RegLocation rl_index,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700162 RegLocation rl_dest, int scale) OVERRIDE;
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700163 void GenArrayPut(int opt_flags, OpSize size, RegLocation rl_array,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700164 RegLocation rl_index, RegLocation rl_src, int scale, bool card_mark) OVERRIDE;
165
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700166 void GenArithOpDouble(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700167 RegLocation rl_src2) OVERRIDE;
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700168 void GenArithOpFloat(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700169 RegLocation rl_src2) OVERRIDE;
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700170 void GenCmpFP(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700171 RegLocation rl_src2) OVERRIDE;
172 void GenConversion(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src) OVERRIDE;
173
174 bool GenInlinedCas(CallInfo* info, bool is_long, bool is_object) OVERRIDE;
175 bool GenInlinedMinMax(CallInfo* info, bool is_min, bool is_long) OVERRIDE;
176 bool GenInlinedMinMaxFP(CallInfo* info, bool is_min, bool is_double) OVERRIDE;
Yixin Shou8c914c02014-07-28 14:17:09 -0400177 bool GenInlinedReverseBits(CallInfo* info, OpSize size) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700178 bool GenInlinedSqrt(CallInfo* info) OVERRIDE;
Yixin Shou7071c8d2014-03-05 06:07:48 -0500179 bool GenInlinedAbsFloat(CallInfo* info) OVERRIDE;
180 bool GenInlinedAbsDouble(CallInfo* info) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700181 bool GenInlinedPeek(CallInfo* info, OpSize size) OVERRIDE;
182 bool GenInlinedPoke(CallInfo* info, OpSize size) OVERRIDE;
Andreas Gampe98430592014-07-27 19:44:50 -0700183 bool GenInlinedCharAt(CallInfo* info) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700184
185 // Long instructions.
Andreas Gampec76c6142014-08-04 16:30:03 -0700186 void GenArithOpLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700187 RegLocation rl_src2, int flags) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700188 void GenArithImmOpLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700189 RegLocation rl_src2, int flags) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700190 void GenShiftImmOpLong(Instruction::Code opcode, RegLocation rl_dest,
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700191 RegLocation rl_src1, RegLocation rl_shift, int flags) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700192 void GenCmpLong(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2) OVERRIDE;
193 void GenIntToLong(RegLocation rl_dest, RegLocation rl_src) OVERRIDE;
194 void GenShiftOpLong(Instruction::Code opcode, RegLocation rl_dest,
195 RegLocation rl_src1, RegLocation rl_shift) OVERRIDE;
Razvan A Lupusoru3bc01742014-02-06 13:18:43 -0800196
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700197 /*
198 * @brief Generate a two address long operation with a constant value
199 * @param rl_dest location of result
200 * @param rl_src constant source operand
201 * @param op Opcode to be generated
202 * @return success or not
203 */
204 bool GenLongImm(RegLocation rl_dest, RegLocation rl_src, Instruction::Code op);
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700205
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700206 /*
207 * @brief Generate a three address long operation with a constant value
208 * @param rl_dest location of result
209 * @param rl_src1 source operand
210 * @param rl_src2 constant source operand
211 * @param op Opcode to be generated
212 * @return success or not
213 */
214 bool GenLongLongImm(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2,
215 Instruction::Code op);
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700216 /**
217 * @brief Generate a long arithmetic operation.
218 * @param rl_dest The destination.
219 * @param rl_src1 First operand.
220 * @param rl_src2 Second operand.
221 * @param op The DEX opcode for the operation.
222 * @param is_commutative The sources can be swapped if needed.
223 */
224 virtual void GenLongArith(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2,
225 Instruction::Code op, bool is_commutative);
Mark Mendelle02d48f2014-01-15 11:19:23 -0800226
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700227 /**
228 * @brief Generate a two operand long arithmetic operation.
229 * @param rl_dest The destination.
230 * @param rl_src Second operand.
231 * @param op The DEX opcode for the operation.
232 */
233 void GenLongArith(RegLocation rl_dest, RegLocation rl_src, Instruction::Code op);
Mark Mendelle02d48f2014-01-15 11:19:23 -0800234
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700235 /**
236 * @brief Generate a long operation.
237 * @param rl_dest The destination. Must be in a register
238 * @param rl_src The other operand. May be in a register or in memory.
239 * @param op The DEX opcode for the operation.
240 */
241 virtual void GenLongRegOrMemOp(RegLocation rl_dest, RegLocation rl_src, Instruction::Code op);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700242
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700243
244 // TODO: collapse reg_lo, reg_hi
245 RegLocation GenDivRem(RegLocation rl_dest, RegStorage reg_lo, RegStorage reg_hi, bool is_div)
246 OVERRIDE;
247 RegLocation GenDivRemLit(RegLocation rl_dest, RegStorage reg_lo, int lit, bool is_div) OVERRIDE;
248 void GenDivZeroCheckWide(RegStorage reg) OVERRIDE;
249 void GenEntrySequence(RegLocation* ArgLocs, RegLocation rl_method) OVERRIDE;
250 void GenExitSequence() OVERRIDE;
251 void GenSpecialExitSequence() OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700252 void GenFusedFPCmpBranch(BasicBlock* bb, MIR* mir, bool gt_bias, bool is_double) OVERRIDE;
253 void GenFusedLongCmpBranch(BasicBlock* bb, MIR* mir) OVERRIDE;
254 void GenSelect(BasicBlock* bb, MIR* mir) OVERRIDE;
255 void GenSelectConst32(RegStorage left_op, RegStorage right_op, ConditionCode code,
256 int32_t true_val, int32_t false_val, RegStorage rs_dest,
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700257 RegisterClass dest_reg_class) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700258 bool GenMemBarrier(MemBarrierKind barrier_kind) OVERRIDE;
259 void GenMoveException(RegLocation rl_dest) OVERRIDE;
260 void GenMultiplyByTwoBitMultiplier(RegLocation rl_src, RegLocation rl_result, int lit,
261 int first_bit, int second_bit) OVERRIDE;
262 void GenNegDouble(RegLocation rl_dest, RegLocation rl_src) OVERRIDE;
263 void GenNegFloat(RegLocation rl_dest, RegLocation rl_src) OVERRIDE;
Andreas Gampe48971b32014-08-06 10:09:01 -0700264 void GenLargePackedSwitch(MIR* mir, DexOffset table_offset, RegLocation rl_src) OVERRIDE;
265 void GenLargeSparseSwitch(MIR* mir, DexOffset table_offset, RegLocation rl_src) OVERRIDE;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700266
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700267 /**
268 * @brief Implement instanceof a final class with x86 specific code.
269 * @param use_declaring_class 'true' if we can use the class itself.
270 * @param type_idx Type index to use if use_declaring_class is 'false'.
271 * @param rl_dest Result to be set to 0 or 1.
272 * @param rl_src Object to be tested.
273 */
274 void GenInstanceofFinal(bool use_declaring_class, uint32_t type_idx, RegLocation rl_dest,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700275 RegLocation rl_src) OVERRIDE;
Chao-ying Fua0147762014-06-06 18:38:49 -0700276
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700277 // Single operation generators.
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700278 LIR* OpUnconditionalBranch(LIR* target) OVERRIDE;
279 LIR* OpCmpBranch(ConditionCode cond, RegStorage src1, RegStorage src2, LIR* target) OVERRIDE;
280 LIR* OpCmpImmBranch(ConditionCode cond, RegStorage reg, int check_value, LIR* target) OVERRIDE;
281 LIR* OpCondBranch(ConditionCode cc, LIR* target) OVERRIDE;
282 LIR* OpDecAndBranch(ConditionCode c_code, RegStorage reg, LIR* target) OVERRIDE;
283 LIR* OpFpRegCopy(RegStorage r_dest, RegStorage r_src) OVERRIDE;
284 LIR* OpIT(ConditionCode cond, const char* guide) OVERRIDE;
285 void OpEndIT(LIR* it) OVERRIDE;
286 LIR* OpMem(OpKind op, RegStorage r_base, int disp) OVERRIDE;
287 LIR* OpPcRelLoad(RegStorage reg, LIR* target) OVERRIDE;
288 LIR* OpReg(OpKind op, RegStorage r_dest_src) OVERRIDE;
289 void OpRegCopy(RegStorage r_dest, RegStorage r_src) OVERRIDE;
290 LIR* OpRegCopyNoInsert(RegStorage r_dest, RegStorage r_src) OVERRIDE;
291 LIR* OpRegImm(OpKind op, RegStorage r_dest_src1, int value) OVERRIDE;
292 LIR* OpRegReg(OpKind op, RegStorage r_dest_src1, RegStorage r_src2) OVERRIDE;
293 LIR* OpMovRegMem(RegStorage r_dest, RegStorage r_base, int offset, MoveType move_type) OVERRIDE;
294 LIR* OpMovMemReg(RegStorage r_base, int offset, RegStorage r_src, MoveType move_type) OVERRIDE;
295 LIR* OpCondRegReg(OpKind op, ConditionCode cc, RegStorage r_dest, RegStorage r_src) OVERRIDE;
296 LIR* OpRegRegImm(OpKind op, RegStorage r_dest, RegStorage r_src1, int value) OVERRIDE;
297 LIR* OpRegRegReg(OpKind op, RegStorage r_dest, RegStorage r_src1, RegStorage r_src2) OVERRIDE;
298 LIR* OpTestSuspend(LIR* target) OVERRIDE;
299 LIR* OpVldm(RegStorage r_base, int count) OVERRIDE;
300 LIR* OpVstm(RegStorage r_base, int count) OVERRIDE;
301 void OpRegCopyWide(RegStorage dest, RegStorage src) OVERRIDE;
302 bool GenInlinedCurrentThread(CallInfo* info) OVERRIDE;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700303
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700304 bool InexpensiveConstantInt(int32_t value) OVERRIDE;
305 bool InexpensiveConstantFloat(int32_t value) OVERRIDE;
306 bool InexpensiveConstantLong(int64_t value) OVERRIDE;
307 bool InexpensiveConstantDouble(int64_t value) OVERRIDE;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700308
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700309 /*
310 * @brief Should try to optimize for two address instructions?
311 * @return true if we try to avoid generating three operand instructions.
312 */
313 virtual bool GenerateTwoOperandInstructions() const { return true; }
Mark Mendelle87f9b52014-04-30 14:13:18 -0400314
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700315 /*
316 * @brief x86 specific codegen for int operations.
317 * @param opcode Operation to perform.
318 * @param rl_dest Destination for the result.
319 * @param rl_lhs Left hand operand.
320 * @param rl_rhs Right hand operand.
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700321 * @param flags The instruction optimization flags.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700322 */
323 void GenArithOpInt(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_lhs,
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700324 RegLocation rl_rhs, int flags) OVERRIDE;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800325
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700326 /*
327 * @brief Load the Method* of a dex method into the register.
328 * @param target_method The MethodReference of the method to be invoked.
329 * @param type How the method will be invoked.
330 * @param register that will contain the code address.
331 * @note register will be passed to TargetReg to get physical register.
332 */
333 void LoadMethodAddress(const MethodReference& target_method, InvokeType type,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700334 SpecialTargetRegister symbolic_reg) OVERRIDE;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800335
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700336 /*
337 * @brief Load the Class* of a Dex Class type into the register.
Fred Shihe7f82e22014-08-06 10:46:37 -0700338 * @param dex DexFile that contains the class type.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700339 * @param type How the method will be invoked.
340 * @param register that will contain the code address.
341 * @note register will be passed to TargetReg to get physical register.
342 */
Fred Shihe7f82e22014-08-06 10:46:37 -0700343 void LoadClassType(const DexFile& dex_file, uint32_t type_idx,
344 SpecialTargetRegister symbolic_reg) OVERRIDE;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800345
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700346 void FlushIns(RegLocation* ArgLocs, RegLocation rl_method) OVERRIDE;
Dmitry Petrochenko58994cd2014-05-17 01:02:18 +0700347
Vladimir Markof4da6752014-08-01 19:04:18 +0100348 NextCallInsn GetNextSDCallInsn() OVERRIDE;
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700349 int GenDalvikArgsNoRange(CallInfo* info, int call_state, LIR** pcrLabel,
Dmitry Petrochenko58994cd2014-05-17 01:02:18 +0700350 NextCallInsn next_call_insn,
351 const MethodReference& target_method,
352 uint32_t vtable_idx,
353 uintptr_t direct_code, uintptr_t direct_method, InvokeType type,
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700354 bool skip_this) OVERRIDE;
Dmitry Petrochenko58994cd2014-05-17 01:02:18 +0700355
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700356 int GenDalvikArgsRange(CallInfo* info, int call_state, LIR** pcrLabel,
357 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;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800362
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700363 /*
364 * @brief Generate a relative call to the method that will be patched at link time.
365 * @param target_method The MethodReference of the method to be invoked.
366 * @param type How the method will be invoked.
367 * @returns Call instruction
368 */
Vladimir Markof4da6752014-08-01 19:04:18 +0100369 LIR* CallWithLinkerFixup(const MethodReference& target_method, InvokeType type);
370
371 /*
372 * @brief Generate the actual call insn based on the method info.
373 * @param method_info the lowering info for the method call.
374 * @returns Call instruction
375 */
376 LIR* GenCallInsn(const MirMethodLoweringInfo& method_info) OVERRIDE;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800377
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700378 /*
379 * @brief Handle x86 specific literals
380 */
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700381 void InstallLiteralPools() OVERRIDE;
Mark Mendellae9fd932014-02-10 16:14:35 -0800382
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700383 /*
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700384 * @brief Generate the debug_frame FDE information.
385 * @returns pointer to vector containing CFE information
386 */
Tong Shen547cdfd2014-08-05 01:54:19 -0700387 std::vector<uint8_t>* ReturnFrameDescriptionEntry() OVERRIDE;
Razvan A Lupusorubd288c22013-12-20 17:27:23 -0800388
Andreas Gampe98430592014-07-27 19:44:50 -0700389 LIR* InvokeTrampoline(OpKind op, RegStorage r_tgt, QuickEntrypointEnum trampoline) OVERRIDE;
390
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700391 protected:
Ian Rogersb28c1c02014-11-08 11:21:21 -0800392 RegStorage TargetReg32(SpecialTargetRegister reg) const;
Chao-ying Fua77ee512014-07-01 17:43:41 -0700393 // Casting of RegStorage
394 RegStorage As32BitReg(RegStorage reg) {
395 DCHECK(!reg.IsPair());
396 if ((kFailOnSizeError || kReportSizeError) && !reg.Is64Bit()) {
397 if (kFailOnSizeError) {
398 LOG(FATAL) << "Expected 64b register " << reg.GetReg();
399 } else {
400 LOG(WARNING) << "Expected 64b register " << reg.GetReg();
401 return reg;
402 }
403 }
404 RegStorage ret_val = RegStorage(RegStorage::k32BitSolo,
405 reg.GetRawBits() & RegStorage::kRegTypeMask);
406 DCHECK_EQ(GetRegInfo(reg)->FindMatchingView(RegisterInfo::k32SoloStorageMask)
407 ->GetReg().GetReg(),
408 ret_val.GetReg());
409 return ret_val;
410 }
411
412 RegStorage As64BitReg(RegStorage reg) {
413 DCHECK(!reg.IsPair());
414 if ((kFailOnSizeError || kReportSizeError) && !reg.Is32Bit()) {
415 if (kFailOnSizeError) {
416 LOG(FATAL) << "Expected 32b register " << reg.GetReg();
417 } else {
418 LOG(WARNING) << "Expected 32b register " << reg.GetReg();
419 return reg;
420 }
421 }
422 RegStorage ret_val = RegStorage(RegStorage::k64BitSolo,
423 reg.GetRawBits() & RegStorage::kRegTypeMask);
424 DCHECK_EQ(GetRegInfo(reg)->FindMatchingView(RegisterInfo::k64SoloStorageMask)
425 ->GetReg().GetReg(),
426 ret_val.GetReg());
427 return ret_val;
428 }
429
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700430 LIR* LoadBaseIndexedDisp(RegStorage r_base, RegStorage r_index, int scale, int displacement,
431 RegStorage r_dest, OpSize size);
432 LIR* StoreBaseIndexedDisp(RegStorage r_base, RegStorage r_index, int scale, int displacement,
Jean Christophe Beylerb5bce7c2014-07-25 12:32:18 -0700433 RegStorage r_src, OpSize size, int opt_flags = 0);
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700434
Ian Rogersb28c1c02014-11-08 11:21:21 -0800435 RegStorage GetCoreArgMappingToPhysicalReg(int core_arg_num) const;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700436
437 int AssignInsnOffsets();
438 void AssignOffsets();
439 AssemblerStatus AssembleInstructions(CodeOffset start_addr);
440
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700441 size_t ComputeSize(const X86EncodingMap* entry, int32_t raw_reg, int32_t raw_index,
Ian Rogers5aa6e042014-06-13 16:38:24 -0700442 int32_t raw_base, int32_t displacement);
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700443 void CheckValidByteRegister(const X86EncodingMap* entry, int32_t raw_reg);
444 void EmitPrefix(const X86EncodingMap* entry,
Ian Rogers5aa6e042014-06-13 16:38:24 -0700445 int32_t raw_reg_r, int32_t raw_reg_x, int32_t raw_reg_b);
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700446 void EmitOpcode(const X86EncodingMap* entry);
447 void EmitPrefixAndOpcode(const X86EncodingMap* entry,
Ian Rogers5aa6e042014-06-13 16:38:24 -0700448 int32_t reg_r, int32_t reg_x, int32_t reg_b);
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700449 void EmitDisp(uint8_t base, int32_t disp);
450 void EmitModrmThread(uint8_t reg_or_opcode);
451 void EmitModrmDisp(uint8_t reg_or_opcode, uint8_t base, int32_t disp);
452 void EmitModrmSibDisp(uint8_t reg_or_opcode, uint8_t base, uint8_t index, int scale,
453 int32_t disp);
454 void EmitImm(const X86EncodingMap* entry, int64_t imm);
455 void EmitNullary(const X86EncodingMap* entry);
456 void EmitOpRegOpcode(const X86EncodingMap* entry, int32_t raw_reg);
457 void EmitOpReg(const X86EncodingMap* entry, int32_t raw_reg);
458 void EmitOpMem(const X86EncodingMap* entry, int32_t raw_base, int32_t disp);
459 void EmitOpArray(const X86EncodingMap* entry, int32_t raw_base, int32_t raw_index, int scale,
460 int32_t disp);
461 void EmitMemReg(const X86EncodingMap* entry, int32_t raw_base, int32_t disp, int32_t raw_reg);
462 void EmitRegMem(const X86EncodingMap* entry, int32_t raw_reg, int32_t raw_base, int32_t disp);
463 void EmitRegArray(const X86EncodingMap* entry, int32_t raw_reg, int32_t raw_base,
464 int32_t raw_index, int scale, int32_t disp);
465 void EmitArrayReg(const X86EncodingMap* entry, int32_t raw_base, int32_t raw_index, int scale,
466 int32_t disp, int32_t raw_reg);
467 void EmitMemImm(const X86EncodingMap* entry, int32_t raw_base, int32_t disp, int32_t imm);
468 void EmitArrayImm(const X86EncodingMap* entry, int32_t raw_base, int32_t raw_index, int scale,
469 int32_t raw_disp, int32_t imm);
470 void EmitRegThread(const X86EncodingMap* entry, int32_t raw_reg, int32_t disp);
471 void EmitRegReg(const X86EncodingMap* entry, int32_t raw_reg1, int32_t raw_reg2);
472 void EmitRegRegImm(const X86EncodingMap* entry, int32_t raw_reg1, int32_t raw_reg2, int32_t imm);
473 void EmitRegMemImm(const X86EncodingMap* entry, int32_t raw_reg1, int32_t raw_base, int32_t disp,
474 int32_t imm);
475 void EmitMemRegImm(const X86EncodingMap* entry, int32_t base, int32_t disp, int32_t raw_reg1,
476 int32_t imm);
477 void EmitRegImm(const X86EncodingMap* entry, int32_t raw_reg, int32_t imm);
478 void EmitThreadImm(const X86EncodingMap* entry, int32_t disp, int32_t imm);
479 void EmitMovRegImm(const X86EncodingMap* entry, int32_t raw_reg, int64_t imm);
480 void EmitShiftRegImm(const X86EncodingMap* entry, int32_t raw_reg, int32_t imm);
481 void EmitShiftRegCl(const X86EncodingMap* entry, int32_t raw_reg, int32_t raw_cl);
482 void EmitShiftMemCl(const X86EncodingMap* entry, int32_t raw_base, int32_t disp, int32_t raw_cl);
Yixin Shouf40f8902014-08-14 14:10:32 -0400483 void EmitShiftRegRegCl(const X86EncodingMap* entry, int32_t raw_reg1, int32_t raw_reg2,
484 int32_t raw_cl);
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700485 void EmitShiftMemImm(const X86EncodingMap* entry, int32_t raw_base, int32_t disp, int32_t imm);
486 void EmitRegCond(const X86EncodingMap* entry, int32_t raw_reg, int32_t cc);
487 void EmitMemCond(const X86EncodingMap* entry, int32_t raw_base, int32_t disp, int32_t cc);
488 void EmitRegRegCond(const X86EncodingMap* entry, int32_t raw_reg1, int32_t raw_reg2, int32_t cc);
489 void EmitRegMemCond(const X86EncodingMap* entry, int32_t raw_reg1, int32_t raw_base, int32_t disp,
490 int32_t cc);
Razvan A Lupusorubd288c22013-12-20 17:27:23 -0800491
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700492 void EmitJmp(const X86EncodingMap* entry, int32_t rel);
493 void EmitJcc(const X86EncodingMap* entry, int32_t rel, int32_t cc);
494 void EmitCallMem(const X86EncodingMap* entry, int32_t raw_base, int32_t disp);
495 void EmitCallImmediate(const X86EncodingMap* entry, int32_t disp);
496 void EmitCallThread(const X86EncodingMap* entry, int32_t disp);
497 void EmitPcRel(const X86EncodingMap* entry, int32_t raw_reg, int32_t raw_base_or_table,
498 int32_t raw_index, int scale, int32_t table_or_disp);
499 void EmitMacro(const X86EncodingMap* entry, int32_t raw_reg, int32_t offset);
500 void EmitUnimplemented(const X86EncodingMap* entry, LIR* lir);
501 void GenFusedLongCmpImmBranch(BasicBlock* bb, RegLocation rl_src1,
502 int64_t val, ConditionCode ccode);
503 void GenConstWide(RegLocation rl_dest, int64_t value);
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700504 void GenMultiplyVectorSignedByte(RegStorage rs_dest_src1, RegStorage rs_src2);
505 void GenMultiplyVectorLong(RegStorage rs_dest_src1, RegStorage rs_src2);
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700506 void GenShiftByteVector(MIR* mir);
Yixin Shouf40f8902014-08-14 14:10:32 -0400507 void AndMaskVectorRegister(RegStorage rs_src1, uint32_t m1, uint32_t m2, uint32_t m3,
508 uint32_t m4);
509 void MaskVectorRegister(X86OpCode opcode, RegStorage rs_src1, uint32_t m1, uint32_t m2,
510 uint32_t m3, uint32_t m4);
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700511 void AppendOpcodeWithConst(X86OpCode opcode, int reg, MIR* mir);
Mark Mendell0a1174e2014-09-11 14:51:02 -0400512 virtual void LoadVectorRegister(RegStorage rs_dest, RegStorage rs_src, OpSize opsize,
513 int op_mov);
Mark Mendell2637f2e2014-04-30 10:10:47 -0400514
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700515 static bool ProvidesFullMemoryBarrier(X86OpCode opcode);
Mark Mendelle02d48f2014-01-15 11:19:23 -0800516
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700517 /*
518 * @brief Ensure that a temporary register is byte addressable.
519 * @returns a temporary guarenteed to be byte addressable.
520 */
521 virtual RegStorage AllocateByteRegister();
Razvan A Lupusoru99ad7232014-02-25 17:41:08 -0800522
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700523 /*
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700524 * @brief Use a wide temporary as a 128-bit register
525 * @returns a 128-bit temporary register.
526 */
527 virtual RegStorage Get128BitRegister(RegStorage reg);
528
529 /*
Chao-ying Fu7e399fd2014-06-10 18:11:11 -0700530 * @brief Check if a register is byte addressable.
531 * @returns true if a register is byte addressable.
532 */
Ian Rogersb28c1c02014-11-08 11:21:21 -0800533 bool IsByteRegister(RegStorage reg) const;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700534
535 void GenDivRemLongLit(RegLocation rl_dest, RegLocation rl_src, int64_t imm, bool is_div);
536
DaniilSokolov70c4f062014-06-24 17:34:00 -0700537 bool GenInlinedArrayCopyCharArray(CallInfo* info) OVERRIDE;
Chao-ying Fu7e399fd2014-06-10 18:11:11 -0700538
539 /*
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700540 * @brief generate inline code for fast case of Strng.indexOf.
541 * @param info Call parameters
542 * @param zero_based 'true' if the index into the string is 0.
543 * @returns 'true' if the call was inlined, 'false' if a regular call needs to be
544 * generated.
545 */
546 bool GenInlinedIndexOf(CallInfo* info, bool zero_based);
Mark Mendelle87f9b52014-04-30 14:13:18 -0400547
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700548 /**
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700549 * @brief Used to reserve a range of vector registers.
550 * @see kMirOpReserveVectorRegisters
551 * @param mir The extended MIR for reservation.
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700552 */
553 void ReserveVectorRegisters(MIR* mir);
554
555 /**
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700556 * @brief Used to return a range of vector registers.
557 * @see kMirOpReturnVectorRegisters
558 * @param mir The extended MIR for returning vector regs.
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700559 */
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700560 void ReturnVectorRegisters(MIR* mir);
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700561
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700562 /*
563 * @brief Load 128 bit constant into vector register.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700564 * @param mir The MIR whose opcode is kMirConstVector
565 * @note vA is the TypeSize for the register.
566 * @note vB is the destination XMM register. arg[0..3] are 32 bit constant values.
567 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700568 void GenConst128(MIR* mir);
Mark Mendell4028a6c2014-02-19 20:06:20 -0800569
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700570 /*
571 * @brief MIR to move a vectorized register to another.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700572 * @param mir The MIR whose opcode is kMirConstVector.
573 * @note vA: TypeSize
574 * @note vB: destination
575 * @note vC: source
576 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700577 void GenMoveVector(MIR* mir);
Mark Mendelld65c51a2014-04-29 16:55:20 -0400578
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700579 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400580 * @brief Packed multiply of units in two vector registers: vB = vB .* @note vC using vA to know
581 * the type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700582 * @param mir The MIR whose opcode is kMirConstVector.
583 * @note vA: TypeSize
584 * @note vB: destination and source
585 * @note vC: source
586 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700587 void GenMultiplyVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400588
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700589 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400590 * @brief Packed addition of units in two vector registers: vB = vB .+ vC using vA to know the
591 * type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700592 * @param mir The MIR whose opcode is kMirConstVector.
593 * @note vA: TypeSize
594 * @note vB: destination and source
595 * @note vC: source
596 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700597 void GenAddVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400598
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700599 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400600 * @brief Packed subtraction of units in two vector registers: vB = vB .- vC using vA to know the
601 * type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700602 * @param mir The MIR whose opcode is kMirConstVector.
603 * @note vA: TypeSize
604 * @note vB: destination and source
605 * @note vC: source
606 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700607 void GenSubtractVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400608
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700609 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400610 * @brief Packed shift left of units in two vector registers: vB = vB .<< vC using vA to know the
611 * type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700612 * @param mir The MIR whose opcode is kMirConstVector.
613 * @note vA: TypeSize
614 * @note vB: destination and source
615 * @note vC: immediate
616 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700617 void GenShiftLeftVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400618
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700619 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400620 * @brief Packed signed shift right of units in two vector registers: vB = vB .>> vC using vA to
621 * know the type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700622 * @param mir The MIR whose opcode is kMirConstVector.
623 * @note vA: TypeSize
624 * @note vB: destination and source
625 * @note vC: immediate
626 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700627 void GenSignedShiftRightVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400628
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700629 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400630 * @brief Packed unsigned shift right of units in two vector registers: vB = vB .>>> vC using vA
631 * to know the type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700632 * @param mir The MIR whose opcode is kMirConstVector.
633 * @note vA: TypeSize
634 * @note vB: destination and source
635 * @note vC: immediate
636 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700637 void GenUnsignedShiftRightVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400638
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700639 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400640 * @brief Packed bitwise and of units in two vector registers: vB = vB .& vC using vA to know the
641 * type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700642 * @note vA: TypeSize
643 * @note vB: destination and source
644 * @note vC: source
645 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700646 void GenAndVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400647
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700648 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400649 * @brief Packed bitwise or of units in two vector registers: vB = vB .| vC using vA to know the
650 * type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700651 * @param mir The MIR whose opcode is kMirConstVector.
652 * @note vA: TypeSize
653 * @note vB: destination and source
654 * @note vC: source
655 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700656 void GenOrVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400657
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700658 /*
Yixin Shouf40f8902014-08-14 14:10:32 -0400659 * @brief Packed bitwise xor of units in two vector registers: vB = vB .^ vC using vA to know the
660 * type of the vector.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700661 * @param mir The MIR whose opcode is kMirConstVector.
662 * @note vA: TypeSize
663 * @note vB: destination and source
664 * @note vC: source
665 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700666 void GenXorVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400667
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700668 /*
669 * @brief Reduce a 128-bit packed element into a single VR by taking lower bits
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700670 * @param mir The MIR whose opcode is kMirConstVector.
671 * @details Instruction does a horizontal addition of the packed elements and then adds it to VR.
672 * @note vA: TypeSize
673 * @note vB: destination and source VR (not vector register)
674 * @note vC: source (vector register)
675 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700676 void GenAddReduceVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400677
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700678 /*
679 * @brief Extract a packed element into a single VR.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700680 * @param mir The MIR whose opcode is kMirConstVector.
681 * @note vA: TypeSize
682 * @note vB: destination VR (not vector register)
683 * @note vC: source (vector register)
684 * @note arg[0]: The index to use for extraction from vector register (which packed element).
685 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700686 void GenReduceVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400687
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700688 /*
689 * @brief Create a vector value, with all TypeSize values equal to vC
690 * @param bb The basic block in which the MIR is from.
691 * @param mir The MIR whose opcode is kMirConstVector.
692 * @note vA: TypeSize.
693 * @note vB: destination vector register.
694 * @note vC: source VR (not vector register).
695 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700696 void GenSetVector(MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400697
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700698 /**
699 * @brief Used to generate code for kMirOpPackedArrayGet.
700 * @param bb The basic block of MIR.
701 * @param mir The mir whose opcode is kMirOpPackedArrayGet.
702 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700703 void GenPackedArrayGet(BasicBlock* bb, MIR* mir);
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700704
705 /**
706 * @brief Used to generate code for kMirOpPackedArrayPut.
707 * @param bb The basic block of MIR.
708 * @param mir The mir whose opcode is kMirOpPackedArrayPut.
709 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700710 void GenPackedArrayPut(BasicBlock* bb, MIR* mir);
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700711
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700712 /*
713 * @brief Generate code for a vector opcode.
714 * @param bb The basic block in which the MIR is from.
715 * @param mir The MIR whose opcode is a non-standard opcode.
716 */
717 void GenMachineSpecificExtendedMethodMIR(BasicBlock* bb, MIR* mir);
Mark Mendellfe945782014-05-22 09:52:36 -0400718
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700719 /*
720 * @brief Return the correct x86 opcode for the Dex operation
721 * @param op Dex opcode for the operation
722 * @param loc Register location of the operand
723 * @param is_high_op 'true' if this is an operation on the high word
724 * @param value Immediate value for the operation. Used for byte variants
725 * @returns the correct x86 opcode to perform the operation
726 */
727 X86OpCode GetOpcode(Instruction::Code op, RegLocation loc, bool is_high_op, int32_t value);
Mark Mendelld65c51a2014-04-29 16:55:20 -0400728
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700729 /*
730 * @brief Return the correct x86 opcode for the Dex operation
731 * @param op Dex opcode for the operation
732 * @param dest location of the destination. May be register or memory.
733 * @param rhs Location for the rhs of the operation. May be in register or memory.
734 * @param is_high_op 'true' if this is an operation on the high word
735 * @returns the correct x86 opcode to perform the operation
736 * @note at most one location may refer to memory
737 */
738 X86OpCode GetOpcode(Instruction::Code op, RegLocation dest, RegLocation rhs,
739 bool is_high_op);
Mark Mendelle02d48f2014-01-15 11:19:23 -0800740
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700741 /*
742 * @brief Is this operation a no-op for this opcode and value
743 * @param op Dex opcode for the operation
744 * @param value Immediate value for the operation.
745 * @returns 'true' if the operation will have no effect
746 */
747 bool IsNoOp(Instruction::Code op, int32_t value);
Mark Mendelle02d48f2014-01-15 11:19:23 -0800748
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700749 /**
750 * @brief Calculate magic number and shift for a given divisor
751 * @param divisor divisor number for calculation
752 * @param magic hold calculated magic number
753 * @param shift hold calculated shift
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700754 * @param is_long 'true' if divisor is jlong, 'false' for jint.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700755 */
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700756 void CalculateMagicAndShift(int64_t divisor, int64_t& magic, int& shift, bool is_long);
Mark Mendelle02d48f2014-01-15 11:19:23 -0800757
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700758 /*
759 * @brief Generate an integer div or rem operation.
760 * @param rl_dest Destination Location.
761 * @param rl_src1 Numerator Location.
762 * @param rl_src2 Divisor Location.
763 * @param is_div 'true' if this is a division, 'false' for a remainder.
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700764 * @param flags The instruction optimization flags. It can include information
765 * if exception check can be elided.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700766 */
767 RegLocation GenDivRem(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2,
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700768 bool is_div, int flags);
Mark Mendell2bf31e62014-01-23 12:13:40 -0800769
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700770 /*
771 * @brief Generate an integer div or rem operation by a literal.
772 * @param rl_dest Destination Location.
773 * @param rl_src Numerator Location.
774 * @param lit Divisor.
775 * @param is_div 'true' if this is a division, 'false' for a remainder.
776 */
777 RegLocation GenDivRemLit(RegLocation rl_dest, RegLocation rl_src, int lit, bool is_div);
Mark Mendell2bf31e62014-01-23 12:13:40 -0800778
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700779 /*
780 * Generate code to implement long shift operations.
781 * @param opcode The DEX opcode to specify the shift type.
782 * @param rl_dest The destination.
783 * @param rl_src The value to be shifted.
784 * @param shift_amount How much to shift.
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700785 * @param flags The instruction optimization flags.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700786 * @returns the RegLocation of the result.
787 */
788 RegLocation GenShiftImmOpLong(Instruction::Code opcode, RegLocation rl_dest,
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700789 RegLocation rl_src, int shift_amount, int flags);
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700790 /*
791 * Generate an imul of a register by a constant or a better sequence.
792 * @param dest Destination Register.
793 * @param src Source Register.
794 * @param val Constant multiplier.
795 */
796 void GenImulRegImm(RegStorage dest, RegStorage src, int val);
Mark Mendell4708dcd2014-01-22 09:05:18 -0800797
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700798 /*
799 * Generate an imul of a memory location by a constant or a better sequence.
800 * @param dest Destination Register.
801 * @param sreg Symbolic register.
802 * @param displacement Displacement on stack of Symbolic Register.
803 * @param val Constant multiplier.
804 */
805 void GenImulMemImm(RegStorage dest, int sreg, int displacement, int val);
Mark Mendellfeb2b4e2014-01-28 12:59:49 -0800806
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700807 /*
808 * @brief Compare memory to immediate, and branch if condition true.
809 * @param cond The condition code that when true will branch to the target.
810 * @param temp_reg A temporary register that can be used if compare memory is not
811 * supported by the architecture.
812 * @param base_reg The register holding the base address.
813 * @param offset The offset from the base.
814 * @param check_value The immediate to compare to.
Dave Allison69dfe512014-07-11 17:11:58 +0000815 * @param target branch target (or nullptr)
816 * @param compare output for getting LIR for comparison (or nullptr)
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700817 */
818 LIR* OpCmpMemImmBranch(ConditionCode cond, RegStorage temp_reg, RegStorage base_reg,
Dave Allison69dfe512014-07-11 17:11:58 +0000819 int offset, int check_value, LIR* target, LIR** compare);
Mark Mendell766e9292014-01-27 07:55:47 -0800820
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700821 void GenRemFP(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2, bool is_double);
822
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700823 /*
824 * Can this operation be using core registers without temporaries?
825 * @param rl_lhs Left hand operand.
826 * @param rl_rhs Right hand operand.
827 * @returns 'true' if the operation can proceed without needing temporary regs.
828 */
829 bool IsOperationSafeWithoutTemps(RegLocation rl_lhs, RegLocation rl_rhs);
Razvan A Lupusoru614c2b42014-01-28 17:05:21 -0800830
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700831 /**
832 * @brief Generates inline code for conversion of long to FP by using x87/
833 * @param rl_dest The destination of the FP.
834 * @param rl_src The source of the long.
835 * @param is_double 'true' if dealing with double, 'false' for float.
836 */
837 virtual void GenLongToFP(RegLocation rl_dest, RegLocation rl_src, bool is_double);
Mark Mendell67c39c42014-01-31 17:28:00 -0800838
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700839 void GenArrayBoundsCheck(RegStorage index, RegStorage array_base, int32_t len_offset);
840 void GenArrayBoundsCheck(int32_t index, RegStorage array_base, int32_t len_offset);
841
842 LIR* OpRegMem(OpKind op, RegStorage r_dest, RegStorage r_base, int offset);
843 LIR* OpRegMem(OpKind op, RegStorage r_dest, RegLocation value);
844 LIR* OpMemReg(OpKind op, RegLocation rl_dest, int value);
845 LIR* OpThreadMem(OpKind op, ThreadOffset<4> thread_offset);
846 LIR* OpThreadMem(OpKind op, ThreadOffset<8> thread_offset);
847 void OpRegThreadMem(OpKind op, RegStorage r_dest, ThreadOffset<4> thread_offset);
848 void OpRegThreadMem(OpKind op, RegStorage r_dest, ThreadOffset<8> thread_offset);
849 void OpTlsCmp(ThreadOffset<4> offset, int val);
850 void OpTlsCmp(ThreadOffset<8> offset, int val);
851
852 void OpLea(RegStorage r_base, RegStorage reg1, RegStorage reg2, int scale, int offset);
853
Andreas Gampec76c6142014-08-04 16:30:03 -0700854 // Try to do a long multiplication where rl_src2 is a constant. This simplified setup might fail,
855 // in which case false will be returned.
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700856 bool GenMulLongConst(RegLocation rl_dest, RegLocation rl_src1, int64_t val, int flags);
Andreas Gampec76c6142014-08-04 16:30:03 -0700857 void GenMulLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700858 RegLocation rl_src2, int flags);
Andreas Gampec76c6142014-08-04 16:30:03 -0700859 void GenNotLong(RegLocation rl_dest, RegLocation rl_src);
860 void GenNegLong(RegLocation rl_dest, RegLocation rl_src);
861 void GenDivRemLong(Instruction::Code, RegLocation rl_dest, RegLocation rl_src1,
Razvan A Lupusoru5c5676b2014-09-29 16:42:11 -0700862 RegLocation rl_src2, bool is_div, int flags);
Andreas Gampec76c6142014-08-04 16:30:03 -0700863
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700864 void SpillCoreRegs();
865 void UnSpillCoreRegs();
866 void UnSpillFPRegs();
867 void SpillFPRegs();
868
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700869 /*
870 * @brief Perform MIR analysis before compiling method.
871 * @note Invokes Mir2LiR::Materialize after analysis.
872 */
873 void Materialize();
Razvan A Lupusoru614c2b42014-01-28 17:05:21 -0800874
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700875 /*
876 * Mir2Lir's UpdateLoc() looks to see if the Dalvik value is currently live in any temp register
877 * without regard to data type. In practice, this can result in UpdateLoc returning a
878 * location record for a Dalvik float value in a core register, and vis-versa. For targets
879 * which can inexpensively move data between core and float registers, this can often be a win.
880 * However, for x86 this is generally not a win. These variants of UpdateLoc()
881 * take a register class argument - and will return an in-register location record only if
882 * the value is live in a temp register of the correct class. Additionally, if the value is in
883 * a temp register of the wrong register class, it will be clobbered.
884 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700885 RegLocation UpdateLocTyped(RegLocation loc);
886 RegLocation UpdateLocWideTyped(RegLocation loc);
Mark Mendell67c39c42014-01-31 17:28:00 -0800887
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700888 /*
889 * @brief Analyze MIR before generating code, to prepare for the code generation.
890 */
891 void AnalyzeMIR();
buzbee30adc732014-05-09 15:10:18 -0700892
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700893 /*
894 * @brief Analyze one basic block.
895 * @param bb Basic block to analyze.
896 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700897 void AnalyzeBB(BasicBlock* bb);
Mark Mendell67c39c42014-01-31 17:28:00 -0800898
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700899 /*
900 * @brief Analyze one extended MIR instruction
901 * @param opcode MIR instruction opcode.
902 * @param bb Basic block containing instruction.
903 * @param mir Extended instruction to analyze.
904 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700905 void AnalyzeExtendedMIR(int opcode, BasicBlock* bb, MIR* mir);
Mark Mendell67c39c42014-01-31 17:28:00 -0800906
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700907 /*
908 * @brief Analyze one MIR instruction
909 * @param opcode MIR instruction opcode.
910 * @param bb Basic block containing instruction.
911 * @param mir Instruction to analyze.
912 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700913 virtual void AnalyzeMIR(int opcode, BasicBlock* bb, MIR* mir);
Mark Mendell67c39c42014-01-31 17:28:00 -0800914
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700915 /*
916 * @brief Analyze one MIR float/double instruction
917 * @param opcode MIR instruction opcode.
918 * @param bb Basic block containing instruction.
919 * @param mir Instruction to analyze.
920 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700921 virtual void AnalyzeFPInstruction(int opcode, BasicBlock* bb, MIR* mir);
Mark Mendell67c39c42014-01-31 17:28:00 -0800922
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700923 /*
924 * @brief Analyze one use of a double operand.
925 * @param rl_use Double RegLocation for the operand.
926 */
927 void AnalyzeDoubleUse(RegLocation rl_use);
Mark Mendell67c39c42014-01-31 17:28:00 -0800928
Yixin Shou7071c8d2014-03-05 06:07:48 -0500929 /*
930 * @brief Analyze one invoke-static MIR instruction
931 * @param opcode MIR instruction opcode.
932 * @param bb Basic block containing instruction.
933 * @param mir Instruction to analyze.
934 */
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700935 void AnalyzeInvokeStatic(int opcode, BasicBlock* bb, MIR* mir);
Yixin Shou7071c8d2014-03-05 06:07:48 -0500936
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700937 // Information derived from analysis of MIR
Dmitry Petrochenko9ee801f2014-05-12 11:31:37 +0700938
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700939 // The compiler temporary for the code address of the method.
940 CompilerTemp *base_of_code_;
Mark Mendell67c39c42014-01-31 17:28:00 -0800941
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700942 // Have we decided to compute a ptr to code and store in temporary VR?
943 bool store_method_addr_;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800944
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700945 // Have we used the stored method address?
946 bool store_method_addr_used_;
Mark Mendell67c39c42014-01-31 17:28:00 -0800947
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700948 // Instructions to remove if we didn't use the stored method address.
949 LIR* setup_method_address_[2];
Mark Mendell55d0eac2014-02-06 11:02:52 -0800950
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700951 // Instructions needing patching with Method* values.
Vladimir Markoe39c54e2014-09-22 14:50:02 +0100952 ArenaVector<LIR*> method_address_insns_;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800953
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700954 // Instructions needing patching with Class Type* values.
Vladimir Markoe39c54e2014-09-22 14:50:02 +0100955 ArenaVector<LIR*> class_type_address_insns_;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800956
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700957 // Instructions needing patching with PC relative code addresses.
Vladimir Markoe39c54e2014-09-22 14:50:02 +0100958 ArenaVector<LIR*> call_method_insns_;
Mark Mendell55d0eac2014-02-06 11:02:52 -0800959
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700960 // Prologue decrement of stack pointer.
961 LIR* stack_decrement_;
Mark Mendellae9fd932014-02-10 16:14:35 -0800962
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700963 // Epilogue increment of stack pointer.
964 LIR* stack_increment_;
Mark Mendellae9fd932014-02-10 16:14:35 -0800965
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700966 // The list of const vector literals.
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700967 LIR* const_vectors_;
Mark Mendelld65c51a2014-04-29 16:55:20 -0400968
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700969 /*
970 * @brief Search for a matching vector literal
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700971 * @param constants An array of size 4 which contains all of 32-bit constants.
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700972 * @returns pointer to matching LIR constant, or nullptr if not found.
973 */
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700974 LIR* ScanVectorLiteral(int32_t* constants);
Mark Mendelld65c51a2014-04-29 16:55:20 -0400975
Ian Rogers0f9b9c52014-06-09 01:32:12 -0700976 /*
977 * @brief Add a constant 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 */
Lupusoru, Razvan Ab3a84e22014-07-28 14:11:01 -0700980 LIR* AddVectorLiteral(int32_t* constants);
Mark Mendelld65c51a2014-04-29 16:55:20 -0400981
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700982 bool WideGPRsAreAliases() const OVERRIDE {
Serguei Katkov59a42af2014-07-05 00:55:46 +0700983 return cu_->target64; // On 64b, we have 64b GPRs.
984 }
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700985
986 bool WideFPRsAreAliases() const OVERRIDE {
Serguei Katkov59a42af2014-07-05 00:55:46 +0700987 return true; // xmm registers have 64b views even on x86.
988 }
989
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700990 /*
991 * @brief Dump a RegLocation using printf
992 * @param loc Register location to dump
993 */
994 static void DumpRegLocation(RegLocation loc);
995
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700996 InToRegStorageMapping in_to_reg_storage_mapping_;
Alexei Zavjalov6bbf0962014-07-15 02:19:41 +0700997
Udayan Banerji60bfe7b2014-07-08 19:59:43 -0700998 private:
Yixin Shou8c914c02014-07-28 14:17:09 -0400999 void SwapBits(RegStorage result_reg, int shift, int32_t value);
1000 void SwapBits64(RegStorage result_reg, int shift, int64_t value);
Ian Rogers6a3c1fc2014-10-31 00:33:20 -07001001
1002 static const X86EncodingMap EncodingMap[kX86Last];
1003
1004 friend std::ostream& operator<<(std::ostream& os, const X86OpCode& rhs);
1005
1006 DISALLOW_COPY_AND_ASSIGN(X86Mir2Lir);
Brian Carlstrom7940e442013-07-12 13:46:57 -07001007};
1008
1009} // namespace art
1010
Brian Carlstromfc0e3212013-07-17 14:40:12 -07001011#endif // ART_COMPILER_DEX_QUICK_X86_CODEGEN_X86_H_