Files
swift-mirror/lib/SILOptimizer/Mandatory/PhiStorageOptimizer.h
Andrew Trick b90007a98c Update and reimplement AddressLowering pass (for SIL opaque values).
Merge the AddressLowering pass from its old development branch and update
it so we can begin incrementally enabling it under a flag.

This has been reimplemented for simplicity. There's no point in
looking at the old code.
2022-03-09 17:18:15 -08:00

52 lines
1.6 KiB
C++

//===--- PhiStorageOptimizer.h - Phi storage optimizer --------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2021 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 PhiStorageOptimizer, a utility for use with the
/// mandatory AddressLowering pass.
///
//===----------------------------------------------------------------------===//
#include "AddressLowering.h"
#include "swift/SIL/SILArgument.h"
#include "swift/SIL/SILBasicBlock.h"
#include "swift/SIL/SILValue.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
namespace swift {
class CoalescedPhi {
friend class PhiStorageOptimizer;
SmallVector<Operand *, 4> coalescedOperands;
CoalescedPhi(const CoalescedPhi &) = delete;
CoalescedPhi &operator=(const CoalescedPhi &) = delete;
public:
CoalescedPhi() = default;
CoalescedPhi(CoalescedPhi &&) = default;
CoalescedPhi &operator=(CoalescedPhi &&) = default;
void coalesce(PhiValue phi, const ValueStorageMap &valueStorageMap);
bool empty() const { return coalescedOperands.empty(); }
ArrayRef<Operand *> getCoalescedOperands() const { return coalescedOperands; }
SILInstruction::OperandValueRange getCoalescedValues() const {
return SILInstruction::getOperandValues(getCoalescedOperands());
}
};
} // namespace swift