| 1 |
/* d-tree.h -- Definitions and declarations for code generation. |
| 2 |
Copyright (C) 2006-2025 Free Software Foundation, Inc. |
| 3 |
|
| 4 |
GCC 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, or (at your option) |
| 7 |
any later version. |
| 8 |
|
| 9 |
GCC 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. |
| 13 |
|
| 14 |
You should have received a copy of the GNU General Public License |
| 15 |
along with GCC; see the file COPYING3. If not see |
| 16 |
<http://www.gnu.org/licenses/>. */ |
| 17 |
|
| 18 |
#ifndef GCC_D_TREE_H |
| 19 |
#define GCC_D_TREE_H |
| 20 |
|
| 21 |
/* Forward type declarations to avoid including unnecessary headers. */ |
| 22 |
|
| 23 |
class Dsymbol; |
| 24 |
class Declaration; |
| 25 |
class AggregateDeclaration; |
| 26 |
class ClassDeclaration; |
| 27 |
class EnumDeclaration; |
| 28 |
class FuncDeclaration; |
| 29 |
class StructDeclaration; |
| 30 |
class TypeInfoDeclaration; |
| 31 |
class VarDeclaration; |
| 32 |
class Expression; |
| 33 |
class ClassReferenceExp; |
| 34 |
class IndexExp; |
| 35 |
class SliceExp; |
| 36 |
class Module; |
| 37 |
class Statement; |
| 38 |
class Type; |
| 39 |
class TypeFunction; |
| 40 |
class Parameter; |
| 41 |
struct BaseClass; |
| 42 |
struct Scope; |
| 43 |
struct Loc; |
| 44 |
|
| 45 |
template <typename TYPE> struct Array; |
| 46 |
typedef Array <Expression *> Expressions; |
| 47 |
|
| 48 |
/* Usage of TREE_LANG_FLAG_?: |
| 49 |
0: METHOD_CALL_EXPR |
| 50 |
1: CALL_EXPR_WARN_IF_UNUSED (in CALL_EXPR). |
| 51 |
|
| 52 |
Usage of TYPE_LANG_FLAG_?: |
| 53 |
0: TYPE_SHARED |
| 54 |
1: TYPE_IMAGINARY_FLOAT (in REAL_TYPE). |
| 55 |
ANON_AGGR_TYPE_P (in RECORD_TYPE, UNION_TYPE). |
| 56 |
2: CLASS_TYPE_P (in RECORD_TYPE). |
| 57 |
3: TYPE_DYNAMIC_ARRAY (in RECORD_TYPE). |
| 58 |
4: TYPE_DELEGATE (in RECORD_TYPE). |
| 59 |
5: TYPE_ASSOCIATIVE_ARRAY (in RECORD_TYPE). |
| 60 |
|
| 61 |
Usage of TYPE_LANG_SLOT_?: |
| 62 |
1: TYPE_FORWARD_REFERENCES (in RECORD_TYPE, UNION_TYPE). |
| 63 |
|
| 64 |
Usage of DECL_LANG_FLAG_?: |
| 65 |
0: LABEL_VARIABLE_CASE (in LABEL_DECL). |
| 66 |
DECL_BUILT_IN_CTFE (in FUNCTION_DECL). |
| 67 |
1: DECL_IN_UNITTEST_CONDITION_P (in FUNCTION_DECL). |
| 68 |
2: DECL_INSTANTIATED (in FUNCTION_DECL, VAR_DECL). */ |
| 69 |
|
| 70 |
/* Language-specific tree checkers. */ |
| 71 |
|
| 72 |
#define VAR_OR_FUNCTION_DECL_CHECK(NODE) \ |
| 73 |
TREE_CHECK2 (NODE, VAR_DECL, FUNCTION_DECL) |
| 74 |
|
| 75 |
#define AGGREGATE_OR_ENUM_TYPE_CHECK(NODE) \ |
| 76 |
TREE_CHECK4 (NODE, RECORD_TYPE, UNION_TYPE, \ |
| 77 |
QUAL_UNION_TYPE, ENUMERAL_TYPE) |
| 78 |
|
| 79 |
/* The kinds of scopes we recognize. */ |
| 80 |
|
| 81 |
enum level_kind |
| 82 |
{ |
| 83 |
level_block, /* An ordinary block scope. */ |
| 84 |
level_try, /* A try-block. */ |
| 85 |
level_catch, /* A catch-block. */ |
| 86 |
level_finally, /* A finally-block. */ |
| 87 |
level_cond, /* The scope for an if condition. */ |
| 88 |
level_switch, /* The scope for a switch statement. */ |
| 89 |
level_loop, /* A for, do-while, or unrolled-loop block. */ |
| 90 |
level_with, /* The scope for a with statement. */ |
| 91 |
level_function /* The block representing an entire function. */ |
| 92 |
}; |
| 93 |
|
| 94 |
/* List of codes for internally recognised compiler intrinsics. */ |
| 95 |
|
| 96 |
enum intrinsic_code |
| 97 |
{ |
| 98 |
#define DEF_D_INTRINSIC(CODE, B, N, M, D, C, F) CODE, |
| 99 |
|
| 100 |
#include "intrinsics.def" |
| 101 |
|
| 102 |
#undef DEF_D_INTRINSIC |
| 103 |
INTRINSIC_LAST |
| 104 |
}; |
| 105 |
|
| 106 |
/* For use with break and continue statements. */ |
| 107 |
|
| 108 |
enum bc_kind |
| 109 |
{ |
| 110 |
bc_break = 0, |
| 111 |
bc_continue = 1 |
| 112 |
}; |
| 113 |
|
| 114 |
/* The datatype used to implement D scope. It is needed primarily to support |
| 115 |
the back-end, but also helps debugging information for local variables. */ |
| 116 |
|
| 117 |
struct GTY((chain_next ("%h.level_chain"))) binding_level |
| 118 |
{ |
| 119 |
/* A chain of declarations for all variables, constants and functions. |
| 120 |
These are in the reverse of the order supplied. */ |
| 121 |
tree names; |
| 122 |
|
| 123 |
/* For each level (except the global one), a chain of BLOCK nodes for |
| 124 |
all the levels that were entered and exited one level down. */ |
| 125 |
tree blocks; |
| 126 |
|
| 127 |
/* The binding level this one is contained in. */ |
| 128 |
binding_level *level_chain; |
| 129 |
|
| 130 |
/* The kind of scope this object represents. */ |
| 131 |
ENUM_BITFIELD (level_kind) kind : 4; |
| 132 |
}; |
| 133 |
|
| 134 |
/* The binding level currently in effect. */ |
| 135 |
extern GTY(()) binding_level *current_binding_level; |
| 136 |
extern GTY(()) binding_level *global_binding_level; |
| 137 |
|
| 138 |
/* Used only for jumps to as-yet undefined labels, since jumps to |
| 139 |
defined labels can have their validity checked immediately. */ |
| 140 |
|
| 141 |
struct GTY((chain_next ("%h.next"))) d_label_use_entry |
| 142 |
{ |
| 143 |
d_label_use_entry *next; |
| 144 |
|
| 145 |
/* The frontend Statement associated with the jump. */ |
| 146 |
Statement * GTY((skip)) statement; |
| 147 |
|
| 148 |
/* The binding level to which this entry is *currently* attached. |
| 149 |
This is initially the binding level in which the goto appeared, |
| 150 |
but is modified as scopes are closed. */ |
| 151 |
binding_level *level; |
| 152 |
}; |
| 153 |
|
| 154 |
/* A list of all LABEL_DECLs in the function that have names. Here so |
| 155 |
we can clear out their names' definitions at the end of the |
| 156 |
function, and so we can check the validity of jumps to these labels. */ |
| 157 |
|
| 158 |
struct GTY(()) d_label_entry |
| 159 |
{ |
| 160 |
/* The label decl itself. */ |
| 161 |
tree label; |
| 162 |
|
| 163 |
/* The frontend Statement associated with the label. */ |
| 164 |
Statement * GTY((skip)) statement; |
| 165 |
|
| 166 |
/* The binding level to which the label is *currently* attached. |
| 167 |
This is initially set to the binding level in which the label |
| 168 |
is defined, but is modified as scopes are closed. */ |
| 169 |
binding_level *level; |
| 170 |
|
| 171 |
/* A list of forward references of the label. */ |
| 172 |
d_label_use_entry *fwdrefs; |
| 173 |
|
| 174 |
/* The following bits are set after the label is defined, and are |
| 175 |
updated as scopes are popped. They indicate that a backward jump |
| 176 |
to the label will illegally enter a scope of the given flavor. */ |
| 177 |
bool in_try_scope; |
| 178 |
bool in_catch_scope; |
| 179 |
|
| 180 |
/* If set, the label we reference represents a break/continue pair. */ |
| 181 |
bool bc_label; |
| 182 |
}; |
| 183 |
|
| 184 |
/* Frame information for a function declaration. */ |
| 185 |
|
| 186 |
struct GTY(()) tree_frame_info |
| 187 |
{ |
| 188 |
struct tree_common common; |
| 189 |
tree frame_type; |
| 190 |
}; |
| 191 |
|
| 192 |
/* True if the function creates a nested frame. */ |
| 193 |
#define FRAMEINFO_CREATES_FRAME(NODE) \ |
| 194 |
(TREE_LANG_FLAG_0 (FUNCFRAME_INFO_CHECK (NODE))) |
| 195 |
|
| 196 |
/* True if the function has a static chain passed in its DECL_ARGUMENTS. */ |
| 197 |
#define FRAMEINFO_STATIC_CHAIN(NODE) \ |
| 198 |
(TREE_LANG_FLAG_1 (FUNCFRAME_INFO_CHECK (NODE))) |
| 199 |
|
| 200 |
/* True if the function frame is a closure (initialized on the heap). */ |
| 201 |
#define FRAMEINFO_IS_CLOSURE(NODE) \ |
| 202 |
(TREE_LANG_FLAG_2 (FUNCFRAME_INFO_CHECK (NODE))) |
| 203 |
|
| 204 |
#define FRAMEINFO_TYPE(NODE) \ |
| 205 |
(((tree_frame_info *) FUNCFRAME_INFO_CHECK (NODE))->frame_type) |
| 206 |
|
| 207 |
/* Language-dependent contents of an identifier. */ |
| 208 |
|
| 209 |
struct GTY(()) lang_identifier |
| 210 |
{ |
| 211 |
struct tree_identifier common; |
| 212 |
|
| 213 |
/* The identifier as the user sees it. */ |
| 214 |
tree pretty_ident; |
| 215 |
|
| 216 |
/* The back-end tree associated with this identifier. */ |
| 217 |
tree decl_tree; |
| 218 |
|
| 219 |
/* The frontend Declaration associated with this identifier. */ |
| 220 |
Declaration * GTY((skip)) dsymbol; |
| 221 |
AggregateDeclaration * GTY((skip)) daggregate; |
| 222 |
}; |
| 223 |
|
| 224 |
#define IDENTIFIER_LANG_SPECIFIC(NODE) \ |
| 225 |
((struct lang_identifier *) IDENTIFIER_NODE_CHECK (NODE)) |
| 226 |
|
| 227 |
#define IDENTIFIER_PRETTY_NAME(NODE) \ |
| 228 |
(IDENTIFIER_LANG_SPECIFIC (NODE)->pretty_ident) |
| 229 |
|
| 230 |
#define IDENTIFIER_DECL_TREE(NODE) \ |
| 231 |
(IDENTIFIER_LANG_SPECIFIC (NODE)->decl_tree) |
| 232 |
|
| 233 |
#define IDENTIFIER_DSYMBOL(NODE) \ |
| 234 |
(IDENTIFIER_LANG_SPECIFIC (NODE)->dsymbol) |
| 235 |
|
| 236 |
#define IDENTIFIER_DAGGREGATE(NODE) \ |
| 237 |
(IDENTIFIER_LANG_SPECIFIC (NODE)->daggregate) |
| 238 |
|
| 239 |
/* Global state pertinent to the current function. */ |
| 240 |
|
| 241 |
struct GTY(()) language_function |
| 242 |
{ |
| 243 |
/* Our function and enclosing module. */ |
| 244 |
FuncDeclaration * GTY((skip)) function; |
| 245 |
Module * GTY((skip)) module; |
| 246 |
|
| 247 |
/* Static chain of function, for D2, this is a closure. */ |
| 248 |
tree static_chain; |
| 249 |
|
| 250 |
/* Stack of statement lists being collected while we are |
| 251 |
compiling the function. */ |
| 252 |
vec <tree, va_gc> *stmt_list; |
| 253 |
|
| 254 |
/* Variables that are in scope that will need destruction later. */ |
| 255 |
vec <tree, va_gc> *vars_in_scope; |
| 256 |
|
| 257 |
/* Table of all used or defined labels in the function. */ |
| 258 |
hash_map <Statement *, d_label_entry> *labels; |
| 259 |
}; |
| 260 |
|
| 261 |
/* The D front end types have not been integrated into the GCC garbage |
| 262 |
collection system. Handle this by using the "skip" attribute. */ |
| 263 |
|
| 264 |
struct GTY(()) lang_decl |
| 265 |
{ |
| 266 |
Declaration * GTY((skip)) decl; |
| 267 |
|
| 268 |
/* FIELD_DECL in frame struct that this variable is allocated in. */ |
| 269 |
tree frame_field; |
| 270 |
|
| 271 |
/* RESULT_DECL in a function that returns by nrvo. */ |
| 272 |
tree named_result; |
| 273 |
|
| 274 |
/* Chain of DECL_LANG_THUNKS in a function. */ |
| 275 |
tree thunks; |
| 276 |
|
| 277 |
/* In a FUNCTION_DECL, this is the THUNK_LANG_OFFSET. */ |
| 278 |
int offset; |
| 279 |
|
| 280 |
/* In a FUNCTION_DECL, if this is an intrinsic, the code for it. */ |
| 281 |
enum intrinsic_code intrinsic; |
| 282 |
|
| 283 |
/* FUNCFRAME_INFO in a function that has non-local references. */ |
| 284 |
tree frame_info; |
| 285 |
}; |
| 286 |
|
| 287 |
/* The current D per-function global variables. */ |
| 288 |
|
| 289 |
#define d_function_chain (cfun ? cfun->language : NULL) |
| 290 |
|
| 291 |
/* The D frontend Declaration AST for GCC decl NODE. */ |
| 292 |
#define DECL_LANG_FRONTEND(NODE) \ |
| 293 |
(DECL_LANG_SPECIFIC (NODE) \ |
| 294 |
? DECL_LANG_SPECIFIC (NODE)->decl : NULL) |
| 295 |
|
| 296 |
#define SET_DECL_LANG_FRAME_FIELD(NODE, VAL) \ |
| 297 |
DECL_LANG_SPECIFIC (NODE)->frame_field = VAL |
| 298 |
|
| 299 |
#define DECL_LANG_FRAME_FIELD(NODE) \ |
| 300 |
(DECL_P (NODE) \ |
| 301 |
? DECL_LANG_SPECIFIC (NODE)->frame_field : NULL) |
| 302 |
|
| 303 |
#define SET_DECL_LANG_NRVO(NODE, VAL) \ |
| 304 |
DECL_LANG_SPECIFIC (NODE)->named_result = VAL |
| 305 |
|
| 306 |
#define DECL_LANG_NRVO(NODE) \ |
| 307 |
(DECL_P (NODE) \ |
| 308 |
? DECL_LANG_SPECIFIC (NODE)->named_result : NULL) |
| 309 |
|
| 310 |
#define DECL_LANG_THUNKS(NODE) \ |
| 311 |
DECL_LANG_SPECIFIC (NODE)->thunks |
| 312 |
|
| 313 |
#define THUNK_LANG_OFFSET(NODE) \ |
| 314 |
DECL_LANG_SPECIFIC (NODE)->offset |
| 315 |
|
| 316 |
#define DECL_INTRINSIC_CODE(NODE) \ |
| 317 |
DECL_LANG_SPECIFIC (NODE)->intrinsic |
| 318 |
|
| 319 |
#define DECL_LANG_FRAMEINFO(NODE) \ |
| 320 |
DECL_LANG_SPECIFIC (NODE)->frame_info |
| 321 |
|
| 322 |
/* The lang_type field is not set for every GCC type. */ |
| 323 |
|
| 324 |
struct GTY(()) lang_type |
| 325 |
{ |
| 326 |
Type * GTY((skip)) type; |
| 327 |
}; |
| 328 |
|
| 329 |
/* The D frontend Type AST for GCC type NODE. */ |
| 330 |
#define TYPE_LANG_FRONTEND(NODE) \ |
| 331 |
(TYPE_LANG_SPECIFIC (NODE) \ |
| 332 |
? TYPE_LANG_SPECIFIC (NODE)->type : NULL) |
| 333 |
|
| 334 |
|
| 335 |
enum d_tree_node_structure_enum |
| 336 |
{ |
| 337 |
TS_D_GENERIC, |
| 338 |
TS_D_IDENTIFIER, |
| 339 |
TS_D_FRAMEINFO, |
| 340 |
LAST_TS_D_ENUM |
| 341 |
}; |
| 342 |
|
| 343 |
/* The resulting tree type. */ |
| 344 |
|
| 345 |
union GTY((desc ("d_tree_node_structure (&%h)"), |
| 346 |
chain_next ("CODE_CONTAINS_STRUCT (TREE_CODE (&%h.generic), TS_COMMON)" |
| 347 |
" ? ((union lang_tree_node *) TREE_CHAIN (&%h.generic)) : NULL"))) |
| 348 |
lang_tree_node |
| 349 |
{ |
| 350 |
union tree_node GTY ((tag ("TS_D_GENERIC"), |
| 351 |
desc ("tree_node_structure (&%h)"))) generic; |
| 352 |
lang_identifier GTY ((tag ("TS_D_IDENTIFIER"))) identifier; |
| 353 |
tree_frame_info GTY ((tag ("TS_D_FRAMEINFO"))) frameinfo; |
| 354 |
}; |
| 355 |
|
| 356 |
/* True if the Tdelegate typed expression is not really a variable, |
| 357 |
but a literal function / method reference. */ |
| 358 |
#define METHOD_CALL_EXPR(NODE) \ |
| 359 |
(TREE_LANG_FLAG_0 (NODE)) |
| 360 |
|
| 361 |
/* True if the CALL_EXPR is free of side effects, and its return value |
| 362 |
should not be discarded. */ |
| 363 |
#define CALL_EXPR_WARN_IF_UNUSED(NODE) \ |
| 364 |
(TREE_LANG_FLAG_1 (CALL_EXPR_CHECK (NODE))) |
| 365 |
|
| 366 |
/* True if the type was declared 'shared'. */ |
| 367 |
#define TYPE_SHARED(NODE) \ |
| 368 |
(TYPE_LANG_FLAG_0 (NODE)) |
| 369 |
|
| 370 |
/* True if the type is an imaginary float type. */ |
| 371 |
#define TYPE_IMAGINARY_FLOAT(NODE) \ |
| 372 |
(TYPE_LANG_FLAG_1 (REAL_TYPE_CHECK (NODE))) |
| 373 |
|
| 374 |
/* True if the type is an anonymous record or union. */ |
| 375 |
#define ANON_AGGR_TYPE_P(NODE) \ |
| 376 |
(TYPE_LANG_FLAG_1 (RECORD_OR_UNION_CHECK (NODE))) |
| 377 |
|
| 378 |
/* True if the type is the underlying record for a class. */ |
| 379 |
#define CLASS_TYPE_P(NODE) \ |
| 380 |
(TYPE_LANG_FLAG_2 (RECORD_TYPE_CHECK (NODE))) |
| 381 |
|
| 382 |
/* True if the type is a D dynamic array. */ |
| 383 |
#define TYPE_DYNAMIC_ARRAY(NODE) \ |
| 384 |
(TYPE_LANG_FLAG_3 (RECORD_TYPE_CHECK (NODE))) |
| 385 |
|
| 386 |
/* True if the type is a D delegate. */ |
| 387 |
#define TYPE_DELEGATE(NODE) \ |
| 388 |
(TYPE_LANG_FLAG_4 (RECORD_TYPE_CHECK (NODE))) |
| 389 |
|
| 390 |
/* True if the type is a D associative array. */ |
| 391 |
#define TYPE_ASSOCIATIVE_ARRAY(NODE) \ |
| 392 |
(TYPE_LANG_FLAG_5 (RECORD_TYPE_CHECK (NODE))) |
| 393 |
|
| 394 |
/* In an incomplete RECORD_TYPE, UNION_TYPE, or ENUMERAL_TYPE, a list of field |
| 395 |
declarations whose type would be completed by completing that type. */ |
| 396 |
#define TYPE_FORWARD_REFERENCES(NODE) \ |
| 397 |
(TYPE_LANG_SLOT_1 (AGGREGATE_OR_ENUM_TYPE_CHECK (NODE))) |
| 398 |
|
| 399 |
/* True if the decl is a variable case label decl. */ |
| 400 |
#define LABEL_VARIABLE_CASE(NODE) \ |
| 401 |
(DECL_LANG_FLAG_0 (LABEL_DECL_CHECK (NODE))) |
| 402 |
|
| 403 |
/* True if the decl is a CTFE built-in. */ |
| 404 |
#define DECL_BUILT_IN_CTFE(NODE) \ |
| 405 |
(DECL_LANG_FLAG_0 (FUNCTION_DECL_CHECK (NODE))) |
| 406 |
|
| 407 |
/* True if the decl is only compiled in when unittests are turned on. */ |
| 408 |
#define DECL_IN_UNITTEST_CONDITION_P(NODE) \ |
| 409 |
(DECL_LANG_FLAG_1 (FUNCTION_DECL_CHECK (NODE))) |
| 410 |
|
| 411 |
/* True if the decl comes from a template instance. */ |
| 412 |
#define DECL_INSTANTIATED(NODE) \ |
| 413 |
(DECL_LANG_FLAG_2 (VAR_OR_FUNCTION_DECL_CHECK (NODE))) |
| 414 |
|
| 415 |
enum d_tree_index |
| 416 |
{ |
| 417 |
DTI_VTABLE_ENTRY_TYPE, |
| 418 |
DTI_VTBL_PTR_TYPE, |
| 419 |
DTI_VTBL_INTERFACE_TYPE, |
| 420 |
|
| 421 |
DTI_BOOL_TYPE, |
| 422 |
DTI_CHAR_TYPE, |
| 423 |
DTI_WCHAR_TYPE, |
| 424 |
DTI_DCHAR_TYPE, |
| 425 |
|
| 426 |
DTI_BYTE_TYPE, |
| 427 |
DTI_UBYTE_TYPE, |
| 428 |
DTI_SHORT_TYPE, |
| 429 |
DTI_USHORT_TYPE, |
| 430 |
DTI_INT_TYPE, |
| 431 |
DTI_UINT_TYPE, |
| 432 |
DTI_LONG_TYPE, |
| 433 |
DTI_ULONG_TYPE, |
| 434 |
DTI_CENT_TYPE, |
| 435 |
DTI_UCENT_TYPE, |
| 436 |
|
| 437 |
DTI_IFLOAT_TYPE, |
| 438 |
DTI_IDOUBLE_TYPE, |
| 439 |
DTI_IREAL_TYPE, |
| 440 |
|
| 441 |
DTI_UNKNOWN_TYPE, |
| 442 |
|
| 443 |
DTI_ARRAY_TYPE, |
| 444 |
DTI_NULL_ARRAY, |
| 445 |
DTI_BOTTOM_TYPE, |
| 446 |
|
| 447 |
DTI_BOOL_FALSE, |
| 448 |
DTI_BOOL_TRUE, |
| 449 |
|
| 450 |
DTI_MAX |
| 451 |
}; |
| 452 |
|
| 453 |
extern GTY(()) tree d_global_trees[DTI_MAX]; |
| 454 |
|
| 455 |
#define vtable_entry_type d_global_trees[DTI_VTABLE_ENTRY_TYPE] |
| 456 |
#define vtbl_ptr_type_node d_global_trees[DTI_VTBL_PTR_TYPE] |
| 457 |
#define vtbl_interface_type_node d_global_trees[DTI_VTBL_INTERFACE_TYPE] |
| 458 |
/* D built-in language types. */ |
| 459 |
#define d_bool_type d_global_trees[DTI_BOOL_TYPE] |
| 460 |
#define d_byte_type d_global_trees[DTI_BYTE_TYPE] |
| 461 |
#define d_ubyte_type d_global_trees[DTI_UBYTE_TYPE] |
| 462 |
#define d_short_type d_global_trees[DTI_SHORT_TYPE] |
| 463 |
#define d_ushort_type d_global_trees[DTI_USHORT_TYPE] |
| 464 |
#define d_int_type d_global_trees[DTI_INT_TYPE] |
| 465 |
#define d_uint_type d_global_trees[DTI_UINT_TYPE] |
| 466 |
#define d_long_type d_global_trees[DTI_LONG_TYPE] |
| 467 |
#define d_ulong_type d_global_trees[DTI_ULONG_TYPE] |
| 468 |
#define d_cent_type d_global_trees[DTI_CENT_TYPE] |
| 469 |
#define d_ucent_type d_global_trees[DTI_UCENT_TYPE] |
| 470 |
/* Imaginary floating-point types. */ |
| 471 |
#define ifloat_type_node d_global_trees[DTI_IFLOAT_TYPE] |
| 472 |
#define idouble_type_node d_global_trees[DTI_IDOUBLE_TYPE] |
| 473 |
#define ireal_type_node d_global_trees[DTI_IREAL_TYPE] |
| 474 |
/* UTF-8, 16 and 32 types. */ |
| 475 |
#define char8_type_node d_global_trees[DTI_CHAR_TYPE] |
| 476 |
#define char16_type_node d_global_trees[DTI_DCHAR_TYPE] |
| 477 |
#define char32_type_node d_global_trees[DTI_WCHAR_TYPE] |
| 478 |
/* Empty record type used as placeholder when real type is unknown. */ |
| 479 |
#define unknown_type_node d_global_trees[DTI_UNKNOWN_TYPE] |
| 480 |
/* Generic dynamic array type void[]. */ |
| 481 |
#define array_type_node d_global_trees[DTI_ARRAY_TYPE] |
| 482 |
/* Null initializer for dynamic arrays. */ |
| 483 |
#define null_array_node d_global_trees[DTI_NULL_ARRAY] |
| 484 |
/* The bottom type, referred to as `noreturn` in code. */ |
| 485 |
#define noreturn_type_node d_global_trees[DTI_BOTTOM_TYPE] |
| 486 |
/* D boolean values are always byte-sized, unlike boolean_type_node. */ |
| 487 |
#define d_bool_false_node d_global_trees[DTI_BOOL_FALSE] |
| 488 |
#define d_bool_true_node d_global_trees[DTI_BOOL_TRUE] |
| 489 |
|
| 490 |
/* A prefix for internal variables, which are not user-visible. */ |
| 491 |
#if !defined (NO_DOT_IN_LABEL) |
| 492 |
# define GDC_PREFIX(x) "gdc." x |
| 493 |
#elif !defined (NO_DOLLAR_IN_LABEL) |
| 494 |
# define GDC_PREFIX(x) "gdc$" x |
| 495 |
#else |
| 496 |
# define GDC_PREFIX(x) "gdc_" x |
| 497 |
#endif |
| 498 |
|
| 499 |
/* Internally recognised D runtime library functions. */ |
| 500 |
|
| 501 |
enum libcall_fn |
| 502 |
{ |
| 503 |
#define DEF_D_RUNTIME(CODE, N, T, P, F) LIBCALL_ ## CODE, |
| 504 |
|
| 505 |
#include "runtime.def" |
| 506 |
|
| 507 |
#undef DEF_D_RUNTIME |
| 508 |
LIBCALL_LAST |
| 509 |
}; |
| 510 |
|
| 511 |
/* Gate for when the D frontend makes an early call into the codegen pass, such |
| 512 |
as when it requires target information or CTFE evaluation. As full semantic |
| 513 |
may not be completed, we only want to build the superficial tree structure |
| 514 |
without finishing any decls or types. */ |
| 515 |
extern bool doing_semantic_analysis_p; |
| 516 |
|
| 517 |
/* In d-attribs.c. */ |
| 518 |
extern tree insert_type_attribute (tree, const char *, tree = NULL_TREE); |
| 519 |
extern tree insert_decl_attribute (tree, const char *, tree = NULL_TREE); |
| 520 |
extern void apply_user_attributes (Dsymbol *, tree); |
| 521 |
|
| 522 |
/* In d-builtins.cc. */ |
| 523 |
extern const struct scoped_attribute_specs d_langhook_gnu_attribute_table; |
| 524 |
extern const struct scoped_attribute_specs d_langhook_common_attribute_table; |
| 525 |
extern Type *build_frontend_type (tree); |
| 526 |
|
| 527 |
extern tree d_builtin_function (tree); |
| 528 |
extern tree d_builtin_function_ext_scope (tree); |
| 529 |
extern void d_init_builtins (void); |
| 530 |
extern void d_register_builtin_type (tree, const char *); |
| 531 |
extern void d_build_builtins_module (Module *); |
| 532 |
extern void d_maybe_set_builtin (Module *); |
| 533 |
extern Expression *d_eval_constant_expression (const Loc &, tree); |
| 534 |
extern void d_init_versions (void); |
| 535 |
|
| 536 |
/* In d-codegen.cc. */ |
| 537 |
extern location_t make_location_t (const SourceLoc &); |
| 538 |
extern location_t make_location_t (const Loc); |
| 539 |
extern tree d_decl_context (Dsymbol *); |
| 540 |
extern tree copy_aggregate_type (tree); |
| 541 |
extern bool declaration_reference_p (Declaration *); |
| 542 |
extern tree declaration_type (Declaration *); |
| 543 |
extern bool parameter_reference_p (Parameter *); |
| 544 |
extern tree parameter_type (Parameter *); |
| 545 |
extern tree build_integer_cst (dinteger_t, tree = d_int_type); |
| 546 |
extern tree build_float_cst (const real_t &, Type *); |
| 547 |
extern tree d_array_length (tree); |
| 548 |
extern tree d_array_ptr (tree); |
| 549 |
extern tree d_array_value (tree, tree, tree); |
| 550 |
extern tree get_array_length (tree, Type *); |
| 551 |
extern tree build_class_binfo (tree, ClassDeclaration *); |
| 552 |
extern tree build_interface_binfo (tree, ClassDeclaration *, unsigned &); |
| 553 |
extern tree delegate_method (tree); |
| 554 |
extern tree delegate_object (tree); |
| 555 |
extern tree build_delegate_cst (tree, tree, Type *); |
| 556 |
extern tree build_method_call (tree, tree, Type *); |
| 557 |
extern void extract_from_method_call (tree, tree &, tree &); |
| 558 |
extern tree build_typeof_null_value (Type *); |
| 559 |
extern tree build_vindex_ref (tree, tree, size_t); |
| 560 |
extern tree d_save_expr (tree); |
| 561 |
extern tree stabilize_expr (tree *); |
| 562 |
extern tree build_target_expr (tree, tree); |
| 563 |
extern tree force_target_expr (tree); |
| 564 |
extern tree build_address (tree); |
| 565 |
extern tree d_mark_addressable (tree, bool = true); |
| 566 |
extern tree d_mark_used (tree); |
| 567 |
extern tree d_mark_read (tree); |
| 568 |
extern tree build_memcmp_call (tree, tree, tree); |
| 569 |
extern tree build_memcpy_call (tree, tree, tree); |
| 570 |
extern tree build_memset_call (tree, tree = NULL_TREE); |
| 571 |
extern bool identity_compare_p (StructDeclaration *); |
| 572 |
extern tree build_float_identity (tree_code, tree, tree); |
| 573 |
extern tree build_struct_comparison (tree_code, StructDeclaration *, |
| 574 |
tree, tree); |
| 575 |
extern tree build_array_struct_comparison (tree_code, StructDeclaration *, |
| 576 |
tree, tree, tree); |
| 577 |
extern tree build_struct_literal (tree, vec <constructor_elt, va_gc> *); |
| 578 |
extern tree build_padded_constructor (tree, vec <constructor_elt, va_gc> *); |
| 579 |
extern tree component_ref (tree, tree); |
| 580 |
extern tree build_assign (tree_code, tree, tree); |
| 581 |
extern tree modify_expr (tree, tree); |
| 582 |
extern tree build_nop (tree, tree); |
| 583 |
extern tree build_vconvert (tree, tree); |
| 584 |
extern tree build_boolop (tree_code, tree, tree); |
| 585 |
extern tree build_condition (tree, tree, tree, tree); |
| 586 |
extern tree build_vcondition (tree, tree, tree); |
| 587 |
extern tree compound_expr (tree, tree); |
| 588 |
extern tree return_expr (tree); |
| 589 |
extern tree size_mult_expr (tree, tree); |
| 590 |
extern tree real_part (tree); |
| 591 |
extern tree imaginary_part (tree); |
| 592 |
extern tree complex_expr (tree, tree, tree); |
| 593 |
extern tree underlying_complex_expr (tree, tree); |
| 594 |
extern tree indirect_ref (tree, tree); |
| 595 |
extern tree build_deref (tree); |
| 596 |
extern tree build_pointer_index (tree, tree); |
| 597 |
extern tree build_offset_op (tree_code, tree, tree); |
| 598 |
extern tree build_offset (tree, tree); |
| 599 |
extern tree build_memref (tree, tree, tree); |
| 600 |
extern tree build_array_set (tree, tree, tree); |
| 601 |
extern tree build_array_from_val (Type *, tree); |
| 602 |
extern tree build_array_from_exprs (Type *, Expressions *, bool); |
| 603 |
extern tree void_okay_p (tree); |
| 604 |
extern tree build_assert_call (const Loc &, libcall_fn, tree = NULL_TREE); |
| 605 |
extern tree build_array_bounds_call (const Loc &); |
| 606 |
extern tree build_bounds_index_condition (IndexExp *, tree, tree); |
| 607 |
extern tree build_bounds_slice_condition (SliceExp *, tree, tree, tree); |
| 608 |
extern bool array_bounds_check (void); |
| 609 |
extern bool checkaction_trap_p (void); |
| 610 |
extern TypeFunction *get_function_type (Type *); |
| 611 |
extern bool call_side_effect_free_p (FuncDeclaration *, Type *); |
| 612 |
extern bool call_by_alias_p (FuncDeclaration *, FuncDeclaration *); |
| 613 |
extern tree d_build_call_expr (FuncDeclaration *, tree, Expressions *); |
| 614 |
extern tree d_build_call (TypeFunction *, tree, tree, Expressions *); |
| 615 |
extern tree build_float_modulus (tree, tree, tree); |
| 616 |
extern tree build_vthis_function (tree, tree); |
| 617 |
extern tree error_no_frame_access (Dsymbol *); |
| 618 |
extern tree get_frame_for_symbol (Dsymbol *); |
| 619 |
extern tree build_vthis (AggregateDeclaration *); |
| 620 |
extern void build_closure (FuncDeclaration *); |
| 621 |
extern tree get_frameinfo (FuncDeclaration *); |
| 622 |
extern tree get_framedecl (FuncDeclaration *, FuncDeclaration *); |
| 623 |
|
| 624 |
/* In d-convert.cc. */ |
| 625 |
extern bool decl_with_nonnull_addr_p (const_tree); |
| 626 |
extern tree d_truthvalue_conversion (tree); |
| 627 |
extern tree d_convert (tree, tree); |
| 628 |
extern tree convert_expr (tree, Type *, Type *); |
| 629 |
extern tree convert_for_rvalue (tree, Type *, Type *); |
| 630 |
extern tree convert_for_assignment (Expression *, Type *, bool = false); |
| 631 |
extern tree convert_for_argument (Expression *, Parameter *); |
| 632 |
extern tree convert_for_condition (tree, Type *); |
| 633 |
extern tree d_array_convert (Expression *); |
| 634 |
extern tree d_array_convert (Type *, Expression *); |
| 635 |
|
| 636 |
/* In d-gimplify.cc. */ |
| 637 |
extern int d_gimplify_expr (tree *, gimple_seq *, gimple_seq *); |
| 638 |
|
| 639 |
/* In d-incpath.cc. */ |
| 640 |
extern void add_import_paths (const char *, const char *, bool); |
| 641 |
|
| 642 |
/* In d-lang.cc. */ |
| 643 |
extern void d_add_builtin_module (Module *); |
| 644 |
extern d_tree_node_structure_enum d_tree_node_structure (lang_tree_node *); |
| 645 |
extern struct lang_type *build_lang_type (Type *); |
| 646 |
extern struct lang_decl *build_lang_decl (Declaration *); |
| 647 |
extern tree d_pushdecl (tree); |
| 648 |
extern void d_keep (tree); |
| 649 |
|
| 650 |
/* In decl.cc. */ |
| 651 |
extern const char *d_mangle_decl (Dsymbol *); |
| 652 |
extern tree mangle_internal_decl (Dsymbol *, const char *, const char *); |
| 653 |
extern void build_decl_tree (Dsymbol *); |
| 654 |
extern tree get_symbol_decl (Declaration *); |
| 655 |
extern tree declare_extern_var (tree, tree); |
| 656 |
extern void declare_local_var (VarDeclaration *); |
| 657 |
extern tree build_local_temp (tree); |
| 658 |
extern tree get_decl_tree (Declaration *); |
| 659 |
extern void d_finish_decl (tree); |
| 660 |
extern tree make_thunk (FuncDeclaration *, int); |
| 661 |
extern tree start_function (FuncDeclaration *); |
| 662 |
extern void finish_function (tree); |
| 663 |
extern tree get_vtable_decl (ClassDeclaration *); |
| 664 |
extern tree build_new_class_expr (ClassReferenceExp *); |
| 665 |
extern tree aggregate_initializer_decl (AggregateDeclaration *); |
| 666 |
extern tree layout_struct_initializer (StructDeclaration *); |
| 667 |
extern tree layout_class_initializer (ClassDeclaration *); |
| 668 |
extern tree enum_initializer_decl (EnumDeclaration *); |
| 669 |
extern tree build_artificial_decl (tree, tree, const char * = NULL); |
| 670 |
extern tree create_field_decl (tree, const char *, int, int); |
| 671 |
extern void build_type_decl (tree, Dsymbol *); |
| 672 |
extern void set_linkage_for_decl (tree); |
| 673 |
extern void set_visibility_for_decl (tree, Dsymbol *); |
| 674 |
|
| 675 |
/* In expr.cc. */ |
| 676 |
extern tree build_expr (Expression *, bool = false, bool = false); |
| 677 |
extern tree build_expr_dtor (Expression *); |
| 678 |
extern tree build_return_dtor (Expression *, Type *, TypeFunction *); |
| 679 |
|
| 680 |
/* In imports.cc. */ |
| 681 |
extern tree build_import_decl (Dsymbol *); |
| 682 |
|
| 683 |
/* In intrinsics.cc. */ |
| 684 |
extern void maybe_set_intrinsic (FuncDeclaration *); |
| 685 |
extern tree maybe_expand_intrinsic (tree); |
| 686 |
extern tree maybe_reject_intrinsic (tree); |
| 687 |
|
| 688 |
/* In modules.cc. */ |
| 689 |
extern void build_module_tree (Module *); |
| 690 |
extern tree d_module_context (void); |
| 691 |
extern void register_module_decl (Declaration *); |
| 692 |
extern void d_defer_declaration (Declaration *); |
| 693 |
extern void d_finish_compilation (tree *, int); |
| 694 |
|
| 695 |
/* In runtime.cc. */ |
| 696 |
extern tree build_libcall (libcall_fn, Type *, int ...); |
| 697 |
|
| 698 |
/* In typeinfo.cc. */ |
| 699 |
extern bool have_typeinfo_p (ClassDeclaration *); |
| 700 |
extern tree layout_typeinfo (TypeInfoDeclaration *); |
| 701 |
extern tree layout_classinfo (ClassDeclaration *); |
| 702 |
extern unsigned base_vtable_offset (ClassDeclaration *, BaseClass *); |
| 703 |
extern tree get_typeinfo_decl (TypeInfoDeclaration *); |
| 704 |
extern tree get_classinfo_decl (ClassDeclaration *); |
| 705 |
extern void check_typeinfo_type (const Loc &, Scope *, Expression * = NULL); |
| 706 |
extern tree build_typeinfo (const Loc &, Type *, Expression * = NULL); |
| 707 |
extern tree build_typeinfo (Expression *, Type *); |
| 708 |
extern void create_typeinfo (Type *, Scope *); |
| 709 |
extern void create_tinfo_types (Module *); |
| 710 |
extern void layout_cpp_typeinfo (ClassDeclaration *); |
| 711 |
extern tree get_cpp_typeinfo_decl (ClassDeclaration *); |
| 712 |
|
| 713 |
/* In toir.cc. */ |
| 714 |
extern void push_binding_level (level_kind); |
| 715 |
extern tree pop_binding_level (void); |
| 716 |
extern void push_stmt_list (void); |
| 717 |
extern tree pop_stmt_list (void); |
| 718 |
extern void add_stmt (tree); |
| 719 |
extern void build_function_body (FuncDeclaration *); |
| 720 |
|
| 721 |
/* In types.cc. */ |
| 722 |
extern tree d_unsigned_type (tree); |
| 723 |
extern tree d_signed_type (tree); |
| 724 |
extern bool valist_array_p (Type *); |
| 725 |
extern bool empty_aggregate_p (tree); |
| 726 |
extern bool same_type_p (Type *, Type *); |
| 727 |
extern Type *get_object_type (void); |
| 728 |
extern tree make_array_type (Type *, unsigned HOST_WIDE_INT); |
| 729 |
extern tree make_struct_type (const char *, int n, ...); |
| 730 |
extern tree insert_type_modifiers (tree, unsigned); |
| 731 |
extern void insert_aggregate_field (tree, tree, size_t); |
| 732 |
extern void finish_aggregate_type (unsigned, unsigned, tree); |
| 733 |
extern tree build_ctype (Type *); |
| 734 |
|
| 735 |
#endif /* GCC_D_TREE_H */ |