2 * Copyright (C) 2009 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include "codegen/Optimizer.h"
19 #ifndef _DALVIK_VM_COMPILER_IR
20 #define _DALVIK_VM_COMPILER_IR
23 /* For coding convenience reasons chaining cell types should appear first */
24 CHAINING_CELL_NORMAL = 0,
26 CHAINING_CELL_INVOKE_SINGLETON,
27 CHAINING_CELL_INVOKE_PREDICTED,
28 CHAINING_CELL_BACKWARD_BRANCH,
35 typedef struct ChainCellCounts {
37 u1 count[CHAINING_CELL_LAST];
50 DecodedInstruction dalvikInsn;
57 typedef struct BasicBlock {
60 unsigned int startOffset;
61 const Method *containingMethod; // For blocks from the callee
63 bool needFallThroughBranch; // For blocks ended due to length limit
66 struct BasicBlock *fallThrough;
67 struct BasicBlock *taken;
68 struct BasicBlock *next; // Serial link for book keeping purposes
71 typedef struct CompilationUnit {
74 BasicBlock **blockList;
76 const JitTraceDescription *traceDesc;
80 LIR *chainCellOffsetLIR;
81 GrowableList pcReconstructionList;
82 int headerSize; // bytes before the first code ptr
83 int dataOffset; // starting offset of literal pool
84 int totalSize; // header + code size
85 unsigned char *codeBuffer;
90 bool executionCount; // Add code to count trace executions
91 int numChainingCells[CHAINING_CELL_LAST];
92 LIR *firstChainingLIR[CHAINING_CELL_LAST];
93 RegisterScoreboard registerScoreboard; // Track register dependency
94 int optRound; // round number to tell an LIR's age
95 JitInstructionSetType instructionSet;
98 BasicBlock *dvmCompilerNewBB(BBType blockType);
100 void dvmCompilerAppendMIR(BasicBlock *bb, MIR *mir);
102 void dvmCompilerAppendLIR(CompilationUnit *cUnit, LIR *lir);
104 void dvmCompilerInsertLIRBefore(LIR *currentLIR, LIR *newLIR);
106 /* Debug Utilities */
107 void dvmCompilerDumpCompilationUnit(CompilationUnit *cUnit);
109 #endif /* _DALVIK_VM_COMPILER_IR */