| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | #ifndef LLVM_CLANG_LIB_CODEGEN_ABIINFO_H |
| 10 | #define LLVM_CLANG_LIB_CODEGEN_ABIINFO_H |
| 11 | |
| 12 | #include "clang/AST/CharUnits.h" |
| 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 | class Type; |
| 22 | } |
| 23 | |
| 24 | namespace clang { |
| 25 | class ASTContext; |
| 26 | class CodeGenOptions; |
| 27 | class TargetInfo; |
| 28 | |
| 29 | namespace CodeGen { |
| 30 | class ABIArgInfo; |
| 31 | class Address; |
| 32 | class CGCXXABI; |
| 33 | class CGFunctionInfo; |
| 34 | class CodeGenFunction; |
| 35 | class CodeGenTypes; |
| 36 | class SwiftABIInfo; |
| 37 | |
| 38 | namespace swiftcall { |
| 39 | class SwiftAggLowering; |
| 40 | } |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | class ABIInfo { |
| 51 | public: |
| 52 | CodeGen::CodeGenTypes &CGT; |
| 53 | protected: |
| 54 | llvm::CallingConv::ID RuntimeCC; |
| 55 | public: |
| 56 | ABIInfo(CodeGen::CodeGenTypes &cgt) |
| 57 | : CGT(cgt), RuntimeCC(llvm::CallingConv::C) {} |
| 58 | |
| 59 | virtual ~ABIInfo(); |
| 60 | |
| 61 | virtual bool supportsSwift() const { return false; } |
| 62 | |
| 63 | CodeGen::CGCXXABI &getCXXABI() const; |
| 64 | ASTContext &getContext() const; |
| 65 | llvm::LLVMContext &getVMContext() const; |
| 66 | const llvm::DataLayout &getDataLayout() const; |
| 67 | const TargetInfo &getTarget() const; |
| 68 | const CodeGenOptions &getCodeGenOpts() const; |
| 69 | |
| 70 | |
| 71 | |
| 72 | llvm::CallingConv::ID getRuntimeCC() const { |
| 73 | return RuntimeCC; |
| 74 | } |
| 75 | |
| 76 | virtual void computeInfo(CodeGen::CGFunctionInfo &FI) const = 0; |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | virtual CodeGen::Address EmitVAArg(CodeGen::CodeGenFunction &CGF, |
| 86 | CodeGen::Address VAListAddr, |
| 87 | QualType Ty) const = 0; |
| 88 | |
| 89 | bool isAndroid() const; |
| 90 | |
| 91 | |
| 92 | |
| 93 | virtual CodeGen::Address EmitMSVAArg(CodeGen::CodeGenFunction &CGF, |
| 94 | CodeGen::Address VAListAddr, |
| 95 | QualType Ty) const; |
| 96 | |
| 97 | virtual bool isHomogeneousAggregateBaseType(QualType Ty) const; |
| 98 | |
| 99 | virtual bool isHomogeneousAggregateSmallEnough(const Type *Base, |
| 100 | uint64_t Members) const; |
| 101 | |
| 102 | bool isHomogeneousAggregate(QualType Ty, const Type *&Base, |
| 103 | uint64_t &Members) const; |
| 104 | |
| 105 | |
| 106 | |
| 107 | CodeGen::ABIArgInfo |
| 108 | getNaturalAlignIndirect(QualType Ty, bool ByRef = true, |
| 109 | bool Realign = false, |
| 110 | llvm::Type *Padding = nullptr) const; |
| 111 | |
| 112 | CodeGen::ABIArgInfo |
| 113 | getNaturalAlignIndirectInReg(QualType Ty, bool Realign = false) const; |
| 114 | |
| 115 | |
| 116 | }; |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | class SwiftABIInfo : public ABIInfo { |
| 124 | public: |
| 125 | SwiftABIInfo(CodeGen::CodeGenTypes &cgt) : ABIInfo(cgt) {} |
| 126 | |
| 127 | bool supportsSwift() const final override { return true; } |
| 128 | |
| 129 | virtual bool shouldPassIndirectlyForSwift(ArrayRef<llvm::Type*> types, |
| 130 | bool asReturnValue) const = 0; |
| 131 | |
| 132 | virtual bool isLegalVectorTypeForSwift(CharUnits totalSize, |
| 133 | llvm::Type *eltTy, |
| 134 | unsigned elts) const; |
| 135 | |
| 136 | virtual bool isSwiftErrorInRegister() const = 0; |
| 137 | |
| 138 | static bool classof(const ABIInfo *info) { |
| 139 | return info->supportsSwift(); |
| 140 | } |
| 141 | }; |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | #endif |
| 146 | |