-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Clang][AArch64] Add fix vector types to header into SVE #73258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
e0f245e
cb36c09
367c579
e41718e
46ad11d
dca5def
8953195
8de2bc8
2f2ee53
4899f9c
a61cbbd
f36af88
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 3 | ||
|
||
// RUN: %clang_cc1 -DSVE_HEADER -triple aarch64 -target-feature +sve -emit-llvm -O2 -o - %s | opt -S -passes=mem2reg,sroa | FileCheck %s | ||
// RUN: %clang_cc1 -DSVE_HEADER -triple aarch64-none-linux-gnu -target-feature +sve2p1 -S -disable-O0-optnone -Werror -Wall -o - /dev/null %s | ||
|
||
// RUN: %clang_cc1 -DNEON_HEADER -triple aarch64 -target-feature +sve -emit-llvm -O2 -o - %s | opt -S -passes=mem2reg,sroa | FileCheck %s | ||
// RUN: %clang_cc1 -DNEON_HEADER -triple aarch64-none-linux-gnu -target-feature +sve2p1 -S -disable-O0-optnone -Werror -Wall -o - /dev/null %s | ||
|
||
// RUN: %clang_cc1 -DSVE_HEADER -DNEON_HEADER -triple aarch64 -target-feature +sve -emit-llvm -O2 -o - %s | opt -S -passes=mem2reg,sroa | FileCheck %s | ||
// RUN: %clang_cc1 -DSVE_HEADER -DNEON_HEADER -triple aarch64-none-linux-gnu -target-feature +sve2p1 -S -disable-O0-optnone -Werror -Wall -o - /dev/null %s | ||
|
||
// RUN: %clang_cc1 -DNEON_HEADER -DSVE_HEADER2 -triple aarch64 -target-feature +sve -emit-llvm -O2 -o - %s | opt -S -passes=mem2reg,sroa | FileCheck %s | ||
// RUN: %clang_cc1 -DNEON_HEADER -DSVE_HEADER2 -triple aarch64-none-linux-gnu -target-feature +sve2p1 -S -disable-O0-optnone -Werror -Wall -o - /dev/null %s | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've just added a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you. |
||
#ifdef SVE_HEADER | ||
#include <arm_sve.h> | ||
#endif | ||
|
||
#ifdef NEON_HEADER | ||
#include <arm_neon.h> | ||
#endif | ||
|
||
#ifdef SVE_HEADER_2 | ||
#include <arm_sve.h> | ||
#endif | ||
|
||
// function return types | ||
// CHECK-LABEL: define dso_local <8 x half> @test_ret_v8f16( | ||
// CHECK-SAME: <8 x half> noundef returned [[V:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: ret <8 x half> [[V]] | ||
// | ||
float16x8_t test_ret_v8f16(float16x8_t v) { | ||
return v; | ||
} | ||
|
||
// CHECK-LABEL: define dso_local <4 x float> @test_ret_v4f32( | ||
// CHECK-SAME: <4 x float> noundef returned [[V:%.*]]) local_unnamed_addr #[[ATTR0]] { | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: ret <4 x float> [[V]] | ||
// | ||
float32x4_t test_ret_v4f32(float32x4_t v) { | ||
return v; | ||
} | ||
|
||
// CHECK-LABEL: define dso_local <2 x double> @test_ret_v2f64( | ||
// CHECK-SAME: <2 x double> noundef returned [[V:%.*]]) local_unnamed_addr #[[ATTR0]] { | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: ret <2 x double> [[V]] | ||
// | ||
float64x2_t test_ret_v2f64(float64x2_t v) { | ||
return v; | ||
} | ||
|
||
// CHECK-LABEL: define dso_local <8 x bfloat> @test_ret_v8bf16( | ||
// CHECK-SAME: <8 x bfloat> noundef returned [[V:%.*]]) local_unnamed_addr #[[ATTR0]] { | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: ret <8 x bfloat> [[V]] | ||
// | ||
bfloat16x8_t test_ret_v8bf16(bfloat16x8_t v) { | ||
return v; | ||
} | ||
|
||
// CHECK-LABEL: define dso_local <16 x i8> @test_ret_v16s8( | ||
// CHECK-SAME: <16 x i8> noundef returned [[V:%.*]]) local_unnamed_addr #[[ATTR0]] { | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: ret <16 x i8> [[V]] | ||
// | ||
int8x16_t test_ret_v16s8(int8x16_t v) { | ||
return v; | ||
} | ||
|
||
// CHECK-LABEL: define dso_local <8 x i16> @test_ret_v8s16( | ||
// CHECK-SAME: <8 x i16> noundef returned [[V:%.*]]) local_unnamed_addr #[[ATTR0]] { | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: ret <8 x i16> [[V]] | ||
// | ||
int16x8_t test_ret_v8s16(int16x8_t v) { | ||
return v; | ||
} | ||
|
||
// CHECK-LABEL: define dso_local <4 x i32> @test_ret_v32s4( | ||
// CHECK-SAME: <4 x i32> noundef returned [[V:%.*]]) local_unnamed_addr #[[ATTR0]] { | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: ret <4 x i32> [[V]] | ||
// | ||
int32x4_t test_ret_v32s4(int32x4_t v) { | ||
return v; | ||
} | ||
|
||
// CHECK-LABEL: define dso_local <2 x i64> @test_ret_v64s2( | ||
// CHECK-SAME: <2 x i64> noundef returned [[V:%.*]]) local_unnamed_addr #[[ATTR0]] { | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: ret <2 x i64> [[V]] | ||
// | ||
int64x2_t test_ret_v64s2(int64x2_t v) { | ||
return v; | ||
} | ||
|
||
// CHECK-LABEL: define dso_local <16 x i8> @test_ret_v16u8( | ||
// CHECK-SAME: <16 x i8> noundef returned [[V:%.*]]) local_unnamed_addr #[[ATTR0]] { | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: ret <16 x i8> [[V]] | ||
// | ||
uint8x16_t test_ret_v16u8(uint8x16_t v) { | ||
return v; | ||
} | ||
|
||
// CHECK-LABEL: define dso_local <8 x i16> @test_ret_v8u16( | ||
// CHECK-SAME: <8 x i16> noundef returned [[V:%.*]]) local_unnamed_addr #[[ATTR0]] { | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: ret <8 x i16> [[V]] | ||
// | ||
uint16x8_t test_ret_v8u16(uint16x8_t v) { | ||
return v; | ||
} | ||
|
||
// CHECK-LABEL: define dso_local <4 x i32> @test_ret_v32u4( | ||
// CHECK-SAME: <4 x i32> noundef returned [[V:%.*]]) local_unnamed_addr #[[ATTR0]] { | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: ret <4 x i32> [[V]] | ||
// | ||
uint32x4_t test_ret_v32u4(uint32x4_t v) { | ||
return v; | ||
} | ||
|
||
// CHECK-LABEL: define dso_local <2 x i64> @test_ret_v64u2( | ||
// CHECK-SAME: <2 x i64> noundef returned [[V:%.*]]) local_unnamed_addr #[[ATTR0]] { | ||
// CHECK-NEXT: entry: | ||
// CHECK-NEXT: ret <2 x i64> [[V]] | ||
// | ||
uint64x2_t test_ret_v64u2(uint64x2_t v) { | ||
return v; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
// RUN: %clang_cc1 %s -triple armv7 -fsyntax-only -verify | ||
|
||
typedef __attribute__((neon_vector_type(2))) int int32x2_t; // expected-error{{'neon_vector_type' attribute is not supported on targets missing 'neon' or 'mve'; specify an appropriate -march= or -mcpu=}} | ||
CarolineConcatto marked this conversation as resolved.
Show resolved
Hide resolved
|
||
typedef __attribute__((neon_polyvector_type(16))) short poly8x16_t; // expected-error{{'neon_polyvector_type' attribute is not supported on targets missing 'neon' or 'mve'; specify an appropriate -march= or -mcpu=}} | ||
typedef __attribute__((arm_sve_vector_bits(256))) void nosveflag; // expected-error{{'arm_sve_vector_bits' attribute is not supported on targets missing 'sve'; specify an appropriate -march= or -mcpu=}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -593,6 +593,8 @@ class NeonEmitter { | |
// Emit arm_bf16.h.inc | ||
void runBF16(raw_ostream &o); | ||
|
||
void runVectorType(raw_ostream &o); | ||
|
||
// Emit all the __builtin prototypes used in arm_neon.h, arm_fp16.h and | ||
// arm_bf16.h | ||
void runHeader(raw_ostream &o); | ||
|
@@ -2355,13 +2357,7 @@ void NeonEmitter::run(raw_ostream &OS) { | |
|
||
OS << "#include <arm_bf16.h>\n"; | ||
|
||
// Emit NEON-specific scalar typedefs. | ||
OS << "typedef float float32_t;\n"; | ||
OS << "typedef __fp16 float16_t;\n"; | ||
|
||
OS << "#ifdef __aarch64__\n"; | ||
OS << "typedef double float64_t;\n"; | ||
OS << "#endif\n\n"; | ||
OS << "#include <arm_vector_types.h>\n"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: is it worth calling this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess there's a question as to why the poly types have been omitted. We don't need to be that precious about the header containing only the bare minimum types that are needed across NEON and SVE. I've seen circumstances where users have wanted the types but nothing else. I know this is not the goal of this patch but it's a step in that direction. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Omitting the poly types was a suggestion I made to allow including Strictly speaking you could use the types for interfaces despite of which feature flags are set, but this seems to have been the chosen approach historically. Given that there is no requirement for these types to be available outside of arm_neon.h, I thought it made sense to only share the common types and preserve existing behaviour for the poly types. |
||
|
||
// For now, signedness of polynomial types depends on target | ||
OS << "#ifdef __aarch64__\n"; | ||
|
@@ -2374,10 +2370,7 @@ void NeonEmitter::run(raw_ostream &OS) { | |
OS << "typedef int16_t poly16_t;\n"; | ||
OS << "typedef int64_t poly64_t;\n"; | ||
OS << "#endif\n"; | ||
|
||
emitNeonTypeDefs("cQcsQsiQilQlUcQUcUsQUsUiQUiUlQUlhQhfQfdQdPcQPcPsQPsPlQPl", OS); | ||
|
||
emitNeonTypeDefs("bQb", OS); | ||
emitNeonTypeDefs("PcQPcPsQPsPlQPl", OS); | ||
|
||
OS << "#define __ai static __inline__ __attribute__((__always_inline__, " | ||
"__nodebug__))\n\n"; | ||
|
@@ -2546,6 +2539,38 @@ void NeonEmitter::runFP16(raw_ostream &OS) { | |
OS << "#endif /* __ARM_FP16_H */\n"; | ||
} | ||
|
||
void NeonEmitter::runVectorType(raw_ostream &OS) { | ||
OS << "/*===---- arm_vector_types - ARM vector type " | ||
"------===\n" | ||
" *\n" | ||
" *\n" | ||
" * Part of the LLVM Project, under the Apache License v2.0 with LLVM " | ||
"Exceptions.\n" | ||
" * See https://llvm.org/LICENSE.txt for license information.\n" | ||
" * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception\n" | ||
" *\n" | ||
" *===-----------------------------------------------------------------" | ||
"------===\n" | ||
" */\n\n"; | ||
OS << "#if !defined(__ARM_NEON_H) && !defined(__ARM_SVE_H)\n"; | ||
OS << "#error \"This file should not be used standalone. Please include" | ||
" arm_neon.h or arm_sve.h instead\"\n\n"; | ||
OS << "#endif\n"; | ||
OS << "#ifndef __ARM_NEON_TYPES_H\n"; | ||
OS << "#define __ARM_NEON_TYPES_H\n"; | ||
OS << "typedef float float32_t;\n"; | ||
OS << "typedef __fp16 float16_t;\n"; | ||
|
||
OS << "#ifdef __aarch64__\n"; | ||
OS << "typedef double float64_t;\n"; | ||
OS << "#endif\n\n"; | ||
|
||
emitNeonTypeDefs("cQcsQsiQilQlUcQUcUsQUsUiQUiUlQUlhQhfQfdQd", OS); | ||
|
||
emitNeonTypeDefs("bQb", OS); | ||
OS << "#endif // __ARM_NEON_TYPES_H\n"; | ||
} | ||
|
||
void NeonEmitter::runBF16(raw_ostream &OS) { | ||
OS << "/*===---- arm_bf16.h - ARM BF16 intrinsics " | ||
"-----------------------------------===\n" | ||
|
@@ -2640,6 +2665,10 @@ void clang::EmitNeonSema(RecordKeeper &Records, raw_ostream &OS) { | |
NeonEmitter(Records).runHeader(OS); | ||
} | ||
|
||
void clang::EmitVectorType(RecordKeeper &Records, raw_ostream &OS) { | ||
NeonEmitter(Records).runVectorType(OS); | ||
} | ||
|
||
void clang::EmitNeonTest(RecordKeeper &Records, raw_ostream &OS) { | ||
llvm_unreachable("Neon test generation no longer implemented!"); | ||
} |
Uh oh!
There was an error while loading. Please reload this page.