blob: 9b9bece5853152c1d9ce8331c697e13452e616b0 [file] [log] [blame]
buzbeeeaf09bc2012-11-15 14:51:41 -08001/*
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
17#ifndef ART_SRC_COMPILER_CODEGEN_CODEGENUTIL_H_
18#define ART_SRC_COMPILER_CODEGEN_CODEGENUTIL_H_
19
Brian Carlstrom641ce032013-01-31 15:21:37 -080020#include <stdint.h>
21
22#include "compiler/compiler_enums.h"
buzbee4ef3e452012-12-14 13:35:28 -080023#include "compiler/compiler_ir.h"
Brian Carlstrom641ce032013-01-31 15:21:37 -080024
buzbeeeaf09bc2012-11-15 14:51:41 -080025namespace art {
26
Brian Carlstrom641ce032013-01-31 15:21:37 -080027class CompilationUnit;
28struct LIR;
29
buzbee02031b12012-11-23 09:41:35 -080030void MarkSafepointPC(CompilationUnit* cu, LIR* inst);
31bool FastInstance(CompilationUnit* cu, uint32_t field_idx,
32 int& field_offset, bool& is_volatile, bool is_put);
33void SetupResourceMasks(CompilationUnit* cu, LIR* lir);
buzbeefa57c472012-11-21 12:06:18 -080034inline int32_t s4FromSwitchData(const void* switch_data) { return *reinterpret_cast<const int32_t*>(switch_data); }
35inline RegisterClass oat_reg_class_by_size(OpSize size) { return (size == kUnsignedHalf || size == kSignedHalf || size == kUnsignedByte || size == kSignedByte ) ? kCoreReg : kAnyReg; }
36void AssembleLIR(CompilationUnit* cu);
buzbee02031b12012-11-23 09:41:35 -080037void SetMemRefType(CompilationUnit* cu, LIR* lir, bool is_load, int mem_type);
38void AnnotateDalvikRegAccess(CompilationUnit* cu, LIR* lir, int reg_id, bool is_load, bool is64bit);
buzbeefa57c472012-11-21 12:06:18 -080039uint64_t GetRegMaskCommon(CompilationUnit* cu, int reg);
40void SetupRegMask(CompilationUnit* cu, uint64_t* mask, int reg);
41void SetupResourceMasks(CompilationUnit* cu, LIR* lir);
42void DumpLIRInsn(CompilationUnit* cu, LIR* arg, unsigned char* base_addr);
43void DumpPromotionMap(CompilationUnit *cu);
44void CodegenDump(CompilationUnit* cu);
buzbee02031b12012-11-23 09:41:35 -080045LIR* RawLIR(CompilationUnit* cu, int dalvik_offset, int opcode, int op0 = 0, int op1 = 0,
46 int op2 = 0, int op3 = 0, int op4 = 0, LIR* target = NULL);
buzbeefa57c472012-11-21 12:06:18 -080047LIR* NewLIR0(CompilationUnit* cu, int opcode);
48LIR* NewLIR1(CompilationUnit* cu, int opcode, int dest);
49LIR* NewLIR2(CompilationUnit* cu, int opcode, int dest, int src1);
50LIR* NewLIR3(CompilationUnit* cu, int opcode, int dest, int src1, int src2);
51LIR* NewLIR4(CompilationUnit* cu, int opcode, int dest, int src1, int src2, int info);
52LIR* NewLIR5(CompilationUnit* cu, int opcode, int dest, int src1, int src2, int info1, int info2);
53LIR* ScanLiteralPool(LIR* data_target, int value, unsigned int delta);
54LIR* ScanLiteralPoolWide(LIR* data_target, int val_lo, int val_hi);
55LIR* AddWordData(CompilationUnit* cu, LIR* *constant_list_p, int value);
56LIR* AddWideData(CompilationUnit* cu, LIR* *constant_list_p, int val_lo, int val_hi);
57void ProcessSwitchTables(CompilationUnit* cu);
buzbee52a77fc2012-11-20 19:50:46 -080058void DumpSparseSwitchTable(const uint16_t* table);
59void DumpPackedSwitchTable(const uint16_t* table);
buzbeefa57c472012-11-21 12:06:18 -080060LIR* MarkBoundary(CompilationUnit* cu, int offset, const char* inst_str);
buzbee02031b12012-11-23 09:41:35 -080061void NopLIR(LIR* lir);
buzbeee6285f92012-12-06 15:57:46 -080062bool EvaluateBranch(Instruction::Code opcode, int src1, int src2);
buzbee4ef3e452012-12-14 13:35:28 -080063bool IsInexpensiveConstant(CompilationUnit* cu, RegLocation rl_src);
64ConditionCode FlipComparisonOrder(ConditionCode before);
buzbeeeaf09bc2012-11-15 14:51:41 -080065
66} // namespace art
67
68#endif // ART_SRC_COMPILER_CODEGEN_CODEGENUTIL_H_