mkArrayDecl :: CoreId -> Name -> RunGen Definition
mkArrayDecl coreId name = do
    typeMap <- gets typeMap
    nameMap <- gets nameMap
    let Just ty = Map.lookup name typeMap
        Just (coreId', addr) = Map.lookup name nameMap
     -- convert address to global when the given array is on another core
        addr'
            | coreId' == coreId = addr
            | otherwise = addr `toGlobal` coreId'
    return $ if coreId' == sharedId
       then [cedecl| volatile void * const $id:name = (void *)$addr; |]
       else [cedecl| volatile $ty:ty * const $id:name = ($ty:ty *)$addr'; |]
mkArrayDecl :: CoreId -> Name -> RunGen Definition
mkArrayDecl coreId name = do
    typeMap <- gets typeMap
    nameMap <- gets nameMap
    let Just ty = Map.lookup name typeMap
        Just (coreId', addr) = Map.lookup name nameMap
     -- convert address to global when the given array is on another core
        addr'
            | coreId' == coreId = addr
            | otherwise = addr `toGlobal` coreId'
    return $ if coreId' == sharedId
       then [cedecl| volatile void * const $id:name = (void *)$addr; |]
       else [cedecl| volatile $ty:ty * const $id:name = ($ty:ty *)$addr'; |]
mkArrayDecl coreId name = do
    typeMap <- gets typeMap
    nameMap <- gets nameMap
    let Just ty = Map.lookup name typeMap
        Just (coreId', addr) = Map.lookup name nameMap
     -- convert address to global when the given array is on another core
        addr'
            | coreId' == coreId = addr
            | otherwise = addr `toGlobal` coreId'
    return $ if coreId' == sharedId
       then [cedecl| volatile void * const $id:name = (void *)$addr; |]
       else [cedecl| volatile $ty:ty * const $id:name = ($ty:ty *)$addr'; |]