Index: lib/CodeGen/ABIInfo.h =================================================================== --- lib/CodeGen/ABIInfo.h +++ lib/CodeGen/ABIInfo.h @@ -33,11 +33,6 @@ class CGFunctionInfo; class CodeGenFunction; class CodeGenTypes; - class SwiftABIInfo; - -namespace swiftcall { - class SwiftAggLowering; -} // FIXME: All of this stuff should be part of the target interface // somehow. It is currently here because it is not clear how to factor @@ -124,32 +119,6 @@ }; - /// A refining implementation of ABIInfo for targets that support swiftcall. - /// - /// If we find ourselves wanting multiple such refinements, they'll probably - /// be independent refinements, and we should probably find another way - /// to do it than simple inheritance. - class SwiftABIInfo : public ABIInfo { - public: - SwiftABIInfo(CodeGen::CodeGenTypes &cgt) : ABIInfo(cgt) {} - - bool supportsSwift() const final override { return true; } - - virtual bool shouldPassIndirectlyForSwift(CharUnits totalSize, - ArrayRef types, - bool asReturnValue) const = 0; - - virtual bool isLegalVectorTypeForSwift(CharUnits totalSize, - llvm::Type *eltTy, - unsigned elts) const; - - virtual bool isSwiftErrorInRegister() const = 0; - - static bool classof(const ABIInfo *info) { - return info->supportsSwift(); - } - }; - } // end namespace CodeGen } // end namespace clang Index: lib/CodeGen/CMakeLists.txt =================================================================== --- lib/CodeGen/CMakeLists.txt +++ lib/CodeGen/CMakeLists.txt @@ -84,6 +84,7 @@ SanitizerMetadata.cpp SwiftCallingConv.cpp TargetInfo.cpp + Target/SwiftABIInfo.cpp VarBypassDetector.cpp DEPENDS Index: lib/CodeGen/SwiftCallingConv.cpp =================================================================== --- lib/CodeGen/SwiftCallingConv.cpp +++ lib/CodeGen/SwiftCallingConv.cpp @@ -14,6 +14,7 @@ #include "clang/CodeGen/SwiftCallingConv.h" #include "clang/Basic/TargetInfo.h" #include "CodeGenModule.h" +#include "Target/SwiftABIInfo.h" #include "TargetInfo.h" using namespace clang; Index: lib/CodeGen/Target/SwiftABIInfo.h =================================================================== --- /dev/null +++ lib/CodeGen/Target/SwiftABIInfo.h @@ -0,0 +1,59 @@ +//===----- SwiftABIInfo.h - Implements ABIInfo for Swift. -------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_LIB_CODEGEN_TARGET_SWIFTABIINFO_H +#define LLVM_CLANG_LIB_CODEGEN_TARGET_SWIFTABIINFO_H + +#include "../ABIInfo.h" +#include "clang/AST/CharUnits.h" + +namespace llvm { + class Type; +} + +namespace clang { + +namespace CodeGen { + class CodeGenTypes; + class SwiftABIInfo; + +namespace swiftcall { + class SwiftAggLowering; +} + + /// A refining implementation of ABIInfo for targets that support swiftcall. + /// + /// If we find ourselves wanting multiple such refinements, they'll probably + /// be independent refinements, and we should probably find another way + /// to do it than simple inheritance. + class SwiftABIInfo : public ABIInfo { + public: + SwiftABIInfo(CodeGen::CodeGenTypes &cgt) : ABIInfo(cgt) {} + + bool supportsSwift() const final override { return true; } + + virtual bool shouldPassIndirectlyForSwift(CharUnits totalSize, + ArrayRef types, + bool asReturnValue) const = 0; + + virtual bool isLegalVectorTypeForSwift(CharUnits totalSize, + llvm::Type *eltTy, + unsigned elts) const; + + virtual bool isSwiftErrorInRegister() const = 0; + + static bool classof(const ABIInfo *info) { + return info->supportsSwift(); + } + }; + +} // end namespace CodeGen +} // end namespace clang + +#endif Index: lib/CodeGen/Target/SwiftABIInfo.cpp =================================================================== --- /dev/null +++ lib/CodeGen/Target/SwiftABIInfo.cpp @@ -0,0 +1,21 @@ +//===----- SwiftABIInfo.cpp - Implement ABIInfo for Swift. ------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "SwiftABIInfo.h" + +using namespace clang; +using namespace CodeGen; + +bool SwiftABIInfo::isLegalVectorTypeForSwift(CharUnits vectorSize, + llvm::Type *eltTy, + unsigned numElts) const { + // The default implementation of this assumes that the target guarantees + // 128-bit SIMD support but nothing more. + return (vectorSize.getQuantity() > 8 && vectorSize.getQuantity() <= 16); +} Index: lib/CodeGen/TargetInfo.cpp =================================================================== --- lib/CodeGen/TargetInfo.cpp +++ lib/CodeGen/TargetInfo.cpp @@ -17,6 +17,7 @@ #include "CGCXXABI.h" #include "CGValue.h" #include "CodeGenFunction.h" +#include "Target/SwiftABIInfo.h" #include "clang/AST/RecordLayout.h" #include "clang/CodeGen/CGFunctionInfo.h" #include "clang/CodeGen/SwiftCallingConv.h" @@ -126,14 +127,6 @@ return (intCount + fpCount > maxAllRegisters); } -bool SwiftABIInfo::isLegalVectorTypeForSwift(CharUnits vectorSize, - llvm::Type *eltTy, - unsigned numElts) const { - // The default implementation of this assumes that the target guarantees - // 128-bit SIMD support but nothing more. - return (vectorSize.getQuantity() > 8 && vectorSize.getQuantity() <= 16); -} - static CGCXXABI::RecordArgABI getRecordArgABI(const RecordType *RT, CGCXXABI &CXXABI) { const CXXRecordDecl *RD = dyn_cast(RT->getDecl());