|
1 | | -#===-----------------------------------------------------------------------===// |
| 1 | +# ===----------------------------------------------------------------------===// |
2 | 2 | # |
3 | 3 | # This source file is part of the Swift.org open source project |
4 | 4 | # |
|
8 | 8 | # See https://swift.org/LICENSE.txt for license information |
9 | 9 | # See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors |
10 | 10 | # |
11 | | -#===-----------------------------------------------------------------------===// |
| 11 | +# ===----------------------------------------------------------------------===// |
12 | 12 |
|
13 | 13 | atomicTypes = [ |
14 | | - # Name Size Alignment Builtin Swift Type |
15 | | - ("_Atomic8BitStorage", "8", "1", "Builtin.Int8", "UInt8"), |
16 | | - ("_Atomic16BitStorage", "16", "2", "Builtin.Int16", "UInt16"), |
17 | | - ("_Atomic32BitStorage", "32", "4", "Builtin.Int32", "UInt32"), |
18 | | - ("_Atomic64BitStorage", "64", "8", "Builtin.Int64", "UInt64"), |
19 | | - |
20 | | - # Note: WordPair only on 64 bit platforms. |
21 | | - ("_Atomic128BitStorage", "128", "16", "Builtin.Int128", "WordPair"), |
| 14 | + # Name, Size, Alignment, Builtin, Swift Type |
| 15 | + ("_Atomic8BitStorage", "8", "1", "Builtin.Int8", "UInt8"), |
| 16 | + ("_Atomic16BitStorage", "16", "2", "Builtin.Int16", "UInt16"), |
| 17 | + ("_Atomic32BitStorage", "32", "4", "Builtin.Int32", "UInt32"), |
| 18 | + ("_Atomic64BitStorage", "64", "8", "Builtin.Int64", "UInt64"), |
| 19 | + |
| 20 | + # Note: WordPair only on 64 bit platforms. |
| 21 | + ("_Atomic128BitStorage", "128", "16", "Builtin.Int128", "WordPair"), |
22 | 22 | ] |
23 | 23 |
|
24 | 24 | intTypes = [ |
25 | | - # Swift Storage Type Builtin |
26 | | - ("Int8", "_Atomic8BitStorage", "Int8"), |
27 | | - ("Int16", "_Atomic16BitStorage", "Int16"), |
28 | | - ("Int32", "_Atomic32BitStorage", "Int32"), |
29 | | - ("Int64", "_Atomic64BitStorage", "Int64"), |
30 | | - |
31 | | - # We handle the word type's storage in source. |
32 | | - ("Int", "", ""), |
33 | | - ("UInt", "", ""), |
34 | | - |
35 | | - ("UInt8", "_Atomic8BitStorage", "Int8"), |
36 | | - ("UInt16", "_Atomic16BitStorage", "Int16"), |
37 | | - ("UInt32", "_Atomic32BitStorage", "Int32"), |
38 | | - ("UInt64", "_Atomic64BitStorage", "Int64"), |
| 25 | + # Swift, Storage Type, Builtin |
| 26 | + ("Int8", "_Atomic8BitStorage", "Int8"), |
| 27 | + ("Int16", "_Atomic16BitStorage", "Int16"), |
| 28 | + ("Int32", "_Atomic32BitStorage", "Int32"), |
| 29 | + ("Int64", "_Atomic64BitStorage", "Int64"), |
| 30 | + |
| 31 | + # We handle the word type's storage in source. |
| 32 | + ("Int", "", ""), |
| 33 | + ("UInt", "", ""), |
| 34 | + |
| 35 | + ("UInt8", "_Atomic8BitStorage", "Int8"), |
| 36 | + ("UInt16", "_Atomic16BitStorage", "Int16"), |
| 37 | + ("UInt32", "_Atomic32BitStorage", "Int32"), |
| 38 | + ("UInt64", "_Atomic64BitStorage", "Int64"), |
39 | 39 | ] |
40 | 40 |
|
41 | 41 | loadOrderings = [ |
42 | | - # Swift API name doc name LLVM name |
43 | | - ("relaxed", "Relaxed", "relaxed", "monotonic"), |
44 | | - ("acquiring", "Acquiring", "acquiring", "acquire"), |
45 | | - ("sequentiallyConsistent", "SequentiallyConsistent", "sequentially consistent", "seqcst") |
| 42 | + # Swift, API name, doc name, LLVM name |
| 43 | + ("relaxed", "Relaxed", "relaxed", "monotonic"), |
| 44 | + ("acquiring", "Acquiring", "acquiring", "acquire"), |
| 45 | + ( |
| 46 | + "sequentiallyConsistent", |
| 47 | + "SequentiallyConsistent", |
| 48 | + "sequentially consistent", |
| 49 | + "seqcst" |
| 50 | + ) |
46 | 51 | ] |
47 | 52 |
|
48 | 53 | storeOrderings = [ |
49 | | - # Swift enum case, API name, doc name, LLVM name |
50 | | - ("relaxed", "Relaxed", "relaxed", "monotonic"), |
51 | | - ("releasing", "Releasing", "releasing", "release"), |
52 | | - ("sequentiallyConsistent", "SequentiallyConsistent", "sequentially consistent", "seqcst") |
| 54 | + # Swift enum case, API name, doc name, LLVM name |
| 55 | + ("relaxed", "Relaxed", "relaxed", "monotonic"), |
| 56 | + ("releasing", "Releasing", "releasing", "release"), |
| 57 | + ( |
| 58 | + "sequentiallyConsistent", |
| 59 | + "SequentiallyConsistent", |
| 60 | + "sequentially consistent", |
| 61 | + "seqcst" |
| 62 | + ) |
53 | 63 | ] |
54 | 64 |
|
55 | 65 | updateOrderings = [ |
56 | | - # Swift enum case, API name, doc name, LLVM name, failure name |
57 | | - ("relaxed", "Relaxed", "relaxed", "monotonic", "monotonic"), |
58 | | - ("acquiring", "Acquiring", "acquiring", "acquire", "acquire"), |
59 | | - ("releasing", "Releasing", "releasing", "release", "monotonic"), |
60 | | - ("acquiringAndReleasing", "AcquiringAndReleasing", "acquiring-and-releasing", "acqrel", "acquire"), |
61 | | - ("sequentiallyConsistent", "SequentiallyConsistent", "sequentially consistent", "seqcst", "seqcst"), |
| 66 | + # Swift enum case, API name, doc name, LLVM name, failure name |
| 67 | + ("relaxed", "Relaxed", "relaxed", "monotonic", "monotonic"), |
| 68 | + ("acquiring", "Acquiring", "acquiring", "acquire", "acquire"), |
| 69 | + ("releasing", "Releasing", "releasing", "release", "monotonic"), |
| 70 | + ( |
| 71 | + "acquiringAndReleasing", |
| 72 | + "AcquiringAndReleasing", |
| 73 | + "acquiring-and-releasing", |
| 74 | + "acqrel", |
| 75 | + "acquire" |
| 76 | + ), |
| 77 | + ( |
| 78 | + "sequentiallyConsistent", |
| 79 | + "SequentiallyConsistent", |
| 80 | + "sequentially consistent", |
| 81 | + "seqcst", |
| 82 | + "seqcst" |
| 83 | + ), |
62 | 84 | ] |
63 | 85 |
|
64 | 86 | integerOperations = [ |
65 | | - # Swift name, llvm name, operator, doc name |
66 | | - ("WrappingAdd", "add", "&+", "wrapping add"), |
67 | | - ("WrappingSubtract", "sub", "&-", "wrapping subtract"), |
68 | | - ("BitwiseAnd", "and", "&", "bitwise AND"), |
69 | | - ("BitwiseOr", "or", "|", "bitwise OR"), |
70 | | - ("BitwiseXor", "xor", "^", "bitwise XOR"), |
71 | | - |
72 | | - # These two are handled specially in source. |
73 | | - ("Min", "min", "", "minimum"), |
74 | | - ("Max", "max", "", "maximum") |
| 87 | + # Swift name, llvm name, operator, doc name |
| 88 | + ("WrappingAdd", "add", "&+", "wrapping add"), |
| 89 | + ("WrappingSubtract", "sub", "&-", "wrapping subtract"), |
| 90 | + ("BitwiseAnd", "and", "&", "bitwise AND"), |
| 91 | + ("BitwiseOr", "or", "|", "bitwise OR"), |
| 92 | + ("BitwiseXor", "xor", "^", "bitwise XOR"), |
| 93 | + |
| 94 | + # These two are handled specially in source. |
| 95 | + ("Min", "min", "", "minimum"), |
| 96 | + ("Max", "max", "", "maximum") |
75 | 97 | ] |
76 | 98 |
|
77 | 99 | boolOperations = [ |
78 | | - # Swift name, llvm name, operator, doc |
79 | | - ("LogicalAnd", "and", "&&", "logical AND"), |
80 | | - ("LogicalOr", "or", "||", "logical OR"), |
81 | | - ("LogicalXor", "xor", "!=", "logical XOR") |
| 100 | + # Swift name, llvm name, operator, doc |
| 101 | + ("LogicalAnd", "and", "&&", "logical AND"), |
| 102 | + ("LogicalOr", "or", "||", "logical OR"), |
| 103 | + ("LogicalXor", "xor", "!=", "logical XOR") |
82 | 104 | ] |
83 | 105 |
|
| 106 | + |
84 | 107 | # LLVM doesn't support arbitrary ordering combinations yet, so for the |
85 | 108 | # two-ordering cmpxchg variants we need to upgrade the success |
86 | 109 | # ordering when necessary so that it is at least as "strong" as the |
87 | 110 | # failure case. This function implements that mapping. |
88 | 111 | # |
89 | 112 | # See llvm/Support/AtomicOrdering.h |
90 | 113 | def actualOrders(success, failure): |
91 | | - def max(success, failure): |
92 | | - if failure == "acquire": |
93 | | - if success == "monotonic": |
94 | | - return "acquire" |
95 | | - if success == "release": |
96 | | - return "acqrel" |
97 | | - if failure == "seqcst": |
98 | | - return "seqcst" |
99 | | - return success |
100 | | - actualSuccess = max(success, failure) |
101 | | - return actualSuccess + "_" + failure |
| 114 | + def max(success, failure): |
| 115 | + if failure == "acquire": |
| 116 | + if success == "monotonic": |
| 117 | + return "acquire" |
| 118 | + if success == "release": |
| 119 | + return "acqrel" |
| 120 | + if failure == "seqcst": |
| 121 | + return "seqcst" |
| 122 | + return success |
| 123 | + actualSuccess = max(success, failure) |
| 124 | + return actualSuccess + "_" + failure |
| 125 | + |
102 | 126 |
|
103 | 127 | def llvmToCaseName(ordering): |
104 | | - if ordering == "monotonic": |
105 | | - return "relaxed" |
106 | | - if ordering == "acquire": |
107 | | - return "acquiring" |
108 | | - if ordering == "release": |
109 | | - return "releasing" |
110 | | - if ordering == "acqrel": |
111 | | - return "acquiringAndReleasing" |
112 | | - if ordering == "seqcst": |
113 | | - return "sequentiallyConsistent" |
| 128 | + if ordering == "monotonic": |
| 129 | + return "relaxed" |
| 130 | + if ordering == "acquire": |
| 131 | + return "acquiring" |
| 132 | + if ordering == "release": |
| 133 | + return "releasing" |
| 134 | + if ordering == "acqrel": |
| 135 | + return "acquiringAndReleasing" |
| 136 | + if ordering == "seqcst": |
| 137 | + return "sequentiallyConsistent" |
| 138 | + |
114 | 139 |
|
115 | 140 | def atomicOperationName(intType, operation): |
116 | | - if operation == "Min": |
117 | | - return "umin" if intType.startswith("U") else "min" |
118 | | - if operation == "Max": |
119 | | - return "umax" if intType.startswith("U") else "max" |
120 | | - return operation |
| 141 | + if operation == "Min": |
| 142 | + return "umin" if intType.startswith("U") else "min" |
| 143 | + if operation == "Max": |
| 144 | + return "umax" if intType.startswith("U") else "max" |
| 145 | + return operation |
| 146 | + |
121 | 147 |
|
122 | 148 | def lowerFirst(str): |
123 | | - return str[:1].lower() + str[1:] if str else "" |
| 149 | + return str[:1].lower() + str[1:] if str else "" |
| 150 | + |
124 | 151 |
|
125 | 152 | def argLabel(label): |
126 | | - return label + ": " if label != "_" else "" |
| 153 | + return label + ": " if label != "_" else "" |
0 commit comments