annotate gcc/gimple-builder.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Functions for high level gimple building routines.
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
2 Copyright (C) 2013-2020 Free Software Foundation, Inc.
111
kono
parents:
diff changeset
3
kono
parents:
diff changeset
4 This file is part of GCC.
kono
parents:
diff changeset
5
kono
parents:
diff changeset
6 GCC is free software; you can redistribute it and/or modify
kono
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
kono
parents:
diff changeset
8 the Free Software Foundation; either version 3, or (at your option)
kono
parents:
diff changeset
9 any later version.
kono
parents:
diff changeset
10
kono
parents:
diff changeset
11 GCC is distributed in the hope that it will be useful,
kono
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
kono
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
kono
parents:
diff changeset
14 GNU General Public License for more details.
kono
parents:
diff changeset
15
kono
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
kono
parents:
diff changeset
17 along with GCC; see the file COPYING3. If not see
kono
parents:
diff changeset
18 <http://www.gnu.org/licenses/>. */
kono
parents:
diff changeset
19
kono
parents:
diff changeset
20 #include "config.h"
kono
parents:
diff changeset
21 #include "system.h"
kono
parents:
diff changeset
22 #include "coretypes.h"
kono
parents:
diff changeset
23 #include "backend.h"
kono
parents:
diff changeset
24 #include "tree.h"
kono
parents:
diff changeset
25 #include "gimple.h"
kono
parents:
diff changeset
26 #include "stringpool.h"
kono
parents:
diff changeset
27 #include "tree-vrp.h"
kono
parents:
diff changeset
28 #include "tree-ssanames.h"
kono
parents:
diff changeset
29
kono
parents:
diff changeset
30
kono
parents:
diff changeset
31 /* Return the expression type to use based on the CODE and type of
kono
parents:
diff changeset
32 the given operand OP. If the expression CODE is a comparison,
kono
parents:
diff changeset
33 the returned type is boolean_type_node. Otherwise, it returns
kono
parents:
diff changeset
34 the type of OP. */
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 static tree
kono
parents:
diff changeset
37 get_expr_type (enum tree_code code, tree op)
kono
parents:
diff changeset
38 {
kono
parents:
diff changeset
39 return (TREE_CODE_CLASS (code) == tcc_comparison)
kono
parents:
diff changeset
40 ? boolean_type_node
kono
parents:
diff changeset
41 : TREE_TYPE (op);
kono
parents:
diff changeset
42 }
kono
parents:
diff changeset
43
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 /* Build a new gimple assignment. The LHS of the assignment is a new
kono
parents:
diff changeset
46 temporary whose type matches the given expression. MODE indicates
kono
parents:
diff changeset
47 whether the LHS should be an SSA or a normal temporary. CODE is
kono
parents:
diff changeset
48 the expression code for the RHS. OP1 is the first operand and VAL
kono
parents:
diff changeset
49 is an integer value to be used as the second operand. */
kono
parents:
diff changeset
50
kono
parents:
diff changeset
51 gassign *
kono
parents:
diff changeset
52 build_assign (enum tree_code code, tree op1, int val, tree lhs)
kono
parents:
diff changeset
53 {
kono
parents:
diff changeset
54 tree op2 = build_int_cst (TREE_TYPE (op1), val);
kono
parents:
diff changeset
55 if (lhs == NULL_TREE)
kono
parents:
diff changeset
56 lhs = make_ssa_name (get_expr_type (code, op1));
kono
parents:
diff changeset
57 return gimple_build_assign (lhs, code, op1, op2);
kono
parents:
diff changeset
58 }
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 gassign *
kono
parents:
diff changeset
61 build_assign (enum tree_code code, gimple *g, int val, tree lhs )
kono
parents:
diff changeset
62 {
kono
parents:
diff changeset
63 return build_assign (code, gimple_assign_lhs (g), val, lhs);
kono
parents:
diff changeset
64 }
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 /* Build and return a new GIMPLE assignment. The new assignment will
kono
parents:
diff changeset
68 have the opcode CODE and operands OP1 and OP2. The type of the
kono
parents:
diff changeset
69 expression on the RHS is inferred to be the type of OP1.
kono
parents:
diff changeset
70
kono
parents:
diff changeset
71 The LHS of the statement will be an SSA name or a GIMPLE temporary
kono
parents:
diff changeset
72 in normal form depending on the type of builder invoking this
kono
parents:
diff changeset
73 function. */
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 gassign *
kono
parents:
diff changeset
76 build_assign (enum tree_code code, tree op1, tree op2, tree lhs)
kono
parents:
diff changeset
77 {
kono
parents:
diff changeset
78 if (lhs == NULL_TREE)
kono
parents:
diff changeset
79 lhs = make_ssa_name (get_expr_type (code, op1));
kono
parents:
diff changeset
80 return gimple_build_assign (lhs, code, op1, op2);
kono
parents:
diff changeset
81 }
kono
parents:
diff changeset
82
kono
parents:
diff changeset
83 gassign *
kono
parents:
diff changeset
84 build_assign (enum tree_code code, gimple *op1, tree op2, tree lhs)
kono
parents:
diff changeset
85 {
kono
parents:
diff changeset
86 return build_assign (code, gimple_assign_lhs (op1), op2, lhs);
kono
parents:
diff changeset
87 }
kono
parents:
diff changeset
88
kono
parents:
diff changeset
89 gassign *
kono
parents:
diff changeset
90 build_assign (enum tree_code code, tree op1, gimple *op2, tree lhs)
kono
parents:
diff changeset
91 {
kono
parents:
diff changeset
92 return build_assign (code, op1, gimple_assign_lhs (op2), lhs);
kono
parents:
diff changeset
93 }
kono
parents:
diff changeset
94
kono
parents:
diff changeset
95 gassign *
kono
parents:
diff changeset
96 build_assign (enum tree_code code, gimple *op1, gimple *op2, tree lhs)
kono
parents:
diff changeset
97 {
kono
parents:
diff changeset
98 return build_assign (code, gimple_assign_lhs (op1), gimple_assign_lhs (op2),
kono
parents:
diff changeset
99 lhs);
kono
parents:
diff changeset
100 }
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103 /* Create and return a type cast assignment. This creates a NOP_EXPR
kono
parents:
diff changeset
104 that converts OP to TO_TYPE. */
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 gassign *
kono
parents:
diff changeset
107 build_type_cast (tree to_type, tree op, tree lhs)
kono
parents:
diff changeset
108 {
kono
parents:
diff changeset
109 if (lhs == NULL_TREE)
kono
parents:
diff changeset
110 lhs = make_ssa_name (to_type);
kono
parents:
diff changeset
111 return gimple_build_assign (lhs, NOP_EXPR, op);
kono
parents:
diff changeset
112 }
kono
parents:
diff changeset
113
kono
parents:
diff changeset
114 gassign *
kono
parents:
diff changeset
115 build_type_cast (tree to_type, gimple *op, tree lhs)
kono
parents:
diff changeset
116 {
kono
parents:
diff changeset
117 return build_type_cast (to_type, gimple_assign_lhs (op), lhs);
kono
parents:
diff changeset
118 }
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120
kono
parents:
diff changeset
121