Skip to content

Commit 61b93bd

Browse files
committed
Auto merge of #38561 - nagisa:rdrandseed, r=alexcrichton
Add intrinsics & target features for rd{rand,seed} One question is whether or not we want to map feature name `rdrnd` to `rdrand` instead. EDIT: as for use case, I would like to port my rdrand crate from inline assembly to these intrinsics.
2 parents 0af0b58 + b2cf6df commit 61b93bd

File tree

4 files changed

+85
-1
lines changed

4 files changed

+85
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"intrinsic_prefix": "_rdrand",
3+
"llvm_prefix": "llvm.x86.rdrand.",
4+
"intrinsics": [
5+
{
6+
"intrinsic": "16_step",
7+
"width": ["0"],
8+
"llvm": "16",
9+
"ret": "(U16,S32)",
10+
"args": []
11+
},
12+
{
13+
"intrinsic": "32_step",
14+
"width": ["0"],
15+
"llvm": "32",
16+
"ret": "(U32,S32)",
17+
"args": []
18+
},
19+
{
20+
"intrinsic": "64_step",
21+
"width": ["0"],
22+
"llvm": "64",
23+
"ret": "(U64,S32)",
24+
"args": []
25+
}
26+
]
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"intrinsic_prefix": "_rdseed",
3+
"llvm_prefix": "llvm.x86.rdseed.",
4+
"intrinsics": [
5+
{
6+
"intrinsic": "16_step",
7+
"width": ["0"],
8+
"llvm": "16",
9+
"ret": "(U16,S32)",
10+
"args": []
11+
},
12+
{
13+
"intrinsic": "32_step",
14+
"width": ["0"],
15+
"llvm": "32",
16+
"ret": "(U32,S32)",
17+
"args": []
18+
},
19+
{
20+
"intrinsic": "64_step",
21+
"width": ["0"],
22+
"llvm": "64",
23+
"ret": "(U64,S32)",
24+
"args": []
25+
}
26+
]
27+
}

src/librustc_driver/target_features.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const ARM_WHITELIST: &'static [&'static str] = &["neon\0", "vfp2\0", "vfp3\0", "
2525
const X86_WHITELIST: &'static [&'static str] = &["avx\0", "avx2\0", "bmi\0", "bmi2\0", "sse\0",
2626
"sse2\0", "sse3\0", "sse4.1\0", "sse4.2\0",
2727
"ssse3\0", "tbm\0", "lzcnt\0", "popcnt\0",
28-
"sse4a\0"];
28+
"sse4a\0", "rdrnd\0", "rdseed\0"];
2929

3030
/// Add `target_feature = "..."` cfgs for a variety of platform
3131
/// specific features (SSE, NEON etc.).

src/librustc_platform_intrinsics/x86.rs

+30
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,36 @@ pub fn find(name: &str) -> Option<Intrinsic> {
872872
output: &::F64x4,
873873
definition: Named("llvm.x86.fma.vfnmsub.pd.256")
874874
},
875+
"_rdrand16_step" => Intrinsic {
876+
inputs: { static INPUTS: [&'static Type; 0] = []; &INPUTS },
877+
output: { static AGG: Type = Type::Aggregate(false, { static PARTS: [&'static Type; 2] = [&::U16, &::I32]; &PARTS }); &AGG },
878+
definition: Named("llvm.x86.rdrand.16")
879+
},
880+
"_rdrand32_step" => Intrinsic {
881+
inputs: { static INPUTS: [&'static Type; 0] = []; &INPUTS },
882+
output: { static AGG: Type = Type::Aggregate(false, { static PARTS: [&'static Type; 2] = [&::U32, &::I32]; &PARTS }); &AGG },
883+
definition: Named("llvm.x86.rdrand.32")
884+
},
885+
"_rdrand64_step" => Intrinsic {
886+
inputs: { static INPUTS: [&'static Type; 0] = []; &INPUTS },
887+
output: { static AGG: Type = Type::Aggregate(false, { static PARTS: [&'static Type; 2] = [&::U64, &::I32]; &PARTS }); &AGG },
888+
definition: Named("llvm.x86.rdrand.64")
889+
},
890+
"_rdseed16_step" => Intrinsic {
891+
inputs: { static INPUTS: [&'static Type; 0] = []; &INPUTS },
892+
output: { static AGG: Type = Type::Aggregate(false, { static PARTS: [&'static Type; 2] = [&::U16, &::I32]; &PARTS }); &AGG },
893+
definition: Named("llvm.x86.rdseed.16")
894+
},
895+
"_rdseed32_step" => Intrinsic {
896+
inputs: { static INPUTS: [&'static Type; 0] = []; &INPUTS },
897+
output: { static AGG: Type = Type::Aggregate(false, { static PARTS: [&'static Type; 2] = [&::U32, &::I32]; &PARTS }); &AGG },
898+
definition: Named("llvm.x86.rdseed.32")
899+
},
900+
"_rdseed64_step" => Intrinsic {
901+
inputs: { static INPUTS: [&'static Type; 0] = []; &INPUTS },
902+
output: { static AGG: Type = Type::Aggregate(false, { static PARTS: [&'static Type; 2] = [&::U64, &::I32]; &PARTS }); &AGG },
903+
definition: Named("llvm.x86.rdseed.64")
904+
},
875905
"_mm_adds_epi8" => Intrinsic {
876906
inputs: { static INPUTS: [&'static Type; 2] = [&::I8x16, &::I8x16]; &INPUTS },
877907
output: &::I8x16,

0 commit comments

Comments
 (0)