diff graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotLIRGenerator.java @ 12664:1fdecc36c8ac

HSAIL updates to integrate recent changes to the providers infrastructure. Contributed-by: Tom Deneau <tom.deneau@amd.com>
author Doug Simon <doug.simon@oracle.com>
date Mon, 04 Nov 2013 17:17:08 +0100
parents ae412befde21
children d59a65c11feb
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotLIRGenerator.java	Mon Nov 04 16:12:48 2013 +0100
+++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotLIRGenerator.java	Mon Nov 04 17:17:08 2013 +0100
@@ -29,10 +29,8 @@
 import com.oracle.graal.hotspot.*;
 import com.oracle.graal.lir.*;
 import com.oracle.graal.lir.hsail.*;
-import com.oracle.graal.lir.hsail.HSAILMove.LoadCompressedPointer;
-import com.oracle.graal.lir.hsail.HSAILMove.LoadOp;
-import com.oracle.graal.lir.hsail.HSAILMove.StoreCompressedPointer;
-import com.oracle.graal.lir.hsail.HSAILMove.StoreOp;
+import com.oracle.graal.lir.hsail.HSAILControlFlow.*;
+import com.oracle.graal.lir.hsail.HSAILMove.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.phases.util.*;
 
@@ -79,4 +77,46 @@
             append(new StoreOp(kind, storeAddress, input, state));
         }
     }
+
+    /***
+     * This is a very temporary solution to emitForeignCall. We don't really support foreign calls
+     * yet, but we do want to generate dummy code for them. The ForeignCallXXXOps just end up
+     * emitting a comment as to what Foreign call they would have made.
+     **/
+    @Override
+    public Variable emitForeignCall(ForeignCallLinkage linkage, DeoptimizingNode info, Value... args) {
+        Variable result = newVariable(Kind.Object);  // linkage.getDescriptor().getResultType());
+
+        // to make the LIRVerifier happy, we move any constants into registers
+        Value[] argLocations = new Value[args.length];
+        for (int i = 0; i < args.length; i++) {
+            Value arg = args[i];
+            AllocatableValue loc = newVariable(arg.getKind());
+            emitMove(loc, arg);
+            argLocations[i] = loc;
+        }
+
+        // here we could check the callName if we wanted to only handle certain callnames
+        String callName = linkage.getDescriptor().getName();
+        switch (argLocations.length) {
+            case 0:
+                append(new ForeignCallNoArgOp(callName, result));
+                break;
+            case 1:
+                append(new ForeignCall1ArgOp(callName, result, argLocations[0]));
+                break;
+            case 2:
+                append(new ForeignCall2ArgOp(callName, result, argLocations[0], argLocations[1]));
+                break;
+            default:
+                throw new InternalError("NYI emitForeignCall " + callName + ", " + argLocations.length + ", " + linkage);
+        }
+        return result;
+    }
+
+    @Override
+    protected void emitForeignCall(ForeignCallLinkage linkage, Value result, Value[] arguments, Value[] temps, LIRFrameState info) {
+        // this version of emitForeignCall not used for now
+    }
+
 }