1 //===----- ABIInfo.h - ABI information access & encapsulation ---*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef LLVM_CLANG_LIB_CODEGEN_ABIINFO_H 11 #define LLVM_CLANG_LIB_CODEGEN_ABIINFO_H 12 13 #include "clang/AST/Type.h" 14 #include "llvm/IR/CallingConv.h" 15 #include "llvm/IR/Type.h" 16 17 namespace llvm { 18 class Value; 19 class LLVMContext; 20 class DataLayout; 21 } 22 23 namespace clang { 24 class ASTContext; 25 class TargetInfo; 26 27 namespace CodeGen { 28 class CGCXXABI; 29 class CGFunctionInfo; 30 class CodeGenFunction; 31 class CodeGenTypes; 32 } 33 34 // FIXME: All of this stuff should be part of the target interface 35 // somehow. It is currently here because it is not clear how to factor 36 // the targets to support this, since the Targets currently live in a 37 // layer below types n'stuff. 38 39 40 /// ABIInfo - Target specific hooks for defining how a type should be 41 /// passed or returned from functions. 42 class ABIInfo { 43 public: 44 CodeGen::CodeGenTypes &CGT; 45 protected: 46 llvm::CallingConv::ID RuntimeCC; 47 llvm::CallingConv::ID BuiltinCC; 48 public: ABIInfo(CodeGen::CodeGenTypes & cgt)49 ABIInfo(CodeGen::CodeGenTypes &cgt) 50 : CGT(cgt), 51 RuntimeCC(llvm::CallingConv::C), 52 BuiltinCC(llvm::CallingConv::C) {} 53 54 virtual ~ABIInfo(); 55 56 CodeGen::CGCXXABI &getCXXABI() const; 57 ASTContext &getContext() const; 58 llvm::LLVMContext &getVMContext() const; 59 const llvm::DataLayout &getDataLayout() const; 60 const TargetInfo &getTarget() const; 61 62 /// Return the calling convention to use for system runtime 63 /// functions. getRuntimeCC()64 llvm::CallingConv::ID getRuntimeCC() const { 65 return RuntimeCC; 66 } 67 68 /// Return the calling convention to use for compiler builtins getBuiltinCC()69 llvm::CallingConv::ID getBuiltinCC() const { 70 return BuiltinCC; 71 } 72 73 virtual void computeInfo(CodeGen::CGFunctionInfo &FI) const = 0; 74 75 /// EmitVAArg - Emit the target dependent code to load a value of 76 /// \arg Ty from the va_list pointed to by \arg VAListAddr. 77 78 // FIXME: This is a gaping layering violation if we wanted to drop 79 // the ABI information any lower than CodeGen. Of course, for 80 // VAArg handling it has to be at this level; there is no way to 81 // abstract this out. 82 virtual llvm::Value *EmitVAArg(llvm::Value *VAListAddr, QualType Ty, 83 CodeGen::CodeGenFunction &CGF) const = 0; 84 85 virtual bool isHomogeneousAggregateBaseType(QualType Ty) const; 86 87 virtual bool isHomogeneousAggregateSmallEnough(const Type *Base, 88 uint64_t Members) const; 89 90 bool isHomogeneousAggregate(QualType Ty, const Type *&Base, 91 uint64_t &Members) const; 92 93 }; 94 } // end namespace clang 95 96 #endif 97