Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit bdb8cb4

Browse files
committedNov 20, 2023
Auto merge of rust-lang#118078 - compiler-errors:rollup-8ln8dvl, r=compiler-errors
Rollup of 8 pull requests Successful merges: - rust-lang#115526 (Add arm64e-apple-ios & arm64e-apple-darwin targets) - rust-lang#115691 (Add `$message_type` field to distinguish json diagnostic outputs) - rust-lang#117828 (Avoid iterating over hashmaps in astconv) - rust-lang#117832 (interpret: simplify handling of shifts by no longer trying to handle signed and unsigned shift amounts in the same branch) - rust-lang#117891 (Recover `dyn` and `impl` after `for<...>`) - rust-lang#117957 (if available use a Child's pidfd for kill/wait) - rust-lang#117994 (Ignore but do not assume region obligations from unifying headers in negative coherence) - rust-lang#118068 (subtree update cg_gcc 2023/11/17) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 4f3da90 + ad735c9 commit bdb8cb4

File tree

64 files changed

+713
-219
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+713
-219
lines changed
 

‎compiler/rustc_codegen_gcc/src/base.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use std::env;
33
use std::time::Instant;
44

55
use gccjit::{
6-
Context,
76
FunctionType,
87
GlobalKind,
98
};
@@ -18,8 +17,9 @@ use rustc_codegen_ssa::mono_item::MonoItemExt;
1817
use rustc_codegen_ssa::traits::DebugInfoMethods;
1918
use rustc_session::config::DebugInfo;
2019
use rustc_span::Symbol;
20+
use rustc_target::spec::PanicStrategy;
2121

