File tree Expand file tree Collapse file tree 3 files changed +39
-0
lines changed Expand file tree Collapse file tree 3 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -813,6 +813,15 @@ ClangTypeConverter::visitBuiltinFloatType(BuiltinFloatType *type) {
813813 llvm_unreachable (" cannot translate floating-point format to C" );
814814}
815815
816+ clang::QualType
817+ ClangTypeConverter::visitBuiltinVectorType (BuiltinVectorType *type) {
818+ auto &clangCtx = ClangASTContext;
819+ auto eltTy = visit (type->getElementType ());
820+ return clangCtx.getVectorType (
821+ eltTy, type->getNumElements (), clang::VectorKind::Generic
822+ );
823+ }
824+
816825clang::QualType ClangTypeConverter::visitArchetypeType (ArchetypeType *type) {
817826 // We see these in the case where we invoke an @objc function
818827 // through a protocol.
Original file line number Diff line number Diff line change @@ -157,6 +157,7 @@ class ClangTypeConverter :
157157 clang::QualType visitBuiltinRawPointerType (BuiltinRawPointerType *type);
158158 clang::QualType visitBuiltinIntegerType (BuiltinIntegerType *type);
159159 clang::QualType visitBuiltinFloatType (BuiltinFloatType *type);
160+ clang::QualType visitBuiltinVectorType (BuiltinVectorType *type);
160161 clang::QualType visitArchetypeType (ArchetypeType *type);
161162 clang::QualType visitDependentMemberType (DependentMemberType *type);
162163 template <bool templateArgument = false >
Original file line number Diff line number Diff line change 1+ //===----------------------------------------------------------*- swift -*-===//
2+ //
3+ // This source file is part of the Swift.org open source project
4+ //
5+ // Copyright (c) 2025 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+ // REQUIRES: swift_feature_Extern
13+ // REQUIRES: swift_feature_BuiltinModule
14+ // RUN: %target-swift-frontend -primary-file %s -enable-experimental-feature BuiltinModule -enable-experimental-feature Extern -emit-ir | %FileCheck %s --check-prefix=CHECK
15+
16+ import Builtin
17+
18+ @_extern ( c, " llvm.uadd.sat.v16i8 " ) @usableFromInline
19+ func _uaddSat( _ a: Builtin . Vec16xInt8 , _ b: Builtin . Vec16xInt8 ) -> Builtin . Vec16xInt8
20+
21+ @_transparent
22+ public func saturatingAdd( _ a: SIMD16 < UInt8 > , _ b: SIMD16 < UInt8 > ) -> SIMD16 < UInt8 > {
23+ // Hack around init from Builtin type being stdlib-internal using unsafeBitCast.
24+ unsafeBitCast ( _uaddSat ( a. _storage. _value, b. _storage. _value) , to: SIMD16< UInt8> . self )
25+ }
26+ // CHECK: saturatingAdd{{.*}} {
27+ // CHECK: entry:
28+ // CHECK: call <16 x i8> @llvm.uadd.sat.v16i8
29+
You can’t perform that action at this time.
0 commit comments