mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Fixes a regression in the source compatibility suite which I had a lot of trouble extracting into a separate test case. Most of this patch is just moving the outlining code into a separate file and organizing it into a helper class instead of copy/pasting so much code. The main functional change is implicit in the difference between collecting formal metadata and collecting it for layout, which then is exploited in bindMetadataParameters. As a secondary change, stop collecting metadata for class-bounded archetypes; we don't actually need it to do value operations.
84 lines
2.4 KiB
C++
84 lines
2.4 KiB
C++
//===--- Outlining.h - Value operation outlining ----------------*- C++ -*-===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See https://swift.org/LICENSE.txt for license information
|
|
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file defines interfaces for outlining value witnesses.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef SWIFT_IRGEN_OUTLINING_H
|
|
#define SWIFT_IRGEN_OUTLINING_H
|
|
|
|
#include "swift/Basic/LLVM.h"
|
|
#include "llvm/ADT/MapVector.h"
|
|
|
|
namespace llvm {
|
|
class Value;
|
|
class Type;
|
|
}
|
|
|
|
namespace swift {
|
|
class CanGenericSignature;
|
|
class CanType;
|
|
enum IsInitialization_t : bool;
|
|
enum IsTake_t : bool;
|
|
class SILType;
|
|
|
|
namespace irgen {
|
|
class Address;
|
|
class Explosion;
|
|
class IRGenFunction;
|
|
class IRGenModule;
|
|
class LocalTypeDataKey;
|
|
class TypeInfo;
|
|
|
|
/// A helper class for emitting outlined value operations.
|
|
///
|
|
/// The use-pattern for this class is:
|
|
/// - construct it
|
|
/// - collect all the metadata that will be required in order to perform
|
|
/// the value operations
|
|
/// - emit the call to the outlined copy/destroy helper
|
|
class OutliningMetadataCollector {
|
|
public:
|
|
IRGenFunction &IGF;
|
|
private:
|
|
llvm::MapVector<LocalTypeDataKey, llvm::Value *> Values;
|
|
friend class IRGenModule;
|
|
|
|
public:
|
|
OutliningMetadataCollector(IRGenFunction &IGF) : IGF(IGF) {}
|
|
|
|
void collectFormalTypeMetadata(CanType type);
|
|
void collectTypeMetadataForLayout(SILType type);
|
|
|
|
void emitCallToOutlinedCopy(Address dest, Address src,
|
|
SILType T, const TypeInfo &ti,
|
|
IsInitialization_t isInit, IsTake_t isTake) const;
|
|
void emitCallToOutlinedDestroy(Address addr, SILType T,
|
|
const TypeInfo &ti) const;
|
|
|
|
private:
|
|
void addMetadataArguments(SmallVectorImpl<llvm::Value *> &args) const ;
|
|
void addMetadataParameterTypes(SmallVectorImpl<llvm::Type *> ¶mTys) const;
|
|
void bindMetadataParameters(IRGenFunction &helperIGF,
|
|
Explosion ¶ms) const;
|
|
};
|
|
|
|
std::pair<CanType, CanGenericSignature>
|
|
getTypeAndGenericSignatureForManglingOutlineFunction(SILType type);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
#endif
|