From 8bf298fa95bb23081e9e2507bfb31b017c01be15 Mon Sep 17 00:00:00 2001 From: Piyou Chen Date: Wed, 14 Aug 2024 18:11:54 +0800 Subject: [PATCH] =?utf8?q?[RISCV][compiler-rt]=20create=20=5F=5Friscv=5F?= =?utf8?q?=5Fcpu=5Fmodel=20for=20vendorID,=20ArchID,=20=E2=80=A6=20(#10144?= =?utf8?q?9)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit …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 --- 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 05c36b3d9e39..987812c18fa7 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; -- 2.11.4.GIT