Zonr Chang | f74ee19 | 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 | #include "TargetCompilerConfigs.h" |
| 18 | |
| 19 | using namespace bcc; |
| 20 | |
| 21 | //===----------------------------------------------------------------------===// |
| 22 | // ARM |
| 23 | //===----------------------------------------------------------------------===// |
| 24 | #if defined(PROVIDE_ARM_CODEGEN) |
| 25 | |
| 26 | void ARMCompilerConfig::GetFeatureVector(std::vector<std::string> &pAttributes, |
| 27 | bool pEnableNEON) { |
| 28 | #if defined(ARCH_ARM_HAVE_VFP) |
| 29 | pAttributes.push_back("+vfp3"); |
| 30 | # if !defined(ARCH_ARM_HAVE_VFP_D32) |
| 31 | pAttributes.push_back("+d16"); |
| 32 | # endif |
| 33 | #endif |
| 34 | |
| 35 | #if defined(ARCH_ARM_HAVE_NEON) && !defined(DISABLE_ARCH_ARM_HAVE_NEON) |
| 36 | if (pEnableNEON) { |
| 37 | // FIXME(all): Turn NEON back on after debugging the rebase. |
| 38 | //attributes.push_back("+neon"); |
| 39 | //attributes.push_back("+neonfp"); |
| 40 | pAttributes.push_back("-neon"); |
| 41 | pAttributes.push_back("-neonfp"); |
| 42 | } else { |
| 43 | pAttributes.push_back("-neon"); |
| 44 | pAttributes.push_back("-neonfp"); |
| 45 | } |
| 46 | #else |
| 47 | pAttributes.push_back("-neon"); |
| 48 | pAttributes.push_back("-neonfp"); |
| 49 | #endif |
| 50 | |
| 51 | return; |
| 52 | } |
| 53 | |
| 54 | ARMCompilerConfig::ARMCompilerConfig() |
| 55 | : CompilerConfig(DEFAULT_ARM_TRIPLE_STRING) { |
| 56 | |
| 57 | // Enable NEON by default. |
| 58 | mEnableNEON = true; |
| 59 | |
| 60 | std::vector<std::string> attributes; |
| 61 | GetFeatureVector(attributes, /* pEnableNEON */mEnableNEON); |
| 62 | setFeatureString(attributes); |
| 63 | |
| 64 | return; |
| 65 | } |
| 66 | |
| 67 | bool ARMCompilerConfig::enableNEON(bool pEnable) { |
| 68 | #if defined(ARCH_ARM_HAVE_NEON) && !defined(DISABLE_ARCH_ARM_HAVE_NEON) |
| 69 | if (mEnableNEON != pEnable) { |
| 70 | std::vector<std::string> attributes; |
| 71 | GetFeatureVector(attributes, pEnable); |
| 72 | setFeatureString(attributes); |
| 73 | mEnableNEON = pEnable; |
| 74 | return true; |
| 75 | } |
| 76 | // Fall-through |
| 77 | #endif |
| 78 | return false; |
| 79 | } |
| 80 | #endif // defined(PROVIDE_ARM_CODEGEN) |