Implement bitwise complement operator

This translates to/from OpNot for SPIR-V, and ~ for all three textual
language backends.

Fixed: tint:866
Change-Id: Id934fb309221e3fca0e7efa33edaaae137fd8085
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/54980
Auto-Submit: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
James Price
2021-06-17 08:35:54 +00:00
committed by Tint LUCI CQ
parent 52b6a004b8
commit c932b5535f
25 changed files with 243 additions and 10 deletions

View File

@@ -2500,6 +2500,7 @@ bool Resolver::UnaryOp(ast::UnaryOpExpression* unary) {
const sem::Type* type = nullptr;
switch (unary->op()) {
case ast::UnaryOp::kComplement:
case ast::UnaryOp::kNegation:
case ast::UnaryOp::kNot:
// Result type matches the deref'd inner type.

View File

@@ -1946,7 +1946,8 @@ TEST_P(UnaryOpExpressionTest, Expr_UnaryOp) {
}
INSTANTIATE_TEST_SUITE_P(ResolverTest,
UnaryOpExpressionTest,
testing::Values(ast::UnaryOp::kNegation,
testing::Values(ast::UnaryOp::kComplement,
ast::UnaryOp::kNegation,
ast::UnaryOp::kNot));
TEST_F(ResolverTest, StorageClass_SetsIfMissing) {