changeset 14802:10dde0063f5a

BaselineCompiler: update LIRBlock.
author Josef Eisl <josef.eisl@jku.at>
date Thu, 13 Mar 2014 18:45:17 +0100
parents 66d3397c2c0d
children c4219e527b83
files graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineCompiler.java graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/LIRBlock.java
diffstat 2 files changed, 41 insertions(+), 60 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineCompiler.java	Thu Mar 13 18:44:09 2014 +0100
+++ b/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineCompiler.java	Thu Mar 13 18:45:17 2014 +0100
@@ -27,6 +27,9 @@
 import static com.oracle.graal.phases.GraalOptions.*;
 import static java.lang.reflect.Modifier.*;
 
+import java.util.*;
+
+import com.oracle.graal.alloc.*;
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.api.meta.ResolvedJavaType.Representation;
@@ -44,6 +47,7 @@
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.calc.FloatConvertNode.FloatConvert;
+import com.oracle.graal.nodes.cfg.*;
 import com.oracle.graal.nodes.java.MethodCallTargetNode.InvokeKind;
 import com.oracle.graal.nodes.java.*;
 
@@ -101,8 +105,29 @@
             filter.remove();
         }
         // emitLIR
-        LIRBlock b = new LIRBlock();
-        LIRGenerator lirGen = null;
+        LIRBlock b = new LIRBlock(0);
+        LIRBlock[] blocks = new LIRBlock[1];
+        blocks[0] = b;
+
+        AbstractControlFlowGraph<?> cfg = new LIRControlFlowGraph(blocks, null);
+        BlocksToDoubles blockProbabilities = new BlocksToDoubles(blocks.length);
+        blockProbabilities.put(b, 1);
+
+        List<? extends AbstractBlock<?>> linearScanOrder = ComputeBlockOrder.computeLinearScanOrder(blocks.length, b, blockProbabilities);
+        List<? extends AbstractBlock<?>> codeEmittingOrder = ComputeBlockOrder.computeCodeEmittingOrder(blocks.length, b, blockProbabilities);
+        LIR lir = new LIR(cfg, linearScanOrder, codeEmittingOrder);
+        CallingConvention cc = CodeUtil.getCallingConvention(backend.getProviders().getCodeCache(), CallingConvention.Type.JavaCallee, method, false);
+        LIRGenerator lirGen = backend.newLIRGenerator(null, null, backend.newFrameMap(), cc, lir);
+
+        // add instruction
+        lirGen.emitAdd(Constant.forLong(42), Constant.forLong(73));
+
+        List<LIRInstruction> lirList = null;
+        lir.setLir(b, lirList);
+
+        // register allocation
+        lirGen.getFrameMap().finish();
+
         // emitCode
         Assumptions assumptions = new Assumptions(OptAssumptions.getValue());
         GraalCompiler.emitCode(backend, new long[0], assumptions, lirGen, compilationResult, installedCodeOwner, factory);
--- a/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/LIRBlock.java	Thu Mar 13 18:44:09 2014 +0100
+++ b/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/LIRBlock.java	Thu Mar 13 18:45:17 2014 +0100
@@ -28,11 +28,12 @@
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.cfg.*;
 
-public class LIRBlock implements com.oracle.graal.nodes.cfg.AbstractBlock<LIRBlock> {
+public class LIRBlock extends AbstractBlockBase<LIRBlock> {
 
-    public int getId() {
-        // TODO Auto-generated method stub
-        throw GraalInternalError.unimplemented("Auto-generated method stub");
+    public LIRBlock(int id) {
+        this.id = id;
+        predecessors = Collections.emptyList();
+        successors = Collections.emptyList();
     }
 
     public AbstractBeginNode getBeginNode() {
@@ -42,72 +43,27 @@
 
     public Loop getLoop() {
         // TODO Auto-generated method stub
-        throw GraalInternalError.unimplemented("Auto-generated method stub");
+        return null;
     }
 
     public int getLoopDepth() {
         // TODO Auto-generated method stub
-        throw GraalInternalError.unimplemented("Auto-generated method stub");
+        return 0;
+    }
+
+    public boolean isLoopEnd() {
+        // TODO Auto-generated method stub
+        return false;
     }
 
     public boolean isLoopHeader() {
         // TODO Auto-generated method stub
-        throw GraalInternalError.unimplemented("Auto-generated method stub");
-    }
-
-    public boolean isLoopEnd() {
-        // TODO Auto-generated method stub
-        throw GraalInternalError.unimplemented("Auto-generated method stub");
+        return false;
     }
 
     public boolean isExceptionEntry() {
         // TODO Auto-generated method stub
-        throw GraalInternalError.unimplemented("Auto-generated method stub");
-    }
-
-    public List<LIRBlock> getPredecessors() {
-        // TODO Auto-generated method stub
-        throw GraalInternalError.unimplemented("Auto-generated method stub");
-    }
-
-    public int getPredecessorCount() {
-        // TODO Auto-generated method stub
-        throw GraalInternalError.unimplemented("Auto-generated method stub");
-    }
-
-    public List<LIRBlock> getSuccessors() {
-        // TODO Auto-generated method stub
-        throw GraalInternalError.unimplemented("Auto-generated method stub");
-    }
-
-    public int getSuccessorCount() {
-        // TODO Auto-generated method stub
-        throw GraalInternalError.unimplemented("Auto-generated method stub");
-    }
-
-    public int getLinearScanNumber() {
-        // TODO Auto-generated method stub
-        throw GraalInternalError.unimplemented("Auto-generated method stub");
-    }
-
-    public void setLinearScanNumber(int linearScanNumber) {
-        // TODO Auto-generated method stub
-        throw GraalInternalError.unimplemented("Auto-generated method stub");
-    }
-
-    public boolean isAligned() {
-        // TODO Auto-generated method stub
-        throw GraalInternalError.unimplemented("Auto-generated method stub");
-    }
-
-    public void setAlign(boolean align) {
-        // TODO Auto-generated method stub
-        throw GraalInternalError.unimplemented("Auto-generated method stub");
-    }
-
-    public LIRBlock getDominator() {
-        // TODO Auto-generated method stub
-        throw GraalInternalError.unimplemented("Auto-generated method stub");
+        return false;
     }
 
 }