// TFLite specific attribute that is used when generating the output
// flatbuffer.
- let hasOptions = 0b1;
+ let hasOptions = 1;
}
```
// Whether the attribute is optional. Typically requires a custom
// convertFromStorage method to handle the case where the attribute is
// not present.
- bit isOptional = 0b0;
+ bit isOptional = 0;
}
// Decorates an attribute to have an (unvalidated) default value if not present.
let returnType = "Optional<" # attr.returnType #">";
let convertFromStorage = "$_self ? " # returnType # "(" #
attr.convertFromStorage # ") : (llvm::None)";
- let isOptional = 0b1;
+ let isOptional = 1;
// Remember `attr`'s def name.
// TOOD(b/132458159): consider embedding Attr as a field.
// TODO(b/120163349): figure out a better way to write canonicalization
// patterns in TableGen rules directly instead of using this marker
// and C++ implementations.
- bit hasCanonicalizer = 0b0;
+ bit hasCanonicalizer = 0;
// Whether this op has a constant folder.
- bit hasConstantFolder = 0b0;
+ bit hasConstantFolder = 0;
// Whether this op has a folder.
- bit hasFolder = 0b0;
+ bit hasFolder = 0;
// Op traits.
list<OpTrait> traits = props;
} // namespace StandardTypes
-inline bool Type::isBF16() const { return getKind() == StandardTypes::BF16; }
-inline bool Type::isF16() const { return getKind() == StandardTypes::F16; }
-inline bool Type::isF32() const { return getKind() == StandardTypes::F32; }
-inline bool Type::isF64() const { return getKind() == StandardTypes::F64; }
+inline bool Type::isBF16() { return getKind() == StandardTypes::BF16; }
+inline bool Type::isF16() { return getKind() == StandardTypes::F16; }
+inline bool Type::isF32() { return getKind() == StandardTypes::F32; }
+inline bool Type::isF64() { return getKind() == StandardTypes::F64; }
-inline bool Type::isIndex() const { return getKind() == StandardTypes::Index; }
+inline bool Type::isIndex() { return getKind() == StandardTypes::Index; }
/// Index is a special integer-like type with unknown platform-dependent bit
/// width.
};
/// Return true if this is an integer type with the specified width.
-inline bool Type::isInteger(unsigned width) const {
+inline bool Type::isInteger(unsigned width) {
if (auto intTy = dyn_cast<IntegerType>())
return intTy.getWidth() == width;
return false;
}
-inline bool Type::isIntOrIndex() const {
+inline bool Type::isIntOrIndex() {
return isa<IndexType>() || isa<IntegerType>();
}
-inline bool Type::isIntOrIndexOrFloat() const {
+inline bool Type::isIntOrIndexOrFloat() {
return isa<IndexType>() || isa<IntegerType>() || isa<FloatType>();
}
-inline bool Type::isIntOrFloat() const {
+inline bool Type::isIntOrFloat() {
return isa<IntegerType>() || isa<FloatType>();
}
}
/// Return the bitwidth of this float type.
- unsigned getWidth() const;
+ unsigned getWidth();
/// Return the floating semantics of this float type.
- const llvm::fltSemantics &getFloatSemantics() const;
+ const llvm::fltSemantics &getFloatSemantics();
};
/// This is a common base class between Vector, UnrankedTensor, and RankedTensor
unsigned getKind() const;
/// Return the LLVMContext in which this type was uniqued.
- MLIRContext *getContext() const;
+ MLIRContext *getContext();
/// Get the dialect this type is registered to.
- const Dialect &getDialect() const;
+ const Dialect &getDialect();
// Convenience predicates. This is only for floating point types,
// derived types should use isa/dyn_cast.
- bool isIndex() const;
- bool isBF16() const;
- bool isF16() const;
- bool isF32() const;
- bool isF64() const;
+ bool isIndex();
+ bool isBF16();
+ bool isF16();
+ bool isF32();
+ bool isF64();
/// Return true if this is an integer type with the specified width.
- bool isInteger(unsigned width) const;
+ bool isInteger(unsigned width);
/// Return the bit width of an integer or a float type, assert failure on
/// other types.
- unsigned getIntOrFloatBitWidth() const;
+ unsigned getIntOrFloatBitWidth();
/// Return true if this is an integer or index type.
- bool isIntOrIndex() const;
+ bool isIntOrIndex();
/// Return true if this is an integer, index, or float type.
- bool isIntOrIndexOrFloat() const;
+ bool isIntOrIndexOrFloat();
/// Return true of this is an integer or a float type.
- bool isIntOrFloat() const;
+ bool isIntOrFloat();
/// Print the current type.
- void print(raw_ostream &os) const;
- void dump() const;
+ void print(raw_ostream &os);
+ void dump();
friend ::llvm::hash_code hash_value(Type arg);
def AddFOp : FloatArithmeticOp<"addf"> {
let summary = "floating point addition operation";
- let hasConstantFolder = 0b1;
+ let hasConstantFolder = 1;
}
def AddIOp : IntArithmeticOp<"addi", [Commutative]> {
let summary = "integer addition operation";
let hasFolder = 1;
- let hasConstantFolder = 0b1;
+ let hasConstantFolder = 1;
}
def AllocOp : Std_Op<"alloc"> {
MemRefType getType() { return getResult()->getType().cast<MemRefType>(); }
}];
- let hasCanonicalizer = 0b1;
+ let hasCanonicalizer = 1;
}
def AndOp : IntArithmeticOp<"and", [Commutative]> {
let summary = "integer binary and";
- let hasConstantFolder = 0b1;
+ let hasConstantFolder = 1;
let hasFolder = 1;
}
operand_iterator arg_operand_end() { return operand_end(); }
}];
- let hasCanonicalizer = 0b1;
+ let hasCanonicalizer = 1;
}
def ConstantOp : Std_Op<"constant", [NoSideEffect]> {
let arguments = (ins MemRef<AnyType>:$memref);
- let hasCanonicalizer = 0b1;
+ let hasCanonicalizer = 1;
}
def DimOp : Std_Op<"dim", [NoSideEffect]> {
}
}];
- let hasConstantFolder = 0b1;
+ let hasConstantFolder = 1;
}
def DivFOp : FloatArithmeticOp<"divf"> {
def DivISOp : IntArithmeticOp<"divis"> {
let summary = "signed integer division operation";
- let hasConstantFolder = 0b1;
+ let hasConstantFolder = 1;
}
def DivIUOp : IntArithmeticOp<"diviu"> {
let summary = "unsigned integer division operation";
- let hasConstantFolder = 0b1;
+ let hasConstantFolder = 1;
}
def ExtractElementOp : Std_Op<"extract_element", [NoSideEffect]> {
}
}];
- let hasConstantFolder = 0b1;
+ let hasConstantFolder = 1;
}
def MemRefCastOp : CastOp<"memref_cast"> {
def MulFOp : FloatArithmeticOp<"mulf"> {
let summary = "foating point multiplication operation";
- let hasConstantFolder = 0b1;
+ let hasConstantFolder = 1;
}
def MulIOp : IntArithmeticOp<"muli", [Commutative]> {
let summary = "integer multiplication operation";
- let hasConstantFolder = 0b1;
+ let hasConstantFolder = 1;
let hasFolder = 1;
}
def OrOp : IntArithmeticOp<"or", [Commutative]> {
let summary = "integer binary or";
- let hasConstantFolder = 0b1;
+ let hasConstantFolder = 1;
let hasFolder = 1;
}
def RemISOp : IntArithmeticOp<"remis"> {
let summary = "signed integer division remainder operation";
- let hasConstantFolder = 0b1;
+ let hasConstantFolder = 1;
}
def RemIUOp : IntArithmeticOp<"remiu"> {
let summary = "unsigned integer division remainder operation";
- let hasConstantFolder = 0b1;
+ let hasConstantFolder = 1;
}
def ReturnOp : Std_Op<"return", [Terminator]> {
def SubFOp : FloatArithmeticOp<"subf"> {
let summary = "floating point subtraction operation";
- let hasConstantFolder = 0b1;
+ let hasConstantFolder = 1;
}
def SubIOp : IntArithmeticOp<"subi"> {
let summary = "integer subtraction operation";
- let hasConstantFolder = 0b1;
- let hasCanonicalizer = 0b1;
+ let hasConstantFolder = 1;
+ let hasCanonicalizer = 1;
}
def TensorCastOp : CastOp<"tensor_cast"> {
def XOrOp : IntArithmeticOp<"xor", [Commutative]> {
let summary = "integer binary xor";
- let hasConstantFolder = 0b1;
- let hasCanonicalizer = 0b1;
+ let hasConstantFolder = 1;
+ let hasCanonicalizer = 1;
let hasFolder = 1;
}
llvm::errs() << "\n";
}
-void Type::print(raw_ostream &os) const {
+void Type::print(raw_ostream &os) {
ModuleState state(getContext());
ModulePrinter(os, state).printType(*this);
}
-void Type::dump() const { print(llvm::errs()); }
+void Type::dump() { print(llvm::errs()); }
void AffineMap::dump() const {
print(llvm::errs());
// Float Type
//===----------------------------------------------------------------------===//
-unsigned FloatType::getWidth() const {
+unsigned FloatType::getWidth() {
switch (getKind()) {
case StandardTypes::BF16:
case StandardTypes::F16:
}
/// Returns the floating semantics for the given type.
-const llvm::fltSemantics &FloatType::getFloatSemantics() const {
+const llvm::fltSemantics &FloatType::getFloatSemantics() {
if (isBF16())
// Treat BF16 like a double. This is unfortunate but BF16 fltSemantics is
// not defined in LLVM.
llvm_unreachable("non-floating point type used");
}
-unsigned Type::getIntOrFloatBitWidth() const {
+unsigned Type::getIntOrFloatBitWidth() {
assert(isIntOrFloat() && "only ints and floats have a bitwidth");
if (auto intType = dyn_cast<IntegerType>()) {
return intType.getWidth();
unsigned Type::getKind() const { return impl->getKind(); }
/// Get the dialect this type is registered to.
-const Dialect &Type::getDialect() const { return impl->getDialect(); }
+const Dialect &Type::getDialect() { return impl->getDialect(); }
-MLIRContext *Type::getContext() const { return getDialect().getContext(); }
+MLIRContext *Type::getContext() { return getDialect().getContext(); }
unsigned Type::getSubclassData() const { return impl->getSubclassData(); }
void Type::setSubclassData(unsigned val) { impl->setSubclassData(val); }
VectorType::get(shape, FloatType::getF32(f->getContext()));
// Only filter operations that operate on a strict super-vector and have one
// return. This makes testing easier.
- auto filter = [subVectorType](Operation &op) {
- assert(subVectorType.getElementType() ==
- FloatType::getF32(subVectorType.getContext()) &&
+ auto filter = [&](Operation &op) {
+ assert(subVectorType.getElementType().isF32() &&
"Only f32 supported for now");
if (!matcher::operatesOnSuperVectorsOf(op, subVectorType)) {
return false;