MLIR 23.0.0git
AttributeParser.cpp File Reference

Go to the source code of this file.

Functions

static std::optional< APInt > buildAttributeAPInt (Type type, bool isNegative, StringRef spelling)
 Construct an APint from a parsed value, a known attribute type and sign.
static ParseResult parseElementAttrHexValues (Parser &parser, Token tok, std::string &result)
 Parse elements values stored within a hex string.
static FailureOr< AttributeparseDenseElementsAttrTyped (Parser &p, SMLoc loc)
 Try to parse a dense elements attribute with the type-first syntax.

Function Documentation

◆ buildAttributeAPInt()

std::optional< APInt > buildAttributeAPInt ( Type type,
bool isNegative,
StringRef spelling )
static

Construct an APint from a parsed value, a known attribute type and sign.

Definition at line 361 of file AttributeParser.cpp.

References mlir::Type::getIntOrFloatBitWidth(), mlir::Type::isIndex(), mlir::Type::isSignedInteger(), and result.

Referenced by mlir::detail::Parser::parseDecOrHexAttr().

◆ parseDenseElementsAttrTyped()

FailureOr< Attribute > parseDenseElementsAttrTyped ( Parser & p,
SMLoc loc )
static

Try to parse a dense elements attribute with the type-first syntax.

Syntax: dense<TYPE : [ATTR, ATTR, ...]> This syntax is used for types other than int, float, index and complex.

Returns:

  • "null" attribute if this is not the type-first syntax.
  • "failure" in case of a parse error.
  • A valid Attribute otherwise.

Definition at line 965 of file AttributeParser.cpp.

References mlir::detail::Parser::emitError(), mlir::DenseElementsAttr::getFromRawBuffer(), mlir::Token::getLoc(), mlir::detail::Parser::getToken(), mlir::OptionalParseResult::has_value(), mlir::Token::is(), mlir::detail::Parser::parseAttribute(), mlir::detail::Parser::parseCommaSeparatedList(), mlir::detail::Parser::parseOptionalType(), mlir::detail::Parser::parseToken(), and success().

Referenced by mlir::detail::Parser::parseDenseElementsAttr().

◆ parseElementAttrHexValues()

ParseResult parseElementAttrHexValues ( Parser & parser,
Token tok,
std::string & result )
static

Parse elements values stored within a hex string.

On success, the values are stored into 'result'.

Definition at line 452 of file AttributeParser.cpp.

References mlir::detail::Parser::emitError(), mlir::Token::getHexStringValue(), mlir::Token::getLoc(), result, and success().