changeset 11285:fc86bdb42a52

Avoid repeated lowering of convert nodes on AMD64
author Gilles Duboscq <duboscq@ssw.jku.at>
date Sun, 11 Aug 2013 15:11:10 +0200
parents d876002b98e6
children 485a5f029b32
files graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ConvertNode.java graal/com.oracle.graal.replacements.amd64/src/com/oracle/graal/replacements/amd64/AMD64ConvertNode.java graal/com.oracle.graal.replacements.amd64/src/com/oracle/graal/replacements/amd64/AMD64ConvertSnippets.java
diffstat 3 files changed, 54 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ConvertNode.java	Sat Aug 10 22:57:50 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ConvertNode.java	Sun Aug 11 15:11:10 2013 +0200
@@ -34,7 +34,7 @@
 /**
  * The {@code ConvertNode} class represents a conversion between primitive types.
  */
-public final class ConvertNode extends FloatingNode implements Canonicalizable, LIRLowerable, Lowerable, ArithmeticOperation {
+public class ConvertNode extends FloatingNode implements Canonicalizable, LIRLowerable, Lowerable, ArithmeticOperation {
 
     public static enum Op {
         I2L(Int, Long, true),
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.replacements.amd64/src/com/oracle/graal/replacements/amd64/AMD64ConvertNode.java	Sun Aug 11 15:11:10 2013 +0200
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.replacements.amd64;
+
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.calc.ConvertNode.Op;
+import com.oracle.graal.nodes.calc.*;
+import com.oracle.graal.nodes.spi.*;
+import com.oracle.graal.nodes.type.*;
+
+/**
+ * This node has the semantics of the AMD64 conversions. It is used in the lowering of the
+ * ConvertNode which, on AMD64 needs a AMD64ConvertNode plus some fixup code that handles the corner
+ * cases that differ between AMD64 and Java.
+ * 
+ */
+public class AMD64ConvertNode extends FloatingNode implements LIRLowerable, ArithmeticOperation {
+
+    @Input private ValueNode value;
+    public final Op opcode;
+
+    public AMD64ConvertNode(Op opcode, ValueNode value) {
+        super(StampFactory.forKind(opcode.to.getStackKind()));
+        this.opcode = opcode;
+        this.value = value;
+    }
+
+    public void generate(LIRGeneratorTool gen) {
+        gen.setResult(this, gen.emitConvert(opcode, gen.operand(value)));
+    }
+}
--- a/graal/com.oracle.graal.replacements.amd64/src/com/oracle/graal/replacements/amd64/AMD64ConvertSnippets.java	Sat Aug 10 22:57:50 2013 +0200
+++ b/graal/com.oracle.graal.replacements.amd64/src/com/oracle/graal/replacements/amd64/AMD64ConvertSnippets.java	Sun Aug 11 15:11:10 2013 +0200
@@ -176,7 +176,7 @@
             convert.replaceAtUsages(replacee);
             Arguments args = new Arguments(key);
             args.add("input", convert.value());
-            args.add("result", convert);
+            args.add("result", convert.graph().unique(new AMD64ConvertNode(convert.opcode, convert.value())));
 
             SnippetTemplate template = template(args);
             Debug.log("Lowering %s in %s: node=%s, template=%s, arguments=%s", convert.opcode, graph, convert, template, args);