Home | History | Annotate | Download | only in AndroidBitcode
      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_ABC_EXPAND_VAARG_PASS_H
     18 #define BCC_ABC_EXPAND_VAARG_PASS_H
     19 
     20 #include <llvm/Pass.h>
     21 
     22 namespace llvm {
     23   class Function;
     24   class Instruction;
     25   class LLVMContext;
     26   class Value;
     27 } // end llvm namespace
     28 
     29 namespace bcc {
     30 
     31 /*
     32  * This pass expands va_arg LLVM instruction generated from llvm-ndk-cc.
     33  *
     34  * LLVM backend does not yet fully support va_arg on many targets. Also,
     35  * it does not currently support va_arg with aggregate types on any target.
     36  * Therefore, each target should implement its own verion of
     37  * ABCExpandVAArg::expandVAArg to expand va_arg.
     38  */
     39 
     40 class ABCExpandVAArgPass : public llvm::FunctionPass {
     41 private:
     42   static char ID;
     43 
     44 protected:
     45   llvm::LLVMContext *mContext;
     46 
     47 private:
     48   virtual llvm::Value *expandVAArg(llvm::Instruction *pInst) = 0;
     49 
     50 public:
     51   ABCExpandVAArgPass() : llvm::FunctionPass(ID), mContext(NULL) { }
     52 
     53   virtual bool runOnFunction(llvm::Function &pFunc);
     54 };
     55 
     56 } // end bcc namespace
     57 
     58 #endif // BCC_ABC_EXPAND_VAARG_PASS_H
     59