[clang] [llvm] [AArch64] Add FP8 Neon intrinsics for dot-product (PR #119911)
https://github.com/momchil-velikov closed https://github.com/llvm/llvm-project/pull/119911 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add FP8 Neon intrinsics for dot-product (PR #119911)
@@ -0,0 +1,143 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 + +// RUN: %clang_cc1-triple aarch64-none-linux-gnu -target-feature +neon -target-feature +bf16 -target-feature +fp8 -target-feature +fp8dot2 -target-feature +fp8dot4 -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s momchil-velikov wrote: Removed. https://github.com/llvm/llvm-project/pull/119911 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add FP8 Neon intrinsics for dot-product (PR #119911)
@@ -0,0 +1,54 @@ +// RUN: %clang_cc1 -triple aarch64-linux-gnu -target-feature +neon -target-feature +bf16 -target-feature +faminmax -target-feature +fp8 -emit-llvm -verify %s -o /dev/null momchil-velikov wrote: They are needed. https://github.com/llvm/llvm-project/pull/119911 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add FP8 Neon intrinsics for dot-product (PR #119911)
https://github.com/momchil-velikov edited https://github.com/llvm/llvm-project/pull/119911 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add FP8 Neon intrinsics for dot-product (PR #119911)
@@ -0,0 +1,143 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 + +// RUN: %clang_cc1-triple aarch64-none-linux-gnu -target-feature +neon -target-feature +bf16 -target-feature +fp8 -target-feature +fp8dot2 -target-feature +fp8dot4 -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s CarolineConcatto wrote: Same comment as the cvt, do we need instcombine here? https://github.com/llvm/llvm-project/pull/119911 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add FP8 Neon intrinsics for dot-product (PR #119911)
https://github.com/CarolineConcatto edited https://github.com/llvm/llvm-project/pull/119911 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add FP8 Neon intrinsics for dot-product (PR #119911)
@@ -0,0 +1,54 @@ +// RUN: %clang_cc1 -triple aarch64-linux-gnu -target-feature +neon -target-feature +bf16 -target-feature +faminmax -target-feature +fp8 -emit-llvm -verify %s -o /dev/null CarolineConcatto wrote: nit: remove -target-feature +bf16 -target-feature +faminmax https://github.com/llvm/llvm-project/pull/119911 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add FP8 Neon intrinsics for dot-product (PR #119911)
https://github.com/CarolineConcatto approved this pull request. The commit messsage is missing the f32_mf8 intrinsics https://github.com/llvm/llvm-project/pull/119911 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add FP8 Neon intrinsics for dot-product (PR #119911)
github-actions[bot] wrote: :warning: Python code formatter, darker found issues in your code. :warning: You can test this locally with the following command: ``bash darker --check --diff -r 7cb6e6bced8ca5767c3e609f4826982638fd9543...e1a3e8fa0896fb87aced430c5f9ba9c9df07aadc llvm/utils/UpdateTestChecks/common.py llvm/utils/update_cc_test_checks.py `` View the diff from darker here. ``diff --- UpdateTestChecks/common.py 2025-01-06 15:08:27.00 + +++ UpdateTestChecks/common.py 2025-01-06 16:55:56.824824 + @@ -556,12 +556,11 @@ UTC_ADVERT = "NOTE: Assertions have been autogenerated by " UTC_AVOID = "NOTE: Do not autogenerate" UNUSED_NOTE = "NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:" DATA_LAYOUT_RE = re.compile( -r"target\sdatalayout\s=\s\"(?P.+)\"$", -flags=(re.M | re.S) +r"target\sdatalayout\s=\s\"(?P.+)\"$", flags=(re.M | re.S) ) OPT_FUNCTION_RE = re.compile( r"^(\s*;\s*Function\sAttrs:\s(?P[\w\s():,]+?))?\s*define\s+(?P[^@]*)@(?P[\w.$-]+?)\s*" r"(?P\((\)|(.*?[\w.-]+?)\))[^{]*\{)\n(?P.*?)^\}$", @@ -653,20 +652,22 @@ if march.startswith(prefix): return triple print("Cannot find a triple. Assume 'x86'", file=sys.stderr) return "x86" + def get_global_underscores(raw_tool_output): m = DATA_LAYOUT_RE.search(raw_tool_output) if not m: return False data_layout = m.group("layout") idx = data_layout.find("m:") if idx < 0: return False ch = data_layout[idx + 2] -return ch == 'o' or ch == 'x' +return ch == "o" or ch == "x" + def apply_filters(line, filters): has_filter = False for f in filters: if not f.is_filter_out: --- update_cc_test_checks.py2025-01-06 15:08:27.00 + +++ update_cc_test_checks.py2025-01-06 16:55:57.046330 + @@ -123,11 +123,11 @@ search = spell mangled = node.get("mangledName", spell) # Strip leading underscore from globals, so the name matches the LLVM one if global_underscores: storage = node.get("storageClass", None) -if storage != "static" and mangled[0] == '_': +if storage != "static" and mangled[0] == "_": mangled = mangled[1:] ret[int(line) - 1].append((spell, mangled, search)) ast = json.loads(stdout) if ast["kind"] != "TranslationUnitDecl": @@ -252,11 +252,13 @@ args.opt = None return args, parser -def get_function_body(builder, args, filename, clang_args, extra_commands, prefixes, raw_tool_output): +def get_function_body( +builder, args, filename, clang_args, extra_commands, prefixes, raw_tool_output +): # TODO Clean up duplication of asm/common build_function_body_dictionary for extra_command in extra_commands: extra_args = shlex.split(extra_command) with tempfile.NamedTemporaryFile() as f: f.write(raw_tool_output.encode()) @@ -387,16 +389,24 @@ common.debug("Extracted FileCheck prefixes: {}".format(prefixes)) # Invoke external tool and extract function bodies. raw_tool_output = common.invoke_tool(ti.args.clang, clang_args, ti.path) get_function_body( -builder, ti.args, ti.path, clang_args, extra_commands, prefixes, raw_tool_output +builder, +ti.args, +ti.path, +clang_args, +extra_commands, +prefixes, +raw_tool_output, ) # Invoke clang -Xclang -ast-dump=json to get mapping from start lines to # mangled names. Forward all clang args for now. -for k, v in get_line2func_list(ti.args, clang_args, common.get_global_underscores(raw_tool_output)).items(): +for k, v in get_line2func_list( +ti.args, clang_args, common.get_global_underscores(raw_tool_output) +).items(): line2func_list[k].extend(v) func_dict = builder.finish_and_get_func_dict() global_vars_seen_dict = {} prefix_set = set([prefix for p in filecheck_run_list for prefix in p[0]]) `` https://github.com/llvm/llvm-project/pull/119911 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add FP8 Neon intrinsics for dot-product (PR #119911)
https://github.com/jthackray approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/119911 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add FP8 Neon intrinsics for dot-product (PR #119911)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 2dc22615fd46ab2566d0f26d5ba234ab12dc4bf8 3e4db7f3cc211951fea14c3f827219bd4f260e35 --extensions h,cpp,c -- clang/test/CodeGen/AArch64/builtin-shufflevector-fp8.c clang/test/CodeGen/AArch64/fp8-intrinsics/acle_neon_fp8_cvt.c clang/test/CodeGen/AArch64/fp8-intrinsics/acle_neon_fp8_fdot.c clang/test/Sema/aarch64-fp8-intrinsics/acle_neon_fp8.c clang/test/Sema/builtin-shufflevector.c clang/include/clang/AST/Type.h clang/lib/AST/ASTContext.cpp clang/lib/AST/ItaniumMangle.cpp clang/lib/AST/Type.cpp clang/lib/CodeGen/CGBuiltin.cpp clang/lib/CodeGen/CodeGenFunction.h clang/lib/CodeGen/CodeGenTypes.cpp clang/lib/CodeGen/Targets/AArch64.cpp clang/lib/Sema/SemaChecking.cpp clang/utils/TableGen/NeonEmitter.cpp clang/utils/TableGen/SveEmitter.cpp `` View the diff from clang-format here. ``diff diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 02bd09bda0..de57e7d6ef 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -5176,12 +5176,12 @@ ExprResult Sema::BuiltinShuffleVector(CallExpr *TheCall) { resType = Context.MFloat8x16Ty; break; default: - return ExprError(Diag(TheCall->getBeginLoc(), - diag::err_shufflevector_unsupported_result_vector_type) - << TheCall->getDirectCallee() - << /*isMorethantwoArgs*/ false - << SourceRange(TheCall->getArg(0)->getBeginLoc(), - TheCall->getArg(1)->getEndLoc())); + return ExprError( + Diag(TheCall->getBeginLoc(), + diag::err_shufflevector_unsupported_result_vector_type) + << TheCall->getDirectCallee() << /*isMorethantwoArgs*/ false + << SourceRange(TheCall->getArg(0)->getBeginLoc(), + TheCall->getArg(1)->getEndLoc())); } } QualType eltType = LHSType->castAs()->getElementType(); `` https://github.com/llvm/llvm-project/pull/119911 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add FP8 Neon intrinsics for dot-product (PR #119911)
llvmbot wrote: @llvm/pr-subscribers-llvm-ir Author: Momchil Velikov (momchil-velikov) Changes This patch adds the following intrinsics: float16x4_t vdot_f16_mf8_fpm(float16x4_t vd, mfloat8x8_t vn, mfloat8x8_t vm, fpm_t fpm) float16x8_t vdotq_f16_mf8_fpm(float16x8_t vd, mfloat8x16_t vn, mfloat8x16_t vm, fpm_t fpm) float16x4_t vdot_lane_f16_mf8_fpm(float16x4_t vd, mfloat8x8_t vn, mfloat8x8_t vm, __builtin_constant_p(lane), fpm_t fpm) float16x4_t vdot_laneq_f16_mf8_fpm(float16x4_t vd, mfloat8x8_t vn, mfloat8x16_t vm, __builtin_constant_p(lane), fpm_t fpm) float16x8_t vdotq_lane_f16_mf8_fpm(float16x8_t vd, mfloat8x16_t vn, mfloat8x8_t vm, __builtin_constant_p(lane), fpm_t fpm) float16x8_t vdotq_laneq_f16_mf8_fpm(float16x8_t vd, mfloat8x16_t vn, mfloat8x16_t vm, __builtin_constant_p(lane), fpm_t fpm) --- Patch is 107.21 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/119911.diff 25 Files Affected: - (modified) clang/include/clang/AST/Type.h (+9) - (modified) clang/include/clang/Basic/AArch64SVEACLETypes.def (+18-6) - (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+5) - (modified) clang/include/clang/Basic/arm_neon.td (+46-1) - (modified) clang/include/clang/Basic/arm_neon_incl.td (+2) - (modified) clang/lib/AST/ASTContext.cpp (+30-7) - (modified) clang/lib/AST/ItaniumMangle.cpp (+5) - (modified) clang/lib/AST/Type.cpp (+14-3) - (modified) clang/lib/CodeGen/CGBuiltin.cpp (+166-1) - (modified) clang/lib/CodeGen/CodeGenFunction.h (+8) - (modified) clang/lib/CodeGen/CodeGenTypes.cpp (+10-3) - (modified) clang/lib/CodeGen/Targets/AArch64.cpp (+5-2) - (modified) clang/lib/Sema/SemaChecking.cpp (+33-6) - (added) clang/test/CodeGen/AArch64/builtin-shufflevector-fp8.c (+123) - (added) clang/test/CodeGen/AArch64/fp8-intrinsics/acle_neon_fp8_cvt.c (+308) - (added) clang/test/CodeGen/AArch64/fp8-intrinsics/acle_neon_fp8_fdot.c (+143) - (added) clang/test/Sema/aarch64-fp8-intrinsics/acle_neon_fp8.c (+57) - (added) clang/test/Sema/builtin-shufflevector.c (+30) - (modified) clang/utils/TableGen/NeonEmitter.cpp (+22-2) - (modified) clang/utils/TableGen/SveEmitter.cpp (+2-2) - (modified) llvm/include/llvm/IR/IntrinsicsAArch64.td (+43) - (modified) llvm/lib/Target/AArch64/AArch64InstrFormats.td (+83-45) - (modified) llvm/lib/Target/AArch64/AArch64InstrInfo.td (+14-14) - (added) llvm/test/CodeGen/AArch64/fp8-neon-fdot.ll (+74) - (added) llvm/test/CodeGen/AArch64/neon-fp8-cvt.ll (+112) ``diff diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index f0eee77c73ef06d..cacd3d75ffcd8de 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -2404,6 +2404,10 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase { /// SVE vector or predicate, excluding tuple types such as svint32x4_t. bool isSveVLSBuiltinType() const; + /// Determines if this is a *builtin* NEON vector type, a type not built with + /// `neon_vector_type` + bool isNeonVectorBuiltinType() const; + /// Returns the representative type for the element of an SVE builtin type. /// This is used to represent fixed-length SVE vectors created with the /// 'arm_sve_vector_bits' type attribute as VectorType. @@ -2518,6 +2522,7 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase { bool isFloat32Type() const; bool isDoubleType() const; bool isBFloat16Type() const; + bool isMFloat8Type() const; bool isFloat128Type() const; bool isIbm128Type() const; bool isRealType() const; // C99 6.2.5p17 (real floating + integer) @@ -8532,6 +8537,10 @@ inline bool Type::isBFloat16Type() const { return isSpecificBuiltinType(BuiltinType::BFloat16); } +inline bool Type::isMFloat8Type() const { + return isSpecificBuiltinType(BuiltinType::MFloat8); +} + inline bool Type::isFloat128Type() const { return isSpecificBuiltinType(BuiltinType::Float128); } diff --git a/clang/include/clang/Basic/AArch64SVEACLETypes.def b/clang/include/clang/Basic/AArch64SVEACLETypes.def index 063cac1f4a58ee7..6b704b386536c9b 100644 --- a/clang/include/clang/Basic/AArch64SVEACLETypes.def +++ b/clang/include/clang/Basic/AArch64SVEACLETypes.def @@ -57,6 +57,11 @@ // - IsBF true for vector of brain float elements. //===--===// +#ifndef SVE_SCALAR_TYPE +#define SVE_SCALAR_TYPE(Name, MangledName, Id, SingletonId, Bits) \ + SVE_TYPE(Name, Id, SingletonId) +#endif + #ifndef SVE_VECTOR_TYPE #define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \ SVE_TYPE(Name, Id, SingletonId) @@ -72,6 +77,11 @@ SVE_VECTOR_TYPE_DETAILS(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF, false, false, true) #endif +#ifndef SVE_VECTOR_TYPE_MFLOAT +#define SVE_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF) \ + SVE_VECTOR_TYPE_DETAILS(Name, MangledN
[clang] [llvm] [AArch64] Add FP8 Neon intrinsics for dot-product (PR #119911)
llvmbot wrote: @llvm/pr-subscribers-clang-codegen Author: Momchil Velikov (momchil-velikov) Changes This patch adds the following intrinsics: float16x4_t vdot_f16_mf8_fpm(float16x4_t vd, mfloat8x8_t vn, mfloat8x8_t vm, fpm_t fpm) float16x8_t vdotq_f16_mf8_fpm(float16x8_t vd, mfloat8x16_t vn, mfloat8x16_t vm, fpm_t fpm) float16x4_t vdot_lane_f16_mf8_fpm(float16x4_t vd, mfloat8x8_t vn, mfloat8x8_t vm, __builtin_constant_p(lane), fpm_t fpm) float16x4_t vdot_laneq_f16_mf8_fpm(float16x4_t vd, mfloat8x8_t vn, mfloat8x16_t vm, __builtin_constant_p(lane), fpm_t fpm) float16x8_t vdotq_lane_f16_mf8_fpm(float16x8_t vd, mfloat8x16_t vn, mfloat8x8_t vm, __builtin_constant_p(lane), fpm_t fpm) float16x8_t vdotq_laneq_f16_mf8_fpm(float16x8_t vd, mfloat8x16_t vn, mfloat8x16_t vm, __builtin_constant_p(lane), fpm_t fpm) --- Patch is 107.21 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/119911.diff 25 Files Affected: - (modified) clang/include/clang/AST/Type.h (+9) - (modified) clang/include/clang/Basic/AArch64SVEACLETypes.def (+18-6) - (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+5) - (modified) clang/include/clang/Basic/arm_neon.td (+46-1) - (modified) clang/include/clang/Basic/arm_neon_incl.td (+2) - (modified) clang/lib/AST/ASTContext.cpp (+30-7) - (modified) clang/lib/AST/ItaniumMangle.cpp (+5) - (modified) clang/lib/AST/Type.cpp (+14-3) - (modified) clang/lib/CodeGen/CGBuiltin.cpp (+166-1) - (modified) clang/lib/CodeGen/CodeGenFunction.h (+8) - (modified) clang/lib/CodeGen/CodeGenTypes.cpp (+10-3) - (modified) clang/lib/CodeGen/Targets/AArch64.cpp (+5-2) - (modified) clang/lib/Sema/SemaChecking.cpp (+33-6) - (added) clang/test/CodeGen/AArch64/builtin-shufflevector-fp8.c (+123) - (added) clang/test/CodeGen/AArch64/fp8-intrinsics/acle_neon_fp8_cvt.c (+308) - (added) clang/test/CodeGen/AArch64/fp8-intrinsics/acle_neon_fp8_fdot.c (+143) - (added) clang/test/Sema/aarch64-fp8-intrinsics/acle_neon_fp8.c (+57) - (added) clang/test/Sema/builtin-shufflevector.c (+30) - (modified) clang/utils/TableGen/NeonEmitter.cpp (+22-2) - (modified) clang/utils/TableGen/SveEmitter.cpp (+2-2) - (modified) llvm/include/llvm/IR/IntrinsicsAArch64.td (+43) - (modified) llvm/lib/Target/AArch64/AArch64InstrFormats.td (+83-45) - (modified) llvm/lib/Target/AArch64/AArch64InstrInfo.td (+14-14) - (added) llvm/test/CodeGen/AArch64/fp8-neon-fdot.ll (+74) - (added) llvm/test/CodeGen/AArch64/neon-fp8-cvt.ll (+112) ``diff diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index f0eee77c73ef06d..cacd3d75ffcd8de 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -2404,6 +2404,10 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase { /// SVE vector or predicate, excluding tuple types such as svint32x4_t. bool isSveVLSBuiltinType() const; + /// Determines if this is a *builtin* NEON vector type, a type not built with + /// `neon_vector_type` + bool isNeonVectorBuiltinType() const; + /// Returns the representative type for the element of an SVE builtin type. /// This is used to represent fixed-length SVE vectors created with the /// 'arm_sve_vector_bits' type attribute as VectorType. @@ -2518,6 +2522,7 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase { bool isFloat32Type() const; bool isDoubleType() const; bool isBFloat16Type() const; + bool isMFloat8Type() const; bool isFloat128Type() const; bool isIbm128Type() const; bool isRealType() const; // C99 6.2.5p17 (real floating + integer) @@ -8532,6 +8537,10 @@ inline bool Type::isBFloat16Type() const { return isSpecificBuiltinType(BuiltinType::BFloat16); } +inline bool Type::isMFloat8Type() const { + return isSpecificBuiltinType(BuiltinType::MFloat8); +} + inline bool Type::isFloat128Type() const { return isSpecificBuiltinType(BuiltinType::Float128); } diff --git a/clang/include/clang/Basic/AArch64SVEACLETypes.def b/clang/include/clang/Basic/AArch64SVEACLETypes.def index 063cac1f4a58ee7..6b704b386536c9b 100644 --- a/clang/include/clang/Basic/AArch64SVEACLETypes.def +++ b/clang/include/clang/Basic/AArch64SVEACLETypes.def @@ -57,6 +57,11 @@ // - IsBF true for vector of brain float elements. //===--===// +#ifndef SVE_SCALAR_TYPE +#define SVE_SCALAR_TYPE(Name, MangledName, Id, SingletonId, Bits) \ + SVE_TYPE(Name, Id, SingletonId) +#endif + #ifndef SVE_VECTOR_TYPE #define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \ SVE_TYPE(Name, Id, SingletonId) @@ -72,6 +77,11 @@ SVE_VECTOR_TYPE_DETAILS(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF, false, false, true) #endif +#ifndef SVE_VECTOR_TYPE_MFLOAT +#define SVE_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF) \ + SVE_VECTOR_TYPE_DETAILS(Name, Ma
[clang] [llvm] [AArch64] Add FP8 Neon intrinsics for dot-product (PR #119911)
llvmbot wrote: @llvm/pr-subscribers-backend-aarch64 Author: Momchil Velikov (momchil-velikov) Changes This patch adds the following intrinsics: float16x4_t vdot_f16_mf8_fpm(float16x4_t vd, mfloat8x8_t vn, mfloat8x8_t vm, fpm_t fpm) float16x8_t vdotq_f16_mf8_fpm(float16x8_t vd, mfloat8x16_t vn, mfloat8x16_t vm, fpm_t fpm) float16x4_t vdot_lane_f16_mf8_fpm(float16x4_t vd, mfloat8x8_t vn, mfloat8x8_t vm, __builtin_constant_p(lane), fpm_t fpm) float16x4_t vdot_laneq_f16_mf8_fpm(float16x4_t vd, mfloat8x8_t vn, mfloat8x16_t vm, __builtin_constant_p(lane), fpm_t fpm) float16x8_t vdotq_lane_f16_mf8_fpm(float16x8_t vd, mfloat8x16_t vn, mfloat8x8_t vm, __builtin_constant_p(lane), fpm_t fpm) float16x8_t vdotq_laneq_f16_mf8_fpm(float16x8_t vd, mfloat8x16_t vn, mfloat8x16_t vm, __builtin_constant_p(lane), fpm_t fpm) --- Patch is 107.21 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/119911.diff 25 Files Affected: - (modified) clang/include/clang/AST/Type.h (+9) - (modified) clang/include/clang/Basic/AArch64SVEACLETypes.def (+18-6) - (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+5) - (modified) clang/include/clang/Basic/arm_neon.td (+46-1) - (modified) clang/include/clang/Basic/arm_neon_incl.td (+2) - (modified) clang/lib/AST/ASTContext.cpp (+30-7) - (modified) clang/lib/AST/ItaniumMangle.cpp (+5) - (modified) clang/lib/AST/Type.cpp (+14-3) - (modified) clang/lib/CodeGen/CGBuiltin.cpp (+166-1) - (modified) clang/lib/CodeGen/CodeGenFunction.h (+8) - (modified) clang/lib/CodeGen/CodeGenTypes.cpp (+10-3) - (modified) clang/lib/CodeGen/Targets/AArch64.cpp (+5-2) - (modified) clang/lib/Sema/SemaChecking.cpp (+33-6) - (added) clang/test/CodeGen/AArch64/builtin-shufflevector-fp8.c (+123) - (added) clang/test/CodeGen/AArch64/fp8-intrinsics/acle_neon_fp8_cvt.c (+308) - (added) clang/test/CodeGen/AArch64/fp8-intrinsics/acle_neon_fp8_fdot.c (+143) - (added) clang/test/Sema/aarch64-fp8-intrinsics/acle_neon_fp8.c (+57) - (added) clang/test/Sema/builtin-shufflevector.c (+30) - (modified) clang/utils/TableGen/NeonEmitter.cpp (+22-2) - (modified) clang/utils/TableGen/SveEmitter.cpp (+2-2) - (modified) llvm/include/llvm/IR/IntrinsicsAArch64.td (+43) - (modified) llvm/lib/Target/AArch64/AArch64InstrFormats.td (+83-45) - (modified) llvm/lib/Target/AArch64/AArch64InstrInfo.td (+14-14) - (added) llvm/test/CodeGen/AArch64/fp8-neon-fdot.ll (+74) - (added) llvm/test/CodeGen/AArch64/neon-fp8-cvt.ll (+112) ``diff diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index f0eee77c73ef06d..cacd3d75ffcd8de 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -2404,6 +2404,10 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase { /// SVE vector or predicate, excluding tuple types such as svint32x4_t. bool isSveVLSBuiltinType() const; + /// Determines if this is a *builtin* NEON vector type, a type not built with + /// `neon_vector_type` + bool isNeonVectorBuiltinType() const; + /// Returns the representative type for the element of an SVE builtin type. /// This is used to represent fixed-length SVE vectors created with the /// 'arm_sve_vector_bits' type attribute as VectorType. @@ -2518,6 +2522,7 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase { bool isFloat32Type() const; bool isDoubleType() const; bool isBFloat16Type() const; + bool isMFloat8Type() const; bool isFloat128Type() const; bool isIbm128Type() const; bool isRealType() const; // C99 6.2.5p17 (real floating + integer) @@ -8532,6 +8537,10 @@ inline bool Type::isBFloat16Type() const { return isSpecificBuiltinType(BuiltinType::BFloat16); } +inline bool Type::isMFloat8Type() const { + return isSpecificBuiltinType(BuiltinType::MFloat8); +} + inline bool Type::isFloat128Type() const { return isSpecificBuiltinType(BuiltinType::Float128); } diff --git a/clang/include/clang/Basic/AArch64SVEACLETypes.def b/clang/include/clang/Basic/AArch64SVEACLETypes.def index 063cac1f4a58ee7..6b704b386536c9b 100644 --- a/clang/include/clang/Basic/AArch64SVEACLETypes.def +++ b/clang/include/clang/Basic/AArch64SVEACLETypes.def @@ -57,6 +57,11 @@ // - IsBF true for vector of brain float elements. //===--===// +#ifndef SVE_SCALAR_TYPE +#define SVE_SCALAR_TYPE(Name, MangledName, Id, SingletonId, Bits) \ + SVE_TYPE(Name, Id, SingletonId) +#endif + #ifndef SVE_VECTOR_TYPE #define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \ SVE_TYPE(Name, Id, SingletonId) @@ -72,6 +77,11 @@ SVE_VECTOR_TYPE_DETAILS(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF, false, false, true) #endif +#ifndef SVE_VECTOR_TYPE_MFLOAT +#define SVE_VECTOR_TYPE_MFLOAT(Name, MangledName, Id, SingletonId, NumEls, ElBits, NF) \ + SVE_VECTOR_TYPE_DETAILS(Name,