[llvm] Add support for DFP IR type. (PR #69718)

Andy Kaylor via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 20 11:28:11 PDT 2023


================
@@ -207,9 +216,15 @@ int Type::getFPMantissaWidth() const {
   if (getTypeID() == HalfTyID) return 11;
   if (getTypeID() == BFloatTyID) return 8;
   if (getTypeID() == FloatTyID) return 24;
+  // TODO - Does this depend on the encoding format used (BID or DPD)?
----------------
andykaylor wrote:

For both BID and DPD the size of the mantissa is variable. It's always at least 20 bits, but it can borrow up to three bits from the "combination" field. A comment above the declaration of this method says "If the FP type does not have a stable mantissa, this method returns -1." I think that's what you need to do for the decimal types.

Any code that's trying to get the mantissa width is probably doing something that won't work with decimal FP types.

Note that the PPC_FP128 type currently does this, and it's handled as the default case at the bottom of this function. You could add the decimal types the same way by updating the assert, but I don't see any reason not to give them (and PPC_FP128) an explicit check.

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


More information about the llvm-commits mailing list