Skip to content

Commit

Permalink
[AIE2P] Add missing broadcast intrinsics.
Browse files Browse the repository at this point in the history
  • Loading branch information
SagarMaheshwari99 committed Jan 18, 2025
1 parent a8d7dde commit 03185de
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 28 deletions.
12 changes: 1 addition & 11 deletions clang/lib/Headers/aie2p_aie_api_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// (c) Copyright 2024 Advanced Micro Devices, Inc. or its affiliates
// (c) Copyright 2024-2025 Advanced Micro Devices, Inc. or its affiliates
//
//===----------------------------------------------------------------------===//

Expand Down Expand Up @@ -731,12 +731,6 @@ inline __attribute__((always_inline)) v16uint32 broadcast_to_v16uint32(v2uint32
inline __attribute__((always_inline)) v16cint16 broadcast_to_v16cint16(cint16 );
inline __attribute__((always_inline)) v16cint16 broadcast_to_v16cint16(v2cint16 );
inline __attribute__((always_inline)) v8cint32 broadcast_to_v8cint32(cint32 );
inline __attribute__((always_inline)) v64int8 broadcast_one_to_v64int8();
inline __attribute__((always_inline)) v32int16 broadcast_one_to_v32int16();
inline __attribute__((always_inline)) v16int32 broadcast_one_to_v16int32();
inline __attribute__((always_inline)) v64uint8 broadcast_one_to_v64uint8();
inline __attribute__((always_inline)) v32uint16 broadcast_one_to_v32uint16();
inline __attribute__((always_inline)) v16uint32 broadcast_one_to_v16uint32();
inline __attribute__((always_inline)) v16cint16 broadcast_one_to_v16cint16();
inline __attribute__((always_inline)) v8cint32 broadcast_one_to_v8cint32();
inline __attribute__((always_inline)) v16cint16 broadcast_one_c16();
Expand Down Expand Up @@ -2783,10 +2777,6 @@ inline __attribute__((always_inline)) v32acc64 mac_4x8_8x8_conf(v32int16 , int ,
inline __attribute__((always_inline)) v32acc64 msc_4x8_8x8_conf(v32int16 , int , v64int16_sparse , int , v32acc64 , int , int , int , int );
inline __attribute__((always_inline)) v32acc64 addmac_4x8_8x8_conf(v32int16 , int , v64int16_sparse , int , v32acc64 , v32acc64 , int , int , int , int , int );
inline __attribute__((always_inline)) v32acc64 addmsc_4x8_8x8_conf(v32int16 , int , v64int16_sparse , int , v32acc64 , v32acc64 , int , int , int , int , int );
inline __attribute__((always_inline)) v64acc32 clr64();
inline __attribute__((always_inline)) v64acc32 broadcast_zero_to_v64acc32();
inline __attribute__((always_inline)) v32acc64 clr32();
inline __attribute__((always_inline)) v32acc64 broadcast_zero_to_v32acc64();
inline __attribute__((always_inline)) v16cacc64 add(v16cacc64 , v16cacc64 );
inline __attribute__((always_inline)) v16cacc64 sub(v16cacc64 , v16cacc64 );
inline __attribute__((always_inline)) v16cacc64 neg(v16cacc64 );
Expand Down
42 changes: 32 additions & 10 deletions clang/lib/Headers/aie2p_scl2vec.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// (c) Copyright 2024 Advanced Micro Devices, Inc. or its affiliates
// (c) Copyright 2024-2025 Advanced Micro Devices, Inc. or its affiliates
//
//===----------------------------------------------------------------------===//

Expand Down Expand Up @@ -1621,16 +1621,26 @@ INTRINSIC(v16accfloat) shiftr_elem(v16accfloat v, float s) {
}
// broadcast value one(1) to all vector lanes
INTRINSIC(v64int8) broadcast_one_s8() { return broadcast_s8(1); }
INTRINSIC(v64int8) broadcast_one_to_v64int8() { return broadcast_one_s8(); }

INTRINSIC(v32int16) broadcast_one_s16() { return broadcast_s16(1); }
INTRINSIC(v32int16) broadcast_one_to_v32int16() { return broadcast_one_s16(); }

INTRINSIC(v16int32) broadcast_one_s32() { return broadcast_s32(1); }
INTRINSIC(v16int32) broadcast_one_to_v16int32() { return broadcast_one_s32(); }

INTRINSIC(v64uint8) broadcast_one_u8() { return broadcast_u8(1); }
INTRINSIC(v64uint8) broadcast_one_to_v64uint8() { return broadcast_one_u8(); }

INTRINSIC(v32uint16) broadcast_one_u16() { return broadcast_u16(1); }
INTRINSIC(v32uint16) broadcast_one_to_v32uint16() {
return broadcast_one_u16();
}

INTRINSIC(v16uint32) broadcast_one_u32() { return broadcast_u32(1); }
INTRINSIC(v16uint32) broadcast_one_to_v16uint32() {
return broadcast_one_u32();
}

INTRINSIC(v32bfloat16) broadcast_one_bfloat16() {
return broadcast_bfloat16(1);
Expand Down Expand Up @@ -1708,15 +1718,6 @@ INTRINSIC(v16uint32) broadcast_zero_to_v16uint32() { return broadcast_u32(0); }
}
INTRINSIC(v16float) broadcast_zero_to_v16float() { return broadcast_float(0); }

INTRINSIC(v16acc64) broadcast_zero_to_v16acc64() {
return __builtin_bit_cast(v16acc64, 0 - v32int32{0});
}

[[deprecated("Function 'clr' is deprecated. Please use the 'broadcast_zero_to' "
"variant instead.")]] INTRINSIC(v16acc64) clr16() {
return broadcast_zero_to_v16acc64();
}

#if 0
[[deprecated("Function 'broadcast_zero_c16' is deprecated. Please use the 'broadcast_zero_to_v16cint16' variant instead.")]] INTRINSIC(v16cint16) broadcast_zero_c16() { return broadcast_c16(0); }
INTRINSIC(v16cint16) broadcast_zero_to_v16cint16() { return broadcast_c16(0); }
Expand Down Expand Up @@ -1794,6 +1795,27 @@ broadcast_elem(v16float v, int idx) {
INTRINSIC(v64int8)
broadcast_to_v64int8(int b) { return broadcast_s8((int)b); }

INTRINSIC(v16acc64) broadcast_zero_to_v16acc64() { return v16acc64{}; }

[[deprecated("Function 'clr' is deprecated. Please use the 'broadcast_zero_to' "
"variant instead.")]] INTRINSIC(v16acc64) clr16() {
return broadcast_zero_to_v16acc64();
}

INTRINSIC(v32acc64) broadcast_zero_to_v32acc64() { return v32acc64{}; }

[[deprecated("Function 'clr' is deprecated. Please use the 'broadcast_zero_to' "
"variant instead.")]] INTRINSIC(v32acc64) clr32() {
return broadcast_zero_to_v32acc64();
}

INTRINSIC(v64acc32) broadcast_zero_to_v64acc32() { return v64acc32{}; }

[[deprecated("Function 'clr' is deprecated. Please use the 'broadcast_zero_to' "
"variant instead.")]] INTRINSIC(v64acc32) clr64() {
return broadcast_zero_to_v64acc32();
}

INTRINSIC(v16accfloat) broadcast_zero_to_v16accfloat() {
return __builtin_bit_cast(v16accfloat, (float)0 - v16float{0});
}
Expand Down
31 changes: 24 additions & 7 deletions clang/test/CodeGen/aie/aie2p/aie2p-scl2vec-intrinsic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// (c) Copyright 2024 Advanced Micro Devices, Inc. or its affiliates
// (c) Copyright 2024-2025 Advanced Micro Devices, Inc. or its affiliates
//
//===----------------------------------------------------------------------===//

Expand Down Expand Up @@ -702,30 +702,47 @@ v64int8
test_broadcast_to_v64int8(int b) {
return broadcast_to_v64int8(b);
}
v16accfloat
// AIE2P-LABEL: define dso_local inreg noundef <16 x i64> @_Z31test_broadcast_zero_to_v16acc64v(
// AIE2P-SAME: ) local_unnamed_addr #[[ATTR0]] {
// AIE2P-NEXT: entry:
// AIE2P-NEXT: ret <16 x i64> zeroinitializer
//
v16acc64 test_broadcast_zero_to_v16acc64() {
return broadcast_zero_to_v16acc64();
}
// AIE2P-LABEL: define dso_local inreg noundef <32 x i64> @_Z31test_broadcast_zero_to_v32acc64v(
// AIE2P-SAME: ) local_unnamed_addr #[[ATTR0]] {
// AIE2P-NEXT: entry:
// AIE2P-NEXT: ret <32 x i64> zeroinitializer
//
v32acc64 test_broadcast_zero_to_v32acc64() { return broadcast_zero_to_v32acc64(); }
// AIE2P-LABEL: define dso_local inreg noundef <64 x i32> @_Z31test_broadcast_zero_to_v64acc32v(
// AIE2P-SAME: ) local_unnamed_addr #[[ATTR0]] {
// AIE2P-NEXT: entry:
// AIE2P-NEXT: ret <64 x i32> zeroinitializer
//
v64acc32 test_broadcast_zero_to_v64acc32() { return broadcast_zero_to_v64acc32(); }
// AIE2P-LABEL: define dso_local inreg noundef <16 x float> @_Z34test_broadcast_zero_to_v16accfloatv(
// AIE2P-SAME: ) local_unnamed_addr #[[ATTR0]] {
// AIE2P-NEXT: entry:
// AIE2P-NEXT: ret <16 x float> zeroinitializer
//
test_broadcast_zero_to_v16accfloat() {
v16accfloat test_broadcast_zero_to_v16accfloat() {
return broadcast_zero_to_v16accfloat();
}
v32accfloat
// AIE2P-LABEL: define dso_local inreg noundef <32 x float> @_Z34test_broadcast_zero_to_v32accfloatv(
// AIE2P-SAME: ) local_unnamed_addr #[[ATTR0]] {
// AIE2P-NEXT: entry:
// AIE2P-NEXT: ret <32 x float> zeroinitializer
//
test_broadcast_zero_to_v32accfloat() {
v32accfloat test_broadcast_zero_to_v32accfloat() {
return broadcast_zero_to_v32accfloat();
}
v64accfloat
// AIE2P-LABEL: define dso_local inreg noundef <64 x float> @_Z34test_broadcast_zero_to_v64accfloatv(
// AIE2P-SAME: ) local_unnamed_addr #[[ATTR0]] {
// AIE2P-NEXT: entry:
// AIE2P-NEXT: ret <64 x float> zeroinitializer
//
test_broadcast_zero_to_v64accfloat() {
v64accfloat test_broadcast_zero_to_v64accfloat() {
return broadcast_zero_to_v64accfloat();
}

0 comments on commit 03185de

Please sign in to comment.