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