-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #109989 - ids1024:m68k-asm, r=Amanieu
Add inline assembly support for m68k I believe this should be correct, to the extent I understand the logic around inline assembly. M68k is fairly straightforward here, other than having separate address registers.
- Loading branch information
Showing
7 changed files
with
220 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1175,7 +1175,9 @@ symbols! { | |
reg32, | ||
reg64, | ||
reg_abcd, | ||
reg_addr, | ||
reg_byte, | ||
reg_data, | ||
reg_iw, | ||
reg_nonzero, | ||
reg_pair, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
use super::{InlineAsmArch, InlineAsmType}; | ||
use rustc_macros::HashStable_Generic; | ||
use rustc_span::Symbol; | ||
use std::fmt; | ||
|
||
def_reg_class! { | ||
M68k M68kInlineAsmRegClass { | ||
reg, | ||
reg_addr, | ||
reg_data, | ||
} | ||
} | ||
|
||
impl M68kInlineAsmRegClass { | ||
pub fn valid_modifiers(self, _arch: super::InlineAsmArch) -> &'static [char] { | ||
&[] | ||
} | ||
|
||
pub fn suggest_class(self, _arch: InlineAsmArch, _ty: InlineAsmType) -> Option<Self> { | ||
None | ||
} | ||
|
||
pub fn suggest_modifier( | ||
self, | ||
_arch: InlineAsmArch, | ||
_ty: InlineAsmType, | ||
) -> Option<(char, &'static str)> { | ||
None | ||
} | ||
|
||
pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> { | ||
None | ||
} | ||
|
||
pub fn supported_types( | ||
self, | ||
_arch: InlineAsmArch, | ||
) -> &'static [(InlineAsmType, Option<Symbol>)] { | ||
match self { | ||
Self::reg => types! { _: I16, I32; }, | ||
Self::reg_data => types! { _: I8, I16, I32; }, | ||
Self::reg_addr => types! { _: I16, I32; }, | ||
} | ||
} | ||
} | ||
|
||
def_regs! { | ||
M68k M68kInlineAsmReg M68kInlineAsmRegClass { | ||
d0: reg, reg_data = ["d0"], | ||
d1: reg, reg_data = ["d1"], | ||
d2: reg, reg_data = ["d2"], | ||
d3: reg, reg_data = ["d3"], | ||
d4: reg, reg_data = ["d4"], | ||
d5: reg, reg_data = ["d5"], | ||
d6: reg, reg_data = ["d6"], | ||
d7: reg, reg_data = ["d7"], | ||
a0: reg, reg_addr = ["a0"], | ||
a1: reg, reg_addr = ["a1"], | ||
a2: reg, reg_addr = ["a2"], | ||
a3: reg, reg_addr = ["a3"], | ||
#error = ["a4"] => | ||
"a4 is used internally by LLVM and cannot be used as an operand for inline asm", | ||
#error = ["a5", "bp"] => | ||
"a5 is used internally by LLVM and cannot be used as an operand for inline asm", | ||
#error = ["a6", "fp"] => | ||
"a6 is used internally by LLVM and cannot be used as an operand for inline asm", | ||
#error = ["a7", "sp", "usp", "ssp", "isp"] => | ||
"the stack pointer cannot be used as an operand for inline asm", | ||
} | ||
} | ||
|
||
impl M68kInlineAsmReg { | ||
pub fn emit( | ||
self, | ||
out: &mut dyn fmt::Write, | ||
_arch: InlineAsmArch, | ||
_modifier: Option<char>, | ||
) -> fmt::Result { | ||
out.write_str(self.name()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.