blob: 4f146560b2e160fce7b41d38a46f5932ae2ad947 [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"
23
buzbeeeaf09bc2012-11-15 14:51:41 -080024namespace art {
25
Brian Carlstrom641ce032013-01-31 15:21:37 -080026class CompilationUnit;
27struct LIR;
28
buzbee02031b12012-11-23 09:41:35 -080029void MarkSafepointPC(CompilationUnit* cu, LIR* inst);
30bool FastInstance(CompilationUnit* cu, uint32_t field_idx,
31 int& field_offset, bool& is_volatile, bool is_put);
32void SetupResourceMasks(CompilationUnit* cu, LIR* lir);
buzbeefa57c472012-11-21 12:06:18 -080033inline int32_t s4FromSwitchData(const void* switch_data) { return *reinterpret_cast<const int32_t*>(switch_data); }
34inline RegisterClass oat_reg_class_by_size(OpSize size) { return (size == kUnsignedHalf || size == kSignedHalf || size == kUnsignedByte || size == kSignedByte ) ? kCoreReg : kAnyReg; }
35void AssembleLIR(CompilationUnit* cu);
buzbee02031b12012-11-23 09:41:35 -080036void SetMemRefType(CompilationUnit* cu, LIR* lir, bool is_load, int mem_type);
37void AnnotateDalvikRegAccess(CompilationUnit* cu, LIR* lir, int reg_id, bool is_load, bool is64bit);
buzbeefa57c472012-11-21 12:06:18 -080038uint64_t GetRegMaskCommon(CompilationUnit* cu, int reg);
39void SetupRegMask(CompilationUnit* cu, uint64_t* mask, int reg);
40void SetupResourceMasks(CompilationUnit* cu, LIR* lir);
41void DumpLIRInsn(CompilationUnit* cu, LIR* arg, unsigned char* base_addr);
42void DumpPromotionMap(CompilationUnit *cu);
43void CodegenDump(CompilationUnit* cu);
buzbee02031b12012-11-23 09:41:35 -080044LIR* RawLIR(CompilationUnit* cu, int dalvik_offset, int opcode, int op0 = 0, int op1 = 0,
45 int op2 = 0, int op3 = 0, int op4 = 0, LIR* target = NULL);
buzbeefa57c472012-11-21 12:06:18 -080046LIR* NewLIR0(CompilationUnit* cu, int opcode);
47LIR* NewLIR1(CompilationUnit* cu, int opcode, int dest);
48LIR* NewLIR2(CompilationUnit* cu, int opcode, int dest, int src1);
49LIR* NewLIR3(CompilationUnit* cu, int opcode, int dest, int src1, int src2);
50LIR* NewLIR4(CompilationUnit* cu, int opcode, int dest, int src1, int src2, int info);
51LIR* NewLIR5(CompilationUnit* cu, int opcode, int dest, int src1, int src2, int info1, int info2);
52LIR* ScanLiteralPool(LIR* data_target, int value, unsigned int delta);
53LIR* ScanLiteralPoolWide(LIR* data_target, int val_lo, int val_hi);
54LIR* AddWordData(CompilationUnit* cu, LIR* *constant_list_p, int value);
55LIR* AddWideData(CompilationUnit* cu, LIR* *constant_list_p, int val_lo, int val_hi);
56void ProcessSwitchTables(CompilationUnit* cu);
buzbee52a77fc2012-11-20 19:50:46 -080057void DumpSparseSwitchTable(const uint16_t* table);
58void DumpPackedSwitchTable(const uint16_t* table);
buzbeefa57c472012-11-21 12:06:18 -080059LIR* MarkBoundary(CompilationUnit* cu, int offset, const char* inst_str);
buzbee02031b12012-11-23 09:41:35 -080060void NopLIR(LIR* lir);
buzbeee6285f92012-12-06 15:57:46 -080061bool EvaluateBranch(Instruction::Code opcode, int src1, int src2);
buzbeeeaf09bc2012-11-15 14:51:41 -080062
63} // namespace art
64
65#endif // ART_SRC_COMPILER_CODEGEN_CODEGENUTIL_H_