/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* 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.
*
*/
#ifndef SHARE_VM_OPTO_IDEALKIT_HPP
#define SHARE_VM_OPTO_IDEALKIT_HPP
#include "opto/addnode.hpp"
#include "opto/cfgnode.hpp"
#include "opto/connode.hpp"
#include "opto/divnode.hpp"
#include "opto/graphKit.hpp"
#include "opto/mulnode.hpp"
#include "opto/phaseX.hpp"
#include "opto/subnode.hpp"
//-----------------------------------------------------------------------------
//----------------------------IdealKit-----------------------------------------
// Set of utilities for creating control flow and scalar SSA data flow.
// Control:
// if_then(left, relop, right)
// else_ (optional)
// end_if
// loop(iv variable, initial, relop, limit)
// - sets iv to initial for first trip
// - exits when relation on limit is true
// - the values of initial and limit should be loop invariant
// - no increment, must be explicitly coded
// - final value of iv is available after end_loop (until dead())
// end_loop
// make_label(number of gotos)
// goto_(label)
// bind(label)
// Data:
// ConI(integer constant) - create an integer constant
// set(variable, value) - assignment
// value(variable) - reference value
// dead(variable) - variable's value is no longer live
// increment(variable, value) - increment variable by value
// simple operations: AddI, SubI, AndI, LShiftI, etc.
// Example:
// Node* limit = ??
// IdealVariable i(kit), j(kit);
// declarations_done();
// Node* exit = make_label(1); // 1 goto
// set(j, ConI(0));
// loop(i, ConI(0), BoolTest::lt, limit); {
// if_then(value(i), BoolTest::gt, ConI(5)) {
// set(j, ConI(1));
// goto_(exit); dead(i);
// } end_if();
// increment(i, ConI(1));
// } end_loop(); dead(i);
// bind(exit);
//
// See string_indexOf for a more complete example.
class IdealKit;
// Variable definition for IdealKit
friend class IdealKit;
private:
int _id;
public:
IdealVariable(IdealKit &k);
};
friend class IdealVariable;
// The main state (called a cvstate for Control and Variables)
// contains both the current values of the variables and the
// current set of predecessor control edges. The variable values
// are managed via a Node [in(1)..in(_var_ct)], and the predecessor
// control edges managed via a RegionNode. The in(0) of the Node
// for variables points to the RegionNode for the control edges.
protected:
Compile * const C;
// Create a new cvstate filled with nulls
}
// This declares the position where vars are kept in the cvstate
// For some degree of consistency we use the TypeFunc enum to
// soak up spots in the inputs even though we only use early Control
// and Memory slots. (So far.)
#ifdef ASSERT
#endif
// Users should not care about slices only MergedMem so no access for them.
public:
~IdealKit() {
stop();
}
// Control
bool push_new_state = true);
void else_();
void end_if();
void loop(GraphKit* gkit, int nargs, IdealVariable& iv, Node* init, BoolTest::mask cmp, Node* limit,
void end_loop();
void declarations_done();
// Data
// TLS
// Pointers
// Raw address should be transformed regardless 'delay_transform' flag
// to produce canonical form CastX2P(offset).
Node* AddP(Node *base, Node *ptr, Node *off) { return _gvn.transform(new (C) AddPNode(base, ptr, off)); }
#ifdef _LP64
#else // _LP64
#endif // _LP64
// Memory operations
// This is the base version which is given an alias index.
const Type* t,
int adr_idx,
bool require_atomic_access = false);
// Return the new StoreXNode
int adr_idx,
bool require_atomic_access = false);
// Store a card mark ordered after store_oop
int oop_adr_idx,
int adr_idx);
// Trivial call
const char *leaf_name,
const char *leaf_name,
};
#endif // SHARE_VM_OPTO_IDEALKIT_HPP