1 /*BEGIN_LEGAL
2 
3 Copyright (c) 2018 Intel Corporation
4 
5   Licensed under the Apache License, Version 2.0 (the "License");
6   you may not use this file except in compliance with the License.
7   You may obtain a copy of the License at
8 
9       http://www.apache.org/licenses/LICENSE-2.0
10 
11   Unless required by applicable law or agreed to in writing, software
12   distributed under the License is distributed on an "AS IS" BASIS,
13   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   See the License for the specific language governing permissions and
15   limitations under the License.
16 
17 END_LEGAL */
18 /// @file xed-encode-isa-functions.c
19 ///
20 
21 ////////////////////////////////////////////////////////////////////////////
22 // This file contains the public interface to the encoder.
23 ////////////////////////////////////////////////////////////////////////////
24 #include "xed-encode.h"
25 #include "xed-encode-private.h"
26 #include "xed-encode-isa-functions.h"
27 #include "xed-tables-extern.h"
28 #include "xed-operand-accessors.h"
29 
30 
31 
32 // FIXME: I could generate these 3 functions:
33 
34 static xed_bool_t
xed_encode_nonterminal_INSTRUCTIONS(xed_encoder_request_t * r)35 xed_encode_nonterminal_INSTRUCTIONS(xed_encoder_request_t* r)
36 {
37     xed_iclass_enum_t iclass;
38 
39     // bind function sets the encoding iform index
40     xed_encode_function_pointer_t bind_func;
41 
42     iclass = xed_encoder_request_get_iclass(r);
43     bind_func = xed_encoder_get_group_encoding_function(iclass);
44     if (bind_func)    {
45         xed_bool_t okay = (*bind_func)(r);
46         return okay;
47     }
48     return 0;
49 }
50 
51 // These are called during the encoding sequence to look up the right
52 // encoder functions specific to an iclass.
53 
54 xed_bool_t
xed_encode_nonterminal_INSTRUCTIONS_BIND(xed_encoder_request_t * xes)55 xed_encode_nonterminal_INSTRUCTIONS_BIND(xed_encoder_request_t* xes)
56 {
57     return xed_encode_nonterminal_INSTRUCTIONS(xes);
58 }
59 xed_bool_t
xed_encode_nonterminal_INSTRUCTIONS_EMIT(xed_encoder_request_t * xes)60 xed_encode_nonterminal_INSTRUCTIONS_EMIT(xed_encoder_request_t* xes)
61 {
62     xed_ptrn_func_ptr_t emit_ptrn_function;
63 
64     emit_ptrn_function = xed_encoder_get_emit_ptrn(xes);
65     (*emit_ptrn_function)(xes);
66     return 1;
67     //FIXME: use this in the future
68     //return xed3_operand_get_error(xes);
69 }
70 
71 
72