Skip to content

Commit f634e2a

Browse files
committed
scripts: dump-symbols
1 parent 0cbe2d9 commit f634e2a

File tree

3 files changed

+46
-21
lines changed

3 files changed

+46
-21
lines changed

crates/vsimd/src/macros.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ macro_rules! dispatch {
181181

182182
(@resolve_static, "sse2", $($arg_name: ident),*) => {
183183
#[cfg(all(
184-
// not(miri),
185184
any(target_arch = "x86", target_arch = "x86_64"),
186185
target_feature = "sse2"
187186
))]
@@ -247,7 +246,6 @@ macro_rules! dispatch {
247246
};
248247

249248
(@resolve_dynamic, "sse2") => {
250-
// #[cfg(all(not(miri), any(target_arch = "x86", target_arch = "x86_64")))]
251249
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
252250
if $crate::isa::SSE2::is_enabled() {
253251
return sse2;
@@ -354,7 +352,6 @@ macro_rules! dispatch {
354352
simd = {$simd_fn:path},
355353
target = {"sse2"},
356354
) => {
357-
// #[cfg(all(not(miri), any(target_arch = "x86", target_arch = "x86_64")))]
358355
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
359356
#[inline]
360357
#[target_feature(enable = "sse2")]
@@ -386,7 +383,7 @@ macro_rules! dispatch {
386383
target = {"simd128"},
387384
) => {
388385
#[cfg(target_arch = "wasm32")]
389-
#[inline]
386+
#[cfg_attr(not(vsimd_dump_symbols), inline)]
390387
#[target_feature(enable = "simd128")]
391388
$vis unsafe fn simd128($($arg_name:$arg_type),*) -> $ret {
392389
use $crate::isa::{WASM128, InstructionSet as _};

justfile

+6-2
Original file line numberDiff line numberDiff line change
@@ -154,17 +154,21 @@ dump-asm:
154154
./scripts/dump-symbols.py --mode asm | bash -ex
155155
COMMIT_HASH=`git rev-parse --short HEAD`
156156
cd target/symbols
157-
tokei -f -s files -t assembly -c 150 > $COMMIT_HASH-asm.txt
157+
F=$COMMIT_HASH-asm.txt
158+
tokei -f -s files -t assembly -c 150 > $F
158159
tokei -f -s lines -t assembly -c 150
160+
echo target/symbols/$F
159161

160162
dump-llvm-ir:
161163
#!/bin/bash -ex
162164
cd {{justfile_directory()}}
163165
./scripts/dump-symbols.py --mode llvm-ir | bash -ex
164166
COMMIT_HASH=`git rev-parse --short HEAD`
165167
cd target/symbols
166-
tokei -f -s files -t LLVM -c 150 > $COMMIT_HASH-llvm-ir.txt
168+
F=$COMMIT_HASH-llvm-ir.txt
169+
tokei -f -s files -t LLVM -c 150 > $F
167170
tokei -f -s lines -t LLVM -c 150
171+
echo target/symbols/$F
168172

169173
bench-quick:
170174
RUSTFLAGS='-Ctarget-cpu=native' cargo run -p simd-benches --bin simd-benches --profile bench --features unstable

scripts/dump-symbols.py

+39-15
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,17 @@
1919
"utf32_swap_endianness": ["avx2", "ssse3", "neon", "simd128"],
2020
"utf16_swap_endianness": ["avx2", "ssse3", "neon", "simd128"],
2121
},
22-
# ...
22+
"uuid-simd": {
23+
"parse_simple": ["avx2", "ssse3", "sse2", "neon", "simd128"],
24+
"parse_hyphenated": ["avx2", "sse4.1", "neon", "simd128"],
25+
"format_simple": ["avx2", "ssse3", "sse2", "neon", "simd128"],
26+
"format_hyphenated": ["avx2", "sse4.1", "neon", "simd128"],
27+
},
28+
"base32-simd": {
29+
"check": ["avx2", "ssse3", "neon", "simd128"],
30+
"encode": ["avx2", "sse4.1", "neon", "simd128"],
31+
"decode": ["avx2", "sse4.1", "neon", "simd128"],
32+
},
2333
}
2434

2535
TARGETS = {
@@ -28,10 +38,14 @@
2838
"ssse3": ["x86_64-unknown-linux-gnu", "i686-unknown-linux-gnu"],
2939
"sse2": ["x86_64-unknown-linux-gnu", "i686-unknown-linux-gnu"],
3040
"neon": ["aarch64-unknown-linux-gnu", "armv7-unknown-linux-gnueabihf"],
31-
# "simd128": ["wasm32-unknown-unknown"],
32-
"simd128": [], # TODO: https://github.com/pacak/cargo-show-asm/issues/91
41+
"simd128": ["wasm32-unknown-unknown"],
3342
}
3443

44+
45+
def space_join(l):
46+
return " ".join(l)
47+
48+
3549
if __name__ == "__main__":
3650
opt = argparse.ArgumentParser()
3751
opt.add_argument("--mode", type=str, choices=["asm", "llvm-ir"], required=True)
@@ -44,16 +58,26 @@
4458
for feature in features:
4559
for target in TARGETS[feature]:
4660
print(f"mkdir -p target/symbols/{target}")
61+
4762
symbol = f"{pkg.replace('-', '_')}::multiversion::{name}::{feature.replace('.', '')}"
48-
if args.mode == "asm":
49-
print(
50-
f"cargo asm -p {pkg} --simplify --features unstable --target {target} -- {symbol} "
51-
f"| awk NF"
52-
f"> target/symbols/{target}/{symbol}.asm"
53-
)
54-
elif args.mode == "llvm-ir":
55-
print(
56-
f"RUSTFLAGS=-Cdebuginfo=0 "
57-
f"cargo asm -p {pkg} --llvm --features unstable --target {target} -- {symbol} "
58-
f"> target/symbols/{target}/{symbol}.ll"
59-
)
63+
64+
rustflags = ["--cfg vsimd_dump_symbols"]
65+
if target == "wasm32-unknown-unknown":
66+
rustflags.append("-C target-feature=+simd128")
67+
68+
match args.mode:
69+
case "asm":
70+
extra_flags = "--wasm" if target == "wasm32-unknown-unknown" else ""
71+
print(
72+
f'RUSTFLAGS="{space_join(rustflags)}" '
73+
f"cargo asm -p {pkg} --simplify --features unstable --target {target} {extra_flags} -- {symbol} "
74+
f"| awk NF"
75+
f"> target/symbols/{target}/{symbol}.asm"
76+
)
77+
case "llvm-ir":
78+
rustflags.append("-Cdebuginfo=0")
79+
print(
80+
f'RUSTFLAGS="{space_join(rustflags)}" '
81+
f"cargo asm -p {pkg} --llvm --features unstable --target {target} -- {symbol} "
82+
f"> target/symbols/{target}/{symbol}.ll"
83+
)

0 commit comments

Comments
 (0)