Home | History | Annotate | Download | only in dex
      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_COMPILER_DEX_FRONTEND_H_
     18 #define ART_COMPILER_DEX_FRONTEND_H_
     19 
     20 #include "dex_file.h"
     21 #include "dex_instruction.h"
     22 
     23 
     24 
     25 
     26 
     27 
     28 namespace llvm {
     29   class Module;
     30   class LLVMContext;
     31 }
     32 
     33 namespace art {
     34 namespace llvm {
     35   class IntrinsicHelper;
     36   class IRBuilder;
     37 }
     38 
     39 /*
     40  * Assembly is an iterative process, and usually terminates within
     41  * two or three passes.  This should be high enough to handle bizarre
     42  * cases, but detect an infinite loop bug.
     43  */
     44 #define MAX_ASSEMBLER_RETRIES 50
     45 
     46 // Suppress optimization if corresponding bit set.
     47 enum opt_control_vector {
     48   kLoadStoreElimination = 0,
     49   kLoadHoisting,
     50   kSuppressLoads,
     51   kNullCheckElimination,
     52   kPromoteRegs,
     53   kTrackLiveTemps,
     54   kSafeOptimizations,
     55   kBBOpt,
     56   kMatch,
     57   kPromoteCompilerTemps,
     58   kBranchFusing,
     59 };
     60 
     61 // Force code generation paths for testing.
     62 enum debugControlVector {
     63   kDebugVerbose,
     64   kDebugDumpCFG,
     65   kDebugSlowFieldPath,
     66   kDebugSlowInvokePath,
     67   kDebugSlowStringPath,
     68   kDebugSlowTypePath,
     69   kDebugSlowestFieldPath,
     70   kDebugSlowestStringPath,
     71   kDebugExerciseResolveMethod,
     72   kDebugVerifyDataflow,
     73   kDebugShowMemoryUsage,
     74   kDebugShowNops,
     75   kDebugCountOpcodes,
     76   kDebugDumpCheckStats,
     77   kDebugDumpBitcodeFile,
     78   kDebugVerifyBitcode,
     79   kDebugShowSummaryMemoryUsage,
     80   kDebugShowFilterStats,
     81 };
     82 
     83 class LLVMInfo {
     84   public:
     85     LLVMInfo();
     86     ~LLVMInfo();
     87 
     88     ::llvm::LLVMContext* GetLLVMContext() {
     89       return llvm_context_.get();
     90     }
     91 
     92     ::llvm::Module* GetLLVMModule() {
     93       return llvm_module_;
     94     }
     95 
     96     art::llvm::IntrinsicHelper* GetIntrinsicHelper() {
     97       return intrinsic_helper_.get();
     98     }
     99 
    100     art::llvm::IRBuilder* GetIRBuilder() {
    101       return ir_builder_.get();
    102     }
    103 
    104   private:
    105     UniquePtr< ::llvm::LLVMContext> llvm_context_;
    106     ::llvm::Module* llvm_module_;  // Managed by context_.
    107     UniquePtr<art::llvm::IntrinsicHelper> intrinsic_helper_;
    108     UniquePtr<art::llvm::IRBuilder> ir_builder_;
    109 };
    110 
    111 struct CompilationUnit;
    112 struct BasicBlock;
    113 
    114 }  // namespace art
    115 
    116 extern "C" art::CompiledMethod* ArtCompileMethod(art::CompilerDriver& driver,
    117                                                  const art::DexFile::CodeItem* code_item,
    118                                                  uint32_t access_flags,
    119                                                  art::InvokeType invoke_type,
    120                                                  uint16_t class_def_idx,
    121                                                  uint32_t method_idx,
    122                                                  jobject class_loader,
    123                                                  const art::DexFile& dex_file);
    124 
    125 
    126 
    127 #endif  // ART_COMPILER_DEX_FRONTEND_H_
    128