forked from OSchip/llvm-project
Return bool from all emitError methods similar to Operation::emitOpError
This simplifies call-sites returning true after emitting an error. After the conversion, dropped braces around single statement blocks as that seems more common. Also, switched to emitError method instead of emitting Error kind using the emitDiagnostic method. TESTED with existing unit tests PiperOrigin-RevId: 224527868
This commit is contained in:
parent
d2d7c11f19
commit
adca59e4f7
|
@ -80,10 +80,10 @@ public:
|
||||||
void dump() const;
|
void dump() const;
|
||||||
|
|
||||||
/// Emit an error about fatal conditions with this operation, reporting up to
|
/// Emit an error about fatal conditions with this operation, reporting up to
|
||||||
/// any diagnostic handlers that may be listening. NOTE: This may terminate
|
/// any diagnostic handlers that may be listening. This function always
|
||||||
/// the containing application, only use when the IR is in an inconsistent
|
/// returns true. NOTE: This may terminate the containing application, only
|
||||||
/// state.
|
/// use when the IR is in an inconsistent state.
|
||||||
void emitError(const Twine &message) const;
|
bool emitError(const Twine &message) const;
|
||||||
|
|
||||||
/// Emit a warning about this operation, reporting up to any diagnostic
|
/// Emit a warning about this operation, reporting up to any diagnostic
|
||||||
/// handlers that may be listening.
|
/// handlers that may be listening.
|
||||||
|
|
|
@ -313,10 +313,10 @@ public:
|
||||||
void dropAllReferences();
|
void dropAllReferences();
|
||||||
|
|
||||||
/// Emit an error about fatal conditions with this operation, reporting up to
|
/// Emit an error about fatal conditions with this operation, reporting up to
|
||||||
/// any diagnostic handlers that may be listening. NOTE: This may terminate
|
/// any diagnostic handlers that may be listening. This function always
|
||||||
/// the containing application, only use when the IR is in an inconsistent
|
/// returns true. NOTE: This may terminate the containing application, only
|
||||||
/// state.
|
/// use when the IR is in an inconsistent state.
|
||||||
void emitError(const Twine &message) const;
|
bool emitError(const Twine &message) const;
|
||||||
|
|
||||||
/// Emit a warning about this operation, reporting up to any diagnostic
|
/// Emit a warning about this operation, reporting up to any diagnostic
|
||||||
/// handlers that may be listening.
|
/// handlers that may be listening.
|
||||||
|
|
|
@ -79,15 +79,15 @@ public:
|
||||||
/// Return the current diagnostic handler, or null if none is present.
|
/// Return the current diagnostic handler, or null if none is present.
|
||||||
DiagnosticHandlerTy getDiagnosticHandler() const;
|
DiagnosticHandlerTy getDiagnosticHandler() const;
|
||||||
|
|
||||||
/// This emits an diagnostic using the registered issue handle if present, or
|
/// Emit a diagnostic using the registered issue handle if present, or with
|
||||||
/// with the default behavior if not. The MLIR compiler should not generally
|
/// the default behavior if not. The MLIR compiler should not generally
|
||||||
/// interact with this, it should use methods on Operation instead.
|
/// interact with this, it should use methods on Operation instead.
|
||||||
void emitDiagnostic(Location location, const Twine &message,
|
void emitDiagnostic(Location location, const Twine &message,
|
||||||
DiagnosticKind kind) const;
|
DiagnosticKind kind) const;
|
||||||
|
|
||||||
/// Emits an error message using the registered issue handle if present, or to
|
/// Emit an error message using the registered issue handle if present, or to
|
||||||
/// the standard error stream otherwise.
|
/// the standard error stream otherwise and return true.
|
||||||
void emitError(Location location, const Twine &message) const;
|
bool emitError(Location location, const Twine &message) const;
|
||||||
|
|
||||||
// This is effectively private given that only MLIRContext.cpp can see the
|
// This is effectively private given that only MLIRContext.cpp can see the
|
||||||
// MLIRContextImpl type.
|
// MLIRContextImpl type.
|
||||||
|
|
|
@ -169,10 +169,10 @@ public:
|
||||||
void erase() { state->erase(); }
|
void erase() { state->erase(); }
|
||||||
|
|
||||||
/// Emit an error about fatal conditions with this operation, reporting up to
|
/// Emit an error about fatal conditions with this operation, reporting up to
|
||||||
/// any diagnostic handlers that may be listening. NOTE: This may terminate
|
/// any diagnostic handlers that may be listening. This function always
|
||||||
/// the containing application, only use when the IR is in an inconsistent
|
/// returns true. NOTE: This may terminate the containing application, only
|
||||||
/// state.
|
/// use when the IR is in an inconsistent state.
|
||||||
void emitError(const Twine &message) const;
|
bool emitError(const Twine &message) const;
|
||||||
|
|
||||||
/// Emit an error with the op name prefixed, like "'dim' op " which is
|
/// Emit an error with the op name prefixed, like "'dim' op " which is
|
||||||
/// convenient for verifiers. This always returns true.
|
/// convenient for verifiers. This always returns true.
|
||||||
|
|
|
@ -185,10 +185,8 @@ public:
|
||||||
|
|
||||||
// Check for the right kind of attribute.
|
// Check for the right kind of attribute.
|
||||||
result = type.dyn_cast<TypeType>();
|
result = type.dyn_cast<TypeType>();
|
||||||
if (!result) {
|
if (!result)
|
||||||
emitError(loc, "invalid kind of type specified");
|
return emitError(loc, "invalid kind of type specified");
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -241,10 +239,8 @@ public:
|
||||||
|
|
||||||
// Check for the right kind of attribute.
|
// Check for the right kind of attribute.
|
||||||
result = attr.dyn_cast<AttrType>();
|
result = attr.dyn_cast<AttrType>();
|
||||||
if (!result) {
|
if (!result)
|
||||||
emitError(loc, "invalid kind of constant specified");
|
return emitError(loc, "invalid kind of constant specified");
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -184,10 +184,10 @@ public:
|
||||||
RemoveResult removeAttr(Identifier name);
|
RemoveResult removeAttr(Identifier name);
|
||||||
|
|
||||||
/// Emit an error about fatal conditions with this operation, reporting up to
|
/// Emit an error about fatal conditions with this operation, reporting up to
|
||||||
/// any diagnostic handlers that may be listening. NOTE: This may terminate
|
/// any diagnostic handlers that may be listening. This function always
|
||||||
/// the containing application, only use when the IR is in an inconsistent
|
/// returns true. NOTE: This may terminate the containing application, only
|
||||||
/// state.
|
/// use when the IR is in an inconsistent state.
|
||||||
void emitError(const Twine &message) const;
|
bool emitError(const Twine &message) const;
|
||||||
|
|
||||||
/// Emit an error with the op name prefixed, like "'dim' op " which is
|
/// Emit an error with the op name prefixed, like "'dim' op " which is
|
||||||
/// convenient for verifiers. This function always returns true.
|
/// convenient for verifiers. This function always returns true.
|
||||||
|
|
|
@ -169,10 +169,10 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Emit an error about fatal conditions with this operation, reporting up to
|
/// Emit an error about fatal conditions with this operation, reporting up to
|
||||||
/// any diagnostic handlers that may be listening. NOTE: This may terminate
|
/// any diagnostic handlers that may be listening. This function always
|
||||||
/// the containing application, only use when the IR is in an inconsistent
|
/// returns true. NOTE: This may terminate the containing application, only
|
||||||
/// state.
|
/// use when the IR is in an inconsistent state.
|
||||||
void emitError(const Twine &message) const;
|
bool emitError(const Twine &message) const;
|
||||||
|
|
||||||
/// Emit a warning about this operation, reporting up to any diagnostic
|
/// Emit a warning about this operation, reporting up to any diagnostic
|
||||||
/// handlers that may be listening.
|
/// handlers that may be listening.
|
||||||
|
|
|
@ -53,13 +53,11 @@ namespace {
|
||||||
class Verifier {
|
class Verifier {
|
||||||
public:
|
public:
|
||||||
bool failure(const Twine &message, const Operation &value) {
|
bool failure(const Twine &message, const Operation &value) {
|
||||||
value.emitError(message);
|
return value.emitError(message);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool failure(const Twine &message, const Function &fn) {
|
bool failure(const Twine &message, const Function &fn) {
|
||||||
fn.emitError(message);
|
return fn.emitError(message);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool failure(const Twine &message, const BasicBlock &bb) {
|
bool failure(const Twine &message, const BasicBlock &bb) {
|
||||||
|
|
|
@ -508,11 +508,9 @@ bool ReturnOp::verify() const {
|
||||||
Twine(results.size()));
|
Twine(results.size()));
|
||||||
|
|
||||||
for (unsigned i = 0, e = results.size(); i != e; ++i)
|
for (unsigned i = 0, e = results.size(); i != e; ++i)
|
||||||
if (getOperand(i)->getType() != results[i]) {
|
if (getOperand(i)->getType() != results[i])
|
||||||
emitError("type of return operand " + Twine(i) +
|
return emitError("type of return operand " + Twine(i) +
|
||||||
" doesn't match function result type");
|
" doesn't match function result type");
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,13 +147,12 @@ void Function::emitWarning(const Twine &message) const {
|
||||||
MLIRContext::DiagnosticKind::Warning);
|
MLIRContext::DiagnosticKind::Warning);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Emit an error about fatal conditions with this instruction, reporting up to
|
/// Emit an error about fatal conditions with this operation, reporting up to
|
||||||
/// any diagnostic handlers that may be listening. NOTE: This may terminate
|
/// any diagnostic handlers that may be listening. This function always
|
||||||
/// the containing application, only use when the IR is in an inconsistent
|
/// returns true. NOTE: This may terminate the containing application, only use
|
||||||
/// state.
|
/// when the IR is in an inconsistent state.
|
||||||
void Function::emitError(const Twine &message) const {
|
bool Function::emitError(const Twine &message) const {
|
||||||
getContext()->emitDiagnostic(getLoc(), message,
|
return getContext()->emitError(getLoc(), message);
|
||||||
MLIRContext::DiagnosticKind::Error);
|
|
||||||
}
|
}
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// ExtFunction implementation.
|
// ExtFunction implementation.
|
||||||
|
|
|
@ -240,13 +240,12 @@ void Instruction::emitWarning(const Twine &message) const {
|
||||||
MLIRContext::DiagnosticKind::Warning);
|
MLIRContext::DiagnosticKind::Warning);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Emit an error about fatal conditions with this instruction, reporting up to
|
/// Emit an error about fatal conditions with this operation, reporting up to
|
||||||
/// any diagnostic handlers that may be listening. NOTE: This may terminate
|
/// any diagnostic handlers that may be listening. This function always
|
||||||
/// the containing application, only use when the IR is in an inconsistent
|
/// returns true. NOTE: This may terminate the containing application, only use
|
||||||
/// state.
|
/// when the IR is in an inconsistent state.
|
||||||
void Instruction::emitError(const Twine &message) const {
|
bool Instruction::emitError(const Twine &message) const {
|
||||||
getContext()->emitDiagnostic(getLoc(), message,
|
return getContext()->emitError(getLoc(), message);
|
||||||
MLIRContext::DiagnosticKind::Error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Instruction::addSuccessorOperand(unsigned index, CFGValue *value) {
|
void Instruction::addSuccessorOperand(unsigned index, CFGValue *value) {
|
||||||
|
|
|
@ -540,9 +540,10 @@ void MLIRContext::emitDiagnostic(Location location, const llvm::Twine &message,
|
||||||
os.flush();
|
os.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MLIRContext::emitError(Location location,
|
bool MLIRContext::emitError(Location location,
|
||||||
const llvm::Twine &message) const {
|
const llvm::Twine &message) const {
|
||||||
emitDiagnostic(location, message, DiagnosticKind::Error);
|
emitDiagnostic(location, message, DiagnosticKind::Error);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
|
@ -278,19 +278,17 @@ void Operation::emitWarning(const Twine &message) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Emit an error about fatal conditions with this operation, reporting up to
|
/// Emit an error about fatal conditions with this operation, reporting up to
|
||||||
/// any diagnostic handlers that may be listening. NOTE: This may terminate
|
/// any diagnostic handlers that may be listening. This function always returns
|
||||||
/// the containing application, only use when the IR is in an inconsistent
|
/// true. NOTE: This may terminate the containing application, only use when
|
||||||
/// state.
|
/// the IR is in an inconsistent state.
|
||||||
void Operation::emitError(const Twine &message) const {
|
bool Operation::emitError(const Twine &message) const {
|
||||||
getContext()->emitDiagnostic(getLoc(), message,
|
return getContext()->emitError(getLoc(), message);
|
||||||
MLIRContext::DiagnosticKind::Error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Emit an error with the op name prefixed, like "'dim' op " which is
|
/// Emit an error with the op name prefixed, like "'dim' op " which is
|
||||||
/// convenient for verifiers.
|
/// convenient for verifiers.
|
||||||
bool Operation::emitOpError(const Twine &message) const {
|
bool Operation::emitOpError(const Twine &message) const {
|
||||||
emitError(Twine('\'') + getName().getStringRef() + "' op " + message);
|
return emitError(Twine('\'') + getName().getStringRef() + "' op " + message);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Remove this operation from its parent block and delete it.
|
/// Remove this operation from its parent block and delete it.
|
||||||
|
@ -380,8 +378,8 @@ void OpState::print(OpAsmPrinter *p) const {
|
||||||
/// any diagnostic handlers that may be listening. NOTE: This may terminate
|
/// any diagnostic handlers that may be listening. NOTE: This may terminate
|
||||||
/// the containing application, only use when the IR is in an inconsistent
|
/// the containing application, only use when the IR is in an inconsistent
|
||||||
/// state.
|
/// state.
|
||||||
void OpState::emitError(const Twine &message) const {
|
bool OpState::emitError(const Twine &message) const {
|
||||||
getOperation()->emitError(message);
|
return getOperation()->emitError(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Emit an error with the op name prefixed, like "'dim' op " which is
|
/// Emit an error with the op name prefixed, like "'dim' op " which is
|
||||||
|
@ -557,19 +555,15 @@ static bool verifyBBArguments(
|
||||||
llvm::iterator_range<Operation::const_operand_iterator> operands,
|
llvm::iterator_range<Operation::const_operand_iterator> operands,
|
||||||
const BasicBlock *destBB, const Operation *op) {
|
const BasicBlock *destBB, const Operation *op) {
|
||||||
unsigned operandCount = std::distance(operands.begin(), operands.end());
|
unsigned operandCount = std::distance(operands.begin(), operands.end());
|
||||||
if (operandCount != destBB->getNumArguments()) {
|
if (operandCount != destBB->getNumArguments())
|
||||||
op->emitError("branch has " + Twine(operandCount) +
|
return op->emitError("branch has " + Twine(operandCount) +
|
||||||
" operands, but target block has " +
|
" operands, but target block has " +
|
||||||
Twine(destBB->getNumArguments()));
|
Twine(destBB->getNumArguments()));
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto operandIt = operands.begin();
|
auto operandIt = operands.begin();
|
||||||
for (unsigned i = 0, e = operandCount; i != e; ++i, ++operandIt) {
|
for (unsigned i = 0, e = operandCount; i != e; ++i, ++operandIt) {
|
||||||
if ((*operandIt)->getType() != destBB->getArgument(i)->getType()) {
|
if ((*operandIt)->getType() != destBB->getArgument(i)->getType())
|
||||||
op->emitError("type mismatch in bb argument #" + Twine(i));
|
return op->emitError("type mismatch in bb argument #" + Twine(i));
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -580,10 +574,8 @@ static bool verifyTerminatorSuccessors(const Operation *op) {
|
||||||
const Function *fn = op->getOperationFunction();
|
const Function *fn = op->getOperationFunction();
|
||||||
for (unsigned i = 0, e = op->getNumSuccessors(); i != e; ++i) {
|
for (unsigned i = 0, e = op->getNumSuccessors(); i != e; ++i) {
|
||||||
auto *succ = op->getSuccessor(i);
|
auto *succ = op->getSuccessor(i);
|
||||||
if (succ->getFunction() != fn) {
|
if (succ->getFunction() != fn)
|
||||||
op->emitError("reference to block defined in another function");
|
return op->emitError("reference to block defined in another function");
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (verifyBBArguments(op->getSuccessorOperands(i), succ, op))
|
if (verifyBBArguments(op->getSuccessorOperands(i), succ, op))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,13 +164,12 @@ void Statement::emitWarning(const Twine &message) const {
|
||||||
MLIRContext::DiagnosticKind::Warning);
|
MLIRContext::DiagnosticKind::Warning);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Emit an error about fatal conditions with this statement, reporting up to
|
/// Emit an error about fatal conditions with this operation, reporting up to
|
||||||
/// any diagnostic handlers that may be listening. NOTE: This may terminate
|
/// any diagnostic handlers that may be listening. This function always
|
||||||
/// the containing application, only use when the IR is in an inconsistent
|
/// returns true. NOTE: This may terminate the containing application, only
|
||||||
/// state.
|
/// use when the IR is in an inconsistent state.
|
||||||
void Statement::emitError(const Twine &message) const {
|
bool Statement::emitError(const Twine &message) const {
|
||||||
getContext()->emitDiagnostic(getLoc(), message,
|
return getContext()->emitError(getLoc(), message);
|
||||||
MLIRContext::DiagnosticKind::Error);
|
|
||||||
}
|
}
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// ilist_traits for Statement
|
// ilist_traits for Statement
|
||||||
|
|
|
@ -55,8 +55,8 @@ Location Lexer::getEncodedSourceLocation(llvm::SMLoc loc) {
|
||||||
|
|
||||||
/// emitError - Emit an error message and return an Token::error token.
|
/// emitError - Emit an error message and return an Token::error token.
|
||||||
Token Lexer::emitError(const char *loc, const Twine &message) {
|
Token Lexer::emitError(const char *loc, const Twine &message) {
|
||||||
context->emitDiagnostic(getEncodedSourceLocation(SMLoc::getFromPointer(loc)),
|
context->emitError(getEncodedSourceLocation(SMLoc::getFromPointer(loc)),
|
||||||
message, MLIRContext::DiagnosticKind::Error);
|
message);
|
||||||
return formToken(Token::error, loc);
|
return formToken(Token::error, loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -228,8 +228,7 @@ ParseResult Parser::emitError(SMLoc loc, const Twine &message) {
|
||||||
if (getToken().is(Token::error))
|
if (getToken().is(Token::error))
|
||||||
return ParseFailure;
|
return ParseFailure;
|
||||||
|
|
||||||
getContext()->emitDiagnostic(getEncodedSourceLocation(loc), message,
|
getContext()->emitError(getEncodedSourceLocation(loc), message);
|
||||||
MLIRContext::DiagnosticKind::Error);
|
|
||||||
return ParseFailure;
|
return ParseFailure;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1486,39 +1486,27 @@ bool VectorTransferReadOp::parse(OpAsmParser *parser, OperationState *result) {
|
||||||
|
|
||||||
// Resolution.
|
// Resolution.
|
||||||
auto funType = type.dyn_cast<FunctionType>();
|
auto funType = type.dyn_cast<FunctionType>();
|
||||||
if (!funType) {
|
if (!funType)
|
||||||
parser->emitError(parser->getNameLoc(), "Function type expected");
|
return parser->emitError(parser->getNameLoc(), "Function type expected");
|
||||||
return true;
|
if (funType.getNumInputs() < 1)
|
||||||
}
|
return parser->emitError(parser->getNameLoc(),
|
||||||
if (funType.getNumInputs() < 1) {
|
"Function type expects at least one input");
|
||||||
parser->emitError(parser->getNameLoc(),
|
|
||||||
"Function type expects at least one input");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
MemRefType memrefType =
|
MemRefType memrefType =
|
||||||
funType.getInput(Offsets::MemRefOffset).dyn_cast<MemRefType>();
|
funType.getInput(Offsets::MemRefOffset).dyn_cast<MemRefType>();
|
||||||
if (!memrefType) {
|
if (!memrefType)
|
||||||
parser->emitError(parser->getNameLoc(),
|
return parser->emitError(parser->getNameLoc(),
|
||||||
"MemRef type expected for first input");
|
"MemRef type expected for first input");
|
||||||
return true;
|
if (funType.getNumResults() < 1)
|
||||||
}
|
return parser->emitError(parser->getNameLoc(),
|
||||||
if (funType.getNumResults() < 1) {
|
"Function type expects exactly one vector result");
|
||||||
parser->emitError(parser->getNameLoc(),
|
|
||||||
"Function type expects exactly one vector result");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
VectorType vectorType = funType.getResult(0).dyn_cast<VectorType>();
|
VectorType vectorType = funType.getResult(0).dyn_cast<VectorType>();
|
||||||
if (!vectorType) {
|
if (!vectorType)
|
||||||
parser->emitError(parser->getNameLoc(),
|
return parser->emitError(parser->getNameLoc(),
|
||||||
"Vector type expected for first result");
|
"Vector type expected for first result");
|
||||||
return true;
|
if (parsedOperands.size() != funType.getNumInputs())
|
||||||
}
|
return parser->emitError(parser->getNameLoc(),
|
||||||
if (parsedOperands.size() != funType.getNumInputs()) {
|
"requires " + Twine(funType.getNumInputs()) +
|
||||||
parser->emitError(parser->getNameLoc(), "requires " +
|
" operands");
|
||||||
Twine(funType.getNumInputs()) +
|
|
||||||
" operands");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Extract optional paddingValue.
|
// Extract optional paddingValue.
|
||||||
OpAsmParser::OperandType memrefInfo = parsedOperands[0];
|
OpAsmParser::OperandType memrefInfo = parsedOperands[0];
|
||||||
|
@ -1535,12 +1523,10 @@ bool VectorTransferReadOp::parse(OpAsmParser *parser, OperationState *result) {
|
||||||
paddingType = funType.getInputs().back();
|
paddingType = funType.getInputs().back();
|
||||||
paddingValue = indexInfo.pop_back_val();
|
paddingValue = indexInfo.pop_back_val();
|
||||||
}
|
}
|
||||||
if (funType.getNumInputs() != expectedNumOperands) {
|
if (funType.getNumInputs() != expectedNumOperands)
|
||||||
parser->emitError(
|
return parser->emitError(
|
||||||
parser->getNameLoc(),
|
parser->getNameLoc(),
|
||||||
"requires actual number of operands to match function type");
|
"requires actual number of operands to match function type");
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto indexType = parser->getBuilder().getIndexType();
|
auto indexType = parser->getBuilder().getIndexType();
|
||||||
return parser->resolveOperand(memrefInfo, memrefType, result->operands) ||
|
return parser->resolveOperand(memrefInfo, memrefType, result->operands) ||
|
||||||
|
@ -1693,36 +1679,28 @@ bool VectorTransferWriteOp::parse(OpAsmParser *parser, OperationState *result) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resolution.
|
// Resolution.
|
||||||
if (parsedOperands.size() != types.size()) {
|
if (parsedOperands.size() != types.size())
|
||||||
parser->emitError(parser->getNameLoc(),
|
return parser->emitError(
|
||||||
"requires number of operands and input types to match");
|
parser->getNameLoc(),
|
||||||
return true;
|
"requires number of operands and input types to match");
|
||||||
}
|
if (parsedOperands.size() < Offsets::FirstIndexOffset)
|
||||||
if (parsedOperands.size() < Offsets::FirstIndexOffset) {
|
return parser->emitError(parser->getNameLoc(),
|
||||||
parser->emitError(parser->getNameLoc(),
|
"requires at least vector and memref operands");
|
||||||
"requires at least vector and memref operands");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
VectorType vectorType = types[Offsets::VectorOffset].dyn_cast<VectorType>();
|
VectorType vectorType = types[Offsets::VectorOffset].dyn_cast<VectorType>();
|
||||||
if (!vectorType) {
|
if (!vectorType)
|
||||||
parser->emitError(parser->getNameLoc(),
|
return parser->emitError(parser->getNameLoc(),
|
||||||
"Vector type expected for first input type");
|
"Vector type expected for first input type");
|
||||||
return true;
|
|
||||||
}
|
|
||||||
MemRefType memrefType = types[Offsets::MemRefOffset].dyn_cast<MemRefType>();
|
MemRefType memrefType = types[Offsets::MemRefOffset].dyn_cast<MemRefType>();
|
||||||
if (!memrefType) {
|
if (!memrefType)
|
||||||
parser->emitError(parser->getNameLoc(),
|
return parser->emitError(parser->getNameLoc(),
|
||||||
"MemRef type expected for second input type");
|
"MemRef type expected for second input type");
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned expectedNumOperands =
|
unsigned expectedNumOperands =
|
||||||
Offsets::FirstIndexOffset + memrefType.getRank();
|
Offsets::FirstIndexOffset + memrefType.getRank();
|
||||||
if (parsedOperands.size() != expectedNumOperands) {
|
if (parsedOperands.size() != expectedNumOperands)
|
||||||
parser->emitError(parser->getNameLoc(),
|
return parser->emitError(parser->getNameLoc(),
|
||||||
"requires " + Twine(expectedNumOperands) + " operands");
|
"requires " + Twine(expectedNumOperands) +
|
||||||
return true;
|
" operands");
|
||||||
}
|
|
||||||
|
|
||||||
OpAsmParser::OperandType vectorInfo = parsedOperands[Offsets::VectorOffset];
|
OpAsmParser::OperandType vectorInfo = parsedOperands[Offsets::VectorOffset];
|
||||||
OpAsmParser::OperandType memrefInfo = parsedOperands[Offsets::MemRefOffset];
|
OpAsmParser::OperandType memrefInfo = parsedOperands[Offsets::MemRefOffset];
|
||||||
|
|
|
@ -279,14 +279,10 @@ ModuleLowerer::linearizeSubscripts(ArrayRef<llvm::Value *> indices,
|
||||||
// TODO(zinenko): this function should disappear when the conversion fully
|
// TODO(zinenko): this function should disappear when the conversion fully
|
||||||
// supports MemRefs.
|
// supports MemRefs.
|
||||||
static bool checkSupportedMemRefType(MemRefType type, const Operation &op) {
|
static bool checkSupportedMemRefType(MemRefType type, const Operation &op) {
|
||||||
if (!type.getAffineMaps().empty()) {
|
if (!type.getAffineMaps().empty())
|
||||||
op.emitError("NYI: memrefs with affine maps");
|
return op.emitError("NYI: memrefs with affine maps");
|
||||||
return true;
|
if (type.getMemorySpace() != 0)
|
||||||
}
|
return op.emitError("NYI: non-default memory space");
|
||||||
if (type.getMemorySpace() != 0) {
|
|
||||||
op.emitError("NYI: non-default memory space");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -494,10 +490,8 @@ bool ModuleLowerer::convertInstruction(const Instruction &inst) {
|
||||||
return true;
|
return true;
|
||||||
// TODO(somebody): float attributes have "double" semantics whatever the
|
// TODO(somebody): float attributes have "double" semantics whatever the
|
||||||
// type of the constant. This should be fixed at the parser level.
|
// type of the constant. This should be fixed at the parser level.
|
||||||
if (!type->isFloatTy()) {
|
if (!type->isFloatTy())
|
||||||
inst.emitError("NYI: only floats are currently supported");
|
return inst.emitError("NYI: only floats are currently supported");
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool unused;
|
bool unused;
|
||||||
auto APvalue = constantOp->getValue();
|
auto APvalue = constantOp->getValue();
|
||||||
APFloat::opStatus status = APvalue.convert(
|
APFloat::opStatus status = APvalue.convert(
|
||||||
|
@ -507,10 +501,8 @@ bool ModuleLowerer::convertInstruction(const Instruction &inst) {
|
||||||
"Lossy conversion of a float constant to the float type");
|
"Lossy conversion of a float constant to the float type");
|
||||||
// No return intended.
|
// No return intended.
|
||||||
}
|
}
|
||||||
if (status != APFloat::opOK) {
|
if (status != APFloat::opOK)
|
||||||
inst.emitError("Failed to convert a floating point constant");
|
return inst.emitError("Failed to convert a floating point constant");
|
||||||
return true;
|
|
||||||
}
|
|
||||||
auto value = APvalue.convertToFloat();
|
auto value = APvalue.convertToFloat();
|
||||||
valueMapping[constantOp->getResult()] =
|
valueMapping[constantOp->getResult()] =
|
||||||
llvm::ConstantFP::get(type->getContext(), llvm::APFloat(value));
|
llvm::ConstantFP::get(type->getContext(), llvm::APFloat(value));
|
||||||
|
@ -520,10 +512,8 @@ bool ModuleLowerer::convertInstruction(const Instruction &inst) {
|
||||||
llvm::Type *type = convertType(constantOp->getType());
|
llvm::Type *type = convertType(constantOp->getType());
|
||||||
if (!type)
|
if (!type)
|
||||||
return true;
|
return true;
|
||||||
if (!isa<llvm::IntegerType>(type)) {
|
if (!isa<llvm::IntegerType>(type))
|
||||||
inst.emitError("only integer types are supported");
|
return inst.emitError("only integer types are supported");
|
||||||
return true;
|
|
||||||
}
|
|
||||||
auto attr = (constantOp->getValue()).cast<IntegerAttr>();
|
auto attr = (constantOp->getValue()).cast<IntegerAttr>();
|
||||||
// Create a new APInt even if we can extract one from the attribute, because
|
// Create a new APInt even if we can extract one from the attribute, because
|
||||||
// attributes are currently hardcoded to be 64-bit APInts and LLVM will
|
// attributes are currently hardcoded to be 64-bit APInts and LLVM will
|
||||||
|
@ -569,7 +559,7 @@ bool ModuleLowerer::convertInstruction(const Instruction &inst) {
|
||||||
const SSAValue *container = dimOp->getOperand();
|
const SSAValue *container = dimOp->getOperand();
|
||||||
MemRefType type = container->getType().dyn_cast<MemRefType>();
|
MemRefType type = container->getType().dyn_cast<MemRefType>();
|
||||||
if (!type)
|
if (!type)
|
||||||
return dimOp->emitError("only memref types are supported"), true;
|
return dimOp->emitError("only memref types are supported");
|
||||||
|
|
||||||
auto shape = type.getShape();
|
auto shape = type.getShape();
|
||||||
auto index = dimOp->getIndex();
|
auto index = dimOp->getIndex();
|
||||||
|
@ -641,8 +631,7 @@ bool ModuleLowerer::convertInstruction(const Instruction &inst) {
|
||||||
blockMapping[condBranchInst->getFalseDest()]);
|
blockMapping[condBranchInst->getFalseDest()]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
inst.emitError("unsupported operation");
|
return inst.emitError("unsupported operation");
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ModuleLowerer::convertBasicBlock(const BasicBlock &bb,
|
bool ModuleLowerer::convertBasicBlock(const BasicBlock &bb,
|
||||||
|
|
|
@ -535,15 +535,11 @@ static bool instantiateMaterialization(Statement *stmt,
|
||||||
MaterializationState *state) {
|
MaterializationState *state) {
|
||||||
LLVM_DEBUG(dbgs() << "\ninstantiate: " << *stmt);
|
LLVM_DEBUG(dbgs() << "\ninstantiate: " << *stmt);
|
||||||
|
|
||||||
if (isa<ForStmt>(stmt)) {
|
if (isa<ForStmt>(stmt))
|
||||||
stmt->emitError("NYI path ForStmt");
|
return stmt->emitError("NYI path ForStmt");
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isa<IfStmt>(stmt)) {
|
if (isa<IfStmt>(stmt))
|
||||||
stmt->emitError("NYI path IfStmt");
|
return stmt->emitError("NYI path IfStmt");
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a builder here for unroll-and-jam effects.
|
// Create a builder here for unroll-and-jam effects.
|
||||||
MLFuncBuilder b(stmt);
|
MLFuncBuilder b(stmt);
|
||||||
|
@ -562,14 +558,10 @@ static bool instantiateMaterialization(Statement *stmt,
|
||||||
// The only op with 0 results reaching this point must, by construction, be
|
// The only op with 0 results reaching this point must, by construction, be
|
||||||
// VectorTransferWriteOps and have been caught above. Ops with >= 2 results
|
// VectorTransferWriteOps and have been caught above. Ops with >= 2 results
|
||||||
// are not yet supported. So just support 1 result.
|
// are not yet supported. So just support 1 result.
|
||||||
if (opStmt->getNumResults() != 1) {
|
if (opStmt->getNumResults() != 1)
|
||||||
stmt->emitError("NYI: ops with != 1 results");
|
return stmt->emitError("NYI: ops with != 1 results");
|
||||||
return true;
|
if (opStmt->getResult(0)->getType() != state->superVectorType)
|
||||||
}
|
return stmt->emitError("Op does not return a supervector.");
|
||||||
if (opStmt->getResult(0)->getType() != state->superVectorType) {
|
|
||||||
stmt->emitError("Op does not return a supervector.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
auto *clone =
|
auto *clone =
|
||||||
instantiate(&b, opStmt, state->hwVectorType, state->substitutionsMap);
|
instantiate(&b, opStmt, state->hwVectorType, state->substitutionsMap);
|
||||||
if (!clone) {
|
if (!clone) {
|
||||||
|
|
Loading…
Reference in New Issue