aboutsummaryrefslogtreecommitdiff
path: root/gcc/d/d-tree.h
blob: 7a54dfbc59eac8b1405c7a7621bb046780010f98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
/* d-tree.h -- Definitions and declarations for code generation.
   Copyright (C) 2006-2019 Free Software Foundation, Inc.

GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.

GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.  */

#ifndef GCC_D_TREE_H
#define GCC_D_TREE_H

/* Forward type declarations to avoid including unnecessary headers.  */

class Dsymbol;
class Declaration;
class AggregateDeclaration;
class ClassDeclaration;
class EnumDeclaration;
class FuncDeclaration;
class StructDeclaration;
class TypeInfoDeclaration;
class VarDeclaration;
class UserAttributeDeclaration;
class Expression;
class ClassReferenceExp;
class Module;
class Statement;
class Type;
class TypeFunction;
class Parameter;
struct BaseClass;
struct Scope;
struct Loc;

template <typename TYPE> struct Array;
typedef Array<Expression *> Expressions;

/* Usage of TREE_LANG_FLAG_?:
   0: METHOD_CALL_EXPR
   1: CALL_EXPR_ARGS_ORDERED (in CALL_EXPR).

   Usage of TYPE_LANG_FLAG_?:
   0: TYPE_SHARED
   1: TYPE_IMAGINARY_FLOAT (in REAL_TYPE).
      ANON_AGGR_TYPE_P (in RECORD_TYPE, UNION_TYPE).
   2: CLASS_TYPE_P (in RECORD_TYPE).
   3: TYPE_DYNAMIC_ARRAY (in RECORD_TYPE).
   4: TYPE_DELEGATE (in RECORD_TYPE).
   5: TYPE_ASSOCIATIVE_ARRAY (in RECORD_TYPE).

   Usage of DECL_LANG_FLAG_?:
   0: LABEL_VARIABLE_CASE (in LABEL_DECL).
      DECL_BUILT_IN_CTFE (in FUNCTION_DECL).
   1: DECL_IN_UNITTEST_CONDITION_P (in FUNCTION_DECL).  */

/* The kinds of scopes we recognize.  */

enum level_kind
{
  level_block,		/* An ordinary block scope.  */
  level_try,		/* A try-block.  */
  level_catch,		/* A catch-block.  */
  level_finally,	/* A finally-block.  */
  level_cond,		/* The scope for an if condition.  */
  level_switch,		/* The scope for a switch statement.  */
  level_loop,		/* A for, do-while, or unrolled-loop block.  */
  level_with,		/* The scope for a with statement.  */
  level_function	/* The block representing an entire function.  */
};

/* List of codes for internally recognised compiler intrinsics.  */

enum intrinsic_code
{
#define DEF_D_INTRINSIC(CODE, A, N, M, D, C) INTRINSIC_ ## CODE,

#include "intrinsics.def"

#undef DEF_D_INTRINSIC
  INTRINSIC_LAST
};

/* For use with break and continue statements.  */

enum bc_kind
{
  bc_break    = 0,
  bc_continue = 1
};

/* The datatype used to implement D scope.  It is needed primarily to support
   the back-end, but also helps debugging information for local variables.  */

struct GTY((chain_next ("%h.level_chain"))) binding_level
{
  /* A chain of declarations for all variables, constants and functions.
     These are in the reverse of the order supplied.  */
  tree names;

  /* For each level (except the global one), a chain of BLOCK nodes for
     all the levels that were entered and exited one level down.  */
  tree blocks;

  /* The binding level this one is contained in.  */
  binding_level *level_chain;

  /* The kind of scope this object represents.  */
  ENUM_BITFIELD (level_kind) kind : 4;
};

/* The binding level currently in effect.  */
extern GTY(()) binding_level *current_binding_level;
extern GTY(()) binding_level *global_binding_level;

/* Used only for jumps to as-yet undefined labels, since jumps to
   defined labels can have their validity checked immediately.  */

