[compiler-rt] 8bf298f - [RISCV][compiler-rt] create __riscv__cpu_model for vendorID, ArchID, … (#101449)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 14 03:11:57 PDT 2024
Author: Piyou Chen
Date: 2024-08-14T18:11:54+08:00
New Revision: 8bf298fa95bb23081e9e2507bfb31b017c01be15
URL: https://github.com/llvm/llvm-project/commit/8bf298fa95bb23081e9e2507bfb31b017c01be15
DIFF: https://github.com/llvm/llvm-project/commit/8bf298fa95bb23081e9e2507bfb31b017c01be15.diff
LOG: [RISCV][compiler-rt] create __riscv__cpu_model for vendorID, ArchID, … (#101449)
…ImplID
This patch
1. remove the vendorId from `__riscv_vendor_feature_bits`
2. Define a new structure for vendorID, ArchID and ImplID
3. Update the relate init code
Added:
Modified:
compiler-rt/lib/builtins/cpu_model/riscv.c
Removed:
################################################################################
diff --git a/compiler-rt/lib/builtins/cpu_model/riscv.c b/compiler-rt/lib/builtins/cpu_model/riscv.c
index 05c36b3d9e39ea..987812c18fa792 100644
--- a/compiler-rt/lib/builtins/cpu_model/riscv.c
+++ b/compiler-rt/lib/builtins/cpu_model/riscv.c
@@ -16,11 +16,16 @@ struct {
#define RISCV_VENDOR_FEATURE_BITS_LENGTH 1
struct {
- unsigned vendorID;
unsigned length;
unsigned long long features[RISCV_VENDOR_FEATURE_BITS_LENGTH];
} __riscv_vendor_feature_bits __attribute__((visibility("hidden"), nocommon));
+struct {
+ unsigned mVendorID;
+ unsigned mArchID;
+ unsigned mImplID;
+} __riscv_cpu_model __attribute__((visibility("hidden"), nocommon));
+
// NOTE: Should sync-up with RISCVFeatures.td
// TODO: Maybe generate a header from tablegen then include it.
#define A_GROUPID 0
@@ -244,8 +249,10 @@ static void initRISCVFeature(struct riscv_hwprobe Hwprobes[]) {
// will be cleared to -1, and its value set to 0.
// This unsets all extension bitmask bits.
- // Init vendor extension
- __riscv_vendor_feature_bits.vendorID = Hwprobes[2].value;
+ // Init VendorID, ArchID, ImplID
+ __riscv_cpu_model.mVendorID = Hwprobes[2].value;
+ __riscv_cpu_model.mArchID = Hwprobes[3].value;
+ __riscv_cpu_model.mImplID = Hwprobes[4].value;
// Init standard extension
// TODO: Maybe Extension implied generate from tablegen?
@@ -349,9 +356,9 @@ void CONSTRUCTOR_ATTRIBUTE __init_riscv_feature_bits(void *PlatformArgs) {
#if defined(__linux__)
struct riscv_hwprobe Hwprobes[] = {
- {RISCV_HWPROBE_KEY_BASE_BEHAVIOR, 0},
- {RISCV_HWPROBE_KEY_IMA_EXT_0, 0},
- {RISCV_HWPROBE_KEY_MVENDORID, 0},
+ {RISCV_HWPROBE_KEY_BASE_BEHAVIOR, 0}, {RISCV_HWPROBE_KEY_IMA_EXT_0, 0},
+ {RISCV_HWPROBE_KEY_MVENDORID, 0}, {RISCV_HWPROBE_KEY_MARCHID, 0},
+ {RISCV_HWPROBE_KEY_MIMPID, 0},
};
if (initHwProbe(Hwprobes, sizeof(Hwprobes) / sizeof(Hwprobes[0])))
return;
More information about the llvm-commits
mailing list