8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "memory/allocation.inline.hpp"
27 #include "opto/addnode.hpp"
28 #include "opto/machnode.hpp"
29 #include "opto/mathexactnode.hpp"
30 #include "opto/matcher.hpp"
31 #include "opto/subnode.hpp"
32
33 MathExactNode::MathExactNode(Node* ctrl, Node* n1, Node* n2) : MultiNode(3) {
34 init_req(0, ctrl);
35 init_req(1, n1);
36 init_req(2, n2);
37 }
38
39 Node* AddExactINode::match(const ProjNode* proj, const Matcher* m) {
40 uint ideal_reg = proj->ideal_reg();
41 RegMask rm;
42 if (proj->_con == result_proj_node) {
43 rm = m->mathExactI_result_proj_mask();
44 } else {
45 assert(proj->_con == flags_proj_node, "must be result or flags");
46 assert(ideal_reg == Op_RegFlags, "sanity");
47 rm = m->mathExactI_flags_proj_mask();
48 }
49 return new (m->C) MachProjNode(this, proj->_con, rm, ideal_reg);
50 }
51
52 // If the MathExactNode won't overflow we have to replace the
53 // FlagsProjNode and ProjNode that is generated by the MathExactNode
54 Node* MathExactNode::no_overflow(PhaseGVN *phase, Node* new_result) {
55 PhaseIterGVN *igvn = phase->is_IterGVN();
56 if (igvn) {
|
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "memory/allocation.inline.hpp"
27 #include "opto/addnode.hpp"
28 #include "opto/cfgnode.hpp"
29 #include "opto/machnode.hpp"
30 #include "opto/matcher.hpp"
31 #include "opto/mathexactnode.hpp"
32 #include "opto/subnode.hpp"
33
34 MathExactNode::MathExactNode(Node* ctrl, Node* n1, Node* n2) : MultiNode(3) {
35 init_req(0, ctrl);
36 init_req(1, n1);
37 init_req(2, n2);
38 }
39
40 Node* MathExactNode::control_node() const {
41 Node* flags = flags_node();
42 BoolNode* boolnode = flags->unique_out()->as_Bool();
43 IfNode* iff = boolnode->unique_out()->as_If();
44 return iff->in(0);
45 }
46
47 Node* MathExactNode::non_throwing_branch() const {
48 Node* flags = flags_node();
49 BoolNode* boolnode = flags->unique_out()->as_Bool();
50 IfNode* iff = boolnode->unique_out()->as_If();
51 if (boolnode->_test._test == BoolTest::overflow) {
52 return iff->proj_out(0);
53 }
54 return iff->proj_out(1);
55 }
56
57 Node* AddExactINode::match(const ProjNode* proj, const Matcher* m) {
58 uint ideal_reg = proj->ideal_reg();
59 RegMask rm;
60 if (proj->_con == result_proj_node) {
61 rm = m->mathExactI_result_proj_mask();
62 } else {
63 assert(proj->_con == flags_proj_node, "must be result or flags");
64 assert(ideal_reg == Op_RegFlags, "sanity");
65 rm = m->mathExactI_flags_proj_mask();
66 }
67 return new (m->C) MachProjNode(this, proj->_con, rm, ideal_reg);
68 }
69
70 // If the MathExactNode won't overflow we have to replace the
71 // FlagsProjNode and ProjNode that is generated by the MathExactNode
72 Node* MathExactNode::no_overflow(PhaseGVN *phase, Node* new_result) {
73 PhaseIterGVN *igvn = phase->is_IterGVN();
74 if (igvn) {
|