Skip to content

Rollup of 8 pull requests #131690

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
5db54be
Stabilize Pin::as_deref_mut
coolreader18 Aug 22, 2024
0c41c34
Allow zero-size reads/writes on null pointers
saethlin Oct 7, 2024
84dacc1
Add more precondition check tests
saethlin Oct 7, 2024
aec09a4
Clean up is_aligned_and_not_null
saethlin Oct 9, 2024
a3606d7
Add a test for zero-sized writes through null
saethlin Oct 9, 2024
c085071
Remove unadorned
compiler-errors Oct 11, 2024
d6391d5
Note what qualifier
compiler-errors Oct 11, 2024
d858dfe
Fix clobber_abi and disallow SVE-related registers in Arm64EC inline …
taiki-e Oct 13, 2024
67ebb6c
Fix AArch64InlineAsmReg::emit
taiki-e Oct 13, 2024
ceced53
Special treatment empty tuple when suggest adding a string literal in…
surechen Oct 9, 2024
cec5986
Document various parts of compiletest's `lib.rs`
Zalathar Oct 13, 2024
9f42f94
triagebot: tag PRs affecting compiletest with `A-compiletest`
jieyouxu Oct 14, 2024
7ed6d1c
Rollup merge of #129424 - coolreader18:stabilize-pin_as_deref_mut, r=…
matthiaskrgr Oct 14, 2024
43bf4f1
Rollup merge of #131332 - taiki-e:arm64ec-clobber-abi, r=Amanieu
matthiaskrgr Oct 14, 2024
32062b4
Rollup merge of #131384 - saethlin:precondition-tests, r=ibraheemdev
matthiaskrgr Oct 14, 2024
75231f8
Rollup merge of #131430 - surechen:fix_130495, r=jieyouxu
matthiaskrgr Oct 14, 2024
b8cdca8
Rollup merge of #131550 - compiler-errors:extern-diags, r=spastorino
matthiaskrgr Oct 14, 2024
dbb0581
Rollup merge of #131667 - taiki-e:aarch64-inline-asm-reg-emit, r=Amanieu
matthiaskrgr Oct 14, 2024
53cfc10
Rollup merge of #131679 - Zalathar:ct-docs, r=jieyouxu
matthiaskrgr Oct 14, 2024
ac9b212
Rollup merge of #131682 - jieyouxu:compiletest-label, r=Zalathar
matthiaskrgr Oct 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix AArch64InlineAsmReg::emit
  • Loading branch information
taiki-e committed Oct 13, 2024
commit 67ebb6c20b0cf8dfb587fd1085413232ccd8260c
51 changes: 5 additions & 46 deletions compiler/rustc_codegen_llvm/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,57 +542,16 @@ fn xmm_reg_index(reg: InlineAsmReg) -> Option<u32> {

/// If the register is an AArch64 integer register then return its index.
fn a64_reg_index(reg: InlineAsmReg) -> Option<u32> {
use AArch64InlineAsmReg::*;
// Unlike `a64_vreg_index`, we can't subtract `x0` to get the u32 because
// `x19` and `x29` are missing and the integer constants for the
// `x0`..`x30` enum variants don't all match the register number. E.g. the
// integer constant for `x18` is 18, but the constant for `x20` is 19.
Some(match reg {
InlineAsmReg::AArch64(r) => match r {
x0 => 0,
x1 => 1,
x2 => 2,
x3 => 3,
x4 => 4,
x5 => 5,
x6 => 6,
x7 => 7,
x8 => 8,
x9 => 9,
x10 => 10,
x11 => 11,
x12 => 12,
x13 => 13,
x14 => 14,
x15 => 15,
x16 => 16,
x17 => 17,
x18 => 18,
// x19 is reserved
x20 => 20,
x21 => 21,
x22 => 22,
x23 => 23,
x24 => 24,
x25 => 25,
x26 => 26,
x27 => 27,
x28 => 28,
// x29 is reserved
x30 => 30,
_ => return None,
},
_ => return None,
})
match reg {
InlineAsmReg::AArch64(r) => r.reg_index(),
_ => None,
}
}

/// If the register is an AArch64 vector register then return its index.
fn a64_vreg_index(reg: InlineAsmReg) -> Option<u32> {
use AArch64InlineAsmReg::*;
match reg {
InlineAsmReg::AArch64(reg) if reg as u32 >= v0 as u32 && reg as u32 <= v31 as u32 => {
Some(reg as u32 - v0 as u32)
}
InlineAsmReg::AArch64(reg) => reg.vreg_index(),
_ => None,
}
}
Expand Down
60 changes: 57 additions & 3 deletions compiler/rustc_target/src/asm/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,66 @@ impl AArch64InlineAsmReg {
_arch: InlineAsmArch,
modifier: Option<char>,
) -> fmt::Result {
let (prefix, index) = if (self as u32) < Self::v0 as u32 {
(modifier.unwrap_or('x'), self as u32 - Self::x0 as u32)
let (prefix, index) = if let Some(index) = self.reg_index() {
(modifier.unwrap_or('x'), index)
} else if let Some(index) = self.vreg_index() {
(modifier.unwrap_or('v'), index)
} else {
(modifier.unwrap_or('v'), self as u32 - Self::v0 as u32)
return out.write_str(self.name());
};
assert!(index < 32);
write!(out, "{prefix}{index}")
}

/// If the register is an integer register then return its index.
pub fn reg_index(self) -> Option<u32> {
// Unlike `vreg_index`, we can't subtract `x0` to get the u32 because
// `x19` and `x29` are missing and the integer constants for the
// `x0`..`x30` enum variants don't all match the register number. E.g. the
// integer constant for `x18` is 18, but the constant for `x20` is 19.
use AArch64InlineAsmReg::*;
Some(match self {
x0 => 0,
x1 => 1,
x2 => 2,
x3 => 3,
x4 => 4,
x5 => 5,
x6 => 6,
x7 => 7,
x8 => 8,
x9 => 9,
x10 => 10,
x11 => 11,
x12 => 12,
x13 => 13,
x14 => 14,
x15 => 15,
x16 => 16,
x17 => 17,
x18 => 18,
// x19 is reserved
x20 => 20,
x21 => 21,
x22 => 22,
x23 => 23,
x24 => 24,
x25 => 25,
x26 => 26,
x27 => 27,
x28 => 28,
// x29 is reserved
x30 => 30,
_ => return None,
})
}

/// If the register is a vector register then return its index.
pub fn vreg_index(self) -> Option<u32> {
use AArch64InlineAsmReg::*;
if self as u32 >= v0 as u32 && self as u32 <= v31 as u32 {
return Some(self as u32 - v0 as u32);
}
None
}
}
Loading