c1_Canonicalizer.hpp revision 1472:c18cbe5936b8
1/*
2 * Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25class Canonicalizer: InstructionVisitor {
26 private:
27  Instruction* _canonical;
28  int _bci;
29
30  void set_canonical(Value x);
31  void set_bci(int bci)                          { _bci = bci; }
32  void set_constant(jint x)                      { set_canonical(new Constant(new IntConstant(x))); }
33  void set_constant(jlong x)                     { set_canonical(new Constant(new LongConstant(x))); }
34  void set_constant(jfloat x)                    { set_canonical(new Constant(new FloatConstant(x))); }
35  void set_constant(jdouble x)                   { set_canonical(new Constant(new DoubleConstant(x))); }
36  void move_const_to_right(Op2* x);
37  void do_Op2(Op2* x);
38  void do_UnsafeRawOp(UnsafeRawOp* x);
39
40  void unsafe_raw_match(UnsafeRawOp* x,
41                        Instruction** base,
42                        Instruction** index,
43                        int* scale);
44
45 public:
46  Canonicalizer(Value x, int bci)                { _canonical = x; _bci = bci; if (CanonicalizeNodes) x->visit(this); }
47  Value canonical() const                        { return _canonical; }
48  int bci() const                                { return _bci; }
49
50  virtual void do_Phi            (Phi*             x);
51  virtual void do_Constant       (Constant*        x);
52  virtual void do_Local          (Local*           x);
53  virtual void do_LoadField      (LoadField*       x);
54  virtual void do_StoreField     (StoreField*      x);
55  virtual void do_ArrayLength    (ArrayLength*     x);
56  virtual void do_LoadIndexed    (LoadIndexed*     x);
57  virtual void do_StoreIndexed   (StoreIndexed*    x);
58  virtual void do_NegateOp       (NegateOp*        x);
59  virtual void do_ArithmeticOp   (ArithmeticOp*    x);
60  virtual void do_ShiftOp        (ShiftOp*         x);
61  virtual void do_LogicOp        (LogicOp*         x);
62  virtual void do_CompareOp      (CompareOp*       x);
63  virtual void do_IfOp           (IfOp*            x);
64  virtual void do_IfInstanceOf   (IfInstanceOf*    x);
65  virtual void do_Convert        (Convert*         x);
66  virtual void do_NullCheck      (NullCheck*       x);
67  virtual void do_Invoke         (Invoke*          x);
68  virtual void do_NewInstance    (NewInstance*     x);
69  virtual void do_NewTypeArray   (NewTypeArray*    x);
70  virtual void do_NewObjectArray (NewObjectArray*  x);
71  virtual void do_NewMultiArray  (NewMultiArray*   x);
72  virtual void do_CheckCast      (CheckCast*       x);
73  virtual void do_InstanceOf     (InstanceOf*      x);
74  virtual void do_MonitorEnter   (MonitorEnter*    x);
75  virtual void do_MonitorExit    (MonitorExit*     x);
76  virtual void do_Intrinsic      (Intrinsic*       x);
77  virtual void do_BlockBegin     (BlockBegin*      x);
78  virtual void do_Goto           (Goto*            x);
79  virtual void do_If             (If*              x);
80  virtual void do_TableSwitch    (TableSwitch*     x);
81  virtual void do_LookupSwitch   (LookupSwitch*    x);
82  virtual void do_Return         (Return*          x);
83  virtual void do_Throw          (Throw*           x);
84  virtual void do_Base           (Base*            x);
85  virtual void do_OsrEntry       (OsrEntry*        x);
86  virtual void do_ExceptionObject(ExceptionObject* x);
87  virtual void do_RoundFP        (RoundFP*         x);
88  virtual void do_UnsafeGetRaw   (UnsafeGetRaw*    x);
89  virtual void do_UnsafePutRaw   (UnsafePutRaw*    x);
90  virtual void do_UnsafeGetObject(UnsafeGetObject* x);
91  virtual void do_UnsafePutObject(UnsafePutObject* x);
92  virtual void do_UnsafePrefetchRead (UnsafePrefetchRead*  x);
93  virtual void do_UnsafePrefetchWrite(UnsafePrefetchWrite* x);
94  virtual void do_ProfileCall    (ProfileCall*     x);
95  virtual void do_ProfileCounter (ProfileCounter*  x);
96};
97