Skip to content

Commit e6a1e23

Browse files
authored
Add SWIFT_STDLIB_ENABLE_VECTOR_TYPES to take away support for SIMD (#41149)
1 parent 17c5d6f commit e6a1e23

File tree

7 files changed

+34
-4
lines changed

7 files changed

+34
-4
lines changed

stdlib/cmake/modules/AddSwiftStdlib.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,10 @@ function(_add_target_variant_c_compile_flags)
364364
list(APPEND result "-DSWIFT_STDLIB_SHORT_MANGLING_LOOKUPS")
365365
endif()
366366

367+
if(SWIFT_STDLIB_ENABLE_VECTOR_TYPES)
368+
list(APPEND result "-DSWIFT_STDLIB_ENABLE_VECTOR_TYPES")
369+
endif()
370+
367371
if(SWIFT_STDLIB_HAS_TYPE_PRINTING)
368372
list(APPEND result "-DSWIFT_STDLIB_HAS_TYPE_PRINTING")
369373
endif()

stdlib/cmake/modules/StdlibOptions.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ option(SWIFT_STDLIB_SHORT_MANGLING_LOOKUPS
101101
"Build stdlib with fast-path context descriptor lookups based on well-known short manglings."
102102
TRUE)
103103

104+
option(SWIFT_STDLIB_ENABLE_VECTOR_TYPES
105+
"Build stdlib with support for SIMD and vector types"
106+
TRUE)
107+
104108
option(SWIFT_STDLIB_HAS_TYPE_PRINTING
105109
"Build stdlib with support for printing user-friendly type name as strings at runtime"
106110
TRUE)

stdlib/public/Differentiation/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
#
1111
#===----------------------------------------------------------------------===#
1212

13+
if(SWIFT_STDLIB_ENABLE_VECTOR_TYPES)
14+
set(swiftDifferentiationSIMDFiles SIMDDifferentiation.swift.gyb)
15+
else()
16+
set(swiftDifferentiationSIMDFiles)
17+
endif()
18+
1319
add_swift_target_library(swift_Differentiation ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_STDLIB
1420
Differentiable.swift
1521
DifferentialOperators.swift
@@ -23,7 +29,7 @@ add_swift_target_library(swift_Differentiation ${SWIFT_STDLIB_LIBRARY_BUILD_TYPE
2329
GYB_SOURCES
2430
FloatingPointDifferentiation.swift.gyb
2531
TgmathDerivatives.swift.gyb
26-
SIMDDifferentiation.swift.gyb
32+
${swiftDifferentiationSIMDFiles}
2733

2834
SWIFT_MODULE_DEPENDS_OSX Darwin
2935
SWIFT_MODULE_DEPENDS_IOS Darwin

stdlib/public/core/CMakeLists.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ set(SWIFTLIB_SOURCES
220220
PlaygroundDisplay.swift
221221
CommandLine.swift
222222
SliceBuffer.swift
223-
SIMDVector.swift
224223
UnfoldSequence.swift
225224
VarArgs.swift
226225
Zip.swift
@@ -229,10 +228,14 @@ set(SWIFTLIB_SOURCES
229228

230229
set(SWIFTLIB_GYB_SOURCES
231230
${SWIFTLIB_ESSENTIAL_GYB_SOURCES}
232-
SIMDConcreteOperations.swift.gyb
233-
SIMDVectorTypes.swift.gyb
234231
Tuple.swift.gyb
235232
)
233+
234+
if(SWIFT_STDLIB_ENABLE_VECTOR_TYPES)
235+
list(APPEND SWIFTLIB_SOURCES SIMDVector.swift)
236+
list(APPEND SWIFTLIB_GYB_SOURCES SIMDConcreteOperations.swift.gyb SIMDVectorTypes.swift.gyb)
237+
endif()
238+
236239
set(GROUP_INFO_JSON_FILE ${CMAKE_CURRENT_SOURCE_DIR}/GroupInfo.json)
237240
set(swift_core_link_flags "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}")
238241
set(swift_core_framework_depends)

stdlib/public/runtime/Demangle.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,9 @@ _buildDemanglerForBuiltinType(const Metadata *type, Demangle::Demangler &Dem) {
240240
#define BUILTIN_TYPE(Symbol, Name) \
241241
if (type == &METADATA_SYM(Symbol).base) \
242242
return Dem.createNode(Node::Kind::BuiltinTypeName, Name);
243+
#if !SWIFT_STDLIB_ENABLE_VECTOR_TYPES
244+
#define BUILTIN_VECTOR_TYPE(ElementSymbol, ElementName, Width)
245+
#endif
243246
#include "swift/Runtime/BuiltinTypes.def"
244247
return nullptr;
245248
}

stdlib/public/runtime/KnownMetadata.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,15 @@ const ValueWitnessTable swift::VALUE_WITNESS_SYM(Symbol) = \
184184
const ValueWitnessTable swift::VALUE_WITNESS_SYM(Symbol) = \
185185
ValueWitnessTableForBox<pointer_types::Symbol>::table;
186186

187+
#if SWIFT_STDLIB_ENABLE_VECTOR_TYPES
187188
#define BUILTIN_VECTOR_TYPE(ElementSymbol, _, Width) \
188189
const ValueWitnessTable \
189190
swift::VALUE_WITNESS_SYM(VECTOR_BUILTIN_SYMBOL_NAME(ElementSymbol,Width)) = \
190191
ValueWitnessTableForBox<NativeBox<SIMDVectorType<ctypes::ElementSymbol, \
191192
Width>>>::table;
193+
#else
194+
#define BUILTIN_VECTOR_TYPE(ElementSymbol, ElementName, Width)
195+
#endif
192196

193197
#include "swift/Runtime/BuiltinTypes.def"
194198

@@ -262,6 +266,9 @@ const ValueWitnessTable swift::VALUE_WITNESS_SYM(EMPTY_TUPLE_MANGLING) =
262266
};
263267
#define BUILTIN_TYPE(Symbol, Name) \
264268
OPAQUE_METADATA(Symbol)
269+
#if !SWIFT_STDLIB_ENABLE_VECTOR_TYPES
270+
#define BUILTIN_VECTOR_TYPE(ElementSymbol, ElementName, Width)
271+
#endif
265272
#include "swift/Runtime/BuiltinTypes.def"
266273

267274
/// The standard metadata for the empty tuple.

stdlib/public/runtime/MetadataLookup.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,6 +1461,9 @@ class DecodedMetadataBuilder {
14611461
#define BUILTIN_TYPE(Symbol, _) \
14621462
if (mangledName.equals(#Symbol)) \
14631463
return &METADATA_SYM(Symbol).base;
1464+
#if !SWIFT_STDLIB_ENABLE_VECTOR_TYPES
1465+
#define BUILTIN_VECTOR_TYPE(ElementSymbol, ElementName, Width)
1466+
#endif
14641467
#include "swift/Runtime/BuiltinTypes.def"
14651468
return BuiltType();
14661469
}

0 commit comments

Comments
 (0)