[PATCH 22/57][Arm][GAS] Add support for MVE instructions: vmlaldav, vmlalv, vmlsldav...
[binutils-gdb.git] / gdb / compile / compile-internal.h
blob406a369d683d5333b05ab147d5320e42a5a87385
1 /* Header file for GDB compile command and supporting functions.
2 Copyright (C) 2014-2019 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17 #ifndef COMPILE_COMPILE_INTERNAL_H
18 #define COMPILE_COMPILE_INTERNAL_H
20 #include "gcc-c-interface.h"
22 /* Debugging flag for the "compile" family of commands. */
24 extern int compile_debug;
26 struct block;
28 /* An object that maps a gdb type to a gcc type. */
30 struct type_map_instance
32 /* The gdb type. */
34 struct type *type;
36 /* The corresponding gcc type handle. */
38 gcc_type gcc_type_handle;
41 /* An object of this type holds state associated with a given
42 compilation job. */
44 class compile_instance
46 public:
47 compile_instance (struct gcc_base_context *gcc_fe, const char *options);
49 virtual ~compile_instance ()
51 m_gcc_fe->ops->destroy (m_gcc_fe);
54 /* Returns the GCC options to be passed during compilation. */
55 const std::string &gcc_target_options () const
57 return m_gcc_target_options;
60 /* Query the type cache for TYPE, returning the compiler's
61 type for it in RET. */
62 bool get_cached_type (struct type *type, gcc_type *ret) const;
64 /* Insert GCC_TYPE into the type cache for TYPE.
66 It is ok for a given type to be inserted more than once, provided that
67 the exact same association is made each time. */
68 void insert_type (struct type *type, gcc_type gcc_type);
70 /* Associate SYMBOL with some error text. */
71 void insert_symbol_error (const struct symbol *sym, const char *text);
73 /* Emit the error message corresponding to SYM, if one exists, and
74 arrange for it not to be emitted again. */
75 void error_symbol_once (const struct symbol *sym);
77 /* These currently just forward to the underlying ops
78 vtable. */
80 /* Set the plug-in print callback. */
81 void set_print_callback (void (*print_function) (void *, const char *),
82 void *datum);
84 /* Return the plug-in's front-end version. */
85 unsigned int version () const;
87 /* Set the plug-in's verbosity level. Nop for GCC_FE_VERSION_0. */
88 void set_verbose (int level);
90 /* Set the plug-in driver program. Nop for GCC_FE_VERSION_0. */
91 void set_driver_filename (const char *filename);
93 /* Set the regular expression used to match the configury triplet
94 prefix to the compiler. Nop for GCC_FE_VERSION_0. */
95 void set_triplet_regexp (const char *regexp);
97 /* Set compilation arguments. REGEXP is only used for protocol
98 version GCC_FE_VERSION_0. */
99 char *set_arguments (int argc, char **argv, const char *regexp = NULL);
101 /* Set the filename of the program to compile. Nop for GCC_FE_VERSION_0. */
102 void set_source_file (const char *filename);
104 /* Compile the previously specified source file to FILENAME.
105 VERBOSE_LEVEL is only used for protocol version GCC_FE_VERSION_0. */
106 bool compile (const char *filename, int verbose_level = -1);
108 /* Set the scope type for this compile. */
109 void set_scope (enum compile_i_scope_types scope)
111 m_scope = scope;
114 /* Return the scope type. */
115 enum compile_i_scope_types scope () const
117 return m_scope;
120 /* Set the block to be used for symbol searches. */
121 void set_block (const struct block *block)
123 m_block = block;
126 /* Return the search block. */
127 const struct block *block () const
129 return m_block;
132 protected:
134 /* The GCC front end. */
135 struct gcc_base_context *m_gcc_fe;
137 /* The "scope" of this compilation. */
138 enum compile_i_scope_types m_scope;
140 /* The block in which an expression is being parsed. */
141 const struct block *m_block;
143 /* Specify "-std=gnu11", "-std=gnu++11" or similar. These options are put
144 after CU's DW_AT_producer compilation options to override them. */
145 std::string m_gcc_target_options;
147 /* Map from gdb types to gcc types. */
148 htab_up m_type_map;
150 /* Map from gdb symbols to gcc error messages to emit. */
151 htab_up m_symbol_err_map;
154 /* Define header and footers for different scopes. */
156 /* A simple scope just declares a function named "_gdb_expr", takes no
157 arguments and returns no value. */
159 #define COMPILE_I_SIMPLE_REGISTER_STRUCT_TAG "__gdb_regs"
160 #define COMPILE_I_SIMPLE_REGISTER_ARG_NAME "__regs"
161 #define COMPILE_I_SIMPLE_REGISTER_DUMMY "_dummy"
162 #define COMPILE_I_PRINT_OUT_ARG_TYPE "void *"
163 #define COMPILE_I_PRINT_OUT_ARG "__gdb_out_param"
164 #define COMPILE_I_EXPR_VAL "__gdb_expr_val"
165 #define COMPILE_I_EXPR_PTR_TYPE "__gdb_expr_ptr_type"
167 /* A "type" to indicate a NULL type. */
169 const gcc_type GCC_TYPE_NONE = (gcc_type) -1;
171 /* Call gdbarch_register_name (GDBARCH, REGNUM) and convert its result
172 to a form suitable for the compiler source. The register names
173 should not clash with inferior defined macros. */
175 extern std::string compile_register_name_mangled (struct gdbarch *gdbarch,
176 int regnum);
178 /* Convert compiler source register name to register number of
179 GDBARCH. Returned value is always >= 0, function throws an error
180 for non-matching REG_NAME. */
182 extern int compile_register_name_demangle (struct gdbarch *gdbarch,
183 const char *reg_name);
185 /* Type used to hold and pass around the source and object file names
186 to use for compilation. */
187 class compile_file_names
189 public:
190 compile_file_names (std::string source_file, std::string object_file)
191 : m_source_file (source_file), m_object_file (object_file)
194 /* Provide read-only views only. Return 'const char *' instead of
195 std::string to avoid having to use c_str() everywhere in client
196 code. */
198 const char *source_file () const
199 { return m_source_file.c_str (); }
201 const char *object_file () const
202 { return m_object_file.c_str (); }
204 private:
205 /* Storage for the file names. */
206 std::string m_source_file;
207 std::string m_object_file;
210 #endif /* COMPILE_COMPILE_INTERNAL_H */