]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/llvm/tools/clang/lib/CodeGen/ABIInfo.h
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.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 CLANG_CODEGEN_ABIINFO_H
11 #define CLANG_CODEGEN_ABIINFO_H
12
13 #include "clang/AST/Type.h"
14 #include "llvm/IR/Type.h"
15 #include "llvm/IR/CallingConv.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   public:
48     ABIInfo(CodeGen::CodeGenTypes &cgt)
49       : CGT(cgt), RuntimeCC(llvm::CallingConv::C) {}
50
51     virtual ~ABIInfo();
52
53     CodeGen::CGCXXABI &getCXXABI() const;
54     ASTContext &getContext() const;
55     llvm::LLVMContext &getVMContext() const;
56     const llvm::DataLayout &getDataLayout() const;
57     const TargetInfo &getTarget() const;
58
59     /// Return the calling convention to use for system runtime
60     /// functions.
61     llvm::CallingConv::ID getRuntimeCC() const {
62       return RuntimeCC;
63     }
64
65     virtual void computeInfo(CodeGen::CGFunctionInfo &FI) const = 0;
66
67     /// EmitVAArg - Emit the target dependent code to load a value of
68     /// \arg Ty from the va_list pointed to by \arg VAListAddr.
69
70     // FIXME: This is a gaping layering violation if we wanted to drop
71     // the ABI information any lower than CodeGen. Of course, for
72     // VAArg handling it has to be at this level; there is no way to
73     // abstract this out.
74     virtual llvm::Value *EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
75                                    CodeGen::CodeGenFunction &CGF) const = 0;
76   };
77 }  // end namespace clang
78
79 #endif