22-
use crate::{LockedTargetInfo, gcc_util};
22+
use crate::{LockedTargetInfo, gcc_util, new_context};
2323
use crate::GccContext;
2424
use crate::builder::Builder;
2525
use crate::context::CodegenCx;
@@ -88,20 +88,18 @@ pub fn compile_codegen_unit(tcx: TyCtxt<'_>, cgu_name: Symbol, target_info: Lock
8888
fn module_codegen(tcx: TyCtxt<'_>, (cgu_name, target_info): (Symbol, LockedTargetInfo)) -> ModuleCodegen<GccContext> {
8989
let cgu = tcx.codegen_unit(cgu_name);
9090
// Instantiate monomorphizations without filling out definitions yet...
91-
let context = Context::default();
91+
let context = new_context(tcx);
9292

93-
context.add_command_line_option("-fexceptions");
94-
context.add_driver_option("-fexceptions");
93+
if tcx.sess.panic_strategy() == PanicStrategy::Unwind {
94+
context.add_command_line_option("-fexceptions");
95+
context.add_driver_option("-fexceptions");
96+
}
9597

9698
let disabled_features: HashSet<_> = tcx.sess.opts.cg.target_feature.split(',')
9799
.filter(|feature| feature.starts_with('-'))
98100
.map(|string| &string[1..])
99101
.collect();
100102

101-
if tcx.sess.target.arch == "x86" || tcx.sess.target.arch == "x86_64" {
102-
context.add_command_line_option("-masm=intel");
103-
}
104-
105103
if !disabled_features.contains("avx") && tcx.sess.target.arch == "x86_64" {
106104
// NOTE: we always enable AVX because the equivalent of llvm.x86.sse2.cmp.pd in GCC for
107105
// SSE2 is multiple builtins, so we use the AVX __builtin_ia32_cmppd instead.

‎compiler/rustc_codegen_gcc/src/int.rs

+22-3
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
7676
a >> b
7777
}
7878
}
79+
else if a_type.is_vector() && a_type.is_vector() {
80+
a >> b
81+
}
7982
else if a_native && !b_native {
8083
self.gcc_lshr(a, self.gcc_int_cast(b, a_type))
8184
}
@@ -144,7 +147,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
144147
fn additive_operation(&self, operation: BinaryOp, a: RValue<'gcc>, mut b: RValue<'gcc>) -> RValue<'gcc> {
145148
let a_type = a.get_type();
146149
let b_type = b.get_type();
147-
if self.is_native_int_type_or_bool(a_type) && self.is_native_int_type_or_bool(b_type) {
150+
if (self.is_native_int_type_or_bool(a_type) && self.is_native_int_type_or_bool(b_type)) || (a_type.is_vector() && b_type.is_vector()) {
148151
if a_type != b_type {
149152
if a_type.is_vector() {
150153
// Vector types need to be bitcast.
@@ -158,6 +161,8 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
158161
self.context.new_binary_op(None, operation, a_type, a, b)
159162
}
160163
else {
164+
debug_assert!(a_type.dyncast_array().is_some());
165+
debug_assert!(b_type.dyncast_array().is_some());
161166
let signed = a_type.is_compatible_with(self.i128_type);
162167
let func_name =
163168
match (operation, signed) {
@@ -189,10 +194,12 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
189194
fn multiplicative_operation(&self, operation: BinaryOp, operation_name: &str, signed: bool, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
190195
let a_type = a.get_type();
191196
let b_type = b.get_type();
192-
if self.is_native_int_type_or_bool(a_type) && self.is_native_int_type_or_bool(b_type) {
197+
if (self.is_native_int_type_or_bool(a_type) && self.is_native_int_type_or_bool(b_type)) || (a_type.is_vector() && b_type.is_vector()) {
193198
self.context.new_binary_op(None, operation, a_type, a, b)
194199
}
195200
else {
201+
debug_assert!(a_type.dyncast_array().is_some());
202+
debug_assert!(b_type.dyncast_array().is_some());
196203
let sign =
197204
if signed {
198205
""
@@ -337,6 +344,8 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
337344
pub fn operation_with_overflow(&self, func_name: &str, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> (RValue<'gcc>, RValue<'gcc>) {
338345
let a_type = lhs.get_type();
339346
let b_type = rhs.get_type();
347+
debug_assert!(a_type.dyncast_array().is_some());
348+
debug_assert!(b_type.dyncast_array().is_some());
340349
let param_a = self.context.new_parameter(None, a_type, "a");
341350
let param_b = self.context.new_parameter(None, b_type, "b");
342351
let result_field = self.context.new_field(None, a_type, "result");
@@ -496,7 +505,11 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
496505
pub fn gcc_xor(&self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
497506
let a_type = a.get_type();
498507
let b_type = b.get_type();
499-
if self.is_native_int_type_or_bool(a_type) && self.is_native_int_type_or_bool(b_type) {
508+
if a_type.is_vector() && b_type.is_vector() {
509+
let b = self.bitcast_if_needed(b, a_type);
510+
a ^ b
511+
}
512+
else if self.is_native_int_type_or_bool(a_type) && self.is_native_int_type_or_bool(b_type) {
500513
a ^ b
501514
}
502515
else {
@@ -527,6 +540,9 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
527540
a << b
528541
}
529542
}
543+
else if a_type.is_vector() && a_type.is_vector() {
544+
a << b
545+
}
530546
else if a_native && !b_native {
531547
self.gcc_shl(a, self.gcc_int_cast(b, a_type))
532548
}
@@ -690,6 +706,7 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
690706
let a_native = self.is_native_int_type_or_bool(a_type);
691707
let b_native = self.is_native_int_type_or_bool(b_type);
692708
if a_type.is_vector() && b_type.is_vector() {
709+
let b = self.bitcast_if_needed(b, a_type);
693710
self.context.new_binary_op(None, operation, a_type, a, b)
694711
}
695712
else if a_native && b_native {
@@ -748,6 +765,7 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
748765
return self.context.new_cast(None, value, dest_typ);
749766
}
750767

768+
debug_assert!(value_type.dyncast_array().is_some());
751769
let name_suffix =
752770
match self.type_kind(dest_typ) {
753771
TypeKind::Float => "tisf",
@@ -781,6 +799,7 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
781799
return self.context.new_cast(None, value, dest_typ);
782800
}
783801

802+
debug_assert!(value_type.dyncast_array().is_some());
784803
let name_suffix =
785804
match self.type_kind(value_type) {
786805
TypeKind::Float => "sfti",
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Failed to load comments.