-
Notifications
You must be signed in to change notification settings - Fork 221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integration of reporting api with translator parser #2457
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -158,6 +158,10 @@ class TranslatorOpts { | |
|
||
void setPreserveAuxData(bool ArgValue) { PreserveAuxData = ArgValue; } | ||
|
||
void setIsReport(bool IsReport) { this->IsReport = IsReport; } | ||
|
||
bool isReport() { return IsReport; } | ||
|
||
void setGenKernelArgNameMDEnabled(bool ArgNameMD) { | ||
GenKernelArgNameMD = ArgNameMD; | ||
} | ||
|
@@ -285,6 +289,8 @@ class TranslatorOpts { | |
bool PreserveAuxData = false; | ||
|
||
BuiltinFormat SPIRVBuiltinFormat = BuiltinFormat::Function; | ||
|
||
bool IsReport = false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a small comment about this field. Thanks There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This field only purpose is to go around iostream interface to make branch in parser routine and it won't last. Should be removed during removal of iostream implementation. |
||
}; | ||
|
||
} // namespace SPIRV | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -575,7 +575,7 @@ class SPIRVModuleImpl : public SPIRVModule { | |
|
||
void layoutEntry(SPIRVEntry *Entry); | ||
std::istream &parseSPT(std::istream &I); | ||
std::istream &parseSPIRV(std::istream &I); | ||
template <bool IS_REPORT> std::istream &parseSPIRV(std::istream &I); | ||
}; | ||
|
||
SPIRVModuleImpl::~SPIRVModuleImpl() { | ||
|
@@ -787,6 +787,12 @@ void SPIRVModuleImpl::layoutEntry(SPIRVEntry *E) { | |
addTo(AsmVec, E); | ||
break; | ||
} | ||
case OpExtInstImport: { | ||
auto *EII = static_cast<SPIRVExtInstImport *>(E); | ||
std::string_view IL = EII->getImportLiteral(); | ||
SrcExtension.emplace(IL); | ||
break; | ||
} | ||
default: | ||
if (isTypeOpCode(OC)) | ||
TypeVec.push_back(static_cast<SPIRVType *>(E)); | ||
|
@@ -2321,6 +2327,7 @@ std::istream &SPIRVModuleImpl::parseSPT(std::istream &I) { | |
return I; | ||
} | ||
|
||
template <bool IS_REPORT> | ||
std::istream &SPIRVModuleImpl::parseSPIRV(std::istream &I) { | ||
SPIRVModuleImpl &MI = *this; | ||
MI.setAutoAddCapability(false); | ||
|
@@ -2387,6 +2394,11 @@ std::istream &SPIRVModuleImpl::parseSPIRV(std::istream &I) { | |
SPIRVDBG(spvdbgs() << "getWordCountAndOpCode EOF 0 0\n"); | ||
break; | ||
} | ||
if constexpr (IS_REPORT) { | ||
if (OpCode == OpMemoryModel) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That does look fishy, why do we need to skip OpMemoryModel? There should be no more then 2 OpMemoryModel in the model. |
||
break; | ||
} | ||
} | ||
} | ||
MI.resolveUnknownStructFields(); | ||
return I; | ||
|
@@ -2399,7 +2411,10 @@ std::istream &operator>>(std::istream &I, SPIRVModule &M) { | |
return MI.parseSPT(I); | ||
} | ||
#endif | ||
return MI.parseSPIRV(I); | ||
if (!MI.TranslationOpts.isReport()) { | ||
return MI.parseSPIRV<false>(I); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we not pass the isReport as an argument? Templated code might result in unneeded code bloating here. Thanks There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately, at this stage no. We don't want to introduce unneeded branch in parser hot path for both report and binary cases. User using binary translation shouldn't pay price for Reporting API. This could be avoided if the implementation wouldn't be in iostreams. That makes efficient implementation of early stop very hard. |
||
} | ||
return MI.parseSPIRV<true>(I); | ||
} | ||
|
||
SPIRVModule *SPIRVModule::createSPIRVModule() { return new SPIRVModuleImpl(); } | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
; RUN: llvm-spirv %s -to-binary -o %t.spv | ||
; RUN: llvm-spirv --spirv-print-report %t.spv | FileCheck %s --check-prefix=CHECK-DAG | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What will be reported if an extension is missing in spirv-ext? Can we add a CHECK for that? Thanks There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exactly the same like in other tests which covers situation with missing extensions. We already have such tests. For more detailed response please look on the answer below. |
||
; RUN: llvm-spirv --spirv-print-report --spirv-ext=+SPV_INTEL_loop_fuse,+SPV_KHR_bit_instructions %t.spv | FileCheck %s --check-prefix=CHECK-DAG | ||
|
||
; CHECK-DAG: Version: 1.0 | ||
; CHECK-DAG: Memory model: OpenCL | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably shouldn't change a type for the Version