src/hotspot/cpu/s390/s390.ad
changeset 54960 e46fe26d7f77
parent 54780 f8d182aedc92
child 55343 03d417fd7d9a
child 58678 9cf78a70fa4f
equal deleted inserted replaced
54959:00425a850a2f 54960:e46fe26d7f77
     1 //
     1 //
     2 // Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
     2 // Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
     3 // Copyright (c) 2017, SAP SE. All rights reserved.
     3 // Copyright (c) 2017, 2019 SAP SE. All rights reserved.
     4 // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4 // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5 //
     5 //
     6 // This code is free software; you can redistribute it and/or modify it
     6 // This code is free software; you can redistribute it and/or modify it
     7 // under the terms of the GNU General Public License version 2 only, as
     7 // under the terms of the GNU General Public License version 2 only, as
     8 // published by the Free Software Foundation.
     8 // published by the Free Software Foundation.
  1386     // ic_miss_stub to find the proper method.
  1386     // ic_miss_stub to find the proper method.
  1387     __ load_const_optimized(R1_ic_miss_stub_addr, icmiss);
  1387     __ load_const_optimized(R1_ic_miss_stub_addr, icmiss);
  1388     __ z_br(R1_ic_miss_stub_addr);
  1388     __ z_br(R1_ic_miss_stub_addr);
  1389     __ bind(valid);
  1389     __ bind(valid);
  1390   }
  1390   }
  1391 
       
  1392 }
  1391 }
  1393 
  1392 
  1394 uint MachUEPNode::size(PhaseRegAlloc *ra_) const {
  1393 uint MachUEPNode::size(PhaseRegAlloc *ra_) const {
  1395   // Determine size dynamically.
  1394   // Determine size dynamically.
  1396   return MachNode::size(ra_);
  1395   return MachNode::size(ra_);
  4316 
  4315 
  4317 instruct loadConI(iRegI dst, immI src) %{
  4316 instruct loadConI(iRegI dst, immI src) %{
  4318   match(Set dst src);
  4317   match(Set dst src);
  4319   ins_cost(DEFAULT_COST);
  4318   ins_cost(DEFAULT_COST);
  4320   size(6);
  4319   size(6);
  4321   format %{ "LGFI     $dst,$src\t # (int)" %}
  4320   format %{ "LGFI    $dst,$src\t # (int)" %}
  4322   ins_encode %{ __ z_lgfi($dst$$Register, $src$$constant); %}  // Sign-extend to 64 bit, it's at no cost.
  4321   ins_encode %{ __ z_lgfi($dst$$Register, $src$$constant); %}  // Sign-extend to 64 bit, it's at no cost.
  4323   ins_pipe(pipe_class_dummy);
  4322   ins_pipe(pipe_class_dummy);
  4324 %}
  4323 %}
  4325 
  4324 
  4326 instruct loadConI16(iRegI dst, immI16 src) %{
  4325 instruct loadConI16(iRegI dst, immI16 src) %{
  4327   match(Set dst src);
  4326   match(Set dst src);
  4328   ins_cost(DEFAULT_COST_LOW);
  4327   ins_cost(DEFAULT_COST_LOW);
  4329   size(4);
  4328   size(4);
  4330   format %{ "LGHI     $dst,$src\t # (int)" %}
  4329   format %{ "LGHI    $dst,$src\t # (int)" %}
  4331   ins_encode %{ __ z_lghi($dst$$Register, $src$$constant); %}  // Sign-extend to 64 bit, it's at no cost.
  4330   ins_encode %{ __ z_lghi($dst$$Register, $src$$constant); %}  // Sign-extend to 64 bit, it's at no cost.
  4332   ins_pipe(pipe_class_dummy);
  4331   ins_pipe(pipe_class_dummy);
  4333 %}
  4332 %}
  4334 
  4333 
  4335 instruct loadConI_0(iRegI dst, immI_0 src, flagsReg cr) %{
  4334 instruct loadConI_0(iRegI dst, immI_0 src, flagsReg cr) %{
  4721 // Load narrow oop
  4720 // Load narrow oop
  4722 instruct loadN(iRegN dst, memory mem) %{
  4721 instruct loadN(iRegN dst, memory mem) %{
  4723   match(Set dst (LoadN mem));
  4722   match(Set dst (LoadN mem));
  4724   ins_cost(MEMORY_REF_COST);
  4723   ins_cost(MEMORY_REF_COST);
  4725   size(Z_DISP3_SIZE);
  4724   size(Z_DISP3_SIZE);
  4726   format %{ "LoadN  $dst,$mem\t# (cOop)" %}
  4725   format %{ "LoadN   $dst,$mem\t # (cOop)" %}
  4727   opcode(LLGF_ZOPC, LLGF_ZOPC);
  4726   opcode(LLGF_ZOPC, LLGF_ZOPC);
  4728   ins_encode(z_form_rt_mem_opt(dst, mem));
  4727   ins_encode(z_form_rt_mem_opt(dst, mem));
  4729   ins_pipe(pipe_class_dummy);
  4728   ins_pipe(pipe_class_dummy);
  4730 %}
  4729 %}
  4731 
  4730 
  4732 // Load narrow Klass Pointer
  4731 // Load narrow Klass Pointer
  4733 instruct loadNKlass(iRegN dst, memory mem) %{
  4732 instruct loadNKlass(iRegN dst, memory mem) %{
  4734   match(Set dst (LoadNKlass mem));
  4733   match(Set dst (LoadNKlass mem));
  4735   ins_cost(MEMORY_REF_COST);
  4734   ins_cost(MEMORY_REF_COST);
  4736   size(Z_DISP3_SIZE);
  4735   size(Z_DISP3_SIZE);
  4737   format %{ "LoadNKlass $dst,$mem\t# (klass cOop)" %}
  4736   format %{ "LoadNKlass $dst,$mem\t # (klass cOop)" %}
  4738   opcode(LLGF_ZOPC, LLGF_ZOPC);
  4737   opcode(LLGF_ZOPC, LLGF_ZOPC);
  4739   ins_encode(z_form_rt_mem_opt(dst, mem));
  4738   ins_encode(z_form_rt_mem_opt(dst, mem));
  4740   ins_pipe(pipe_class_dummy);
  4739   ins_pipe(pipe_class_dummy);
  4741 %}
  4740 %}
  4742 
  4741 
  4785 instruct decodeLoadN(iRegP dst, memory mem) %{
  4784 instruct decodeLoadN(iRegP dst, memory mem) %{
  4786   match(Set dst (DecodeN (LoadN mem)));
  4785   match(Set dst (DecodeN (LoadN mem)));
  4787   predicate(false && (CompressedOops::base()==NULL)&&(CompressedOops::shift()==0));
  4786   predicate(false && (CompressedOops::base()==NULL)&&(CompressedOops::shift()==0));
  4788   ins_cost(MEMORY_REF_COST);
  4787   ins_cost(MEMORY_REF_COST);
  4789   size(Z_DISP3_SIZE);
  4788   size(Z_DISP3_SIZE);
  4790   format %{ "DecodeLoadN  $dst,$mem\t# (cOop Load+Decode)" %}
  4789   format %{ "DecodeLoadN  $dst,$mem\t # (cOop Load+Decode)" %}
  4791   opcode(LLGF_ZOPC, LLGF_ZOPC);
  4790   opcode(LLGF_ZOPC, LLGF_ZOPC);
  4792   ins_encode(z_form_rt_mem_opt(dst, mem));
  4791   ins_encode(z_form_rt_mem_opt(dst, mem));
  4793   ins_pipe(pipe_class_dummy);
  4792   ins_pipe(pipe_class_dummy);
  4794 %}
  4793 %}
  4795 
  4794 
  4796 instruct decodeLoadNKlass(iRegP dst, memory mem) %{
  4795 instruct decodeLoadNKlass(iRegP dst, memory mem) %{
  4797   match(Set dst (DecodeNKlass (LoadNKlass mem)));
  4796   match(Set dst (DecodeNKlass (LoadNKlass mem)));
  4798   predicate(false && (CompressedKlassPointers::base()==NULL)&&(CompressedKlassPointers::shift()==0));
  4797   predicate(false && (CompressedKlassPointers::base()==NULL)&&(CompressedKlassPointers::shift()==0));
  4799   ins_cost(MEMORY_REF_COST);
  4798   ins_cost(MEMORY_REF_COST);
  4800   size(Z_DISP3_SIZE);
  4799   size(Z_DISP3_SIZE);
  4801   format %{ "DecodeLoadNKlass  $dst,$mem\t# (load/decode NKlass)" %}
  4800   format %{ "DecodeLoadNKlass  $dst,$mem\t # (load/decode NKlass)" %}
  4802   opcode(LLGF_ZOPC, LLGF_ZOPC);
  4801   opcode(LLGF_ZOPC, LLGF_ZOPC);
  4803   ins_encode(z_form_rt_mem_opt(dst, mem));
  4802   ins_encode(z_form_rt_mem_opt(dst, mem));
  4804   ins_pipe(pipe_class_dummy);
  4803   ins_pipe(pipe_class_dummy);
  4805 %}
  4804 %}
  4806 
  4805 
  4824   match(Set dst (DecodeN src));
  4823   match(Set dst (DecodeN src));
  4825   effect(KILL cr);
  4824   effect(KILL cr);
  4826   predicate(CompressedOops::base() == NULL || !ExpandLoadingBaseDecode);
  4825   predicate(CompressedOops::base() == NULL || !ExpandLoadingBaseDecode);
  4827   ins_cost(MEMORY_REF_COST+3 * DEFAULT_COST + BRANCH_COST);
  4826   ins_cost(MEMORY_REF_COST+3 * DEFAULT_COST + BRANCH_COST);
  4828   // TODO: s390 port size(VARIABLE_SIZE);
  4827   // TODO: s390 port size(VARIABLE_SIZE);
  4829   format %{ "decodeN  $dst,$src\t# (decode cOop)" %}
  4828   format %{ "decodeN  $dst,$src\t # (decode cOop)" %}
  4830   ins_encode %{  __ oop_decoder($dst$$Register, $src$$Register, true); %}
  4829   ins_encode %{  __ oop_decoder($dst$$Register, $src$$Register, true); %}
  4831   ins_pipe(pipe_class_dummy);
  4830   ins_pipe(pipe_class_dummy);
  4832 %}
  4831 %}
  4833 
  4832 
  4834 // General Klass decoder
  4833 // General Klass decoder
  4848   predicate((n->bottom_type()->make_ptr()->ptr() == TypePtr::NotNull ||
  4847   predicate((n->bottom_type()->make_ptr()->ptr() == TypePtr::NotNull ||
  4849              n->bottom_type()->is_oopptr()->ptr() == TypePtr::Constant) &&
  4848              n->bottom_type()->is_oopptr()->ptr() == TypePtr::Constant) &&
  4850             (CompressedOops::base()== NULL || !ExpandLoadingBaseDecode_NN));
  4849             (CompressedOops::base()== NULL || !ExpandLoadingBaseDecode_NN));
  4851   ins_cost(MEMORY_REF_COST+2 * DEFAULT_COST);
  4850   ins_cost(MEMORY_REF_COST+2 * DEFAULT_COST);
  4852   // TODO: s390 port size(VARIABLE_SIZE);
  4851   // TODO: s390 port size(VARIABLE_SIZE);
  4853   format %{ "decodeN  $dst,$src\t# (decode cOop NN)" %}
  4852   format %{ "decodeN  $dst,$src\t # (decode cOop NN)" %}
  4854   ins_encode %{ __ oop_decoder($dst$$Register, $src$$Register, false); %}
  4853   ins_encode %{ __ oop_decoder($dst$$Register, $src$$Register, false); %}
  4855   ins_pipe(pipe_class_dummy);
  4854   ins_pipe(pipe_class_dummy);
  4856 %}
  4855 %}
  4857 
  4856 
  4858   instruct loadBase(iRegL dst, immL baseImm) %{
  4857   instruct loadBase(iRegL dst, immL baseImm) %{
  4871     // generate wrong code. Oop_decoder generates additional lgr when
  4870     // generate wrong code. Oop_decoder generates additional lgr when
  4872     // dst==base.
  4871     // dst==base.
  4873     effect(KILL cr);
  4872     effect(KILL cr);
  4874     predicate(false);
  4873     predicate(false);
  4875     // TODO: s390 port size(VARIABLE_SIZE);
  4874     // TODO: s390 port size(VARIABLE_SIZE);
  4876     format %{ "decodeN  $dst = ($src == 0) ? NULL : ($src << 3) + $base + pow2_offset\t# (decode cOop)" %}
  4875     format %{ "decodeN  $dst = ($src == 0) ? NULL : ($src << 3) + $base + pow2_offset\t # (decode cOop)" %}
  4877     ins_encode %{
  4876     ins_encode %{
  4878       __ oop_decoder($dst$$Register, $src$$Register, true, $base$$Register,
  4877       __ oop_decoder($dst$$Register, $src$$Register, true, $base$$Register,
  4879                      (jlong)MacroAssembler::get_oop_base_pow2_offset((uint64_t)(intptr_t)CompressedOops::base()));
  4878                      (jlong)MacroAssembler::get_oop_base_pow2_offset((uint64_t)(intptr_t)CompressedOops::base()));
  4880     %}
  4879     %}
  4881     ins_pipe(pipe_class_dummy);
  4880     ins_pipe(pipe_class_dummy);
  4885   instruct decodeN_NN_base(iRegP dst, iRegN src, iRegL base, flagsReg cr) %{
  4884   instruct decodeN_NN_base(iRegP dst, iRegN src, iRegL base, flagsReg cr) %{
  4886     match(Set dst (DecodeN src base));
  4885     match(Set dst (DecodeN src base));
  4887     effect(KILL cr);
  4886     effect(KILL cr);
  4888     predicate(false);
  4887     predicate(false);
  4889     // TODO: s390 port size(VARIABLE_SIZE);
  4888     // TODO: s390 port size(VARIABLE_SIZE);
  4890     format %{ "decodeN  $dst = ($src << 3) + $base + pow2_offset\t# (decode cOop)" %}
  4889     format %{ "decodeN  $dst = ($src << 3) + $base + pow2_offset\t # (decode cOop)" %}
  4891     ins_encode %{
  4890     ins_encode %{
  4892       __ oop_decoder($dst$$Register, $src$$Register, false, $base$$Register,
  4891       __ oop_decoder($dst$$Register, $src$$Register, false, $base$$Register,
  4893                      (jlong)MacroAssembler::get_oop_base_pow2_offset((uint64_t)(intptr_t)CompressedOops::base()));
  4892                      (jlong)MacroAssembler::get_oop_base_pow2_offset((uint64_t)(intptr_t)CompressedOops::base()));
  4894     %}
  4893     %}
  4895     ins_pipe(pipe_class_dummy);
  4894     ins_pipe(pipe_class_dummy);
  4935             (CompressedOops::base() == 0 ||
  4934             (CompressedOops::base() == 0 ||
  4936              CompressedOops::base_disjoint() ||
  4935              CompressedOops::base_disjoint() ||
  4937              !ExpandLoadingBaseEncode));
  4936              !ExpandLoadingBaseEncode));
  4938   ins_cost(MEMORY_REF_COST+3 * DEFAULT_COST);
  4937   ins_cost(MEMORY_REF_COST+3 * DEFAULT_COST);
  4939   // TODO: s390 port size(VARIABLE_SIZE);
  4938   // TODO: s390 port size(VARIABLE_SIZE);
  4940   format %{ "encodeP  $dst,$src\t# (encode cOop)" %}
  4939   format %{ "encodeP  $dst,$src\t # (encode cOop)" %}
  4941   ins_encode %{ __ oop_encoder($dst$$Register, $src$$Register, true, Z_R1_scratch, -1, all_outs_are_Stores(this)); %}
  4940   ins_encode %{ __ oop_encoder($dst$$Register, $src$$Register, true, Z_R1_scratch, -1, all_outs_are_Stores(this)); %}
  4942   ins_pipe(pipe_class_dummy);
  4941   ins_pipe(pipe_class_dummy);
  4943 %}
  4942 %}
  4944 
  4943 
  4945 // General class encoder
  4944 // General class encoder
  4958             (CompressedOops::base() == 0 ||
  4957             (CompressedOops::base() == 0 ||
  4959              CompressedOops::base_disjoint() ||
  4958              CompressedOops::base_disjoint() ||
  4960              !ExpandLoadingBaseEncode_NN));
  4959              !ExpandLoadingBaseEncode_NN));
  4961   ins_cost(MEMORY_REF_COST+3 * DEFAULT_COST);
  4960   ins_cost(MEMORY_REF_COST+3 * DEFAULT_COST);
  4962   // TODO: s390 port size(VARIABLE_SIZE);
  4961   // TODO: s390 port size(VARIABLE_SIZE);
  4963   format %{ "encodeP  $dst,$src\t# (encode cOop)" %}
  4962   format %{ "encodeP  $dst,$src\t # (encode cOop)" %}
  4964   ins_encode %{ __ oop_encoder($dst$$Register, $src$$Register, false, Z_R1_scratch, -1, all_outs_are_Stores(this)); %}
  4963   ins_encode %{ __ oop_encoder($dst$$Register, $src$$Register, false, Z_R1_scratch, -1, all_outs_are_Stores(this)); %}
  4965   ins_pipe(pipe_class_dummy);
  4964   ins_pipe(pipe_class_dummy);
  4966 %}
  4965 %}
  4967 
  4966 
  4968   // Encoder for heapbased mode peeling off loading the base.
  4967   // Encoder for heapbased mode peeling off loading the base.
  4970     match(Set dst (EncodeP src (Binary base dst)));
  4969     match(Set dst (EncodeP src (Binary base dst)));
  4971     effect(TEMP_DEF dst);
  4970     effect(TEMP_DEF dst);
  4972     predicate(false);
  4971     predicate(false);
  4973     ins_cost(MEMORY_REF_COST+2 * DEFAULT_COST);
  4972     ins_cost(MEMORY_REF_COST+2 * DEFAULT_COST);
  4974     // TODO: s390 port size(VARIABLE_SIZE);
  4973     // TODO: s390 port size(VARIABLE_SIZE);
  4975     format %{ "encodeP  $dst = ($src>>3) +$base + pow2_offset\t# (encode cOop)" %}
  4974     format %{ "encodeP  $dst = ($src>>3) +$base + pow2_offset\t # (encode cOop)" %}
  4976     ins_encode %{
  4975     ins_encode %{
  4977       jlong offset = -(jlong)MacroAssembler::get_oop_base_pow2_offset
  4976       jlong offset = -(jlong)MacroAssembler::get_oop_base_pow2_offset
  4978         (((uint64_t)(intptr_t)CompressedOops::base()) >> CompressedOops::shift());
  4977         (((uint64_t)(intptr_t)CompressedOops::base()) >> CompressedOops::shift());
  4979       __ oop_encoder($dst$$Register, $src$$Register, true, $base$$Register, offset);
  4978       __ oop_encoder($dst$$Register, $src$$Register, true, $base$$Register, offset);
  4980     %}
  4979     %}
  4986     match(Set dst (EncodeP src base));
  4985     match(Set dst (EncodeP src base));
  4987     effect(USE pow2_offset);
  4986     effect(USE pow2_offset);
  4988     predicate(false);
  4987     predicate(false);
  4989     ins_cost(MEMORY_REF_COST+2 * DEFAULT_COST);
  4988     ins_cost(MEMORY_REF_COST+2 * DEFAULT_COST);
  4990     // TODO: s390 port size(VARIABLE_SIZE);
  4989     // TODO: s390 port size(VARIABLE_SIZE);
  4991     format %{ "encodeP  $dst = ($src>>3) +$base + $pow2_offset\t# (encode cOop)" %}
  4990     format %{ "encodeP  $dst = ($src>>3) +$base + $pow2_offset\t # (encode cOop)" %}
  4992     ins_encode %{ __ oop_encoder($dst$$Register, $src$$Register, false, $base$$Register, $pow2_offset$$constant); %}
  4991     ins_encode %{ __ oop_encoder($dst$$Register, $src$$Register, false, $base$$Register, $pow2_offset$$constant); %}
  4993     ins_pipe(pipe_class_dummy);
  4992     ins_pipe(pipe_class_dummy);
  4994   %}
  4993   %}
  4995 
  4994 
  4996 // Encoder for heapbased mode peeling off loading the base.
  4995 // Encoder for heapbased mode peeling off loading the base.
  5039 // Store Compressed Pointer
  5038 // Store Compressed Pointer
  5040 instruct storeN(memory mem, iRegN_P2N src) %{
  5039 instruct storeN(memory mem, iRegN_P2N src) %{
  5041   match(Set mem (StoreN mem src));
  5040   match(Set mem (StoreN mem src));
  5042   ins_cost(MEMORY_REF_COST);
  5041   ins_cost(MEMORY_REF_COST);
  5043   size(Z_DISP_SIZE);
  5042   size(Z_DISP_SIZE);
  5044   format %{ "ST      $src,$mem\t# (cOop)" %}
  5043   format %{ "ST      $src,$mem\t # (cOop)" %}
  5045   opcode(STY_ZOPC, ST_ZOPC);
  5044   opcode(STY_ZOPC, ST_ZOPC);
  5046   ins_encode(z_form_rt_mem_opt(src, mem));
  5045   ins_encode(z_form_rt_mem_opt(src, mem));
  5047   ins_pipe(pipe_class_dummy);
  5046   ins_pipe(pipe_class_dummy);
  5048 %}
  5047 %}
  5049 
  5048 
  5050 // Store Compressed Klass pointer
  5049 // Store Compressed Klass pointer
  5051 instruct storeNKlass(memory mem, iRegN src) %{
  5050 instruct storeNKlass(memory mem, iRegN src) %{
  5052   match(Set mem (StoreNKlass mem src));
  5051   match(Set mem (StoreNKlass mem src));
  5053   ins_cost(MEMORY_REF_COST);
  5052   ins_cost(MEMORY_REF_COST);
  5054   size(Z_DISP_SIZE);
  5053   size(Z_DISP_SIZE);
  5055   format %{ "ST      $src,$mem\t# (cKlass)" %}
  5054   format %{ "ST      $src,$mem\t # (cKlass)" %}
  5056   opcode(STY_ZOPC, ST_ZOPC);
  5055   opcode(STY_ZOPC, ST_ZOPC);
  5057   ins_encode(z_form_rt_mem_opt(src, mem));
  5056   ins_encode(z_form_rt_mem_opt(src, mem));
  5058   ins_pipe(pipe_class_dummy);
  5057   ins_pipe(pipe_class_dummy);
  5059 %}
  5058 %}
  5060 
  5059 
  5062 
  5061 
  5063 instruct compN_iRegN(iRegN_P2N src1, iRegN_P2N src2, flagsReg cr) %{
  5062 instruct compN_iRegN(iRegN_P2N src1, iRegN_P2N src2, flagsReg cr) %{
  5064   match(Set cr (CmpN src1 src2));
  5063   match(Set cr (CmpN src1 src2));
  5065   ins_cost(DEFAULT_COST);
  5064   ins_cost(DEFAULT_COST);
  5066   size(2);
  5065   size(2);
  5067   format %{ "CLR     $src1,$src2\t# (cOop)" %}
  5066   format %{ "CLR     $src1,$src2\t # (cOop)" %}
  5068   opcode(CLR_ZOPC);
  5067   opcode(CLR_ZOPC);
  5069   ins_encode(z_rrform(src1, src2));
  5068   ins_encode(z_rrform(src1, src2));
  5070   ins_pipe(pipe_class_dummy);
  5069   ins_pipe(pipe_class_dummy);
  5071 %}
  5070 %}
  5072 
  5071 
  5073 instruct compN_iRegN_immN(iRegN_P2N src1, immN src2, flagsReg cr) %{
  5072 instruct compN_iRegN_immN(iRegN_P2N src1, immN src2, flagsReg cr) %{
  5074   match(Set cr (CmpN src1 src2));
  5073   match(Set cr (CmpN src1 src2));
  5075   ins_cost(DEFAULT_COST);
  5074   ins_cost(DEFAULT_COST);
  5076   size(6);
  5075   size(6);
  5077   format %{ "CLFI    $src1,$src2\t# (cOop) compare immediate narrow" %}
  5076   format %{ "CLFI    $src1,$src2\t # (cOop) compare immediate narrow" %}
  5078   ins_encode %{
  5077   ins_encode %{
  5079     AddressLiteral cOop = __ constant_oop_address((jobject)$src2$$constant);
  5078     AddressLiteral cOop = __ constant_oop_address((jobject)$src2$$constant);
  5080     __ relocate(cOop.rspec(), 1);
  5079     __ relocate(cOop.rspec(), 1);
  5081     __ compare_immediate_narrow_oop($src1$$Register, (narrowOop)cOop.value());
  5080     __ compare_immediate_narrow_oop($src1$$Register, (narrowOop)cOop.value());
  5082   %}
  5081   %}
  5085 
  5084 
  5086 instruct compNKlass_iRegN_immN(iRegN src1, immNKlass src2, flagsReg cr) %{
  5085 instruct compNKlass_iRegN_immN(iRegN src1, immNKlass src2, flagsReg cr) %{
  5087   match(Set cr (CmpN src1 src2));
  5086   match(Set cr (CmpN src1 src2));
  5088   ins_cost(DEFAULT_COST);
  5087   ins_cost(DEFAULT_COST);
  5089   size(6);
  5088   size(6);
  5090   format %{ "CLFI    $src1,$src2\t# (NKlass) compare immediate narrow" %}
  5089   format %{ "CLFI    $src1,$src2\t # (NKlass) compare immediate narrow" %}
  5091   ins_encode %{
  5090   ins_encode %{
  5092     AddressLiteral NKlass = __ constant_metadata_address((Metadata*)$src2$$constant);
  5091     AddressLiteral NKlass = __ constant_metadata_address((Metadata*)$src2$$constant);
  5093     __ relocate(NKlass.rspec(), 1);
  5092     __ relocate(NKlass.rspec(), 1);
  5094     __ compare_immediate_narrow_klass($src1$$Register, (Klass*)NKlass.value());
  5093     __ compare_immediate_narrow_klass($src1$$Register, (Klass*)NKlass.value());
  5095   %}
  5094   %}
  5098 
  5097 
  5099 instruct compN_iRegN_immN0(iRegN_P2N src1, immN0 src2, flagsReg cr) %{
  5098 instruct compN_iRegN_immN0(iRegN_P2N src1, immN0 src2, flagsReg cr) %{
  5100   match(Set cr (CmpN src1 src2));
  5099   match(Set cr (CmpN src1 src2));
  5101   ins_cost(DEFAULT_COST);
  5100   ins_cost(DEFAULT_COST);
  5102   size(2);
  5101   size(2);
  5103   format %{ "LTR     $src1,$src2\t# (cOop) LTR because comparing against zero" %}
  5102   format %{ "LTR     $src1,$src2\t # (cOop) LTR because comparing against zero" %}
  5104   opcode(LTR_ZOPC);
  5103   opcode(LTR_ZOPC);
  5105   ins_encode(z_rrform(src1, src1));
  5104   ins_encode(z_rrform(src1, src1));
  5106   ins_pipe(pipe_class_dummy);
  5105   ins_pipe(pipe_class_dummy);
  5107 %}
  5106 %}
  5108 
  5107 
  6793 instruct sllI_reg_reg(iRegI dst, iRegI src, iRegI nbits, flagsReg cr) %{
  6792 instruct sllI_reg_reg(iRegI dst, iRegI src, iRegI nbits, flagsReg cr) %{
  6794   match(Set dst (LShiftI src nbits));
  6793   match(Set dst (LShiftI src nbits));
  6795   effect(KILL cr); // R1 is killed, too.
  6794   effect(KILL cr); // R1 is killed, too.
  6796   ins_cost(3 * DEFAULT_COST);
  6795   ins_cost(3 * DEFAULT_COST);
  6797   size(14);
  6796   size(14);
  6798   format %{ "SLL     $dst,$src,[$nbits] & 31\t# use RISC-like SLLG also for int" %}
  6797   format %{ "SLL     $dst,$src,[$nbits] & 31\t # use RISC-like SLLG also for int" %}
  6799   ins_encode %{
  6798   ins_encode %{
  6800     __ z_lgr(Z_R1_scratch, $nbits$$Register);
  6799     __ z_lgr(Z_R1_scratch, $nbits$$Register);
  6801     __ z_nill(Z_R1_scratch, BitsPerJavaInteger-1);
  6800     __ z_nill(Z_R1_scratch, BitsPerJavaInteger-1);
  6802     __ z_sllg($dst$$Register, $src$$Register, 0, Z_R1_scratch);
  6801     __ z_sllg($dst$$Register, $src$$Register, 0, Z_R1_scratch);
  6803   %}
  6802   %}
  6807 // Register Shift Left Immediate
  6806 // Register Shift Left Immediate
  6808 // Constant shift count is masked in ideal graph already.
  6807 // Constant shift count is masked in ideal graph already.
  6809 instruct sllI_reg_imm(iRegI dst, iRegI src, immI nbits) %{
  6808 instruct sllI_reg_imm(iRegI dst, iRegI src, immI nbits) %{
  6810   match(Set dst (LShiftI src nbits));
  6809   match(Set dst (LShiftI src nbits));
  6811   size(6);
  6810   size(6);
  6812   format %{ "SLL     $dst,$src,$nbits\t# use RISC-like SLLG also for int" %}
  6811   format %{ "SLL     $dst,$src,$nbits\t # use RISC-like SLLG also for int" %}
  6813   ins_encode %{
  6812   ins_encode %{
  6814     int Nbit = $nbits$$constant;
  6813     int Nbit = $nbits$$constant;
  6815     assert((Nbit & (BitsPerJavaInteger - 1)) == Nbit, "Check shift mask in ideal graph");
  6814     assert((Nbit & (BitsPerJavaInteger - 1)) == Nbit, "Check shift mask in ideal graph");
  6816     __ z_sllg($dst$$Register, $src$$Register, Nbit & (BitsPerJavaInteger - 1), Z_R0);
  6815     __ z_sllg($dst$$Register, $src$$Register, Nbit & (BitsPerJavaInteger - 1), Z_R0);
  6817   %}
  6816   %}
  7123 %}
  7122 %}
  7124 
  7123 
  7125 instruct overflowNegI_rReg(flagsReg cr, immI_0 zero, iRegI op2) %{
  7124 instruct overflowNegI_rReg(flagsReg cr, immI_0 zero, iRegI op2) %{
  7126   match(Set cr (OverflowSubI zero op2));
  7125   match(Set cr (OverflowSubI zero op2));
  7127   effect(DEF cr, USE op2);
  7126   effect(DEF cr, USE op2);
  7128   format %{ "NEG    $op2\t# overflow check int" %}
  7127   format %{ "NEG    $op2\t # overflow check int" %}
  7129   ins_encode %{
  7128   ins_encode %{
  7130     __ clear_reg(Z_R0_scratch, false, false);
  7129     __ clear_reg(Z_R0_scratch, false, false);
  7131     __ z_sr(Z_R0_scratch, $op2$$Register);
  7130     __ z_sr(Z_R0_scratch, $op2$$Register);
  7132   %}
  7131   %}
  7133   ins_pipe(pipe_class_dummy);
  7132   ins_pipe(pipe_class_dummy);
  7134 %}
  7133 %}
  7135 
  7134 
  7136 instruct overflowNegL_rReg(flagsReg cr, immL_0 zero, iRegL op2) %{
  7135 instruct overflowNegL_rReg(flagsReg cr, immL_0 zero, iRegL op2) %{
  7137   match(Set cr (OverflowSubL zero op2));
  7136   match(Set cr (OverflowSubL zero op2));
  7138   effect(DEF cr, USE op2);
  7137   effect(DEF cr, USE op2);
  7139   format %{ "NEGG    $op2\t# overflow check long" %}
  7138   format %{ "NEGG    $op2\t # overflow check long" %}
  7140   ins_encode %{
  7139   ins_encode %{
  7141     __ clear_reg(Z_R0_scratch, true, false);
  7140     __ clear_reg(Z_R0_scratch, true, false);
  7142     __ z_sgr(Z_R0_scratch, $op2$$Register);
  7141     __ z_sgr(Z_R0_scratch, $op2$$Register);
  7143   %}
  7142   %}
  7144   ins_pipe(pipe_class_dummy);
  7143   ins_pipe(pipe_class_dummy);
  9189   // Same match rule as `branchConFar'.
  9188   // Same match rule as `branchConFar'.
  9190   match(If cmp cr);
  9189   match(If cmp cr);
  9191   effect(USE lbl);
  9190   effect(USE lbl);
  9192   ins_cost(BRANCH_COST);
  9191   ins_cost(BRANCH_COST);
  9193   size(4);
  9192   size(4);
  9194   format %{ "branch_con_short,$cmp   $cr, $lbl" %}
  9193   format %{ "branch_con_short,$cmp   $lbl" %}
  9195   ins_encode(z_enc_branch_con_short(cmp, lbl));
  9194   ins_encode(z_enc_branch_con_short(cmp, lbl));
  9196   ins_pipe(pipe_class_dummy);
  9195   ins_pipe(pipe_class_dummy);
  9197   // If set to 1 this indicates that the current instruction is a
  9196   // If set to 1 this indicates that the current instruction is a
  9198   // short variant of a long branch. This avoids using this
  9197   // short variant of a long branch. This avoids using this
  9199   // instruction in first-pass matching. It will then only be used in
  9198   // instruction in first-pass matching. It will then only be used in
  9211   match(If cmp cr);
  9210   match(If cmp cr);
  9212   effect(USE cr, USE lbl);
  9211   effect(USE cr, USE lbl);
  9213   // Make more expensive to prefer compare_and_branch over separate instructions.
  9212   // Make more expensive to prefer compare_and_branch over separate instructions.
  9214   ins_cost(2 * BRANCH_COST);
  9213   ins_cost(2 * BRANCH_COST);
  9215   size(6);
  9214   size(6);
  9216   format %{ "branch_con_far,$cmp   $cr, $lbl" %}
  9215   format %{ "branch_con_far,$cmp   $lbl" %}
  9217   ins_encode(z_enc_branch_con_far(cmp, lbl));
  9216   ins_encode(z_enc_branch_con_far(cmp, lbl));
  9218   ins_pipe(pipe_class_dummy);
  9217   ins_pipe(pipe_class_dummy);
  9219   // This is not a short variant of a branch, but the long variant..
  9218   // This is not a short variant of a branch, but the long variant..
  9220   ins_short_branch(0);
  9219   ins_short_branch(0);
  9221 %}
  9220 %}
  9780 // TailJump below removes the return address.
  9779 // TailJump below removes the return address.
  9781 instruct TailCalljmpInd(iRegP jump_target, inline_cache_regP method_oop) %{
  9780 instruct TailCalljmpInd(iRegP jump_target, inline_cache_regP method_oop) %{
  9782   match(TailCall jump_target method_oop);
  9781   match(TailCall jump_target method_oop);
  9783   ins_cost(CALL_COST);
  9782   ins_cost(CALL_COST);
  9784   size(2);
  9783   size(2);
  9785   format %{ "Jmp     $jump_target\t# $method_oop holds method oop" %}
  9784   format %{ "Jmp     $jump_target\t # $method_oop holds method oop" %}
  9786   ins_encode %{ __ z_br($jump_target$$Register); %}
  9785   ins_encode %{ __ z_br($jump_target$$Register); %}
  9787   ins_pipe(pipe_class_dummy);
  9786   ins_pipe(pipe_class_dummy);
  9788 %}
  9787 %}
  9789 
  9788 
  9790 // Return Instruction
  9789 // Return Instruction
 10788 instruct bytes_reverse_int(iRegI dst, iRegI src) %{
 10787 instruct bytes_reverse_int(iRegI dst, iRegI src) %{
 10789   match(Set dst (ReverseBytesI src));
 10788   match(Set dst (ReverseBytesI src));
 10790   predicate(UseByteReverseInstruction);  // See Matcher::match_rule_supported
 10789   predicate(UseByteReverseInstruction);  // See Matcher::match_rule_supported
 10791   ins_cost(DEFAULT_COST);
 10790   ins_cost(DEFAULT_COST);
 10792   size(4);
 10791   size(4);
 10793   format %{ "LRVR    $dst,$src\t# byte reverse int" %}
 10792   format %{ "LRVR    $dst,$src\t # byte reverse int" %}
 10794   opcode(LRVR_ZOPC);
 10793   opcode(LRVR_ZOPC);
 10795   ins_encode(z_rreform(dst, src));
 10794   ins_encode(z_rreform(dst, src));
 10796   ins_pipe(pipe_class_dummy);
 10795   ins_pipe(pipe_class_dummy);
 10797 %}
 10796 %}
 10798 
 10797 
 10799 instruct bytes_reverse_long(iRegL dst, iRegL src) %{
 10798 instruct bytes_reverse_long(iRegL dst, iRegL src) %{
 10800   match(Set dst (ReverseBytesL src));
 10799   match(Set dst (ReverseBytesL src));
 10801   predicate(UseByteReverseInstruction);  // See Matcher::match_rule_supported
 10800   predicate(UseByteReverseInstruction);  // See Matcher::match_rule_supported
 10802   ins_cost(DEFAULT_COST);
 10801   ins_cost(DEFAULT_COST);
 10803   // TODO: s390 port size(FIXED_SIZE);
 10802   // TODO: s390 port size(FIXED_SIZE);
 10804   format %{ "LRVGR   $dst,$src\t# byte reverse long" %}
 10803   format %{ "LRVGR   $dst,$src\t # byte reverse long" %}
 10805   opcode(LRVGR_ZOPC);
 10804   opcode(LRVGR_ZOPC);
 10806   ins_encode(z_rreform(dst, src));
 10805   ins_encode(z_rreform(dst, src));
 10807   ins_pipe(pipe_class_dummy);
 10806   ins_pipe(pipe_class_dummy);
 10808 %}
 10807 %}
 10809 
 10808 
 10819 instruct countLeadingZerosI(revenRegI dst, iRegI src, roddRegI tmp, flagsReg cr) %{
 10818 instruct countLeadingZerosI(revenRegI dst, iRegI src, roddRegI tmp, flagsReg cr) %{
 10820   match(Set dst (CountLeadingZerosI src));
 10819   match(Set dst (CountLeadingZerosI src));
 10821   effect(KILL tmp, KILL cr);
 10820   effect(KILL tmp, KILL cr);
 10822   ins_cost(3 * DEFAULT_COST);
 10821   ins_cost(3 * DEFAULT_COST);
 10823   size(14);
 10822   size(14);
 10824   format %{ "SLLG    $dst,$src,32\t# no need to always count 32 zeroes first\n\t"
 10823   format %{ "SLLG    $dst,$src,32\t # no need to always count 32 zeroes first\n\t"
 10825             "IILH    $dst,0x8000 \t# insert \"stop bit\" to force result 32 for zero src.\n\t"
 10824             "IILH    $dst,0x8000 \t # insert \"stop bit\" to force result 32 for zero src.\n\t"
 10826             "FLOGR   $dst,$dst"
 10825             "FLOGR   $dst,$dst"
 10827          %}
 10826          %}
 10828   ins_encode %{
 10827   ins_encode %{
 10829     // Performance experiments indicate that "FLOGR" is using some kind of
 10828     // Performance experiments indicate that "FLOGR" is using some kind of
 10830     // iteration to find the leftmost "1" bit.
 10829     // iteration to find the leftmost "1" bit.
 10857 instruct countLeadingZerosL(revenRegI dst, iRegL src, roddRegI tmp, flagsReg cr) %{
 10856 instruct countLeadingZerosL(revenRegI dst, iRegL src, roddRegI tmp, flagsReg cr) %{
 10858   match(Set dst (CountLeadingZerosL src));
 10857   match(Set dst (CountLeadingZerosL src));
 10859   effect(KILL tmp, KILL cr);
 10858   effect(KILL tmp, KILL cr);
 10860   ins_cost(DEFAULT_COST);
 10859   ins_cost(DEFAULT_COST);
 10861   size(4);
 10860   size(4);
 10862   format %{ "FLOGR   $dst,$src \t# count leading zeros (long)\n\t" %}
 10861   format %{ "FLOGR   $dst,$src \t # count leading zeros (long)\n\t" %}
 10863   ins_encode %{ __ z_flogr($dst$$Register, $src$$Register); %}
 10862   ins_encode %{ __ z_flogr($dst$$Register, $src$$Register); %}
 10864   ins_pipe(pipe_class_dummy);
 10863   ins_pipe(pipe_class_dummy);
 10865 %}
 10864 %}
 10866 
 10865 
 10867 // trailing zeroes
 10866 // trailing zeroes
 10882 instruct countTrailingZerosI(revenRegI dst, iRegI src, roddRegI tmp, flagsReg cr) %{
 10881 instruct countTrailingZerosI(revenRegI dst, iRegI src, roddRegI tmp, flagsReg cr) %{
 10883   match(Set dst (CountTrailingZerosI src));
 10882   match(Set dst (CountTrailingZerosI src));
 10884   effect(TEMP_DEF dst, TEMP tmp, KILL cr);
 10883   effect(TEMP_DEF dst, TEMP tmp, KILL cr);
 10885   ins_cost(8 * DEFAULT_COST);
 10884   ins_cost(8 * DEFAULT_COST);
 10886   // TODO: s390 port size(FIXED_SIZE);  // Emitted code depends on PreferLAoverADD being on/off.
 10885   // TODO: s390 port size(FIXED_SIZE);  // Emitted code depends on PreferLAoverADD being on/off.
 10887   format %{ "LLGFR   $dst,$src  \t# clear upper 32 bits (we are dealing with int)\n\t"
 10886   format %{ "LLGFR   $dst,$src  \t # clear upper 32 bits (we are dealing with int)\n\t"
 10888             "LCGFR   $tmp,$src  \t# load 2's complement (32->64 bit)\n\t"
 10887             "LCGFR   $tmp,$src  \t # load 2's complement (32->64 bit)\n\t"
 10889             "AGHI    $dst,-1    \t# tmp1 = src-1\n\t"
 10888             "AGHI    $dst,-1    \t # tmp1 = src-1\n\t"
 10890             "AGHI    $tmp,-1    \t# tmp2 = -src-1 = ~src\n\t"
 10889             "AGHI    $tmp,-1    \t # tmp2 = -src-1 = ~src\n\t"
 10891             "NGR     $dst,$tmp  \t# tmp3 = tmp1&tmp2\n\t"
 10890             "NGR     $dst,$tmp  \t # tmp3 = tmp1&tmp2\n\t"
 10892             "FLOGR   $dst,$dst  \t# count trailing zeros (int)\n\t"
 10891             "FLOGR   $dst,$dst  \t # count trailing zeros (int)\n\t"
 10893             "AHI     $dst,-64   \t# tmp4 = 64-(trailing zeroes)-64\n\t"
 10892             "AHI     $dst,-64   \t # tmp4 = 64-(trailing zeroes)-64\n\t"
 10894             "LCR     $dst,$dst  \t# res = -tmp4"
 10893             "LCR     $dst,$dst  \t # res = -tmp4"
 10895          %}
 10894          %}
 10896   ins_encode %{
 10895   ins_encode %{
 10897     Register Rdst = $dst$$Register;
 10896     Register Rdst = $dst$$Register;
 10898     Register Rsrc = $src$$Register;
 10897     Register Rsrc = $src$$Register;
 10899     // Rtmp only needed for for zero-argument shortcut. With kill effect in
 10898     // Rtmp only needed for for zero-argument shortcut. With kill effect in
 10935 instruct countTrailingZerosL(revenRegI dst, iRegL src, roddRegL tmp, flagsReg cr) %{
 10934 instruct countTrailingZerosL(revenRegI dst, iRegL src, roddRegL tmp, flagsReg cr) %{
 10936   match(Set dst (CountTrailingZerosL src));
 10935   match(Set dst (CountTrailingZerosL src));
 10937   effect(TEMP_DEF dst, KILL tmp, KILL cr);
 10936   effect(TEMP_DEF dst, KILL tmp, KILL cr);
 10938   ins_cost(8 * DEFAULT_COST);
 10937   ins_cost(8 * DEFAULT_COST);
 10939   // TODO: s390 port size(FIXED_SIZE);  // Emitted code depends on PreferLAoverADD being on/off.
 10938   // TODO: s390 port size(FIXED_SIZE);  // Emitted code depends on PreferLAoverADD being on/off.
 10940   format %{ "LCGR    $dst,$src  \t# preserve src\n\t"
 10939   format %{ "LCGR    $dst,$src  \t # preserve src\n\t"
 10941             "NGR     $dst,$src  \t#"
 10940             "NGR     $dst,$src  \t #\n\t"
 10942             "AGHI    $dst,-1    \t# tmp1 = src-1\n\t"
 10941             "AGHI    $dst,-1    \t # tmp1 = src-1\n\t"
 10943             "FLOGR   $dst,$dst  \t# count trailing zeros (long), kill $tmp\n\t"
 10942             "FLOGR   $dst,$dst  \t # count trailing zeros (long), kill $tmp\n\t"
 10944             "AHI     $dst,-64   \t# tmp4 = 64-(trailing zeroes)-64\n\t"
 10943             "AHI     $dst,-64   \t # tmp4 = 64-(trailing zeroes)-64\n\t"
 10945             "LCR     $dst,$dst  \t#"
 10944             "LCR     $dst,$dst  \t #"
 10946          %}
 10945          %}
 10947   ins_encode %{
 10946   ins_encode %{
 10948     Register Rdst = $dst$$Register;
 10947     Register Rdst = $dst$$Register;
 10949     Register Rsrc = $src$$Register;
 10948     Register Rsrc = $src$$Register;
 10950     assert_different_registers(Rdst, Rsrc); // Rtmp == Rsrc allowed.
 10949     assert_different_registers(Rdst, Rsrc); // Rtmp == Rsrc allowed.
 10967   match(Set dst (PopCountI src));
 10966   match(Set dst (PopCountI src));
 10968   effect(TEMP_DEF dst, TEMP tmp, KILL cr);
 10967   effect(TEMP_DEF dst, TEMP tmp, KILL cr);
 10969   predicate(UsePopCountInstruction && VM_Version::has_PopCount());
 10968   predicate(UsePopCountInstruction && VM_Version::has_PopCount());
 10970   ins_cost(DEFAULT_COST);
 10969   ins_cost(DEFAULT_COST);
 10971   size(24);
 10970   size(24);
 10972   format %{ "POPCNT  $dst,$src\t# pop count int" %}
 10971   format %{ "POPCNT  $dst,$src\t # pop count int" %}
 10973   ins_encode %{
 10972   ins_encode %{
 10974     Register Rdst = $dst$$Register;
 10973     Register Rdst = $dst$$Register;
 10975     Register Rsrc = $src$$Register;
 10974     Register Rsrc = $src$$Register;
 10976     Register Rtmp = $tmp$$Register;
 10975     Register Rtmp = $tmp$$Register;
 10977 
 10976 
 10994   match(Set dst (PopCountL src));
 10993   match(Set dst (PopCountL src));
 10995   effect(TEMP_DEF dst, TEMP tmp, KILL cr);
 10994   effect(TEMP_DEF dst, TEMP tmp, KILL cr);
 10996   predicate(UsePopCountInstruction && VM_Version::has_PopCount());
 10995   predicate(UsePopCountInstruction && VM_Version::has_PopCount());
 10997   ins_cost(DEFAULT_COST);
 10996   ins_cost(DEFAULT_COST);
 10998   // TODO: s390 port size(FIXED_SIZE);
 10997   // TODO: s390 port size(FIXED_SIZE);
 10999   format %{ "POPCNT  $dst,$src\t# pop count long" %}
 10998   format %{ "POPCNT  $dst,$src\t # pop count long" %}
 11000   ins_encode %{
 10999   ins_encode %{
 11001     Register Rdst = $dst$$Register;
 11000     Register Rdst = $dst$$Register;
 11002     Register Rsrc = $src$$Register;
 11001     Register Rsrc = $src$$Register;
 11003     Register Rtmp = $tmp$$Register;
 11002     Register Rtmp = $tmp$$Register;
 11004 
 11003