1 /*
  2  * Copyright (c) 1997, 2023, 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 
 25 #ifndef SHARE_OPTO_CONNODE_HPP
 26 #define SHARE_OPTO_CONNODE_HPP
 27 
 28 #include "opto/node.hpp"
 29 #include "opto/opcodes.hpp"
 30 #include "opto/type.hpp"
 31 
 32 class PhaseTransform;
 33 class MachNode;
 34 
 35 //------------------------------ConNode----------------------------------------
 36 // Simple constants
 37 class ConNode : public TypeNode {
 38 public:
 39   ConNode( const Type *t ) : TypeNode(t->remove_speculative(),1) {
 40     init_req(0, (Node*)Compile::current()->root());
 41     init_flags(Flag_is_Con);
 42     init_class_id(Class_Con);
 43   }
 44   virtual int  Opcode() const;
 45   virtual uint hash() const;
 46   virtual const RegMask &out_RegMask() const { return RegMask::Empty; }
 47   virtual const RegMask &in_RegMask(uint) const { return RegMask::Empty; }
 48 
 49   // Polymorphic factory method:
 50   static ConNode* make(const Type *t);
 51 };
 52 
 53 //------------------------------ConINode---------------------------------------
 54 // Simple integer constants
 55 class ConINode : public ConNode {
 56 public:
 57   ConINode(const TypeInt* t) : ConNode(t) {
 58     init_class_id(Class_ConI);
 59   }
 60   virtual int Opcode() const;
 61 
 62   // Factory method:
 63   static ConINode* make(int con) {
 64     return new ConINode( TypeInt::make(con) );
 65   }
 66 
 67 };
 68 
 69 //------------------------------ConPNode---------------------------------------
 70 // Simple pointer constants
 71 class ConPNode : public ConNode {
 72 public:
 73   ConPNode(const TypePtr *t) : ConNode(t) {}
 74   virtual int Opcode() const;
 75 
 76   // Factory methods:
 77   static ConPNode* make(address con) {
 78     if (con == nullptr) {
 79       return new ConPNode(TypePtr::NULL_PTR);
 80     } else {
 81       return new ConPNode(TypeRawPtr::make(con));
 82     }
 83   }
 84 };
 85 
 86 
 87 //------------------------------ConNNode--------------------------------------
 88 // Simple narrow oop constants
 89 class ConNNode : public ConNode {
 90 public:
 91   ConNNode( const TypeNarrowOop *t ) : ConNode(t) {}
 92   virtual int Opcode() const;
 93 };
 94 
 95 //------------------------------ConNKlassNode---------------------------------
 96 // Simple narrow klass constants
 97 class ConNKlassNode : public ConNode {
 98 public:
 99   ConNKlassNode( const TypeNarrowKlass *t ) : ConNode(t) {}
100   virtual int Opcode() const;
101 };
102 
103 
104 //------------------------------ConLNode---------------------------------------
105 // Simple long constants
106 class ConLNode : public ConNode {
107 public:
108   ConLNode( const TypeLong *t ) : ConNode(t) {}
109   virtual int Opcode() const;
110 
111   // Factory method:
112   static ConLNode* make(jlong con) {
113     return new ConLNode( TypeLong::make(con) );
114   }
115 
116 };
117 
118 //------------------------------ConFNode---------------------------------------
119 // Simple float constants
120 class ConFNode : public ConNode {
121 public:
122   ConFNode( const TypeF *t ) : ConNode(t) {}
123   virtual int Opcode() const;
124 
125   // Factory method:
126   static ConFNode* make(float con) {
127     return new ConFNode( TypeF::make(con) );
128   }
129 
130 };
131 
132 //------------------------------ConDNode---------------------------------------
133 // Simple double constants
134 class ConDNode : public ConNode {
135 public:
136   ConDNode( const TypeD *t ) : ConNode(t) {}
137   virtual int Opcode() const;
138 
139   // Factory method:
140   static ConDNode* make(double con) {
141     return new ConDNode( TypeD::make(con) );
142   }
143 
144 };
145 
146 //------------------------------ThreadLocalNode--------------------------------
147 // Ideal Node which returns the base of ThreadLocalStorage.
148 class ThreadLocalNode : public Node {
149 public:
150     ThreadLocalNode( ) : Node((Node*)Compile::current()->root()) {}
151     virtual int Opcode() const;
152     virtual const Type *bottom_type() const { return TypeRawPtr::BOTTOM;}
153     virtual uint ideal_reg() const { return Op_RegP; }
154 };
155 
156 
157 
158 #endif // SHARE_OPTO_CONNODE_HPP