Skip to content

Commit 99fd8b6

Browse files
committed
Rename some macros based on the PR review comments.
- use the SWIFT prefix for all macros - make names of some macros shorter
1 parent de3b850 commit 99fd8b6

File tree

13 files changed

+246
-237
lines changed

13 files changed

+246
-237
lines changed

include/swift/Runtime/Config.h

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -67,31 +67,31 @@
6767
// Annotation for specifying a calling convention of
6868
// a runtime function. It should be used with declarations
6969
// of runtime functions like this:
70-
// void runtime_function_name() CALLING_CONVENTION(RegisterPreservingCC)
71-
#define CALLING_CONVENTION(CC) CALLING_CONVENTION_##CC
70+
// void runtime_function_name() SWIFT_CC(RegisterPreservingCC)
71+
#define SWIFT_CC(CC) SWIFT_CC_##CC
7272

73-
#define CALLING_CONVENTION_preserve_most __attribute__((preserve_most))
74-
#define CALLING_CONVENTION_preserve_all __attribute__((preserve_all))
75-
#define CALLING_CONVENTION_c
73+
#define SWIFT_CC_preserve_most __attribute__((preserve_most))
74+
#define SWIFT_CC_preserve_all __attribute__((preserve_all))
75+
#define SWIFT_CC_c
7676

7777
// Map a logical calling convention (e.g. RegisterPreservingCC) to LLVM calling
7878
// convention.
79-
#define LLVM_CC(CC) LLVM_CC_##CC
79+
#define SWIFT_LLVM_CC(CC) SWIFT_LLVM_CC_##CC
8080

8181
// Currently, RuntimeFunction.def uses the following calling conventions:
8282
// DefaultCC, RegisterPreservingCC.
8383
// If new runtime calling conventions are added later, they need to be mapped
8484
// here to something appropriate.
8585

8686
// DefaultCC is usually the standard C calling convention.
87-
#define CALLING_CONVENTION_DefaultCC CALLING_CONVENTION_c
88-
#define CALLING_CONVENTION_DefaultCC_IMPL CALLING_CONVENTION_c
89-
#define LLVM_CC_DefaultCC llvm::CallingConv::C
87+
#define SWIFT_CC_DefaultCC SWIFT_CC_c
88+
#define SWIFT_CC_DefaultCC_IMPL SWIFT_CC_c
89+
#define SWIFT_LLVM_CC_DefaultCC llvm::CallingConv::C
9090

9191
// If defined, it indicates that runtime function wrappers
9292
// should be used on all platforms, even they do not support
9393
// the new calling convention which requires this.
94-
#define RT_USE_WRAPPERS_ALWAYS 1
94+
#define SWIFT_RT_USE_WRAPPERS_ALWAYS 1
9595

9696
// If defined, it indicates that this calling convention is
9797
// supported by the currnet target.
@@ -114,23 +114,24 @@
114114
// linker may clobber some of the callee-saved registers defined by
115115
// this new calling convention when it performs lazy binding of
116116
// runtime functions using this new calling convention.
117-
#define CALLING_CONVENTION_RegisterPreservingCC CALLING_CONVENTION_preserve_most
118-
#define CALLING_CONVENTION_RegisterPreservingCC_IMPL \
119-
CALLING_CONVENTION_preserve_most
120-
#define LLVM_CC_RegisterPreservingCC llvm::CallingConv::PreserveMost
117+
#define SWIFT_CC_RegisterPreservingCC \
118+
SWIFT_CC_preserve_most
119+
#define SWIFT_CC_RegisterPreservingCC_IMPL \
120+
SWIFT_CC_preserve_most
121+
#define SWIFT_LLVM_CC_RegisterPreservingCC llvm::CallingConv::PreserveMost
121122

122123
// Indicate that wrappers should be used, because it is required
123124
// for the calling convention to get around dynamic linking issues.
124-
#define RT_USE_WRAPPERS 1
125+
#define SWIFT_RT_USE_WRAPPERS 1
125126

126127
#else
127128

128129
// Targets not supporting the dedicated runtime calling convention
129130
// should use the standard calling convention instead.
130131
// No wrappers are required in this case by the calling convention.
131-
#define CALLING_CONVENTION_RegisterPreservingCC CALLING_CONVENTION_c
132-
#define CALLING_CONVENTION_RegisterPreservingCC_IMPL CALLING_CONVENTION_c
133-
#define LLVM_CC_RegisterPreservingCC llvm::CallingConv::C
132+
#define SWIFT_CC_RegisterPreservingCC SWIFT_CC_c
133+
#define SWIFT_CC_RegisterPreservingCC_IMPL SWIFT_CC_c
134+
#define SWIFT_LLVM_CC_RegisterPreservingCC llvm::CallingConv::C
134135

