Skip to content

Commit b5f08a4

Browse files
committed
[ConstraintSystem] Add skeleton of constraint optimizer
1 parent 4432c51 commit b5f08a4

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

lib/Sema/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ add_swift_host_library(swiftSema STATIC
1313
CSStep.cpp
1414
CSTrail.cpp
1515
CSFix.cpp
16+
CSOptimizer.cpp
1617
CSDiagnostics.cpp
1718
CodeSynthesis.cpp
1819
CodeSynthesisDistributedActor.cpp

lib/Sema/CSOptimizer.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//===--- CSOptimizer.cpp - Constraint Optimizer ---------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
//
13+
// This file implements disjunction and other constraint optimizations.
14+
//
15+
//===----------------------------------------------------------------------===//
16+
17+
#include "swift/Sema/ConstraintSystem.h"
18+
#include "llvm/ADT/SmallVector.h"
19+
20+
using namespace swift;
21+
using namespace constraints;
22+
23+
void ConstraintSystem::optimizeDisjunctions(
24+
SmallVectorImpl<Constraint *> &disjunctions) {
25+
}

lib/Sema/CSSolver.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1835,6 +1835,8 @@ Constraint *ConstraintSystem::selectDisjunction() {
18351835
if (disjunctions.empty())
18361836
return nullptr;
18371837

1838+
optimizeDisjunctions(disjunctions);
1839+
18381840
if (auto *disjunction = selectBestBindingDisjunction(*this, disjunctions))
18391841
return disjunction;
18401842

0 commit comments

Comments
 (0)