[Mlir-commits] [mlir] TranslateToCpp: Emit floating point literals with suffix (PR #85392)

Simon Camphausen llvmlistbot at llvm.org
Fri Mar 15 06:36:13 PDT 2024


================
@@ -1193,10 +1192,18 @@ LogicalResult CppEmitter::emitAttribute(Location loc, Attribute attr) {
 
   // Print floating point attributes.
   if (auto fAttr = dyn_cast<FloatAttr>(attr)) {
+    if (!fAttr.getType().isF32() && !fAttr.getType().isF64()) {
+      return emitError(loc,
+                       "expected floating point attribute to be f32 or f64");
+    }
     printFloat(fAttr.getValue());
     return success();
   }
   if (auto dense = dyn_cast<DenseFPElementsAttr>(attr)) {
+    if (!dense.getElementType().isF32() && !dense.getElementType().isF64()) {
----------------
simon-camp wrote:

Same as above

https://github.com/llvm/llvm-project/pull/85392


More information about the Mlir-commits mailing list