Skip to content

Commit 27b669a

Browse files
committed
Auto merge of #121728 - tgross35:f16-f128-step1-ty-updates, r=compiler-errors
Add stubs in IR and ABI for `f16` and `f128` This is the very first step toward the changes in rust-lang/rust#114607 and the [`f16` and `f128` RFC](https://rust-lang.github.io/rfcs/3453-f16-and-f128.html). It adds the types to `rustc_type_ir::FloatTy` and `rustc_abi::Primitive`, and just propagates those out as `unimplemented!` stubs where necessary. These types do not parse yet so there is no feature gate, and it should be okay to use `unimplemented!`. The next steps will probably be AST support with parsing and the feature gate. r? `@compiler-errors` cc `@Nilstrieb` suggested breaking the PR up in rust-lang/rust#120645 (comment)
2 parents 427d617 + 8dd96ba commit 27b669a

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/type_.rs

+10
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,10 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
8383

8484
pub fn type_float_from_ty(&self, t: ty::FloatTy) -> Type<'gcc> {
8585
match t {
86+
ty::FloatTy::F16 => self.type_f16(),
8687
ty::FloatTy::F32 => self.type_f32(),
8788
ty::FloatTy::F64 => self.type_f64(),
89+
ty::FloatTy::F128 => self.type_f128(),
8890
}
8991
}
9092
}
@@ -118,13 +120,21 @@ impl<'gcc, 'tcx> BaseTypeMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
118120
self.isize_type
119121
}
120122

123+
fn type_f16(&self) -> Type<'gcc> {
124+
unimplemented!("f16_f128")
125+
}
126+
121127
fn type_f32(&self) -> Type<'gcc> {
122128
self.float_type
123129
}
124130

125131
fn type_f64(&self) -> Type<'gcc> {
126132
self.double_type
127133
}
134+
135+
fn type_f128(&self) -> Type<'gcc> {
136+
unimplemented!("f16_f128")
137+
}
128138

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

src/type_of.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc_middle::bug;
66
use rustc_middle::ty::{self, Ty, TypeVisitableExt};
77
use rustc_middle::ty::layout::{LayoutOf, TyAndLayout};
88
use rustc_middle::ty::print::with_no_trimmed_paths;
9-
use rustc_target::abi::{self, Abi, Align, F32, F64, FieldsShape, Int, Integer, Pointer, PointeeInfo, Size, TyAbiInterface, Variants};
9+
use rustc_target::abi::{self, Abi, Align, F16, F128, F32, F64, FieldsShape, Int, Integer, Pointer, PointeeInfo, Size, TyAbiInterface, Variants};
1010
use rustc_target::abi::call::{CastTarget, FnAbi, Reg};
1111

1212
use crate::abi::{FnAbiGcc, FnAbiGccExt, GccType};
@@ -257,8 +257,10 @@ impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> {
257257
match scalar.primitive() {
258258
Int(i, true) => cx.type_from_integer(i),
259259
Int(i, false) => cx.type_from_unsigned_integer(i),
260+
F16 => cx.type_f16(),
260261
F32 => cx.type_f32(),
261262
F64 => cx.type_f64(),
263+
F128 => cx.type_f128(),
262264
Pointer(address_space) => {
263265
// If we know the alignment, pick something better than i8.
264266
let pointee =

0 commit comments

Comments
 (0)