[clang] [llvm] [HLSL] Add Barrier builtin (PR #228277)
Joshua Batista via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 7 15:48:26 PDT 2026
================
@@ -1767,6 +1798,51 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned BuiltinID,
CGM.getHLSLRuntime().getGroupMemoryBarrierWithGroupSyncIntrinsic();
return EmitIntrinsicCall(ID);
}
+ case Builtin::BI__builtin_hlsl_barrier: {
+ std::optional<llvm::APSInt> SemanticFlagsConstant =
+ E->getArg(1)->getIntegerConstantExpr(getContext());
+ assert(SemanticFlagsConstant && "expected constant semantic flags");
+ constexpr uint64_t GroupScope =
+ llvm::to_underlying(llvm::dxil::BarrierSemanticFlag::GroupScope);
+ constexpr uint64_t DeviceScope =
+ llvm::to_underlying(llvm::dxil::BarrierSemanticFlag::DeviceScope);
+ constexpr uint64_t ScopeMask = GroupScope | DeviceScope;
+ uint64_t SemanticFlagsValue = SemanticFlagsConstant->getZExtValue();
+ if ((SemanticFlagsValue & ScopeMask) == ScopeMask)
----------------
bob80905 wrote:
If the ScopeMask is set, then device scope and group scope are both on. device scope covers group scope, so we can drop group scope here.
This could be clearer, so I'll add a comment.
https://github.com/llvm/llvm-project/pull/228277
More information about the cfe-commits
mailing list