aboutsummaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorLaytan <laytanlaats@hotmail.com>2024-08-15 20:39:35 +0200
committerLaytan Laats <laytanlaats@hotmail.com>2024-08-20 14:06:40 +0200
commitca6ef95b038f3eb443971240de73924a721485cc (patch)
treefb72aa52d41f114540dfcc3c5832dc88b2b5cbd5 /misc
parent29838da782ad4ce77507665f6f6aa36142ceeac1 (diff)
add support for linux_riscv64 and freestanding_riscv64
Diffstat (limited to 'misc')
-rw-r--r--misc/featuregen/README.md4
-rwxr-xr-xmisc/featuregen/build_featuregen.sh5
-rw-r--r--misc/featuregen/featuregen.py19
3 files changed, 18 insertions, 10 deletions
diff --git a/misc/featuregen/README.md b/misc/featuregen/README.md
index 22a798cca..82d95a2b6 100644
--- a/misc/featuregen/README.md
+++ b/misc/featuregen/README.md
@@ -5,7 +5,7 @@ for features regarding microarchitecture and target features of the compiler.
It is not pretty! But LLVM has no way to query this information with their C API.
-It generates these globals (intended for `src/build_settings.cpp`:
+It generates these globals (intended for `src/build_settings_microarch.cpp`:
- `target_microarch_list`: an array of strings indexed by the architecture, each string is a comma-seperated list of microarchitectures available on that architecture
- `target_features_list`: an array of strings indexed by the architecture, each string is a comma-seperated list of target features available on that architecture
@@ -23,6 +23,6 @@ does not impact much at all, the only thing it will do is make LLVM print a mess
## Usage
1. Make sure the table of architectures at the top of the python script is up-to-date (the triple can be any valid triple for the architecture)
-1. `./build.sh`
+1. `./build_featuregen.sh`
1. `python3 featuregen.py`
1. Copy the output into `src/build_settings.cpp`
diff --git a/misc/featuregen/build_featuregen.sh b/misc/featuregen/build_featuregen.sh
new file mode 100755
index 000000000..d68f29925
--- /dev/null
+++ b/misc/featuregen/build_featuregen.sh
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+
+set -ex
+
+$(llvm-config --bindir)/clang++ $(llvm-config --cxxflags --ldflags --libs) featuregen.cpp -o featuregen
diff --git a/misc/featuregen/featuregen.py b/misc/featuregen/featuregen.py
index da4cc68f5..ecc47f70c 100644
--- a/misc/featuregen/featuregen.py
+++ b/misc/featuregen/featuregen.py
@@ -4,12 +4,13 @@ import os
import sys
archs = [
- ("amd64", "linux_amd64", "x86_64-pc-linux-gnu", [], []),
- ("i386", "linux_i386", "i386-pc-linux-gnu", [], []),
- ("arm32", "linux_arm32", "arm-linux-gnu", [], []),
- ("arm64", "linux_arm64", "aarch64-linux-elf", [], []),
- ("wasm32", "js_wasm32", "wasm32-js-js", [], []),
- ("wasm64p32", "js_wasm64p32","wasm32-js-js", [], []),
+ ("amd64", "linux_amd64", "x86_64-pc-linux-gnu", [], []),
+ ("i386", "linux_i386", "i386-pc-linux-gnu", [], []),
+ ("arm32", "linux_arm32", "arm-linux-gnu", [], []),
+ ("arm64", "linux_arm64", "aarch64-linux-elf", [], []),
+ ("wasm32", "js_wasm32", "wasm32-js-js", [], []),
+ ("wasm64p32", "js_wasm64p32", "wasm32-js-js", [], []),
+ ("riscv64", "linux_riscv64", "riscv64-linux-gnu", [], []),
];
SEEKING_CPUS = 0
@@ -78,7 +79,8 @@ print("\t// TargetArch_Invalid:")
print('\tstr_lit(""),')
for arch, target, triple, cpus, features in archs:
print(f"\t// TargetArch_{arch}:")
- print(f'\tstr_lit("{','.join(cpus)}"),')
+ cpus_str = ','.join(cpus)
+ print(f'\tstr_lit("{cpus_str}"),')
print("};")
print("")
@@ -89,7 +91,8 @@ print("\t// TargetArch_Invalid:")
print('\tstr_lit(""),')
for arch, target, triple, cpus, features in archs:
print(f"\t// TargetArch_{arch}:")
- print(f'\tstr_lit("{','.join(features)}"),')
+ features_str = ','.join(features)
+ print(f'\tstr_lit("{features_str}"),')
print("};")
print("")