Changeset View
Changeset View
Standalone View
Standalone View
mlir/lib/Dialect/EmitC/IR/EmitC.cpp
Show First 20 Lines • Show All 221 Lines • ▼ Show 20 Lines | if (parser.parseOptionalString(&value) || value.empty()) { | ||||
parser.emitError(loc) << "expected non empty string"; | parser.emitError(loc) << "expected non empty string"; | ||||
return Type(); | return Type(); | ||||
} | } | ||||
if (parser.parseGreater()) | if (parser.parseGreater()) | ||||
return Type(); | return Type(); | ||||
return get(parser.getContext(), value); | return get(parser.getContext(), value); | ||||
} | } | ||||
Type EmitCDialect::parseType(DialectAsmParser &parser) const { | |||||
llvm::SMLoc typeLoc = parser.getCurrentLocation(); | |||||
StringRef mnemonic; | |||||
if (parser.parseKeyword(&mnemonic)) | |||||
return Type(); | |||||
Type genType; | |||||
OptionalParseResult parseResult = | |||||
generatedTypeParser(parser, mnemonic, genType); | |||||
if (parseResult.hasValue()) | |||||
return genType; | |||||
parser.emitError(typeLoc, "unknown type in EmitC dialect"); | |||||
return Type(); | |||||
} | |||||
void EmitCDialect::printType(Type type, DialectAsmPrinter &os) const { | |||||
if (failed(generatedTypePrinter(type, os))) | |||||
llvm_unreachable("unexpected 'EmitC' type kind"); | |||||
} | |||||
void emitc::OpaqueType::print(DialectAsmPrinter &printer) const { | void emitc::OpaqueType::print(DialectAsmPrinter &printer) const { | ||||
printer << "opaque<\""; | printer << "opaque<\""; | ||||
llvm::printEscapedString(getValue(), printer.getStream()); | llvm::printEscapedString(getValue(), printer.getStream()); | ||||
printer << "\">"; | printer << "\">"; | ||||
} | } |