struct GTY((chain_next ("%h.next"))) d_label_use_entry
{
  d_label_use_entry *next;

  /* The frontend Statement associated with the jump.  */
  Statement * GTY((skip)) statement;

  /* The binding level to which this entry is *currently* attached.
     This is initially the binding level in which the goto appeared,
     but is modified as scopes are closed.  */
  binding_level *level;
};

/* A list of all LABEL_DECLs in the function that have names.  Here so
   we can clear out their names' definitions at the end of the
   function, and so we can check the validity of jumps to these labels.  */

struct GTY(()) d_label_entry
{
  /* The label decl itself.  */
  tree label;

  /* The frontend Statement associated with the label.  */
  Statement * GTY((skip)) statement;

  /* The binding level to which the label is *currently* attached.
     This is initially set to the binding level in which the label
     is defined, but is modified as scopes are closed.  */
  binding_level *level;

  /* A list of forward references of the label.  */
  d_label_use_entry *fwdrefs;

  /* The following bits are set after the label is defined, and are
     updated as scopes are popped.  They indicate that a backward jump
     to the label will illegally enter a scope of the given flavor.  */
  bool in_try_scope;
  bool in_catch_scope;

  /* If set, the label we reference represents a break/continue pair.  */
  bool bc_label;
};

/* Frame information for a function declaration.  */

struct GTY(()) tree_frame_info
{
  struct tree_common common;
  tree frame_type;
};

/* True if the function creates a nested frame.  */
#define FRAMEINFO_CREATES_FRAME(NODE) \
  (TREE_LANG_FLAG_0 (FUNCFRAME_INFO_CHECK (NODE)))

/* True if the function has a static chain passed in its DECL_ARGUMENTS.  */
#define FRAMEINFO_STATIC_CHAIN(NODE) \
  (TREE_LANG_FLAG_1 (FUNCFRAME_INFO_CHECK (NODE)))

/* True if the function frame is a closure (initialized on the heap).  */
#define FRAMEINFO_IS_CLOSURE(NODE) \
  (TREE_LANG_FLAG_2 (FUNCFRAME_INFO_CHECK (NODE)))

#define FRAMEINFO_TYPE(NODE) \
  (((tree_frame_info *) FUNCFRAME_INFO_CHECK (NODE))->frame_type)

/* Language-dependent contents of an identifier.  */

struct GTY(()) lang_identifier
{
  struct tree_identifier common;

  /* The identifier as the user sees it.  */
  tree pretty_ident;

  /* The back-end tree associated with this identifier.  */
  tree decl_tree;

  /* The frontend Declaration associated with this identifier.  */
  Declaration * GTY((skip)) dsymbol;
};

#define IDENTIFIER_LANG_SPECIFIC(NODE) \
  ((struct lang_identifier *) IDENTIFIER_NODE_CHECK (NODE))

#define IDENTIFIER_PRETTY_NAME(NODE) \
  (IDENTIFIER_LANG_SPECIFIC (NODE)->pretty_ident)

#define IDENTIFIER_DECL_TREE(NODE) \
  (IDENTIFIER_LANG_SPECIFIC (NODE)->decl_tree)

#define IDENTIFIER_DSYMBOL(NODE) \
  (IDENTIFIER_LANG_SPECIFIC (NODE)->dsymbol)

/* Global state pertinent to the current function.  */

struct GTY(()) language_function
{
  /* Our function and enclosing module.  */
  FuncDeclaration * GTY((skip)) function;
  Module * GTY((skip)) module;

  /* Static chain of function, for D2, this is a closure.  */
  tree static_chain;

  /* Stack of statement lists being collected while we are
     compiling the function.  */
  vec<tree, va_gc> *stmt_list;

  /* Variables that are in scope that will need destruction later.  */
  vec<tree, va_gc> *vars_in_scope;

  /* Table of all used or defined labels in the function.  */
  hash_map<Statement *, d_label_entry> *labels;
};

