📄 tree.h
字号:
/* Front-end tree definitions for GNU compiler. Copyright (C) 1989 Free Software Foundation, Inc.This file is part of GNU CC.GNU CC is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2, or (at your option)any later version.GNU CC is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU CC; see the file COPYING. If not, write tothe Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */#include "machmode.h"/* codes of tree nodes */#define DEFTREECODE(SYM, STRING, TYPE, NARGS) SYM,enum tree_code {#include "tree.def" LAST_AND_UNUSED_TREE_CODE /* A convenient way to get a value for NUM_TREE_CODE. */};#undef DEFTREECODE/* Number of tree codes. */#define NUM_TREE_CODES ((int)LAST_AND_UNUSED_TREE_CODE)/* Indexed by enum tree_code, contains a character which is `<' for a comparison expression, `1', for a unary arithmetic expression, `2' for a binary arithmetic expression, `e' for other types of expressions, `r' for a reference, `c' for a constant, `d' for a decl, `t' for a type, `s' for a statement, and `x' for anything else (TREE_LIST, IDENTIFIER, etc). */extern char **tree_code_type;#define TREE_CODE_CLASS(CODE) (*tree_code_type[(int) (CODE)])/* Number of argument-words in each kind of tree-node. */extern int *tree_code_length;/* Names of tree components. */extern char **tree_code_name;/* Codes that identify the various built in functions so that expand_call can identify them quickly. */enum built_in_function{ NOT_BUILT_IN, BUILT_IN_ALLOCA, BUILT_IN_ABS, BUILT_IN_FABS, BUILT_IN_LABS, BUILT_IN_FFS, BUILT_IN_DIV, BUILT_IN_LDIV, BUILT_IN_FFLOOR, BUILT_IN_FCEIL, BUILT_IN_FMOD, BUILT_IN_FREM, BUILT_IN_MEMCPY, BUILT_IN_MEMCMP, BUILT_IN_MEMSET, BUILT_IN_STRCPY, BUILT_IN_STRCMP, BUILT_IN_STRLEN, BUILT_IN_FSQRT, BUILT_IN_SIN, BUILT_IN_COS, BUILT_IN_GETEXP, BUILT_IN_GETMAN, BUILT_IN_SAVEREGS, BUILT_IN_CLASSIFY_TYPE, BUILT_IN_NEXT_ARG, BUILT_IN_ARGS_INFO, BUILT_IN_CONSTANT_P, BUILT_IN_FRAME_ADDRESS, BUILT_IN_RETURN_ADDRESS, BUILT_IN_CALLER_RETURN_ADDRESS, /* C++ extensions */ BUILT_IN_NEW, BUILT_IN_VEC_NEW, BUILT_IN_DELETE, BUILT_IN_VEC_DELETE};/* The definition of tree nodes fills the next several pages. *//* A tree node can represent a data type, a variable, an expression or a statement. Each node has a TREE_CODE which says what kind of thing it represents. Some common codes are: INTEGER_TYPE -- represents a type of integers. ARRAY_TYPE -- represents a type of pointer. VAR_DECL -- represents a declared variable. INTEGER_CST -- represents a constant integer value. PLUS_EXPR -- represents a sum (an expression). As for the contents of a tree node: there are some fields that all nodes share. Each TREE_CODE has various special-purpose fields as well. The fields of a node are never accessed directly, always through accessor macros. *//* This type is used everywhere to refer to a tree node. */typedef union tree_node *tree;/* Every kind of tree node starts with this structure, so all nodes have these fields. See the accessor macros, defined below, for documentation of the fields. */struct tree_common{ union tree_node *chain; union tree_node *type;#ifdef ONLY_INT_FIELDS unsigned int code : 8;#else enum tree_code code : 8;#endif unsigned side_effects_flag : 1; unsigned constant_flag : 1; unsigned permanent_flag : 1; unsigned addressable_flag : 1; unsigned volatile_flag : 1; unsigned readonly_flag : 1; unsigned unsigned_flag : 1; unsigned asm_written_flag: 1; unsigned used_flag : 1; unsigned raises_flag : 1; unsigned static_flag : 1; unsigned public_flag : 1; unsigned private_flag : 1; unsigned protected_flag : 1; unsigned lang_flag_0 : 1; unsigned lang_flag_1 : 1; unsigned lang_flag_2 : 1; unsigned lang_flag_3 : 1; unsigned lang_flag_4 : 1; unsigned lang_flag_5 : 1; unsigned lang_flag_6 : 1; /* There is room for two more flags. */};/* Define accessors for the fields that all tree nodes have (though some fields are not used for all kinds of nodes). *//* The tree-code says what kind of node it is. Codes are defined in tree.def. */#define TREE_CODE(NODE) ((enum tree_code) (NODE)->common.code)#define TREE_SET_CODE(NODE, VALUE) ((NODE)->common.code = (int) (VALUE))/* In all nodes that are expressions, this is the data type of the expression. In POINTER_TYPE nodes, this is the type that the pointer points to. In ARRAY_TYPE nodes, this is the type of the elements. */#define TREE_TYPE(NODE) ((NODE)->common.type)/* Nodes are chained together for many purposes. Types are chained together to record them for being output to the debugger (see the function `chain_type'). Decls in the same scope are chained together to record the contents of the scope. Statement nodes for successive statements used to be chained together. Often lists of things are represented by TREE_LIST nodes that are chained together. */#define TREE_CHAIN(NODE) ((NODE)->common.chain)/* Given an expression as a tree, strip any NON_LVALUE_EXPRs and NOP_EXPRs that don't change the machine mode. */#define STRIP_NOPS(EXP) \ while ((TREE_CODE (EXP) == NOP_EXPR \ || TREE_CODE (EXP) == CONVERT_EXPR \ || TREE_CODE (EXP) == NON_LVALUE_EXPR) \ && (TYPE_MODE (TREE_TYPE (EXP)) \ == TYPE_MODE (TREE_TYPE (TREE_OPERAND (EXP, 0))))) \ (EXP) = TREE_OPERAND (EXP, 0);/* Like STRIP_NOPS, but don't alter the TREE_TYPE either. */#define STRIP_TYPE_NOPS(EXP) \ while ((TREE_CODE (EXP) == NOP_EXPR \ || TREE_CODE (EXP) == CONVERT_EXPR \ || TREE_CODE (EXP) == NON_LVALUE_EXPR) \ && (TREE_TYPE (EXP) \ == TREE_TYPE (TREE_OPERAND (EXP, 0)))) \ (EXP) = TREE_OPERAND (EXP, 0);/* Define many boolean fields that all tree nodes have. *//* In VAR_DECL nodes, nonzero means address of this is needed. So it cannot be in a register. In a FUNCTION_DECL, nonzero means its address is needed. So it must be compiled even if it is an inline function. In CONSTRUCTOR nodes, it means object constructed must be in memory. In LABEL_DECL nodes, it means a goto for this label has been seen from a place outside all binding contours that restore stack levels. In ..._TYPE nodes, it means that objects of this type must be fully addressable. This means that pieces of this object cannot go into register parameters, for example. In IDENTIFIER_NODEs, this means that some extern decl for this name had its address taken. That matters for inline functions. */#define TREE_ADDRESSABLE(NODE) ((NODE)->common.addressable_flag)/* In a VAR_DECL, nonzero means allocate static storage. In a FUNCTION_DECL, nonzero if function has been defined. In a CONSTRUCTOR, nonzero means allocate static storage. */#define TREE_STATIC(NODE) ((NODE)->common.static_flag)/* In a CONVERT_EXPR or NOP_EXPR, this means the node was made implicitly and should not lead to an "unused value" warning. */#define TREE_NO_UNUSED_WARNING(NODE) ((NODE)->common.static_flag)/* In an INTEGER_CST, this means there was overflow in folding. */#define TREE_CONSTANT_OVERFLOW(NODE) ((NODE)->common.static_flag)/* Nonzero for a TREE_LIST or TREE_VEC node means that the derivation chain is via a `virtual' declaration. */#define TREE_VIA_VIRTUAL(NODE) ((NODE)->common.static_flag)/* In a VAR_DECL or FUNCTION_DECL, nonzero means name is to be accessible from outside this module. In an identifier node, nonzero means an external declaration accessible from outside this module was previously seen for this name in an inner scope. */#define TREE_PUBLIC(NODE) ((NODE)->common.public_flag)/* Nonzero for TREE_LIST or TREE_VEC node means that the path to the base class is via a `public' declaration, which preserves public fields from the base class as public. */#define TREE_VIA_PUBLIC(NODE) ((NODE)->common.public_flag)/* Ditto, for `private' declarations. */#define TREE_VIA_PRIVATE(NODE) ((NODE)->common.private_flag)/* Nonzero for TREE_LIST node means that the path to the base class is via a `protected' declaration, which preserves protected fields from the base class as protected. OVERLOADED. */#define TREE_VIA_PROTECTED(NODE) ((NODE)->common.protected_flag)/* In any expression, nonzero means it has side effects or reevaluation of the whole expression could produce a different value. This is set if any subexpression is a function call, a side effect or a reference to a volatile variable. In a ..._DECL, this is set only if the declaration said `volatile'. */#define TREE_SIDE_EFFECTS(NODE) ((NODE)->common.side_effects_flag)/* Nonzero means this expression is volatile in the C sense: its address should be of type `volatile WHATEVER *'. In other words, the declared item is volatile qualified. This is used in _DECL nodes and _REF nodes. In a ..._TYPE node, means this type is volatile-qualified. But use TYPE_VOLATILE instead of this macro when the node is a type, because eventually we may make that a different bit. If this bit is set in an expression, so is TREE_SIDE_EFFECTS. */#define TREE_THIS_VOLATILE(NODE) ((NODE)->common.volatile_flag)/* In a VAR_DECL, PARM_DECL or FIELD_DECL, or any kind of ..._REF node, nonzero means it may not be the lhs of an assignment. In a ..._TYPE node, means this type is const-qualified (but the macro TYPE_READONLY should be used instead of this macro when the node is a type). */#define TREE_READONLY(NODE) ((NODE)->common.readonly_flag)/* Value of expression is constant. Always appears in all ..._CST nodes. May also appear in an arithmetic expression, an ADDR_EXPR or a CONSTRUCTOR if the value is constant. */#define TREE_CONSTANT(NODE) ((NODE)->common.constant_flag)/* Nonzero means permanent node; node will continue to exist for the entire compiler run. Otherwise it will be recycled at the end of the function. */#define TREE_PERMANENT(NODE) ((NODE)->common.permanent_flag)/* In INTEGER_TYPE or ENUMERAL_TYPE nodes, means an unsigned type. In FIELD_DECL nodes, means an unsigned bit field. The same bit is used in functions as DECL_BUILT_IN_NONANSI. */#define TREE_UNSIGNED(NODE) ((NODE)->common.unsigned_flag)/* Nonzero in a VAR_DECL means assembler code has been written. Nonzero in a FUNCTION_DECL means that the function has been compiled. This is interesting in an inline function, since it might not need to be compiled separately. Nonzero in a RECORD_TYPE, UNION_TYPE or ENUMERAL_TYPE if the sdb debugging info for the type has been written. In a BLOCK node, nonzero if reorder_blocks has already seen this block. */#define TREE_ASM_WRITTEN(NODE) ((NODE)->common.asm_written_flag)/* Nonzero in a _DECL if the name is used in its scope. Nonzero in an expr node means inhibit warning if value is unused. In IDENTIFIER_NODEs, this means that some extern decl for this name was used. */#define TREE_USED(NODE) ((NODE)->common.used_flag)/* Nonzero for a tree node whose evaluation could result in the raising of an exception. Not implemented yet. */#define TREE_RAISES(NODE) ((NODE)->common.raises_flag)/* Used in classes in C++. */#define TREE_PRIVATE(NODE) ((NODE)->common.private_flag)/* Used in classes in C++. In a BLOCK node, this is BLOCK_HANDLER_BLOCK. */#define TREE_PROTECTED(NODE) ((NODE)->common.protected_flag)/* These flags are available for each language front end to use internally. */#define TREE_LANG_FLAG_0(NODE) ((NODE)->common.lang_flag_0)#define TREE_LANG_FLAG_1(NODE) ((NODE)->common.lang_flag_1)#define TREE_LANG_FLAG_2(NODE) ((NODE)->common.lang_flag_2)#define TREE_LANG_FLAG_3(NODE) ((NODE)->common.lang_flag_3)#define TREE_LANG_FLAG_4(NODE) ((NODE)->common.lang_flag_4)#define TREE_LANG_FLAG_5(NODE) ((NODE)->common.lang_flag_5)#define TREE_LANG_FLAG_6(NODE) ((NODE)->common.lang_flag_6)/* Define additional fields and accessors for nodes representing constants. *//* In an INTEGER_CST node. These two together make a 2-word integer. If the data type is signed, the value is sign-extended to 2 words even though not all of them may really be in use. In an unsigned constant shorter than 2 words, the extra bits are 0. */#define TREE_INT_CST_LOW(NODE) ((NODE)->int_cst.int_cst_low)#define TREE_INT_CST_HIGH(NODE) ((NODE)->int_cst.int_cst_high)#define INT_CST_LT(A, B) \(TREE_INT_CST_HIGH (A) < TREE_INT_CST_HIGH (B) \ || (TREE_INT_CST_HIGH (A) == TREE_INT_CST_HIGH (B) \ && ((unsigned HOST_WIDE_INT) TREE_INT_CST_LOW (A) \ < (unsigned HOST_WIDE_INT) TREE_INT_CST_LOW (B))))#define INT_CST_LT_UNSIGNED(A, B) \(((unsigned HOST_WIDE_INT) TREE_INT_CST_HIGH (A) \ < (unsigned HOST_WIDE_INT) TREE_INT_CST_HIGH (B)) \ || (((unsigned HOST_WIDE_INT) TREE_INT_CST_HIGH (A) \ == (unsigned HOST_WIDE_INT ) TREE_INT_CST_HIGH (B)) \ && (((unsigned HOST_WIDE_INT) TREE_INT_CST_LOW (A) \ < (unsigned HOST_WIDE_INT) TREE_INT_CST_LOW (B)))))struct tree_int_cst{ char common[sizeof (struct tree_common)];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -