This is an archive of the discontinued LLVM Phabricator instance.

[mlir] use built-in vector types instead of LLVM dialect types when possible
ClosedPublic

Authored by ftynse on Jan 11 2021, 5:13 AM.

Details

Summary

Continue the convergence between LLVM dialect and built-in types by using the
built-in vector type whenever possible, that is for fixed vectors of built-in
integers and built-in floats. LLVM dialect vector type is still in use for
pointers, less frequent floating point types that do not have a built-in
equivalent, and scalable vectors. However, the top-level LLVMVectorType class
has been removed in favor of free functions capable of inspecting both built-in
and LLVM dialect vector types: LLVM::getVectorElementType,
LLVM::getNumVectorElements and LLVM::getFixedVectorType. Additional work is
necessary to design an implemented the extensions to built-in types so as to
remove the LLVMFixedVectorType entirely.

Note that the default output format for the built-in vectors does not have
whitespace around the x separator, e.g., vector<4xf32> as opposed to the
LLVM dialect vector type format that does, e.g., !llvm.vec<4 x fp128>. This
required changing the FileCheck patterns in several tests.

Diff Detail

Event Timeline

ftynse created this revision.Jan 11 2021, 5:13 AM
ftynse requested review of this revision.Jan 11 2021, 5:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 11 2021, 5:13 AM
silvas accepted this revision.Jan 11 2021, 11:16 AM

Thanks! This looks great!

mlir/docs/Dialects/LLVM.md
264

I think this section might require a bit more updating. Should we touch on the use of LLVMFixedVectorType vs VectorType and when they are currently used?

This revision is now accepted and ready to land.Jan 11 2021, 11:16 AM
mehdi_amini accepted this revision.Jan 11 2021, 4:21 PM

Thanks Alex!

ftynse added inline comments.Jan 12 2021, 12:59 AM
mlir/docs/Dialects/LLVM.md
264

I'll do this in a single sweep for all types, there is a common blob that needs to be written.

mehdi_amini added inline comments.Jun 14 2023, 8:33 PM
mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp
369

Seems like we don't check the element type or the rank for LLVMScalableVectorType ?

Herald added a reviewer: dcaballe. · View Herald Transcript
Herald added a reviewer: kuhar. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript