src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp
author coleenp
Wed, 21 Mar 2018 19:45:24 -0400
changeset 49480 d7df2dd501ce
parent 49470 a273b521a559
child 49906 4bb58f644e4e
permissions -rw-r--r--
8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files Summary: Remove frame.inline.hpp,etc from header files and adjust transitive includes. Reviewed-by: stefank, stuefe
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
     1
/*
48856
c866eaca24cb 8194984: 9 Null pointer dereference defect groups related to ciMethodData::bci_to_data()
dlong
parents: 48332
diff changeset
     2
 * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
46317
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 42884
diff changeset
     3
 * Copyright (c) 2012, 2017, SAP SE. All rights reserved.
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
     5
 *
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
     8
 * published by the Free Software Foundation.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
     9
 *
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    14
 * accompanied this code).
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    15
 *
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    19
 *
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    22
 * questions.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    23
 *
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    24
 */
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    25
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    26
#include "precompiled.hpp"
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    27
#include "c1/c1_Compilation.hpp"
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    28
#include "c1/c1_LIRAssembler.hpp"
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    29
#include "c1/c1_MacroAssembler.hpp"
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    30
#include "c1/c1_Runtime1.hpp"
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    31
#include "c1/c1_ValueStack.hpp"
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    32
#include "ci/ciArrayKlass.hpp"
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    33
#include "ci/ciInstance.hpp"
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    34
#include "gc/shared/collectedHeap.hpp"
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    35
#include "gc/shared/barrierSet.hpp"
49455
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 48856
diff changeset
    36
#include "gc/shared/cardTableBarrierSet.hpp"
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    37
#include "nativeInst_ppc.hpp"
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    38
#include "oops/objArrayKlass.hpp"
49480
d7df2dd501ce 8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents: 49470
diff changeset
    39
#include "runtime/frame.inline.hpp"
48332
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 47698
diff changeset
    40
