Skip to content

Commit 40456ae

Browse files
eddybLegNeato
authored andcommitted
rustup: update to nightly-2024-03-11.
1 parent cc75231 commit 40456ae

19 files changed

+92
-130
lines changed

crates/rustc_codegen_spirv/build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ use std::process::{Command, ExitCode};
1010
/// `cargo publish`. We need to figure out a way to do this properly, but let's hardcode it for now :/
1111
//const REQUIRED_RUST_TOOLCHAIN: &str = include_str!("../../rust-toolchain.toml");
1212
const REQUIRED_RUST_TOOLCHAIN: &str = r#"[toolchain]
13-
channel = "nightly-2024-03-01"
13+
channel = "nightly-2024-03-11"
1414
components = ["rust-src", "rustc-dev", "llvm-tools"]
15-
# commit_hash = 878c8a2a62d49ca5c454547ad67290a1df746cb5"#;
15+
# commit_hash = 3b1717c052de4a2dbdd3badb0e7a885f40a8ad9e"#;
1616

1717
fn get_rustc_commit_hash() -> Result<String, Box<dyn Error>> {
1818
let rustc = std::env::var("RUSTC").unwrap_or_else(|_| String::from("rustc"));

crates/rustc_codegen_spirv/src/abi.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,8 +505,10 @@ fn trans_scalar<'tcx>(
505505
Primitive::Int(width, signedness) => {
506506
SpirvType::Integer(width.size().bits() as u32, signedness).def(span, cx)
507507
}
508+
Primitive::F16 => SpirvType::Float(16).def(span, cx),
508509
Primitive::F32 => SpirvType::Float(32).def(span, cx),
509510
Primitive::F64 => SpirvType::Float(64).def(span, cx),
511+
Primitive::F128 => SpirvType::Float(128).def(span, cx),
510512
Primitive::Pointer(_) => {
511513
let pointee_ty = dig_scalar_pointee(cx, ty, offset);
512514
// Pointers can be recursive. So, record what we're currently translating, and if we're already translating

crates/rustc_codegen_spirv/src/builder/builder_methods.rs

Lines changed: 5 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,9 +1465,12 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
14651465
.size(self)
14661466
.align_to(b.primitive().align(self).abi);
14671467

1468-
let pair_ty = place.layout.spirv_type(self.span(), self);
14691468
let mut load = |i, scalar: Scalar, align| {
1470-
let llptr = self.struct_gep(pair_ty, place.llval, i as u64);
1469+
let llptr = if i == 0 {
1470+
place.llval
1471+
} else {
1472+
self.inbounds_ptradd(place.llval, self.const_usize(b_offset.bytes()))
1473+
};
14711474
let load = self.load(
14721475
self.scalar_pair_element_backend_type(place.layout, i, false),
14731476
llptr,
@@ -1581,79 +1584,6 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
15811584
self.maybe_inbounds_gep(ty, ptr, indices, true)
15821585
}
15831586

1584-
fn struct_gep(&mut self, ty: Self::Type, ptr: Self::Value, idx: u64) -> Self::Value {
1585-
let (offset, result_pointee_type) = match self.lookup_type(ty) {
1586-
SpirvType::Adt {
1587-
field_offsets,
1588-
field_types,
1589-
..
1590-
} => (field_offsets[idx as usize], field_types[idx as usize]),
1591-
SpirvType::Array { element, .. }
1592-
| SpirvType::RuntimeArray { element, .. }
1593-
| SpirvType::Vector { element, .. }
1594-
| SpirvType::Matrix { element, .. } => (
1595-
self.lookup_type(element).sizeof(self).unwrap() * idx,
1596-
element,
1597-
),
1598-
SpirvType::InterfaceBlock { inner_type } => {
1599-
assert_eq!(idx, 0);
1600-
(Size::ZERO, inner_type)
1601-
}
1602-
other => self.fatal(format!(
1603-
"struct_gep not on struct, array, or vector type: {other:?}, index {idx}"
1604-
)),
1605-
};
1606-
let result_pointee_size = self.lookup_type(result_pointee_type).sizeof(self);
1607-
let result_type = self.type_ptr_to(result_pointee_type);
1608-
1609-
// Special-case field accesses through a `pointercast`, to accesss the
1610-
// right field in the original type, for the `Logical` addressing model.
1611-
let ptr = ptr.strip_ptrcasts();
1612-
let original_pointee_ty = match self.lookup_type(ptr.ty) {
1613-
SpirvType::Pointer { pointee } => pointee,
1614-
other => self.fatal(format!("struct_gep called on non-pointer type: {other:?}")),
1615-
};
1616-
if let Some((indices, _)) = self.recover_access_chain_from_offset(
1617-
original_pointee_ty,
1618-
offset,
1619-
result_pointee_size..=result_pointee_size,
1620-
Some(result_pointee_type),
1621-
) {
1622-
let original_ptr = ptr.def(self);
1623-
let indices = indices
1624-
.into_iter()
1625-
.map(|idx| self.constant_u32(self.span(), idx).def(self))
1626-
.collect::<Vec<_>>();
1627-
return self
1628-
.emit()
1629-
.in_bounds_access_chain(result_type, None, original_ptr, indices)
1630-
.unwrap()
1631-
.with_type(result_type);
1632-
}
1633-
1634-
// FIXME(eddyb) can we even get to this point, with valid SPIR-V?
1635-
1636-
// HACK(eddyb) temporary workaround for untyped pointers upstream.
1637-
// FIXME(eddyb) replace with untyped memory SPIR-V + `qptr` or similar.
1638-
let ptr = self.pointercast(ptr, self.type_ptr_to(ty));
1639-
1640-
// Important! LLVM, and therefore intel-compute-runtime, require the `getelementptr` instruction (and therefore
1641-
// OpAccessChain) on structs to be a constant i32. Not i64! i32.
1642-
if idx > u32::MAX as u64 {
1643-
self.fatal("struct_gep bigger than u32::MAX");
1644-
}
1645-
let index_const = self.constant_u32(self.span(), idx as u32).def(self);
1646-
self.emit()
1647-
.in_bounds_access_chain(
1648-
result_type,
1649-
None,
1650-
ptr.def(self),
1651-
[index_const].iter().cloned(),
1652-
)
1653-
.unwrap()
1654-
.with_type(result_type)
1655-
}
1656-
16571587
// intcast has the logic for dealing with bools, so use that
16581588
fn trunc(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value {
16591589
self.intcast(val, dest_ty, false)

crates/rustc_codegen_spirv/src/builder/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use rustc_codegen_ssa::traits::{
2020
AbiBuilderMethods, ArgAbiMethods, BackendTypes, BuilderMethods, CoverageInfoBuilderMethods,
2121
DebugInfoBuilderMethods, HasCodegen, StaticBuilderMethods, TypeMembershipMethods,
2222
};
23-
use rustc_errors::{Diag, DiagnosticMessage};
23+
use rustc_errors::{Diag, DiagMessage};
2424
use rustc_middle::mir::Coverage;
2525
use rustc_middle::span_bug;
2626
use rustc_middle::ty::layout::{
@@ -69,7 +69,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
6969
}
7070

7171
#[track_caller]
72-
pub fn struct_err(&self, msg: impl Into<DiagnosticMessage>) -> Diag<'_> {
72+
pub fn struct_err(&self, msg: impl Into<DiagMessage>) -> Diag<'_> {
7373
if let Some(current_span) = self.current_span {
7474
self.tcx.dcx().struct_span_err(current_span, msg)
7575
} else {
@@ -78,7 +78,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
7878
}
7979

8080
#[track_caller]
81-
pub fn err(&self, msg: impl Into<DiagnosticMessage>) {
81+
pub fn err(&self, msg: impl Into<DiagMessage>) {
8282
if let Some(current_span) = self.current_span {
8383
self.tcx.dcx().span_err(current_span, msg);
8484
} else {
@@ -87,7 +87,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
8787
}
8888

8989
#[track_caller]
90-
pub fn fatal(&self, msg: impl Into<DiagnosticMessage>) -> ! {
90+
pub fn fatal(&self, msg: impl Into<DiagMessage>) -> ! {
9191
if let Some(current_span) = self.current_span {
9292
self.tcx.dcx().span_fatal(current_span, msg)
9393
} else {

crates/rustc_codegen_spirv/src/builder/spirv_asm.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ impl<'a, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'tcx> {
5858
options: InlineAsmOptions,
5959
_line_spans: &[Span],
6060
_instance: Instance<'_>,
61-
_dest_catch_funclet: Option<(Self::BasicBlock, Self::BasicBlock, Option<&Self::Funclet>)>,
61+
_dest: Option<Self::BasicBlock>,
62+
_catch_funclet: Option<(Self::BasicBlock, Option<&Self::Funclet>)>,
6263
) {
6364
const SUPPORTED_OPTIONS: InlineAsmOptions = InlineAsmOptions::NORETURN;
6465
let unsupported_options = options & !SUPPORTED_OPTIONS;
@@ -889,6 +890,12 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
889890
.span_err(span, "cannot write to static variable asm argument");
890891
None
891892
}
893+
InlineAsmOperandRef::Label { label: _ } => {
894+
self.tcx
895+
.dcx()
896+
.span_err(span, "cannot write to label asm argument");
897+
None
898+
}
892899
},
893900
}
894901
}
@@ -988,6 +995,12 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
988995
);
989996
None
990997
}
998+
InlineAsmOperandRef::Label { label: _ } => {
999+
self.tcx
1000+
.dcx()
1001+
.span_err(span, "cannot take the type of a label asm argument");
1002+
None
1003+
}
9911004
},
9921005
Token::Placeholder(hole, span) => match hole {
9931006
InlineAsmOperandRef::In { reg, value } => {
@@ -1032,6 +1045,12 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
10321045
.span_err(span, "static variable asm argument not supported yet");
10331046
None
10341047
}
1048+
InlineAsmOperandRef::Label { label: _ } => {
1049+
self.tcx
1050+
.dcx()
1051+
.span_err(span, "label asm argument not supported yet");
1052+
None
1053+
}
10351054
},
10361055
}
10371056
}

crates/rustc_codegen_spirv/src/codegen_cx/constant.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,10 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> {
265265
other.debug(ty, self)
266266
)),
267267
},
268+
Primitive::F16 => self
269+
.tcx
270+
.dcx()
271+
.fatal("scalar_to_backend Primitive::F16 not supported"),
268272
Primitive::F32 => {
269273
let res = self.constant_f32(DUMMY_SP, f32::from_bits(data as u32));
270274
assert_eq!(res.ty, ty);
@@ -275,6 +279,10 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> {
275279
assert_eq!(res.ty, ty);
276280
res
277281
}
282+
Primitive::F128 => self
283+
.tcx
284+
.dcx()
285+
.fatal("scalar_to_backend Primitive::F128 not supported"),
278286
Primitive::Pointer(_) => {
279287
if data == 0 {
280288
self.constant_null(ty)

crates/rustc_codegen_spirv/src/codegen_cx/entry.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -505,11 +505,18 @@ impl<'tcx> CodegenCx<'tcx> {
505505
.def(hir_param.span, self);
506506
var_ptr_spirv_type = self.type_ptr_to(var_spirv_type);
507507

508-
let value_ptr = bx.struct_gep(
509-
var_spirv_type,
510-
var_id.unwrap().with_type(var_ptr_spirv_type),
511-
0,
512-
);
508+
let zero_u32 = self.constant_u32(hir_param.span, 0).def_cx(self);
509+
let value_ptr_spirv_type = self.type_ptr_to(value_spirv_type);
510+
let value_ptr = bx
511+
.emit()
512+
.in_bounds_access_chain(
513+
value_ptr_spirv_type,
514+
None,
515+
var_id.unwrap(),
516+
[zero_u32].iter().cloned(),
517+
)
518+
.unwrap()
519+
.with_type(value_ptr_spirv_type);
513520

514521
let value_len = if is_unsized_with_len {
515522
match self.lookup_type(value_spirv_type) {

crates/rustc_codegen_spirv/src/codegen_cx/type_.rs

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc_middle::{bug, span_bug};
1212
use rustc_span::source_map::Spanned;
1313
use rustc_span::{Span, DUMMY_SP};
1414
use rustc_target::abi::call::{CastTarget, FnAbi, Reg};
15-
use rustc_target::abi::{Abi, AddressSpace, FieldsShape};
15+
use rustc_target::abi::{Abi, AddressSpace};
1616

1717
impl<'tcx> LayoutOfHelpers<'tcx> for CodegenCx<'tcx> {
1818
type LayoutOfResult = TyAndLayout<'tcx>;
@@ -107,23 +107,6 @@ impl<'tcx> LayoutTypeMethods<'tcx> for CodegenCx<'tcx> {
107107
}
108108
}
109109

110-
fn backend_field_index(&self, layout: TyAndLayout<'tcx>, index: usize) -> u64 {
111-
match layout.abi {
112-
Abi::Scalar(_) | Abi::ScalarPair(..) => {
113-
bug!("backend_field_index({:?}): not applicable", layout);
114-
}
115-
_ => {}
116-
}
117-
match layout.fields {
118-
FieldsShape::Primitive | FieldsShape::Union(_) => {
119-
bug!("backend_field_index({:?}): not applicable", layout)
120-
}
121-
FieldsShape::Array { .. } => index as u64,
122-
// note: codegen_llvm implements this as 1+index*2 due to padding fields
123-
FieldsShape::Arbitrary { .. } => layout.fields.memory_index(index) as u64,
124-
}
125-
}
126-
127110
fn scalar_pair_element_backend_type(
128111
&self,
129112
layout: TyAndLayout<'tcx>,
@@ -165,12 +148,18 @@ impl<'tcx> BaseTypeMethods<'tcx> for CodegenCx<'tcx> {
165148
SpirvType::Integer(ptr_size, false).def(DUMMY_SP, self)
166149
}
167150

151+
fn type_f16(&self) -> Self::Type {
152+
SpirvType::Float(16).def(DUMMY_SP, self)
153+
}
168154
fn type_f32(&self) -> Self::Type {
169155
SpirvType::Float(32).def(DUMMY_SP, self)
170156
}
171157
fn type_f64(&self) -> Self::Type {
172158
SpirvType::Float(64).def(DUMMY_SP, self)
173159
}
160+
fn type_f128(&self) -> Self::Type {
161+
SpirvType::Float(128).def(DUMMY_SP, self)
162+
}
174163

175164
fn type_array(&self, ty: Self::Type, len: u64) -> Self::Type {
176165
SpirvType::Array {
@@ -209,6 +198,7 @@ impl<'tcx> BaseTypeMethods<'tcx> for CodegenCx<'tcx> {
209198
16 => TypeKind::Half,
210199
32 => TypeKind::Float,
211200
64 => TypeKind::Double,
201+
128 => TypeKind::FP128,
212202
other => self
213203
.tcx
214204
.dcx()

crates/rustc_codegen_spirv/src/linker/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,9 @@ pub fn link(
647647
entry.insert((entry_name, module));
648648
break;
649649
}
650+
// FIXME(eddyb) false positive: `file_stem` was moved out of,
651+
// so assigning it is necessary, but clippy doesn't know that.
652+
#[allow(clippy::assigning_clones)]
650653
Entry::Occupied(entry) => {
651654
// FIXME(eddyb) there's no way to access the owned key
652655
// passed to `BTreeMap::entry` from `OccupiedEntry`.

crates/rustc_codegen_spirv/src/linker/test.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -122,20 +122,17 @@ fn link_with_linker_opts(
122122
// is really a silent unwinding device, that should be treated the same as
123123
// `Err(ErrorGuaranteed)` returns from `link`).
124124
rustc_driver::catch_fatal_errors(|| {
125-
let mut early_error_handler =
125+
let mut early_dcx =
126126
rustc_session::EarlyDiagCtxt::new(rustc_session::config::ErrorOutputType::default());
127-
early_error_handler.initialize_checked_jobserver();
128-
let matches = rustc_driver::handle_options(
129-
&early_error_handler,
130-
&["".to_string(), "x.rs".to_string()],
131-
)
132-
.unwrap();
133-
let sopts =
134-
rustc_session::config::build_session_options(&mut early_error_handler, &matches);
127+
early_dcx.initialize_checked_jobserver();
128+
let matches =
129+
rustc_driver::handle_options(&early_dcx, &["".to_string(), "x.rs".to_string()])
130+
.unwrap();
131+
let sopts = rustc_session::config::build_session_options(&mut early_dcx, &matches);
135132

136133
rustc_span::create_session_globals_then(sopts.edition, || {
137134
let mut sess = rustc_session::build_session(
138-
early_error_handler,
135+
early_dcx,
139136
sopts,
140137
CompilerIO {
141138
input: Input::Str {
@@ -160,7 +157,7 @@ fn link_with_linker_opts(
160157

161158
// HACK(eddyb) inject `write_diags` into `sess`, to work around
162159
// the removals in https://github.com/rust-lang/rust/pull/102992.
163-
sess.parse_sess.dcx = {
160+
sess.psess.dcx = {
164161
let fallback_bundle = {
165162
extern crate rustc_error_messages;
166163
rustc_error_messages::fallback_fluent_bundle(
@@ -170,7 +167,7 @@ fn link_with_linker_opts(
170167
};
171168
let emitter =
172169
rustc_errors::emitter::HumanEmitter::new(Box::new(buf), fallback_bundle)
173-
.sm(Some(sess.parse_sess.clone_source_map()));
170+
.sm(Some(sess.psess.clone_source_map()));
174171

175172
rustc_errors::DiagCtxt::new(Box::new(emitter))
176173
.with_flags(sess.opts.unstable_opts.dcx_flags(true))

0 commit comments

Comments
 (0)