001/*
002 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation.
008 *
009 * This code is distributed in the hope that it will be useful, but WITHOUT
010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
011 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
012 * version 2 for more details (a copy is included in the LICENSE file that
013 * accompanied this code).
014 *
015 * You should have received a copy of the GNU General Public License version
016 * 2 along with this work; if not, write to the Free Software Foundation,
017 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
018 *
019 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
020 * or visit www.oracle.com if you need additional information or have any
021 * questions.
022 */
023package com.oracle.graal.replacements;
024
025import java.lang.annotation.*;
026
027import com.oracle.graal.replacements.nodes.*;
028
029/**
030 * A snippet is a Graal graph expressed as a Java source method. Snippets are used for lowering
031 * nodes that have runtime dependent semantics (e.g. the {@code CHECKCAST} bytecode).
032 */
033@Retention(RetentionPolicy.RUNTIME)
034@Target(ElementType.METHOD)
035public @interface Snippet {
036
037    /**
038     * Denotes a snippet parameter representing 0 or more arguments that will be bound during
039     * snippet template {@linkplain SnippetTemplate#instantiate instantiation}. During snippet
040     * template creation, its value must be an array whose length specifies the number of arguments
041     * (the contents of the array are ignored) bound to the parameter during
042     * {@linkplain SnippetTemplate#instantiate instantiation}.
043     *
044     * Such a parameter must be used in a counted loop in the snippet preceded by a call to
045     * {@link ExplodeLoopNode#explodeLoop()}. The counted looped must be a standard iteration over
046     * all the loop's elements (i.e. {@code for (T e : arr) ... }).
047     */
048    @Retention(RetentionPolicy.RUNTIME)
049    @Target(ElementType.PARAMETER)
050    public @interface VarargsParameter {
051    }
052
053    /**
054     * Denotes a snippet parameter that will bound to a constant value during snippet template
055     * {@linkplain SnippetTemplate#instantiate instantiation}.
056     */
057    @Retention(RetentionPolicy.RUNTIME)
058    @Target(ElementType.PARAMETER)
059    public @interface ConstantParameter {
060    }
061}