]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_target/src/spec/nvptx64_nvidia_cuda.rs
Rollup merge of #86685 - RalfJung:alloc-mut, r=oli-obk
[rust.git] / compiler / rustc_target / src / spec / nvptx64_nvidia_cuda.rs
1 use crate::spec::abi::Abi;
2 use crate::spec::{LinkerFlavor, MergeFunctions, PanicStrategy, Target, TargetOptions};
3
4 pub fn target() -> Target {
5     Target {
6         arch: "nvptx64".to_string(),
7         data_layout: "e-i64:64-i128:128-v16:16-v32:32-n16:32:64".to_string(),
8         llvm_target: "nvptx64-nvidia-cuda".to_string(),
9         pointer_width: 64,
10
11         options: TargetOptions {
12             os: "cuda".to_string(),
13             vendor: "nvidia".to_string(),
14             linker_flavor: LinkerFlavor::PtxLinker,
15             // The linker can be installed from `crates.io`.
16             linker: Some("rust-ptx-linker".to_string()),
17             linker_is_gnu: false,
18
19             // With `ptx-linker` approach, it can be later overridden via link flags.
20             cpu: "sm_30".to_string(),
21
22             // FIXME: create tests for the atomics.
23             max_atomic_width: Some(64),
24
25             // Unwinding on CUDA is neither feasible nor useful.
26             panic_strategy: PanicStrategy::Abort,
27
28             // Needed to use `dylib` and `bin` crate types and the linker.
29             dynamic_linking: true,
30             executables: true,
31
32             // Avoid using dylib because it contain metadata not supported
33             // by LLVM NVPTX backend.
34             only_cdylib: true,
35
36             // Let the `ptx-linker` to handle LLVM lowering into MC / assembly.
37             obj_is_bitcode: true,
38
39             // Convenient and predicable naming scheme.
40             dll_prefix: "".to_string(),
41             dll_suffix: ".ptx".to_string(),
42             exe_suffix: ".ptx".to_string(),
43
44             // Disable MergeFunctions LLVM optimisation pass because it can
45             // produce kernel functions that call other kernel functions.
46             // This behavior is not supported by PTX ISA.
47             merge_functions: MergeFunctions::Disabled,
48
49             // FIXME: enable compilation tests for the target and
50             // create the tests for this.
51             unsupported_abis: vec![
52                 Abi::Cdecl,
53                 Abi::Stdcall { unwind: false },
54                 Abi::Stdcall { unwind: true },
55                 Abi::Fastcall,
56                 Abi::Vectorcall,
57                 Abi::Thiscall { unwind: false },
58                 Abi::Thiscall { unwind: true },
59                 Abi::Aapcs,
60                 Abi::Win64,
61                 Abi::SysV64,
62                 Abi::Msp430Interrupt,
63                 Abi::X86Interrupt,
64                 Abi::AmdGpuKernel,
65             ],
66
67             ..Default::default()
68         },
69     }
70 }