MLIR 22.0.0git
LLVMTypeSyntax.cpp File Reference
#include "mlir/Dialect/LLVMIR/LLVMTypes.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/DialectImplementation.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/TypeSwitch.h"

Go to the source code of this file.

Functions

static void dispatchPrint (AsmPrinter &printer, Type type)
 If the given type is compatible with the LLVM dialect, prints it using internal functions to avoid getting a verbose !llvm prefix.
static StringRef getTypeKeyword (Type type)
 Returns the keyword to use for the given type.
static ParseResult dispatchParse (AsmParser &parser, Type &type)
 Helper to use in parse lists.
static LLVMStructType trySetStructBody (LLVMStructType type, ArrayRef< Type > subtypes, bool isPacked, AsmParser &parser, SMLoc subtypesLoc)
 Attempts to set the body of an identified structure type.
static Type dispatchParse (AsmParser &parser, bool allowAny=true)
 Parses a type appearing inside another LLVM dialect-compatible type.

Function Documentation

◆ dispatchParse() [1/2]

Type dispatchParse ( AsmParser & parser,
bool allowAny = true )
static

Parses a type appearing inside another LLVM dialect-compatible type.

This will try to parse any type in full form (including types with the !llvm prefix), and on failure fall back to parsing the short-hand version of the LLVM dialect types without the !llvm prefix.

Definition at line 244 of file LLVMTypeSyntax.cpp.

References mlir::AsmParser::emitError(), mlir::AsmParser::getContext(), mlir::AsmParser::getCurrentLocation(), mlir::AsmParser::parseKeyword(), mlir::AsmParser::parseOptionalType(), and result.

◆ dispatchParse() [2/2]

ParseResult dispatchParse ( AsmParser & parser,
Type & type )
static

Helper to use in parse lists.

Definition at line 285 of file LLVMTypeSyntax.cpp.

References dispatchParse(), and success().

Referenced by dispatchParse(), mlir::LLVM::parsePrettyLLVMType(), and mlir::LLVM::detail::parseType().

◆ dispatchPrint()

void dispatchPrint ( AsmPrinter & printer,
Type type )
static

If the given type is compatible with the LLVM dialect, prints it using internal functions to avoid getting a verbose !llvm prefix.

Otherwise prints it as usual.

Definition at line 25 of file LLVMTypeSyntax.cpp.

References mlir::LLVM::isCompatibleType(), mlir::AsmPrinter::printType(), and mlir::LLVM::detail::printType().

Referenced by mlir::LLVM::printPrettyLLVMType().

◆ getTypeKeyword()

StringRef getTypeKeyword ( Type type)
static

Returns the keyword to use for the given type.

Definition at line 35 of file LLVMTypeSyntax.cpp.

Referenced by mlir::LLVM::detail::printType().

◆ trySetStructBody()

LLVMStructType trySetStructBody ( LLVMStructType type,
ArrayRef< Type > subtypes,
bool isPacked,
AsmParser & parser,
SMLoc subtypesLoc )
static

Attempts to set the body of an identified structure type.

Reports a parsing error at subtypesLoc in case of failure.

Definition at line 118 of file LLVMTypeSyntax.cpp.

References mlir::AsmParser::emitError().