Skip to content

Commit

Permalink
Limit new Floatxx types to master branch only
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Zakrzewski committed Apr 11, 2024
1 parent 55e9217 commit 35bc8ff
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,13 @@ pub struct CodegenCx<'gcc, 'tcx> {

pub float_type: Type<'gcc>,
pub double_type: Type<'gcc>,
#[cfg(feature="master")]
pub float16_type: Type<'gcc>,
#[cfg(feature="master")]
pub float32_type: Type<'gcc>,
#[cfg(feature="master")]
pub float64_type: Type<'gcc>,
#[cfg(feature="master")]
pub float128_type: Type<'gcc>,

pub linkage: Cell<FunctionType>,
Expand Down Expand Up @@ -187,9 +191,13 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
// TODO(antoyo): set alignment on those types as well.
let float_type = context.new_type::<f32>();
let double_type = context.new_type::<f64>();
#[cfg(feature="master")]
let float16_type = context.new_c_type(CType::Float16);
#[cfg(feature="master")]
let float32_type = context.new_c_type(CType::Float32);
#[cfg(feature="master")]
let float64_type = context.new_c_type(CType::Float64);
#[cfg(feature="master")]
let float128_type = context.new_c_type(CType::Float128);

let char_type = context.new_c_type(CType::Char);
Expand Down Expand Up @@ -316,9 +324,13 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {

float_type,
double_type,
#[cfg(feature="master")]
float16_type,
#[cfg(feature="master")]
float32_type,
#[cfg(feature="master")]
float64_type,
#[cfg(feature="master")]
float128_type,

linkage: Cell::new(FunctionType::Internal),
Expand Down
11 changes: 11 additions & 0 deletions src/type_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,15 @@ impl<'gcc, 'tcx> BaseTypeMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
self.isize_type
}

#[cfg(feature="master")]
fn type_f16(&self) -> Type<'gcc> {
self.float16_type
}
#[cfg(not(feature="master"))]
fn type_f16(&self) -> Type<'gcc> {
unimplemented!("f16")
}


fn type_f32(&self) -> Type<'gcc> {
self.float_type
Expand All @@ -132,9 +138,14 @@ impl<'gcc, 'tcx> BaseTypeMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
self.double_type
}

#[cfg(feature="master")]
fn type_f128(&self) -> Type<'gcc> {
self.float128_type
}
#[cfg(not(feature="master"))]
fn type_f128(&self) -> Type<'gcc> {
unimplemented!("f128")
}

fn type_func(&self, params: &[Type<'gcc>], return_type: Type<'gcc>) -> Type<'gcc> {
self.context.new_function_pointer_type(None, return_type, params, false)
Expand Down

0 comments on commit 35bc8ff

Please sign in to comment.