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 {
9516 format %{ "MR $dst, $src \t// Long->Ptr" %}
9517 // variable size, 0 or 4.
9518 ins_encode %{
9519 __ mr_if_needed($dst$$Register, $src$$Register);
9520 %}
9521 ins_pipe(pipe_class_default);
9522 %}
9523
9524 // Cast Pointer to Long for unsafe natives.
9525 instruct castP2X(iRegLdst dst, iRegP_N2P src) %{
9526 match(Set dst (CastP2X src));
9527
9528 format %{ "MR $dst, $src \t// Ptr->Long" %}
9529 // variable size, 0 or 4.
9530 ins_encode %{
9531 __ mr_if_needed($dst$$Register, $src$$Register);
9532 %}
9533 ins_pipe(pipe_class_default);
9534 %}
9535
9536 instruct castPP(iRegPdst dst) %{
9537 match(Set dst (CastPP dst));
9538 format %{ " -- \t// castPP of $dst" %}
9539 size(0);
9540 ins_encode( /*empty*/ );
9541 ins_pipe(pipe_class_default);
9542 %}
9543
9544 instruct castII(iRegIdst dst) %{
9545 match(Set dst (CastII dst));
9546 format %{ " -- \t// castII of $dst" %}
9547 size(0);
9548 ins_encode( /*empty*/ );
9549 ins_pipe(pipe_class_default);
9550 %}
9551
9552 instruct castLL(iRegLdst dst) %{
9553 match(Set dst (CastLL dst));
9554 format %{ " -- \t// castLL of $dst" %}
9555 size(0);
11032 size(4);
11033 ins_encode %{
11034 __ clrrdi($dst$$Register, $src$$Register, log2i_exact(-(julong)$mask$$constant));
11035 %}
11036 ins_pipe(pipe_class_default);
11037 %}
11038
11039 // Array size computation.
11040 instruct array_size(iRegLdst dst, iRegPsrc end, iRegPsrc start) %{
11041 match(Set dst (SubL (CastP2X end) (CastP2X start)));
11042
11043 format %{ "SUB $dst, $end, $start \t// array size in bytes" %}
11044 size(4);
11045 ins_encode %{
11046 __ subf($dst$$Register, $start$$Register, $end$$Register);
11047 %}
11048 ins_pipe(pipe_class_default);
11049 %}
11050
11051 // Clear-array with constant short array length. The versions below can use dcbz with cnt > 30.
11052 instruct inlineCallClearArrayShort(immLmax30 cnt, rarg2RegP base, Universe dummy, regCTR ctr) %{
11053 match(Set dummy (ClearArray cnt base));
11054 effect(USE_KILL base, KILL ctr);
11055 ins_cost(2 * MEMORY_REF_COST);
11056
11057 format %{ "ClearArray $cnt, $base" %}
11058 ins_encode %{
11059 __ clear_memory_constlen($base$$Register, $cnt$$constant, R0); // kills base, R0
11060 %}
11061 ins_pipe(pipe_class_default);
11062 %}
11063
11064 // Clear-array with constant large array length.
11065 instruct inlineCallClearArrayLarge(immL cnt, rarg2RegP base, Universe dummy, iRegLdst tmp, regCTR ctr) %{
11066 match(Set dummy (ClearArray cnt base));
11067 effect(USE_KILL base, TEMP tmp, KILL ctr);
11068 ins_cost(3 * MEMORY_REF_COST);
11069
11070 format %{ "ClearArray $cnt, $base \t// KILL $tmp" %}
11071 ins_encode %{
11072 __ clear_memory_doubleword($base$$Register, $tmp$$Register, R0, $cnt$$constant); // kills base, R0
11073 %}
11074 ins_pipe(pipe_class_default);
11075 %}
11076
11077 // Clear-array with dynamic array length.
11078 instruct inlineCallClearArray(rarg1RegL cnt, rarg2RegP base, Universe dummy, regCTR ctr) %{
11079 match(Set dummy (ClearArray cnt base));
11080 effect(USE_KILL cnt, USE_KILL base, KILL ctr);
11081 ins_cost(4 * MEMORY_REF_COST);
11082
11083 format %{ "ClearArray $cnt, $base" %}
11084 ins_encode %{
11085 __ clear_memory_doubleword($base$$Register, $cnt$$Register, R0); // kills cnt, base, R0
11086 %}
11087 ins_pipe(pipe_class_default);
11088 %}
11089
11090 instruct string_compareL(rarg1RegP str1, rarg2RegP str2, rarg3RegI cnt1, rarg4RegI cnt2, iRegIdst result,
11091 iRegIdst tmp, regCTR ctr, flagsRegCR0 cr0) %{
11092 predicate(((StrCompNode*)n)->encoding() == StrIntrinsicNode::LL);
11093 match(Set result (StrComp (Binary str1 cnt1) (Binary str2 cnt2)));
11094 effect(TEMP_DEF result, USE_KILL str1, USE_KILL str2, USE_KILL cnt1, USE_KILL cnt2, KILL ctr, KILL cr0, TEMP tmp);
11095 ins_cost(300);
11096 format %{ "String Compare byte[] $str1,$cnt1,$str2,$cnt2 -> $result \t// KILL $tmp" %}
11097 ins_encode %{
11098 __ string_compare($str1$$Register, $str2$$Register,
11099 $cnt1$$Register, $cnt2$$Register,
11100 $tmp$$Register,
11101 $result$$Register, StrIntrinsicNode::LL);
11102 %}
11103 ins_pipe(pipe_class_default);
11104 %}
11105
11106 instruct string_compareU(rarg1RegP str1, rarg2RegP str2, rarg3RegI cnt1, rarg4RegI cnt2, iRegIdst result,
11107 iRegIdst tmp, regCTR ctr, flagsRegCR0 cr0) %{
11108 predicate(((StrCompNode*)n)->encoding() == StrIntrinsicNode::UU);
11109 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 {
9513 format %{ "MR $dst, $src \t// Long->Ptr" %}
9514 // variable size, 0 or 4.
9515 ins_encode %{
9516 __ mr_if_needed($dst$$Register, $src$$Register);
9517 %}
9518 ins_pipe(pipe_class_default);
9519 %}
9520
9521 // Cast Pointer to Long for unsafe natives.
9522 instruct castP2X(iRegLdst dst, iRegP_N2P src) %{
9523 match(Set dst (CastP2X src));
9524
9525 format %{ "MR $dst, $src \t// Ptr->Long" %}
9526 // variable size, 0 or 4.
9527 ins_encode %{
9528 __ mr_if_needed($dst$$Register, $src$$Register);
9529 %}
9530 ins_pipe(pipe_class_default);
9531 %}
9532
9533 instruct castN2X(iRegLdst dst, iRegNsrc src) %{
9534 match(Set dst (CastP2X src));
9535
9536 format %{ "MR $dst, $src \t// Ptr->Long" %}
9537 // variable size, 0 or 4.
9538 ins_encode %{
9539 __ mr_if_needed($dst$$Register, $src$$Register);
9540 %}
9541 ins_pipe(pipe_class_default);
9542 %}
9543
9544 instruct castPP(iRegPdst dst) %{
9545 match(Set dst (CastPP dst));
9546 format %{ " -- \t// castPP of $dst" %}
9547 size(0);
9548 ins_encode( /*empty*/ );
9549 ins_pipe(pipe_class_default);
9550 %}
9551
9552 instruct castII(iRegIdst dst) %{
9553 match(Set dst (CastII dst));
9554 format %{ " -- \t// castII of $dst" %}
9555 size(0);
9556 ins_encode( /*empty*/ );
9557 ins_pipe(pipe_class_default);
9558 %}
9559
9560 instruct castLL(iRegLdst dst) %{
9561 match(Set dst (CastLL dst));
9562 format %{ " -- \t// castLL of $dst" %}
9563 size(0);
11040 size(4);
11041 ins_encode %{
11042 __ clrrdi($dst$$Register, $src$$Register, log2i_exact(-(julong)$mask$$constant));
11043 %}
11044 ins_pipe(pipe_class_default);
11045 %}
11046
11047 // Array size computation.
11048 instruct array_size(iRegLdst dst, iRegPsrc end, iRegPsrc start) %{
11049 match(Set dst (SubL (CastP2X end) (CastP2X start)));
11050
11051 format %{ "SUB $dst, $end, $start \t// array size in bytes" %}
11052 size(4);
11053 ins_encode %{
11054 __ subf($dst$$Register, $start$$Register, $end$$Register);
11055 %}
11056 ins_pipe(pipe_class_default);
11057 %}
11058
11059 // Clear-array with constant short array length. The versions below can use dcbz with cnt > 30.
11060 instruct inlineCallClearArrayShort(immLmax30 cnt, rarg2RegP base, immL_0 zero, Universe dummy, regCTR ctr) %{
11061 match(Set dummy (ClearArray (Binary cnt base) zero));
11062 effect(USE_KILL base, KILL ctr);
11063 ins_cost(2 * MEMORY_REF_COST);
11064
11065 format %{ "ClearArray $cnt, $base" %}
11066 ins_encode %{
11067 __ clear_memory_constlen($base$$Register, $cnt$$constant, R0); // kills base, R0
11068 %}
11069 ins_pipe(pipe_class_default);
11070 %}
11071
11072 // Clear-array with constant large array length.
11073 instruct inlineCallClearArrayLarge(immL cnt, rarg2RegP base, immL_0 zero, Universe dummy, iRegLdst tmp, regCTR ctr) %{
11074 match(Set dummy (ClearArray (Binary cnt base) zero));
11075 effect(USE_KILL base, TEMP tmp, KILL ctr);
11076 ins_cost(3 * MEMORY_REF_COST);
11077
11078 format %{ "ClearArray $cnt, $base \t// KILL $tmp" %}
11079 ins_encode %{
11080 __ clear_memory_doubleword($base$$Register, $tmp$$Register, R0, $cnt$$constant); // kills base, R0
11081 %}
11082 ins_pipe(pipe_class_default);
11083 %}
11084
11085 // Clear-array with dynamic array length.
11086 instruct inlineCallClearArray(rarg1RegL cnt, rarg2RegP base, immL_0 zero, Universe dummy, regCTR ctr) %{
11087 match(Set dummy (ClearArray (Binary cnt base) zero));
11088 effect(USE_KILL cnt, USE_KILL base, KILL ctr);
11089 ins_cost(4 * MEMORY_REF_COST);
11090
11091 format %{ "ClearArray $cnt, $base" %}
11092 ins_encode %{
11093 __ clear_memory_doubleword($base$$Register, $cnt$$Register, R0); // kills cnt, base, R0
11094 %}
11095 ins_pipe(pipe_class_default);
11096 %}
11097
11098 // Clear-array with dynamic array length and non-zero value.
11099 instruct inlineCallClearArrayWordCopy(rarg1RegL cnt, rarg2RegP base, iRegLdst val, Universe dummy, regCTR ctr) %{
11100 predicate(((ClearArrayNode*)n)->word_copy_only());
11101 match(Set dummy (ClearArray (Binary cnt base) val));
11102 effect(USE_KILL base, KILL ctr);
11103 ins_cost(8 * MEMORY_REF_COST);
11104
11105 format %{ "ClearArray $cnt, $base, $val" %}
11106 ins_encode %{
11107 __ fill_words($base$$Register, $cnt$$Register, $val$$Register);
11108 %}
11109 ins_pipe(pipe_class_default);
11110 %}
11111
11112 instruct string_compareL(rarg1RegP str1, rarg2RegP str2, rarg3RegI cnt1, rarg4RegI cnt2, iRegIdst result,
11113 iRegIdst tmp, regCTR ctr, flagsRegCR0 cr0) %{
11114 predicate(((StrCompNode*)n)->encoding() == StrIntrinsicNode::LL);
11115 match(Set result (StrComp (Binary str1 cnt1) (Binary str2 cnt2)));
11116 effect(TEMP_DEF result, USE_KILL str1, USE_KILL str2, USE_KILL cnt1, USE_KILL cnt2, KILL ctr, KILL cr0, TEMP tmp);
11117 ins_cost(300);
11118 format %{ "String Compare byte[] $str1,$cnt1,$str2,$cnt2 -> $result \t// KILL $tmp" %}
11119 ins_encode %{
11120 __ string_compare($str1$$Register, $str2$$Register,
11121 $cnt1$$Register, $cnt2$$Register,
11122 $tmp$$Register,
11123 $result$$Register, StrIntrinsicNode::LL);
11124 %}
11125 ins_pipe(pipe_class_default);
11126 %}
11127
11128 instruct string_compareU(rarg1RegP str1, rarg2RegP str2, rarg3RegI cnt1, rarg4RegI cnt2, iRegIdst result,
11129 iRegIdst tmp, regCTR ctr, flagsRegCR0 cr0) %{
11130 predicate(((StrCompNode*)n)->encoding() == StrIntrinsicNode::UU);
11131 match(Set result (StrComp (Binary str1 cnt1) (Binary str2 cnt2)));
|