@@ -1267,34 +1267,32 @@ static ParseResult parseAllocatorHandle(OpAsmParser &parser,
12671267 allocatorHandleAttr = IntegerAttr::get (parser.getBuilder ().getI64Type (), 0 );
12681268 return success ();
12691269 }
1270- auto parseKeyword = [&]() -> ParseResult {
1271- if (failed (parser.parseKeyword (&allocatorKeyword)))
1272- return failure ();
1273- if (allocatorKeyword == " omp_null_allocator" )
1274- allocator = 0 ;
1275- else if (allocatorKeyword == " omp_default_mem_alloc" )
1276- allocator = 1 ;
1277- else if (allocatorKeyword == " omp_large_cap_mem_alloc" )
1278- allocator = 2 ;
1279- else if (allocatorKeyword == " omp_const_mem_alloc" )
1280- allocator = 3 ;
1281- else if (allocatorKeyword == " omp_high_bw_mem_alloc" )
1282- allocator = 4 ;
1283- else if (allocatorKeyword == " omp_low_lat_mem_alloc" )
1284- allocator = 5 ;
1285- else if (allocatorKeyword == " omp_cgroup_mem_alloc" )
1286- allocator = 6 ;
1287- else if (allocatorKeyword == " omp_pteam_mem_alloc" )
1288- allocator = 7 ;
1289- else if (allocatorKeyword == " omp_thread_mem_alloc" )
1290- allocator = 8 ;
1291- else
1292- return parser.emitError (parser.getCurrentLocation ())
1293- << allocatorKeyword << " is not a valid allocator" ;
1270+ OptionalParseResult parsedInteger = parser.parseOptionalInteger (allocator);
1271+ if (parsedInteger.has_value ()) {
1272+ allocatorHandleAttr =
1273+ IntegerAttr::get (parser.getBuilder ().getI64Type (), allocator);
12941274 return success ();
1295- };
1296- if (parser.parseCommaSeparatedList ( parseKeyword))
1275+ }
1276+ if (failed ( parser.parseKeyword (&allocatorKeyword) ))
12971277 return failure ();
1278+ if (allocatorKeyword == " omp_null_allocator" )
1279+ allocator = 0 ;
1280+ else if (allocatorKeyword == " omp_default_mem_alloc" )
1281+ allocator = 1 ;
1282+ else if (allocatorKeyword == " omp_large_cap_mem_alloc" )
1283+ allocator = 2 ;
1284+ else if (allocatorKeyword == " omp_const_mem_alloc" )
1285+ allocator = 3 ;
1286+ else if (allocatorKeyword == " omp_high_bw_mem_alloc" )
1287+ allocator = 4 ;
1288+ else if (allocatorKeyword == " omp_low_lat_mem_alloc" )
1289+ allocator = 5 ;
1290+ else if (allocatorKeyword == " omp_cgroup_mem_alloc" )
1291+ allocator = 6 ;
1292+ else if (allocatorKeyword == " omp_pteam_mem_alloc" )
1293+ allocator = 7 ;
1294+ else if (allocatorKeyword == " omp_thread_mem_alloc" )
1295+ allocator = 8 ;
12981296 allocatorHandleAttr =
12991297 IntegerAttr::get (parser.getBuilder ().getI64Type (), allocator);
13001298 return success ();
@@ -1333,6 +1331,9 @@ static void printAllocatorHandle(OpAsmPrinter &p, Operation *op,
13331331 case 8 :
13341332 allocatorHandle = " omp_thread_mem_alloc" ;
13351333 break ;
1334+ default :
1335+ p << Twine (allocator).str ();
1336+ return ;
13361337 }
13371338 p << allocatorHandle;
13381339}
0 commit comments