1 /* 2 * Copyright (c) 2005, 2018, 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_VM_C1_C1_LIRGENERATOR_HPP 26 #define SHARE_VM_C1_C1_LIRGENERATOR_HPP 27 28 #include "gc/shared/c1/barrierSetC1.hpp" 29 #include "c1/c1_Decorators.hpp" 30 #include "c1/c1_Instruction.hpp" 31 #include "c1/c1_LIR.hpp" 32 #include "ci/ciMethodData.hpp" 33 #include "utilities/macros.hpp" 34 #include "utilities/sizes.hpp" 35 36 // The classes responsible for code emission and register allocation 37 38 39 class LIRGenerator; 40 class LIREmitter; 41 class Invoke; 42 class SwitchRange; 43 class LIRItem; 44 45 typedef GrowableArray<LIRItem*> LIRItemList; 46 47 class SwitchRange: public CompilationResourceObj { 48 private: 49 int _low_key; 50 int _high_key; 51 BlockBegin* _sux; 52 public: 53 SwitchRange(int start_key, BlockBegin* sux): _low_key(start_key), _high_key(start_key), _sux(sux) {} 54 void set_high_key(int key) { _high_key = key; } 55 56 int high_key() const { return _high_key; } 57 int low_key() const { return _low_key; } 58 BlockBegin* sux() const { return _sux; } 59 }; 60 61 typedef GrowableArray<SwitchRange*> SwitchRangeArray; 62 typedef GrowableArray<SwitchRange*> SwitchRangeList; 63 64 class ResolveNode; 65 66 typedef GrowableArray<ResolveNode*> NodeList; 67 68 // Node objects form a directed graph of LIR_Opr 69 // Edges between Nodes represent moves from one Node to its destinations 70 class ResolveNode: public CompilationResourceObj { 71 private: 72 LIR_Opr _operand; // the source or destinaton 73 NodeList _destinations; // for the operand 74 bool _assigned; // Value assigned to this Node? 75 bool _visited; // Node already visited? 76 bool _start_node; // Start node already visited? 77 78 public: 79 ResolveNode(LIR_Opr operand) 80 : _operand(operand) 81 , _assigned(false) 82 , _visited(false) 83 , _start_node(false) {}; 84 85 // accessors 86 LIR_Opr operand() const { return _operand; } 87 int no_of_destinations() const { return _destinations.length(); } 88 ResolveNode* destination_at(int i) { return _destinations.at(i); } 89 bool assigned() const { return _assigned; } 90 bool visited() const { return _visited; } 91 bool start_node() const { return _start_node; } 92 93 // modifiers 94 void append(ResolveNode* dest) { _destinations.append(dest); } 95 void set_assigned() { _assigned = true; } 96 void set_visited() { _visited = true; } 97 void set_start_node() { _start_node = true; } 98 }; 99 100 101 // This is shared state to be used by the PhiResolver so the operand 102 // arrays don't have to be reallocated for reach resolution. 103 class PhiResolverState: public CompilationResourceObj { 104 friend class PhiResolver; 105 106 private: 107 NodeList _virtual_operands; // Nodes where the operand is a virtual register 108 NodeList _other_operands; // Nodes where the operand is not a virtual register 109 NodeList _vreg_table; // Mapping from virtual register to Node 110 111 public: 112 PhiResolverState() {} 113 114 void reset(int max_vregs); 115 }; 116 117 118 // class used to move value of phi operand to phi function 119 class PhiResolver: public CompilationResourceObj { 120 private: 121 LIRGenerator* _gen; 122 PhiResolverState& _state; // temporary state cached by LIRGenerator 123 124 ResolveNode* _loop; 125 LIR_Opr _temp; 126 127 // access to shared state arrays 128 NodeList& virtual_operands() { return _state._virtual_operands; } 129 NodeList& other_operands() { return _state._other_operands; } 130 NodeList& vreg_table() { return _state._vreg_table; } 131 132 ResolveNode* create_node(LIR_Opr opr, bool source); 133 ResolveNode* source_node(LIR_Opr opr) { return create_node(opr, true); } 134 ResolveNode* destination_node(LIR_Opr opr) { return create_node(opr, false); } 135 136 void emit_move(LIR_Opr src, LIR_Opr dest); 137 void move_to_temp(LIR_Opr src); 138 void move_temp_to(LIR_Opr dest); 139 void move(ResolveNode* src, ResolveNode* dest); 140 141 LIRGenerator* gen() { 142 return _gen; 143 } 144 145 public: 146 PhiResolver(LIRGenerator* _lir_gen, int max_vregs); 147 ~PhiResolver(); 148 149 void move(LIR_Opr src, LIR_Opr dest); 150 }; 151 152 153 // only the classes below belong in the same file 154 class LIRGenerator: public InstructionVisitor, public BlockClosure { 155 friend class BarrierSetC1; 156 friend class ModRefBarrierSetC1; 157 friend class CardTableBarrierSetC1; 158 friend class G1BarrierSetC1; 159 // LIRGenerator should never get instatiated on the heap. 160 private: 161 void* operator new(size_t size) throw(); 162 void* operator new[](size_t size) throw(); 163 void operator delete(void* p) { ShouldNotReachHere(); } 164 void operator delete[](void* p) { ShouldNotReachHere(); } 165 166 Compilation* _compilation; 167 ciMethod* _method; // method that we are compiling 168 PhiResolverState _resolver_state; 169 BlockBegin* _block; 170 int _virtual_register_number; 171 Values _instruction_for_operand; 172 BitMap2D _vreg_flags; // flags which can be set on a per-vreg basis 173 LIR_List* _lir; 174 175 LIRGenerator* gen() { 176 return this; 177 } 178 179 void print_if_not_loaded(const NewInstance* new_instance) PRODUCT_RETURN; 180 181 #ifdef ASSERT 182 LIR_List* lir(const char * file, int line) const { 183 _lir->set_file_and_line(file, line); 184 return _lir; 185 } 186 #endif 187 LIR_List* lir() const { 188 return _lir; 189 } 190 191 // a simple cache of constants used within a block 192 GrowableArray<LIR_Const*> _constants; 193 LIR_OprList _reg_for_constants; 194 Values _unpinned_constants; 195 196 friend class PhiResolver; 197 198 // unified bailout support 199 void bailout(const char* msg) const { compilation()->bailout(msg); } 200 bool bailed_out() const { return compilation()->bailed_out(); } 201 202 void block_do_prolog(BlockBegin* block); 203 void block_do_epilog(BlockBegin* block); 204 205 // register allocation 206 LIR_Opr rlock(Value instr); // lock a free register 207 LIR_Opr rlock_result(Value instr); 208 LIR_Opr rlock_result(Value instr, BasicType type); 209 LIR_Opr rlock_byte(BasicType type); 210 LIR_Opr rlock_callee_saved(BasicType type); 211 212 // get a constant into a register and get track of what register was used 213 LIR_Opr load_constant(Constant* x); 214 LIR_Opr load_constant(LIR_Const* constant); 215 216 // Given an immediate value, return an operand usable in logical ops. 217 LIR_Opr load_immediate(int x, BasicType type); 218 219 void set_result(Value x, LIR_Opr opr) { 220 assert(opr->is_valid(), "must set to valid value"); 221 assert(x->operand()->is_illegal(), "operand should never change"); 222 assert(!opr->is_register() || opr->is_virtual(), "should never set result to a physical register"); 223 x->set_operand(opr); 224 assert(opr == x->operand(), "must be"); 225 if (opr->is_virtual()) { 226 _instruction_for_operand.at_put_grow(opr->vreg_number(), x, NULL); 227 } 228 } 229 void set_no_result(Value x) { assert(!x->has_uses(), "can't have use"); x->clear_operand(); } 230 231 friend class LIRItem; 232 233 LIR_Opr round_item(LIR_Opr opr); 234 LIR_Opr force_to_spill(LIR_Opr value, BasicType t); 235 236 PhiResolverState& resolver_state() { return _resolver_state; } 237 238 void move_to_phi(PhiResolver* resolver, Value cur_val, Value sux_val); 239 void move_to_phi(ValueStack* cur_state); 240 241 // code emission 242 void do_ArithmeticOp_Long (ArithmeticOp* x); 243 void do_ArithmeticOp_Int (ArithmeticOp* x); 244 void do_ArithmeticOp_FPU (ArithmeticOp* x); 245 246 // platform dependent 247 LIR_Opr getThreadPointer(); 248 249 void do_RegisterFinalizer(Intrinsic* x); 250 void do_isInstance(Intrinsic* x); 251 void do_isPrimitive(Intrinsic* x); 252 void do_getClass(Intrinsic* x); 253 void do_currentThread(Intrinsic* x); 254 void do_FmaIntrinsic(Intrinsic* x); 255 void do_MathIntrinsic(Intrinsic* x); 256 void do_LibmIntrinsic(Intrinsic* x); 257 void do_ArrayCopy(Intrinsic* x); 258 void do_CompareAndSwap(Intrinsic* x, ValueType* type); 259 void do_NIOCheckIndex(Intrinsic* x); 260 void do_FPIntrinsics(Intrinsic* x); 261 void do_Reference_get(Intrinsic* x); 262 void do_update_CRC32(Intrinsic* x); 263 void do_update_CRC32C(Intrinsic* x); 264 void do_vectorizedMismatch(Intrinsic* x); 265 266 LIR_Opr call_runtime(BasicTypeArray* signature, LIRItemList* args, address entry, ValueType* result_type, CodeEmitInfo* info); 267 LIR_Opr call_runtime(BasicTypeArray* signature, LIR_OprList* args, address entry, ValueType* result_type, CodeEmitInfo* info); 268 269 // convenience functions 270 LIR_Opr call_runtime(Value arg1, address entry, ValueType* result_type, CodeEmitInfo* info); 271 LIR_Opr call_runtime(Value arg1, Value arg2, address entry, ValueType* result_type, CodeEmitInfo* info); 272 273 // GC Barriers 274 275 // generic interface 276 277 void access_store_at(DecoratorSet decorators, BasicType type, 278 LIRItem& base, LIR_Opr offset, LIR_Opr value, 279 CodeEmitInfo* patch_info, CodeEmitInfo* store_emit_info); 280 281 void access_load_at(DecoratorSet decorators, BasicType type, 282 LIRItem& base, LIR_Opr offset, LIR_Opr result, 283 CodeEmitInfo* patch_info, CodeEmitInfo* load_emit_info); 284 285 LIR_Opr access_atomic_cmpxchg_at(DecoratorSet decorators, BasicType type, 286 LIRItem& base, LIRItem& offset, LIRItem& cmp_value, LIRItem& new_value); 287 288 LIR_Opr access_atomic_xchg_at(DecoratorSet decorators, BasicType type, 289 LIRItem& base, LIRItem& offset, LIRItem& value); 290 291 LIR_Opr access_atomic_add_at(DecoratorSet decorators, BasicType type, 292 LIRItem& base, LIRItem& offset, LIRItem& value); 293 294 // These need to guarantee JMM volatile semantics are preserved on each platform 295 // and requires one implementation per architecture. 296 LIR_Opr atomic_cmpxchg(BasicType type, LIR_Opr addr, LIRItem& cmp_value, LIRItem& new_value); 297 LIR_Opr atomic_xchg(BasicType type, LIR_Opr addr, LIRItem& new_value); 298 LIR_Opr atomic_add(BasicType type, LIR_Opr addr, LIRItem& new_value); 299 300 // specific implementations 301 void array_store_check(LIR_Opr value, LIR_Opr array, CodeEmitInfo* store_check_info, ciMethod* profiled_method, int profiled_bci); 302 303 static LIR_Opr result_register_for(ValueType* type, bool callee = false); 304 305 ciObject* get_jobject_constant(Value value); 306 307 LIRItemList* invoke_visit_arguments(Invoke* x); 308 void invoke_load_arguments(Invoke* x, LIRItemList* args, const LIR_OprList* arg_list); 309 310 void trace_block_entry(BlockBegin* block); 311 312 // volatile field operations are never patchable because a klass 313 // must be loaded to know it's volatile which means that the offset 314 // it always known as well. 315 void volatile_field_store(LIR_Opr value, LIR_Address* address, CodeEmitInfo* info); 316 void volatile_field_load(LIR_Address* address, LIR_Opr result, CodeEmitInfo* info); 317 318 void put_Object_unsafe(LIR_Opr src, LIR_Opr offset, LIR_Opr data, BasicType type, bool is_volatile); 319 void get_Object_unsafe(LIR_Opr dest, LIR_Opr src, LIR_Opr offset, BasicType type, bool is_volatile); 320 321 void arithmetic_call_op (Bytecodes::Code code, LIR_Opr result, LIR_OprList* args); 322 323 void increment_counter(address counter, BasicType type, int step = 1); 324 void increment_counter(LIR_Address* addr, int step = 1); 325 326 // is_strictfp is only needed for mul and div (and only generates different code on i486) 327 void arithmetic_op(Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, bool is_strictfp, LIR_Opr tmp, CodeEmitInfo* info = NULL); 328 // machine dependent. returns true if it emitted code for the multiply 329 bool strength_reduce_multiply(LIR_Opr left, jint constant, LIR_Opr result, LIR_Opr tmp); 330 331 void store_stack_parameter (LIR_Opr opr, ByteSize offset_from_sp_in_bytes); 332 333 void klass2reg_with_patching(LIR_Opr r, ciMetadata* obj, CodeEmitInfo* info, bool need_resolve = false); 334 335 // this loads the length and compares against the index 336 void array_range_check (LIR_Opr array, LIR_Opr index, CodeEmitInfo* null_check_info, CodeEmitInfo* range_check_info); 337 // For java.nio.Buffer.checkIndex 338 void nio_range_check (LIR_Opr buffer, LIR_Opr index, LIR_Opr result, CodeEmitInfo* info); 339 340 void arithmetic_op_int (Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, LIR_Opr tmp); 341 void arithmetic_op_long (Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, CodeEmitInfo* info = NULL); 342 void arithmetic_op_fpu (Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, bool is_strictfp, LIR_Opr tmp = LIR_OprFact::illegalOpr); 343 344 void shift_op (Bytecodes::Code code, LIR_Opr dst_reg, LIR_Opr value, LIR_Opr count, LIR_Opr tmp); 345 346 void logic_op (Bytecodes::Code code, LIR_Opr dst_reg, LIR_Opr left, LIR_Opr right); 347 348 void monitor_enter (LIR_Opr object, LIR_Opr lock, LIR_Opr hdr, LIR_Opr scratch, int monitor_no, CodeEmitInfo* info_for_exception, CodeEmitInfo* info); 349 void monitor_exit (LIR_Opr object, LIR_Opr lock, LIR_Opr hdr, LIR_Opr scratch, int monitor_no); 350 351 void new_instance (LIR_Opr dst, ciInstanceKlass* klass, bool is_unresolved, LIR_Opr scratch1, LIR_Opr scratch2, LIR_Opr scratch3, LIR_Opr scratch4, LIR_Opr klass_reg, CodeEmitInfo* info); 352 353 // machine dependent 354 void cmp_mem_int(LIR_Condition condition, LIR_Opr base, int disp, int c, CodeEmitInfo* info); 355 void cmp_reg_mem(LIR_Condition condition, LIR_Opr reg, LIR_Opr base, int disp, BasicType type, CodeEmitInfo* info); 356 357 void arraycopy_helper(Intrinsic* x, int* flags, ciArrayKlass** expected_type); 358 359 // returns a LIR_Address to address an array location. May also 360 // emit some code as part of address calculation. If 361 // needs_card_mark is true then compute the full address for use by 362 // both the store and the card mark. 363 LIR_Address* generate_address(LIR_Opr base, 364 LIR_Opr index, int shift, 365 int disp, 366 BasicType type); 367 LIR_Address* generate_address(LIR_Opr base, int disp, BasicType type) { 368 return generate_address(base, LIR_OprFact::illegalOpr, 0, disp, type); 369 } 370 LIR_Address* emit_array_address(LIR_Opr array_opr, LIR_Opr index_opr, BasicType type); 371 372 // the helper for generate_address 373 void add_large_constant(LIR_Opr src, int c, LIR_Opr dest); 374 375 // machine preferences and characteristics 376 bool can_inline_as_constant(Value i S390_ONLY(COMMA int bits = 20)) const; 377 bool can_inline_as_constant(LIR_Const* c) const; 378 bool can_store_as_constant(Value i, BasicType type) const; 379 380 LIR_Opr safepoint_poll_register(); 381 382 void profile_branch(If* if_instr, If::Condition cond); 383 void increment_event_counter_impl(CodeEmitInfo* info, 384 ciMethod *method, int frequency, 385 int bci, bool backedge, bool notify); 386 void increment_event_counter(CodeEmitInfo* info, int bci, bool backedge); 387 void increment_invocation_counter(CodeEmitInfo *info) { 388 if (compilation()->count_invocations()) { 389 increment_event_counter(info, InvocationEntryBci, false); 390 } 391 } 392 void increment_backedge_counter(CodeEmitInfo* info, int bci) { 393 if (compilation()->count_backedges()) { 394 increment_event_counter(info, bci, true); 395 } 396 } 397 void decrement_age(CodeEmitInfo* info); 398 CodeEmitInfo* state_for(Instruction* x, ValueStack* state, bool ignore_xhandler = false); 399 CodeEmitInfo* state_for(Instruction* x); 400 401 // allocates a virtual register for this instruction if 402 // one isn't already allocated. Only for Phi and Local. 403 LIR_Opr operand_for_instruction(Instruction *x); 404 405 void set_block(BlockBegin* block) { _block = block; } 406 407 void block_prolog(BlockBegin* block); 408 void block_epilog(BlockBegin* block); 409 410 void do_root (Instruction* instr); 411 void walk (Instruction* instr); 412 413 void bind_block_entry(BlockBegin* block); 414 void start_block(BlockBegin* block); 415 416 LIR_Opr new_register(BasicType type); 417 LIR_Opr new_register(Value value) { return new_register(as_BasicType(value->type())); } 418 LIR_Opr new_register(ValueType* type) { return new_register(as_BasicType(type)); } 419 420 // returns a register suitable for doing pointer math 421 LIR_Opr new_pointer_register() { 422 #ifdef _LP64 423 return new_register(T_LONG); 424 #else 425 return new_register(T_INT); 426 #endif 427 } 428 429 static LIR_Condition lir_cond(If::Condition cond) { 430 LIR_Condition l = lir_cond_unknown; 431 switch (cond) { 432 case If::eql: l = lir_cond_equal; break; 433 case If::neq: l = lir_cond_notEqual; break; 434 case If::lss: l = lir_cond_less; break; 435 case If::leq: l = lir_cond_lessEqual; break; 436 case If::geq: l = lir_cond_greaterEqual; break; 437 case If::gtr: l = lir_cond_greater; break; 438 case If::aeq: l = lir_cond_aboveEqual; break; 439 case If::beq: l = lir_cond_belowEqual; break; 440 default: fatal("You must pass valid If::Condition"); 441 }; 442 return l; 443 } 444 445 #ifdef __SOFTFP__ 446 void do_soft_float_compare(If *x); 447 #endif // __SOFTFP__ 448 449 SwitchRangeArray* create_lookup_ranges(TableSwitch* x); 450 SwitchRangeArray* create_lookup_ranges(LookupSwitch* x); 451 void do_SwitchRanges(SwitchRangeArray* x, LIR_Opr value, BlockBegin* default_sux); 452 453 #ifdef TRACE_HAVE_INTRINSICS 454 void do_ClassIDIntrinsic(Intrinsic* x); 455 void do_getBufferWriter(Intrinsic* x); 456 #endif 457 458 void do_RuntimeCall(address routine, Intrinsic* x); 459 460 ciKlass* profile_type(ciMethodData* md, int md_first_offset, int md_offset, intptr_t profiled_k, 461 Value arg, LIR_Opr& mdp, bool not_null, ciKlass* signature_at_call_k, 462 ciKlass* callee_signature_k); 463 void profile_arguments(ProfileCall* x); 464 void profile_parameters(Base* x); 465 void profile_parameters_at_call(ProfileCall* x); 466 LIR_Opr mask_boolean(LIR_Opr array, LIR_Opr value, CodeEmitInfo*& null_check_info); 467 LIR_Opr maybe_mask_boolean(StoreIndexed* x, LIR_Opr array, LIR_Opr value, CodeEmitInfo*& null_check_info); 468 469 public: 470 Compilation* compilation() const { return _compilation; } 471 FrameMap* frame_map() const { return _compilation->frame_map(); } 472 ciMethod* method() const { return _method; } 473 BlockBegin* block() const { return _block; } 474 IRScope* scope() const { return block()->scope(); } 475 476 int max_virtual_register_number() const { return _virtual_register_number; } 477 478 void block_do(BlockBegin* block); 479 480 // Flags that can be set on vregs 481 enum VregFlag { 482 must_start_in_memory = 0 // needs to be assigned a memory location at beginning, but may then be loaded in a register 483 , callee_saved = 1 // must be in a callee saved register 484 , byte_reg = 2 // must be in a byte register 485 , num_vreg_flags 486 487 }; 488 489 LIRGenerator(Compilation* compilation, ciMethod* method) 490 : _compilation(compilation) 491 , _method(method) 492 , _virtual_register_number(LIR_OprDesc::vreg_base) 493 , _vreg_flags(num_vreg_flags) { 494 } 495 496 // for virtual registers, maps them back to Phi's or Local's 497 Instruction* instruction_for_opr(LIR_Opr opr); 498 Instruction* instruction_for_vreg(int reg_num); 499 500 void set_vreg_flag (int vreg_num, VregFlag f); 501 bool is_vreg_flag_set(int vreg_num, VregFlag f); 502 void set_vreg_flag (LIR_Opr opr, VregFlag f) { set_vreg_flag(opr->vreg_number(), f); } 503 bool is_vreg_flag_set(LIR_Opr opr, VregFlag f) { return is_vreg_flag_set(opr->vreg_number(), f); } 504 505 // statics 506 static LIR_Opr exceptionOopOpr(); 507 static LIR_Opr exceptionPcOpr(); 508 static LIR_Opr divInOpr(); 509 static LIR_Opr divOutOpr(); 510 static LIR_Opr remOutOpr(); 511 #ifdef S390 512 // On S390 we can do ldiv, lrem without RT call. 513 static LIR_Opr ldivInOpr(); 514 static LIR_Opr ldivOutOpr(); 515 static LIR_Opr lremOutOpr(); 516 #endif 517 static LIR_Opr shiftCountOpr(); 518 LIR_Opr syncLockOpr(); 519 LIR_Opr syncTempOpr(); 520 LIR_Opr atomicLockOpr(); 521 522 // returns a register suitable for saving the thread in a 523 // call_runtime_leaf if one is needed. 524 LIR_Opr getThreadTemp(); 525 526 // visitor functionality 527 virtual void do_Phi (Phi* x); 528 virtual void do_Local (Local* x); 529 virtual void do_Constant (Constant* x); 530 virtual void do_LoadField (LoadField* x); 531 virtual void do_StoreField (StoreField* x); 532 virtual void do_ArrayLength (ArrayLength* x); 533 virtual void do_LoadIndexed (LoadIndexed* x); 534 virtual void do_StoreIndexed (StoreIndexed* x); 535 virtual void do_NegateOp (NegateOp* x); 536 virtual void do_ArithmeticOp (ArithmeticOp* x); 537 virtual void do_ShiftOp (ShiftOp* x); 538 virtual void do_LogicOp (LogicOp* x); 539 virtual void do_CompareOp (CompareOp* x); 540 virtual void do_IfOp (IfOp* x); 541 virtual void do_Convert (Convert* x); 542 virtual void do_NullCheck (NullCheck* x); 543 virtual void do_TypeCast (TypeCast* x); 544 virtual void do_Invoke (Invoke* x); 545 virtual void do_NewInstance (NewInstance* x); 546 virtual void do_NewTypeArray (NewTypeArray* x); 547 virtual void do_NewObjectArray (NewObjectArray* x); 548 virtual void do_NewMultiArray (NewMultiArray* x); 549 virtual void do_CheckCast (CheckCast* x); 550 virtual void do_InstanceOf (InstanceOf* x); 551 virtual void do_MonitorEnter (MonitorEnter* x); 552 virtual void do_MonitorExit (MonitorExit* x); 553 virtual void do_Intrinsic (Intrinsic* x); 554 virtual void do_BlockBegin (BlockBegin* x); 555 virtual void do_Goto (Goto* x); 556 virtual void do_If (If* x); 557 virtual void do_IfInstanceOf (IfInstanceOf* x); 558 virtual void do_TableSwitch (TableSwitch* x); 559 virtual void do_LookupSwitch (LookupSwitch* x); 560 virtual void do_Return (Return* x); 561 virtual void do_Throw (Throw* x); 562 virtual void do_Base (Base* x); 563 virtual void do_OsrEntry (OsrEntry* x); 564 virtual void do_ExceptionObject(ExceptionObject* x); 565 virtual void do_RoundFP (RoundFP* x); 566 virtual void do_UnsafeGetRaw (UnsafeGetRaw* x); 567 virtual void do_UnsafePutRaw (UnsafePutRaw* x); 568 virtual void do_UnsafeGetObject(UnsafeGetObject* x); 569 virtual void do_UnsafePutObject(UnsafePutObject* x); 570 virtual void do_UnsafeGetAndSetObject(UnsafeGetAndSetObject* x); 571 virtual void do_ProfileCall (ProfileCall* x); 572 virtual void do_ProfileReturnType (ProfileReturnType* x); 573 virtual void do_ProfileInvoke (ProfileInvoke* x); 574 virtual void do_RuntimeCall (RuntimeCall* x); 575 virtual void do_MemBar (MemBar* x); 576 virtual void do_RangeCheckPredicate(RangeCheckPredicate* x); 577 #ifdef ASSERT 578 virtual void do_Assert (Assert* x); 579 #endif 580 581 #ifdef C1_LIRGENERATOR_MD_HPP 582 #include C1_LIRGENERATOR_MD_HPP 583 #endif 584 }; 585 586 587 class LIRItem: public CompilationResourceObj { 588 private: 589 Value _value; 590 LIRGenerator* _gen; 591 LIR_Opr _result; 592 bool _destroys_register; 593 LIR_Opr _new_result; 594 595 LIRGenerator* gen() const { return _gen; } 596 597 public: 598 LIRItem(Value value, LIRGenerator* gen) { 599 _destroys_register = false; 600 _gen = gen; 601 set_instruction(value); 602 } 603 604 LIRItem(LIRGenerator* gen) { 605 _destroys_register = false; 606 _gen = gen; 607 _result = LIR_OprFact::illegalOpr; 608 set_instruction(NULL); 609 } 610 611 void set_instruction(Value value) { 612 _value = value; 613 _result = LIR_OprFact::illegalOpr; 614 if (_value != NULL) { 615 _gen->walk(_value); 616 _result = _value->operand(); 617 } 618 _new_result = LIR_OprFact::illegalOpr; 619 } 620 621 Value value() const { return _value; } 622 ValueType* type() const { return value()->type(); } 623 LIR_Opr result() { 624 assert(!_destroys_register || (!_result->is_register() || _result->is_virtual()), 625 "shouldn't use set_destroys_register with physical regsiters"); 626 if (_destroys_register && _result->is_register()) { 627 if (_new_result->is_illegal()) { 628 _new_result = _gen->new_register(type()); 629 gen()->lir()->move(_result, _new_result); 630 } 631 return _new_result; 632 } else { 633 return _result; 634 } 635 return _result; 636 } 637 638 void set_result(LIR_Opr opr); 639 640 void load_item(); 641 void load_byte_item(); 642 void load_nonconstant(S390_ONLY(int bits = 20)); 643 // load any values which can't be expressed as part of a single store instruction 644 void load_for_store(BasicType store_type); 645 void load_item_force(LIR_Opr reg); 646 647 void dont_load_item() { 648 // do nothing 649 } 650 651 void set_destroys_register() { 652 _destroys_register = true; 653 } 654 655 bool is_constant() const { return value()->as_Constant() != NULL; } 656 bool is_stack() { return result()->is_stack(); } 657 bool is_register() { return result()->is_register(); } 658 659 ciObject* get_jobject_constant() const; 660 jint get_jint_constant() const; 661 jlong get_jlong_constant() const; 662 jfloat get_jfloat_constant() const; 663 jdouble get_jdouble_constant() const; 664 jint get_address_constant() const; 665 }; 666 667 #endif // SHARE_VM_C1_C1_LIRGENERATOR_HPP