Skip to content

Commit

Permalink
Add support for Float16, Float32, Float64 and Float128
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Robert Zakrzewski committed Apr 22, 2024
1 parent 8692192 commit 2743807
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion libgccjit.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
b6f163f52
ab469a6daaed9f4191ac8c32894b3f44d78b2ba5
24 changes: 21 additions & 3 deletions src/type_.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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> {
Expand All @@ -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> {
Expand Down

0 comments on commit 2743807

Please sign in to comment.