Skip to content

Commit 44b269d

Browse files
committed
rustc_target: allow unenumerated architectures
1 parent 75f4028 commit 44b269d

File tree

3 files changed

+36
-36
lines changed

3 files changed

+36
-36
lines changed

src/abi.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,12 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
235235

236236
#[cfg(feature = "master")]
237237
fn gcc_cconv(&self, cx: &CodegenCx<'gcc, 'tcx>) -> Option<FnAttribute<'gcc>> {
238-
conv_to_fn_attribute(self.conv, cx.tcx.sess.target.arch)
238+
conv_to_fn_attribute(self.conv, &cx.tcx.sess.target.arch)
239239
}
240240
}
241241

242242
#[cfg(feature = "master")]
243-
pub fn conv_to_fn_attribute<'gcc>(conv: CanonAbi, arch: Arch) -> Option<FnAttribute<'gcc>> {
243+
pub fn conv_to_fn_attribute<'gcc>(conv: CanonAbi, arch: &Arch) -> Option<FnAttribute<'gcc>> {
244244
let attribute = match conv {
245245
CanonAbi::C | CanonAbi::Rust => return None,
246246
CanonAbi::RustCold => FnAttribute::Cold,
@@ -254,8 +254,8 @@ pub fn conv_to_fn_attribute<'gcc>(conv: CanonAbi, arch: Arch) -> Option<FnAttrib
254254
ArmCall::Aapcs => FnAttribute::ArmPcs("aapcs"),
255255
},
256256
CanonAbi::GpuKernel => match arch {
257-
Arch::AmdGpu => FnAttribute::GcnAmdGpuHsaKernel,
258-
Arch::Nvptx64 => FnAttribute::NvptxKernel,
257+
&Arch::AmdGpu => FnAttribute::GcnAmdGpuHsaKernel,
258+
&Arch::Nvptx64 => FnAttribute::NvptxKernel,
259259
arch => panic!("Arch {arch} does not support GpuKernel calling convention"),
260260
},
261261
// TODO(antoyo): check if those AVR attributes are mapped correctly.

src/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ impl<'gcc, 'tcx> MiscCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
487487
let entry_name = self.sess().target.entry_name.as_ref();
488488
if !self.functions.borrow().contains_key(entry_name) {
489489
#[cfg(feature = "master")]
490-
let conv = conv_to_fn_attribute(self.sess().target.entry_abi, self.sess().target.arch);
490+
let conv = conv_to_fn_attribute(self.sess().target.entry_abi, &self.sess().target.arch);
491491
#[cfg(not(feature = "master"))]
492492
let conv = None;
493493
Some(self.declare_entry_fn(entry_name, fn_type, conv))

src/gcc_util.rs

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -67,46 +67,46 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
6767
// To find a list of GCC's names, check https://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html
6868
pub fn to_gcc_features<'a>(sess: &Session, s: &'a str) -> SmallVec<[&'a str; 2]> {
6969
// cSpell:disable
70-
match (sess.target.arch, s) {
70+
match (&sess.target.arch, s) {
7171
// FIXME: seems like x87 does not exist?
72-
(Arch::X86 | Arch::X86_64, "x87") => smallvec![],
73-
(Arch::X86 | Arch::X86_64, "sse4.2") => smallvec!["sse4.2", "crc32"],
74-
(Arch::X86 | Arch::X86_64, "pclmulqdq") => smallvec!["pclmul"],
75-
(Arch::X86 | Arch::X86_64, "rdrand") => smallvec!["rdrnd"],
76-
(Arch::X86 | Arch::X86_64, "bmi1") => smallvec!["bmi"],
77-
(Arch::X86 | Arch::X86_64, "cmpxchg16b") => smallvec!["cx16"],
78-
(Arch::X86 | Arch::X86_64, "avx512vaes") => smallvec!["vaes"],
79-
(Arch::X86 | Arch::X86_64, "avx512gfni") => smallvec!["gfni"],
80-
(Arch::X86 | Arch::X86_64, "avx512vpclmulqdq") => smallvec!["vpclmulqdq"],
72+
(&Arch::X86 | &Arch::X86_64, "x87") => smallvec![],
73+
(&Arch::X86 | &Arch::X86_64, "sse4.2") => smallvec!["sse4.2", "crc32"],
74+
(&Arch::X86 | &Arch::X86_64, "pclmulqdq") => smallvec!["pclmul"],
75+
(&Arch::X86 | &Arch::X86_64, "rdrand") => smallvec!["rdrnd"],
76+
(&Arch::X86 | &Arch::X86_64, "bmi1") => smallvec!["bmi"],
77+
(&Arch::X86 | &Arch::X86_64, "cmpxchg16b") => smallvec!["cx16"],
78+
(&Arch::X86 | &Arch::X86_64, "avx512vaes") => smallvec!["vaes"],
79+
(&Arch::X86 | &Arch::X86_64, "avx512gfni") => smallvec!["gfni"],
80+
(&Arch::X86 | &Arch::X86_64, "avx512vpclmulqdq") => smallvec!["vpclmulqdq"],
8181
// NOTE: seems like GCC requires 'avx512bw' for 'avx512vbmi2'.
82-
(Arch::X86 | Arch::X86_64, "avx512vbmi2") => {
82+
(&Arch::X86 | &Arch::X86_64, "avx512vbmi2") => {
8383
smallvec!["avx512vbmi2", "avx512bw"]
8484
}
8585
// NOTE: seems like GCC requires 'avx512bw' for 'avx512bitalg'.
86-
(Arch::X86 | Arch::X86_64, "avx512bitalg") => {
86+
(&Arch::X86 | &Arch::X86_64, "avx512bitalg") => {
8787
smallvec!["avx512bitalg", "avx512bw"]
8888
}
89-
(Arch::AArch64, "rcpc2") => smallvec!["rcpc-immo"],
90-
(Arch::AArch64, "dpb") => smallvec!["ccpp"],
91-
(Arch::AArch64, "dpb2") => smallvec!["ccdp"],
92-
(Arch::AArch64, "frintts") => smallvec!["fptoint"],
93-
(Arch::AArch64, "fcma") => smallvec!["complxnum"],
94-
(Arch::AArch64, "pmuv3") => smallvec!["perfmon"],
95-
(Arch::AArch64, "paca") => smallvec!["pauth"],
96-
(Arch::AArch64, "pacg") => smallvec!["pauth"],
89+
(&Arch::AArch64, "rcpc2") => smallvec!["rcpc-immo"],
90+
(&Arch::AArch64, "dpb") => smallvec!["ccpp"],
91+
(&Arch::AArch64, "dpb2") => smallvec!["ccdp"],
92+
(&Arch::AArch64, "frintts") => smallvec!["fptoint"],
93+
(&Arch::AArch64, "fcma") => smallvec!["complxnum"],
94+
(&Arch::AArch64, "pmuv3") => smallvec!["perfmon"],
95+
(&Arch::AArch64, "paca") => smallvec!["pauth"],
96+
(&Arch::AArch64, "pacg") => smallvec!["pauth"],
9797
// Rust ties fp and neon together. In GCC neon implicitly enables fp,
9898
// but we manually enable neon when a feature only implicitly enables fp
99-
(Arch::AArch64, "f32mm") => smallvec!["f32mm", "neon"],
100-
(Arch::AArch64, "f64mm") => smallvec!["f64mm", "neon"],
101-
(Arch::AArch64, "fhm") => smallvec!["fp16fml", "neon"],
102-
(Arch::AArch64, "fp16") => smallvec!["fullfp16", "neon"],
103-
(Arch::AArch64, "jsconv") => smallvec!["jsconv", "neon"],
104-
(Arch::AArch64, "sve") => smallvec!["sve", "neon"],
105-
(Arch::AArch64, "sve2") => smallvec!["sve2", "neon"],
106-
(Arch::AArch64, "sve2-aes") => smallvec!["sve2-aes", "neon"],
107-
(Arch::AArch64, "sve2-sm4") => smallvec!["sve2-sm4", "neon"],
108-
(Arch::AArch64, "sve2-sha3") => smallvec!["sve2-sha3", "neon"],
109-
(Arch::AArch64, "sve2-bitperm") => smallvec!["sve2-bitperm", "neon"],
99+
(&Arch::AArch64, "f32mm") => smallvec!["f32mm", "neon"],
100+
(&Arch::AArch64, "f64mm") => smallvec!["f64mm", "neon"],
101+
(&Arch::AArch64, "fhm") => smallvec!["fp16fml", "neon"],
102+
(&Arch::AArch64, "fp16") => smallvec!["fullfp16", "neon"],
103+
(&Arch::AArch64, "jsconv") => smallvec!["jsconv", "neon"],
104+
(&Arch::AArch64, "sve") => smallvec!["sve", "neon"],
105+
(&Arch::AArch64, "sve2") => smallvec!["sve2", "neon"],
106+
(&Arch::AArch64, "sve2-aes") => smallvec!["sve2-aes", "neon"],
107+
(&Arch::AArch64, "sve2-sm4") => smallvec!["sve2-sm4", "neon"],
108+
(&Arch::AArch64, "sve2-sha3") => smallvec!["sve2-sha3", "neon"],
109+
(&Arch::AArch64, "sve2-bitperm") => smallvec!["sve2-bitperm", "neon"],
110110
(_, s) => smallvec![s],
111111
}
112112
// cSpell:enable

0 commit comments

Comments
 (0)