1525 if (ConstantsALot) {
1526 const int num_consts = const_size();
1527 for (int i = 0; i < num_consts; i++) {
1528 __ long_constant(0xB0B5B00BBABE);
1529 }
1530 }
1531 #endif
1532 if (!method_is_frameless) {
1533 // Save return pc.
1534 __ std(return_pc, _abi0(lr), callers_sp);
1535 }
1536
1537 if (C->stub_function() == nullptr) {
1538 BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
1539 bs->nmethod_entry_barrier(masm, push_frame_temp);
1540 }
1541
1542 C->output()->set_frame_complete(__ offset());
1543 }
1544
1545 uint MachPrologNode::size(PhaseRegAlloc *ra_) const {
1546 // Variable size. determine dynamically.
1547 return MachNode::size(ra_);
1548 }
1549
1550 int MachPrologNode::reloc() const {
1551 // Return number of relocatable values contained in this instruction.
1552 return 1; // 1 reloc entry for load_const(toc).
1553 }
1554
1555 //=============================================================================
1556
1557 #ifndef PRODUCT
1558 void MachEpilogNode::format(PhaseRegAlloc *ra_, outputStream *st) const {
1559 Compile* C = ra_->C;
1560
1561 st->print("EPILOG\n\t");
1562 st->print("restore return pc\n\t");
1563 st->print("pop frame\n\t");
1564
1565 if (do_polling() && C->is_method_compilation()) {
1566 st->print("safepoint poll\n\t");
1567 }
1568 }
1569 #endif
1588 __ addi(R1_SP, R1_SP, (int)framesize);
1589 }
1590
1591 if (StackReservedPages > 0 && C->has_reserved_stack_access()) {
1592 __ reserved_stack_check(return_pc);
1593 }
1594
1595 if (method_needs_polling) {
1596 Label dummy_label;
1597 Label* code_stub = &dummy_label;
1598 if (!UseSIGTRAP && !C->output()->in_scratch_emit_size()) {
1599 C2SafepointPollStub* stub = new (C->comp_arena()) C2SafepointPollStub(__ offset());
1600 C->output()->add_stub(stub);
1601 code_stub = &stub->entry();
1602 __ relocate(relocInfo::poll_return_type);
1603 }
1604 __ safepoint_poll(*code_stub, temp, true /* at_return */, true /* in_nmethod */);
1605 }
1606 }
1607
1608 uint MachEpilogNode::size(PhaseRegAlloc *ra_) const {
1609 // Variable size. Determine dynamically.
1610 return MachNode::size(ra_);
1611 }
1612
1613 int MachEpilogNode::reloc() const {
1614 // Return number of relocatable values contained in this instruction.
1615 return 1; // 1 for load_from_polling_page.
1616 }
1617
1618 const Pipeline * MachEpilogNode::pipeline() const {
1619 return MachNode::pipeline_class();
1620 }
1621
1622 // =============================================================================
1623
1624 // Figure out which register class each belongs in: rc_int, rc_float, rc_vec or
1625 // rc_stack.
1626 enum RC { rc_bad, rc_int, rc_float, rc_vec, rc_stack };
1627
1628 static enum RC rc_class(OptoReg::Name reg) {
1629 // Return the register class for the given register. The given register
1630 // reg is a <register>_num value, which is an index into the MachRegisterNumbers
1631 // enumeration in adGlobals_ppc.hpp.
1632
1942 st->print("ADDI %s, SP, %d \t// box node", reg_str, offset);
1943 }
1944 #endif
1945
1946 void BoxLockNode::emit(C2_MacroAssembler *masm, PhaseRegAlloc *ra_) const {
1947 int offset = ra_->reg2offset(in_RegMask(0).find_first_elem());
1948 int reg = ra_->get_encode(this);
1949
1950 if (Assembler::is_simm(offset, 16)) {
1951 __ addi(as_Register(reg), R1, offset);
1952 } else {
1953 ShouldNotReachHere();
1954 }
1955 }
1956
1957 uint BoxLockNode::size(PhaseRegAlloc *ra_) const {
1958 // BoxLockNode is not a MachNode, so we can't just call MachNode::size(ra_).
1959 return 4;
1960 }
1961
1962 #ifndef PRODUCT
1963 void MachUEPNode::format(PhaseRegAlloc *ra_, outputStream *st) const {
1964 st->print_cr("---- MachUEPNode ----");
1965 st->print_cr("...");
1966 }
1967 #endif
1968
1969 void MachUEPNode::emit(C2_MacroAssembler *masm, PhaseRegAlloc *ra_) const {
1970 // This is the unverified entry point.
1971 __ ic_check(CodeEntryAlignment);
1972 // Argument is valid and klass is as expected, continue.
1973 }
1974
1975 uint MachUEPNode::size(PhaseRegAlloc *ra_) const {
1976 // Variable size. Determine dynamically.
1977 return MachNode::size(ra_);
1978 }
1979
1980 //=============================================================================
1981
1982 %} // interrupt source
1983
1984 source_hpp %{ // Header information of the source block.
1985
1986 class HandlerImpl {
1987
1988 public:
1989
1990 static int emit_deopt_handler(C2_MacroAssembler* masm);
1991
1992 static uint size_deopt_handler() {
1993 // The deopt_handler is a bl64_patchable.
1994 return MacroAssembler::bl64_patchable_size + BytesPerInstWord;
1995 }
1996
1997 };
1998
1999 class Node::PD {
9606 format %{ "MR $dst, $src \t// Long->Ptr" %}
9607 // variable size, 0 or 4.
9608 ins_encode %{
9609 __ mr_if_needed($dst$$Register, $src$$Register);
9610 %}
9611 ins_pipe(pipe_class_default);
9612 %}
9613
9614 // Cast Pointer to Long for unsafe natives.
9615 instruct castP2X(iRegLdst dst, iRegP_N2P src) %{
9616 match(Set dst (CastP2X src));
9617
9618 format %{ "MR $dst, $src \t// Ptr->Long" %}
9619 // variable size, 0 or 4.
9620 ins_encode %{
9621 __ mr_if_needed($dst$$Register, $src$$Register);
9622 %}
9623 ins_pipe(pipe_class_default);
9624 %}
9625
9626 instruct castPP(iRegPdst dst) %{
9627 match(Set dst (CastPP dst));
9628 format %{ " -- \t// castPP of $dst" %}
9629 size(0);
9630 ins_encode( /*empty*/ );
9631 ins_pipe(pipe_class_default);
9632 %}
9633
9634 instruct castII(iRegIdst dst) %{
9635 match(Set dst (CastII dst));
9636 format %{ " -- \t// castII of $dst" %}
9637 size(0);
9638 ins_encode( /*empty*/ );
9639 ins_pipe(pipe_class_default);
9640 %}
9641
9642 instruct castLL(iRegLdst dst) %{
9643 match(Set dst (CastLL dst));
9644 format %{ " -- \t// castLL of $dst" %}
9645 size(0);
11122 size(4);
11123 ins_encode %{
11124 __ clrrdi($dst$$Register, $src$$Register, log2i_exact(-(julong)$mask$$constant));
11125 %}
11126 ins_pipe(pipe_class_default);
11127 %}
11128
11129 // Array size computation.
11130 instruct array_size(iRegLdst dst, iRegPsrc end, iRegPsrc start) %{
11131 match(Set dst (SubL (CastP2X end) (CastP2X start)));
11132
11133 format %{ "SUB $dst, $end, $start \t// array size in bytes" %}
11134 size(4);
11135 ins_encode %{
11136 __ subf($dst$$Register, $start$$Register, $end$$Register);
11137 %}
11138 ins_pipe(pipe_class_default);
11139 %}
11140
11141 // Clear-array with constant short array length. The versions below can use dcbz with cnt > 30.
11142 instruct inlineCallClearArrayShort(immLmax30 cnt, rarg2RegP base, Universe dummy, regCTR ctr) %{
11143 match(Set dummy (ClearArray cnt base));
11144 effect(USE_KILL base, KILL ctr);
11145 ins_cost(2 * MEMORY_REF_COST);
11146
11147 format %{ "ClearArray $cnt, $base" %}
11148 ins_encode %{
11149 __ clear_memory_constlen($base$$Register, $cnt$$constant, R0); // kills base, R0
11150 %}
11151 ins_pipe(pipe_class_default);
11152 %}
11153
11154 // Clear-array with constant large array length.
11155 instruct inlineCallClearArrayLarge(immL cnt, rarg2RegP base, Universe dummy, iRegLdst tmp, regCTR ctr) %{
11156 match(Set dummy (ClearArray cnt base));
11157 effect(USE_KILL base, TEMP tmp, KILL ctr);
11158 ins_cost(3 * MEMORY_REF_COST);
11159
11160 format %{ "ClearArray $cnt, $base \t// KILL $tmp" %}
11161 ins_encode %{
11162 __ clear_memory_doubleword($base$$Register, $tmp$$Register, R0, $cnt$$constant); // kills base, R0
11163 %}
11164 ins_pipe(pipe_class_default);
11165 %}
11166
11167 // Clear-array with dynamic array length.
11168 instruct inlineCallClearArray(rarg1RegL cnt, rarg2RegP base, Universe dummy, regCTR ctr) %{
11169 match(Set dummy (ClearArray cnt base));
11170 effect(USE_KILL cnt, USE_KILL base, KILL ctr);
11171 ins_cost(4 * MEMORY_REF_COST);
11172
11173 format %{ "ClearArray $cnt, $base" %}
11174 ins_encode %{
11175 __ clear_memory_doubleword($base$$Register, $cnt$$Register, R0); // kills cnt, base, R0
11176 %}
11177 ins_pipe(pipe_class_default);
11178 %}
11179
11180 instruct string_compareL(rarg1RegP str1, rarg2RegP str2, rarg3RegI cnt1, rarg4RegI cnt2, iRegIdst result,
11181 iRegIdst tmp, regCTR ctr, flagsRegCR0 cr0) %{
11182 predicate(((StrCompNode*)n)->encoding() == StrIntrinsicNode::LL);
11183 match(Set result (StrComp (Binary str1 cnt1) (Binary str2 cnt2)));
11184 effect(TEMP_DEF result, USE_KILL str1, USE_KILL str2, USE_KILL cnt1, USE_KILL cnt2, KILL ctr, KILL cr0, TEMP tmp);
11185 ins_cost(300);
11186 format %{ "String Compare byte[] $str1,$cnt1,$str2,$cnt2 -> $result \t// KILL $tmp" %}
11187 ins_encode %{
11188 __ string_compare($str1$$Register, $str2$$Register,
11189 $cnt1$$Register, $cnt2$$Register,
11190 $tmp$$Register,
11191 $result$$Register, StrIntrinsicNode::LL);
11192 %}
11193 ins_pipe(pipe_class_default);
11194 %}
11195
11196 instruct string_compareU(rarg1RegP str1, rarg2RegP str2, rarg3RegI cnt1, rarg4RegI cnt2, iRegIdst result,
11197 iRegIdst tmp, regCTR ctr, flagsRegCR0 cr0) %{
11198 predicate(((StrCompNode*)n)->encoding() == StrIntrinsicNode::UU);
11199 match(Set result (StrComp (Binary str1 cnt1) (Binary str2 cnt2)));
|
1525 if (ConstantsALot) {
1526 const int num_consts = const_size();
1527 for (int i = 0; i < num_consts; i++) {
1528 __ long_constant(0xB0B5B00BBABE);
1529 }
1530 }
1531 #endif
1532 if (!method_is_frameless) {
1533 // Save return pc.
1534 __ std(return_pc, _abi0(lr), callers_sp);
1535 }
1536
1537 if (C->stub_function() == nullptr) {
1538 BarrierSetAssembler* bs = BarrierSet::barrier_set()->barrier_set_assembler();
1539 bs->nmethod_entry_barrier(masm, push_frame_temp);
1540 }
1541
1542 C->output()->set_frame_complete(__ offset());
1543 }
1544
1545 int MachPrologNode::reloc() const {
1546 // Return number of relocatable values contained in this instruction.
1547 return 1; // 1 reloc entry for load_const(toc).
1548 }
1549
1550 //=============================================================================
1551
1552 #ifndef PRODUCT
1553 void MachEpilogNode::format(PhaseRegAlloc *ra_, outputStream *st) const {
1554 Compile* C = ra_->C;
1555
1556 st->print("EPILOG\n\t");
1557 st->print("restore return pc\n\t");
1558 st->print("pop frame\n\t");
1559
1560 if (do_polling() && C->is_method_compilation()) {
1561 st->print("safepoint poll\n\t");
1562 }
1563 }
1564 #endif
1583 __ addi(R1_SP, R1_SP, (int)framesize);
1584 }
1585
1586 if (StackReservedPages > 0 && C->has_reserved_stack_access()) {
1587 __ reserved_stack_check(return_pc);
1588 }
1589
1590 if (method_needs_polling) {
1591 Label dummy_label;
1592 Label* code_stub = &dummy_label;
1593 if (!UseSIGTRAP && !C->output()->in_scratch_emit_size()) {
1594 C2SafepointPollStub* stub = new (C->comp_arena()) C2SafepointPollStub(__ offset());
1595 C->output()->add_stub(stub);
1596 code_stub = &stub->entry();
1597 __ relocate(relocInfo::poll_return_type);
1598 }
1599 __ safepoint_poll(*code_stub, temp, true /* at_return */, true /* in_nmethod */);
1600 }
1601 }
1602
1603 int MachEpilogNode::reloc() const {
1604 // Return number of relocatable values contained in this instruction.
1605 return 1; // 1 for load_from_polling_page.
1606 }
1607
1608 const Pipeline * MachEpilogNode::pipeline() const {
1609 return MachNode::pipeline_class();
1610 }
1611
1612 // =============================================================================
1613
1614 // Figure out which register class each belongs in: rc_int, rc_float, rc_vec or
1615 // rc_stack.
1616 enum RC { rc_bad, rc_int, rc_float, rc_vec, rc_stack };
1617
1618 static enum RC rc_class(OptoReg::Name reg) {
1619 // Return the register class for the given register. The given register
1620 // reg is a <register>_num value, which is an index into the MachRegisterNumbers
1621 // enumeration in adGlobals_ppc.hpp.
1622
1932 st->print("ADDI %s, SP, %d \t// box node", reg_str, offset);
1933 }
1934 #endif
1935
1936 void BoxLockNode::emit(C2_MacroAssembler *masm, PhaseRegAlloc *ra_) const {
1937 int offset = ra_->reg2offset(in_RegMask(0).find_first_elem());
1938 int reg = ra_->get_encode(this);
1939
1940 if (Assembler::is_simm(offset, 16)) {
1941 __ addi(as_Register(reg), R1, offset);
1942 } else {
1943 ShouldNotReachHere();
1944 }
1945 }
1946
1947 uint BoxLockNode::size(PhaseRegAlloc *ra_) const {
1948 // BoxLockNode is not a MachNode, so we can't just call MachNode::size(ra_).
1949 return 4;
1950 }
1951
1952 #ifndef PRODUCT
1953 void MachVEPNode::format(PhaseRegAlloc* ra_, outputStream* st) const
1954 {
1955 Unimplemented();
1956 }
1957 #endif
1958
1959 void MachVEPNode::emit(C2_MacroAssembler *masm, PhaseRegAlloc* ra_) const
1960 {
1961 Unimplemented();
1962 }
1963
1964 #ifndef PRODUCT
1965 void MachUEPNode::format(PhaseRegAlloc *ra_, outputStream *st) const {
1966 st->print_cr("---- MachUEPNode ----");
1967 st->print_cr("...");
1968 }
1969 #endif
1970
1971 void MachUEPNode::emit(C2_MacroAssembler *masm, PhaseRegAlloc *ra_) const {
1972 // This is the unverified entry point.
1973 __ ic_check(CodeEntryAlignment);
1974 // Argument is valid and klass is as expected, continue.
1975 }
1976
1977 //=============================================================================
1978
1979 %} // interrupt source
1980
1981 source_hpp %{ // Header information of the source block.
1982
1983 class HandlerImpl {
1984
1985 public:
1986
1987 static int emit_deopt_handler(C2_MacroAssembler* masm);
1988
1989 static uint size_deopt_handler() {
1990 // The deopt_handler is a bl64_patchable.
1991 return MacroAssembler::bl64_patchable_size + BytesPerInstWord;
1992 }
1993
1994 };
1995
1996 class Node::PD {
9603 format %{ "MR $dst, $src \t// Long->Ptr" %}
9604 // variable size, 0 or 4.
9605 ins_encode %{
9606 __ mr_if_needed($dst$$Register, $src$$Register);
9607 %}
9608 ins_pipe(pipe_class_default);
9609 %}
9610
9611 // Cast Pointer to Long for unsafe natives.
9612 instruct castP2X(iRegLdst dst, iRegP_N2P src) %{
9613 match(Set dst (CastP2X src));
9614
9615 format %{ "MR $dst, $src \t// Ptr->Long" %}
9616 // variable size, 0 or 4.
9617 ins_encode %{
9618 __ mr_if_needed($dst$$Register, $src$$Register);
9619 %}
9620 ins_pipe(pipe_class_default);
9621 %}
9622
9623 instruct castN2X(iRegLdst dst, iRegNsrc src) %{
9624 match(Set dst (CastP2X src));
9625
9626 format %{ "MR $dst, $src \t// Ptr->Long" %}
9627 // variable size, 0 or 4.
9628 ins_encode %{
9629 __ mr_if_needed($dst$$Register, $src$$Register);
9630 %}
9631 ins_pipe(pipe_class_default);
9632 %}
9633
9634 instruct castPP(iRegPdst dst) %{
9635 match(Set dst (CastPP dst));
9636 format %{ " -- \t// castPP of $dst" %}
9637 size(0);
9638 ins_encode( /*empty*/ );
9639 ins_pipe(pipe_class_default);
9640 %}
9641
9642 instruct castII(iRegIdst dst) %{
9643 match(Set dst (CastII dst));
9644 format %{ " -- \t// castII of $dst" %}
9645 size(0);
9646 ins_encode( /*empty*/ );
9647 ins_pipe(pipe_class_default);
9648 %}
9649
9650 instruct castLL(iRegLdst dst) %{
9651 match(Set dst (CastLL dst));
9652 format %{ " -- \t// castLL of $dst" %}
9653 size(0);
11130 size(4);
11131 ins_encode %{
11132 __ clrrdi($dst$$Register, $src$$Register, log2i_exact(-(julong)$mask$$constant));
11133 %}
11134 ins_pipe(pipe_class_default);
11135 %}
11136
11137 // Array size computation.
11138 instruct array_size(iRegLdst dst, iRegPsrc end, iRegPsrc start) %{
11139 match(Set dst (SubL (CastP2X end) (CastP2X start)));
11140
11141 format %{ "SUB $dst, $end, $start \t// array size in bytes" %}
11142 size(4);
11143 ins_encode %{
11144 __ subf($dst$$Register, $start$$Register, $end$$Register);
11145 %}
11146 ins_pipe(pipe_class_default);
11147 %}
11148
11149 // Clear-array with constant short array length. The versions below can use dcbz with cnt > 30.
11150 instruct inlineCallClearArrayShort(immLmax30 cnt, rarg2RegP base, immL_0 zero, Universe dummy, regCTR ctr) %{
11151 match(Set dummy (ClearArray (Binary cnt base) zero));
11152 effect(USE_KILL base, KILL ctr);
11153 ins_cost(2 * MEMORY_REF_COST);
11154
11155 format %{ "ClearArray $cnt, $base" %}
11156 ins_encode %{
11157 __ clear_memory_constlen($base$$Register, $cnt$$constant, R0); // kills base, R0
11158 %}
11159 ins_pipe(pipe_class_default);
11160 %}
11161
11162 // Clear-array with constant large array length.
11163 instruct inlineCallClearArrayLarge(immL cnt, rarg2RegP base, immL_0 zero, Universe dummy, iRegLdst tmp, regCTR ctr) %{
11164 match(Set dummy (ClearArray (Binary cnt base) zero));
11165 effect(USE_KILL base, TEMP tmp, KILL ctr);
11166 ins_cost(3 * MEMORY_REF_COST);
11167
11168 format %{ "ClearArray $cnt, $base \t// KILL $tmp" %}
11169 ins_encode %{
11170 __ clear_memory_doubleword($base$$Register, $tmp$$Register, R0, $cnt$$constant); // kills base, R0
11171 %}
11172 ins_pipe(pipe_class_default);
11173 %}
11174
11175 // Clear-array with dynamic array length.
11176 instruct inlineCallClearArray(rarg1RegL cnt, rarg2RegP base, immL_0 zero, Universe dummy, regCTR ctr) %{
11177 match(Set dummy (ClearArray (Binary cnt base) zero));
11178 effect(USE_KILL cnt, USE_KILL base, KILL ctr);
11179 ins_cost(4 * MEMORY_REF_COST);
11180
11181 format %{ "ClearArray $cnt, $base" %}
11182 ins_encode %{
11183 __ clear_memory_doubleword($base$$Register, $cnt$$Register, R0); // kills cnt, base, R0
11184 %}
11185 ins_pipe(pipe_class_default);
11186 %}
11187
11188 // Clear-array with dynamic array length and non-zero value.
11189 instruct inlineCallClearArrayWordCopy(rarg1RegL cnt, rarg2RegP base, iRegLdst val, Universe dummy, regCTR ctr) %{
11190 predicate(((ClearArrayNode*)n)->word_copy_only());
11191 match(Set dummy (ClearArray (Binary cnt base) val));
11192 effect(USE_KILL base, KILL ctr);
11193 ins_cost(8 * MEMORY_REF_COST);
11194
11195 format %{ "ClearArray $cnt, $base, $val" %}
11196 ins_encode %{
11197 __ fill_words($base$$Register, $cnt$$Register, $val$$Register);
11198 %}
11199 ins_pipe(pipe_class_default);
11200 %}
11201
11202 instruct string_compareL(rarg1RegP str1, rarg2RegP str2, rarg3RegI cnt1, rarg4RegI cnt2, iRegIdst result,
11203 iRegIdst tmp, regCTR ctr, flagsRegCR0 cr0) %{
11204 predicate(((StrCompNode*)n)->encoding() == StrIntrinsicNode::LL);
11205 match(Set result (StrComp (Binary str1 cnt1) (Binary str2 cnt2)));
11206 effect(TEMP_DEF result, USE_KILL str1, USE_KILL str2, USE_KILL cnt1, USE_KILL cnt2, KILL ctr, KILL cr0, TEMP tmp);
11207 ins_cost(300);
11208 format %{ "String Compare byte[] $str1,$cnt1,$str2,$cnt2 -> $result \t// KILL $tmp" %}
11209 ins_encode %{
11210 __ string_compare($str1$$Register, $str2$$Register,
11211 $cnt1$$Register, $cnt2$$Register,
11212 $tmp$$Register,
11213 $result$$Register, StrIntrinsicNode::LL);
11214 %}
11215 ins_pipe(pipe_class_default);
11216 %}
11217
11218 instruct string_compareU(rarg1RegP str1, rarg2RegP str2, rarg3RegI cnt1, rarg4RegI cnt2, iRegIdst result,
11219 iRegIdst tmp, regCTR ctr, flagsRegCR0 cr0) %{
11220 predicate(((StrCompNode*)n)->encoding() == StrIntrinsicNode::UU);
11221 match(Set result (StrComp (Binary str1 cnt1) (Binary str2 cnt2)));
|