Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: src/trusted/validator_ragel/decoder_internal.h

Issue 11000033: Move validator_x86_XX.rl out of unreviewed. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2012 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 * This file contains common parts of x86-32 and x86-64 internals (inline
9 * functions and defines).
10 */
11
12 #ifndef NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_RAGEL_DECODER_INTERNAL_H_
13 #define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_RAGEL_DECODER_INTERNAL_H_
14
15 #include "native_client/src/trusted/validator_ragel/decoding.h"
16 #include "native_client/src/trusted/validator_ragel/decoder.h"
17
18 #define GET_VEX_PREFIX3() vex_prefix3
Brad Chen 2012/10/04 17:26:04 Please add a comment above this set of defines tha
khim 2012/10/05 08:22:53 Done.
19 #define SET_VEX_PREFIX3(P) vex_prefix3 = (P)
20 #define SET_DATA16_PREFIX(S) instruction.prefix.data16 = (S)
21 #define SET_LOCK_PREFIX(S) instruction.prefix.lock = (S)
22 #define SET_REPZ_PREFIX(S) instruction.prefix.repz = (S)
23 #define SET_REPNZ_PREFIX(S) instruction.prefix.repnz = (S)
24 #define SET_BRANCH_TAKEN(S) instruction.prefix.branch_taken = (S)
25 #define SET_BRANCH_NOT_TAKEN(S) instruction.prefix.branch_not_taken = (S)
26 #define SET_INSTRUCTION_NAME(N) instruction.name = (N)
27 #define GET_OPERAND_NAME(N) instruction.operands[(N)].name
28 #define SET_OPERAND_NAME(N, S) instruction.operands[(N)].name = (S)
29 #define SET_OPERAND_TYPE(N, S) instruction.operands[(N)].type = (S)
30 #define SET_OPERANDS_COUNT(N) instruction.operands_count = (N)
31 #define SET_MODRM_BASE(N) instruction.rm.base = (N)
32 #define SET_MODRM_INDEX(N) instruction.rm.index = (N)
33 #define SET_MODRM_SCALE(S) instruction.rm.scale = (S)
34 #define SET_DISP_TYPE(T) instruction.rm.disp_type = (T)
35 #define SET_DISP_PTR(P) \
36 instruction.rm.offset = DecodeDisplacementValue(instruction.rm.disp_type, (P))
37 #define SET_IMM_TYPE(T) imm_operand = (T)
38 #define SET_IMM_PTR(P) \
39 instruction.imm[0] = DecodeImmediateValue(imm_operand, (P))
40 #define SET_IMM2_TYPE(T) imm2_operand = (T)
41 #define SET_IMM2_PTR(P) \
42 instruction.imm[1] = DecodeImmediateValue(imm2_operand, (P))
43 #define SET_CPU_FEATURE(F)
44
45 enum {
Brad Chen 2012/10/04 17:26:04 Please add a comment above this enum defn explaini
khim 2012/10/05 08:22:53 Actually this one is not used at all: it was used
46 REX_B = 1,
47 REX_X = 2,
48 REX_R = 4,
49 REX_W = 8
50 };
51
52 static FORCEINLINE uint64_t DecodeDisplacementValue(
53 enum DisplacementMode disp_mode, const uint8_t *disp_ptr) {
54 switch(disp_mode) {
55 case DISPNONE: return 0;
56 case DISP8: return SignExtend8Bit(AnyFieldValue8bit(disp_ptr));
57 case DISP16: return SignExtend16Bit(AnyFieldValue16bit(disp_ptr));
58 case DISP32: return SignExtend32Bit(AnyFieldValue32bit(disp_ptr));
59 case DISP64: return AnyFieldValue64bit(disp_ptr);
60 }
61 assert(FALSE);
62 return 0;
63 }
64
65 enum ImmediateMode {
Brad Chen 2012/10/04 17:26:04 Please group enums together and then static functi
khim 2012/10/05 08:22:53 Done.
66 IMMNONE,
67 IMM2,
68 IMM8,
69 IMM16,
70 IMM32,
71 IMM64
72 };
73
74 static FORCEINLINE uint64_t DecodeImmediateValue(enum ImmediateMode imm_mode,
75 const uint8_t *imm_ptr) {
76 switch(imm_mode) {
77 case IMMNONE: return 0;
78 case IMM2: return imm_ptr[0] & 0x03;
79 case IMM8: return AnyFieldValue8bit(imm_ptr);
80 case IMM16: return AnyFieldValue16bit(imm_ptr);
81 case IMM32: return AnyFieldValue32bit(imm_ptr);
82 case IMM64: return AnyFieldValue64bit(imm_ptr);
83 }
84 assert(FALSE);
85 return 0;
86 }
87
88 #endif /* NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_RAGEL_DECODER_INTERNAL_H_ */
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698