/* The D front end types have not been integrated into the GCC garbage
   collection system.  Handle this by using the "skip" attribute.  */

struct GTY(()) lang_decl
{
  Declaration * GTY((skip)) decl;

  /* FIELD_DECL in frame struct that this variable is allocated in.  */
  tree frame_field;

  /* RESULT_DECL in a function that returns by nrvo.  */
  tree named_result;

  /* Chain of DECL_LANG_THUNKS in a function.  */
  tree thunks;

  /* In a FUNCTION_DECL, this is the THUNK_LANG_OFFSET.  */
  int offset;

  /* In a FUNCTION_DECL, if this is an intrinsic, the code for it.  */
  enum intrinsic_code intrinsic;

  /* FUNCFRAME_INFO in a function that has non-local references.  */
  tree frame_info;
};

/* The current D per-function global variables.  */

#define d_function_chain (cfun ? cfun->language : NULL)

/* The D frontend Declaration AST for GCC decl NODE.  */
#define DECL_LANG_FRONTEND(NODE) \
  (DECL_LANG_SPECIFIC (NODE) \
   ? DECL_LANG_SPECIFIC (NODE)->decl : NULL)

#define SET_DECL_LANG_FRAME_FIELD(NODE, VAL) \
  DECL_LANG_SPECIFIC (NODE)->frame_field = VAL

#define DECL_LANG_FRAME_FIELD(NODE) \
  (DECL_P (NODE) \
   ? DECL_LANG_SPECIFIC (NODE)->frame_field : NULL)

#define SET_DECL_LANG_NRVO(NODE, VAL) \
  DECL_LANG_SPECIFIC (NODE)->named_result = VAL

#define DECL_LANG_NRVO(NODE) \
  (DECL_P (NODE) \
   ? DECL_LANG_SPECIFIC (NODE)->named_result : NULL)

#define DECL_LANG_THUNKS(NODE) \
  DECL_LANG_SPECIFIC (NODE)->thunks

#define THUNK_LANG_OFFSET(NODE) \
  DECL_LANG_SPECIFIC (NODE)->offset

#define DECL_INTRINSIC_CODE(NODE) \
  DECL_LANG_SPECIFIC (NODE)->intrinsic

#define DECL_LANG_FRAMEINFO(NODE) \
  DECL_LANG_SPECIFIC (NODE)->frame_info

/* The lang_type field is not set for every GCC type.  */

struct GTY(()) lang_type
{
  Type * GTY((skip)) type;
};

/* The D frontend Type AST for GCC type NODE.  */
#define TYPE_LANG_FRONTEND(NODE) \
  (TYPE_LANG_SPECIFIC (NODE) \
   ? TYPE_LANG_SPECIFIC (NODE)->type : NULL)


enum d_tree_node_structure_enum
{
  TS_D_GENERIC,
  TS_D_IDENTIFIER,
  TS_D_FRAMEINFO,
  LAST_TS_D_ENUM
};

/* The resulting tree type.  */

union GTY((desc ("d_tree_node_structure (&%h)"),
	   chain_next ("CODE_CONTAINS_STRUCT (TREE_CODE (&%h.generic), TS_COMMON)"
		       " ? ((union lang_tree_node *) TREE_CHAIN (&%h.generic)) : NULL")))
lang_tree_node
{
  union tree_node GTY ((tag ("TS_D_GENERIC"),
			desc ("tree_node_structure (&%h)"))) generic;
  lang_identifier GTY ((tag ("TS_D_IDENTIFIER"))) identifier;
  tree_frame_info GTY ((tag ("TS_D_FRAMEINFO"))) frameinfo;
};

/* True if the Tdelegate typed expression is not really a variable,
   but a literal function / method reference.  */
#define METHOD_CALL_EXPR(NODE) \
  (TREE_LANG_FLAG_0 (NODE))

/* True if all arguments in a call expression should be evaluated in the
   order they are given (left to right).  */
