This repository was archived by the owner on Aug 5, 2024. It is now read-only.
File tree 4 files changed +20
-5
lines changed
4 files changed +20
-5
lines changed Original file line number Diff line number Diff line change
1
+ condstore1 (inout v :: double) (w :: double) (b :: bool) :: () :=
2
+ v[b] <- w;
3
+
4
+ condstore2 {n} (inout A :: double[n]) (w :: double) (b :: bool) :: () :=
5
+ A[b] <- w;
6
+
7
+ condstore3 {n} (inout A :: double[n]) (w :: double) :: () :=
8
+ A[A < w] <- w;
Original file line number Diff line number Diff line change @@ -1705,6 +1705,9 @@ compileLoc loc@(Index a idxs) = do aloc <- asLoc $ compileStat a
1705
1705
vty@ (VecType {}) -> do
1706
1706
idxloc <- asLoc $ compileStat idx
1707
1707
return $ Left (length $ getIndices vty, vecBaseType vty, idxloc)
1708
+ BoolType -> do
1709
+ idxloc <- asLoc $ compileStat idx
1710
+ return $ Left (0 , BoolType , idxloc)
1708
1711
ty -> do
1709
1712
idxex <- asExp $ compileStat idx
1710
1713
return $ Right idxex
Original file line number Diff line number Diff line change @@ -942,9 +942,9 @@ getLocType :: Location CExpr -> Type
942
942
getLocType (Ref ty v) = ty
943
943
getLocType (Index a idxs) = normalizeTypes $ getTypeIdx idxs (normalizeTypes $ getType a)
944
944
where getTypeIdx [] aty = aty
945
- getTypeIdx (idx: idxs) aty@ ( VecType {}) = getTypeIdxty [] (getType idx) idxs aty
945
+ getTypeIdx (idx: idxs) aty = getTypeIdxty [] (getType idx) idxs aty
946
946
947
- getTypeIdxty acc idxty idxs vty@ ( VecType {}) =
947
+ getTypeIdxty acc idxty idxs vty =
948
948
case normalizeTypes idxty of
949
949
VecType st' idxs' idxtybase -> VecType st' idxs' $
950
950
getTypeIdxty (acc ++ idxs') idxtybase idxs vty
Original file line number Diff line number Diff line change @@ -968,11 +968,15 @@ typeCheckLoc pos (Index a idxs) = do -- see note [indexing rules] and see `getLo
968
968
idxty <- typeCheck idx
969
969
typeCheckIdxty oty [] idxty idxs aty
970
970
typeCheckIdx oty (idx: idxs) ty = do
971
- addUError $ UGenTyError pos oty " Too many indices on expression of type"
972
- return ty
971
+ idxty <- typeCheck idx
972
+ case idxty of
973
+ BoolType -> typeCheckIdxty oty [] idxty idxs ty
974
+ _ -> do addUError $ UGenTyError pos oty
975
+ " Too many indices on expression of type"
976
+ return ty
973
977
974
978
typeCheckIdxty :: Type -> [CExpr ] -> Type -> [CExpr ] -> Type -> UM Type
975
- typeCheckIdxty oty acc idxty idxs vty@ ( VecType {}) =
979
+ typeCheckIdxty oty acc idxty idxs vty =
976
980
case normalizeTypes idxty of
977
981
VecType st' idxs' idxtybase -> -- result shape equals shape of index
978
982
VecType st' idxs' <$> (typeCheckIdxty oty (acc ++ idxs') idxtybase idxs vty)
You can’t perform that action at this time.
0 commit comments