| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2009 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 _DALVIK_VM_COMPILER_IR |
| 18 | #define _DALVIK_VM_COMPILER_IR |
| 19 | |
| 20 | typedef enum BBType { |
| 21 | /* For coding convenience reasons chaining cell types should appear first */ |
| 22 | CHAINING_CELL_GENERIC = 0, |
| 23 | CHAINING_CELL_POST_INVOKE, |
| 24 | CHAINING_CELL_INVOKE, |
| 25 | CHAINING_CELL_LAST, |
| 26 | DALVIK_BYTECODE, |
| 27 | PC_RECONSTRUCTION, |
| 28 | EXCEPTION_HANDLING, |
| 29 | } BBType; |
| 30 | |
| 31 | typedef struct LIR { |
| 32 | int offset; |
| 33 | struct LIR *next; |
| 34 | struct LIR *prev; |
| 35 | struct LIR *target; |
| 36 | } LIR; |
| 37 | |
| 38 | typedef struct MIR { |
| 39 | DecodedInstruction dalvikInsn; |
| 40 | unsigned int width; |
| 41 | unsigned int offset; |
| 42 | struct MIR *prev; |
| 43 | struct MIR *next; |
| 44 | } MIR; |
| 45 | |
| 46 | typedef struct BasicBlock { |
| 47 | int id; |
| 48 | int visited; |
| 49 | unsigned int startOffset; |
| 50 | const Method *containingMethod; // For blocks from the callee |
| 51 | BBType blockType; |
| 52 | MIR *firstMIRInsn; |
| 53 | MIR *lastMIRInsn; |
| 54 | struct BasicBlock *fallThrough; |
| 55 | struct BasicBlock *taken; |
| 56 | struct BasicBlock *next; // Serial link for book keeping purposes |
| 57 | } BasicBlock; |
| 58 | |
| 59 | typedef struct CompilationUnit { |
| 60 | int numBlocks; |
| 61 | BasicBlock **blockList; |
| 62 | const Method *method; |
| 63 | const JitTraceDescription *traceDesc; |
| 64 | LIR *firstLIRInsn; |
| 65 | LIR *lastLIRInsn; |
| 66 | LIR *wordList; |
| 67 | GrowableList pcReconstructionList; |
| 68 | int dataOffset; |
| 69 | int totalSize; |
| 70 | unsigned char *codeBuffer; |
| 71 | void *baseAddr; |
| 72 | bool printMe; |
| 73 | bool allSingleStep; |
| 74 | int numChainingCells[CHAINING_CELL_LAST]; |
| 75 | LIR *firstChainingLIR[CHAINING_CELL_LAST]; |
| 76 | } CompilationUnit; |
| 77 | |
| 78 | BasicBlock *dvmCompilerNewBB(BBType blockType); |
| 79 | |
| 80 | void dvmCompilerAppendMIR(BasicBlock *bb, MIR *mir); |
| 81 | |
| 82 | void dvmCompilerAppendLIR(CompilationUnit *cUnit, LIR *lir); |
| 83 | |
| 84 | /* Debug Utilities */ |
| 85 | void dvmCompilerDumpCompilationUnit(CompilationUnit *cUnit); |
| 86 | |
| 87 | #endif /* _DALVIK_VM_COMPILER_IR */ |