From 27438075031217e1bddc3d976e8bda66be6c8e3b Mon Sep 17 00:00:00 2001 From: Robert Zakrzewski Date: Wed, 10 Apr 2024 23:08:01 +0200 Subject: [PATCH] Add support for Float16, Float32, Float64 and Float128 Upgrade libgccjit.version Limit new Floatxx types to master branch only apply rustfmt Make new types available only when requested Make new types available only when requested Check if Float16 and Float128 are supported by the target platform --- Cargo.lock | 8 ++++---- libgccjit.version | 2 +- src/type_.rs | 24 +++++++++++++++++++++--- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ab2c7ca8a47..5fc73332937 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,16 +79,16 @@ dependencies = [ [[package]] name = "gccjit" -version = "1.0.0" -source = "git+https://github.com/antoyo/gccjit.rs#9f8f67edc006d543b17529a001803ffece48349e" +version = "2.0.0" +source = "git+https://github.com/antoyo/gccjit.rs#be7ca8d4481e1158dc678d4d313ef7ee2f74abd5" dependencies = [ "gccjit_sys", ] [[package]] name = "gccjit_sys" -version = "0.0.1" -source = "git+https://github.com/antoyo/gccjit.rs#9f8f67edc006d543b17529a001803ffece48349e" +version = "0.1.0" +source = "git+https://github.com/antoyo/gccjit.rs#be7ca8d4481e1158dc678d4d313ef7ee2f74abd5" dependencies = [ "libc", ] diff --git a/libgccjit.version b/libgccjit.version index 41bec6df5d9..2d35b63db7e 100644 --- a/libgccjit.version +++ b/libgccjit.version @@ -1 +1 @@ -b6f163f52 +ab469a6daaed9f4191ac8c32894b3f44d78b2ba5 diff --git a/src/type_.rs b/src/type_.rs index 8fe3328ec55..d28d84bc83f 100644 --- a/src/type_.rs +++ b/src/type_.rs @@ -1,4 +1,4 @@ -use gccjit::{RValue, Struct, Type}; +use gccjit::{CType, RValue, Struct, Type}; use rustc_codegen_ssa::common::TypeKind; use rustc_codegen_ssa::traits::{BaseTypeMethods, DerivedTypeMethods, TypeMembershipMethods}; use rustc_middle::ty::layout::TyAndLayout; @@ -120,8 +120,17 @@ impl<'gcc, 'tcx> BaseTypeMethods<'tcx> for CodegenCx<'gcc, 'tcx> { self.isize_type } + #[cfg(feature = "master")] fn type_f16(&self) -> Type<'gcc> { - unimplemented!("f16_f128") + if self.context.get_target_info().supports_target_dependent_type(CType::Float16) { + return self.context.new_c_type(CType::Float16); + } + unimplemented!("f16") + } + + #[cfg(not(feature = "master"))] + fn type_f16(&self) -> Type<'gcc> { + unimplemented!("f16") } fn type_f32(&self) -> Type<'gcc> { @@ -132,8 +141,17 @@ impl<'gcc, 'tcx> BaseTypeMethods<'tcx> for CodegenCx<'gcc, 'tcx> { self.double_type } + #[cfg(feature = "master")] + fn type_f128(&self) -> Type<'gcc> { + if self.context.get_target_info().supports_target_dependent_type(CType::Float128) { + return self.context.new_c_type(CType::Float128); + } + unimplemented!("f128") + } + + #[cfg(not(feature = "master"))] fn type_f128(&self) -> Type<'gcc> { - unimplemented!("f16_f128") + unimplemented!("f128") } fn type_func(&self, params: &[Type<'gcc>], return_type: Type<'gcc>) -> Type<'gcc> {