#define CALL_EXPR_ARGS_ORDERED(NODE) \
  (TREE_LANG_FLAG_1 (CALL_EXPR_CHECK (NODE)))

/* True if the type was declared 'shared'.  */
#define TYPE_SHARED(NODE) \
  (TYPE_LANG_FLAG_0 (NODE))

/* True if the type is an imaginary float type.  */
#define TYPE_IMAGINARY_FLOAT(NODE) \
  (TYPE_LANG_FLAG_1 (REAL_TYPE_CHECK (NODE)))

/* True if the type is an anonymous record or union.  */
#define ANON_AGGR_TYPE_P(NODE) \
  (TYPE_LANG_FLAG_1 (RECORD_OR_UNION_CHECK (NODE)))

/* True if the type is the underlying record for a class.  */
#define CLASS_TYPE_P(NODE) \
  (TYPE_LANG_FLAG_2 (RECORD_TYPE_CHECK (NODE)))

/* True if the type is a D dynamic array.  */
#define TYPE_DYNAMIC_ARRAY(NODE) \
  (TYPE_LANG_FLAG_3 (RECORD_TYPE_CHECK (NODE)))

/* True if the type is a D delegate.  */
#define TYPE_DELEGATE(NODE) \
  (TYPE_LANG_FLAG_4 (RECORD_TYPE_CHECK (NODE)))

/* True if the type is a D associative array.  */
#define TYPE_ASSOCIATIVE_ARRAY(NODE) \
  (TYPE_LANG_FLAG_5 (RECORD_TYPE_CHECK (NODE)))

/* True if the decl is a variable case label decl.  */
#define LABEL_VARIABLE_CASE(NODE) \
  (DECL_LANG_FLAG_0 (LABEL_DECL_CHECK (NODE)))

/* True if the decl is a CTFE built-in.  */
#define DECL_BUILT_IN_CTFE(NODE) \
  (DECL_LANG_FLAG_0 (FUNCTION_DECL_CHECK (NODE)))

/* True if the decl is only compiled in when unittests are turned on.  */
#define DECL_IN_UNITTEST_CONDITION_P(NODE) \
  (DECL_LANG_FLAG_1 (FUNCTION_DECL_CHECK (NODE)))

enum d_tree_index
{
  DTI_VTABLE_ENTRY_TYPE,
  DTI_VTBL_PTR_TYPE,
  DTI_VTBL_INTERFACE_TYPE,

  DTI_BOOL_TYPE,
  DTI_CHAR_TYPE,
  DTI_WCHAR_TYPE,
  DTI_DCHAR_TYPE,

  DTI_BYTE_TYPE,
  DTI_UBYTE_TYPE,
  DTI_SHORT_TYPE,
  DTI_USHORT_TYPE,
  DTI_INT_TYPE,
  DTI_UINT_TYPE,
  DTI_LONG_TYPE,
  DTI_ULONG_TYPE,
  DTI_CENT_TYPE,
  DTI_UCENT_TYPE,

  DTI_IFLOAT_TYPE,
  DTI_IDOUBLE_TYPE,
  DTI_IREAL_TYPE,

  DTI_UNKNOWN_TYPE,

  DTI_ARRAY_TYPE,
  DTI_NULL_ARRAY,

  DTI_MAX
};

extern GTY(()) tree d_global_trees[DTI_MAX];

