summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorDiego Novillo <dnovillo@google.com>2017-11-08 12:40:02 -0500
committerDiego Novillo <dnovillo@google.com>2017-11-08 14:03:08 -0500
commitd2938e48427cb6e8d5996712c23496d62e3c08d1 (patch)
treef3d683cf92c471dfa3ad308ac013bbc1671a8723 /tools
parentf32d11f74b75eb7660375ab295fb9c150c429948 (diff)
downloadSPIRV-Tools-d2938e48427cb6e8d5996712c23496d62e3c08d1.tar.gz
SPIRV-Tools-d2938e48427cb6e8d5996712c23496d62e3c08d1.tar.bz2
SPIRV-Tools-d2938e48427cb6e8d5996712c23496d62e3c08d1.zip
Re-format files in source, source/opt, source/util, source/val and tools.
NFC. This just makes sure every file is formatted following the formatting definition in .clang-format. Re-formatted with: $ clang-format -i $(find source tools include -name '*.cpp') $ clang-format -i $(find source tools include -name '*.h')
Diffstat (limited to 'tools')
-rw-r--r--tools/cfg/bin_to_dot.cpp2
-rw-r--r--tools/cfg/bin_to_dot.h2
-rw-r--r--tools/cfg/cfg.cpp5
-rw-r--r--tools/comp/markv.cpp64
-rw-r--r--tools/comp/markv_model_shader_default.cpp2
-rw-r--r--tools/dis/dis.cpp2
-rw-r--r--tools/stats/stats.cpp27
-rw-r--r--tools/stats/stats_analyzer.cpp702
-rw-r--r--tools/stats/stats_analyzer.h1
9 files changed, 399 insertions, 408 deletions
diff --git a/tools/cfg/bin_to_dot.cpp b/tools/cfg/bin_to_dot.cpp
index 06db6572..a7a2a203 100644
--- a/tools/cfg/bin_to_dot.cpp
+++ b/tools/cfg/bin_to_dot.cpp
@@ -81,7 +81,7 @@ class DotConverter {
spv_result_t DotConverter::HandleInstruction(
const spv_parsed_instruction_t& inst) {
- switch(inst.opcode) {
+ switch (inst.opcode) {
case SpvOpFunction:
current_function_id_ = inst.result_id;
seen_function_entry_block_ = false;
diff --git a/tools/cfg/bin_to_dot.h b/tools/cfg/bin_to_dot.h
index 69e24f4b..1181b252 100644
--- a/tools/cfg/bin_to_dot.h
+++ b/tools/cfg/bin_to_dot.h
@@ -24,4 +24,4 @@ spv_result_t BinaryToDot(const spv_const_context context, const uint32_t* words,
size_t num_words, std::iostream* out,
spv_diagnostic* diagnostic);
-#endif // BIN_TO_DOT_H_
+#endif // BIN_TO_DOT_H_
diff --git a/tools/cfg/cfg.cpp b/tools/cfg/cfg.cpp
index f609ddef..2d0bcfae 100644
--- a/tools/cfg/cfg.cpp
+++ b/tools/cfg/cfg.cpp
@@ -49,7 +49,7 @@ static const auto kDefaultEnvironment = SPV_ENV_UNIVERSAL_1_2;
int main(int argc, char** argv) {
const char* inFile = nullptr;
- const char* outFile = nullptr; // Stays nullptr if printing to stdout.
+ const char* outFile = nullptr; // Stays nullptr if printing to stdout.
for (int argi = 1; argi < argc; ++argi) {
if ('-' == argv[argi][0]) {
@@ -110,7 +110,8 @@ int main(int argc, char** argv) {
spv_diagnostic diagnostic = nullptr;
std::stringstream ss;
- auto error = BinaryToDot(context, contents.data(), contents.size(), &ss, &diagnostic);
+ auto error =
+ BinaryToDot(context, contents.data(), contents.size(), &ss, &diagnostic);
if (error) {
spvDiagnosticPrint(diagnostic);
spvDiagnosticDestroy(diagnostic);
diff --git a/tools/comp/markv.cpp b/tools/comp/markv.cpp
index 23585e5b..d2d8ad4d 100644
--- a/tools/comp/markv.cpp
+++ b/tools/comp/markv.cpp
@@ -88,8 +88,7 @@ void DiagnosticsMessageHandler(spv_message_level_t level, const char*,
case SPV_MSG_FATAL:
case SPV_MSG_INTERNAL_ERROR:
case SPV_MSG_ERROR:
- std::cerr << "error: " << position.index << ": " << message
- << std::endl;
+ std::cerr << "error: " << position.index << ": " << message << std::endl;
break;
case SPV_MSG_WARNING:
std::cerr << "warning: " << position.index << ": " << message
@@ -207,32 +206,34 @@ int main(int argc, char** argv) {
if (!ReadFile<uint32_t>(input_filename, "rb", &spirv)) return 1;
assert(!spirv.empty());
- if (SPV_SUCCESS != spvtools::SpirvToMarkv(
- ctx.context, spirv, options, *model, DiagnosticsMessageHandler,
- want_comments ? output_to_stderr : no_comments,
- spvtools::MarkvDebugConsumer(), &markv)) {
+ if (SPV_SUCCESS !=
+ spvtools::SpirvToMarkv(ctx.context, spirv, options, *model,
+ DiagnosticsMessageHandler,
+ want_comments ? output_to_stderr : no_comments,
+ spvtools::MarkvDebugConsumer(), &markv)) {
std::cerr << "error: Failed to encode " << input_filename << " to MARK-V "
<< std::endl;
return 1;
}
- if (!WriteFile<uint8_t>(output_filename, "wb", markv.data(),
- markv.size())) return 1;
+ if (!WriteFile<uint8_t>(output_filename, "wb", markv.data(), markv.size()))
+ return 1;
} else if (task == kDecode) {
if (!ReadFile<uint8_t>(input_filename, "rb", &markv)) return 1;
assert(!markv.empty());
- if (SPV_SUCCESS != spvtools::MarkvToSpirv(
- ctx.context, markv, options, *model, DiagnosticsMessageHandler,
- want_comments ? output_to_stderr : no_comments,
- spvtools::MarkvDebugConsumer(), &spirv)) {
+ if (SPV_SUCCESS !=
+ spvtools::MarkvToSpirv(ctx.context, markv, options, *model,
+ DiagnosticsMessageHandler,
+ want_comments ? output_to_stderr : no_comments,
+ spvtools::MarkvDebugConsumer(), &spirv)) {
std::cerr << "error: Failed to decode " << input_filename << " to SPIR-V "
<< std::endl;
return 1;
}
- if (!WriteFile<uint32_t>(output_filename, "wb", spirv.data(),
- spirv.size())) return 1;
+ if (!WriteFile<uint32_t>(output_filename, "wb", spirv.data(), spirv.size()))
+ return 1;
} else if (task == kTest) {
if (!ReadFile<uint32_t>(input_filename, "rb", &spirv)) return 1;
assert(!spirv.empty());
@@ -241,8 +242,8 @@ int main(int argc, char** argv) {
spvtools::Optimizer optimizer(kSpvEnv);
optimizer.RegisterPass(spvtools::CreateCompactIdsPass());
if (!optimizer.Run(spirv.data(), spirv.size(), &spirv_before)) {
- std::cerr << "error: Optimizer failure on: "
- << input_filename << std::endl;
+ std::cerr << "error: Optimizer failure on: " << input_filename
+ << std::endl;
}
std::vector<std::string> encoder_instruction_bits;
@@ -252,19 +253,20 @@ int main(int argc, char** argv) {
std::vector<std::string> decoder_instruction_comments;
std::vector<std::vector<uint32_t>> decoder_instruction_words;
- const auto encoder_debug_consumer = [&](
- const std::vector<uint32_t>& words, const std::string& bits,
- const std::string& comment) {
+ const auto encoder_debug_consumer = [&](const std::vector<uint32_t>& words,
+ const std::string& bits,
+ const std::string& comment) {
encoder_instruction_words.push_back(words);
encoder_instruction_bits.push_back(bits);
encoder_instruction_comments.push_back(comment);
return true;
};
- if (SPV_SUCCESS != spvtools::SpirvToMarkv(
- ctx.context, spirv_before, options, *model, DiagnosticsMessageHandler,
- want_comments ? output_to_stderr : no_comments,
- encoder_debug_consumer, &markv)) {
+ if (SPV_SUCCESS !=
+ spvtools::SpirvToMarkv(ctx.context, spirv_before, options, *model,
+ DiagnosticsMessageHandler,
+ want_comments ? output_to_stderr : no_comments,
+ encoder_debug_consumer, &markv)) {
std::cerr << "error: Failed to encode " << input_filename << " to MARK-V "
<< std::endl;
return 1;
@@ -294,9 +296,9 @@ int main(int argc, char** argv) {
}
};
- const auto decoder_debug_consumer = [&](
- const std::vector<uint32_t>& words, const std::string& bits,
- const std::string& comment) {
+ const auto decoder_debug_consumer = [&](const std::vector<uint32_t>& words,
+ const std::string& bits,
+ const std::string& comment) {
const size_t inst_index = decoder_instruction_words.size();
if (inst_index >= encoder_instruction_words.size()) {
write_bug_report();
@@ -313,7 +315,8 @@ int main(int argc, char** argv) {
decoder_instruction_words[inst_index]) {
write_bug_report();
std::cerr << "error: Words of the last decoded instruction differ from "
- "reference: " << input_filename << std::endl;
+ "reference: "
+ << input_filename << std::endl;
return false;
}
@@ -321,7 +324,8 @@ int main(int argc, char** argv) {
decoder_instruction_bits[inst_index]) {
write_bug_report();
std::cerr << "error: Bits of the last decoded instruction differ from "
- "reference: " << input_filename << std::endl;
+ "reference: "
+ << input_filename << std::endl;
return false;
}
return true;
@@ -330,8 +334,8 @@ int main(int argc, char** argv) {
std::vector<uint32_t> spirv_after;
const spv_result_t decoding_result = spvtools::MarkvToSpirv(
ctx.context, markv, options, *model, DiagnosticsMessageHandler,
- want_comments ? output_to_stderr : no_comments,
- decoder_debug_consumer, &spirv_after);
+ want_comments ? output_to_stderr : no_comments, decoder_debug_consumer,
+ &spirv_after);
if (decoding_result == SPV_REQUESTED_TERMINATION) {
std::cerr << "error: Decoding interrupted by the debugger: "
diff --git a/tools/comp/markv_model_shader_default.cpp b/tools/comp/markv_model_shader_default.cpp
index a58c103f..2021894d 100644
--- a/tools/comp/markv_model_shader_default.cpp
+++ b/tools/comp/markv_model_shader_default.cpp
@@ -17,9 +17,9 @@
#include <algorithm>
#include <map>
#include <memory>
-#include <vector>
#include <unordered_map>
#include <unordered_set>
+#include <vector>
using spvutils::HuffmanCodec;
diff --git a/tools/dis/dis.cpp b/tools/dis/dis.cpp
index 9c14b07a..51ee4a05 100644
--- a/tools/dis/dis.cpp
+++ b/tools/dis/dis.cpp
@@ -13,7 +13,7 @@
// limitations under the License.
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
-#include <stdio.h> // Need fileno
+#include <stdio.h> // Need fileno
#include <unistd.h>
#endif
diff --git a/tools/stats/stats.cpp b/tools/stats/stats.cpp
index 3eea9821..1e586d90 100644
--- a/tools/stats/stats.cpp
+++ b/tools/stats/stats.cpp
@@ -89,8 +89,7 @@ void DiagnosticsMessageHandler(spv_message_level_t level, const char*,
case SPV_MSG_FATAL:
case SPV_MSG_INTERNAL_ERROR:
case SPV_MSG_ERROR:
- std::cerr << "error: " << position.index << ": " << message
- << std::endl;
+ std::cerr << "error: " << position.index << ": " << message << std::endl;
break;
case SPV_MSG_WARNING:
std::cout << "warning: " << position.index << ": " << message
@@ -133,25 +132,24 @@ int main(int argc, char** argv) {
} else if (0 == strcmp(cur_arg, "--codegen_opcode_hist")) {
codegen_opcode_hist = true;
export_text = false;
- } else if (0 == strcmp(cur_arg,
- "--codegen_opcode_and_num_operands_hist")) {
+ } else if (0 ==
+ strcmp(cur_arg, "--codegen_opcode_and_num_operands_hist")) {
codegen_opcode_and_num_operands_hist = true;
export_text = false;
} else if (strcmp(
- "--codegen_opcode_and_num_operands_markov_huffman_codecs",
- cur_arg) == 0) {
+ "--codegen_opcode_and_num_operands_markov_huffman_codecs",
+ cur_arg) == 0) {
codegen_opcode_and_num_operands_markov_huffman_codecs = true;
export_text = false;
- } else if (0 == strcmp(cur_arg,
- "--codegen_literal_string_huffman_codecs")) {
+ } else if (0 ==
+ strcmp(cur_arg, "--codegen_literal_string_huffman_codecs")) {
codegen_literal_string_huffman_codecs = true;
export_text = false;
- } else if (0 == strcmp(cur_arg,
- "--codegen_non_id_word_huffman_codecs")) {
+ } else if (0 == strcmp(cur_arg, "--codegen_non_id_word_huffman_codecs")) {
codegen_non_id_word_huffman_codecs = true;
export_text = false;
- } else if (0 == strcmp(cur_arg,
- "--codegen_id_descriptor_huffman_codecs")) {
+ } else if (0 ==
+ strcmp(cur_arg, "--codegen_id_descriptor_huffman_codecs")) {
codegen_id_descriptor_huffman_codecs = true;
export_text = false;
} else if (0 == strcmp(cur_arg, "--verbose") ||
@@ -199,8 +197,9 @@ int main(int argc, char** argv) {
std::vector<uint32_t> contents;
if (!ReadFile<uint32_t>(path, "rb", &contents)) return 1;
- if (SPV_SUCCESS != libspirv::AggregateStats(
- *ctx.context, contents.data(), contents.size(), nullptr, &stats)) {
+ if (SPV_SUCCESS != libspirv::AggregateStats(*ctx.context, contents.data(),
+ contents.size(), nullptr,
+ &stats)) {
std::cerr << "error: Failed to aggregate stats for " << path << std::endl;
return 1;
}
diff --git a/tools/stats/stats_analyzer.cpp b/tools/stats/stats_analyzer.cpp
index b9d2c66c..da0b9e3c 100644
--- a/tools/stats/stats_analyzer.cpp
+++ b/tools/stats/stats_analyzer.cpp
@@ -23,13 +23,13 @@
#include <unordered_set>
#include <vector>
-#include "spirv/1.2/spirv.h"
-#include "source/enum_string_mapping.h"
#include "source/comp/markv_model.h"
+#include "source/enum_string_mapping.h"
#include "source/opcode.h"
#include "source/operand.h"
#include "source/spirv_constant.h"
#include "source/util/huffman_codec.h"
+#include "spirv/1.2/spirv.h"
using libspirv::SpirvStats;
using spvutils::HuffmanCodec;
@@ -49,325 +49,325 @@ inline uint32_t CombineOpcodeAndNumOperands(uint32_t opcode,
// Returns all SPIR-V v1.2 opcodes.
std::vector<uint32_t> GetAllOpcodes() {
return std::vector<uint32_t>({
- SpvOpNop,
- SpvOpUndef,
- SpvOpSourceContinued,
- SpvOpSource,
- SpvOpSourceExtension,
- SpvOpName,
- SpvOpMemberName,
- SpvOpString,
- SpvOpLine,
- SpvOpExtension,
- SpvOpExtInstImport,
- SpvOpExtInst,
- SpvOpMemoryModel,
- SpvOpEntryPoint,
- SpvOpExecutionMode,
- SpvOpCapability,
- SpvOpTypeVoid,
- SpvOpTypeBool,
- SpvOpTypeInt,
- SpvOpTypeFloat,
- SpvOpTypeVector,
- SpvOpTypeMatrix,
- SpvOpTypeImage,
- SpvOpTypeSampler,
- SpvOpTypeSampledImage,
- SpvOpTypeArray,
- SpvOpTypeRuntimeArray,
- SpvOpTypeStruct,
- SpvOpTypeOpaque,
- SpvOpTypePointer,
- SpvOpTypeFunction,
- SpvOpTypeEvent,
- SpvOpTypeDeviceEvent,
- SpvOpTypeReserveId,
- SpvOpTypeQueue,
- SpvOpTypePipe,
- SpvOpTypeForwardPointer,
- SpvOpConstantTrue,
- SpvOpConstantFalse,
- SpvOpConstant,
- SpvOpConstantComposite,
- SpvOpConstantSampler,
- SpvOpConstantNull,
- SpvOpSpecConstantTrue,
- SpvOpSpecConstantFalse,
- SpvOpSpecConstant,
- SpvOpSpecConstantComposite,
- SpvOpSpecConstantOp,
- SpvOpFunction,
- SpvOpFunctionParameter,
- SpvOpFunctionEnd,
- SpvOpFunctionCall,
- SpvOpVariable,
- SpvOpImageTexelPointer,
- SpvOpLoad,
- SpvOpStore,
- SpvOpCopyMemory,
- SpvOpCopyMemorySized,
- SpvOpAccessChain,
- SpvOpInBoundsAccessChain,
- SpvOpPtrAccessChain,
- SpvOpArrayLength,
- SpvOpGenericPtrMemSemantics,
- SpvOpInBoundsPtrAccessChain,
- SpvOpDecorate,
- SpvOpMemberDecorate,
- SpvOpDecorationGroup,
- SpvOpGroupDecorate,
- SpvOpGroupMemberDecorate,
- SpvOpVectorExtractDynamic,
- SpvOpVectorInsertDynamic,
- SpvOpVectorShuffle,
- SpvOpCompositeConstruct,
- SpvOpCompositeExtract,
- SpvOpCompositeInsert,
- SpvOpCopyObject,
- SpvOpTranspose,
- SpvOpSampledImage,
- SpvOpImageSampleImplicitLod,
- SpvOpImageSampleExplicitLod,
- SpvOpImageSampleDrefImplicitLod,
- SpvOpImageSampleDrefExplicitLod,
- SpvOpImageSampleProjImplicitLod,
- SpvOpImageSampleProjExplicitLod,
- SpvOpImageSampleProjDrefImplicitLod,
- SpvOpImageSampleProjDrefExplicitLod,
- SpvOpImageFetch,
- SpvOpImageGather,
- SpvOpImageDrefGather,
- SpvOpImageRead,
- SpvOpImageWrite,
- SpvOpImage,
- SpvOpImageQueryFormat,
- SpvOpImageQueryOrder,
- SpvOpImageQuerySizeLod,
- SpvOpImageQuerySize,
- SpvOpImageQueryLod,
- SpvOpImageQueryLevels,
- SpvOpImageQuerySamples,
- SpvOpConvertFToU,
- SpvOpConvertFToS,
- SpvOpConvertSToF,
- SpvOpConvertUToF,
- SpvOpUConvert,
- SpvOpSConvert,
- SpvOpFConvert,
- SpvOpQuantizeToF16,
- SpvOpConvertPtrToU,
- SpvOpSatConvertSToU,
- SpvOpSatConvertUToS,
- SpvOpConvertUToPtr,
- SpvOpPtrCastToGeneric,
- SpvOpGenericCastToPtr,
- SpvOpGenericCastToPtrExplicit,
- SpvOpBitcast,
- SpvOpSNegate,
- SpvOpFNegate,
- SpvOpIAdd,
- SpvOpFAdd,
- SpvOpISub,
- SpvOpFSub,
- SpvOpIMul,
- SpvOpFMul,
- SpvOpUDiv,
- SpvOpSDiv,
- SpvOpFDiv,
- SpvOpUMod,
- SpvOpSRem,
- SpvOpSMod,
- SpvOpFRem,
- SpvOpFMod,
- SpvOpVectorTimesScalar,
- SpvOpMatrixTimesScalar,
- SpvOpVectorTimesMatrix,
- SpvOpMatrixTimesVector,
- SpvOpMatrixTimesMatrix,
- SpvOpOuterProduct,
- SpvOpDot,
- SpvOpIAddCarry,
- SpvOpISubBorrow,
- SpvOpUMulExtended,
- SpvOpSMulExtended,
- SpvOpAny,
- SpvOpAll,
- SpvOpIsNan,
- SpvOpIsInf,
- SpvOpIsFinite,
- SpvOpIsNormal,
- SpvOpSignBitSet,
- SpvOpLessOrGreater,
- SpvOpOrdered,
- SpvOpUnordered,
- SpvOpLogicalEqual,
- SpvOpLogicalNotEqual,
- SpvOpLogicalOr,
- SpvOpLogicalAnd,
- SpvOpLogicalNot,
- SpvOpSelect,
- SpvOpIEqual,
- SpvOpINotEqual,
- SpvOpUGreaterThan,
- SpvOpSGreaterThan,
- SpvOpUGreaterThanEqual,
- SpvOpSGreaterThanEqual,
- SpvOpULessThan,
- SpvOpSLessThan,
- SpvOpULessThanEqual,
- SpvOpSLessThanEqual,
- SpvOpFOrdEqual,
- SpvOpFUnordEqual,
- SpvOpFOrdNotEqual,
- SpvOpFUnordNotEqual,
- SpvOpFOrdLessThan,
- SpvOpFUnordLessThan,
- SpvOpFOrdGreaterThan,
- SpvOpFUnordGreaterThan,
- SpvOpFOrdLessThanEqual,
- SpvOpFUnordLessThanEqual,
- SpvOpFOrdGreaterThanEqual,
- SpvOpFUnordGreaterThanEqual,
- SpvOpShiftRightLogical,
- SpvOpShiftRightArithmetic,
- SpvOpShiftLeftLogical,
- SpvOpBitwiseOr,
- SpvOpBitwiseXor,
- SpvOpBitwiseAnd,
- SpvOpNot,
- SpvOpBitFieldInsert,
- SpvOpBitFieldSExtract,
- SpvOpBitFieldUExtract,
- SpvOpBitReverse,
- SpvOpBitCount,
- SpvOpDPdx,
- SpvOpDPdy,
- SpvOpFwidth,
- SpvOpDPdxFine,
- SpvOpDPdyFine,
- SpvOpFwidthFine,
- SpvOpDPdxCoarse,
- SpvOpDPdyCoarse,
- SpvOpFwidthCoarse,
- SpvOpEmitVertex,
- SpvOpEndPrimitive,
- SpvOpEmitStreamVertex,
- SpvOpEndStreamPrimitive,
- SpvOpControlBarrier,
- SpvOpMemoryBarrier,
- SpvOpAtomicLoad,
- SpvOpAtomicStore,
- SpvOpAtomicExchange,
- SpvOpAtomicCompareExchange,
- SpvOpAtomicCompareExchangeWeak,
- SpvOpAtomicIIncrement,
- SpvOpAtomicIDecrement,
- SpvOpAtomicIAdd,
- SpvOpAtomicISub,
- SpvOpAtomicSMin,
- SpvOpAtomicUMin,
- SpvOpAtomicSMax,
- SpvOpAtomicUMax,
- SpvOpAtomicAnd,
- SpvOpAtomicOr,
- SpvOpAtomicXor,
- SpvOpPhi,
- SpvOpLoopMerge,
- SpvOpSelectionMerge,
- SpvOpLabel,
- SpvOpBranch,
- SpvOpBranchConditional,
- SpvOpSwitch,
- SpvOpKill,
- SpvOpReturn,
- SpvOpReturnValue,
- SpvOpUnreachable,
- SpvOpLifetimeStart,
- SpvOpLifetimeStop,
- SpvOpGroupAsyncCopy,
- SpvOpGroupWaitEvents,
- SpvOpGroupAll,
- SpvOpGroupAny,
- SpvOpGroupBroadcast,
- SpvOpGroupIAdd,
- SpvOpGroupFAdd,
- SpvOpGroupFMin,
- SpvOpGroupUMin,
- SpvOpGroupSMin,
- SpvOpGroupFMax,
- SpvOpGroupUMax,
- SpvOpGroupSMax,
- SpvOpReadPipe,
- SpvOpWritePipe,
- SpvOpReservedReadPipe,
- SpvOpReservedWritePipe,
- SpvOpReserveReadPipePackets,
- SpvOpReserveWritePipePackets,
- SpvOpCommitReadPipe,
- SpvOpCommitWritePipe,
- SpvOpIsValidReserveId,
- SpvOpGetNumPipePackets,
- SpvOpGetMaxPipePackets,
- SpvOpGroupReserveReadPipePackets,
- SpvOpGroupReserveWritePipePackets,
- SpvOpGroupCommitReadPipe,
- SpvOpGroupCommitWritePipe,
- SpvOpEnqueueMarker,
- SpvOpEnqueueKernel,
- SpvOpGetKernelNDrangeSubGroupCount,
- SpvOpGetKernelNDrangeMaxSubGroupSize,
- SpvOpGetKernelWorkGroupSize,
- SpvOpGetKernelPreferredWorkGroupSizeMultiple,
- SpvOpRetainEvent,
- SpvOpReleaseEvent,
- SpvOpCreateUserEvent,
- SpvOpIsValidEvent,
- SpvOpSetUserEventStatus,
- SpvOpCaptureEventProfilingInfo,
- SpvOpGetDefaultQueue,
- SpvOpBuildNDRange,
- SpvOpImageSparseSampleImplicitLod,
- SpvOpImageSparseSampleExplicitLod,
- SpvOpImageSparseSampleDrefImplicitLod,
- SpvOpImageSparseSampleDrefExplicitLod,
- SpvOpImageSparseSampleProjImplicitLod,
- SpvOpImageSparseSampleProjExplicitLod,
- SpvOpImageSparseSampleProjDrefImplicitLod,
- SpvOpImageSparseSampleProjDrefExplicitLod,
- SpvOpImageSparseFetch,
- SpvOpImageSparseGather,
- SpvOpImageSparseDrefGather,
- SpvOpImageSparseTexelsResident,
- SpvOpNoLine,
- SpvOpAtomicFlagTestAndSet,
- SpvOpAtomicFlagClear,
- SpvOpImageSparseRead,
- SpvOpSizeOf,
- SpvOpTypePipeStorage,
- SpvOpConstantPipeStorage,
- SpvOpCreatePipeFromPipeStorage,
- SpvOpGetKernelLocalSizeForSubgroupCount,
- SpvOpGetKernelMaxNumSubgroups,
- SpvOpTypeNamedBarrier,
- SpvOpNamedBarrierInitialize,
- SpvOpMemoryNamedBarrier,
- SpvOpModuleProcessed,
- SpvOpExecutionModeId,
- SpvOpDecorateId,
- SpvOpSubgroupBallotKHR,
- SpvOpSubgroupFirstInvocationKHR,
- SpvOpSubgroupAllKHR,
- SpvOpSubgroupAnyKHR,
- SpvOpSubgroupAllEqualKHR,
- SpvOpSubgroupReadInvocationKHR,
+ SpvOpNop,
+ SpvOpUndef,
+ SpvOpSourceContinued,
+ SpvOpSource,
+ SpvOpSourceExtension,
+ SpvOpName,
+ SpvOpMemberName,
+ SpvOpString,
+ SpvOpLine,
+ SpvOpExtension,
+ SpvOpExtInstImport,
+ SpvOpExtInst,
+ SpvOpMemoryModel,
+ SpvOpEntryPoint,
+ SpvOpExecutionMode,
+ SpvOpCapability,
+ SpvOpTypeVoid,
+ SpvOpTypeBool,
+ SpvOpTypeInt,
+ SpvOpTypeFloat,
+ SpvOpTypeVector,
+ SpvOpTypeMatrix,
+ SpvOpTypeImage,
+ SpvOpTypeSampler,
+ SpvOpTypeSampledImage,
+ SpvOpTypeArray,
+ SpvOpTypeRuntimeArray,
+ SpvOpTypeStruct,
+ SpvOpTypeOpaque,
+ SpvOpTypePointer,
+ SpvOpTypeFunction,
+ SpvOpTypeEvent,
+ SpvOpTypeDeviceEvent,
+ SpvOpTypeReserveId,
+ SpvOpTypeQueue,
+ SpvOpTypePipe,
+ SpvOpTypeForwardPointer,
+ SpvOpConstantTrue,
+ SpvOpConstantFalse,
+ SpvOpConstant,
+ SpvOpConstantComposite,
+ SpvOpConstantSampler,
+ SpvOpConstantNull,
+ SpvOpSpecConstantTrue,
+ SpvOpSpecConstantFalse,
+ SpvOpSpecConstant,
+ SpvOpSpecConstantComposite,
+ SpvOpSpecConstantOp,
+ SpvOpFunction,
+ SpvOpFunctionParameter,
+ SpvOpFunctionEnd,
+ SpvOpFunctionCall,
+ SpvOpVariable,
+ SpvOpImageTexelPointer,
+ SpvOpLoad,
+ SpvOpStore,
+ SpvOpCopyMemory,
+ SpvOpCopyMemorySized,
+ SpvOpAccessChain,
+ SpvOpInBoundsAccessChain,
+ SpvOpPtrAccessChain,
+ SpvOpArrayLength,
+ SpvOpGenericPtrMemSemantics,
+ SpvOpInBoundsPtrAccessChain,
+ SpvOpDecorate,
+ SpvOpMemberDecorate,
+ SpvOpDecorationGroup,
+ SpvOpGroupDecorate,
+ SpvOpGroupMemberDecorate,
+ SpvOpVectorExtractDynamic,
+ SpvOpVectorInsertDynamic,
+ SpvOpVectorShuffle,
+ SpvOpCompositeConstruct,
+ SpvOpCompositeExtract,
+ SpvOpCompositeInsert,
+ SpvOpCopyObject,
+ SpvOpTranspose,
+ SpvOpSampledImage,
+ SpvOpImageSampleImplicitLod,
+ SpvOpImageSampleExplicitLod,
+ SpvOpImageSampleDrefImplicitLod,
+ SpvOpImageSampleDrefExplicitLod,
+ SpvOpImageSampleProjImplicitLod,
+ SpvOpImageSampleProjExplicitLod,
+ SpvOpImageSampleProjDrefImplicitLod,
+ SpvOpImageSampleProjDrefExplicitLod,
+ SpvOpImageFetch,
+ SpvOpImageGather,
+ SpvOpImageDrefGather,
+ SpvOpImageRead,
+ SpvOpImageWrite,
+ SpvOpImage,
+ SpvOpImageQueryFormat,
+ SpvOpImageQueryOrder,
+ SpvOpImageQuerySizeLod,
+ SpvOpImageQuerySize,
+ SpvOpImageQueryLod,
+ SpvOpImageQueryLevels,
+ SpvOpImageQuerySamples,
+ SpvOpConvertFToU,
+ SpvOpConvertFToS,
+ SpvOpConvertSToF,
+ SpvOpConvertUToF,
+ SpvOpUConvert,
+ SpvOpSConvert,
+ SpvOpFConvert,
+ SpvOpQuantizeToF16,
+ SpvOpConvertPtrToU,
+ SpvOpSatConvertSToU,
+ SpvOpSatConvertUToS,
+ SpvOpConvertUToPtr,
+ SpvOpPtrCastToGeneric,
+ SpvOpGenericCastToPtr,
+ SpvOpGenericCastToPtrExplicit,
+ SpvOpBitcast,
+ SpvOpSNegate,
+ SpvOpFNegate,
+ SpvOpIAdd,
+ SpvOpFAdd,
+ SpvOpISub,
+ SpvOpFSub,
+ SpvOpIMul,
+ SpvOpFMul,
+ SpvOpUDiv,
+ SpvOpSDiv,
+ SpvOpFDiv,
+ SpvOpUMod,
+ SpvOpSRem,
+ SpvOpSMod,
+ SpvOpFRem,
+ SpvOpFMod,
+ SpvOpVectorTimesScalar,
+ SpvOpMatrixTimesScalar,
+ SpvOpVectorTimesMatrix,
+ SpvOpMatrixTimesVector,
+ SpvOpMatrixTimesMatrix,
+ SpvOpOuterProduct,
+ SpvOpDot,
+ SpvOpIAddCarry,
+ SpvOpISubBorrow,
+ SpvOpUMulExtended,
+ SpvOpSMulExtended,
+ SpvOpAny,
+ SpvOpAll,
+ SpvOpIsNan,
+ SpvOpIsInf,
+ SpvOpIsFinite,
+ SpvOpIsNormal,
+ SpvOpSignBitSet,
+ SpvOpLessOrGreater,
+ SpvOpOrdered,
+ SpvOpUnordered,
+ SpvOpLogicalEqual,
+ SpvOpLogicalNotEqual,
+ SpvOpLogicalOr,
+ SpvOpLogicalAnd,
+ SpvOpLogicalNot,
+ SpvOpSelect,
+ SpvOpIEqual,
+ SpvOpINotEqual,
+ SpvOpUGreaterThan,
+ SpvOpSGreaterThan,
+ SpvOpUGreaterThanEqual,
+ SpvOpSGreaterThanEqual,
+ SpvOpULessThan,
+ SpvOpSLessThan,
+ SpvOpULessThanEqual,
+ SpvOpSLessThanEqual,
+ SpvOpFOrdEqual,
+ SpvOpFUnordEqual,
+ SpvOpFOrdNotEqual,
+ SpvOpFUnordNotEqual,
+ SpvOpFOrdLessThan,
+ SpvOpFUnordLessThan,
+ SpvOpFOrdGreaterThan,
+ SpvOpFUnordGreaterThan,
+ SpvOpFOrdLessThanEqual,
+ SpvOpFUnordLessThanEqual,
+ SpvOpFOrdGreaterThanEqual,
+ SpvOpFUnordGreaterThanEqual,
+ SpvOpShiftRightLogical,
+ SpvOpShiftRightArithmetic,
+ SpvOpShiftLeftLogical,
+ SpvOpBitwiseOr,
+ SpvOpBitwiseXor,
+ SpvOpBitwiseAnd,
+ SpvOpNot,
+ SpvOpBitFieldInsert,
+ SpvOpBitFieldSExtract,
+ SpvOpBitFieldUExtract,
+ SpvOpBitReverse,
+ SpvOpBitCount,
+ SpvOpDPdx,
+ SpvOpDPdy,
+ SpvOpFwidth,
+ SpvOpDPdxFine,
+ SpvOpDPdyFine,
+ SpvOpFwidthFine,
+ SpvOpDPdxCoarse,
+ SpvOpDPdyCoarse,
+ SpvOpFwidthCoarse,
+ SpvOpEmitVertex,
+ SpvOpEndPrimitive,
+ SpvOpEmitStreamVertex,
+ SpvOpEndStreamPrimitive,
+ SpvOpControlBarrier,
+ SpvOpMemoryBarrier,
+ SpvOpAtomicLoad,
+ SpvOpAtomicStore,
+ SpvOpAtomicExchange,
+ SpvOpAtomicCompareExchange,
+ SpvOpAtomicCompareExchangeWeak,
+ SpvOpAtomicIIncrement,
+ SpvOpAtomicIDecrement,
+ SpvOpAtomicIAdd,
+ SpvOpAtomicISub,
+ SpvOpAtomicSMin,
+ SpvOpAtomicUMin,
+ SpvOpAtomicSMax,
+ SpvOpAtomicUMax,
+ SpvOpAtomicAnd,
+ SpvOpAtomicOr,
+ SpvOpAtomicXor,
+ SpvOpPhi,
+ SpvOpLoopMerge,
+ SpvOpSelectionMerge,
+ SpvOpLabel,
+ SpvOpBranch,
+ SpvOpBranchConditional,
+ SpvOpSwitch,
+ SpvOpKill,
+ SpvOpReturn,
+ SpvOpReturnValue,
+ SpvOpUnreachable,
+ SpvOpLifetimeStart,
+ SpvOpLifetimeStop,
+ SpvOpGroupAsyncCopy,
+ SpvOpGroupWaitEvents,
+ SpvOpGroupAll,
+ SpvOpGroupAny,
+ SpvOpGroupBroadcast,
+ SpvOpGroupIAdd,
+ SpvOpGroupFAdd,
+ SpvOpGroupFMin,
+ SpvOpGroupUMin,
+ SpvOpGroupSMin,
+ SpvOpGroupFMax,
+ SpvOpGroupUMax,
+ SpvOpGroupSMax,
+ SpvOpReadPipe,
+ SpvOpWritePipe,
+ SpvOpReservedReadPipe,
+ SpvOpReservedWritePipe,
+ SpvOpReserveReadPipePackets,
+ SpvOpReserveWritePipePackets,
+ SpvOpCommitReadPipe,
+ SpvOpCommitWritePipe,
+ SpvOpIsValidReserveId,
+ SpvOpGetNumPipePackets,
+ SpvOpGetMaxPipePackets,
+ SpvOpGroupReserveReadPipePackets,
+ SpvOpGroupReserveWritePipePackets,
+ SpvOpGroupCommitReadPipe,
+ SpvOpGroupCommitWritePipe,
+ SpvOpEnqueueMarker,
+ SpvOpEnqueueKernel,
+ SpvOpGetKernelNDrangeSubGroupCount,
+ SpvOpGetKernelNDrangeMaxSubGroupSize,
+ SpvOpGetKernelWorkGroupSize,
+ SpvOpGetKernelPreferredWorkGroupSizeMultiple,
+ SpvOpRetainEvent,
+ SpvOpReleaseEvent,
+ SpvOpCreateUserEvent,
+ SpvOpIsValidEvent,
+ SpvOpSetUserEventStatus,
+ SpvOpCaptureEventProfilingInfo,
+ SpvOpGetDefaultQueue,
+ SpvOpBuildNDRange,
+ SpvOpImageSparseSampleImplicitLod,
+ SpvOpImageSparseSampleExplicitLod,
+ SpvOpImageSparseSampleDrefImplicitLod,
+ SpvOpImageSparseSampleDrefExplicitLod,
+ SpvOpImageSparseSampleProjImplicitLod,
+ SpvOpImageSparseSampleProjExplicitLod,
+ SpvOpImageSparseSampleProjDrefImplicitLod,
+ SpvOpImageSparseSampleProjDrefExplicitLod,
+ SpvOpImageSparseFetch,
+ SpvOpImageSparseGather,
+ SpvOpImageSparseDrefGather,
+ SpvOpImageSparseTexelsResident,
+ SpvOpNoLine,
+ SpvOpAtomicFlagTestAndSet,
+ SpvOpAtomicFlagClear,
+ SpvOpImageSparseRead,
+ SpvOpSizeOf,
+ SpvOpTypePipeStorage,
+ SpvOpConstantPipeStorage,
+ SpvOpCreatePipeFromPipeStorage,
+ SpvOpGetKernelLocalSizeForSubgroupCount,
+ SpvOpGetKernelMaxNumSubgroups,
+ SpvOpTypeNamedBarrier,
+ SpvOpNamedBarrierInitialize,
+ SpvOpMemoryNamedBarrier,
+ SpvOpModuleProcessed,
+ SpvOpExecutionModeId,
+ SpvOpDecorateId,
+ SpvOpSubgroupBallotKHR,
+ SpvOpSubgroupFirstInvocationKHR,
+ SpvOpSubgroupAllKHR,
+ SpvOpSubgroupAnyKHR,
+ SpvOpSubgroupAllEqualKHR,
+ SpvOpSubgroupReadInvocationKHR,
});
}
std::string GetVersionString(uint32_t word) {
std::stringstream ss;
- ss << "Version " << SPV_SPIRV_VERSION_MAJOR_PART(word)
- << "." << SPV_SPIRV_VERSION_MINOR_PART(word);
+ ss << "Version " << SPV_SPIRV_VERSION_MAJOR_PART(word) << "."
+ << SPV_SPIRV_VERSION_MINOR_PART(word);
return ss.str();
}
@@ -429,10 +429,9 @@ void WriteFreq(std::ostream& out, const std::unordered_map<Key, double>& freq,
});
for (const auto& pair : sorted_freq) {
- if (pair.second < threshold)
- break;
- out << label_from_key(pair.first) << " " << pair.second * 100.0
- << "%" << std::endl;
+ if (pair.second < threshold) break;
+ out << label_from_key(pair.first) << " " << pair.second * 100.0 << "%"
+ << std::endl;
}
}
@@ -521,8 +520,7 @@ void StatsAnalyzer::WriteConstantLiterals(std::ostream& out) {
}
void StatsAnalyzer::WriteOpcodeMarkov(std::ostream& out) {
- if (stats_.opcode_markov_hist.empty())
- return;
+ if (stats_.opcode_markov_hist.empty()) return;
const std::unordered_map<uint32_t, std::unordered_map<uint32_t, uint32_t>>&
cue_to_hist = stats_.opcode_markov_hist[0];
@@ -530,18 +528,17 @@ void StatsAnalyzer::WriteOpcodeMarkov(std::ostream& out) {
// Sort by prevalence of the opcodes in opcode_freq_ (descending).
std::vector<std::pair<uint32_t, std::unordered_map<uint32_t, uint32_t>>>
sorted_cue_to_hist(cue_to_hist.begin(), cue_to_hist.end());
- std::sort(sorted_cue_to_hist.begin(), sorted_cue_to_hist.end(),
- [this](
- const std::pair<uint32_t,
- std::unordered_map<uint32_t, uint32_t>>& left,
- const std::pair<uint32_t,
- std::unordered_map<uint32_t, uint32_t>>& right) {
- const double lf = opcode_freq_[left.first];
- const double rf = opcode_freq_[right.first];
- if (lf == rf)
- return right.first > left.first;
- return lf > rf;
- });
+ std::sort(
+ sorted_cue_to_hist.begin(), sorted_cue_to_hist.end(),
+ [this](const std::pair<uint32_t, std::unordered_map<uint32_t, uint32_t>>&
+ left,
+ const std::pair<uint32_t, std::unordered_map<uint32_t, uint32_t>>&
+ right) {
+ const double lf = opcode_freq_[left.first];
+ const double rf = opcode_freq_[right.first];
+ if (lf == rf) return right.first > left.first;
+ return lf > rf;
+ });
for (const auto& kv : sorted_cue_to_hist) {
const uint32_t cue = kv.first;
@@ -555,8 +552,8 @@ void StatsAnalyzer::WriteOpcodeMarkov(std::ostream& out) {
total += pair.second;
}
- std::vector<std::pair<uint32_t, uint32_t>>
- sorted_hist(hist.begin(), hist.end());
+ std::vector<std::pair<uint32_t, uint32_t>> sorted_hist(hist.begin(),
+ hist.end());
std::sort(sorted_hist.begin(), sorted_hist.end(),
[](const std::pair<uint32_t, uint32_t>& left,
const std::pair<uint32_t, uint32_t>& right) {
@@ -593,10 +590,8 @@ void StatsAnalyzer::WriteCodegenOpcodeHist(std::ostream& out) {
const uint32_t count = it == stats_.opcode_hist.end() ? 0 : it->second;
const double kMaxValue = 1000.0;
uint32_t value = uint32_t(kMaxValue * double(count) / double(total));
- if (value == 0)
- value = 1;
- out << " { SpvOp" << GetOpcodeString(opcode)
- << ", " << value << " },\n";
+ if (value == 0) value = 1;
+ out << " { SpvOp" << GetOpcodeString(opcode) << ", " << value << " },\n";
}
// Add kMarkvNoneOfTheAbove as a signal for unknown opcode.
@@ -608,7 +603,6 @@ void StatsAnalyzer::WriteCodegenOpcodeAndNumOperandsHist(std::ostream& out) {
out << "std::map<uint64_t, uint32_t> GetOpcodeAndNumOperandsHist() {\n"
<< " return std::map<uint64_t, uint32_t>({\n";
-
uint32_t total = 0;
for (const auto& kv : stats_.opcode_and_num_operands_hist) {
total += kv.second;
@@ -630,13 +624,12 @@ void StatsAnalyzer::WriteCodegenOpcodeAndNumOperandsHist(std::ostream& out) {
}
out << " { CombineOpcodeAndNumOperands(SpvOp"
- << spvOpcodeString(SpvOp(opcode))
- << ", " << num_operands << "), " << count << " },\n";
+ << spvOpcodeString(SpvOp(opcode)) << ", " << num_operands << "), "
+ << count << " },\n";
}
// Heuristic.
- const uint32_t none_of_the_above =
- std::max(1, int(left_out + total * 0.01));
+ const uint32_t none_of_the_above = std::max(1, int(left_out + total * 0.01));
out << " { kMarkvNoneOfTheAbove, " << none_of_the_above << " },\n";
out << " });\n}\n";
}
@@ -667,8 +660,7 @@ void StatsAnalyzer::WriteCodegenOpcodeAndNumOperandsMarkovHuffmanCodecs(
const uint32_t opcode_and_num_operands = pair.first;
const uint32_t opcode = opcode_and_num_operands & 0xFFFF;
- if (opcode == SpvOpTypeStruct)
- continue;
+ if (opcode == SpvOpTypeStruct) continue;
const uint32_t num_operands = opcode_and_num_operands >> 16;
const uint32_t count = pair.second;
@@ -711,8 +703,7 @@ void StatsAnalyzer::WriteCodegenLiteralStringHuffmanCodecs(std::ostream& out) {
for (const auto& kv : stats_.literal_strings_hist) {
const uint32_t opcode = kv.first;
- if (opcode == SpvOpName || opcode == SpvOpMemberName)
- continue;
+ if (opcode == SpvOpName || opcode == SpvOpMemberName) continue;
const double kOpcodeFrequentEnoughToAnalyze = 0.001;
if (opcode_freq_[opcode] < kOpcodeFrequentEnoughToAnalyze) continue;
@@ -806,16 +797,15 @@ void StatsAnalyzer::WriteCodegenNonIdWordHuffmanCodecs(std::ostream& out) {
out << codec.SerializeToText(4);
out << ");\n" << std::endl;
out << " codecs.emplace(std::pair<uint32_t, uint32_t>(SpvOp"
- << spvOpcodeString(SpvOp(opcode))
- << ", " << index << "), std::move(codec));\n";
+ << spvOpcodeString(SpvOp(opcode)) << ", " << index
+ << "), std::move(codec));\n";
out << " }\n\n";
}
out << " return codecs;\n}\n";
}
-void StatsAnalyzer::WriteCodegenIdDescriptorHuffmanCodecs(
- std::ostream& out) {
+void StatsAnalyzer::WriteCodegenIdDescriptorHuffmanCodecs(std::ostream& out) {
out << "std::map<std::pair<uint32_t, uint32_t>, "
<< "std::unique_ptr<HuffmanCodec<uint64_t>>>\n"
<< "GetIdDescriptorHuffmanCodecs() {\n"
@@ -834,7 +824,6 @@ void StatsAnalyzer::WriteCodegenIdDescriptorHuffmanCodecs(
const std::map<uint32_t, uint32_t>& hist = kv.second;
-
uint32_t total = 0;
for (const auto& pair : hist) {
total += pair.second;
@@ -860,7 +849,6 @@ void StatsAnalyzer::WriteCodegenIdDescriptorHuffmanCodecs(
processed_hist.emplace(kMarkvNoneOfTheAbove,
std::max(1, int(left_out + total * 0.01)));
-
HuffmanCodec<uint64_t> codec(processed_hist);
out << " {\n";
@@ -869,8 +857,8 @@ void StatsAnalyzer::WriteCodegenIdDescriptorHuffmanCodecs(
out << codec.SerializeToText(4);
out << ");\n" << std::endl;
out << " codecs.emplace(std::pair<uint32_t, uint32_t>(SpvOp"
- << spvOpcodeString(SpvOp(opcode))
- << ", " << index << "), std::move(codec));\n";
+ << spvOpcodeString(SpvOp(opcode)) << ", " << index
+ << "), std::move(codec));\n";
out << " }\n\n";
}
diff --git a/tools/stats/stats_analyzer.h b/tools/stats/stats_analyzer.h
index 6cff20a0..a3b91bae 100644
--- a/tools/stats/stats_analyzer.h
+++ b/tools/stats/stats_analyzer.h
@@ -77,5 +77,4 @@ class StatsAnalyzer {
std::unordered_map<uint32_t, double> opcode_freq_;
};
-
#endif // LIBSPIRV_TOOLS_STATS_STATS_ANALYZER_H_