Skip to content

Commit ae8bc91

Browse files
committed
[nfc] Move SILDebugVariable from SILInstruction.h -> SILDebugVariable.h
Just batching this with another NFC commit in preparation for a larger later commit.
1 parent 0d0bf13 commit ae8bc91

File tree

2 files changed

+73
-44
lines changed

2 files changed

+73
-44
lines changed

include/swift/SIL/SILDebugVariable.h

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
//===--- SILDebugVariable.h -----------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2021 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+
#ifndef SWIFT_SIL_SILDEBUGVARIABLE_H
14+
#define SWIFT_SIL_SILDEBUGVARIABLE_H
15+
16+
#include "swift/Basic/LLVM.h"
17+
#include "swift/SIL/SILDebugInfoExpression.h"
18+
#include "swift/SIL/SILLocation.h"
19+
#include "swift/SIL/SILType.h"
20+
#include "llvm/ADT/StringRef.h"
21+
22+
namespace swift {
23+
24+
class AllocationInst;
25+
26+
/// Holds common debug information about local variables and function
27+
/// arguments that are needed by DebugValueInst, AllocStackInst,
28+
/// and AllocBoxInst.
29+
struct SILDebugVariable {
30+
StringRef Name;
31+
unsigned ArgNo : 16;
32+
unsigned Constant : 1;
33+
unsigned Implicit : 1;
34+
Optional<SILType> Type;
35+
Optional<SILLocation> Loc;
36+
const SILDebugScope *Scope;
37+
SILDebugInfoExpression DIExpr;
38+
39+
// Use vanilla copy ctor / operator
40+
SILDebugVariable(const SILDebugVariable &) = default;
41+
SILDebugVariable &operator=(const SILDebugVariable &) = default;
42+
43+
SILDebugVariable()
44+
: ArgNo(0), Constant(false), Implicit(false), Scope(nullptr) {}
45+
SILDebugVariable(bool Constant, uint16_t ArgNo)
46+
: ArgNo(ArgNo), Constant(Constant), Implicit(false), Scope(nullptr) {}
47+
SILDebugVariable(StringRef Name, bool Constant, unsigned ArgNo,
48+
bool IsImplicit = false, Optional<SILType> AuxType = {},
49+
Optional<SILLocation> DeclLoc = {},
50+
const SILDebugScope *DeclScope = nullptr,
51+
llvm::ArrayRef<SILDIExprElement> ExprElements = {})
52+
: Name(Name), ArgNo(ArgNo), Constant(Constant), Implicit(IsImplicit),
53+
Type(AuxType), Loc(DeclLoc), Scope(DeclScope), DIExpr(ExprElements) {}
54+
55+
/// Created from either AllocStack or AllocBox instruction
56+
static Optional<SILDebugVariable>
57+
createFromAllocation(const AllocationInst *AI);
58+
59+
bool operator==(const SILDebugVariable &V) {
60+
return ArgNo == V.ArgNo && Constant == V.Constant && Name == V.Name &&
61+
Implicit == V.Implicit && Type == V.Type && Loc == V.Loc &&
62+
Scope == V.Scope && DIExpr == V.DIExpr;
63+
}
64+
65+
bool isLet() const { return Name.size() && Constant; }
66+
67+
bool isVar() const { return Name.size() && !Constant; }
68+
};
69+
70+
} // namespace swift
71+
72+
#endif

include/swift/SIL/SILInstruction.h

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "swift/SIL/SILAllocated.h"
3434
#include "swift/SIL/SILArgumentArrayRef.h"
3535
#include "swift/SIL/SILDebugInfoExpression.h"
36+
#include "swift/SIL/SILDebugVariable.h"
3637
#include "swift/SIL/SILDeclRef.h"
3738
#include "swift/SIL/SILFunctionConventions.h"
3839
#include "swift/SIL/SILLocation.h"
@@ -1775,50 +1776,6 @@ class UnaryInstructionWithTypeDependentOperandsBase
17751776
}
17761777
};
17771778

1778-
/// Holds common debug information about local variables and function
1779-
/// arguments that are needed by DebugValueInst, AllocStackInst,
1780-
/// and AllocBoxInst.
1781-
struct SILDebugVariable {
1782-
StringRef Name;
1783-
unsigned ArgNo : 16;
1784-
unsigned Constant : 1;
1785-
unsigned Implicit : 1;
1786-
Optional<SILType> Type;
1787-
Optional<SILLocation> Loc;
1788-
const SILDebugScope *Scope;
1789-
SILDebugInfoExpression DIExpr;
1790-
1791-
// Use vanilla copy ctor / operator
1792-
SILDebugVariable(const SILDebugVariable &) = default;
1793-
SILDebugVariable &operator=(const SILDebugVariable &) = default;
1794-
1795-
SILDebugVariable()
1796-
: ArgNo(0), Constant(false), Implicit(false), Scope(nullptr) {}
1797-
SILDebugVariable(bool Constant, uint16_t ArgNo)
1798-
: ArgNo(ArgNo), Constant(Constant), Implicit(false), Scope(nullptr) {}
1799-
SILDebugVariable(StringRef Name, bool Constant, unsigned ArgNo,
1800-
bool IsImplicit = false, Optional<SILType> AuxType = {},
1801-
Optional<SILLocation> DeclLoc = {},
1802-
const SILDebugScope *DeclScope = nullptr,
1803-
llvm::ArrayRef<SILDIExprElement> ExprElements = {})
1804-
: Name(Name), ArgNo(ArgNo), Constant(Constant), Implicit(IsImplicit),
1805-
Type(AuxType), Loc(DeclLoc), Scope(DeclScope), DIExpr(ExprElements) {}
1806-
1807-
/// Created from either AllocStack or AllocBox instruction
1808-
static Optional<SILDebugVariable>
1809-
createFromAllocation(const AllocationInst *AI);
1810-
1811-
bool operator==(const SILDebugVariable &V) {
1812-
return ArgNo == V.ArgNo && Constant == V.Constant && Name == V.Name &&
1813-
Implicit == V.Implicit && Type == V.Type && Loc == V.Loc &&
1814-
Scope == V.Scope && DIExpr == V.DIExpr;
1815-
}
1816-
1817-
bool isLet() const { return Name.size() && Constant; }
1818-
1819-
bool isVar() const { return Name.size() && !Constant; }
1820-
};
1821-
18221779
/// A DebugVariable where storage for the strings has been
18231780
/// tail-allocated following the parent SILInstruction.
18241781
class TailAllocatedDebugVariable {

0 commit comments

Comments
 (0)