]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/lib/CodeGen/ABIInfo.h
MFV r308265: Update tzdata to 2016i.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / lib / CodeGen / ABIInfo.h
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 ABIArgInfo;
29     class Address;
30     class CGCXXABI;
31     class CGFunctionInfo;
32     class CodeGenFunction;
33     class CodeGenTypes;
34   }
35
36   // FIXME: All of this stuff should be part of the target interface
37   // somehow. It is currently here because it is not clear how to factor
38   // the targets to support this, since the Targets currently live in a
39   // layer below types n'stuff.
40
41
42   /// ABIInfo - Target specific hooks for defining how a type should be
43   /// passed or returned from functions.
44   class ABIInfo {
45   public:
46     CodeGen::CodeGenTypes &CGT;
47   protected:
48     llvm::CallingConv::ID RuntimeCC;
49     llvm::CallingConv::ID BuiltinCC;
50   public:
51     ABIInfo(CodeGen::CodeGenTypes &cgt)
52       : CGT(cgt),
53         RuntimeCC(llvm::CallingConv::C),
54         BuiltinCC(llvm::CallingConv::C) {}
55
56     virtual ~ABIInfo();
57
58     CodeGen::CGCXXABI &getCXXABI() const;
59     ASTContext &getContext() const;
60     llvm::LLVMContext &getVMContext() const;
61     const llvm::DataLayout &getDataLayout() const;
62     const TargetInfo &getTarget() const;
63
64     /// Return the calling convention to use for system runtime
65     /// functions.
66     llvm::CallingConv::ID getRuntimeCC() const {
67       return RuntimeCC;
68     }
69
70     /// Return the calling convention to use for compiler builtins
71     llvm::CallingConv::ID getBuiltinCC() const {
72       return BuiltinCC;
73     }
74
75     virtual void computeInfo(CodeGen::CGFunctionInfo &FI) const = 0;
76
77     /// EmitVAArg - Emit the target dependent code to load a value of
78     /// \arg Ty from the va_list pointed to by \arg VAListAddr.
79
80     // FIXME: This is a gaping layering violation if we wanted to drop
81     // the ABI information any lower than CodeGen. Of course, for
82     // VAArg handling it has to be at this level; there is no way to
83     // abstract this out.
84     virtual CodeGen::Address EmitVAArg(CodeGen::CodeGenFunction &CGF,
85                                        CodeGen::Address VAListAddr,
86                                        QualType Ty) const = 0;
87
88     /// Emit the target dependent code to load a value of
89     /// \arg Ty from the \c __builtin_ms_va_list pointed to by \arg VAListAddr.
90     virtual CodeGen::Address EmitMSVAArg(CodeGen::CodeGenFunction &CGF,
91                                          CodeGen::Address VAListAddr,
92                                          QualType Ty) const;
93
94     virtual bool isHomogeneousAggregateBaseType(QualType Ty) const;
95
96     virtual bool isHomogeneousAggregateSmallEnough(const Type *Base,
97                                                    uint64_t Members) const;
98
99     virtual bool shouldSignExtUnsignedType(QualType Ty) const;
100
101     bool isHomogeneousAggregate(QualType Ty, const Type *&Base,
102                                 uint64_t &Members) const;
103
104     /// A convenience method to return an indirect ABIArgInfo with an
105     /// expected alignment equal to the ABI alignment of the given type.
106     CodeGen::ABIArgInfo
107     getNaturalAlignIndirect(QualType Ty, bool ByRef = true,
108                             bool Realign = false,
109                             llvm::Type *Padding = nullptr) const;
110
111     CodeGen::ABIArgInfo
112     getNaturalAlignIndirectInReg(QualType Ty, bool Realign = false) const;
113   };
114 }  // end namespace clang
115
116 #endif