interpreter-assembler-unittest.h 2.62 KB
Newer Older
1 2 3 4 5 6 7
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_UNITTESTS_INTERPRETER_INTERPRETER_ASSEMBLER_UNITTEST_H_
#define V8_UNITTESTS_INTERPRETER_INTERPRETER_ASSEMBLER_UNITTEST_H_

8
#include "src/compiler/code-assembler.h"
9 10 11 12 13 14 15 16 17 18 19
#include "src/compiler/machine-operator.h"
#include "src/interpreter/interpreter-assembler.h"
#include "test/unittests/test-utils.h"
#include "testing/gmock-support.h"

namespace v8 {
namespace internal {
namespace interpreter {

using ::testing::Matcher;

20 21 22 23 24 25 26 27
class InterpreterAssemblerTest;

class InterpreterAssemblerTestState : public compiler::CodeAssemblerState {
 public:
  InterpreterAssemblerTestState(InterpreterAssemblerTest* test,
                                Bytecode bytecode);
};

28 29 30 31 32 33 34
class InterpreterAssemblerTest : public TestWithIsolateAndZone {
 public:
  InterpreterAssemblerTest() {}
  ~InterpreterAssemblerTest() override {}

  class InterpreterAssemblerForTest final : public InterpreterAssembler {
   public:
35
    InterpreterAssemblerForTest(
36
        InterpreterAssemblerTestState* state, Bytecode bytecode,
37
        OperandScale operand_scale = OperandScale::kSingle)
38
        : InterpreterAssembler(state, bytecode, operand_scale) {}
39
    ~InterpreterAssemblerForTest();
40 41 42 43 44 45 46 47 48 49 50

    Matcher<compiler::Node*> IsLoad(
        const Matcher<compiler::LoadRepresentation>& rep_matcher,
        const Matcher<compiler::Node*>& base_matcher,
        const Matcher<compiler::Node*>& index_matcher);
    Matcher<compiler::Node*> IsStore(
        const Matcher<compiler::StoreRepresentation>& rep_matcher,
        const Matcher<compiler::Node*>& base_matcher,
        const Matcher<compiler::Node*>& index_matcher,
        const Matcher<compiler::Node*>& value_matcher);

51 52 53 54 55 56 57 58 59 60 61
    Matcher<compiler::Node*> IsUnsignedByteOperand(int offset);
    Matcher<compiler::Node*> IsSignedByteOperand(int offset);
    Matcher<compiler::Node*> IsUnsignedShortOperand(int offset);
    Matcher<compiler::Node*> IsSignedShortOperand(int offset);
    Matcher<compiler::Node*> IsUnsignedQuadOperand(int offset);
    Matcher<compiler::Node*> IsSignedQuadOperand(int offset);

    Matcher<compiler::Node*> IsSignedOperand(int offset,
                                             OperandSize operand_size);
    Matcher<compiler::Node*> IsUnsignedOperand(int offset,
                                               OperandSize operand_size);
62 63 64 65 66 67 68 69 70 71 72

   private:
    DISALLOW_COPY_AND_ASSIGN(InterpreterAssemblerForTest);
  };
};

}  // namespace interpreter
}  // namespace internal
}  // namespace v8

#endif  // V8_UNITTESTS_INTERPRETER_INTERPRETER_ASSEMBLER_UNITTEST_H_