LevyHsu updated this revision to Diff 334328.
LevyHsu added a comment.

1. clang/lib/Headers/riscv_zbb_intrin.h
  - Fixed llvm header and other style issues.
2. clang/lib/Headers/rvintrin.h
  - Fixed llvm header and other style issues.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99319/new/

https://reviews.llvm.org/D99319

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_zbb_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-zbb %s
+// RUN: %clang_cc1 -triple riscv64 -fsyntax-only \
+// RUN:   -target-feature +experimental-zbb %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_zbb)
+#include "riscv_zbb_intrin.h"
+#endif
+
+#undef __DEFAULT_FN_ATTRS
+#undef uint_xlen_t
+#undef int_xlen_t
+#endif // __RVINTRIN_H
Index: clang/lib/Headers/riscv_zbb_intrin.h
===================================================================
--- /dev/null
+++ clang/lib/Headers/riscv_zbb_intrin.h
@@ -0,0 +1,52 @@
+/*===-------------------- 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_ZBB_INTRIN_H
+#define __RISCV_ZBB_INTRIN_H
+
+#include <stdint.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+// Zbb
+
+// RV32/64 ORC_B_32
+static __inline__ int32_t __DEFAULT_FN_ATTRS _rv32_orc_b(int32_t rs1) {
+  return __builtin_riscv_orc_b_32(rs1);
+}
+
+// RV32 ORC_B
+#if __riscv_xlen == 32
+static __inline__ int_xlen_t __DEFAULT_FN_ATTRS _rv_orc_b(int_xlen_t rs1) {
+  return __builtin_riscv_orc_b_32(rs1);
+}
+#endif // if __riscv_xlen == 32
+
+// RV64 ORC_B and ORC_B_64
+#if __riscv_xlen == 64
+static __inline__ int_xlen_t __DEFAULT_FN_ATTRS _rv_orc_b(int_xlen_t rs1) {
+  return __builtin_riscv_orc_b_64(rs1);
+}
+
+static __inline__ int64_t __DEFAULT_FN_ATTRS _rv64_orc_b(int64_t rs1) {
+  return __builtin_riscv_orc_b_64(rs1);
+}
+#endif // if __riscv_xlen == 64
+
+#if defined(__cplusplus)
+}
+#endif // if defined(__cplusplus)
+
+#endif // __RISCV_ZBB_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_zbb_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_zbb_intrin.h", "<riscv_zbb_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_zbb_intrin.h$", "<riscv_zbb_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

Reply via email to