@@ -600,6 +600,25 @@ String CLikeSourceEmitter::generateName(IRInst* inst)
600
600
return String (intrinsicDecoration->getDefinition ());
601
601
}
602
602
603
+ auto entryPointDecor = inst->findDecoration <IREntryPointDecoration>();
604
+ if (entryPointDecor)
605
+ {
606
+ if (getSourceStyle () == SourceStyle::GLSL)
607
+ {
608
+ // GLSL will always need to use `main` as the
609
+ // name for an entry-point function, but other
610
+ // targets should try to use the original name.
611
+ //
612
+ // TODO: always use the original name, and
613
+ // use the appropriate options for glslang to
614
+ // make it support a non-`main` name.
615
+ //
616
+ return " main" ;
617
+ }
618
+
619
+ return entryPointDecor->getName ()->getStringSlice ();
620
+ }
621
+
603
622
// If we have a name hint on the instruction, then we will try to use that
604
623
// to provide the actual name in the output code.
605
624
//
@@ -2448,34 +2467,6 @@ bool CLikeSourceEmitter::isDefinition(IRFunc* func)
2448
2467
return func->getFirstBlock () != nullptr ;
2449
2468
}
2450
2469
2451
- String CLikeSourceEmitter::getFuncName (IRFunc* func)
2452
- {
2453
- if (auto entryPointLayout = asEntryPoint (func))
2454
- {
2455
- // GLSL will always need to use `main` as the
2456
- // name for an entry-point function, but other
2457
- // targets should try to use the original name.
2458
- //
2459
- // TODO: always use the original name, and
2460
- // use the appropriate options for glslang to
2461
- // make it support a non-`main` name.
2462
- //
2463
- if (getSourceStyle () != SourceStyle::GLSL)
2464
- {
2465
- return getText (entryPointLayout->getFuncDecl ()->getName ());
2466
- }
2467
-
2468
- //
2469
-
2470
- return " main" ;
2471
- }
2472
- else
2473
- {
2474
- return getName (func);
2475
- }
2476
- }
2477
-
2478
-
2479
2470
void CLikeSourceEmitter::emitEntryPointAttributes (IRFunc* irFunc, IREntryPointDecoration* entryPointDecor)
2480
2471
{
2481
2472
emitEntryPointAttributesImpl (irFunc, entryPointDecor);
@@ -2549,7 +2540,7 @@ void CLikeSourceEmitter::emitSimpleFuncImpl(IRFunc* func)
2549
2540
emitEntryPointAttributes (func, entryPointDecor);
2550
2541
}
2551
2542
2552
- auto name = getFuncName (func);
2543
+ auto name = getName (func);
2553
2544
2554
2545
emitType (resultType, name);
2555
2546
@@ -2657,7 +2648,7 @@ void CLikeSourceEmitter::emitFuncDecl(IRFunc* func)
2657
2648
auto funcType = func->getDataType ();
2658
2649
auto resultType = func->getResultType ();
2659
2650
2660
- auto name = getFuncName (func);
2651
+ auto name = getName (func);
2661
2652
2662
2653
emitType (resultType, name);
2663
2654
0 commit comments