blob: d66790d405b498c069f35499968f01e071c888b8 [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"
21#include "x86_lir.h"
22
23namespace art {
24
Mark Mendelle87f9b52014-04-30 14:13:18 -040025class X86Mir2Lir : public Mir2Lir {
Brian Carlstrom7940e442013-07-12 13:46:57 -070026 public:
Dmitry Petrochenko9ee801f2014-05-12 11:31:37 +070027 X86Mir2Lir(CompilationUnit* cu, MIRGraph* mir_graph, ArenaAllocator* arena, bool gen64bit);
Brian Carlstrom7940e442013-07-12 13:46:57 -070028
29 // Required for target - codegen helpers.
buzbee11b63d12013-08-27 07:34:17 -070030 bool SmallLiteralDivRem(Instruction::Code dalvik_opcode, bool is_div, RegLocation rl_src,
buzbee2700f7e2014-03-07 09:46:20 -080031 RegLocation rl_dest, int lit);
Ian Rogerse2143c02014-03-28 08:47:16 -070032 bool EasyMultiply(RegLocation rl_src, RegLocation rl_dest, int lit) OVERRIDE;
Dave Allisonb373e092014-02-20 16:06:36 -080033 LIR* CheckSuspendUsingLoad() OVERRIDE;
Andreas Gampe2f244e92014-05-08 03:35:25 -070034 RegStorage LoadHelper(ThreadOffset<4> offset) OVERRIDE;
35 RegStorage LoadHelper(ThreadOffset<8> offset) OVERRIDE;
Vladimir Marko674744e2014-04-24 15:18:26 +010036 LIR* LoadBaseDispVolatile(RegStorage r_base, int displacement, RegStorage r_dest,
37 OpSize size) OVERRIDE;
Vladimir Marko3bf7c602014-05-07 14:55:43 +010038 LIR* LoadBaseDisp(RegStorage r_base, int displacement, RegStorage r_dest,
39 OpSize size) OVERRIDE;
buzbee2700f7e2014-03-07 09:46:20 -080040 LIR* LoadBaseIndexed(RegStorage r_base, RegStorage r_index, RegStorage r_dest, int scale,
Vladimir Marko3bf7c602014-05-07 14:55:43 +010041 OpSize size) OVERRIDE;
buzbee2700f7e2014-03-07 09:46:20 -080042 LIR* LoadBaseIndexedDisp(RegStorage r_base, RegStorage r_index, int scale, int displacement,
Vladimir Marko3bf7c602014-05-07 14:55:43 +010043 RegStorage r_dest, OpSize size) OVERRIDE;
buzbee2700f7e2014-03-07 09:46:20 -080044 LIR* LoadConstantNoClobber(RegStorage r_dest, int value);
45 LIR* LoadConstantWide(RegStorage r_dest, int64_t value);
Vladimir Marko674744e2014-04-24 15:18:26 +010046 LIR* StoreBaseDispVolatile(RegStorage r_base, int displacement, RegStorage r_src,
47 OpSize size) OVERRIDE;
Vladimir Marko3bf7c602014-05-07 14:55:43 +010048 LIR* StoreBaseDisp(RegStorage r_base, int displacement, RegStorage r_src,
49 OpSize size) OVERRIDE;
buzbee2700f7e2014-03-07 09:46:20 -080050 LIR* StoreBaseIndexed(RegStorage r_base, RegStorage r_index, RegStorage r_src, int scale,
Vladimir Marko3bf7c602014-05-07 14:55:43 +010051 OpSize size) OVERRIDE;
buzbee2700f7e2014-03-07 09:46:20 -080052 LIR* StoreBaseIndexedDisp(RegStorage r_base, RegStorage r_index, int scale, int displacement,
Vladimir Marko3bf7c602014-05-07 14:55:43 +010053 RegStorage r_src, OpSize size) OVERRIDE;
buzbee2700f7e2014-03-07 09:46:20 -080054 void MarkGCCard(RegStorage val_reg, RegStorage tgt_addr_reg);
Brian Carlstrom7940e442013-07-12 13:46:57 -070055
56 // Required for target - register utilities.
buzbee2700f7e2014-03-07 09:46:20 -080057 RegStorage TargetReg(SpecialTargetRegister reg);
58 RegStorage GetArgMappingToPhysicalReg(int arg_num);
Brian Carlstrom7940e442013-07-12 13:46:57 -070059 RegLocation GetReturnAlt();
60 RegLocation GetReturnWideAlt();
61 RegLocation LocCReturn();
62 RegLocation LocCReturnDouble();
63 RegLocation LocCReturnFloat();
64 RegLocation LocCReturnWide();
buzbee091cc402014-03-31 10:14:40 -070065 uint64_t GetRegMaskCommon(RegStorage reg);
Brian Carlstrom7940e442013-07-12 13:46:57 -070066 void AdjustSpillMask();
Vladimir Marko31c2aac2013-12-09 16:31:19 +000067 void ClobberCallerSave();
Brian Carlstrom7940e442013-07-12 13:46:57 -070068 void FreeCallTemps();
Brian Carlstrom7940e442013-07-12 13:46:57 -070069 void LockCallTemps();
buzbee091cc402014-03-31 10:14:40 -070070 void MarkPreservedSingle(int v_reg, RegStorage reg);
71 void MarkPreservedDouble(int v_reg, RegStorage reg);
Brian Carlstrom7940e442013-07-12 13:46:57 -070072 void CompilerInitializeRegAlloc();
73
74 // Required for target - miscellaneous.
buzbeeb48819d2013-09-14 16:15:25 -070075 void AssembleLIR();
76 int AssignInsnOffsets();
77 void AssignOffsets();
buzbee0d829482013-10-11 15:24:55 -070078 AssemblerStatus AssembleInstructions(CodeOffset start_addr);
Brian Carlstrom7940e442013-07-12 13:46:57 -070079 void DumpResourceMask(LIR* lir, uint64_t mask, const char* prefix);
buzbeeb48819d2013-09-14 16:15:25 -070080 void SetupTargetResourceMasks(LIR* lir, uint64_t flags);
Brian Carlstrom7940e442013-07-12 13:46:57 -070081 const char* GetTargetInstFmt(int opcode);
82 const char* GetTargetInstName(int opcode);
83 std::string BuildInsnString(const char* fmt, LIR* lir, unsigned char* base_addr);
84 uint64_t GetPCUseDefEncoding();
85 uint64_t GetTargetInstFlags(int opcode);
86 int GetInsnSize(LIR* lir);
87 bool IsUnconditionalBranch(LIR* lir);
88
Vladimir Marko674744e2014-04-24 15:18:26 +010089 // Check support for volatile load/store of a given size.
90 bool SupportsVolatileLoadStore(OpSize size) OVERRIDE;
91 // Get the register class for load/store of a field.
92 RegisterClass RegClassForFieldLoadStore(OpSize size, bool is_volatile) OVERRIDE;
93
Brian Carlstrom7940e442013-07-12 13:46:57 -070094 // Required for target - Dalvik-level generators.
buzbee2700f7e2014-03-07 09:46:20 -080095 void GenArithImmOpLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
96 RegLocation rl_src2);
97 void GenArrayGet(int opt_flags, OpSize size, RegLocation rl_array, RegLocation rl_index,
98 RegLocation rl_dest, int scale);
Brian Carlstrom7940e442013-07-12 13:46:57 -070099 void GenArrayPut(int opt_flags, OpSize size, RegLocation rl_array,
Ian Rogersa9a82542013-10-04 11:17:26 -0700100 RegLocation rl_index, RegLocation rl_src, int scale, bool card_mark);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700101 void GenShiftImmOpLong(Instruction::Code opcode, RegLocation rl_dest,
Ian Rogersa9a82542013-10-04 11:17:26 -0700102 RegLocation rl_src1, RegLocation rl_shift);
buzbee2700f7e2014-03-07 09:46:20 -0800103 void GenMulLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
104 RegLocation rl_src2);
105 void GenAddLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
106 RegLocation rl_src2);
107 void GenAndLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
108 RegLocation rl_src2);
109 void GenArithOpDouble(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
Brian Carlstrom7940e442013-07-12 13:46:57 -0700110 RegLocation rl_src2);
buzbee2700f7e2014-03-07 09:46:20 -0800111 void GenArithOpFloat(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
112 RegLocation rl_src2);
113 void GenCmpFP(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
114 RegLocation rl_src2);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700115 void GenConversion(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src);
Vladimir Marko1c282e22013-11-21 14:49:47 +0000116 bool GenInlinedCas(CallInfo* info, bool is_long, bool is_object);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700117 bool GenInlinedMinMaxInt(CallInfo* info, bool is_min);
118 bool GenInlinedSqrt(CallInfo* info);
Vladimir Markoe508a202013-11-04 15:24:22 +0000119 bool GenInlinedPeek(CallInfo* info, OpSize size);
120 bool GenInlinedPoke(CallInfo* info, OpSize size);
Serban Constantinescued65c5e2014-05-22 15:10:18 +0100121 void GenNotLong(RegLocation rl_dest, RegLocation rl_src);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700122 void GenNegLong(RegLocation rl_dest, RegLocation rl_src);
buzbee2700f7e2014-03-07 09:46:20 -0800123 void GenOrLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
124 RegLocation rl_src2);
125 void GenSubLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
126 RegLocation rl_src2);
127 void GenXorLong(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_src1,
128 RegLocation rl_src2);
Serban Constantinescued65c5e2014-05-22 15:10:18 +0100129 void GenDivRemLong(Instruction::Code, RegLocation rl_dest, RegLocation rl_src1,
130 RegLocation rl_src2, bool is_div);
buzbee2700f7e2014-03-07 09:46:20 -0800131 // TODO: collapse reg_lo, reg_hi
132 RegLocation GenDivRem(RegLocation rl_dest, RegStorage reg_lo, RegStorage reg_hi, bool is_div);
133 RegLocation GenDivRemLit(RegLocation rl_dest, RegStorage reg_lo, int lit, bool is_div);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700134 void GenCmpLong(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2);
Mingyao Yange643a172014-04-08 11:02:52 -0700135 void GenDivZeroCheckWide(RegStorage reg);
Mingyao Yang80365d92014-04-18 12:10:58 -0700136 void GenArrayBoundsCheck(RegStorage index, RegStorage array_base, int32_t len_offset);
137 void GenArrayBoundsCheck(int32_t index, RegStorage array_base, int32_t len_offset);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700138 void GenEntrySequence(RegLocation* ArgLocs, RegLocation rl_method);
139 void GenExitSequence();
Razvan A Lupusoru3bc01742014-02-06 13:18:43 -0800140 void GenSpecialExitSequence();
buzbee0d829482013-10-11 15:24:55 -0700141 void GenFillArrayData(DexOffset table_offset, RegLocation rl_src);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700142 void GenFusedFPCmpBranch(BasicBlock* bb, MIR* mir, bool gt_bias, bool is_double);
143 void GenFusedLongCmpBranch(BasicBlock* bb, MIR* mir);
144 void GenSelect(BasicBlock* bb, MIR* mir);
Andreas Gampeb14329f2014-05-15 11:16:06 -0700145 bool GenMemBarrier(MemBarrierKind barrier_kind);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700146 void GenMoveException(RegLocation rl_dest);
buzbee2700f7e2014-03-07 09:46:20 -0800147 void GenMultiplyByTwoBitMultiplier(RegLocation rl_src, RegLocation rl_result, int lit,
148 int first_bit, int second_bit);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700149 void GenNegDouble(RegLocation rl_dest, RegLocation rl_src);
150 void GenNegFloat(RegLocation rl_dest, RegLocation rl_src);
buzbee0d829482013-10-11 15:24:55 -0700151 void GenPackedSwitch(MIR* mir, DexOffset table_offset, RegLocation rl_src);
152 void GenSparseSwitch(MIR* mir, DexOffset table_offset, RegLocation rl_src);
Razvan A Lupusoru3bc01742014-02-06 13:18:43 -0800153
Mark Mendelle02d48f2014-01-15 11:19:23 -0800154 /*
155 * @brief Generate a two address long operation with a constant value
156 * @param rl_dest location of result
157 * @param rl_src constant source operand
158 * @param op Opcode to be generated
159 */
160 void GenLongImm(RegLocation rl_dest, RegLocation rl_src, Instruction::Code op);
161 /*
162 * @brief Generate a three address long operation with a constant value
163 * @param rl_dest location of result
164 * @param rl_src1 source operand
165 * @param rl_src2 constant source operand
166 * @param op Opcode to be generated
167 */
buzbee2700f7e2014-03-07 09:46:20 -0800168 void GenLongLongImm(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2,
169 Instruction::Code op);
Mark Mendelle02d48f2014-01-15 11:19:23 -0800170
171 /**
172 * @brief Generate a long arithmetic operation.
173 * @param rl_dest The destination.
174 * @param rl_src1 First operand.
175 * @param rl_src2 Second operand.
176 * @param op The DEX opcode for the operation.
177 * @param is_commutative The sources can be swapped if needed.
178 */
Mark Mendelle87f9b52014-04-30 14:13:18 -0400179 virtual void GenLongArith(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2,
180 Instruction::Code op, bool is_commutative);
Mark Mendelle02d48f2014-01-15 11:19:23 -0800181
182 /**
183 * @brief Generate a two operand long arithmetic operation.
184 * @param rl_dest The destination.
185 * @param rl_src Second operand.
186 * @param op The DEX opcode for the operation.
187 */
188 void GenLongArith(RegLocation rl_dest, RegLocation rl_src, Instruction::Code op);
189
190 /**
191 * @brief Generate a long operation.
192 * @param rl_dest The destination. Must be in a register
193 * @param rl_src The other operand. May be in a register or in memory.
194 * @param op The DEX opcode for the operation.
195 */
Mark Mendelle87f9b52014-04-30 14:13:18 -0400196 virtual void GenLongRegOrMemOp(RegLocation rl_dest, RegLocation rl_src, Instruction::Code op);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700197
Mark Mendelldf8ee2e2014-01-27 16:37:47 -0800198 /**
199 * @brief Implement instanceof a final class with x86 specific code.
200 * @param use_declaring_class 'true' if we can use the class itself.
201 * @param type_idx Type index to use if use_declaring_class is 'false'.
202 * @param rl_dest Result to be set to 0 or 1.
203 * @param rl_src Object to be tested.
204 */
buzbee2700f7e2014-03-07 09:46:20 -0800205 void GenInstanceofFinal(bool use_declaring_class, uint32_t type_idx, RegLocation rl_dest,
206 RegLocation rl_src);
Mark Mendell6607d972014-02-10 06:54:18 -0800207 /*
208 *
209 * @brief Implement Set up instanceof a class with x86 specific code.
210 * @param needs_access_check 'true' if we must check the access.
211 * @param type_known_final 'true' if the type is known to be a final class.
212 * @param type_known_abstract 'true' if the type is known to be an abstract class.
213 * @param use_declaring_class 'true' if the type can be loaded off the current Method*.
214 * @param can_assume_type_is_in_dex_cache 'true' if the type is known to be in the cache.
215 * @param type_idx Type index to use if use_declaring_class is 'false'.
216 * @param rl_dest Result to be set to 0 or 1.
217 * @param rl_src Object to be tested.
218 */
219 void GenInstanceofCallingHelper(bool needs_access_check, bool type_known_final,
220 bool type_known_abstract, bool use_declaring_class,
221 bool can_assume_type_is_in_dex_cache,
buzbee2700f7e2014-03-07 09:46:20 -0800222 uint32_t type_idx, RegLocation rl_dest, RegLocation rl_src);
Mark Mendell6607d972014-02-10 06:54:18 -0800223
Brian Carlstrom7940e442013-07-12 13:46:57 -0700224 // Single operation generators.
225 LIR* OpUnconditionalBranch(LIR* target);
buzbee2700f7e2014-03-07 09:46:20 -0800226 LIR* OpCmpBranch(ConditionCode cond, RegStorage src1, RegStorage src2, LIR* target);
227 LIR* OpCmpImmBranch(ConditionCode cond, RegStorage reg, int check_value, LIR* target);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700228 LIR* OpCondBranch(ConditionCode cc, LIR* target);
buzbee2700f7e2014-03-07 09:46:20 -0800229 LIR* OpDecAndBranch(ConditionCode c_code, RegStorage reg, LIR* target);
230 LIR* OpFpRegCopy(RegStorage r_dest, RegStorage r_src);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700231 LIR* OpIT(ConditionCode cond, const char* guide);
Dave Allison3da67a52014-04-02 17:03:45 -0700232 void OpEndIT(LIR* it);
buzbee2700f7e2014-03-07 09:46:20 -0800233 LIR* OpMem(OpKind op, RegStorage r_base, int disp);
234 LIR* OpPcRelLoad(RegStorage reg, LIR* target);
235 LIR* OpReg(OpKind op, RegStorage r_dest_src);
buzbee7a11ab02014-04-28 20:02:38 -0700236 void OpRegCopy(RegStorage r_dest, RegStorage r_src);
buzbee2700f7e2014-03-07 09:46:20 -0800237 LIR* OpRegCopyNoInsert(RegStorage r_dest, RegStorage r_src);
238 LIR* OpRegImm(OpKind op, RegStorage r_dest_src1, int value);
239 LIR* OpRegMem(OpKind op, RegStorage r_dest, RegStorage r_base, int offset);
240 LIR* OpRegMem(OpKind op, RegStorage r_dest, RegLocation value);
Mark Mendellfeb2b4e2014-01-28 12:59:49 -0800241 LIR* OpMemReg(OpKind op, RegLocation rl_dest, int value);
buzbee2700f7e2014-03-07 09:46:20 -0800242 LIR* OpRegReg(OpKind op, RegStorage r_dest_src1, RegStorage r_src2);
243 LIR* OpMovRegMem(RegStorage r_dest, RegStorage r_base, int offset, MoveType move_type);
244 LIR* OpMovMemReg(RegStorage r_base, int offset, RegStorage r_src, MoveType move_type);
245 LIR* OpCondRegReg(OpKind op, ConditionCode cc, RegStorage r_dest, RegStorage r_src);
246 LIR* OpRegRegImm(OpKind op, RegStorage r_dest, RegStorage r_src1, int value);
247 LIR* OpRegRegReg(OpKind op, RegStorage r_dest, RegStorage r_src1, RegStorage r_src2);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700248 LIR* OpTestSuspend(LIR* target);
Andreas Gampe2f244e92014-05-08 03:35:25 -0700249 LIR* OpThreadMem(OpKind op, ThreadOffset<4> thread_offset) OVERRIDE;
250 LIR* OpThreadMem(OpKind op, ThreadOffset<8> thread_offset) OVERRIDE;
buzbee2700f7e2014-03-07 09:46:20 -0800251 LIR* OpVldm(RegStorage r_base, int count);
252 LIR* OpVstm(RegStorage r_base, int count);
253 void OpLea(RegStorage r_base, RegStorage reg1, RegStorage reg2, int scale, int offset);
254 void OpRegCopyWide(RegStorage dest, RegStorage src);
Andreas Gampe2f244e92014-05-08 03:35:25 -0700255 void OpTlsCmp(ThreadOffset<4> offset, int val) OVERRIDE;
256 void OpTlsCmp(ThreadOffset<8> offset, int val) OVERRIDE;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700257
buzbee091cc402014-03-31 10:14:40 -0700258 void OpRegThreadMem(OpKind op, RegStorage r_dest, ThreadOffset<4> thread_offset);
Andreas Gampe2f244e92014-05-08 03:35:25 -0700259 void OpRegThreadMem(OpKind op, RegStorage r_dest, ThreadOffset<8> thread_offset);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700260 void SpillCoreRegs();
261 void UnSpillCoreRegs();
262 static const X86EncodingMap EncodingMap[kX86Last];
263 bool InexpensiveConstantInt(int32_t value);
264 bool InexpensiveConstantFloat(int32_t value);
265 bool InexpensiveConstantLong(int64_t value);
266 bool InexpensiveConstantDouble(int64_t value);
267
Mark Mendellfeb2b4e2014-01-28 12:59:49 -0800268 /*
Mark Mendelle87f9b52014-04-30 14:13:18 -0400269 * @brief Should try to optimize for two address instructions?
270 * @return true if we try to avoid generating three operand instructions.
271 */
272 virtual bool GenerateTwoOperandInstructions() const { return true; }
273
274 /*
Mark Mendellfeb2b4e2014-01-28 12:59:49 -0800275 * @brief x86 specific codegen for int operations.
276 * @param opcode Operation to perform.
277 * @param rl_dest Destination for the result.
278 * @param rl_lhs Left hand operand.
279 * @param rl_rhs Right hand operand.
280 */
buzbee2700f7e2014-03-07 09:46:20 -0800281 void GenArithOpInt(Instruction::Code opcode, RegLocation rl_dest, RegLocation rl_lhs,
282 RegLocation rl_rhs);
Mark Mendellfeb2b4e2014-01-28 12:59:49 -0800283
Mark Mendell55d0eac2014-02-06 11:02:52 -0800284 /*
285 * @brief Dump a RegLocation using printf
286 * @param loc Register location to dump
287 */
288 static void DumpRegLocation(RegLocation loc);
289
290 /*
291 * @brief Load the Method* of a dex method into the register.
Jeff Hao49161ce2014-03-12 11:05:25 -0700292 * @param target_method The MethodReference of the method to be invoked.
Mark Mendell55d0eac2014-02-06 11:02:52 -0800293 * @param type How the method will be invoked.
294 * @param register that will contain the code address.
295 * @note register will be passed to TargetReg to get physical register.
296 */
Jeff Hao49161ce2014-03-12 11:05:25 -0700297 void LoadMethodAddress(const MethodReference& target_method, InvokeType type,
Mark Mendell55d0eac2014-02-06 11:02:52 -0800298 SpecialTargetRegister symbolic_reg);
299
300 /*
301 * @brief Load the Class* of a Dex Class type into the register.
302 * @param type How the method will be invoked.
303 * @param register that will contain the code address.
304 * @note register will be passed to TargetReg to get physical register.
305 */
306 void LoadClassType(uint32_t type_idx, SpecialTargetRegister symbolic_reg);
307
308 /*
309 * @brief Generate a relative call to the method that will be patched at link time.
Jeff Hao49161ce2014-03-12 11:05:25 -0700310 * @param target_method The MethodReference of the method to be invoked.
Mark Mendell55d0eac2014-02-06 11:02:52 -0800311 * @param type How the method will be invoked.
312 * @returns Call instruction
313 */
Mark Mendelle87f9b52014-04-30 14:13:18 -0400314 virtual LIR * CallWithLinkerFixup(const MethodReference& target_method, InvokeType type);
Mark Mendell55d0eac2014-02-06 11:02:52 -0800315
316 /*
317 * @brief Handle x86 specific literals
318 */
319 void InstallLiteralPools();
320
Mark Mendellae9fd932014-02-10 16:14:35 -0800321 /*
322 * @brief Generate the debug_frame CFI information.
323 * @returns pointer to vector containing CFE information
324 */
325 static std::vector<uint8_t>* ReturnCommonCallFrameInformation();
326
327 /*
328 * @brief Generate the debug_frame FDE information.
329 * @returns pointer to vector containing CFE information
330 */
331 std::vector<uint8_t>* ReturnCallFrameInformation();
332
Mark Mendelle87f9b52014-04-30 14:13:18 -0400333 protected:
Dmitry Petrochenkoa20468c2014-04-30 13:40:19 +0700334 size_t ComputeSize(const X86EncodingMap* entry, int base, int displacement,
335 int reg_r, int reg_x, bool has_sib);
336 uint8_t LowRegisterBits(uint8_t reg);
337 bool NeedsRex(uint8_t reg);
Vladimir Marko057c74a2013-12-03 15:20:45 +0000338 void EmitPrefix(const X86EncodingMap* entry);
Dmitry Petrochenkoa20468c2014-04-30 13:40:19 +0700339 void EmitPrefix(const X86EncodingMap* entry, uint8_t reg_r, uint8_t reg_x, uint8_t reg_b);
Vladimir Marko057c74a2013-12-03 15:20:45 +0000340 void EmitOpcode(const X86EncodingMap* entry);
341 void EmitPrefixAndOpcode(const X86EncodingMap* entry);
Dmitry Petrochenkoa20468c2014-04-30 13:40:19 +0700342 void EmitPrefixAndOpcode(const X86EncodingMap* entry,
343 uint8_t reg_r, uint8_t reg_x, uint8_t reg_b);
Vladimir Marko057c74a2013-12-03 15:20:45 +0000344 void EmitDisp(uint8_t base, int disp);
Dmitry Petrochenko9ee801f2014-05-12 11:31:37 +0700345 void EmitModrmThread(uint8_t reg_or_opcode);
Vladimir Marko057c74a2013-12-03 15:20:45 +0000346 void EmitModrmDisp(uint8_t reg_or_opcode, uint8_t base, int disp);
347 void EmitModrmSibDisp(uint8_t reg_or_opcode, uint8_t base, uint8_t index, int scale, int disp);
Dmitry Petrochenko96992e82014-05-20 04:03:46 +0700348 void EmitImm(const X86EncodingMap* entry, int64_t imm);
Vladimir Markoa8b4caf2013-10-24 15:08:57 +0100349 void EmitOpRegOpcode(const X86EncodingMap* entry, uint8_t reg);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700350 void EmitOpReg(const X86EncodingMap* entry, uint8_t reg);
351 void EmitOpMem(const X86EncodingMap* entry, uint8_t base, int disp);
buzbee2700f7e2014-03-07 09:46:20 -0800352 void EmitOpArray(const X86EncodingMap* entry, uint8_t base, uint8_t index, int scale, int disp);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700353 void EmitMemReg(const X86EncodingMap* entry, uint8_t base, int disp, uint8_t reg);
Mark Mendell343adb52013-12-18 06:02:17 -0800354 void EmitMemImm(const X86EncodingMap* entry, uint8_t base, int disp, int32_t imm);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700355 void EmitRegMem(const X86EncodingMap* entry, uint8_t reg, uint8_t base, int disp);
356 void EmitRegArray(const X86EncodingMap* entry, uint8_t reg, uint8_t base, uint8_t index,
357 int scale, int disp);
358 void EmitArrayReg(const X86EncodingMap* entry, uint8_t base, uint8_t index, int scale, int disp,
359 uint8_t reg);
Mark Mendell2637f2e2014-04-30 10:10:47 -0400360 void EmitArrayImm(const X86EncodingMap* entry, uint8_t base, uint8_t index, int scale, int disp,
361 int32_t imm);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700362 void EmitRegThread(const X86EncodingMap* entry, uint8_t reg, int disp);
363 void EmitRegReg(const X86EncodingMap* entry, uint8_t reg1, uint8_t reg2);
364 void EmitRegRegImm(const X86EncodingMap* entry, uint8_t reg1, uint8_t reg2, int32_t imm);
Mark Mendell4708dcd2014-01-22 09:05:18 -0800365 void EmitRegRegImmRev(const X86EncodingMap* entry, uint8_t reg1, uint8_t reg2, int32_t imm);
buzbee2700f7e2014-03-07 09:46:20 -0800366 void EmitRegMemImm(const X86EncodingMap* entry, uint8_t reg1, uint8_t base, int disp,
367 int32_t imm);
Mark Mendell2637f2e2014-04-30 10:10:47 -0400368 void EmitMemRegImm(const X86EncodingMap* entry, uint8_t base, int disp, uint8_t reg1, int32_t imm);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700369 void EmitRegImm(const X86EncodingMap* entry, uint8_t reg, int imm);
370 void EmitThreadImm(const X86EncodingMap* entry, int disp, int imm);
Dmitry Petrochenko96992e82014-05-20 04:03:46 +0700371 void EmitMovRegImm(const X86EncodingMap* entry, uint8_t reg, int64_t imm);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700372 void EmitShiftRegImm(const X86EncodingMap* entry, uint8_t reg, int imm);
Mark Mendell2637f2e2014-04-30 10:10:47 -0400373 void EmitShiftMemImm(const X86EncodingMap* entry, uint8_t base, int disp, int imm);
Mark Mendellfeb2b4e2014-01-28 12:59:49 -0800374 void EmitShiftMemCl(const X86EncodingMap* entry, uint8_t base, int displacement, uint8_t cl);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700375 void EmitShiftRegCl(const X86EncodingMap* entry, uint8_t reg, uint8_t cl);
376 void EmitRegCond(const X86EncodingMap* entry, uint8_t reg, uint8_t condition);
Mark Mendell2637f2e2014-04-30 10:10:47 -0400377 void EmitMemCond(const X86EncodingMap* entry, uint8_t base, int displacement, uint8_t condition);
Razvan A Lupusorubd288c22013-12-20 17:27:23 -0800378
379 /**
380 * @brief Used for encoding conditional register to register operation.
381 * @param entry The entry in the encoding map for the opcode.
382 * @param reg1 The first physical register.
383 * @param reg2 The second physical register.
384 * @param condition The condition code for operation.
385 */
386 void EmitRegRegCond(const X86EncodingMap* entry, uint8_t reg1, uint8_t reg2, uint8_t condition);
387
Mark Mendell2637f2e2014-04-30 10:10:47 -0400388 /**
389 * @brief Used for encoding conditional register to memory operation.
390 * @param entry The entry in the encoding map for the opcode.
391 * @param reg1 The first physical register.
392 * @param base The memory base register.
393 * @param displacement The memory displacement.
394 * @param condition The condition code for operation.
395 */
396 void EmitRegMemCond(const X86EncodingMap* entry, uint8_t reg1, uint8_t base, int displacement, uint8_t condition);
397
Brian Carlstrom7940e442013-07-12 13:46:57 -0700398 void EmitJmp(const X86EncodingMap* entry, int rel);
399 void EmitJcc(const X86EncodingMap* entry, int rel, uint8_t cc);
400 void EmitCallMem(const X86EncodingMap* entry, uint8_t base, int disp);
Mark Mendell55d0eac2014-02-06 11:02:52 -0800401 void EmitCallImmediate(const X86EncodingMap* entry, int disp);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700402 void EmitCallThread(const X86EncodingMap* entry, int disp);
403 void EmitPcRel(const X86EncodingMap* entry, uint8_t reg, int base_or_table, uint8_t index,
404 int scale, int table_or_disp);
405 void EmitMacro(const X86EncodingMap* entry, uint8_t reg, int offset);
406 void EmitUnimplemented(const X86EncodingMap* entry, LIR* lir);
Mark Mendell412d4f82013-12-18 13:32:36 -0800407 void GenFusedLongCmpImmBranch(BasicBlock* bb, RegLocation rl_src1,
408 int64_t val, ConditionCode ccode);
Bill Buzbeed61ba4b2014-01-13 21:44:01 +0000409 void GenConstWide(RegLocation rl_dest, int64_t value);
Mark Mendelle02d48f2014-01-15 11:19:23 -0800410
Razvan A Lupusoru99ad7232014-02-25 17:41:08 -0800411 static bool ProvidesFullMemoryBarrier(X86OpCode opcode);
412
Mark Mendelle02d48f2014-01-15 11:19:23 -0800413 /*
Mark Mendelle87f9b52014-04-30 14:13:18 -0400414 * @brief Ensure that a temporary register is byte addressable.
415 * @returns a temporary guarenteed to be byte addressable.
416 */
417 virtual RegStorage AllocateByteRegister();
418
419 /*
Mark Mendell4028a6c2014-02-19 20:06:20 -0800420 * @brief generate inline code for fast case of Strng.indexOf.
421 * @param info Call parameters
422 * @param zero_based 'true' if the index into the string is 0.
423 * @returns 'true' if the call was inlined, 'false' if a regular call needs to be
424 * generated.
425 */
426 bool GenInlinedIndexOf(CallInfo* info, bool zero_based);
427
428 /*
Mark Mendelld65c51a2014-04-29 16:55:20 -0400429 * @brief Load 128 bit constant into vector register.
430 * @param bb The basic block in which the MIR is from.
431 * @param mir The MIR whose opcode is kMirConstVector
432 * @note vA is the TypeSize for the register.
433 * @note vB is the destination XMM register. arg[0..3] are 32 bit constant values.
434 */
435 void GenConst128(BasicBlock* bb, MIR* mir);
436
437 /*
Mark Mendellfe945782014-05-22 09:52:36 -0400438 * @brief MIR to move a vectorized register to another.
439 * @param bb The basic block in which the MIR is from.
440 * @param mir The MIR whose opcode is kMirConstVector.
441 * @note vA: TypeSize
442 * @note vB: destination
443 * @note vC: source
444 */
445 void GenMoveVector(BasicBlock *bb, MIR *mir);
446
447 /*
448 * @brief Packed multiply of units in two vector registers: vB = vB .* @note vC using vA to know the type of the vector.
449 * @param bb The basic block in which the MIR is from.
450 * @param mir The MIR whose opcode is kMirConstVector.
451 * @note vA: TypeSize
452 * @note vB: destination and source
453 * @note vC: source
454 */
455 void GenMultiplyVector(BasicBlock *bb, MIR *mir);
456
457 /*
458 * @brief Packed addition of units in two vector registers: vB = vB .+ vC using vA to know the type of the vector.
459 * @param bb The basic block in which the MIR is from.
460 * @param mir The MIR whose opcode is kMirConstVector.
461 * @note vA: TypeSize
462 * @note vB: destination and source
463 * @note vC: source
464 */
465 void GenAddVector(BasicBlock *bb, MIR *mir);
466
467 /*
468 * @brief Packed subtraction of units in two vector registers: vB = vB .- vC using vA to know the type of the vector.
469 * @param bb The basic block in which the MIR is from.
470 * @param mir The MIR whose opcode is kMirConstVector.
471 * @note vA: TypeSize
472 * @note vB: destination and source
473 * @note vC: source
474 */
475 void GenSubtractVector(BasicBlock *bb, MIR *mir);
476
477 /*
478 * @brief Packed shift left of units in two vector registers: vB = vB .<< vC using vA to know the type of the vector.
479 * @param bb The basic block in which the MIR is from.
480 * @param mir The MIR whose opcode is kMirConstVector.
481 * @note vA: TypeSize
482 * @note vB: destination and source
483 * @note vC: immediate
484 */
485 void GenShiftLeftVector(BasicBlock *bb, MIR *mir);
486
487 /*
488 * @brief Packed signed shift right of units in two vector registers: vB = vB .>> vC using vA to know the type of the vector.
489 * @param bb The basic block in which the MIR is from.
490 * @param mir The MIR whose opcode is kMirConstVector.
491 * @note vA: TypeSize
492 * @note vB: destination and source
493 * @note vC: immediate
494 */
495 void GenSignedShiftRightVector(BasicBlock *bb, MIR *mir);
496
497 /*
498 * @brief Packed unsigned shift right of units in two vector registers: vB = vB .>>> vC using vA to know the type of the vector.
499 * @param bb The basic block in which the MIR is from..
500 * @param mir The MIR whose opcode is kMirConstVector.
501 * @note vA: TypeSize
502 * @note vB: destination and source
503 * @note vC: immediate
504 */
505 void GenUnsignedShiftRightVector(BasicBlock *bb, MIR *mir);
506
507 /*
508 * @brief Packed bitwise and of units in two vector registers: vB = vB .& vC using vA to know the type of the vector.
509 * @note vA: TypeSize
510 * @note vB: destination and source
511 * @note vC: source
512 */
513 void GenAndVector(BasicBlock *bb, MIR *mir);
514
515 /*
516 * @brief Packed bitwise or of units in two vector registers: vB = vB .| vC using vA to know the type of the vector.
517 * @param bb The basic block in which the MIR is from.
518 * @param mir The MIR whose opcode is kMirConstVector.
519 * @note vA: TypeSize
520 * @note vB: destination and source
521 * @note vC: source
522 */
523 void GenOrVector(BasicBlock *bb, MIR *mir);
524
525 /*
526 * @brief Packed bitwise xor of units in two vector registers: vB = vB .^ vC using vA to know the type of the vector.
527 * @param bb The basic block in which the MIR is from.
528 * @param mir The MIR whose opcode is kMirConstVector.
529 * @note vA: TypeSize
530 * @note vB: destination and source
531 * @note vC: source
532 */
533 void GenXorVector(BasicBlock *bb, MIR *mir);
534
535 /*
536 * @brief Reduce a 128-bit packed element into a single VR by taking lower bits
537 * @param bb The basic block in which the MIR is from.
538 * @param mir The MIR whose opcode is kMirConstVector.
539 * @details Instruction does a horizontal addition of the packed elements and then adds it to VR.
540 * @note vA: TypeSize
541 * @note vB: destination and source VR (not vector register)
542 * @note vC: source (vector register)
543 */
544 void GenAddReduceVector(BasicBlock *bb, MIR *mir);
545
546 /*
547 * @brief Extract a packed element into a single VR.
548 * @param bb The basic block in which the MIR is from.
549 * @param mir The MIR whose opcode is kMirConstVector.
550 * @note vA: TypeSize
551 * @note vB: destination VR (not vector register)
552 * @note vC: source (vector register)
553 * @note arg[0]: The index to use for extraction from vector register (which packed element).
554 */
555 void GenReduceVector(BasicBlock *bb, MIR *mir);
556
557 /*
558 * @brief Create a vector value, with all TypeSize values equal to vC
559 * @param bb The basic block in which the MIR is from.
560 * @param mir The MIR whose opcode is kMirConstVector.
561 * @note vA: TypeSize.
562 * @note vB: destination vector register.
563 * @note vC: source VR (not vector register).
564 */
565 void GenSetVector(BasicBlock *bb, MIR *mir);
566
567 /*
Mark Mendelld65c51a2014-04-29 16:55:20 -0400568 * @brief Generate code for a vector opcode.
569 * @param bb The basic block in which the MIR is from.
570 * @param mir The MIR whose opcode is a non-standard opcode.
571 */
572 void GenMachineSpecificExtendedMethodMIR(BasicBlock* bb, MIR* mir);
573
574 /*
Mark Mendelle02d48f2014-01-15 11:19:23 -0800575 * @brief Return the correct x86 opcode for the Dex operation
576 * @param op Dex opcode for the operation
577 * @param loc Register location of the operand
578 * @param is_high_op 'true' if this is an operation on the high word
579 * @param value Immediate value for the operation. Used for byte variants
580 * @returns the correct x86 opcode to perform the operation
581 */
582 X86OpCode GetOpcode(Instruction::Code op, RegLocation loc, bool is_high_op, int32_t value);
583
584 /*
585 * @brief Return the correct x86 opcode for the Dex operation
586 * @param op Dex opcode for the operation
587 * @param dest location of the destination. May be register or memory.
588 * @param rhs Location for the rhs of the operation. May be in register or memory.
589 * @param is_high_op 'true' if this is an operation on the high word
590 * @returns the correct x86 opcode to perform the operation
591 * @note at most one location may refer to memory
592 */
593 X86OpCode GetOpcode(Instruction::Code op, RegLocation dest, RegLocation rhs,
594 bool is_high_op);
595
596 /*
597 * @brief Is this operation a no-op for this opcode and value
598 * @param op Dex opcode for the operation
599 * @param value Immediate value for the operation.
600 * @returns 'true' if the operation will have no effect
601 */
602 bool IsNoOp(Instruction::Code op, int32_t value);
603
Mark Mendell2bf31e62014-01-23 12:13:40 -0800604 /**
605 * @brief Calculate magic number and shift for a given divisor
606 * @param divisor divisor number for calculation
607 * @param magic hold calculated magic number
608 * @param shift hold calculated shift
609 */
610 void CalculateMagicAndShift(int divisor, int& magic, int& shift);
611
612 /*
613 * @brief Generate an integer div or rem operation.
614 * @param rl_dest Destination Location.
615 * @param rl_src1 Numerator Location.
616 * @param rl_src2 Divisor Location.
617 * @param is_div 'true' if this is a division, 'false' for a remainder.
618 * @param check_zero 'true' if an exception should be generated if the divisor is 0.
619 */
buzbee2700f7e2014-03-07 09:46:20 -0800620 RegLocation GenDivRem(RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2,
621 bool is_div, bool check_zero);
Mark Mendell2bf31e62014-01-23 12:13:40 -0800622
623 /*
624 * @brief Generate an integer div or rem operation by a literal.
625 * @param rl_dest Destination Location.
626 * @param rl_src Numerator Location.
627 * @param lit Divisor.
628 * @param is_div 'true' if this is a division, 'false' for a remainder.
629 */
630 RegLocation GenDivRemLit(RegLocation rl_dest, RegLocation rl_src, int lit, bool is_div);
Mark Mendell4708dcd2014-01-22 09:05:18 -0800631
632 /*
633 * Generate code to implement long shift operations.
634 * @param opcode The DEX opcode to specify the shift type.
635 * @param rl_dest The destination.
636 * @param rl_src The value to be shifted.
637 * @param shift_amount How much to shift.
638 * @returns the RegLocation of the result.
639 */
640 RegLocation GenShiftImmOpLong(Instruction::Code opcode, RegLocation rl_dest,
641 RegLocation rl_src, int shift_amount);
642 /*
643 * Generate an imul of a register by a constant or a better sequence.
644 * @param dest Destination Register.
645 * @param src Source Register.
646 * @param val Constant multiplier.
647 */
buzbee2700f7e2014-03-07 09:46:20 -0800648 void GenImulRegImm(RegStorage dest, RegStorage src, int val);
Mark Mendellfeb2b4e2014-01-28 12:59:49 -0800649
Mark Mendell4708dcd2014-01-22 09:05:18 -0800650 /*
651 * Generate an imul of a memory location by a constant or a better sequence.
652 * @param dest Destination Register.
653 * @param sreg Symbolic register.
654 * @param displacement Displacement on stack of Symbolic Register.
655 * @param val Constant multiplier.
656 */
buzbee2700f7e2014-03-07 09:46:20 -0800657 void GenImulMemImm(RegStorage dest, int sreg, int displacement, int val);
Mark Mendell766e9292014-01-27 07:55:47 -0800658
659 /*
660 * @brief Compare memory to immediate, and branch if condition true.
661 * @param cond The condition code that when true will branch to the target.
662 * @param temp_reg A temporary register that can be used if compare memory is not
663 * supported by the architecture.
664 * @param base_reg The register holding the base address.
665 * @param offset The offset from the base.
666 * @param check_value The immediate to compare to.
667 */
buzbee2700f7e2014-03-07 09:46:20 -0800668 LIR* OpCmpMemImmBranch(ConditionCode cond, RegStorage temp_reg, RegStorage base_reg,
Mark Mendell766e9292014-01-27 07:55:47 -0800669 int offset, int check_value, LIR* target);
Razvan A Lupusoru614c2b42014-01-28 17:05:21 -0800670
Mark Mendellfeb2b4e2014-01-28 12:59:49 -0800671 /*
672 * Can this operation be using core registers without temporaries?
673 * @param rl_lhs Left hand operand.
674 * @param rl_rhs Right hand operand.
675 * @returns 'true' if the operation can proceed without needing temporary regs.
676 */
677 bool IsOperationSafeWithoutTemps(RegLocation rl_lhs, RegLocation rl_rhs);
Mark Mendell67c39c42014-01-31 17:28:00 -0800678
Razvan A Lupusoru614c2b42014-01-28 17:05:21 -0800679 /**
680 * @brief Generates inline code for conversion of long to FP by using x87/
681 * @param rl_dest The destination of the FP.
682 * @param rl_src The source of the long.
683 * @param is_double 'true' if dealing with double, 'false' for float.
684 */
Mark Mendelle87f9b52014-04-30 14:13:18 -0400685 virtual void GenLongToFP(RegLocation rl_dest, RegLocation rl_src, bool is_double);
Razvan A Lupusoru614c2b42014-01-28 17:05:21 -0800686
Mark Mendell67c39c42014-01-31 17:28:00 -0800687 /*
688 * @brief Perform MIR analysis before compiling method.
689 * @note Invokes Mir2LiR::Materialize after analysis.
690 */
691 void Materialize();
692
693 /*
buzbee30adc732014-05-09 15:10:18 -0700694 * Mir2Lir's UpdateLoc() looks to see if the Dalvik value is currently live in any temp register
695 * without regard to data type. In practice, this can result in UpdateLoc returning a
696 * location record for a Dalvik float value in a core register, and vis-versa. For targets
697 * which can inexpensively move data between core and float registers, this can often be a win.
698 * However, for x86 this is generally not a win. These variants of UpdateLoc()
699 * take a register class argument - and will return an in-register location record only if
700 * the value is live in a temp register of the correct class. Additionally, if the value is in
701 * a temp register of the wrong register class, it will be clobbered.
702 */
703 RegLocation UpdateLocTyped(RegLocation loc, int reg_class);
704 RegLocation UpdateLocWideTyped(RegLocation loc, int reg_class);
705
706 /*
Mark Mendell67c39c42014-01-31 17:28:00 -0800707 * @brief Analyze MIR before generating code, to prepare for the code generation.
708 */
709 void AnalyzeMIR();
710
711 /*
712 * @brief Analyze one basic block.
713 * @param bb Basic block to analyze.
714 */
715 void AnalyzeBB(BasicBlock * bb);
716
717 /*
718 * @brief Analyze one extended MIR instruction
719 * @param opcode MIR instruction opcode.
720 * @param bb Basic block containing instruction.
721 * @param mir Extended instruction to analyze.
722 */
723 void AnalyzeExtendedMIR(int opcode, BasicBlock * bb, MIR *mir);
724
725 /*
726 * @brief Analyze one MIR instruction
727 * @param opcode MIR instruction opcode.
728 * @param bb Basic block containing instruction.
729 * @param mir Instruction to analyze.
730 */
Mark Mendelle87f9b52014-04-30 14:13:18 -0400731 virtual void AnalyzeMIR(int opcode, BasicBlock * bb, MIR *mir);
Mark Mendell67c39c42014-01-31 17:28:00 -0800732
733 /*
734 * @brief Analyze one MIR float/double instruction
735 * @param opcode MIR instruction opcode.
736 * @param bb Basic block containing instruction.
737 * @param mir Instruction to analyze.
738 */
739 void AnalyzeFPInstruction(int opcode, BasicBlock * bb, MIR *mir);
740
741 /*
742 * @brief Analyze one use of a double operand.
743 * @param rl_use Double RegLocation for the operand.
744 */
745 void AnalyzeDoubleUse(RegLocation rl_use);
746
Dmitry Petrochenko9ee801f2014-05-12 11:31:37 +0700747 bool Gen64Bit() const { return gen64bit_; }
748
Mark Mendell67c39c42014-01-31 17:28:00 -0800749 // Information derived from analysis of MIR
750
Mark Mendell55d0eac2014-02-06 11:02:52 -0800751 // The compiler temporary for the code address of the method.
752 CompilerTemp *base_of_code_;
753
Mark Mendell67c39c42014-01-31 17:28:00 -0800754 // Have we decided to compute a ptr to code and store in temporary VR?
755 bool store_method_addr_;
756
Mark Mendell55d0eac2014-02-06 11:02:52 -0800757 // Have we used the stored method address?
758 bool store_method_addr_used_;
759
760 // Instructions to remove if we didn't use the stored method address.
761 LIR* setup_method_address_[2];
762
763 // Instructions needing patching with Method* values.
764 GrowableArray<LIR*> method_address_insns_;
765
766 // Instructions needing patching with Class Type* values.
767 GrowableArray<LIR*> class_type_address_insns_;
768
769 // Instructions needing patching with PC relative code addresses.
770 GrowableArray<LIR*> call_method_insns_;
Mark Mendellae9fd932014-02-10 16:14:35 -0800771
772 // Prologue decrement of stack pointer.
773 LIR* stack_decrement_;
774
775 // Epilogue increment of stack pointer.
776 LIR* stack_increment_;
Dmitry Petrochenko9ee801f2014-05-12 11:31:37 +0700777
778 // 64-bit mode
779 bool gen64bit_;
Mark Mendelld65c51a2014-04-29 16:55:20 -0400780
781 // The list of const vector literals.
782 LIR *const_vectors_;
783
784 /*
785 * @brief Search for a matching vector literal
786 * @param mir A kMirOpConst128b MIR instruction to match.
787 * @returns pointer to matching LIR constant, or nullptr if not found.
788 */
789 LIR *ScanVectorLiteral(MIR *mir);
790
791 /*
792 * @brief Add a constant vector literal
793 * @param mir A kMirOpConst128b MIR instruction to match.
794 */
795 LIR *AddVectorLiteral(MIR *mir);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700796};
797
798} // namespace art
799
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700800#endif // ART_COMPILER_DEX_QUICK_X86_CODEGEN_X86_H_