]>
Commit | Line | Data |
---|---|---|
5099ac24 FG |
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 | Msp430 Msp430InlineAsmRegClass { | |
8 | reg, | |
9 | } | |
10 | } | |
11 | ||
12 | impl Msp430InlineAsmRegClass { | |
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, arch) { | |
38 | (Self::reg, _) => types! { _: I8, I16; }, | |
39 | } | |
40 | } | |
41 | } | |
42 | ||
43 | // The reserved registers are taken from: | |
44 | // https://github.com/llvm/llvm-project/blob/36cb29cbbe1b22dcd298ad65e1fabe899b7d7249/llvm/lib/Target/MSP430/MSP430RegisterInfo.cpp#L73. | |
45 | def_regs! { | |
46 | Msp430 Msp430InlineAsmReg Msp430InlineAsmRegClass { | |
47 | r5: reg = ["r5"], | |
48 | r6: reg = ["r6"], | |
49 | r7: reg = ["r7"], | |
50 | r8: reg = ["r8"], | |
51 | r9: reg = ["r9"], | |
52 | r10: reg = ["r10"], | |
53 | r11: reg = ["r11"], | |
54 | r12: reg = ["r12"], | |
55 | r13: reg = ["r13"], | |
56 | r14: reg = ["r14"], | |
57 | r15: reg = ["r15"], | |
58 | ||
59 | #error = ["r0", "pc"] => | |
60 | "the program counter cannot be used as an operand for inline asm", | |
61 | #error = ["r1", "sp"] => | |
62 | "the stack pointer cannot be used as an operand for inline asm", | |
63 | #error = ["r2", "sr"] => | |
64 | "the status register cannot be used as an operand for inline asm", | |
65 | #error = ["r3", "cg"] => | |
66 | "the constant generator cannot be used as an operand for inline asm", | |
67 | #error = ["r4", "fp"] => | |
68 | "the frame pointer cannot be used as an operand for inline asm", | |
69 | } | |
70 | } | |
71 | ||
72 | impl Msp430InlineAsmReg { | |
73 | pub fn emit( | |
74 | self, | |
75 | out: &mut dyn fmt::Write, | |
76 | _arch: InlineAsmArch, | |
77 | _modifier: Option<char>, | |
78 | ) -> fmt::Result { | |
79 | out.write_str(self.name()) | |
80 | } | |
81 | } |