Fix formatting

This commit is contained in:
Antoni Boucher 2024-03-05 08:33:42 -05:00
parent b76515708b
commit cd75da1f2c
5 changed files with 87 additions and 56 deletions

View File

@ -1018,19 +1018,21 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
let llty = place.layout.scalar_pair_element_gcc_type(self, i); let llty = place.layout.scalar_pair_element_gcc_type(self, i);
let load = self.load(llty, llptr, align); let load = self.load(llty, llptr, align);
scalar_load_metadata(self, load, scalar); scalar_load_metadata(self, load, scalar);
if scalar.is_bool() { self.trunc(load, self.type_i1()) } else { load } if scalar.is_bool() {
self.trunc(load, self.type_i1())
} else {
load
}
}; };
OperandValue::Pair( OperandValue::Pair(
load(0, a, place.align), load(0, a, place.align),
load(1, b, place.align.restrict_for_offset(b_offset)), load(1, b, place.align.restrict_for_offset(b_offset)),
) )
} } else {
else {
OperandValue::Ref(place.llval, None, place.align) OperandValue::Ref(place.llval, None, place.align)
}; };
OperandRef { val, layout: place.layout } OperandRef { val, layout: place.layout }
} }
@ -2075,7 +2077,11 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
self.vector_reduce(src, |a, b, context| context.new_binary_op(loc, op, a.get_type(), a, b)) self.vector_reduce(src, |a, b, context| context.new_binary_op(loc, op, a.get_type(), a, b))
} }
pub fn vector_reduce_fadd_reassoc(&mut self, _acc: RValue<'gcc>, _src: RValue<'gcc>) -> RValue<'gcc> { pub fn vector_reduce_fadd_reassoc(
&mut self,
_acc: RValue<'gcc>,
_src: RValue<'gcc>,
) -> RValue<'gcc> {
unimplemented!(); unimplemented!();
} }
@ -2102,7 +2108,11 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
unimplemented!(); unimplemented!();
} }
pub fn vector_reduce_fmul_reassoc(&mut self, _acc: RValue<'gcc>, _src: RValue<'gcc>) -> RValue<'gcc> { pub fn vector_reduce_fmul_reassoc(
&mut self,
_acc: RValue<'gcc>,
_src: RValue<'gcc>,
) -> RValue<'gcc> {
unimplemented!(); unimplemented!();
} }

View File

@ -1,6 +1,4 @@
use rustc_errors::{ use rustc_errors::{Diag, DiagCtxt, EmissionGuarantee, IntoDiagnostic, Level};
DiagCtxt, Diag, EmissionGuarantee, IntoDiagnostic, Level,
};
use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_span::Span; use rustc_span::Span;

View File

@ -22,10 +22,10 @@ use rustc_middle::bug;
use rustc_middle::ty::layout::LayoutOf; use rustc_middle::ty::layout::LayoutOf;
#[cfg(feature = "master")] #[cfg(feature = "master")]
use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt}; use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt};
use rustc_span::{Span, Symbol, sym};
use rustc_target::abi::HasDataLayout;
use rustc_middle::ty::{self, Instance, Ty}; use rustc_middle::ty::{self, Instance, Ty};
use rustc_span::{sym, Span, Symbol};
use rustc_target::abi::call::{ArgAbi, FnAbi, PassMode}; use rustc_target::abi::call::{ArgAbi, FnAbi, PassMode};
use rustc_target::abi::HasDataLayout;
#[cfg(feature = "master")] #[cfg(feature = "master")]
use rustc_target::spec::abi::Abi; use rustc_target::spec::abi::Abi;
use rustc_target::spec::PanicStrategy; use rustc_target::spec::PanicStrategy;
@ -122,44 +122,46 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
let result = PlaceRef::new_sized(llresult, fn_abi.ret.layout); let result = PlaceRef::new_sized(llresult, fn_abi.ret.layout);
let simple = get_simple_intrinsic(self, name); let simple = get_simple_intrinsic(self, name);
let llval = let llval = match name {
match name { _ if simple.is_some() => {
_ if simple.is_some() => { // FIXME(antoyo): remove this cast when the API supports function.
// FIXME(antoyo): remove this cast when the API supports function. let func = unsafe { std::mem::transmute(simple.expect("simple")) };
let func = unsafe { std::mem::transmute(simple.expect("simple")) }; self.call(
self.call(self.type_void(), None, None, func, &args.iter().map(|arg| arg.immediate()).collect::<Vec<_>>(), None) self.type_void(),
}, None,
sym::likely => { None,
self.expect(args[0].immediate(), true) func,
} &args.iter().map(|arg| arg.immediate()).collect::<Vec<_>>(),
sym::unlikely => { None,
self.expect(args[0].immediate(), false) )
} }
sym::is_val_statically_known => { sym::likely => self.expect(args[0].immediate(), true),
let a = args[0].immediate(); sym::unlikely => self.expect(args[0].immediate(), false),
let builtin = self.context.get_builtin_function("__builtin_constant_p"); sym::is_val_statically_known => {
let res = self.context.new_call(None, builtin, &[a]); let a = args[0].immediate();
self.icmp(IntPredicate::IntEQ, res, self.const_i32(0)) let builtin = self.context.get_builtin_function("__builtin_constant_p");
} let res = self.context.new_call(None, builtin, &[a]);
sym::catch_unwind => { self.icmp(IntPredicate::IntEQ, res, self.const_i32(0))
try_intrinsic( }
self, sym::catch_unwind => {
args[0].immediate(), try_intrinsic(
args[1].immediate(), self,
args[2].immediate(), args[0].immediate(),
llresult, args[1].immediate(),
); args[2].immediate(),
return Ok(()); llresult,
} );
sym::breakpoint => { return Ok(());
unimplemented!(); }
} sym::breakpoint => {
sym::va_copy => { unimplemented!();
unimplemented!(); }
} sym::va_copy => {
sym::va_arg => { unimplemented!();
unimplemented!(); }
} sym::va_arg => {
unimplemented!();
}
sym::volatile_load | sym::unaligned_volatile_load => { sym::volatile_load | sym::unaligned_volatile_load => {
let tp_ty = fn_args.type_at(0); let tp_ty = fn_args.type_at(0);

View File

@ -123,7 +123,7 @@ impl<'gcc, 'tcx> BaseTypeMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
fn type_f16(&self) -> Type<'gcc> { fn type_f16(&self) -> Type<'gcc> {
unimplemented!("f16_f128") unimplemented!("f16_f128")
} }
fn type_f32(&self) -> Type<'gcc> { fn type_f32(&self) -> Type<'gcc> {
self.float_type self.float_type
} }
@ -131,7 +131,7 @@ impl<'gcc, 'tcx> BaseTypeMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
fn type_f64(&self) -> Type<'gcc> { fn type_f64(&self) -> Type<'gcc> {
self.double_type self.double_type
} }
fn type_f128(&self) -> Type<'gcc> { fn type_f128(&self) -> Type<'gcc> {
unimplemented!("f16_f128") unimplemented!("f16_f128")
} }

