Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions mlir/include/mlir/IR/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ class Type {
// Convenience predicates. This is only for floating point types,
// derived types should use isa/dyn_cast.
bool isIndex() const;
bool isFloat() const;
bool isFloat4E2M1FN() const;
bool isFloat6E2M3FN() const;
bool isFloat6E3M2FN() const;
Expand Down Expand Up @@ -164,10 +165,10 @@ class Type {

/// Return true if this is a signless integer or index type.
bool isSignlessIntOrIndex() const;
/// Return true if this is a signless integer, index, or float type.
bool isSignlessIntOrIndexOrFloat() const;
/// Return true of this is a signless integer or a float type.
bool isSignlessIntOrFloat() const;
/// Return true if this is a signless integer, index, or float type.
bool isSignlessIntOrIndexOrFloat() const;

/// Return true if this is an integer (of any signedness) or an index type.
bool isIntOrIndex() const;
Expand Down
22 changes: 10 additions & 12 deletions mlir/lib/IR/Types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ bool Type::isF128() const { return llvm::isa<Float128Type>(*this); }

bool Type::isIndex() const { return llvm::isa<IndexType>(*this); }

bool Type::isFloat() const { return llvm::isa<FloatType>(*this); }

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be seen as fitting here for consistency, however I wonder if the desirable thing wouldn't instead be to remove all the other isXXXX from the generic Type class?

bool Type::isInteger() const { return llvm::isa<IntegerType>(*this); }

/// Return true if this is an integer type with the specified width.
Expand Down Expand Up @@ -109,26 +111,22 @@ bool Type::isUnsignedInteger(unsigned width) const {
}

bool Type::isSignlessIntOrIndex() const {
return isSignlessInteger() || llvm::isa<IndexType>(*this);
}

bool Type::isSignlessIntOrIndexOrFloat() const {
return isSignlessInteger() || llvm::isa<IndexType, FloatType>(*this);
return isSignlessInteger() || isIndex();
}

bool Type::isSignlessIntOrFloat() const {
return isSignlessInteger() || llvm::isa<FloatType>(*this);
return isSignlessInteger() || isFloat();
}

bool Type::isIntOrIndex() const {
return llvm::isa<IntegerType>(*this) || isIndex();
bool Type::isSignlessIntOrIndexOrFloat() const {
return isSignlessIntOrIndex() || isFloat();
}

bool Type::isIntOrFloat() const {
return llvm::isa<IntegerType, FloatType>(*this);
}
bool Type::isIntOrIndex() const { return isInteger() || isIndex(); }

bool Type::isIntOrFloat() const { return isInteger() || isFloat(); }

bool Type::isIntOrIndexOrFloat() const { return isIntOrFloat() || isIndex(); }
bool Type::isIntOrIndexOrFloat() const { return isIntOrIndex() || isFloat(); }

unsigned Type::getIntOrFloatBitWidth() const {
assert(isIntOrFloat() && "only integers and floats have a bitwidth");
Expand Down
Loading