[mlir][bufferization] Let alloc_tensor copy tensor-like values into memrefs (#240102)
This change generalizes `bufferization.alloc_tensor`'s `copy` operand
and result type to `TensorLikeType`.
The `AllocTensorOp::getType` override returning `RankedTensorType` is
eliminated and places that demand a shape (size helpers, verifiers,
canonicalization, etc) now cast to `RankedTensorType` explicitly and
skip any other kind of result type. Verifier checks that result types
that are not a ranked tensor type take no dynamic sizes or size hint.
This generalization allows One-Shot Bufferize to copy tensor-like
values. `allocateTensorForShapedValue` and
`resolveTensorOpOperandConflicts` previously handled builtin tensors
only. With a `copy` operand, the allocation is sized from the `copy`.
Without one, a result that is not a ranked tensor is sized from its
buffer type, which must be static.
The allocation hook still takes `MemRefType`, so further generalization
there is TODO and a non-`MemRefType` buffer is diagnosed.
Also adds tests to cover One-Shot's copies of a custom tensor type, with
static and dynamic shapes, and the new verifier check.
Note for LLVM integration: `AllocTensorOp::getType()` now returns
`TensorLikeType`.
Assisted-by: Claude
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>