Skip to content

Commit ba29cf2

Browse files
[mlir][LLVM] Delete LLVMFixedVectorType
1 parent b7b3758 commit ba29cf2

File tree

10 files changed

+78
-176
lines changed

10 files changed

+78
-176
lines changed

mlir/docs/Dialects/LLVM.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -327,11 +327,9 @@ multiple of some fixed size in case of _scalable_ vectors, and the element type.
327327
Vectors cannot be nested and only 1D vectors are supported. Scalable vectors are
328328
still considered 1D.
329329

330-
LLVM dialect uses built-in vector types for _fixed_-size vectors of built-in
331-
types, and provides additional types for fixed-sized vectors of LLVM dialect
332-
types (`LLVMFixedVectorType`) and scalable vectors of any types
333-
(`LLVMScalableVectorType`). These two additional types share the following
334-
syntax:
330+
The LLVM dialect uses built-in vector types for _fixed_-size vectors of built-in
331+
types, and provides additional types for scalable vectors of any types
332+
(`LLVMScalableVectorType`):
335333

336334
```
337335
llvm-vec-type ::= `!llvm.vec<` (`?` `x`)? integer-literal `x` type `>`

mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ namespace LLVM {
6666
}
6767

6868
DEFINE_TRIVIAL_LLVM_TYPE(LLVMVoidType, "llvm.void");
69-
DEFINE_TRIVIAL_LLVM_TYPE(LLVMPPCFP128Type, "llvm.ppc_fp128");
7069
DEFINE_TRIVIAL_LLVM_TYPE(LLVMTokenType, "llvm.token");
7170
DEFINE_TRIVIAL_LLVM_TYPE(LLVMLabelType, "llvm.label");
7271
DEFINE_TRIVIAL_LLVM_TYPE(LLVMMetadataType, "llvm.metadata");

mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.td

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -288,38 +288,6 @@ def LLVMPointerType : LLVMType<"LLVMPointer", "ptr", [
288288
];
289289
}
290290

291-
//===----------------------------------------------------------------------===//
292-
// LLVMFixedVectorType
293-
//===----------------------------------------------------------------------===//
294-
295-
def LLVMFixedVectorType : LLVMType<"LLVMFixedVector", "vec"> {
296-
let summary = "LLVM fixed vector type";
297-
let description = [{
298-
LLVM dialect vector type that supports all element types that are supported
299-
in LLVM vectors but that are not supported by the builtin MLIR vector type.
300-
E.g., LLVMFixedVectorType supports LLVM pointers as element type.
301-
}];
302-
303-
let typeName = "llvm.fixed_vec";
304-
305-
let parameters = (ins "Type":$elementType, "unsigned":$numElements);
306-
let assemblyFormat = [{
307-
`<` $numElements `x` custom<PrettyLLVMType>($elementType) `>`
308-
}];
309-
310-
let genVerifyDecl = 1;
311-
312-
let builders = [
313-
TypeBuilderWithInferredContext<(ins "Type":$elementType,
314-
"unsigned":$numElements)>
315-
];
316-
317-
let extraClassDeclaration = [{
318-
/// Checks if the given type can be used in a vector type.
319-
static bool isValidElementType(Type type);
320-
}];
321-
}
322-
323291
//===----------------------------------------------------------------------===//
324292
// LLVMScalableVectorType
325293
//===----------------------------------------------------------------------===//
@@ -400,4 +368,17 @@ def LLVMX86AMXType : LLVMType<"LLVMX86AMX", "x86_amx"> {
400368
}];
401369
}
402370

371+
//===----------------------------------------------------------------------===//
372+
// LLVMPPCFP128Type
373+
//===----------------------------------------------------------------------===//
374+
375+
def LLVMPPCFP128Type : LLVMType<"LLVMPPCFP128", "ppc_fp128",
376+
[DeclareTypeInterfaceMethods<FloatTypeInterface, ["getFloatSemantics"]>]> {
377+
let summary = "128 bit FP type with IBM double-double semantics";
378+
let description = [{
379+
A 128 bit floating-point type with IBM double-double semantics.
380+
See S_PPCDoubleDouble in APFloat.h for details.
381+
}];
382+
}
383+
403384
#endif // LLVMTYPES_TD

mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp

Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -687,8 +687,6 @@ static Type extractVectorElementType(Type type) {
687687
return vectorType.getElementType();
688688
if (auto scalableVectorType = llvm::dyn_cast<LLVMScalableVectorType>(type))
689689
return scalableVectorType.getElementType();
690-
if (auto fixedVectorType = llvm::dyn_cast<LLVMFixedVectorType>(type))
691-
return fixedVectorType.getElementType();
692690
return type;
693691
}
694692

@@ -725,20 +723,19 @@ static void destructureIndices(Type currType, ArrayRef<GEPArg> indices,
725723
if (rawConstantIndices.size() == 1 || !currType)
726724
continue;
727725

728-
currType =
729-
TypeSwitch<Type, Type>(currType)
730-
.Case<VectorType, LLVMScalableVectorType, LLVMFixedVectorType,
731-
LLVMArrayType>([](auto containerType) {
732-
return containerType.getElementType();
733-
})
734-
.Case([&](LLVMStructType structType) -> Type {
735-
int64_t memberIndex = rawConstantIndices.back();
736-
if (memberIndex >= 0 && static_cast<size_t>(memberIndex) <
737-
structType.getBody().size())
738-
return structType.getBody()[memberIndex];
739-
return nullptr;
740-
})
741-
.Default(Type(nullptr));
726+
currType = TypeSwitch<Type, Type>(currType)
727+
.Case<VectorType, LLVMScalableVectorType, LLVMArrayType>(
728+
[](auto containerType) {
729+
return containerType.getElementType();
730+
})
731+
.Case([&](LLVMStructType structType) -> Type {
732+
int64_t memberIndex = rawConstantIndices.back();
733+
if (memberIndex >= 0 && static_cast<size_t>(memberIndex) <
734+
structType.getBody().size())
735+
return structType.getBody()[memberIndex];
736+
return nullptr;
737+
})
738+
.Default(Type(nullptr));
742739
}
743740
}
744741

@@ -839,11 +836,11 @@ verifyStructIndices(Type baseGEPType, unsigned indexPos,
839836
return verifyStructIndices(elementTypes[gepIndex], indexPos + 1,
840837
indices, emitOpError);
841838
})
842-
.Case<VectorType, LLVMScalableVectorType, LLVMFixedVectorType,
843-
LLVMArrayType>([&](auto containerType) -> LogicalResult {
844-
return verifyStructIndices(containerType.getElementType(), indexPos + 1,
845-
indices, emitOpError);
846-
})
839+
.Case<VectorType, LLVMScalableVectorType, LLVMArrayType>(
840+
[&](auto containerType) -> LogicalResult {
841+
return verifyStructIndices(containerType.getElementType(),
842+
indexPos + 1, indices, emitOpError);
843+
})
847844
.Default([&](auto otherType) -> LogicalResult {
848845
return emitOpError()
849846
<< "type " << otherType << " cannot be indexed (index #"
@@ -3157,16 +3154,14 @@ OpFoldResult LLVM::ZeroOp::fold(FoldAdaptor) {
31573154
//===----------------------------------------------------------------------===//
31583155

31593156
/// Compute the total number of elements in the given type, also taking into
3160-
/// account nested types. Supported types are `VectorType`, `LLVMArrayType` and
3161-
/// `LLVMFixedVectorType`. Everything else is treated as a scalar.
3157+
/// account nested types. Supported types are `VectorType` and `LLVMArrayType`.
3158+
/// Everything else is treated as a scalar.
31623159
static int64_t getNumElements(Type t) {
31633160
if (auto vecType = dyn_cast<VectorType>(t))
31643161
return vecType.getNumElements() * getNumElements(vecType.getElementType());
31653162
if (auto arrayType = dyn_cast<LLVM::LLVMArrayType>(t))
31663163
return arrayType.getNumElements() *
31673164
getNumElements(arrayType.getElementType());
3168-
if (auto vecType = dyn_cast<LLVMFixedVectorType>(t))
3169-
return vecType.getNumElements() * getNumElements(vecType.getElementType());
31703165
assert(!isa<LLVM::LLVMScalableVectorType>(t) &&
31713166
"number of elements of a scalable vector type is unknown");
31723167
return 1;
@@ -3184,8 +3179,6 @@ static bool hasScalableVectorType(Type t) {
31843179
}
31853180
if (auto arrayType = dyn_cast<LLVM::LLVMArrayType>(t))
31863181
return hasScalableVectorType(arrayType.getElementType());
3187-
if (auto vecType = dyn_cast<LLVMFixedVectorType>(t))
3188-
return hasScalableVectorType(vecType.getElementType());
31893182
return false;
31903183
}
31913184

@@ -3265,8 +3258,7 @@ LogicalResult LLVM::ConstantOp::verify() {
32653258
<< "scalable vector type requires a splat attribute";
32663259
return success();
32673260
}
3268-
if (!isa<VectorType, LLVM::LLVMArrayType, LLVM::LLVMFixedVectorType>(
3269-
getType()))
3261+
if (!isa<VectorType, LLVM::LLVMArrayType>(getType()))
32703262
return emitOpError() << "expected vector or array type";
32713263
// The number of elements of the attribute and the type must match.
32723264
int64_t attrNumElements;
@@ -3515,8 +3507,7 @@ LogicalResult LLVM::BitcastOp::verify() {
35153507
if (!resultType)
35163508
return success();
35173509

3518-
auto isVector =
3519-
llvm::IsaPred<VectorType, LLVMScalableVectorType, LLVMFixedVectorType>;
3510+
auto isVector = llvm::IsaPred<VectorType, LLVMScalableVectorType>;
35203511

35213512
// Due to bitcast requiring both operands to be of the same size, it is not
35223513
// possible for only one of the two to be a pointer of vectors.
@@ -3982,7 +3973,6 @@ void LLVMDialect::initialize() {
39823973

39833974
// clang-format off
39843975
addTypes<LLVMVoidType,
3985-
LLVMPPCFP128Type,
39863976
LLVMTokenType,
39873977
LLVMLabelType,
39883978
LLVMMetadataType>();

mlir/lib/Dialect/LLVMIR/IR/LLVMMemorySlot.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ static bool isSupportedTypeForConversion(Type type) {
137137
// LLVM vector types are only used for either pointers or target specific
138138
// types. These types cannot be casted in the general case, thus the memory
139139
// optimizations do not support them.
140-
if (isa<LLVM::LLVMFixedVectorType, LLVM::LLVMScalableVectorType>(type))
140+
if (isa<LLVM::LLVMScalableVectorType>(type))
141141
return false;
142142

143143
if (auto vectorType = dyn_cast<VectorType>(type)) {

mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ static StringRef getTypeKeyword(Type type) {
4040
.Case<LLVMMetadataType>([&](Type) { return "metadata"; })
4141
.Case<LLVMFunctionType>([&](Type) { return "func"; })
4242
.Case<LLVMPointerType>([&](Type) { return "ptr"; })
43-
.Case<LLVMFixedVectorType, LLVMScalableVectorType>(
44-
[&](Type) { return "vec"; })
43+
.Case<LLVMScalableVectorType>([&](Type) { return "vec"; })
4544
.Case<LLVMArrayType>([&](Type) { return "array"; })
4645
.Case<LLVMStructType>([&](Type) { return "struct"; })
4746
.Case<LLVMTargetExtType>([&](Type) { return "target"; })
@@ -104,9 +103,9 @@ void mlir::LLVM::detail::printType(Type type, AsmPrinter &printer) {
104103
printer << getTypeKeyword(type);
105104

106105
llvm::TypeSwitch<Type>(type)
107-
.Case<LLVMPointerType, LLVMArrayType, LLVMFixedVectorType,
108-
LLVMScalableVectorType, LLVMFunctionType, LLVMTargetExtType,
109-
LLVMStructType>([&](auto type) { type.print(printer); });
106+
.Case<LLVMPointerType, LLVMArrayType, LLVMScalableVectorType,
107+
LLVMFunctionType, LLVMTargetExtType, LLVMStructType>(
108+
[&](auto type) { type.print(printer); });
110109
}
111110

112111
//===----------------------------------------------------------------------===//
@@ -143,14 +142,11 @@ static Type parseVectorType(AsmParser &parser) {
143142
}
144143

145144
bool isScalable = dims.size() == 2;
146-
if (isScalable)
147-
return parser.getChecked<LLVMScalableVectorType>(loc, elementType, dims[1]);
148-
if (elementType.isSignlessIntOrFloat()) {
149-
parser.emitError(typePos)
150-
<< "cannot use !llvm.vec for built-in primitives, use 'vector' instead";
145+
if (!isScalable) {
146+
parser.emitError(dimPos) << "expected scalable vector";
151147
return Type();
152148
}
153-
return parser.getChecked<LLVMFixedVectorType>(loc, elementType, dims[0]);
149+
return parser.getChecked<LLVMScalableVectorType>(loc, elementType, dims[1]);
154150
}
155151

156152
/// Attempts to set the body of an identified structure type. Reports a parsing

0 commit comments

Comments
 (0)