@@ -331,10 +331,10 @@ argConstValue :: PrimArg -> LLVM (Maybe ConstValue)
331
331
argConstValue ArgVar {} = return Nothing
332
332
argConstValue (ArgInt n ty) = do
333
333
sz <- typeRepSize <$> lift (typeRepresentation ty)
334
- return $ Just $ IntStructMember n (sz `div` 8 )
334
+ return $ Just $ IntStructMember n (sz `div` byteBits )
335
335
argConstValue (ArgFloat n ty) = do
336
336
sz <- typeRepSize <$> lift (typeRepresentation ty)
337
- return $ Just $ FloatStructMember n (sz `div` 8 )
337
+ return $ Just $ FloatStructMember n (sz `div` byteBits )
338
338
argConstValue ArgClosure {} = return Nothing -- const closures already handled
339
339
argConstValue (ArgGlobal info _) = do
340
340
-- XXX is ArgGlobal a constant? Does it give the address, or value, of the
@@ -345,7 +345,7 @@ argConstValue (ArgConstRef structID _) = do
345
345
argConstValue ArgUnneeded {} = return Nothing
346
346
argConstValue (ArgUndef ty) = do
347
347
sz <- typeRepSize <$> lift (typeRepresentation ty)
348
- return $ Just $ UndefStructMember (sz `div` 8 )
348
+ return $ Just $ UndefStructMember (sz `div` byteBits )
349
349
350
350
351
351
-- | If needed, add an extern declaration for a prim to the set.
@@ -472,38 +472,6 @@ writeAssemblyConstants = do
472
472
-- declared and recorded. This will happen because sets are sorted
473
473
-- alphabetically, and CString comes before WybeString.
474
474
writeConstDeclaration :: StructID -> LLVM ()
475
- -- writeConstDeclaration spec@(WybeStringSpec str) n = do
476
- -- -- let stringName = specialName2 "string" $ show n
477
- -- -- modify $ \s -> s { constNames=Map.insert spec stringName
478
- -- -- $ constNames s}
479
- -- cStringID <- lift $ recordConstStruct $ CStringInfo str
480
- -- writeConstDeclaration (StructSpec cStringID) n
481
- -- wStringID <- lift $ recordConstStruct $ StructInfo
482
- -- [ IntStructMember (fromIntegral $ length str) wordSize
483
- -- , PointerStructMember cStringID]
484
- -- writeConstDeclaration (StructSpec wStringID) n
485
- -- -- return ()
486
- -- writeConstDeclaration spec@(CStringSpec str) n = do
487
- -- -- let textName = specialName2 "cstring" $ show n
488
- -- cStringID <- lift $ recordConstStruct $ CStringInfo str
489
- -- writeConstDeclaration (StructSpec cStringID) n
490
- -- -- modify $ \s -> s { constNames=Map.insert spec textName
491
- -- -- $ constNames s}
492
- -- -- declareStringConstant textName str Nothing
493
- -- writeConstDeclaration spec@(ClosureSpec pspec args) n = do
494
- -- -- let closureName = specialName2 "closure" $ show n
495
- -- -- modify $ \s -> s { constNames=Map.insert spec closureName $ constNames s}
496
- -- let pname = show pspec
497
- -- -- argReps <- mapM argTypeRep args
498
- -- -- declareStructConstant closureName
499
- -- -- ((ArgGlobal (GlobalVariable pname) (Representation CPointer), CPointer)
500
- -- -- : zip args argReps)
501
- -- -- Nothing
502
- -- constArgs <- mapM argStructMember args
503
- -- closureID <- lift $ recordConstStruct
504
- -- $ StructInfo (GlobalNameMember pname : constArgs )
505
- -- writeConstDeclaration (StructSpec closureID) n
506
-
507
475
writeConstDeclaration structID = do
508
476
info <- trustFromJust (" writeConstDeclaration of " ++ show structID)
509
477
<$> lift (lookupConstInfo structID)
@@ -816,12 +784,9 @@ writeWybeCall wybeProc args pos = do
816
784
817
785
-- | Generate a Wybe proc call instruction, or defer it if necessary.
818
786
writeHOCall :: PrimArg -> [PrimArg ] -> OptPos -> LLVM ()
819
- writeHOCall (ArgClosure pspec closed _) args pos = do
820
- -- NB: this case doesn't seem to ever occur -- probably handled earlier
821
- pspec' <- fromMaybe pspec <$> lift (maybeGetClosureOf pspec)
822
- logLLVM $ " Compiling HO call as first order call to " ++ show pspec'
823
- ++ " closed over " ++ show closed
824
- writeWybeCall pspec' (closed ++ args) pos
787
+ writeHOCall closure@ (ArgClosure pspec closed _) args pos = do
788
+ -- NB: this case should have been handled earlier
789
+ shouldnt $ " Higher order call with constand closure should have been handled earlier: " ++ show closure
825
790
writeHOCall closure args pos = do
826
791
(ins,outs,oRefs,iRefs) <- partitionArgsWithRefs $ closure: args
827
792
unless (List. null oRefs && List. null iRefs)
0 commit comments