Support using const pointers in asm const operand#138618
Support using const pointers in asm const operand#138618nbdd0121 wants to merge 10 commits intorust-lang:mainfrom
const operand#138618Conversation
|
r? codegen |
This comment has been minimized.
This comment has been minimized.
|
r? compiler-errors |
|
Some changes occurred in compiler/rustc_codegen_ssa Some changes occurred in compiler/rustc_codegen_gcc |
| out_place: Option<PlaceRef<'tcx, B::Value>>, | ||
| }, | ||
| Const { | ||
| Interpolate { |
There was a problem hiding this comment.
Please add more doc comment explaining the significance of the difference between Interpolate and Const for backends. It begs the question for why we ever turn const operands into strings, for example.
There was a problem hiding this comment.
Added some explaination. Technically we should be able to use Const for integers, although I am a bit conservative here and don't want to change how existing things work.
This might also be useful to have in the future if we decided to add interpolate "some CTFE string to be interpolated" new type of operand.
|
☔ The latest upstream changes (presumably #140415) made this pull request unmergeable. Please resolve the merge conflicts. |
|
@rustbot author |
|
Reminder, once the PR becomes ready for a review, use |
This comment has been minimized.
This comment has been minimized.
|
Some changes occurred in compiler/rustc_codegen_cranelift cc @bjorn3 |
|
☔ The latest upstream changes (presumably #141668) made this pull request unmergeable. Please resolve the merge conflicts. |
tests/assembly-llvm/asm/x86-types.rs
Outdated
| // and on x86 PIC symbol can't be constant. | ||
| // x86_64-LABEL: const_ptr: | ||
| // x86_64: #APP | ||
| // x86_64: mov al, byte ptr [{{.*}}anon{{.*}}] |
There was a problem hiding this comment.
// x86_64: mov al, byte ptr [{{.*}}anon{{.*}}]
What was the expansion you observed?
There was a problem hiding this comment.
mov al, byte ptr [.Lanon.2e8c0013b01edcd3779e8174c2338a00.0]
This comment has been minimized.
This comment has been minimized.
085397e to
45aa236
Compare
|
@rustbot ready |
|
r? @rust-lang/compiler |
|
for the future you can just write |
|
Oops, sorry! |
|
☔ The latest upstream changes (presumably #150559) made this pull request unmergeable. Please resolve the merge conflicts. |
|
r? rust-lang/compiler |
|
@nbdd0121 I've self-assigned this because I'm going to delta-review it this weekend, so it would be worth fixing the merge conflicts whenever convenient. |
This is currently a no-op, but will be useful when const in `global_asm!` can be pointers.
Currently global_asm already have symbol names when using v0 scheme, this makes them obtain symbols with legacy scheme too.
This gives the asm-const code the basic ability to deal wiht pointer and provenances, which lays the ground work for asm_const_ptr. Note that `SymStatic` is not removed, as it supports `#[thread_local]` statics where CTFE does not.
With the previous commit, now we can see there are some code duplication for the handling of `GlobalAlloc` inside backends. Do some clean up to unify them.
CTFE pointers created via type ID, `without_provenance` or pointers to const ZSTs can now be codegenned with all 3 backends. These pointers are generated in the same way as integers.
The backend now fully supports codegen of const pointers, remove the block inside typeck behind a new feature gate. Tests are also added.
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
View all comments
Implements RFC#3848 with tracking issue #128464
This adds support of const pointers for asm
constin addition to plain integers.The inline
asm!support is implemented usingiconstraint, and theglobal_asm!andnaked_asm!support is implemented by insertingsymbol + offsetand makesymbolcompiler-used. For unnamed consts, it will create additional internal & hidden symbols so that they can be referenced by global_asm.The feature is also implemented for GCC backend but it's untested.