mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-10-18 11:10:05 +00:00
Cleanup whitespace lint warnings. (#1690)
This CL cleans up the whitespace warnings and enables the check when running 'git cl presubmit --all -uf'.
This commit is contained in:
parent
9532aede29
commit
84846b7e76
14
PRESUBMIT.py
14
PRESUBMIT.py
@ -19,24 +19,22 @@ for more details about the presubmit API built into depot_tools.
|
||||
"""
|
||||
|
||||
LINT_FILTERS = [
|
||||
"-build/header_guard",
|
||||
"-build/include",
|
||||
"-build/include_order",
|
||||
"-build/include_what_you_use",
|
||||
"-build/namespaces",
|
||||
"-build/storage_class",
|
||||
"-readability/braces",
|
||||
"-readability/casting",
|
||||
"-readability/fn_size",
|
||||
"-readability/inheritance",
|
||||
"-readability/todo",
|
||||
"-runtime/explicit",
|
||||
"-runtime/int",
|
||||
"-runtime/printf",
|
||||
"-runtime/references",
|
||||
"-whitespace/blank_line",
|
||||
"-whitespace/ending_newline",
|
||||
"-whitespace/line_length",
|
||||
"-whitespace/newline",
|
||||
"-whitespace/operators",
|
||||
"-whitespace/parens",
|
||||
"-whitespace/semicolon",
|
||||
"-whitespace/todo"
|
||||
"-runtime/string",
|
||||
]
|
||||
|
||||
|
||||
|
@ -246,8 +246,9 @@ const char* spvOperandTypeStr(spv_operand_type_t type) {
|
||||
void spvPushOperandTypes(const spv_operand_type_t* types,
|
||||
spv_operand_pattern_t* pattern) {
|
||||
const spv_operand_type_t* endTypes;
|
||||
for (endTypes = types; *endTypes != SPV_OPERAND_TYPE_NONE; ++endTypes)
|
||||
;
|
||||
for (endTypes = types; *endTypes != SPV_OPERAND_TYPE_NONE; ++endTypes) {
|
||||
}
|
||||
|
||||
while (endTypes-- != types) {
|
||||
pattern->push_back(*endTypes);
|
||||
}
|
||||
|
@ -446,9 +446,8 @@ bool AggressiveDCEPass::AggressiveDCE(opt::Function* func) {
|
||||
if (varId != 0) {
|
||||
ProcessLoad(varId);
|
||||
}
|
||||
}
|
||||
// If function call, treat as if it loads from all pointer arguments
|
||||
else if (liveInst->opcode() == SpvOpFunctionCall) {
|
||||
} else if (liveInst->opcode() == SpvOpFunctionCall) {
|
||||
liveInst->ForEachInId([this](const uint32_t* iid) {
|
||||
// Skip non-ptr args
|
||||
if (!IsPtr(*iid)) return;
|
||||
@ -456,14 +455,12 @@ bool AggressiveDCEPass::AggressiveDCE(opt::Function* func) {
|
||||
(void)GetPtr(*iid, &varId);
|
||||
ProcessLoad(varId);
|
||||
});
|
||||
}
|
||||
// If function parameter, treat as if it's result id is loaded from
|
||||
else if (liveInst->opcode() == SpvOpFunctionParameter) {
|
||||
} else if (liveInst->opcode() == SpvOpFunctionParameter) {
|
||||
ProcessLoad(liveInst->result_id());
|
||||
}
|
||||
// We treat an OpImageTexelPointer as a load of the pointer, and
|
||||
// that value is manipulated to get the result.
|
||||
else if (liveInst->opcode() == SpvOpImageTexelPointer) {
|
||||
} else if (liveInst->opcode() == SpvOpImageTexelPointer) {
|
||||
uint32_t varId;
|
||||
(void)GetPtr(liveInst, &varId);
|
||||
if (varId != 0) {
|
||||
|
@ -106,19 +106,17 @@ void DeadInsertElimPass::MarkInsertChain(
|
||||
std::unordered_set<uint32_t> obj_visited_phis;
|
||||
MarkInsertChain(get_def_use_mgr()->GetDef(objId), nullptr, 0,
|
||||
&obj_visited_phis);
|
||||
}
|
||||
// If extract indices match insert, we are done. Mark insert and
|
||||
// inserted object.
|
||||
else if (ExtInsMatch(*pExtIndices, insInst, extOffset)) {
|
||||
} else if (ExtInsMatch(*pExtIndices, insInst, extOffset)) {
|
||||
liveInserts_.insert(insInst->result_id());
|
||||
uint32_t objId = insInst->GetSingleWordInOperand(kInsertObjectIdInIdx);
|
||||
std::unordered_set<uint32_t> obj_visited_phis;
|
||||
MarkInsertChain(get_def_use_mgr()->GetDef(objId), nullptr, 0,
|
||||
&obj_visited_phis);
|
||||
break;
|
||||
}
|
||||
// If non-matching intersection, mark insert
|
||||
else if (ExtInsConflict(*pExtIndices, insInst, extOffset)) {
|
||||
} else if (ExtInsConflict(*pExtIndices, insInst, extOffset)) {
|
||||
liveInserts_.insert(insInst->result_id());
|
||||
// If more extract indices than insert, we are done. Use remaining
|
||||
// extract indices to mark inserted object.
|
||||
@ -129,10 +127,9 @@ void DeadInsertElimPass::MarkInsertChain(
|
||||
MarkInsertChain(get_def_use_mgr()->GetDef(objId), pExtIndices,
|
||||
extOffset + numInsertIndices, &obj_visited_phis);
|
||||
break;
|
||||
}
|
||||
// If fewer extract indices than insert, also mark inserted object and
|
||||
// continue up chain.
|
||||
else {
|
||||
} else {
|
||||
uint32_t objId = insInst->GetSingleWordInOperand(kInsertObjectIdInIdx);
|
||||
std::unordered_set<uint32_t> obj_visited_phis;
|
||||
MarkInsertChain(get_def_use_mgr()->GetDef(objId), nullptr, 0,
|
||||
|
@ -280,10 +280,12 @@ inline SExpression operator+(SENode* lhs, SExpression rhs) { return rhs + lhs; }
|
||||
template <typename T,
|
||||
typename std::enable_if<std::is_integral<T>::value, int>::type>
|
||||
inline SExpression operator-(T lhs, SExpression rhs) {
|
||||
// NOLINTNEXTLINE(whitespace/braces)
|
||||
return SExpression{rhs.GetScalarEvolutionAnalysis()->CreateConstant(lhs)} -
|
||||
rhs;
|
||||
}
|
||||
inline SExpression operator-(SENode* lhs, SExpression rhs) {
|
||||
// NOLINTNEXTLINE(whitespace/braces)
|
||||
return SExpression{lhs} - rhs;
|
||||
}
|
||||
|
||||
@ -297,10 +299,12 @@ inline SExpression operator*(SENode* lhs, SExpression rhs) { return rhs * lhs; }
|
||||
template <typename T,
|
||||
typename std::enable_if<std::is_integral<T>::value, int>::type>
|
||||
inline std::pair<SExpression, int64_t> operator/(T lhs, SExpression rhs) {
|
||||
// NOLINTNEXTLINE(whitespace/braces)
|
||||
return SExpression{rhs.GetScalarEvolutionAnalysis()->CreateConstant(lhs)} /
|
||||
rhs;
|
||||
}
|
||||
inline std::pair<SExpression, int64_t> operator/(SENode* lhs, SExpression rhs) {
|
||||
// NOLINTNEXTLINE(whitespace/braces)
|
||||
return SExpression{lhs} / rhs;
|
||||
}
|
||||
|
||||
|
@ -310,9 +310,8 @@ spv_result_t VersionCheck(ValidationState_t& _, const Instruction* inst) {
|
||||
static_cast<spv_target_env>(min_version))
|
||||
<< " at minimum.";
|
||||
}
|
||||
}
|
||||
// Otherwise, we only error out when no enabling extensions are registered.
|
||||
else if (!_.HasAnyOfExtensions(exts)) {
|
||||
} else if (!_.HasAnyOfExtensions(exts)) {
|
||||
if (min_version == ~0u) {
|
||||
return _.diag(SPV_ERROR_MISSING_EXTENSION)
|
||||
<< spvOpcodeString(opcode)
|
||||
|
@ -227,8 +227,8 @@ INSTANTIATE_TEST_CASE_P(
|
||||
::testing::ValuesIn(std::vector<
|
||||
std::pair<FloatProxy<double>, std::string>>({
|
||||
// Various NAN and INF cases
|
||||
{uint64_t(0xFFF0000000000000LL), "-0x1p+1024"}, //-inf
|
||||
{uint64_t(0x7FF0000000000000LL), "0x1p+1024"}, //+inf
|
||||
{uint64_t(0xFFF0000000000000LL), "-0x1p+1024"}, // -inf
|
||||
{uint64_t(0x7FF0000000000000LL), "0x1p+1024"}, // +inf
|
||||
{uint64_t(0xFFF8000000000000LL), "-0x1.8p+1024"}, // -nan
|
||||
{uint64_t(0xFFF0F00000000000LL), "-0x1.0fp+1024"}, // -nan
|
||||
{uint64_t(0xFFF0000000000001LL), "-0x1.0000000000001p+1024"}, // -nan
|
||||
|
@ -483,8 +483,8 @@ INSTANTIATE_TEST_CASE_P(
|
||||
{6,
|
||||
{
|
||||
// Can't check constants properly
|
||||
//"%8 = OpConstant %6 0",
|
||||
//"%18 = OpConstant %6 1",
|
||||
// "%8 = OpConstant %6 0",
|
||||
// "%18 = OpConstant %6 1",
|
||||
"%7 = OpPhi %6 %8 %4 %9 %5",
|
||||
"%9 = OpIAdd %6 %7 %8",
|
||||
}
|
||||
@ -504,7 +504,7 @@ INSTANTIATE_TEST_CASE_P(
|
||||
{9, {"%7 = OpPhi %6 %8 %4 %9 %5"}},
|
||||
{10,
|
||||
{
|
||||
//"%12 = OpConstant %10 1.0",
|
||||
// "%12 = OpConstant %10 1.0",
|
||||
"%11 = OpPhi %10 %12 %4 %13 %5",
|
||||
"%13 = OpFAdd %10 %11 %12",
|
||||
}
|
||||
@ -831,8 +831,8 @@ INSTANTIATE_TEST_CASE_P(
|
||||
{6,
|
||||
{
|
||||
// Can't properly check constants
|
||||
//"%8 = OpConstant %6 0",
|
||||
//"%18 = OpConstant %6 1",
|
||||
// "%8 = OpConstant %6 0",
|
||||
// "%18 = OpConstant %6 1",
|
||||
"%7 = OpPhi %6 %8 %4 %13 %5",
|
||||
"%9 = OpIAdd %6 %7 %8"
|
||||
}
|
||||
@ -853,7 +853,7 @@ INSTANTIATE_TEST_CASE_P(
|
||||
{10,
|
||||
{
|
||||
"%11 = OpPhi %10 %12 %4 %13 %5",
|
||||
//"%12 = OpConstant %10 1",
|
||||
// "%12 = OpConstant %10 1",
|
||||
"%13 = OpFAdd %10 %9 %12"
|
||||
}
|
||||
},
|
||||
@ -1085,14 +1085,14 @@ INSTANTIATE_TEST_CASE_P(
|
||||
{4,
|
||||
{
|
||||
"%7 = OpPhi %6 %8 %4 %9 %5",
|
||||
//"%11 = OpPhi %10 %12 %4 %13 %5",
|
||||
// "%11 = OpPhi %10 %12 %4 %13 %5",
|
||||
}
|
||||
},
|
||||
{5,
|
||||
{
|
||||
"OpBranch %5",
|
||||
"%7 = OpPhi %6 %8 %4 %9 %5",
|
||||
//"%11 = OpPhi %10 %12 %4 %13 %5",
|
||||
// "%11 = OpPhi %10 %12 %4 %13 %5",
|
||||
"OpLoopMerge %19 %5 None",
|
||||
"OpBranchConditional %17 %5 %19",
|
||||
}
|
||||
@ -1100,35 +1100,35 @@ INSTANTIATE_TEST_CASE_P(
|
||||
{6,
|
||||
{
|
||||
// Can't properly check constants
|
||||
//"%8 = OpConstant %6 0",
|
||||
//"%18 = OpConstant %6 1",
|
||||
// "%8 = OpConstant %6 0",
|
||||
// "%18 = OpConstant %6 1",
|
||||
"%7 = OpPhi %6 %8 %4 %9 %5",
|
||||
//"%9 = OpIAdd %6 %7 %8"
|
||||
// "%9 = OpIAdd %6 %7 %8"
|
||||
}
|
||||
},
|
||||
{7, {"%17 = OpSLessThan %16 %7 %18"}},
|
||||
{8,
|
||||
{
|
||||
"%7 = OpPhi %6 %8 %4 %9 %5",
|
||||
//"%9 = OpIAdd %6 %7 %8",
|
||||
// "%9 = OpIAdd %6 %7 %8",
|
||||
}
|
||||
},
|
||||
// {9, {"%7 = OpPhi %6 %8 %4 %13 %5"}},
|
||||
{10,
|
||||
{
|
||||
//"%11 = OpPhi %10 %12 %4 %13 %5",
|
||||
//"%12 = OpConstant %10 1",
|
||||
// "%11 = OpPhi %10 %12 %4 %13 %5",
|
||||
// "%12 = OpConstant %10 1",
|
||||
"%13 = OpFAdd %10 %11 %12"
|
||||
}
|
||||
},
|
||||
// {11, {"%13 = OpFAdd %10 %11 %12"}},
|
||||
{12,
|
||||
{
|
||||
//"%11 = OpPhi %10 %12 %4 %13 %5",
|
||||
// "%11 = OpPhi %10 %12 %4 %13 %5",
|
||||
"%13 = OpFAdd %10 %11 %12"
|
||||
}
|
||||
},
|
||||
//{13, {"%11 = OpPhi %10 %12 %4 %13 %5"}},
|
||||
// {13, {"%11 = OpPhi %10 %12 %4 %13 %5"}},
|
||||
{16, {"%17 = OpSLessThan %16 %7 %18"}},
|
||||
{17, {"OpBranchConditional %17 %5 %19"}},
|
||||
{18, {"%17 = OpSLessThan %16 %7 %18"}},
|
||||
|
@ -5618,7 +5618,7 @@ TEST_P(MatchingInstructionWithNoResultFoldingTest, Case) {
|
||||
// Fold the instruction to test.
|
||||
opt::Instruction* inst = nullptr;
|
||||
opt::Function* func = &*context->module()->begin();
|
||||
for(auto& bb : *func) {
|
||||
for (auto& bb : *func) {
|
||||
opt::Instruction* terminator = bb.terminator();
|
||||
if (terminator->IsReturnOrAbort()) {
|
||||
inst = terminator->PreviousNode();
|
||||
|
@ -176,14 +176,14 @@ TEST_F(InlineTest, Nested) {
|
||||
"%15 = OpTypeFunction %void",
|
||||
"%float = OpTypeFloat 32",
|
||||
"%_ptr_Function_float = OpTypePointer Function %float",
|
||||
"%18 = OpTypeFunction %float %_ptr_Function_float %_ptr_Function_float",
|
||||
"%v4float = OpTypeVector %float 4",
|
||||
"%18 = OpTypeFunction %float %_ptr_Function_float %_ptr_Function_float",
|
||||
"%v4float = OpTypeVector %float 4",
|
||||
"%_ptr_Function_v4float = OpTypePointer Function %v4float",
|
||||
"%21 = OpTypeFunction %float %_ptr_Function_v4float",
|
||||
"%uint = OpTypeInt 32 0",
|
||||
"%uint = OpTypeInt 32 0",
|
||||
"%uint_0 = OpConstant %uint 0",
|
||||
"%uint_1 = OpConstant %uint 1",
|
||||
"%uint_2 = OpConstant %uint 2",
|
||||
"%uint_2 = OpConstant %uint 2",
|
||||
"%_ptr_Input_v4float = OpTypePointer Input %v4float",
|
||||
"%BaseColor = OpVariable %_ptr_Input_v4float Input",
|
||||
"%_ptr_Output_v4float = OpTypePointer Output %v4float",
|
||||
@ -250,7 +250,7 @@ TEST_F(InlineTest, Nested) {
|
||||
"%48 = OpVariable %_ptr_Function_float Function",
|
||||
"%color = OpVariable %_ptr_Function_v4float Function",
|
||||
"%param_1 = OpVariable %_ptr_Function_v4float Function",
|
||||
"%29 = OpLoad %v4float %BaseColor",
|
||||
"%29 = OpLoad %v4float %BaseColor",
|
||||
"OpStore %param_1 %29",
|
||||
"%49 = OpAccessChain %_ptr_Function_float %param_1 %uint_0",
|
||||
"%50 = OpLoad %float %49",
|
||||
@ -266,7 +266,7 @@ TEST_F(InlineTest, Nested) {
|
||||
"%60 = OpFMul %float %58 %59",
|
||||
"OpStore %57 %60",
|
||||
"%56 = OpLoad %float %57",
|
||||
"OpStore %48 %56",
|
||||
"OpStore %48 %56",
|
||||
"%30 = OpLoad %float %48",
|
||||
"%31 = OpCompositeConstruct %v4float %30 %30 %30 %30",
|
||||
"OpStore %color %31",
|
||||
@ -615,7 +615,7 @@ TEST_F(InlineTest, PhiAfterCall) {
|
||||
"OpStore %r %44",
|
||||
"%45 = OpLoad %float %r",
|
||||
"%46 = OpFOrdLessThan %bool %45 %float_0",
|
||||
"OpSelectionMerge %47 None",
|
||||
"OpSelectionMerge %47 None",
|
||||
"OpBranchConditional %46 %48 %47",
|
||||
"%48 = OpLabel",
|
||||
"%49 = OpLoad %float %r",
|
||||
@ -643,7 +643,7 @@ TEST_F(InlineTest, PhiAfterCall) {
|
||||
"OpStore %param %30",
|
||||
"%31 = OpFunctionCall %float %foo_f1_ %param",
|
||||
"%32 = OpFOrdGreaterThan %bool %31 %float_2",
|
||||
"OpSelectionMerge %33 None",
|
||||
"OpSelectionMerge %33 None",
|
||||
"OpBranchConditional %32 %34 %33",
|
||||
"%34 = OpLabel",
|
||||
"%35 = OpAccessChain %_ptr_Function_float %color %uint_1",
|
||||
@ -654,7 +654,7 @@ TEST_F(InlineTest, PhiAfterCall) {
|
||||
"OpBranch %33",
|
||||
"%33 = OpLabel",
|
||||
"%39 = OpPhi %bool %32 %27 %38 %34",
|
||||
"OpSelectionMerge %40 None",
|
||||
"OpSelectionMerge %40 None",
|
||||
"OpBranchConditional %39 %41 %40",
|
||||
"%41 = OpLabel",
|
||||
"OpStore %color %25",
|
||||
@ -694,7 +694,7 @@ TEST_F(InlineTest, PhiAfterCall) {
|
||||
"%60 = OpFNegate %float %59",
|
||||
"OpStore %52 %60",
|
||||
"OpBranch %57",
|
||||
"%57 = OpLabel",
|
||||
"%57 = OpLabel",
|
||||
"%61 = OpLoad %float %52",
|
||||
"OpStore %53 %61",
|
||||
"%31 = OpLoad %float %53",
|
||||
@ -710,7 +710,7 @@ TEST_F(InlineTest, PhiAfterCall) {
|
||||
"%65 = OpLoad %float %62",
|
||||
"%66 = OpFOrdLessThan %bool %65 %float_0",
|
||||
"OpSelectionMerge %67 None",
|
||||
"OpBranchConditional %66 %68 %67",
|
||||
"OpBranchConditional %66 %68 %67",
|
||||
"%68 = OpLabel",
|
||||
"%69 = OpLoad %float %62",
|
||||
"%70 = OpFNegate %float %69",
|
||||
@ -1207,7 +1207,7 @@ TEST_F(InlineTest, OpImageAndOpSampledImageOutOfBlock) {
|
||||
"%uint = OpTypeInt 32 0",
|
||||
"%uint_0 = OpConstant %uint 0",
|
||||
"%float_0 = OpConstant %float 0",
|
||||
"%bool = OpTypeBool",
|
||||
"%bool = OpTypeBool",
|
||||
"%26 = OpTypeImage %float 2D 0 0 0 1 Unknown",
|
||||
"%_ptr_UniformConstant_26 = OpTypePointer UniformConstant %26",
|
||||
"%t2D = OpVariable %_ptr_UniformConstant_26 UniformConstant",
|
||||
@ -1221,7 +1221,7 @@ TEST_F(InlineTest, OpImageAndOpSampledImageOutOfBlock) {
|
||||
"%_ptr_Input_v4float = OpTypePointer Input %v4float",
|
||||
"%BaseColor = OpVariable %_ptr_Input_v4float Input",
|
||||
"%samp2 = OpVariable %_ptr_UniformConstant_28 UniformConstant",
|
||||
"%float_0_5 = OpConstant %float 0.5",
|
||||
"%float_0_5 = OpConstant %float 0.5",
|
||||
"%36 = OpConstantComposite %v2float %float_0_5 %float_0_5",
|
||||
"%_ptr_Output_v4float = OpTypePointer Output %v4float",
|
||||
"%FragColor = OpVariable %_ptr_Output_v4float Output",
|
||||
|
@ -175,115 +175,116 @@ OpFunctionEnd
|
||||
// TODO(alanbaker): Re-enable when vector and matrix scalarization is supported.
|
||||
// TEST_F(ScalarReplacementTest, VectorInitialization) {
|
||||
// const std::string text = R"(
|
||||
//;
|
||||
//; CHECK: [[elem:%\w+]] = OpTypeInt 32 0
|
||||
//; CHECK: [[vector:%\w+]] = OpTypeVector [[elem]] 4
|
||||
//; CHECK: [[vector_ptr:%\w+]] = OpTypePointer Function [[vector]]
|
||||
//; CHECK: [[elem_ptr:%\w+]] = OpTypePointer Function [[elem]]
|
||||
//; CHECK: [[zero:%\w+]] = OpConstant [[elem]] 0
|
||||
//; CHECK: [[undef:%\w+]] = OpUndef [[elem]]
|
||||
//; CHECK: [[two:%\w+]] = OpConstant [[elem]] 2
|
||||
//; CHECK: [[null:%\w+]] = OpConstantNull [[elem]]
|
||||
//; CHECK-NOT: OpVariable [[vector_ptr]]
|
||||
//; CHECK: OpVariable [[elem_ptr]] Function [[zero]]
|
||||
//; CHECK-NOT: OpVariable [[elem_ptr]] Function [[undef]]
|
||||
//; CHECK-NEXT: OpVariable [[elem_ptr]] Function
|
||||
//; CHECK-NEXT: OpVariable [[elem_ptr]] Function [[two]]
|
||||
//; CHECK-NEXT: OpVariable [[elem_ptr]] Function [[null]]
|
||||
//; CHECK-NOT: OpVariable [[elem_ptr]] Function [[undef]]
|
||||
//;
|
||||
// OpCapability Shader
|
||||
// OpCapability Linkage
|
||||
// OpMemoryModel Logical GLSL450
|
||||
// OpName %6 "vector_init"
|
||||
//%1 = OpTypeVoid
|
||||
//%2 = OpTypeInt 32 0
|
||||
//%3 = OpTypeVector %2 4
|
||||
//%4 = OpTypePointer Function %3
|
||||
//%20 = OpTypePointer Function %2
|
||||
//%6 = OpTypeFunction %1
|
||||
//%7 = OpConstant %2 0
|
||||
//%8 = OpUndef %2
|
||||
//%9 = OpConstant %2 2
|
||||
//%30 = OpConstant %2 1
|
||||
//%31 = OpConstant %2 3
|
||||
//%10 = OpConstantNull %2
|
||||
//%11 = OpConstantComposite %3 %10 %9 %8 %7
|
||||
//%12 = OpFunction %1 None %6
|
||||
//%13 = OpLabel
|
||||
//%14 = OpVariable %4 Function %11
|
||||
//%15 = OpAccessChain %20 %14 %7
|
||||
// OpStore %15 %10
|
||||
//%16 = OpAccessChain %20 %14 %9
|
||||
// OpStore %16 %10
|
||||
//%17 = OpAccessChain %20 %14 %30
|
||||
// OpStore %17 %10
|
||||
//%18 = OpAccessChain %20 %14 %31
|
||||
// OpStore %18 %10
|
||||
// OpReturn
|
||||
// OpFunctionEnd
|
||||
// )";
|
||||
// ;
|
||||
// ; CHECK: [[elem:%\w+]] = OpTypeInt 32 0
|
||||
// ; CHECK: [[vector:%\w+]] = OpTypeVector [[elem]] 4
|
||||
// ; CHECK: [[vector_ptr:%\w+]] = OpTypePointer Function [[vector]]
|
||||
// ; CHECK: [[elem_ptr:%\w+]] = OpTypePointer Function [[elem]]
|
||||
// ; CHECK: [[zero:%\w+]] = OpConstant [[elem]] 0
|
||||
// ; CHECK: [[undef:%\w+]] = OpUndef [[elem]]
|
||||
// ; CHECK: [[two:%\w+]] = OpConstant [[elem]] 2
|
||||
// ; CHECK: [[null:%\w+]] = OpConstantNull [[elem]]
|
||||
// ; CHECK-NOT: OpVariable [[vector_ptr]]
|
||||
// ; CHECK: OpVariable [[elem_ptr]] Function [[zero]]
|
||||
// ; CHECK-NOT: OpVariable [[elem_ptr]] Function [[undef]]
|
||||
// ; CHECK-NEXT: OpVariable [[elem_ptr]] Function
|
||||
// ; CHECK-NEXT: OpVariable [[elem_ptr]] Function [[two]]
|
||||
// ; CHECK-NEXT: OpVariable [[elem_ptr]] Function [[null]]
|
||||
// ; CHECK-NOT: OpVariable [[elem_ptr]] Function [[undef]]
|
||||
// ;
|
||||
// OpCapability Shader
|
||||
// OpCapability Linkage
|
||||
// OpMemoryModel Logical GLSL450
|
||||
// OpName %6 "vector_init"
|
||||
// %1 = OpTypeVoid
|
||||
// %2 = OpTypeInt 32 0
|
||||
// %3 = OpTypeVector %2 4
|
||||
// %4 = OpTypePointer Function %3
|
||||
// %20 = OpTypePointer Function %2
|
||||
// %6 = OpTypeFunction %1
|
||||
// %7 = OpConstant %2 0
|
||||
// %8 = OpUndef %2
|
||||
// %9 = OpConstant %2 2
|
||||
// %30 = OpConstant %2 1
|
||||
// %31 = OpConstant %2 3
|
||||
// %10 = OpConstantNull %2
|
||||
// %11 = OpConstantComposite %3 %10 %9 %8 %7
|
||||
// %12 = OpFunction %1 None %6
|
||||
// %13 = OpLabel
|
||||
// %14 = OpVariable %4 Function %11
|
||||
// %15 = OpAccessChain %20 %14 %7
|
||||
// OpStore %15 %10
|
||||
// %16 = OpAccessChain %20 %14 %9
|
||||
// OpStore %16 %10
|
||||
// %17 = OpAccessChain %20 %14 %30
|
||||
// OpStore %17 %10
|
||||
// %18 = OpAccessChain %20 %14 %31
|
||||
// OpStore %18 %10
|
||||
// OpReturn
|
||||
// OpFunctionEnd
|
||||
// )";
|
||||
//
|
||||
// SinglePassRunAndMatch<opt::ScalarReplacementPass>(text, true);
|
||||
//}
|
||||
// SinglePassRunAndMatch<opt::ScalarReplacementPass>(text, true);
|
||||
// }
|
||||
//
|
||||
// TEST_F(ScalarReplacementTest, MatrixInitialization) {
|
||||
// const std::string text = R"(
|
||||
//;
|
||||
//; CHECK: [[float:%\w+]] = OpTypeFloat 32
|
||||
//; CHECK: [[vector:%\w+]] = OpTypeVector [[float]] 2
|
||||
//; CHECK: [[matrix:%\w+]] = OpTypeMatrix [[vector]] 2
|
||||
//; CHECK: [[matrix_ptr:%\w+]] = OpTypePointer Function [[matrix]]
|
||||
//; CHECK: [[float_ptr:%\w+]] = OpTypePointer Function [[float]]
|
||||
//; CHECK: [[vec_ptr:%\w+]] = OpTypePointer Function [[vector]]
|
||||
//; CHECK: [[zerof:%\w+]] = OpConstant [[float]] 0
|
||||
//; CHECK: [[onef:%\w+]] = OpConstant [[float]] 1
|
||||
//; CHECK: [[one_zero:%\w+]] = OpConstantComposite [[vector]] [[onef]] [[zerof]]
|
||||
//; CHECK: [[zero_one:%\w+]] = OpConstantComposite [[vector]] [[zerof]] [[onef]]
|
||||
//; CHECK: [[const_mat:%\w+]] = OpConstantComposite [[matrix]] [[one_zero]]
|
||||
//[[zero_one]] ; CHECK-NOT: OpVariable [[matrix]] ; CHECK-NOT: OpVariable
|
||||
//[[vector]] Function [[one_zero]] ; CHECK: [[f1:%\w+]] = OpVariable
|
||||
//[[float_ptr]] Function [[zerof]] ; CHECK-NEXT: [[f2:%\w+]] = OpVariable
|
||||
//[[float_ptr]] Function [[onef]] ; CHECK-NEXT: [[vec_var:%\w+]] = OpVariable
|
||||
//[[vec_ptr]] Function [[zero_one]] ; CHECK-NOT: OpVariable [[matrix]] ;
|
||||
// CHECK-NOT: OpVariable [[vector]] Function [[one_zero]]
|
||||
//;
|
||||
// OpCapability Shader
|
||||
// OpCapability Linkage
|
||||
// OpMemoryModel Logical GLSL450
|
||||
// OpName %7 "matrix_init"
|
||||
//%1 = OpTypeVoid
|
||||
//%2 = OpTypeFloat 32
|
||||
//%3 = OpTypeVector %2 2
|
||||
//%4 = OpTypeMatrix %3 2
|
||||
//%5 = OpTypePointer Function %4
|
||||
//%6 = OpTypePointer Function %2
|
||||
//%30 = OpTypePointer Function %3
|
||||
//%10 = OpTypeInt 32 0
|
||||
//%7 = OpTypeFunction %1 %10
|
||||
//%8 = OpConstant %2 0.0
|
||||
//%9 = OpConstant %2 1.0
|
||||
//%11 = OpConstant %10 0
|
||||
//%12 = OpConstant %10 1
|
||||
//%13 = OpConstantComposite %3 %9 %8
|
||||
//%14 = OpConstantComposite %3 %8 %9
|
||||
//%15 = OpConstantComposite %4 %13 %14
|
||||
//%16 = OpFunction %1 None %7
|
||||
//%31 = OpFunctionParameter %10
|
||||
//%17 = OpLabel
|
||||
//%18 = OpVariable %5 Function %15
|
||||
//%19 = OpAccessChain %6 %18 %11 %12
|
||||
// OpStore %19 %8
|
||||
//%20 = OpAccessChain %6 %18 %11 %11
|
||||
// OpStore %20 %8
|
||||
//%21 = OpAccessChain %30 %18 %12
|
||||
// OpStore %21 %14
|
||||
// OpReturn
|
||||
// OpFunctionEnd
|
||||
// )";
|
||||
// TEST_F(ScalarReplacementTest, MatrixInitialization) {
|
||||
// const std::string text = R"(
|
||||
// ;
|
||||
// ; CHECK: [[float:%\w+]] = OpTypeFloat 32
|
||||
// ; CHECK: [[vector:%\w+]] = OpTypeVector [[float]] 2
|
||||
// ; CHECK: [[matrix:%\w+]] = OpTypeMatrix [[vector]] 2
|
||||
// ; CHECK: [[matrix_ptr:%\w+]] = OpTypePointer Function [[matrix]]
|
||||
// ; CHECK: [[float_ptr:%\w+]] = OpTypePointer Function [[float]]
|
||||
// ; CHECK: [[vec_ptr:%\w+]] = OpTypePointer Function [[vector]]
|
||||
// ; CHECK: [[zerof:%\w+]] = OpConstant [[float]] 0
|
||||
// ; CHECK: [[onef:%\w+]] = OpConstant [[float]] 1
|
||||
// ; CHECK: [[one_zero:%\w+]] = OpConstantComposite [[vector]] [[onef]]
|
||||
// [[zerof]] ; CHECK: [[zero_one:%\w+]] = OpConstantComposite [[vector]]
|
||||
// [[zerof]] [[onef]] ; CHECK: [[const_mat:%\w+]] = OpConstantComposite
|
||||
// [[matrix]] [[one_zero]]
|
||||
// [[zero_one]] ; CHECK-NOT: OpVariable [[matrix]] ; CHECK-NOT: OpVariable
|
||||
// [[vector]] Function [[one_zero]] ; CHECK: [[f1:%\w+]] = OpVariable
|
||||
// [[float_ptr]] Function [[zerof]] ; CHECK-NEXT: [[f2:%\w+]] = OpVariable
|
||||
// [[float_ptr]] Function [[onef]] ; CHECK-NEXT: [[vec_var:%\w+]] = OpVariable
|
||||
// [[vec_ptr]] Function [[zero_one]] ; CHECK-NOT: OpVariable [[matrix]] ;
|
||||
// CHECK-NOT: OpVariable [[vector]] Function [[one_zero]]
|
||||
// ;
|
||||
// OpCapability Shader
|
||||
// OpCapability Linkage
|
||||
// OpMemoryModel Logical GLSL450
|
||||
// OpName %7 "matrix_init"
|
||||
// %1 = OpTypeVoid
|
||||
// %2 = OpTypeFloat 32
|
||||
// %3 = OpTypeVector %2 2
|
||||
// %4 = OpTypeMatrix %3 2
|
||||
// %5 = OpTypePointer Function %4
|
||||
// %6 = OpTypePointer Function %2
|
||||
// %30 = OpTypePointer Function %3
|
||||
// %10 = OpTypeInt 32 0
|
||||
// %7 = OpTypeFunction %1 %10
|
||||
// %8 = OpConstant %2 0.0
|
||||
// %9 = OpConstant %2 1.0
|
||||
// %11 = OpConstant %10 0
|
||||
// %12 = OpConstant %10 1
|
||||
// %13 = OpConstantComposite %3 %9 %8
|
||||
// %14 = OpConstantComposite %3 %8 %9
|
||||
// %15 = OpConstantComposite %4 %13 %14
|
||||
// %16 = OpFunction %1 None %7
|
||||
// %31 = OpFunctionParameter %10
|
||||
// %17 = OpLabel
|
||||
// %18 = OpVariable %5 Function %15
|
||||
// %19 = OpAccessChain %6 %18 %11 %12
|
||||
// OpStore %19 %8
|
||||
// %20 = OpAccessChain %6 %18 %11 %11
|
||||
// OpStore %20 %8
|
||||
// %21 = OpAccessChain %30 %18 %12
|
||||
// OpStore %21 %14
|
||||
// OpReturn
|
||||
// OpFunctionEnd
|
||||
// )";
|
||||
//
|
||||
// SinglePassRunAndMatch<opt::ScalarReplacementPass>(text, true);
|
||||
//}
|
||||
// SinglePassRunAndMatch<opt::ScalarReplacementPass>(text, true);
|
||||
// }
|
||||
|
||||
TEST_F(ScalarReplacementTest, ElideAccessChain) {
|
||||
const std::string text = R"(
|
||||
@ -448,7 +449,6 @@ OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::ScalarReplacementPass>(text, true);
|
||||
;
|
||||
}
|
||||
|
||||
TEST_F(ScalarReplacementTest, NonUniformCompositeInitialization) {
|
||||
@ -530,7 +530,6 @@ OpFunctionEnd
|
||||
)";
|
||||
|
||||
SinglePassRunAndMatch<opt::ScalarReplacementPass>(text, true);
|
||||
;
|
||||
}
|
||||
|
||||
TEST_F(ScalarReplacementTest, ElideUncombinedAccessChains) {
|
||||
|
@ -574,8 +574,8 @@ INSTANTIATE_TEST_CASE_P(
|
||||
"%1 = OpTypeFloat 32\n%2 = OpConstant %1 0x1.0018p+128\n", // +nan
|
||||
"%1 = OpTypeFloat 32\n%2 = OpConstant %1 0x1.01ep+128\n", // +nan
|
||||
"%1 = OpTypeFloat 32\n%2 = OpConstant %1 0x1.fffffep+128\n", // +nan
|
||||
"%1 = OpTypeFloat 64\n%2 = OpConstant %1 -0x1p+1024\n", //-inf
|
||||
"%1 = OpTypeFloat 64\n%2 = OpConstant %1 0x1p+1024\n", //+inf
|
||||
"%1 = OpTypeFloat 64\n%2 = OpConstant %1 -0x1p+1024\n", // -inf
|
||||
"%1 = OpTypeFloat 64\n%2 = OpConstant %1 0x1p+1024\n", // +inf
|
||||
"%1 = OpTypeFloat 64\n%2 = OpConstant %1 -0x1.8p+1024\n", // -nan
|
||||
"%1 = OpTypeFloat 64\n%2 = OpConstant %1 -0x1.0fp+1024\n", // -nan
|
||||
"%1 = OpTypeFloat 64\n%2 = OpConstant %1 -0x1.0000000000001p+1024\n", // -nan
|
||||
|
@ -957,16 +957,16 @@ make_pair(string(kGLSL450MemoryModel) +
|
||||
vector<string>{"LiteralSampler"})
|
||||
)),);
|
||||
|
||||
//TODO(umar): Sampler Filter Mode
|
||||
//TODO(umar): Image Format
|
||||
//TODO(umar): Image Channel Order
|
||||
//TODO(umar): Image Channel Data Type
|
||||
//TODO(umar): Image Operands
|
||||
//TODO(umar): FP Fast Math Mode
|
||||
//TODO(umar): FP Rounding Mode
|
||||
//TODO(umar): Linkage Type
|
||||
//TODO(umar): Access Qualifier
|
||||
//TODO(umar): Function Parameter Attribute
|
||||
// TODO(umar): Sampler Filter Mode
|
||||
// TODO(umar): Image Format
|
||||
// TODO(umar): Image Channel Order
|
||||
// TODO(umar): Image Channel Data Type
|
||||
// TODO(umar): Image Operands
|
||||
// TODO(umar): FP Fast Math Mode
|
||||
// TODO(umar): FP Rounding Mode
|
||||
// TODO(umar): Linkage Type
|
||||
// TODO(umar): Access Qualifier
|
||||
// TODO(umar): Function Parameter Attribute
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Decoration, ValidateCapability,
|
||||
Combine(
|
||||
|
@ -1615,7 +1615,7 @@ TEST_F(ValidateDecorations, BufferBlock16bitStandardStorageBufferLayout) {
|
||||
TEST_F(ValidateDecorations, PushConstantArrayBaseAlignmentGood) {
|
||||
// Tests https://github.com/KhronosGroup/SPIRV-Tools/issues/1664
|
||||
// From GLSL vertex shader:
|
||||
//#version 450
|
||||
// #version 450
|
||||
// layout(push_constant) uniform S { vec2 v; float arr[2]; } u;
|
||||
// void main() { }
|
||||
|
||||
|
@ -134,38 +134,38 @@ INSTANTIATE_TEST_CASE_P(InstructionsOrder,
|
||||
// validation error. Therefore, "Lines to compile" for some instructions
|
||||
// are not "All" in the below.
|
||||
//
|
||||
// | Instruction | Line(s) valid | Lines to compile
|
||||
::testing::Values( make_tuple(string("OpCapability") , Equals<0> , Range<0, 2>())
|
||||
, make_tuple(string("OpExtension") , Equals<1> , All)
|
||||
, make_tuple(string("OpExtInstImport") , Equals<2> , All)
|
||||
, make_tuple(string("OpMemoryModel") , Equals<3> , Range<1, kRangeEnd>())
|
||||
, make_tuple(string("OpEntryPoint") , Equals<4> , All)
|
||||
, make_tuple(string("OpExecutionMode ") , Range<5, 6>() , All)
|
||||
, make_tuple(string("OpExecutionModeId") , Range<5, 6>() , All)
|
||||
, make_tuple(string("OpSource ") , Range<7, 11>() , Range<8, kRangeEnd>())
|
||||
, make_tuple(string("OpSourceContinued ") , Range<7, 11>() , All)
|
||||
, make_tuple(string("OpSourceExtension ") , Range<7, 11>() , All)
|
||||
, make_tuple(string("%str2 = OpString ") , Range<7, 11>() , All)
|
||||
, make_tuple(string("OpName ") , Range<12, 13>() , All)
|
||||
, make_tuple(string("OpMemberName ") , Range<12, 13>() , All)
|
||||
, make_tuple(string("OpDecorate ") , Range<14, 17>() , All)
|
||||
, make_tuple(string("OpMemberDecorate ") , Range<14, 17>() , All)
|
||||
, make_tuple(string("OpGroupDecorate ") , Range<14, 17>() , Range<17, kRangeEnd>())
|
||||
, make_tuple(string("OpDecorationGroup") , Range<14, 17>() , Range<0, 16>())
|
||||
, make_tuple(string("OpTypeBool") , Range<18, 31>() , All)
|
||||
, make_tuple(string("OpTypeVoid") , Range<18, 31>() , Range<0, 26>())
|
||||
, make_tuple(string("OpTypeFloat") , Range<18, 31>() , Range<0,21>())
|
||||
, make_tuple(string("OpTypeInt") , Range<18, 31>() , Range<0, 21>())
|
||||
, make_tuple(string("OpTypeVector %floatt 4") , Range<18, 31>() , Range<20, 24>())
|
||||
, make_tuple(string("OpTypeMatrix %vec4 4") , Range<18, 31>() , Range<23, kRangeEnd>())
|
||||
, make_tuple(string("OpTypeStruct") , Range<18, 31>() , Range<25, kRangeEnd>())
|
||||
, make_tuple(string("%vfunct = OpTypeFunction"), Range<18, 31>() , Range<21, 31>())
|
||||
, make_tuple(string("OpConstant") , Range<18, 31>() , Range<21, kRangeEnd>())
|
||||
, make_tuple(string("OpLine ") , Range<18, kRangeEnd>() , Range<8, kRangeEnd>())
|
||||
, make_tuple(string("OpNoLine") , Range<18, kRangeEnd>() , All)
|
||||
, make_tuple(string("%fLabel = OpLabel") , Equals<39> , All)
|
||||
, make_tuple(string("OpNop") , Equals<40> , Range<40,kRangeEnd>())
|
||||
, make_tuple(string("OpReturn ; %func2 return") , Equals<41> , All)
|
||||
// | Instruction | Line(s) valid | Lines to compile
|
||||
::testing::Values(make_tuple(string("OpCapability") , Equals<0> , Range<0, 2>())
|
||||
, make_tuple(string("OpExtension") , Equals<1> , All)
|
||||
, make_tuple(string("OpExtInstImport") , Equals<2> , All)
|
||||
, make_tuple(string("OpMemoryModel") , Equals<3> , Range<1, kRangeEnd>())
|
||||
, make_tuple(string("OpEntryPoint") , Equals<4> , All)
|
||||
, make_tuple(string("OpExecutionMode ") , Range<5, 6>() , All)
|
||||
, make_tuple(string("OpExecutionModeId") , Range<5, 6>() , All)
|
||||
, make_tuple(string("OpSource ") , Range<7, 11>() , Range<8, kRangeEnd>())
|
||||
, make_tuple(string("OpSourceContinued ") , Range<7, 11>() , All)
|
||||
, make_tuple(string("OpSourceExtension ") , Range<7, 11>() , All)
|
||||
, make_tuple(string("%str2 = OpString ") , Range<7, 11>() , All)
|
||||
, make_tuple(string("OpName ") , Range<12, 13>() , All)
|
||||
, make_tuple(string("OpMemberName ") , Range<12, 13>() , All)
|
||||
, make_tuple(string("OpDecorate ") , Range<14, 17>() , All)
|
||||
, make_tuple(string("OpMemberDecorate ") , Range<14, 17>() , All)
|
||||
, make_tuple(string("OpGroupDecorate ") , Range<14, 17>() , Range<17, kRangeEnd>())
|
||||
, make_tuple(string("OpDecorationGroup") , Range<14, 17>() , Range<0, 16>())
|
||||
, make_tuple(string("OpTypeBool") , Range<18, 31>() , All)
|
||||
, make_tuple(string("OpTypeVoid") , Range<18, 31>() , Range<0, 26>())
|
||||
, make_tuple(string("OpTypeFloat") , Range<18, 31>() , Range<0,21>())
|
||||
, make_tuple(string("OpTypeInt") , Range<18, 31>() , Range<0, 21>())
|
||||
, make_tuple(string("OpTypeVector %floatt 4") , Range<18, 31>() , Range<20, 24>())
|
||||
, make_tuple(string("OpTypeMatrix %vec4 4") , Range<18, 31>() , Range<23, kRangeEnd>())
|
||||
, make_tuple(string("OpTypeStruct") , Range<18, 31>() , Range<25, kRangeEnd>())
|
||||
, make_tuple(string("%vfunct = OpTypeFunction"), Range<18, 31>() , Range<21, 31>())
|
||||
, make_tuple(string("OpConstant") , Range<18, 31>() , Range<21, kRangeEnd>())
|
||||
, make_tuple(string("OpLine ") , Range<18, kRangeEnd>() , Range<8, kRangeEnd>())
|
||||
, make_tuple(string("OpNoLine") , Range<18, kRangeEnd>() , All)
|
||||
, make_tuple(string("%fLabel = OpLabel") , Equals<39> , All)
|
||||
, make_tuple(string("OpNop") , Equals<40> , Range<40,kRangeEnd>())
|
||||
, make_tuple(string("OpReturn ; %func2 return") , Equals<41> , All)
|
||||
)),);
|
||||
// clang-format on
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user