Skip to content

Commit 8bf298f

Browse files
authored
[RISCV][compiler-rt] create __riscv__cpu_model for vendorID, ArchID, … (llvm#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
1 parent 2fc7a72 commit 8bf298f

File tree

1 file changed

+13
-6
lines changed
  • compiler-rt/lib/builtins/cpu_model

1 file changed

+13
-6
lines changed

compiler-rt/lib/builtins/cpu_model/riscv.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,16 @@ struct {
1616

1717
#define RISCV_VENDOR_FEATURE_BITS_LENGTH 1
1818
struct {
19-
unsigned vendorID;
2019
unsigned length;
2120
unsigned long long features[RISCV_VENDOR_FEATURE_BITS_LENGTH];
2221
} __riscv_vendor_feature_bits __attribute__((visibility("hidden"), nocommon));
2322

23+
struct {
24+
unsigned mVendorID;
25+
unsigned mArchID;
26+
unsigned mImplID;
27+
} __riscv_cpu_model __attribute__((visibility("hidden"), nocommon));
28+
2429
// NOTE: Should sync-up with RISCVFeatures.td
2530
// TODO: Maybe generate a header from tablegen then include it.
2631
#define A_GROUPID 0
@@ -244,8 +249,10 @@ static void initRISCVFeature(struct riscv_hwprobe Hwprobes[]) {
244249
// will be cleared to -1, and its value set to 0.
245250
// This unsets all extension bitmask bits.
246251

247-
// Init vendor extension
248-
__riscv_vendor_feature_bits.vendorID = Hwprobes[2].value;
252+
// Init VendorID, ArchID, ImplID
253+
__riscv_cpu_model.mVendorID = Hwprobes[2].value;
254+
__riscv_cpu_model.mArchID = Hwprobes[3].value;
255+
__riscv_cpu_model.mImplID = Hwprobes[4].value;
249256

250257
// Init standard extension
251258
// TODO: Maybe Extension implied generate from tablegen?
@@ -349,9 +356,9 @@ void CONSTRUCTOR_ATTRIBUTE __init_riscv_feature_bits(void *PlatformArgs) {
349356

350357
#if defined(__linux__)
351358
struct riscv_hwprobe Hwprobes[] = {
352-
{RISCV_HWPROBE_KEY_BASE_BEHAVIOR, 0},
353-
{RISCV_HWPROBE_KEY_IMA_EXT_0, 0},
354-
{RISCV_HWPROBE_KEY_MVENDORID, 0},
359+
{RISCV_HWPROBE_KEY_BASE_BEHAVIOR, 0}, {RISCV_HWPROBE_KEY_IMA_EXT_0, 0},
360+
{RISCV_HWPROBE_KEY_MVENDORID, 0}, {RISCV_HWPROBE_KEY_MARCHID, 0},
361+
{RISCV_HWPROBE_KEY_MIMPID, 0},
355362
};
356363
if (initHwProbe(Hwprobes, sizeof(Hwprobes) / sizeof(Hwprobes[0])))
357364
return;

0 commit comments

Comments
 (0)