Codegen: Matrixslice support

Fixes #8093.  More cleanup probably possible.
Merge pull request #8094 from cbm755/fix_8093

Codegen: Matrixslice support