View File

@ -5,9 +5,12 @@ use gccjit::{Struct, Type};
use rustc_middle::bug; use rustc_middle::bug;
use rustc_middle::ty::layout::{LayoutOf, TyAndLayout}; use rustc_middle::ty::layout::{LayoutOf, TyAndLayout};
use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_middle::ty::print::with_no_trimmed_paths;
use rustc_target::abi::{self, Abi, Align, F16, F128, F32, F64, FieldsShape, Int, Integer, Pointer, PointeeInfo, Size, TyAbiInterface, Variants};
use rustc_middle::ty::{self, Ty, TypeVisitableExt}; use rustc_middle::ty::{self, Ty, TypeVisitableExt};
use rustc_target::abi::call::{CastTarget, FnAbi, Reg}; use rustc_target::abi::call::{CastTarget, FnAbi, Reg};
use rustc_target::abi::{
self, Abi, Align, FieldsShape, Int, Integer, PointeeInfo, Pointer, Size, TyAbiInterface,
Variants, F128, F16, F32, F64,
};
use crate::abi::{FnAbiGcc, FnAbiGccExt, GccType}; use crate::abi::{FnAbiGcc, FnAbiGccExt, GccType};
use crate::context::CodegenCx; use crate::context::CodegenCx;
@ -157,9 +160,22 @@ pub trait LayoutGccExt<'tcx> {
fn is_gcc_scalar_pair(&self) -> bool; fn is_gcc_scalar_pair(&self) -> bool;
fn gcc_type<'gcc>(&self, cx: &CodegenCx<'gcc, 'tcx>) -> Type<'gcc>; fn gcc_type<'gcc>(&self, cx: &CodegenCx<'gcc, 'tcx>) -> Type<'gcc>;
fn immediate_gcc_type<'gcc>(&self, cx: &CodegenCx<'gcc, 'tcx>) -> Type<'gcc>; fn immediate_gcc_type<'gcc>(&self, cx: &CodegenCx<'gcc, 'tcx>) -> Type<'gcc>;
fn scalar_gcc_type_at<'gcc>(&self, cx: &CodegenCx<'gcc, 'tcx>, scalar: &abi::Scalar, offset: Size) -> Type<'gcc>; fn scalar_gcc_type_at<'gcc>(
fn scalar_pair_element_gcc_type<'gcc>(&self, cx: &CodegenCx<'gcc, 'tcx>, index: usize) -> Type<'gcc>; &self,
fn pointee_info_at<'gcc>(&self, cx: &CodegenCx<'gcc, 'tcx>, offset: Size) -> Option<PointeeInfo>; cx: &CodegenCx<'gcc, 'tcx>,
scalar: &abi::Scalar,
offset: Size,
) -> Type<'gcc>;
fn scalar_pair_element_gcc_type<'gcc>(
&self,
cx: &CodegenCx<'gcc, 'tcx>,
index: usize,
) -> Type<'gcc>;
fn pointee_info_at<'gcc>(
&self,
cx: &CodegenCx<'gcc, 'tcx>,
offset: Size,
) -> Option<PointeeInfo>;
} }
impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> { impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> {
@ -341,7 +357,12 @@ impl<'gcc, 'tcx> LayoutTypeMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
layout.is_gcc_scalar_pair() layout.is_gcc_scalar_pair()
} }
fn scalar_pair_element_backend_type(&self, layout: TyAndLayout<'tcx>, index: usize, _immediate: bool) -> Type<'gcc> { fn scalar_pair_element_backend_type(
&self,
layout: TyAndLayout<'tcx>,
index: usize,
_immediate: bool,
) -> Type<'gcc> {
layout.scalar_pair_element_gcc_type(self, index) layout.scalar_pair_element_gcc_type(self, index)
} }