blob: bf10a7a2fb8fda508df522cd48b5e445c95ce661 [file] [log] [blame]
Zonr Chang8b2c3e72012-04-12 15:34:58 +08001/*
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
Stephen Hines2f6a4932012-05-03 12:27:13 -070017#ifndef BCC_EXECUTION_ENGINE_TARGET_COMPILER_CONFIGS_H
18#define BCC_EXECUTION_ENGINE_TARGET_COMPILER_CONFIGS_H
Zonr Chang8b2c3e72012-04-12 15:34:58 +080019
Stephen Hines2f6a4932012-05-03 12:27:13 -070020#include "CompilerConfig.h"
21#include "Config.h"
Zonr Chang8b2c3e72012-04-12 15:34:58 +080022
23namespace bcc {
24
25//===----------------------------------------------------------------------===//
26// ARM
27//===----------------------------------------------------------------------===//
28#if defined(PROVIDE_ARM_CODEGEN)
29class ARMCompilerConfig : public CompilerConfig {
30private:
31 bool mEnableNEON;
32
33 static void GetFeatureVector(std::vector<std::string> &pAttributes,
34 bool pEnableNEON);
35
36public:
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)
48class MipsCompilerConfig : public CompilerConfig {
49public:
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)
58class X86FamilyCompilerConfigBase : public CompilerConfig {
59protected:
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
68class X86_32CompilerConfig : public X86FamilyCompilerConfigBase {
69public:
70 X86_32CompilerConfig() :
71 X86FamilyCompilerConfigBase(DEFAULT_X86_TRIPLE_STRING) { }
72};
73
74class X86_64CompilerConfig : public X86FamilyCompilerConfigBase {
75public:
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//===----------------------------------------------------------------------===//
86class 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
Stephen Hines2f6a4932012-05-03 12:27:13 -0700102#endif // BCC_EXECUTION_ENGINE_TARGET_COMPILER_CONFIGS_H