@@ -27,24 +27,21 @@ using namespace llvm;
2727
2828namespace {
2929
30- constexpr StringRef SYCL_HOST_ACCESS_ATTR = " sycl-host-access" ;
31- constexpr StringRef SYCL_PIPELINED_ATTR = " sycl-pipelined" ;
32- constexpr StringRef SYCL_REGISTER_ALLOC_MODE_ATTR = " sycl-register-alloc-mode" ;
33- constexpr StringRef SYCL_GRF_SIZE_ATTR = " sycl-grf-size" ;
30+ constexpr StringRef SyclHostAccessAttr = " sycl-host-access" ;
31+ constexpr StringRef SyclPipelinedAttr = " sycl-pipelined" ;
32+ constexpr StringRef SyclRegisterAllocModeAttr = " sycl-register-alloc-mode" ;
33+ constexpr StringRef SyclGrfSizeAttr = " sycl-grf-size" ;
3434
35- constexpr StringRef SPIRV_DECOR_MD_KIND = " spirv.Decorations" ;
36- constexpr StringRef SPIRV_PARAM_DECOR_MD_KIND = " spirv.ParameterDecorations" ;
35+ constexpr StringRef SpirvDecorMdKind = " spirv.Decorations" ;
36+ constexpr StringRef SpirvParamDecorMdKind = " spirv.ParameterDecorations" ;
3737// The corresponding SPIR-V OpCode for the host_access property is documented
3838// in the SPV_INTEL_global_variable_decorations design document:
3939// https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/DeviceGlobal/SPV_INTEL_global_variable_decorations.asciidoc#decoration
40- constexpr uint32_t SPIRV_HOST_ACCESS_DECOR = 6147 ;
41- constexpr uint32_t SPIRV_HOST_ACCESS_DEFAULT_VALUE = 2 ; // Read/Write
40+ constexpr uint32_t SpirvHostAccessDecor = 6147 ;
41+ constexpr uint32_t SpirvHostAccessDefaultValue = 2 ; // Read/Write
4242
43- constexpr uint32_t SPIRV_INITIATION_INTERVAL_DECOR = 5917 ;
44- constexpr uint32_t SPIRV_PIPELINE_ENABLE_DECOR = 5919 ;
45-
46- constexpr uint32_t SPIRV_CACHE_CONTROL_READ_DECOR = 6442 ;
47- constexpr uint32_t SPIRV_CACHE_CONTROL_WRITE_DECOR = 6443 ;
43+ constexpr uint32_t SpirvInitiationIntervalDecor = 5917 ;
44+ constexpr uint32_t SpirvPipelineEnableDecor = 5919 ;
4845
4946enum class DecorValueTy {
5047 uint32,
@@ -89,12 +86,12 @@ enum FloatControlMask {
8986// These opcodes are specified in SPIRV specification (SPV_KHR_float_controls
9087// and SPV_INTEL_float_controls2 extensions):
9188// https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.pdf
92- constexpr uint32_t SPIRV_ROUNDING_MODE_RTE = 4462 ; // RoundingModeRTE
93- constexpr uint32_t SPIRV_ROUNDING_MODE_RTZ = 4463 ; // RoundingModeRTZ
94- constexpr uint32_t SPIRV_ROUNDING_MODE_RTP_INTEL = 5620 ; // RoundingModeRTPINTEL
95- constexpr uint32_t SPIRV_ROUNDING_MODE_RTN_INTEL = 5621 ; // RoundingModeRTNINTEL
96- constexpr uint32_t SPIRV_DENORM_FLUSH_TO_ZERO = 4460 ; // DenormFlushToZero
97- constexpr uint32_t SPIRV_DENORM_PRESERVE = 4459 ; // DenormPreserve
89+ constexpr uint32_t SpirvRoundingModeRte = 4462 ; // RoundingModeRTE
90+ constexpr uint32_t SpirvRoundingModeRtz = 4463 ; // RoundingModeRTZ
91+ constexpr uint32_t SpirvRoundingModeRtpIntel = 5620 ; // RoundingModeRTPINTEL
92+ constexpr uint32_t SpirvRoundingModeRtnIntel = 5621 ; // RoundingModeRTNINTEL
93+ constexpr uint32_t SpirvDenormFlushToZero = 4460 ; // DenormFlushToZero
94+ constexpr uint32_t SpirvDenormPreserve = 4459 ; // DenormPreserve
9895
9996// / Builds a metadata node for a SPIR-V decoration (decoration code is
10097// / \c uint32_t integers) with no value.
@@ -147,15 +144,15 @@ MDNode *buildSpirvDecorCacheProp(LLVMContext &Ctx, StringRef Name,
147144 uint32_t OpCode, uint32_t CacheMode,
148145 uint32_t CacheLevel) {
149146 // SPIR-V encodings of read control
150- enum cache_control_read_type {
147+ enum CacheControlReadType {
151148 read_uncached = 0 ,
152149 read_cached = 1 ,
153150 read_streaming = 2 ,
154151 read_invalidate = 3 ,
155152 read_const_cached = 4
156153 };
157154 // SPIR-V encodings of write control
158- enum cache_control_write_type {
155+ enum CacheControlWriteType {
159156 write_uncached = 0 ,
160157 write_through = 1 ,
161158 write_back = 2 ,
@@ -338,28 +335,28 @@ attributeToExecModeMetadata(const Attribute &Attr, Function &F) {
338335 };
339336
340337 if (IsFPModeSet (RTE))
341- AddFPControlMetadata (SPIRV_ROUNDING_MODE_RTE );
338+ AddFPControlMetadata (SpirvRoundingModeRte );
342339
343340 if (IsFPModeSet (RTP))
344- AddFPControlMetadata (SPIRV_ROUNDING_MODE_RTP_INTEL );
341+ AddFPControlMetadata (SpirvRoundingModeRtpIntel );
345342
346343 if (IsFPModeSet (RTN))
347- AddFPControlMetadata (SPIRV_ROUNDING_MODE_RTN_INTEL );
344+ AddFPControlMetadata (SpirvRoundingModeRtnIntel );
348345
349346 if (IsFPModeSet (RTZ))
350- AddFPControlMetadata (SPIRV_ROUNDING_MODE_RTZ );
347+ AddFPControlMetadata (SpirvRoundingModeRtz );
351348
352349 if (IsFPModeSet (DENORM_FTZ))
353- AddFPControlMetadata (SPIRV_DENORM_FLUSH_TO_ZERO );
350+ AddFPControlMetadata (SpirvDenormFlushToZero );
354351
355352 if (IsFPModeSet (DENORM_HF_ALLOW))
356- AddFPControlMetadataForWidth (SPIRV_DENORM_PRESERVE , 16 );
353+ AddFPControlMetadataForWidth (SpirvDenormPreserve , 16 );
357354
358355 if (IsFPModeSet (DENORM_F_ALLOW))
359- AddFPControlMetadataForWidth (SPIRV_DENORM_PRESERVE , 32 );
356+ AddFPControlMetadataForWidth (SpirvDenormPreserve , 32 );
360357
361358 if (IsFPModeSet (DENORM_D_ALLOW))
362- AddFPControlMetadataForWidth (SPIRV_DENORM_PRESERVE , 64 );
359+ AddFPControlMetadataForWidth (SpirvDenormPreserve , 64 );
363360 }
364361
365362 static constexpr std::tuple<const char *, const char *> SimpleWGAttrs[] = {
@@ -483,12 +480,12 @@ attributeToExecModeMetadata(const Attribute &Attr, Function &F) {
483480 MDNode::get (Ctx, ClusterMDArgs));
484481 }
485482
486- if ((AttrKindStr == SYCL_REGISTER_ALLOC_MODE_ATTR ||
487- AttrKindStr == SYCL_GRF_SIZE_ATTR ) &&
483+ if ((AttrKindStr == SyclRegisterAllocModeAttr ||
484+ AttrKindStr == SyclGrfSizeAttr ) &&
488485 !llvm::esimd::isESIMD (F)) {
489486 // TODO: Remove SYCL_REGISTER_ALLOC_MODE_ATTR support in next ABI break.
490487 uint32_t PropVal = getAttributeAsInteger<uint32_t >(Attr);
491- if (AttrKindStr == SYCL_GRF_SIZE_ATTR ) {
488+ if (AttrKindStr == SyclGrfSizeAttr ) {
492489 // The RegisterAllocMode metadata supports only 0, 128, and 256 for
493490 // PropVal.
494491 if (PropVal != 0 && PropVal != 128 && PropVal != 256 )
@@ -570,9 +567,9 @@ void getUserListIgnoringCast(
570567PreservedAnalyses CompileTimePropertiesPass::run (Module &M,
571568 ModuleAnalysisManager &MAM) {
572569 LLVMContext &Ctx = M.getContext ();
573- unsigned MDKindID = Ctx.getMDKindID (SPIRV_DECOR_MD_KIND );
570+ unsigned MDKindID = Ctx.getMDKindID (SpirvDecorMdKind );
574571 bool CompileTimePropertiesMet = false ;
575- unsigned MDParamKindID = Ctx.getMDKindID (SPIRV_PARAM_DECOR_MD_KIND );
572+ unsigned MDParamKindID = Ctx.getMDKindID (SpirvParamDecorMdKind );
576573
577574 // Let's process all the globals
578575 for (auto &GV : M.globals ()) {
@@ -594,19 +591,18 @@ PreservedAnalyses CompileTimePropertiesPass::run(Module &M,
594591 // of the variable.
595592 if (isDeviceGlobalVariable (GV)) {
596593 auto HostAccessDecorValue =
597- GV.hasAttribute (SYCL_HOST_ACCESS_ATTR )
598- ? getAttributeAsInteger<uint32_t >(GV, SYCL_HOST_ACCESS_ATTR )
599- : SPIRV_HOST_ACCESS_DEFAULT_VALUE ;
594+ GV.hasAttribute (SyclHostAccessAttr )
595+ ? getAttributeAsInteger<uint32_t >(GV, SyclHostAccessAttr )
596+ : SpirvHostAccessDefaultValue ;
600597 auto VarName = getGlobalVariableUniqueId (GV);
601- MDOps.push_back (buildSpirvDecorMetadata (Ctx, SPIRV_HOST_ACCESS_DECOR ,
598+ MDOps.push_back (buildSpirvDecorMetadata (Ctx, SpirvHostAccessDecor ,
602599 HostAccessDecorValue, VarName));
603600 }
604601
605602 if (isHostPipeVariable (GV)) {
606603 auto VarName = getGlobalVariableUniqueId (GV);
607- MDOps.push_back (buildSpirvDecorMetadata (Ctx, SPIRV_HOST_ACCESS_DECOR,
608- SPIRV_HOST_ACCESS_DEFAULT_VALUE,
609- VarName));
604+ MDOps.push_back (buildSpirvDecorMetadata (
605+ Ctx, SpirvHostAccessDecor, SpirvHostAccessDefaultValue, VarName));
610606 }
611607
612608 // Add the generated metadata to the variable
@@ -668,26 +664,25 @@ PreservedAnalyses CompileTimePropertiesPass::run(Module &M,
668664 for (const Attribute &Attribute : F.getAttributes ().getFnAttrs ()) {
669665 // Handle pipelined attribute as a special case.
670666 if (Attribute.isStringAttribute () &&
671- Attribute.getKindAsString () == SYCL_PIPELINED_ATTR ) {
667+ Attribute.getKindAsString () == SyclPipelinedAttr ) {
672668 auto PipelineOrInitiationInterval =
673669 getAttributeAsInteger<int32_t >(Attribute);
674670 MDNode *SPIRVMetadata;
675671 if (PipelineOrInitiationInterval < 0 ) {
676672 // Default pipelining desired
677673 SPIRVMetadata =
678- buildSpirvDecorMetadata (Ctx, SPIRV_PIPELINE_ENABLE_DECOR , 1 );
674+ buildSpirvDecorMetadata (Ctx, SpirvPipelineEnableDecor , 1 );
679675 } else if (PipelineOrInitiationInterval == 0 ) {
680676 // No pipelining desired
681677 SPIRVMetadata =
682- buildSpirvDecorMetadata (Ctx, SPIRV_PIPELINE_ENABLE_DECOR , 0 );
678+ buildSpirvDecorMetadata (Ctx, SpirvPipelineEnableDecor , 0 );
683679 } else {
684680 // Pipelining desired, with specified Initiation Interval
685681 SPIRVMetadata =
686- buildSpirvDecorMetadata (Ctx, SPIRV_PIPELINE_ENABLE_DECOR , 1 );
682+ buildSpirvDecorMetadata (Ctx, SpirvPipelineEnableDecor , 1 );
687683 MDOps.push_back (SPIRVMetadata);
688- SPIRVMetadata =
689- buildSpirvDecorMetadata (Ctx, SPIRV_INITIATION_INTERVAL_DECOR,
690- PipelineOrInitiationInterval);
684+ SPIRVMetadata = buildSpirvDecorMetadata (
685+ Ctx, SpirvInitiationIntervalDecor, PipelineOrInitiationInterval);
691686 }
692687 MDOps.push_back (SPIRVMetadata);
693688 } else if (MDNode *SPIRVMetadata =
@@ -946,7 +941,7 @@ bool CompileTimePropertiesPass::transformSYCLPropertiesAnnotation(
946941
947942 if (CacheProp) {
948943 LLVMContext &Ctx = M.getContext ();
949- unsigned MDKindID = Ctx.getMDKindID (SPIRV_DECOR_MD_KIND );
944+ unsigned MDKindID = Ctx.getMDKindID (SpirvDecorMdKind );
950945 if (!FPGAProp && llvm::isa<llvm::Instruction>(IntrInst->getArgOperand (0 ))) {
951946 // If there are no annotations other than cache controls we can apply the
952947 // controls to the pointer and remove the intrinsic.
0 commit comments