forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#88245 - Sl1mb0:s390-asm, r=Amanieu
S390x inline asm This adds register definitions and constraint codes for the s390x general and floating point registers necessary for fixing rust-lang#85931; as well as a few tests. Further testing is needed, but I am a little unsure of what specific tests should be added to `src/test/assembly/asm/s390x.rs` to address this.
- Loading branch information
Showing
4 changed files
with
305 additions
and
0 deletions.
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 |
---|---|---|
@@ -0,0 +1,106 @@ | ||
use super::{InlineAsmArch, InlineAsmType}; | ||
use rustc_macros::HashStable_Generic; | ||
use std::fmt; | ||
|
||
def_reg_class! { | ||
S390x S390xInlineAsmRegClass { | ||
reg, | ||
freg, | ||
} | ||
} | ||
|
||
impl S390xInlineAsmRegClass { | ||
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<&'static str>)] { | ||
match (self, arch) { | ||
(Self::reg, _) => types! { _: I8, I16, I32, I64; }, | ||
(Self::freg, _) => types! { _: F32, F64; }, | ||
} | ||
} | ||
} | ||
|
||
def_regs! { | ||
S390x S390xInlineAsmReg S390xInlineAsmRegClass { | ||
r0: reg = ["r0"], | ||
r1: reg = ["r1"], | ||
r2: reg = ["r2"], | ||
r3: reg = ["r3"], | ||
r4: reg = ["r4"], | ||
r5: reg = ["r5"], | ||
r6: reg = ["r6"], | ||
r7: reg = ["r7"], | ||
r8: reg = ["r8"], | ||
r9: reg = ["r9"], | ||
r10: reg = ["r10"], | ||
r12: reg = ["r12"], | ||
r13: reg = ["r13"], | ||
r14: reg = ["r14"], | ||
f0: freg = ["f0"], | ||
f1: freg = ["f1"], | ||
f2: freg = ["f2"], | ||
f3: freg = ["f3"], | ||
f4: freg = ["f4"], | ||
f5: freg = ["f5"], | ||
f6: freg = ["f6"], | ||
f7: freg = ["f7"], | ||
f8: freg = ["f8"], | ||
f9: freg = ["f9"], | ||
f10: freg = ["f10"], | ||
f11: freg = ["f11"], | ||
f12: freg = ["f12"], | ||
f13: freg = ["f13"], | ||
f14: freg = ["f14"], | ||
f15: freg = ["f15"], | ||
#error = ["r11"] => | ||
"The frame pointer cannot be used as an operand for inline asm", | ||
#error = ["r15"] => | ||
"The stack pointer cannot be used as an operand for inline asm", | ||
#error = [ | ||
"c0", "c1", "c2", "c3", | ||
"c4", "c5", "c6", "c7", | ||
"c8", "c9", "c10", "c11", | ||
"c12", "c13", "c14", "c15" | ||
] => | ||
"control registers are reserved by the kernel and cannot be used as operands for inline asm", | ||
#error = [ | ||
"a0", "a1", "a2", "a3", | ||
"a4", "a5", "a6", "a7", | ||
"a8", "a9", "a10", "a11", | ||
"a12", "a13", "a14", "a15" | ||
] => | ||
"access registers are not supported and cannot be used as operands for inline asm", | ||
} | ||
} | ||
|
||
impl S390xInlineAsmReg { | ||
pub fn emit( | ||
self, | ||
out: &mut dyn fmt::Write, | ||
_arch: InlineAsmArch, | ||
_modifier: Option<char>, | ||
) -> fmt::Result { | ||
write!(out, "%{}", self.name()) | ||
} | ||
} |
Oops, something went wrong.