EPFL-LAP / dynamatic

DHLS (Dynamic High-Level Synthesis) compiler based on MLIR
Other
49 stars 14 forks source link

[Frontend] making synthesize.sh to use the CP set in the frontend #103

Closed Jiahui17 closed 1 month ago

Jiahui17 commented 1 month ago

Improves changes in #73 (synthesize.sh did not use the CP set in the frontend).

The frontend now rejects incorrectly formatted CP values.

Jiahui17 commented 1 month ago

Thanks for the contribution!

Shouldn't we do all this floating point verification / formatting once and for all in the frontend itself so that our shell scripts don't have to do this stuff (which is annoying in the shell)?

I just looked it up and LLVM has nice utilities to convert from string to double/float without throwing exceptions on errors.

#include "llvm/ADT/StringExtras.h"

llvm::StringRef myFloatString = ...;
double cp;
if (!llvm::to_float(myFloatString, cp)) {
  // This means that conversion failed
  return failure();
}
// This means that conversion succeeded, cp is set to the parsed value

Once we actually have a double for the cp it should be easy to limit the number of decimal digits that are printed when passing the argument to scripts.

Good idea, I just moved the checking logic into the frontend.

Is there a better way to format a float as a string in certain decimal places? I found one in std library but it is C++20 only

Jiahui17 commented 1 month ago

LGTM! thank you