#include "runtime/safepointMechanism.inline.hpp"
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    41
#include "runtime/sharedRuntime.hpp"
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    42
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    43
#define __ _masm->
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    44
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    45
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    46
const ConditionRegister LIR_Assembler::BOOL_RESULT = CCR5;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    47
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    48
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    49
bool LIR_Assembler::is_small_constant(LIR_Opr opr) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    50
  Unimplemented(); return false; // Currently not used on this platform.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    51
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    52
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    53
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    54
LIR_Opr LIR_Assembler::receiverOpr() {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    55
  return FrameMap::R3_oop_opr;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    56
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    57
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    58
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    59
LIR_Opr LIR_Assembler::osrBufferPointer() {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    60
  return FrameMap::R3_opr;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    61
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    62
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    63
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    64
// This specifies the stack pointer decrement needed to build the frame.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    65
int LIR_Assembler::initial_frame_size_in_bytes() const {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    66
  return in_bytes(frame_map()->framesize_in_bytes());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    67
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    68
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    69
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    70
// Inline cache check: the inline cached class is in inline_cache_reg;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    71
// we fetch the class of the receiver and compare it with the cached class.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    72
// If they do not match we jump to slow case.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    73
int LIR_Assembler::check_icache() {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    74
  int offset = __ offset();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    75
  __ inline_cache_check(R3_ARG1, R19_inline_cache_reg);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    76
  return offset;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    77
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    78
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    79
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    80
void LIR_Assembler::osr_entry() {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    81
  // On-stack-replacement entry sequence:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    82
  //
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    83
  //   1. Create a new compiled activation.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    84
  //   2. Initialize local variables in the compiled activation. The expression
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    85
  //      stack must be empty at the osr_bci; it is not initialized.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    86
  //   3. Jump to the continuation address in compiled code to resume execution.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    87
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    88
  // OSR entry point
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    89
  offsets()->set_value(CodeOffsets::OSR_Entry, code_offset());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    90
  BlockBegin* osr_entry = compilation()->hir()->osr_entry();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    91
  ValueStack* entry_state = osr_entry->end()->state();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    92
  int number_of_locks = entry_state->locks_size();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    93
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    94
  // Create a frame for the compiled activation.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    95
  __ build_frame(initial_frame_size_in_bytes(), bang_size_in_bytes());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    96
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    97
  // OSR buffer is
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    98
  //
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    99
  // locals[nlocals-1..0]
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   100
  // monitors[number_of_locks-1..0]
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   101
  //
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   102
  // Locals is a direct copy of the interpreter frame so in the osr buffer
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   103
  // the first slot in the local array is the last local from the interpreter
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   104
  // and the last slot is local[0] (receiver) from the interpreter.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   105
  //
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   106
  // Similarly with locks. The first lock slot in the osr buffer is the nth lock
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   107
  // from the interpreter frame, the nth lock slot in the osr buffer is 0th lock
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   108
  // in the interpreter frame (the method lock if a sync method).
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   109
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   110
  // Initialize monitors in the compiled activation.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   111
  //   R3: pointer to osr buffer
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   112
  //
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   113
  // All other registers are dead at this point and the locals will be
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   114
  // copied into place by code emitted in the IR.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   115
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   116
  Register OSR_buf = osrBufferPointer()->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   117
  { assert(frame::interpreter_frame_monitor_size() == BasicObjectLock::size(), "adjust code below");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   118
    int monitor_offset = BytesPerWord * method()->max_locals() +
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   119
      (2 * BytesPerWord) * (number_of_locks - 1);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   120
    // SharedRuntime::OSR_migration_begin() packs BasicObjectLocks in
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   121
    // the OSR buffer using 2 word entries: first the lock and then
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   122
    // the oop.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   123
    for (int i = 0; i < number_of_locks; i++) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   124
      int slot_offset = monitor_offset - ((i * 2) * BytesPerWord);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   125
#ifdef ASSERT
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   126
      // Verify the interpreter's monitor has a non-null object.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   127
      {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   128
        Label L;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   129
        __ ld(R0, slot_offset + 1*BytesPerWord, OSR_buf);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   130
        __ cmpdi(CCR0, R0, 0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   131
        __ bne(CCR0, L);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   132
        __ stop("locked object is NULL");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   133
        __ bind(L);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   134
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   135
#endif // ASSERT
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   136
      // Copy the lock field into the compiled activation.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   137
      Address ml = frame_map()->address_for_monitor_lock(i),
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   138
              mo = frame_map()->address_for_monitor_object(i);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   139
      assert(ml.index() == noreg && mo.index() == noreg, "sanity");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   140
      __ ld(R0, slot_offset + 0, OSR_buf);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   141
      __ std(R0, ml.disp(), ml.base());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   142
      __ ld(R0, slot_offset + 1*BytesPerWord, OSR_buf);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   143
      __ std(R0, mo.disp(), mo.base());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   144
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   145
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   146
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   147
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   148
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   149
int LIR_Assembler::emit_exception_handler() {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   150
  // If the last instruction is a call (typically to do a throw which
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   151
  // is coming at the end after block reordering) the return address
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   152
  // must still point into the code area in order to avoid assertion
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   153
  // failures when searching for the corresponding bci => add a nop
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   154
  // (was bug 5/14/1999 - gri).
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   155
  __ nop();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   156
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   157
  // Generate code for the exception handler.
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42068
diff changeset
   158
  address handler_base = __ start_a_stub(exception_handler_size());
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   159
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   160
  if (handler_base == NULL) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   161
    // Not enough space left for the handler.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   162
    bailout("exception handler overflow");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   163
    return -1;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   164
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   165
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   166
  int offset = code_offset();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   167
  address entry_point = CAST_FROM_FN_PTR(address, Runtime1::entry_for(Runtime1::handle_exception_from_callee_id));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   168
  //__ load_const_optimized(R0, entry_point);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   169
  __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(entry_point));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   170
  __ mtctr(R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   171
  __ bctr();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   172
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42068
diff changeset
   173
  guarantee(code_offset() - offset <= exception_handler_size(), "overflow");
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   174
  __ end_a_stub();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   175
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   176
  return offset;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   177
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   178
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   179
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   180
// Emit the code to remove the frame from the stack in the exception
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   181
// unwind path.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   182
int LIR_Assembler::emit_unwind_handler() {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   183
  _masm->block_comment("Unwind handler");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   184
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   185
  int offset = code_offset();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   186
  bool preserve_exception = method()->is_synchronized() || compilation()->env()->dtrace_method_probes();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   187
  const Register Rexception = R3 /*LIRGenerator::exceptionOopOpr()*/, Rexception_save = R31;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   188
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   189
  // Fetch the exception from TLS and clear out exception related thread state.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   190
  __ ld(Rexception, in_bytes(JavaThread::exception_oop_offset()), R16_thread);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   191
  __ li(R0, 0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   192
  __ std(R0, in_bytes(JavaThread::exception_oop_offset()), R16_thread);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   193
  __ std(R0, in_bytes(JavaThread::exception_pc_offset()), R16_thread);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   194
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   195
  __ bind(_unwind_handler_entry);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   196
  __ verify_not_null_oop(Rexception);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   197
  if (preserve_exception) { __ mr(Rexception_save, Rexception); }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   198
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   199
  // Perform needed unlocking
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   200
  MonitorExitStub* stub = NULL;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   201
  if (method()->is_synchronized()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   202
    monitor_address(0, FrameMap::R4_opr);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   203
    stub = new MonitorExitStub(FrameMap::R4_opr, true, 0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   204
    __ unlock_object(R5, R6, R4, *stub->entry());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   205
    __ bind(*stub->continuation());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   206
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   207
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   208
  if (compilation()->env()->dtrace_method_probes()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   209
    Unimplemented();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   210
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   211
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   212
  // Dispatch to the unwind logic.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   213
  address unwind_stub = Runtime1::entry_for(Runtime1::unwind_exception_id);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   214
  //__ load_const_optimized(R0, unwind_stub);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   215
  __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(unwind_stub));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   216
  if (preserve_exception) { __ mr(Rexception, Rexception_save); }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   217
  __ mtctr(R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   218
  __ bctr();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   219
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   220
  // Emit the slow path assembly.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   221
  if (stub != NULL) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   222
    stub->emit_code(this);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   223
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   224
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   225
  return offset;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   226
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   227
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   228
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   229
int LIR_Assembler::emit_deopt_handler() {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   230
  // If the last instruction is a call (typically to do a throw which
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   231
  // is coming at the end after block reordering) the return address
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   232
  // must still point into the code area in order to avoid assertion
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   233
  // failures when searching for the corresponding bci => add a nop
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   234
  // (was bug 5/14/1999 - gri).
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   235
  __ nop();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   236
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   237
  // Generate code for deopt handler.
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42068
diff changeset
   238
  address handler_base = __ start_a_stub(deopt_handler_size());
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   239
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   240
  if (handler_base == NULL) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   241
    // Not enough space left for the handler.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   242
    bailout("deopt handler overflow");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   243
    return -1;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   244
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   245
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   246
  int offset = code_offset();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   247
  __ bl64_patchable(SharedRuntime::deopt_blob()->unpack(), relocInfo::runtime_call_type);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   248
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42068
diff changeset
   249
  guarantee(code_offset() - offset <= deopt_handler_size(), "overflow");
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   250
  __ end_a_stub();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   251
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   252
  return offset;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   253
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   254
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   255
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   256
void LIR_Assembler::jobject2reg(jobject o, Register reg) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   257
  if (o == NULL) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   258
    __ li(reg, 0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   259
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   260
    AddressLiteral addrlit = __ constant_oop_address(o);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   261
    __ load_const(reg, addrlit, (reg != R0) ? R0 : noreg);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   262
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   263
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   264
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   265
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   266
void LIR_Assembler::jobject2reg_with_patching(Register reg, CodeEmitInfo *info) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   267
  // Allocate a new index in table to hold the object once it's been patched.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   268
  int oop_index = __ oop_recorder()->allocate_oop_index(NULL);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   269
  PatchingStub* patch = new PatchingStub(_masm, patching_id(info), oop_index);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   270
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   271
  AddressLiteral addrlit((address)NULL, oop_Relocation::spec(oop_index));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   272
  __ load_const(reg, addrlit, R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   273
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   274
  patching_epilog(patch, lir_patch_normal, reg, info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   275
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   276
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   277
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   278
void LIR_Assembler::metadata2reg(Metadata* o, Register reg) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   279
  AddressLiteral md = __ constant_metadata_address(o); // Notify OOP recorder (don't need the relocation)
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   280
  __ load_const_optimized(reg, md.value(), (reg != R0) ? R0 : noreg);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   281
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   282
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   283
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   284
void LIR_Assembler::klass2reg_with_patching(Register reg, CodeEmitInfo *info) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   285
  // Allocate a new index in table to hold the klass once it's been patched.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   286
  int index = __ oop_recorder()->allocate_metadata_index(NULL);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   287
  PatchingStub* patch = new PatchingStub(_masm, PatchingStub::load_klass_id, index);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   288
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   289
  AddressLiteral addrlit((address)NULL, metadata_Relocation::spec(index));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   290
  assert(addrlit.rspec().type() == relocInfo::metadata_type, "must be an metadata reloc");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   291
  __ load_const(reg, addrlit, R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   292
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   293
  patching_epilog(patch, lir_patch_normal, reg, info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   294
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   295
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   296
42884
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42650
diff changeset
   297
void LIR_Assembler::arithmetic_idiv(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr temp, LIR_Opr result, CodeEmitInfo* info) {
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42650
diff changeset
   298
  const bool is_int = result->is_single_cpu();
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42650
diff changeset
   299
  Register Rdividend = is_int ? left->as_register() : left->as_register_lo();
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   300
  Register Rdivisor  = noreg;
42884
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42650
diff changeset
   301
  Register Rscratch  = temp->as_register();
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42650
diff changeset
   302
  Register Rresult   = is_int ? result->as_register() : result->as_register_lo();
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   303
  long divisor = -1;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   304
42884
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42650
diff changeset
   305
  if (right->is_register()) {
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42650
diff changeset
   306
    Rdivisor = is_int ? right->as_register() : right->as_register_lo();
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   307
  } else {
42884
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42650
diff changeset
   308
    divisor = is_int ? right->as_constant_ptr()->as_jint()
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42650
diff changeset
   309
                     : right->as_constant_ptr()->as_jlong();
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   310
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   311
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   312
  assert(Rdividend != Rscratch, "");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   313
  assert(Rdivisor  != Rscratch, "");
42884
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42650
diff changeset
   314
  assert(code == lir_idiv || code == lir_irem, "Must be irem or idiv");
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   315
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   316
  if (Rdivisor == noreg) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   317
    if (divisor == 1) { // stupid, but can happen
42884
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42650
diff changeset
   318
      if (code == lir_idiv) {
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   319
        __ mr_if_needed(Rresult, Rdividend);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   320
      } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   321
        __ li(Rresult, 0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   322
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   323
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   324
    } else if (is_power_of_2(divisor)) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   325
      // Convert division by a power of two into some shifts and logical operations.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   326
      int log2 = log2_intptr(divisor);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   327
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   328
      // Round towards 0.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   329
      if (divisor == 2) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   330
        if (is_int) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   331
          __ srwi(Rscratch, Rdividend, 31);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   332
        } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   333
          __ srdi(Rscratch, Rdividend, 63);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   334
        }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   335
      } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   336
        if (is_int) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   337
          __ srawi(Rscratch, Rdividend, 31);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   338
        } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   339
          __ sradi(Rscratch, Rdividend, 63);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   340
        }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   341
        __ clrldi(Rscratch, Rscratch, 64-log2);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   342
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   343
      __ add(Rscratch, Rdividend, Rscratch);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   344
42884
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42650
diff changeset
   345
      if (code == lir_idiv) {
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   346
        if (is_int) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   347
          __ srawi(Rresult, Rscratch, log2);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   348
        } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   349
          __ sradi(Rresult, Rscratch, log2);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   350
        }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   351
      } else { // lir_irem
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   352
        __ clrrdi(Rscratch, Rscratch, log2);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   353
        __ sub(Rresult, Rdividend, Rscratch);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   354
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   355
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   356
    } else if (divisor == -1) {
42884
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42650
diff changeset
   357
      if (code == lir_idiv) {
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   358
        __ neg(Rresult, Rdividend);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   359
      } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   360
        __ li(Rresult, 0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   361
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   362
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   363
    } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   364
      __ load_const_optimized(Rscratch, divisor);
42884
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42650
diff changeset
   365
      if (code == lir_idiv) {
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   366
        if (is_int) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   367
          __ divw(Rresult, Rdividend, Rscratch); // Can't divide minint/-1.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   368
        } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   369
          __ divd(Rresult, Rdividend, Rscratch); // Can't divide minint/-1.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   370
        }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   371
      } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   372
        assert(Rscratch != R0, "need both");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   373
        if (is_int) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   374
          __ divw(R0, Rdividend, Rscratch); // Can't divide minint/-1.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   375
          __ mullw(Rscratch, R0, Rscratch);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   376
        } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   377
          __ divd(R0, Rdividend, Rscratch); // Can't divide minint/-1.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   378
          __ mulld(Rscratch, R0, Rscratch);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   379
        }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   380
        __ sub(Rresult, Rdividend, Rscratch);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   381
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   382
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   383
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   384
    return;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   385
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   386
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   387
  Label regular, done;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   388
  if (is_int) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   389
    __ cmpwi(CCR0, Rdivisor, -1);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   390
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   391
    __ cmpdi(CCR0, Rdivisor, -1);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   392
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   393
  __ bne(CCR0, regular);
42884
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42650
diff changeset
   394
  if (code == lir_idiv) {
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   395
    __ neg(Rresult, Rdividend);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   396
    __ b(done);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   397
    __ bind(regular);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   398
    if (is_int) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   399
      __ divw(Rresult, Rdividend, Rdivisor); // Can't divide minint/-1.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   400
    } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   401
      __ divd(Rresult, Rdividend, Rdivisor); // Can't divide minint/-1.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   402
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   403
  } else { // lir_irem
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   404
    __ li(Rresult, 0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   405
    __ b(done);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   406
    __ bind(regular);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   407
    if (is_int) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   408
      __ divw(Rscratch, Rdividend, Rdivisor); // Can't divide minint/-1.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   409
      __ mullw(Rscratch, Rscratch, Rdivisor);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   410
    } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   411
      __ divd(Rscratch, Rdividend, Rdivisor); // Can't divide minint/-1.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   412
      __ mulld(Rscratch, Rscratch, Rdivisor);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   413
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   414
    __ sub(Rresult, Rdividend, Rscratch);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   415
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   416
  __ bind(done);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   417
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   418
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   419
42884
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42650
diff changeset
   420
void LIR_Assembler::emit_op3(LIR_Op3* op) {
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42650
diff changeset
   421
  switch (op->code()) {
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42650
diff changeset
   422
  case lir_idiv:
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42650
diff changeset
   423
  case lir_irem:
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42650
diff changeset
   424
    arithmetic_idiv(op->code(), op->in_opr1(), op->in_opr2(), op->in_opr3(),
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42650
diff changeset
   425
                    op->result_opr(), op->info());
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42650
diff changeset
   426
    break;
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42650
diff changeset
   427
  case lir_fmad:
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42650
diff changeset
   428
    __ fmadd(op->result_opr()->as_double_reg(), op->in_opr1()->as_double_reg(),
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42650
diff changeset
   429
             op->in_opr2()->as_double_reg(), op->in_opr3()->as_double_reg());
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42650
diff changeset
   430
    break;
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42650
diff changeset
   431
  case lir_fmaf:
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42650
diff changeset
   432
    __ fmadds(op->result_opr()->as_float_reg(), op->in_opr1()->as_float_reg(),
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42650
diff changeset
   433
              op->in_opr2()->as_float_reg(), op->in_opr3()->as_float_reg());
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42650
diff changeset
   434
    break;
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42650
diff changeset
   435
  default: ShouldNotReachHere(); break;
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42650
diff changeset
   436
  }
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42650
diff changeset
   437
}
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42650
diff changeset
   438
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42650
diff changeset
   439
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   440
void LIR_Assembler::emit_opBranch(LIR_OpBranch* op) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   441
#ifdef ASSERT
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   442
  assert(op->block() == NULL || op->block()->label() == op->label(), "wrong label");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   443
  if (op->block() != NULL)  _branch_target_blocks.append(op->block());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   444
  if (op->ublock() != NULL) _branch_target_blocks.append(op->ublock());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   445
  assert(op->info() == NULL, "shouldn't have CodeEmitInfo");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   446
#endif
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   447
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   448
  Label *L = op->label();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   449
  if (op->cond() == lir_cond_always) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   450
    __ b(*L);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   451
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   452
    Label done;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   453
    bool is_unordered = false;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   454
    if (op->code() == lir_cond_float_branch) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   455
      assert(op->ublock() != NULL, "must have unordered successor");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   456
      is_unordered = true;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   457
    } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   458
      assert(op->code() == lir_branch, "just checking");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   459
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   460
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   461
    bool positive = false;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   462
    Assembler::Condition cond = Assembler::equal;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   463
    switch (op->cond()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   464
      case lir_cond_equal:        positive = true ; cond = Assembler::equal  ; is_unordered = false; break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   465
      case lir_cond_notEqual:     positive = false; cond = Assembler::equal  ; is_unordered = false; break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   466
      case lir_cond_less:         positive = true ; cond = Assembler::less   ; break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   467
      case lir_cond_belowEqual:   assert(op->code() != lir_cond_float_branch, ""); // fallthru
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   468
      case lir_cond_lessEqual:    positive = false; cond = Assembler::greater; break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   469
      case lir_cond_greater:      positive = true ; cond = Assembler::greater; break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   470
      case lir_cond_aboveEqual:   assert(op->code() != lir_cond_float_branch, ""); // fallthru
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   471
      case lir_cond_greaterEqual: positive = false; cond = Assembler::less   ; break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   472
      default:                    ShouldNotReachHere();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   473
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   474
    int bo = positive ? Assembler::bcondCRbiIs1 : Assembler::bcondCRbiIs0;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   475
    int bi = Assembler::bi0(BOOL_RESULT, cond);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   476
    if (is_unordered) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   477
      if (positive) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   478
        if (op->ublock() == op->block()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   479
          __ bc_far_optimized(Assembler::bcondCRbiIs1, __ bi0(BOOL_RESULT, Assembler::summary_overflow), *L);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   480
        }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   481
      } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   482
        if (op->ublock() != op->block()) { __ bso(BOOL_RESULT, done); }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   483
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   484
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   485
    __ bc_far_optimized(bo, bi, *L);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   486
    __ bind(done);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   487
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   488
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   489
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   490
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   491
void LIR_Assembler::emit_opConvert(LIR_OpConvert* op) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   492
  Bytecodes::Code code = op->bytecode();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   493
  LIR_Opr src = op->in_opr(),
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   494
          dst = op->result_opr();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   495
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   496
  switch(code) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   497
    case Bytecodes::_i2l: {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   498
      __ extsw(dst->as_register_lo(), src->as_register());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   499
      break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   500
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   501
    case Bytecodes::_l2i: {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   502
      __ mr_if_needed(dst->as_register(), src->as_register_lo()); // high bits are garbage
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   503
      break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   504
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   505
    case Bytecodes::_i2b: {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   506
      __ extsb(dst->as_register(), src->as_register());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   507
      break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   508
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   509
    case Bytecodes::_i2c: {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   510
      __ clrldi(dst->as_register(), src->as_register(), 64-16);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   511
      break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   512
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   513
    case Bytecodes::_i2s: {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   514
      __ extsh(dst->as_register(), src->as_register());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   515
      break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   516
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   517
    case Bytecodes::_i2d:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   518
    case Bytecodes::_l2d: {
46615
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   519
      bool src_in_memory = !VM_Version::has_mtfprd();
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   520
      FloatRegister rdst = dst->as_double_reg();
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   521
      FloatRegister rsrc;
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   522
      if (src_in_memory) {
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   523
        rsrc = src->as_double_reg(); // via mem
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   524
      } else {
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   525
        // move src to dst register
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   526
        if (code == Bytecodes::_i2d) {
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   527
          __ mtfprwa(rdst, src->as_register());
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   528
        } else {
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   529
          __ mtfprd(rdst, src->as_register_lo());
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   530
        }
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   531
        rsrc = rdst;
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   532
      }
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   533
      __ fcfid(rdst, rsrc);
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   534
      break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   535
    }
46615
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   536
    case Bytecodes::_i2f:
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   537
    case Bytecodes::_l2f: {
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   538
      bool src_in_memory = !VM_Version::has_mtfprd();
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   539
      FloatRegister rdst = dst->as_float_reg();
46615
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   540
      FloatRegister rsrc;
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   541
      if (src_in_memory) {
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   542
        rsrc = src->as_double_reg(); // via mem
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   543
      } else {
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   544
        // move src to dst register
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   545
        if (code == Bytecodes::_i2f) {
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   546
          __ mtfprwa(rdst, src->as_register());
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   547
        } else {
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   548
          __ mtfprd(rdst, src->as_register_lo());
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   549
        }
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   550
        rsrc = rdst;
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   551
      }
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   552
      if (VM_Version::has_fcfids()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   553
        __ fcfids(rdst, rsrc);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   554
      } else {
46615
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   555
        assert(code == Bytecodes::_i2f, "fcfid+frsp needs fixup code to avoid rounding incompatibility");
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   556
        __ fcfid(rdst, rsrc);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   557
        __ frsp(rdst, rdst);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   558
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   559
      break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   560
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   561
    case Bytecodes::_f2d: {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   562
      __ fmr_if_needed(dst->as_double_reg(), src->as_float_reg());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   563
      break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   564
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   565
    case Bytecodes::_d2f: {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   566
      __ frsp(dst->as_float_reg(), src->as_double_reg());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   567
      break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   568
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   569
    case Bytecodes::_d2i:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   570
    case Bytecodes::_f2i: {
46615
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   571
      bool dst_in_memory = !VM_Version::has_mtfprd();
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   572
      FloatRegister rsrc = (code == Bytecodes::_d2i) ? src->as_double_reg() : src->as_float_reg();
46615
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   573
      Address       addr = dst_in_memory ? frame_map()->address_for_slot(dst->double_stack_ix()) : NULL;
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   574
      Label L;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   575
      // Result must be 0 if value is NaN; test by comparing value to itself.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   576
      __ fcmpu(CCR0, rsrc, rsrc);
46615
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   577
      if (dst_in_memory) {
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   578
        __ li(R0, 0); // 0 in case of NAN
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   579
        __ std(R0, addr.disp(), addr.base());
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   580
      } else {
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   581
        __ li(dst->as_register(), 0);
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   582
      }
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   583
      __ bso(CCR0, L);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   584
      __ fctiwz(rsrc, rsrc); // USE_KILL
46615
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   585
      if (dst_in_memory) {
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   586
        __ stfd(rsrc, addr.disp(), addr.base());
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   587
      } else {
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   588
        __ mffprd(dst->as_register(), rsrc);
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   589
      }
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   590
      __ bind(L);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   591
      break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   592
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   593
    case Bytecodes::_d2l:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   594
    case Bytecodes::_f2l: {
46615
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   595
      bool dst_in_memory = !VM_Version::has_mtfprd();
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   596
      FloatRegister rsrc = (code == Bytecodes::_d2l) ? src->as_double_reg() : src->as_float_reg();
46615
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   597
      Address       addr = dst_in_memory ? frame_map()->address_for_slot(dst->double_stack_ix()) : NULL;
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   598
      Label L;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   599
      // Result must be 0 if value is NaN; test by comparing value to itself.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   600
      __ fcmpu(CCR0, rsrc, rsrc);
46615
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   601
      if (dst_in_memory) {
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   602
        __ li(R0, 0); // 0 in case of NAN
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   603
        __ std(R0, addr.disp(), addr.base());
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   604
      } else {
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   605
        __ li(dst->as_register_lo(), 0);
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   606
      }
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   607
      __ bso(CCR0, L);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   608
      __ fctidz(rsrc, rsrc); // USE_KILL
46615
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   609
      if (dst_in_memory) {
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   610
        __ stfd(rsrc, addr.disp(), addr.base());
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   611
      } else {
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   612
        __ mffprd(dst->as_register_lo(), rsrc);
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46317
diff changeset
   613
      }
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   614
      __ bind(L);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   615
      break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   616
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   617
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   618
    default: ShouldNotReachHere();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   619
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   620
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   621
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   622
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   623
void LIR_Assembler::align_call(LIR_Code) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   624
  // do nothing since all instructions are word aligned on ppc
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   625
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   626
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   627
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   628
bool LIR_Assembler::emit_trampoline_stub_for_call(address target, Register Rtoc) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   629
  int start_offset = __ offset();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   630
  // Put the entry point as a constant into the constant pool.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   631
  const address entry_point_toc_addr   = __ address_constant(target, RelocationHolder::none);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   632
  if (entry_point_toc_addr == NULL) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   633
    bailout("const section overflow");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   634
    return false;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   635
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   636
  const int     entry_point_toc_offset = __ offset_to_method_toc(entry_point_toc_addr);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   637
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   638
  // Emit the trampoline stub which will be related to the branch-and-link below.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   639
  address stub = __ emit_trampoline_stub(entry_point_toc_offset, start_offset, Rtoc);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   640
  if (!stub) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   641
    bailout("no space for trampoline stub");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   642
    return false;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   643
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   644
  return true;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   645
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   646
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   647
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   648
void LIR_Assembler::call(LIR_OpJavaCall* op, relocInfo::relocType rtype) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   649
  assert(rtype==relocInfo::opt_virtual_call_type || rtype==relocInfo::static_call_type, "unexpected rtype");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   650
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   651
  bool success = emit_trampoline_stub_for_call(op->addr());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   652
  if (!success) { return; }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   653
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   654
  __ relocate(rtype);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   655
  // Note: At this point we do not have the address of the trampoline
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   656
  // stub, and the entry point might be too far away for bl, so __ pc()
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   657
  // serves as dummy and the bl will be patched later.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   658
  __ code()->set_insts_mark();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   659
  __ bl(__ pc());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   660
  add_call_info(code_offset(), op->info());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   661
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   662
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   663
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   664
void LIR_Assembler::ic_call(LIR_OpJavaCall* op) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   665
  __ calculate_address_from_global_toc(R2_TOC, __ method_toc());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   666
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   667
  // Virtual call relocation will point to ic load.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   668
  address virtual_call_meta_addr = __ pc();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   669
  // Load a clear inline cache.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   670
  AddressLiteral empty_ic((address) Universe::non_oop_word());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   671
  bool success = __ load_const_from_method_toc(R19_inline_cache_reg, empty_ic, R2_TOC);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   672
  if (!success) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   673
    bailout("const section overflow");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   674
    return;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   675
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   676
  // Call to fixup routine. Fixup routine uses ScopeDesc info
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   677
  // to determine who we intended to call.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   678
  __ relocate(virtual_call_Relocation::spec(virtual_call_meta_addr));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   679
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   680
  success = emit_trampoline_stub_for_call(op->addr(), R2_TOC);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   681
  if (!success) { return; }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   682
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   683
  // Note: At this point we do not have the address of the trampoline
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   684
  // stub, and the entry point might be too far away for bl, so __ pc()
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   685
  // serves as dummy and the bl will be patched later.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   686
  __ bl(__ pc());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   687
  add_call_info(code_offset(), op->info());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   688
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   689
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   690
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   691
void LIR_Assembler::vtable_call(LIR_OpJavaCall* op) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   692
  ShouldNotReachHere(); // ic_call is used instead.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   693
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   694
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   695
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   696
void LIR_Assembler::explicit_null_check(Register addr, CodeEmitInfo* info) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   697
  ImplicitNullCheckStub* stub = new ImplicitNullCheckStub(code_offset(), info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   698
  __ null_check(addr, stub->entry());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   699
  append_code_stub(stub);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   700
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   701
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   702
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   703
// Attention: caller must encode oop if needed
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   704
int LIR_Assembler::store(LIR_Opr from_reg, Register base, int offset, BasicType type, bool wide, bool unaligned) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   705
  int store_offset;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   706
  if (!Assembler::is_simm16(offset)) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   707
    // For offsets larger than a simm16 we setup the offset.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   708
    assert(wide && !from_reg->is_same_register(FrameMap::R0_opr), "large offset only supported in special case");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   709
    __ load_const_optimized(R0, offset);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   710
    store_offset = store(from_reg, base, R0, type, wide);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   711
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   712
    store_offset = code_offset();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   713
    switch (type) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   714
      case T_BOOLEAN: // fall through
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   715
      case T_BYTE  : __ stb(from_reg->as_register(), offset, base); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   716
      case T_CHAR  :
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   717
      case T_SHORT : __ sth(from_reg->as_register(), offset, base); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   718
      case T_INT   : __ stw(from_reg->as_register(), offset, base); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   719
      case T_LONG  : __ std(from_reg->as_register_lo(), offset, base); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   720
      case T_ADDRESS:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   721
      case T_METADATA: __ std(from_reg->as_register(), offset, base); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   722
      case T_ARRAY : // fall through
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   723
      case T_OBJECT:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   724
        {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   725
          if (UseCompressedOops && !wide) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   726
            // Encoding done in caller
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   727
            __ stw(from_reg->as_register(), offset, base);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   728
          } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   729
            __ std(from_reg->as_register(), offset, base);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   730
          }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   731
          __ verify_oop(from_reg->as_register());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   732
          break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   733
        }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   734
      case T_FLOAT : __ stfs(from_reg->as_float_reg(), offset, base); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   735
      case T_DOUBLE: __ stfd(from_reg->as_double_reg(), offset, base); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   736
      default      : ShouldNotReachHere();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   737
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   738
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   739
  return store_offset;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   740
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   741
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   742
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   743
// Attention: caller must encode oop if needed
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   744
int LIR_Assembler::store(LIR_Opr from_reg, Register base, Register disp, BasicType type, bool wide) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   745
  int store_offset = code_offset();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   746
  switch (type) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   747
    case T_BOOLEAN: // fall through
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   748
    case T_BYTE  : __ stbx(from_reg->as_register(), base, disp); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   749
    case T_CHAR  :
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   750
    case T_SHORT : __ sthx(from_reg->as_register(), base, disp); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   751
    case T_INT   : __ stwx(from_reg->as_register(), base, disp); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   752
    case T_LONG  :
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   753
#ifdef _LP64
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   754
      __ stdx(from_reg->as_register_lo(), base, disp);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   755
#else
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   756
      Unimplemented();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   757
#endif
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   758
      break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   759
    case T_ADDRESS:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   760
      __ stdx(from_reg->as_register(), base, disp);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   761
      break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   762
    case T_ARRAY : // fall through
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   763
    case T_OBJECT:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   764
      {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   765
        if (UseCompressedOops && !wide) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   766
          // Encoding done in caller.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   767
          __ stwx(from_reg->as_register(), base, disp);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   768
        } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   769
          __ stdx(from_reg->as_register(), base, disp);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   770
        }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   771
        __ verify_oop(from_reg->as_register()); // kills R0
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   772
        break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   773
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   774
    case T_FLOAT : __ stfsx(from_reg->as_float_reg(), base, disp); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   775
    case T_DOUBLE: __ stfdx(from_reg->as_double_reg(), base, disp); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   776
    default      : ShouldNotReachHere();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   777
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   778
  return store_offset;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   779
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   780
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   781
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   782
int LIR_Assembler::load(Register base, int offset, LIR_Opr to_reg, BasicType type, bool wide, bool unaligned) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   783
  int load_offset;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   784
  if (!Assembler::is_simm16(offset)) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   785
    // For offsets larger than a simm16 we setup the offset.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   786
    __ load_const_optimized(R0, offset);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   787
    load_offset = load(base, R0, to_reg, type, wide);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   788
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   789
    load_offset = code_offset();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   790
    switch(type) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   791
      case T_BOOLEAN: // fall through
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   792
      case T_BYTE  :   __ lbz(to_reg->as_register(), offset, base);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   793
                       __ extsb(to_reg->as_register(), to_reg->as_register()); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   794
      case T_CHAR  :   __ lhz(to_reg->as_register(), offset, base); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   795
      case T_SHORT :   __ lha(to_reg->as_register(), offset, base); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   796
      case T_INT   :   __ lwa(to_reg->as_register(), offset, base); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   797
      case T_LONG  :   __ ld(to_reg->as_register_lo(), offset, base); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   798
      case T_METADATA: __ ld(to_reg->as_register(), offset, base); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   799
      case T_ADDRESS:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   800
        if (offset == oopDesc::klass_offset_in_bytes() && UseCompressedClassPointers) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   801
          __ lwz(to_reg->as_register(), offset, base);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   802
          __ decode_klass_not_null(to_reg->as_register());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   803
        } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   804
          __ ld(to_reg->as_register(), offset, base);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   805
        }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   806
        break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   807
      case T_ARRAY : // fall through
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   808
      case T_OBJECT:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   809
        {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   810
          if (UseCompressedOops && !wide) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   811
            __ lwz(to_reg->as_register(), offset, base);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   812
            __ decode_heap_oop(to_reg->as_register());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   813
          } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   814
            __ ld(to_reg->as_register(), offset, base);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   815
          }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   816
          __ verify_oop(to_reg->as_register());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   817
          break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   818
        }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   819
      case T_FLOAT:  __ lfs(to_reg->as_float_reg(), offset, base); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   820
      case T_DOUBLE: __ lfd(to_reg->as_double_reg(), offset, base); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   821
      default      : ShouldNotReachHere();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   822
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   823
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   824
  return load_offset;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   825
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   826
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   827
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   828
int LIR_Assembler::load(Register base, Register disp, LIR_Opr to_reg, BasicType type, bool wide) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   829
  int load_offset = code_offset();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   830
  switch(type) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   831
    case T_BOOLEAN: // fall through
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   832
    case T_BYTE  :  __ lbzx(to_reg->as_register(), base, disp);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   833
                    __ extsb(to_reg->as_register(), to_reg->as_register()); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   834
    case T_CHAR  :  __ lhzx(to_reg->as_register(), base, disp); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   835
    case T_SHORT :  __ lhax(to_reg->as_register(), base, disp); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   836
    case T_INT   :  __ lwax(to_reg->as_register(), base, disp); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   837
    case T_ADDRESS: __ ldx(to_reg->as_register(), base, disp); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   838
    case T_ARRAY : // fall through
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   839
    case T_OBJECT:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   840
      {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   841
        if (UseCompressedOops && !wide) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   842
          __ lwzx(to_reg->as_register(), base, disp);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   843
          __ decode_heap_oop(to_reg->as_register());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   844
        } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   845
          __ ldx(to_reg->as_register(), base, disp);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   846
        }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   847
        __ verify_oop(to_reg->as_register());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   848
        break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   849
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   850
    case T_FLOAT:  __ lfsx(to_reg->as_float_reg() , base, disp); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   851
    case T_DOUBLE: __ lfdx(to_reg->as_double_reg(), base, disp); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   852
    case T_LONG  :
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   853
#ifdef _LP64
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   854
      __ ldx(to_reg->as_register_lo(), base, disp);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   855
#else
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   856
      Unimplemented();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   857
#endif
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   858
      break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   859
    default      : ShouldNotReachHere();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   860
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   861
  return load_offset;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   862
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   863
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   864
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   865
void LIR_Assembler::const2stack(LIR_Opr src, LIR_Opr dest) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   866
  LIR_Const* c = src->as_constant_ptr();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   867
  Register src_reg = R0;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   868
  switch (c->type()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   869
    case T_INT:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   870
    case T_FLOAT: {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   871
      int value = c->as_jint_bits();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   872
      __ load_const_optimized(src_reg, value);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   873
      Address addr = frame_map()->address_for_slot(dest->single_stack_ix());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   874
      __ stw(src_reg, addr.disp(), addr.base());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   875
      break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   876
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   877
    case T_ADDRESS: {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   878
      int value = c->as_jint_bits();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   879
      __ load_const_optimized(src_reg, value);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   880
      Address addr = frame_map()->address_for_slot(dest->single_stack_ix());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   881
      __ std(src_reg, addr.disp(), addr.base());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   882
      break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   883
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   884
    case T_OBJECT: {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   885
      jobject2reg(c->as_jobject(), src_reg);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   886
      Address addr = frame_map()->address_for_slot(dest->single_stack_ix());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   887
      __ std(src_reg, addr.disp(), addr.base());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   888
      break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   889
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   890
    case T_LONG:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   891
    case T_DOUBLE: {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   892
      int value = c->as_jlong_bits();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   893
      __ load_const_optimized(src_reg, value);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   894
      Address addr = frame_map()->address_for_double_slot(dest->double_stack_ix());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   895
      __ std(src_reg, addr.disp(), addr.base());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   896
      break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   897
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   898
    default:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   899
      Unimplemented();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   900
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   901
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   902
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   903
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   904
void LIR_Assembler::const2mem(LIR_Opr src, LIR_Opr dest, BasicType type, CodeEmitInfo* info, bool wide) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   905
  LIR_Const* c = src->as_constant_ptr();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   906
  LIR_Address* addr = dest->as_address_ptr();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   907
  Register base = addr->base()->as_pointer_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   908
  LIR_Opr tmp = LIR_OprFact::illegalOpr;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   909
  int offset = -1;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   910
  // Null check for large offsets in LIRGenerator::do_StoreField.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   911
  bool needs_explicit_null_check = !ImplicitNullChecks;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   912
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   913
  if (info != NULL && needs_explicit_null_check) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   914
    explicit_null_check(base, info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   915
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   916
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   917
  switch (c->type()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   918
    case T_FLOAT: type = T_INT;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   919
    case T_INT:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   920
    case T_ADDRESS: {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   921
      tmp = FrameMap::R0_opr;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   922
      __ load_const_optimized(tmp->as_register(), c->as_jint_bits());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   923
      break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   924
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   925
    case T_DOUBLE: type = T_LONG;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   926
    case T_LONG: {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   927
      tmp = FrameMap::R0_long_opr;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   928
      __ load_const_optimized(tmp->as_register_lo(), c->as_jlong_bits());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   929
      break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   930
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   931
    case T_OBJECT: {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   932
      tmp = FrameMap::R0_opr;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   933
      if (UseCompressedOops && !wide && c->as_jobject() != NULL) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   934
        AddressLiteral oop_addr = __ constant_oop_address(c->as_jobject());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   935
        __ lis(R0, oop_addr.value() >> 16); // Don't care about sign extend (will use stw).
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   936
        __ relocate(oop_addr.rspec(), /*compressed format*/ 1);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   937
        __ ori(R0, R0, oop_addr.value() & 0xffff);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   938
      } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   939
        jobject2reg(c->as_jobject(), R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   940
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   941
      break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   942
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   943
    default:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   944
      Unimplemented();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   945
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   946
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   947
  // Handle either reg+reg or reg+disp address.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   948
  if (addr->index()->is_valid()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   949
    assert(addr->disp() == 0, "must be zero");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   950
    offset = store(tmp, base, addr->index()->as_pointer_register(), type, wide);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   951
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   952
    assert(Assembler::is_simm16(addr->disp()), "can't handle larger addresses");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   953
    offset = store(tmp, base, addr->disp(), type, wide, false);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   954
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   955
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   956
  if (info != NULL) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   957
    assert(offset != -1, "offset should've been set");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   958
    if (!needs_explicit_null_check) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   959
      add_debug_info_for_null_check(offset, info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   960
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   961
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   962
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   963
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   964
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   965
void LIR_Assembler::const2reg(LIR_Opr src, LIR_Opr dest, LIR_PatchCode patch_code, CodeEmitInfo* info) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   966
  LIR_Const* c = src->as_constant_ptr();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   967
  LIR_Opr to_reg = dest;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   968
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   969
  switch (c->type()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   970
    case T_INT: {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   971
      assert(patch_code == lir_patch_none, "no patching handled here");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   972
      __ load_const_optimized(dest->as_register(), c->as_jint(), R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   973
      break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   974
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   975
    case T_ADDRESS: {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   976
      assert(patch_code == lir_patch_none, "no patching handled here");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   977
      __ load_const_optimized(dest->as_register(), c->as_jint(), R0);  // Yes, as_jint ...
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   978
      break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   979
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   980
    case T_LONG: {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   981
      assert(patch_code == lir_patch_none, "no patching handled here");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   982
      __ load_const_optimized(dest->as_register_lo(), c->as_jlong(), R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   983
      break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   984
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   985
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   986
    case T_OBJECT: {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   987
      if (patch_code == lir_patch_none) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   988
        jobject2reg(c->as_jobject(), to_reg->as_register());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   989
      } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   990
        jobject2reg_with_patching(to_reg->as_register(), info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   991
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   992
      break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   993
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   994
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   995
    case T_METADATA:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   996
      {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   997
        if (patch_code == lir_patch_none) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   998
          metadata2reg(c->as_metadata(), to_reg->as_register());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   999
        } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1000
          klass2reg_with_patching(to_reg->as_register(), info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1001
        }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1002
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1003
      break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1004
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1005
    case T_FLOAT:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1006
      {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1007
        if (to_reg->is_single_fpu()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1008
          address const_addr = __ float_constant(c->as_jfloat());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1009
          if (const_addr == NULL) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1010
            bailout("const section overflow");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1011
            break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1012
          }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1013
          RelocationHolder rspec = internal_word_Relocation::spec(const_addr);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1014
          __ relocate(rspec);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1015
          __ load_const(R0, const_addr);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1016
          __ lfsx(to_reg->as_float_reg(), R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1017
        } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1018
          assert(to_reg->is_single_cpu(), "Must be a cpu register.");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1019
          __ load_const_optimized(to_reg->as_register(), jint_cast(c->as_jfloat()), R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1020
        }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1021
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1022
      break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1023
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1024
    case T_DOUBLE:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1025
      {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1026
        if (to_reg->is_double_fpu()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1027
          address const_addr = __ double_constant(c->as_jdouble());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1028
          if (const_addr == NULL) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1029
            bailout("const section overflow");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1030
            break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1031
          }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1032
          RelocationHolder rspec = internal_word_Relocation::spec(const_addr);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1033
          __ relocate(rspec);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1034
          __ load_const(R0, const_addr);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1035
          __ lfdx(to_reg->as_double_reg(), R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1036
        } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1037
          assert(to_reg->is_double_cpu(), "Must be a long register.");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1038
          __ load_const_optimized(to_reg->as_register_lo(), jlong_cast(c->as_jdouble()), R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1039
        }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1040
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1041
      break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1042
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1043
    default:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1044
      ShouldNotReachHere();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1045
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1046
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1047
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1048
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1049
Address LIR_Assembler::as_Address(LIR_Address* addr) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1050
  Unimplemented(); return Address();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1051
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1052
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1053
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1054
inline RegisterOrConstant index_or_disp(LIR_Address* addr) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1055
  if (addr->index()->is_illegal()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1056
    return (RegisterOrConstant)(addr->disp());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1057
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1058
    return (RegisterOrConstant)(addr->index()->as_pointer_register());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1059
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1060
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1061
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1062
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1063
void LIR_Assembler::stack2stack(LIR_Opr src, LIR_Opr dest, BasicType type) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1064
  const Register tmp = R0;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1065
  switch (type) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1066
    case T_INT:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1067
    case T_FLOAT: {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1068
      Address from = frame_map()->address_for_slot(src->single_stack_ix());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1069
      Address to   = frame_map()->address_for_slot(dest->single_stack_ix());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1070
      __ lwz(tmp, from.disp(), from.base());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1071
      __ stw(tmp, to.disp(), to.base());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1072
      break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1073
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1074
    case T_ADDRESS:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1075
    case T_OBJECT: {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1076
      Address from = frame_map()->address_for_slot(src->single_stack_ix());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1077
      Address to   = frame_map()->address_for_slot(dest->single_stack_ix());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1078
      __ ld(tmp, from.disp(), from.base());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1079
      __ std(tmp, to.disp(), to.base());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1080
      break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1081
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1082
    case T_LONG:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1083
    case T_DOUBLE: {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1084
      Address from = frame_map()->address_for_double_slot(src->double_stack_ix());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1085
      Address to   = frame_map()->address_for_double_slot(dest->double_stack_ix());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1086
      __ ld(tmp, from.disp(), from.base());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1087
      __ std(tmp, to.disp(), to.base());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1088
      break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1089
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1090
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1091
    default:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1092
      ShouldNotReachHere();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1093
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1094
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1095
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1096
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1097
Address LIR_Assembler::as_Address_hi(LIR_Address* addr) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1098
  Unimplemented(); return Address();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1099
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1100
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1101
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1102
Address LIR_Assembler::as_Address_lo(LIR_Address* addr) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1103
  Unimplemented(); return Address();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1104
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1105
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1106
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1107
void LIR_Assembler::mem2reg(LIR_Opr src_opr, LIR_Opr dest, BasicType type,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1108
                            LIR_PatchCode patch_code, CodeEmitInfo* info, bool wide, bool unaligned) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1109
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1110
  assert(type != T_METADATA, "load of metadata ptr not supported");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1111
  LIR_Address* addr = src_opr->as_address_ptr();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1112
  LIR_Opr to_reg = dest;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1113
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1114
  Register src = addr->base()->as_pointer_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1115
  Register disp_reg = noreg;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1116
  int disp_value = addr->disp();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1117
  bool needs_patching = (patch_code != lir_patch_none);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1118
  // null check for large offsets in LIRGenerator::do_LoadField
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1119
  bool needs_explicit_null_check = !os::zero_page_read_protected() || !ImplicitNullChecks;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1120
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1121
  if (info != NULL && needs_explicit_null_check) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1122
    explicit_null_check(src, info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1123
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1124
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1125
  if (addr->base()->type() == T_OBJECT) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1126
    __ verify_oop(src);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1127
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1128
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1129
  PatchingStub* patch = NULL;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1130
  if (needs_patching) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1131
    patch = new PatchingStub(_masm, PatchingStub::access_field_id);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1132
    assert(!to_reg->is_double_cpu() ||
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1133
           patch_code == lir_patch_none ||
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1134
           patch_code == lir_patch_normal, "patching doesn't match register");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1135
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1136
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1137
  if (addr->index()->is_illegal()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1138
    if (!Assembler::is_simm16(disp_value)) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1139
      if (needs_patching) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1140
        __ load_const32(R0, 0); // patchable int
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1141
      } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1142
        __ load_const_optimized(R0, disp_value);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1143
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1144
      disp_reg = R0;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1145
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1146
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1147
    disp_reg = addr->index()->as_pointer_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1148
    assert(disp_value == 0, "can't handle 3 operand addresses");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1149
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1150
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1151
  // Remember the offset of the load. The patching_epilog must be done
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1152
  // before the call to add_debug_info, otherwise the PcDescs don't get
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1153
  // entered in increasing order.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1154
  int offset;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1155
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1156
  if (disp_reg == noreg) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1157
    assert(Assembler::is_simm16(disp_value), "should have set this up");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1158
    offset = load(src, disp_value, to_reg, type, wide, unaligned);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1159
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1160
    assert(!unaligned, "unexpected");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1161
    offset = load(src, disp_reg, to_reg, type, wide);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1162
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1163
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1164
  if (patch != NULL) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1165
    patching_epilog(patch, patch_code, src, info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1166
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1167
  if (info != NULL && !needs_explicit_null_check) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1168
    add_debug_info_for_null_check(offset, info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1169
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1170
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1171
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1172
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1173
void LIR_Assembler::stack2reg(LIR_Opr src, LIR_Opr dest, BasicType type) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1174
  Address addr;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1175
  if (src->is_single_word()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1176
    addr = frame_map()->address_for_slot(src->single_stack_ix());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1177
  } else if (src->is_double_word())  {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1178
    addr = frame_map()->address_for_double_slot(src->double_stack_ix());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1179
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1180
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1181
  bool unaligned = (addr.disp() - STACK_BIAS) % 8 != 0;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1182
  load(addr.base(), addr.disp(), dest, dest->type(), true /*wide*/, unaligned);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1183
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1184
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1185
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1186
void LIR_Assembler::reg2stack(LIR_Opr from_reg, LIR_Opr dest, BasicType type, bool pop_fpu_stack) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1187
  Address addr;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1188
  if (dest->is_single_word()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1189
    addr = frame_map()->address_for_slot(dest->single_stack_ix());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1190
  } else if (dest->is_double_word())  {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1191
    addr = frame_map()->address_for_slot(dest->double_stack_ix());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1192
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1193
  bool unaligned = (addr.disp() - STACK_BIAS) % 8 != 0;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1194
  store(from_reg, addr.base(), addr.disp(), from_reg->type(), true /*wide*/, unaligned);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1195
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1196
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1197
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1198
void LIR_Assembler::reg2reg(LIR_Opr from_reg, LIR_Opr to_reg) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1199
  if (from_reg->is_float_kind() && to_reg->is_float_kind()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1200
    if (from_reg->is_double_fpu()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1201
      // double to double moves
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1202
      assert(to_reg->is_double_fpu(), "should match");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1203
      __ fmr_if_needed(to_reg->as_double_reg(), from_reg->as_double_reg());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1204
    } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1205
      // float to float moves
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1206
      assert(to_reg->is_single_fpu(), "should match");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1207
      __ fmr_if_needed(to_reg->as_float_reg(), from_reg->as_float_reg());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1208
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1209
  } else if (!from_reg->is_float_kind() && !to_reg->is_float_kind()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1210
    if (from_reg->is_double_cpu()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1211
      __ mr_if_needed(to_reg->as_pointer_register(), from_reg->as_pointer_register());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1212
    } else if (to_reg->is_double_cpu()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1213
      // int to int moves
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1214
      __ mr_if_needed(to_reg->as_register_lo(), from_reg->as_register());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1215
    } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1216
      // int to int moves
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1217
      __ mr_if_needed(to_reg->as_register(), from_reg->as_register());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1218
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1219
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1220
    ShouldNotReachHere();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1221
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1222
  if (to_reg->type() == T_OBJECT || to_reg->type() == T_ARRAY) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1223
    __ verify_oop(to_reg->as_register());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1224
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1225
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1226
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1227
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1228
void LIR_Assembler::reg2mem(LIR_Opr from_reg, LIR_Opr dest, BasicType type,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1229
                            LIR_PatchCode patch_code, CodeEmitInfo* info, bool pop_fpu_stack,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1230
                            bool wide, bool unaligned) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1231
  assert(type != T_METADATA, "store of metadata ptr not supported");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1232
  LIR_Address* addr = dest->as_address_ptr();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1233
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1234
  Register src = addr->base()->as_pointer_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1235
  Register disp_reg = noreg;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1236
  int disp_value = addr->disp();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1237
  bool needs_patching = (patch_code != lir_patch_none);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1238
  bool compress_oop = (type == T_ARRAY || type == T_OBJECT) && UseCompressedOops && !wide &&
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1239
                      Universe::narrow_oop_mode() != Universe::UnscaledNarrowOop;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1240
  bool load_disp = addr->index()->is_illegal() && !Assembler::is_simm16(disp_value);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1241
  bool use_R29 = compress_oop && load_disp; // Avoid register conflict, also do null check before killing R29.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1242
  // Null check for large offsets in LIRGenerator::do_StoreField.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1243
  bool needs_explicit_null_check = !ImplicitNullChecks || use_R29;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1244
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1245
  if (info != NULL && needs_explicit_null_check) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1246
    explicit_null_check(src, info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1247
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1248
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1249
  if (addr->base()->is_oop_register()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1250
    __ verify_oop(src);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1251
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1252
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1253
  PatchingStub* patch = NULL;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1254
  if (needs_patching) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1255
    patch = new PatchingStub(_masm, PatchingStub::access_field_id);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1256
    assert(!from_reg->is_double_cpu() ||
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1257
           patch_code == lir_patch_none ||
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1258
           patch_code == lir_patch_normal, "patching doesn't match register");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1259
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1260
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1261
  if (addr->index()->is_illegal()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1262
    if (load_disp) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1263
      disp_reg = use_R29 ? R29_TOC : R0;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1264
      if (needs_patching) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1265
        __ load_const32(disp_reg, 0); // patchable int
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1266
      } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1267
        __ load_const_optimized(disp_reg, disp_value);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1268
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1269
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1270
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1271
    disp_reg = addr->index()->as_pointer_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1272
    assert(disp_value == 0, "can't handle 3 operand addresses");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1273
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1274
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1275
  // remember the offset of the store. The patching_epilog must be done
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1276
  // before the call to add_debug_info_for_null_check, otherwise the PcDescs don't get
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1277
  // entered in increasing order.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1278
  int offset;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1279
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1280
  if (compress_oop) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1281
    Register co = __ encode_heap_oop(R0, from_reg->as_register());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1282
    from_reg = FrameMap::as_opr(co);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1283
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1284
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1285
  if (disp_reg == noreg) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1286
    assert(Assembler::is_simm16(disp_value), "should have set this up");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1287
    offset = store(from_reg, src, disp_value, type, wide, unaligned);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1288
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1289
    assert(!unaligned, "unexpected");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1290
    offset = store(from_reg, src, disp_reg, type, wide);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1291
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1292
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1293
  if (use_R29) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1294
    __ load_const_optimized(R29_TOC, MacroAssembler::global_toc(), R0); // reinit
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1295
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1296
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1297
  if (patch != NULL) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1298
    patching_epilog(patch, patch_code, src, info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1299
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1300
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1301
  if (info != NULL && !needs_explicit_null_check) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1302
    add_debug_info_for_null_check(offset, info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1303
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1304
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1305
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1306
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1307
void LIR_Assembler::return_op(LIR_Opr result) {
38931
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38685
diff changeset
  1308
  const Register return_pc        = R31;  // Must survive C-call to enable_stack_reserved_zone().
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1309
  const Register polling_page     = R12;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1310
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1311
  // Pop the stack before the safepoint code.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1312
  int frame_size = initial_frame_size_in_bytes();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1313
  if (Assembler::is_simm(frame_size, 16)) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1314
    __ addi(R1_SP, R1_SP, frame_size);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1315
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1316
    __ pop_frame();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1317
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1318
48332
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 47698
diff changeset
  1319
  if (SafepointMechanism::uses_thread_local_poll()) {
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 47698
diff changeset
  1320
    __ ld(polling_page, in_bytes(Thread::polling_page_offset()), R16_thread);
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1321
  } else {
48332
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 47698
diff changeset
  1322
    __ load_const_optimized(polling_page, (long)(address) os::get_polling_page(), R0);
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1323
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1324
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1325
  // Restore return pc relative to callers' sp.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1326
  __ ld(return_pc, _abi(lr), R1_SP);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1327
  // Move return pc to LR.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1328
  __ mtlr(return_pc);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1329
38931
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38685
diff changeset
  1330
  if (StackReservedPages > 0 && compilation()->has_reserved_stack_access()) {
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38685
diff changeset
  1331
    __ reserved_stack_check(return_pc);
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38685
diff changeset
  1332
  }
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38685
diff changeset
  1333
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1334
  // We need to mark the code position where the load from the safepoint
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1335
  // polling page was emitted as relocInfo::poll_return_type here.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1336
  __ relocate(relocInfo::poll_return_type);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1337
  __ load_from_polling_page(polling_page);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1338
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1339
  // Return.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1340
  __ blr();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1341
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1342
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1343
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1344
int LIR_Assembler::safepoint_poll(LIR_Opr tmp, CodeEmitInfo* info) {
48332
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 47698
diff changeset
  1345
  const Register poll_addr = tmp->as_register();
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 47698
diff changeset
  1346
  if (SafepointMechanism::uses_thread_local_poll()) {
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 47698
diff changeset
  1347
    __ ld(poll_addr, in_bytes(Thread::polling_page_offset()), R16_thread);
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 47698
diff changeset
  1348
  } else {
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 47698
diff changeset
  1349
    __ load_const_optimized(poll_addr, (intptr_t)os::get_polling_page(), R0);
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1350
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1351
  if (info != NULL) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1352
    add_debug_info_for_branch(info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1353
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1354
  int offset = __ offset();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1355
  __ relocate(relocInfo::poll_type);
48332
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 47698
diff changeset
  1356
  __ load_from_polling_page(poll_addr);
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1357
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1358
  return offset;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1359
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1360
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1361
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1362
void LIR_Assembler::emit_static_call_stub() {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1363
  address call_pc = __ pc();
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42068
diff changeset
  1364
  address stub = __ start_a_stub(static_call_stub_size());
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1365
  if (stub == NULL) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1366
    bailout("static call stub overflow");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1367
    return;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1368
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1369
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1370
  // For java_to_interp stubs we use R11_scratch1 as scratch register
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1371
  // and in call trampoline stubs we use R12_scratch2. This way we
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1372
  // can distinguish them (see is_NativeCallTrampolineStub_at()).
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1373
  const Register reg_scratch = R11_scratch1;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1374
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1375
  // Create a static stub relocation which relates this stub
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1376
  // with the call instruction at insts_call_instruction_offset in the
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1377
  // instructions code-section.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1378
  int start = __ offset();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1379
  __ relocate(static_stub_Relocation::spec(call_pc));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1380
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1381
  // Now, create the stub's code:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1382
  // - load the TOC
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1383
  // - load the inline cache oop from the constant pool
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1384
  // - load the call target from the constant pool
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1385
  // - call
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1386
  __ calculate_address_from_global_toc(reg_scratch, __ method_toc());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1387
  AddressLiteral ic = __ allocate_metadata_address((Metadata *)NULL);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1388
  bool success = __ load_const_from_method_toc(R19_inline_cache_reg, ic, reg_scratch, /*fixed_size*/ true);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1389
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1390
  if (ReoptimizeCallSequences) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1391
    __ b64_patchable((address)-1, relocInfo::none);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1392
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1393
    AddressLiteral a((address)-1);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1394
    success = success && __ load_const_from_method_toc(reg_scratch, a, reg_scratch, /*fixed_size*/ true);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1395
    __ mtctr(reg_scratch);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1396
    __ bctr();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1397
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1398
  if (!success) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1399
    bailout("const section overflow");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1400
    return;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1401
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1402
42650
1f304d0c888b 8171008: Integrate AOT compiler into JDK
kvn
parents: 42068
diff changeset
  1403
  assert(__ offset() - start <= static_call_stub_size(), "stub too big");
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1404
  __ end_a_stub();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1405
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1406
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1407
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1408
void LIR_Assembler::comp_op(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Op2* op) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1409
  bool unsigned_comp = (condition == lir_cond_belowEqual || condition == lir_cond_aboveEqual);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1410
  if (opr1->is_single_fpu()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1411
    __ fcmpu(BOOL_RESULT, opr1->as_float_reg(), opr2->as_float_reg());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1412
  } else if (opr1->is_double_fpu()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1413
    __ fcmpu(BOOL_RESULT, opr1->as_double_reg(), opr2->as_double_reg());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1414
  } else if (opr1->is_single_cpu()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1415
    if (opr2->is_constant()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1416
      switch (opr2->as_constant_ptr()->type()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1417
        case T_INT:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1418
          {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1419
            jint con = opr2->as_constant_ptr()->as_jint();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1420
            if (unsigned_comp) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1421
              if (Assembler::is_uimm(con, 16)) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1422
                __ cmplwi(BOOL_RESULT, opr1->as_register(), con);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1423
              } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1424
                __ load_const_optimized(R0, con);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1425
                __ cmplw(BOOL_RESULT, opr1->as_register(), R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1426
              }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1427
            } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1428
              if (Assembler::is_simm(con, 16)) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1429
                __ cmpwi(BOOL_RESULT, opr1->as_register(), con);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1430
              } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1431
                __ load_const_optimized(R0, con);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1432
                __ cmpw(BOOL_RESULT, opr1->as_register(), R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1433
              }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1434
            }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1435
          }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1436
          break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1437
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1438
        case T_OBJECT:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1439
          // There are only equal/notequal comparisons on objects.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1440
          {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1441
            assert(condition == lir_cond_equal || condition == lir_cond_notEqual, "oops");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1442
            jobject con = opr2->as_constant_ptr()->as_jobject();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1443
            if (con == NULL) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1444
              __ cmpdi(BOOL_RESULT, opr1->as_register(), 0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1445
            } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1446
              jobject2reg(con, R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1447
              __ cmpd(BOOL_RESULT, opr1->as_register(), R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1448
            }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1449
          }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1450
          break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1451
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1452
        default:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1453
          ShouldNotReachHere();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1454
          break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1455
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1456
    } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1457
      if (opr2->is_address()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1458
        DEBUG_ONLY( Unimplemented(); ) // Seems to be unused at the moment.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1459
        LIR_Address *addr = opr2->as_address_ptr();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1460
        BasicType type = addr->type();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1461
        if (type == T_OBJECT) { __ ld(R0, index_or_disp(addr), addr->base()->as_register()); }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1462
        else                  { __ lwa(R0, index_or_disp(addr), addr->base()->as_register()); }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1463
        __ cmpd(BOOL_RESULT, opr1->as_register(), R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1464
      } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1465
        if (unsigned_comp) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1466
          __ cmplw(BOOL_RESULT, opr1->as_register(), opr2->as_register());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1467
        } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1468
          __ cmpw(BOOL_RESULT, opr1->as_register(), opr2->as_register());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1469
        }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1470
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1471
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1472
  } else if (opr1->is_double_cpu()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1473
    if (opr2->is_constant()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1474
      jlong con = opr2->as_constant_ptr()->as_jlong();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1475
      if (unsigned_comp) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1476
        if (Assembler::is_uimm(con, 16)) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1477
          __ cmpldi(BOOL_RESULT, opr1->as_register_lo(), con);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1478
        } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1479
          __ load_const_optimized(R0, con);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1480
          __ cmpld(BOOL_RESULT, opr1->as_register_lo(), R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1481
        }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1482
      } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1483
        if (Assembler::is_simm(con, 16)) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1484
          __ cmpdi(BOOL_RESULT, opr1->as_register_lo(), con);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1485
        } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1486
          __ load_const_optimized(R0, con);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1487
          __ cmpd(BOOL_RESULT, opr1->as_register_lo(), R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1488
        }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1489
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1490
    } else if (opr2->is_register()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1491
      if (unsigned_comp) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1492
        __ cmpld(BOOL_RESULT, opr1->as_register_lo(), opr2->as_register_lo());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1493
      } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1494
        __ cmpd(BOOL_RESULT, opr1->as_register_lo(), opr2->as_register_lo());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1495
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1496
    } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1497
      ShouldNotReachHere();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1498
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1499
  } else if (opr1->is_address()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1500
    DEBUG_ONLY( Unimplemented(); ) // Seems to be unused at the moment.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1501
    LIR_Address * addr = opr1->as_address_ptr();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1502
    BasicType type = addr->type();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1503
    assert (opr2->is_constant(), "Checking");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1504
    if (type == T_OBJECT) { __ ld(R0, index_or_disp(addr), addr->base()->as_register()); }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1505
    else                  { __ lwa(R0, index_or_disp(addr), addr->base()->as_register()); }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1506
    __ cmpdi(BOOL_RESULT, R0, opr2->as_constant_ptr()->as_jint());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1507
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1508
    ShouldNotReachHere();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1509
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1510
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1511
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1512
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1513
void LIR_Assembler::comp_fl2i(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr dst, LIR_Op2* op){
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1514
  const Register Rdst = dst->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1515
  Label done;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1516
  if (code == lir_cmp_fd2i || code == lir_ucmp_fd2i) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1517
    bool is_unordered_less = (code == lir_ucmp_fd2i);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1518
    if (left->is_single_fpu()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1519
      __ fcmpu(CCR0, left->as_float_reg(), right->as_float_reg());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1520
    } else if (left->is_double_fpu()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1521
      __ fcmpu(CCR0, left->as_double_reg(), right->as_double_reg());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1522
    } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1523
      ShouldNotReachHere();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1524
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1525
    __ li(Rdst, is_unordered_less ? -1 : 1);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1526
    __ bso(CCR0, done);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1527
  } else if (code == lir_cmp_l2i) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1528
    __ cmpd(CCR0, left->as_register_lo(), right->as_register_lo());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1529
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1530
    ShouldNotReachHere();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1531
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1532
  __ mfcr(R0); // set bit 32..33 as follows: <: 0b10, =: 0b00, >: 0b01
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1533
  __ srwi(Rdst, R0, 30);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1534
  __ srawi(R0, R0, 31);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1535
  __ orr(Rdst, R0, Rdst); // set result as follows: <: -1, =: 0, >: 1
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1536
  __ bind(done);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1537
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1538
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1539
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1540
inline void load_to_reg(LIR_Assembler *lasm, LIR_Opr src, LIR_Opr dst) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1541
  if (src->is_constant()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1542
    lasm->const2reg(src, dst, lir_patch_none, NULL);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1543
  } else if (src->is_register()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1544
    lasm->reg2reg(src, dst);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1545
  } else if (src->is_stack()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1546
    lasm->stack2reg(src, dst, dst->type());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1547
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1548
    ShouldNotReachHere();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1549
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1550
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1551
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1552
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1553
void LIR_Assembler::cmove(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result, BasicType type) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1554
  if (opr1->is_equal(opr2) || opr1->is_same_register(opr2)) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1555
    load_to_reg(this, opr1, result); // Condition doesn't matter.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1556
    return;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1557
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1558
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1559
  bool positive = false;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1560
  Assembler::Condition cond = Assembler::equal;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1561
  switch (condition) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1562
    case lir_cond_equal:        positive = true ; cond = Assembler::equal  ; break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1563
    case lir_cond_notEqual:     positive = false; cond = Assembler::equal  ; break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1564
    case lir_cond_less:         positive = true ; cond = Assembler::less   ; break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1565
    case lir_cond_belowEqual:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1566
    case lir_cond_lessEqual:    positive = false; cond = Assembler::greater; break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1567
    case lir_cond_greater:      positive = true ; cond = Assembler::greater; break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1568
    case lir_cond_aboveEqual:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1569
    case lir_cond_greaterEqual: positive = false; cond = Assembler::less   ; break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1570
    default:                    ShouldNotReachHere();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1571
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1572
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1573
  // Try to use isel on >=Power7.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1574
  if (VM_Version::has_isel() && result->is_cpu_register()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1575
    bool o1_is_reg = opr1->is_cpu_register(), o2_is_reg = opr2->is_cpu_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1576
    const Register result_reg = result->is_single_cpu() ? result->as_register() : result->as_register_lo();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1577
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1578
    // We can use result_reg to load one operand if not already in register.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1579
    Register first  = o1_is_reg ? (opr1->is_single_cpu() ? opr1->as_register() : opr1->as_register_lo()) : result_reg,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1580
             second = o2_is_reg ? (opr2->is_single_cpu() ? opr2->as_register() : opr2->as_register_lo()) : result_reg;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1581
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1582
    if (first != second) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1583
      if (!o1_is_reg) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1584
        load_to_reg(this, opr1, result);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1585
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1586
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1587
      if (!o2_is_reg) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1588
        load_to_reg(this, opr2, result);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1589
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1590
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1591
      __ isel(result_reg, BOOL_RESULT, cond, !positive, first, second);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1592
      return;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1593
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1594
  } // isel
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1595
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1596
  load_to_reg(this, opr1, result);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1597
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1598
  Label skip;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1599
  int bo = positive ? Assembler::bcondCRbiIs1 : Assembler::bcondCRbiIs0;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1600
  int bi = Assembler::bi0(BOOL_RESULT, cond);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1601
  __ bc(bo, bi, skip);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1602
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1603
  load_to_reg(this, opr2, result);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1604
  __ bind(skip);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1605
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1606
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1607
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1608
void LIR_Assembler::arith_op(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr dest,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1609
                             CodeEmitInfo* info, bool pop_fpu_stack) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1610
  assert(info == NULL, "unused on this code path");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1611
  assert(left->is_register(), "wrong items state");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1612
  assert(dest->is_register(), "wrong items state");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1613
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1614
  if (right->is_register()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1615
    if (dest->is_float_kind()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1616
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1617
      FloatRegister lreg, rreg, res;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1618
      if (right->is_single_fpu()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1619
        lreg = left->as_float_reg();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1620
        rreg = right->as_float_reg();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1621
        res  = dest->as_float_reg();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1622
        switch (code) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1623
          case lir_add: __ fadds(res, lreg, rreg); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1624
          case lir_sub: __ fsubs(res, lreg, rreg); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1625
          case lir_mul: // fall through
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1626
          case lir_mul_strictfp: __ fmuls(res, lreg, rreg); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1627
          case lir_div: // fall through
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1628
          case lir_div_strictfp: __ fdivs(res, lreg, rreg); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1629
          default: ShouldNotReachHere();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1630
        }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1631
      } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1632
        lreg = left->as_double_reg();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1633
        rreg = right->as_double_reg();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1634
        res  = dest->as_double_reg();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1635
        switch (code) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1636
          case lir_add: __ fadd(res, lreg, rreg); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1637
          case lir_sub: __ fsub(res, lreg, rreg); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1638
          case lir_mul: // fall through
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1639
          case lir_mul_strictfp: __ fmul(res, lreg, rreg); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1640
          case lir_div: // fall through
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1641
          case lir_div_strictfp: __ fdiv(res, lreg, rreg); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1642
          default: ShouldNotReachHere();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1643
        }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1644
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1645
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1646
    } else if (dest->is_double_cpu()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1647
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1648
      Register dst_lo = dest->as_register_lo();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1649
      Register op1_lo = left->as_pointer_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1650
      Register op2_lo = right->as_pointer_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1651
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1652
      switch (code) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1653
        case lir_add: __ add(dst_lo, op1_lo, op2_lo); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1654
        case lir_sub: __ sub(dst_lo, op1_lo, op2_lo); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1655
        case lir_mul: __ mulld(dst_lo, op1_lo, op2_lo); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1656
        default: ShouldNotReachHere();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1657
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1658
    } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1659
      assert (right->is_single_cpu(), "Just Checking");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1660
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1661
      Register lreg = left->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1662
      Register res  = dest->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1663
      Register rreg = right->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1664
      switch (code) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1665
        case lir_add:  __ add  (res, lreg, rreg); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1666
        case lir_sub:  __ sub  (res, lreg, rreg); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1667
        case lir_mul:  __ mullw(res, lreg, rreg); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1668
        default: ShouldNotReachHere();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1669
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1670
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1671
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1672
    assert (right->is_constant(), "must be constant");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1673
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1674
    if (dest->is_single_cpu()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1675
      Register lreg = left->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1676
      Register res  = dest->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1677
      int    simm16 = right->as_constant_ptr()->as_jint();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1678
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1679
      switch (code) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1680
        case lir_sub:  assert(Assembler::is_simm16(-simm16), "cannot encode"); // see do_ArithmeticOp_Int
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1681
                       simm16 = -simm16;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1682
        case lir_add:  if (res == lreg && simm16 == 0) break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1683
                       __ addi(res, lreg, simm16); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1684
        case lir_mul:  if (res == lreg && simm16 == 1) break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1685
                       __ mulli(res, lreg, simm16); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1686
        default: ShouldNotReachHere();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1687
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1688
    } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1689
      Register lreg = left->as_pointer_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1690
      Register res  = dest->as_register_lo();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1691
      long con = right->as_constant_ptr()->as_jlong();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1692
      assert(Assembler::is_simm16(con), "must be simm16");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1693
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1694
      switch (code) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1695
        case lir_sub:  assert(Assembler::is_simm16(-con), "cannot encode");  // see do_ArithmeticOp_Long
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1696
                       con = -con;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1697
        case lir_add:  if (res == lreg && con == 0) break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1698
                       __ addi(res, lreg, (int)con); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1699
        case lir_mul:  if (res == lreg && con == 1) break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1700
                       __ mulli(res, lreg, (int)con); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1701
        default: ShouldNotReachHere();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1702
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1703
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1704
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1705
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1706
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1707
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1708
void LIR_Assembler::fpop() {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1709
  Unimplemented();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1710
  // do nothing
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1711
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1712
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1713
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1714
void LIR_Assembler::intrinsic_op(LIR_Code code, LIR_Opr value, LIR_Opr thread, LIR_Opr dest, LIR_Op* op) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1715
  switch (code) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1716
    case lir_sqrt: {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1717
      __ fsqrt(dest->as_double_reg(), value->as_double_reg());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1718
      break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1719
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1720
    case lir_abs: {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1721
      __ fabs(dest->as_double_reg(), value->as_double_reg());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1722
      break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1723
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1724
    default: {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1725
      ShouldNotReachHere();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1726
      break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1727
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1728
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1729
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1730
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1731
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1732
void LIR_Assembler::logic_op(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr dest) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1733
  if (right->is_constant()) { // see do_LogicOp
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1734
    long uimm;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1735
    Register d, l;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1736
    if (dest->is_single_cpu()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1737
      uimm = right->as_constant_ptr()->as_jint();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1738
      d = dest->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1739
      l = left->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1740
    } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1741
      uimm = right->as_constant_ptr()->as_jlong();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1742
      d = dest->as_register_lo();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1743
      l = left->as_register_lo();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1744
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1745
    long uimms  = (unsigned long)uimm >> 16,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1746
         uimmss = (unsigned long)uimm >> 32;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1747
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1748
    switch (code) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1749
      case lir_logic_and:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1750
        if (uimmss != 0 || (uimms != 0 && (uimm & 0xFFFF) != 0) || is_power_of_2_long(uimm)) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1751
          __ andi(d, l, uimm); // special cases
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1752
        } else if (uimms != 0) { __ andis_(d, l, uimms); }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1753
        else { __ andi_(d, l, uimm); }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1754
        break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1755
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1756
      case lir_logic_or:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1757
        if (uimms != 0) { assert((uimm & 0xFFFF) == 0, "sanity"); __ oris(d, l, uimms); }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1758
        else { __ ori(d, l, uimm); }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1759
        break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1760
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1761
      case lir_logic_xor:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1762
        if (uimm == -1) { __ nand(d, l, l); } // special case
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1763
        else if (uimms != 0) { assert((uimm & 0xFFFF) == 0, "sanity"); __ xoris(d, l, uimms); }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1764
        else { __ xori(d, l, uimm); }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1765
        break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1766
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1767
      default: ShouldNotReachHere();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1768
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1769
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1770
    assert(right->is_register(), "right should be in register");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1771
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1772
    if (dest->is_single_cpu()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1773
      switch (code) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1774
        case lir_logic_and: __ andr(dest->as_register(), left->as_register(), right->as_register()); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1775
        case lir_logic_or:  __ orr (dest->as_register(), left->as_register(), right->as_register()); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1776
        case lir_logic_xor: __ xorr(dest->as_register(), left->as_register(), right->as_register()); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1777
        default: ShouldNotReachHere();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1778
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1779
    } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1780
      Register l = (left->is_single_cpu() && left->is_oop_register()) ? left->as_register() :
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1781
                                                                        left->as_register_lo();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1782
      Register r = (right->is_single_cpu() && right->is_oop_register()) ? right->as_register() :
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1783
                                                                          right->as_register_lo();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1784
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1785
      switch (code) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1786
        case lir_logic_and: __ andr(dest->as_register_lo(), l, r); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1787
        case lir_logic_or:  __ orr (dest->as_register_lo(), l, r); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1788
        case lir_logic_xor: __ xorr(dest->as_register_lo(), l, r); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1789
        default: ShouldNotReachHere();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1790
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1791
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1792
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1793
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1794
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1795
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1796
int LIR_Assembler::shift_amount(BasicType t) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1797
  int elem_size = type2aelembytes(t);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1798
  switch (elem_size) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1799
    case 1 : return 0;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1800
    case 2 : return 1;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1801
    case 4 : return 2;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1802
    case 8 : return 3;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1803
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1804
  ShouldNotReachHere();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1805
  return -1;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1806
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1807
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1808
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1809
void LIR_Assembler::throw_op(LIR_Opr exceptionPC, LIR_Opr exceptionOop, CodeEmitInfo* info) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1810
  info->add_register_oop(exceptionOop);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1811
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1812
  // Reuse the debug info from the safepoint poll for the throw op itself.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1813
  address pc_for_athrow = __ pc();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1814
  int pc_for_athrow_offset = __ offset();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1815
  //RelocationHolder rspec = internal_word_Relocation::spec(pc_for_athrow);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1816
  //__ relocate(rspec);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1817
  //__ load_const(exceptionPC->as_register(), pc_for_athrow, R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1818
  __ calculate_address_from_global_toc(exceptionPC->as_register(), pc_for_athrow, true, true, /*add_relocation*/ true);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1819
  add_call_info(pc_for_athrow_offset, info); // for exception handler
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1820
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1821
  address stub = Runtime1::entry_for(compilation()->has_fpu_code() ? Runtime1::handle_exception_id
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1822
                                                                   : Runtime1::handle_exception_nofpu_id);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1823
  //__ load_const_optimized(R0, stub);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1824
  __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(stub));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1825
  __ mtctr(R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1826
  __ bctr();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1827
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1828
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1829
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1830
void LIR_Assembler::unwind_op(LIR_Opr exceptionOop) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1831
  // Note: Not used with EnableDebuggingOnDemand.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1832
  assert(exceptionOop->as_register() == R3, "should match");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1833
  __ b(_unwind_handler_entry);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1834
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1835
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1836
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1837
void LIR_Assembler::emit_arraycopy(LIR_OpArrayCopy* op) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1838
  Register src = op->src()->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1839
  Register dst = op->dst()->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1840
  Register src_pos = op->src_pos()->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1841
  Register dst_pos = op->dst_pos()->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1842
  Register length  = op->length()->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1843
  Register tmp = op->tmp()->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1844
  Register tmp2 = R0;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1845
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1846
  int flags = op->flags();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1847
  ciArrayKlass* default_type = op->expected_type();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1848
  BasicType basic_type = default_type != NULL ? default_type->element_type()->basic_type() : T_ILLEGAL;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1849
  if (basic_type == T_ARRAY) basic_type = T_OBJECT;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1850
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1851
  // Set up the arraycopy stub information.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1852
  ArrayCopyStub* stub = op->stub();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1853
  const int frame_resize = frame::abi_reg_args_size - sizeof(frame::jit_abi); // C calls need larger frame.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1854
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1855
  // Always do stub if no type information is available. It's ok if
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1856
  // the known type isn't loaded since the code sanity checks
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1857
  // in debug mode and the type isn't required when we know the exact type
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1858
  // also check that the type is an array type.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1859
  if (op->expected_type() == NULL) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1860
    assert(src->is_nonvolatile() && src_pos->is_nonvolatile() && dst->is_nonvolatile() && dst_pos->is_nonvolatile() &&
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1861
           length->is_nonvolatile(), "must preserve");
49470
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  1862
    address copyfunc_addr = StubRoutines::generic_arraycopy();
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  1863
    assert(copyfunc_addr != NULL, "generic arraycopy stub required");
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  1864
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1865
    // 3 parms are int. Convert to long.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1866
    __ mr(R3_ARG1, src);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1867
    __ extsw(R4_ARG2, src_pos);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1868
    __ mr(R5_ARG3, dst);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1869
    __ extsw(R6_ARG4, dst_pos);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1870
    __ extsw(R7_ARG5, length);
49470
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  1871
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1872
#ifndef PRODUCT
49470
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  1873
    if (PrintC1Statistics) {
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  1874
      address counter = (address)&Runtime1::_generic_arraycopystub_cnt;
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  1875
      int simm16_offs = __ load_const_optimized(tmp, counter, tmp2, true);
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  1876
      __ lwz(R11_scratch1, simm16_offs, tmp);
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  1877
      __ addi(R11_scratch1, R11_scratch1, 1);
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  1878
      __ stw(R11_scratch1, simm16_offs, tmp);
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  1879
    }
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1880
#endif
49470
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  1881
    __ call_c_with_frame_resize(copyfunc_addr, /*stub does not need resized frame*/ 0);
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  1882
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  1883
    __ nand(tmp, R3_RET, R3_RET);
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  1884
    __ subf(length, tmp, length);
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  1885
    __ add(src_pos, tmp, src_pos);
a273b521a559 8199696: Remove Runtime1::arraycopy
eosterlund
parents: 49455
diff changeset
  1886
    __ add(dst_pos, tmp, dst_pos);
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1887
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1888
    __ cmpwi(CCR0, R3_RET, 0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1889
    __ bc_far_optimized(Assembler::bcondCRbiIs1, __ bi0(CCR0, Assembler::less), *stub->entry());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1890
    __ bind(*stub->continuation());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1891
    return;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1892
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1893
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1894
  assert(default_type != NULL && default_type->is_array_klass(), "must be true at this point");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1895
  Label cont, slow, copyfunc;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1896
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1897
  bool simple_check_flag_set = flags & (LIR_OpArrayCopy::src_null_check |
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1898
                                        LIR_OpArrayCopy::dst_null_check |
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1899
                                        LIR_OpArrayCopy::src_pos_positive_check |
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1900
                                        LIR_OpArrayCopy::dst_pos_positive_check |
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1901
                                        LIR_OpArrayCopy::length_positive_check);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1902
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1903
  // Use only one conditional branch for simple checks.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1904
  if (simple_check_flag_set) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1905
    ConditionRegister combined_check = CCR1, tmp_check = CCR1;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1906
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1907
    // Make sure src and dst are non-null.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1908
    if (flags & LIR_OpArrayCopy::src_null_check) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1909
      __ cmpdi(combined_check, src, 0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1910
      tmp_check = CCR0;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1911
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1912
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1913
    if (flags & LIR_OpArrayCopy::dst_null_check) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1914
      __ cmpdi(tmp_check, dst, 0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1915
      if (tmp_check != combined_check) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1916
        __ cror(combined_check, Assembler::equal, tmp_check, Assembler::equal);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1917
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1918
      tmp_check = CCR0;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1919
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1920
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1921
    // Clear combined_check.eq if not already used.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1922
    if (tmp_check == combined_check) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1923
      __ crandc(combined_check, Assembler::equal, combined_check, Assembler::equal);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1924
      tmp_check = CCR0;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1925
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1926
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1927
    if (flags & LIR_OpArrayCopy::src_pos_positive_check) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1928
      // Test src_pos register.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1929
      __ cmpwi(tmp_check, src_pos, 0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1930
      __ cror(combined_check, Assembler::equal, tmp_check, Assembler::less);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1931
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1932
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1933
    if (flags & LIR_OpArrayCopy::dst_pos_positive_check) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1934
      // Test dst_pos register.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1935
      __ cmpwi(tmp_check, dst_pos, 0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1936
      __ cror(combined_check, Assembler::equal, tmp_check, Assembler::less);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1937
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1938
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1939
    if (flags & LIR_OpArrayCopy::length_positive_check) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1940
      // Make sure length isn't negative.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1941
      __ cmpwi(tmp_check, length, 0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1942
      __ cror(combined_check, Assembler::equal, tmp_check, Assembler::less);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1943
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1944
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1945
    __ beq(combined_check, slow);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1946
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1947
42068
18c8a4d5998e 8168083: PPC64: Cleanup template interpreter after 8154580 and 8154867
mdoerr
parents: 41546
diff changeset
  1948
  // If the compiler was not able to prove that exact type of the source or the destination
18c8a4d5998e 8168083: PPC64: Cleanup template interpreter after 8154580 and 8154867
mdoerr
parents: 41546
diff changeset
  1949
  // of the arraycopy is an array type, check at runtime if the source or the destination is
18c8a4d5998e 8168083: PPC64: Cleanup template interpreter after 8154580 and 8154867
mdoerr
parents: 41546
diff changeset
  1950
  // an instance type.
41546
357406d17607 8161044: PPC64: Improve internal array handling
zmajo
parents: 38931
diff changeset
  1951
  if (flags & LIR_OpArrayCopy::type_check) {
42068
18c8a4d5998e 8168083: PPC64: Cleanup template interpreter after 8154580 and 8154867
mdoerr
parents: 41546
diff changeset
  1952
    if (!(flags & LIR_OpArrayCopy::dst_objarray)) {
41546
357406d17607 8161044: PPC64: Improve internal array handling
zmajo
parents: 38931
diff changeset
  1953
      __ load_klass(tmp, dst);
357406d17607 8161044: PPC64: Improve internal array handling
zmajo
parents: 38931
diff changeset
  1954
      __ lwz(tmp2, in_bytes(Klass::layout_helper_offset()), tmp);
357406d17607 8161044: PPC64: Improve internal array handling
zmajo
parents: 38931
diff changeset
  1955
      __ cmpwi(CCR0, tmp2, Klass::_lh_neutral_value);
357406d17607 8161044: PPC64: Improve internal array handling
zmajo
parents: 38931
diff changeset
  1956
      __ bge(CCR0, slow);
357406d17607 8161044: PPC64: Improve internal array handling
zmajo
parents: 38931
diff changeset
  1957
    }
357406d17607 8161044: PPC64: Improve internal array handling
zmajo
parents: 38931
diff changeset
  1958
42068
18c8a4d5998e 8168083: PPC64: Cleanup template interpreter after 8154580 and 8154867
mdoerr
parents: 41546
diff changeset
  1959
    if (!(flags & LIR_OpArrayCopy::src_objarray)) {
41546
357406d17607 8161044: PPC64: Improve internal array handling
zmajo
parents: 38931
diff changeset
  1960
      __ load_klass(tmp, src);
357406d17607 8161044: PPC64: Improve internal array handling
zmajo
parents: 38931
diff changeset
  1961
      __ lwz(tmp2, in_bytes(Klass::layout_helper_offset()), tmp);
357406d17607 8161044: PPC64: Improve internal array handling
zmajo
parents: 38931
diff changeset
  1962
      __ cmpwi(CCR0, tmp2, Klass::_lh_neutral_value);
357406d17607 8161044: PPC64: Improve internal array handling
zmajo
parents: 38931
diff changeset
  1963
      __ bge(CCR0, slow);
357406d17607 8161044: PPC64: Improve internal array handling
zmajo
parents: 38931
diff changeset
  1964
    }
357406d17607 8161044: PPC64: Improve internal array handling
zmajo
parents: 38931
diff changeset
  1965
  }
357406d17607 8161044: PPC64: Improve internal array handling
zmajo
parents: 38931
diff changeset
  1966
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1967
  // Higher 32bits must be null.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1968
  __ extsw(length, length);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1969
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1970
  __ extsw(src_pos, src_pos);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1971
  if (flags & LIR_OpArrayCopy::src_range_check) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1972
    __ lwz(tmp2, arrayOopDesc::length_offset_in_bytes(), src);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1973
    __ add(tmp, length, src_pos);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1974
    __ cmpld(CCR0, tmp2, tmp);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1975
    __ ble(CCR0, slow);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1976
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1977
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1978
  __ extsw(dst_pos, dst_pos);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1979
  if (flags & LIR_OpArrayCopy::dst_range_check) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1980
    __ lwz(tmp2, arrayOopDesc::length_offset_in_bytes(), dst);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1981
    __ add(tmp, length, dst_pos);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1982
    __ cmpld(CCR0, tmp2, tmp);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1983
    __ ble(CCR0, slow);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1984
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1985
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1986
  int shift = shift_amount(basic_type);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1987
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1988
  if (!(flags & LIR_OpArrayCopy::type_check)) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1989
    __ b(cont);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1990
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1991
    // We don't know the array types are compatible.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1992
    if (basic_type != T_OBJECT) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1993
      // Simple test for basic type arrays.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1994
      if (UseCompressedClassPointers) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1995
        // We don't need decode because we just need to compare.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1996
        __ lwz(tmp, oopDesc::klass_offset_in_bytes(), src);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1997
        __ lwz(tmp2, oopDesc::klass_offset_in_bytes(), dst);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1998
        __ cmpw(CCR0, tmp, tmp2);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  1999
      } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2000
        __ ld(tmp, oopDesc::klass_offset_in_bytes(), src);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2001
        __ ld(tmp2, oopDesc::klass_offset_in_bytes(), dst);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2002
        __ cmpd(CCR0, tmp, tmp2);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2003
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2004
      __ beq(CCR0, cont);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2005
    } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2006
      // For object arrays, if src is a sub class of dst then we can
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2007
      // safely do the copy.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2008
      address copyfunc_addr = StubRoutines::checkcast_arraycopy();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2009
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2010
      const Register sub_klass = R5, super_klass = R4; // like CheckCast/InstanceOf
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2011
      assert_different_registers(tmp, tmp2, sub_klass, super_klass);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2012
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2013
      __ load_klass(sub_klass, src);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2014
      __ load_klass(super_klass, dst);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2015
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2016
      __ check_klass_subtype_fast_path(sub_klass, super_klass, tmp, tmp2,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2017
                                       &cont, copyfunc_addr != NULL ? &copyfunc : &slow, NULL);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2018
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2019
      address slow_stc = Runtime1::entry_for(Runtime1::slow_subtype_check_id);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2020
      //__ load_const_optimized(tmp, slow_stc, tmp2);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2021
      __ calculate_address_from_global_toc(tmp, slow_stc, true, true, false);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2022
      __ mtctr(tmp);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2023
      __ bctrl(); // sets CR0
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2024
      __ beq(CCR0, cont);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2025
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2026
      if (copyfunc_addr != NULL) { // Use stub if available.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2027
        __ bind(copyfunc);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2028
        // Src is not a sub class of dst so we have to do a
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2029
        // per-element check.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2030
        int mask = LIR_OpArrayCopy::src_objarray|LIR_OpArrayCopy::dst_objarray;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2031
        if ((flags & mask) != mask) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2032
          assert(flags & mask, "one of the two should be known to be an object array");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2033
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2034
          if (!(flags & LIR_OpArrayCopy::src_objarray)) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2035
            __ load_klass(tmp, src);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2036
          } else if (!(flags & LIR_OpArrayCopy::dst_objarray)) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2037
            __ load_klass(tmp, dst);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2038
          }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2039
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2040
          __ lwz(tmp2, in_bytes(Klass::layout_helper_offset()), tmp);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2041
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2042
          jint objArray_lh = Klass::array_layout_helper(T_OBJECT);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2043
          __ load_const_optimized(tmp, objArray_lh);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2044
          __ cmpw(CCR0, tmp, tmp2);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2045
          __ bne(CCR0, slow);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2046
        }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2047
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2048
        Register src_ptr = R3_ARG1;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2049
        Register dst_ptr = R4_ARG2;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2050
        Register len     = R5_ARG3;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2051
        Register chk_off = R6_ARG4;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2052
        Register super_k = R7_ARG5;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2053
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2054
        __ addi(src_ptr, src, arrayOopDesc::base_offset_in_bytes(basic_type));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2055
        __ addi(dst_ptr, dst, arrayOopDesc::base_offset_in_bytes(basic_type));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2056
        if (shift == 0) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2057
          __ add(src_ptr, src_pos, src_ptr);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2058
          __ add(dst_ptr, dst_pos, dst_ptr);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2059
        } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2060
          __ sldi(tmp, src_pos, shift);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2061
          __ sldi(tmp2, dst_pos, shift);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2062
          __ add(src_ptr, tmp, src_ptr);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2063
          __ add(dst_ptr, tmp2, dst_ptr);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2064
        }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2065
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2066
        __ load_klass(tmp, dst);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2067
        __ mr(len, length);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2068
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2069
        int ek_offset = in_bytes(ObjArrayKlass::element_klass_offset());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2070
        __ ld(super_k, ek_offset, tmp);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2071
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2072
        int sco_offset = in_bytes(Klass::super_check_offset_offset());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2073
        __ lwz(chk_off, sco_offset, super_k);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2074
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2075
        __ call_c_with_frame_resize(copyfunc_addr, /*stub does not need resized frame*/ 0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2076
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2077
#ifndef PRODUCT
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2078
        if (PrintC1Statistics) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2079
          Label failed;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2080
          __ cmpwi(CCR0, R3_RET, 0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2081
          __ bne(CCR0, failed);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2082
          address counter = (address)&Runtime1::_arraycopy_checkcast_cnt;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2083
          int simm16_offs = __ load_const_optimized(tmp, counter, tmp2, true);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2084
          __ lwz(R11_scratch1, simm16_offs, tmp);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2085
          __ addi(R11_scratch1, R11_scratch1, 1);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2086
          __ stw(R11_scratch1, simm16_offs, tmp);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2087
          __ bind(failed);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2088
        }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2089
#endif
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2090
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2091
        __ nand(tmp, R3_RET, R3_RET);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2092
        __ cmpwi(CCR0, R3_RET, 0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2093
        __ beq(CCR0, *stub->continuation());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2094
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2095
#ifndef PRODUCT
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2096
        if (PrintC1Statistics) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2097
          address counter = (address)&Runtime1::_arraycopy_checkcast_attempt_cnt;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2098
          int simm16_offs = __ load_const_optimized(tmp, counter, tmp2, true);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2099
          __ lwz(R11_scratch1, simm16_offs, tmp);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2100
          __ addi(R11_scratch1, R11_scratch1, 1);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2101
          __ stw(R11_scratch1, simm16_offs, tmp);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2102
        }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2103
#endif
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2104
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2105
        __ subf(length, tmp, length);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2106
        __ add(src_pos, tmp, src_pos);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2107
        __ add(dst_pos, tmp, dst_pos);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2108
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2109
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2110
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2111
  __ bind(slow);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2112
  __ b(*stub->entry());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2113
  __ bind(cont);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2114
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2115
#ifdef ASSERT
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2116
  if (basic_type != T_OBJECT || !(flags & LIR_OpArrayCopy::type_check)) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2117
    // Sanity check the known type with the incoming class. For the
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2118
    // primitive case the types must match exactly with src.klass and
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2119
    // dst.klass each exactly matching the default type. For the
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2120
    // object array case, if no type check is needed then either the
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2121
    // dst type is exactly the expected type and the src type is a
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2122
    // subtype which we can't check or src is the same array as dst
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2123
    // but not necessarily exactly of type default_type.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2124
    Label known_ok, halt;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2125
    metadata2reg(op->expected_type()->constant_encoding(), tmp);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2126
    if (UseCompressedClassPointers) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2127
      // Tmp holds the default type. It currently comes uncompressed after the
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2128
      // load of a constant, so encode it.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2129
      __ encode_klass_not_null(tmp);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2130
      // Load the raw value of the dst klass, since we will be comparing
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2131
      // uncompressed values directly.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2132
      __ lwz(tmp2, oopDesc::klass_offset_in_bytes(), dst);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2133
      __ cmpw(CCR0, tmp, tmp2);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2134
      if (basic_type != T_OBJECT) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2135
        __ bne(CCR0, halt);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2136
        // Load the raw value of the src klass.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2137
        __ lwz(tmp2, oopDesc::klass_offset_in_bytes(), src);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2138
        __ cmpw(CCR0, tmp, tmp2);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2139
        __ beq(CCR0, known_ok);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2140
      } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2141
        __ beq(CCR0, known_ok);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2142
        __ cmpw(CCR0, src, dst);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2143
        __ beq(CCR0, known_ok);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2144
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2145
    } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2146
      __ ld(tmp2, oopDesc::klass_offset_in_bytes(), dst);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2147
      __ cmpd(CCR0, tmp, tmp2);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2148
      if (basic_type != T_OBJECT) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2149
        __ bne(CCR0, halt);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2150
        // Load the raw value of the src klass.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2151
        __ ld(tmp2, oopDesc::klass_offset_in_bytes(), src);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2152
        __ cmpd(CCR0, tmp, tmp2);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2153
        __ beq(CCR0, known_ok);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2154
      } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2155
        __ beq(CCR0, known_ok);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2156
        __ cmpd(CCR0, src, dst);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2157
        __ beq(CCR0, known_ok);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2158
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2159
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2160
    __ bind(halt);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2161
    __ stop("incorrect type information in arraycopy");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2162
    __ bind(known_ok);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2163
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2164
#endif
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2165
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2166
#ifndef PRODUCT
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2167
  if (PrintC1Statistics) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2168
    address counter = Runtime1::arraycopy_count_address(basic_type);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2169
    int simm16_offs = __ load_const_optimized(tmp, counter, tmp2, true);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2170
    __ lwz(R11_scratch1, simm16_offs, tmp);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2171
    __ addi(R11_scratch1, R11_scratch1, 1);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2172
    __ stw(R11_scratch1, simm16_offs, tmp);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2173
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2174
#endif
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2175
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2176
  Register src_ptr = R3_ARG1;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2177
  Register dst_ptr = R4_ARG2;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2178
  Register len     = R5_ARG3;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2179
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2180
  __ addi(src_ptr, src, arrayOopDesc::base_offset_in_bytes(basic_type));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2181
  __ addi(dst_ptr, dst, arrayOopDesc::base_offset_in_bytes(basic_type));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2182
  if (shift == 0) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2183
    __ add(src_ptr, src_pos, src_ptr);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2184
    __ add(dst_ptr, dst_pos, dst_ptr);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2185
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2186
    __ sldi(tmp, src_pos, shift);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2187
    __ sldi(tmp2, dst_pos, shift);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2188
    __ add(src_ptr, tmp, src_ptr);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2189
    __ add(dst_ptr, tmp2, dst_ptr);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2190
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2191
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2192
  bool disjoint = (flags & LIR_OpArrayCopy::overlapping) == 0;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2193
  bool aligned = (flags & LIR_OpArrayCopy::unaligned) == 0;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2194
  const char *name;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2195
  address entry = StubRoutines::select_arraycopy_function(basic_type, aligned, disjoint, name, false);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2196
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2197
  // Arraycopy stubs takes a length in number of elements, so don't scale it.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2198
  __ mr(len, length);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2199
  __ call_c_with_frame_resize(entry, /*stub does not need resized frame*/ 0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2200
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2201
  __ bind(*stub->continuation());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2202
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2203
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2204
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2205
void LIR_Assembler::shift_op(LIR_Code code, LIR_Opr left, LIR_Opr count, LIR_Opr dest, LIR_Opr tmp) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2206
  if (dest->is_single_cpu()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2207
    __ rldicl(tmp->as_register(), count->as_register(), 0, 64-5);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2208
#ifdef _LP64
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2209
    if (left->type() == T_OBJECT) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2210
      switch (code) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2211
        case lir_shl:  __ sld(dest->as_register(), left->as_register(), tmp->as_register()); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2212
        case lir_shr:  __ srad(dest->as_register(), left->as_register(), tmp->as_register()); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2213
        case lir_ushr: __ srd(dest->as_register(), left->as_register(), tmp->as_register()); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2214
        default: ShouldNotReachHere();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2215
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2216
    } else
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2217
#endif
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2218
      switch (code) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2219
        case lir_shl:  __ slw(dest->as_register(), left->as_register(), tmp->as_register()); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2220
        case lir_shr:  __ sraw(dest->as_register(), left->as_register(), tmp->as_register()); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2221
        case lir_ushr: __ srw(dest->as_register(), left->as_register(), tmp->as_register()); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2222
        default: ShouldNotReachHere();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2223
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2224
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2225
    __ rldicl(tmp->as_register(), count->as_register(), 0, 64-6);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2226
    switch (code) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2227
      case lir_shl:  __ sld(dest->as_register_lo(), left->as_register_lo(), tmp->as_register()); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2228
      case lir_shr:  __ srad(dest->as_register_lo(), left->as_register_lo(), tmp->as_register()); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2229
      case lir_ushr: __ srd(dest->as_register_lo(), left->as_register_lo(), tmp->as_register()); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2230
      default: ShouldNotReachHere();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2231
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2232
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2233
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2234
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2235
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2236
void LIR_Assembler::shift_op(LIR_Code code, LIR_Opr left, jint count, LIR_Opr dest) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2237
#ifdef _LP64
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2238
  if (left->type() == T_OBJECT) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2239
    count = count & 63;  // Shouldn't shift by more than sizeof(intptr_t).
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2240
    if (count == 0) { __ mr_if_needed(dest->as_register_lo(), left->as_register()); }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2241
    else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2242
      switch (code) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2243
        case lir_shl:  __ sldi(dest->as_register_lo(), left->as_register(), count); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2244
        case lir_shr:  __ sradi(dest->as_register_lo(), left->as_register(), count); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2245
        case lir_ushr: __ srdi(dest->as_register_lo(), left->as_register(), count); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2246
        default: ShouldNotReachHere();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2247
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2248
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2249
    return;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2250
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2251
#endif
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2252
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2253
  if (dest->is_single_cpu()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2254
    count = count & 0x1F; // Java spec
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2255
    if (count == 0) { __ mr_if_needed(dest->as_register(), left->as_register()); }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2256
    else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2257
      switch (code) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2258
        case lir_shl: __ slwi(dest->as_register(), left->as_register(), count); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2259
        case lir_shr:  __ srawi(dest->as_register(), left->as_register(), count); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2260
        case lir_ushr: __ srwi(dest->as_register(), left->as_register(), count); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2261
        default: ShouldNotReachHere();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2262
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2263
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2264
  } else if (dest->is_double_cpu()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2265
    count = count & 63; // Java spec
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2266
    if (count == 0) { __ mr_if_needed(dest->as_pointer_register(), left->as_pointer_register()); }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2267
    else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2268
      switch (code) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2269
        case lir_shl:  __ sldi(dest->as_pointer_register(), left->as_pointer_register(), count); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2270
        case lir_shr:  __ sradi(dest->as_pointer_register(), left->as_pointer_register(), count); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2271
        case lir_ushr: __ srdi(dest->as_pointer_register(), left->as_pointer_register(), count); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2272
        default: ShouldNotReachHere();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2273
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2274
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2275
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2276
    ShouldNotReachHere();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2277
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2278
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2279
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2280
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2281
void LIR_Assembler::emit_alloc_obj(LIR_OpAllocObj* op) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2282
  if (op->init_check()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2283
    if (!os::zero_page_read_protected() || !ImplicitNullChecks) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2284
      explicit_null_check(op->klass()->as_register(), op->stub()->info());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2285
    } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2286
      add_debug_info_for_null_check_here(op->stub()->info());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2287
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2288
    __ lbz(op->tmp1()->as_register(),
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2289
           in_bytes(InstanceKlass::init_state_offset()), op->klass()->as_register());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2290
    __ cmpwi(CCR0, op->tmp1()->as_register(), InstanceKlass::fully_initialized);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2291
    __ bc_far_optimized(Assembler::bcondCRbiIs0, __ bi0(CCR0, Assembler::equal), *op->stub()->entry());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2292
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2293
  __ allocate_object(op->obj()->as_register(),
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2294
                     op->tmp1()->as_register(),
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2295
                     op->tmp2()->as_register(),
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2296
                     op->tmp3()->as_register(),
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2297
                     op->header_size(),
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2298
                     op->object_size(),
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2299
                     op->klass()->as_register(),
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2300
                     *op->stub()->entry());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2301
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2302
  __ bind(*op->stub()->continuation());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2303
  __ verify_oop(op->obj()->as_register());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2304
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2305
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2306
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2307
void LIR_Assembler::emit_alloc_array(LIR_OpAllocArray* op) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2308
  LP64_ONLY( __ extsw(op->len()->as_register(), op->len()->as_register()); )
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2309
  if (UseSlowPath ||
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2310
      (!UseFastNewObjectArray && (op->type() == T_OBJECT || op->type() == T_ARRAY)) ||
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2311
      (!UseFastNewTypeArray   && (op->type() != T_OBJECT && op->type() != T_ARRAY))) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2312
    __ b(*op->stub()->entry());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2313
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2314
    __ allocate_array(op->obj()->as_register(),
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2315
                      op->len()->as_register(),
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2316
                      op->tmp1()->as_register(),
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2317
                      op->tmp2()->as_register(),
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2318
                      op->tmp3()->as_register(),
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2319
                      arrayOopDesc::header_size(op->type()),
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2320
                      type2aelembytes(op->type()),
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2321
                      op->klass()->as_register(),
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2322
                      *op->stub()->entry());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2323
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2324
  __ bind(*op->stub()->continuation());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2325
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2326
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2327
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2328
void LIR_Assembler::type_profile_helper(Register mdo, int mdo_offset_bias,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2329
                                        ciMethodData *md, ciProfileData *data,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2330
                                        Register recv, Register tmp1, Label* update_done) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2331
  uint i;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2332
  for (i = 0; i < VirtualCallData::row_limit(); i++) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2333
    Label next_test;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2334
    // See if the receiver is receiver[n].
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2335
    __ ld(tmp1, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_offset(i)) - mdo_offset_bias, mdo);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2336
    __ verify_klass_ptr(tmp1);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2337
    __ cmpd(CCR0, recv, tmp1);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2338
    __ bne(CCR0, next_test);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2339
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2340
    __ ld(tmp1, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_count_offset(i)) - mdo_offset_bias, mdo);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2341
    __ addi(tmp1, tmp1, DataLayout::counter_increment);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2342
    __ std(tmp1, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_count_offset(i)) - mdo_offset_bias, mdo);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2343
    __ b(*update_done);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2344
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2345
    __ bind(next_test);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2346
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2347
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2348
  // Didn't find receiver; find next empty slot and fill it in.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2349
  for (i = 0; i < VirtualCallData::row_limit(); i++) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2350
    Label next_test;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2351
    __ ld(tmp1, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_offset(i)) - mdo_offset_bias, mdo);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2352
    __ cmpdi(CCR0, tmp1, 0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2353
    __ bne(CCR0, next_test);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2354
    __ li(tmp1, DataLayout::counter_increment);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2355
    __ std(recv, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_offset(i)) - mdo_offset_bias, mdo);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2356
    __ std(tmp1, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_count_offset(i)) - mdo_offset_bias, mdo);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2357
    __ b(*update_done);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2358
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2359
    __ bind(next_test);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2360
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2361
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2362
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2363
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2364
void LIR_Assembler::setup_md_access(ciMethod* method, int bci,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2365
                                    ciMethodData*& md, ciProfileData*& data, int& mdo_offset_bias) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2366
  md = method->method_data_or_null();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2367
  assert(md != NULL, "Sanity");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2368
  data = md->bci_to_data(bci);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2369
  assert(data != NULL,       "need data for checkcast");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2370
  assert(data->is_ReceiverTypeData(), "need ReceiverTypeData for type check");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2371
  if (!Assembler::is_simm16(md->byte_offset_of_slot(data, DataLayout::header_offset()) + data->size_in_bytes())) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2372
    // The offset is large so bias the mdo by the base of the slot so
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2373
    // that the ld can use simm16s to reference the slots of the data.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2374
    mdo_offset_bias = md->byte_offset_of_slot(data, DataLayout::header_offset());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2375
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2376
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2377
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2378
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2379
void LIR_Assembler::emit_typecheck_helper(LIR_OpTypeCheck *op, Label* success, Label* failure, Label* obj_is_null) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2380
  Register obj = op->object()->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2381
  Register k_RInfo = op->tmp1()->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2382
  Register klass_RInfo = op->tmp2()->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2383
  Register Rtmp1 = op->tmp3()->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2384
  Register dst = op->result_opr()->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2385
  ciKlass* k = op->klass();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2386
  bool should_profile = op->should_profile();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2387
  bool move_obj_to_dst = (op->code() == lir_checkcast);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2388
  // Attention: do_temp(opTypeCheck->_object) is not used, i.e. obj may be same as one of the temps.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2389
  bool reg_conflict = (obj == k_RInfo || obj == klass_RInfo || obj == Rtmp1);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2390
  bool restore_obj = move_obj_to_dst && reg_conflict;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2391
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2392
  __ cmpdi(CCR0, obj, 0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2393
  if (move_obj_to_dst || reg_conflict) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2394
    __ mr_if_needed(dst, obj);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2395
    if (reg_conflict) { obj = dst; }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2396
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2397
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2398
  ciMethodData* md;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2399
  ciProfileData* data;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2400
  int mdo_offset_bias = 0;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2401
  if (should_profile) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2402
    ciMethod* method = op->profiled_method();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2403
    assert(method != NULL, "Should have method");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2404
    setup_md_access(method, op->profiled_bci(), md, data, mdo_offset_bias);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2405
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2406
    Register mdo      = k_RInfo;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2407
    Register data_val = Rtmp1;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2408
    Label not_null;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2409
    __ bne(CCR0, not_null);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2410
    metadata2reg(md->constant_encoding(), mdo);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2411
    __ add_const_optimized(mdo, mdo, mdo_offset_bias, R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2412
    __ lbz(data_val, md->byte_offset_of_slot(data, DataLayout::flags_offset()) - mdo_offset_bias, mdo);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2413
    __ ori(data_val, data_val, BitData::null_seen_byte_constant());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2414
    __ stb(data_val, md->byte_offset_of_slot(data, DataLayout::flags_offset()) - mdo_offset_bias, mdo);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2415
    __ b(*obj_is_null);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2416
    __ bind(not_null);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2417
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2418
    __ beq(CCR0, *obj_is_null);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2419
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2420
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2421
  // get object class
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2422
  __ load_klass(klass_RInfo, obj);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2423
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2424
  if (k->is_loaded()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2425
    metadata2reg(k->constant_encoding(), k_RInfo);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2426
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2427
    klass2reg_with_patching(k_RInfo, op->info_for_patch());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2428
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2429
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2430
  Label profile_cast_failure, failure_restore_obj, profile_cast_success;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2431
  Label *failure_target = should_profile ? &profile_cast_failure : failure;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2432
  Label *success_target = should_profile ? &profile_cast_success : success;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2433
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2434
  if (op->fast_check()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2435
    assert_different_registers(klass_RInfo, k_RInfo);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2436
    __ cmpd(CCR0, k_RInfo, klass_RInfo);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2437
    if (should_profile) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2438
      __ bne(CCR0, *failure_target);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2439
      // Fall through to success case.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2440
    } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2441
      __ beq(CCR0, *success);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2442
      // Fall through to failure case.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2443
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2444
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2445
    bool need_slow_path = true;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2446
    if (k->is_loaded()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2447
      if ((int) k->super_check_offset() != in_bytes(Klass::secondary_super_cache_offset())) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2448
        need_slow_path = false;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2449
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2450
      // Perform the fast part of the checking logic.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2451
      __ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, R0, (need_slow_path ? success_target : NULL),
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2452
                                       failure_target, NULL, RegisterOrConstant(k->super_check_offset()));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2453
    } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2454
      // Perform the fast part of the checking logic.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2455
      __ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, R0, success_target, failure_target);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2456
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2457
    if (!need_slow_path) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2458
      if (!should_profile) { __ b(*success); }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2459
    } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2460
      // Call out-of-line instance of __ check_klass_subtype_slow_path(...):
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2461
      address entry = Runtime1::entry_for(Runtime1::slow_subtype_check_id);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2462
      //__ load_const_optimized(Rtmp1, entry, R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2463
      __ calculate_address_from_global_toc(Rtmp1, entry, true, true, false);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2464
      __ mtctr(Rtmp1);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2465
      __ bctrl(); // sets CR0
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2466
      if (should_profile) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2467
        __ bne(CCR0, *failure_target);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2468
        // Fall through to success case.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2469
      } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2470
        __ beq(CCR0, *success);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2471
        // Fall through to failure case.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2472
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2473
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2474
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2475
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2476
  if (should_profile) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2477
    Register mdo = k_RInfo, recv = klass_RInfo;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2478
    assert_different_registers(mdo, recv, Rtmp1);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2479
    __ bind(profile_cast_success);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2480
    metadata2reg(md->constant_encoding(), mdo);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2481
    __ add_const_optimized(mdo, mdo, mdo_offset_bias, R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2482
    type_profile_helper(mdo, mdo_offset_bias, md, data, recv, Rtmp1, success);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2483
    __ b(*success);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2484
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2485
    // Cast failure case.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2486
    __ bind(profile_cast_failure);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2487
    metadata2reg(md->constant_encoding(), mdo);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2488
    __ add_const_optimized(mdo, mdo, mdo_offset_bias, R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2489
    __ ld(Rtmp1, md->byte_offset_of_slot(data, CounterData::count_offset()) - mdo_offset_bias, mdo);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2490
    __ addi(Rtmp1, Rtmp1, -DataLayout::counter_increment);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2491
    __ std(Rtmp1, md->byte_offset_of_slot(data, CounterData::count_offset()) - mdo_offset_bias, mdo);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2492
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2493
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2494
  __ bind(*failure);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2495
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2496
  if (restore_obj) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2497
    __ mr(op->object()->as_register(), dst);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2498
    // Fall through to failure case.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2499
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2500
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2501
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2502
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2503
void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2504
  LIR_Code code = op->code();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2505
  if (code == lir_store_check) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2506
    Register value = op->object()->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2507
    Register array = op->array()->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2508
    Register k_RInfo = op->tmp1()->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2509
    Register klass_RInfo = op->tmp2()->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2510
    Register Rtmp1 = op->tmp3()->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2511
    bool should_profile = op->should_profile();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2512
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2513
    __ verify_oop(value);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2514
    CodeStub* stub = op->stub();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2515
    // Check if it needs to be profiled.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2516
    ciMethodData* md;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2517
    ciProfileData* data;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2518
    int mdo_offset_bias = 0;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2519
    if (should_profile) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2520
      ciMethod* method = op->profiled_method();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2521
      assert(method != NULL, "Should have method");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2522
      setup_md_access(method, op->profiled_bci(), md, data, mdo_offset_bias);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2523
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2524
    Label profile_cast_success, failure, done;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2525
    Label *success_target = should_profile ? &profile_cast_success : &done;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2526
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2527
    __ cmpdi(CCR0, value, 0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2528
    if (should_profile) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2529
      Label not_null;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2530
      __ bne(CCR0, not_null);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2531
      Register mdo      = k_RInfo;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2532
      Register data_val = Rtmp1;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2533
      metadata2reg(md->constant_encoding(), mdo);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2534
      __ add_const_optimized(mdo, mdo, mdo_offset_bias, R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2535
      __ lbz(data_val, md->byte_offset_of_slot(data, DataLayout::flags_offset()) - mdo_offset_bias, mdo);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2536
      __ ori(data_val, data_val, BitData::null_seen_byte_constant());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2537
      __ stb(data_val, md->byte_offset_of_slot(data, DataLayout::flags_offset()) - mdo_offset_bias, mdo);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2538
      __ b(done);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2539
      __ bind(not_null);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2540
    } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2541
      __ beq(CCR0, done);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2542
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2543
    if (!os::zero_page_read_protected() || !ImplicitNullChecks) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2544
      explicit_null_check(array, op->info_for_exception());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2545
    } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2546
      add_debug_info_for_null_check_here(op->info_for_exception());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2547
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2548
    __ load_klass(k_RInfo, array);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2549
    __ load_klass(klass_RInfo, value);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2550
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2551
    // Get instance klass.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2552
    __ ld(k_RInfo, in_bytes(ObjArrayKlass::element_klass_offset()), k_RInfo);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2553
    // Perform the fast part of the checking logic.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2554
    __ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, R0, success_target, &failure, NULL);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2555
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2556
    // Call out-of-line instance of __ check_klass_subtype_slow_path(...):
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2557
    const address slow_path = Runtime1::entry_for(Runtime1::slow_subtype_check_id);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2558
    //__ load_const_optimized(R0, slow_path);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2559
    __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(slow_path));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2560
    __ mtctr(R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2561
    __ bctrl(); // sets CR0
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2562
    if (!should_profile) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2563
      __ beq(CCR0, done);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2564
      __ bind(failure);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2565
    } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2566
      __ bne(CCR0, failure);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2567
      // Fall through to the success case.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2568
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2569
      Register mdo  = klass_RInfo, recv = k_RInfo, tmp1 = Rtmp1;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2570
      assert_different_registers(value, mdo, recv, tmp1);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2571
      __ bind(profile_cast_success);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2572
      metadata2reg(md->constant_encoding(), mdo);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2573
      __ add_const_optimized(mdo, mdo, mdo_offset_bias, R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2574
      __ load_klass(recv, value);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2575
      type_profile_helper(mdo, mdo_offset_bias, md, data, recv, tmp1, &done);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2576
      __ b(done);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2577
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2578
      // Cast failure case.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2579
      __ bind(failure);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2580
      metadata2reg(md->constant_encoding(), mdo);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2581
      __ add_const_optimized(mdo, mdo, mdo_offset_bias, R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2582
      Address data_addr(mdo, md->byte_offset_of_slot(data, CounterData::count_offset()) - mdo_offset_bias);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2583
      __ ld(tmp1, md->byte_offset_of_slot(data, CounterData::count_offset()) - mdo_offset_bias, mdo);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2584
      __ addi(tmp1, tmp1, -DataLayout::counter_increment);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2585
      __ std(tmp1, md->byte_offset_of_slot(data, CounterData::count_offset()) - mdo_offset_bias, mdo);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2586
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2587
    __ b(*stub->entry());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2588
    __ bind(done);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2589
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2590
  } else if (code == lir_checkcast) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2591
    Label success, failure;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2592
    emit_typecheck_helper(op, &success, /*fallthru*/&failure, &success); // Moves obj to dst.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2593
    __ b(*op->stub()->entry());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2594
    __ align(32, 12);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2595
    __ bind(success);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2596
  } else if (code == lir_instanceof) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2597
    Register dst = op->result_opr()->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2598
    Label success, failure, done;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2599
    emit_typecheck_helper(op, &success, /*fallthru*/&failure, &failure);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2600
    __ li(dst, 0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2601
    __ b(done);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2602
    __ align(32, 12);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2603
    __ bind(success);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2604
    __ li(dst, 1);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2605
    __ bind(done);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2606
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2607
    ShouldNotReachHere();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2608
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2609
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2610
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2611
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2612
void LIR_Assembler::emit_compare_and_swap(LIR_OpCompareAndSwap* op) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2613
  Register addr = op->addr()->as_pointer_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2614
  Register cmp_value = noreg, new_value = noreg;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2615
  bool is_64bit = false;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2616
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2617
  if (op->code() == lir_cas_long) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2618
    cmp_value = op->cmp_value()->as_register_lo();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2619
    new_value = op->new_value()->as_register_lo();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2620
    is_64bit = true;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2621
  } else if (op->code() == lir_cas_int || op->code() == lir_cas_obj) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2622
    cmp_value = op->cmp_value()->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2623
    new_value = op->new_value()->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2624
    if (op->code() == lir_cas_obj) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2625
      if (UseCompressedOops) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2626
        Register t1 = op->tmp1()->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2627
        Register t2 = op->tmp2()->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2628
        cmp_value = __ encode_heap_oop(t1, cmp_value);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2629
        new_value = __ encode_heap_oop(t2, new_value);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2630
      } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2631
        is_64bit = true;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2632
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2633
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2634
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2635
    Unimplemented();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2636
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2637
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2638
  if (is_64bit) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2639
    __ cmpxchgd(BOOL_RESULT, /*current_value=*/R0, cmp_value, new_value, addr,
38685
e34308190947 8141635: Implement VarHandles/Unsafe intrinsics on POWER
mdoerr
parents: 38017
diff changeset
  2640
                MacroAssembler::MemBarNone,
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2641
                MacroAssembler::cmpxchgx_hint_atomic_update(),
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2642
                noreg, NULL, /*check without ldarx first*/true);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2643
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2644
    __ cmpxchgw(BOOL_RESULT, /*current_value=*/R0, cmp_value, new_value, addr,
38685
e34308190947 8141635: Implement VarHandles/Unsafe intrinsics on POWER
mdoerr
parents: 38017
diff changeset
  2645
                MacroAssembler::MemBarNone,
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2646
                MacroAssembler::cmpxchgx_hint_atomic_update(),
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2647
                noreg, /*check without ldarx first*/true);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2648
  }
38685
e34308190947 8141635: Implement VarHandles/Unsafe intrinsics on POWER
mdoerr
parents: 38017
diff changeset
  2649
e34308190947 8141635: Implement VarHandles/Unsafe intrinsics on POWER
mdoerr
parents: 38017
diff changeset
  2650
  if (support_IRIW_for_not_multiple_copy_atomic_cpu) {
e34308190947 8141635: Implement VarHandles/Unsafe intrinsics on POWER
mdoerr
parents: 38017
diff changeset
  2651
    __ isync();
e34308190947 8141635: Implement VarHandles/Unsafe intrinsics on POWER
mdoerr
parents: 38017
diff changeset
  2652
  } else {
e34308190947 8141635: Implement VarHandles/Unsafe intrinsics on POWER
mdoerr
parents: 38017
diff changeset
  2653
    __ sync();
e34308190947 8141635: Implement VarHandles/Unsafe intrinsics on POWER
mdoerr
parents: 38017
diff changeset
  2654
  }
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2655
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2656
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2657
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2658
void LIR_Assembler::set_24bit_FPU() {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2659
  Unimplemented();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2660
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2661
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2662
void LIR_Assembler::reset_FPU() {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2663
  Unimplemented();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2664
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2665
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2666
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2667
void LIR_Assembler::breakpoint() {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2668
  __ illtrap();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2669
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2670
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2671
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2672
void LIR_Assembler::push(LIR_Opr opr) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2673
  Unimplemented();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2674
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2675
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2676
void LIR_Assembler::pop(LIR_Opr opr) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2677
  Unimplemented();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2678
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2679
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2680
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2681
void LIR_Assembler::monitor_address(int monitor_no, LIR_Opr dst_opr) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2682
  Address mon_addr = frame_map()->address_for_monitor_lock(monitor_no);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2683
  Register dst = dst_opr->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2684
  Register reg = mon_addr.base();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2685
  int offset = mon_addr.disp();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2686
  // Compute pointer to BasicLock.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2687
  __ add_const_optimized(dst, reg, offset);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2688
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2689
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2690
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2691
void LIR_Assembler::emit_lock(LIR_OpLock* op) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2692
  Register obj = op->obj_opr()->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2693
  Register hdr = op->hdr_opr()->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2694
  Register lock = op->lock_opr()->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2695
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2696
  // Obj may not be an oop.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2697
  if (op->code() == lir_lock) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2698
    MonitorEnterStub* stub = (MonitorEnterStub*)op->stub();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2699
    if (UseFastLocking) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2700
      assert(BasicLock::displaced_header_offset_in_bytes() == 0, "lock_reg must point to the displaced header");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2701
      // Add debug info for NullPointerException only if one is possible.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2702
      if (op->info() != NULL) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2703
        if (!os::zero_page_read_protected() || !ImplicitNullChecks) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2704
          explicit_null_check(obj, op->info());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2705
        } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2706
          add_debug_info_for_null_check_here(op->info());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2707
        }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2708
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2709
      __ lock_object(hdr, obj, lock, op->scratch_opr()->as_register(), *op->stub()->entry());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2710
    } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2711
      // always do slow locking
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2712
      // note: The slow locking code could be inlined here, however if we use
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2713
      //       slow locking, speed doesn't matter anyway and this solution is
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2714
      //       simpler and requires less duplicated code - additionally, the
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2715
      //       slow locking code is the same in either case which simplifies
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2716
      //       debugging.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2717
      __ b(*op->stub()->entry());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2718
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2719
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2720
    assert (op->code() == lir_unlock, "Invalid code, expected lir_unlock");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2721
    if (UseFastLocking) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2722
      assert(BasicLock::displaced_header_offset_in_bytes() == 0, "lock_reg must point to the displaced header");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2723
      __ unlock_object(hdr, obj, lock, *op->stub()->entry());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2724
    } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2725
      // always do slow unlocking
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2726
      // note: The slow unlocking code could be inlined here, however if we use
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2727
      //       slow unlocking, speed doesn't matter anyway and this solution is
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2728
      //       simpler and requires less duplicated code - additionally, the
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2729
      //       slow unlocking code is the same in either case which simplifies
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2730
      //       debugging.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2731
      __ b(*op->stub()->entry());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2732
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2733
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2734
  __ bind(*op->stub()->continuation());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2735
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2736
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2737
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2738
void LIR_Assembler::emit_profile_call(LIR_OpProfileCall* op) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2739
  ciMethod* method = op->profiled_method();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2740
  int bci          = op->profiled_bci();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2741
  ciMethod* callee = op->profiled_callee();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2742
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2743
  // Update counter for all call types.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2744
  ciMethodData* md = method->method_data_or_null();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2745
  assert(md != NULL, "Sanity");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2746
  ciProfileData* data = md->bci_to_data(bci);
48856
c866eaca24cb 8194984: 9 Null pointer dereference defect groups related to ciMethodData::bci_to_data()
dlong
parents: 48332
diff changeset
  2747
  assert(data != NULL && data->is_CounterData(), "need CounterData for calls");
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2748
  assert(op->mdo()->is_single_cpu(),  "mdo must be allocated");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2749
  Register mdo = op->mdo()->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2750
#ifdef _LP64
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2751
  assert(op->tmp1()->is_double_cpu(), "tmp1 must be allocated");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2752
  Register tmp1 = op->tmp1()->as_register_lo();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2753
#else
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2754
  assert(op->tmp1()->is_single_cpu(), "tmp1 must be allocated");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2755
  Register tmp1 = op->tmp1()->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2756
#endif
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2757
  metadata2reg(md->constant_encoding(), mdo);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2758
  int mdo_offset_bias = 0;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2759
  if (!Assembler::is_simm16(md->byte_offset_of_slot(data, CounterData::count_offset()) +
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2760
                            data->size_in_bytes())) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2761
    // The offset is large so bias the mdo by the base of the slot so
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2762
    // that the ld can use simm16s to reference the slots of the data.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2763
    mdo_offset_bias = md->byte_offset_of_slot(data, CounterData::count_offset());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2764
    __ add_const_optimized(mdo, mdo, mdo_offset_bias, R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2765
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2766
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2767
  // Perform additional virtual call profiling for invokevirtual and
47698
d4bfafe600d0 8166750: C1 profiling handles statically bindable call sites differently than the interpreter
iveresov
parents: 47216
diff changeset
  2768
  // invokeinterface bytecodes
d4bfafe600d0 8166750: C1 profiling handles statically bindable call sites differently than the interpreter
iveresov
parents: 47216
diff changeset
  2769
  if (op->should_profile_receiver_type()) {
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2770
    assert(op->recv()->is_single_cpu(), "recv must be allocated");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2771
    Register recv = op->recv()->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2772
    assert_different_registers(mdo, tmp1, recv);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2773
    assert(data->is_VirtualCallData(), "need VirtualCallData for virtual calls");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2774
    ciKlass* known_klass = op->known_holder();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2775
    if (C1OptimizeVirtualCallProfiling && known_klass != NULL) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2776
      // We know the type that will be seen at this call site; we can
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2777
      // statically update the MethodData* rather than needing to do
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2778
      // dynamic tests on the receiver type.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2779
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2780
      // NOTE: we should probably put a lock around this search to
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2781
      // avoid collisions by concurrent compilations.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2782
      ciVirtualCallData* vc_data = (ciVirtualCallData*) data;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2783
      uint i;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2784
      for (i = 0; i < VirtualCallData::row_limit(); i++) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2785
        ciKlass* receiver = vc_data->receiver(i);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2786
        if (known_klass->equals(receiver)) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2787
          __ ld(tmp1, md->byte_offset_of_slot(data, VirtualCallData::receiver_count_offset(i)) - mdo_offset_bias, mdo);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2788
          __ addi(tmp1, tmp1, DataLayout::counter_increment);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2789
          __ std(tmp1, md->byte_offset_of_slot(data, VirtualCallData::receiver_count_offset(i)) - mdo_offset_bias, mdo);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2790
          return;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2791
        }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2792
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2793
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2794
      // Receiver type not found in profile data; select an empty slot.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2795
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2796
      // Note that this is less efficient than it should be because it
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2797
      // always does a write to the receiver part of the
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2798
      // VirtualCallData rather than just the first time.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2799
      for (i = 0; i < VirtualCallData::row_limit(); i++) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2800
        ciKlass* receiver = vc_data->receiver(i);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2801
        if (receiver == NULL) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2802
          metadata2reg(known_klass->constant_encoding(), tmp1);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2803
          __ std(tmp1, md->byte_offset_of_slot(data, VirtualCallData::receiver_offset(i)) - mdo_offset_bias, mdo);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2804
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2805
          __ ld(tmp1, md->byte_offset_of_slot(data, VirtualCallData::receiver_count_offset(i)) - mdo_offset_bias, mdo);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2806
          __ addi(tmp1, tmp1, DataLayout::counter_increment);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2807
          __ std(tmp1, md->byte_offset_of_slot(data, VirtualCallData::receiver_count_offset(i)) - mdo_offset_bias, mdo);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2808
          return;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2809
        }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2810
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2811
    } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2812
      __ load_klass(recv, recv);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2813
      Label update_done;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2814
      type_profile_helper(mdo, mdo_offset_bias, md, data, recv, tmp1, &update_done);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2815
      // Receiver did not match any saved receiver and there is no empty row for it.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2816
      // Increment total counter to indicate polymorphic case.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2817
      __ ld(tmp1, md->byte_offset_of_slot(data, CounterData::count_offset()) - mdo_offset_bias, mdo);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2818
      __ addi(tmp1, tmp1, DataLayout::counter_increment);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2819
      __ std(tmp1, md->byte_offset_of_slot(data, CounterData::count_offset()) - mdo_offset_bias, mdo);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2820
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2821
      __ bind(update_done);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2822
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2823
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2824
    // Static call
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2825
    __ ld(tmp1, md->byte_offset_of_slot(data, CounterData::count_offset()) - mdo_offset_bias, mdo);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2826
    __ addi(tmp1, tmp1, DataLayout::counter_increment);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2827
    __ std(tmp1, md->byte_offset_of_slot(data, CounterData::count_offset()) - mdo_offset_bias, mdo);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2828
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2829
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2830
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2831
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2832
void LIR_Assembler::align_backward_branch_target() {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2833
  __ align(32, 12); // Insert up to 3 nops to align with 32 byte boundary.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2834
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2835
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2836
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2837
void LIR_Assembler::emit_delay(LIR_OpDelay* op) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2838
  Unimplemented();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2839
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2840
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2841
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2842
void LIR_Assembler::negate(LIR_Opr left, LIR_Opr dest) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2843
  assert(left->is_register(), "can only handle registers");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2844
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2845
  if (left->is_single_cpu()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2846
    __ neg(dest->as_register(), left->as_register());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2847
  } else if (left->is_single_fpu()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2848
    __ fneg(dest->as_float_reg(), left->as_float_reg());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2849
  } else if (left->is_double_fpu()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2850
    __ fneg(dest->as_double_reg(), left->as_double_reg());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2851
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2852
    assert (left->is_double_cpu(), "Must be a long");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2853
    __ neg(dest->as_register_lo(), left->as_register_lo());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2854
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2855
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2856
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2857
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2858
void LIR_Assembler::fxch(int i) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2859
  Unimplemented();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2860
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2861
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2862
void LIR_Assembler::fld(int i) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2863
  Unimplemented();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2864
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2865
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2866
void LIR_Assembler::ffree(int i) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2867
  Unimplemented();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2868
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2869
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2870
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2871
void LIR_Assembler::rt_call(LIR_Opr result, address dest,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2872
                            const LIR_OprList* args, LIR_Opr tmp, CodeEmitInfo* info) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2873
  // Stubs: Called via rt_call, but dest is a stub address (no function descriptor).
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2874
  if (dest == Runtime1::entry_for(Runtime1::register_finalizer_id) ||
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2875
      dest == Runtime1::entry_for(Runtime1::new_multi_array_id   )) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2876
    //__ load_const_optimized(R0, dest);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2877
    __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(dest));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2878
    __ mtctr(R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2879
    __ bctrl();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2880
    assert(info != NULL, "sanity");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2881
    add_call_info_here(info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2882
    return;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2883
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2884
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2885
  __ call_c_with_frame_resize(dest, /*no resizing*/ 0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2886
  if (info != NULL) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2887
    add_call_info_here(info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2888
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2889
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2890
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2891
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2892
void LIR_Assembler::volatile_move_op(LIR_Opr src, LIR_Opr dest, BasicType type, CodeEmitInfo* info) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2893
  ShouldNotReachHere(); // Not needed on _LP64.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2894
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2895
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2896
void LIR_Assembler::membar() {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2897
  __ fence();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2898
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2899
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2900
void LIR_Assembler::membar_acquire() {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2901
  __ acquire();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2902
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2903
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2904
void LIR_Assembler::membar_release() {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2905
  __ release();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2906
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2907
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2908
void LIR_Assembler::membar_loadload() {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2909
  __ membar(Assembler::LoadLoad);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2910
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2911
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2912
void LIR_Assembler::membar_storestore() {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2913
  __ membar(Assembler::StoreStore);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2914
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2915
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2916
void LIR_Assembler::membar_loadstore() {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2917
  __ membar(Assembler::LoadStore);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2918
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2919
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2920
void LIR_Assembler::membar_storeload() {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2921
  __ membar(Assembler::StoreLoad);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2922
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2923
38017
55047d16f141 8147844: new method j.l.Runtime.onSpinWait() and the corresponding x86 hotspot instrinsic
ikrylov
parents: 35594
diff changeset
  2924
void LIR_Assembler::on_spin_wait() {
55047d16f141 8147844: new method j.l.Runtime.onSpinWait() and the corresponding x86 hotspot instrinsic
ikrylov
parents: 35594
diff changeset
  2925
  Unimplemented();
55047d16f141 8147844: new method j.l.Runtime.onSpinWait() and the corresponding x86 hotspot instrinsic
ikrylov
parents: 35594
diff changeset
  2926
}
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2927
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2928
void LIR_Assembler::leal(LIR_Opr addr_opr, LIR_Opr dest) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2929
  LIR_Address* addr = addr_opr->as_address_ptr();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2930
  assert(addr->scale() == LIR_Address::times_1, "no scaling on this platform");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2931
  if (addr->index()->is_illegal()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2932
    __ add_const_optimized(dest->as_pointer_register(), addr->base()->as_pointer_register(), addr->disp());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2933
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2934
    assert(addr->disp() == 0, "can't have both: index and disp");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2935
    __ add(dest->as_pointer_register(), addr->index()->as_pointer_register(), addr->base()->as_pointer_register());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2936
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2937
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2938
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2939
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2940
void LIR_Assembler::get_thread(LIR_Opr result_reg) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2941
  ShouldNotReachHere();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2942
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2943
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2944
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2945
#ifdef ASSERT
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2946
// Emit run-time assertion.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2947
void LIR_Assembler::emit_assert(LIR_OpAssert* op) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2948
  Unimplemented();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2949
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2950
#endif
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2951
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2952
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2953
void LIR_Assembler::peephole(LIR_List* lir) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2954
  // Optimize instruction pairs before emitting.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2955
  LIR_OpList* inst = lir->instructions_list();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2956
  for (int i = 1; i < inst->length(); i++) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2957
    LIR_Op* op = inst->at(i);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2958
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2959
    // 2 register-register-moves
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2960
    if (op->code() == lir_move) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2961
      LIR_Opr in2  = ((LIR_Op1*)op)->in_opr(),
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2962
              res2 = ((LIR_Op1*)op)->result_opr();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2963
      if (in2->is_register() && res2->is_register()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2964
        LIR_Op* prev = inst->at(i - 1);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2965
        if (prev && prev->code() == lir_move) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2966
          LIR_Opr in1  = ((LIR_Op1*)prev)->in_opr(),
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2967
                  res1 = ((LIR_Op1*)prev)->result_opr();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2968
          if (in1->is_same_register(res2) && in2->is_same_register(res1)) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2969
            inst->remove_at(i);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2970
          }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2971
        }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2972
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2973
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2974
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2975
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2976
  return;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2977
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2978
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2979
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2980
void LIR_Assembler::atomic_op(LIR_Code code, LIR_Opr src, LIR_Opr data, LIR_Opr dest, LIR_Opr tmp) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2981
  const Register Rptr = src->as_pointer_register(),
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2982
                 Rtmp = tmp->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2983
  Register Rco = noreg;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2984
  if (UseCompressedOops && data->is_oop()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2985
    Rco = __ encode_heap_oop(Rtmp, data->as_register());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2986
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2987
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2988
  Label Lretry;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2989
  __ bind(Lretry);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2990
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2991
  if (data->type() == T_INT) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2992
    const Register Rold = dest->as_register(),
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2993
                   Rsrc = data->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2994
    assert_different_registers(Rptr, Rtmp, Rold, Rsrc);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2995
    __ lwarx(Rold, Rptr, MacroAssembler::cmpxchgx_hint_atomic_update());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2996
    if (code == lir_xadd) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2997
      __ add(Rtmp, Rsrc, Rold);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2998
      __ stwcx_(Rtmp, Rptr);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  2999
    } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3000
      __ stwcx_(Rsrc, Rptr);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3001
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3002
  } else if (data->is_oop()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3003
    assert(code == lir_xchg, "xadd for oops");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3004
    const Register Rold = dest->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3005
    if (UseCompressedOops) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3006
      assert_different_registers(Rptr, Rold, Rco);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3007
      __ lwarx(Rold, Rptr, MacroAssembler::cmpxchgx_hint_atomic_update());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3008
      __ stwcx_(Rco, Rptr);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3009
    } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3010
      const Register Robj = data->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3011
      assert_different_registers(Rptr, Rold, Robj);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3012
      __ ldarx(Rold, Rptr, MacroAssembler::cmpxchgx_hint_atomic_update());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3013
      __ stdcx_(Robj, Rptr);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3014
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3015
  } else if (data->type() == T_LONG) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3016
    const Register Rold = dest->as_register_lo(),
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3017
                   Rsrc = data->as_register_lo();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3018
    assert_different_registers(Rptr, Rtmp, Rold, Rsrc);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3019
    __ ldarx(Rold, Rptr, MacroAssembler::cmpxchgx_hint_atomic_update());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3020
    if (code == lir_xadd) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3021
      __ add(Rtmp, Rsrc, Rold);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3022
      __ stdcx_(Rtmp, Rptr);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3023
    } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3024
      __ stdcx_(Rsrc, Rptr);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3025
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3026
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3027
    ShouldNotReachHere();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3028
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3029
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3030
  if (UseStaticBranchPredictionInCompareAndSwapPPC64) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3031
    __ bne_predict_not_taken(CCR0, Lretry);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3032
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3033
    __ bne(                  CCR0, Lretry);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3034
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3035
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3036
  if (UseCompressedOops && data->is_oop()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3037
    __ decode_heap_oop(dest->as_register());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3038
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3039
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3040
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3041
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3042
void LIR_Assembler::emit_profile_type(LIR_OpProfileType* op) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3043
  Register obj = op->obj()->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3044
  Register tmp = op->tmp()->as_pointer_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3045
  LIR_Address* mdo_addr = op->mdp()->as_address_ptr();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3046
  ciKlass* exact_klass = op->exact_klass();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3047
  intptr_t current_klass = op->current_klass();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3048
  bool not_null = op->not_null();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3049
  bool no_conflict = op->no_conflict();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3050
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3051
  Label Lupdate, Ldo_update, Ldone;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3052
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3053
  bool do_null = !not_null;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3054
  bool exact_klass_set = exact_klass != NULL && ciTypeEntries::valid_ciklass(current_klass) == exact_klass;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3055
  bool do_update = !TypeEntries::is_type_unknown(current_klass) && !exact_klass_set;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3056
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3057
  assert(do_null || do_update, "why are we here?");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3058
  assert(!TypeEntries::was_null_seen(current_klass) || do_update, "why are we here?");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3059
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3060
  __ verify_oop(obj);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3061
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3062
  if (do_null) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3063
    if (!TypeEntries::was_null_seen(current_klass)) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3064
      __ cmpdi(CCR0, obj, 0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3065
      __ bne(CCR0, Lupdate);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3066
      __ ld(R0, index_or_disp(mdo_addr), mdo_addr->base()->as_pointer_register());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3067
      __ ori(R0, R0, TypeEntries::null_seen);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3068
      if (do_update) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3069
        __ b(Ldo_update);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3070
      } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3071
        __ std(R0, index_or_disp(mdo_addr), mdo_addr->base()->as_pointer_register());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3072
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3073
    } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3074
      if (do_update) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3075
        __ cmpdi(CCR0, obj, 0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3076
        __ beq(CCR0, Ldone);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3077
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3078
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3079
#ifdef ASSERT
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3080
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3081
    __ cmpdi(CCR0, obj, 0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3082
    __ bne(CCR0, Lupdate);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3083
    __ stop("unexpect null obj", 0x9652);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3084
#endif
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3085
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3086
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3087
  __ bind(Lupdate);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3088
  if (do_update) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3089
    Label Lnext;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3090
    const Register klass = R29_TOC; // kill and reload
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3091
    bool klass_reg_used = false;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3092
#ifdef ASSERT
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3093
    if (exact_klass != NULL) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3094
      Label ok;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3095
      klass_reg_used = true;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3096
      __ load_klass(klass, obj);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3097
      metadata2reg(exact_klass->constant_encoding(), R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3098
      __ cmpd(CCR0, klass, R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3099
      __ beq(CCR0, ok);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3100
      __ stop("exact klass and actual klass differ", 0x8564);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3101
      __ bind(ok);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3102
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3103
#endif
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3104
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3105
    if (!no_conflict) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3106
      if (exact_klass == NULL || TypeEntries::is_type_none(current_klass)) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3107
        klass_reg_used = true;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3108
        if (exact_klass != NULL) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3109
          __ ld(tmp, index_or_disp(mdo_addr), mdo_addr->base()->as_pointer_register());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3110
          metadata2reg(exact_klass->constant_encoding(), klass);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3111
        } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3112
          __ load_klass(klass, obj);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3113
          __ ld(tmp, index_or_disp(mdo_addr), mdo_addr->base()->as_pointer_register()); // may kill obj
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3114
        }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3115
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3116
        // Like InterpreterMacroAssembler::profile_obj_type
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3117
        __ clrrdi(R0, tmp, exact_log2(-TypeEntries::type_klass_mask));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3118
        // Basically same as andi(R0, tmp, TypeEntries::type_klass_mask);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3119
        __ cmpd(CCR1, R0, klass);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3120
        // Klass seen before, nothing to do (regardless of unknown bit).
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3121
        //beq(CCR1, do_nothing);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3122
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3123
        __ andi_(R0, klass, TypeEntries::type_unknown);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3124
        // Already unknown. Nothing to do anymore.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3125
        //bne(CCR0, do_nothing);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3126
        __ crorc(CCR0, Assembler::equal, CCR1, Assembler::equal); // cr0 eq = cr1 eq or cr0 ne
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3127
        __ beq(CCR0, Lnext);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3128
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3129
        if (TypeEntries::is_type_none(current_klass)) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3130
          __ clrrdi_(R0, tmp, exact_log2(-TypeEntries::type_mask));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3131
          __ orr(R0, klass, tmp); // Combine klass and null_seen bit (only used if (tmp & type_mask)==0).
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3132
          __ beq(CCR0, Ldo_update); // First time here. Set profile type.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3133
        }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3134
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3135
      } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3136
        assert(ciTypeEntries::valid_ciklass(current_klass) != NULL &&
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3137
               ciTypeEntries::valid_ciklass(current_klass) != exact_klass, "conflict only");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3138
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3139
        __ ld(tmp, index_or_disp(mdo_addr), mdo_addr->base()->as_pointer_register());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3140
        __ andi_(R0, tmp, TypeEntries::type_unknown);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3141
        // Already unknown. Nothing to do anymore.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3142
        __ bne(CCR0, Lnext);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3143
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3144
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3145
      // Different than before. Cannot keep accurate profile.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3146
      __ ori(R0, tmp, TypeEntries::type_unknown);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3147
    } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3148
      // There's a single possible klass at this profile point
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3149
      assert(exact_klass != NULL, "should be");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3150
      __ ld(tmp, index_or_disp(mdo_addr), mdo_addr->base()->as_pointer_register());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3151
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3152
      if (TypeEntries::is_type_none(current_klass)) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3153
        klass_reg_used = true;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3154
        metadata2reg(exact_klass->constant_encoding(), klass);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3155
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3156
        __ clrrdi(R0, tmp, exact_log2(-TypeEntries::type_klass_mask));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3157
        // Basically same as andi(R0, tmp, TypeEntries::type_klass_mask);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3158
        __ cmpd(CCR1, R0, klass);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3159
        // Klass seen before, nothing to do (regardless of unknown bit).
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3160
        __ beq(CCR1, Lnext);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3161
#ifdef ASSERT
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3162
        {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3163
          Label ok;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3164
          __ clrrdi_(R0, tmp, exact_log2(-TypeEntries::type_mask));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3165
          __ beq(CCR0, ok); // First time here.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3166
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3167
          __ stop("unexpected profiling mismatch", 0x7865);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3168
          __ bind(ok);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3169
        }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3170
#endif
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3171
        // First time here. Set profile type.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3172
        __ orr(R0, klass, tmp); // Combine klass and null_seen bit (only used if (tmp & type_mask)==0).
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3173
      } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3174
        assert(ciTypeEntries::valid_ciklass(current_klass) != NULL &&
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3175
               ciTypeEntries::valid_ciklass(current_klass) != exact_klass, "inconsistent");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3176
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3177
        // Already unknown. Nothing to do anymore.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3178
        __ andi_(R0, tmp, TypeEntries::type_unknown);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3179
        __ bne(CCR0, Lnext);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3180
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3181
        // Different than before. Cannot keep accurate profile.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3182
        __ ori(R0, tmp, TypeEntries::type_unknown);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3183
      }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3184
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3185
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3186
    __ bind(Ldo_update);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3187
    __ std(R0, index_or_disp(mdo_addr), mdo_addr->base()->as_pointer_register());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3188
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3189
    __ bind(Lnext);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3190
    if (klass_reg_used) { __ load_const_optimized(R29_TOC, MacroAssembler::global_toc(), R0); } // reinit
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3191
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3192
  __ bind(Ldone);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3193
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3194
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3195
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3196
void LIR_Assembler::emit_updatecrc32(LIR_OpUpdateCRC32* op) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3197
  assert(op->crc()->is_single_cpu(), "crc must be register");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3198
  assert(op->val()->is_single_cpu(), "byte value must be register");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3199
  assert(op->result_opr()->is_single_cpu(), "result must be register");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3200
  Register crc = op->crc()->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3201
  Register val = op->val()->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3202
  Register res = op->result_opr()->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3203
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3204
  assert_different_registers(val, crc, res);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3205
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3206
  __ load_const_optimized(res, StubRoutines::crc_table_addr(), R0);
46317
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 42884
diff changeset
  3207
  __ kernel_crc32_singleByteReg(crc, val, res, true);
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 42884
diff changeset
  3208
  __ mr(res, crc);
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3209
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3210
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
  3211
#undef __