[ConstraintSystem] Add skeleton of constraint optimizer

This commit is contained in:
Pavel Yaskevich
2023-02-04 19:01:34 -08:00
parent 4432c51f57
commit b5f08a4009
3 changed files with 28 additions and 0 deletions

View File

@@ -13,6 +13,7 @@ add_swift_host_library(swiftSema STATIC
CSStep.cpp
CSTrail.cpp
CSFix.cpp
CSOptimizer.cpp
CSDiagnostics.cpp
CodeSynthesis.cpp
CodeSynthesisDistributedActor.cpp

25
lib/Sema/CSOptimizer.cpp Normal file
View File

@@ -0,0 +1,25 @@
//===--- CSOptimizer.cpp - Constraint Optimizer ---------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2023 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 implements disjunction and other constraint optimizations.
//
//===----------------------------------------------------------------------===//
#include "swift/Sema/ConstraintSystem.h"
#include "llvm/ADT/SmallVector.h"
using namespace swift;
using namespace constraints;
void ConstraintSystem::optimizeDisjunctions(
SmallVectorImpl<Constraint *> &disjunctions) {
}

View File

@@ -1835,6 +1835,8 @@ Constraint *ConstraintSystem::selectDisjunction() {
if (disjunctions.empty())
return nullptr;
optimizeDisjunctions(disjunctions);
if (auto *disjunction = selectBestBindingDisjunction(*this, disjunctions))
return disjunction;