Skip to content

Commit 4f341b2

Browse files
svenvhdbudanov-cmplr
authored andcommitted
Update for LLVM Optional API changes
Update for LLVM commit b5f8d42 ("[ADT] Deprecate Optional::{hasValue,getValue} (NFC)", 2022-08-07). This is a mechanical replacement of `hasValue` to `has_value` and `getValue` to `value`. Original commit: KhronosGroup/SPIRV-LLVM-Translator@ffeb4df
1 parent b64cb87 commit 4f341b2

File tree

10 files changed

+27
-27
lines changed

10 files changed

+27
-27
lines changed

llvm-spirv/lib/SPIRV/LLVMSPIRVOpts.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ using namespace SPIRV;
5050

5151
bool TranslatorOpts::isUnknownIntrinsicAllowed(IntrinsicInst *II) const
5252
noexcept {
53-
if (!SPIRVAllowUnknownIntrinsics.hasValue())
53+
if (!SPIRVAllowUnknownIntrinsics.has_value())
5454
return false;
55-
const auto &IntrinsicPrefixList = SPIRVAllowUnknownIntrinsics.getValue();
55+
const auto &IntrinsicPrefixList = SPIRVAllowUnknownIntrinsics.value();
5656
StringRef IntrinsicName = II->getCalledOperand()->getName();
5757
for (const auto Prefix : IntrinsicPrefixList) {
5858
if (IntrinsicName.startswith(Prefix)) // Also true if `Prefix` is empty
@@ -62,7 +62,7 @@ bool TranslatorOpts::isUnknownIntrinsicAllowed(IntrinsicInst *II) const
6262
}
6363

6464
bool TranslatorOpts::isSPIRVAllowUnknownIntrinsicsEnabled() const noexcept {
65-
return SPIRVAllowUnknownIntrinsics.hasValue();
65+
return SPIRVAllowUnknownIntrinsics.has_value();
6666
}
6767

6868
void TranslatorOpts::setSPIRVAllowUnknownIntrinsics(

llvm-spirv/lib/SPIRV/LLVMToSPIRVDbgTran.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -532,8 +532,8 @@ SPIRVEntry *LLVMToSPIRVDbgTran::transDbgPointerType(const DIDerivedType *PT) {
532532
Ops[BaseTypeIdx] = Base->getId();
533533
Ops[StorageClassIdx] = ~0U; // all ones denote no address space
534534
Optional<unsigned> AS = PT->getDWARFAddressSpace();
535-
if (AS.hasValue()) {
536-
SPIRAddressSpace SPIRAS = static_cast<SPIRAddressSpace>(AS.getValue());
535+
if (AS.has_value()) {
536+
SPIRAddressSpace SPIRAS = static_cast<SPIRAddressSpace>(AS.value());
537537
Ops[StorageClassIdx] = SPIRSPIRVAddrSpaceMap::map(SPIRAS);
538538
}
539539
Ops[FlagsIdx] = transDebugFlags(PT);
@@ -986,7 +986,7 @@ SPIRVExtInst *LLVMToSPIRVDbgTran::getSource(const T *DIEntry) {
986986
Ops[FileIdx] = BM->getString(FileName)->getId();
987987
DIFile *F = DIEntry ? DIEntry->getFile() : nullptr;
988988
if (F && F->getRawChecksum()) {
989-
auto CheckSum = F->getChecksum().getValue();
989+
auto CheckSum = F->getChecksum().value();
990990
Ops[TextIdx] = BM->getString("//__" + CheckSum.getKindAsString().str() +
991991
":" + CheckSum.Value.str())
992992
->getId();

llvm-spirv/lib/SPIRV/SPIRVLowerMemmove.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ void SPIRVLowerMemmoveBase::LowerMemMoveInst(MemMoveInst &I) {
7272
MaybeAlign SrcAlign = I.getSourceAlign();
7373

7474
auto *Alloca = Builder.CreateAlloca(AllocaTy);
75-
if (SrcAlign.hasValue())
76-
Alloca->setAlignment(SrcAlign.getValue());
75+
if (SrcAlign.has_value())
76+
Alloca->setAlignment(SrcAlign.value());
7777

7878
// FIXME: Do we need to pass the size of alloca here? From LangRef:
7979
// > The first argument is a constant integer representing the size of the

llvm-spirv/lib/SPIRV/SPIRVReader.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,8 +1652,8 @@ Value *SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
16521652
LVar->addAttribute(kVCMetadata::VCVolatile);
16531653
auto SEVAttr = translateSEVMetadata(BVar, LVar->getContext());
16541654
if (SEVAttr)
1655-
LVar->addAttribute(SEVAttr.getValue().getKindAsString(),
1656-
SEVAttr.getValue().getValueAsString());
1655+
LVar->addAttribute(SEVAttr.value().getKindAsString(),
1656+
SEVAttr.value().getValueAsString());
16571657
}
16581658

16591659
return Res;
@@ -4118,7 +4118,7 @@ bool SPIRVToLLVM::transVectorComputeMetadata(SPIRVFunction *BF) {
41184118
auto SEVAttr = translateSEVMetadata(BF, F->getContext());
41194119

41204120
if (SEVAttr)
4121-
F->addAttributeAtIndex(AttributeList::ReturnIndex, SEVAttr.getValue());
4121+
F->addAttributeAtIndex(AttributeList::ReturnIndex, SEVAttr.value());
41224122

41234123
for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E;
41244124
++I) {
@@ -4137,7 +4137,7 @@ bool SPIRVToLLVM::transVectorComputeMetadata(SPIRVFunction *BF) {
41374137
}
41384138
SEVAttr = translateSEVMetadata(BA, F->getContext());
41394139
if (SEVAttr)
4140-
F->addParamAttr(ArgNo, SEVAttr.getValue());
4140+
F->addParamAttr(ArgNo, SEVAttr.value());
41414141
if (BA->hasDecorate(internal::DecorationFuncParamDescINTEL)) {
41424142
auto Desc =
41434143
BA->getDecorationStringLiteral(internal::DecorationFuncParamDescINTEL)

llvm-spirv/lib/SPIRV/SPIRVToLLVMDbgTran.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1116,7 +1116,7 @@ SPIRVToLLVMDbgTran::ParseChecksum(StringRef Text) {
11161116
auto Checksum = Text.substr(ColonPos).ltrim(':');
11171117
if (auto Kind = DIFile::getChecksumKind(KindStr)) {
11181118
size_t ChecksumEndPos = Checksum.find_if_not(llvm::isHexDigit);
1119-
CS.emplace(Kind.getValue(), Checksum.substr(0, ChecksumEndPos));
1119+
CS.emplace(Kind.value(), Checksum.substr(0, ChecksumEndPos));
11201120
}
11211121
}
11221122
return CS;

llvm-spirv/lib/SPIRV/SPIRVWriter.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2712,15 +2712,15 @@ struct IntelLSUControlsInfo {
27122712
ResultVec.emplace_back(DecorationDontStaticallyCoalesceINTEL,
27132713
std::vector<std::string>());
27142714
// Conditional values
2715-
if (CacheSizeInfo.hasValue()) {
2715+
if (CacheSizeInfo.has_value()) {
27162716
ResultVec.emplace_back(
27172717
DecorationCacheSizeINTEL,
2718-
std::vector<std::string>{std::to_string(CacheSizeInfo.getValue())});
2718+
std::vector<std::string>{std::to_string(CacheSizeInfo.value())});
27192719
}
2720-
if (PrefetchInfo.hasValue()) {
2720+
if (PrefetchInfo.has_value()) {
27212721
ResultVec.emplace_back(
27222722
DecorationPrefetchINTEL,
2723-
std::vector<std::string>{std::to_string(PrefetchInfo.getValue())});
2723+
std::vector<std::string>{std::to_string(PrefetchInfo.value())});
27242724
}
27252725
return ResultVec;
27262726
}
@@ -2898,7 +2898,7 @@ AnnotationDecorations tryParseAnnotationString(SPIRVModule *BM,
28982898
LSUControls.setWithBitMask(ParamsBitMask);
28992899
} else if (Name == "cache-size") {
29002900
ValidDecorationFound = true;
2901-
if (!LSUControls.CacheSizeInfo.hasValue())
2901+
if (!LSUControls.CacheSizeInfo.has_value())
29022902
continue;
29032903
unsigned CacheSizeValue = 0;
29042904
bool Failure = ValueStr.getAsInteger(10, CacheSizeValue);

llvm-spirv/lib/SPIRV/libSPIRV/SPIRVModule.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -610,8 +610,8 @@ void SPIRVModuleImpl::addCapability(SPIRVCapabilityKind Cap) {
610610
// While we are reading existing SPIR-V we need to read it as-is and don't
611611
// add required extensions for each entry automatically
612612
auto Ext = CapObj->getRequiredExtension();
613-
if (Ext.hasValue())
614-
addExtension(Ext.getValue());
613+
if (Ext.has_value())
614+
addExtension(Ext.value());
615615
}
616616

617617
CapMap.insert(std::make_pair(Cap, CapObj));
@@ -735,8 +735,8 @@ SPIRVEntry *SPIRVModuleImpl::addEntry(SPIRVEntry *Entry) {
735735
// While we are reading existing SPIR-V we need to read it as-is and don't
736736
// add required extensions for each entry automatically
737737
auto Ext = Entry->getRequiredExtension();
738-
if (Ext.hasValue())
739-
addExtension(Ext.getValue());
738+
if (Ext.has_value())
739+
addExtension(Ext.value());
740740
}
741741

742742
return Entry;

llvm-spirv/lib/SPIRV/libSPIRV/SPIRVStream.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ const SPIRVDecoder &operator>>(const SPIRVDecoder &I, std::vector<T> &V) {
172172
template <typename T>
173173
const SPIRVDecoder &operator>>(const SPIRVDecoder &I, llvm::Optional<T> &V) {
174174
if (V)
175-
I >> V.getValue();
175+
I >> V.value();
176176
return I;
177177
}
178178

@@ -206,7 +206,7 @@ template <typename T>
206206
const SPIRVEncoder &operator<<(const SPIRVEncoder &O,
207207
const llvm::Optional<T> &V) {
208208
if (V)
209-
O << V.getValue();
209+
O << V.value();
210210
return O;
211211
}
212212

llvm-spirv/lib/SPIRV/libSPIRV/SPIRVType.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -898,10 +898,10 @@ class SPIRVTypeBufferSurfaceINTEL : public SPIRVType {
898898
return {ExtensionID::SPV_INTEL_vector_compute};
899899
}
900900

901-
bool hasAccessQualifier() const { return AccessKind.hasValue(); }
901+
bool hasAccessQualifier() const { return AccessKind.has_value(); }
902902
SPIRVAccessQualifierKind getAccessQualifier() const {
903903
assert(hasAccessQualifier());
904-
return AccessKind.getValue();
904+
return AccessKind.value();
905905
}
906906

907907
protected:

llvm-spirv/lib/SPIRV/libSPIRV/SPIRVValue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class SPIRVValue : public SPIRVEntry {
129129
return EV;
130130
EV = Type->getRequiredExtension();
131131
assert(Module &&
132-
(!EV.hasValue() || Module->isAllowedToUseExtension(EV.getValue())));
132+
(!EV.has_value() || Module->isAllowedToUseExtension(EV.value())));
133133
return EV;
134134
}
135135

0 commit comments

Comments
 (0)