clang API Documentation

ABIInfo.h
Go to the documentation of this file.
00001 //===----- ABIInfo.h - ABI information access & encapsulation ---*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 
00010 #ifndef LLVM_CLANG_LIB_CODEGEN_ABIINFO_H
00011 #define LLVM_CLANG_LIB_CODEGEN_ABIINFO_H
00012 
00013 #include "clang/AST/Type.h"
00014 #include "llvm/IR/CallingConv.h"
00015 #include "llvm/IR/Type.h"
00016 
00017 namespace llvm {
00018   class Value;
00019   class LLVMContext;
00020   class DataLayout;
00021 }
00022 
00023 namespace clang {
00024   class ASTContext;
00025   class TargetInfo;
00026 
00027   namespace CodeGen {
00028     class CGCXXABI;
00029     class CGFunctionInfo;
00030     class CodeGenFunction;
00031     class CodeGenTypes;
00032   }
00033 
00034   // FIXME: All of this stuff should be part of the target interface
00035   // somehow. It is currently here because it is not clear how to factor
00036   // the targets to support this, since the Targets currently live in a
00037   // layer below types n'stuff.
00038 
00039 
00040   /// ABIInfo - Target specific hooks for defining how a type should be
00041   /// passed or returned from functions.
00042   class ABIInfo {
00043   public:
00044     CodeGen::CodeGenTypes &CGT;
00045   protected:
00046     llvm::CallingConv::ID RuntimeCC;
00047   public:
00048     ABIInfo(CodeGen::CodeGenTypes &cgt)
00049       : CGT(cgt), RuntimeCC(llvm::CallingConv::C) {}
00050 
00051     virtual ~ABIInfo();
00052 
00053     CodeGen::CGCXXABI &getCXXABI() const;
00054     ASTContext &getContext() const;
00055     llvm::LLVMContext &getVMContext() const;
00056     const llvm::DataLayout &getDataLayout() const;
00057     const TargetInfo &getTarget() const;
00058 
00059     /// Return the calling convention to use for system runtime
00060     /// functions.
00061     llvm::CallingConv::ID getRuntimeCC() const {
00062       return RuntimeCC;
00063     }
00064 
00065     virtual void computeInfo(CodeGen::CGFunctionInfo &FI) const = 0;
00066 
00067     /// EmitVAArg - Emit the target dependent code to load a value of
00068     /// \arg Ty from the va_list pointed to by \arg VAListAddr.
00069 
00070     // FIXME: This is a gaping layering violation if we wanted to drop
00071     // the ABI information any lower than CodeGen. Of course, for
00072     // VAArg handling it has to be at this level; there is no way to
00073     // abstract this out.
00074     virtual llvm::Value *EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
00075                                    CodeGen::CodeGenFunction &CGF) const = 0;
00076 
00077     virtual bool isHomogeneousAggregateBaseType(QualType Ty) const;
00078 
00079     virtual bool isHomogeneousAggregateSmallEnough(const Type *Base,
00080                                                    uint64_t Members) const;
00081 
00082     bool isHomogeneousAggregate(QualType Ty, const Type *&Base,
00083                                 uint64_t &Members) const;
00084 
00085   };
00086 }  // end namespace clang
00087 
00088 #endif