Skip to content

Commit 562aeb4

Browse files
committed
Merge branch 'master' into sync_from_rust_2024_12_11
2 parents 691aec2 + eb87eab commit 562aeb4

16 files changed

+179
-32
lines changed

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ master = ["gccjit/master"]
2222
default = ["master"]
2323

2424
[dependencies]
25-
gccjit = "2.2"
25+
gccjit = "2.4"
2626
#gccjit = { git = "https://github.com/rust-lang/gccjit.rs" }
2727

2828
# Local copy.

build_system/src/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::collections::HashMap;
2-
use std::ffi::OsStr;
32
#[cfg(unix)]
43
use std::ffi::c_int;
4+
use std::ffi::OsStr;
55
use std::fmt::Debug;
66
use std::fs;
77
#[cfg(unix)]

libgccjit.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
e744a9459d33864067214741daf5c5bc2a7b88c6
1+
45648c2edd4ecd862d9f08196d3d6c6ccba79f07

patches/libgccjit12/0001-core-Disable-portable-simd-test.patch

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,4 @@ index b71786c..cf484d5 100644
2727
mod slice;
2828
mod str;
2929
mod str_lossy;
30-
--
31-
2.45.2
30+
-- 2.45.2

src/abi.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use gccjit::{ToLValue, ToRValue, Type};
44
use rustc_codegen_ssa::traits::{AbiBuilderMethods, BaseTypeCodegenMethods};
55
use rustc_data_structures::fx::FxHashSet;
66
use rustc_middle::bug;
7+
use rustc_middle::ty::layout::LayoutOf;
78
use rustc_middle::ty::Ty;
89
use rustc_middle::ty::layout::LayoutOf;
910
#[cfg(feature = "master")]

src/archive.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
use std::path::Path;
2+
3+
use rustc_codegen_ssa::back::archive::{
4+
ArArchiveBuilder, ArchiveBuilder, ArchiveBuilderBuilder, DEFAULT_OBJECT_READER,
5+
};
6+
use rustc_session::Session;
7+
8+
pub(crate) struct ArArchiveBuilderBuilder;
9+
10+
impl ArchiveBuilderBuilder for ArArchiveBuilderBuilder {
11+
fn new_archive_builder<'a>(&self, sess: &'a Session) -> Box<dyn ArchiveBuilder + 'a> {
12+
Box::new(ArArchiveBuilder::new(sess, &DEFAULT_OBJECT_READER))
13+
}
14+
15+
fn create_dll_import_lib(
16+
&self,
17+
_sess: &Session,
18+
_lib_name: &str,
19+
_import_name_and_ordinal_vector: Vec<(String, Option<u16>)>,
20+
_output_path: &Path,
21+
) {
22+
unimplemented!("creating dll imports is not yet supported");
23+
}
24+
}

src/base.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,12 +199,13 @@ pub fn compile_codegen_unit(
199199
let f32_type_supported = target_info.supports_target_dependent_type(CType::Float32);
200200
let f64_type_supported = target_info.supports_target_dependent_type(CType::Float64);
201201
let f128_type_supported = target_info.supports_target_dependent_type(CType::Float128);
202+
let u128_type_supported = target_info.supports_target_dependent_type(CType::UInt128t);
202203
// TODO: improve this to avoid passing that many arguments.
203204
let cx = CodegenCx::new(
204205
&context,
205206
cgu,
206207
tcx,
207-
target_info.supports_128bit_int(),
208+
u128_type_supported,
208209
f16_type_supported,
209210
f32_type_supported,
210211
f64_type_supported,

src/builder.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,18 +1102,24 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
11021102
val: RValue<'gcc>,
11031103
ptr: RValue<'gcc>,
11041104
align: Align,
1105-
_flags: MemFlags,
1105+
flags: MemFlags,
11061106
) -> RValue<'gcc> {
11071107
let ptr = self.check_store(val, ptr);
11081108
let destination = ptr.dereference(self.location);
11091109
// NOTE: libgccjit does not support specifying the alignment on the assignment, so we cast
11101110
// to type so it gets the proper alignment.
11111111
let destination_type = destination.to_rvalue().get_type().unqualified();
1112-
let aligned_type = destination_type.get_aligned(align.bytes()).make_pointer();
1113-
let aligned_destination = self.cx.context.new_bitcast(self.location, ptr, aligned_type);
1114-
let aligned_destination = aligned_destination.dereference(self.location);
1115-
self.llbb().add_assignment(self.location, aligned_destination, val);
1116-
// TODO(antoyo): handle align and flags.
1112+
let align = if flags.contains(MemFlags::UNALIGNED) { 1 } else { align.bytes() };
1113+
let mut modified_destination_type = destination_type.get_aligned(align);
1114+
if flags.contains(MemFlags::VOLATILE) {
1115+
modified_destination_type = modified_destination_type.make_volatile();
1116+
}
1117+
1118+
let modified_ptr =
1119+
self.cx.context.new_cast(self.location, ptr, modified_destination_type.make_pointer());
1120+
let modified_destination = modified_ptr.dereference(self.location);
1121+
self.llbb().add_assignment(self.location, modified_destination, val);
1122+
// TODO(antoyo): handle `MemFlags::NONTEMPORAL`.
11171123
// NOTE: dummy value here since it's never used. FIXME(antoyo): API should not return a value here?
11181124
// When adding support for NONTEMPORAL, make sure to not just emit MOVNT on x86; see the
11191125
// LLVM backend for details.
@@ -1236,13 +1242,13 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
12361242
}
12371243

12381244
fn ptrtoint(&mut self, value: RValue<'gcc>, dest_ty: Type<'gcc>) -> RValue<'gcc> {
1239-
let usize_value = self.cx.const_bitcast(value, self.cx.type_isize());
1245+
let usize_value = self.cx.context.new_cast(None, value, self.cx.type_isize());
12401246
self.intcast(usize_value, dest_ty, false)
12411247
}
12421248

12431249
fn inttoptr(&mut self, value: RValue<'gcc>, dest_ty: Type<'gcc>) -> RValue<'gcc> {
12441250
let usize_value = self.intcast(value, self.cx.type_isize(), false);
1245-
self.cx.const_bitcast(usize_value, dest_ty)
1251+
self.cx.context.new_cast(None, usize_value, dest_ty)
12461252
}
12471253

12481254
fn bitcast(&mut self, value: RValue<'gcc>, dest_ty: Type<'gcc>) -> RValue<'gcc> {

src/common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,10 @@ impl<'gcc, 'tcx> ConstCodegenMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
240240
}
241241
};
242242
let ptr_type = base_addr.get_type();
243-
let base_addr = self.const_bitcast(base_addr, self.usize_type);
243+
let base_addr = self.context.new_cast(None, base_addr, self.usize_type);
244244
let offset =
245245
self.context.new_rvalue_from_long(self.usize_type, offset.bytes() as i64);
246-
let ptr = self.const_bitcast(base_addr + offset, ptr_type);
246+
let ptr = self.context.new_cast(None, base_addr + offset, ptr_type);
247247
if !matches!(layout.primitive(), Pointer(_)) {
248248
self.const_bitcast(ptr.dereference(None).to_rvalue(), ty)
249249
} else {

0 commit comments

Comments
 (0)