Commits

Mattias Lundell  committed 7bcc59a

added cyclic datastructures

  • Participants
  • Parent commits 0ee9e03

Comments (0)

Files changed (2)

File rtsPOSIX/config.log

 configure:3203: checking for the pthreads library -lpthreads
 configure:3246: gcc -o conftest -g -O2 -m32    conftest.c -lpthreads  >&5
 /usr/bin/ld: error: cannot find -lpthreads
-/usr/bin/ld: /tmp/ccAKQAXo.o: in function main:conftest.c:12: error: undefined reference to 'pthread_join'
-/usr/bin/ld: /tmp/ccAKQAXo.o: in function main:conftest.c:13: error: undefined reference to '__pthread_register_cancel'
-/usr/bin/ld: /tmp/ccAKQAXo.o: in function main:conftest.c:14: error: undefined reference to 'pthread_create'
-/usr/bin/ld: /tmp/ccAKQAXo.o: in function main:conftest.c:14: error: undefined reference to '__pthread_unregister_cancel'
+/usr/bin/ld: /tmp/ccqQYfO1.o: in function main:conftest.c:12: error: undefined reference to 'pthread_join'
+/usr/bin/ld: /tmp/ccqQYfO1.o: in function main:conftest.c:13: error: undefined reference to '__pthread_register_cancel'
+/usr/bin/ld: /tmp/ccqQYfO1.o: in function main:conftest.c:14: error: undefined reference to 'pthread_create'
+/usr/bin/ld: /tmp/ccqQYfO1.o: in function main:conftest.c:14: error: undefined reference to '__pthread_unregister_cancel'
 collect2: ld returned 1 exit status
 configure:3253: $? = 1
 configure: failed program was:
 configure:3276: result: no
 configure:3148: checking whether pthreads work without any flags
 configure:3246: gcc -o conftest -g -O2 -m32    conftest.c   >&5
-/usr/bin/ld: /tmp/cca4JwDx.o: in function main:conftest.c:12: error: undefined reference to 'pthread_join'
-/usr/bin/ld: /tmp/cca4JwDx.o: in function main:conftest.c:13: error: undefined reference to '__pthread_register_cancel'
-/usr/bin/ld: /tmp/cca4JwDx.o: in function main:conftest.c:14: error: undefined reference to 'pthread_create'
-/usr/bin/ld: /tmp/cca4JwDx.o: in function main:conftest.c:14: error: undefined reference to '__pthread_unregister_cancel'
+/usr/bin/ld: /tmp/ccZjxpi8.o: in function main:conftest.c:12: error: undefined reference to 'pthread_join'
+/usr/bin/ld: /tmp/ccZjxpi8.o: in function main:conftest.c:13: error: undefined reference to '__pthread_register_cancel'
+/usr/bin/ld: /tmp/ccZjxpi8.o: in function main:conftest.c:14: error: undefined reference to 'pthread_create'
+/usr/bin/ld: /tmp/ccZjxpi8.o: in function main:conftest.c:14: error: undefined reference to '__pthread_unregister_cancel'
 collect2: ld returned 1 exit status
 configure:3253: $? = 1
 configure: failed program was:
 configure:3153: checking whether pthreads work with -Kthread
 configure:3246: gcc -o conftest -g -O2 -m32 -Kthread   conftest.c   >&5
 gcc: unrecognized option '-Kthread'
-/usr/bin/ld: /tmp/ccJTKaWB.o: in function main:conftest.c:12: error: undefined reference to 'pthread_join'
-/usr/bin/ld: /tmp/ccJTKaWB.o: in function main:conftest.c:13: error: undefined reference to '__pthread_register_cancel'
-/usr/bin/ld: /tmp/ccJTKaWB.o: in function main:conftest.c:14: error: undefined reference to 'pthread_create'
-/usr/bin/ld: /tmp/ccJTKaWB.o: in function main:conftest.c:14: error: undefined reference to '__pthread_unregister_cancel'
+/usr/bin/ld: /tmp/ccNqh879.o: in function main:conftest.c:12: error: undefined reference to 'pthread_join'
+/usr/bin/ld: /tmp/ccNqh879.o: in function main:conftest.c:13: error: undefined reference to '__pthread_register_cancel'
+/usr/bin/ld: /tmp/ccNqh879.o: in function main:conftest.c:14: error: undefined reference to 'pthread_create'
+/usr/bin/ld: /tmp/ccNqh879.o: in function main:conftest.c:14: error: undefined reference to '__pthread_unregister_cancel'
 collect2: ld returned 1 exit status
 configure:3253: $? = 1
 configure: failed program was:
 configure:3153: checking whether pthreads work with -kthread
 configure:3246: gcc -o conftest -g -O2 -m32 -kthread   conftest.c   >&5
 gcc: unrecognized option '-kthread'
