1 /*
  2  * Copyright (c) 1997, 2025, 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   virtual Node* Ideal(PhaseGVN* phase, bool can_reshape) {
 50     return Node::Ideal(phase, can_reshape);
 51   }
 52 
 53   // Polymorphic factory method:
 54   static ConNode* make(const Type *t);
 55 };
 56 
 57 //------------------------------ConINode---------------------------------------
 58 // Simple integer constants
 59 class ConINode : public ConNode {
 60 public:
 61   ConINode(const TypeInt* t) : ConNode(t) {
 62     init_class_id(Class_ConI);
 63   }
 64   virtual int Opcode() const;
 65 
 66   // Factory method:
 67   static ConINode* make(int con) {
 68     return new ConINode( TypeInt::make(con) );
 69   }
 70 
 71 };
 72 
 73 //------------------------------ConPNode---------------------------------------
 74 // Simple pointer constants
 75 class ConPNode : public ConNode {
 76 public:
 77   ConPNode(const TypePtr *t) : ConNode(t) {}
 78   virtual int Opcode() const;
 79 
 80   // Factory methods:
 81   static ConPNode* make(address con) {
 82     if (con == nullptr) {
 83       return new ConPNode(TypePtr::NULL_PTR);
 84     } else {
 85       return new ConPNode(TypeRawPtr::make(con));
 86     }
 87   }
 88 };
 89 
 90 
 91 //------------------------------ConNNode--------------------------------------
 92 // Simple narrow oop constants
 93 class ConNNode : public ConNode {
 94 public:
 95   ConNNode( const TypeNarrowOop *t ) : ConNode(t) {}
 96   virtual int Opcode() const;
 97 };
 98 
 99 //------------------------------ConNKlassNode---------------------------------
100 // Simple narrow klass constants
101 class ConNKlassNode : public ConNode {
102 public:
103   ConNKlassNode( const TypeNarrowKlass *t ) : ConNode(t) {}
104   virtual int Opcode() const;
105 };
106 
107 
108 //------------------------------ConLNode---------------------------------------
109 // Simple long constants
110 class ConLNode : public ConNode {
111 public:
112   ConLNode( const TypeLong *t ) : ConNode(t) {}
113   virtual int Opcode() const;
114 
115   // Factory method:
116   static ConLNode* make(jlong con) {
117     return new ConLNode( TypeLong::make(con) );
118   }
119 
120 };
121 
122 //------------------------------ConHNode---------------------------------------
123 // Simple half float constants
124 class ConHNode : public ConNode {
125 public:
126   ConHNode(const TypeH* t) : ConNode(t) {}
127   virtual int Opcode() const;
128 
129   // Factory method:
130   static ConHNode* make(float con) {
131     return new ConHNode(TypeH::make(con));
132   }
133 };
134 
135 //------------------------------ConFNode---------------------------------------
136 // Simple float constants
137 class ConFNode : public ConNode {
138 public:
139   ConFNode( const TypeF *t ) : ConNode(t) {}
140   virtual int Opcode() const;
141 
142   // Factory method:
143   static ConFNode* make(float con) {
144     return new ConFNode( TypeF::make(con) );
145   }
146 
147 };
148 
149 //------------------------------ConDNode---------------------------------------
150 // Simple double constants
151 class ConDNode : public ConNode {
152 public:
153   ConDNode( const TypeD *t ) : ConNode(t) {}
154   virtual int Opcode() const;
155 
156   // Factory method:
157   static ConDNode* make(double con) {
158     return new ConDNode( TypeD::make(con) );
159   }
160 
161 };
162 
163 //------------------------------ThreadLocalNode--------------------------------
164 // Ideal Node which returns the base of ThreadLocalStorage.
165 class ThreadLocalNode : public Node {
166 public:
167     ThreadLocalNode( ) : Node((Node*)Compile::current()->root()) {}
168     virtual int Opcode() const;
169     virtual const Type *bottom_type() const { return TypeRawPtr::BOTTOM;}
170     virtual uint ideal_reg() const { return Op_RegP; }
171 };
172 
173 
174 
175 #endif // SHARE_OPTO_CONNODE_HPP