@@ -122,6 +122,24 @@ static SPIRVMemoryModelKind getMemoryModel(Module &M) {
122
122
return SPIRVMemoryModelKind::MemoryModelMax;
123
123
}
124
124
125
+ static void translateSEVDecoration (Attribute Sev, SPIRVValue *Val) {
126
+ assert (Sev.isStringAttribute () &&
127
+ Sev.getKindAsString () == kVCMetadata ::VCSingleElementVector);
128
+
129
+ auto *Ty = Val->getType ();
130
+ assert ((Ty->isTypeBool () || Ty->isTypeFloat () || Ty->isTypeInt () ||
131
+ Ty->isTypePointer ()) &&
132
+ " This decoration is valid only for Scalar or Pointer types" );
133
+
134
+ if (Ty->isTypePointer ()) {
135
+ SPIRVWord IndirectLevelsOnElement = 0 ;
136
+ Sev.getValueAsString ().getAsInteger (0 , IndirectLevelsOnElement);
137
+ Val->addDecorate (DecorationSingleElementVectorINTEL,
138
+ IndirectLevelsOnElement);
139
+ } else
140
+ Val->addDecorate (DecorationSingleElementVectorINTEL);
141
+ }
142
+
125
143
LLVMToSPIRVBase::LLVMToSPIRVBase (SPIRVModule *SMod)
126
144
: M(nullptr ), Ctx(nullptr ), BM(SMod), SrcLang(0 ), SrcLangVer(0 ) {
127
145
DbgTran = std::make_unique<LLVMToSPIRVDbgTran>(nullptr , SMod, this );
@@ -720,14 +738,11 @@ void LLVMToSPIRVBase::transVectorComputeMetadata(Function *F) {
720
738
BF->addDecorate (DecorationSIMTCallINTEL, SIMTMode);
721
739
}
722
740
723
- if (Attrs.hasRetAttr (kVCMetadata ::VCSingleElementVector)) {
724
- auto *RT = BF->getType ();
725
- (void )RT;
726
- assert ((RT->isTypeBool () || RT->isTypeFloat () || RT->isTypeInt () ||
727
- RT->isTypePointer ()) &&
728
- " This decoration is valid only for Scalar or Pointer types" );
729
- BF->addDecorate (DecorationSingleElementVectorINTEL);
730
- }
741
+ if (Attrs.hasRetAttr (kVCMetadata ::VCSingleElementVector))
742
+ translateSEVDecoration (
743
+ Attrs.getAttributeAtIndex (AttributeList::ReturnIndex,
744
+ kVCMetadata ::VCSingleElementVector),
745
+ BF);
731
746
732
747
for (Function::arg_iterator I = F->arg_begin (), E = F->arg_end (); I != E;
733
748
++I) {
@@ -740,14 +755,9 @@ void LLVMToSPIRVBase::transVectorComputeMetadata(Function *F) {
740
755
.getAsInteger (0 , Kind);
741
756
BA->addDecorate (DecorationFuncParamIOKindINTEL, Kind);
742
757
}
743
- if (Attrs.hasParamAttr (ArgNo, kVCMetadata ::VCSingleElementVector)) {
744
- auto *AT = BA->getType ();
745
- (void )AT;
746
- assert ((AT->isTypeBool () || AT->isTypeFloat () || AT->isTypeInt () ||
747
- AT->isTypePointer ()) &&
748
- " This decoration is valid only for Scalar or Pointer types" );
749
- BA->addDecorate (DecorationSingleElementVectorINTEL);
750
- }
758
+ if (Attrs.hasParamAttr (ArgNo, kVCMetadata ::VCSingleElementVector))
759
+ translateSEVDecoration (
760
+ Attrs.getParamAttr (ArgNo, kVCMetadata ::VCSingleElementVector), BA);
751
761
}
752
762
if (!isKernel (F) &&
753
763
BM->isAllowedToUseExtension (ExtensionID::SPV_INTEL_float_controls2) &&
@@ -1519,6 +1529,10 @@ LLVMToSPIRVBase::transValueWithoutDecoration(Value *V, SPIRVBasicBlock *BB,
1519
1529
}
1520
1530
if (GV->hasAttribute (kVCMetadata ::VCVolatile))
1521
1531
BVar->addDecorate (DecorationVolatile);
1532
+
1533
+ if (GV->hasAttribute (kVCMetadata ::VCSingleElementVector))
1534
+ translateSEVDecoration (
1535
+ GV->getAttribute (kVCMetadata ::VCSingleElementVector), BVar);
1522
1536
}
1523
1537
1524
1538
mapValue (V, BVar);
0 commit comments