-/usr/bin/ld: /tmp/cc6Bi38D.o: in function main:conftest.c:12: error: undefined reference to 'pthread_join'
-/usr/bin/ld: /tmp/cc6Bi38D.o: in function main:conftest.c:13: error: undefined reference to '__pthread_register_cancel'
-/usr/bin/ld: /tmp/cc6Bi38D.o: in function main:conftest.c:14: error: undefined reference to 'pthread_create'
-/usr/bin/ld: /tmp/cc6Bi38D.o: in function main:conftest.c:14: error: undefined reference to '__pthread_unregister_cancel'
+/usr/bin/ld: /tmp/cc6kPCje.o: in function main:conftest.c:12: error: undefined reference to 'pthread_join'
+/usr/bin/ld: /tmp/cc6kPCje.o: in function main:conftest.c:13: error: undefined reference to '__pthread_register_cancel'
+/usr/bin/ld: /tmp/cc6kPCje.o: in function main:conftest.c:14: error: undefined reference to 'pthread_create'
+/usr/bin/ld: /tmp/cc6kPCje.o: in function main:conftest.c:14: error: undefined reference to '__pthread_unregister_cancel'
 collect2: ld returned 1 exit status
 configure:3253: $? = 1
 configure: failed program was:
 configure:3203: checking for the pthreads library -llthread
 configure:3246: gcc -o conftest -g -O2 -m32    conftest.c -llthread  >&5
 /usr/bin/ld: error: cannot find -llthread
-/usr/bin/ld: /tmp/cc95yjsI.o: in function main:conftest.c:12: error: undefined reference to 'pthread_join'
-/usr/bin/ld: /tmp/cc95yjsI.o: in function main:conftest.c:13: error: undefined reference to '__pthread_register_cancel'
-/usr/bin/ld: /tmp/cc95yjsI.o: in function main:conftest.c:14: error: undefined reference to 'pthread_create'
-/usr/bin/ld: /tmp/cc95yjsI.o: in function main:conftest.c:14: error: undefined reference to '__pthread_unregister_cancel'
+/usr/bin/ld: /tmp/ccXFylGk.o: in function main:conftest.c:12: error: undefined reference to 'pthread_join'
+/usr/bin/ld: /tmp/ccXFylGk.o: in function main:conftest.c:13: error: undefined reference to '__pthread_register_cancel'
+/usr/bin/ld: /tmp/ccXFylGk.o: in function main:conftest.c:14: error: undefined reference to 'pthread_create'
+/usr/bin/ld: /tmp/ccXFylGk.o: in function main:conftest.c:14: error: undefined reference to '__pthread_unregister_cancel'
 collect2: ld returned 1 exit status
 configure:3253: $? = 1
 configure: failed program was:

File src/Kindle2LLVM.hs

                     f i (x, Val t _)
                                 = k2cName x <+> text "=" <+> k2cExp (rootInd' t i) <> text ";"
                    -}
+                  -- s1_Cyclic = (S_Cyclic)roots->elems[0];
                   f root i (vname, Val vtyp _) = do
-                        let typ = k2llvmType vtyp
+                        let typ  = k2llvmType vtyp
                             name = k2llvmName vname
