< prev index next >

src/share/vm/c1/c1_LIRGenerator.hpp

Print this page
rev 12113 : 8166561: [s390] Adaptions needed for s390 port in C1 and C2.


  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 "c1/c1_Instruction.hpp"
  29 #include "c1/c1_LIR.hpp"
  30 #include "ci/ciMethodData.hpp"

  31 #include "utilities/sizes.hpp"
  32 
  33 // The classes responsible for code emission and register allocation
  34 
  35 
  36 class LIRGenerator;
  37 class LIREmitter;
  38 class Invoke;
  39 class SwitchRange;
  40 class LIRItem;
  41 
  42 typedef GrowableArray<LIRItem*> LIRItemList;
  43 
  44 class SwitchRange: public CompilationResourceObj {
  45  private:
  46   int _low_key;
  47   int _high_key;
  48   BlockBegin* _sux;
  49  public:
  50   SwitchRange(int start_key, BlockBegin* sux): _low_key(start_key), _high_key(start_key), _sux(sux) {}


 343 
 344   void arraycopy_helper(Intrinsic* x, int* flags, ciArrayKlass** expected_type);
 345 
 346   // returns a LIR_Address to address an array location.  May also
 347   // emit some code as part of address calculation.  If
 348   // needs_card_mark is true then compute the full address for use by
 349   // both the store and the card mark.
 350   LIR_Address* generate_address(LIR_Opr base,
 351                                 LIR_Opr index, int shift,
 352                                 int disp,
 353                                 BasicType type);
 354   LIR_Address* generate_address(LIR_Opr base, int disp, BasicType type) {
 355     return generate_address(base, LIR_OprFact::illegalOpr, 0, disp, type);
 356   }
 357   LIR_Address* emit_array_address(LIR_Opr array_opr, LIR_Opr index_opr, BasicType type, bool needs_card_mark);
 358 
 359   // the helper for generate_address
 360   void add_large_constant(LIR_Opr src, int c, LIR_Opr dest);
 361 
 362   // machine preferences and characteristics
 363   bool can_inline_as_constant(Value i) const;
 364   bool can_inline_as_constant(LIR_Const* c) const;
 365   bool can_store_as_constant(Value i, BasicType type) const;
 366 
 367   LIR_Opr safepoint_poll_register();
 368 
 369   void profile_branch(If* if_instr, If::Condition cond);
 370   void increment_event_counter_impl(CodeEmitInfo* info,
 371                                     ciMethod *method, int frequency,
 372                                     int bci, bool backedge, bool notify);
 373   void increment_event_counter(CodeEmitInfo* info, int bci, bool backedge);
 374   void increment_invocation_counter(CodeEmitInfo *info) {
 375     if (compilation()->count_invocations()) {
 376       increment_event_counter(info, InvocationEntryBci, false);
 377     }
 378   }
 379   void increment_backedge_counter(CodeEmitInfo* info, int bci) {
 380     if (compilation()->count_backedges()) {
 381       increment_event_counter(info, bci, true);
 382     }
 383   }


 479     , _virtual_register_number(LIR_OprDesc::vreg_base)
 480     , _vreg_flags(num_vreg_flags) {
 481     init();
 482   }
 483 
 484   // for virtual registers, maps them back to Phi's or Local's
 485   Instruction* instruction_for_opr(LIR_Opr opr);
 486   Instruction* instruction_for_vreg(int reg_num);
 487 
 488   void set_vreg_flag   (int vreg_num, VregFlag f);
 489   bool is_vreg_flag_set(int vreg_num, VregFlag f);
 490   void set_vreg_flag   (LIR_Opr opr,  VregFlag f) { set_vreg_flag(opr->vreg_number(), f); }
 491   bool is_vreg_flag_set(LIR_Opr opr,  VregFlag f) { return is_vreg_flag_set(opr->vreg_number(), f); }
 492 
 493   // statics
 494   static LIR_Opr exceptionOopOpr();
 495   static LIR_Opr exceptionPcOpr();
 496   static LIR_Opr divInOpr();
 497   static LIR_Opr divOutOpr();
 498   static LIR_Opr remOutOpr();






 499   static LIR_Opr shiftCountOpr();
 500   LIR_Opr syncLockOpr();
 501   LIR_Opr syncTempOpr();
 502   LIR_Opr atomicLockOpr();
 503 
 504   // returns a register suitable for saving the thread in a
 505   // call_runtime_leaf if one is needed.
 506   LIR_Opr getThreadTemp();
 507 
 508   // visitor functionality
 509   virtual void do_Phi            (Phi*             x);
 510   virtual void do_Local          (Local*           x);
 511   virtual void do_Constant       (Constant*        x);
 512   virtual void do_LoadField      (LoadField*       x);
 513   virtual void do_StoreField     (StoreField*      x);
 514   virtual void do_ArrayLength    (ArrayLength*     x);
 515   virtual void do_LoadIndexed    (LoadIndexed*     x);
 516   virtual void do_StoreIndexed   (StoreIndexed*    x);
 517   virtual void do_NegateOp       (NegateOp*        x);
 518   virtual void do_ArithmeticOp   (ArithmeticOp*    x);


 604   ValueType* type() const      { return value()->type(); }
 605   LIR_Opr result()             {
 606     assert(!_destroys_register || (!_result->is_register() || _result->is_virtual()),
 607            "shouldn't use set_destroys_register with physical regsiters");
 608     if (_destroys_register && _result->is_register()) {
 609       if (_new_result->is_illegal()) {
 610         _new_result = _gen->new_register(type());
 611         gen()->lir()->move(_result, _new_result);
 612       }
 613       return _new_result;
 614     } else {
 615       return _result;
 616     }
 617     return _result;
 618   }
 619 
 620   void set_result(LIR_Opr opr);
 621 
 622   void load_item();
 623   void load_byte_item();
 624   void load_nonconstant();
 625   // load any values which can't be expressed as part of a single store instruction
 626   void load_for_store(BasicType store_type);
 627   void load_item_force(LIR_Opr reg);
 628 
 629   void dont_load_item() {
 630     // do nothing
 631   }
 632 
 633   void set_destroys_register() {
 634     _destroys_register = true;
 635   }
 636 
 637   bool is_constant() const { return value()->as_Constant() != NULL; }
 638   bool is_stack()          { return result()->is_stack(); }
 639   bool is_register()       { return result()->is_register(); }
 640 
 641   ciObject* get_jobject_constant() const;
 642   jint      get_jint_constant() const;
 643   jlong     get_jlong_constant() const;
 644   jfloat    get_jfloat_constant() const;


  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 "c1/c1_Instruction.hpp"
  29 #include "c1/c1_LIR.hpp"
  30 #include "ci/ciMethodData.hpp"
  31 #include "utilities/macros.hpp"
  32 #include "utilities/sizes.hpp"
  33 
  34 // The classes responsible for code emission and register allocation
  35 
  36 
  37 class LIRGenerator;
  38 class LIREmitter;
  39 class Invoke;
  40 class SwitchRange;
  41 class LIRItem;
  42 
  43 typedef GrowableArray<LIRItem*> LIRItemList;
  44 
  45 class SwitchRange: public CompilationResourceObj {
  46  private:
  47   int _low_key;
  48   int _high_key;
  49   BlockBegin* _sux;
  50  public:
  51   SwitchRange(int start_key, BlockBegin* sux): _low_key(start_key), _high_key(start_key), _sux(sux) {}


 344 
 345   void arraycopy_helper(Intrinsic* x, int* flags, ciArrayKlass** expected_type);
 346 
 347   // returns a LIR_Address to address an array location.  May also
 348   // emit some code as part of address calculation.  If
 349   // needs_card_mark is true then compute the full address for use by
 350   // both the store and the card mark.
 351   LIR_Address* generate_address(LIR_Opr base,
 352                                 LIR_Opr index, int shift,
 353                                 int disp,
 354                                 BasicType type);
 355   LIR_Address* generate_address(LIR_Opr base, int disp, BasicType type) {
 356     return generate_address(base, LIR_OprFact::illegalOpr, 0, disp, type);
 357   }
 358   LIR_Address* emit_array_address(LIR_Opr array_opr, LIR_Opr index_opr, BasicType type, bool needs_card_mark);
 359 
 360   // the helper for generate_address
 361   void add_large_constant(LIR_Opr src, int c, LIR_Opr dest);
 362 
 363   // machine preferences and characteristics
 364   bool can_inline_as_constant(Value i S390_ONLY(COMMA int bits = 20)) const;
 365   bool can_inline_as_constant(LIR_Const* c) const;
 366   bool can_store_as_constant(Value i, BasicType type) const;
 367 
 368   LIR_Opr safepoint_poll_register();
 369 
 370   void profile_branch(If* if_instr, If::Condition cond);
 371   void increment_event_counter_impl(CodeEmitInfo* info,
 372                                     ciMethod *method, int frequency,
 373                                     int bci, bool backedge, bool notify);
 374   void increment_event_counter(CodeEmitInfo* info, int bci, bool backedge);
 375   void increment_invocation_counter(CodeEmitInfo *info) {
 376     if (compilation()->count_invocations()) {
 377       increment_event_counter(info, InvocationEntryBci, false);
 378     }
 379   }
 380   void increment_backedge_counter(CodeEmitInfo* info, int bci) {
 381     if (compilation()->count_backedges()) {
 382       increment_event_counter(info, bci, true);
 383     }
 384   }


 480     , _virtual_register_number(LIR_OprDesc::vreg_base)
 481     , _vreg_flags(num_vreg_flags) {
 482     init();
 483   }
 484 
 485   // for virtual registers, maps them back to Phi's or Local's
 486   Instruction* instruction_for_opr(LIR_Opr opr);
 487   Instruction* instruction_for_vreg(int reg_num);
 488 
 489   void set_vreg_flag   (int vreg_num, VregFlag f);
 490   bool is_vreg_flag_set(int vreg_num, VregFlag f);
 491   void set_vreg_flag   (LIR_Opr opr,  VregFlag f) { set_vreg_flag(opr->vreg_number(), f); }
 492   bool is_vreg_flag_set(LIR_Opr opr,  VregFlag f) { return is_vreg_flag_set(opr->vreg_number(), f); }
 493 
 494   // statics
 495   static LIR_Opr exceptionOopOpr();
 496   static LIR_Opr exceptionPcOpr();
 497   static LIR_Opr divInOpr();
 498   static LIR_Opr divOutOpr();
 499   static LIR_Opr remOutOpr();
 500 #ifdef S390
 501   // On S390 we can do ldiv, lrem without RT call.
 502   static LIR_Opr ldivInOpr();
 503   static LIR_Opr ldivOutOpr();
 504   static LIR_Opr lremOutOpr();
 505 #endif
 506   static LIR_Opr shiftCountOpr();
 507   LIR_Opr syncLockOpr();
 508   LIR_Opr syncTempOpr();
 509   LIR_Opr atomicLockOpr();
 510 
 511   // returns a register suitable for saving the thread in a
 512   // call_runtime_leaf if one is needed.
 513   LIR_Opr getThreadTemp();
 514 
 515   // visitor functionality
 516   virtual void do_Phi            (Phi*             x);
 517   virtual void do_Local          (Local*           x);
 518   virtual void do_Constant       (Constant*        x);
 519   virtual void do_LoadField      (LoadField*       x);
 520   virtual void do_StoreField     (StoreField*      x);
 521   virtual void do_ArrayLength    (ArrayLength*     x);
 522   virtual void do_LoadIndexed    (LoadIndexed*     x);
 523   virtual void do_StoreIndexed   (StoreIndexed*    x);
 524   virtual void do_NegateOp       (NegateOp*        x);
 525   virtual void do_ArithmeticOp   (ArithmeticOp*    x);


 611   ValueType* type() const      { return value()->type(); }
 612   LIR_Opr result()             {
 613     assert(!_destroys_register || (!_result->is_register() || _result->is_virtual()),
 614            "shouldn't use set_destroys_register with physical regsiters");
 615     if (_destroys_register && _result->is_register()) {
 616       if (_new_result->is_illegal()) {
 617         _new_result = _gen->new_register(type());
 618         gen()->lir()->move(_result, _new_result);
 619       }
 620       return _new_result;
 621     } else {
 622       return _result;
 623     }
 624     return _result;
 625   }
 626 
 627   void set_result(LIR_Opr opr);
 628 
 629   void load_item();
 630   void load_byte_item();
 631   void load_nonconstant(S390_ONLY(int bits = 20));
 632   // load any values which can't be expressed as part of a single store instruction
 633   void load_for_store(BasicType store_type);
 634   void load_item_force(LIR_Opr reg);
 635 
 636   void dont_load_item() {
 637     // do nothing
 638   }
 639 
 640   void set_destroys_register() {
 641     _destroys_register = true;
 642   }
 643 
 644   bool is_constant() const { return value()->as_Constant() != NULL; }
 645   bool is_stack()          { return result()->is_stack(); }
 646   bool is_register()       { return result()->is_register(); }
 647 
 648   ciObject* get_jobject_constant() const;
 649   jint      get_jint_constant() const;
 650   jlong     get_jlong_constant() const;
 651   jfloat    get_jfloat_constant() const;
< prev index next >