blob: 67cb637b4a5904a218f0a3fb71b5252725a35093 [file] [log] [blame]
Ben Chengba4fc8b2009-06-01 13:00:29 -07001/*
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
20typedef 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
Bill Buzbee46cd5b62009-06-05 15:36:06 -070031typedef struct ChainCellCounts {
32 union {
33 u1 count[CHAINING_CELL_LAST];
34 u4 dummyForAlignment;
35 } u;
36} ChainCellCounts;
37
Ben Chengba4fc8b2009-06-01 13:00:29 -070038typedef struct LIR {
39 int offset;
40 struct LIR *next;
41 struct LIR *prev;
42 struct LIR *target;
43} LIR;
44
45typedef struct MIR {
46 DecodedInstruction dalvikInsn;
47 unsigned int width;
48 unsigned int offset;
49 struct MIR *prev;
50 struct MIR *next;
51} MIR;
52
53typedef struct BasicBlock {
54 int id;
55 int visited;
56 unsigned int startOffset;
57 const Method *containingMethod; // For blocks from the callee
58 BBType blockType;
59 MIR *firstMIRInsn;
60 MIR *lastMIRInsn;
61 struct BasicBlock *fallThrough;
62 struct BasicBlock *taken;
63 struct BasicBlock *next; // Serial link for book keeping purposes
64} BasicBlock;
65
66typedef struct CompilationUnit {
67 int numBlocks;
68 BasicBlock **blockList;
69 const Method *method;
70 const JitTraceDescription *traceDesc;
71 LIR *firstLIRInsn;
72 LIR *lastLIRInsn;
73 LIR *wordList;
74 GrowableList pcReconstructionList;
75 int dataOffset;
76 int totalSize;
77 unsigned char *codeBuffer;
78 void *baseAddr;
79 bool printMe;
80 bool allSingleStep;
81 int numChainingCells[CHAINING_CELL_LAST];
82 LIR *firstChainingLIR[CHAINING_CELL_LAST];
83} CompilationUnit;
84
85BasicBlock *dvmCompilerNewBB(BBType blockType);
86
87void dvmCompilerAppendMIR(BasicBlock *bb, MIR *mir);
88
89void dvmCompilerAppendLIR(CompilationUnit *cUnit, LIR *lir);
90
91/* Debug Utilities */
92void dvmCompilerDumpCompilationUnit(CompilationUnit *cUnit);
93
94#endif /* _DALVIK_VM_COMPILER_IR */