Cleanup formatting and linter.
This CL cleans up various formatting and lint errors. Change-Id: Ieee14db90e36acc8b469d58abb84fcf3595321bb Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/23224 Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
parent
93e39b451b
commit
c7b66da6ad
|
@ -27,7 +27,7 @@ class NullLiteral : public Literal {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// @param type the type
|
/// @param type the type
|
||||||
NullLiteral(ast::type::Type* type);
|
explicit NullLiteral(ast::type::Type* type);
|
||||||
~NullLiteral() override;
|
~NullLiteral() override;
|
||||||
|
|
||||||
/// @returns true if this is a null literal
|
/// @returns true if this is a null literal
|
||||||
|
@ -43,4 +43,4 @@ class NullLiteral : public Literal {
|
||||||
} // namespace ast
|
} // namespace ast
|
||||||
} // namespace tint
|
} // namespace tint
|
||||||
|
|
||||||
#endif // SRC_AST_NULL_LITERAL_H_
|
#endif // SRC_AST_NULL_LITERAL_H_
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
|
|
|
@ -896,8 +896,9 @@ bool FunctionEmitter::LabelControlFlowConstructs() {
|
||||||
assert(parent->kind == Construct::kContinue);
|
assert(parent->kind == Construct::kContinue);
|
||||||
parent = parent->parent;
|
parent = parent->parent;
|
||||||
}
|
}
|
||||||
constructs_.push_back(std::make_unique<Construct>(
|
constructs_.push_back(
|
||||||
parent, int(depth), k, begin_id, end_id, begin_pos, end_pos));
|
std::make_unique<Construct>(parent, static_cast<int>(depth), k,
|
||||||
|
begin_id, end_id, begin_pos, end_pos));
|
||||||
Construct* result = constructs_.back().get();
|
Construct* result = constructs_.back().get();
|
||||||
enclosing.push_back(result);
|
enclosing.push_back(result);
|
||||||
return result;
|
return result;
|
||||||
|
@ -1433,7 +1434,8 @@ bool FunctionEmitter::FindIfSelectionInternalHeaders() {
|
||||||
// dominated by its own (different) header.
|
// dominated by its own (different) header.
|
||||||
return Fail() << "Block " << true_head
|
return Fail() << "Block " << true_head
|
||||||
<< " is the true branch for if-selection header "
|
<< " is the true branch for if-selection header "
|
||||||
<< construct->begin_id << " and also the merge block for header block "
|
<< construct->begin_id
|
||||||
|
<< " and also the merge block for header block "
|
||||||
<< true_head_info->header_for_merge
|
<< true_head_info->header_for_merge
|
||||||
<< " (violates dominance rule)";
|
<< " (violates dominance rule)";
|
||||||
}
|
}
|
||||||
|
@ -1444,7 +1446,8 @@ bool FunctionEmitter::FindIfSelectionInternalHeaders() {
|
||||||
// dominated by its own (different) header.
|
// dominated by its own (different) header.
|
||||||
return Fail() << "Block " << false_head
|
return Fail() << "Block " << false_head
|
||||||
<< " is the false branch for if-selection header "
|
<< " is the false branch for if-selection header "
|
||||||
<< construct->begin_id << " and also the merge block for header block "
|
<< construct->begin_id
|
||||||
|
<< " and also the merge block for header block "
|
||||||
<< false_head_info->header_for_merge
|
<< false_head_info->header_for_merge
|
||||||
<< " (violates dominance rule)";
|
<< " (violates dominance rule)";
|
||||||
}
|
}
|
||||||
|
@ -1530,8 +1533,8 @@ bool FunctionEmitter::FindIfSelectionInternalHeaders() {
|
||||||
// hence the merge block is not dominated by its own (different)
|
// hence the merge block is not dominated by its own (different)
|
||||||
// header.
|
// header.
|
||||||
return Fail()
|
return Fail()
|
||||||
<< "Block " << premerge_id
|
<< "Block " << premerge_id << " is the merge block for "
|
||||||
<< " is the merge block for " << dest_block_info->header_for_merge
|
<< dest_block_info->header_for_merge
|
||||||
<< " but has alternate paths reaching it, starting from"
|
<< " but has alternate paths reaching it, starting from"
|
||||||
<< " blocks " << true_head << " and " << false_head
|
<< " blocks " << true_head << " and " << false_head
|
||||||
<< " which are the true and false branches for the"
|
<< " which are the true and false branches for the"
|
||||||
|
@ -1697,7 +1700,7 @@ bool FunctionEmitter::EmitBasicBlock(const BlockInfo& block_info) {
|
||||||
// test DISABLED_BlockIsContinueForMoreThanOneHeader. If we generalize this,
|
// test DISABLED_BlockIsContinueForMoreThanOneHeader. If we generalize this,
|
||||||
// then by a dominance argument, the inner loop continue target can only be
|
// then by a dominance argument, the inner loop continue target can only be
|
||||||
// a single-block loop.
|
// a single-block loop.
|
||||||
// TODO(dneto): Handle this case.
|
// TODO(dneto): Handle this case.
|
||||||
// - All that's left is a kContinue and one of kIfSelection, kSwitchSelection,
|
// - All that's left is a kContinue and one of kIfSelection, kSwitchSelection,
|
||||||
// kLoop.
|
// kLoop.
|
||||||
//
|
//
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
|
@ -2733,7 +2733,7 @@ TEST_F(SpvParserTest,
|
||||||
|
|
||||||
TEST_F(
|
TEST_F(
|
||||||
SpvParserTest,
|
SpvParserTest,
|
||||||
VerifyHeaderContinueMergeOrder_HeaderDoesNotStrictlyDominateContinueTarget) {
|
VerifyHeaderContinueMergeOrder_HeaderDoesNotStrictlyDominateContinueTarget) { // NOLINT
|
||||||
auto assembly = CommonTypes() + R"(
|
auto assembly = CommonTypes() + R"(
|
||||||
%100 = OpFunction %void None %voidfn
|
%100 = OpFunction %void None %voidfn
|
||||||
|
|
||||||
|
@ -4240,7 +4240,10 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_BranchEscapesIfConstruct) {
|
||||||
FunctionEmitter fe(p, *spirv_function(100));
|
FunctionEmitter fe(p, *spirv_function(100));
|
||||||
EXPECT_FALSE(FlowClassifyCFGEdges(&fe)) << p->error();
|
EXPECT_FALSE(FlowClassifyCFGEdges(&fe)) << p->error();
|
||||||
// Some further processing
|
// Some further processing
|
||||||
EXPECT_THAT(p->error(), Eq("Branch from block 30 to block 80 is an invalid exit from construct starting at block 20; branch bypasses merge block 50"));
|
EXPECT_THAT(
|
||||||
|
p->error(),
|
||||||
|
Eq("Branch from block 30 to block 80 is an invalid exit from construct "
|
||||||
|
"starting at block 20; branch bypasses merge block 50"));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest, ClassifyCFGEdges_ReturnInContinueConstruct) {
|
TEST_F(SpvParserTest, ClassifyCFGEdges_ReturnInContinueConstruct) {
|
||||||
|
@ -5852,7 +5855,7 @@ TEST_F(SpvParserTest,
|
||||||
|
|
||||||
TEST_F(
|
TEST_F(
|
||||||
SpvParserTest,
|
SpvParserTest,
|
||||||
ClassifyCFGEdges_Fallthrough_BranchConditionalWith_Back_LoopOnOutside_IsError) {
|
ClassifyCFGEdges_Fallthrough_BranchConditionalWith_Back_LoopOnOutside_IsError) { // NOLINT
|
||||||
// Code generation assumes OpBranchConditional can't have kCaseFallThrough
|
// Code generation assumes OpBranchConditional can't have kCaseFallThrough
|
||||||
// with kBack.
|
// with kBack.
|
||||||
//
|
//
|
||||||
|
@ -5899,7 +5902,7 @@ TEST_F(
|
||||||
|
|
||||||
TEST_F(
|
TEST_F(
|
||||||
SpvParserTest,
|
SpvParserTest,
|
||||||
FindSwitchCaseSelectionHeaders_Fallthrough_BranchConditionalWith_Back_LoopOnInside_FallthroughIsMerge_IsError) {
|
FindSwitchCaseSelectionHeaders_Fallthrough_BranchConditionalWith_Back_LoopOnInside_FallthroughIsMerge_IsError) { // NOLINT
|
||||||
// Code generation assumes OpBranchConditional can't have kCaseFallThrough
|
// Code generation assumes OpBranchConditional can't have kCaseFallThrough
|
||||||
// with kBack.
|
// with kBack.
|
||||||
//
|
//
|
||||||
|
@ -5938,7 +5941,7 @@ TEST_F(
|
||||||
|
|
||||||
TEST_F(
|
TEST_F(
|
||||||
SpvParserTest,
|
SpvParserTest,
|
||||||
ClassifyCFGEdges_Fallthrough_BranchConditionalWith_Back_LoopOnInside_FallthroughIsNotMerge_IsError) {
|
ClassifyCFGEdges_Fallthrough_BranchConditionalWith_Back_LoopOnInside_FallthroughIsNotMerge_IsError) { // NOLINT
|
||||||
// Code generation assumes OpBranchConditional can't have kCaseFallThrough
|
// Code generation assumes OpBranchConditional can't have kCaseFallThrough
|
||||||
// with kBack.
|
// with kBack.
|
||||||
//
|
//
|
||||||
|
@ -5979,7 +5982,7 @@ TEST_F(
|
||||||
|
|
||||||
TEST_F(
|
TEST_F(
|
||||||
SpvParserTest,
|
SpvParserTest,
|
||||||
ClassifyCFGEdges_Fallthrough_BranchConditionalWith_Back_LoopOnInside_NestedMerge_IsError) {
|
ClassifyCFGEdges_Fallthrough_BranchConditionalWith_Back_LoopOnInside_NestedMerge_IsError) { // NOLINT
|
||||||
// Code generation assumes OpBranchConditional can't have kCaseFallThrough
|
// Code generation assumes OpBranchConditional can't have kCaseFallThrough
|
||||||
// with kBack.
|
// with kBack.
|
||||||
//
|
//
|
||||||
|
@ -6416,7 +6419,7 @@ TEST_F(SpvParserTest,
|
||||||
|
|
||||||
TEST_F(
|
TEST_F(
|
||||||
SpvParserTest,
|
SpvParserTest,
|
||||||
FindSwitchCaseHeaders_DomViolation_SwitchCase_CantBeMergeForOtherConstruct) {
|
FindSwitchCaseHeaders_DomViolation_SwitchCase_CantBeMergeForOtherConstruct) { // NOLINT
|
||||||
auto assembly = CommonTypes() + R"(
|
auto assembly = CommonTypes() + R"(
|
||||||
%100 = OpFunction %void None %voidfn
|
%100 = OpFunction %void None %voidfn
|
||||||
|
|
||||||
|
@ -7100,7 +7103,8 @@ TEST_F(SpvParserTest, ClassifyCFGEdges_IfBreak_WithForwardToPremerge) {
|
||||||
EXPECT_THAT(p->error(), Eq(""));
|
EXPECT_THAT(p->error(), Eq(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest, FindIfSelectionInternalHeaders_DomViolation_Merge_CantBeTrueHeader) {
|
TEST_F(SpvParserTest,
|
||||||
|
FindIfSelectionInternalHeaders_DomViolation_Merge_CantBeTrueHeader) {
|
||||||
auto assembly = CommonTypes() + R"(
|
auto assembly = CommonTypes() + R"(
|
||||||
%100 = OpFunction %void None %voidfn
|
%100 = OpFunction %void None %voidfn
|
||||||
|
|
||||||
|
@ -7125,10 +7129,14 @@ TEST_F(SpvParserTest, FindIfSelectionInternalHeaders_DomViolation_Merge_CantBeTr
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p, *spirv_function(100));
|
FunctionEmitter fe(p, *spirv_function(100));
|
||||||
EXPECT_FALSE(FlowFindIfSelectionInternalHeaders(&fe));
|
EXPECT_FALSE(FlowFindIfSelectionInternalHeaders(&fe));
|
||||||
EXPECT_THAT(p->error(), Eq("Block 40 is the true branch for if-selection header 10 and also the merge block for header block 20 (violates dominance rule)"));
|
EXPECT_THAT(
|
||||||
|
p->error(),
|
||||||
|
Eq("Block 40 is the true branch for if-selection header 10 and also the "
|
||||||
|
"merge block for header block 20 (violates dominance rule)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest, FindIfSelectionInternalHeaders_DomViolation_Merge_CantBeFalseHeader) {
|
TEST_F(SpvParserTest,
|
||||||
|
FindIfSelectionInternalHeaders_DomViolation_Merge_CantBeFalseHeader) {
|
||||||
auto assembly = CommonTypes() + R"(
|
auto assembly = CommonTypes() + R"(
|
||||||
%100 = OpFunction %void None %voidfn
|
%100 = OpFunction %void None %voidfn
|
||||||
|
|
||||||
|
@ -7153,10 +7161,14 @@ TEST_F(SpvParserTest, FindIfSelectionInternalHeaders_DomViolation_Merge_CantBeFa
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p, *spirv_function(100));
|
FunctionEmitter fe(p, *spirv_function(100));
|
||||||
EXPECT_FALSE(FlowFindIfSelectionInternalHeaders(&fe));
|
EXPECT_FALSE(FlowFindIfSelectionInternalHeaders(&fe));
|
||||||
EXPECT_THAT(p->error(), Eq("Block 40 is the false branch for if-selection header 10 and also the merge block for header block 20 (violates dominance rule)"));
|
EXPECT_THAT(
|
||||||
|
p->error(),
|
||||||
|
Eq("Block 40 is the false branch for if-selection header 10 and also the "
|
||||||
|
"merge block for header block 20 (violates dominance rule)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest, FindIfSelectionInternalHeaders_DomViolation_Merge_CantBePremerge) {
|
TEST_F(SpvParserTest,
|
||||||
|
FindIfSelectionInternalHeaders_DomViolation_Merge_CantBePremerge) {
|
||||||
auto assembly = CommonTypes() + R"(
|
auto assembly = CommonTypes() + R"(
|
||||||
%100 = OpFunction %void None %voidfn
|
%100 = OpFunction %void None %voidfn
|
||||||
|
|
||||||
|
@ -7187,7 +7199,11 @@ TEST_F(SpvParserTest, FindIfSelectionInternalHeaders_DomViolation_Merge_CantBePr
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
FunctionEmitter fe(p, *spirv_function(100));
|
FunctionEmitter fe(p, *spirv_function(100));
|
||||||
EXPECT_FALSE(FlowFindIfSelectionInternalHeaders(&fe));
|
EXPECT_FALSE(FlowFindIfSelectionInternalHeaders(&fe));
|
||||||
EXPECT_THAT(p->error(), Eq("Block 70 is the merge block for 50 but has alternate paths reaching it, starting from blocks 20 and 50 which are the true and false branches for the if-selection header block 10 (violates dominance rule)"));
|
EXPECT_THAT(p->error(),
|
||||||
|
Eq("Block 70 is the merge block for 50 but has alternate paths "
|
||||||
|
"reaching it, starting from blocks 20 and 50 which are the "
|
||||||
|
"true and false branches for the if-selection header block 10 "
|
||||||
|
"(violates dominance rule)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest, EmitBody_IfBreak_FromThen_ForwardWithinThen) {
|
TEST_F(SpvParserTest, EmitBody_IfBreak_FromThen_ForwardWithinThen) {
|
||||||
|
@ -12218,7 +12234,7 @@ Return{}
|
||||||
|
|
||||||
TEST_F(
|
TEST_F(
|
||||||
SpvParserTest,
|
SpvParserTest,
|
||||||
EmitBody_BranchConditional_Continue_Continue_AfterHeader_Conditional_EmptyContinuing) {
|
EmitBody_BranchConditional_Continue_Continue_AfterHeader_Conditional_EmptyContinuing) { // NOLINT
|
||||||
// Like the previous tests, but with an empty continuing clause.
|
// Like the previous tests, but with an empty continuing clause.
|
||||||
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
auto* p = parser(test::Assemble(CommonTypes() + R"(
|
||||||
%100 = OpFunction %void None %voidfn
|
%100 = OpFunction %void None %voidfn
|
||||||
|
|
|
@ -260,7 +260,8 @@ TEST_F(SpvParserTest_CompositeExtract, Vector) {
|
||||||
Identifier{y}
|
Identifier{y}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})")) << ToString(fe.ast_body());
|
})"))
|
||||||
|
<< ToString(fe.ast_body());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(SpvParserTest_CompositeExtract, Vector_IndexTooBigError) {
|
TEST_F(SpvParserTest_CompositeExtract, Vector_IndexTooBigError) {
|
||||||
|
|
|
@ -52,7 +52,7 @@ namespace spirv {
|
||||||
using Decoration = std::vector<uint32_t>;
|
using Decoration = std::vector<uint32_t>;
|
||||||
using DecorationList = std::vector<Decoration>;
|
using DecorationList = std::vector<Decoration>;
|
||||||
|
|
||||||
// An AST expression with its type.
|
/// An AST expression with its type.
|
||||||
struct TypedExpression {
|
struct TypedExpression {
|
||||||
/// Dummy constructor
|
/// Dummy constructor
|
||||||
TypedExpression();
|
TypedExpression();
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "src/type_determiner.h"
|
#include "src/type_determiner.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "spirv/unified1/GLSL.std.450.h"
|
#include "spirv/unified1/GLSL.std.450.h"
|
||||||
#include "src/ast/array_accessor_expression.h"
|
#include "src/ast/array_accessor_expression.h"
|
||||||
|
@ -47,6 +48,99 @@
|
||||||
#include "src/ast/variable_decl_statement.h"
|
#include "src/ast/variable_decl_statement.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
// Most of these are floating-point general except the below which are only
|
||||||
|
// FP16 and FP32. We only have FP32 at this point so the below works, if we
|
||||||
|
// get FP64 support or otherwise we'll need to differentiate.
|
||||||
|
// * radians
|
||||||
|
// * degrees
|
||||||
|
// * sin, cos, tan
|
||||||
|
// * asin, acos, atan
|
||||||
|
// * sinh, cosh, tanh
|
||||||
|
// * asinh, acosh, atanh
|
||||||
|
// * exp, exp2
|
||||||
|
// * log, log2
|
||||||
|
enum class GlslDataType {
|
||||||
|
kFloatScalarOrVector,
|
||||||
|
kIntScalarOrVector,
|
||||||
|
kFloatVector
|
||||||
|
};
|
||||||
|
struct GlslData {
|
||||||
|
const char* name;
|
||||||
|
uint8_t param_count;
|
||||||
|
uint32_t op_id;
|
||||||
|
GlslDataType type;
|
||||||
|
uint8_t vector_count;
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr const GlslData kGlslData[] = {
|
||||||
|
{"acos", 1, GLSLstd450Acos, GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"acosh", 1, GLSLstd450Acosh, GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"asin", 1, GLSLstd450Asin, GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"asinh", 1, GLSLstd450Asinh, GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"atan", 1, GLSLstd450Atan, GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"atan2", 2, GLSLstd450Atan2, GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"atanh", 1, GLSLstd450Atanh, GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"ceil", 1, GLSLstd450Ceil, GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"cos", 1, GLSLstd450Cos, GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"cosh", 1, GLSLstd450Cosh, GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"cross", 2, GLSLstd450Cross, GlslDataType::kFloatVector, 3},
|
||||||
|
{"degrees", 1, GLSLstd450Degrees, GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"distance", 2, GLSLstd450Distance, GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"exp", 1, GLSLstd450Exp, GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"exp2", 1, GLSLstd450Exp2, GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"fabs", 1, GLSLstd450FAbs, GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"faceforward", 3, GLSLstd450FaceForward,
|
||||||
|
GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"fclamp", 3, GLSLstd450FClamp, GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"findilsb", 1, GLSLstd450FindILsb, GlslDataType::kIntScalarOrVector, 0},
|
||||||
|
{"findumsb", 1, GLSLstd450FindUMsb, GlslDataType::kIntScalarOrVector, 0},
|
||||||
|
{"findsmsb", 1, GLSLstd450FindSMsb, GlslDataType::kIntScalarOrVector, 0},
|
||||||
|
{"floor", 1, GLSLstd450Floor, GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"fma", 3, GLSLstd450Fma, GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"fmax", 2, GLSLstd450FMax, GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"fmin", 2, GLSLstd450FMin, GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"fmix", 3, GLSLstd450FMix, GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"fract", 1, GLSLstd450Fract, GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"fsign", 1, GLSLstd450FSign, GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"interpolateatcentroid", 1, GLSLstd450InterpolateAtCentroid,
|
||||||
|
GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"inversesqrt", 1, GLSLstd450InverseSqrt,
|
||||||
|
GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"length", 1, GLSLstd450Length, GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"log", 1, GLSLstd450Log, GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"log2", 1, GLSLstd450Log2, GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"nclamp", 3, GLSLstd450NClamp, GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"nmax", 2, GLSLstd450NMax, GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"nmin", 2, GLSLstd450NMin, GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"normalize", 1, GLSLstd450Normalize, GlslDataType::kFloatScalarOrVector,
|
||||||
|
0},
|
||||||
|
{"pow", 2, GLSLstd450Pow, GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"radians", 1, GLSLstd450Radians, GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"reflect", 2, GLSLstd450Reflect, GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"round", 1, GLSLstd450Round, GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"roundeven", 1, GLSLstd450RoundEven, GlslDataType::kFloatScalarOrVector,
|
||||||
|
0},
|
||||||
|
{"sabs", 1, GLSLstd450SAbs, GlslDataType::kIntScalarOrVector, 0},
|
||||||
|
{"sin", 1, GLSLstd450Sin, GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"sinh", 1, GLSLstd450Sinh, GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"smax", 2, GLSLstd450SMax, GlslDataType::kIntScalarOrVector, 0},
|
||||||
|
{"smin", 2, GLSLstd450SMin, GlslDataType::kIntScalarOrVector, 0},
|
||||||
|
{"smoothstep", 3, GLSLstd450SmoothStep, GlslDataType::kFloatScalarOrVector,
|
||||||
|
0},
|
||||||
|
{"sqrt", 1, GLSLstd450Sqrt, GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"ssign", 1, GLSLstd450SSign, GlslDataType::kIntScalarOrVector, 0},
|
||||||
|
{"step", 2, GLSLstd450Step, GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"tan", 1, GLSLstd450Tan, GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"tanh", 1, GLSLstd450Tanh, GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"trunc", 1, GLSLstd450Trunc, GlslDataType::kFloatScalarOrVector, 0},
|
||||||
|
{"umax", 2, GLSLstd450UMax, GlslDataType::kIntScalarOrVector, 0},
|
||||||
|
{"umin", 2, GLSLstd450UMin, GlslDataType::kIntScalarOrVector, 0},
|
||||||
|
};
|
||||||
|
constexpr const uint32_t kGlslDataCount = sizeof(kGlslData) / sizeof(GlslData);
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
TypeDeterminer::TypeDeterminer(Context* ctx, ast::Module* mod)
|
TypeDeterminer::TypeDeterminer(Context* ctx, ast::Module* mod)
|
||||||
: ctx_(*ctx), mod_(mod) {}
|
: ctx_(*ctx), mod_(mod) {}
|
||||||
|
@ -623,96 +717,6 @@ bool TypeDeterminer::DetermineUnaryOp(ast::UnaryOpExpression* expr) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Most of these are floating-point general except the below which are only
|
|
||||||
// FP16 and FP32. We only have FP32 at this point so the below works, if we
|
|
||||||
// get FP64 support or otherwise we'll need to differentiate.
|
|
||||||
// * radians
|
|
||||||
// * degrees
|
|
||||||
// * sin, cos, tan
|
|
||||||
// * asin, acos, atan
|
|
||||||
// * sinh, cosh, tanh
|
|
||||||
// * asinh, acosh, atanh
|
|
||||||
// * exp, exp2
|
|
||||||
// * log, log2
|
|
||||||
enum class GlslDataType {
|
|
||||||
kFloatScalarOrVector,
|
|
||||||
kIntScalarOrVector,
|
|
||||||
kFloatVector
|
|
||||||
};
|
|
||||||
struct GlslData {
|
|
||||||
const char* name;
|
|
||||||
uint8_t param_count;
|
|
||||||
uint32_t op_id;
|
|
||||||
GlslDataType type;
|
|
||||||
uint8_t vector_count;
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr const GlslData kGlslData[] = {
|
|
||||||
{"acos", 1, GLSLstd450Acos, GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"acosh", 1, GLSLstd450Acosh, GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"asin", 1, GLSLstd450Asin, GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"asinh", 1, GLSLstd450Asinh, GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"atan", 1, GLSLstd450Atan, GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"atan2", 2, GLSLstd450Atan2, GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"atanh", 1, GLSLstd450Atanh, GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"ceil", 1, GLSLstd450Ceil, GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"cos", 1, GLSLstd450Cos, GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"cosh", 1, GLSLstd450Cosh, GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"cross", 2, GLSLstd450Cross, GlslDataType::kFloatVector, 3},
|
|
||||||
{"degrees", 1, GLSLstd450Degrees, GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"distance", 2, GLSLstd450Distance, GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"exp", 1, GLSLstd450Exp, GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"exp2", 1, GLSLstd450Exp2, GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"fabs", 1, GLSLstd450FAbs, GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"faceforward", 3, GLSLstd450FaceForward,
|
|
||||||
GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"fclamp", 3, GLSLstd450FClamp, GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"findilsb", 1, GLSLstd450FindILsb, GlslDataType::kIntScalarOrVector, 0},
|
|
||||||
{"findumsb", 1, GLSLstd450FindUMsb, GlslDataType::kIntScalarOrVector, 0},
|
|
||||||
{"findsmsb", 1, GLSLstd450FindSMsb, GlslDataType::kIntScalarOrVector, 0},
|
|
||||||
{"floor", 1, GLSLstd450Floor, GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"fma", 3, GLSLstd450Fma, GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"fmax", 2, GLSLstd450FMax, GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"fmin", 2, GLSLstd450FMin, GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"fmix", 3, GLSLstd450FMix, GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"fract", 1, GLSLstd450Fract, GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"fsign", 1, GLSLstd450FSign, GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"interpolateatcentroid", 1, GLSLstd450InterpolateAtCentroid,
|
|
||||||
GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"inversesqrt", 1, GLSLstd450InverseSqrt,
|
|
||||||
GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"length", 1, GLSLstd450Length, GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"log", 1, GLSLstd450Log, GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"log2", 1, GLSLstd450Log2, GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"nclamp", 3, GLSLstd450NClamp, GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"nmax", 2, GLSLstd450NMax, GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"nmin", 2, GLSLstd450NMin, GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"normalize", 1, GLSLstd450Normalize, GlslDataType::kFloatScalarOrVector,
|
|
||||||
0},
|
|
||||||
{"pow", 2, GLSLstd450Pow, GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"radians", 1, GLSLstd450Radians, GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"reflect", 2, GLSLstd450Reflect, GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"round", 1, GLSLstd450Round, GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"roundeven", 1, GLSLstd450RoundEven, GlslDataType::kFloatScalarOrVector,
|
|
||||||
0},
|
|
||||||
{"sabs", 1, GLSLstd450SAbs, GlslDataType::kIntScalarOrVector, 0},
|
|
||||||
{"sin", 1, GLSLstd450Sin, GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"sinh", 1, GLSLstd450Sinh, GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"smax", 2, GLSLstd450SMax, GlslDataType::kIntScalarOrVector, 0},
|
|
||||||
{"smin", 2, GLSLstd450SMin, GlslDataType::kIntScalarOrVector, 0},
|
|
||||||
{"smoothstep", 3, GLSLstd450SmoothStep, GlslDataType::kFloatScalarOrVector,
|
|
||||||
0},
|
|
||||||
{"sqrt", 1, GLSLstd450Sqrt, GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"ssign", 1, GLSLstd450SSign, GlslDataType::kIntScalarOrVector, 0},
|
|
||||||
{"step", 2, GLSLstd450Step, GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"tan", 1, GLSLstd450Tan, GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"tanh", 1, GLSLstd450Tanh, GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"trunc", 1, GLSLstd450Trunc, GlslDataType::kFloatScalarOrVector, 0},
|
|
||||||
{"umax", 2, GLSLstd450UMax, GlslDataType::kIntScalarOrVector, 0},
|
|
||||||
{"umin", 2, GLSLstd450UMin, GlslDataType::kIntScalarOrVector, 0},
|
|
||||||
};
|
|
||||||
constexpr const uint32_t kGlslDataCount = sizeof(kGlslData) / sizeof(GlslData);
|
|
||||||
|
|
||||||
ast::type::Type* TypeDeterminer::GetImportData(
|
ast::type::Type* TypeDeterminer::GetImportData(
|
||||||
const Source& source,
|
const Source& source,
|
||||||
const std::string& path,
|
const std::string& path,
|
||||||
|
|
|
@ -40,4 +40,4 @@ TEST_F(BuilderTest, Kill) {
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace spirv
|
} // namespace spirv
|
||||||
} // namespace writer
|
} // namespace writer
|
||||||
} // namespace tint
|
} // namespace tint
|
||||||
|
|
Loading…
Reference in New Issue