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 #include "bcc/Support/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     pAttributes.push_back("+neon");
     38     pAttributes.push_back("+neonfp");
     39   } else {
     40     pAttributes.push_back("-neon");
     41     pAttributes.push_back("-neonfp");
     42   }
     43 #else
     44   pAttributes.push_back("-neon");
     45   pAttributes.push_back("-neonfp");
     46 #endif
     47 
     48   return;
     49 }
     50 
     51 ARMCompilerConfig::ARMCompilerConfig()
     52   : CompilerConfig(DEFAULT_ARM_TRIPLE_STRING) {
     53 
     54   // Enable NEON by default.
     55   mEnableNEON = true;
     56 
     57   std::vector<std::string> attributes;
     58   GetFeatureVector(attributes, /* pEnableNEON */mEnableNEON);
     59   setFeatureString(attributes);
     60 
     61   return;
     62 }
     63 
     64 bool ARMCompilerConfig::enableNEON(bool pEnable) {
     65 #if defined(ARCH_ARM_HAVE_NEON) && !defined(DISABLE_ARCH_ARM_HAVE_NEON)
     66   if (mEnableNEON != pEnable) {
     67     std::vector<std::string> attributes;
     68     GetFeatureVector(attributes, pEnable);
     69     setFeatureString(attributes);
     70     mEnableNEON = pEnable;
     71     return true;
     72   }
     73   // Fall-through
     74 #endif
     75   return false;
     76 }
     77 #endif // defined(PROVIDE_ARM_CODEGEN)
     78