Files
clang-p2996/clang/test/CodeGen/LoongArch/bfloat-mangle.cpp
Ami-zhang 0ed5d9aff6 [LoongArch][BF16] Add support for the __bf16 type (#142548)
The LoongArch psABI recently added __bf16 type support. Now we can
enable this new type in clang.

Currently, bf16 operations are automatically supported by promoting to
float. This patch adds bf16 support by ensuring that load extension /
truncate store operations are properly expanded.

And this commit implements support for bf16 truncate/extend on hard FP
targets. The extend operation is implemented by a shift just as in the
standard legalization. This requires custom lowering of the truncate
libcall on hard float ABIs (the normal libcall code path is used on soft
ABIs).
2025-06-09 11:15:41 +08:00

13 lines
555 B
C++

// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
// RUN: %clang_cc1 -triple loongarch64 -emit-llvm -o - %s | FileCheck %s
// RUN: %clang_cc1 -triple loongarch32 -emit-llvm -o - %s | FileCheck %s
// CHECK-LABEL: define dso_local void @_Z3fooDF16b
// CHECK-SAME: (bfloat noundef [[B:%.*]]) #[[ATTR0:[0-9]+]] {
// CHECK-NEXT: entry:
// CHECK-NEXT: [[B_ADDR:%.*]] = alloca bfloat, align 2
// CHECK-NEXT: store bfloat [[B]], ptr [[B_ADDR]], align 2
// CHECK-NEXT: ret void
//
void foo(__bf16 b) {}