[compiler-rt] [RISCV][compiler-rt] create __riscv__cpu_model for vendorID, ArchID, … (PR #101449)
Piyou Chen via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 31 20:42:54 PDT 2024
https://github.com/BeMg created https://github.com/llvm/llvm-project/pull/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
>From fc861054373c786d4588bb3072d566b6f6940cb8 Mon Sep 17 00:00:00 2001
From: Piyou Chen <piyou.chen at sifive.com>
Date: Wed, 31 Jul 2024 20:22:01 -0700
Subject: [PATCH] [RISCV][compiler-rt] create __riscv__cpu_model for vendorID,
ArchID, ImplID
---
compiler-rt/lib/builtins/cpu_model/riscv.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/compiler-rt/lib/builtins/cpu_model/riscv.c b/compiler-rt/lib/builtins/cpu_model/riscv.c
index 92931fae64fbf..d643ddefd334d 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
@@ -208,8 +213,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?
@@ -297,9 +304,9 @@ void CONSTRUCTOR_ATTRIBUTE __init_riscv_feature_bits() {
#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