Home | History | Annotate | Download | only in Support
      1 /*
      2  * Copyright 2012, 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 BCC_SUPPORT_TARGET_COMPILER_CONFIGS_H
     18 #define BCC_SUPPORT_TARGET_COMPILER_CONFIGS_H
     19 
     20 #include "bcc/Config/Config.h"
     21 #include "bcc/Support/CompilerConfig.h"
     22 
     23 namespace bcc {
     24 
     25 //===----------------------------------------------------------------------===//
     26 // ARM
     27 //===----------------------------------------------------------------------===//
     28 #if defined(PROVIDE_ARM_CODEGEN)
     29 class ARMCompilerConfig : public CompilerConfig {
     30 private:
     31   bool mEnableNEON;
     32 
     33   static void GetFeatureVector(std::vector<std::string> &pAttributes,
     34                                bool pEnableNEON);
     35 
     36 public:
     37   ARMCompilerConfig();
     38 
     39   // Return true if config has been changed after returning from this function.
     40   bool enableNEON(bool pEnable = true);
     41 };
     42 #endif // defined(PROVIDE_ARM_CODEGEN)
     43 
     44 //===----------------------------------------------------------------------===//
     45 // MIPS
     46 //===----------------------------------------------------------------------===//
     47 #if defined(PROVIDE_MIPS_CODEGEN)
     48 class MipsCompilerConfig : public CompilerConfig {
     49 public:
     50   MipsCompilerConfig() : CompilerConfig(DEFAULT_MIPS_TRIPLE_STRING) {}
     51 };
     52 #endif // defined(PROVIDE_MIPS_CODEGEN)
     53 
     54 //===----------------------------------------------------------------------===//
     55 // X86 and X86_64
     56 //===----------------------------------------------------------------------===//
     57 #if defined(PROVIDE_X86_CODEGEN)
     58 class X86FamilyCompilerConfigBase : public CompilerConfig {
     59 protected:
     60   X86FamilyCompilerConfigBase(const std::string &pTriple)
     61     : CompilerConfig(pTriple) {
     62     // Disable frame pointer elimination optimization on x86 family.
     63     getTargetOptions().NoFramePointerElim = true;
     64     getTargetOptions().UseInitArray = true;
     65     return;
     66   }
     67 };
     68 
     69 class X86_32CompilerConfig : public X86FamilyCompilerConfigBase {
     70 public:
     71   X86_32CompilerConfig() :
     72       X86FamilyCompilerConfigBase(DEFAULT_X86_TRIPLE_STRING) { }
     73 };
     74 
     75 class X86_64CompilerConfig : public X86FamilyCompilerConfigBase {
     76 public:
     77   X86_64CompilerConfig() :
     78       X86FamilyCompilerConfigBase(DEFAULT_X86_64_TRIPLE_STRING) {
     79     setCodeModel(llvm::CodeModel::Medium);
     80   }
     81 };
     82 #endif // defined(PROVIDE_X86_CODEGEN)
     83 
     84 //===----------------------------------------------------------------------===//
     85 // Default target
     86 //===----------------------------------------------------------------------===//
     87 class DefaultCompilerConfig : public
     88 #if defined(DEFAULT_ARM_CODEGEN)
     89   ARMCompilerConfig
     90 #elif defined(DEFAULT_MIPS_CODEGEN)
     91   MipsCompilerConfig
     92 #elif defined(DEFAULT_X86_CODEGEN)
     93   X86_32CompilerConfig
     94 #elif defined(DEFAULT_X86_64_CODEGEN)
     95   X86_64CompilerConfig
     96 #else
     97 #  error "Unsupported Default Target!"
     98 #endif
     99 { };
    100 
    101 } // end namespace bcc
    102 
    103 #endif // BCC_SUPPORT_TARGET_COMPILER_CONFIGS_H
    104