From b9fc9c284557c1707372fae9aeef5384fcf3905e Mon Sep 17 00:00:00 2001 From: Ethan Girouard Date: Tue, 2 Sep 2025 17:31:38 -0400 Subject: [PATCH] Add information for unimplemented codegen --- src/Windows12/CodeGen.hs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Windows12/CodeGen.hs b/src/Windows12/CodeGen.hs index 06a1f16..13b850e 100644 --- a/src/Windows12/CodeGen.hs +++ b/src/Windows12/CodeGen.hs @@ -20,6 +20,7 @@ import qualified LLVM.AST.FloatingPointPredicate as FP import Control.Monad.State hiding (void) +import Data.Text.Prettyprint.Doc (pretty) import Data.Text (Text, unpack) import Data.String.Conversions import Data.String @@ -117,7 +118,7 @@ codegenLVal (Member (Id sName) field) = do gep struct [ConstantOperand (C.Int 32 0), ConstantOperand (C.Int 32 (fromIntegral offset))] Nothing -> error $ "Struct " ++ show sName ++ " not found" -codeGenLVal _ = error "Unimplemented or invalid LValue" +codegenLVal e = error $ "Unimplemented or invalid LValue " ++ show (pretty e) ++ " (" ++ show e ++ ")" -- Given a struct and a field name, return the offset of the field in the struct. -- In LLVM each field is actually size 1 @@ -216,6 +217,8 @@ codegenExpr (Cast t e) = undefined -- TODO casts codegenExpr (Sizeof t) = ConstantOperand . C.Int 32 . fromIntegral <$> size t +codegenExpr e = error $ "Unimplemented or invalid Expression " ++ show (pretty e) ++ " (" ++ show e ++ ")" + mkTerminator :: IRBuilder () -> IRBuilder () mkTerminator instr = do check <- hasTerminator @@ -290,7 +293,7 @@ codegenStmt (Var name t (Just e)) = codegenStmt (Assign BaseAssign (Id name) e) -- This is because allocation is done already codegenStmt (Var name _ Nothing) = return () -codegenStmt s = error $ "Unimplemented or invalid statement " ++ show s +codegenStmt s = error $ "Unimplemented or invalid statement " ++ show (pretty s) ++ " (" ++ show s ++ ")" -- Generate code for a function -- First create the function, then allocate space for the arguments and locals