111
|
1 /* A C++ API for libgccjit, purely as inline wrapper functions.
|
145
|
2 Copyright (C) 2014-2020 Free Software Foundation, Inc.
|
111
|
3
|
|
4 This file is part of GCC.
|
|
5
|
|
6 GCC is free software; you can redistribute it and/or modify it
|
|
7 under the terms of the GNU General Public License as published by
|
|
8 the Free Software Foundation; either version 3, or (at your option)
|
|
9 any later version.
|
|
10
|
|
11 GCC is distributed in the hope that it will be useful, but
|
|
12 WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
14 General Public License for more details.
|
|
15
|
|
16 You should have received a copy of the GNU General Public License
|
|
17 along with GCC; see the file COPYING3. If not see
|
|
18 <http://www.gnu.org/licenses/>. */
|
|
19
|
|
20 #ifndef LIBGCCJIT_PLUS_PLUS_H
|
|
21 #define LIBGCCJIT_PLUS_PLUS_H
|
|
22
|
|
23 #include "libgccjit.h"
|
|
24
|
|
25 #include <limits>
|
|
26 #include <ostream>
|
|
27 #include <vector>
|
|
28
|
|
29 /****************************************************************************
|
|
30 C++ API
|
|
31 ****************************************************************************/
|
|
32
|
|
33 namespace gccjit
|
|
34 {
|
|
35 /* Indentation indicates inheritance. */
|
|
36 class context;
|
|
37 class error;
|
|
38 class object;
|
|
39 class location;
|
|
40 class field;
|
|
41 class type;
|
|
42 class struct_;
|
|
43 class function;
|
|
44 class block;
|
|
45 class rvalue;
|
|
46 class lvalue;
|
|
47 class param;
|
|
48 class case_;
|
|
49 class timer;
|
|
50 class auto_time;
|
|
51
|
|
52 /* Errors within the API become C++ exceptions of this class. */
|
|
53 class error
|
|
54 {
|
|
55 };
|
|
56
|
|
57 class object
|
|
58 {
|
|
59 public:
|
|
60 context get_context () const;
|
|
61
|
|
62 std::string get_debug_string () const;
|
|
63
|
|
64 protected:
|
|
65 object ();
|
|
66 object (gcc_jit_object *obj);
|
|
67
|
|
68 gcc_jit_object *get_inner_object () const;
|
|
69
|
|
70 private:
|
|
71 gcc_jit_object *m_inner_obj;
|
|
72 };
|
|
73
|
|
74 inline std::ostream& operator << (std::ostream& stream, const object &obj);
|
|
75
|
|
76 /* Some client code will want to supply source code locations, others
|
|
77 won't. To avoid doubling the number of entrypoints, everything
|
|
78 accepting a location also has a default argument. To do this, the
|
|
79 other classes need to see that "location" has a default constructor,
|
|
80 hence we need to declare it first. */
|
|
81 class location : public object
|
|
82 {
|
|
83 public:
|
|
84 location ();
|
|
85 location (gcc_jit_location *loc);
|
|
86
|
|
87 gcc_jit_location *get_inner_location () const;
|
|
88 };
|
|
89
|
|
90 class context
|
|
91 {
|
|
92 public:
|
|
93 static context acquire ();
|
|
94 context ();
|
|
95 context (gcc_jit_context *ctxt);
|
|
96
|
|
97 gccjit::context new_child_context ();
|
|
98
|
|
99 gcc_jit_context *get_inner_context () { return m_inner_ctxt; }
|
|
100
|
|
101 void release ();
|
|
102
|
|
103 gcc_jit_result *compile ();
|
|
104
|
|
105 void compile_to_file (enum gcc_jit_output_kind output_kind,
|
|
106 const char *output_path);
|
|
107
|
|
108 void dump_to_file (const std::string &path,
|
|
109 bool update_locations);
|
|
110
|
|
111 void set_logfile (FILE *logfile,
|
|
112 int flags,
|
|
113 int verbosity);
|
|
114
|
|
115 void dump_reproducer_to_file (const char *path);
|
|
116
|
|
117 void set_str_option (enum gcc_jit_str_option opt,
|
|
118 const char *value);
|
|
119
|
|
120 void set_int_option (enum gcc_jit_int_option opt,
|
|
121 int value);
|
|
122
|
|
123 void set_bool_option (enum gcc_jit_bool_option opt,
|
|
124 int value);
|
|
125
|
|
126 void set_bool_allow_unreachable_blocks (int bool_value);
|
|
127 void set_bool_use_external_driver (int bool_value);
|
|
128
|
|
129 void add_command_line_option (const char *optname);
|
145
|
130 void add_driver_option (const char *optname);
|
111
|
131
|
|
132 void set_timer (gccjit::timer t);
|
|
133 gccjit::timer get_timer () const;
|
|
134
|
|
135 location
|
|
136 new_location (const std::string &filename,
|
|
137 int line,
|
|
138 int column);
|
|
139
|
|
140 type get_type (enum gcc_jit_types kind);
|
|
141 type get_int_type (size_t num_bytes, int is_signed);
|
|
142
|
|
143 /* A way to map a specific int type, using the compiler to
|
|
144 get the details automatically e.g.:
|
|
145 gccjit::type type = get_int_type <my_int_type_t> (); */
|
|
146 template <typename T>
|
|
147 type get_int_type ();
|
|
148
|
|
149 type new_array_type (type element_type, int num_elements,
|
|
150 location loc = location ());
|
|
151
|
|
152 field new_field (type type_, const std::string &name,
|
|
153 location loc = location ());
|
|
154
|
145
|
155 field new_bitfield (type type_, int width, const std::string &name,
|
|
156 location loc = location ());
|
|
157
|
111
|
158 struct_ new_struct_type (const std::string &name,
|
|
159 std::vector<field> &fields,
|
|
160 location loc = location ());
|
|
161
|
|
162 struct_ new_opaque_struct_type (const std::string &name,
|
|
163 location loc = location ());
|
|
164
|
|
165 param new_param (type type_,
|
|
166 const std::string &name,
|
|
167 location loc = location ());
|
|
168
|
|
169 function new_function (enum gcc_jit_function_kind kind,
|
|
170 type return_type,
|
|
171 const std::string &name,
|
|
172 std::vector<param> ¶ms,
|
|
173 int is_variadic,
|
|
174 location loc = location ());
|
|
175
|
|
176 function get_builtin_function (const std::string &name);
|
|
177
|
|
178 lvalue new_global (enum gcc_jit_global_kind kind,
|
|
179 type type_,
|
|
180 const std::string &name,
|
|
181 location loc = location ());
|
|
182
|
|
183 rvalue new_rvalue (type numeric_type,
|
|
184 int value) const;
|
|
185 rvalue new_rvalue (type numeric_type,
|
|
186 long value) const;
|
|
187 rvalue zero (type numeric_type) const;
|
|
188 rvalue one (type numeric_type) const;
|
|
189 rvalue new_rvalue (type numeric_type,
|
|
190 double value) const;
|
|
191 rvalue new_rvalue (type pointer_type,
|
|
192 void *value) const;
|
|
193 rvalue new_rvalue (const std::string &value) const;
|
|
194 rvalue new_rvalue (type vector_type,
|
|
195 std::vector<rvalue> elements) const;
|
|
196
|
|
197 /* Generic unary operations... */
|
|
198 rvalue new_unary_op (enum gcc_jit_unary_op op,
|
|
199 type result_type,
|
|
200 rvalue a,
|
|
201 location loc = location ());
|
|
202
|
|
203 /* ...and shorter ways to spell the various specific kinds of
|
|
204 unary op. */
|
|
205 rvalue new_minus (type result_type,
|
|
206 rvalue a,
|
|
207 location loc = location ());
|
|
208 rvalue new_bitwise_negate (type result_type,
|
|
209 rvalue a,
|
|
210 location loc = location ());
|
|
211 rvalue new_logical_negate (type result_type,
|
|
212 rvalue a,
|
|
213 location loc = location ());
|
|
214
|
|
215 /* Generic binary operations... */
|
|
216 rvalue new_binary_op (enum gcc_jit_binary_op op,
|
|
217 type result_type,
|
|
218 rvalue a, rvalue b,
|
|
219 location loc = location ());
|
|
220
|
|
221 /* ...and shorter ways to spell the various specific kinds of
|
|
222 binary op. */
|
|
223 rvalue new_plus (type result_type,
|
|
224 rvalue a, rvalue b,
|
|
225 location loc = location ());
|
|
226 rvalue new_minus (type result_type,
|
|
227 rvalue a, rvalue b,
|
|
228 location loc = location ());
|
|
229 rvalue new_mult (type result_type,
|
|
230 rvalue a, rvalue b,
|
|
231 location loc = location ());
|
|
232 rvalue new_divide (type result_type,
|
|
233 rvalue a, rvalue b,
|
|
234 location loc = location ());
|
|
235 rvalue new_modulo (type result_type,
|
|
236 rvalue a, rvalue b,
|
|
237 location loc = location ());
|
|
238 rvalue new_bitwise_and (type result_type,
|
|
239 rvalue a, rvalue b,
|
|
240 location loc = location ());
|
|
241 rvalue new_bitwise_xor (type result_type,
|
|
242 rvalue a, rvalue b,
|
|
243 location loc = location ());
|
|
244 rvalue new_bitwise_or (type result_type,
|
|
245 rvalue a, rvalue b,
|
|
246 location loc = location ());
|
|
247 rvalue new_logical_and (type result_type,
|
|
248 rvalue a, rvalue b,
|
|
249 location loc = location ());
|
|
250 rvalue new_logical_or (type result_type,
|
|
251 rvalue a, rvalue b,
|
|
252 location loc = location ());
|
|
253
|
|
254 /* Generic comparisons... */
|
|
255 rvalue new_comparison (enum gcc_jit_comparison op,
|
|
256 rvalue a, rvalue b,
|
|
257 location loc = location ());
|
|
258 /* ...and shorter ways to spell the various specific kinds of
|
|
259 comparison. */
|
|
260 rvalue new_eq (rvalue a, rvalue b,
|
|
261 location loc = location ());
|
|
262 rvalue new_ne (rvalue a, rvalue b,
|
|
263 location loc = location ());
|
|
264 rvalue new_lt (rvalue a, rvalue b,
|
|
265 location loc = location ());
|
|
266 rvalue new_le (rvalue a, rvalue b,
|
|
267 location loc = location ());
|
|
268 rvalue new_gt (rvalue a, rvalue b,
|
|
269 location loc = location ());
|
|
270 rvalue new_ge (rvalue a, rvalue b,
|
|
271 location loc = location ());
|
|
272
|
|
273 /* The most general way of creating a function call. */
|
|
274 rvalue new_call (function func,
|
|
275 std::vector<rvalue> &args,
|
|
276 location loc = location ());
|
|
277
|
|
278 /* In addition, we provide a series of overloaded "new_call" methods
|
|
279 for specific numbers of args (from 0 - 6), to avoid the need for
|
|
280 client code to manually build a vector. */
|
|
281 rvalue new_call (function func,
|
|
282 location loc = location ());
|
|
283 rvalue new_call (function func,
|
|
284 rvalue arg0,
|
|
285 location loc = location ());
|
|
286 rvalue new_call (function func,
|
|
287 rvalue arg0, rvalue arg1,
|
|
288 location loc = location ());
|
|
289 rvalue new_call (function func,
|
|
290 rvalue arg0, rvalue arg1, rvalue arg2,
|
|
291 location loc = location ());
|
|
292 rvalue new_call (function func,
|
|
293 rvalue arg0, rvalue arg1, rvalue arg2,
|
|
294 rvalue arg3,
|
|
295 location loc = location ());
|
|
296 rvalue new_call (function func,
|
|
297 rvalue arg0, rvalue arg1, rvalue arg2,
|
|
298 rvalue arg3, rvalue arg4,
|
|
299 location loc = location ());
|
|
300 rvalue new_call (function func,
|
|
301 rvalue arg0, rvalue arg1, rvalue arg2,
|
|
302 rvalue arg3, rvalue arg4, rvalue arg5,
|
|
303 location loc = location ());
|
|
304
|
|
305 rvalue new_cast (rvalue expr,
|
|
306 type type_,
|
|
307 location loc = location ());
|
|
308
|
|
309 lvalue new_array_access (rvalue ptr,
|
|
310 rvalue index,
|
|
311 location loc = location ());
|
|
312
|
|
313 case_ new_case (rvalue min_value,
|
|
314 rvalue max_value,
|
|
315 block dest_block);
|
|
316
|
|
317 private:
|
|
318 gcc_jit_context *m_inner_ctxt;
|
|
319 };
|
|
320
|
|
321 class field : public object
|
|
322 {
|
|
323 public:
|
|
324 field ();
|
|
325 field (gcc_jit_field *inner);
|
|
326
|
|
327 gcc_jit_field *get_inner_field () const;
|
|
328 };
|
|
329
|
|
330 class type : public object
|
|
331 {
|
|
332 public:
|
|
333 type ();
|
|
334 type (gcc_jit_type *inner);
|
|
335
|
|
336 gcc_jit_type *get_inner_type () const;
|
|
337
|
|
338 type get_pointer ();
|
|
339 type get_const ();
|
|
340 type get_volatile ();
|
|
341 type get_aligned (size_t alignment_in_bytes);
|
|
342 type get_vector (size_t num_units);
|
|
343
|
|
344 // Shortcuts for getting values of numeric types:
|
|
345 rvalue zero ();
|
|
346 rvalue one ();
|
|
347 };
|
|
348
|
|
349 class struct_ : public type
|
|
350 {
|
|
351 public:
|
|
352 struct_ ();
|
|
353 struct_ (gcc_jit_struct *inner);
|
|
354
|
|
355 gcc_jit_struct *get_inner_struct () const;
|
|
356 };
|
|
357
|
|
358 class function : public object
|
|
359 {
|
|
360 public:
|
|
361 function ();
|
|
362 function (gcc_jit_function *func);
|
|
363
|
|
364 gcc_jit_function *get_inner_function () const;
|
|
365
|
|
366 void dump_to_dot (const std::string &path);
|
|
367
|
|
368 param get_param (int index) const;
|
|
369
|
|
370 block new_block ();
|
|
371 block new_block (const std::string &name);
|
|
372
|
|
373 lvalue new_local (type type_,
|
|
374 const std::string &name,
|
|
375 location loc = location ());
|
|
376
|
|
377 rvalue get_address (location loc = location ());
|
|
378
|
|
379 /* A series of overloaded operator () with various numbers of arguments
|
|
380 for a very terse way of creating a call to this function. The call
|
|
381 is created within the same context as the function itself, which may
|
|
382 not be what you want. */
|
|
383 rvalue operator() (location loc = location ());
|
|
384 rvalue operator() (rvalue arg0,
|
|
385 location loc = location ());
|
|
386 rvalue operator() (rvalue arg0, rvalue arg1,
|
|
387 location loc = location ());
|
|
388 rvalue operator() (rvalue arg0, rvalue arg1, rvalue arg2,
|
|
389 location loc = location ());
|
|
390 };
|
|
391
|
|
392 class block : public object
|
|
393 {
|
|
394 public:
|
|
395 block ();
|
|
396 block (gcc_jit_block *inner);
|
|
397
|
|
398 gcc_jit_block *get_inner_block () const;
|
|
399
|
|
400 function get_function () const;
|
|
401
|
|
402 void add_eval (rvalue rvalue,
|
|
403 location loc = location ());
|
|
404
|
|
405 void add_assignment (lvalue lvalue,
|
|
406 rvalue rvalue,
|
|
407 location loc = location ());
|
|
408
|
|
409 void add_assignment_op (lvalue lvalue,
|
|
410 enum gcc_jit_binary_op op,
|
|
411 rvalue rvalue,
|
|
412 location loc = location ());
|
|
413
|
|
414 /* A way to add a function call to the body of a function being
|
|
415 defined, with various numbers of args. */
|
|
416 rvalue add_call (function other,
|
|
417 location loc = location ());
|
|
418 rvalue add_call (function other,
|
|
419 rvalue arg0,
|
|
420 location loc = location ());
|
|
421 rvalue add_call (function other,
|
|
422 rvalue arg0, rvalue arg1,
|
|
423 location loc = location ());
|
|
424 rvalue add_call (function other,
|
|
425 rvalue arg0, rvalue arg1, rvalue arg2,
|
|
426 location loc = location ());
|
|
427 rvalue add_call (function other,
|
|
428 rvalue arg0, rvalue arg1, rvalue arg2, rvalue arg3,
|
|
429 location loc = location ());
|
|
430
|
|
431 void add_comment (const std::string &text,
|
|
432 location loc = location ());
|
|
433
|
|
434 void end_with_conditional (rvalue boolval,
|
|
435 block on_true,
|
|
436 block on_false,
|
|
437 location loc = location ());
|
|
438
|
|
439 void end_with_jump (block target,
|
|
440 location loc = location ());
|
|
441
|
|
442 void end_with_return (rvalue rvalue,
|
|
443 location loc = location ());
|
|
444 void end_with_return (location loc = location ());
|
|
445
|
|
446 void end_with_switch (rvalue expr,
|
|
447 block default_block,
|
|
448 std::vector <case_> cases,
|
|
449 location loc = location ());
|
|
450 };
|
|
451
|
|
452 class rvalue : public object
|
|
453 {
|
|
454 public:
|
|
455 rvalue ();
|
|
456 rvalue (gcc_jit_rvalue *inner);
|
|
457 gcc_jit_rvalue *get_inner_rvalue () const;
|
|
458
|
|
459 type get_type ();
|
|
460
|
|
461 rvalue access_field (field field,
|
|
462 location loc = location ());
|
|
463
|
|
464 lvalue dereference_field (field field,
|
|
465 location loc = location ());
|
|
466
|
|
467 lvalue dereference (location loc = location ());
|
|
468
|
|
469 rvalue cast_to (type type_,
|
|
470 location loc = location ());
|
|
471
|
|
472 /* Array access. */
|
|
473 lvalue operator[] (rvalue index);
|
|
474 lvalue operator[] (int index);
|
|
475 };
|
|
476
|
|
477 class lvalue : public rvalue
|
|
478 {
|
|
479 public:
|
|
480 lvalue ();
|
|
481 lvalue (gcc_jit_lvalue *inner);
|
|
482
|
|
483 gcc_jit_lvalue *get_inner_lvalue () const;
|
|
484
|
|
485 lvalue access_field (field field,
|
|
486 location loc = location ());
|
|
487
|
|
488 rvalue get_address (location loc = location ());
|
|
489 };
|
|
490
|
|
491 class param : public lvalue
|
|
492 {
|
|
493 public:
|
|
494 param ();
|
|
495 param (gcc_jit_param *inner);
|
|
496
|
|
497 gcc_jit_param *get_inner_param () const;
|
|
498 };
|
|
499
|
|
500 class case_ : public object
|
|
501 {
|
|
502 public:
|
|
503 case_ ();
|
|
504 case_ (gcc_jit_case *inner);
|
|
505
|
|
506 gcc_jit_case *get_inner_case () const;
|
|
507 };
|
|
508
|
|
509 /* Overloaded operators, for those who want the most terse API
|
|
510 (at the possible risk of being a little too magical).
|
|
511
|
|
512 In each case, the first parameter is used to determine which context
|
|
513 owns the resulting expression, and, where appropriate, what the
|
|
514 latter's type is. */
|
|
515
|
|
516 /* Unary operators. */
|
|
517 rvalue operator- (rvalue a); // unary minus
|
|
518 rvalue operator~ (rvalue a); // unary bitwise negate
|
|
519 rvalue operator! (rvalue a); // unary logical negate
|
|
520
|
|
521 /* Binary operators. */
|
|
522 rvalue operator+ (rvalue a, rvalue b);
|
|
523 rvalue operator- (rvalue a, rvalue b);
|
|
524 rvalue operator* (rvalue a, rvalue b);
|
|
525 rvalue operator/ (rvalue a, rvalue b);
|
|
526 rvalue operator% (rvalue a, rvalue b);
|
|
527 rvalue operator& (rvalue a, rvalue b); // bitwise and
|
|
528 rvalue operator^ (rvalue a, rvalue b); // bitwise_xor
|
|
529 rvalue operator| (rvalue a, rvalue b); // bitwise_or
|
|
530 rvalue operator&& (rvalue a, rvalue b); // logical_and
|
|
531 rvalue operator|| (rvalue a, rvalue b); // logical_or
|
|
532
|
|
533 /* Comparisons. */
|
|
534 rvalue operator== (rvalue a, rvalue b);
|
|
535 rvalue operator!= (rvalue a, rvalue b);
|
|
536 rvalue operator< (rvalue a, rvalue b);
|
|
537 rvalue operator<= (rvalue a, rvalue b);
|
|
538 rvalue operator> (rvalue a, rvalue b);
|
|
539 rvalue operator>= (rvalue a, rvalue b);
|
|
540
|
|
541 /* Dereferencing. */
|
|
542 lvalue operator* (rvalue ptr);
|
|
543
|
|
544 class timer
|
|
545 {
|
|
546 public:
|
|
547 timer ();
|
|
548 timer (gcc_jit_timer *inner_timer);
|
|
549
|
|
550 void push (const char *item_name);
|
|
551 void pop (const char *item_name);
|
|
552 void print (FILE *f_out) const;
|
|
553
|
|
554 void release ();
|
|
555
|
|
556 gcc_jit_timer *get_inner_timer () const;
|
|
557
|
|
558 private:
|
|
559 gcc_jit_timer *m_inner_timer;
|
|
560 };
|
|
561
|
|
562 class auto_time
|
|
563 {
|
|
564 public:
|
|
565 auto_time (timer t, const char *item_name);
|
|
566 auto_time (context ctxt, const char *item_name);
|
|
567 ~auto_time ();
|
|
568
|
|
569 private:
|
|
570 timer m_timer;
|
|
571 const char *m_item_name;
|
|
572 };
|
|
573 }
|
|
574
|
|
575 /****************************************************************************
|
|
576 Implementation of the API
|
|
577 ****************************************************************************/
|
|
578 namespace gccjit {
|
|
579
|
|
580 // class context
|
|
581 inline context context::acquire ()
|
|
582 {
|
|
583 return context (gcc_jit_context_acquire ());
|
|
584 }
|
|
585 inline context::context () : m_inner_ctxt (NULL) {}
|
|
586 inline context::context (gcc_jit_context *inner) : m_inner_ctxt (inner)
|
|
587 {
|
|
588 if (!inner)
|
|
589 throw error ();
|
|
590 }
|
|
591
|
|
592 inline gccjit::context
|
|
593 context::new_child_context ()
|
|
594 {
|
|
595 return context (gcc_jit_context_new_child_context (m_inner_ctxt));
|
|
596 }
|
|
597
|
|
598 inline void
|
|
599 context::release ()
|
|
600 {
|
|
601 gcc_jit_context_release (m_inner_ctxt);
|
|
602 m_inner_ctxt = NULL;
|
|
603 }
|
|
604
|
|
605 inline gcc_jit_result *
|
|
606 context::compile ()
|
|
607 {
|
|
608 gcc_jit_result *result = gcc_jit_context_compile (m_inner_ctxt);
|
|
609 if (!result)
|
|
610 throw error ();
|
|
611 return result;
|
|
612 }
|
|
613
|
|
614 inline void
|
|
615 context::compile_to_file (enum gcc_jit_output_kind output_kind,
|
|
616 const char *output_path)
|
|
617 {
|
|
618 gcc_jit_context_compile_to_file (m_inner_ctxt,
|
|
619 output_kind,
|
|
620 output_path);
|
|
621 }
|
|
622
|
|
623 inline void
|
|
624 context::dump_to_file (const std::string &path,
|
|
625 bool update_locations)
|
|
626 {
|
|
627 gcc_jit_context_dump_to_file (m_inner_ctxt,
|
|
628 path.c_str (),
|
|
629 update_locations);
|
|
630 }
|
|
631
|
|
632 inline void
|
|
633 context::set_logfile (FILE *logfile,
|
|
634 int flags,
|
|
635 int verbosity)
|
|
636 {
|
|
637 gcc_jit_context_set_logfile (m_inner_ctxt,
|
|
638 logfile,
|
|
639 flags,
|
|
640 verbosity);
|
|
641 }
|
|
642
|
|
643 inline void
|
|
644 context::dump_reproducer_to_file (const char *path)
|
|
645 {
|
|
646 gcc_jit_context_dump_reproducer_to_file (m_inner_ctxt,
|
|
647 path);
|
|
648 }
|
|
649
|
|
650 inline void
|
|
651 context::set_str_option (enum gcc_jit_str_option opt,
|
|
652 const char *value)
|
|
653 {
|
|
654 gcc_jit_context_set_str_option (m_inner_ctxt, opt, value);
|
|
655
|
|
656 }
|
|
657
|
|
658 inline void
|
|
659 context::set_int_option (enum gcc_jit_int_option opt,
|
|
660 int value)
|
|
661 {
|
|
662 gcc_jit_context_set_int_option (m_inner_ctxt, opt, value);
|
|
663
|
|
664 }
|
|
665
|
|
666 inline void
|
|
667 context::set_bool_option (enum gcc_jit_bool_option opt,
|
|
668 int value)
|
|
669 {
|
|
670 gcc_jit_context_set_bool_option (m_inner_ctxt, opt, value);
|
|
671 }
|
|
672
|
|
673 inline void
|
|
674 context::set_bool_allow_unreachable_blocks (int bool_value)
|
|
675 {
|
|
676 gcc_jit_context_set_bool_allow_unreachable_blocks (m_inner_ctxt,
|
|
677 bool_value);
|
|
678 }
|
|
679
|
|
680 inline void
|
|
681 context::set_bool_use_external_driver (int bool_value)
|
|
682 {
|
|
683 gcc_jit_context_set_bool_use_external_driver (m_inner_ctxt,
|
|
684 bool_value);
|
|
685 }
|
|
686
|
|
687 inline void
|
|
688 context::add_command_line_option (const char *optname)
|
|
689 {
|
|
690 gcc_jit_context_add_command_line_option (m_inner_ctxt, optname);
|
|
691 }
|
|
692
|
|
693 inline void
|
145
|
694 context::add_driver_option (const char *optname)
|
|
695 {
|
|
696 gcc_jit_context_add_driver_option (m_inner_ctxt, optname);
|
|
697 }
|
|
698
|
|
699 inline void
|
111
|
700 context::set_timer (gccjit::timer t)
|
|
701 {
|
|
702 gcc_jit_context_set_timer (m_inner_ctxt, t.get_inner_timer ());
|
|
703 }
|
|
704
|
|
705 inline gccjit::timer
|
|
706 context::get_timer () const
|
|
707 {
|
|
708 return gccjit::timer (gcc_jit_context_get_timer (m_inner_ctxt));
|
|
709 }
|
|
710
|
|
711
|
|
712 inline location
|
|
713 context::new_location (const std::string &filename,
|
|
714 int line,
|
|
715 int column)
|
|
716 {
|
|
717 return location (gcc_jit_context_new_location (m_inner_ctxt,
|
|
718 filename.c_str (),
|
|
719 line,
|
|
720 column));
|
|
721 }
|
|
722
|
|
723 inline type
|
|
724 context::get_type (enum gcc_jit_types kind)
|
|
725 {
|
|
726 return type (gcc_jit_context_get_type (m_inner_ctxt, kind));
|
|
727 }
|
|
728
|
|
729 inline type
|
|
730 context::get_int_type (size_t num_bytes, int is_signed)
|
|
731 {
|
|
732 return type (gcc_jit_context_get_int_type (m_inner_ctxt,
|
|
733 num_bytes,
|
|
734 is_signed));
|
|
735 }
|
|
736
|
|
737 template <typename T>
|
|
738 inline type
|
|
739 context::get_int_type ()
|
|
740 {
|
|
741 return get_int_type (sizeof (T), std::numeric_limits<T>::is_signed);
|
|
742 }
|
|
743
|
|
744 inline type
|
|
745 context::new_array_type (type element_type, int num_elements, location loc)
|
|
746 {
|
|
747 return type (gcc_jit_context_new_array_type (
|
|
748 m_inner_ctxt,
|
|
749 loc.get_inner_location (),
|
|
750 element_type.get_inner_type (),
|
|
751 num_elements));
|
|
752 }
|
|
753
|
|
754 inline field
|
|
755 context::new_field (type type_, const std::string &name, location loc)
|
|
756 {
|
|
757 return field (gcc_jit_context_new_field (m_inner_ctxt,
|
|
758 loc.get_inner_location (),
|
|
759 type_.get_inner_type (),
|
|
760 name.c_str ()));
|
|
761 }
|
|
762
|
145
|
763 inline field
|
|
764 context::new_bitfield (type type_, int width, const std::string &name,
|
|
765 location loc)
|
|
766 {
|
|
767 return field (gcc_jit_context_new_bitfield (m_inner_ctxt,
|
|
768 loc.get_inner_location (),
|
|
769 type_.get_inner_type (),
|
|
770 width,
|
|
771 name.c_str ()));
|
|
772 }
|
|
773
|
111
|
774 inline struct_
|
|
775 context::new_struct_type (const std::string &name,
|
|
776 std::vector<field> &fields,
|
|
777 location loc)
|
|
778 {
|
|
779 /* Treat std::vector as an array, relying on it not being resized: */
|
|
780 field *as_array_of_wrappers = &fields[0];
|
|
781
|
|
782 /* Treat the array as being of the underlying pointers, relying on
|
|
783 the wrapper type being such a pointer internally. */
|
|
784 gcc_jit_field **as_array_of_ptrs =
|
|
785 reinterpret_cast<gcc_jit_field **> (as_array_of_wrappers);
|
|
786
|
|
787 return struct_ (gcc_jit_context_new_struct_type (m_inner_ctxt,
|
|
788 loc.get_inner_location (),
|
|
789 name.c_str (),
|
|
790 fields.size (),
|
|
791 as_array_of_ptrs));
|
|
792 }
|
|
793
|
|
794 inline struct_
|
|
795 context::new_opaque_struct_type (const std::string &name,
|
|
796 location loc)
|
|
797 {
|
|
798 return struct_ (gcc_jit_context_new_opaque_struct (
|
|
799 m_inner_ctxt,
|
|
800 loc.get_inner_location (),
|
|
801 name.c_str ()));
|
|
802 }
|
|
803
|
|
804 inline param
|
|
805 context::new_param (type type_,
|
|
806 const std::string &name,
|
|
807 location loc)
|
|
808 {
|
|
809 return param (gcc_jit_context_new_param (m_inner_ctxt,
|
|
810 loc.get_inner_location (),
|
|
811 type_.get_inner_type (),
|
|
812 name.c_str ()));
|
|
813 }
|
|
814
|
|
815 inline function
|
|
816 context::new_function (enum gcc_jit_function_kind kind,
|
|
817 type return_type,
|
|
818 const std::string &name,
|
|
819 std::vector<param> ¶ms,
|
|
820 int is_variadic,
|
|
821 location loc)
|
|
822 {
|
|
823 /* Treat std::vector as an array, relying on it not being resized: */
|
|
824 param *as_array_of_wrappers = ¶ms[0];
|
|
825
|
|
826 /* Treat the array as being of the underlying pointers, relying on
|
|
827 the wrapper type being such a pointer internally. */
|
|
828 gcc_jit_param **as_array_of_ptrs =
|
|
829 reinterpret_cast<gcc_jit_param **> (as_array_of_wrappers);
|
|
830
|
|
831 return function (gcc_jit_context_new_function (m_inner_ctxt,
|
|
832 loc.get_inner_location (),
|
|
833 kind,
|
|
834 return_type.get_inner_type (),
|
|
835 name.c_str (),
|
|
836 params.size (),
|
|
837 as_array_of_ptrs,
|
|
838 is_variadic));
|
|
839 }
|
|
840
|
|
841 inline function
|
|
842 context::get_builtin_function (const std::string &name)
|
|
843 {
|
|
844 return function (gcc_jit_context_get_builtin_function (m_inner_ctxt,
|
|
845 name.c_str ()));
|
|
846 }
|
|
847
|
|
848 inline lvalue
|
|
849 context::new_global (enum gcc_jit_global_kind kind,
|
|
850 type type_,
|
|
851 const std::string &name,
|
|
852 location loc)
|
|
853 {
|
|
854 return lvalue (gcc_jit_context_new_global (m_inner_ctxt,
|
|
855 loc.get_inner_location (),
|
|
856 kind,
|
|
857 type_.get_inner_type (),
|
|
858 name.c_str ()));
|
|
859 }
|
|
860
|
|
861 inline rvalue
|
|
862 context::new_rvalue (type numeric_type,
|
|
863 int value) const
|
|
864 {
|
|
865 return rvalue (
|
|
866 gcc_jit_context_new_rvalue_from_int (m_inner_ctxt,
|
|
867 numeric_type.get_inner_type (),
|
|
868 value));
|
|
869 }
|
|
870
|
|
871 inline rvalue
|
|
872 context::new_rvalue (type numeric_type,
|
|
873 long value) const
|
|
874 {
|
|
875 return rvalue (
|
|
876 gcc_jit_context_new_rvalue_from_long (m_inner_ctxt,
|
|
877 numeric_type.get_inner_type (),
|
|
878 value));
|
|
879 }
|
|
880
|
|
881 inline rvalue
|
|
882 context::zero (type numeric_type) const
|
|
883 {
|
|
884 return rvalue (gcc_jit_context_zero (m_inner_ctxt,
|
|
885 numeric_type.get_inner_type ()));
|
|
886 }
|
|
887
|
|
888 inline rvalue
|
|
889 context::one (type numeric_type) const
|
|
890 {
|
|
891 return rvalue (gcc_jit_context_one (m_inner_ctxt,
|
|
892 numeric_type.get_inner_type ()));
|
|
893 }
|
|
894
|
|
895 inline rvalue
|
|
896 context::new_rvalue (type numeric_type,
|
|
897 double value) const
|
|
898 {
|
|
899 return rvalue (
|
|
900 gcc_jit_context_new_rvalue_from_double (m_inner_ctxt,
|
|
901 numeric_type.get_inner_type (),
|
|
902 value));
|
|
903 }
|
|
904
|
|
905 inline rvalue
|
|
906 context::new_rvalue (type pointer_type,
|
|
907 void *value) const
|
|
908 {
|
|
909 return rvalue (
|
|
910 gcc_jit_context_new_rvalue_from_ptr (m_inner_ctxt,
|
|
911 pointer_type.get_inner_type (),
|
|
912 value));
|
|
913 }
|
|
914
|
|
915 inline rvalue
|
|
916 context::new_rvalue (const std::string &value) const
|
|
917 {
|
|
918 return rvalue (
|
|
919 gcc_jit_context_new_string_literal (m_inner_ctxt, value.c_str ()));
|
|
920 }
|
|
921
|
|
922 inline rvalue
|
|
923 context::new_rvalue (type vector_type,
|
|
924 std::vector<rvalue> elements) const
|
|
925 {
|
|
926 /* Treat std::vector as an array, relying on it not being resized: */
|
|
927 rvalue *as_array_of_wrappers = &elements[0];
|
|
928
|
|
929 /* Treat the array as being of the underlying pointers, relying on
|
|
930 the wrapper type being such a pointer internally. */
|
|
931 gcc_jit_rvalue **as_array_of_ptrs =
|
|
932 reinterpret_cast<gcc_jit_rvalue **> (as_array_of_wrappers);
|
|
933
|
|
934 return rvalue (
|
|
935 gcc_jit_context_new_rvalue_from_vector (m_inner_ctxt,
|
|
936 NULL,
|
|
937 vector_type.get_inner_type (),
|
|
938 elements.size (),
|
|
939 as_array_of_ptrs));
|
|
940 }
|
|
941
|
|
942 inline rvalue
|
|
943 context::new_unary_op (enum gcc_jit_unary_op op,
|
|
944 type result_type,
|
|
945 rvalue a,
|
|
946 location loc)
|
|
947 {
|
|
948 return rvalue (gcc_jit_context_new_unary_op (m_inner_ctxt,
|
|
949 loc.get_inner_location (),
|
|
950 op,
|
|
951 result_type.get_inner_type (),
|
|
952 a.get_inner_rvalue ()));
|
|
953 }
|
|
954 inline rvalue
|
|
955 context::new_minus (type result_type,
|
|
956 rvalue a,
|
|
957 location loc)
|
|
958 {
|
|
959 return rvalue (new_unary_op (GCC_JIT_UNARY_OP_MINUS,
|
|
960 result_type, a, loc));
|
|
961 }
|
|
962 inline rvalue
|
|
963 context::new_bitwise_negate (type result_type,
|
|
964 rvalue a,
|
|
965 location loc)
|
|
966 {
|
|
967 return rvalue (new_unary_op (GCC_JIT_UNARY_OP_BITWISE_NEGATE,
|
|
968 result_type, a, loc));
|
|
969 }
|
|
970 inline rvalue
|
|
971 context::new_logical_negate (type result_type,
|
|
972 rvalue a,
|
|
973 location loc)
|
|
974 {
|
|
975 return rvalue (new_unary_op (GCC_JIT_UNARY_OP_LOGICAL_NEGATE,
|
|
976 result_type, a, loc));
|
|
977 }
|
|
978
|
|
979 inline rvalue
|
|
980 context::new_binary_op (enum gcc_jit_binary_op op,
|
|
981 type result_type,
|
|
982 rvalue a, rvalue b,
|
|
983 location loc)
|
|
984 {
|
|
985 return rvalue (gcc_jit_context_new_binary_op (m_inner_ctxt,
|
|
986 loc.get_inner_location (),
|
|
987 op,
|
|
988 result_type.get_inner_type (),
|
|
989 a.get_inner_rvalue (),
|
|
990 b.get_inner_rvalue ()));
|
|
991 }
|
|
992 inline rvalue
|
|
993 context::new_plus (type result_type,
|
|
994 rvalue a, rvalue b,
|
|
995 location loc)
|
|
996 {
|
|
997 return new_binary_op (GCC_JIT_BINARY_OP_PLUS,
|
|
998 result_type, a, b, loc);
|
|
999 }
|
|
1000 inline rvalue
|
|
1001 context::new_minus (type result_type,
|
|
1002 rvalue a, rvalue b,
|
|
1003 location loc)
|
|
1004 {
|
|
1005 return new_binary_op (GCC_JIT_BINARY_OP_MINUS,
|
|
1006 result_type, a, b, loc);
|
|
1007 }
|
|
1008 inline rvalue
|
|
1009 context::new_mult (type result_type,
|
|
1010 rvalue a, rvalue b,
|
|
1011 location loc)
|
|
1012 {
|
|
1013 return new_binary_op (GCC_JIT_BINARY_OP_MULT,
|
|
1014 result_type, a, b, loc);
|
|
1015 }
|
|
1016 inline rvalue
|
|
1017 context::new_divide (type result_type,
|
|
1018 rvalue a, rvalue b,
|
|
1019 location loc)
|
|
1020 {
|
|
1021 return new_binary_op (GCC_JIT_BINARY_OP_DIVIDE,
|
|
1022 result_type, a, b, loc);
|
|
1023 }
|
|
1024 inline rvalue
|
|
1025 context::new_modulo (type result_type,
|
|
1026 rvalue a, rvalue b,
|
|
1027 location loc)
|
|
1028 {
|
|
1029 return new_binary_op (GCC_JIT_BINARY_OP_MODULO,
|
|
1030 result_type, a, b, loc);
|
|
1031 }
|
|
1032 inline rvalue
|
|
1033 context::new_bitwise_and (type result_type,
|
|
1034 rvalue a, rvalue b,
|
|
1035 location loc)
|
|
1036 {
|
|
1037 return new_binary_op (GCC_JIT_BINARY_OP_BITWISE_AND,
|
|
1038 result_type, a, b, loc);
|
|
1039 }
|
|
1040 inline rvalue
|
|
1041 context::new_bitwise_xor (type result_type,
|
|
1042 rvalue a, rvalue b,
|
|
1043 location loc)
|
|
1044 {
|
|
1045 return new_binary_op (GCC_JIT_BINARY_OP_BITWISE_XOR,
|
|
1046 result_type, a, b, loc);
|
|
1047 }
|
|
1048 inline rvalue
|
|
1049 context::new_bitwise_or (type result_type,
|
|
1050 rvalue a, rvalue b,
|
|
1051 location loc)
|
|
1052 {
|
|
1053 return new_binary_op (GCC_JIT_BINARY_OP_BITWISE_OR,
|
|
1054 result_type, a, b, loc);
|
|
1055 }
|
|
1056 inline rvalue
|
|
1057 context::new_logical_and (type result_type,
|
|
1058 rvalue a, rvalue b,
|
|
1059 location loc)
|
|
1060 {
|
|
1061 return new_binary_op (GCC_JIT_BINARY_OP_LOGICAL_AND,
|
|
1062 result_type, a, b, loc);
|
|
1063 }
|
|
1064 inline rvalue
|
|
1065 context::new_logical_or (type result_type,
|
|
1066 rvalue a, rvalue b,
|
|
1067 location loc)
|
|
1068 {
|
|
1069 return new_binary_op (GCC_JIT_BINARY_OP_LOGICAL_OR,
|
|
1070 result_type, a, b, loc);
|
|
1071 }
|
|
1072
|
|
1073 inline rvalue
|
|
1074 context::new_comparison (enum gcc_jit_comparison op,
|
|
1075 rvalue a, rvalue b,
|
|
1076 location loc)
|
|
1077 {
|
|
1078 return rvalue (gcc_jit_context_new_comparison (m_inner_ctxt,
|
|
1079 loc.get_inner_location (),
|
|
1080 op,
|
|
1081 a.get_inner_rvalue (),
|
|
1082 b.get_inner_rvalue ()));
|
|
1083 }
|
|
1084 inline rvalue
|
|
1085 context::new_eq (rvalue a, rvalue b,
|
|
1086 location loc)
|
|
1087 {
|
|
1088 return new_comparison (GCC_JIT_COMPARISON_EQ,
|
|
1089 a, b, loc);
|
|
1090 }
|
|
1091 inline rvalue
|
|
1092 context::new_ne (rvalue a, rvalue b,
|
|
1093 location loc)
|
|
1094 {
|
|
1095 return new_comparison (GCC_JIT_COMPARISON_NE,
|
|
1096 a, b, loc);
|
|
1097 }
|
|
1098 inline rvalue
|
|
1099 context::new_lt (rvalue a, rvalue b,
|
|
1100 location loc)
|
|
1101 {
|
|
1102 return new_comparison (GCC_JIT_COMPARISON_LT,
|
|
1103 a, b, loc);
|
|
1104 }
|
|
1105 inline rvalue
|
|
1106 context::new_le (rvalue a, rvalue b,
|
|
1107 location loc)
|
|
1108 {
|
|
1109 return new_comparison (GCC_JIT_COMPARISON_LE,
|
|
1110 a, b, loc);
|
|
1111 }
|
|
1112 inline rvalue
|
|
1113 context::new_gt (rvalue a, rvalue b,
|
|
1114 location loc)
|
|
1115 {
|
|
1116 return new_comparison (GCC_JIT_COMPARISON_GT,
|
|
1117 a, b, loc);
|
|
1118 }
|
|
1119 inline rvalue
|
|
1120 context::new_ge (rvalue a, rvalue b,
|
|
1121 location loc)
|
|
1122 {
|
|
1123 return new_comparison (GCC_JIT_COMPARISON_GE,
|
|
1124 a, b, loc);
|
|
1125 }
|
|
1126
|
|
1127 inline rvalue
|
|
1128 context::new_call (function func,
|
|
1129 std::vector<rvalue> &args,
|
|
1130 location loc)
|
|
1131 {
|
|
1132 /* Treat std::vector as an array, relying on it not being resized: */
|
|
1133 rvalue *as_array_of_wrappers = &args[0];
|
|
1134
|
|
1135 /* Treat the array as being of the underlying pointers, relying on
|
|
1136 the wrapper type being such a pointer internally. */
|
|
1137 gcc_jit_rvalue **as_array_of_ptrs =
|
|
1138 reinterpret_cast<gcc_jit_rvalue **> (as_array_of_wrappers);
|
|
1139 return gcc_jit_context_new_call (m_inner_ctxt,
|
|
1140 loc.get_inner_location (),
|
|
1141 func.get_inner_function (),
|
|
1142 args.size (),
|
|
1143 as_array_of_ptrs);
|
|
1144 }
|
|
1145 inline rvalue
|
|
1146 context::new_call (function func,
|
|
1147 location loc)
|
|
1148 {
|
|
1149 std::vector<rvalue> args;
|
|
1150 return new_call (func, args, loc);
|
|
1151 }
|
|
1152
|
|
1153 inline rvalue
|
|
1154 context::new_call (function func,
|
|
1155 rvalue arg0,
|
|
1156 location loc)
|
|
1157 {
|
|
1158 std::vector<rvalue> args(1);
|
|
1159 args[0] = arg0;
|
|
1160 return new_call (func, args, loc);
|
|
1161 }
|
|
1162 inline rvalue
|
|
1163 context::new_call (function func,
|
|
1164 rvalue arg0, rvalue arg1,
|
|
1165 location loc)
|
|
1166 {
|
|
1167 std::vector<rvalue> args(2);
|
|
1168 args[0] = arg0;
|
|
1169 args[1] = arg1;
|
|
1170 return new_call (func, args, loc);
|
|
1171 }
|
|
1172 inline rvalue
|
|
1173 context::new_call (function func,
|
|
1174 rvalue arg0, rvalue arg1, rvalue arg2,
|
|
1175 location loc)
|
|
1176 {
|
|
1177 std::vector<rvalue> args(3);
|
|
1178 args[0] = arg0;
|
|
1179 args[1] = arg1;
|
|
1180 args[2] = arg2;
|
|
1181 return new_call (func, args, loc);
|
|
1182 }
|
|
1183 inline rvalue
|
|
1184 context::new_call (function func,
|
|
1185 rvalue arg0, rvalue arg1, rvalue arg2,
|
|
1186 rvalue arg3,
|
|
1187 location loc)
|
|
1188 {
|
|
1189 std::vector<rvalue> args(4);
|
|
1190 args[0] = arg0;
|
|
1191 args[1] = arg1;
|
|
1192 args[2] = arg2;
|
|
1193 args[3] = arg3;
|
|
1194 return new_call (func, args, loc);
|
|
1195 }
|
|
1196 inline rvalue
|
|
1197 context::new_call (function func,
|
|
1198 rvalue arg0, rvalue arg1, rvalue arg2,
|
|
1199 rvalue arg3, rvalue arg4,
|
|
1200 location loc)
|
|
1201 {
|
|
1202 std::vector<rvalue> args(5);
|
|
1203 args[0] = arg0;
|
|
1204 args[1] = arg1;
|
|
1205 args[2] = arg2;
|
|
1206 args[3] = arg3;
|
|
1207 args[4] = arg4;
|
|
1208 return new_call (func, args, loc);
|
|
1209 }
|
|
1210 inline rvalue
|
|
1211 context::new_call (function func,
|
|
1212 rvalue arg0, rvalue arg1, rvalue arg2,
|
|
1213 rvalue arg3, rvalue arg4, rvalue arg5,
|
|
1214 location loc)
|
|
1215 {
|
|
1216 std::vector<rvalue> args(6);
|
|
1217 args[0] = arg0;
|
|
1218 args[1] = arg1;
|
|
1219 args[2] = arg2;
|
|
1220 args[3] = arg3;
|
|
1221 args[4] = arg4;
|
|
1222 args[5] = arg5;
|
|
1223 return new_call (func, args, loc);
|
|
1224 }
|
|
1225
|
|
1226 inline rvalue
|
|
1227 context::new_cast (rvalue expr,
|
|
1228 type type_,
|
|
1229 location loc)
|
|
1230 {
|
|
1231 return rvalue (gcc_jit_context_new_cast (m_inner_ctxt,
|
|
1232 loc.get_inner_location (),
|
|
1233 expr.get_inner_rvalue (),
|
|
1234 type_.get_inner_type ()));
|
|
1235 }
|
|
1236
|
|
1237 inline lvalue
|
|
1238 context::new_array_access (rvalue ptr,
|
|
1239 rvalue index,
|
|
1240 location loc)
|
|
1241 {
|
|
1242 return lvalue (gcc_jit_context_new_array_access (m_inner_ctxt,
|
|
1243 loc.get_inner_location (),
|
|
1244 ptr.get_inner_rvalue (),
|
|
1245 index.get_inner_rvalue ()));
|
|
1246 }
|
|
1247
|
|
1248 inline case_
|
|
1249 context::new_case (rvalue min_value,
|
|
1250 rvalue max_value,
|
|
1251 block dest_block)
|
|
1252 {
|
|
1253 return case_ (gcc_jit_context_new_case (m_inner_ctxt,
|
|
1254 min_value.get_inner_rvalue (),
|
|
1255 max_value.get_inner_rvalue (),
|
|
1256 dest_block.get_inner_block ()));
|
|
1257 }
|
|
1258
|
|
1259 // class object
|
|
1260 inline context
|
|
1261 object::get_context () const
|
|
1262 {
|
|
1263 return context (gcc_jit_object_get_context (m_inner_obj));
|
|
1264 }
|
|
1265
|
|
1266 inline std::string
|
|
1267 object::get_debug_string () const
|
|
1268 {
|
|
1269 return gcc_jit_object_get_debug_string (m_inner_obj);
|
|
1270 }
|
|
1271
|
|
1272 inline object::object () : m_inner_obj (NULL) {}
|
|
1273 inline object::object (gcc_jit_object *obj) : m_inner_obj (obj)
|
|
1274 {
|
|
1275 if (!obj)
|
|
1276 throw error ();
|
|
1277 }
|
|
1278
|
|
1279 inline gcc_jit_object *
|
|
1280 object::get_inner_object () const
|
|
1281 {
|
|
1282 return m_inner_obj;
|
|
1283 }
|
|
1284
|
|
1285 inline std::ostream&
|
|
1286 operator << (std::ostream& stream, const object &obj)
|
|
1287 {
|
|
1288 return stream << obj.get_debug_string ();
|
|
1289 }
|
|
1290
|
|
1291 // class location
|
|
1292 inline location::location () : object () {}
|
|
1293 inline location::location (gcc_jit_location *loc)
|
|
1294 : object (gcc_jit_location_as_object (loc))
|
|
1295 {}
|
|
1296
|
|
1297 inline gcc_jit_location *
|
|
1298 location::get_inner_location () const
|
|
1299 {
|
|
1300 /* Manual downcast: */
|
|
1301 return reinterpret_cast<gcc_jit_location *> (get_inner_object ());
|
|
1302 }
|
|
1303
|
|
1304 // class field
|
|
1305 inline field::field () : object () {}
|
|
1306 inline field::field (gcc_jit_field *inner)
|
|
1307 : object (gcc_jit_field_as_object (inner))
|
|
1308 {}
|
|
1309
|
|
1310 inline gcc_jit_field *
|
|
1311 field::get_inner_field () const
|
|
1312 {
|
|
1313 /* Manual downcast: */
|
|
1314 return reinterpret_cast<gcc_jit_field *> (get_inner_object ());
|
|
1315 }
|
|
1316
|
|
1317 // class type
|
|
1318 inline type::type () : object () {}
|
|
1319 inline type::type (gcc_jit_type *inner)
|
|
1320 : object (gcc_jit_type_as_object (inner))
|
|
1321 {}
|
|
1322
|
|
1323 inline gcc_jit_type *
|
|
1324 type::get_inner_type () const
|
|
1325 {
|
|
1326 /* Manual downcast: */
|
|
1327 return reinterpret_cast<gcc_jit_type *> (get_inner_object ());
|
|
1328 }
|
|
1329
|
|
1330 inline type
|
|
1331 type::get_pointer ()
|
|
1332 {
|
|
1333 return type (gcc_jit_type_get_pointer (get_inner_type ()));
|
|
1334 }
|
|
1335
|
|
1336 inline type
|
|
1337 type::get_const ()
|
|
1338 {
|
|
1339 return type (gcc_jit_type_get_const (get_inner_type ()));
|
|
1340 }
|
|
1341
|
|
1342 inline type
|
|
1343 type::get_volatile ()
|
|
1344 {
|
|
1345 return type (gcc_jit_type_get_volatile (get_inner_type ()));
|
|
1346 }
|
|
1347
|
|
1348 inline type
|
|
1349 type::get_aligned (size_t alignment_in_bytes)
|
|
1350 {
|
|
1351 return type (gcc_jit_type_get_aligned (get_inner_type (),
|
|
1352 alignment_in_bytes));
|
|
1353 }
|
|
1354
|
|
1355 inline type
|
|
1356 type::get_vector (size_t num_units)
|
|
1357 {
|
|
1358 return type (gcc_jit_type_get_vector (get_inner_type (),
|
|
1359 num_units));
|
|
1360 }
|
|
1361
|
|
1362 inline rvalue
|
|
1363 type::zero ()
|
|
1364 {
|
|
1365 return get_context ().new_rvalue (*this, 0);
|
|
1366 }
|
|
1367
|
|
1368 inline rvalue
|
|
1369 type::one ()
|
|
1370 {
|
|
1371 return get_context ().new_rvalue (*this, 1);
|
|
1372 }
|
|
1373
|
|
1374 // class struct_
|
|
1375 inline struct_::struct_ () : type (NULL) {}
|
|
1376 inline struct_::struct_ (gcc_jit_struct *inner) :
|
|
1377 type (gcc_jit_struct_as_type (inner))
|
|
1378 {
|
|
1379 }
|
|
1380
|
|
1381 inline gcc_jit_struct *
|
|
1382 struct_::get_inner_struct () const
|
|
1383 {
|
|
1384 /* Manual downcast: */
|
|
1385 return reinterpret_cast<gcc_jit_struct *> (get_inner_object ());
|
|
1386 }
|
|
1387
|
|
1388 // class function
|
|
1389 inline function::function () : object () {}
|
|
1390 inline function::function (gcc_jit_function *inner)
|
|
1391 : object (gcc_jit_function_as_object (inner))
|
|
1392 {}
|
|
1393
|
|
1394 inline gcc_jit_function *
|
|
1395 function::get_inner_function () const
|
|
1396 {
|
|
1397 /* Manual downcast: */
|
|
1398 return reinterpret_cast<gcc_jit_function *> (get_inner_object ());
|
|
1399 }
|
|
1400
|
|
1401 inline void
|
|
1402 function::dump_to_dot (const std::string &path)
|
|
1403 {
|
|
1404 gcc_jit_function_dump_to_dot (get_inner_function (),
|
|
1405 path.c_str ());
|
|
1406 }
|
|
1407
|
|
1408 inline param
|
|
1409 function::get_param (int index) const
|
|
1410 {
|
|
1411 return param (gcc_jit_function_get_param (get_inner_function (),
|
|
1412 index));
|
|
1413 }
|
|
1414
|
|
1415 inline block
|
|
1416 function::new_block ()
|
|
1417 {
|
|
1418 return block (gcc_jit_function_new_block (get_inner_function (),
|
|
1419 NULL));
|
|
1420 }
|
|
1421
|
|
1422 inline block
|
|
1423 function::new_block (const std::string &name)
|
|
1424 {
|
|
1425 return block (gcc_jit_function_new_block (get_inner_function (),
|
|
1426 name.c_str ()));
|
|
1427 }
|
|
1428
|
|
1429 inline lvalue
|
|
1430 function::new_local (type type_,
|
|
1431 const std::string &name,
|
|
1432 location loc)
|
|
1433 {
|
|
1434 return lvalue (gcc_jit_function_new_local (get_inner_function (),
|
|
1435 loc.get_inner_location (),
|
|
1436 type_.get_inner_type (),
|
|
1437 name.c_str ()));
|
|
1438 }
|
|
1439
|
|
1440 inline rvalue
|
|
1441 function::get_address (location loc)
|
|
1442 {
|
|
1443 return rvalue (gcc_jit_function_get_address (get_inner_function (),
|
|
1444 loc.get_inner_location ()));
|
|
1445 }
|
|
1446
|
|
1447 inline function
|
|
1448 block::get_function () const
|
|
1449 {
|
|
1450 return function (gcc_jit_block_get_function ( get_inner_block ()));
|
|
1451 }
|
|
1452
|
|
1453 inline void
|
|
1454 block::add_eval (rvalue rvalue,
|
|
1455 location loc)
|
|
1456 {
|
|
1457 gcc_jit_block_add_eval (get_inner_block (),
|
|
1458 loc.get_inner_location (),
|
|
1459 rvalue.get_inner_rvalue ());
|
|
1460 }
|
|
1461
|
|
1462 inline void
|
|
1463 block::add_assignment (lvalue lvalue,
|
|
1464 rvalue rvalue,
|
|
1465 location loc)
|
|
1466 {
|
|
1467 gcc_jit_block_add_assignment (get_inner_block (),
|
|
1468 loc.get_inner_location (),
|
|
1469 lvalue.get_inner_lvalue (),
|
|
1470 rvalue.get_inner_rvalue ());
|
|
1471 }
|
|
1472
|
|
1473 inline void
|
|
1474 block::add_assignment_op (lvalue lvalue,
|
|
1475 enum gcc_jit_binary_op op,
|
|
1476 rvalue rvalue,
|
|
1477 location loc)
|
|
1478 {
|
|
1479 gcc_jit_block_add_assignment_op (get_inner_block (),
|
|
1480 loc.get_inner_location (),
|
|
1481 lvalue.get_inner_lvalue (),
|
|
1482 op,
|
|
1483 rvalue.get_inner_rvalue ());
|
|
1484 }
|
|
1485
|
|
1486 inline void
|
|
1487 block::add_comment (const std::string &text,
|
|
1488 location loc)
|
|
1489 {
|
|
1490 gcc_jit_block_add_comment (get_inner_block (),
|
|
1491 loc.get_inner_location (),
|
|
1492 text.c_str ());
|
|
1493 }
|
|
1494
|
|
1495 inline void
|
|
1496 block::end_with_conditional (rvalue boolval,
|
|
1497 block on_true,
|
|
1498 block on_false,
|
|
1499 location loc)
|
|
1500 {
|
|
1501 gcc_jit_block_end_with_conditional (get_inner_block (),
|
|
1502 loc.get_inner_location (),
|
|
1503 boolval.get_inner_rvalue (),
|
|
1504 on_true.get_inner_block (),
|
|
1505 on_false.get_inner_block ());
|
|
1506 }
|
|
1507
|
|
1508 inline void
|
|
1509 block::end_with_jump (block target,
|
|
1510 location loc)
|
|
1511 {
|
|
1512 gcc_jit_block_end_with_jump (get_inner_block (),
|
|
1513 loc.get_inner_location (),
|
|
1514 target.get_inner_block ());
|
|
1515 }
|
|
1516
|
|
1517 inline void
|
|
1518 block::end_with_return (rvalue rvalue,
|
|
1519 location loc)
|
|
1520 {
|
|
1521 gcc_jit_block_end_with_return (get_inner_block (),
|
|
1522 loc.get_inner_location (),
|
|
1523 rvalue.get_inner_rvalue ());
|
|
1524 }
|
|
1525
|
|
1526 inline void
|
|
1527 block::end_with_return (location loc)
|
|
1528 {
|
|
1529 gcc_jit_block_end_with_void_return (get_inner_block (),
|
|
1530 loc.get_inner_location ());
|
|
1531 }
|
|
1532
|
|
1533 inline void
|
|
1534 block::end_with_switch (rvalue expr,
|
|
1535 block default_block,
|
|
1536 std::vector <case_> cases,
|
|
1537 location loc)
|
|
1538 {
|
|
1539 /* Treat std::vector as an array, relying on it not being resized: */
|
|
1540 case_ *as_array_of_wrappers = &cases[0];
|
|
1541
|
|
1542 /* Treat the array as being of the underlying pointers, relying on
|
|
1543 the wrapper type being such a pointer internally. */
|
|
1544 gcc_jit_case **as_array_of_ptrs =
|
|
1545 reinterpret_cast<gcc_jit_case **> (as_array_of_wrappers);
|
|
1546 gcc_jit_block_end_with_switch (get_inner_block (),
|
|
1547 loc.get_inner_location (),
|
|
1548 expr.get_inner_rvalue (),
|
|
1549 default_block.get_inner_block (),
|
|
1550 cases.size (),
|
|
1551 as_array_of_ptrs);
|
|
1552 }
|
|
1553
|
|
1554 inline rvalue
|
|
1555 block::add_call (function other,
|
|
1556 location loc)
|
|
1557 {
|
|
1558 rvalue c = get_context ().new_call (other, loc);
|
|
1559 add_eval (c);
|
|
1560 return c;
|
|
1561 }
|
|
1562 inline rvalue
|
|
1563 block::add_call (function other,
|
|
1564 rvalue arg0,
|
|
1565 location loc)
|
|
1566 {
|
|
1567 rvalue c = get_context ().new_call (other, arg0, loc);
|
|
1568 add_eval (c);
|
|
1569 return c;
|
|
1570 }
|
|
1571 inline rvalue
|
|
1572 block::add_call (function other,
|
|
1573 rvalue arg0, rvalue arg1,
|
|
1574 location loc)
|
|
1575 {
|
|
1576 rvalue c = get_context ().new_call (other, arg0, arg1, loc);
|
|
1577 add_eval (c);
|
|
1578 return c;
|
|
1579 }
|
|
1580 inline rvalue
|
|
1581 block::add_call (function other,
|
|
1582 rvalue arg0, rvalue arg1, rvalue arg2,
|
|
1583 location loc)
|
|
1584 {
|
|
1585 rvalue c = get_context ().new_call (other, arg0, arg1, arg2, loc);
|
|
1586 add_eval (c);
|
|
1587 return c;
|
|
1588 }
|
|
1589
|
|
1590 inline rvalue
|
|
1591 block::add_call (function other,
|
|
1592 rvalue arg0, rvalue arg1, rvalue arg2, rvalue arg3,
|
|
1593 location loc)
|
|
1594 {
|
|
1595 rvalue c = get_context ().new_call (other, arg0, arg1, arg2, arg3, loc);
|
|
1596 add_eval (c);
|
|
1597 return c;
|
|
1598 }
|
|
1599
|
|
1600 inline rvalue
|
|
1601 function::operator() (location loc)
|
|
1602 {
|
|
1603 return get_context ().new_call (*this, loc);
|
|
1604 }
|
|
1605 inline rvalue
|
|
1606 function::operator() (rvalue arg0,
|
|
1607 location loc)
|
|
1608 {
|
|
1609 return get_context ().new_call (*this,
|
|
1610 arg0,
|
|
1611 loc);
|
|
1612 }
|
|
1613 inline rvalue
|
|
1614 function::operator() (rvalue arg0, rvalue arg1,
|
|
1615 location loc)
|
|
1616 {
|
|
1617 return get_context ().new_call (*this,
|
|
1618 arg0, arg1,
|
|
1619 loc);
|
|
1620 }
|
|
1621 inline rvalue
|
|
1622 function::operator() (rvalue arg0, rvalue arg1, rvalue arg2,
|
|
1623 location loc)
|
|
1624 {
|
|
1625 return get_context ().new_call (*this,
|
|
1626 arg0, arg1, arg2,
|
|
1627 loc);
|
|
1628 }
|
|
1629
|
|
1630 // class block
|
|
1631 inline block::block () : object () {}
|
|
1632 inline block::block (gcc_jit_block *inner)
|
|
1633 : object (gcc_jit_block_as_object (inner))
|
|
1634 {}
|
|
1635
|
|
1636 inline gcc_jit_block *
|
|
1637 block::get_inner_block () const
|
|
1638 {
|
|
1639 /* Manual downcast: */
|
|
1640 return reinterpret_cast<gcc_jit_block *> (get_inner_object ());
|
|
1641 }
|
|
1642
|
|
1643 // class rvalue
|
|
1644 inline rvalue::rvalue () : object () {}
|
|
1645 inline rvalue::rvalue (gcc_jit_rvalue *inner)
|
|
1646 : object (gcc_jit_rvalue_as_object (inner))
|
|
1647 {}
|
|
1648
|
|
1649 inline gcc_jit_rvalue *
|
|
1650 rvalue::get_inner_rvalue () const
|
|
1651 {
|
|
1652 /* Manual downcast: */
|
|
1653 return reinterpret_cast<gcc_jit_rvalue *> (get_inner_object ());
|
|
1654 }
|
|
1655
|
|
1656 inline type
|
|
1657 rvalue::get_type ()
|
|
1658 {
|
|
1659 return type (gcc_jit_rvalue_get_type (get_inner_rvalue ()));
|
|
1660 }
|
|
1661
|
|
1662 inline rvalue
|
|
1663 rvalue::access_field (field field,
|
|
1664 location loc)
|
|
1665 {
|
|
1666 return rvalue (gcc_jit_rvalue_access_field (get_inner_rvalue (),
|
|
1667 loc.get_inner_location (),
|
|
1668 field.get_inner_field ()));
|
|
1669 }
|
|
1670
|
|
1671 inline lvalue
|
|
1672 rvalue::dereference_field (field field,
|
|
1673 location loc)
|
|
1674 {
|
|
1675 return lvalue (gcc_jit_rvalue_dereference_field (get_inner_rvalue (),
|
|
1676 loc.get_inner_location (),
|
|
1677 field.get_inner_field ()));
|
|
1678 }
|
|
1679
|
|
1680 inline lvalue
|
|
1681 rvalue::dereference (location loc)
|
|
1682 {
|
|
1683 return lvalue (gcc_jit_rvalue_dereference (get_inner_rvalue (),
|
|
1684 loc.get_inner_location ()));
|
|
1685 }
|
|
1686
|
|
1687 inline rvalue
|
|
1688 rvalue::cast_to (type type_,
|
|
1689 location loc)
|
|
1690 {
|
|
1691 return get_context ().new_cast (*this, type_, loc);
|
|
1692 }
|
|
1693
|
|
1694 inline lvalue
|
|
1695 rvalue::operator[] (rvalue index)
|
|
1696 {
|
|
1697 return get_context ().new_array_access (*this, index);
|
|
1698 }
|
|
1699
|
|
1700 inline lvalue
|
|
1701 rvalue::operator[] (int index)
|
|
1702 {
|
|
1703 context ctxt = get_context ();
|
|
1704 type int_t = ctxt.get_int_type <int> ();
|
|
1705 return ctxt.new_array_access (*this,
|
|
1706 ctxt.new_rvalue (int_t,
|
|
1707 index));
|
|
1708 }
|
|
1709
|
|
1710 // class lvalue : public rvalue
|
|
1711 inline lvalue::lvalue () : rvalue () {}
|
|
1712 inline lvalue::lvalue (gcc_jit_lvalue *inner)
|
|
1713 : rvalue (gcc_jit_lvalue_as_rvalue (inner))
|
|
1714 {}
|
|
1715
|
|
1716 inline gcc_jit_lvalue *
|
|
1717 lvalue::get_inner_lvalue () const
|
|
1718 {
|
|
1719 /* Manual downcast: */
|
|
1720 return reinterpret_cast<gcc_jit_lvalue *> (get_inner_object ());
|
|
1721 }
|
|
1722
|
|
1723 inline lvalue
|
|
1724 lvalue::access_field (field field, location loc)
|
|
1725 {
|
|
1726 return lvalue (gcc_jit_lvalue_access_field (get_inner_lvalue (),
|
|
1727 loc.get_inner_location (),
|
|
1728 field.get_inner_field ()));
|
|
1729 }
|
|
1730
|
|
1731 inline rvalue
|
|
1732 lvalue::get_address (location loc)
|
|
1733 {
|
|
1734 return rvalue (gcc_jit_lvalue_get_address (get_inner_lvalue (),
|
|
1735 loc.get_inner_location ()));
|
|
1736 }
|
|
1737
|
|
1738 // class param : public lvalue
|
|
1739 inline param::param () : lvalue () {}
|
|
1740 inline param::param (gcc_jit_param *inner)
|
|
1741 : lvalue (gcc_jit_param_as_lvalue (inner))
|
|
1742 {}
|
|
1743
|
|
1744 // class case_ : public object
|
|
1745 inline case_::case_ () : object () {}
|
|
1746 inline case_::case_ (gcc_jit_case *inner)
|
|
1747 : object (gcc_jit_case_as_object (inner))
|
|
1748 {
|
|
1749 }
|
|
1750
|
|
1751 inline gcc_jit_case *
|
|
1752 case_::get_inner_case () const
|
|
1753 {
|
|
1754 /* Manual downcast: */
|
|
1755 return reinterpret_cast<gcc_jit_case *> (get_inner_object ());
|
|
1756 }
|
|
1757
|
|
1758 /* Overloaded operators. */
|
|
1759 // Unary operators
|
|
1760 inline rvalue operator- (rvalue a)
|
|
1761 {
|
|
1762 return a.get_context ().new_minus (a.get_type (), a);
|
|
1763 }
|
|
1764 inline rvalue operator~ (rvalue a)
|
|
1765 {
|
|
1766 return a.get_context ().new_bitwise_negate (a.get_type (), a);
|
|
1767 }
|
|
1768 inline rvalue operator! (rvalue a)
|
|
1769 {
|
|
1770 return a.get_context ().new_logical_negate (a.get_type (), a);
|
|
1771 }
|
|
1772
|
|
1773 // Binary operators
|
|
1774 inline rvalue operator+ (rvalue a, rvalue b)
|
|
1775 {
|
|
1776 return a.get_context ().new_plus (a.get_type (), a, b);
|
|
1777 }
|
|
1778 inline rvalue operator- (rvalue a, rvalue b)
|
|
1779 {
|
|
1780 return a.get_context ().new_minus (a.get_type (), a, b);
|
|
1781 }
|
|
1782 inline rvalue operator* (rvalue a, rvalue b)
|
|
1783 {
|
|
1784 return a.get_context ().new_mult (a.get_type (), a, b);
|
|
1785 }
|
|
1786 inline rvalue operator/ (rvalue a, rvalue b)
|
|
1787 {
|
|
1788 return a.get_context ().new_divide (a.get_type (), a, b);
|
|
1789 }
|
|
1790 inline rvalue operator% (rvalue a, rvalue b)
|
|
1791 {
|
|
1792 return a.get_context ().new_modulo (a.get_type (), a, b);
|
|
1793 }
|
|
1794 inline rvalue operator& (rvalue a, rvalue b)
|
|
1795 {
|
|
1796 return a.get_context ().new_bitwise_and (a.get_type (), a, b);
|
|
1797 }
|
|
1798 inline rvalue operator^ (rvalue a, rvalue b)
|
|
1799 {
|
|
1800 return a.get_context ().new_bitwise_xor (a.get_type (), a, b);
|
|
1801 }
|
|
1802 inline rvalue operator| (rvalue a, rvalue b)
|
|
1803 {
|
|
1804 return a.get_context ().new_bitwise_or (a.get_type (), a, b);
|
|
1805 }
|
|
1806 inline rvalue operator&& (rvalue a, rvalue b)
|
|
1807 {
|
|
1808 return a.get_context ().new_logical_and (a.get_type (), a, b);
|
|
1809 }
|
|
1810 inline rvalue operator|| (rvalue a, rvalue b)
|
|
1811 {
|
|
1812 return a.get_context ().new_logical_or (a.get_type (), a, b);
|
|
1813 }
|
|
1814
|
|
1815 /* Comparisons. */
|
|
1816 inline rvalue operator== (rvalue a, rvalue b)
|
|
1817 {
|
|
1818 return a.get_context ().new_eq (a, b);
|
|
1819 }
|
|
1820 inline rvalue operator!= (rvalue a, rvalue b)
|
|
1821 {
|
|
1822 return a.get_context ().new_ne (a, b);
|
|
1823 }
|
|
1824 inline rvalue operator< (rvalue a, rvalue b)
|
|
1825 {
|
|
1826 return a.get_context ().new_lt (a, b);
|
|
1827 }
|
|
1828 inline rvalue operator<= (rvalue a, rvalue b)
|
|
1829 {
|
|
1830 return a.get_context ().new_le (a, b);
|
|
1831 }
|
|
1832 inline rvalue operator> (rvalue a, rvalue b)
|
|
1833 {
|
|
1834 return a.get_context ().new_gt (a, b);
|
|
1835 }
|
|
1836 inline rvalue operator>= (rvalue a, rvalue b)
|
|
1837 {
|
|
1838 return a.get_context ().new_ge (a, b);
|
|
1839 }
|
|
1840
|
|
1841 /* Dereferencing. */
|
|
1842 inline lvalue operator* (rvalue ptr)
|
|
1843 {
|
|
1844 return ptr.dereference ();
|
|
1845 }
|
|
1846
|
|
1847 // class timer
|
|
1848 inline
|
|
1849 timer::timer ()
|
|
1850 {
|
|
1851 m_inner_timer = gcc_jit_timer_new ();
|
|
1852 }
|
|
1853
|
|
1854 inline
|
|
1855 timer::timer (gcc_jit_timer *inner_timer)
|
|
1856 {
|
|
1857 m_inner_timer = inner_timer;
|
|
1858 }
|
|
1859
|
|
1860 inline void
|
|
1861 timer::push (const char *item_name)
|
|
1862 {
|
|
1863 gcc_jit_timer_push (m_inner_timer, item_name);
|
|
1864
|
|
1865 }
|
|
1866
|
|
1867 inline void
|
|
1868 timer::pop (const char *item_name)
|
|
1869 {
|
|
1870 gcc_jit_timer_pop (m_inner_timer, item_name);
|
|
1871 }
|
|
1872
|
|
1873 inline void
|
|
1874 timer::print (FILE *f_out) const
|
|
1875 {
|
|
1876 gcc_jit_timer_print (m_inner_timer, f_out);
|
|
1877 }
|
|
1878
|
|
1879 inline gcc_jit_timer *
|
|
1880 timer::get_inner_timer () const
|
|
1881 {
|
|
1882 return m_inner_timer;
|
|
1883 }
|
|
1884
|
|
1885 inline void
|
|
1886 timer::release ()
|
|
1887 {
|
|
1888 gcc_jit_timer_release (m_inner_timer);
|
|
1889 m_inner_timer = NULL;
|
|
1890 }
|
|
1891
|
|
1892 // class auto_time
|
|
1893
|
|
1894 inline
|
|
1895 auto_time::auto_time (timer t, const char *item_name)
|
|
1896 : m_timer (t),
|
|
1897 m_item_name (item_name)
|
|
1898 {
|
|
1899 t.push (item_name);
|
|
1900 }
|
|
1901
|
|
1902 inline
|
|
1903 auto_time::auto_time (context ctxt, const char *item_name)
|
|
1904 : m_timer (ctxt.get_timer ()),
|
|
1905 m_item_name (item_name)
|
|
1906 {
|
|
1907 m_timer.push (item_name);
|
|
1908 }
|
|
1909
|
|
1910 inline
|
|
1911 auto_time::~auto_time ()
|
|
1912 {
|
|
1913 m_timer.pop (m_item_name);
|
|
1914 }
|
|
1915
|
|
1916 } // namespace gccjit
|
|
1917
|
|
1918 #endif /* #ifndef LIBGCCJIT_PLUS_PLUS_H */
|