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