Moved the mobile stuff across to use the CCSP API
This commit is contained in:
parent
4bc15aae48
commit
a995d29c32
|
@ -342,7 +342,7 @@ cgenType (A.Array _ t)
|
||||||
_ -> return ()
|
_ -> return ()
|
||||||
tell ["*"]
|
tell ["*"]
|
||||||
cgenType (A.Record n) = genName n
|
cgenType (A.Record n) = genName n
|
||||||
cgenType (A.Mobile t@(A.Array {})) = call genType t
|
cgenType (A.Mobile t@(A.Array {})) = tell["mt_array_t*"]
|
||||||
cgenType (A.Mobile t) = call genType t >> tell ["*"]
|
cgenType (A.Mobile t) = call genType t >> tell ["*"]
|
||||||
|
|
||||||
-- UserProtocol -- not used
|
-- UserProtocol -- not used
|
||||||
|
@ -771,8 +771,10 @@ cgenVariable' checkValid v
|
||||||
= do (A.Mobile t) <- astTypeOf v
|
= do (A.Mobile t) <- astTypeOf v
|
||||||
am <- abbrevModeOfVariable v
|
am <- abbrevModeOfVariable v
|
||||||
case (t, am, mt) of
|
case (t, am, mt) of
|
||||||
(A.Array {}, A.Original,_) -> inner ind v mt
|
(A.Array _ t, _, _) ->
|
||||||
(A.Array {}, _,Nothing) -> inner ind v mt
|
do (cg, n) <- inner ind v Nothing
|
||||||
|
let cast = tell ["("] >> call genType t >> tell ["*)"]
|
||||||
|
return (tell ["("] >> cast >> tell ["(("] >> addPrefix cg n >> tell [")->data))"], 0)
|
||||||
(A.Record {}, A.Original,_) -> inner ind v mt
|
(A.Record {}, A.Original,_) -> inner ind v mt
|
||||||
_ -> inner (ind+1) v mt
|
_ -> inner (ind+1) v mt
|
||||||
inner ind (A.DirectedVariable m dir v) mt
|
inner ind (A.DirectedVariable m dir v) mt
|
||||||
|
@ -789,7 +791,7 @@ cgenVariable' checkValid v
|
||||||
A.Mobile (A.Array ds _) -> return ds
|
A.Mobile (A.Array ds _) -> return ds
|
||||||
(cg, n) <- inner ind v (Just t)
|
(cg, n) <- inner ind v (Just t)
|
||||||
let check = if checkValid then subCheck else A.NoCheck
|
let check = if checkValid then subCheck else A.NoCheck
|
||||||
return ((if (length ds /= length es) then tell ["/*stillarray*/&"] else return ()) >> addPrefix
|
return ((if (length ds /= length es) then tell ["&"] else return ()) >> addPrefix
|
||||||
cg n >> call genArraySubscript check v (map (\e -> (findMeta e, call genExpression e)) es), 0)
|
cg n >> call genArraySubscript check v (map (\e -> (findMeta e, call genExpression e)) es), 0)
|
||||||
inner ind sv@(A.SubscriptedVariable _ (A.SubscriptField m n) v) mt
|
inner ind sv@(A.SubscriptedVariable _ (A.SubscriptField m n) v) mt
|
||||||
= do (cg, ind') <- inner ind v mt
|
= do (cg, ind') <- inner ind v mt
|
||||||
|
@ -860,12 +862,10 @@ cgenArraySubscript check v es
|
||||||
genDynamicDim v i
|
genDynamicDim v i
|
||||||
= do t <- astTypeOf v
|
= do t <- astTypeOf v
|
||||||
case (t, v) of
|
case (t, v) of
|
||||||
(A.Mobile {}, _) -> do tell ["tock_mobile_sizes("]
|
(A.Mobile {}, _) -> do call genVariable v
|
||||||
call genVariable v
|
tell ["->dimensions[", show i, "]"]
|
||||||
tell [")[", show i, "]"]
|
(_, A.DerefVariable _ v') -> do call genVariable v'
|
||||||
(_, A.DerefVariable _ v') -> do tell ["tock_mobile_sizes("]
|
tell ["->dimensions[", show i, "]"]
|
||||||
call genVariable v'
|
|
||||||
tell [")[", show i, "]"]
|
|
||||||
_ -> call genVariable v >> call genSizeSuffix (show i)
|
_ -> call genVariable v >> call genSizeSuffix (show i)
|
||||||
|
|
||||||
-- | Generate the individual offsets that need adding together to find the
|
-- | Generate the individual offsets that need adding together to find the
|
||||||
|
@ -1337,9 +1337,8 @@ cintroduceSpec (A.Specification _ n (A.IsExpr _ am t e))
|
||||||
case t of
|
case t of
|
||||||
A.Mobile (A.Array ds _) -> do
|
A.Mobile (A.Array ds _) -> do
|
||||||
sequence_ [case d of
|
sequence_ [case d of
|
||||||
A.Dimension e -> do tell ["tock_mobile_sizes("]
|
A.Dimension e -> do genName n
|
||||||
genName n
|
tell ["->dimensions[", show i, "]="]
|
||||||
tell [")[", show i, "]="]
|
|
||||||
call genExpression e
|
call genExpression e
|
||||||
tell [";"]
|
tell [";"]
|
||||||
A.UnknownDimension -> return ()
|
A.UnknownDimension -> return ()
|
||||||
|
@ -1887,29 +1886,29 @@ cgenAssert m e
|
||||||
|
|
||||||
--{{{ mobiles
|
--{{{ mobiles
|
||||||
cgenAllocMobile :: Meta -> A.Type -> Maybe A.Expression -> CGen()
|
cgenAllocMobile :: Meta -> A.Type -> Maybe A.Expression -> CGen()
|
||||||
cgenAllocMobile m (A.Mobile t@(A.Array ds _)) Nothing
|
cgenAllocMobile m (A.Mobile t@(A.Array ds innerT)) Nothing
|
||||||
= do tell ["(void*)(("]
|
= do tell ["MTAllocArray(wptr,"]
|
||||||
call genType A.Int
|
mobileElemType innerT
|
||||||
-- TODO use some Tock function instead of malloc
|
tell [",", show $ length ds]
|
||||||
tell ["*)malloc((", show (length ds), "*sizeof("]
|
prefixComma $ [call genExpression e | A.Dimension e <- ds]
|
||||||
call genType A.Int
|
tell [")"]
|
||||||
tell [")) + ("]
|
|
||||||
call genBytesIn m t (Left False)
|
|
||||||
tell [")) + ", show (length ds), ")"]
|
|
||||||
cgenAllocMobile m (A.Mobile t) Nothing
|
cgenAllocMobile m (A.Mobile t) Nothing
|
||||||
= do tell ["malloc("]
|
= do tell ["MTAlloc(wptr,"]
|
||||||
call genBytesIn m t (Left False)
|
mobileElemType t
|
||||||
tell [")"]
|
tell [")"]
|
||||||
--TODO add a pass, just for C, that pulls out the initialisation expressions for mobiles
|
--TODO add a pass, just for C, that pulls out the initialisation expressions for mobiles
|
||||||
-- into a subsequent assignment
|
-- into a subsequent assignment
|
||||||
cgenAllocMobile _ _ _ = call genMissing "Mobile allocation with initialising-expression"
|
cgenAllocMobile _ _ _ = call genMissing "Mobile allocation with initialising-expression"
|
||||||
|
|
||||||
-- TODO adjust for being a mobile array
|
mobileElemType :: A.Type -> CGen ()
|
||||||
|
mobileElemType A.Int = mobileElemType cIntReplacement
|
||||||
|
mobileElemType t = tell ["MT_NUM_", showOccam t]
|
||||||
|
|
||||||
cgenClearMobile :: Meta -> A.Variable -> CGen ()
|
cgenClearMobile :: Meta -> A.Variable -> CGen ()
|
||||||
cgenClearMobile _ v
|
cgenClearMobile _ v
|
||||||
= do tell ["if("]
|
= do tell ["if("]
|
||||||
genVar
|
genVar
|
||||||
tell ["!=NULL){free("]
|
tell ["!=NULL){MTRelease("]
|
||||||
genVar
|
genVar
|
||||||
tell [");"]
|
tell [");"]
|
||||||
genVar
|
genVar
|
||||||
|
|
|
@ -495,10 +495,6 @@ int64_t occam_convert_double_int64_t_trunc (double v, const char *pos) {
|
||||||
|
|
||||||
//{{{ Mobile Stuff
|
//{{{ Mobile Stuff
|
||||||
|
|
||||||
static inline INT * tock_mobile_sizes(void* const ptr) occam_unused;
|
|
||||||
static inline INT * tock_mobile_sizes(void* const ptr) {
|
|
||||||
return ((INT *)ptr) - 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
//}}}
|
//}}}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user