@@ -53,14 +53,14 @@ static StringRef getTypeKeyword(Type type) {
5353
5454// / Prints a structure type. Keeps track of known struct names to handle self-
5555// / or mutually-referring structs without falling into infinite recursion.
56- static void printStructType (AsmPrinter &printer, LLVMStructType type) {
56+ void LLVMStructType::print (AsmPrinter &printer) const {
5757 FailureOr<AsmPrinter::CyclicPrintReset> cyclicPrint;
5858
5959 printer << " <" ;
60- if (type. isIdentified ()) {
61- cyclicPrint = printer.tryStartCyclicPrint (type );
60+ if (isIdentified ()) {
61+ cyclicPrint = printer.tryStartCyclicPrint (* this );
6262
63- printer << ' "' << type. getName () << ' "' ;
63+ printer << ' "' << getName () << ' "' ;
6464 // If we are printing a reference to one of the enclosing structs, just
6565 // print the name and stop to avoid infinitely long output.
6666 if (failed (cyclicPrint)) {
@@ -70,17 +70,17 @@ static void printStructType(AsmPrinter &printer, LLVMStructType type) {
7070 printer << " , " ;
7171 }
7272
73- if (type. isIdentified () && type. isOpaque ()) {
73+ if (isIdentified () && isOpaque ()) {
7474 printer << " opaque>" ;
7575 return ;
7676 }
7777
78- if (type. isPacked ())
78+ if (isPacked ())
7979 printer << " packed " ;
8080
8181 // Put the current type on stack to avoid infinite recursion.
8282 printer << ' (' ;
83- llvm::interleaveComma (type. getBody (), printer.getStream (),
83+ llvm::interleaveComma (getBody (), printer.getStream (),
8484 [&](Type subtype) { dispatchPrint (printer, subtype); });
8585 printer << ' )' ;
8686 printer << ' >' ;
@@ -105,11 +105,8 @@ void mlir::LLVM::detail::printType(Type type, AsmPrinter &printer) {
105105
106106 llvm::TypeSwitch<Type>(type)
107107 .Case <LLVMPointerType, LLVMArrayType, LLVMFixedVectorType,
108- LLVMScalableVectorType, LLVMFunctionType, LLVMTargetExtType>(
109- [&](auto type) { type.print (printer); })
110- .Case ([&](LLVMStructType structType) {
111- printStructType (printer, structType);
112- });
108+ LLVMScalableVectorType, LLVMFunctionType, LLVMTargetExtType,
109+ LLVMStructType>([&](auto type) { type.print (printer); });
113110}
114111
115112// ===----------------------------------------------------------------------===//
@@ -182,7 +179,7 @@ static LLVMStructType trySetStructBody(LLVMStructType type,
182179// / `(` llvm-type-list `)` `>`
183180// / | `struct<` string-literal `>`
184181// / | `struct<` string-literal `, opaque>`
185- static LLVMStructType parseStructType (AsmParser &parser) {
182+ Type LLVMStructType::parse (AsmParser &parser) {
186183 Location loc = parser.getEncodedSourceLoc (parser.getCurrentLocation ());
187184
188185 if (failed (parser.parseLess ()))
@@ -316,7 +313,7 @@ static Type dispatchParse(AsmParser &parser, bool allowAny = true) {
316313 .Case (" ptr" , [&] { return LLVMPointerType::parse (parser); })
317314 .Case (" vec" , [&] { return parseVectorType (parser); })
318315 .Case (" array" , [&] { return LLVMArrayType::parse (parser); })
319- .Case (" struct" , [&] { return parseStructType (parser); })
316+ .Case (" struct" , [&] { return LLVMStructType::parse (parser); })
320317 .Case (" target" , [&] { return LLVMTargetExtType::parse (parser); })
321318 .Case (" x86_amx" , [&] { return LLVMX86AMXType::get (ctx); })
322319 .Default ([&] {
0 commit comments