Skip to content

Commit 6e00d37

Browse files
committed
Advance the port to llvm/llvm-project@462a31f
(last APFloat-related LLVM commit from 2022).
1 parent 37e914f commit 6e00d37

File tree

7 files changed

+1000
-167
lines changed

7 files changed

+1000
-167
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
members = ["fuzz"]
33

44
[workspace.package]
5-
version = "0.0.7+llvm-f45d5e71d3e1"
5+
version = "0.0.8+llvm-462a31f5a5ab"
66
edition = "2021"
77
license = "Apache-2.0 WITH LLVM-exception"
88

fuzz/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ echo | clang++ -x c++ - -std=c++17 \
9191
$clang_codegen_flags \
9292
-I "$llvm"/include \
9393
-I "$OUT_DIR"/fake-config \
94-
-DNDEBUG -DHAVE_UNISTD_H -DLLVM_ON_UNIX \
94+
-DNDEBUG -DHAVE_UNISTD_H -DLLVM_ON_UNIX -DLLVM_ENABLE_THREADS=0 \
9595
--include="$llvm"/lib/Support/{APInt,APFloat,SmallVector,ErrorHandling}.cpp \
9696
--include="$OUT_DIR"/cxx_apf_fuzz.cpp \
9797
-c -emit-llvm -o "$OUT_DIR"/cxx_apf_fuzz.bc

fuzz/ops.rs

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -320,25 +320,28 @@ struct FuzzOp {
320320
}
321321
};
322322
" + &[
323-
(16, "APFloat::IEEEhalf()"),
324-
(32, "APFloat::IEEEsingle()"),
325-
(64, "APFloat::IEEEdouble()"),
326-
(128, "APFloat::IEEEquad()"),
327-
(16, "APFloat::BFloat()"),
328-
(80, "APFloat::x87DoubleExtended()"),
323+
(16, "IEEEhalf"),
324+
(32, "IEEEsingle"),
325+
(64, "IEEEdouble"),
326+
(128, "IEEEquad"),
327+
(16, "BFloat"),
328+
(8, "Float8E5M2"),
329+
(8, "Float8E4M3FN"),
330+
(80, "x87DoubleExtended"),
329331
]
330332
.into_iter()
331-
.map(|(w, cxx_apf_semantics)| {
332-
let (name_prefix, uint_width) = match w {
333-
16 if cxx_apf_semantics.contains("BFloat") => ("BrainF", 16),
334-
80 => ("X87_F", 128),
335-
_ => ("IEEE", w),
333+
.map(|(w, cxx_apf_semantics): (usize, _)| {
334+
let uint_width = w.next_power_of_two();
335+
let name = match (w, cxx_apf_semantics) {
336+
(16, "BFloat") => "BrainF16".into(),
337+
(8, s) if s.starts_with("Float8") => s.replace("Float8", "F8"),
338+
(80, "x87DoubleExtended") => "X87_F80".into(),
339+
_ => {
340+
assert!(cxx_apf_semantics.starts_with("IEEE"));
341+
format!("IEEE{w}")
342+
}
336343
};
337-
let name = format!("{name_prefix}{w}");
338-
let exported_symbol = format!(
339-
"cxx_apf_fuzz_eval_op_{}{w}",
340-
name_prefix.to_ascii_lowercase()
341-
);
344+
let exported_symbol = format!("cxx_apf_fuzz_eval_op_{}", name.to_ascii_lowercase());
342345
exported_symbols.push(exported_symbol.clone());
343346
let uint = format!("uint{uint_width}_t");
344347
format!(
@@ -367,7 +370,7 @@ struct __attribute__((packed)) {name} {{
367370
> words;
368371
for(int i = 0; i < {w}; i += APInt::APINT_BITS_PER_WORD)
369372
words[i / APInt::APINT_BITS_PER_WORD] = bits >> i;
370-
return APFloat({cxx_apf_semantics}, APInt({w}, words));
373+
return APFloat(APFloat::{cxx_apf_semantics}(), APInt({w}, words));
371374
}}
372375
}};
373376
extern "C" {{

fuzz/src/main.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,16 @@ float_reprs! {
206206
}
207207

208208
// Non-standard IEEE-like formats.
209+
F8E5M2(u8) {
210+
type RustcApFloat = rustc_apfloat::ieee::Float8E5M2;
211+
const REPR_TAG = 8 + 0;
212+
extern fn = cxx_apf_fuzz_eval_op_f8e5m2;
213+
}
214+
F8E4M3FN(u8) {
215+
type RustcApFloat = rustc_apfloat::ieee::Float8E4M3FN;
216+
const REPR_TAG = 8 + 1;
217+
extern fn = cxx_apf_fuzz_eval_op_f8e4m3fn;
218+
}
209219
BrainF16(u16) {
210220
type RustcApFloat = rustc_apfloat::ieee::BFloat;
211221
const REPR_TAG = 16 + 1;

0 commit comments

Comments
 (0)