buzbee | eaf09bc | 2012-11-15 14:51:41 -0800 | [diff] [blame] | 1 | /* |
| 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 Carlstrom | 641ce03 | 2013-01-31 15:21:37 -0800 | [diff] [blame] | 20 | #include <stdint.h> |
| 21 | |
| 22 | #include "compiler/compiler_enums.h" |
buzbee | 4ef3e45 | 2012-12-14 13:35:28 -0800 | [diff] [blame] | 23 | #include "compiler/compiler_ir.h" |
Brian Carlstrom | 641ce03 | 2013-01-31 15:21:37 -0800 | [diff] [blame] | 24 | |
buzbee | eaf09bc | 2012-11-15 14:51:41 -0800 | [diff] [blame] | 25 | namespace art { |
| 26 | |
Brian Carlstrom | 641ce03 | 2013-01-31 15:21:37 -0800 | [diff] [blame] | 27 | class CompilationUnit; |
| 28 | struct LIR; |
| 29 | |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 30 | void MarkSafepointPC(CompilationUnit* cu, LIR* inst); |
| 31 | bool FastInstance(CompilationUnit* cu, uint32_t field_idx, |
| 32 | int& field_offset, bool& is_volatile, bool is_put); |
| 33 | void SetupResourceMasks(CompilationUnit* cu, LIR* lir); |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 34 | inline int32_t s4FromSwitchData(const void* switch_data) { return *reinterpret_cast<const int32_t*>(switch_data); } |
| 35 | inline RegisterClass oat_reg_class_by_size(OpSize size) { return (size == kUnsignedHalf || size == kSignedHalf || size == kUnsignedByte || size == kSignedByte ) ? kCoreReg : kAnyReg; } |
| 36 | void AssembleLIR(CompilationUnit* cu); |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 37 | void SetMemRefType(CompilationUnit* cu, LIR* lir, bool is_load, int mem_type); |
| 38 | void AnnotateDalvikRegAccess(CompilationUnit* cu, LIR* lir, int reg_id, bool is_load, bool is64bit); |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 39 | uint64_t GetRegMaskCommon(CompilationUnit* cu, int reg); |
| 40 | void SetupRegMask(CompilationUnit* cu, uint64_t* mask, int reg); |
| 41 | void SetupResourceMasks(CompilationUnit* cu, LIR* lir); |
| 42 | void DumpLIRInsn(CompilationUnit* cu, LIR* arg, unsigned char* base_addr); |
| 43 | void DumpPromotionMap(CompilationUnit *cu); |
| 44 | void CodegenDump(CompilationUnit* cu); |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 45 | LIR* 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); |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 47 | LIR* NewLIR0(CompilationUnit* cu, int opcode); |
| 48 | LIR* NewLIR1(CompilationUnit* cu, int opcode, int dest); |
| 49 | LIR* NewLIR2(CompilationUnit* cu, int opcode, int dest, int src1); |
| 50 | LIR* NewLIR3(CompilationUnit* cu, int opcode, int dest, int src1, int src2); |
| 51 | LIR* NewLIR4(CompilationUnit* cu, int opcode, int dest, int src1, int src2, int info); |
| 52 | LIR* NewLIR5(CompilationUnit* cu, int opcode, int dest, int src1, int src2, int info1, int info2); |
| 53 | LIR* ScanLiteralPool(LIR* data_target, int value, unsigned int delta); |
| 54 | LIR* ScanLiteralPoolWide(LIR* data_target, int val_lo, int val_hi); |
| 55 | LIR* AddWordData(CompilationUnit* cu, LIR* *constant_list_p, int value); |
| 56 | LIR* AddWideData(CompilationUnit* cu, LIR* *constant_list_p, int val_lo, int val_hi); |
| 57 | void ProcessSwitchTables(CompilationUnit* cu); |
buzbee | 52a77fc | 2012-11-20 19:50:46 -0800 | [diff] [blame] | 58 | void DumpSparseSwitchTable(const uint16_t* table); |
| 59 | void DumpPackedSwitchTable(const uint16_t* table); |
buzbee | fa57c47 | 2012-11-21 12:06:18 -0800 | [diff] [blame] | 60 | LIR* MarkBoundary(CompilationUnit* cu, int offset, const char* inst_str); |
buzbee | 02031b1 | 2012-11-23 09:41:35 -0800 | [diff] [blame] | 61 | void NopLIR(LIR* lir); |
buzbee | e6285f9 | 2012-12-06 15:57:46 -0800 | [diff] [blame] | 62 | bool EvaluateBranch(Instruction::Code opcode, int src1, int src2); |
buzbee | 4ef3e45 | 2012-12-14 13:35:28 -0800 | [diff] [blame] | 63 | bool IsInexpensiveConstant(CompilationUnit* cu, RegLocation rl_src); |
| 64 | ConditionCode FlipComparisonOrder(ConditionCode before); |
buzbee | eaf09bc | 2012-11-15 14:51:41 -0800 | [diff] [blame] | 65 | |
| 66 | } // namespace art |
| 67 | |
| 68 | #endif // ART_SRC_COMPILER_CODEGEN_CODEGENUTIL_H_ |