1 // Copyright 2015 the V8 project authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef V8_UNITTESTS_INTERPRETER_INTERPRETER_ASSEMBLER_UNITTEST_H_ 6 #define V8_UNITTESTS_INTERPRETER_INTERPRETER_ASSEMBLER_UNITTEST_H_ 7 8 #include "src/compiler/machine-operator.h" 9 #include "src/interpreter/interpreter-assembler.h" 10 #include "test/unittests/test-utils.h" 11 #include "testing/gmock-support.h" 12 13 namespace v8 { 14 namespace internal { 15 namespace interpreter { 16 17 using ::testing::Matcher; 18 19 class InterpreterAssemblerTest : public TestWithIsolateAndZone { 20 public: InterpreterAssemblerTest()21 InterpreterAssemblerTest() {} ~InterpreterAssemblerTest()22 ~InterpreterAssemblerTest() override {} 23 24 class InterpreterAssemblerForTest final : public InterpreterAssembler { 25 public: 26 InterpreterAssemblerForTest( 27 InterpreterAssemblerTest* test, Bytecode bytecode, 28 OperandScale operand_scale = OperandScale::kSingle) 29 : InterpreterAssembler(test->isolate(), test->zone(), bytecode, 30 operand_scale) {} 31 ~InterpreterAssemblerForTest() override; 32 33 Matcher<compiler::Node*> IsLoad( 34 const Matcher<compiler::LoadRepresentation>& rep_matcher, 35 const Matcher<compiler::Node*>& base_matcher, 36 const Matcher<compiler::Node*>& index_matcher); 37 Matcher<compiler::Node*> IsStore( 38 const Matcher<compiler::StoreRepresentation>& rep_matcher, 39 const Matcher<compiler::Node*>& base_matcher, 40 const Matcher<compiler::Node*>& index_matcher, 41 const Matcher<compiler::Node*>& value_matcher); 42 43 Matcher<compiler::Node*> IsUnsignedByteOperand(int offset); 44 Matcher<compiler::Node*> IsSignedByteOperand(int offset); 45 Matcher<compiler::Node*> IsUnsignedShortOperand(int offset); 46 Matcher<compiler::Node*> IsSignedShortOperand(int offset); 47 Matcher<compiler::Node*> IsUnsignedQuadOperand(int offset); 48 Matcher<compiler::Node*> IsSignedQuadOperand(int offset); 49 50 Matcher<compiler::Node*> IsSignedOperand(int offset, 51 OperandSize operand_size); 52 Matcher<compiler::Node*> IsUnsignedOperand(int offset, 53 OperandSize operand_size); 54 55 using InterpreterAssembler::graph; 56 57 private: 58 DISALLOW_COPY_AND_ASSIGN(InterpreterAssemblerForTest); 59 }; 60 }; 61 62 } // namespace interpreter 63 } // namespace internal 64 } // namespace v8 65 66 #endif // V8_UNITTESTS_INTERPRETER_INTERPRETER_ASSEMBLER_UNITTEST_H_ 67