-                        r1 <- k2llvmExp (rootInd' vtyp i)
+                        r1  <- k2llvmExp (rootInd' vtyp i)
                         var <- lookupVar name
                         case var of
                           Just reg -> store r1 reg
-                          Nothing -> do
+                          Nothing  -> do
                                    r2 <- alloca typ
                                    store r1 r2
                                    addVar name r2
                                   k2cExp (rootInd i) <+> text "=" <+> k2cExp (ECast tPOLY (EVar x)) <> text ";" $$
                                   k2cStructBinds (rootInd' t i) n bs'
                    -}
+
+                  {-
+                    k2llvmCmd (CUpdA array index newval cmd1) = do
+                      r1 <- k2llvmExp array
+                      r2 <- k2llvmExp index
+                      r3 <- k2llvmExp newval
+                      let etyp = getTyp r3
+                      (offset,typ) <- getStructIndex (struct "Array") "elems"
+                      r4 <- getelementptr typ [intConst offset] r1
+                      getelementptr etyp [r2] r4 >>= store r3
+                      k2llvmCmd cmd1
+                   -}
+                  -- k2llvmCmd
                   g root i u (vname, Val vtyp (ENew ntyp [] binds)) = do
                         update u root i
-                        let typ = k2llvmType vtyp
+                        let typ  = k2llvmType vtyp
                             name = k2llvmName vname
                         size <- getStructSize (dropPtrs typ)
-                        var <- lookupVar name
-                        r1 <- k2llvmNew var typ size
+                        var  <- lookupVar name
+                        r1   <- k2llvmNew var typ size
                         addVar name r1
-                        r2 <- k2llvmExp (rootInd i)
-                        r3 <- k2llvmExp (ECast tPOLY (EVar vname))
+                        r2   <- k2llvmExp (rootInd i)
+                        r3   <- k2llvmExp (ECast tPOLY (EVar vname))
                         store r3 r2
                         k2llvmStructBinds (rootInd' vtyp i) ntyp binds
                         --r2 <- rootInd i
                                 = update u i $$
                                   k2cName x <+> text "=" <+> k2cExp e <> text ";" $$
                                   k2cExp (rootInd i) <+> text "=" <+> k2cExp (ECast tPOLY (EVar x)) <> text ";"
-
                    -}
                   g root i u (vname, Val vtyp e)      = do
                         update u root i
   let typ@(Tptr typ_noptr) = getTyp r1
   (offset,typ) <- getStructIndex typ_noptr (k2llvmName name)
   getelementptr typ [intConst offset] r1 >>= load
+-- Used by cyclic data structures
+k2llvmExp (ECall (Prim IndexArray _ ) [] exps@([_,EVar (Name a _ _ _),_])) | a == "roots" = do
+  [_,arr,i] <- mapM k2llvmExp exps
+  getelementptr poly [intConst 2,i] arr
 k2llvmExp (ECall name atypes exps) = codeGenECall name exps
 k2llvmExp (EEnter (ECast clos@(TCon (Prim CLOS _) (rettyp:typs)) fun) fname atypes exps) = do
   let rettyp' = k2llvmType rettyp
   r3 <- load =<< getelementptr typ [intConst offset] r1
   exps' <- mapM k2llvmExp (exp:exps)
   callhigher r3 typ exps'
+-- Used by cyclic data structures
+k2llvmExp (ECast ktotype exp@(ECall (Prim IndexArray _ ) [] [_,EVar (Name a _ _ _),_])) | a == "roots" = do
+  r1 <- load =<< k2llvmExp exp
+  let totype = k2llvmType ktotype
+  k2llvmCastExp totype r1
 -- boolean "optimizations" casts
 k2llvmExp (ECast (TCon (Prim Bool _) _) (ECast _ (ELit (LInt _ 1)))) = return true
 k2llvmExp (ECast (TCon (Prim Bool _) _) (ECast _ (ELit (LInt _ 0)))) = return false
 k2llvmExp (ECast (TCon (Prim BITS8  _) _) (ELit (LInt _ n))) = return (bit8Const  n)
 k2llvmExp (ECast ktotype exp1) = do
   r1 <- k2llvmExp exp1
-  let totype   = k2llvmType ktotype
-      fromtype = getTyp r1
+  let totype = k2llvmType ktotype
+  k2llvmCastExp totype r1
+
+k2llvmCastExp totype r1 = do
+  let fromtype = getTyp r1
   case fromtype of
     Tptr _ -> case totype of
                 Tint _ -> ptrtoint totype r1
                     EmptyArray -> mapM k2llvmExp exps >>= call "EmptyArray"
                     IndexArray -> do
                       [_,arr,i] <- mapM k2llvmExp exps
-                      getelementptr poly [intConst 2,i] arr --  >>= load
+                      getelementptr poly [intConst 2,i] arr >>= load
                     SizeArray  -> do
                       [_,arr] <- mapM k2llvmExp exps
                       getstructelemptr "size" arr >>= load