buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [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_COMPILERCODEGEN_H_ |
| 18 | #define ART_SRC_COMPILER_COMPILERCODEGEN_H_ |
| 19 | |
| 20 | #include "../CompilerIR.h" |
| 21 | |
Elliott Hughes | 11d1b0c | 2012-01-23 16:57:47 -0800 | [diff] [blame] | 22 | namespace art { |
| 23 | |
buzbee | a2ebdd7 | 2012-03-04 14:57:06 -0800 | [diff] [blame] | 24 | LIR* rawLIR(CompilationUnit* cUnit, int dalvikOffset, int opcode, int op0 = 0, |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 25 | int op1 = 0, int op2 = 0, int op3 = 0, int op4 = 0, |
| 26 | LIR* target = NULL); |
buzbee | a2ebdd7 | 2012-03-04 14:57:06 -0800 | [diff] [blame] | 27 | |
buzbee | e88dfbf | 2012-03-05 11:19:57 -0800 | [diff] [blame] | 28 | int oatGetInsnSize(LIR* lir); |
| 29 | |
buzbee | 84fd693 | 2012-03-29 16:44:16 -0700 | [diff] [blame] | 30 | void genFusedLongCmpBranch(CompilationUnit* cUnit, BasicBlock* bb, MIR* mir); |
| 31 | void genFusedFPCmpBranch(CompilationUnit* cUnit, BasicBlock* bb, MIR* mir, |
| 32 | bool gtBias, bool isDouble); |
| 33 | |
buzbee | 6969d50 | 2012-06-15 16:40:31 -0700 | [diff] [blame] | 34 | CallInfo* oatNewCallInfo(CompilationUnit* cUnit, BasicBlock* bb, MIR* mir, |
| 35 | InvokeType type, bool isRange); |
buzbee | 84fd693 | 2012-03-29 16:44:16 -0700 | [diff] [blame] | 36 | |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 37 | /* Lower middle-level IR to low-level IR for the whole method */ |
| 38 | void oatMethodMIR2LIR(CompilationUnit* cUnit); |
| 39 | |
buzbee | 2cfc639 | 2012-05-07 14:51:40 -0700 | [diff] [blame] | 40 | /* Bitcode conversions */ |
| 41 | void oatMethodMIR2Bitcode(CompilationUnit* cUnit); |
| 42 | void oatMethodBitcode2LIR(CompilationUnit* cUnit); |
| 43 | |
buzbee | 16da88c | 2012-03-20 10:38:17 -0700 | [diff] [blame] | 44 | /* Lower middle-level IR to low-level IR for the simple methods */ |
| 45 | void oatSpecialMIR2LIR(CompilationUnit* cUnit, SpecialCaseHandler specialCase ); |
| 46 | |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 47 | /* Assemble LIR into machine code */ |
| 48 | void oatAssembleLIR(CompilationUnit* cUnit); |
buzbee | e3acd07 | 2012-02-25 17:03:10 -0800 | [diff] [blame] | 49 | AssemblerStatus oatAssembleInstructions(CompilationUnit* cUnit, |
| 50 | intptr_t startAddr); |
| 51 | void oatAssignOffsets(CompilationUnit* cUnit); |
| 52 | int oatAssignInsnOffsets(CompilationUnit* cUnit); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 53 | |
| 54 | /* Implemented in the codegen/<target>/ArchUtility.c */ |
| 55 | void oatCodegenDump(CompilationUnit* cUnit); |
buzbee | 67bc236 | 2011-10-11 18:08:40 -0700 | [diff] [blame] | 56 | void oatDumpPromotionMap(CompilationUnit* cUnit); |
buzbee | 5de3494 | 2012-03-01 14:51:57 -0800 | [diff] [blame] | 57 | std::string buildInsnString(const char* fmt, LIR* lir, |
| 58 | unsigned char* baseAddr); |
| 59 | |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 60 | |
| 61 | /* Implemented in codegen/<target>/Ralloc.c */ |
| 62 | void oatSimpleRegAlloc(CompilationUnit* cUnit); |
| 63 | |
| 64 | /* Implemented in codegen/<target>/Thumb<version>Util.c */ |
| 65 | void oatInitializeRegAlloc(CompilationUnit* cUnit); |
| 66 | |
| 67 | /* Implemented in codegen/<target>/<target_variant>/ArchVariant.c */ |
Elliott Hughes | b3bd5f0 | 2012-03-08 21:05:27 -0800 | [diff] [blame] | 68 | InstructionSet oatInstructionSet(); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 69 | |
| 70 | /* |
| 71 | * Implemented in codegen/<target>/<target_variant>/ArchVariant.c |
| 72 | * Architecture-specific initializations and checks |
| 73 | */ |
| 74 | bool oatArchVariantInit(void); |
| 75 | |
| 76 | /* Implemented in codegen/<target>/<target_variant>/ArchVariant.c */ |
| 77 | int oatTargetOptHint(int key); |
| 78 | |
| 79 | /* Implemented in codegen/<target>/<target_variant>/ArchVariant.c */ |
| 80 | void oatGenMemBarrier(CompilationUnit* cUnit, int barrierKind); |
| 81 | |
buzbee | b046e16 | 2012-10-30 15:48:42 -0700 | [diff] [blame] | 82 | LIR* genRegMemCheck(CompilationUnit* cUnit, ConditionCode cCode, |
| 83 | int reg1, int base, int offset, ThrowKind kind); |
| 84 | LIR* opThreadMem(CompilationUnit* cUnit, OpKind op, int threadOffset); |
| 85 | LIR* opMem(CompilationUnit* cUnit, OpKind op, int rBase, int disp); |
| 86 | LIR* storeBaseIndexedDisp(CompilationUnit *cUnit, |
| 87 | int rBase, int rIndex, int scale, int displacement, |
| 88 | int rSrc, int rSrcHi, OpSize size, int sReg); |
| 89 | LIR* opRegMem(CompilationUnit *cUnit, OpKind op, int rDest, int rBase, int offset); |
| 90 | LIR* opCmpBranch(CompilationUnit* cUnit, ConditionCode cond, int src1, |
| 91 | int src2, LIR* target); |
| 92 | void oatSetupRegMask(CompilationUnit* cUnit, u8* mask, int reg); |
| 93 | u8 oatGetRegMaskCommon(CompilationUnit* cUnit, int reg); |
| 94 | void setupTargetResourceMasks(CompilationUnit* cUnit, LIR* lir); |
| 95 | RegLocation genDivRem(CompilationUnit* cUnit, RegLocation rlDest, int regLo, int regHi, bool isDiv); |
| 96 | RegLocation genDivRemLit(CompilationUnit* cUnit, RegLocation rlDest, int regLo, int lit, bool isDiv); |
| 97 | void markGCCard(CompilationUnit* cUnit, int valReg, int tgtAddrReg); |
| 98 | bool genInlinedMinMaxInt(CompilationUnit *cUnit, CallInfo* info, bool isMin); |
| 99 | void opLea(CompilationUnit* cUnit, int rBase, int reg1, int reg2, int scale, int offset); |
| 100 | void opTlsCmp(CompilationUnit* cUnit, int offset, int val); |
| 101 | bool genInlinedSqrt(CompilationUnit* cUnit, CallInfo* info); |
| 102 | bool genInlinedCas32(CompilationUnit* cUnit, CallInfo* info, bool need_write_barrier); |
| 103 | LIR* opPcRelLoad(CompilationUnit* cUnit, int reg, LIR* target); |
| 104 | LIR* opVldm(CompilationUnit* cUnit, int rBase, int count); |
| 105 | LIR* opVstm(CompilationUnit* cUnit, int rBase, int count); |
| 106 | void genMultiplyByTwoBitMultiplier(CompilationUnit* cUnit, RegLocation rlSrc, |
| 107 | RegLocation rlResult, int lit, |
| 108 | int firstBit, int secondBit); |
| 109 | RegLocation inlineTarget(CompilationUnit* cUnit, CallInfo* info); |
| 110 | RegLocation inlineTargetWide(CompilationUnit* cUnit, CallInfo* info); |
| 111 | void genDivZeroCheck(CompilationUnit* cUnit, int regLo, int regHi); |
| 112 | LIR* genImmedCheck(CompilationUnit* cUnit, ConditionCode cCode, |
| 113 | int reg, int immVal, ThrowKind kind); |
| 114 | LIR* opTestSuspend(CompilationUnit* cUnit, LIR* target); |
| 115 | LIR* opDecAndBranch(CompilationUnit* cUnit, ConditionCode cCode, int reg, LIR* target); |
| 116 | LIR* opIT(CompilationUnit* cUnit, ArmConditionCode cond, const char* guide); |
| 117 | |
Elliott Hughes | 11d1b0c | 2012-01-23 16:57:47 -0800 | [diff] [blame] | 118 | } // namespace art |
| 119 | |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 120 | #endif // ART_SRC_COMPILER_COMPILERCODEGEN_H_ |