@@ -53,14 +53,14 @@ static StringRef getTypeKeyword(Type type) {
53
53
54
54
// / Prints a structure type. Keeps track of known struct names to handle self-
55
55
// / or mutually-referring structs without falling into infinite recursion.
56
- static void printStructType (AsmPrinter &printer, LLVMStructType type) {
56
+ void LLVMStructType::print (AsmPrinter &printer) const {
57
57
FailureOr<AsmPrinter::CyclicPrintReset> cyclicPrint;
58
58
59
59
printer << " <" ;
60
- if (type. isIdentified ()) {
61
- cyclicPrint = printer.tryStartCyclicPrint (type );
60
+ if (isIdentified ()) {
61
+ cyclicPrint = printer.tryStartCyclicPrint (* this );
62
62
63
- printer << ' "' << type. getName () << ' "' ;
63
+ printer << ' "' << getName () << ' "' ;
64
64
// If we are printing a reference to one of the enclosing structs, just
65
65
// print the name and stop to avoid infinitely long output.
66
66
if (failed (cyclicPrint)) {
@@ -70,17 +70,17 @@ static void printStructType(AsmPrinter &printer, LLVMStructType type) {
70
70
printer << " , " ;
71
71
}
72
72
73
- if (type. isIdentified () && type. isOpaque ()) {
73
+ if (isIdentified () && isOpaque ()) {
74
74
printer << " opaque>" ;
75
75
return ;
76
76
}
77
77
78
- if (type. isPacked ())
78
+ if (isPacked ())
79
79
printer << " packed " ;
80
80
81
81
// Put the current type on stack to avoid infinite recursion.
82
82
printer << ' (' ;
83
- llvm::interleaveComma (type. getBody (), printer.getStream (),
83
+ llvm::interleaveComma (getBody (), printer.getStream (),
84
84
[&](Type subtype) { dispatchPrint (printer, subtype); });
85
85
printer << ' )' ;
86
86
printer << ' >' ;
@@ -105,11 +105,8 @@ void mlir::LLVM::detail::printType(Type type, AsmPrinter &printer) {
105
105
106
106
llvm::TypeSwitch<Type>(type)
107
107
.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); });
113
110
}
114
111
115
112
// ===----------------------------------------------------------------------===//
@@ -182,7 +179,7 @@ static LLVMStructType trySetStructBody(LLVMStructType type,
182
179
// / `(` llvm-type-list `)` `>`
183
180
// / | `struct<` string-literal `>`
184
181
// / | `struct<` string-literal `, opaque>`
185
- static LLVMStructType parseStructType (AsmParser &parser) {
182
+ Type LLVMStructType::parse (AsmParser &parser) {
186
183
Location loc = parser.getEncodedSourceLoc (parser.getCurrentLocation ());
187
184
188
185
if (failed (parser.parseLess ()))
@@ -316,7 +313,7 @@ static Type dispatchParse(AsmParser &parser, bool allowAny = true) {
316
313
.Case (" ptr" , [&] { return LLVMPointerType::parse (parser); })
317
314
.Case (" vec" , [&] { return parseVectorType (parser); })
318
315
.Case (" array" , [&] { return LLVMArrayType::parse (parser); })
319
- .Case (" struct" , [&] { return parseStructType (parser); })
316
+ .Case (" struct" , [&] { return LLVMStructType::parse (parser); })
320
317
.Case (" target" , [&] { return LLVMTargetExtType::parse (parser); })
321
318
.Case (" x86_amx" , [&] { return LLVMX86AMXType::get (ctx); })
322
319
.Default ([&] {
0 commit comments