summaryrefslogtreecommitdiffstats
path: root/mlir/lib/IR/Operation.cpp
diff options
context:
space:
mode:
authorRiver Riddle <riverriddle@google.com>2018-10-30 14:59:22 -0700
committerjpienaar <jpienaar@google.com>2019-03-29 13:45:54 -0700
commit4c465a181db49c436f62da303e8fdd3ed317fee7 (patch)
treefb190912d0714222d6e336e19d5b8ea16342fb6e /mlir/lib/IR/Operation.cpp
parent75376b8e33c67a42e3dca2c597197e0622b6eaa2 (diff)
downloadbcm5719-llvm-4c465a181db49c436f62da303e8fdd3ed317fee7.tar.gz
bcm5719-llvm-4c465a181db49c436f62da303e8fdd3ed317fee7.zip
Implement value type abstraction for types.
This is done by changing Type to be a POD interface around an underlying pointer storage and adding in-class support for isa/dyn_cast/cast. PiperOrigin-RevId: 219372163
Diffstat (limited to 'mlir/lib/IR/Operation.cpp')
-rw-r--r--mlir/lib/IR/Operation.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/mlir/lib/IR/Operation.cpp b/mlir/lib/IR/Operation.cpp
index 2ed09b83b53..0722421c8ba 100644
--- a/mlir/lib/IR/Operation.cpp
+++ b/mlir/lib/IR/Operation.cpp
@@ -377,7 +377,7 @@ bool OpTrait::impl::verifyAtLeastNResults(const Operation *op,
}
bool OpTrait::impl::verifySameOperandsAndResult(const Operation *op) {
- auto *type = op->getResult(0)->getType();
+ auto type = op->getResult(0)->getType();
for (unsigned i = 1, e = op->getNumResults(); i < e; ++i) {
if (op->getResult(i)->getType() != type)
return op->emitOpError(
@@ -393,19 +393,19 @@ bool OpTrait::impl::verifySameOperandsAndResult(const Operation *op) {
/// If this is a vector type, or a tensor type, return the scalar element type
/// that it is built around, otherwise return the type unmodified.
-static Type *getTensorOrVectorElementType(Type *type) {
- if (auto *vec = dyn_cast<VectorType>(type))
- return vec->getElementType();
+static Type getTensorOrVectorElementType(Type type) {
+ if (auto vec = type.dyn_cast<VectorType>())
+ return vec.getElementType();
// Look through tensor<vector<...>> to find the underlying element type.
- if (auto *tensor = dyn_cast<TensorType>(type))
- return getTensorOrVectorElementType(tensor->getElementType());
+ if (auto tensor = type.dyn_cast<TensorType>())
+ return getTensorOrVectorElementType(tensor.getElementType());
return type;
}
bool OpTrait::impl::verifyResultsAreFloatLike(const Operation *op) {
for (auto *result : op->getResults()) {
- if (!isa<FloatType>(getTensorOrVectorElementType(result->getType())))
+ if (!getTensorOrVectorElementType(result->getType()).isa<FloatType>())
return op->emitOpError("requires a floating point type");
}
@@ -414,7 +414,7 @@ bool OpTrait::impl::verifyResultsAreFloatLike(const Operation *op) {
bool OpTrait::impl::verifyResultsAreIntegerLike(const Operation *op) {
for (auto *result : op->getResults()) {
- if (!isa<IntegerType>(getTensorOrVectorElementType(result->getType())))
+ if (!getTensorOrVectorElementType(result->getType()).isa<IntegerType>())
return op->emitOpError("requires an integer type");
}
return false;
@@ -436,7 +436,7 @@ void impl::buildBinaryOp(Builder *builder, OperationState *result,
bool impl::parseBinaryOp(OpAsmParser *parser, OperationState *result) {
SmallVector<OpAsmParser::OperandType, 2> ops;
- Type *type;
+ Type type;
return parser->parseOperandList(ops, 2) ||
parser->parseOptionalAttributeDict(result->attributes) ||
parser->parseColonType(type) ||
@@ -448,7 +448,7 @@ void impl::printBinaryOp(const Operation *op, OpAsmPrinter *p) {
*p << op->getName() << ' ' << *op->getOperand(0) << ", "
<< *op->getOperand(1);
p->printOptionalAttrDict(op->getAttrs());
- *p << " : " << *op->getResult(0)->getType();
+ *p << " : " << op->getResult(0)->getType();
}
//===----------------------------------------------------------------------===//
@@ -456,14 +456,14 @@ void impl::printBinaryOp(const Operation *op, OpAsmPrinter *p) {
//===----------------------------------------------------------------------===//
void impl::buildCastOp(Builder *builder, OperationState *result,
- SSAValue *source, Type *destType) {
+ SSAValue *source, Type destType) {
result->addOperands(source);
result->addTypes(destType);
}
bool impl::parseCastOp(OpAsmParser *parser, OperationState *result) {
OpAsmParser::OperandType srcInfo;
- Type *srcType, *dstType;
+ Type srcType, dstType;
return parser->parseOperand(srcInfo) || parser->parseColonType(srcType) ||
parser->resolveOperand(srcInfo, srcType, result->operands) ||
parser->parseKeywordType("to", dstType) ||
@@ -472,5 +472,5 @@ bool impl::parseCastOp(OpAsmParser *parser, OperationState *result) {
void impl::printCastOp(const Operation *op, OpAsmPrinter *p) {
*p << op->getName() << ' ' << *op->getOperand(0) << " : "
- << *op->getOperand(0)->getType() << " to " << *op->getResult(0)->getType();
+ << op->getOperand(0)->getType() << " to " << op->getResult(0)->getType();
}
OpenPOWER on IntegriCloud