1313#ifndef SWIFT_SIL_SILARGUMENT_H
1414#define SWIFT_SIL_SILARGUMENT_H
1515
16- #include " swift/SIL/SILValue .h"
16+ #include " swift/SIL/SILArgumentConvention .h"
1717#include " swift/SIL/SILFunction.h"
18+ #include " swift/SIL/SILValue.h"
1819
1920namespace swift {
2021
2122class SILBasicBlock ;
2223class SILModule ;
2324
24- // / Conventions for apply operands and function-entry arguments in SIL.
25- // /
26- // / By design, this is exactly the same as ParameterConvention, plus
27- // / Indirect_Out.
28- enum class SILArgumentConvention : uint8_t {
29- Indirect_In,
30- Indirect_In_Guaranteed,
31- Indirect_Inout,
32- Indirect_InoutAliasable,
33- Indirect_Out,
34- Direct_Owned,
35- Direct_Unowned,
36- Direct_Deallocating,
37- Direct_Guaranteed,
38- };
39-
40- inline bool isIndirectConvention (SILArgumentConvention convention) {
41- return convention <= SILArgumentConvention::Indirect_Out;
42- }
43-
44- // / Turn a ParameterConvention into a SILArgumentConvention.
45- inline SILArgumentConvention getSILArgumentConvention (ParameterConvention conv){
46- switch (conv) {
47- case ParameterConvention::Indirect_In:
48- return SILArgumentConvention::Indirect_In;
49- case ParameterConvention::Indirect_Inout:
50- return SILArgumentConvention::Indirect_Inout;
51- case ParameterConvention::Indirect_InoutAliasable:
52- return SILArgumentConvention::Indirect_InoutAliasable;
53- case ParameterConvention::Indirect_In_Guaranteed:
54- return SILArgumentConvention::Indirect_In_Guaranteed;
55- case ParameterConvention::Direct_Unowned:
56- return SILArgumentConvention::Direct_Unowned;
57- case ParameterConvention::Direct_Guaranteed:
58- return SILArgumentConvention::Direct_Guaranteed;
59- case ParameterConvention::Direct_Owned:
60- return SILArgumentConvention::Direct_Owned;
61- case ParameterConvention::Direct_Deallocating:
62- return SILArgumentConvention::Direct_Deallocating;
63- }
64- llvm_unreachable (" covered switch isn't covered?!" );
65- }
66-
6725inline SILArgumentConvention
6826SILFunctionType::getSILArgumentConvention (unsigned index) const {
6927 assert (index <= getNumSILArguments ());
@@ -72,44 +30,8 @@ SILFunctionType::getSILArgumentConvention(unsigned index) const {
7230 return SILArgumentConvention::Indirect_Out;
7331 } else {
7432 auto param = getParameters ()[index - numIndirectResults];
75- return swift::getSILArgumentConvention (param.getConvention ());
76- }
77- }
78-
79- enum class InoutAliasingAssumption {
80- // / Assume that an inout indirect parameter may alias other objects.
81- // / This is the safe assumption an optimization should make if it may break
82- // / memory safety in case the inout aliasing rule is violation.
83- Aliasing,
84-
85- // / Assume that an inout indirect parameter cannot alias other objects.
86- // / Optimizations should only use this if they can guarantee that they will
87- // / not break memory safety even if the inout aliasing rule is violated.
88- NotAliasing
89- };
90-
91- // / Returns true if \p conv is a not-aliasing indirect parameter.
92- // / The \p isInoutAliasing specifies what to assume about the inout convention.
93- // / See InoutAliasingAssumption.
94- inline bool isNotAliasedIndirectParameter (SILArgumentConvention conv,
95- InoutAliasingAssumption isInoutAliasing) {
96- switch (conv) {
97- case SILArgumentConvention::Indirect_In:
98- case SILArgumentConvention::Indirect_Out:
99- case SILArgumentConvention::Indirect_In_Guaranteed:
100- return true ;
101-
102- case SILArgumentConvention::Indirect_Inout:
103- return isInoutAliasing == InoutAliasingAssumption::NotAliasing;
104-
105- case SILArgumentConvention::Indirect_InoutAliasable:
106- case SILArgumentConvention::Direct_Unowned:
107- case SILArgumentConvention::Direct_Guaranteed:
108- case SILArgumentConvention::Direct_Owned:
109- case SILArgumentConvention::Direct_Deallocating:
110- return false ;
33+ return SILArgumentConvention (param.getConvention ());
11134 }
112- llvm_unreachable (" covered switch isn't covered?!" );
11335}
11436
11537class SILArgument : public ValueBase {
0 commit comments