SaveAllRegistersNode.java revision 12651:6ef01bd40ce2
1296341Sdelphij/* 2238405Sjkim * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. 3238405Sjkim * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4238405Sjkim * 5238405Sjkim * This code is free software; you can redistribute it and/or modify it 6238405Sjkim * under the terms of the GNU General Public License version 2 only, as 7238405Sjkim * published by the Free Software Foundation. 8238405Sjkim * 9238405Sjkim * This code is distributed in the hope that it will be useful, but WITHOUT 10238405Sjkim * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11238405Sjkim * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12238405Sjkim * version 2 for more details (a copy is included in the LICENSE file that 13238405Sjkim * accompanied this code). 14238405Sjkim * 15238405Sjkim * You should have received a copy of the GNU General Public License version 16238405Sjkim * 2 along with this work; if not, write to the Free Software Foundation, 17238405Sjkim * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18238405Sjkim * 19238405Sjkim * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20238405Sjkim * or visit www.oracle.com if you need additional information or have any 21238405Sjkim * questions. 22238405Sjkim */ 23238405Sjkimpackage org.graalvm.compiler.hotspot.nodes; 24238405Sjkim 25238405Sjkimimport jdk.vm.ci.meta.JavaKind; 26238405Sjkim 27238405Sjkimimport org.graalvm.compiler.core.common.LocationIdentity; 28238405Sjkimimport org.graalvm.compiler.core.common.type.StampFactory; 29238405Sjkimimport org.graalvm.compiler.graph.NodeClass; 30238405Sjkimimport org.graalvm.compiler.hotspot.HotSpotLIRGenerator; 31238405Sjkimimport org.graalvm.compiler.lir.StandardOp.SaveRegistersOp; 32238405Sjkimimport org.graalvm.compiler.nodeinfo.InputType; 33238405Sjkimimport org.graalvm.compiler.nodeinfo.NodeInfo; 34238405Sjkimimport org.graalvm.compiler.nodes.FixedWithNextNode; 35238405Sjkimimport org.graalvm.compiler.nodes.memory.MemoryCheckpoint; 36238405Sjkimimport org.graalvm.compiler.nodes.spi.LIRLowerable; 37238405Sjkimimport org.graalvm.compiler.nodes.spi.NodeLIRBuilderTool; 38238405Sjkim 39238405Sjkim/** 40238405Sjkim * Saves all allocatable registers. 41279264Sdelphij */ 42279264Sdelphij@NodeInfo(allowedUsageTypes = {InputType.Memory}) 43238405Sjkimpublic final class SaveAllRegistersNode extends FixedWithNextNode implements LIRLowerable, MemoryCheckpoint.Single { 44238405Sjkim 45238405Sjkim public static final NodeClass<SaveAllRegistersNode> TYPE = NodeClass.create(SaveAllRegistersNode.class); 46238405Sjkim protected SaveRegistersOp saveRegistersOp; 47238405Sjkim 48238405Sjkim public SaveAllRegistersNode() { 49238405Sjkim super(TYPE, StampFactory.forKind(JavaKind.Long)); 50238405Sjkim } 51238405Sjkim 52238405Sjkim @Override 53279264Sdelphij public void generate(NodeLIRBuilderTool gen) { 54279264Sdelphij saveRegistersOp = ((HotSpotLIRGenerator) gen.getLIRGeneratorTool()).emitSaveAllRegisters(); 55279264Sdelphij } 56238405Sjkim 57279264Sdelphij /** 58279264Sdelphij * @return the map from registers to the stack locations in they are saved 59279264Sdelphij */ 60279264Sdelphij public SaveRegistersOp getSaveRegistersOp() { 61279264Sdelphij assert saveRegistersOp != null : "saved registers op has not yet been created"; 62279264Sdelphij return saveRegistersOp; 63238405Sjkim } 64279264Sdelphij 65279264Sdelphij /** 66279264Sdelphij * @return a token that couples this node to an {@link UncommonTrapCallNode} so that the latter 67279264Sdelphij * has access to the {@linkplain SaveRegistersOp#getMap register save map} 68279264Sdelphij */ 69238405Sjkim @NodeIntrinsic 70279264Sdelphij public static native long saveAllRegisters(); 71238405Sjkim 72238405Sjkim @Override 73238405Sjkim public LocationIdentity getLocationIdentity() { 74238405Sjkim return LocationIdentity.any(); 75238405Sjkim } 76238405Sjkim} 77238405Sjkim