Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
5f2790c
using rustc in the middle of an attrpath errors
jdonszelmann Mar 7, 2026
3250d8d
Move 3 files (2 .rs and 1 .stderr) from ui/issues to ui/transmute
ujjwalvishwakarma2006 Mar 26, 2026
58ceac1
Add issue link at the top in file tests/ui/transmute/transmute-slice-…
ujjwalvishwakarma2006 Mar 26, 2026
e0f17b9
Add issue link, and update trait and type names for better readability
ujjwalvishwakarma2006 Mar 26, 2026
a261c8c
Add updated .stderr file
ujjwalvishwakarma2006 Mar 26, 2026
f1797f8
Moved and renamed issue-34571.rs to enum/enum_u8_variant.rs
aryannrd Mar 28, 2026
6d8c10e
Added description and orignal issue link to enum_u8_variant.rs
aryannrd Mar 28, 2026
09e48be
Moved and renamed issue-49973.rs to layout/opt-repr-i32-min.rs
aryannrd Mar 29, 2026
49ea8ce
Added link and test description for opt-repr-i32-min.rs
aryannrd Mar 29, 2026
16c3d97
Moved and renamed issue-38160 to macros/macro-const-stringify.rs
aryannrd Mar 30, 2026
c0e8750
Added issue link and description to macro-const-stringify.rs
aryannrd Mar 30, 2026
147d110
fixing tidy issues
aryannrd Mar 31, 2026
eb5453f
ty_utils: lower tuples to `ScalableVector` repr
davidtwco Feb 19, 2026
e3d70b6
cg_llvm: `sve_tuple_{create,get,set}` intrinsics
davidtwco Feb 19, 2026
8cccf30
cg_llvm/debuginfo: scalable vectors
davidtwco Feb 26, 2026
73fdeed
cg_llvm: `sve_cast` intrinsic
davidtwco Feb 28, 2026
3e0572e
improve diagnostics for attrs that *contain* the word rustc
jdonszelmann Mar 7, 2026
7dc9a08
Lower spans for literal const args
reddevilmidzy Mar 27, 2026
28b06a6
Rename probe_ty_var to try_resolve_ty_var
jdonszelmann Mar 30, 2026
e29f4f4
Revert `Ty` type alias in `rustc_type_ir`
Jamesbarford Apr 2, 2026
0e2c554
rename opaque_generic_const_args to generic_const_args
khyperia Mar 31, 2026
9465366
remove the o from oGCA
khyperia Apr 2, 2026
aa33699
Rollup merge of #153286 - davidtwco:sve-intrinsics, r=Amanieu
JonathanBrouwer Apr 2, 2026
6cbe25b
Rollup merge of #153532 - jdonszelmann:attributes-containing-rustc, r…
JonathanBrouwer Apr 2, 2026
d3d7482
Rollup merge of #154710 - khyperia:rename-ogca, r=BoxyUwU
JonathanBrouwer Apr 2, 2026
5521230
Rollup merge of #154425 - ujjwalvishwakarma2006:migrate-transmute-tes…
JonathanBrouwer Apr 2, 2026
5fb8385
Rollup merge of #154469 - reddevilmidzy:mgca-lower, r=BoxyUwU
JonathanBrouwer Apr 2, 2026
cc98d0a
Rollup merge of #154578 - jdonszelmann:rename-probe, r=lcnr,boxyuwu
JonathanBrouwer Apr 2, 2026
abb2497
Rollup merge of #154615 - aryannrd:moving-issues, r=Kivooeo
JonathanBrouwer Apr 2, 2026
bac466e
Rollup merge of #154709 - Jamesbarford:chore/revert-ty-type-alias, r=…
JonathanBrouwer Apr 2, 2026
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
21 changes: 14 additions & 7 deletions compiler/rustc_abi/src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use tracing::{debug, trace};

use crate::{
AbiAlign, Align, BackendRepr, FieldsShape, HasDataLayout, IndexSlice, IndexVec, Integer,
LayoutData, Niche, NonZeroUsize, Primitive, ReprOptions, Scalar, Size, StructKind, TagEncoding,
TargetDataLayout, Variants, WrappingRange,
LayoutData, Niche, NonZeroUsize, NumScalableVectors, Primitive, ReprOptions, Scalar, Size,
StructKind, TagEncoding, TargetDataLayout, Variants, WrappingRange,
};

mod coroutine;
Expand Down Expand Up @@ -204,13 +204,19 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
&self,
element: F,
count: u64,
number_of_vectors: NumScalableVectors,
) -> LayoutCalculatorResult<FieldIdx, VariantIdx, F>
where
FieldIdx: Idx,
VariantIdx: Idx,
F: AsRef<LayoutData<FieldIdx, VariantIdx>> + fmt::Debug,
{
vector_type_layout(SimdVectorKind::Scalable, self.cx.data_layout(), element, count)
vector_type_layout(
SimdVectorKind::Scalable(number_of_vectors),
self.cx.data_layout(),
element,
count,
)
}

