From a845d8fc57b6b09198bcb104f060925298034636 Mon Sep 17 00:00:00 2001 From: Phoebe Wang Date: Mon, 29 Aug 2022 15:39:04 +0800 Subject: [PATCH] [X86][BF16] Add type mangling for Windows Reviewed By: FreddyYe Differential Revision: https://reviews.llvm.org/D132742 --- clang/lib/AST/MicrosoftMangle.cpp | 5 ++++- clang/test/CodeGen/X86/bfloat-mangle.cpp | 9 ++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp index 09075e60142a..e58fedb6fa54 100644 --- a/clang/lib/AST/MicrosoftMangle.cpp +++ b/clang/lib/AST/MicrosoftMangle.cpp @@ -2469,6 +2469,10 @@ void MicrosoftCXXNameMangler::mangleType(const BuiltinType *T, Qualifiers, Out << "$halff@"; break; + case BuiltinType::BFloat16: + mangleArtificialTagType(TTK_Struct, "__bf16", {"__clang"}); + break; + #define SVE_TYPE(Name, Id, SingletonId) \ case BuiltinType::Id: #include "clang/Basic/AArch64SVEACLETypes.def" @@ -2501,7 +2505,6 @@ void MicrosoftCXXNameMangler::mangleType(const BuiltinType *T, Qualifiers, case BuiltinType::SatUShortFract: case BuiltinType::SatUFract: case BuiltinType::SatULongFract: - case BuiltinType::BFloat16: case BuiltinType::Ibm128: case BuiltinType::Float128: { DiagnosticsEngine &Diags = Context.getDiags(); diff --git a/clang/test/CodeGen/X86/bfloat-mangle.cpp b/clang/test/CodeGen/X86/bfloat-mangle.cpp index 2892a76d8d91..acc6c280f2e8 100644 --- a/clang/test/CodeGen/X86/bfloat-mangle.cpp +++ b/clang/test/CodeGen/X86/bfloat-mangle.cpp @@ -1,5 +1,8 @@ -// RUN: %clang_cc1 -triple i386-unknown-unknown -target-feature +sse2 -emit-llvm -o - %s | FileCheck %s -// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-feature +sse2 -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple i386-unknown-unknown -target-feature +sse2 -emit-llvm -o - %s | FileCheck %s --check-prefixes=LINUX +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-feature +sse2 -emit-llvm -o - %s | FileCheck %s --check-prefixes=LINUX +// RUN: %clang_cc1 -triple i386-windows-msvc -target-feature +sse2 -emit-llvm -o - %s | FileCheck %s --check-prefixes=WINDOWS +// RUN: %clang_cc1 -triple x86_64-windows-msvc -target-feature +sse2 -emit-llvm -o - %s | FileCheck %s --check-prefixes=WINDOWS -// CHECK: define {{.*}}void @_Z3foou6__bf16(bfloat noundef %b) +// LINUX: define {{.*}}void @_Z3foou6__bf16(bfloat noundef %b) +// WINDOWS: define {{.*}}void @"?foo@@YAXU__bf16@__clang@@@Z"(bfloat noundef %b) void foo(__bf16 b) {}