< prev index next >

src/hotspot/share/c1/c1_LIR.hpp

Print this page
*** 1,7 ***
  /*
!  * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.
--- 1,7 ---
  /*
!  * Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.

*** 867,10 ***
--- 867,13 ---
  class      LIR_OpRoundFP;
  class    LIR_Op2;
  class    LIR_OpDelay;
  class    LIR_Op3;
  class      LIR_OpAllocArray;
+ #ifdef RISCV
+ class    LIR_Op4;
+ #endif
  class    LIR_OpCall;
  class      LIR_OpJavaCall;
  class      LIR_OpRTCall;
  class    LIR_OpArrayCopy;
  class    LIR_OpUpdateCRC32;

*** 911,26 ***
--- 914,34 ---
        , lir_push
        , lir_pop
        , lir_null_check
        , lir_return
        , lir_leal
+ #ifndef RISCV
        , lir_branch
        , lir_cond_float_branch
+ #endif
        , lir_move
        , lir_convert
        , lir_alloc_object
        , lir_monaddr
        , lir_roundfp
        , lir_safepoint
        , lir_unwind
    , end_op1
    , begin_op2
+ #ifdef RISCV
+       , lir_branch
+       , lir_cond_float_branch
+ #endif
        , lir_cmp
        , lir_cmp_l2i
        , lir_ucmp_fd2i
        , lir_cmp_fd2i
+ #ifndef RISCV
        , lir_cmove
+ #endif
        , lir_add
        , lir_sub
        , lir_mul
        , lir_div
        , lir_rem

*** 954,10 ***
--- 965,15 ---
        , lir_idiv
        , lir_irem
        , lir_fmad
        , lir_fmaf
    , end_op3
+ #ifdef RISCV
+   , begin_op4
+       , lir_cmove
+   , end_op4
+ #endif
    , begin_opJavaCall
        , lir_static_call
        , lir_optvirtual_call
        , lir_icvirtual_call
        , lir_dynamic_call

*** 990,10 ***
--- 1006,15 ---
      , lir_profile_type
    , end_opMDOProfile
    , begin_opAssert
      , lir_assert
    , end_opAssert
+ #if defined(RISCV) && defined(INCLUDE_ZGC)
+   , begin_opZLoadBarrierTest
+     , lir_zloadbarrier_test
+   , end_opZLoadBarrierTest
+ #endif
  };
  
  
  enum LIR_Condition {
      lir_cond_equal

*** 1126,10 ***
--- 1147,13 ---
    virtual LIR_OpConvert* as_OpConvert() { return NULL; }
    virtual LIR_Op0* as_Op0() { return NULL; }
    virtual LIR_Op1* as_Op1() { return NULL; }
    virtual LIR_Op2* as_Op2() { return NULL; }
    virtual LIR_Op3* as_Op3() { return NULL; }
+ #ifdef RISCV
+   virtual LIR_Op4* as_Op4() { return NULL; }
+ #endif
    virtual LIR_OpArrayCopy* as_OpArrayCopy() { return NULL; }
    virtual LIR_OpUpdateCRC32* as_OpUpdateCRC32() { return NULL; }
    virtual LIR_OpTypeCheck* as_OpTypeCheck() { return NULL; }
    virtual LIR_OpCompareAndSwap* as_OpCompareAndSwap() { return NULL; }
    virtual LIR_OpProfileCall* as_OpProfileCall() { return NULL; }

*** 1397,51 ***
    LIR_Opr tmp() const                            { return _tmp; }
  
    virtual void verify() const;
  };
  
- 
- class LIR_OpBranch: public LIR_Op {
-  friend class LIR_OpVisitState;
- 
-  private:
-   LIR_Condition _cond;
-   Label*        _label;
-   BlockBegin*   _block;  // if this is a branch to a block, this is the block
-   BlockBegin*   _ublock; // if this is a float-branch, this is the unorderd block
-   CodeStub*     _stub;   // if this is a branch to a stub, this is the stub
- 
-  public:
-   LIR_OpBranch(LIR_Condition cond, Label* lbl)
-     : LIR_Op(lir_branch, LIR_OprFact::illegalOpr, (CodeEmitInfo*) NULL)
-     , _cond(cond)
-     , _label(lbl)
-     , _block(NULL)
-     , _ublock(NULL)
-     , _stub(NULL) { }
- 
-   LIR_OpBranch(LIR_Condition cond, BlockBegin* block);
-   LIR_OpBranch(LIR_Condition cond, CodeStub* stub);
- 
-   // for unordered comparisons
-   LIR_OpBranch(LIR_Condition cond, BlockBegin* block, BlockBegin* ublock);
- 
-   LIR_Condition cond()        const              { return _cond;        }
-   Label*        label()       const              { return _label;       }
-   BlockBegin*   block()       const              { return _block;       }
-   BlockBegin*   ublock()      const              { return _ublock;      }
-   CodeStub*     stub()        const              { return _stub;       }
- 
-   void          change_block(BlockBegin* b);
-   void          change_ublock(BlockBegin* b);
-   void          negate_cond();
- 
-   virtual void emit_code(LIR_Assembler* masm);
-   virtual LIR_OpBranch* as_OpBranch() { return this; }
-   virtual void print_instr(outputStream* out) const PRODUCT_RETURN;
- };
- 
  class LIR_OpReturn: public LIR_Op1 {
   friend class LIR_OpVisitState;
  
   private:
    C1SafepointPollStub* _stub;
--- 1421,10 ---

*** 1610,23 ***
    LIR_Condition _condition;
  
    void verify() const;
  
   public:
!   LIR_Op2(LIR_Code code, LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, CodeEmitInfo* info = NULL)
      : LIR_Op(code, LIR_OprFact::illegalOpr, info)
      , _fpu_stack_size(0)
      , _opr1(opr1)
      , _opr2(opr2)
!     , _type(T_ILLEGAL)
      , _tmp1(LIR_OprFact::illegalOpr)
      , _tmp2(LIR_OprFact::illegalOpr)
      , _tmp3(LIR_OprFact::illegalOpr)
      , _tmp4(LIR_OprFact::illegalOpr)
      , _tmp5(LIR_OprFact::illegalOpr)
      , _condition(condition) {
!     assert(code == lir_cmp || code == lir_assert, "code check");
    }
  
    LIR_Op2(LIR_Code code, LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result, BasicType type)
      : LIR_Op(code, result, NULL)
      , _fpu_stack_size(0)
--- 1593,23 ---
    LIR_Condition _condition;
  
    void verify() const;
  
   public:
!   LIR_Op2(LIR_Code code, LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, CodeEmitInfo* info = NULL, BasicType type = T_ILLEGAL)
      : LIR_Op(code, LIR_OprFact::illegalOpr, info)
      , _fpu_stack_size(0)
      , _opr1(opr1)
      , _opr2(opr2)
!     , _type(type)
      , _tmp1(LIR_OprFact::illegalOpr)
      , _tmp2(LIR_OprFact::illegalOpr)
      , _tmp3(LIR_OprFact::illegalOpr)
      , _tmp4(LIR_OprFact::illegalOpr)
      , _tmp5(LIR_OprFact::illegalOpr)
      , _condition(condition) {
!     assert(code == lir_cmp || code == lir_assert RISCV_ONLY(|| code == lir_branch || code == lir_cond_float_branch), "code check");
    }
  
    LIR_Op2(LIR_Code code, LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result, BasicType type)
      : LIR_Op(code, result, NULL)
      , _fpu_stack_size(0)

*** 1654,11 ***
      , _tmp2(LIR_OprFact::illegalOpr)
      , _tmp3(LIR_OprFact::illegalOpr)
      , _tmp4(LIR_OprFact::illegalOpr)
      , _tmp5(LIR_OprFact::illegalOpr)
      , _condition(lir_cond_unknown) {
!     assert(code != lir_cmp && is_in_range(code, begin_op2, end_op2), "code check");
    }
  
    LIR_Op2(LIR_Code code, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result, LIR_Opr tmp1, LIR_Opr tmp2 = LIR_OprFact::illegalOpr,
            LIR_Opr tmp3 = LIR_OprFact::illegalOpr, LIR_Opr tmp4 = LIR_OprFact::illegalOpr, LIR_Opr tmp5 = LIR_OprFact::illegalOpr)
      : LIR_Op(code, result, NULL)
--- 1637,11 ---
      , _tmp2(LIR_OprFact::illegalOpr)
      , _tmp3(LIR_OprFact::illegalOpr)
      , _tmp4(LIR_OprFact::illegalOpr)
      , _tmp5(LIR_OprFact::illegalOpr)
      , _condition(lir_cond_unknown) {
!     assert(code != lir_cmp && RISCV_ONLY(code != lir_branch && code != lir_cond_float_branch &&) is_in_range(code, begin_op2, end_op2), "code check");
    }
  
    LIR_Op2(LIR_Code code, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result, LIR_Opr tmp1, LIR_Opr tmp2 = LIR_OprFact::illegalOpr,
            LIR_Opr tmp3 = LIR_OprFact::illegalOpr, LIR_Opr tmp4 = LIR_OprFact::illegalOpr, LIR_Opr tmp5 = LIR_OprFact::illegalOpr)
      : LIR_Op(code, result, NULL)

*** 1670,11 ***
      , _tmp2(tmp2)
      , _tmp3(tmp3)
      , _tmp4(tmp4)
      , _tmp5(tmp5)
      , _condition(lir_cond_unknown) {
!     assert(code != lir_cmp && is_in_range(code, begin_op2, end_op2), "code check");
    }
  
    LIR_Opr in_opr1() const                        { return _opr1; }
    LIR_Opr in_opr2() const                        { return _opr2; }
    BasicType type()  const                        { return _type; }
--- 1653,11 ---
      , _tmp2(tmp2)
      , _tmp3(tmp3)
      , _tmp4(tmp4)
      , _tmp5(tmp5)
      , _condition(lir_cond_unknown) {
!     assert(code != lir_cmp && RISCV_ONLY(code != lir_branch && code != lir_cond_float_branch &&) is_in_range(code, begin_op2, end_op2), "code check");
    }
  
    LIR_Opr in_opr1() const                        { return _opr1; }
    LIR_Opr in_opr2() const                        { return _opr2; }
    BasicType type()  const                        { return _type; }

*** 1682,14 ***
--- 1665,22 ---
    LIR_Opr tmp2_opr() const                       { return _tmp2; }
    LIR_Opr tmp3_opr() const                       { return _tmp3; }
    LIR_Opr tmp4_opr() const                       { return _tmp4; }
    LIR_Opr tmp5_opr() const                       { return _tmp5; }
    LIR_Condition condition() const  {
+ #ifdef RISCV
+     assert(code() == lir_cmp || code() == lir_branch || code() == lir_cond_float_branch || code() == lir_assert, "only valid for branch and assert"); return _condition;
+ #else
      assert(code() == lir_cmp || code() == lir_cmove || code() == lir_assert, "only valid for cmp and cmove and assert"); return _condition;
+ #endif
    }
    void set_condition(LIR_Condition condition) {
+ #ifdef RISCV
+     assert(code() == lir_cmp || code() == lir_branch || code() == lir_cond_float_branch, "only valid for branch"); _condition = condition;
+ #else
      assert(code() == lir_cmp || code() == lir_cmove, "only valid for cmp and cmove");  _condition = condition;
+ #endif
    }
  
    void set_fpu_stack_size(int size)              { _fpu_stack_size = size; }
    int  fpu_stack_size() const                    { return _fpu_stack_size; }
  

*** 1699,10 ***
--- 1690,67 ---
    virtual void emit_code(LIR_Assembler* masm);
    virtual LIR_Op2* as_Op2() { return this; }
    virtual void print_instr(outputStream* out) const PRODUCT_RETURN;
  };
  
+ #ifdef RISCV
+ class LIR_OpBranch: public LIR_Op2 {
+ #else
+ class LIR_OpBranch: public LIR_Op {
+ #endif
+  friend class LIR_OpVisitState;
+ 
+  private:
+ #ifndef RISCV
+   LIR_Condition _cond;
+ #endif
+   Label*        _label;
+   BlockBegin*   _block;  // if this is a branch to a block, this is the block
+   BlockBegin*   _ublock; // if this is a float-branch, this is the unordered block
+   CodeStub*     _stub;   // if this is a branch to a stub, this is the stub
+ 
+  public:
+   LIR_OpBranch(LIR_Condition cond, Label* lbl)
+ #ifdef RISCV
+     : LIR_Op2(lir_branch, cond, LIR_OprFact::illegalOpr, LIR_OprFact::illegalOpr, (CodeEmitInfo*) NULL)
+ #else
+     : LIR_Op(lir_branch, LIR_OprFact::illegalOpr, (CodeEmitInfo*) NULL)
+     , _cond(cond)
+ #endif
+     , _label(lbl)
+     , _block(NULL)
+     , _ublock(NULL)
+     , _stub(NULL) { }
+ 
+   LIR_OpBranch(LIR_Condition cond, BlockBegin* block);
+   LIR_OpBranch(LIR_Condition cond, CodeStub* stub);
+ 
+   // for unordered comparisons
+   LIR_OpBranch(LIR_Condition cond, BlockBegin* block, BlockBegin* ublock);
+ 
+ #ifdef RISCV
+   LIR_Condition cond()        const              { return condition();  }
+   void set_cond(LIR_Condition cond)              { set_condition(cond); }
+ #else
+   LIR_Condition cond()        const              { return _cond;        }
+   void set_cond(LIR_Condition cond)              { _cond = cond;        }
+ #endif
+   Label*        label()       const              { return _label;       }
+   BlockBegin*   block()       const              { return _block;       }
+   BlockBegin*   ublock()      const              { return _ublock;      }
+   CodeStub*     stub()        const              { return _stub;        }
+ 
+   void          change_block(BlockBegin* b);
+   void          change_ublock(BlockBegin* b);
+   void          negate_cond();
+ 
+   virtual void emit_code(LIR_Assembler* masm);
+   virtual LIR_OpBranch* as_OpBranch() { return this; }
+   virtual void print_instr(outputStream* out) const PRODUCT_RETURN;
+ 
+ };
+ 
  class LIR_OpAllocArray : public LIR_Op {
   friend class LIR_OpVisitState;
  
   private:
    LIR_Opr   _klass;

*** 1762,10 ***
--- 1810,69 ---
    virtual void emit_code(LIR_Assembler* masm);
    virtual LIR_Op3* as_Op3() { return this; }
    virtual void print_instr(outputStream* out) const PRODUCT_RETURN;
  };
  
+ #ifdef RISCV
+ class LIR_Op4: public LIR_Op {
+   friend class LIR_OpVisitState;
+  protected:
+   LIR_Opr   _opr1;
+   LIR_Opr   _opr2;
+   LIR_Opr   _opr3;
+   LIR_Opr   _opr4;
+   BasicType _type;
+   LIR_Opr   _tmp1;
+   LIR_Opr   _tmp2;
+   LIR_Opr   _tmp3;
+   LIR_Opr   _tmp4;
+   LIR_Opr   _tmp5;
+   LIR_Condition _condition;
+ 
+  public:
+   LIR_Op4(LIR_Code code, LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr opr3, LIR_Opr opr4,
+           LIR_Opr result, BasicType type)
+     : LIR_Op(code, result, NULL)
+     , _opr1(opr1)
+     , _opr2(opr2)
+     , _opr3(opr3)
+     , _opr4(opr4)
+     , _type(type)
+     , _tmp1(LIR_OprFact::illegalOpr)
+     , _tmp2(LIR_OprFact::illegalOpr)
+     , _tmp3(LIR_OprFact::illegalOpr)
+     , _tmp4(LIR_OprFact::illegalOpr)
+     , _tmp5(LIR_OprFact::illegalOpr)
+     , _condition(condition) {
+     assert(code == lir_cmove, "code check");
+     assert(type != T_ILLEGAL, "cmove should have type");
+   }
+ 
+   LIR_Opr in_opr1() const                        { return _opr1; }
+   LIR_Opr in_opr2() const                        { return _opr2; }
+   LIR_Opr in_opr3() const                        { return _opr3; }
+   LIR_Opr in_opr4() const                        { return _opr4; }
+   BasicType type()  const                        { return _type; }
+   LIR_Opr tmp1_opr() const                       { return _tmp1; }
+   LIR_Opr tmp2_opr() const                       { return _tmp2; }
+   LIR_Opr tmp3_opr() const                       { return _tmp3; }
+   LIR_Opr tmp4_opr() const                       { return _tmp4; }
+   LIR_Opr tmp5_opr() const                       { return _tmp5; }
+ 
+   LIR_Condition condition() const                { return _condition; }
+   void set_condition(LIR_Condition condition)    { _condition = condition; }
+ 
+   void set_in_opr1(LIR_Opr opr)                  { _opr1 = opr; }
+   void set_in_opr2(LIR_Opr opr)                  { _opr2 = opr; }
+   void set_in_opr3(LIR_Opr opr)                  { _opr3 = opr; }
+   void set_in_opr4(LIR_Opr opr)                  { _opr4 = opr; }
+   virtual void emit_code(LIR_Assembler* masm);
+   virtual LIR_Op4* as_Op4() { return this; }
+ 
+   virtual void print_instr(outputStream* out) const PRODUCT_RETURN;
+ };
+ #endif
  
  //--------------------------------
  class LabelObj: public CompilationResourceObj {
   private:
    Label _label;

*** 1984,10 ***
--- 2091,14 ---
  #endif
  #ifdef ASSERT
    const char *  _file;
    int           _line;
  #endif
+ #ifdef RISCV
+   LIR_Opr       _cmp_opr1;
+   LIR_Opr       _cmp_opr2;
+ #endif
  
   public:
    void append(LIR_Op* op) {
      if (op->source() == NULL)
        op->set_source(_compilation->current_instruction());

*** 1996,10 ***
--- 2107,16 ---
        _compilation->maybe_print_current_instruction();
        op->print(); tty->cr();
      }
  #endif // PRODUCT
  
+ #ifdef RISCV
+     set_cmp_oprs(op);
+     // lir_cmp set cmp oprs only on riscv
+     if (op->code() == lir_cmp) return;
+ #endif
+ 
      _operations.append(op);
  
  #ifdef ASSERT
      op->verify();
      op->set_file_and_line(_file, _line);

*** 2012,10 ***
--- 2129,14 ---
  
  #ifdef ASSERT
    void set_file_and_line(const char * file, int line);
  #endif
  
+ #ifdef RISCV
+   void set_cmp_oprs(LIR_Op* op);
+ #endif
+ 
    //---------- accessors ---------------
    LIR_OpList* instructions_list()                { return &_operations; }
    int         length() const                     { return _operations.length(); }
    LIR_Op*     at(int i) const                    { return _operations.at(i); }
  

*** 2131,13 ***
--- 2252,20 ---
    }
  
    void cmp_mem_int(LIR_Condition condition, LIR_Opr base, int disp, int c, CodeEmitInfo* info);
    void cmp_reg_mem(LIR_Condition condition, LIR_Opr reg, LIR_Address* addr, CodeEmitInfo* info);
  
+ #ifdef RISCV
+   void cmove(LIR_Condition condition, LIR_Opr src1, LIR_Opr src2, LIR_Opr dst, BasicType type,
+              LIR_Opr cmp_opr1 = LIR_OprFact::illegalOpr, LIR_Opr cmp_opr2 = LIR_OprFact::illegalOpr) {
+     append(new LIR_Op4(lir_cmove, condition, src1, src2, cmp_opr1, cmp_opr2, dst, type));
+   }
+ #else
    void cmove(LIR_Condition condition, LIR_Opr src1, LIR_Opr src2, LIR_Opr dst, BasicType type) {
      append(new LIR_Op2(lir_cmove, condition, src1, src2, dst, type));
    }
+ #endif
  
    void cas_long(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value,
                  LIR_Opr t1, LIR_Opr t2, LIR_Opr result = LIR_OprFact::illegalOpr);
    void cas_obj(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value,
                 LIR_Opr t1, LIR_Opr t2, LIR_Opr result = LIR_OprFact::illegalOpr);
< prev index next >