-
Notifications
You must be signed in to change notification settings - Fork 10.5k
/
Copy pathCondition.h
82 lines (66 loc) · 2.79 KB
/
Condition.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//===--- Condition.h - Defines the SILGen Condition class -------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This file defines the Condition class, used by SIL Generation.
//
//===----------------------------------------------------------------------===//
#ifndef SWIFT_SIL_LOWERING_CONDITION_H
#define SWIFT_SIL_LOWERING_CONDITION_H
#include "llvm/ADT/ArrayRef.h"
#include "swift/Basic/Optional.h"
#include "swift/SIL/SILLocation.h"
#include "swift/SIL/SILValue.h"
#include "llvm/Support/Compiler.h"
namespace swift {
class PatternBindingDecl;
class SILBuilder;
class SILBasicBlock;
namespace Lowering {
/// A condition is the result of evaluating a boolean expression as
/// control flow.
class LLVM_LIBRARY_VISIBILITY Condition {
/// The blocks responsible for executing the true and false conditions. A
/// block is non-null if that branch is possible, but it's only an independent
/// block if both branches are possible.
SILBasicBlock *TrueBB;
SILBasicBlock *FalseBB;
/// The continuation block if both branches are possible.
SILBasicBlock *ContBB;
/// The location wrapping the originator conditional expression.
SILLocation Loc;
public:
Condition(SILBasicBlock *TrueBB, SILBasicBlock *FalseBB,
SILBasicBlock *ContBB,
SILLocation L)
: TrueBB(TrueBB), FalseBB(FalseBB), ContBB(ContBB), Loc(L)
{}
bool hasTrue() const { return TrueBB; }
bool hasFalse() const { return FalseBB; }
/// enterTrue - Begin the emission of the true block. This should only be
/// called if hasTrue() returns true.
void enterTrue(SILBuilder &B);
/// exitTrue - End the emission of the true block. This must be called after
/// enterTrue but before anything else on this Condition.
void exitTrue(SILBuilder &B, ArrayRef<SILValue> Args = {});
/// enterFalse - Begin the emission of the false block. This should only be
/// called if hasFalse() returns true.
void enterFalse(SILBuilder &B);
/// exitFalse - End the emission of the true block. This must be called after
/// enterFalse but before anything else on this Condition.
void exitFalse(SILBuilder &B, ArrayRef<SILValue> Args = {});
/// complete - Complete this conditional execution. This should be called
/// only after all other calls on this Condition have been made.
SILBasicBlock *complete(SILBuilder &B);
};
} // end namespace Lowering
} // end namespace swift
#endif