1 : /*
2 : * Copyright (c) 2011 The Native Client Authors. All rights reserved.
3 : * Use of this source code is governed by a BSD-style license that can be
4 : * found in the LICENSE file.
5 : */
6 :
7 : /*
8 : * ncopcode_desc_inl.c - Holds inline routines for commonly used (simple)
9 : * functions in ncopcode_desc.h. Used to speed up code. Inlined routines
10 : * correspond to the following functions in ncopcode_desc.h, but with
11 : * an 'Inline' suffix:
12 : *
13 : * NaClGetInstNumberOperands
14 : * NaClGetInstOperand
15 : */
16 : #ifndef NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_DECODER_NCOPCODE_DESC_INL_H_
17 : #define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_DECODER_NCOPCODE_DESC_INL_H_
18 :
19 : #include <assert.h>
20 : #include "native_client/src/trusted/validator/x86/decoder/ncopcode_desc.h"
21 : #include "native_client/src/trusted/validator/x86/decoder/nc_decode_tables.h"
22 :
23 : /* Returns the number of logical operands an instruction has. That is,
24 : * returns field num_operands unless the first operand is
25 : * a special encoding that extends the opcode.
26 : */
27 1 : static uint8_t NaClGetInstNumberOperandsInline(const NaClInst* inst) {
28 1 : return inst->num_operands;
29 1 : }
30 :
31 : /* Returns the indexed logical operand for the instruction. That is,
32 : * returns the index-th operand unless the first operand is
33 : * a special encoding that extends the opcode. In the latter
34 : * case, the (index+1)-th operand is returned.
35 : */
36 : static const INLINE NaClOp* NaClGetInstOperandInline(
37 : const NaClDecodeTables* tables,
38 3 : const NaClInst* inst, uint8_t index) {
39 3 : assert(index < inst->num_operands);
40 3 : return &tables->operands_table[inst->operands_offset + index];
41 3 : }
42 :
43 : #endif /* NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_DECODER_NCOPCODE_DESC_INL_H_ */
|