17 #define FAILURE_IF_FAILED(STMT) \
23 #define ERROR_IF(COND, MSG) \
25 return parser.emitError(loc, MSG); \
36 "expected valid level format (e.g. dense, compressed or singleton)")
37 uint64_t properties = 0;
40 if (base.compare(
"structured") == 0) {
43 [&]() ->
ParseResult {
return parseStructured(parser, &structured); },
44 " in structured n out of m");
46 if (structured.size() != 2) {
47 parser.
emitError(loc,
"expected exactly 2 structured sizes");
50 if (structured[0] > structured[1]) {
51 parser.
emitError(loc,
"expected n <= m in n_out_of_m");
58 [&]() ->
ParseResult {
return parseProperty(parser, &properties); },
59 " in level property list");
63 if (base.compare(
"dense") == 0) {
65 }
else if (base.compare(
"batch") == 0) {
67 }
else if (base.compare(
"compressed") == 0) {
69 }
else if (base.compare(
"structured") == 0) {
72 }
else if (base.compare(
"loose_compressed") == 0) {
74 }
else if (base.compare(
"singleton") == 0) {
77 parser.
emitError(loc,
"unknown level format: ") << base;
82 "invalid level type: level format doesn't support the properties");
87 uint64_t *properties)
const {
91 "expected valid level property (e.g. nonordered, nonunique or high)")
99 parser.
emitError(loc,
"unknown level property: ") << strVal;
106 LvlTypeParser::parseStructured(
AsmParser &parser,
112 if (
failed(*intValParseResult)) {
113 parser.
emitError(loc,
"failed to parse structured size");
117 parser.
emitError(loc,
"expected structured size to be >= 0");
120 structured->push_back(intVal);
123 parser.
emitError(loc,
"expected valid integer for structured size");
#define FAILURE_IF_FAILED(STMT)
#define ERROR_IF(COND, MSG)
This base class exposes generic asm parser hooks, usable across the various derived parsers.
@ OptionalParen
Parens supporting zero or more operands, or nothing.
@ OptionalSquare
Square brackets supporting zero or more ops, or nothing.
virtual OptionalParseResult parseOptionalInteger(APInt &result)=0
Parse an optional integer value from the stream.
virtual ParseResult parseCommaSeparatedList(Delimiter delimiter, function_ref< ParseResult()> parseElementFn, StringRef contextMessage=StringRef())=0
Parse a list of comma-separated items with an optional delimiter.
virtual ParseResult parseOptionalKeyword(StringRef keyword)=0
Parse the given keyword if present.
virtual InFlightDiagnostic emitError(SMLoc loc, const Twine &message={})=0
Emit a diagnostic at the specified location and return failure.
virtual SMLoc getCurrentLocation()=0
Get the location of the next token and store it into the argument.
This class provides support for representing a failure result, or a valid value of type T.
This class implements Optional functionality for ParseResult.
bool has_value() const
Returns true if we contain a valid ParseResult value.
This class represents success/failure for parsing-like operations that find it important to chain tog...
FailureOr< uint64_t > parseLvlType(AsmParser &parser) const
constexpr uint64_t mToBits(uint64_t m)
constexpr uint64_t nToBits(uint64_t n)
bool isValidLT(LevelType lt)
constexpr const char * toPropString(LevelPropNonDefault lvlProp)
Returns string representation of the given level properties.
LevelPropNonDefault
This enum defines all the nondefault properties for storage formats.
Include the generated interface declarations.
LogicalResult failure(bool isFailure=true)
Utility function to generate a LogicalResult.
LogicalResult success(bool isSuccess=true)
Utility function to generate a LogicalResult.
bool failed(LogicalResult result)
Utility function that returns true if the provided LogicalResult corresponds to a failure value.
This enum defines all the sparse representations supportable by the SparseTensor dialect.