blob: 21711e567f1cbefddd34d04f84bddc6046212505 [file] [log] [blame]
Brian Carlstrom7940e442013-07-12 13:46:57 -07001/*
2 * Copyright (C) 2012 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_MIR_TO_LIR_H_
18#define ART_COMPILER_DEX_QUICK_MIR_TO_LIR_H_
Brian Carlstrom7940e442013-07-12 13:46:57 -070019
20#include "invoke_type.h"
21#include "compiled_method.h"
22#include "dex/compiler_enums.h"
23#include "dex/compiler_ir.h"
24#include "dex/backend.h"
25#include "dex/growable_array.h"
26#include "dex/arena_allocator.h"
27#include "driver/compiler_driver.h"
Ian Rogers96faf5b2013-08-09 22:05:32 -070028#include "leb128_encoder.h"
Brian Carlstrom7940e442013-07-12 13:46:57 -070029#include "safe_map.h"
30
31namespace art {
32
33// Set to 1 to measure cost of suspend check.
34#define NO_SUSPEND 0
35
36#define IS_BINARY_OP (1ULL << kIsBinaryOp)
37#define IS_BRANCH (1ULL << kIsBranch)
38#define IS_IT (1ULL << kIsIT)
39#define IS_LOAD (1ULL << kMemLoad)
40#define IS_QUAD_OP (1ULL << kIsQuadOp)
41#define IS_QUIN_OP (1ULL << kIsQuinOp)
42#define IS_SEXTUPLE_OP (1ULL << kIsSextupleOp)
43#define IS_STORE (1ULL << kMemStore)
44#define IS_TERTIARY_OP (1ULL << kIsTertiaryOp)
45#define IS_UNARY_OP (1ULL << kIsUnaryOp)
46#define NEEDS_FIXUP (1ULL << kPCRelFixup)
47#define NO_OPERAND (1ULL << kNoOperand)
48#define REG_DEF0 (1ULL << kRegDef0)
49#define REG_DEF1 (1ULL << kRegDef1)
50#define REG_DEFA (1ULL << kRegDefA)
51#define REG_DEFD (1ULL << kRegDefD)
52#define REG_DEF_FPCS_LIST0 (1ULL << kRegDefFPCSList0)
53#define REG_DEF_FPCS_LIST2 (1ULL << kRegDefFPCSList2)
54#define REG_DEF_LIST0 (1ULL << kRegDefList0)
55#define REG_DEF_LIST1 (1ULL << kRegDefList1)
56#define REG_DEF_LR (1ULL << kRegDefLR)
57#define REG_DEF_SP (1ULL << kRegDefSP)
58#define REG_USE0 (1ULL << kRegUse0)
59#define REG_USE1 (1ULL << kRegUse1)
60#define REG_USE2 (1ULL << kRegUse2)
61#define REG_USE3 (1ULL << kRegUse3)
62#define REG_USE4 (1ULL << kRegUse4)
63#define REG_USEA (1ULL << kRegUseA)
64#define REG_USEC (1ULL << kRegUseC)
65#define REG_USED (1ULL << kRegUseD)
66#define REG_USE_FPCS_LIST0 (1ULL << kRegUseFPCSList0)
67#define REG_USE_FPCS_LIST2 (1ULL << kRegUseFPCSList2)
68#define REG_USE_LIST0 (1ULL << kRegUseList0)
69#define REG_USE_LIST1 (1ULL << kRegUseList1)
70#define REG_USE_LR (1ULL << kRegUseLR)
71#define REG_USE_PC (1ULL << kRegUsePC)
72#define REG_USE_SP (1ULL << kRegUseSP)
73#define SETS_CCODES (1ULL << kSetsCCodes)
74#define USES_CCODES (1ULL << kUsesCCodes)
75
76// Common combo register usage patterns.
77#define REG_DEF01 (REG_DEF0 | REG_DEF1)
78#define REG_DEF01_USE2 (REG_DEF0 | REG_DEF1 | REG_USE2)
79#define REG_DEF0_USE01 (REG_DEF0 | REG_USE01)
80#define REG_DEF0_USE0 (REG_DEF0 | REG_USE0)
81#define REG_DEF0_USE12 (REG_DEF0 | REG_USE12)
82#define REG_DEF0_USE1 (REG_DEF0 | REG_USE1)
83#define REG_DEF0_USE2 (REG_DEF0 | REG_USE2)
84#define REG_DEFAD_USEAD (REG_DEFAD_USEA | REG_USED)
85#define REG_DEFAD_USEA (REG_DEFA_USEA | REG_DEFD)
86#define REG_DEFA_USEA (REG_DEFA | REG_USEA)
87#define REG_USE012 (REG_USE01 | REG_USE2)
88#define REG_USE014 (REG_USE01 | REG_USE4)
89#define REG_USE01 (REG_USE0 | REG_USE1)
90#define REG_USE02 (REG_USE0 | REG_USE2)
91#define REG_USE12 (REG_USE1 | REG_USE2)
92#define REG_USE23 (REG_USE2 | REG_USE3)
93
94struct BasicBlock;
95struct CallInfo;
96struct CompilationUnit;
97struct MIR;
buzbeeb48819d2013-09-14 16:15:25 -070098struct LIR;
Brian Carlstrom7940e442013-07-12 13:46:57 -070099struct RegLocation;
100struct RegisterInfo;
101class MIRGraph;
102class Mir2Lir;
103
104typedef int (*NextCallInsn)(CompilationUnit*, CallInfo*, int,
105 const MethodReference& target_method,
106 uint32_t method_idx, uintptr_t direct_code,
107 uintptr_t direct_method, InvokeType type);
108
109typedef std::vector<uint8_t> CodeBuffer;
110
buzbeeb48819d2013-09-14 16:15:25 -0700111struct UseDefMasks {
112 uint64_t use_mask; // Resource mask for use.
113 uint64_t def_mask; // Resource mask for def.
114};
115
116struct AssemblyInfo {
117 LIR* pcrel_next; // Chain of LIR nodes needing pc relative fixups.
118 uint8_t bytes[16]; // Encoded instruction bytes.
119};
Brian Carlstrom7940e442013-07-12 13:46:57 -0700120
121struct LIR {
122 int offset; // Offset of this instruction.
buzbeeb48819d2013-09-14 16:15:25 -0700123 uint16_t dalvik_offset; // Offset of Dalvik opcode in code units (16-bit words).
124 int16_t opcode;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700125 LIR* next;
126 LIR* prev;
127 LIR* target;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700128 struct {
buzbeeb48819d2013-09-14 16:15:25 -0700129 unsigned int alias_info:17; // For Dalvik register disambiguation.
130 bool is_nop:1; // LIR is optimized away.
131 unsigned int size:4; // Note: size of encoded instruction is in bytes.
132 bool use_def_invalid:1; // If true, masks should not be used.
133 unsigned int generation:1; // Used to track visitation state during fixup pass.
134 unsigned int fixup:8; // Fixup kind.
Brian Carlstrom7940e442013-07-12 13:46:57 -0700135 } flags;
buzbeeb48819d2013-09-14 16:15:25 -0700136 union {
137 UseDefMasks m; // Use & Def masks used during optimization.
138 AssemblyInfo a; // Instruction encoding used during assembly phase.
139 } u;
140 int operands[5]; // [0..4] = [dest, src1, src2, extra, extra2].
Brian Carlstrom7940e442013-07-12 13:46:57 -0700141};
142
143// Target-specific initialization.
144Mir2Lir* ArmCodeGenerator(CompilationUnit* const cu, MIRGraph* const mir_graph,
145 ArenaAllocator* const arena);
146Mir2Lir* MipsCodeGenerator(CompilationUnit* const cu, MIRGraph* const mir_graph,
147 ArenaAllocator* const arena);
148Mir2Lir* X86CodeGenerator(CompilationUnit* const cu, MIRGraph* const mir_graph,
149 ArenaAllocator* const arena);
150
151// Utility macros to traverse the LIR list.
152#define NEXT_LIR(lir) (lir->next)
153#define PREV_LIR(lir) (lir->prev)
154
155// Defines for alias_info (tracks Dalvik register references).
156#define DECODE_ALIAS_INFO_REG(X) (X & 0xffff)
buzbeeb48819d2013-09-14 16:15:25 -0700157#define DECODE_ALIAS_INFO_WIDE_FLAG (0x10000)
Brian Carlstrom7940e442013-07-12 13:46:57 -0700158#define DECODE_ALIAS_INFO_WIDE(X) ((X & DECODE_ALIAS_INFO_WIDE_FLAG) ? 1 : 0)
159#define ENCODE_ALIAS_INFO(REG, ISWIDE) (REG | (ISWIDE ? DECODE_ALIAS_INFO_WIDE_FLAG : 0))
160
161// Common resource macros.
162#define ENCODE_CCODE (1ULL << kCCode)
163#define ENCODE_FP_STATUS (1ULL << kFPStatus)
164
165// Abstract memory locations.
166#define ENCODE_DALVIK_REG (1ULL << kDalvikReg)
167#define ENCODE_LITERAL (1ULL << kLiteral)
168#define ENCODE_HEAP_REF (1ULL << kHeapRef)
169#define ENCODE_MUST_NOT_ALIAS (1ULL << kMustNotAlias)
170
171#define ENCODE_ALL (~0ULL)
172#define ENCODE_MEM (ENCODE_DALVIK_REG | ENCODE_LITERAL | \
173 ENCODE_HEAP_REF | ENCODE_MUST_NOT_ALIAS)
buzbeec729a6b2013-09-14 16:04:31 -0700174
175// Mask to denote sreg as the start of a double. Must not interfere with low 16 bits.
176#define STARTING_DOUBLE_SREG 0x10000
177
Brian Carlstrom7934ac22013-07-26 10:54:15 -0700178// TODO: replace these macros
Brian Carlstrom7940e442013-07-12 13:46:57 -0700179#define SLOW_FIELD_PATH (cu_->enable_debug & (1 << kDebugSlowFieldPath))
180#define SLOW_INVOKE_PATH (cu_->enable_debug & (1 << kDebugSlowInvokePath))
181#define SLOW_STRING_PATH (cu_->enable_debug & (1 << kDebugSlowStringPath))
182#define SLOW_TYPE_PATH (cu_->enable_debug & (1 << kDebugSlowTypePath))
183#define EXERCISE_SLOWEST_STRING_PATH (cu_->enable_debug & (1 << kDebugSlowestStringPath))
184#define is_pseudo_opcode(opcode) (static_cast<int>(opcode) < 0)
185
186class Mir2Lir : public Backend {
Brian Carlstrom7940e442013-07-12 13:46:57 -0700187 public:
188 struct SwitchTable {
189 int offset;
190 const uint16_t* table; // Original dex table.
191 int vaddr; // Dalvik offset of switch opcode.
192 LIR* anchor; // Reference instruction for relative offsets.
193 LIR** targets; // Array of case targets.
194 };
195
196 struct FillArrayData {
197 int offset;
198 const uint16_t* table; // Original dex table.
199 int size;
200 int vaddr; // Dalvik offset of FILL_ARRAY_DATA opcode.
201 };
202
203 /* Static register use counts */
204 struct RefCounts {
205 int count;
206 int s_reg;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700207 };
208
209 /*
210 * Data structure tracking the mapping between a Dalvik register (pair) and a
211 * native register (pair). The idea is to reuse the previously loaded value
212 * if possible, otherwise to keep the value in a native register as long as
213 * possible.
214 */
215 struct RegisterInfo {
216 int reg; // Reg number
217 bool in_use; // Has it been allocated?
218 bool is_temp; // Can allocate as temp?
219 bool pair; // Part of a register pair?
220 int partner; // If pair, other reg of pair.
221 bool live; // Is there an associated SSA name?
222 bool dirty; // If live, is it dirty?
223 int s_reg; // Name of live value.
224 LIR *def_start; // Starting inst in last def sequence.
225 LIR *def_end; // Ending inst in last def sequence.
226 };
227
Brian Carlstrom6f485c62013-07-18 15:35:35 -0700228 struct RegisterPool {
229 int num_core_regs;
230 RegisterInfo *core_regs;
231 int next_core_reg;
232 int num_fp_regs;
233 RegisterInfo *FPRegs;
234 int next_fp_reg;
235 };
Brian Carlstrom7940e442013-07-12 13:46:57 -0700236
237 struct PromotionMap {
238 RegLocationType core_location:3;
239 uint8_t core_reg;
240 RegLocationType fp_location:3;
241 uint8_t FpReg;
242 bool first_in_pair;
243 };
244
Brian Carlstrom9b7085a2013-07-18 15:15:21 -0700245 virtual ~Mir2Lir() {}
Brian Carlstrom7940e442013-07-12 13:46:57 -0700246
247 int32_t s4FromSwitchData(const void* switch_data) {
248 return *reinterpret_cast<const int32_t*>(switch_data);
249 }
250
251 RegisterClass oat_reg_class_by_size(OpSize size) {
252 return (size == kUnsignedHalf || size == kSignedHalf || size == kUnsignedByte ||
Brian Carlstromdf629502013-07-17 22:39:56 -0700253 size == kSignedByte) ? kCoreReg : kAnyReg;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700254 }
255
256 size_t CodeBufferSizeInBytes() {
257 return code_buffer_.size() / sizeof(code_buffer_[0]);
258 }
259
260 // Shared by all targets - implemented in codegen_util.cc
261 void AppendLIR(LIR* lir);
262 void InsertLIRBefore(LIR* current_lir, LIR* new_lir);
263 void InsertLIRAfter(LIR* current_lir, LIR* new_lir);
264
265 int ComputeFrameSize();
266 virtual void Materialize();
267 virtual CompiledMethod* GetCompiledMethod();
268 void MarkSafepointPC(LIR* inst);
Ian Rogers9b297bf2013-09-06 11:11:25 -0700269 bool FastInstance(uint32_t field_idx, bool is_put, int* field_offset, bool* is_volatile);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700270 void SetupResourceMasks(LIR* lir);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700271 void SetMemRefType(LIR* lir, bool is_load, int mem_type);
272 void AnnotateDalvikRegAccess(LIR* lir, int reg_id, bool is_load, bool is64bit);
273 void SetupRegMask(uint64_t* mask, int reg);
274 void DumpLIRInsn(LIR* arg, unsigned char* base_addr);
275 void DumpPromotionMap();
276 void CodegenDump();
277 LIR* RawLIR(int dalvik_offset, int opcode, int op0 = 0, int op1 = 0,
278 int op2 = 0, int op3 = 0, int op4 = 0, LIR* target = NULL);
279 LIR* NewLIR0(int opcode);
280 LIR* NewLIR1(int opcode, int dest);
281 LIR* NewLIR2(int opcode, int dest, int src1);
282 LIR* NewLIR3(int opcode, int dest, int src1, int src2);
283 LIR* NewLIR4(int opcode, int dest, int src1, int src2, int info);
284 LIR* NewLIR5(int opcode, int dest, int src1, int src2, int info1, int info2);
285 LIR* ScanLiteralPool(LIR* data_target, int value, unsigned int delta);
286 LIR* ScanLiteralPoolWide(LIR* data_target, int val_lo, int val_hi);
287 LIR* AddWordData(LIR* *constant_list_p, int value);
288 LIR* AddWideData(LIR* *constant_list_p, int val_lo, int val_hi);
289 void ProcessSwitchTables();
290 void DumpSparseSwitchTable(const uint16_t* table);
291 void DumpPackedSwitchTable(const uint16_t* table);
buzbee252254b2013-09-08 16:20:53 -0700292 void MarkBoundary(int offset, const char* inst_str);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700293 void NopLIR(LIR* lir);
buzbee252254b2013-09-08 16:20:53 -0700294 void UnlinkLIR(LIR* lir);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700295 bool EvaluateBranch(Instruction::Code opcode, int src1, int src2);
296 bool IsInexpensiveConstant(RegLocation rl_src);
297 ConditionCode FlipComparisonOrder(ConditionCode before);
Ian Rogersd91d6d62013-09-25 20:26:14 -0700298 void DumpMappingTable(const char* table_name, const char* descriptor,
299 const char* name, const Signature& signature,
Brian Carlstrom7940e442013-07-12 13:46:57 -0700300 const std::vector<uint32_t>& v);
301 void InstallLiteralPools();
302 void InstallSwitchTables();
303 void InstallFillArrayData();
304 bool VerifyCatchEntries();
305 void CreateMappingTables();
306 void CreateNativeGcMap();
307 int AssignLiteralOffset(int offset);
308 int AssignSwitchTablesOffset(int offset);
309 int AssignFillArrayDataOffset(int offset);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700310 LIR* InsertCaseLabel(int vaddr, int keyVal);
311 void MarkPackedCaseLabels(Mir2Lir::SwitchTable *tab_rec);
312 void MarkSparseCaseLabels(Mir2Lir::SwitchTable *tab_rec);
313
314 // Shared by all targets - implemented in local_optimizations.cc
315 void ConvertMemOpIntoMove(LIR* orig_lir, int dest, int src);
316 void ApplyLoadStoreElimination(LIR* head_lir, LIR* tail_lir);
317 void ApplyLoadHoisting(LIR* head_lir, LIR* tail_lir);
318 void ApplyLocalOptimizations(LIR* head_lir, LIR* tail_lir);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700319
320 // Shared by all targets - implemented in ralloc_util.cc
321 int GetSRegHi(int lowSreg);
322 bool oat_live_out(int s_reg);
323 int oatSSASrc(MIR* mir, int num);
324 void SimpleRegAlloc();
325 void ResetRegPool();
326 void CompilerInitPool(RegisterInfo* regs, int* reg_nums, int num);
327 void DumpRegPool(RegisterInfo* p, int num_regs);
328 void DumpCoreRegPool();
329 void DumpFpRegPool();
330 /* Mark a temp register as dead. Does not affect allocation state. */
331 void Clobber(int reg) {
332 ClobberBody(GetRegInfo(reg));
333 }
334 void ClobberSRegBody(RegisterInfo* p, int num_regs, int s_reg);
335 void ClobberSReg(int s_reg);
336 int SRegToPMap(int s_reg);
337 void RecordCorePromotion(int reg, int s_reg);
338 int AllocPreservedCoreReg(int s_reg);
339 void RecordFpPromotion(int reg, int s_reg);
buzbeec729a6b2013-09-14 16:04:31 -0700340 int AllocPreservedSingle(int s_reg);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700341 int AllocPreservedDouble(int s_reg);
buzbeec729a6b2013-09-14 16:04:31 -0700342 int AllocTempBody(RegisterInfo* p, int num_regs, int* next_temp, bool required);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700343 int AllocTempDouble();
344 int AllocFreeTemp();
345 int AllocTemp();
346 int AllocTempFloat();
347 RegisterInfo* AllocLiveBody(RegisterInfo* p, int num_regs, int s_reg);
348 RegisterInfo* AllocLive(int s_reg, int reg_class);
349 void FreeTemp(int reg);
350 RegisterInfo* IsLive(int reg);
351 RegisterInfo* IsTemp(int reg);
352 RegisterInfo* IsPromoted(int reg);
353 bool IsDirty(int reg);
354 void LockTemp(int reg);
355 void ResetDef(int reg);
356 void NullifyRange(LIR *start, LIR *finish, int s_reg1, int s_reg2);
357 void MarkDef(RegLocation rl, LIR *start, LIR *finish);
358 void MarkDefWide(RegLocation rl, LIR *start, LIR *finish);
359 RegLocation WideToNarrow(RegLocation rl);
360 void ResetDefLoc(RegLocation rl);
361 void ResetDefLocWide(RegLocation rl);
362 void ResetDefTracking();
363 void ClobberAllRegs();
364 void FlushAllRegsBody(RegisterInfo* info, int num_regs);
365 void FlushAllRegs();
366 bool RegClassMatches(int reg_class, int reg);
367 void MarkLive(int reg, int s_reg);
368 void MarkTemp(int reg);
369 void UnmarkTemp(int reg);
370 void MarkPair(int low_reg, int high_reg);
371 void MarkClean(RegLocation loc);
372 void MarkDirty(RegLocation loc);
373 void MarkInUse(int reg);
374 void CopyRegInfo(int new_reg, int old_reg);
375 bool CheckCorePoolSanity();
376 RegLocation UpdateLoc(RegLocation loc);
377 RegLocation UpdateLocWide(RegLocation loc);
378 RegLocation UpdateRawLoc(RegLocation loc);
379 RegLocation EvalLocWide(RegLocation loc, int reg_class, bool update);
380 RegLocation EvalLoc(RegLocation loc, int reg_class, bool update);
buzbeec729a6b2013-09-14 16:04:31 -0700381 void CountRefs(RefCounts* core_counts, RefCounts* fp_counts, size_t num_regs);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700382 void DumpCounts(const RefCounts* arr, int size, const char* msg);
383 void DoPromotion();
384 int VRegOffset(int v_reg);
385 int SRegOffset(int s_reg);
386 RegLocation GetReturnWide(bool is_double);
387 RegLocation GetReturn(bool is_float);
buzbeebd663de2013-09-10 15:41:31 -0700388 RegisterInfo* GetRegInfo(int reg);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700389
390 // Shared by all targets - implemented in gen_common.cc.
buzbee11b63d12013-08-27 07:34:17 -0700391 bool HandleEasyDivRem(Instruction::Code dalvik_opcode, bool is_div,
Brian Carlstrom7940e442013-07-12 13:46:57 -0700392 RegLocation rl_src, RegLocation rl_dest, int lit);
393 bool HandleEasyMultiply(RegLocation rl_src, RegLocation rl_dest, int lit);
394 void HandleSuspendLaunchPads();
395 void HandleIntrinsicLaunchPads();
396 void HandleThrowLaunchPads();
397 void GenBarrier();
398 LIR* GenCheck(ConditionCode c_code, ThrowKind kind);
399 LIR* GenImmedCheck(ConditionCode c_code, int reg, int imm_val,
400 ThrowKind kind);
401 LIR* GenNullCheck(int s_reg, int m_reg, int opt_flags);
402 LIR* GenRegRegCheck(ConditionCode c_code, int reg1, int reg2,
403 ThrowKind kind);
404 void GenCompareAndBranch(Instruction::Code opcode, RegLocation rl_src1,
405 RegLocation rl_src2, LIR* taken, LIR* fall_through);
406 void GenCompareZeroAndBranch(Instruction::Code opcode, RegLocation rl_src,
407 LIR* taken, LIR* fall_through);
408 void GenIntToLong(RegLocation rl_dest, RegLocation rl_src);
409 void GenIntNarrowing(Instruction::Code opcode, RegLocation rl_dest,
410 RegLocation rl_src);
411 void GenNewArray(uint32_t type_idx, RegLocation rl_dest,
412 RegLocation rl_src);
413 void GenFilledNewArray(CallInfo* info);
414 void GenSput(uint32_t field_idx, RegLocation rl_src,
415 bool is_long_or_double, bool is_object);
416 void GenSget(uint32_t field_idx, RegLocation rl_dest,
417 bool is_long_or_double, bool is_object);
418 void GenIGet(uint32_t field_idx, int opt_flags, OpSize size,
419 RegLocation rl_dest, RegLocation rl_obj, bool is_long_or_double, bool is_object);
420 void GenIPut(uint32_t field_idx, int opt_flags, OpSize size,
421 RegLocation rl_src, RegLocation rl_obj, bool is_long_or_double, bool is_object);
Ian Rogersa9a82542013-10-04 11:17:26 -0700422 void GenArrayObjPut(int opt_flags, RegLocation rl_array, RegLocation rl_index,
423 RegLocation rl_src);
424
Brian Carlstrom7940e442013-07-12 13:46:57 -0700425 void GenConstClass(uint32_t type_idx, RegLocation rl_dest);
426 void GenConstString(uint32_t string_idx, RegLocation rl_dest);
427 void GenNewInstance(uint32_t type_idx, RegLocation rl_dest);
428 void GenThrow(RegLocation rl_src);
429 void GenInstanceof(uint32_t type_idx, RegLocation rl_dest,
430 RegLocation rl_src);
431 void GenCheckCast(uint32_t insn_idx, uint32_t type_idx,
432 RegLocation rl_src);
433 void GenLong3Addr(OpKind first_op, OpKind second_op, RegLocation rl_dest,
434 RegLocation rl_src1, RegLocation rl_src2);
435 void GenShiftOpLong(Instruction::Code opcode, RegLocation rl_dest,
436 RegLocation rl_src1, RegLocation rl_shift);
437 void GenArithOpInt(Instruction::Code opcode, RegLocation rl_dest,
438 RegLocation rl_src1, RegLocation rl_src2);
439 void GenArithOpIntLit(Instruction::Code opcode, RegLocation rl_dest,
440 RegLocation rl_src, int lit);
441 void GenArithOpLong(Instruction::Code opcode, RegLocation rl_dest,
442 RegLocation rl_src1, RegLocation rl_src2);
Ian Rogers468532e2013-08-05 10:56:33 -0700443 void GenConversionCall(ThreadOffset func_offset, RegLocation rl_dest,
Brian Carlstrom7940e442013-07-12 13:46:57 -0700444 RegLocation rl_src);
445 void GenSuspendTest(int opt_flags);
446 void GenSuspendTestAndBranch(int opt_flags, LIR* target);
447
448 // Shared by all targets - implemented in gen_invoke.cc.
Ian Rogers468532e2013-08-05 10:56:33 -0700449 int CallHelperSetup(ThreadOffset helper_offset);
450 LIR* CallHelper(int r_tgt, ThreadOffset helper_offset, bool safepoint_pc);
451 void CallRuntimeHelperImm(ThreadOffset helper_offset, int arg0, bool safepoint_pc);
452 void CallRuntimeHelperReg(ThreadOffset helper_offset, int arg0, bool safepoint_pc);
453 void CallRuntimeHelperRegLocation(ThreadOffset helper_offset, RegLocation arg0,
454 bool safepoint_pc);
455 void CallRuntimeHelperImmImm(ThreadOffset helper_offset, int arg0, int arg1,
Brian Carlstrom7940e442013-07-12 13:46:57 -0700456 bool safepoint_pc);
Ian Rogers468532e2013-08-05 10:56:33 -0700457 void CallRuntimeHelperImmRegLocation(ThreadOffset helper_offset, int arg0,
Brian Carlstrom7940e442013-07-12 13:46:57 -0700458 RegLocation arg1, bool safepoint_pc);
Ian Rogers468532e2013-08-05 10:56:33 -0700459 void CallRuntimeHelperRegLocationImm(ThreadOffset helper_offset, RegLocation arg0,
Brian Carlstrom7940e442013-07-12 13:46:57 -0700460 int arg1, bool safepoint_pc);
Ian Rogers468532e2013-08-05 10:56:33 -0700461 void CallRuntimeHelperImmReg(ThreadOffset helper_offset, int arg0, int arg1,
Brian Carlstrom7940e442013-07-12 13:46:57 -0700462 bool safepoint_pc);
Ian Rogers468532e2013-08-05 10:56:33 -0700463 void CallRuntimeHelperRegImm(ThreadOffset helper_offset, int arg0, int arg1,
Brian Carlstrom7940e442013-07-12 13:46:57 -0700464 bool safepoint_pc);
Ian Rogers468532e2013-08-05 10:56:33 -0700465 void CallRuntimeHelperImmMethod(ThreadOffset helper_offset, int arg0,
Brian Carlstrom7940e442013-07-12 13:46:57 -0700466 bool safepoint_pc);
Ian Rogers468532e2013-08-05 10:56:33 -0700467 void CallRuntimeHelperRegLocationRegLocation(ThreadOffset helper_offset,
Brian Carlstrom7940e442013-07-12 13:46:57 -0700468 RegLocation arg0, RegLocation arg1,
469 bool safepoint_pc);
Ian Rogers468532e2013-08-05 10:56:33 -0700470 void CallRuntimeHelperRegReg(ThreadOffset helper_offset, int arg0, int arg1,
Brian Carlstrom7940e442013-07-12 13:46:57 -0700471 bool safepoint_pc);
Ian Rogers468532e2013-08-05 10:56:33 -0700472 void CallRuntimeHelperRegRegImm(ThreadOffset helper_offset, int arg0, int arg1,
Brian Carlstrom7940e442013-07-12 13:46:57 -0700473 int arg2, bool safepoint_pc);
Ian Rogers468532e2013-08-05 10:56:33 -0700474 void CallRuntimeHelperImmMethodRegLocation(ThreadOffset helper_offset, int arg0,
Brian Carlstrom7940e442013-07-12 13:46:57 -0700475 RegLocation arg2, bool safepoint_pc);
Ian Rogers468532e2013-08-05 10:56:33 -0700476 void CallRuntimeHelperImmMethodImm(ThreadOffset helper_offset, int arg0, int arg2,
Brian Carlstrom7940e442013-07-12 13:46:57 -0700477 bool safepoint_pc);
Ian Rogers468532e2013-08-05 10:56:33 -0700478 void CallRuntimeHelperImmRegLocationRegLocation(ThreadOffset helper_offset,
Brian Carlstrom7940e442013-07-12 13:46:57 -0700479 int arg0, RegLocation arg1, RegLocation arg2,
480 bool safepoint_pc);
Ian Rogersa9a82542013-10-04 11:17:26 -0700481 void CallRuntimeHelperRegLocationRegLocationRegLocation(ThreadOffset helper_offset,
482 RegLocation arg0, RegLocation arg1,
483 RegLocation arg2,
484 bool safepoint_pc);
Brian Carlstrom7940e442013-07-12 13:46:57 -0700485 void GenInvoke(CallInfo* info);
486 void FlushIns(RegLocation* ArgLocs, RegLocation rl_method);
487 int GenDalvikArgsNoRange(CallInfo* info, int call_state, LIR** pcrLabel,
488 NextCallInsn next_call_insn,
489 const MethodReference& target_method,
490 uint32_t vtable_idx,
491 uintptr_t direct_code, uintptr_t direct_method, InvokeType type,
492 bool skip_this);
493 int GenDalvikArgsRange(CallInfo* info, int call_state, LIR** pcrLabel,
494 NextCallInsn next_call_insn,
495 const MethodReference& target_method,
496 uint32_t vtable_idx,
497 uintptr_t direct_code, uintptr_t direct_method, InvokeType type,
498 bool skip_this);
499 RegLocation InlineTarget(CallInfo* info);
500 RegLocation InlineTargetWide(CallInfo* info);
501
502 bool GenInlinedCharAt(CallInfo* info);
503 bool GenInlinedStringIsEmptyOrLength(CallInfo* info, bool is_empty);
504 bool GenInlinedAbsInt(CallInfo* info);
505 bool GenInlinedAbsLong(CallInfo* info);
506 bool GenInlinedFloatCvt(CallInfo* info);
507 bool GenInlinedDoubleCvt(CallInfo* info);
508 bool GenInlinedIndexOf(CallInfo* info, bool zero_based);
509 bool GenInlinedStringCompareTo(CallInfo* info);
510 bool GenInlinedCurrentThread(CallInfo* info);
511 bool GenInlinedUnsafeGet(CallInfo* info, bool is_long, bool is_volatile);
512 bool GenInlinedUnsafePut(CallInfo* info, bool is_long, bool is_object,
513 bool is_volatile, bool is_ordered);
514 bool GenIntrinsic(CallInfo* info);
515 int LoadArgRegs(CallInfo* info, int call_state,
516 NextCallInsn next_call_insn,
517 const MethodReference& target_method,
518 uint32_t vtable_idx,
519 uintptr_t direct_code, uintptr_t direct_method, InvokeType type,
520 bool skip_this);
521
522 // Shared by all targets - implemented in gen_loadstore.cc.
523 RegLocation LoadCurrMethod();
524 void LoadCurrMethodDirect(int r_tgt);
525 LIR* LoadConstant(int r_dest, int value);
526 LIR* LoadWordDisp(int rBase, int displacement, int r_dest);
527 RegLocation LoadValue(RegLocation rl_src, RegisterClass op_kind);
528 RegLocation LoadValueWide(RegLocation rl_src, RegisterClass op_kind);
529 void LoadValueDirect(RegLocation rl_src, int r_dest);
530 void LoadValueDirectFixed(RegLocation rl_src, int r_dest);
531 void LoadValueDirectWide(RegLocation rl_src, int reg_lo, int reg_hi);
532 void LoadValueDirectWideFixed(RegLocation rl_src, int reg_lo, int reg_hi);
533 LIR* StoreWordDisp(int rBase, int displacement, int r_src);
534 void StoreValue(RegLocation rl_dest, RegLocation rl_src);
535 void StoreValueWide(RegLocation rl_dest, RegLocation rl_src);
536
537 // Shared by all targets - implemented in mir_to_lir.cc.
538 void CompileDalvikInstruction(MIR* mir, BasicBlock* bb, LIR* label_list);
539 void HandleExtendedMethodMIR(BasicBlock* bb, MIR* mir);
540 bool MethodBlockCodeGen(BasicBlock* bb);
541 void SpecialMIR2LIR(SpecialCaseHandler special_case);
542 void MethodMIR2LIR();
543
544
545
546 // Required for target - codegen helpers.
buzbee11b63d12013-08-27 07:34:17 -0700547 virtual bool SmallLiteralDivRem(Instruction::Code dalvik_opcode, bool is_div,
Brian Carlstrom7940e442013-07-12 13:46:57 -0700548 RegLocation rl_src, RegLocation rl_dest, int lit) = 0;
Ian Rogers468532e2013-08-05 10:56:33 -0700549 virtual int LoadHelper(ThreadOffset offset) = 0;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700550 virtual LIR* LoadBaseDisp(int rBase, int displacement, int r_dest, OpSize size, int s_reg) = 0;
551 virtual LIR* LoadBaseDispWide(int rBase, int displacement, int r_dest_lo, int r_dest_hi,
552 int s_reg) = 0;
553 virtual LIR* LoadBaseIndexed(int rBase, int r_index, int r_dest, int scale, OpSize size) = 0;
554 virtual LIR* LoadBaseIndexedDisp(int rBase, int r_index, int scale, int displacement,
555 int r_dest, int r_dest_hi, OpSize size, int s_reg) = 0;
556 virtual LIR* LoadConstantNoClobber(int r_dest, int value) = 0;
557 virtual LIR* LoadConstantWide(int r_dest_lo, int r_dest_hi, int64_t value) = 0;
558 virtual LIR* StoreBaseDisp(int rBase, int displacement, int r_src, OpSize size) = 0;
559 virtual LIR* StoreBaseDispWide(int rBase, int displacement, int r_src_lo, int r_src_hi) = 0;
560 virtual LIR* StoreBaseIndexed(int rBase, int r_index, int r_src, int scale, OpSize size) = 0;
561 virtual LIR* StoreBaseIndexedDisp(int rBase, int r_index, int scale, int displacement,
562 int r_src, int r_src_hi, OpSize size, int s_reg) = 0;
563 virtual void MarkGCCard(int val_reg, int tgt_addr_reg) = 0;
564
565 // Required for target - register utilities.
566 virtual bool IsFpReg(int reg) = 0;
567 virtual bool SameRegType(int reg1, int reg2) = 0;
568 virtual int AllocTypedTemp(bool fp_hint, int reg_class) = 0;
569 virtual int AllocTypedTempPair(bool fp_hint, int reg_class) = 0;
570 virtual int S2d(int low_reg, int high_reg) = 0;
571 virtual int TargetReg(SpecialTargetRegister reg) = 0;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700572 virtual RegLocation GetReturnAlt() = 0;
573 virtual RegLocation GetReturnWideAlt() = 0;
574 virtual RegLocation LocCReturn() = 0;
575 virtual RegLocation LocCReturnDouble() = 0;
576 virtual RegLocation LocCReturnFloat() = 0;
577 virtual RegLocation LocCReturnWide() = 0;
578 virtual uint32_t FpRegMask() = 0;
579 virtual uint64_t GetRegMaskCommon(int reg) = 0;
580 virtual void AdjustSpillMask() = 0;
581 virtual void ClobberCalleeSave() = 0;
582 virtual void FlushReg(int reg) = 0;
583 virtual void FlushRegWide(int reg1, int reg2) = 0;
584 virtual void FreeCallTemps() = 0;
585 virtual void FreeRegLocTemps(RegLocation rl_keep, RegLocation rl_free) = 0;
586 virtual void LockCallTemps() = 0;
587 virtual void MarkPreservedSingle(int v_reg, int reg) = 0;
588 virtual void CompilerInitializeRegAlloc() = 0;
589
590 // Required for target - miscellaneous.
buzbeeb48819d2013-09-14 16:15:25 -0700591 virtual void AssembleLIR() = 0;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700592 virtual void DumpResourceMask(LIR* lir, uint64_t mask, const char* prefix) = 0;
buzbeeb48819d2013-09-14 16:15:25 -0700593 virtual void SetupTargetResourceMasks(LIR* lir, uint64_t flags) = 0;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700594 virtual const char* GetTargetInstFmt(int opcode) = 0;
595 virtual const char* GetTargetInstName(int opcode) = 0;
596 virtual std::string BuildInsnString(const char* fmt, LIR* lir, unsigned char* base_addr) = 0;
597 virtual uint64_t GetPCUseDefEncoding() = 0;
598 virtual uint64_t GetTargetInstFlags(int opcode) = 0;
599 virtual int GetInsnSize(LIR* lir) = 0;
600 virtual bool IsUnconditionalBranch(LIR* lir) = 0;
601
602 // Required for target - Dalvik-level generators.
603 virtual void GenArithImmOpLong(Instruction::Code opcode, RegLocation rl_dest,
604 RegLocation rl_src1, RegLocation rl_src2) = 0;
605 virtual void GenMulLong(RegLocation rl_dest, RegLocation rl_src1,
606 RegLocation rl_src2) = 0;
607 virtual void GenAddLong(RegLocation rl_dest, RegLocation rl_src1,
608 RegLocation rl_src2) = 0;
609 virtual void GenAndLong(RegLocation rl_dest, RegLocation rl_src1,
610 RegLocation rl_src2) = 0;
611 virtual void GenArithOpDouble(Instruction::Code opcode,
612 RegLocation rl_dest, RegLocation rl_src1,
613 RegLocation rl_src2) = 0;
614 virtual void GenArithOpFloat(Instruction::Code opcode, RegLocation rl_dest,
615 RegLocation rl_src1, RegLocation rl_src2) = 0;
616 virtual void GenCmpFP(Instruction::Code opcode, RegLocation rl_dest,
617 RegLocation rl_src1, RegLocation rl_src2) = 0;
618 virtual void GenConversion(Instruction::Code opcode, RegLocation rl_dest,
619 RegLocation rl_src) = 0;
620 virtual bool GenInlinedCas32(CallInfo* info, bool need_write_barrier) = 0;
621 virtual bool GenInlinedMinMaxInt(CallInfo* info, bool is_min) = 0;
622 virtual bool GenInlinedSqrt(CallInfo* info) = 0;
623 virtual void GenNegLong(RegLocation rl_dest, RegLocation rl_src) = 0;
624 virtual void GenOrLong(RegLocation rl_dest, RegLocation rl_src1,
625 RegLocation rl_src2) = 0;
626 virtual void GenSubLong(RegLocation rl_dest, RegLocation rl_src1,
627 RegLocation rl_src2) = 0;
628 virtual void GenXorLong(RegLocation rl_dest, RegLocation rl_src1,
629 RegLocation rl_src2) = 0;
630 virtual LIR* GenRegMemCheck(ConditionCode c_code, int reg1, int base,
631 int offset, ThrowKind kind) = 0;
632 virtual RegLocation GenDivRem(RegLocation rl_dest, int reg_lo, int reg_hi,
633 bool is_div) = 0;
634 virtual RegLocation GenDivRemLit(RegLocation rl_dest, int reg_lo, int lit,
635 bool is_div) = 0;
636 virtual void GenCmpLong(RegLocation rl_dest, RegLocation rl_src1,
637 RegLocation rl_src2) = 0;
638 virtual void GenDivZeroCheck(int reg_lo, int reg_hi) = 0;
639 virtual void GenEntrySequence(RegLocation* ArgLocs,
640 RegLocation rl_method) = 0;
641 virtual void GenExitSequence() = 0;
642 virtual void GenFillArrayData(uint32_t table_offset,
643 RegLocation rl_src) = 0;
644 virtual void GenFusedFPCmpBranch(BasicBlock* bb, MIR* mir, bool gt_bias,
645 bool is_double) = 0;
646 virtual void GenFusedLongCmpBranch(BasicBlock* bb, MIR* mir) = 0;
647 virtual void GenSelect(BasicBlock* bb, MIR* mir) = 0;
648 virtual void GenMemBarrier(MemBarrierKind barrier_kind) = 0;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700649 virtual void GenMoveException(RegLocation rl_dest) = 0;
650 virtual void GenMultiplyByTwoBitMultiplier(RegLocation rl_src,
651 RegLocation rl_result, int lit, int first_bit,
652 int second_bit) = 0;
653 virtual void GenNegDouble(RegLocation rl_dest, RegLocation rl_src) = 0;
654 virtual void GenNegFloat(RegLocation rl_dest, RegLocation rl_src) = 0;
655 virtual void GenPackedSwitch(MIR* mir, uint32_t table_offset,
656 RegLocation rl_src) = 0;
657 virtual void GenSparseSwitch(MIR* mir, uint32_t table_offset,
658 RegLocation rl_src) = 0;
659 virtual void GenSpecialCase(BasicBlock* bb, MIR* mir,
660 SpecialCaseHandler special_case) = 0;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700661 virtual void GenArrayGet(int opt_flags, OpSize size, RegLocation rl_array,
662 RegLocation rl_index, RegLocation rl_dest, int scale) = 0;
663 virtual void GenArrayPut(int opt_flags, OpSize size, RegLocation rl_array,
Ian Rogersa9a82542013-10-04 11:17:26 -0700664 RegLocation rl_index, RegLocation rl_src, int scale,
665 bool card_mark) = 0;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700666 virtual void GenShiftImmOpLong(Instruction::Code opcode,
667 RegLocation rl_dest, RegLocation rl_src1,
668 RegLocation rl_shift) = 0;
669
670 // Required for target - single operation generators.
671 virtual LIR* OpUnconditionalBranch(LIR* target) = 0;
672 virtual LIR* OpCmpBranch(ConditionCode cond, int src1, int src2,
673 LIR* target) = 0;
674 virtual LIR* OpCmpImmBranch(ConditionCode cond, int reg, int check_value,
675 LIR* target) = 0;
676 virtual LIR* OpCondBranch(ConditionCode cc, LIR* target) = 0;
677 virtual LIR* OpDecAndBranch(ConditionCode c_code, int reg,
678 LIR* target) = 0;
679 virtual LIR* OpFpRegCopy(int r_dest, int r_src) = 0;
680 virtual LIR* OpIT(ConditionCode cond, const char* guide) = 0;
681 virtual LIR* OpMem(OpKind op, int rBase, int disp) = 0;
682 virtual LIR* OpPcRelLoad(int reg, LIR* target) = 0;
683 virtual LIR* OpReg(OpKind op, int r_dest_src) = 0;
684 virtual LIR* OpRegCopy(int r_dest, int r_src) = 0;
685 virtual LIR* OpRegCopyNoInsert(int r_dest, int r_src) = 0;
686 virtual LIR* OpRegImm(OpKind op, int r_dest_src1, int value) = 0;
687 virtual LIR* OpRegMem(OpKind op, int r_dest, int rBase, int offset) = 0;
688 virtual LIR* OpRegReg(OpKind op, int r_dest_src1, int r_src2) = 0;
689 virtual LIR* OpRegRegImm(OpKind op, int r_dest, int r_src1, int value) = 0;
690 virtual LIR* OpRegRegReg(OpKind op, int r_dest, int r_src1,
691 int r_src2) = 0;
692 virtual LIR* OpTestSuspend(LIR* target) = 0;
Ian Rogers468532e2013-08-05 10:56:33 -0700693 virtual LIR* OpThreadMem(OpKind op, ThreadOffset thread_offset) = 0;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700694 virtual LIR* OpVldm(int rBase, int count) = 0;
695 virtual LIR* OpVstm(int rBase, int count) = 0;
696 virtual void OpLea(int rBase, int reg1, int reg2, int scale,
697 int offset) = 0;
698 virtual void OpRegCopyWide(int dest_lo, int dest_hi, int src_lo,
699 int src_hi) = 0;
Ian Rogers468532e2013-08-05 10:56:33 -0700700 virtual void OpTlsCmp(ThreadOffset offset, int val) = 0;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700701 virtual bool InexpensiveConstantInt(int32_t value) = 0;
702 virtual bool InexpensiveConstantFloat(int32_t value) = 0;
703 virtual bool InexpensiveConstantLong(int64_t value) = 0;
704 virtual bool InexpensiveConstantDouble(int64_t value) = 0;
705
Ian Rogersd9c4fc92013-10-01 19:45:43 -0700706 // May be optimized by targets.
707 virtual void GenMonitorEnter(int opt_flags, RegLocation rl_src);
708 virtual void GenMonitorExit(int opt_flags, RegLocation rl_src);
709
Brian Carlstrom7940e442013-07-12 13:46:57 -0700710 // Temp workaround
711 void Workaround7250540(RegLocation rl_dest, int value);
712
713 protected:
714 Mir2Lir(CompilationUnit* cu, MIRGraph* mir_graph, ArenaAllocator* arena);
715
716 CompilationUnit* GetCompilationUnit() {
717 return cu_;
718 }
719
720 private:
721 void GenInstanceofFinal(bool use_declaring_class, uint32_t type_idx, RegLocation rl_dest,
722 RegLocation rl_src);
723 void GenInstanceofCallingHelper(bool needs_access_check, bool type_known_final,
724 bool type_known_abstract, bool use_declaring_class,
725 bool can_assume_type_is_in_dex_cache,
726 uint32_t type_idx, RegLocation rl_dest,
727 RegLocation rl_src);
728
729 void ClobberBody(RegisterInfo* p);
730 void ResetDefBody(RegisterInfo* p) {
731 p->def_start = NULL;
732 p->def_end = NULL;
733 }
734
735 public:
736 // TODO: add accessors for these.
737 LIR* literal_list_; // Constants.
738 LIR* method_literal_list_; // Method literals requiring patching.
739 LIR* code_literal_list_; // Code literals requiring patching.
buzbeeb48819d2013-09-14 16:15:25 -0700740 LIR* first_fixup_; // Doubly-linked list of LIR nodes requiring fixups.
Brian Carlstrom7940e442013-07-12 13:46:57 -0700741
742 protected:
743 CompilationUnit* const cu_;
744 MIRGraph* const mir_graph_;
745 GrowableArray<SwitchTable*> switch_tables_;
746 GrowableArray<FillArrayData*> fill_array_data_;
747 GrowableArray<LIR*> throw_launchpads_;
748 GrowableArray<LIR*> suspend_launchpads_;
749 GrowableArray<LIR*> intrinsic_launchpads_;
buzbeebd663de2013-09-10 15:41:31 -0700750 GrowableArray<RegisterInfo*> tempreg_info_;
751 GrowableArray<RegisterInfo*> reginfo_map_;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700752 /*
753 * Holds mapping from native PC to dex PC for safepoints where we may deoptimize.
754 * Native PC is on the return address of the safepointed operation. Dex PC is for
755 * the instruction being executed at the safepoint.
756 */
757 std::vector<uint32_t> pc2dex_mapping_table_;
758 /*
759 * Holds mapping from Dex PC to native PC for catch entry points. Native PC and Dex PC
760 * immediately preceed the instruction.
761 */
762 std::vector<uint32_t> dex2pc_mapping_table_;
buzbeeb48819d2013-09-14 16:15:25 -0700763 int current_code_offset_; // Working byte offset of machine instructons.
Brian Carlstrom7940e442013-07-12 13:46:57 -0700764 int data_offset_; // starting offset of literal pool.
765 int total_size_; // header + code size.
766 LIR* block_label_list_;
767 PromotionMap* promotion_map_;
768 /*
769 * TODO: The code generation utilities don't have a built-in
770 * mechanism to propagate the original Dalvik opcode address to the
771 * associated generated instructions. For the trace compiler, this wasn't
772 * necessary because the interpreter handled all throws and debugging
773 * requests. For now we'll handle this by placing the Dalvik offset
774 * in the CompilationUnit struct before codegen for each instruction.
775 * The low-level LIR creation utilites will pull it from here. Rework this.
776 */
777 int current_dalvik_offset_;
buzbeeb48819d2013-09-14 16:15:25 -0700778 int estimated_native_code_size_; // Just an estimate; used to reserve code_buffer_ size.
Brian Carlstrom7940e442013-07-12 13:46:57 -0700779 RegisterPool* reg_pool_;
780 /*
781 * Sanity checking for the register temp tracking. The same ssa
782 * name should never be associated with one temp register per
783 * instruction compilation.
784 */
785 int live_sreg_;
786 CodeBuffer code_buffer_;
Ian Rogers96faf5b2013-08-09 22:05:32 -0700787 // The encoding mapping table data (dex -> pc offset and pc offset -> dex) with a size prefix.
788 UnsignedLeb128EncodingVector encoded_mapping_table_;
Brian Carlstrom7940e442013-07-12 13:46:57 -0700789 std::vector<uint32_t> core_vmap_table_;
790 std::vector<uint32_t> fp_vmap_table_;
791 std::vector<uint8_t> native_gc_map_;
792 int num_core_spills_;
793 int num_fp_spills_;
794 int frame_size_;
795 unsigned int core_spill_mask_;
796 unsigned int fp_spill_mask_;
797 LIR* first_lir_insn_;
798 LIR* last_lir_insn_;
799}; // Class Mir2Lir
800
801} // namespace art
802
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700803#endif // ART_COMPILER_DEX_QUICK_MIR_TO_LIR_H_