Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Begin prototyping f128 tests #18

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/abis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ pub enum IntVal {
pub enum FloatVal {
c_double(f64),
c_float(f32),
c_float128(f64),
// Is there a reason to mess with `long double`? Surely not.
}

Expand Down
8 changes: 8 additions & 0 deletions src/abis/c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@ impl CcAbiImpl {
));
}
Struct(name, _) => format!("struct {name}"),
Float(FloatVal::c_float128(_)) => "__float128".to_string(),
Float(FloatVal::c_double(_)) => "double".to_string(),
Float(FloatVal::c_float(_)) => "float".to_string(),
Int(int_val) => match int_val {
Expand Down Expand Up @@ -680,6 +681,13 @@ impl CcAbiImpl {
output.push_str(" }");
output
}
Float(FloatVal::c_float128(val)) => {
if val.fract() == 0.0 {
format!("{val}.0")
} else {
format!("{val}")
}
}
Float(FloatVal::c_double(val)) => {
if val.fract() == 0.0 {
format!("{val}.0")
Expand Down
10 changes: 10 additions & 0 deletions src/abis/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,9 @@ impl RustcAbiImpl {
Bool(_) => "bool".to_string(),
Array(vals) => format!("[{}; {}]", self.rust_arg_type(&vals[0])?, vals.len()),
Struct(name, _) => name.to_string(),
Float(FloatVal::c_float128(_)) => {
return Err(GenerateError::RustUnsupported("f128".to_owned()))
}
Float(FloatVal::c_double(_)) => "f64".to_string(),
Float(FloatVal::c_float(_)) => "f32".to_string(),
Int(int_val) => match int_val {
Expand Down Expand Up @@ -509,6 +512,13 @@ impl RustcAbiImpl {
output.push_str(" }");
output
}
Float(FloatVal::c_float128(val)) => {
if val.fract() == 0.0 {
format!("{val}.0")
} else {
format!("{val}")
}
}
Float(FloatVal::c_double(val)) => {
if val.fract() == 0.0 {
format!("{val}.0")
Expand Down
3 changes: 3 additions & 0 deletions src/procgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub fn procgen_tests(regenerate: bool) {
("u8", &[Val::Int(IntVal::c_uint8_t(0x1a))]),
("ptr", &[Val::Ptr(0x1a2b_3c4d_23ea_f142)]),
("bool", &[Val::Bool(true)]),
("f128", &[Val::Float(FloatVal::c_float128(809239021.392))]),
("f64", &[Val::Float(FloatVal::c_double(809239021.392))]),
("f32", &[Val::Float(FloatVal::c_float(-4921.3527))]),
// These are split out because they are the buggy mess that inspired this whole enterprise!
Expand Down Expand Up @@ -99,6 +100,7 @@ pub fn procgen_tests(regenerate: bool) {
Val::Float(float_val) => match float_val {
FloatVal::c_double(out) => graffiti_primitive(out, i),
FloatVal::c_float(out) => graffiti_primitive(out, i),
FloatVal::c_float128(out) => graffiti_primitive(out, i),
},
Val::Bool(out) => *out = true,
}
Expand Down Expand Up @@ -342,6 +344,7 @@ pub fn arg_ty(val: &Val) -> String {
arg_ty(vals.get(0).expect("arrays must have length > 0")),
),
Struct(name, _) => format!("struct_{name}"),
Float(FloatVal::c_float128(_)) => "f128".to_string(),
Float(FloatVal::c_double(_)) => "f64".to_string(),
Float(FloatVal::c_float(_)) => "f32".to_string(),
Int(int_val) => match int_val {
Expand Down
4 changes: 3 additions & 1 deletion src/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ pub fn get_test_rules(test: &TestKey, caller: &dyn AbiImpl, callee: &dyn AbiImpl
// This is Bad! Ideally we should check for all clang<->gcc pairs but to start
// let's mark rust <-> C as disagreeing (because rust also disagrees with clang).
if !cfg!(any(target_arch = "aarch64", target_arch = "s390x"))
&& test.test_name == "ui128" && is_rust_and_c {
&& test.test_name == "ui128"
&& is_rust_and_c
{
result.check = Busted(Check);
}

Expand Down
11 changes: 11 additions & 0 deletions tests/normal/f128.ron
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Test(
name: "f128",
funcs: [
(
name: "f128",
conventions: [c],
inputs: [Float(c_float128(5))],
output: None,
),
]
)