Skip to content

Commit 6b2a99a

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
1 parent 8692192 commit 6b2a99a

File tree

4 files changed

+41
-7
lines changed

4 files changed

+41
-7
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/context.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,14 @@ pub struct CodegenCx<'gcc, 'tcx> {
7171

7272
pub float_type: Type<'gcc>,
7373
pub double_type: Type<'gcc>,
74+
#[cfg(feature = "master")]
75+
pub float16_type: Type<'gcc>,
76+
#[cfg(feature = "master")]
77+
pub float32_type: Type<'gcc>,
78+
#[cfg(feature = "master")]
79+
pub float64_type: Type<'gcc>,
80+
#[cfg(feature = "master")]
81+
pub float128_type: Type<'gcc>,
7482

7583
pub linkage: Cell<FunctionType>,
7684
pub scalar_types: RefCell<FxHashMap<Ty<'tcx>, Type<'gcc>>>,
@@ -183,6 +191,14 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
183191
// TODO(antoyo): set alignment on those types as well.
184192
let float_type = context.new_type::<f32>();
185193
let double_type = context.new_type::<f64>();
194+
#[cfg(feature = "master")]
195+
let float16_type = context.new_c_type(CType::Float16);
196+
#[cfg(feature = "master")]
197+
let float32_type = context.new_c_type(CType::Float32);
198+
#[cfg(feature = "master")]
199+
let float64_type = context.new_c_type(CType::Float64);
200+
#[cfg(feature = "master")]
201+
let float128_type = context.new_c_type(CType::Float128);
186202

187203
let char_type = context.new_c_type(CType::Char);
188204
let uchar_type = context.new_c_type(CType::UChar);
@@ -308,6 +324,14 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
308324

309325
float_type,
310326
double_type,
327+
#[cfg(feature = "master")]
328+
float16_type,
329+
#[cfg(feature = "master")]
330+
float32_type,
331+
#[cfg(feature = "master")]
332+
float64_type,
333+
#[cfg(feature = "master")]
334+
float128_type,
311335

312336
linkage: Cell::new(FunctionType::Internal),
313337
instances: Default::default(),

src/type_.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,13 @@ 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+
self.float16_type
126+
}
127+
#[cfg(not(feature = "master"))]
128+
fn type_f16(&self) -> Type<'gcc> {
129+
unimplemented!("f16")
125130
}
126131

127132
fn type_f32(&self) -> Type<'gcc> {
@@ -132,8 +137,13 @@ impl<'gcc, 'tcx> BaseTypeMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
132137
self.double_type
133138
}
134139

140+
#[cfg(feature = "master")]
141+
fn type_f128(&self) -> Type<'gcc> {
142+
self.float128_type
143+
}
144+
#[cfg(not(feature = "master"))]
135145
fn type_f128(&self) -> Type<'gcc> {
136-
unimplemented!("f16_f128")
146+
unimplemented!("f128")
137147
}
138148

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

0 commit comments

Comments
 (0)