diff --git a/clash-ghc/src-ghc/Clash/GHC/Evaluator/Primitive.hs b/clash-ghc/src-ghc/Clash/GHC/Evaluator/Primitive.hs index cc61505acb..c9663a60d5 100644 --- a/clash-ghc/src-ghc/Clash/GHC/Evaluator/Primitive.hs +++ b/clash-ghc/src-ghc/Clash/GHC/Evaluator/Primitive.hs @@ -1788,11 +1788,15 @@ ghcPrimStep tcm isSubj pInfo tys args mach = case primName pInfo of "Clash.Class.BitPack.Internal.unpackFloat#" | [i] <- bitVectorLiterals' args - -> reduce . Literal . FloatLiteral $ unpack (toBV i :: BitVector 32) + -> let resTy = getResultTy tcm ty tys + val = unpack (toBV i :: BitVector 32) + in reduce (mkFloatCLit val resTy) "Clash.Class.BitPack.Internal.unpackDouble#" | [i] <- bitVectorLiterals' args - -> reduce . Literal . DoubleLiteral $ unpack (toBV i :: BitVector 64) + -> let resTy = getResultTy tcm ty tys + val = unpack (toBV i :: BitVector 64) + in reduce (mkDoubleCLit val resTy) -- expIndex# -- :: KnownNat m @@ -4186,6 +4190,30 @@ bitVectorLitIntLit tcm tys args | otherwise = Nothing +mkFloatCLit :: Word32 -> Type -> Term +mkFloatCLit lit resTy = + App (Prim info) (Literal (FloatLiteral lit)) + where + info = PrimInfo + { primName = "GHC.Types.F#" + , primType = mkFunTy floatPrimTy resTy + , primWorkInfo = WorkNever + , primMultiResult = SingleResult + , primUnfolding = NoUnfolding + } + +mkDoubleCLit :: Word64 -> Type -> Term +mkDoubleCLit lit resTy = + App (Prim info) (Literal (DoubleLiteral lit)) + where + info = PrimInfo + { primName = "GHC.Types.D#" + , primType = mkFunTy doublePrimTy resTy + , primWorkInfo = WorkNever + , primMultiResult = SingleResult + , primUnfolding = NoUnfolding + } + -- From an argument list to function of type -- forall n. KnownNat n => ... -- extract (nTy,nInt)