src/hotspot/cpu/s390/c1_LIRGenerator_s390.cpp
author roland
Thu, 22 Nov 2018 17:25:47 +0100
changeset 52675 7d3cde494494
parent 51966 2a2a78bd1fc3
permissions -rw-r--r--
8214206: Fix for JDK-8213419 is broken on 32-bit Reviewed-by: mdoerr, shade
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     1
/*
49397
d3a8aa01f26f 8071282: remove misc dead code
rraghavan
parents: 47762
diff changeset
     2
 * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
46315
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
     3
 * Copyright (c) 2016, 2017, SAP SE. All rights reserved.
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     5
 *
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     8
 * published by the Free Software Foundation.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
     9
 *
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    14
 * accompanied this code).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    15
 *
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    19
 *
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    22
 * questions.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    23
 *
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    24
 */
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    25
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    26
#include "precompiled.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    27
#include "c1/c1_Compilation.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    28
#include "c1/c1_FrameMap.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    29
#include "c1/c1_Instruction.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    30
#include "c1/c1_LIRAssembler.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    31
#include "c1/c1_LIRGenerator.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    32
#include "c1/c1_Runtime1.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    33
#include "c1/c1_ValueStack.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    34
#include "ci/ciArray.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    35
#include "ci/ciObjArrayKlass.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    36
#include "ci/ciTypeArrayKlass.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    37
#include "runtime/sharedRuntime.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    38
#include "runtime/stubRoutines.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    39
#include "vmreg_s390.inline.hpp"
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    40
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    41
#ifdef ASSERT
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    42
#define __ gen()->lir(__FILE__, __LINE__)->
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    43
#else
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    44
#define __ gen()->lir()->
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    45
#endif
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    46
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    47
void LIRItem::load_byte_item() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    48
  // Byte loads use same registers as other loads.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    49
  load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    50
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    51
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    52
void LIRItem::load_nonconstant(int bits) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    53
  LIR_Opr r = value()->operand();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    54
  if (_gen->can_inline_as_constant(value(), bits)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    55
    if (!r->is_constant()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    56
      r = LIR_OprFact::value_type(value()->type());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    57
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    58
    _result = r;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    59
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    60
    load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    61
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    62
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    63
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    64
//--------------------------------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    65
//               LIRGenerator
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    66
//--------------------------------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    67
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    68
LIR_Opr LIRGenerator::exceptionOopOpr() { return FrameMap::as_oop_opr(Z_EXC_OOP); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    69
LIR_Opr LIRGenerator::exceptionPcOpr()  { return FrameMap::as_opr(Z_EXC_PC); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    70
LIR_Opr LIRGenerator::divInOpr()        { return FrameMap::Z_R11_opr; }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    71
LIR_Opr LIRGenerator::divOutOpr()       { return FrameMap::Z_R11_opr; }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    72
LIR_Opr LIRGenerator::remOutOpr()       { return FrameMap::Z_R10_opr; }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    73
LIR_Opr LIRGenerator::ldivInOpr()       { return FrameMap::Z_R11_long_opr; }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    74
LIR_Opr LIRGenerator::ldivOutOpr()      { return FrameMap::Z_R11_long_opr; }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    75
LIR_Opr LIRGenerator::lremOutOpr()      { return FrameMap::Z_R10_long_opr; }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    76
LIR_Opr LIRGenerator::syncLockOpr()     { return new_register(T_INT); }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    77
LIR_Opr LIRGenerator::syncTempOpr()     { return FrameMap::Z_R13_opr; }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    78
LIR_Opr LIRGenerator::getThreadTemp()   { return LIR_OprFact::illegalOpr; }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    79
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    80
LIR_Opr LIRGenerator::result_register_for (ValueType* type, bool callee) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    81
  LIR_Opr opr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    82
  switch (type->tag()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    83
    case intTag:    opr = FrameMap::Z_R2_opr;        break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    84
    case objectTag: opr = FrameMap::Z_R2_oop_opr;    break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    85
    case longTag:   opr = FrameMap::Z_R2_long_opr;   break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    86
    case floatTag:  opr = FrameMap::Z_F0_opr;        break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    87
    case doubleTag: opr = FrameMap::Z_F0_double_opr; break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    88
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    89
    case addressTag:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    90
    default: ShouldNotReachHere(); return LIR_OprFact::illegalOpr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    91
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    92
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    93
  assert(opr->type_field() == as_OprType(as_BasicType(type)), "type mismatch");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    94
  return opr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    95
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    96
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    97
LIR_Opr LIRGenerator::rlock_byte(BasicType type) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    98
  return new_register(T_INT);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
    99
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   100
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   101
//--------- Loading items into registers. --------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   102
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   103
// z/Architecture cannot inline all constants.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   104
bool LIRGenerator::can_store_as_constant(Value v, BasicType type) const {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   105
  if (v->type()->as_IntConstant() != NULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   106
    return Immediate::is_simm16(v->type()->as_IntConstant()->value());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   107
  } else if (v->type()->as_LongConstant() != NULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   108
    return Immediate::is_simm16(v->type()->as_LongConstant()->value());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   109
  } else if (v->type()->as_ObjectConstant() != NULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   110
    return v->type()->as_ObjectConstant()->value()->is_null_object();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   111
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   112
    return false;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   113
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   114
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   115
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   116
bool LIRGenerator::can_inline_as_constant(Value i, int bits) const {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   117
  if (i->type()->as_IntConstant() != NULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   118
    return Assembler::is_simm(i->type()->as_IntConstant()->value(), bits);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   119
  } else if (i->type()->as_LongConstant() != NULL) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   120
    return Assembler::is_simm(i->type()->as_LongConstant()->value(), bits);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   121
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   122
    return can_store_as_constant(i, as_BasicType(i->type()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   123
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   124
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   125
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   126
bool LIRGenerator::can_inline_as_constant(LIR_Const* c) const {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   127
  if (c->type() == T_INT) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   128
    return Immediate::is_simm20(c->as_jint());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   129
  } else   if (c->type() == T_LONG) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   130
    return Immediate::is_simm20(c->as_jlong());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   131
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   132
  return false;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   133
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   134
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   135
LIR_Opr LIRGenerator::safepoint_poll_register() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   136
  return new_register(longType);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   137
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   138
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   139
LIR_Address* LIRGenerator::generate_address(LIR_Opr base, LIR_Opr index,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   140
                                            int shift, int disp, BasicType type) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   141
  assert(base->is_register(), "must be");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   142
  if (index->is_constant()) {
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   143
    intx large_disp = disp;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   144
    LIR_Const *constant = index->as_constant_ptr();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   145
    if (constant->type() == T_LONG) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   146
      large_disp += constant->as_jlong() << shift;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   147
    } else {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   148
      large_disp += (intx)(constant->as_jint()) << shift;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   149
    }
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   150
    if (Displacement::is_validDisp(large_disp)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   151
      return new LIR_Address(base, large_disp, type);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   152
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   153
    // Index is illegal so replace it with the displacement loaded into a register.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   154
    index = new_pointer_register();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   155
    __ move(LIR_OprFact::intptrConst(large_disp), index);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   156
    return new LIR_Address(base, index, type);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   157
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   158
    if (shift > 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   159
      LIR_Opr tmp = new_pointer_register();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   160
      __ shift_left(index, shift, tmp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   161
      index = tmp;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   162
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   163
    return new LIR_Address(base, index, disp, type);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   164
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   165
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   166
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   167
LIR_Address* LIRGenerator::emit_array_address(LIR_Opr array_opr, LIR_Opr index_opr,
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   168
                                              BasicType type) {
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   169
  int elem_size = type2aelembytes(type);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   170
  int shift = exact_log2(elem_size);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   171
  int offset_in_bytes = arrayOopDesc::base_offset_in_bytes(type);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   172
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   173
  LIR_Address* addr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   174
  if (index_opr->is_constant()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   175
    addr = new LIR_Address(array_opr,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   176
                           offset_in_bytes + (intx)(index_opr->as_jint()) * elem_size, type);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   177
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   178
    if (index_opr->type() == T_INT) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   179
      LIR_Opr tmp = new_register(T_LONG);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   180
      __ convert(Bytecodes::_i2l, index_opr, tmp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   181
      index_opr = tmp;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   182
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   183
    if (shift > 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   184
      __ shift_left(index_opr, shift, index_opr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   185
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   186
    addr = new LIR_Address(array_opr,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   187
                           index_opr,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   188
                           offset_in_bytes, type);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   189
  }
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   190
  return addr;
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   191
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   192
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   193
LIR_Opr LIRGenerator::load_immediate(int x, BasicType type) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   194
  LIR_Opr r = LIR_OprFact::illegalOpr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   195
  if (type == T_LONG) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   196
    r = LIR_OprFact::longConst(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   197
  } else if (type == T_INT) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   198
    r = LIR_OprFact::intConst(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   199
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   200
    ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   201
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   202
  return r;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   203
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   204
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   205
void LIRGenerator::increment_counter(address counter, BasicType type, int step) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   206
  LIR_Opr pointer = new_pointer_register();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   207
  __ move(LIR_OprFact::intptrConst(counter), pointer);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   208
  LIR_Address* addr = new LIR_Address(pointer, type);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   209
  increment_counter(addr, step);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   210
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   211
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   212
void LIRGenerator::increment_counter(LIR_Address* addr, int step) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   213
  __ add((LIR_Opr)addr, LIR_OprFact::intConst(step), (LIR_Opr)addr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   214
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   215
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   216
void LIRGenerator::cmp_mem_int(LIR_Condition condition, LIR_Opr base, int disp, int c, CodeEmitInfo* info) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   217
  LIR_Opr scratch = FrameMap::Z_R1_opr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   218
  __ load(new LIR_Address(base, disp, T_INT), scratch, info);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   219
  __ cmp(condition, scratch, c);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   220
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   221
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   222
void LIRGenerator::cmp_reg_mem(LIR_Condition condition, LIR_Opr reg, LIR_Opr base, int disp, BasicType type, CodeEmitInfo* info) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   223
  __ cmp_reg_mem(condition, reg, new LIR_Address(base, disp, type), info);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   224
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   225
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   226
bool LIRGenerator::strength_reduce_multiply(LIR_Opr left, int c, LIR_Opr result, LIR_Opr tmp) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   227
  if (tmp->is_valid()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   228
    if (is_power_of_2(c + 1)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   229
      __ move(left, tmp);
52675
7d3cde494494 8214206: Fix for JDK-8213419 is broken on 32-bit
roland
parents: 51966
diff changeset
   230
      __ shift_left(left, log2_int(c + 1), left);
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   231
      __ sub(left, tmp, result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   232
      return true;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   233
    } else if (is_power_of_2(c - 1)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   234
      __ move(left, tmp);
52675
7d3cde494494 8214206: Fix for JDK-8213419 is broken on 32-bit
roland
parents: 51966
diff changeset
   235
      __ shift_left(left, log2_int(c - 1), left);
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   236
      __ add(left, tmp, result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   237
      return true;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   238
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   239
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   240
  return false;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   241
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   242
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   243
void LIRGenerator::store_stack_parameter (LIR_Opr item, ByteSize offset_from_sp) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   244
  BasicType type = item->type();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   245
  __ store(item, new LIR_Address(FrameMap::Z_SP_opr, in_bytes(offset_from_sp), type));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   246
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   247
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   248
//----------------------------------------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   249
//             visitor functions
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   250
//----------------------------------------------------------------------
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   251
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   252
void LIRGenerator::array_store_check(LIR_Opr value, LIR_Opr array, CodeEmitInfo* store_check_info, ciMethod* profiled_method, int profiled_bci) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   253
  LIR_Opr tmp1 = new_register(objectType);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   254
  LIR_Opr tmp2 = new_register(objectType);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   255
  LIR_Opr tmp3 = LIR_OprFact::illegalOpr;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   256
  __ store_check(value, array, tmp1, tmp2, tmp3, store_check_info, profiled_method, profiled_bci);
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   257
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   258
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   259
void LIRGenerator::do_MonitorEnter(MonitorEnter* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   260
  assert(x->is_pinned(),"");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   261
  LIRItem obj(x->obj(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   262
  obj.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   263
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   264
  set_no_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   265
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   266
  // "lock" stores the address of the monitor stack slot, so this is not an oop.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   267
  LIR_Opr lock = new_register(T_INT);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   268
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   269
  CodeEmitInfo* info_for_exception = NULL;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   270
  if (x->needs_null_check()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   271
    info_for_exception = state_for (x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   272
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   273
  // This CodeEmitInfo must not have the xhandlers because here the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   274
  // object is already locked (xhandlers expect object to be unlocked).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   275
  CodeEmitInfo* info = state_for (x, x->state(), true);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   276
  monitor_enter(obj.result(), lock, syncTempOpr(), LIR_OprFact::illegalOpr,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   277
                x->monitor_no(), info_for_exception, info);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   278
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   279
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   280
void LIRGenerator::do_MonitorExit(MonitorExit* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   281
  assert(x->is_pinned(),"");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   282
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   283
  LIRItem obj(x->obj(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   284
  obj.dont_load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   285
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   286
  LIR_Opr lock = new_register(T_INT);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   287
  LIR_Opr obj_temp = new_register(T_INT);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   288
  set_no_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   289
  monitor_exit(obj_temp, lock, syncTempOpr(), LIR_OprFact::illegalOpr, x->monitor_no());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   290
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   291
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   292
// _ineg, _lneg, _fneg, _dneg
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   293
void LIRGenerator::do_NegateOp(NegateOp* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   294
  LIRItem value(x->x(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   295
  value.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   296
  LIR_Opr reg = rlock_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   297
  __ negate(value.result(), reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   298
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   299
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   300
// for _fadd, _fmul, _fsub, _fdiv, _frem
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   301
//     _dadd, _dmul, _dsub, _ddiv, _drem
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   302
void LIRGenerator::do_ArithmeticOp_FPU(ArithmeticOp* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   303
  LIRItem left(x->x(),  this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   304
  LIRItem right(x->y(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   305
  LIRItem* left_arg  = &left;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   306
  LIRItem* right_arg = &right;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   307
  assert(!left.is_stack(), "can't both be memory operands");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   308
  left.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   309
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   310
  if (right.is_register() || right.is_constant()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   311
    right.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   312
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   313
    right.dont_load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   314
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   315
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   316
  if ((x->op() == Bytecodes::_frem) || (x->op() == Bytecodes::_drem)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   317
    address entry;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   318
    switch (x->op()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   319
    case Bytecodes::_frem:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   320
      entry = CAST_FROM_FN_PTR(address, SharedRuntime::frem);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   321
      break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   322
    case Bytecodes::_drem:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   323
      entry = CAST_FROM_FN_PTR(address, SharedRuntime::drem);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   324
      break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   325
    default:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   326
      ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   327
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   328
    LIR_Opr result = call_runtime(x->x(), x->y(), entry, x->type(), NULL);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   329
    set_result(x, result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   330
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   331
    LIR_Opr reg = rlock(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   332
    LIR_Opr tmp = LIR_OprFact::illegalOpr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   333
    arithmetic_op_fpu(x->op(), reg, left.result(), right.result(), x->is_strictfp(), tmp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   334
    set_result(x, reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   335
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   336
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   337
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   338
// for _ladd, _lmul, _lsub, _ldiv, _lrem
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   339
void LIRGenerator::do_ArithmeticOp_Long(ArithmeticOp* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   340
  if (x->op() == Bytecodes::_ldiv || x->op() == Bytecodes::_lrem) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   341
    // Use shifts if divisior is a power of 2 otherwise use DSGR instruction.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   342
    // Instruction: DSGR R1, R2
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   343
    // input : R1+1: dividend   (R1, R1+1 designate a register pair, R1 must be even)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   344
    //         R2:   divisor
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   345
    //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   346
    // output: R1+1: quotient
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   347
    //         R1:   remainder
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   348
    //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   349
    // Register selection: R1:   Z_R10
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   350
    //                     R1+1: Z_R11
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   351
    //                     R2:   to be chosen by register allocator (linear scan)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   352
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   353
    // R1, and R1+1 will be destroyed.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   354
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   355
    LIRItem right(x->y(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   356
    LIRItem left(x->x() , this);   // Visit left second, so that the is_register test is valid.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   357
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   358
    // Call state_for before load_item_force because state_for may
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   359
    // force the evaluation of other instructions that are needed for
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   360
    // correct debug info. Otherwise the live range of the fix
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   361
    // register might be too long.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   362
    CodeEmitInfo* info = state_for (x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   363
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   364
    LIR_Opr result = rlock_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   365
    LIR_Opr result_reg = result;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   366
    LIR_Opr tmp = LIR_OprFact::illegalOpr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   367
    LIR_Opr divisor_opr = right.result();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   368
    if (divisor_opr->is_constant() && is_power_of_2(divisor_opr->as_jlong())) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   369
      left.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   370
      right.dont_load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   371
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   372
      left.load_item_force(ldivInOpr());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   373
      right.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   374
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   375
      // DSGR instruction needs register pair.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   376
      if (x->op() == Bytecodes::_ldiv) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   377
        result_reg = ldivOutOpr();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   378
        tmp        = lremOutOpr();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   379
      } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   380
        result_reg = lremOutOpr();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   381
        tmp        = ldivOutOpr();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   382
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   383
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   384
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   385
    if (!ImplicitDiv0Checks) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   386
      __ cmp(lir_cond_equal, right.result(), LIR_OprFact::longConst(0));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   387
      __ branch(lir_cond_equal, T_LONG, new DivByZeroStub(info));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   388
      // Idiv/irem cannot trap (passing info would generate an assertion).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   389
      info = NULL;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   390
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   391
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   392
    if (x->op() == Bytecodes::_lrem) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   393
      __ irem(left.result(), right.result(), result_reg, tmp, info);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   394
    } else if (x->op() == Bytecodes::_ldiv) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   395
      __ idiv(left.result(), right.result(), result_reg, tmp, info);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   396
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   397
      ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   398
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   399
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   400
    if (result_reg != result) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   401
      __ move(result_reg, result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   402
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   403
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   404
    LIRItem left(x->x(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   405
    LIRItem right(x->y(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   406
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   407
    left.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   408
    right.load_nonconstant(32);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   409
    rlock_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   410
    arithmetic_op_long(x->op(), x->operand(), left.result(), right.result(), NULL);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   411
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   412
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   413
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   414
// for: _iadd, _imul, _isub, _idiv, _irem
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   415
void LIRGenerator::do_ArithmeticOp_Int(ArithmeticOp* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   416
  if (x->op() == Bytecodes::_idiv || x->op() == Bytecodes::_irem) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   417
    // Use shifts if divisior is a power of 2 otherwise use DSGFR instruction.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   418
    // Instruction: DSGFR R1, R2
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   419
    // input : R1+1: dividend   (R1, R1+1 designate a register pair, R1 must be even)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   420
    //         R2:   divisor
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   421
    //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   422
    // output: R1+1: quotient
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   423
    //         R1:   remainder
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   424
    //
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   425
    // Register selection: R1:   Z_R10
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   426
    //                     R1+1: Z_R11
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   427
    //                     R2:   To be chosen by register allocator (linear scan).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   428
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   429
    // R1, and R1+1 will be destroyed.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   430
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   431
    LIRItem right(x->y(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   432
    LIRItem left(x->x() , this);   // Visit left second, so that the is_register test is valid.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   433
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   434
    // Call state_for before load_item_force because state_for may
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   435
    // force the evaluation of other instructions that are needed for
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   436
    // correct debug info. Otherwise the live range of the fix
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   437
    // register might be too long.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   438
    CodeEmitInfo* info = state_for (x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   439
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   440
    LIR_Opr result = rlock_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   441
    LIR_Opr result_reg = result;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   442
    LIR_Opr tmp = LIR_OprFact::illegalOpr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   443
    LIR_Opr divisor_opr = right.result();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   444
    if (divisor_opr->is_constant() && is_power_of_2(divisor_opr->as_jint())) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   445
      left.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   446
      right.dont_load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   447
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   448
      left.load_item_force(divInOpr());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   449
      right.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   450
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   451
      // DSGFR instruction needs register pair.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   452
      if (x->op() == Bytecodes::_idiv) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   453
        result_reg = divOutOpr();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   454
        tmp        = remOutOpr();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   455
      } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   456
        result_reg = remOutOpr();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   457
        tmp        = divOutOpr();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   458
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   459
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   460
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   461
    if (!ImplicitDiv0Checks) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   462
      __ cmp(lir_cond_equal, right.result(), LIR_OprFact::intConst(0));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   463
      __ branch(lir_cond_equal, T_INT, new DivByZeroStub(info));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   464
      // Idiv/irem cannot trap (passing info would generate an assertion).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   465
      info = NULL;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   466
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   467
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   468
    if (x->op() == Bytecodes::_irem) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   469
      __ irem(left.result(), right.result(), result_reg, tmp, info);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   470
    } else if (x->op() == Bytecodes::_idiv) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   471
      __ idiv(left.result(), right.result(), result_reg, tmp, info);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   472
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   473
      ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   474
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   475
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   476
    if (result_reg != result) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   477
      __ move(result_reg, result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   478
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   479
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   480
    LIRItem left(x->x(),  this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   481
    LIRItem right(x->y(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   482
    LIRItem* left_arg = &left;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   483
    LIRItem* right_arg = &right;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   484
    if (x->is_commutative() && left.is_stack() && right.is_register()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   485
      // swap them if left is real stack (or cached) and right is real register(not cached)
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   486
      left_arg = &right;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   487
      right_arg = &left;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   488
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   489
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   490
    left_arg->load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   491
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   492
    // Do not need to load right, as we can handle stack and constants.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   493
    if (x->op() == Bytecodes::_imul) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   494
      bool use_tmp = false;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   495
      if (right_arg->is_constant()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   496
        int iconst = right_arg->get_jint_constant();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   497
        if (is_power_of_2(iconst - 1) || is_power_of_2(iconst + 1)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   498
          use_tmp = true;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   499
        }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   500
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   501
      right_arg->dont_load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   502
      LIR_Opr tmp = LIR_OprFact::illegalOpr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   503
      if (use_tmp) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   504
        tmp = new_register(T_INT);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   505
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   506
      rlock_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   507
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   508
      arithmetic_op_int(x->op(), x->operand(), left_arg->result(), right_arg->result(), tmp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   509
    } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   510
      right_arg->dont_load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   511
      rlock_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   512
      LIR_Opr tmp = LIR_OprFact::illegalOpr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   513
      arithmetic_op_int(x->op(), x->operand(), left_arg->result(), right_arg->result(), tmp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   514
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   515
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   516
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   517
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   518
void LIRGenerator::do_ArithmeticOp(ArithmeticOp* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   519
  // If an operand with use count 1 is the left operand, then it is
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   520
  // likely that no move for 2-operand-LIR-form is necessary.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   521
  if (x->is_commutative() && x->y()->as_Constant() == NULL && x->x()->use_count() > x->y()->use_count()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   522
    x->swap_operands();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   523
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   524
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   525
  ValueTag tag = x->type()->tag();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   526
  assert(x->x()->type()->tag() == tag && x->y()->type()->tag() == tag, "wrong parameters");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   527
  switch (tag) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   528
    case floatTag:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   529
    case doubleTag: do_ArithmeticOp_FPU(x);  return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   530
    case longTag:   do_ArithmeticOp_Long(x); return;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   531
    case intTag:    do_ArithmeticOp_Int(x);  return;
51966
2a2a78bd1fc3 8211145: [ppc] [s390]: Build fails due to -Werror=switch (introduced with JDK-8211029)
lucy
parents: 50153
diff changeset
   532
    default:
2a2a78bd1fc3 8211145: [ppc] [s390]: Build fails due to -Werror=switch (introduced with JDK-8211029)
lucy
parents: 50153
diff changeset
   533
      ShouldNotReachHere();
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   534
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   535
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   536
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   537
// _ishl, _lshl, _ishr, _lshr, _iushr, _lushr
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   538
void LIRGenerator::do_ShiftOp(ShiftOp* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   539
  // count must always be in rcx
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   540
  LIRItem value(x->x(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   541
  LIRItem count(x->y(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   542
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   543
  ValueTag elemType = x->type()->tag();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   544
  bool must_load_count = !count.is_constant();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   545
  if (must_load_count) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   546
    count.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   547
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   548
    count.dont_load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   549
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   550
  value.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   551
  LIR_Opr reg = rlock_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   552
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   553
  shift_op(x->op(), reg, value.result(), count.result(), LIR_OprFact::illegalOpr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   554
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   555
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   556
// _iand, _land, _ior, _lor, _ixor, _lxor
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   557
void LIRGenerator::do_LogicOp(LogicOp* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   558
  // IF an operand with use count 1 is the left operand, then it is
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   559
  // likely that no move for 2-operand-LIR-form is necessary.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   560
  if (x->is_commutative() && x->y()->as_Constant() == NULL && x->x()->use_count() > x->y()->use_count()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   561
    x->swap_operands();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   562
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   563
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   564
  LIRItem left(x->x(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   565
  LIRItem right(x->y(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   566
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   567
  left.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   568
  right.load_nonconstant(32);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   569
  LIR_Opr reg = rlock_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   570
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   571
  logic_op(x->op(), reg, left.result(), right.result());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   572
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   573
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   574
// _lcmp, _fcmpl, _fcmpg, _dcmpl, _dcmpg
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   575
void LIRGenerator::do_CompareOp(CompareOp* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   576
  LIRItem left(x->x(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   577
  LIRItem right(x->y(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   578
  left.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   579
  right.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   580
  LIR_Opr reg = rlock_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   581
  if (x->x()->type()->is_float_kind()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   582
    Bytecodes::Code code = x->op();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   583
    __ fcmp2int(left.result(), right.result(), reg, (code == Bytecodes::_fcmpl || code == Bytecodes::_dcmpl));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   584
  } else if (x->x()->type()->tag() == longTag) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   585
    __ lcmp2int(left.result(), right.result(), reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   586
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   587
    ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   588
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   589
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   590
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   591
LIR_Opr LIRGenerator::atomic_cmpxchg(BasicType type, LIR_Opr addr, LIRItem& cmp_value, LIRItem& new_value) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   592
  LIR_Opr t1 = LIR_OprFact::illegalOpr;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   593
  LIR_Opr t2 = LIR_OprFact::illegalOpr;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   594
  cmp_value.load_item();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   595
  new_value.load_item();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   596
  if (type == T_OBJECT) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   597
    if (UseCompressedOops) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   598
      t1 = new_register(T_OBJECT);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   599
      t2 = new_register(T_OBJECT);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   600
    }
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   601
    __ cas_obj(addr->as_address_ptr()->base(), cmp_value.result(), new_value.result(), t1, t2);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   602
  } else if (type == T_INT) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   603
    __ cas_int(addr->as_address_ptr()->base(), cmp_value.result(), new_value.result(), t1, t2);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   604
  } else if (type == T_LONG) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   605
    __ cas_long(addr->as_address_ptr()->base(), cmp_value.result(), new_value.result(), t1, t2);
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   606
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   607
    ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   608
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   609
  // Generate conditional move of boolean result.
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   610
  LIR_Opr result = new_register(T_INT);
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   611
  __ cmove(lir_cond_equal, LIR_OprFact::intConst(1), LIR_OprFact::intConst(0),
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   612
           result, type);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   613
  return result;
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   614
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   615
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   616
LIR_Opr LIRGenerator::atomic_xchg(BasicType type, LIR_Opr addr, LIRItem& value) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   617
  Unimplemented(); // Currently not supported on this platform.
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   618
  return LIR_OprFact::illegalOpr;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   619
}
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   620
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   621
LIR_Opr LIRGenerator::atomic_add(BasicType type, LIR_Opr addr, LIRItem& value) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   622
  LIR_Opr result = new_register(type);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   623
  value.load_item();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   624
  __ xadd(addr, value.result(), result, LIR_OprFact::illegalOpr);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   625
  return result;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49397
diff changeset
   626
}
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   627
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   628
void LIRGenerator::do_MathIntrinsic(Intrinsic* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   629
  switch (x->id()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   630
    case vmIntrinsics::_dabs:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   631
    case vmIntrinsics::_dsqrt: {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   632
      assert(x->number_of_arguments() == 1, "wrong type");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   633
      LIRItem value(x->argument_at(0), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   634
      value.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   635
      LIR_Opr dst = rlock_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   636
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   637
      switch (x->id()) {
51966
2a2a78bd1fc3 8211145: [ppc] [s390]: Build fails due to -Werror=switch (introduced with JDK-8211029)
lucy
parents: 50153
diff changeset
   638
        case vmIntrinsics::_dsqrt: {
2a2a78bd1fc3 8211145: [ppc] [s390]: Build fails due to -Werror=switch (introduced with JDK-8211029)
lucy
parents: 50153
diff changeset
   639
          __ sqrt(value.result(), dst, LIR_OprFact::illegalOpr);
2a2a78bd1fc3 8211145: [ppc] [s390]: Build fails due to -Werror=switch (introduced with JDK-8211029)
lucy
parents: 50153
diff changeset
   640
          break;
2a2a78bd1fc3 8211145: [ppc] [s390]: Build fails due to -Werror=switch (introduced with JDK-8211029)
lucy
parents: 50153
diff changeset
   641
        }
2a2a78bd1fc3 8211145: [ppc] [s390]: Build fails due to -Werror=switch (introduced with JDK-8211029)
lucy
parents: 50153
diff changeset
   642
        case vmIntrinsics::_dabs: {
2a2a78bd1fc3 8211145: [ppc] [s390]: Build fails due to -Werror=switch (introduced with JDK-8211029)
lucy
parents: 50153
diff changeset
   643
          __ abs(value.result(), dst, LIR_OprFact::illegalOpr);
2a2a78bd1fc3 8211145: [ppc] [s390]: Build fails due to -Werror=switch (introduced with JDK-8211029)
lucy
parents: 50153
diff changeset
   644
          break;
2a2a78bd1fc3 8211145: [ppc] [s390]: Build fails due to -Werror=switch (introduced with JDK-8211029)
lucy
parents: 50153
diff changeset
   645
        }
2a2a78bd1fc3 8211145: [ppc] [s390]: Build fails due to -Werror=switch (introduced with JDK-8211029)
lucy
parents: 50153
diff changeset
   646
        default:
2a2a78bd1fc3 8211145: [ppc] [s390]: Build fails due to -Werror=switch (introduced with JDK-8211029)
lucy
parents: 50153
diff changeset
   647
          ShouldNotReachHere();
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   648
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   649
      break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   650
    }
51966
2a2a78bd1fc3 8211145: [ppc] [s390]: Build fails due to -Werror=switch (introduced with JDK-8211029)
lucy
parents: 50153
diff changeset
   651
    case vmIntrinsics::_dsin:   // fall through
2a2a78bd1fc3 8211145: [ppc] [s390]: Build fails due to -Werror=switch (introduced with JDK-8211029)
lucy
parents: 50153
diff changeset
   652
    case vmIntrinsics::_dcos:   // fall through
2a2a78bd1fc3 8211145: [ppc] [s390]: Build fails due to -Werror=switch (introduced with JDK-8211029)
lucy
parents: 50153
diff changeset
   653
    case vmIntrinsics::_dtan:   // fall through
2a2a78bd1fc3 8211145: [ppc] [s390]: Build fails due to -Werror=switch (introduced with JDK-8211029)
lucy
parents: 50153
diff changeset
   654
    case vmIntrinsics::_dlog:   // fall through
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   655
    case vmIntrinsics::_dlog10: // fall through
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   656
    case vmIntrinsics::_dexp: {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   657
      assert(x->number_of_arguments() == 1, "wrong type");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   658
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   659
      address runtime_entry = NULL;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   660
      switch (x->id()) {
51966
2a2a78bd1fc3 8211145: [ppc] [s390]: Build fails due to -Werror=switch (introduced with JDK-8211029)
lucy
parents: 50153
diff changeset
   661
        case vmIntrinsics::_dsin:
2a2a78bd1fc3 8211145: [ppc] [s390]: Build fails due to -Werror=switch (introduced with JDK-8211029)
lucy
parents: 50153
diff changeset
   662
          runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dsin);
2a2a78bd1fc3 8211145: [ppc] [s390]: Build fails due to -Werror=switch (introduced with JDK-8211029)
lucy
parents: 50153
diff changeset
   663
          break;
2a2a78bd1fc3 8211145: [ppc] [s390]: Build fails due to -Werror=switch (introduced with JDK-8211029)
lucy
parents: 50153
diff changeset
   664
        case vmIntrinsics::_dcos:
2a2a78bd1fc3 8211145: [ppc] [s390]: Build fails due to -Werror=switch (introduced with JDK-8211029)
lucy
parents: 50153
diff changeset
   665
          runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dcos);
2a2a78bd1fc3 8211145: [ppc] [s390]: Build fails due to -Werror=switch (introduced with JDK-8211029)
lucy
parents: 50153
diff changeset
   666
          break;
2a2a78bd1fc3 8211145: [ppc] [s390]: Build fails due to -Werror=switch (introduced with JDK-8211029)
lucy
parents: 50153
diff changeset
   667
        case vmIntrinsics::_dtan:
2a2a78bd1fc3 8211145: [ppc] [s390]: Build fails due to -Werror=switch (introduced with JDK-8211029)
lucy
parents: 50153
diff changeset
   668
          runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dtan);
2a2a78bd1fc3 8211145: [ppc] [s390]: Build fails due to -Werror=switch (introduced with JDK-8211029)
lucy
parents: 50153
diff changeset
   669
          break;
2a2a78bd1fc3 8211145: [ppc] [s390]: Build fails due to -Werror=switch (introduced with JDK-8211029)
lucy
parents: 50153
diff changeset
   670
        case vmIntrinsics::_dlog:
2a2a78bd1fc3 8211145: [ppc] [s390]: Build fails due to -Werror=switch (introduced with JDK-8211029)
lucy
parents: 50153
diff changeset
   671
          runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dlog);
2a2a78bd1fc3 8211145: [ppc] [s390]: Build fails due to -Werror=switch (introduced with JDK-8211029)
lucy
parents: 50153
diff changeset
   672
          break;
2a2a78bd1fc3 8211145: [ppc] [s390]: Build fails due to -Werror=switch (introduced with JDK-8211029)
lucy
parents: 50153
diff changeset
   673
        case vmIntrinsics::_dlog10:
2a2a78bd1fc3 8211145: [ppc] [s390]: Build fails due to -Werror=switch (introduced with JDK-8211029)
lucy
parents: 50153
diff changeset
   674
          runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dlog10);
2a2a78bd1fc3 8211145: [ppc] [s390]: Build fails due to -Werror=switch (introduced with JDK-8211029)
lucy
parents: 50153
diff changeset
   675
          break;
2a2a78bd1fc3 8211145: [ppc] [s390]: Build fails due to -Werror=switch (introduced with JDK-8211029)
lucy
parents: 50153
diff changeset
   676
        case vmIntrinsics::_dexp:
2a2a78bd1fc3 8211145: [ppc] [s390]: Build fails due to -Werror=switch (introduced with JDK-8211029)
lucy
parents: 50153
diff changeset
   677
          runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dexp);
2a2a78bd1fc3 8211145: [ppc] [s390]: Build fails due to -Werror=switch (introduced with JDK-8211029)
lucy
parents: 50153
diff changeset
   678
          break;
2a2a78bd1fc3 8211145: [ppc] [s390]: Build fails due to -Werror=switch (introduced with JDK-8211029)
lucy
parents: 50153
diff changeset
   679
        default:
2a2a78bd1fc3 8211145: [ppc] [s390]: Build fails due to -Werror=switch (introduced with JDK-8211029)
lucy
parents: 50153
diff changeset
   680
          ShouldNotReachHere();
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   681
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   682
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   683
      LIR_Opr result = call_runtime(x->argument_at(0), runtime_entry, x->type(), NULL);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   684
      set_result(x, result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   685
      break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   686
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   687
    case vmIntrinsics::_dpow: {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   688
      assert(x->number_of_arguments() == 2, "wrong type");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   689
      address runtime_entry = CAST_FROM_FN_PTR(address, SharedRuntime::dpow);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   690
      LIR_Opr result = call_runtime(x->argument_at(0), x->argument_at(1), runtime_entry, x->type(), NULL);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   691
      set_result(x, result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   692
      break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   693
    }
51966
2a2a78bd1fc3 8211145: [ppc] [s390]: Build fails due to -Werror=switch (introduced with JDK-8211029)
lucy
parents: 50153
diff changeset
   694
    default:
2a2a78bd1fc3 8211145: [ppc] [s390]: Build fails due to -Werror=switch (introduced with JDK-8211029)
lucy
parents: 50153
diff changeset
   695
      break;
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   696
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   697
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   698
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   699
void LIRGenerator::do_ArrayCopy(Intrinsic* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   700
  assert(x->number_of_arguments() == 5, "wrong type");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   701
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   702
  // Copy stubs possibly call C code, e.g. G1 barriers, so we need to reserve room
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   703
  // for the C ABI (see frame::z_abi_160).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   704
  BasicTypeArray sig; // Empty signature is precise enough.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   705
  frame_map()->c_calling_convention(&sig);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   706
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   707
  // Make all state_for calls early since they can emit code.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   708
  CodeEmitInfo* info = state_for (x, x->state());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   709
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   710
  LIRItem src(x->argument_at(0), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   711
  LIRItem src_pos(x->argument_at(1), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   712
  LIRItem dst(x->argument_at(2), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   713
  LIRItem dst_pos(x->argument_at(3), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   714
  LIRItem length(x->argument_at(4), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   715
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   716
  // Operands for arraycopy must use fixed registers, otherwise
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   717
  // LinearScan will fail allocation (because arraycopy always needs a
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   718
  // call).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   719
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   720
  src.load_item_force     (FrameMap::as_oop_opr(Z_ARG1));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   721
  src_pos.load_item_force (FrameMap::as_opr(Z_ARG2));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   722
  dst.load_item_force     (FrameMap::as_oop_opr(Z_ARG3));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   723
  dst_pos.load_item_force (FrameMap::as_opr(Z_ARG4));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   724
  length.load_item_force  (FrameMap::as_opr(Z_ARG5));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   725
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   726
  LIR_Opr tmp =            FrameMap::as_opr(Z_R7);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   727
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   728
  set_no_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   729
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   730
  int flags;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   731
  ciArrayKlass* expected_type;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   732
  arraycopy_helper(x, &flags, &expected_type);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   733
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   734
  __ arraycopy(src.result(), src_pos.result(), dst.result(), dst_pos.result(),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   735
               length.result(), tmp, expected_type, flags, info); // does add_safepoint
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   736
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   737
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   738
// _i2l, _i2f, _i2d, _l2i, _l2f, _l2d, _f2i, _f2l, _f2d, _d2i, _d2l, _d2f
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   739
// _i2b, _i2c, _i2s
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   740
void LIRGenerator::do_Convert(Convert* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   741
  LIRItem value(x->value(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   742
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   743
  value.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   744
  LIR_Opr reg = rlock_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   745
  __ convert(x->op(), value.result(), reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   746
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   747
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   748
void LIRGenerator::do_NewInstance(NewInstance* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   749
  print_if_not_loaded(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   750
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   751
  // This instruction can be deoptimized in the slow path : use
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   752
  // Z_R2 as result register.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   753
  const LIR_Opr reg = result_register_for (x->type());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   754
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   755
  CodeEmitInfo* info = state_for (x, x->state());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   756
  LIR_Opr tmp1 = FrameMap::Z_R12_oop_opr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   757
  LIR_Opr tmp2 = FrameMap::Z_R13_oop_opr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   758
  LIR_Opr tmp3 = reg;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   759
  LIR_Opr tmp4 = LIR_OprFact::illegalOpr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   760
  LIR_Opr klass_reg = FrameMap::Z_R11_metadata_opr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   761
  new_instance(reg, x->klass(), x->is_unresolved(), tmp1, tmp2, tmp3, tmp4, klass_reg, info);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   762
  LIR_Opr result = rlock_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   763
  __ move(reg, result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   764
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   765
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   766
void LIRGenerator::do_NewTypeArray(NewTypeArray* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   767
  CodeEmitInfo* info = state_for (x, x->state());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   768
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   769
  LIRItem length(x->length(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   770
  length.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   771
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   772
  LIR_Opr reg = result_register_for (x->type());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   773
  LIR_Opr tmp1 = FrameMap::Z_R12_oop_opr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   774
  LIR_Opr tmp2 = FrameMap::Z_R13_oop_opr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   775
  LIR_Opr tmp3 = reg;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   776
  LIR_Opr tmp4 = LIR_OprFact::illegalOpr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   777
  LIR_Opr klass_reg = FrameMap::Z_R11_metadata_opr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   778
  LIR_Opr len = length.result();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   779
  BasicType elem_type = x->elt_type();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   780
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   781
  __ metadata2reg(ciTypeArrayKlass::make(elem_type)->constant_encoding(), klass_reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   782
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   783
  CodeStub* slow_path = new NewTypeArrayStub(klass_reg, len, reg, info);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   784
  __ allocate_array(reg, len, tmp1, tmp2, tmp3, tmp4, elem_type, klass_reg, slow_path);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   785
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   786
  LIR_Opr result = rlock_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   787
  __ move(reg, result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   788
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   789
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   790
void LIRGenerator::do_NewObjectArray(NewObjectArray* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   791
  // Evaluate state_for early since it may emit code.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   792
  CodeEmitInfo* info = state_for (x, x->state());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   793
  // In case of patching (i.e., object class is not yet loaded), we need to reexecute the instruction
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   794
  // and therefore provide the state before the parameters have been consumed.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   795
  CodeEmitInfo* patching_info = NULL;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   796
  if (!x->klass()->is_loaded() || PatchALot) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   797
    patching_info = state_for (x, x->state_before());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   798
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   799
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   800
  LIRItem length(x->length(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   801
  length.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   802
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   803
  const LIR_Opr reg = result_register_for (x->type());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   804
  LIR_Opr tmp1 = FrameMap::Z_R12_oop_opr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   805
  LIR_Opr tmp2 = FrameMap::Z_R13_oop_opr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   806
  LIR_Opr tmp3 = LIR_OprFact::illegalOpr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   807
  LIR_Opr tmp4 = LIR_OprFact::illegalOpr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   808
  LIR_Opr klass_reg = FrameMap::Z_R11_metadata_opr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   809
  LIR_Opr len = length.result();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   810
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   811
  CodeStub* slow_path = new NewObjectArrayStub(klass_reg, len, reg, info);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   812
  ciKlass* obj = ciObjArrayKlass::make(x->klass());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   813
  if (obj == ciEnv::unloaded_ciobjarrayklass()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   814
    BAILOUT("encountered unloaded_ciobjarrayklass due to out of memory error");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   815
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   816
  klass2reg_with_patching(klass_reg, obj, patching_info);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   817
  __ allocate_array(reg, len, tmp1, tmp2, tmp3, tmp4, T_OBJECT, klass_reg, slow_path);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   818
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   819
  LIR_Opr result = rlock_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   820
  __ move(reg, result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   821
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   822
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   823
void LIRGenerator::do_NewMultiArray(NewMultiArray* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   824
  Values* dims = x->dims();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   825
  int i = dims->length();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   826
  LIRItemList* items = new LIRItemList(i, i, NULL);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   827
  while (i-- > 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   828
    LIRItem* size = new LIRItem(dims->at(i), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   829
    items->at_put(i, size);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   830
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   831
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   832
  // Evaluate state_for early since it may emit code.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   833
  CodeEmitInfo* patching_info = NULL;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   834
  if (!x->klass()->is_loaded() || PatchALot) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   835
    patching_info = state_for (x, x->state_before());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   836
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   837
    // Cannot re-use same xhandlers for multiple CodeEmitInfos, so
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   838
    // clone all handlers (NOTE: Usually this is handled transparently
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   839
    // by the CodeEmitInfo cloning logic in CodeStub constructors but
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   840
    // is done explicitly here because a stub isn't being used).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   841
    x->set_exception_handlers(new XHandlers(x->exception_handlers()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   842
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   843
  CodeEmitInfo* info = state_for (x, x->state());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   844
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   845
  i = dims->length();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   846
  while (--i >= 0) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   847
    LIRItem* size = items->at(i);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   848
    size->load_nonconstant(32);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   849
    // FrameMap::_reserved_argument_area_size includes the dimensions varargs, because
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   850
    // it's initialized to hir()->max_stack() when the FrameMap is created.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   851
    store_stack_parameter(size->result(), in_ByteSize(i*sizeof(jint) + FrameMap::first_available_sp_in_frame));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   852
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   853
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   854
  LIR_Opr klass_reg = FrameMap::Z_R3_metadata_opr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   855
  klass2reg_with_patching(klass_reg, x->klass(), patching_info);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   856
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   857
  LIR_Opr rank = FrameMap::Z_R4_opr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   858
  __ move(LIR_OprFact::intConst(x->rank()), rank);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   859
  LIR_Opr varargs = FrameMap::Z_R5_opr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   860
  __ leal(LIR_OprFact::address(new LIR_Address(FrameMap::Z_SP_opr, FrameMap::first_available_sp_in_frame, T_INT)),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   861
          varargs);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   862
  LIR_OprList* args = new LIR_OprList(3);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   863
  args->append(klass_reg);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   864
  args->append(rank);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   865
  args->append(varargs);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   866
  LIR_Opr reg = result_register_for (x->type());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   867
  __ call_runtime(Runtime1::entry_for (Runtime1::new_multi_array_id),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   868
                  LIR_OprFact::illegalOpr,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   869
                  reg, args, info);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   870
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   871
  LIR_Opr result = rlock_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   872
  __ move(reg, result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   873
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   874
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   875
void LIRGenerator::do_BlockBegin(BlockBegin* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   876
  // Nothing to do.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   877
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   878
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   879
void LIRGenerator::do_CheckCast(CheckCast* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   880
  LIRItem obj(x->obj(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   881
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   882
  CodeEmitInfo* patching_info = NULL;
49933
c63bdf53a1a7 8202399: [C1] LIRGenerator::do_CheckCast needs to exclude is_invokespecial_receiver_check() when using PatchAlot
dholmes
parents: 49906
diff changeset
   883
  if (!x->klass()->is_loaded() || (PatchALot && !x->is_incompatible_class_change_check() && !x->is_invokespecial_receiver_check())) {
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   884
    // Must do this before locking the destination register as an oop register,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   885
    // and before the obj is loaded (the latter is for deoptimization).
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   886
    patching_info = state_for (x, x->state_before());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   887
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   888
  obj.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   889
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   890
  // info for exceptions
44738
11431bbc9549 8168699: Validate special case invocations
coleenp
parents: 42897
diff changeset
   891
  CodeEmitInfo* info_for_exception =
11431bbc9549 8168699: Validate special case invocations
coleenp
parents: 42897
diff changeset
   892
      (x->needs_exception_state() ? state_for(x) :
11431bbc9549 8168699: Validate special case invocations
coleenp
parents: 42897
diff changeset
   893
                                    state_for(x, x->state_before(), true /*ignore_xhandler*/));
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   894
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   895
  CodeStub* stub;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   896
  if (x->is_incompatible_class_change_check()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   897
    assert(patching_info == NULL, "can't patch this");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   898
    stub = new SimpleExceptionStub(Runtime1::throw_incompatible_class_change_error_id, LIR_OprFact::illegalOpr, info_for_exception);
44738
11431bbc9549 8168699: Validate special case invocations
coleenp
parents: 42897
diff changeset
   899
  } else if (x->is_invokespecial_receiver_check()) {
11431bbc9549 8168699: Validate special case invocations
coleenp
parents: 42897
diff changeset
   900
    assert(patching_info == NULL, "can't patch this");
11431bbc9549 8168699: Validate special case invocations
coleenp
parents: 42897
diff changeset
   901
    stub = new DeoptimizeStub(info_for_exception,
11431bbc9549 8168699: Validate special case invocations
coleenp
parents: 42897
diff changeset
   902
                              Deoptimization::Reason_class_check,
11431bbc9549 8168699: Validate special case invocations
coleenp
parents: 42897
diff changeset
   903
                              Deoptimization::Action_none);
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   904
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   905
    stub = new SimpleExceptionStub(Runtime1::throw_class_cast_exception_id, obj.result(), info_for_exception);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   906
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   907
  LIR_Opr reg = rlock_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   908
  LIR_Opr tmp1 = new_register(objectType);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   909
  LIR_Opr tmp2 = new_register(objectType);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   910
  LIR_Opr tmp3 = LIR_OprFact::illegalOpr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   911
  __ checkcast(reg, obj.result(), x->klass(),
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   912
               tmp1, tmp2, tmp3,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   913
               x->direct_compare(), info_for_exception, patching_info, stub,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   914
               x->profiled_method(), x->profiled_bci());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   915
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   916
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   917
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   918
void LIRGenerator::do_InstanceOf(InstanceOf* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   919
  LIRItem obj(x->obj(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   920
  CodeEmitInfo* patching_info = NULL;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   921
  if (!x->klass()->is_loaded() || PatchALot) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   922
    patching_info = state_for (x, x->state_before());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   923
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   924
  // Ensure the result register is not the input register because the
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   925
  // result is initialized before the patching safepoint.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   926
  obj.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   927
  LIR_Opr out_reg = rlock_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   928
  LIR_Opr tmp1 = new_register(objectType);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   929
  LIR_Opr tmp2 = new_register(objectType);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   930
  LIR_Opr tmp3 = LIR_OprFact::illegalOpr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   931
  __ instanceof(out_reg, obj.result(), x->klass(), tmp1, tmp2, tmp3,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   932
                x->direct_compare(), patching_info,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   933
                x->profiled_method(), x->profiled_bci());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   934
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   935
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   936
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   937
void LIRGenerator::do_If (If* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   938
  assert(x->number_of_sux() == 2, "inconsistency");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   939
  ValueTag tag = x->x()->type()->tag();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   940
  bool is_safepoint = x->is_safepoint();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   941
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   942
  If::Condition cond = x->cond();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   943
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   944
  LIRItem xitem(x->x(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   945
  LIRItem yitem(x->y(), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   946
  LIRItem* xin = &xitem;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   947
  LIRItem* yin = &yitem;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   948
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   949
  if (tag == longTag) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   950
    // For longs, only conditions "eql", "neq", "lss", "geq" are valid;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   951
    // mirror for other conditions.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   952
    if (cond == If::gtr || cond == If::leq) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   953
      cond = Instruction::mirror(cond);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   954
      xin = &yitem;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   955
      yin = &xitem;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   956
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   957
    xin->set_destroys_register();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   958
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   959
  xin->load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   960
  // TODO: don't load long constants != 0L
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   961
  if (tag == longTag && yin->is_constant() && yin->get_jlong_constant() == 0 && (cond == If::eql || cond == If::neq)) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   962
    // inline long zero
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   963
    yin->dont_load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   964
  } else if (tag == longTag || tag == floatTag || tag == doubleTag) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   965
    // Longs cannot handle constants at right side.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   966
    yin->load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   967
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   968
    yin->dont_load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   969
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   970
50153
9010b580d8a9 8201447: C1 does backedge profiling incorrectly
iveresov
parents: 49933
diff changeset
   971
  LIR_Opr left = xin->result();
9010b580d8a9 8201447: C1 does backedge profiling incorrectly
iveresov
parents: 49933
diff changeset
   972
  LIR_Opr right = yin->result();
9010b580d8a9 8201447: C1 does backedge profiling incorrectly
iveresov
parents: 49933
diff changeset
   973
9010b580d8a9 8201447: C1 does backedge profiling incorrectly
iveresov
parents: 49933
diff changeset
   974
  set_no_result(x);
9010b580d8a9 8201447: C1 does backedge profiling incorrectly
iveresov
parents: 49933
diff changeset
   975
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   976
  // Add safepoint before generating condition code so it can be recomputed.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   977
  if (x->is_safepoint()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   978
    // Increment backedge counter if needed.
50153
9010b580d8a9 8201447: C1 does backedge profiling incorrectly
iveresov
parents: 49933
diff changeset
   979
    increment_backedge_counter_conditionally(lir_cond(cond), left, right, state_for(x, x->state_before()),
9010b580d8a9 8201447: C1 does backedge profiling incorrectly
iveresov
parents: 49933
diff changeset
   980
        x->tsux()->bci(), x->fsux()->bci(), x->profiled_bci());
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   981
    // Use safepoint_poll_register() instead of LIR_OprFact::illegalOpr.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   982
    __ safepoint(safepoint_poll_register(), state_for (x, x->state_before()));
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   983
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   984
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   985
  __ cmp(lir_cond(cond), left, right);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   986
  // Generate branch profiling. Profiling code doesn't kill flags.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   987
  profile_branch(x, cond);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   988
  move_to_phi(x->state());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   989
  if (x->x()->type()->is_float_kind()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   990
    __ branch(lir_cond(cond), right->type(), x->tsux(), x->usux());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   991
  } else {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   992
    __ branch(lir_cond(cond), right->type(), x->tsux());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   993
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   994
  assert(x->default_sux() == x->fsux(), "wrong destination above");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   995
  __ jump(x->default_sux());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   996
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   997
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   998
LIR_Opr LIRGenerator::getThreadPointer() {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
   999
  return FrameMap::as_pointer_opr(Z_thread);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1000
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1001
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1002
void LIRGenerator::trace_block_entry(BlockBegin* block) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1003
  __ move(LIR_OprFact::intConst(block->block_id()), FrameMap::Z_R2_opr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1004
  LIR_OprList* args = new LIR_OprList(1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1005
  args->append(FrameMap::Z_R2_opr);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1006
  address func = CAST_FROM_FN_PTR(address, Runtime1::trace_block_entry);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1007
  __ call_runtime_leaf(func, LIR_OprFact::illegalOpr, LIR_OprFact::illegalOpr, args);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1008
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1009
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1010
void LIRGenerator::volatile_field_store(LIR_Opr value, LIR_Address* address,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1011
                                        CodeEmitInfo* info) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1012
  __ store(value, address, info);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1013
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1014
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1015
void LIRGenerator::volatile_field_load(LIR_Address* address, LIR_Opr result,
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1016
                                       CodeEmitInfo* info) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1017
  __ load(address, result, info);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1018
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1019
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1020
void LIRGenerator::do_update_CRC32(Intrinsic* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1021
  assert(UseCRC32Intrinsics, "or should not be here");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1022
  LIR_Opr result = rlock_result(x);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1023
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1024
  switch (x->id()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1025
    case vmIntrinsics::_updateCRC32: {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1026
      LIRItem crc(x->argument_at(0), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1027
      LIRItem val(x->argument_at(1), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1028
      // Registers destroyed by update_crc32.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1029
      crc.set_destroys_register();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1030
      val.set_destroys_register();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1031
      crc.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1032
      val.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1033
      __ update_crc32(crc.result(), val.result(), result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1034
      break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1035
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1036
    case vmIntrinsics::_updateBytesCRC32:
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1037
    case vmIntrinsics::_updateByteBufferCRC32: {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1038
      bool is_updateBytes = (x->id() == vmIntrinsics::_updateBytesCRC32);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1039
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1040
      LIRItem crc(x->argument_at(0), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1041
      LIRItem buf(x->argument_at(1), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1042
      LIRItem off(x->argument_at(2), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1043
      LIRItem len(x->argument_at(3), this);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1044
      buf.load_item();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1045
      off.load_nonconstant();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1046
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1047
      LIR_Opr index = off.result();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1048
      int offset = is_updateBytes ? arrayOopDesc::base_offset_in_bytes(T_BYTE) : 0;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1049
      if (off.result()->is_constant()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1050
        index = LIR_OprFact::illegalOpr;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1051
        offset += off.result()->as_jint();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1052
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1053
      LIR_Opr base_op = buf.result();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1054
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1055
      if (index->is_valid()) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1056
        LIR_Opr tmp = new_register(T_LONG);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1057
        __ convert(Bytecodes::_i2l, index, tmp);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1058
        index = tmp;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1059
      }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1060
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1061
      LIR_Address* a = new LIR_Address(base_op, index, offset, T_BYTE);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1062
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1063
      BasicTypeList signature(3);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1064
      signature.append(T_INT);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1065
      signature.append(T_ADDRESS);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1066
      signature.append(T_INT);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1067
      CallingConvention* cc = frame_map()->c_calling_convention(&signature);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1068
      const LIR_Opr result_reg = result_register_for (x->type());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1069
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1070
      LIR_Opr arg1 = cc->at(0);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1071
      LIR_Opr arg2 = cc->at(1);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1072
      LIR_Opr arg3 = cc->at(2);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1073
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1074
      crc.load_item_force(arg1); // We skip int->long conversion here, because CRC32 stub doesn't care about high bits.
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1075
      __ leal(LIR_OprFact::address(a), arg2);
46315
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1076
      len.load_item_force(arg3); // We skip int->long conversion here, because CRC32 stub expects int.
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1077
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1078
      __ call_runtime_leaf(StubRoutines::updateBytesCRC32(), LIR_OprFact::illegalOpr, result_reg, cc->args());
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1079
      __ move(result_reg, result);
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1080
      break;
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1081
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1082
    default: {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1083
      ShouldNotReachHere();
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1084
    }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1085
  }
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1086
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1087
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1088
void LIRGenerator::do_update_CRC32C(Intrinsic* x) {
46315
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1089
  assert(UseCRC32CIntrinsics, "or should not be here");
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1090
  LIR_Opr result = rlock_result(x);
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1091
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1092
  switch (x->id()) {
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1093
    case vmIntrinsics::_updateBytesCRC32C:
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1094
    case vmIntrinsics::_updateDirectByteBufferCRC32C: {
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1095
      bool is_updateBytes = (x->id() == vmIntrinsics::_updateBytesCRC32C);
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1096
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1097
      LIRItem crc(x->argument_at(0), this);
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1098
      LIRItem buf(x->argument_at(1), this);
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1099
      LIRItem off(x->argument_at(2), this);
46386
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46315
diff changeset
  1100
      LIRItem end(x->argument_at(3), this);
46315
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1101
      buf.load_item();
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1102
      off.load_nonconstant();
46386
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46315
diff changeset
  1103
      end.load_nonconstant();
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46315
diff changeset
  1104
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46315
diff changeset
  1105
      // len = end - off
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46315
diff changeset
  1106
      LIR_Opr len  = end.result();
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46315
diff changeset
  1107
      LIR_Opr tmpA = new_register(T_INT);
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46315
diff changeset
  1108
      LIR_Opr tmpB = new_register(T_INT);
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46315
diff changeset
  1109
      __ move(end.result(), tmpA);
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46315
diff changeset
  1110
      __ move(off.result(), tmpB);
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46315
diff changeset
  1111
      __ sub(tmpA, tmpB, tmpA);
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46315
diff changeset
  1112
      len = tmpA;
46315
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1113
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1114
      LIR_Opr index = off.result();
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1115
      int offset = is_updateBytes ? arrayOopDesc::base_offset_in_bytes(T_BYTE) : 0;
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1116
      if (off.result()->is_constant()) {
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1117
        index = LIR_OprFact::illegalOpr;
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1118
        offset += off.result()->as_jint();
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1119
      }
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1120
      LIR_Opr base_op = buf.result();
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1121
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1122
      if (index->is_valid()) {
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1123
        LIR_Opr tmp = new_register(T_LONG);
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1124
        __ convert(Bytecodes::_i2l, index, tmp);
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1125
        index = tmp;
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1126
      }
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1127
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1128
      LIR_Address* a = new LIR_Address(base_op, index, offset, T_BYTE);
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1129
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1130
      BasicTypeList signature(3);
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1131
      signature.append(T_INT);
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1132
      signature.append(T_ADDRESS);
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1133
      signature.append(T_INT);
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1134
      CallingConvention* cc = frame_map()->c_calling_convention(&signature);
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1135
      const LIR_Opr result_reg = result_register_for (x->type());
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1136
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1137
      LIR_Opr arg1 = cc->at(0);
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1138
      LIR_Opr arg2 = cc->at(1);
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1139
      LIR_Opr arg3 = cc->at(2);
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1140
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1141
      crc.load_item_force(arg1); // We skip int->long conversion here, because CRC32C stub doesn't care about high bits.
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1142
      __ leal(LIR_OprFact::address(a), arg2);
46386
742f8b16d00c 8176580: [ppc, s390] CRC32C: wrong checksum result in some cases
simonis
parents: 46315
diff changeset
  1143
      __ move(len, cc->at(2));   // We skip int->long conversion here, because CRC32C stub expects int.
46315
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1144
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1145
      __ call_runtime_leaf(StubRoutines::updateBytesCRC32C(), LIR_OprFact::illegalOpr, result_reg, cc->args());
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1146
      __ move(result_reg, result);
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1147
      break;
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1148
    }
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1149
    default: {
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1150
      ShouldNotReachHere();
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1151
    }
a796c32af782 8175368: [s390] Provide intrinsic implementation for CRC32C
lucy
parents: 42897
diff changeset
  1152
  }
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1153
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1154
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1155
void LIRGenerator::do_FmaIntrinsic(Intrinsic* x) {
42897
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1156
  assert(x->number_of_arguments() == 3, "wrong type");
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1157
  assert(UseFMA, "Needs FMA instructions support.");
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1158
  LIRItem value(x->argument_at(0), this);
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1159
  LIRItem value1(x->argument_at(1), this);
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1160
  LIRItem value2(x->argument_at(2), this);
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1161
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1162
  value2.set_destroys_register();
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1163
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1164
  value.load_item();
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1165
  value1.load_item();
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1166
  value2.load_item();
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1167
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1168
  LIR_Opr calc_input = value.result();
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1169
  LIR_Opr calc_input1 = value1.result();
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1170
  LIR_Opr calc_input2 = value2.result();
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1171
  LIR_Opr calc_result = rlock_result(x);
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1172
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1173
  switch (x->id()) {
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1174
  case vmIntrinsics::_fmaD:   __ fmad(calc_input, calc_input1, calc_input2, calc_result); break;
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1175
  case vmIntrinsics::_fmaF:   __ fmaf(calc_input, calc_input1, calc_input2, calc_result); break;
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1176
  default:                    ShouldNotReachHere();
57e7b1c75d17 8171398: s390x: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42065
diff changeset
  1177
  }
42065
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1178
}
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1179
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1180
void LIRGenerator::do_vectorizedMismatch(Intrinsic* x) {
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1181
  fatal("vectorizedMismatch intrinsic is not implemented on this platform");
6032b31e3719 8167673: [s390] The s390 port.
goetz
parents:
diff changeset
  1182
}