]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_target/src/asm/s390x.rs
Rollup merge of #97105 - JulianKnodt:const_dep_gen_const_expr, r=lcnr
[rust.git] / compiler / rustc_target / src / asm / s390x.rs
1 use super::{InlineAsmArch, InlineAsmType};
2 use rustc_macros::HashStable_Generic;
3 use rustc_span::Symbol;
4 use std::fmt;
5
6 def_reg_class! {
7     S390x S390xInlineAsmRegClass {
8         reg,
9         freg,
10     }
11 }
12
13 impl S390xInlineAsmRegClass {
14     pub fn valid_modifiers(self, _arch: super::InlineAsmArch) -> &'static [char] {
15         &[]
16     }
17
18     pub fn suggest_class(self, _arch: InlineAsmArch, _ty: InlineAsmType) -> Option<Self> {
19         None
20     }
21
22     pub fn suggest_modifier(
23         self,
24         _arch: InlineAsmArch,
25         _ty: InlineAsmType,
26     ) -> Option<(char, &'static str)> {
27         None
28     }
29
30     pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
31         None
32     }
33
34     pub fn supported_types(
35         self,
36         arch: InlineAsmArch,
37     ) -> &'static [(InlineAsmType, Option<Symbol>)] {
38         match (self, arch) {
39             (Self::reg, _) => types! { _: I8, I16, I32, I64; },
40             (Self::freg, _) => types! { _: F32, F64; },
41         }
42     }
43 }
44
45 def_regs! {
46     S390x S390xInlineAsmReg S390xInlineAsmRegClass {
47         r0: reg = ["r0"],
48         r1: reg = ["r1"],
49         r2: reg = ["r2"],
50         r3: reg = ["r3"],
51         r4: reg = ["r4"],
52         r5: reg = ["r5"],
53         r6: reg = ["r6"],
54         r7: reg = ["r7"],
55         r8: reg = ["r8"],
56         r9: reg = ["r9"],
57         r10: reg = ["r10"],
58         r12: reg = ["r12"],
59         r13: reg = ["r13"],
60         r14: reg = ["r14"],
61         f0: freg = ["f0"],
62         f1: freg = ["f1"],
63         f2: freg = ["f2"],
64         f3: freg = ["f3"],
65         f4: freg = ["f4"],
66         f5: freg = ["f5"],
67         f6: freg = ["f6"],
68         f7: freg = ["f7"],
69         f8: freg = ["f8"],
70         f9: freg = ["f9"],
71         f10: freg = ["f10"],
72         f11: freg = ["f11"],
73         f12: freg = ["f12"],
74         f13: freg = ["f13"],
75         f14: freg = ["f14"],
76         f15: freg = ["f15"],
77         #error = ["r11"] =>
78             "The frame pointer cannot be used as an operand for inline asm",
79         #error = ["r15"] =>
80             "The stack pointer cannot be used as an operand for inline asm",
81         #error = [
82             "c0", "c1", "c2", "c3",
83             "c4", "c5", "c6", "c7",
84             "c8", "c9", "c10", "c11",
85             "c12", "c13", "c14", "c15"
86         ] =>
87             "control registers are reserved by the kernel and cannot be used as operands for inline asm",
88         #error = [
89             "a0", "a1", "a2", "a3",
90             "a4", "a5", "a6", "a7",
91             "a8", "a9", "a10", "a11",
92             "a12", "a13", "a14", "a15"
93         ] =>
94             "access registers are not supported and cannot be used as operands for inline asm",
95     }
96 }
97
98 impl S390xInlineAsmReg {
99     pub fn emit(
100         self,
101         out: &mut dyn fmt::Write,
102         _arch: InlineAsmArch,
103         _modifier: Option<char>,
104     ) -> fmt::Result {
105         write!(out, "%{}", self.name())
106     }
107 }