Zonr Chang | 8b2c3e7 | 2012-04-12 15:34:58 +0800 | [diff] [blame^] | 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_EXECUTION_ENGINE_TARGET_COMPILER_CONFIGS_H |
| 18 | #define BCC_EXECUTION_ENGINE_TARGET_COMPILER_CONFIGS_H |
| 19 | |
| 20 | #include "CompilerConfig.h" |
| 21 | #include "Config.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 | return; |
| 65 | } |
| 66 | }; |
| 67 | |
| 68 | class X86_32CompilerConfig : public X86FamilyCompilerConfigBase { |
| 69 | public: |
| 70 | X86_32CompilerConfig() : |
| 71 | X86FamilyCompilerConfigBase(DEFAULT_X86_TRIPLE_STRING) { } |
| 72 | }; |
| 73 | |
| 74 | class X86_64CompilerConfig : public X86FamilyCompilerConfigBase { |
| 75 | public: |
| 76 | X86_64CompilerConfig() : |
| 77 | X86FamilyCompilerConfigBase(DEFAULT_X86_64_TRIPLE_STRING) { |
| 78 | setCodeModel(llvm::CodeModel::Medium); |
| 79 | } |
| 80 | }; |
| 81 | #endif // defined(PROVIDE_X86_CODEGEN) |
| 82 | |
| 83 | //===----------------------------------------------------------------------===// |
| 84 | // Default target |
| 85 | //===----------------------------------------------------------------------===// |
| 86 | class DefaultCompilerConfig : public |
| 87 | #if defined(DEFAULT_ARM_CODEGEN) |
| 88 | ARMCompilerConfig |
| 89 | #elif defined(DEFAULT_MIPS_CODEGEN) |
| 90 | MipsCompilerConfig |
| 91 | #elif defined(DEFAULT_X86_CODEGEN) |
| 92 | X86_32CompilerConfig |
| 93 | #elif defined(DEFAULT_X86_64_CODEGEN) |
| 94 | X86_64CompilerConfig |
| 95 | #else |
| 96 | # error "Unsupported Default Target!" |
| 97 | #endif |
| 98 | { }; |
| 99 | |
| 100 | } // end namespace bcc |
| 101 | |
| 102 | #endif // BCC_EXECUTION_ENGINE_TARGET_COMPILER_CONFIGS_H |