| 276 | | The following operations on vectors will be supported. They will need to be implemented at the Haskell/core primop layer, Cmm MachOp layer and optional support in the code generators. |
| | 276 | The following operations on vectors will be supported. They will need to be implemented at the Haskell/core primop layer, Cmm `MachOp` layer and optional support in the code generators. |
| | 277 | |
| | 278 | In the following, `<t>` ranges over `Int<w>`, `Word<w>`, `Float`, `Double`. |
| | 279 | |
| | 280 | Loading and storing vectors in arrays, ByteArray# and raw Addr# |
| | 281 | {{{ |
| | 282 | readInt<w>Vec<m>Array# :: MutableByteArray# d -> Int# -> Int# -> State# d -> State# d |
| | 283 | readWord<w>Vec<m>Array# :: MutableByteArray# d -> Int# -> Word# -> State# d -> State# d |
| | 284 | readFloatVec<m>Array# :: MutableByteArray# d -> Int# -> Float# -> State# d -> State# d |
| | 285 | readDoubleVec<m>Array# :: MutableByteArray# d -> Int# -> Double# -> State# d -> State# d |
| | 286 | |
| | 287 | writeInt<w>Vec<m>Array# :: MutableByteArray# d -> Int# -> Int# -> State# d -> State# d |
| | 288 | writeWord<w>Vec<m>Array# :: MutableByteArray# d -> Int# -> Word# -> State# d -> State# d |
| | 289 | writeFloatVec<m>Array# :: MutableByteArray# d -> Int# -> Float# -> State# d -> State# d |
| | 290 | writeDoubleVec<m>Array# :: MutableByteArray# d -> Int# -> Double# -> State# d -> State# d |
| | 291 | |
| | 292 | readInt<w>Vec<m>OffAddr# :: Addr# -> Int# -> Int# -> State# d -> State# d |
| | 293 | readWord<w>Vec<m>OffAddr# :: Addr# -> Int# -> Word# -> State# d -> State# d |
| | 294 | readFloatVec<m>OffAddr# :: Addr# -> Int# -> Float# -> State# d -> State# d |
| | 295 | readDoubleVec<m>OffAddr# :: Addr# -> Int# -> Double# -> State# d -> State# d |
| | 296 | |
| | 297 | writeInt<w>Vec<m>OffAddr# :: Addr# -> Int# -> Int# -> State# d -> State# d |
| | 298 | writeWord<w>Vec<m>OffAddr# :: Addr# -> Int# -> Word# -> State# d -> State# d |
| | 299 | writeFloatVec<m>OffAddr# :: Addr# -> Int# -> Float# -> State# d -> State# d |
| | 300 | writeDoubleVec<m>OffAddr# :: Addr# -> Int# -> Double# -> State# d -> State# d |
| | 301 | }}} |
| 328 | | TODO: |
| 329 | | * conversion sign/width operations, e.g. Word <-> Int, Word8 <-> Word16 etc. |
| 330 | | * conversion fp operations, e.g. Float <-> Int |
| 331 | | Should also consider: |
| | 360 | Integer width narrow/widen operations: |
| | 361 | {{{ |
| | 362 | narrowInt<w>To<w'>Vec<m># :: Int<w>Vec<m># -> Int<w'>Vec<m># -- for w' < w |
| | 363 | narrowWord<w>To<w'>Vec<m># :: Word<w>Vec<m># -> Word<w'>Vec<m># -- for w' < w |
| | 364 | |
| | 365 | widenInt<w>To<w'>Vec<m># :: Int<w>Vec<m># -> Int<w'>Vec<m># -- for w' > w |
| | 366 | widenWord<w>To<w'>Vec<m># :: Word<w>Vec<m># -> Word<w'>Vec<m># -- for w' > w |
| | 367 | }}} |
| | 368 | Note: LLVM calls these truncate and extend (signed extend or unsigned extend) |
| | 369 | |
| | 370 | Floating point conversion: |
| | 371 | {{{ |
| | 372 | narrowDoubleToFloatVec<m># :: DoubleVec<m># -> FloatVec<m># |
| | 373 | widenFloatToDoubleVec<m># :: FloatVec<m># -> DoubleVec<m># |
| | 374 | |
| | 375 | roundFloatToInt32Vec<m> :: FloatVec<m># -> Int32Vec<m># |
| | 376 | roundFloatToInt64Vec<m> :: FloatVec<m># -> Int64Vec<m># |
| | 377 | roundDoubleToInt32Vec<m> :: DoubleVec<m># -> Int32Vec<m># |
| | 378 | roundDoubleToInt64Vec<m> :: DoubleVec<m># -> Int64Vec<m># |
| | 379 | |
| | 380 | truncateFloatToInt32Vec<m> :: FloatVec<m># -> Int32Vec<m># |
| | 381 | truncateFloatToInt64Vec<m> :: FloatVec<m># -> Int64Vec<m># |
| | 382 | truncateDoubleToInt32Vec<m> :: DoubleVec<m># -> Int32Vec<m># |
| | 383 | truncateDoubleToInt64Vec<m> :: DoubleVec<m># -> Int64Vec<m># |
| | 384 | |
| | 385 | promoteInt32ToFloatVec<m> :: Int32Vec<m># -> FloatVec<m># |
| | 386 | promoteInt64ToFloatVec<m> :: Int64Vec<m># -> FloatVec<m># |
| | 387 | promoteInt32ToDoubleVec<m> :: Int32Vec<m># -> DoubleVec<m># |
| | 388 | promoteInt64ToDoubleVec<m> :: Int64Vec<m># -> DoubleVec<m># |
| | 389 | }}} |
| | 390 | |
| | 391 | TODO: Should consider: |