pub fn simd_type<FieldIdx, VariantIdx, F>(
Expand Down Expand Up @@ -1526,7 +1532,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {

enum SimdVectorKind {
/// `#[rustc_scalable_vector]`
Scalable,
Scalable(NumScalableVectors),
/// `#[repr(simd, packed)]`
PackedFixed,
/// `#[repr(simd)]`
Expand Down Expand Up @@ -1559,9 +1565,10 @@ where
let size =
elt.size.checked_mul(count, dl).ok_or_else(|| LayoutCalculatorError::SizeOverflow)?;
let (repr, align) = match kind {
SimdVectorKind::Scalable => {
(BackendRepr::SimdScalableVector { element, count }, dl.llvmlike_vector_align(size))
}
SimdVectorKind::Scalable(number_of_vectors) => (
BackendRepr::SimdScalableVector { element, count, number_of_vectors },
dl.llvmlike_vector_align(size),
),
// Non-power-of-two vectors have padding up to the next power-of-two.
// If we're a packed repr, remove the padding while keeping the alignment as close
// to a vector as possible.
Expand Down
33 changes: 30 additions & 3 deletions compiler/rustc_abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1702,6 +1702,28 @@ impl AddressSpace {
pub const ZERO: Self = AddressSpace(0);
}

/// How many scalable vectors are in a `BackendRepr::ScalableVector`?
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
pub struct NumScalableVectors(pub u8);

impl NumScalableVectors {
/// Returns a `NumScalableVector` for a non-tuple scalable vector (e.g. a single vector).
pub fn for_non_tuple() -> Self {
NumScalableVectors(1)
}

// Returns `NumScalableVectors` for values of two through eight, which are a valid number of
// fields for a tuple of scalable vectors to have. `1` is a valid value of `NumScalableVectors`
// but not for a tuple which would have a field count.
pub fn from_field_count(count: usize) -> Option<Self> {
match count {
2..8 => Some(NumScalableVectors(count as u8)),
_ => None,
}
}
}

/// The way we represent values to the backend
///
/// Previously this was conflated with the "ABI" a type is given, as in the platform-specific ABI.
Expand All @@ -1720,6 +1742,7 @@ pub enum BackendRepr {
SimdScalableVector {
element: Scalar,
count: u64,
number_of_vectors: NumScalableVectors,
},
SimdVector {
element: Scalar,
Expand Down Expand Up @@ -1826,8 +1849,12 @@ impl BackendRepr {
BackendRepr::SimdVector { element: element.to_union(), count }
}
BackendRepr::Memory { .. } => BackendRepr::Memory { sized: true },
BackendRepr::SimdScalableVector { element, count } => {
BackendRepr::SimdScalableVector { element: element.to_union(), count }
BackendRepr::SimdScalableVector { element, count, number_of_vectors } => {
BackendRepr::SimdScalableVector {
element: element.to_union(),
count,
number_of_vectors,
}
}
}
}
Expand Down Expand Up @@ -2167,7 +2194,7 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {
}

/// Returns `true` if the size of the type is only known at runtime.
pub fn is_runtime_sized(&self) -> bool {
pub fn is_scalable_vector(&self) -> bool {
matches!(self.backend_repr, BackendRepr::SimdScalableVector { .. })
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2683,7 +2683,7 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
overly_complex_const(self)
}
ExprKind::Lit(literal) => {
let span = expr.span;
let span = self.lower_span(expr.span);
let literal = self.lower_lit(literal, span);

ConstArg {
Expand All @@ -2695,7 +2695,7 @@ impl<'hir, R: ResolverAstLoweringExt<'hir>> LoweringContext<'_, 'hir, R> {
ExprKind::Unary(UnOp::Neg, inner_expr)
if let ExprKind::Lit(literal) = &inner_expr.kind =>
{
let span = expr.span;
let span = self.lower_span(expr.span);
let literal = self.lower_lit(literal, span);

if !matches!(literal.node, LitKind::Int(..)) {
Expand Down
7 changes: 4 additions & 3 deletions compiler/rustc_codegen_gcc/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ use rustc_data_structures::fx::FxHashSet;
use rustc_middle::bug;
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
use rustc_middle::ty::layout::{
FnAbiError, FnAbiOfHelpers, FnAbiRequest, HasTyCtxt, HasTypingEnv, LayoutError, LayoutOfHelpers,
FnAbiError, FnAbiOfHelpers, FnAbiRequest, HasTyCtxt, HasTypingEnv, LayoutError,
LayoutOfHelpers, TyAndLayout,
};
use rustc_middle::ty::{self, AtomicOrdering, Instance, Ty, TyCtxt};
use rustc_span::Span;
Expand Down Expand Up @@ -943,8 +944,8 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
.get_address(self.location)
}

fn scalable_alloca(&mut self, _elt: u64, _align: Align, _element_ty: Ty<'_>) -> RValue<'gcc> {
todo!()
fn alloca_with_ty(&mut self, ty: TyAndLayout<'tcx>) -> RValue<'gcc> {
self.alloca(ty.layout.size, ty.layout.align.abi)
}

fn load(&mut self, pointee_ty: Type<'gcc>, ptr: RValue<'gcc>, align: Align) -> RValue<'gcc> {
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_codegen_gcc/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ impl<'gcc, 'tcx> ConstCodegenMethods for CodegenCx<'gcc, 'tcx> {
self.const_int(self.type_i32(), i as i64)
}

fn const_i64(&self, i: i64) -> RValue<'gcc> {
self.const_int(self.type_i64(), i)
}

fn const_int(&self, typ: Type<'gcc>, int: i64) -> RValue<'gcc> {
self.gcc_int(typ, int)
}
Expand Down
18 changes: 5 additions & 13 deletions compiler/rustc_codegen_llvm/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ pub(crate) mod autodiff;
pub(crate) mod gpu_offload;

use libc::{c_char, c_uint};
use rustc_abi as abi;
use rustc_abi::{Align, Size, WrappingRange};
use rustc_abi::{self as abi, Align, Size, WrappingRange};
use rustc_codegen_ssa::MemFlags;
use rustc_codegen_ssa::common::{IntPredicate, RealPredicate, SynchronizationScope, TypeKind};
use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue};
Expand Down Expand Up @@ -616,21 +615,14 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
}
}

fn scalable_alloca(&mut self, elt: u64, align: Align, element_ty: Ty<'_>) -> Self::Value {
fn alloca_with_ty(&mut self, layout: TyAndLayout<'tcx>) -> Self::Value {
let mut bx = Builder::with_cx(self.cx);
bx.position_at_start(unsafe { llvm::LLVMGetFirstBasicBlock(self.llfn()) });
let llvm_ty = match element_ty.kind() {
ty::Bool => bx.type_i1(),
ty::Int(int_ty) => self.cx.type_int_from_ty(*int_ty),
ty::Uint(uint_ty) => self.cx.type_uint_from_ty(*uint_ty),
ty::Float(float_ty) => self.cx.type_float_from_ty(*float_ty),
_ => unreachable!("scalable vectors can only contain a bool, int, uint or float"),
};
let scalable_vector_ty = layout.llvm_type(self.cx);

unsafe {
let ty = llvm::LLVMScalableVectorType(llvm_ty, elt.try_into().unwrap());
let alloca = llvm::LLVMBuildAlloca(&bx.llbuilder, ty, UNNAMED);
llvm::LLVMSetAlignment(alloca, align.bytes() as c_uint);
let alloca = llvm::LLVMBuildAlloca(&bx.llbuilder, scalable_vector_ty, UNNAMED);
llvm::LLVMSetAlignment(alloca, layout.align.abi.bytes() as c_uint);
alloca
}
}
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_codegen_llvm/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ impl<'ll, 'tcx> ConstCodegenMethods for CodegenCx<'ll, 'tcx> {
self.const_int(self.type_i32(), i as i64)
}

fn const_i64(&self, i: i64) -> &'ll Value {
self.const_int(self.type_i64(), i as i64)
}

fn const_int(&self, t: &'ll Type, i: i64) -> &'ll Value {
debug_assert!(
self.type_kind(t) == TypeKind::Integer,
Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_codegen_llvm/src/debuginfo/dwarf_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ declare_constant!(DW_OP_plus_uconst: u64);
/// Double-checked by a static assertion in `RustWrapper.cpp`.
#[allow(non_upper_case_globals)]
pub(crate) const DW_OP_LLVM_fragment: u64 = 0x1000;
#[allow(non_upper_case_globals)]
pub(crate) const DW_OP_constu: u64 = 0x10;
#[allow(non_upper_case_globals)]
pub(crate) const DW_OP_minus: u64 = 0x1c;
#[allow(non_upper_case_globals)]
pub(crate) const DW_OP_mul: u64 = 0x1e;
#[allow(non_upper_case_globals)]
pub(crate) const DW_OP_bregx: u64 = 0x92;
// It describes the actual value of a source variable which might not exist in registers or in memory.
#[allow(non_upper_case_globals)]
pub(crate) const DW_OP_stack_value: u64 = 0x9f;
Loading
Loading