LevyHsu updated this revision to Diff 334332. LevyHsu added a comment. 1. clang/lib/Headers/riscv_zbr_intrin.h - Fix coding style issues - Added error messages to alert user not include this headfile directly. 2. clang/lib/Headers/rvintrin.h - Fix coding style issues.
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D99008/new/ https://reviews.llvm.org/D99008 Files: clang-tools-extra/clang-include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp clang-tools-extra/clangd/index/CanonicalIncludes.cpp clang/lib/Headers/CMakeLists.txt clang/lib/Headers/riscv_zbr_intrin.h clang/lib/Headers/rvintrin.h clang/test/Headers/rvintrin.c
Index: clang/test/Headers/rvintrin.c =================================================================== --- /dev/null +++ clang/test/Headers/rvintrin.c @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -triple riscv32 -fsyntax-only \ +// RUN: -target-feature +experimental-zbr %s +// RUN: %clang_cc1 -triple riscv64 -fsyntax-only \ +// RUN: -target-feature +experimental-zbr %s + +#include <rvintrin.h> Index: clang/lib/Headers/rvintrin.h =================================================================== --- /dev/null +++ clang/lib/Headers/rvintrin.h @@ -0,0 +1,26 @@ +/*===-------------------------- rvintrin.h ---------------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __RVINTRIN_H +#define __RVINTRIN_H + +#define int_xlen_t long +#define uint_xlen_t unsigned int_xlen_t + +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __artificial__, __nodebug__)) + +#if defined(__riscv_zbr) +#include "riscv_zbr_intrin.h" +#endif + +#undef __DEFAULT_FN_ATTRS +#undef uint_xlen_t +#undef int_xlen_t +#endif // __RVINTRIN_H Index: clang/lib/Headers/riscv_zbr_intrin.h =================================================================== --- /dev/null +++ clang/lib/Headers/riscv_zbr_intrin.h @@ -0,0 +1,61 @@ +/*===------------------------ riscv_zbb_intrin.h ---------------------------=== + * + * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. + * See https://llvm.org/LICENSE.txt for license information. + * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __RVINTRIN_H +#error "Never use <riscv_zbb_intrin.h> directly; include <rvintrin.h> instead." +#endif + +#ifndef __RISCV_ZBR_INTRIN_H +#define __RISCV_ZBR_INTRIN_H + +#if defined(__cplusplus) +extern "C" { +#endif + +// Zbr +static __inline__ int_xlen_t __DEFAULT_FN_ATTRS _rv_crc32_b(int_xlen_t rs1) { + return __builtin_riscv_crc32_b(rs1); +} + +static __inline__ int_xlen_t __DEFAULT_FN_ATTRS _rv_crc32_h(int_xlen_t rs1) { + return __builtin_riscv_crc32_h(rs1); +} + +static __inline__ int_xlen_t __DEFAULT_FN_ATTRS _rv_crc32_w(int_xlen_t rs1) { + return __builtin_riscv_crc32_w(rs1); +} + +static __inline__ int_xlen_t __DEFAULT_FN_ATTRS _rv_crc32c_b(int_xlen_t rs1) { + return __builtin_riscv_crc32c_b(rs1); +} + +static __inline__ int_xlen_t __DEFAULT_FN_ATTRS _rv_crc32c_h(int_xlen_t rs1) { + return __builtin_riscv_crc32c_h(rs1); +} + +static __inline__ int_xlen_t __DEFAULT_FN_ATTRS _rv_crc32c_w(int_xlen_t rs1) { + return __builtin_riscv_crc32c_w(rs1); +} + +// RV64 only intrinsics +#if __riscv_xlen == 64 +static __inline__ int_xlen_t __DEFAULT_FN_ATTRS _rv_crc32_d(int_xlen_t rs1) { + return __builtin_riscv_crc32_d(rs1); +} + +static __inline__ int_xlen_t __DEFAULT_FN_ATTRS _rv_crc32c_d(int_xlen_t rs1) { + return __builtin_riscv_crc32c_d(rs1); +} +#endif // if defined(__riscv64__) + +#if defined(__cplusplus) +} +#endif // if defined(__cplusplus) + +#endif // __RISCV_ZBR_INTRIN_H Index: clang/lib/Headers/CMakeLists.txt =================================================================== --- clang/lib/Headers/CMakeLists.txt +++ clang/lib/Headers/CMakeLists.txt @@ -97,6 +97,8 @@ ptwriteintrin.h rdseedintrin.h rtmintrin.h + rvintrin.h + riscv_zbr_intrin.h serializeintrin.h sgxintrin.h s390intrin.h Index: clang-tools-extra/clangd/index/CanonicalIncludes.cpp =================================================================== --- clang-tools-extra/clangd/index/CanonicalIncludes.cpp +++ clang-tools-extra/clangd/index/CanonicalIncludes.cpp @@ -152,6 +152,8 @@ {"include/prfchwintrin.h", "<x86intrin.h>"}, {"include/rdseedintrin.h", "<x86intrin.h>"}, {"include/rtmintrin.h", "<immintrin.h>"}, + {"include/rvintrin.h", "<rvintrin.h>"}, + {"include/riscv_zbr_intrin.h", "<riscv_zbr_intrin.h>"}, {"include/shaintrin.h", "<immintrin.h>"}, {"include/smmintrin.h", "<smmintrin.h>"}, {"include/stdalign.h", "<cstdalign>"}, Index: clang-tools-extra/clang-include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp =================================================================== --- clang-tools-extra/clang-include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp +++ clang-tools-extra/clang-include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp @@ -57,6 +57,8 @@ {"include/prfchwintrin.h$", "<x86intrin.h>"}, {"include/rdseedintrin.h$", "<x86intrin.h>"}, {"include/rtmintrin.h$", "<immintrin.h>"}, + {"include/rvintrin.h$", "<rvintrin.h>"}, + {"include/riscv_zbr_intrin.h$", "<riscv_zbr_intrin.h>"}, {"include/shaintrin.h$", "<immintrin.h>"}, {"include/smmintrin.h$", "<smmintrin.h>"}, {"include/stdalign.h$", "<cstdalign>"},
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits