Skip to content

Commit 44cfa13

Browse files
[mlir][LLVM] Delete LLVMFixedVectorType
1 parent fbd5acf commit 44cfa13

File tree

10 files changed

+79
-176
lines changed

10 files changed

+79
-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
@@ -67,7 +67,6 @@ namespace LLVM {
6767
}
6868

6969
DEFINE_TRIVIAL_LLVM_TYPE(LLVMVoidType, "llvm.void");
70-
DEFINE_TRIVIAL_LLVM_TYPE(LLVMPPCFP128Type, "llvm.ppc_fp128");
7170
DEFINE_TRIVIAL_LLVM_TYPE(LLVMTokenType, "llvm.token");
7271
DEFINE_TRIVIAL_LLVM_TYPE(LLVMLabelType, "llvm.label");
7372
DEFINE_TRIVIAL_LLVM_TYPE(LLVMMetadataType, "llvm.metadata");

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

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
include "mlir/Dialect/LLVMIR/LLVMOpBase.td"
1313
include "mlir/IR/AttrTypeBase.td"
14+
include "mlir/IR/BuiltinTypeInterfaces.td"
1415
include "mlir/IR/BuiltinTypes.td"
1516
include "mlir/Interfaces/DataLayoutInterfaces.td"
1617
include "mlir/Interfaces/MemorySlotInterfaces.td"
@@ -288,38 +289,6 @@ def LLVMPointerType : LLVMType<"LLVMPointer", "ptr", [
288289
];
289290
}
290291

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-
323292
//===----------------------------------------------------------------------===//
324293
// LLVMScalableVectorType
325294
//===----------------------------------------------------------------------===//
@@ -400,4 +369,17 @@ def LLVMX86AMXType : LLVMType<"LLVMX86AMX", "x86_amx"> {
400369
}];
401370
}
402371

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

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

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

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

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

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

31103107
/// Compute the total number of elements in the given type, also taking into
3111-
/// account nested types. Supported types are `VectorType`, `LLVMArrayType` and
3112-
/// `LLVMFixedVectorType`. Everything else is treated as a scalar.
3108+
/// account nested types. Supported types are `VectorType` and `LLVMArrayType`.
3109+
/// Everything else is treated as a scalar.
31133110
static int64_t getNumElements(Type t) {
31143111
if (auto vecType = dyn_cast<VectorType>(t))
31153112
return vecType.getNumElements() * getNumElements(vecType.getElementType());
31163113
if (auto arrayType = dyn_cast<LLVM::LLVMArrayType>(t))
31173114
return arrayType.getNumElements() *
31183115
getNumElements(arrayType.getElementType());
3119-
if (auto vecType = dyn_cast<LLVMFixedVectorType>(t))
3120-
return vecType.getNumElements() * getNumElements(vecType.getElementType());
31213116
assert(!isa<LLVM::LLVMScalableVectorType>(t) &&
31223117
"number of elements of a scalable vector type is unknown");
31233118
return 1;
@@ -3135,8 +3130,6 @@ static bool hasScalableVectorType(Type t) {
31353130
}
31363131
if (auto arrayType = dyn_cast<LLVM::LLVMArrayType>(t))
31373132
return hasScalableVectorType(arrayType.getElementType());
3138-
if (auto vecType = dyn_cast<LLVMFixedVectorType>(t))
3139-
return hasScalableVectorType(vecType.getElementType());
31403133
return false;
31413134
}
31423135

@@ -3216,8 +3209,7 @@ LogicalResult LLVM::ConstantOp::verify() {
32163209
<< "scalable vector type requires a splat attribute";
32173210
return success();
32183211
}
3219-
if (!isa<VectorType, LLVM::LLVMArrayType, LLVM::LLVMFixedVectorType>(
3220-
getType()))
3212+
if (!isa<VectorType, LLVM::LLVMArrayType>(getType()))
32213213
return emitOpError() << "expected vector or array type";
32223214
// The number of elements of the attribute and the type must match.
32233215
int64_t attrNumElements;
@@ -3466,8 +3458,7 @@ LogicalResult LLVM::BitcastOp::verify() {
34663458
if (!resultType)
34673459
return success();
34683460

3469-
auto isVector =
3470-
llvm::IsaPred<VectorType, LLVMScalableVectorType, LLVMFixedVectorType>;
3461+
auto isVector = llvm::IsaPred<VectorType, LLVMScalableVectorType>;
34713462

34723463
// Due to bitcast requiring both operands to be of the same size, it is not
34733464
// possible for only one of the two to be a pointer of vectors.
@@ -3883,7 +3874,6 @@ void LLVMDialect::initialize() {
38833874

38843875
// clang-format off
38853876
addTypes<LLVMVoidType,
3886-
LLVMPPCFP128Type,
38873877
LLVMTokenType,
38883878
LLVMLabelType,
38893879
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)