#define vtable_entry_type		d_global_trees[DTI_VTABLE_ENTRY_TYPE]
#define vtbl_ptr_type_node		d_global_trees[DTI_VTBL_PTR_TYPE]
#define vtbl_interface_type_node	d_global_trees[DTI_VTBL_INTERFACE_TYPE]
/* D built-in language types.  */
#define d_bool_type			d_global_trees[DTI_BOOL_TYPE]
#define d_byte_type			d_global_trees[DTI_BYTE_TYPE]
#define d_ubyte_type			d_global_trees[DTI_UBYTE_TYPE]
#define d_short_type			d_global_trees[DTI_SHORT_TYPE]
#define d_ushort_type			d_global_trees[DTI_USHORT_TYPE]
#define d_int_type			d_global_trees[DTI_INT_TYPE]
#define d_uint_type			d_global_trees[DTI_UINT_TYPE]
#define d_long_type			d_global_trees[DTI_LONG_TYPE]
#define d_ulong_type			d_global_trees[DTI_ULONG_TYPE]
#define d_cent_type			d_global_trees[DTI_CENT_TYPE]
#define d_ucent_type			d_global_trees[DTI_UCENT_TYPE]
/* Imaginary floating-point types.  */
#define ifloat_type_node		d_global_trees[DTI_IFLOAT_TYPE]
#define idouble_type_node		d_global_trees[DTI_IDOUBLE_TYPE]
#define ireal_type_node			d_global_trees[DTI_IREAL_TYPE]
/* UTF-8, 16 and 32 types.  */
#define char8_type_node			d_global_trees[DTI_CHAR_TYPE]
#define char16_type_node		d_global_trees[DTI_DCHAR_TYPE]
#define char32_type_node		d_global_trees[DTI_WCHAR_TYPE]
/* Empty record type used as placeholder when real type is unknown.  */
#define unknown_type_node		d_global_trees[DTI_UNKNOWN_TYPE]
/* Generic dynamic array type void[].  */
#define array_type_node			d_global_trees[DTI_ARRAY_TYPE]
/* Null initializer for dynamic arrays.  */
#define null_array_node			d_global_trees[DTI_NULL_ARRAY]

/* A prefix for internal variables, which are not user-visible.  */
#if !defined (NO_DOT_IN_LABEL)
# define GDC_PREFIX(x) "gdc." x
#elif !defined (NO_DOLLAR_IN_LABEL)
# define GDC_PREFIX(x) "gdc$" x
#else
# define GDC_PREFIX(x) "gdc_" x
#endif

/* Internally recognised D runtime library functions.  */

enum libcall_fn
{
#define DEF_D_RUNTIME(CODE, N, T, P, F) LIBCALL_ ## CODE,

#include "runtime.def"

#undef DEF_D_RUNTIME
  LIBCALL_LAST
};

/* Gate for when the D frontend makes an early call into the codegen pass, such
   as when it requires target information or CTFE evaluation.  As full semantic
   may not be completed, we only want to build the superficial tree structure
   without finishing any decls or types.  */
extern bool doing_semantic_analysis_p;

/* In d-attribs.c.  */
extern tree insert_type_attribute (tree, const char *, tree = NULL_TREE);
extern tree insert_decl_attribute (tree, const char *, tree = NULL_TREE);
extern tree build_attributes (Expressions *);

/* In d-builtins.cc.  */
extern const attribute_spec d_langhook_attribute_table[];
extern const attribute_spec d_langhook_common_attribute_table[];

extern tree d_builtin_function (tree);
extern void d_init_builtins (void);
extern void d_register_builtin_type (tree, const char *);
extern void d_build_builtins_module (Module *);
extern void d_maybe_set_builtin (Module *);
extern Expression *d_eval_constant_expression (tree);
extern void d_init_versions (void);

