Files
swift-mirror/test/PrintAsObjC/simd.swift
Joe Groff d0473756ec ClangImporter etc.: Remap C vector types to nested BaseType.VectorN types.
The design we landed on for SIMD is to define the vector types as nested types of their element, e.g. Float.Vector4, Int32.Vector2, etc. Update the Clang importer and other mapping facilities to match.

Swift SVN r28087
2015-05-02 15:04:43 +00:00

39 lines
2.2 KiB
Swift

// RUN: rm -rf %t
// RUN: mkdir %t
// FIXME: BEGIN -enable-source-import hackaround
// RUN: %target-swift-frontend(mock-sdk: -sdk %S/../Inputs/clang-importer-sdk -I %t) -emit-module -o %t %S/../Inputs/clang-importer-sdk/swift-modules/ObjectiveC.swift
// RUN: %target-swift-frontend(mock-sdk: -sdk %S/../Inputs/clang-importer-sdk -I %t) -emit-module -o %t %S/../Inputs/clang-importer-sdk/swift-modules/CoreGraphics.swift
// RUN: %target-swift-frontend(mock-sdk: -sdk %S/../Inputs/clang-importer-sdk -I %t) -emit-module -o %t %S/../Inputs/clang-importer-sdk/swift-modules/Foundation.swift
// RUN: %target-swift-frontend(mock-sdk: -sdk %S/../Inputs/clang-importer-sdk -I %t) -emit-module -o %t %S/../Inputs/clang-importer-sdk/swift-modules/simd.swift
// FIXME: END -enable-source-import hackaround
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource) -I %t -emit-module -emit-module-doc -o %t -module-name simd_test %s
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk-nosource) -I %t -parse-as-library %t/simd_test.swiftmodule -parse -emit-objc-header-path %t/simd.h -import-objc-header %S/../Inputs/empty.h -disable-objc-attr-requires-foundation-module
// RUN: FileCheck %s < %t/simd.h
// RUN: %check-in-clang %t/simd.h
// RUN: %check-in-clang -fno-modules %t/simd.h -include Foundation.h
// REQUIRES: objc_interop
import Foundation
import simd
// CHECK-LABEL: typedef float swift_Float_Vector4 __attribute__((__ext_vector_type__(4)));
// CHECK-LABEL: typedef double swift_Double_Vector2 __attribute__((__ext_vector_type__(2)));
// CHECK-LABEL: typedef int swift_Int32_Vector3 __attribute__((__ext_vector_type__(3)));
// -- The C simd module is useless to Swift.
// CHECK-NOT: @import simd;
// CHECK-LABEL: @interface Foo : NSObject
@objc class Foo: NSObject {
// CHECK-LABEL: - (swift_Float_Vector4)doStuffWithFloat4:(swift_Float_Vector4)x;
@objc func doStuffWithFloat4(x: Float.Vector4) -> Float.Vector4 { return x }
// CHECK-LABEL: - (swift_Double_Vector2)doStuffWithDouble2:(swift_Double_Vector2)x;
@objc func doStuffWithDouble2(x: Double.Vector2) -> Double.Vector2 { return x }
// CHECK-LABEL: - (swift_Int32_Vector3)doStuffWithInt3:(swift_Int32_Vector3)x;
@objc func doStuffWithInt3(x: Int32.Vector3) -> Int32.Vector3 { return x }
}