Daniel Dunbar | 9eb5c6d | 2009-02-03 01:05:53 +0000 | [diff] [blame] | 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 | |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 10 | #ifndef LLVM_CLANG_LIB_CODEGEN_ABIINFO_H |
| 11 | #define LLVM_CLANG_LIB_CODEGEN_ABIINFO_H |
Daniel Dunbar | 9eb5c6d | 2009-02-03 01:05:53 +0000 | [diff] [blame] | 12 | |
Anton Korobeynikov | c4a59eb | 2009-06-05 22:08:42 +0000 | [diff] [blame] | 13 | #include "clang/AST/Type.h" |
John McCall | bd7370a | 2013-02-28 19:01:20 +0000 | [diff] [blame] | 14 | #include "llvm/IR/CallingConv.h" |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 15 | #include "llvm/IR/Type.h" |
Anton Korobeynikov | c4a59eb | 2009-06-05 22:08:42 +0000 | [diff] [blame] | 16 | |
Daniel Dunbar | 88c2fa9 | 2009-02-03 05:31:23 +0000 | [diff] [blame] | 17 | namespace llvm { |
Anton Korobeynikov | c4a59eb | 2009-06-05 22:08:42 +0000 | [diff] [blame] | 18 | class Value; |
Benjamin Kramer | f21efe9 | 2009-08-11 17:46:57 +0000 | [diff] [blame] | 19 | class LLVMContext; |
Micah Villmow | 25a6a84 | 2012-10-08 16:25:52 +0000 | [diff] [blame] | 20 | class DataLayout; |
Daniel Dunbar | 88c2fa9 | 2009-02-03 05:31:23 +0000 | [diff] [blame] | 21 | } |
| 22 | |
Daniel Dunbar | 9eb5c6d | 2009-02-03 01:05:53 +0000 | [diff] [blame] | 23 | namespace clang { |
Daniel Dunbar | 6bad265 | 2009-02-03 06:51:18 +0000 | [diff] [blame] | 24 | class ASTContext; |
John McCall | 64aa4b3 | 2013-04-16 22:48:15 +0000 | [diff] [blame] | 25 | class TargetInfo; |
Daniel Dunbar | 6bad265 | 2009-02-03 06:51:18 +0000 | [diff] [blame] | 26 | |
Daniel Dunbar | 6bad265 | 2009-02-03 06:51:18 +0000 | [diff] [blame] | 27 | namespace CodeGen { |
Mark Lacey | 2363072 | 2013-10-06 01:33:34 +0000 | [diff] [blame] | 28 | class CGCXXABI; |
Daniel Dunbar | 6bad265 | 2009-02-03 06:51:18 +0000 | [diff] [blame] | 29 | class CGFunctionInfo; |
Daniel Dunbar | b53e3e7 | 2009-02-10 21:44:36 +0000 | [diff] [blame] | 30 | class CodeGenFunction; |
Chris Lattner | ea04432 | 2010-07-29 02:01:43 +0000 | [diff] [blame] | 31 | class CodeGenTypes; |
Daniel Dunbar | 6bad265 | 2009-02-03 06:51:18 +0000 | [diff] [blame] | 32 | } |
| 33 | |
Chris Lattner | 2eb9cdd | 2010-07-28 23:46:15 +0000 | [diff] [blame] | 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. |
Daniel Dunbar | 9eb5c6d | 2009-02-03 01:05:53 +0000 | [diff] [blame] | 38 | |
Daniel Dunbar | 9eb5c6d | 2009-02-03 01:05:53 +0000 | [diff] [blame] | 39 | |
| 40 | /// ABIInfo - Target specific hooks for defining how a type should be |
| 41 | /// passed or returned from functions. |
| 42 | class ABIInfo { |
| 43 | public: |
Chris Lattner | ea04432 | 2010-07-29 02:01:43 +0000 | [diff] [blame] | 44 | CodeGen::CodeGenTypes &CGT; |
John McCall | bd7370a | 2013-02-28 19:01:20 +0000 | [diff] [blame] | 45 | protected: |
| 46 | llvm::CallingConv::ID RuntimeCC; |
| 47 | public: |
| 48 | ABIInfo(CodeGen::CodeGenTypes &cgt) |
| 49 | : CGT(cgt), RuntimeCC(llvm::CallingConv::C) {} |
Michael J. Spencer | 9cac494 | 2010-10-19 06:39:39 +0000 | [diff] [blame] | 50 | |
Daniel Dunbar | 9eb5c6d | 2009-02-03 01:05:53 +0000 | [diff] [blame] | 51 | virtual ~ABIInfo(); |
Michael J. Spencer | 9cac494 | 2010-10-19 06:39:39 +0000 | [diff] [blame] | 52 | |
Mark Lacey | 2363072 | 2013-10-06 01:33:34 +0000 | [diff] [blame] | 53 | CodeGen::CGCXXABI &getCXXABI() const; |
Chris Lattner | ea04432 | 2010-07-29 02:01:43 +0000 | [diff] [blame] | 54 | ASTContext &getContext() const; |
| 55 | llvm::LLVMContext &getVMContext() const; |
Micah Villmow | 25a6a84 | 2012-10-08 16:25:52 +0000 | [diff] [blame] | 56 | const llvm::DataLayout &getDataLayout() const; |
John McCall | 64aa4b3 | 2013-04-16 22:48:15 +0000 | [diff] [blame] | 57 | const TargetInfo &getTarget() const; |
Daniel Dunbar | 6bad265 | 2009-02-03 06:51:18 +0000 | [diff] [blame] | 58 | |
John McCall | bd7370a | 2013-02-28 19:01:20 +0000 | [diff] [blame] | 59 | /// Return the calling convention to use for system runtime |
| 60 | /// functions. |
| 61 | llvm::CallingConv::ID getRuntimeCC() const { |
| 62 | return RuntimeCC; |
| 63 | } |
| 64 | |
Chris Lattner | ee5dcd0 | 2010-07-29 02:31:05 +0000 | [diff] [blame] | 65 | virtual void computeInfo(CodeGen::CGFunctionInfo &FI) const = 0; |
Daniel Dunbar | b53e3e7 | 2009-02-10 21:44:36 +0000 | [diff] [blame] | 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. |
Anton Korobeynikov | c4a59eb | 2009-06-05 22:08:42 +0000 | [diff] [blame] | 69 | |
Daniel Dunbar | b53e3e7 | 2009-02-10 21:44:36 +0000 | [diff] [blame] | 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; |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 76 | |
| 77 | virtual bool isHomogeneousAggregateBaseType(QualType Ty) const; |
| 78 | |
| 79 | virtual bool isHomogeneousAggregateSmallEnough(const Type *Base, |
| 80 | uint64_t Members) const; |
| 81 | |
| 82 | bool isHomogeneousAggregate(QualType Ty, const Type *&Base, |
| 83 | uint64_t &Members) const; |
| 84 | |
Daniel Dunbar | 9eb5c6d | 2009-02-03 01:05:53 +0000 | [diff] [blame] | 85 | }; |
| 86 | } // end namespace clang |
| 87 | |
| 88 | #endif |