135136
#endif
136137

@@ -139,40 +140,40 @@
139140

140141
// Generates a name of the runtime enrty's implementation by
141142
// adding an underscore as a prefix and a suffix.
142-
#define RT_ENTRY_IMPL(Name) _##Name##_
143+
#define SWIFT_RT_ENTRY_IMPL(Name) _##Name##_
143144

144145
// Library internal way to invoke the implementation of a runtime entry.
145146
// E.g. a runtime function may be called internally via its public API
146147
// or via the function pointer.
147-
#define RT_ENTRY_CALL(Name) Name
148+
#define SWIFT_RT_ENTRY_CALL(Name) Name
148149

149150
// Name of the symbol holding a reference to the
150151
// implementation of a runtime entry.
151-
#define RT_ENTRY_REF(Name) _##Name
152+
#define SWIFT_RT_ENTRY_REF(Name) _##Name
152153

153154
// String representation of the symbol's name.
154-
#define RT_ENTRY_REF_AS_STR(Name) "_" #Name
155+
#define SWIFT_RT_ENTRY_REF_AS_STR(Name) "_" #Name
155156

156-
#if defined(RT_USE_WRAPPERS_ALWAYS)
157-
#define RT_USE_WRAPPERS
157+
#if defined(SWIFT_RT_USE_WRAPPERS_ALWAYS)
158+
#define SWIFT_RT_USE_WRAPPERS
158159
#endif
159160

160-
#if defined(RT_USE_WRAPPERS)
161+
#if defined(SWIFT_RT_USE_WRAPPERS)
161162

162163
// Both the runtime functions and their implementation are hidden and
163164
// can be directly referenced only inside the runtime library.
164165
// User code can access these runtime entries only indirectly
165166
// via a global function pointer.
166-
#define RT_ENTRY_VISIBILITY LLVM_LIBRARY_VISIBILITY
167-
#define RT_ENTRY_IMPL_VISIBILITY LLVM_LIBRARY_VISIBILITY
167+
#define SWIFT_RT_ENTRY_VISIBILITY LLVM_LIBRARY_VISIBILITY
168+
#define SWIFT_RT_ENTRY_IMPL_VISIBILITY LLVM_LIBRARY_VISIBILITY
168169

169170
#else
170171

171172
// Runtime functions are exported, because it should be possible
172173
// to invoke them directly from the user code. But internal
173174
// implementations of runtime functions do not need to be exported.
174-
#define RT_ENTRY_VISIBILITY SWIFT_RUNTIME_EXPORT
175-
#define RT_ENTRY_IMPL_VISIBILITY LLVM_LIBRARY_VISIBILITY
175+
#define SWIFT_RT_ENTRY_VISIBILITY SWIFT_RUNTIME_EXPORT
176+
#define SWIFT_RT_ENTRY_IMPL_VISIBILITY LLVM_LIBRARY_VISIBILITY
176177

177178
#endif
178179

include/swift/Runtime/Enum.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ extern "C" void swift_initEnumValueWitnessTableSinglePayload(
5050
/// \returns -1 if the payload case is inhabited. If an empty case is inhabited,
5151
/// returns a value greater than or equal to zero and less than
5252
/// emptyCases.
53-
RT_ENTRY_VISIBILITY
53+
SWIFT_RT_ENTRY_VISIBILITY
5454
extern "C" int swift_getEnumCaseSinglePayload(const OpaqueValue *value,
5555
const Metadata *payload,
5656
unsigned emptyCases)
57-
CALLING_CONVENTION(RegisterPreservingCC);
57+
SWIFT_CC(RegisterPreservingCC);
5858

5959

6060

@@ -69,12 +69,12 @@ extern "C" int swift_getEnumCaseSinglePayload(const OpaqueValue *value,
6969
/// case, or a value greater than or equal to zero and less
7070
/// than emptyCases for an empty case.
7171
/// \param emptyCases - the number of empty cases in the enum.
72-
RT_ENTRY_VISIBILITY
72+
SWIFT_RT_ENTRY_VISIBILITY
7373
extern "C" void swift_storeEnumTagSinglePayload(OpaqueValue *value,
7474
const Metadata *payload,
7575
int whichCase,
7676
unsigned emptyCases)
77-
CALLING_CONVENTION(RegisterPreservingCC);
77+
SWIFT_CC(RegisterPreservingCC);
7878

7979
/// \brief Initialize the value witness table for a generic, multi-payload
8080
/// enum instance.

0 commit comments

Comments
 (0)