Home | History | Annotate | Download | only in interpreter
      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_BYTECODE_UTILS_H_
      6 #define V8_UNITTESTS_INTERPRETER_BYTECODE_UTILS_H_
      7 
      8 #include "src/frames.h"
      9 
     10 #if V8_TARGET_LITTLE_ENDIAN
     11 
     12 #define EXTRACT(x, n) static_cast<uint8_t>((x) >> (8 * n))
     13 #define U16(i) EXTRACT(i, 0), EXTRACT(i, 1)
     14 #define U32(i) EXTRACT(i, 0), EXTRACT(i, 1), EXTRACT(i, 2), EXTRACT(i, 3)
     15 
     16 #elif V8_TARGET_BIG_ENDIAN
     17 
     18 #define EXTRACT(x, n) static_cast<uint8_t>((x) >> (8 * n))
     19 
     20 #define U16(i) EXTRACT(i, 1), EXTRACT(i, 0)
     21 #define U32(i) EXTRACT(i, 3), EXTRACT(i, 2), EXTRACT(i, 1), EXTRACT(i, 0)
     22 
     23 #else
     24 
     25 #error "Unknown Architecture"
     26 
     27 #endif
     28 
     29 #define U8(i) static_cast<uint8_t>(i)
     30 #define B(Name) static_cast<uint8_t>(Bytecode::k##Name)
     31 #define REG_OPERAND(i) \
     32   (InterpreterFrameConstants::kRegisterFileFromFp / kPointerSize - (i))
     33 #define R8(i) static_cast<uint8_t>(REG_OPERAND(i))
     34 #define R16(i) U16(REG_OPERAND(i))
     35 #define R32(i) U32(REG_OPERAND(i))
     36 
     37 #endif  // V8_UNITTESTS_INTERPRETER_BYTECODE_UTILS_H_
     38