Skip to content

Commit 2743807

Browse files
author
Robert Zakrzewski
committed
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
1 parent 8692192 commit 2743807

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
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.

libgccjit.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
b6f163f52
1+
ab469a6daaed9f4191ac8c32894b3f44d78b2ba5

src/type_.rs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use gccjit::{RValue, Struct, Type};
1+
use gccjit::{CType, RValue, Struct, Type};
22
use rustc_codegen_ssa::common::TypeKind;
33
use rustc_codegen_ssa::traits::{BaseTypeMethods, DerivedTypeMethods, TypeMembershipMethods};
44
use rustc_middle::ty::layout::TyAndLayout;
@@ -120,8 +120,17 @@ impl<'gcc, 'tcx> BaseTypeMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
120120
self.isize_type
121121
}
122122

123+
#[cfg(feature = "master")]
123124
fn type_f16(&self) -> Type<'gcc> {
124-
unimplemented!("f16_f128")
125+
if self.context.get_target_info().supports_target_dependent_type(CType::Float16) {
126+
return self.context.new_c_type(CType::Float16);
127+
}
128+
unimplemented!("f16")
129+
}
130+
131+
#[cfg(not(feature = "master"))]
132+
fn type_f16(&self) -> Type<'gcc> {
133+
unimplemented!("f16")
125134
}
126135

127136
fn type_f32(&self) -> Type<'gcc> {
@@ -132,8 +141,17 @@ impl<'gcc, 'tcx> BaseTypeMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
132141
self.double_type
133142
}
134143

144+
#[cfg(feature = "master")]
145+
fn type_f128(&self) -> Type<'gcc> {
146+
if self.context.get_target_info().supports_target_dependent_type(CType::Float128) {
147+
return self.context.new_c_type(CType::Float128);
148+
}
149+
unimplemented!("f128")
150+
}
151+
152+
#[cfg(not(feature = "master"))]
135153
fn type_f128(&self) -> Type<'gcc> {
136-
unimplemented!("f16_f128")
154+
unimplemented!("f128")
137155
}
138156

139157
fn type_func(&self, params: &[Type<'gcc>], return_type: Type<'gcc>) -> Type<'gcc> {

0 commit comments

Comments
 (0)