]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_target/src/asm/hexagon.rs
Rollup merge of #101175 - tmandry:curse-push-hook, r=jyn514
[rust.git] / compiler / rustc_target / src / asm / hexagon.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     Hexagon HexagonInlineAsmRegClass {
8         reg,
9     }
10 }
11
12 impl HexagonInlineAsmRegClass {
13     pub fn valid_modifiers(self, _arch: super::InlineAsmArch) -> &'static [char] {
14         &[]
15     }
16
17     pub fn suggest_class(self, _arch: InlineAsmArch, _ty: InlineAsmType) -> Option<Self> {
18         None
19     }
20
21     pub fn suggest_modifier(
22         self,
23         _arch: InlineAsmArch,
24         _ty: InlineAsmType,
25     ) -> Option<(char, &'static str)> {
26         None
27     }
28
29     pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
30         None
31     }
32
33     pub fn supported_types(
34         self,
35         _arch: InlineAsmArch,
36     ) -> &'static [(InlineAsmType, Option<Symbol>)] {
37         match self {
38             Self::reg => types! { _: I8, I16, I32, F32; },
39         }
40     }
41 }
42
43 def_regs! {
44     Hexagon HexagonInlineAsmReg HexagonInlineAsmRegClass {
45         r0: reg = ["r0"],
46         r1: reg = ["r1"],
47         r2: reg = ["r2"],
48         r3: reg = ["r3"],
49         r4: reg = ["r4"],
50         r5: reg = ["r5"],
51         r6: reg = ["r6"],
52         r7: reg = ["r7"],
53         r8: reg = ["r8"],
54         r9: reg = ["r9"],
55         r10: reg = ["r10"],
56         r11: reg = ["r11"],
57         r12: reg = ["r12"],
58         r13: reg = ["r13"],
59         r14: reg = ["r14"],
60         r15: reg = ["r15"],
61         r16: reg = ["r16"],
62         r17: reg = ["r17"],
63         r18: reg = ["r18"],
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 = ["r19"] =>
74             "r19 is used internally by LLVM and cannot be used as an operand for inline asm",
75         #error = ["r29", "sp"] =>
76             "the stack pointer cannot be used as an operand for inline asm",
77         #error = ["r30", "fr"] =>
78             "the frame register cannot be used as an operand for inline asm",
79         #error = ["r31", "lr"] =>
80             "the link register cannot be used as an operand for inline asm",
81     }
82 }
83
84 impl HexagonInlineAsmReg {
85     pub fn emit(
86         self,
87         out: &mut dyn fmt::Write,
88         _arch: InlineAsmArch,
89         _modifier: Option<char>,
90     ) -> fmt::Result {
91         out.write_str(self.name())
92     }
93
94     pub fn overlapping_regs(self, mut _cb: impl FnMut(HexagonInlineAsmReg)) {}
95 }