Add information for unimplemented codegen

This commit is contained in:
2025-09-02 17:31:38 -04:00
parent 1c5cadd263
commit b9fc9c2845

View File

@@ -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