Home | History | Annotate | Download | only in device
      1 /*
      2  * Copyright 2013, 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 ABCC_ABCC_DEVICE_H
     18 #define ABCC_ABCC_DEVICE_H
     19 
     20 #include <android/log.h>
     21 #if VERBOSE
     22 #include <sys/time.h>
     23 #endif
     24 #include "Abcc.h"
     25 
     26 #define LOG_TAG "AbccNative"
     27 #define LOGE(format, ...)  do {\
     28   __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, format, ##__VA_ARGS__);\
     29   } while(0)
     30 
     31 #if VERBOSE
     32 #define LOGV(format, ...)  do {\
     33   __android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, format, ##__VA_ARGS__);\
     34   } while(0)
     35 #else
     36 #define LOGV(format, ...)
     37 #endif  // VERBOSE
     38 
     39 namespace abcc {
     40 
     41 #if VERBOSE
     42 class Timer {
     43 private:
     44   struct timeval _t0;
     45 public:
     46   Timer() {};
     47   void start() { gettimeofday(&_t0, NULL); }
     48   long long stop() {
     49   struct timeval t;
     50     gettimeofday(&t, NULL);
     51     long long l0 = _t0.tv_sec * 1000000LL + _t0.tv_usec;
     52     long long l = t.tv_sec * 1000000LL + t.tv_usec;
     53     return l - l0;
     54   }
     55 };
     56 
     57 extern long long llc_usec;
     58 
     59 #endif // VERBOSE
     60 
     61 
     62 class DeviceBitcodeCompiler : public BitcodeCompiler {
     63 public:
     64   DeviceBitcodeCompiler(const std::string &working_dir, const std::string &sysroot);
     65   virtual void cleanupPost();
     66 
     67 public:
     68   virtual int parseLDFlags(BitcodeInfo &info, const std::string &str);
     69 
     70 private:
     71   virtual void getBitcodeFiles();
     72   virtual void prepareToolchain();
     73   virtual void copyRuntime(const BitcodeInfo &info);
     74   virtual void removeIntermediateFile(const std::string &path);
     75 };
     76 
     77 } // namespace abcc
     78 
     79 #endif
     80