Skip to content
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

Support using const pointers in asm const operand #138618

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

nbdd0121
Copy link
Contributor

@nbdd0121 nbdd0121 commented Mar 17, 2025

Implements #128464

This adds support of const pointers for asm const in addition to plain integers.

The inline asm! support is implemented using i constraint, and the global_asm! and naked_asm! support is implemented by inserting symbol + offset and make symbol compiler-used. For unnamed consts, it will create additional internal & hidden symbols so that they can be referenced by global_asm.

GCC impl is still WIP.

This is used for string interpolation currently, so rename it as so.
The name `Const` will be used to denote a general CTFE constant that
can either be integer or pointer.
This is intended for supporting passing arbitrary CTFE const into inline
assembly.
`global_asm!` themselves don't need symbol names; they currently only have
a symbol name during mono collecion to identify them to partitioning
algorithm.

However it will have shims generated under it which will need unique symbol
names. The name themselves ultimately doesn't matter, so they're generated
like other shim instances.
This is currently a no-op, but will be useful when const in `global_asm!`
can be pointers.
@rustbot
Copy link
Collaborator

rustbot commented Mar 17, 2025

r? @fmease

rustbot has assigned @fmease.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 17, 2025
@fmease
Copy link
Member

fmease commented Mar 17, 2025

r? codegen

@rustbot rustbot assigned workingjubilee and unassigned fmease Mar 17, 2025
@rust-log-analyzer
Copy link
Collaborator

The job mingw-check failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
[RUSTC-TIMING] gccjit_sys test:false 0.024
    Checking gccjit v2.4.0
[RUSTC-TIMING] gccjit test:false 0.170
    Checking rustc_codegen_gcc v0.1.0 (/checkout/compiler/rustc_codegen_gcc)
error[E0004]: non-exhaustive patterns: `GlobalAsmOperandRef::ConstPointer { .. }` not covered
   --> compiler/rustc_codegen_gcc/src/asm.rs:853:27
    |
853 |                     match operands[operand_idx] {
    |                           ^^^^^^^^^^^^^^^^^^^^^ pattern `GlobalAsmOperandRef::ConstPointer { .. }` not covered
    |
note: `GlobalAsmOperandRef<'_>` defined here
   --> /checkout/compiler/rustc_codegen_ssa/src/traits/asm.rs:47:1
    |
47  | pub enum GlobalAsmOperandRef<'tcx> {

@compiler-errors
Copy link
Member

r? compiler-errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants