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