/* In d-codegen.cc.  */
extern location_t make_location_t (const Loc &);
extern tree d_decl_context (Dsymbol *);
extern tree copy_aggregate_type (tree);
extern bool declaration_reference_p (Declaration *);
extern tree declaration_type (Declaration *);
extern bool argument_reference_p (Parameter *);
extern tree type_passed_as (Parameter *);
extern tree build_integer_cst (dinteger_t, tree = d_int_type);
extern tree build_float_cst (const real_t &, Type *);
extern tree d_array_length (tree);
extern tree d_array_ptr (tree);
extern tree d_array_value (tree, tree, tree);
extern tree get_array_length (tree, Type *);
extern tree build_class_binfo (tree, ClassDeclaration *);
extern tree build_interface_binfo (tree, ClassDeclaration *, unsigned &);
extern tree delegate_method (tree);
extern tree delegate_object (tree);
extern tree build_delegate_cst (tree, tree, Type *);
extern tree build_method_call (tree, tree, Type *);
extern void extract_from_method_call (tree, tree &, tree &);
extern tree build_typeof_null_value (Type *);
extern tree build_vindex_ref (tree, tree, size_t);
extern tree d_save_expr (tree);
extern tree stabilize_expr (tree *);
extern tree build_target_expr (tree, tree);
extern tree force_target_expr (tree);
extern tree build_address (tree);
extern tree d_mark_addressable (tree);
extern tree d_mark_used (tree);
extern tree d_mark_read (tree);
extern bool identity_compare_p (StructDeclaration *);
extern tree build_float_identity (tree_code, tree, tree);
extern tree build_struct_comparison (tree_code, StructDeclaration *,
				     tree, tree);
extern tree build_array_struct_comparison (tree_code, StructDeclaration *,
					   tree, tree, tree);
extern tree build_struct_literal (tree, vec<constructor_elt, va_gc> *);
extern tree component_ref (tree, tree);
extern tree build_assign (tree_code, tree, tree);
extern tree modify_expr (tree, tree);
extern tree build_nop (tree, tree);
extern tree build_vconvert (tree, tree);
extern tree build_boolop (tree_code, tree, tree);
extern tree build_condition (tree, tree, tree, tree);
extern tree build_vcondition (tree, tree, tree);
extern tree compound_expr (tree, tree);
extern tree return_expr (tree);
extern tree size_mult_expr (tree, tree);
extern tree real_part (tree);
extern tree imaginary_part (tree);
extern tree complex_expr (tree, tree, tree);
extern tree indirect_ref (tree, tree);
extern tree build_deref (tree);
extern tree build_array_index (tree, tree);
extern tree build_offset_op (tree_code, tree, tree);
extern tree build_offset (tree, tree);
extern tree build_memref (tree, tree, tree);
extern tree build_array_set (tree, tree, tree);
extern tree build_array_from_val (Type *, tree);
extern tree void_okay_p (tree);
extern tree build_bounds_condition (const Loc &, tree, tree, bool);
extern bool array_bounds_check (void);
extern tree bind_expr (tree, tree);
extern TypeFunction *get_function_type (Type *);
extern bool call_by_alias_p (FuncDeclaration *, FuncDeclaration *);
extern tree d_build_call_expr (FuncDeclaration *, tree, Expressions *);
extern tree d_build_call (TypeFunction *, tree, tree, Expressions *);
extern tree d_assert_call (const Loc &, libcall_fn, tree = NULL_TREE);
extern tree build_float_modulus (tree, tree, tree);
extern tree build_vthis_function (tree, tree);
extern tree get_frame_for_symbol (Dsymbol *);
extern tree build_vthis (AggregateDeclaration *);
extern void build_closure (FuncDeclaration *);
extern tree get_frameinfo (FuncDeclaration *);
extern tree get_framedecl (FuncDeclaration *, FuncDeclaration *);

/* In d-convert.cc.  */
extern bool decl_with_nonnull_addr_p (const_tree);
extern tree d_truthvalue_conversion (tree);
extern tree d_convert (tree, tree);
extern tree convert_expr (tree, Type *, Type *);
extern tree convert_for_assignment (tree, Type *, Type *);
extern tree convert_for_argument (tree, Parameter *);
extern tree convert_for_condition (tree, Type *);
extern tree d_array_convert (Expression *);
extern tree d_array_convert (Type *, Expression *);

/* In d-incpath.cc.  */
extern void add_import_paths (const char *, const char *, bool);

