]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_target/src/asm/hexagon.rs
Auto merge of #80339 - jyn514:no-span, r=GuillaumeGomez
[rust.git] / compiler / rustc_target / src / asm / hexagon.rs
1 use super::{InlineAsmArch, InlineAsmType};
2 use rustc_macros::HashStable_Generic;
3 use std::fmt;
4
5 def_reg_class! {
6     Hexagon HexagonInlineAsmRegClass {
7         reg,
8     }
9 }
10
11 impl HexagonInlineAsmRegClass {
12     pub fn valid_modifiers(self, _arch: super::InlineAsmArch) -> &'static [char] {
13         &[]
14     }
15
16     pub fn suggest_class(self, _arch: InlineAsmArch, _ty: InlineAsmType) -> Option<Self> {
17         None
18     }
19
20     pub fn suggest_modifier(
21         self,
22         _arch: InlineAsmArch,
23         _ty: InlineAsmType,
24     ) -> Option<(char, &'static str)> {
25         None
26     }
27
28     pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
29         None
30     }
31
32     pub fn supported_types(
33         self,
34         _arch: InlineAsmArch,
35     ) -> &'static [(InlineAsmType, Option<&'static str>)] {
36         match self {
37             Self::reg => types! { _: I8, I16, I32, F32; },
38         }
39     }
40 }
41
42 def_regs! {
43     Hexagon HexagonInlineAsmReg HexagonInlineAsmRegClass {
44         r0: reg = ["r0"],
45         r1: reg = ["r1"],
46         r2: reg = ["r2"],
47         r3: reg = ["r3"],
48         r4: reg = ["r4"],
49         r5: reg = ["r5"],
50         r6: reg = ["r6"],
51         r7: reg = ["r7"],
52         r8: reg = ["r8"],
53         r9: reg = ["r9"],
54         r10: reg = ["r10"],
55         r11: reg = ["r11"],
56         r12: reg = ["r12"],
57         r13: reg = ["r13"],
58         r14: reg = ["r14"],
59         r15: reg = ["r15"],
60         r16: reg = ["r16"],
61         r17: reg = ["r17"],
62         r18: reg = ["r18"],
63         r19: reg = ["r19"],
64         r20: reg = ["r20"],
65         r21: reg = ["r21"],
66         r22: reg = ["r22"],
67         r23: reg = ["r23"],
68         r24: reg = ["r24"],
69         r25: reg = ["r25"],
70         r26: reg = ["r26"],
71         r27: reg = ["r27"],
72         r28: reg = ["r28"],
73         #error = ["r29", "sp"] =>
74             "the stack pointer cannot be used as an operand for inline asm",
75         #error = ["r30", "fr"] =>
76             "the frame register cannot be used as an operand for inline asm",
77         #error = ["r31", "lr"] =>
78             "the link register cannot be used as an operand for inline asm",
79     }
80 }
81
82 impl HexagonInlineAsmReg {
83     pub fn emit(
84         self,
85         out: &mut dyn fmt::Write,
86         _arch: InlineAsmArch,
87         _modifier: Option<char>,
88     ) -> fmt::Result {
89         out.write_str(self.name())
90     }
91
92     pub fn overlapping_regs(self, mut _cb: impl FnMut(HexagonInlineAsmReg)) {}
93 }