llvm-project/clang/test/Sema/arm-bfloat.cpp
Ties Stuij ecd682bbf5 [ARM] Add __bf16 as new Bfloat16 C Type
Summary:
This patch upstreams support for a new storage only bfloat16 C type.
This type is used to implement primitive support for bfloat16 data, in
line with the Bfloat16 extension of the Armv8.6-a architecture, as
detailed here:

https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/arm-architecture-developments-armv8-6-a

The bfloat type, and its properties are specified in the Arm Architecture
Reference Manual:

https://developer.arm.com/docs/ddi0487/latest/arm-architecture-reference-manual-armv8-for-armv8-a-architecture-profile

In detail this patch:
- introduces an opaque, storage-only C-type __bf16, which introduces a new bfloat IR type.

This is part of a patch series, starting with command-line and Bfloat16
assembly support. The subsequent patches will upstream intrinsics
support for BFloat16, followed by Matrix Multiplication and the
remaining Virtualization features of the armv8.6-a architecture.

The following people contributed to this patch:
- Luke Cheeseman
- Momchil Velikov
- Alexandros Lamprineas
- Luke Geeson
- Simon Tatham
- Ties Stuij

Reviewers: SjoerdMeijer, rjmccall, rsmith, liutianle, RKSimon, craig.topper, jfb, LukeGeeson, fpetrogalli

Reviewed By: SjoerdMeijer

Subscribers: labrinea, majnemer, asmith, dexonsmith, kristof.beyls, arphaman, danielkiss, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D76077
2020-06-05 10:32:43 +01:00

30 lines
1.8 KiB
C++

// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 \
// RUN: -triple aarch64-arm-none-eabi -target-cpu cortex-a75 \
// RUN: -target-feature +bf16 -target-feature +neon %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 \
// RUN: -triple arm-arm-none-eabi -target-cpu cortex-a53 \
// RUN: -target-feature +bf16 -target-feature +neon %s
void test(bool b) {
__bf16 bf16;
bf16 + bf16; // expected-error {{invalid operands to binary expression ('__bf16' and '__bf16')}}
bf16 - bf16; // expected-error {{invalid operands to binary expression ('__bf16' and '__bf16')}}
bf16 * bf16; // expected-error {{invalid operands to binary expression ('__bf16' and '__bf16')}}
bf16 / bf16; // expected-error {{invalid operands to binary expression ('__bf16' and '__bf16')}}
__fp16 fp16;
bf16 + fp16; // expected-error {{invalid operands to binary expression ('__bf16' and '__fp16')}}
fp16 + bf16; // expected-error {{invalid operands to binary expression ('__fp16' and '__bf16')}}
bf16 - fp16; // expected-error {{invalid operands to binary expression ('__bf16' and '__fp16')}}
fp16 - bf16; // expected-error {{invalid operands to binary expression ('__fp16' and '__bf16')}}
bf16 * fp16; // expected-error {{invalid operands to binary expression ('__bf16' and '__fp16')}}
fp16 * bf16; // expected-error {{invalid operands to binary expression ('__fp16' and '__bf16')}}
bf16 / fp16; // expected-error {{invalid operands to binary expression ('__bf16' and '__fp16')}}
fp16 / bf16; // expected-error {{invalid operands to binary expression ('__fp16' and '__bf16')}}
bf16 = fp16; // expected-error {{assigning to '__bf16' from incompatible type '__fp16'}}
fp16 = bf16; // expected-error {{assigning to '__fp16' from incompatible type '__bf16'}}
bf16 + (b ? fp16 : bf16); // expected-error {{incompatible operand types ('__fp16' and '__bf16')}}
}