/* In d-lang.cc.  */
extern void d_add_builtin_module (Module *);
extern void d_add_entrypoint_module (Module *, Module *);
extern d_tree_node_structure_enum d_tree_node_structure (lang_tree_node *);
extern struct lang_type *build_lang_type (Type *);
extern struct lang_decl *build_lang_decl (Declaration *);
extern tree d_pushdecl (tree);
extern tree d_unsigned_type (tree);
extern tree d_signed_type (tree);
extern void d_keep (tree);

/* In decl.cc.  */
extern tree mangle_internal_decl (Dsymbol *, const char *, const char *);
extern void build_decl_tree (Dsymbol *);
extern tree get_symbol_decl (Declaration *);
extern tree declare_extern_var (tree, tree);
extern void declare_local_var (VarDeclaration *);
extern tree build_local_temp (tree);
extern tree get_decl_tree (Declaration *);
extern void d_finish_decl (tree);
extern tree make_thunk (FuncDeclaration *, int);
extern tree start_function (FuncDeclaration *);
extern void finish_function (tree);
extern void mark_needed (tree);
extern unsigned base_vtable_offset (ClassDeclaration *, BaseClass *);
extern tree get_vtable_decl (ClassDeclaration *);
extern tree build_new_class_expr (ClassReferenceExp *);
extern tree aggregate_initializer_decl (AggregateDeclaration *);
extern tree layout_struct_initializer (StructDeclaration *);
extern tree layout_class_initializer (ClassDeclaration *);
extern tree enum_initializer_decl (EnumDeclaration *);
extern tree build_artificial_decl (tree, tree, const char * = NULL);
extern tree create_field_decl (tree, const char *, int, int);
extern void build_type_decl (tree, Dsymbol *);
extern void d_comdat_linkage (tree);
extern void d_linkonce_linkage (tree);

/* In expr.cc.  */
extern tree build_expr (Expression *, bool = false);
extern tree build_expr_dtor (Expression *);
extern tree build_return_dtor (Expression *, Type *, TypeFunction *);

/* In imports.cc.  */
extern tree build_import_decl (Dsymbol *);

/* In intrinsics.cc.  */
extern void maybe_set_intrinsic (FuncDeclaration *);
extern tree maybe_expand_intrinsic (tree);

/* In modules.cc.  */
extern void build_module_tree (Module *);
extern tree d_module_context (void);
extern void register_module_decl (Declaration *);
extern void d_finish_compilation (tree *, int);

/* In runtime.cc.  */
extern tree build_libcall (libcall_fn, Type *, int ...);

/* In typeinfo.cc.  */
extern bool have_typeinfo_p (ClassDeclaration *);
extern tree layout_typeinfo (TypeInfoDeclaration *);
extern tree layout_classinfo (ClassDeclaration *);
extern tree get_typeinfo_decl (TypeInfoDeclaration *);
extern tree get_classinfo_decl (ClassDeclaration *);
extern tree build_typeinfo (const Loc &, Type *);
extern void create_typeinfo (Type *, Module *);
extern void create_tinfo_types (Module *);
extern void layout_cpp_typeinfo (ClassDeclaration *);
extern tree get_cpp_typeinfo_decl (ClassDeclaration *);
extern bool speculative_type_p (Type *);

/* In toir.cc.  */
extern void push_binding_level (level_kind);
extern tree pop_binding_level (void);
extern void push_stmt_list (void);
extern tree pop_stmt_list (void);
extern void add_stmt (tree);
extern void build_function_body (FuncDeclaration *);

/* In types.cc.  */
extern bool valist_array_p (Type *);
extern bool empty_aggregate_p (tree);
extern bool same_type_p (Type *, Type *);
extern Type *get_object_type (void);
extern tree make_array_type (Type *, unsigned HOST_WIDE_INT);
extern tree make_struct_type (const char *, int n, ...);
extern tree insert_type_modifiers (tree, unsigned);
extern void insert_aggregate_field (tree, tree, size_t);
extern void finish_aggregate_type (unsigned, unsigned, tree,
				   UserAttributeDeclaration *);
extern tree build_ctype (Type *);

#endif  /* GCC_D_TREE_H  */