1 // 2 // Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. 3 // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 // 5 // This code is free software; you can redistribute it and/or modify it 6 // under the terms of the GNU General Public License version 2 only, as 7 // published by the Free Software Foundation. 8 // 9 // This code is distributed in the hope that it will be useful, but WITHOUT 10 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 // version 2 for more details (a copy is included in the LICENSE file that 13 // accompanied this code). 14 // 15 // You should have received a copy of the GNU General Public License version 16 // 2 along with this work; if not, write to the Free Software Foundation, 17 // Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 // 19 // Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 // or visit www.oracle.com if you need additional information or have any 21 // questions. 22 // 23 // 24 25 // AMD64 Architecture Description File 26 27 //----------REGISTER DEFINITION BLOCK------------------------------------------ 28 // This information is used by the matcher and the register allocator to 29 // describe individual registers and classes of registers within the target 30 // archtecture. 31 32 register %{ 33 //----------Architecture Description Register Definitions---------------------- 34 // General Registers 35 // "reg_def" name ( register save type, C convention save type, 36 // ideal register type, encoding ); 37 // Register Save Types: 38 // 39 // NS = No-Save: The register allocator assumes that these registers 40 // can be used without saving upon entry to the method, & 41 // that they do not need to be saved at call sites. 42 // 43 // SOC = Save-On-Call: The register allocator assumes that these registers 44 // can be used without saving upon entry to the method, 45 // but that they must be saved at call sites. 46 // 47 // SOE = Save-On-Entry: The register allocator assumes that these registers 48 // must be saved before using them upon entry to the 49 // method, but they do not need to be saved at call 50 // sites. 51 // 52 // AS = Always-Save: The register allocator assumes that these registers 53 // must be saved before using them upon entry to the 54 // method, & that they must be saved at call sites. 55 // 56 // Ideal Register Type is used to determine how to save & restore a 57 // register. Op_RegI will get spilled with LoadI/StoreI, Op_RegP will get 58 // spilled with LoadP/StoreP. If the register supports both, use Op_RegI. 59 // 60 // The encoding number is the actual bit-pattern placed into the opcodes. 61 62 // General Registers 63 // R8-R15 must be encoded with REX. (RSP, RBP, RSI, RDI need REX when 64 // used as byte registers) 65 66 // Previously set RBX, RSI, and RDI as save-on-entry for java code 67 // Turn off SOE in java-code due to frequent use of uncommon-traps. 68 // Now that allocator is better, turn on RSI and RDI as SOE registers. 69 70 reg_def RAX (SOC, SOC, Op_RegI, 0, rax->as_VMReg()); 71 reg_def RAX_H(SOC, SOC, Op_RegI, 0, rax->as_VMReg()->next()); 72 73 reg_def RCX (SOC, SOC, Op_RegI, 1, rcx->as_VMReg()); 74 reg_def RCX_H(SOC, SOC, Op_RegI, 1, rcx->as_VMReg()->next()); 75 76 reg_def RDX (SOC, SOC, Op_RegI, 2, rdx->as_VMReg()); 77 reg_def RDX_H(SOC, SOC, Op_RegI, 2, rdx->as_VMReg()->next()); 78 79 reg_def RBX (SOC, SOE, Op_RegI, 3, rbx->as_VMReg()); 80 reg_def RBX_H(SOC, SOE, Op_RegI, 3, rbx->as_VMReg()->next()); 81 82 reg_def RSP (NS, NS, Op_RegI, 4, rsp->as_VMReg()); 83 reg_def RSP_H(NS, NS, Op_RegI, 4, rsp->as_VMReg()->next()); 84 85 // now that adapter frames are gone RBP is always saved and restored by the prolog/epilog code 86 reg_def RBP (NS, SOE, Op_RegI, 5, rbp->as_VMReg()); 87 reg_def RBP_H(NS, SOE, Op_RegI, 5, rbp->as_VMReg()->next()); 88 89 #ifdef _WIN64 90 91 reg_def RSI (SOC, SOE, Op_RegI, 6, rsi->as_VMReg()); 92 reg_def RSI_H(SOC, SOE, Op_RegI, 6, rsi->as_VMReg()->next()); 93 94 reg_def RDI (SOC, SOE, Op_RegI, 7, rdi->as_VMReg()); 95 reg_def RDI_H(SOC, SOE, Op_RegI, 7, rdi->as_VMReg()->next()); 96 97 #else 98 99 reg_def RSI (SOC, SOC, Op_RegI, 6, rsi->as_VMReg()); 100 reg_def RSI_H(SOC, SOC, Op_RegI, 6, rsi->as_VMReg()->next()); 101 102 reg_def RDI (SOC, SOC, Op_RegI, 7, rdi->as_VMReg()); 103 reg_def RDI_H(SOC, SOC, Op_RegI, 7, rdi->as_VMReg()->next()); 104 105 #endif 106 107 reg_def R8 (SOC, SOC, Op_RegI, 8, r8->as_VMReg()); 108 reg_def R8_H (SOC, SOC, Op_RegI, 8, r8->as_VMReg()->next()); 109 110 reg_def R9 (SOC, SOC, Op_RegI, 9, r9->as_VMReg()); 111 reg_def R9_H (SOC, SOC, Op_RegI, 9, r9->as_VMReg()->next()); 112 113 reg_def R10 (SOC, SOC, Op_RegI, 10, r10->as_VMReg()); 114 reg_def R10_H(SOC, SOC, Op_RegI, 10, r10->as_VMReg()->next()); 115 116 reg_def R11 (SOC, SOC, Op_RegI, 11, r11->as_VMReg()); 117 reg_def R11_H(SOC, SOC, Op_RegI, 11, r11->as_VMReg()->next()); 118 119 reg_def R12 (SOC, SOE, Op_RegI, 12, r12->as_VMReg()); 120 reg_def R12_H(SOC, SOE, Op_RegI, 12, r12->as_VMReg()->next()); 121 122 reg_def R13 (SOC, SOE, Op_RegI, 13, r13->as_VMReg()); 123 reg_def R13_H(SOC, SOE, Op_RegI, 13, r13->as_VMReg()->next()); 124 125 reg_def R14 (SOC, SOE, Op_RegI, 14, r14->as_VMReg()); 126 reg_def R14_H(SOC, SOE, Op_RegI, 14, r14->as_VMReg()->next()); 127 128 reg_def R15 (SOC, SOE, Op_RegI, 15, r15->as_VMReg()); 129 reg_def R15_H(SOC, SOE, Op_RegI, 15, r15->as_VMReg()->next()); 130 131 132 // Floating Point Registers 133 134 // Specify priority of register selection within phases of register 135 // allocation. Highest priority is first. A useful heuristic is to 136 // give registers a low priority when they are required by machine 137 // instructions, like EAX and EDX on I486, and choose no-save registers 138 // before save-on-call, & save-on-call before save-on-entry. Registers 139 // which participate in fixed calling sequences should come last. 140 // Registers which are used as pairs must fall on an even boundary. 141 142 alloc_class chunk0(R10, R10_H, 143 R11, R11_H, 144 R8, R8_H, 145 R9, R9_H, 146 R12, R12_H, 147 RCX, RCX_H, 148 RBX, RBX_H, 149 RDI, RDI_H, 150 RDX, RDX_H, 151 RSI, RSI_H, 152 RAX, RAX_H, 153 RBP, RBP_H, 154 R13, R13_H, 155 R14, R14_H, 156 R15, R15_H, 157 RSP, RSP_H); 158 159 160 //----------Architecture Description Register Classes-------------------------- 161 // Several register classes are automatically defined based upon information in 162 // this architecture description. 163 // 1) reg_class inline_cache_reg ( /* as def'd in frame section */ ) 164 // 2) reg_class compiler_method_oop_reg ( /* as def'd in frame section */ ) 165 // 2) reg_class interpreter_method_oop_reg ( /* as def'd in frame section */ ) 166 // 3) reg_class stack_slots( /* one chunk of stack-based "registers" */ ) 167 // 168 169 // Empty register class. 170 reg_class no_reg(); 171 172 // Class for all pointer registers (including RSP and RBP) 173 reg_class any_reg_with_rbp(RAX, RAX_H, 174 RDX, RDX_H, 175 RBP, RBP_H, 176 RDI, RDI_H, 177 RSI, RSI_H, 178 RCX, RCX_H, 179 RBX, RBX_H, 180 RSP, RSP_H, 181 R8, R8_H, 182 R9, R9_H, 183 R10, R10_H, 184 R11, R11_H, 185 R12, R12_H, 186 R13, R13_H, 187 R14, R14_H, 188 R15, R15_H); 189 190 // Class for all pointer registers (including RSP, but excluding RBP) 191 reg_class any_reg_no_rbp(RAX, RAX_H, 192 RDX, RDX_H, 193 RDI, RDI_H, 194 RSI, RSI_H, 195 RCX, RCX_H, 196 RBX, RBX_H, 197 RSP, RSP_H, 198 R8, R8_H, 199 R9, R9_H, 200 R10, R10_H, 201 R11, R11_H, 202 R12, R12_H, 203 R13, R13_H, 204 R14, R14_H, 205 R15, R15_H); 206 207 // Dynamic register class that selects at runtime between register classes 208 // any_reg_no_rbp and any_reg_with_rbp (depending on the value of the flag PreserveFramePointer). 209 // Equivalent to: return PreserveFramePointer ? any_reg_no_rbp : any_reg_with_rbp; 210 reg_class_dynamic any_reg(any_reg_no_rbp, any_reg_with_rbp, %{ PreserveFramePointer %}); 211 212 // Class for all pointer registers (excluding RSP) 213 reg_class ptr_reg_with_rbp(RAX, RAX_H, 214 RDX, RDX_H, 215 RBP, RBP_H, 216 RDI, RDI_H, 217 RSI, RSI_H, 218 RCX, RCX_H, 219 RBX, RBX_H, 220 R8, R8_H, 221 R9, R9_H, 222 R10, R10_H, 223 R11, R11_H, 224 R13, R13_H, 225 R14, R14_H); 226 227 // Class for all pointer registers (excluding RSP and RBP) 228 reg_class ptr_reg_no_rbp(RAX, RAX_H, 229 RDX, RDX_H, 230 RDI, RDI_H, 231 RSI, RSI_H, 232 RCX, RCX_H, 233 RBX, RBX_H, 234 R8, R8_H, 235 R9, R9_H, 236 R10, R10_H, 237 R11, R11_H, 238 R13, R13_H, 239 R14, R14_H); 240 241 // Dynamic register class that selects between ptr_reg_no_rbp and ptr_reg_with_rbp. 242 reg_class_dynamic ptr_reg(ptr_reg_no_rbp, ptr_reg_with_rbp, %{ PreserveFramePointer %}); 243 244 // Class for all pointer registers (excluding RAX and RSP) 245 reg_class ptr_no_rax_reg_with_rbp(RDX, RDX_H, 246 RBP, RBP_H, 247 RDI, RDI_H, 248 RSI, RSI_H, 249 RCX, RCX_H, 250 RBX, RBX_H, 251 R8, R8_H, 252 R9, R9_H, 253 R10, R10_H, 254 R11, R11_H, 255 R13, R13_H, 256 R14, R14_H); 257 258 // Class for all pointer registers (excluding RAX, RSP, and RBP) 259 reg_class ptr_no_rax_reg_no_rbp(RDX, RDX_H, 260 RDI, RDI_H, 261 RSI, RSI_H, 262 RCX, RCX_H, 263 RBX, RBX_H, 264 R8, R8_H, 265 R9, R9_H, 266 R10, R10_H, 267 R11, R11_H, 268 R13, R13_H, 269 R14, R14_H); 270 271 // Dynamic register class that selects between ptr_no_rax_reg_no_rbp and ptr_no_rax_reg_with_rbp. 272 reg_class_dynamic ptr_no_rax_reg(ptr_no_rax_reg_no_rbp, ptr_no_rax_reg_with_rbp, %{ PreserveFramePointer %}); 273 274 // Class for all pointer registers (excluding RAX, RBX, and RSP) 275 reg_class ptr_no_rax_rbx_reg_with_rbp(RDX, RDX_H, 276 RBP, RBP_H, 277 RDI, RDI_H, 278 RSI, RSI_H, 279 RCX, RCX_H, 280 R8, R8_H, 281 R9, R9_H, 282 R10, R10_H, 283 R11, R11_H, 284 R13, R13_H, 285 R14, R14_H); 286 287 // Class for all pointer registers (excluding RAX, RBX, RSP, and RBP) 288 reg_class ptr_no_rax_rbx_reg_no_rbp(RDX, RDX_H, 289 RDI, RDI_H, 290 RSI, RSI_H, 291 RCX, RCX_H, 292 R8, R8_H, 293 R9, R9_H, 294 R10, R10_H, 295 R11, R11_H, 296 R13, R13_H, 297 R14, R14_H); 298 299 // Dynamic register class that selects between ptr_no_rax_rbx_reg_no_rbp and ptr_no_rax_rbx_reg_with_rbp. 300 reg_class_dynamic ptr_no_rax_rbx_reg(ptr_no_rax_rbx_reg_no_rbp, ptr_no_rax_rbx_reg_with_rbp, %{ PreserveFramePointer %}); 301 302 // Singleton class for RAX pointer register 303 reg_class ptr_rax_reg(RAX, RAX_H); 304 305 // Singleton class for RBX pointer register 306 reg_class ptr_rbx_reg(RBX, RBX_H); 307 308 // Singleton class for RSI pointer register 309 reg_class ptr_rsi_reg(RSI, RSI_H); 310 311 // Singleton class for RDI pointer register 312 reg_class ptr_rdi_reg(RDI, RDI_H); 313 314 // Singleton class for stack pointer 315 reg_class ptr_rsp_reg(RSP, RSP_H); 316 317 // Singleton class for TLS pointer 318 reg_class ptr_r15_reg(R15, R15_H); 319 320 // Class for all long registers (excluding RSP) 321 reg_class long_reg_with_rbp(RAX, RAX_H, 322 RDX, RDX_H, 323 RBP, RBP_H, 324 RDI, RDI_H, 325 RSI, RSI_H, 326 RCX, RCX_H, 327 RBX, RBX_H, 328 R8, R8_H, 329 R9, R9_H, 330 R10, R10_H, 331 R11, R11_H, 332 R13, R13_H, 333 R14, R14_H); 334 335 // Class for all long registers (excluding RSP and RBP) 336 reg_class long_reg_no_rbp(RAX, RAX_H, 337 RDX, RDX_H, 338 RDI, RDI_H, 339 RSI, RSI_H, 340 RCX, RCX_H, 341 RBX, RBX_H, 342 R8, R8_H, 343 R9, R9_H, 344 R10, R10_H, 345 R11, R11_H, 346 R13, R13_H, 347 R14, R14_H); 348 349 // Dynamic register class that selects between long_reg_no_rbp and long_reg_with_rbp. 350 reg_class_dynamic long_reg(long_reg_no_rbp, long_reg_with_rbp, %{ PreserveFramePointer %}); 351 352 // Class for all long registers (excluding RAX, RDX and RSP) 353 reg_class long_no_rax_rdx_reg_with_rbp(RBP, RBP_H, 354 RDI, RDI_H, 355 RSI, RSI_H, 356 RCX, RCX_H, 357 RBX, RBX_H, 358 R8, R8_H, 359 R9, R9_H, 360 R10, R10_H, 361 R11, R11_H, 362 R13, R13_H, 363 R14, R14_H); 364 365 // Class for all long registers (excluding RAX, RDX, RSP, and RBP) 366 reg_class long_no_rax_rdx_reg_no_rbp(RDI, RDI_H, 367 RSI, RSI_H, 368 RCX, RCX_H, 369 RBX, RBX_H, 370 R8, R8_H, 371 R9, R9_H, 372 R10, R10_H, 373 R11, R11_H, 374 R13, R13_H, 375 R14, R14_H); 376 377 // Dynamic register class that selects between long_no_rax_rdx_reg_no_rbp and long_no_rax_rdx_reg_with_rbp. 378 reg_class_dynamic long_no_rax_rdx_reg(long_no_rax_rdx_reg_no_rbp, long_no_rax_rdx_reg_with_rbp, %{ PreserveFramePointer %}); 379 380 // Class for all long registers (excluding RCX and RSP) 381 reg_class long_no_rcx_reg_with_rbp(RBP, RBP_H, 382 RDI, RDI_H, 383 RSI, RSI_H, 384 RAX, RAX_H, 385 RDX, RDX_H, 386 RBX, RBX_H, 387 R8, R8_H, 388 R9, R9_H, 389 R10, R10_H, 390 R11, R11_H, 391 R13, R13_H, 392 R14, R14_H); 393 394 // Class for all long registers (excluding RCX, RSP, and RBP) 395 reg_class long_no_rcx_reg_no_rbp(RDI, RDI_H, 396 RSI, RSI_H, 397 RAX, RAX_H, 398 RDX, RDX_H, 399 RBX, RBX_H, 400 R8, R8_H, 401 R9, R9_H, 402 R10, R10_H, 403 R11, R11_H, 404 R13, R13_H, 405 R14, R14_H); 406 407 // Dynamic register class that selects between long_no_rcx_reg_no_rbp and long_no_rcx_reg_with_rbp. 408 reg_class_dynamic long_no_rcx_reg(long_no_rcx_reg_no_rbp, long_no_rcx_reg_with_rbp, %{ PreserveFramePointer %}); 409 410 // Singleton class for RAX long register 411 reg_class long_rax_reg(RAX, RAX_H); 412 413 // Singleton class for RCX long register 414 reg_class long_rcx_reg(RCX, RCX_H); 415 416 // Singleton class for RDX long register 417 reg_class long_rdx_reg(RDX, RDX_H); 418 419 // Class for all int registers (excluding RSP) 420 reg_class int_reg_with_rbp(RAX, 421 RDX, 422 RBP, 423 RDI, 424 RSI, 425 RCX, 426 RBX, 427 R8, 428 R9, 429 R10, 430 R11, 431 R13, 432 R14); 433 434 // Class for all int registers (excluding RSP and RBP) 435 reg_class int_reg_no_rbp(RAX, 436 RDX, 437 RDI, 438 RSI, 439 RCX, 440 RBX, 441 R8, 442 R9, 443 R10, 444 R11, 445 R13, 446 R14); 447 448 // Dynamic register class that selects between int_reg_no_rbp and int_reg_with_rbp. 449 reg_class_dynamic int_reg(int_reg_no_rbp, int_reg_with_rbp, %{ PreserveFramePointer %}); 450 451 // Class for all int registers (excluding RCX and RSP) 452 reg_class int_no_rcx_reg_with_rbp(RAX, 453 RDX, 454 RBP, 455 RDI, 456 RSI, 457 RBX, 458 R8, 459 R9, 460 R10, 461 R11, 462 R13, 463 R14); 464 465 // Class for all int registers (excluding RCX, RSP, and RBP) 466 reg_class int_no_rcx_reg_no_rbp(RAX, 467 RDX, 468 RDI, 469 RSI, 470 RBX, 471 R8, 472 R9, 473 R10, 474 R11, 475 R13, 476 R14); 477 478 // Dynamic register class that selects between int_no_rcx_reg_no_rbp and int_no_rcx_reg_with_rbp. 479 reg_class_dynamic int_no_rcx_reg(int_no_rcx_reg_no_rbp, int_no_rcx_reg_with_rbp, %{ PreserveFramePointer %}); 480 481 // Class for all int registers (excluding RAX, RDX, and RSP) 482 reg_class int_no_rax_rdx_reg_with_rbp(RBP, 483 RDI, 484 RSI, 485 RCX, 486 RBX, 487 R8, 488 R9, 489 R10, 490 R11, 491 R13, 492 R14); 493 494 // Class for all int registers (excluding RAX, RDX, RSP, and RBP) 495 reg_class int_no_rax_rdx_reg_no_rbp(RDI, 496 RSI, 497 RCX, 498 RBX, 499 R8, 500 R9, 501 R10, 502 R11, 503 R13, 504 R14); 505 506 // Dynamic register class that selects between int_no_rax_rdx_reg_no_rbp and int_no_rax_rdx_reg_with_rbp. 507 reg_class_dynamic int_no_rax_rdx_reg(int_no_rax_rdx_reg_no_rbp, int_no_rax_rdx_reg_with_rbp, %{ PreserveFramePointer %}); 508 509 // Singleton class for RAX int register 510 reg_class int_rax_reg(RAX); 511 512 // Singleton class for RBX int register 513 reg_class int_rbx_reg(RBX); 514 515 // Singleton class for RCX int register 516 reg_class int_rcx_reg(RCX); 517 518 // Singleton class for RCX int register 519 reg_class int_rdx_reg(RDX); 520 521 // Singleton class for RCX int register 522 reg_class int_rdi_reg(RDI); 523 524 // Singleton class for instruction pointer 525 // reg_class ip_reg(RIP); 526 527 %} 528 529 //----------SOURCE BLOCK------------------------------------------------------- 530 // This is a block of C++ code which provides values, functions, and 531 // definitions necessary in the rest of the architecture description 532 source %{ 533 #define RELOC_IMM64 Assembler::imm_operand 534 #define RELOC_DISP32 Assembler::disp32_operand 535 536 #define __ _masm. 537 538 static int clear_avx_size() { 539 if(UseAVX > 2) { 540 return 0; // vzeroupper is ignored 541 } else { 542 return (Compile::current()->max_vector_size() > 16) ? 3 : 0; // vzeroupper 543 } 544 } 545 546 // !!!!! Special hack to get all types of calls to specify the byte offset 547 // from the start of the call to the point where the return address 548 // will point. 549 int MachCallStaticJavaNode::ret_addr_offset() 550 { 551 int offset = 5; // 5 bytes from start of call to where return address points 552 offset += clear_avx_size(); 553 return offset; 554 } 555 556 int MachCallDynamicJavaNode::ret_addr_offset() 557 { 558 int offset = 15; // 15 bytes from start of call to where return address points 559 offset += clear_avx_size(); 560 return offset; 561 } 562 563 int MachCallRuntimeNode::ret_addr_offset() { 564 int offset = 13; // movq r10,#addr; callq (r10) 565 offset += clear_avx_size(); 566 return offset; 567 } 568 569 // Indicate if the safepoint node needs the polling page as an input, 570 // it does if the polling page is more than disp32 away. 571 bool SafePointNode::needs_polling_address_input() 572 { 573 return Assembler::is_polling_page_far(); 574 } 575 576 // 577 // Compute padding required for nodes which need alignment 578 // 579 580 // The address of the call instruction needs to be 4-byte aligned to 581 // ensure that it does not span a cache line so that it can be patched. 582 int CallStaticJavaDirectNode::compute_padding(int current_offset) const 583 { 584 current_offset += clear_avx_size(); // skip vzeroupper 585 current_offset += 1; // skip call opcode byte 586 return round_to(current_offset, alignment_required()) - current_offset; 587 } 588 589 // The address of the call instruction needs to be 4-byte aligned to 590 // ensure that it does not span a cache line so that it can be patched. 591 int CallDynamicJavaDirectNode::compute_padding(int current_offset) const 592 { 593 current_offset += clear_avx_size(); // skip vzeroupper 594 current_offset += 11; // skip movq instruction + call opcode byte 595 return round_to(current_offset, alignment_required()) - current_offset; 596 } 597 598 // EMIT_RM() 599 void emit_rm(CodeBuffer &cbuf, int f1, int f2, int f3) { 600 unsigned char c = (unsigned char) ((f1 << 6) | (f2 << 3) | f3); 601 cbuf.insts()->emit_int8(c); 602 } 603 604 // EMIT_CC() 605 void emit_cc(CodeBuffer &cbuf, int f1, int f2) { 606 unsigned char c = (unsigned char) (f1 | f2); 607 cbuf.insts()->emit_int8(c); 608 } 609 610 // EMIT_OPCODE() 611 void emit_opcode(CodeBuffer &cbuf, int code) { 612 cbuf.insts()->emit_int8((unsigned char) code); 613 } 614 615 // EMIT_OPCODE() w/ relocation information 616 void emit_opcode(CodeBuffer &cbuf, 617 int code, relocInfo::relocType reloc, int offset, int format) 618 { 619 cbuf.relocate(cbuf.insts_mark() + offset, reloc, format); 620 emit_opcode(cbuf, code); 621 } 622 623 // EMIT_D8() 624 void emit_d8(CodeBuffer &cbuf, int d8) { 625 cbuf.insts()->emit_int8((unsigned char) d8); 626 } 627 628 // EMIT_D16() 629 void emit_d16(CodeBuffer &cbuf, int d16) { 630 cbuf.insts()->emit_int16(d16); 631 } 632 633 // EMIT_D32() 634 void emit_d32(CodeBuffer &cbuf, int d32) { 635 cbuf.insts()->emit_int32(d32); 636 } 637 638 // EMIT_D64() 639 void emit_d64(CodeBuffer &cbuf, int64_t d64) { 640 cbuf.insts()->emit_int64(d64); 641 } 642 643 // emit 32 bit value and construct relocation entry from relocInfo::relocType 644 void emit_d32_reloc(CodeBuffer& cbuf, 645 int d32, 646 relocInfo::relocType reloc, 647 int format) 648 { 649 assert(reloc != relocInfo::external_word_type, "use 2-arg emit_d32_reloc"); 650 cbuf.relocate(cbuf.insts_mark(), reloc, format); 651 cbuf.insts()->emit_int32(d32); 652 } 653 654 // emit 32 bit value and construct relocation entry from RelocationHolder 655 void emit_d32_reloc(CodeBuffer& cbuf, int d32, RelocationHolder const& rspec, int format) { 656 #ifdef ASSERT 657 if (rspec.reloc()->type() == relocInfo::oop_type && 658 d32 != 0 && d32 != (intptr_t) Universe::non_oop_word()) { 659 assert(Universe::heap()->is_in_reserved((address)(intptr_t)d32), "should be real oop"); 660 assert(cast_to_oop((intptr_t)d32)->is_oop() && (ScavengeRootsInCode || !cast_to_oop((intptr_t)d32)->is_scavengable()), "cannot embed scavengable oops in code"); 661 } 662 #endif 663 cbuf.relocate(cbuf.insts_mark(), rspec, format); 664 cbuf.insts()->emit_int32(d32); 665 } 666 667 void emit_d32_reloc(CodeBuffer& cbuf, address addr) { 668 address next_ip = cbuf.insts_end() + 4; 669 emit_d32_reloc(cbuf, (int) (addr - next_ip), 670 external_word_Relocation::spec(addr), 671 RELOC_DISP32); 672 } 673 674 675 // emit 64 bit value and construct relocation entry from relocInfo::relocType 676 void emit_d64_reloc(CodeBuffer& cbuf, int64_t d64, relocInfo::relocType reloc, int format) { 677 cbuf.relocate(cbuf.insts_mark(), reloc, format); 678 cbuf.insts()->emit_int64(d64); 679 } 680 681 // emit 64 bit value and construct relocation entry from RelocationHolder 682 void emit_d64_reloc(CodeBuffer& cbuf, int64_t d64, RelocationHolder const& rspec, int format) { 683 #ifdef ASSERT 684 if (rspec.reloc()->type() == relocInfo::oop_type && 685 d64 != 0 && d64 != (int64_t) Universe::non_oop_word()) { 686 assert(Universe::heap()->is_in_reserved((address)d64), "should be real oop"); 687 assert(cast_to_oop(d64)->is_oop() && (ScavengeRootsInCode || !cast_to_oop(d64)->is_scavengable()), 688 "cannot embed scavengable oops in code"); 689 } 690 #endif 691 cbuf.relocate(cbuf.insts_mark(), rspec, format); 692 cbuf.insts()->emit_int64(d64); 693 } 694 695 // Access stack slot for load or store 696 void store_to_stackslot(CodeBuffer &cbuf, int opcode, int rm_field, int disp) 697 { 698 emit_opcode(cbuf, opcode); // (e.g., FILD [RSP+src]) 699 if (-0x80 <= disp && disp < 0x80) { 700 emit_rm(cbuf, 0x01, rm_field, RSP_enc); // R/M byte 701 emit_rm(cbuf, 0x00, RSP_enc, RSP_enc); // SIB byte 702 emit_d8(cbuf, disp); // Displacement // R/M byte 703 } else { 704 emit_rm(cbuf, 0x02, rm_field, RSP_enc); // R/M byte 705 emit_rm(cbuf, 0x00, RSP_enc, RSP_enc); // SIB byte 706 emit_d32(cbuf, disp); // Displacement // R/M byte 707 } 708 } 709 710 // rRegI ereg, memory mem) %{ // emit_reg_mem 711 void encode_RegMem(CodeBuffer &cbuf, 712 int reg, 713 int base, int index, int scale, int disp, relocInfo::relocType disp_reloc) 714 { 715 assert(disp_reloc == relocInfo::none, "cannot have disp"); 716 int regenc = reg & 7; 717 int baseenc = base & 7; 718 int indexenc = index & 7; 719 720 // There is no index & no scale, use form without SIB byte 721 if (index == 0x4 && scale == 0 && base != RSP_enc && base != R12_enc) { 722 // If no displacement, mode is 0x0; unless base is [RBP] or [R13] 723 if (disp == 0 && base != RBP_enc && base != R13_enc) { 724 emit_rm(cbuf, 0x0, regenc, baseenc); // * 725 } else if (-0x80 <= disp && disp < 0x80 && disp_reloc == relocInfo::none) { 726 // If 8-bit displacement, mode 0x1 727 emit_rm(cbuf, 0x1, regenc, baseenc); // * 728 emit_d8(cbuf, disp); 729 } else { 730 // If 32-bit displacement 731 if (base == -1) { // Special flag for absolute address 732 emit_rm(cbuf, 0x0, regenc, 0x5); // * 733 if (disp_reloc != relocInfo::none) { 734 emit_d32_reloc(cbuf, disp, relocInfo::oop_type, RELOC_DISP32); 735 } else { 736 emit_d32(cbuf, disp); 737 } 738 } else { 739 // Normal base + offset 740 emit_rm(cbuf, 0x2, regenc, baseenc); // * 741 if (disp_reloc != relocInfo::none) { 742 emit_d32_reloc(cbuf, disp, relocInfo::oop_type, RELOC_DISP32); 743 } else { 744 emit_d32(cbuf, disp); 745 } 746 } 747 } 748 } else { 749 // Else, encode with the SIB byte 750 // If no displacement, mode is 0x0; unless base is [RBP] or [R13] 751 if (disp == 0 && base != RBP_enc && base != R13_enc) { 752 // If no displacement 753 emit_rm(cbuf, 0x0, regenc, 0x4); // * 754 emit_rm(cbuf, scale, indexenc, baseenc); 755 } else { 756 if (-0x80 <= disp && disp < 0x80 && disp_reloc == relocInfo::none) { 757 // If 8-bit displacement, mode 0x1 758 emit_rm(cbuf, 0x1, regenc, 0x4); // * 759 emit_rm(cbuf, scale, indexenc, baseenc); 760 emit_d8(cbuf, disp); 761 } else { 762 // If 32-bit displacement 763 if (base == 0x04 ) { 764 emit_rm(cbuf, 0x2, regenc, 0x4); 765 emit_rm(cbuf, scale, indexenc, 0x04); // XXX is this valid??? 766 } else { 767 emit_rm(cbuf, 0x2, regenc, 0x4); 768 emit_rm(cbuf, scale, indexenc, baseenc); // * 769 } 770 if (disp_reloc != relocInfo::none) { 771 emit_d32_reloc(cbuf, disp, relocInfo::oop_type, RELOC_DISP32); 772 } else { 773 emit_d32(cbuf, disp); 774 } 775 } 776 } 777 } 778 } 779 780 // This could be in MacroAssembler but it's fairly C2 specific 781 void emit_cmpfp_fixup(MacroAssembler& _masm) { 782 Label exit; 783 __ jccb(Assembler::noParity, exit); 784 __ pushf(); 785 // 786 // comiss/ucomiss instructions set ZF,PF,CF flags and 787 // zero OF,AF,SF for NaN values. 788 // Fixup flags by zeroing ZF,PF so that compare of NaN 789 // values returns 'less than' result (CF is set). 790 // Leave the rest of flags unchanged. 791 // 792 // 7 6 5 4 3 2 1 0 793 // |S|Z|r|A|r|P|r|C| (r - reserved bit) 794 // 0 0 1 0 1 0 1 1 (0x2B) 795 // 796 __ andq(Address(rsp, 0), 0xffffff2b); 797 __ popf(); 798 __ bind(exit); 799 } 800 801 void emit_cmpfp3(MacroAssembler& _masm, Register dst) { 802 Label done; 803 __ movl(dst, -1); 804 __ jcc(Assembler::parity, done); 805 __ jcc(Assembler::below, done); 806 __ setb(Assembler::notEqual, dst); 807 __ movzbl(dst, dst); 808 __ bind(done); 809 } 810 811 812 //============================================================================= 813 const RegMask& MachConstantBaseNode::_out_RegMask = RegMask::Empty; 814 815 int Compile::ConstantTable::calculate_table_base_offset() const { 816 return 0; // absolute addressing, no offset 817 } 818 819 bool MachConstantBaseNode::requires_postalloc_expand() const { return false; } 820 void MachConstantBaseNode::postalloc_expand(GrowableArray <Node *> *nodes, PhaseRegAlloc *ra_) { 821 ShouldNotReachHere(); 822 } 823 824 void MachConstantBaseNode::emit(CodeBuffer& cbuf, PhaseRegAlloc* ra_) const { 825 // Empty encoding 826 } 827 828 uint MachConstantBaseNode::size(PhaseRegAlloc* ra_) const { 829 return 0; 830 } 831 832 #ifndef PRODUCT 833 void MachConstantBaseNode::format(PhaseRegAlloc* ra_, outputStream* st) const { 834 st->print("# MachConstantBaseNode (empty encoding)"); 835 } 836 #endif 837 838 839 //============================================================================= 840 #ifndef PRODUCT 841 void MachPrologNode::format(PhaseRegAlloc* ra_, outputStream* st) const { 842 Compile* C = ra_->C; 843 844 int framesize = C->frame_size_in_bytes(); 845 int bangsize = C->bang_size_in_bytes(); 846 assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned"); 847 // Remove wordSize for return addr which is already pushed. 848 framesize -= wordSize; 849 850 if (C->need_stack_bang(bangsize)) { 851 framesize -= wordSize; 852 st->print("# stack bang (%d bytes)", bangsize); 853 st->print("\n\t"); 854 st->print("pushq rbp\t# Save rbp"); 855 if (PreserveFramePointer) { 856 st->print("\n\t"); 857 st->print("movq rbp, rsp\t# Save the caller's SP into rbp"); 858 } 859 if (framesize) { 860 st->print("\n\t"); 861 st->print("subq rsp, #%d\t# Create frame",framesize); 862 } 863 } else { 864 st->print("subq rsp, #%d\t# Create frame",framesize); 865 st->print("\n\t"); 866 framesize -= wordSize; 867 st->print("movq [rsp + #%d], rbp\t# Save rbp",framesize); 868 if (PreserveFramePointer) { 869 st->print("\n\t"); 870 st->print("movq rbp, [rsp + #%d]\t# Save the caller's SP into rbp", (framesize + wordSize)); 871 } 872 } 873 874 if (VerifyStackAtCalls) { 875 st->print("\n\t"); 876 framesize -= wordSize; 877 st->print("movq [rsp + #%d], 0xbadb100d\t# Majik cookie for stack depth check",framesize); 878 #ifdef ASSERT 879 st->print("\n\t"); 880 st->print("# stack alignment check"); 881 #endif 882 } 883 st->cr(); 884 } 885 #endif 886 887 void MachPrologNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const { 888 Compile* C = ra_->C; 889 MacroAssembler _masm(&cbuf); 890 891 int framesize = C->frame_size_in_bytes(); 892 int bangsize = C->bang_size_in_bytes(); 893 894 __ verified_entry(framesize, C->need_stack_bang(bangsize)?bangsize:0, false); 895 896 C->set_frame_complete(cbuf.insts_size()); 897 898 if (C->has_mach_constant_base_node()) { 899 // NOTE: We set the table base offset here because users might be 900 // emitted before MachConstantBaseNode. 901 Compile::ConstantTable& constant_table = C->constant_table(); 902 constant_table.set_table_base_offset(constant_table.calculate_table_base_offset()); 903 } 904 } 905 906 uint MachPrologNode::size(PhaseRegAlloc* ra_) const 907 { 908 return MachNode::size(ra_); // too many variables; just compute it 909 // the hard way 910 } 911 912 int MachPrologNode::reloc() const 913 { 914 return 0; // a large enough number 915 } 916 917 //============================================================================= 918 #ifndef PRODUCT 919 void MachEpilogNode::format(PhaseRegAlloc* ra_, outputStream* st) const 920 { 921 Compile* C = ra_->C; 922 if (C->max_vector_size() > 16) { 923 st->print("vzeroupper"); 924 st->cr(); st->print("\t"); 925 } 926 927 int framesize = C->frame_size_in_bytes(); 928 assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned"); 929 // Remove word for return adr already pushed 930 // and RBP 931 framesize -= 2*wordSize; 932 933 if (framesize) { 934 st->print_cr("addq rsp, %d\t# Destroy frame", framesize); 935 st->print("\t"); 936 } 937 938 st->print_cr("popq rbp"); 939 if (do_polling() && C->is_method_compilation()) { 940 st->print("\t"); 941 if (Assembler::is_polling_page_far()) { 942 st->print_cr("movq rscratch1, #polling_page_address\n\t" 943 "testl rax, [rscratch1]\t" 944 "# Safepoint: poll for GC"); 945 } else { 946 st->print_cr("testl rax, [rip + #offset_to_poll_page]\t" 947 "# Safepoint: poll for GC"); 948 } 949 } 950 } 951 #endif 952 953 void MachEpilogNode::emit(CodeBuffer& cbuf, PhaseRegAlloc* ra_) const 954 { 955 Compile* C = ra_->C; 956 if (C->max_vector_size() > 16) { 957 // Clear upper bits of YMM registers when current compiled code uses 958 // wide vectors to avoid AVX <-> SSE transition penalty during call. 959 MacroAssembler _masm(&cbuf); 960 __ vzeroupper(); 961 } 962 963 int framesize = C->frame_size_in_bytes(); 964 assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned"); 965 // Remove word for return adr already pushed 966 // and RBP 967 framesize -= 2*wordSize; 968 969 // Note that VerifyStackAtCalls' Majik cookie does not change the frame size popped here 970 971 if (framesize) { 972 emit_opcode(cbuf, Assembler::REX_W); 973 if (framesize < 0x80) { 974 emit_opcode(cbuf, 0x83); // addq rsp, #framesize 975 emit_rm(cbuf, 0x3, 0x00, RSP_enc); 976 emit_d8(cbuf, framesize); 977 } else { 978 emit_opcode(cbuf, 0x81); // addq rsp, #framesize 979 emit_rm(cbuf, 0x3, 0x00, RSP_enc); 980 emit_d32(cbuf, framesize); 981 } 982 } 983 984 // popq rbp 985 emit_opcode(cbuf, 0x58 | RBP_enc); 986 987 if (do_polling() && C->is_method_compilation()) { 988 MacroAssembler _masm(&cbuf); 989 AddressLiteral polling_page(os::get_polling_page(), relocInfo::poll_return_type); 990 if (Assembler::is_polling_page_far()) { 991 __ lea(rscratch1, polling_page); 992 __ relocate(relocInfo::poll_return_type); 993 __ testl(rax, Address(rscratch1, 0)); 994 } else { 995 __ testl(rax, polling_page); 996 } 997 } 998 } 999 1000 uint MachEpilogNode::size(PhaseRegAlloc* ra_) const 1001 { 1002 return MachNode::size(ra_); // too many variables; just compute it 1003 // the hard way 1004 } 1005 1006 int MachEpilogNode::reloc() const 1007 { 1008 return 2; // a large enough number 1009 } 1010 1011 const Pipeline* MachEpilogNode::pipeline() const 1012 { 1013 return MachNode::pipeline_class(); 1014 } 1015 1016 int MachEpilogNode::safepoint_offset() const 1017 { 1018 return 0; 1019 } 1020 1021 //============================================================================= 1022 1023 enum RC { 1024 rc_bad, 1025 rc_int, 1026 rc_float, 1027 rc_stack 1028 }; 1029 1030 static enum RC rc_class(OptoReg::Name reg) 1031 { 1032 if( !OptoReg::is_valid(reg) ) return rc_bad; 1033 1034 if (OptoReg::is_stack(reg)) return rc_stack; 1035 1036 VMReg r = OptoReg::as_VMReg(reg); 1037 1038 if (r->is_Register()) return rc_int; 1039 1040 assert(r->is_XMMRegister(), "must be"); 1041 return rc_float; 1042 } 1043 1044 // Next two methods are shared by 32- and 64-bit VM. They are defined in x86.ad. 1045 static int vec_mov_helper(CodeBuffer *cbuf, bool do_size, int src_lo, int dst_lo, 1046 int src_hi, int dst_hi, uint ireg, outputStream* st); 1047 1048 static int vec_spill_helper(CodeBuffer *cbuf, bool do_size, bool is_load, 1049 int stack_offset, int reg, uint ireg, outputStream* st); 1050 1051 static void vec_stack_to_stack_helper(CodeBuffer *cbuf, int src_offset, 1052 int dst_offset, uint ireg, outputStream* st) { 1053 if (cbuf) { 1054 MacroAssembler _masm(cbuf); 1055 switch (ireg) { 1056 case Op_VecS: 1057 __ movq(Address(rsp, -8), rax); 1058 __ movl(rax, Address(rsp, src_offset)); 1059 __ movl(Address(rsp, dst_offset), rax); 1060 __ movq(rax, Address(rsp, -8)); 1061 break; 1062 case Op_VecD: 1063 __ pushq(Address(rsp, src_offset)); 1064 __ popq (Address(rsp, dst_offset)); 1065 break; 1066 case Op_VecX: 1067 __ pushq(Address(rsp, src_offset)); 1068 __ popq (Address(rsp, dst_offset)); 1069 __ pushq(Address(rsp, src_offset+8)); 1070 __ popq (Address(rsp, dst_offset+8)); 1071 break; 1072 case Op_VecY: 1073 __ vmovdqu(Address(rsp, -32), xmm0); 1074 __ vmovdqu(xmm0, Address(rsp, src_offset)); 1075 __ vmovdqu(Address(rsp, dst_offset), xmm0); 1076 __ vmovdqu(xmm0, Address(rsp, -32)); 1077 case Op_VecZ: 1078 __ evmovdqu(Address(rsp, -64), xmm0, 2); 1079 __ evmovdqu(xmm0, Address(rsp, src_offset), 2); 1080 __ evmovdqu(Address(rsp, dst_offset), xmm0, 2); 1081 __ evmovdqu(xmm0, Address(rsp, -64), 2); 1082 break; 1083 default: 1084 ShouldNotReachHere(); 1085 } 1086 #ifndef PRODUCT 1087 } else { 1088 switch (ireg) { 1089 case Op_VecS: 1090 st->print("movq [rsp - #8], rax\t# 32-bit mem-mem spill\n\t" 1091 "movl rax, [rsp + #%d]\n\t" 1092 "movl [rsp + #%d], rax\n\t" 1093 "movq rax, [rsp - #8]", 1094 src_offset, dst_offset); 1095 break; 1096 case Op_VecD: 1097 st->print("pushq [rsp + #%d]\t# 64-bit mem-mem spill\n\t" 1098 "popq [rsp + #%d]", 1099 src_offset, dst_offset); 1100 break; 1101 case Op_VecX: 1102 st->print("pushq [rsp + #%d]\t# 128-bit mem-mem spill\n\t" 1103 "popq [rsp + #%d]\n\t" 1104 "pushq [rsp + #%d]\n\t" 1105 "popq [rsp + #%d]", 1106 src_offset, dst_offset, src_offset+8, dst_offset+8); 1107 break; 1108 case Op_VecY: 1109 st->print("vmovdqu [rsp - #32], xmm0\t# 256-bit mem-mem spill\n\t" 1110 "vmovdqu xmm0, [rsp + #%d]\n\t" 1111 "vmovdqu [rsp + #%d], xmm0\n\t" 1112 "vmovdqu xmm0, [rsp - #32]", 1113 src_offset, dst_offset); 1114 break; 1115 case Op_VecZ: 1116 st->print("vmovdqu [rsp - #64], xmm0\t# 512-bit mem-mem spill\n\t" 1117 "vmovdqu xmm0, [rsp + #%d]\n\t" 1118 "vmovdqu [rsp + #%d], xmm0\n\t" 1119 "vmovdqu xmm0, [rsp - #64]", 1120 src_offset, dst_offset); 1121 break; 1122 default: 1123 ShouldNotReachHere(); 1124 } 1125 #endif 1126 } 1127 } 1128 1129 uint MachSpillCopyNode::implementation(CodeBuffer* cbuf, 1130 PhaseRegAlloc* ra_, 1131 bool do_size, 1132 outputStream* st) const { 1133 assert(cbuf != NULL || st != NULL, "sanity"); 1134 // Get registers to move 1135 OptoReg::Name src_second = ra_->get_reg_second(in(1)); 1136 OptoReg::Name src_first = ra_->get_reg_first(in(1)); 1137 OptoReg::Name dst_second = ra_->get_reg_second(this); 1138 OptoReg::Name dst_first = ra_->get_reg_first(this); 1139 1140 enum RC src_second_rc = rc_class(src_second); 1141 enum RC src_first_rc = rc_class(src_first); 1142 enum RC dst_second_rc = rc_class(dst_second); 1143 enum RC dst_first_rc = rc_class(dst_first); 1144 1145 assert(OptoReg::is_valid(src_first) && OptoReg::is_valid(dst_first), 1146 "must move at least 1 register" ); 1147 1148 if (src_first == dst_first && src_second == dst_second) { 1149 // Self copy, no move 1150 return 0; 1151 } 1152 if (bottom_type()->isa_vect() != NULL) { 1153 uint ireg = ideal_reg(); 1154 assert((src_first_rc != rc_int && dst_first_rc != rc_int), "sanity"); 1155 assert((ireg == Op_VecS || ireg == Op_VecD || ireg == Op_VecX || ireg == Op_VecY || ireg == Op_VecZ ), "sanity"); 1156 if( src_first_rc == rc_stack && dst_first_rc == rc_stack ) { 1157 // mem -> mem 1158 int src_offset = ra_->reg2offset(src_first); 1159 int dst_offset = ra_->reg2offset(dst_first); 1160 vec_stack_to_stack_helper(cbuf, src_offset, dst_offset, ireg, st); 1161 } else if (src_first_rc == rc_float && dst_first_rc == rc_float ) { 1162 vec_mov_helper(cbuf, false, src_first, dst_first, src_second, dst_second, ireg, st); 1163 } else if (src_first_rc == rc_float && dst_first_rc == rc_stack ) { 1164 int stack_offset = ra_->reg2offset(dst_first); 1165 vec_spill_helper(cbuf, false, false, stack_offset, src_first, ireg, st); 1166 } else if (src_first_rc == rc_stack && dst_first_rc == rc_float ) { 1167 int stack_offset = ra_->reg2offset(src_first); 1168 vec_spill_helper(cbuf, false, true, stack_offset, dst_first, ireg, st); 1169 } else { 1170 ShouldNotReachHere(); 1171 } 1172 return 0; 1173 } 1174 if (src_first_rc == rc_stack) { 1175 // mem -> 1176 if (dst_first_rc == rc_stack) { 1177 // mem -> mem 1178 assert(src_second != dst_first, "overlap"); 1179 if ((src_first & 1) == 0 && src_first + 1 == src_second && 1180 (dst_first & 1) == 0 && dst_first + 1 == dst_second) { 1181 // 64-bit 1182 int src_offset = ra_->reg2offset(src_first); 1183 int dst_offset = ra_->reg2offset(dst_first); 1184 if (cbuf) { 1185 MacroAssembler _masm(cbuf); 1186 __ pushq(Address(rsp, src_offset)); 1187 __ popq (Address(rsp, dst_offset)); 1188 #ifndef PRODUCT 1189 } else { 1190 st->print("pushq [rsp + #%d]\t# 64-bit mem-mem spill\n\t" 1191 "popq [rsp + #%d]", 1192 src_offset, dst_offset); 1193 #endif 1194 } 1195 } else { 1196 // 32-bit 1197 assert(!((src_first & 1) == 0 && src_first + 1 == src_second), "no transform"); 1198 assert(!((dst_first & 1) == 0 && dst_first + 1 == dst_second), "no transform"); 1199 // No pushl/popl, so: 1200 int src_offset = ra_->reg2offset(src_first); 1201 int dst_offset = ra_->reg2offset(dst_first); 1202 if (cbuf) { 1203 MacroAssembler _masm(cbuf); 1204 __ movq(Address(rsp, -8), rax); 1205 __ movl(rax, Address(rsp, src_offset)); 1206 __ movl(Address(rsp, dst_offset), rax); 1207 __ movq(rax, Address(rsp, -8)); 1208 #ifndef PRODUCT 1209 } else { 1210 st->print("movq [rsp - #8], rax\t# 32-bit mem-mem spill\n\t" 1211 "movl rax, [rsp + #%d]\n\t" 1212 "movl [rsp + #%d], rax\n\t" 1213 "movq rax, [rsp - #8]", 1214 src_offset, dst_offset); 1215 #endif 1216 } 1217 } 1218 return 0; 1219 } else if (dst_first_rc == rc_int) { 1220 // mem -> gpr 1221 if ((src_first & 1) == 0 && src_first + 1 == src_second && 1222 (dst_first & 1) == 0 && dst_first + 1 == dst_second) { 1223 // 64-bit 1224 int offset = ra_->reg2offset(src_first); 1225 if (cbuf) { 1226 MacroAssembler _masm(cbuf); 1227 __ movq(as_Register(Matcher::_regEncode[dst_first]), Address(rsp, offset)); 1228 #ifndef PRODUCT 1229 } else { 1230 st->print("movq %s, [rsp + #%d]\t# spill", 1231 Matcher::regName[dst_first], 1232 offset); 1233 #endif 1234 } 1235 } else { 1236 // 32-bit 1237 assert(!((src_first & 1) == 0 && src_first + 1 == src_second), "no transform"); 1238 assert(!((dst_first & 1) == 0 && dst_first + 1 == dst_second), "no transform"); 1239 int offset = ra_->reg2offset(src_first); 1240 if (cbuf) { 1241 MacroAssembler _masm(cbuf); 1242 __ movl(as_Register(Matcher::_regEncode[dst_first]), Address(rsp, offset)); 1243 #ifndef PRODUCT 1244 } else { 1245 st->print("movl %s, [rsp + #%d]\t# spill", 1246 Matcher::regName[dst_first], 1247 offset); 1248 #endif 1249 } 1250 } 1251 return 0; 1252 } else if (dst_first_rc == rc_float) { 1253 // mem-> xmm 1254 if ((src_first & 1) == 0 && src_first + 1 == src_second && 1255 (dst_first & 1) == 0 && dst_first + 1 == dst_second) { 1256 // 64-bit 1257 int offset = ra_->reg2offset(src_first); 1258 if (cbuf) { 1259 MacroAssembler _masm(cbuf); 1260 __ movdbl( as_XMMRegister(Matcher::_regEncode[dst_first]), Address(rsp, offset)); 1261 #ifndef PRODUCT 1262 } else { 1263 st->print("%s %s, [rsp + #%d]\t# spill", 1264 UseXmmLoadAndClearUpper ? "movsd " : "movlpd", 1265 Matcher::regName[dst_first], 1266 offset); 1267 #endif 1268 } 1269 } else { 1270 // 32-bit 1271 assert(!((src_first & 1) == 0 && src_first + 1 == src_second), "no transform"); 1272 assert(!((dst_first & 1) == 0 && dst_first + 1 == dst_second), "no transform"); 1273 int offset = ra_->reg2offset(src_first); 1274 if (cbuf) { 1275 MacroAssembler _masm(cbuf); 1276 __ movflt( as_XMMRegister(Matcher::_regEncode[dst_first]), Address(rsp, offset)); 1277 #ifndef PRODUCT 1278 } else { 1279 st->print("movss %s, [rsp + #%d]\t# spill", 1280 Matcher::regName[dst_first], 1281 offset); 1282 #endif 1283 } 1284 } 1285 return 0; 1286 } 1287 } else if (src_first_rc == rc_int) { 1288 // gpr -> 1289 if (dst_first_rc == rc_stack) { 1290 // gpr -> mem 1291 if ((src_first & 1) == 0 && src_first + 1 == src_second && 1292 (dst_first & 1) == 0 && dst_first + 1 == dst_second) { 1293 // 64-bit 1294 int offset = ra_->reg2offset(dst_first); 1295 if (cbuf) { 1296 MacroAssembler _masm(cbuf); 1297 __ movq(Address(rsp, offset), as_Register(Matcher::_regEncode[src_first])); 1298 #ifndef PRODUCT 1299 } else { 1300 st->print("movq [rsp + #%d], %s\t# spill", 1301 offset, 1302 Matcher::regName[src_first]); 1303 #endif 1304 } 1305 } else { 1306 // 32-bit 1307 assert(!((src_first & 1) == 0 && src_first + 1 == src_second), "no transform"); 1308 assert(!((dst_first & 1) == 0 && dst_first + 1 == dst_second), "no transform"); 1309 int offset = ra_->reg2offset(dst_first); 1310 if (cbuf) { 1311 MacroAssembler _masm(cbuf); 1312 __ movl(Address(rsp, offset), as_Register(Matcher::_regEncode[src_first])); 1313 #ifndef PRODUCT 1314 } else { 1315 st->print("movl [rsp + #%d], %s\t# spill", 1316 offset, 1317 Matcher::regName[src_first]); 1318 #endif 1319 } 1320 } 1321 return 0; 1322 } else if (dst_first_rc == rc_int) { 1323 // gpr -> gpr 1324 if ((src_first & 1) == 0 && src_first + 1 == src_second && 1325 (dst_first & 1) == 0 && dst_first + 1 == dst_second) { 1326 // 64-bit 1327 if (cbuf) { 1328 MacroAssembler _masm(cbuf); 1329 __ movq(as_Register(Matcher::_regEncode[dst_first]), 1330 as_Register(Matcher::_regEncode[src_first])); 1331 #ifndef PRODUCT 1332 } else { 1333 st->print("movq %s, %s\t# spill", 1334 Matcher::regName[dst_first], 1335 Matcher::regName[src_first]); 1336 #endif 1337 } 1338 return 0; 1339 } else { 1340 // 32-bit 1341 assert(!((src_first & 1) == 0 && src_first + 1 == src_second), "no transform"); 1342 assert(!((dst_first & 1) == 0 && dst_first + 1 == dst_second), "no transform"); 1343 if (cbuf) { 1344 MacroAssembler _masm(cbuf); 1345 __ movl(as_Register(Matcher::_regEncode[dst_first]), 1346 as_Register(Matcher::_regEncode[src_first])); 1347 #ifndef PRODUCT 1348 } else { 1349 st->print("movl %s, %s\t# spill", 1350 Matcher::regName[dst_first], 1351 Matcher::regName[src_first]); 1352 #endif 1353 } 1354 return 0; 1355 } 1356 } else if (dst_first_rc == rc_float) { 1357 // gpr -> xmm 1358 if ((src_first & 1) == 0 && src_first + 1 == src_second && 1359 (dst_first & 1) == 0 && dst_first + 1 == dst_second) { 1360 // 64-bit 1361 if (cbuf) { 1362 MacroAssembler _masm(cbuf); 1363 __ movdq( as_XMMRegister(Matcher::_regEncode[dst_first]), as_Register(Matcher::_regEncode[src_first])); 1364 #ifndef PRODUCT 1365 } else { 1366 st->print("movdq %s, %s\t# spill", 1367 Matcher::regName[dst_first], 1368 Matcher::regName[src_first]); 1369 #endif 1370 } 1371 } else { 1372 // 32-bit 1373 assert(!((src_first & 1) == 0 && src_first + 1 == src_second), "no transform"); 1374 assert(!((dst_first & 1) == 0 && dst_first + 1 == dst_second), "no transform"); 1375 if (cbuf) { 1376 MacroAssembler _masm(cbuf); 1377 __ movdl( as_XMMRegister(Matcher::_regEncode[dst_first]), as_Register(Matcher::_regEncode[src_first])); 1378 #ifndef PRODUCT 1379 } else { 1380 st->print("movdl %s, %s\t# spill", 1381 Matcher::regName[dst_first], 1382 Matcher::regName[src_first]); 1383 #endif 1384 } 1385 } 1386 return 0; 1387 } 1388 } else if (src_first_rc == rc_float) { 1389 // xmm -> 1390 if (dst_first_rc == rc_stack) { 1391 // xmm -> mem 1392 if ((src_first & 1) == 0 && src_first + 1 == src_second && 1393 (dst_first & 1) == 0 && dst_first + 1 == dst_second) { 1394 // 64-bit 1395 int offset = ra_->reg2offset(dst_first); 1396 if (cbuf) { 1397 MacroAssembler _masm(cbuf); 1398 __ movdbl( Address(rsp, offset), as_XMMRegister(Matcher::_regEncode[src_first])); 1399 #ifndef PRODUCT 1400 } else { 1401 st->print("movsd [rsp + #%d], %s\t# spill", 1402 offset, 1403 Matcher::regName[src_first]); 1404 #endif 1405 } 1406 } else { 1407 // 32-bit 1408 assert(!((src_first & 1) == 0 && src_first + 1 == src_second), "no transform"); 1409 assert(!((dst_first & 1) == 0 && dst_first + 1 == dst_second), "no transform"); 1410 int offset = ra_->reg2offset(dst_first); 1411 if (cbuf) { 1412 MacroAssembler _masm(cbuf); 1413 __ movflt(Address(rsp, offset), as_XMMRegister(Matcher::_regEncode[src_first])); 1414 #ifndef PRODUCT 1415 } else { 1416 st->print("movss [rsp + #%d], %s\t# spill", 1417 offset, 1418 Matcher::regName[src_first]); 1419 #endif 1420 } 1421 } 1422 return 0; 1423 } else if (dst_first_rc == rc_int) { 1424 // xmm -> gpr 1425 if ((src_first & 1) == 0 && src_first + 1 == src_second && 1426 (dst_first & 1) == 0 && dst_first + 1 == dst_second) { 1427 // 64-bit 1428 if (cbuf) { 1429 MacroAssembler _masm(cbuf); 1430 __ movdq( as_Register(Matcher::_regEncode[dst_first]), as_XMMRegister(Matcher::_regEncode[src_first])); 1431 #ifndef PRODUCT 1432 } else { 1433 st->print("movdq %s, %s\t# spill", 1434 Matcher::regName[dst_first], 1435 Matcher::regName[src_first]); 1436 #endif 1437 } 1438 } else { 1439 // 32-bit 1440 assert(!((src_first & 1) == 0 && src_first + 1 == src_second), "no transform"); 1441 assert(!((dst_first & 1) == 0 && dst_first + 1 == dst_second), "no transform"); 1442 if (cbuf) { 1443 MacroAssembler _masm(cbuf); 1444 __ movdl( as_Register(Matcher::_regEncode[dst_first]), as_XMMRegister(Matcher::_regEncode[src_first])); 1445 #ifndef PRODUCT 1446 } else { 1447 st->print("movdl %s, %s\t# spill", 1448 Matcher::regName[dst_first], 1449 Matcher::regName[src_first]); 1450 #endif 1451 } 1452 } 1453 return 0; 1454 } else if (dst_first_rc == rc_float) { 1455 // xmm -> xmm 1456 if ((src_first & 1) == 0 && src_first + 1 == src_second && 1457 (dst_first & 1) == 0 && dst_first + 1 == dst_second) { 1458 // 64-bit 1459 if (cbuf) { 1460 MacroAssembler _masm(cbuf); 1461 __ movdbl( as_XMMRegister(Matcher::_regEncode[dst_first]), as_XMMRegister(Matcher::_regEncode[src_first])); 1462 #ifndef PRODUCT 1463 } else { 1464 st->print("%s %s, %s\t# spill", 1465 UseXmmRegToRegMoveAll ? "movapd" : "movsd ", 1466 Matcher::regName[dst_first], 1467 Matcher::regName[src_first]); 1468 #endif 1469 } 1470 } else { 1471 // 32-bit 1472 assert(!((src_first & 1) == 0 && src_first + 1 == src_second), "no transform"); 1473 assert(!((dst_first & 1) == 0 && dst_first + 1 == dst_second), "no transform"); 1474 if (cbuf) { 1475 MacroAssembler _masm(cbuf); 1476 __ movflt( as_XMMRegister(Matcher::_regEncode[dst_first]), as_XMMRegister(Matcher::_regEncode[src_first])); 1477 #ifndef PRODUCT 1478 } else { 1479 st->print("%s %s, %s\t# spill", 1480 UseXmmRegToRegMoveAll ? "movaps" : "movss ", 1481 Matcher::regName[dst_first], 1482 Matcher::regName[src_first]); 1483 #endif 1484 } 1485 } 1486 return 0; 1487 } 1488 } 1489 1490 assert(0," foo "); 1491 Unimplemented(); 1492 return 0; 1493 } 1494 1495 #ifndef PRODUCT 1496 void MachSpillCopyNode::format(PhaseRegAlloc *ra_, outputStream* st) const { 1497 implementation(NULL, ra_, false, st); 1498 } 1499 #endif 1500 1501 void MachSpillCopyNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const { 1502 implementation(&cbuf, ra_, false, NULL); 1503 } 1504 1505 uint MachSpillCopyNode::size(PhaseRegAlloc *ra_) const { 1506 return MachNode::size(ra_); 1507 } 1508 1509 //============================================================================= 1510 #ifndef PRODUCT 1511 void BoxLockNode::format(PhaseRegAlloc* ra_, outputStream* st) const 1512 { 1513 int offset = ra_->reg2offset(in_RegMask(0).find_first_elem()); 1514 int reg = ra_->get_reg_first(this); 1515 st->print("leaq %s, [rsp + #%d]\t# box lock", 1516 Matcher::regName[reg], offset); 1517 } 1518 #endif 1519 1520 void BoxLockNode::emit(CodeBuffer& cbuf, PhaseRegAlloc* ra_) const 1521 { 1522 int offset = ra_->reg2offset(in_RegMask(0).find_first_elem()); 1523 int reg = ra_->get_encode(this); 1524 if (offset >= 0x80) { 1525 emit_opcode(cbuf, reg < 8 ? Assembler::REX_W : Assembler::REX_WR); 1526 emit_opcode(cbuf, 0x8D); // LEA reg,[SP+offset] 1527 emit_rm(cbuf, 0x2, reg & 7, 0x04); 1528 emit_rm(cbuf, 0x0, 0x04, RSP_enc); 1529 emit_d32(cbuf, offset); 1530 } else { 1531 emit_opcode(cbuf, reg < 8 ? Assembler::REX_W : Assembler::REX_WR); 1532 emit_opcode(cbuf, 0x8D); // LEA reg,[SP+offset] 1533 emit_rm(cbuf, 0x1, reg & 7, 0x04); 1534 emit_rm(cbuf, 0x0, 0x04, RSP_enc); 1535 emit_d8(cbuf, offset); 1536 } 1537 } 1538 1539 uint BoxLockNode::size(PhaseRegAlloc *ra_) const 1540 { 1541 int offset = ra_->reg2offset(in_RegMask(0).find_first_elem()); 1542 return (offset < 0x80) ? 5 : 8; // REX 1543 } 1544 1545 //============================================================================= 1546 #ifndef PRODUCT 1547 void MachUEPNode::format(PhaseRegAlloc* ra_, outputStream* st) const 1548 { 1549 if (UseCompressedClassPointers) { 1550 st->print_cr("movl rscratch1, [j_rarg0 + oopDesc::klass_offset_in_bytes()]\t# compressed klass"); 1551 st->print_cr("\tdecode_klass_not_null rscratch1, rscratch1"); 1552 st->print_cr("\tcmpq rax, rscratch1\t # Inline cache check"); 1553 } else { 1554 st->print_cr("\tcmpq rax, [j_rarg0 + oopDesc::klass_offset_in_bytes()]\t" 1555 "# Inline cache check"); 1556 } 1557 st->print_cr("\tjne SharedRuntime::_ic_miss_stub"); 1558 st->print_cr("\tnop\t# nops to align entry point"); 1559 } 1560 #endif 1561 1562 void MachUEPNode::emit(CodeBuffer& cbuf, PhaseRegAlloc* ra_) const 1563 { 1564 MacroAssembler masm(&cbuf); 1565 uint insts_size = cbuf.insts_size(); 1566 if (UseCompressedClassPointers) { 1567 masm.load_klass(rscratch1, j_rarg0); 1568 masm.cmpptr(rax, rscratch1); 1569 } else { 1570 masm.cmpptr(rax, Address(j_rarg0, oopDesc::klass_offset_in_bytes())); 1571 } 1572 1573 masm.jump_cc(Assembler::notEqual, RuntimeAddress(SharedRuntime::get_ic_miss_stub())); 1574 1575 /* WARNING these NOPs are critical so that verified entry point is properly 1576 4 bytes aligned for patching by NativeJump::patch_verified_entry() */ 1577 int nops_cnt = 4 - ((cbuf.insts_size() - insts_size) & 0x3); 1578 if (OptoBreakpoint) { 1579 // Leave space for int3 1580 nops_cnt -= 1; 1581 } 1582 nops_cnt &= 0x3; // Do not add nops if code is aligned. 1583 if (nops_cnt > 0) 1584 masm.nop(nops_cnt); 1585 } 1586 1587 uint MachUEPNode::size(PhaseRegAlloc* ra_) const 1588 { 1589 return MachNode::size(ra_); // too many variables; just compute it 1590 // the hard way 1591 } 1592 1593 1594 //============================================================================= 1595 1596 int Matcher::regnum_to_fpu_offset(int regnum) 1597 { 1598 return regnum - 32; // The FP registers are in the second chunk 1599 } 1600 1601 // This is UltraSparc specific, true just means we have fast l2f conversion 1602 const bool Matcher::convL2FSupported(void) { 1603 return true; 1604 } 1605 1606 // Is this branch offset short enough that a short branch can be used? 1607 // 1608 // NOTE: If the platform does not provide any short branch variants, then 1609 // this method should return false for offset 0. 1610 bool Matcher::is_short_branch_offset(int rule, int br_size, int offset) { 1611 // The passed offset is relative to address of the branch. 1612 // On 86 a branch displacement is calculated relative to address 1613 // of a next instruction. 1614 offset -= br_size; 1615 1616 // the short version of jmpConUCF2 contains multiple branches, 1617 // making the reach slightly less 1618 if (rule == jmpConUCF2_rule) 1619 return (-126 <= offset && offset <= 125); 1620 return (-128 <= offset && offset <= 127); 1621 } 1622 1623 const bool Matcher::isSimpleConstant64(jlong value) { 1624 // Will one (StoreL ConL) be cheaper than two (StoreI ConI)?. 1625 //return value == (int) value; // Cf. storeImmL and immL32. 1626 1627 // Probably always true, even if a temp register is required. 1628 return true; 1629 } 1630 1631 // The ecx parameter to rep stosq for the ClearArray node is in words. 1632 const bool Matcher::init_array_count_is_in_bytes = false; 1633 1634 // Threshold size for cleararray. 1635 const int Matcher::init_array_short_size = 8 * BytesPerLong; 1636 1637 // No additional cost for CMOVL. 1638 const int Matcher::long_cmove_cost() { return 0; } 1639 1640 // No CMOVF/CMOVD with SSE2 1641 const int Matcher::float_cmove_cost() { return ConditionalMoveLimit; } 1642 1643 // Does the CPU require late expand (see block.cpp for description of late expand)? 1644 const bool Matcher::require_postalloc_expand = false; 1645 1646 // Should the Matcher clone shifts on addressing modes, expecting them 1647 // to be subsumed into complex addressing expressions or compute them 1648 // into registers? True for Intel but false for most RISCs 1649 const bool Matcher::clone_shift_expressions = true; 1650 1651 // Do we need to mask the count passed to shift instructions or does 1652 // the cpu only look at the lower 5/6 bits anyway? 1653 const bool Matcher::need_masked_shift_count = false; 1654 1655 bool Matcher::narrow_oop_use_complex_address() { 1656 assert(UseCompressedOops, "only for compressed oops code"); 1657 return (LogMinObjAlignmentInBytes <= 3); 1658 } 1659 1660 bool Matcher::narrow_klass_use_complex_address() { 1661 assert(UseCompressedClassPointers, "only for compressed klass code"); 1662 return (LogKlassAlignmentInBytes <= 3); 1663 } 1664 1665 // Is it better to copy float constants, or load them directly from 1666 // memory? Intel can load a float constant from a direct address, 1667 // requiring no extra registers. Most RISCs will have to materialize 1668 // an address into a register first, so they would do better to copy 1669 // the constant from stack. 1670 const bool Matcher::rematerialize_float_constants = true; // XXX 1671 1672 // If CPU can load and store mis-aligned doubles directly then no 1673 // fixup is needed. Else we split the double into 2 integer pieces 1674 // and move it piece-by-piece. Only happens when passing doubles into 1675 // C code as the Java calling convention forces doubles to be aligned. 1676 const bool Matcher::misaligned_doubles_ok = true; 1677 1678 // No-op on amd64 1679 void Matcher::pd_implicit_null_fixup(MachNode *node, uint idx) {} 1680 1681 // Advertise here if the CPU requires explicit rounding operations to 1682 // implement the UseStrictFP mode. 1683 const bool Matcher::strict_fp_requires_explicit_rounding = true; 1684 1685 // Are floats conerted to double when stored to stack during deoptimization? 1686 // On x64 it is stored without convertion so we can use normal access. 1687 bool Matcher::float_in_double() { return false; } 1688 1689 // Do ints take an entire long register or just half? 1690 const bool Matcher::int_in_long = true; 1691 1692 // Return whether or not this register is ever used as an argument. 1693 // This function is used on startup to build the trampoline stubs in 1694 // generateOptoStub. Registers not mentioned will be killed by the VM 1695 // call in the trampoline, and arguments in those registers not be 1696 // available to the callee. 1697 bool Matcher::can_be_java_arg(int reg) 1698 { 1699 return 1700 reg == RDI_num || reg == RDI_H_num || 1701 reg == RSI_num || reg == RSI_H_num || 1702 reg == RDX_num || reg == RDX_H_num || 1703 reg == RCX_num || reg == RCX_H_num || 1704 reg == R8_num || reg == R8_H_num || 1705 reg == R9_num || reg == R9_H_num || 1706 reg == R12_num || reg == R12_H_num || 1707 reg == XMM0_num || reg == XMM0b_num || 1708 reg == XMM1_num || reg == XMM1b_num || 1709 reg == XMM2_num || reg == XMM2b_num || 1710 reg == XMM3_num || reg == XMM3b_num || 1711 reg == XMM4_num || reg == XMM4b_num || 1712 reg == XMM5_num || reg == XMM5b_num || 1713 reg == XMM6_num || reg == XMM6b_num || 1714 reg == XMM7_num || reg == XMM7b_num; 1715 } 1716 1717 bool Matcher::is_spillable_arg(int reg) 1718 { 1719 return can_be_java_arg(reg); 1720 } 1721 1722 bool Matcher::use_asm_for_ldiv_by_con( jlong divisor ) { 1723 // In 64 bit mode a code which use multiply when 1724 // devisor is constant is faster than hardware 1725 // DIV instruction (it uses MulHiL). 1726 return false; 1727 } 1728 1729 // Register for DIVI projection of divmodI 1730 RegMask Matcher::divI_proj_mask() { 1731 return INT_RAX_REG_mask(); 1732 } 1733 1734 // Register for MODI projection of divmodI 1735 RegMask Matcher::modI_proj_mask() { 1736 return INT_RDX_REG_mask(); 1737 } 1738 1739 // Register for DIVL projection of divmodL 1740 RegMask Matcher::divL_proj_mask() { 1741 return LONG_RAX_REG_mask(); 1742 } 1743 1744 // Register for MODL projection of divmodL 1745 RegMask Matcher::modL_proj_mask() { 1746 return LONG_RDX_REG_mask(); 1747 } 1748 1749 // Register for saving SP into on method handle invokes. Not used on x86_64. 1750 const RegMask Matcher::method_handle_invoke_SP_save_mask() { 1751 return NO_REG_mask(); 1752 } 1753 1754 %} 1755 1756 //----------ENCODING BLOCK----------------------------------------------------- 1757 // This block specifies the encoding classes used by the compiler to 1758 // output byte streams. Encoding classes are parameterized macros 1759 // used by Machine Instruction Nodes in order to generate the bit 1760 // encoding of the instruction. Operands specify their base encoding 1761 // interface with the interface keyword. There are currently 1762 // supported four interfaces, REG_INTER, CONST_INTER, MEMORY_INTER, & 1763 // COND_INTER. REG_INTER causes an operand to generate a function 1764 // which returns its register number when queried. CONST_INTER causes 1765 // an operand to generate a function which returns the value of the 1766 // constant when queried. MEMORY_INTER causes an operand to generate 1767 // four functions which return the Base Register, the Index Register, 1768 // the Scale Value, and the Offset Value of the operand when queried. 1769 // COND_INTER causes an operand to generate six functions which return 1770 // the encoding code (ie - encoding bits for the instruction) 1771 // associated with each basic boolean condition for a conditional 1772 // instruction. 1773 // 1774 // Instructions specify two basic values for encoding. Again, a 1775 // function is available to check if the constant displacement is an 1776 // oop. They use the ins_encode keyword to specify their encoding 1777 // classes (which must be a sequence of enc_class names, and their 1778 // parameters, specified in the encoding block), and they use the 1779 // opcode keyword to specify, in order, their primary, secondary, and 1780 // tertiary opcode. Only the opcode sections which a particular 1781 // instruction needs for encoding need to be specified. 1782 encode %{ 1783 // Build emit functions for each basic byte or larger field in the 1784 // intel encoding scheme (opcode, rm, sib, immediate), and call them 1785 // from C++ code in the enc_class source block. Emit functions will 1786 // live in the main source block for now. In future, we can 1787 // generalize this by adding a syntax that specifies the sizes of 1788 // fields in an order, so that the adlc can build the emit functions 1789 // automagically 1790 1791 // Emit primary opcode 1792 enc_class OpcP 1793 %{ 1794 emit_opcode(cbuf, $primary); 1795 %} 1796 1797 // Emit secondary opcode 1798 enc_class OpcS 1799 %{ 1800 emit_opcode(cbuf, $secondary); 1801 %} 1802 1803 // Emit tertiary opcode 1804 enc_class OpcT 1805 %{ 1806 emit_opcode(cbuf, $tertiary); 1807 %} 1808 1809 // Emit opcode directly 1810 enc_class Opcode(immI d8) 1811 %{ 1812 emit_opcode(cbuf, $d8$$constant); 1813 %} 1814 1815 // Emit size prefix 1816 enc_class SizePrefix 1817 %{ 1818 emit_opcode(cbuf, 0x66); 1819 %} 1820 1821 enc_class reg(rRegI reg) 1822 %{ 1823 emit_rm(cbuf, 0x3, 0, $reg$$reg & 7); 1824 %} 1825 1826 enc_class reg_reg(rRegI dst, rRegI src) 1827 %{ 1828 emit_rm(cbuf, 0x3, $dst$$reg & 7, $src$$reg & 7); 1829 %} 1830 1831 enc_class opc_reg_reg(immI opcode, rRegI dst, rRegI src) 1832 %{ 1833 emit_opcode(cbuf, $opcode$$constant); 1834 emit_rm(cbuf, 0x3, $dst$$reg & 7, $src$$reg & 7); 1835 %} 1836 1837 enc_class cdql_enc(no_rax_rdx_RegI div) 1838 %{ 1839 // Full implementation of Java idiv and irem; checks for 1840 // special case as described in JVM spec., p.243 & p.271. 1841 // 1842 // normal case special case 1843 // 1844 // input : rax: dividend min_int 1845 // reg: divisor -1 1846 // 1847 // output: rax: quotient (= rax idiv reg) min_int 1848 // rdx: remainder (= rax irem reg) 0 1849 // 1850 // Code sequnce: 1851 // 1852 // 0: 3d 00 00 00 80 cmp $0x80000000,%eax 1853 // 5: 75 07/08 jne e <normal> 1854 // 7: 33 d2 xor %edx,%edx 1855 // [div >= 8 -> offset + 1] 1856 // [REX_B] 1857 // 9: 83 f9 ff cmp $0xffffffffffffffff,$div 1858 // c: 74 03/04 je 11 <done> 1859 // 000000000000000e <normal>: 1860 // e: 99 cltd 1861 // [div >= 8 -> offset + 1] 1862 // [REX_B] 1863 // f: f7 f9 idiv $div 1864 // 0000000000000011 <done>: 1865 1866 // cmp $0x80000000,%eax 1867 emit_opcode(cbuf, 0x3d); 1868 emit_d8(cbuf, 0x00); 1869 emit_d8(cbuf, 0x00); 1870 emit_d8(cbuf, 0x00); 1871 emit_d8(cbuf, 0x80); 1872 1873 // jne e <normal> 1874 emit_opcode(cbuf, 0x75); 1875 emit_d8(cbuf, $div$$reg < 8 ? 0x07 : 0x08); 1876 1877 // xor %edx,%edx 1878 emit_opcode(cbuf, 0x33); 1879 emit_d8(cbuf, 0xD2); 1880 1881 // cmp $0xffffffffffffffff,%ecx 1882 if ($div$$reg >= 8) { 1883 emit_opcode(cbuf, Assembler::REX_B); 1884 } 1885 emit_opcode(cbuf, 0x83); 1886 emit_rm(cbuf, 0x3, 0x7, $div$$reg & 7); 1887 emit_d8(cbuf, 0xFF); 1888 1889 // je 11 <done> 1890 emit_opcode(cbuf, 0x74); 1891 emit_d8(cbuf, $div$$reg < 8 ? 0x03 : 0x04); 1892 1893 // <normal> 1894 // cltd 1895 emit_opcode(cbuf, 0x99); 1896 1897 // idivl (note: must be emitted by the user of this rule) 1898 // <done> 1899 %} 1900 1901 enc_class cdqq_enc(no_rax_rdx_RegL div) 1902 %{ 1903 // Full implementation of Java ldiv and lrem; checks for 1904 // special case as described in JVM spec., p.243 & p.271. 1905 // 1906 // normal case special case 1907 // 1908 // input : rax: dividend min_long 1909 // reg: divisor -1 1910 // 1911 // output: rax: quotient (= rax idiv reg) min_long 1912 // rdx: remainder (= rax irem reg) 0 1913 // 1914 // Code sequnce: 1915 // 1916 // 0: 48 ba 00 00 00 00 00 mov $0x8000000000000000,%rdx 1917 // 7: 00 00 80 1918 // a: 48 39 d0 cmp %rdx,%rax 1919 // d: 75 08 jne 17 <normal> 1920 // f: 33 d2 xor %edx,%edx 1921 // 11: 48 83 f9 ff cmp $0xffffffffffffffff,$div 1922 // 15: 74 05 je 1c <done> 1923 // 0000000000000017 <normal>: 1924 // 17: 48 99 cqto 1925 // 19: 48 f7 f9 idiv $div 1926 // 000000000000001c <done>: 1927 1928 // mov $0x8000000000000000,%rdx 1929 emit_opcode(cbuf, Assembler::REX_W); 1930 emit_opcode(cbuf, 0xBA); 1931 emit_d8(cbuf, 0x00); 1932 emit_d8(cbuf, 0x00); 1933 emit_d8(cbuf, 0x00); 1934 emit_d8(cbuf, 0x00); 1935 emit_d8(cbuf, 0x00); 1936 emit_d8(cbuf, 0x00); 1937 emit_d8(cbuf, 0x00); 1938 emit_d8(cbuf, 0x80); 1939 1940 // cmp %rdx,%rax 1941 emit_opcode(cbuf, Assembler::REX_W); 1942 emit_opcode(cbuf, 0x39); 1943 emit_d8(cbuf, 0xD0); 1944 1945 // jne 17 <normal> 1946 emit_opcode(cbuf, 0x75); 1947 emit_d8(cbuf, 0x08); 1948 1949 // xor %edx,%edx 1950 emit_opcode(cbuf, 0x33); 1951 emit_d8(cbuf, 0xD2); 1952 1953 // cmp $0xffffffffffffffff,$div 1954 emit_opcode(cbuf, $div$$reg < 8 ? Assembler::REX_W : Assembler::REX_WB); 1955 emit_opcode(cbuf, 0x83); 1956 emit_rm(cbuf, 0x3, 0x7, $div$$reg & 7); 1957 emit_d8(cbuf, 0xFF); 1958 1959 // je 1e <done> 1960 emit_opcode(cbuf, 0x74); 1961 emit_d8(cbuf, 0x05); 1962 1963 // <normal> 1964 // cqto 1965 emit_opcode(cbuf, Assembler::REX_W); 1966 emit_opcode(cbuf, 0x99); 1967 1968 // idivq (note: must be emitted by the user of this rule) 1969 // <done> 1970 %} 1971 1972 // Opcde enc_class for 8/32 bit immediate instructions with sign-extension 1973 enc_class OpcSE(immI imm) 1974 %{ 1975 // Emit primary opcode and set sign-extend bit 1976 // Check for 8-bit immediate, and set sign extend bit in opcode 1977 if (-0x80 <= $imm$$constant && $imm$$constant < 0x80) { 1978 emit_opcode(cbuf, $primary | 0x02); 1979 } else { 1980 // 32-bit immediate 1981 emit_opcode(cbuf, $primary); 1982 } 1983 %} 1984 1985 enc_class OpcSErm(rRegI dst, immI imm) 1986 %{ 1987 // OpcSEr/m 1988 int dstenc = $dst$$reg; 1989 if (dstenc >= 8) { 1990 emit_opcode(cbuf, Assembler::REX_B); 1991 dstenc -= 8; 1992 } 1993 // Emit primary opcode and set sign-extend bit 1994 // Check for 8-bit immediate, and set sign extend bit in opcode 1995 if (-0x80 <= $imm$$constant && $imm$$constant < 0x80) { 1996 emit_opcode(cbuf, $primary | 0x02); 1997 } else { 1998 // 32-bit immediate 1999 emit_opcode(cbuf, $primary); 2000 } 2001 // Emit r/m byte with secondary opcode, after primary opcode. 2002 emit_rm(cbuf, 0x3, $secondary, dstenc); 2003 %} 2004 2005 enc_class OpcSErm_wide(rRegL dst, immI imm) 2006 %{ 2007 // OpcSEr/m 2008 int dstenc = $dst$$reg; 2009 if (dstenc < 8) { 2010 emit_opcode(cbuf, Assembler::REX_W); 2011 } else { 2012 emit_opcode(cbuf, Assembler::REX_WB); 2013 dstenc -= 8; 2014 } 2015 // Emit primary opcode and set sign-extend bit 2016 // Check for 8-bit immediate, and set sign extend bit in opcode 2017 if (-0x80 <= $imm$$constant && $imm$$constant < 0x80) { 2018 emit_opcode(cbuf, $primary | 0x02); 2019 } else { 2020 // 32-bit immediate 2021 emit_opcode(cbuf, $primary); 2022 } 2023 // Emit r/m byte with secondary opcode, after primary opcode. 2024 emit_rm(cbuf, 0x3, $secondary, dstenc); 2025 %} 2026 2027 enc_class Con8or32(immI imm) 2028 %{ 2029 // Check for 8-bit immediate, and set sign extend bit in opcode 2030 if (-0x80 <= $imm$$constant && $imm$$constant < 0x80) { 2031 $$$emit8$imm$$constant; 2032 } else { 2033 // 32-bit immediate 2034 $$$emit32$imm$$constant; 2035 } 2036 %} 2037 2038 enc_class opc2_reg(rRegI dst) 2039 %{ 2040 // BSWAP 2041 emit_cc(cbuf, $secondary, $dst$$reg); 2042 %} 2043 2044 enc_class opc3_reg(rRegI dst) 2045 %{ 2046 // BSWAP 2047 emit_cc(cbuf, $tertiary, $dst$$reg); 2048 %} 2049 2050 enc_class reg_opc(rRegI div) 2051 %{ 2052 // INC, DEC, IDIV, IMOD, JMP indirect, ... 2053 emit_rm(cbuf, 0x3, $secondary, $div$$reg & 7); 2054 %} 2055 2056 enc_class enc_cmov(cmpOp cop) 2057 %{ 2058 // CMOV 2059 $$$emit8$primary; 2060 emit_cc(cbuf, $secondary, $cop$$cmpcode); 2061 %} 2062 2063 enc_class enc_PartialSubtypeCheck() 2064 %{ 2065 Register Rrdi = as_Register(RDI_enc); // result register 2066 Register Rrax = as_Register(RAX_enc); // super class 2067 Register Rrcx = as_Register(RCX_enc); // killed 2068 Register Rrsi = as_Register(RSI_enc); // sub class 2069 Label miss; 2070 const bool set_cond_codes = true; 2071 2072 MacroAssembler _masm(&cbuf); 2073 __ check_klass_subtype_slow_path(Rrsi, Rrax, Rrcx, Rrdi, 2074 NULL, &miss, 2075 /*set_cond_codes:*/ true); 2076 if ($primary) { 2077 __ xorptr(Rrdi, Rrdi); 2078 } 2079 __ bind(miss); 2080 %} 2081 2082 enc_class clear_avx %{ 2083 debug_only(int off0 = cbuf.insts_size()); 2084 if (ra_->C->max_vector_size() > 16) { 2085 // Clear upper bits of YMM registers when current compiled code uses 2086 // wide vectors to avoid AVX <-> SSE transition penalty during call. 2087 MacroAssembler _masm(&cbuf); 2088 __ vzeroupper(); 2089 } 2090 debug_only(int off1 = cbuf.insts_size()); 2091 assert(off1 - off0 == clear_avx_size(), "correct size prediction"); 2092 %} 2093 2094 enc_class Java_To_Runtime(method meth) %{ 2095 // No relocation needed 2096 MacroAssembler _masm(&cbuf); 2097 __ mov64(r10, (int64_t) $meth$$method); 2098 __ call(r10); 2099 %} 2100 2101 enc_class Java_To_Interpreter(method meth) 2102 %{ 2103 // CALL Java_To_Interpreter 2104 // This is the instruction starting address for relocation info. 2105 cbuf.set_insts_mark(); 2106 $$$emit8$primary; 2107 // CALL directly to the runtime 2108 emit_d32_reloc(cbuf, 2109 (int) ($meth$$method - ((intptr_t) cbuf.insts_end()) - 4), 2110 runtime_call_Relocation::spec(), 2111 RELOC_DISP32); 2112 %} 2113 2114 enc_class Java_Static_Call(method meth) 2115 %{ 2116 // JAVA STATIC CALL 2117 // CALL to fixup routine. Fixup routine uses ScopeDesc info to 2118 // determine who we intended to call. 2119 cbuf.set_insts_mark(); 2120 $$$emit8$primary; 2121 2122 if (!_method) { 2123 emit_d32_reloc(cbuf, 2124 (int) ($meth$$method - ((intptr_t) cbuf.insts_end()) - 4), 2125 runtime_call_Relocation::spec(), 2126 RELOC_DISP32); 2127 } else if (_optimized_virtual) { 2128 emit_d32_reloc(cbuf, 2129 (int) ($meth$$method - ((intptr_t) cbuf.insts_end()) - 4), 2130 opt_virtual_call_Relocation::spec(), 2131 RELOC_DISP32); 2132 } else { 2133 emit_d32_reloc(cbuf, 2134 (int) ($meth$$method - ((intptr_t) cbuf.insts_end()) - 4), 2135 static_call_Relocation::spec(), 2136 RELOC_DISP32); 2137 } 2138 if (_method) { 2139 // Emit stub for static call. 2140 address stub = CompiledStaticCall::emit_to_interp_stub(cbuf); 2141 if (stub == NULL) { 2142 ciEnv::current()->record_failure("CodeCache is full"); 2143 return; 2144 } 2145 } 2146 %} 2147 2148 enc_class Java_Dynamic_Call(method meth) %{ 2149 MacroAssembler _masm(&cbuf); 2150 __ ic_call((address)$meth$$method); 2151 %} 2152 2153 enc_class Java_Compiled_Call(method meth) 2154 %{ 2155 // JAVA COMPILED CALL 2156 int disp = in_bytes(Method:: from_compiled_offset()); 2157 2158 // XXX XXX offset is 128 is 1.5 NON-PRODUCT !!! 2159 // assert(-0x80 <= disp && disp < 0x80, "compiled_code_offset isn't small"); 2160 2161 // callq *disp(%rax) 2162 cbuf.set_insts_mark(); 2163 $$$emit8$primary; 2164 if (disp < 0x80) { 2165 emit_rm(cbuf, 0x01, $secondary, RAX_enc); // R/M byte 2166 emit_d8(cbuf, disp); // Displacement 2167 } else { 2168 emit_rm(cbuf, 0x02, $secondary, RAX_enc); // R/M byte 2169 emit_d32(cbuf, disp); // Displacement 2170 } 2171 %} 2172 2173 enc_class reg_opc_imm(rRegI dst, immI8 shift) 2174 %{ 2175 // SAL, SAR, SHR 2176 int dstenc = $dst$$reg; 2177 if (dstenc >= 8) { 2178 emit_opcode(cbuf, Assembler::REX_B); 2179 dstenc -= 8; 2180 } 2181 $$$emit8$primary; 2182 emit_rm(cbuf, 0x3, $secondary, dstenc); 2183 $$$emit8$shift$$constant; 2184 %} 2185 2186 enc_class reg_opc_imm_wide(rRegL dst, immI8 shift) 2187 %{ 2188 // SAL, SAR, SHR 2189 int dstenc = $dst$$reg; 2190 if (dstenc < 8) { 2191 emit_opcode(cbuf, Assembler::REX_W); 2192 } else { 2193 emit_opcode(cbuf, Assembler::REX_WB); 2194 dstenc -= 8; 2195 } 2196 $$$emit8$primary; 2197 emit_rm(cbuf, 0x3, $secondary, dstenc); 2198 $$$emit8$shift$$constant; 2199 %} 2200 2201 enc_class load_immI(rRegI dst, immI src) 2202 %{ 2203 int dstenc = $dst$$reg; 2204 if (dstenc >= 8) { 2205 emit_opcode(cbuf, Assembler::REX_B); 2206 dstenc -= 8; 2207 } 2208 emit_opcode(cbuf, 0xB8 | dstenc); 2209 $$$emit32$src$$constant; 2210 %} 2211 2212 enc_class load_immL(rRegL dst, immL src) 2213 %{ 2214 int dstenc = $dst$$reg; 2215 if (dstenc < 8) { 2216 emit_opcode(cbuf, Assembler::REX_W); 2217 } else { 2218 emit_opcode(cbuf, Assembler::REX_WB); 2219 dstenc -= 8; 2220 } 2221 emit_opcode(cbuf, 0xB8 | dstenc); 2222 emit_d64(cbuf, $src$$constant); 2223 %} 2224 2225 enc_class load_immUL32(rRegL dst, immUL32 src) 2226 %{ 2227 // same as load_immI, but this time we care about zeroes in the high word 2228 int dstenc = $dst$$reg; 2229 if (dstenc >= 8) { 2230 emit_opcode(cbuf, Assembler::REX_B); 2231 dstenc -= 8; 2232 } 2233 emit_opcode(cbuf, 0xB8 | dstenc); 2234 $$$emit32$src$$constant; 2235 %} 2236 2237 enc_class load_immL32(rRegL dst, immL32 src) 2238 %{ 2239 int dstenc = $dst$$reg; 2240 if (dstenc < 8) { 2241 emit_opcode(cbuf, Assembler::REX_W); 2242 } else { 2243 emit_opcode(cbuf, Assembler::REX_WB); 2244 dstenc -= 8; 2245 } 2246 emit_opcode(cbuf, 0xC7); 2247 emit_rm(cbuf, 0x03, 0x00, dstenc); 2248 $$$emit32$src$$constant; 2249 %} 2250 2251 enc_class load_immP31(rRegP dst, immP32 src) 2252 %{ 2253 // same as load_immI, but this time we care about zeroes in the high word 2254 int dstenc = $dst$$reg; 2255 if (dstenc >= 8) { 2256 emit_opcode(cbuf, Assembler::REX_B); 2257 dstenc -= 8; 2258 } 2259 emit_opcode(cbuf, 0xB8 | dstenc); 2260 $$$emit32$src$$constant; 2261 %} 2262 2263 enc_class load_immP(rRegP dst, immP src) 2264 %{ 2265 int dstenc = $dst$$reg; 2266 if (dstenc < 8) { 2267 emit_opcode(cbuf, Assembler::REX_W); 2268 } else { 2269 emit_opcode(cbuf, Assembler::REX_WB); 2270 dstenc -= 8; 2271 } 2272 emit_opcode(cbuf, 0xB8 | dstenc); 2273 // This next line should be generated from ADLC 2274 if ($src->constant_reloc() != relocInfo::none) { 2275 emit_d64_reloc(cbuf, $src$$constant, $src->constant_reloc(), RELOC_IMM64); 2276 } else { 2277 emit_d64(cbuf, $src$$constant); 2278 } 2279 %} 2280 2281 enc_class Con32(immI src) 2282 %{ 2283 // Output immediate 2284 $$$emit32$src$$constant; 2285 %} 2286 2287 enc_class Con32F_as_bits(immF src) 2288 %{ 2289 // Output Float immediate bits 2290 jfloat jf = $src$$constant; 2291 jint jf_as_bits = jint_cast(jf); 2292 emit_d32(cbuf, jf_as_bits); 2293 %} 2294 2295 enc_class Con16(immI src) 2296 %{ 2297 // Output immediate 2298 $$$emit16$src$$constant; 2299 %} 2300 2301 // How is this different from Con32??? XXX 2302 enc_class Con_d32(immI src) 2303 %{ 2304 emit_d32(cbuf,$src$$constant); 2305 %} 2306 2307 enc_class conmemref (rRegP t1) %{ // Con32(storeImmI) 2308 // Output immediate memory reference 2309 emit_rm(cbuf, 0x00, $t1$$reg, 0x05 ); 2310 emit_d32(cbuf, 0x00); 2311 %} 2312 2313 enc_class lock_prefix() 2314 %{ 2315 if (os::is_MP()) { 2316 emit_opcode(cbuf, 0xF0); // lock 2317 } 2318 %} 2319 2320 enc_class REX_mem(memory mem) 2321 %{ 2322 if ($mem$$base >= 8) { 2323 if ($mem$$index < 8) { 2324 emit_opcode(cbuf, Assembler::REX_B); 2325 } else { 2326 emit_opcode(cbuf, Assembler::REX_XB); 2327 } 2328 } else { 2329 if ($mem$$index >= 8) { 2330 emit_opcode(cbuf, Assembler::REX_X); 2331 } 2332 } 2333 %} 2334 2335 enc_class REX_mem_wide(memory mem) 2336 %{ 2337 if ($mem$$base >= 8) { 2338 if ($mem$$index < 8) { 2339 emit_opcode(cbuf, Assembler::REX_WB); 2340 } else { 2341 emit_opcode(cbuf, Assembler::REX_WXB); 2342 } 2343 } else { 2344 if ($mem$$index < 8) { 2345 emit_opcode(cbuf, Assembler::REX_W); 2346 } else { 2347 emit_opcode(cbuf, Assembler::REX_WX); 2348 } 2349 } 2350 %} 2351 2352 // for byte regs 2353 enc_class REX_breg(rRegI reg) 2354 %{ 2355 if ($reg$$reg >= 4) { 2356 emit_opcode(cbuf, $reg$$reg < 8 ? Assembler::REX : Assembler::REX_B); 2357 } 2358 %} 2359 2360 // for byte regs 2361 enc_class REX_reg_breg(rRegI dst, rRegI src) 2362 %{ 2363 if ($dst$$reg < 8) { 2364 if ($src$$reg >= 4) { 2365 emit_opcode(cbuf, $src$$reg < 8 ? Assembler::REX : Assembler::REX_B); 2366 } 2367 } else { 2368 if ($src$$reg < 8) { 2369 emit_opcode(cbuf, Assembler::REX_R); 2370 } else { 2371 emit_opcode(cbuf, Assembler::REX_RB); 2372 } 2373 } 2374 %} 2375 2376 // for byte regs 2377 enc_class REX_breg_mem(rRegI reg, memory mem) 2378 %{ 2379 if ($reg$$reg < 8) { 2380 if ($mem$$base < 8) { 2381 if ($mem$$index >= 8) { 2382 emit_opcode(cbuf, Assembler::REX_X); 2383 } else if ($reg$$reg >= 4) { 2384 emit_opcode(cbuf, Assembler::REX); 2385 } 2386 } else { 2387 if ($mem$$index < 8) { 2388 emit_opcode(cbuf, Assembler::REX_B); 2389 } else { 2390 emit_opcode(cbuf, Assembler::REX_XB); 2391 } 2392 } 2393 } else { 2394 if ($mem$$base < 8) { 2395 if ($mem$$index < 8) { 2396 emit_opcode(cbuf, Assembler::REX_R); 2397 } else { 2398 emit_opcode(cbuf, Assembler::REX_RX); 2399 } 2400 } else { 2401 if ($mem$$index < 8) { 2402 emit_opcode(cbuf, Assembler::REX_RB); 2403 } else { 2404 emit_opcode(cbuf, Assembler::REX_RXB); 2405 } 2406 } 2407 } 2408 %} 2409 2410 enc_class REX_reg(rRegI reg) 2411 %{ 2412 if ($reg$$reg >= 8) { 2413 emit_opcode(cbuf, Assembler::REX_B); 2414 } 2415 %} 2416 2417 enc_class REX_reg_wide(rRegI reg) 2418 %{ 2419 if ($reg$$reg < 8) { 2420 emit_opcode(cbuf, Assembler::REX_W); 2421 } else { 2422 emit_opcode(cbuf, Assembler::REX_WB); 2423 } 2424 %} 2425 2426 enc_class REX_reg_reg(rRegI dst, rRegI src) 2427 %{ 2428 if ($dst$$reg < 8) { 2429 if ($src$$reg >= 8) { 2430 emit_opcode(cbuf, Assembler::REX_B); 2431 } 2432 } else { 2433 if ($src$$reg < 8) { 2434 emit_opcode(cbuf, Assembler::REX_R); 2435 } else { 2436 emit_opcode(cbuf, Assembler::REX_RB); 2437 } 2438 } 2439 %} 2440 2441 enc_class REX_reg_reg_wide(rRegI dst, rRegI src) 2442 %{ 2443 if ($dst$$reg < 8) { 2444 if ($src$$reg < 8) { 2445 emit_opcode(cbuf, Assembler::REX_W); 2446 } else { 2447 emit_opcode(cbuf, Assembler::REX_WB); 2448 } 2449 } else { 2450 if ($src$$reg < 8) { 2451 emit_opcode(cbuf, Assembler::REX_WR); 2452 } else { 2453 emit_opcode(cbuf, Assembler::REX_WRB); 2454 } 2455 } 2456 %} 2457 2458 enc_class REX_reg_mem(rRegI reg, memory mem) 2459 %{ 2460 if ($reg$$reg < 8) { 2461 if ($mem$$base < 8) { 2462 if ($mem$$index >= 8) { 2463 emit_opcode(cbuf, Assembler::REX_X); 2464 } 2465 } else { 2466 if ($mem$$index < 8) { 2467 emit_opcode(cbuf, Assembler::REX_B); 2468 } else { 2469 emit_opcode(cbuf, Assembler::REX_XB); 2470 } 2471 } 2472 } else { 2473 if ($mem$$base < 8) { 2474 if ($mem$$index < 8) { 2475 emit_opcode(cbuf, Assembler::REX_R); 2476 } else { 2477 emit_opcode(cbuf, Assembler::REX_RX); 2478 } 2479 } else { 2480 if ($mem$$index < 8) { 2481 emit_opcode(cbuf, Assembler::REX_RB); 2482 } else { 2483 emit_opcode(cbuf, Assembler::REX_RXB); 2484 } 2485 } 2486 } 2487 %} 2488 2489 enc_class REX_reg_mem_wide(rRegL reg, memory mem) 2490 %{ 2491 if ($reg$$reg < 8) { 2492 if ($mem$$base < 8) { 2493 if ($mem$$index < 8) { 2494 emit_opcode(cbuf, Assembler::REX_W); 2495 } else { 2496 emit_opcode(cbuf, Assembler::REX_WX); 2497 } 2498 } else { 2499 if ($mem$$index < 8) { 2500 emit_opcode(cbuf, Assembler::REX_WB); 2501 } else { 2502 emit_opcode(cbuf, Assembler::REX_WXB); 2503 } 2504 } 2505 } else { 2506 if ($mem$$base < 8) { 2507 if ($mem$$index < 8) { 2508 emit_opcode(cbuf, Assembler::REX_WR); 2509 } else { 2510 emit_opcode(cbuf, Assembler::REX_WRX); 2511 } 2512 } else { 2513 if ($mem$$index < 8) { 2514 emit_opcode(cbuf, Assembler::REX_WRB); 2515 } else { 2516 emit_opcode(cbuf, Assembler::REX_WRXB); 2517 } 2518 } 2519 } 2520 %} 2521 2522 enc_class reg_mem(rRegI ereg, memory mem) 2523 %{ 2524 // High registers handle in encode_RegMem 2525 int reg = $ereg$$reg; 2526 int base = $mem$$base; 2527 int index = $mem$$index; 2528 int scale = $mem$$scale; 2529 int disp = $mem$$disp; 2530 relocInfo::relocType disp_reloc = $mem->disp_reloc(); 2531 2532 encode_RegMem(cbuf, reg, base, index, scale, disp, disp_reloc); 2533 %} 2534 2535 enc_class RM_opc_mem(immI rm_opcode, memory mem) 2536 %{ 2537 int rm_byte_opcode = $rm_opcode$$constant; 2538 2539 // High registers handle in encode_RegMem 2540 int base = $mem$$base; 2541 int index = $mem$$index; 2542 int scale = $mem$$scale; 2543 int displace = $mem$$disp; 2544 2545 relocInfo::relocType disp_reloc = $mem->disp_reloc(); // disp-as-oop when 2546 // working with static 2547 // globals 2548 encode_RegMem(cbuf, rm_byte_opcode, base, index, scale, displace, 2549 disp_reloc); 2550 %} 2551 2552 enc_class reg_lea(rRegI dst, rRegI src0, immI src1) 2553 %{ 2554 int reg_encoding = $dst$$reg; 2555 int base = $src0$$reg; // 0xFFFFFFFF indicates no base 2556 int index = 0x04; // 0x04 indicates no index 2557 int scale = 0x00; // 0x00 indicates no scale 2558 int displace = $src1$$constant; // 0x00 indicates no displacement 2559 relocInfo::relocType disp_reloc = relocInfo::none; 2560 encode_RegMem(cbuf, reg_encoding, base, index, scale, displace, 2561 disp_reloc); 2562 %} 2563 2564 enc_class neg_reg(rRegI dst) 2565 %{ 2566 int dstenc = $dst$$reg; 2567 if (dstenc >= 8) { 2568 emit_opcode(cbuf, Assembler::REX_B); 2569 dstenc -= 8; 2570 } 2571 // NEG $dst 2572 emit_opcode(cbuf, 0xF7); 2573 emit_rm(cbuf, 0x3, 0x03, dstenc); 2574 %} 2575 2576 enc_class neg_reg_wide(rRegI dst) 2577 %{ 2578 int dstenc = $dst$$reg; 2579 if (dstenc < 8) { 2580 emit_opcode(cbuf, Assembler::REX_W); 2581 } else { 2582 emit_opcode(cbuf, Assembler::REX_WB); 2583 dstenc -= 8; 2584 } 2585 // NEG $dst 2586 emit_opcode(cbuf, 0xF7); 2587 emit_rm(cbuf, 0x3, 0x03, dstenc); 2588 %} 2589 2590 enc_class setLT_reg(rRegI dst) 2591 %{ 2592 int dstenc = $dst$$reg; 2593 if (dstenc >= 8) { 2594 emit_opcode(cbuf, Assembler::REX_B); 2595 dstenc -= 8; 2596 } else if (dstenc >= 4) { 2597 emit_opcode(cbuf, Assembler::REX); 2598 } 2599 // SETLT $dst 2600 emit_opcode(cbuf, 0x0F); 2601 emit_opcode(cbuf, 0x9C); 2602 emit_rm(cbuf, 0x3, 0x0, dstenc); 2603 %} 2604 2605 enc_class setNZ_reg(rRegI dst) 2606 %{ 2607 int dstenc = $dst$$reg; 2608 if (dstenc >= 8) { 2609 emit_opcode(cbuf, Assembler::REX_B); 2610 dstenc -= 8; 2611 } else if (dstenc >= 4) { 2612 emit_opcode(cbuf, Assembler::REX); 2613 } 2614 // SETNZ $dst 2615 emit_opcode(cbuf, 0x0F); 2616 emit_opcode(cbuf, 0x95); 2617 emit_rm(cbuf, 0x3, 0x0, dstenc); 2618 %} 2619 2620 2621 // Compare the lonogs and set -1, 0, or 1 into dst 2622 enc_class cmpl3_flag(rRegL src1, rRegL src2, rRegI dst) 2623 %{ 2624 int src1enc = $src1$$reg; 2625 int src2enc = $src2$$reg; 2626 int dstenc = $dst$$reg; 2627 2628 // cmpq $src1, $src2 2629 if (src1enc < 8) { 2630 if (src2enc < 8) { 2631 emit_opcode(cbuf, Assembler::REX_W); 2632 } else { 2633 emit_opcode(cbuf, Assembler::REX_WB); 2634 } 2635 } else { 2636 if (src2enc < 8) { 2637 emit_opcode(cbuf, Assembler::REX_WR); 2638 } else { 2639 emit_opcode(cbuf, Assembler::REX_WRB); 2640 } 2641 } 2642 emit_opcode(cbuf, 0x3B); 2643 emit_rm(cbuf, 0x3, src1enc & 7, src2enc & 7); 2644 2645 // movl $dst, -1 2646 if (dstenc >= 8) { 2647 emit_opcode(cbuf, Assembler::REX_B); 2648 } 2649 emit_opcode(cbuf, 0xB8 | (dstenc & 7)); 2650 emit_d32(cbuf, -1); 2651 2652 // jl,s done 2653 emit_opcode(cbuf, 0x7C); 2654 emit_d8(cbuf, dstenc < 4 ? 0x06 : 0x08); 2655 2656 // setne $dst 2657 if (dstenc >= 4) { 2658 emit_opcode(cbuf, dstenc < 8 ? Assembler::REX : Assembler::REX_B); 2659 } 2660 emit_opcode(cbuf, 0x0F); 2661 emit_opcode(cbuf, 0x95); 2662 emit_opcode(cbuf, 0xC0 | (dstenc & 7)); 2663 2664 // movzbl $dst, $dst 2665 if (dstenc >= 4) { 2666 emit_opcode(cbuf, dstenc < 8 ? Assembler::REX : Assembler::REX_RB); 2667 } 2668 emit_opcode(cbuf, 0x0F); 2669 emit_opcode(cbuf, 0xB6); 2670 emit_rm(cbuf, 0x3, dstenc & 7, dstenc & 7); 2671 %} 2672 2673 enc_class Push_ResultXD(regD dst) %{ 2674 MacroAssembler _masm(&cbuf); 2675 __ fstp_d(Address(rsp, 0)); 2676 __ movdbl($dst$$XMMRegister, Address(rsp, 0)); 2677 __ addptr(rsp, 8); 2678 %} 2679 2680 enc_class Push_SrcXD(regD src) %{ 2681 MacroAssembler _masm(&cbuf); 2682 __ subptr(rsp, 8); 2683 __ movdbl(Address(rsp, 0), $src$$XMMRegister); 2684 __ fld_d(Address(rsp, 0)); 2685 %} 2686 2687 2688 enc_class enc_rethrow() 2689 %{ 2690 cbuf.set_insts_mark(); 2691 emit_opcode(cbuf, 0xE9); // jmp entry 2692 emit_d32_reloc(cbuf, 2693 (int) (OptoRuntime::rethrow_stub() - cbuf.insts_end() - 4), 2694 runtime_call_Relocation::spec(), 2695 RELOC_DISP32); 2696 %} 2697 2698 %} 2699 2700 2701 2702 //----------FRAME-------------------------------------------------------------- 2703 // Definition of frame structure and management information. 2704 // 2705 // S T A C K L A Y O U T Allocators stack-slot number 2706 // | (to get allocators register number 2707 // G Owned by | | v add OptoReg::stack0()) 2708 // r CALLER | | 2709 // o | +--------+ pad to even-align allocators stack-slot 2710 // w V | pad0 | numbers; owned by CALLER 2711 // t -----------+--------+----> Matcher::_in_arg_limit, unaligned 2712 // h ^ | in | 5 2713 // | | args | 4 Holes in incoming args owned by SELF 2714 // | | | | 3 2715 // | | +--------+ 2716 // V | | old out| Empty on Intel, window on Sparc 2717 // | old |preserve| Must be even aligned. 2718 // | SP-+--------+----> Matcher::_old_SP, even aligned 2719 // | | in | 3 area for Intel ret address 2720 // Owned by |preserve| Empty on Sparc. 2721 // SELF +--------+ 2722 // | | pad2 | 2 pad to align old SP 2723 // | +--------+ 1 2724 // | | locks | 0 2725 // | +--------+----> OptoReg::stack0(), even aligned 2726 // | | pad1 | 11 pad to align new SP 2727 // | +--------+ 2728 // | | | 10 2729 // | | spills | 9 spills 2730 // V | | 8 (pad0 slot for callee) 2731 // -----------+--------+----> Matcher::_out_arg_limit, unaligned 2732 // ^ | out | 7 2733 // | | args | 6 Holes in outgoing args owned by CALLEE 2734 // Owned by +--------+ 2735 // CALLEE | new out| 6 Empty on Intel, window on Sparc 2736 // | new |preserve| Must be even-aligned. 2737 // | SP-+--------+----> Matcher::_new_SP, even aligned 2738 // | | | 2739 // 2740 // Note 1: Only region 8-11 is determined by the allocator. Region 0-5 is 2741 // known from SELF's arguments and the Java calling convention. 2742 // Region 6-7 is determined per call site. 2743 // Note 2: If the calling convention leaves holes in the incoming argument 2744 // area, those holes are owned by SELF. Holes in the outgoing area 2745 // are owned by the CALLEE. Holes should not be nessecary in the 2746 // incoming area, as the Java calling convention is completely under 2747 // the control of the AD file. Doubles can be sorted and packed to 2748 // avoid holes. Holes in the outgoing arguments may be nessecary for 2749 // varargs C calling conventions. 2750 // Note 3: Region 0-3 is even aligned, with pad2 as needed. Region 3-5 is 2751 // even aligned with pad0 as needed. 2752 // Region 6 is even aligned. Region 6-7 is NOT even aligned; 2753 // region 6-11 is even aligned; it may be padded out more so that 2754 // the region from SP to FP meets the minimum stack alignment. 2755 // Note 4: For I2C adapters, the incoming FP may not meet the minimum stack 2756 // alignment. Region 11, pad1, may be dynamically extended so that 2757 // SP meets the minimum alignment. 2758 2759 frame 2760 %{ 2761 // What direction does stack grow in (assumed to be same for C & Java) 2762 stack_direction(TOWARDS_LOW); 2763 2764 // These three registers define part of the calling convention 2765 // between compiled code and the interpreter. 2766 inline_cache_reg(RAX); // Inline Cache Register 2767 interpreter_method_oop_reg(RBX); // Method Oop Register when 2768 // calling interpreter 2769 2770 // Optional: name the operand used by cisc-spilling to access 2771 // [stack_pointer + offset] 2772 cisc_spilling_operand_name(indOffset32); 2773 2774 // Number of stack slots consumed by locking an object 2775 sync_stack_slots(2); 2776 2777 // Compiled code's Frame Pointer 2778 frame_pointer(RSP); 2779 2780 // Interpreter stores its frame pointer in a register which is 2781 // stored to the stack by I2CAdaptors. 2782 // I2CAdaptors convert from interpreted java to compiled java. 2783 interpreter_frame_pointer(RBP); 2784 2785 // Stack alignment requirement 2786 stack_alignment(StackAlignmentInBytes); // Alignment size in bytes (128-bit -> 16 bytes) 2787 2788 // Number of stack slots between incoming argument block and the start of 2789 // a new frame. The PROLOG must add this many slots to the stack. The 2790 // EPILOG must remove this many slots. amd64 needs two slots for 2791 // return address. 2792 in_preserve_stack_slots(4 + 2 * VerifyStackAtCalls); 2793 2794 // Number of outgoing stack slots killed above the out_preserve_stack_slots 2795 // for calls to C. Supports the var-args backing area for register parms. 2796 varargs_C_out_slots_killed(frame::arg_reg_save_area_bytes/BytesPerInt); 2797 2798 // The after-PROLOG location of the return address. Location of 2799 // return address specifies a type (REG or STACK) and a number 2800 // representing the register number (i.e. - use a register name) or 2801 // stack slot. 2802 // Ret Addr is on stack in slot 0 if no locks or verification or alignment. 2803 // Otherwise, it is above the locks and verification slot and alignment word 2804 return_addr(STACK - 2 + 2805 round_to((Compile::current()->in_preserve_stack_slots() + 2806 Compile::current()->fixed_slots()), 2807 stack_alignment_in_slots())); 2808 2809 // Body of function which returns an integer array locating 2810 // arguments either in registers or in stack slots. Passed an array 2811 // of ideal registers called "sig" and a "length" count. Stack-slot 2812 // offsets are based on outgoing arguments, i.e. a CALLER setting up 2813 // arguments for a CALLEE. Incoming stack arguments are 2814 // automatically biased by the preserve_stack_slots field above. 2815 2816 calling_convention 2817 %{ 2818 // No difference between ingoing/outgoing just pass false 2819 SharedRuntime::java_calling_convention(sig_bt, regs, length, false); 2820 %} 2821 2822 c_calling_convention 2823 %{ 2824 // This is obviously always outgoing 2825 (void) SharedRuntime::c_calling_convention(sig_bt, regs, /*regs2=*/NULL, length); 2826 %} 2827 2828 // Location of compiled Java return values. Same as C for now. 2829 return_value 2830 %{ 2831 assert(ideal_reg >= Op_RegI && ideal_reg <= Op_RegL, 2832 "only return normal values"); 2833 2834 static const int lo[Op_RegL + 1] = { 2835 0, 2836 0, 2837 RAX_num, // Op_RegN 2838 RAX_num, // Op_RegI 2839 RAX_num, // Op_RegP 2840 XMM0_num, // Op_RegF 2841 XMM0_num, // Op_RegD 2842 RAX_num // Op_RegL 2843 }; 2844 static const int hi[Op_RegL + 1] = { 2845 0, 2846 0, 2847 OptoReg::Bad, // Op_RegN 2848 OptoReg::Bad, // Op_RegI 2849 RAX_H_num, // Op_RegP 2850 OptoReg::Bad, // Op_RegF 2851 XMM0b_num, // Op_RegD 2852 RAX_H_num // Op_RegL 2853 }; 2854 // Excluded flags and vector registers. 2855 assert(ARRAY_SIZE(hi) == _last_machine_leaf - 6, "missing type"); 2856 return OptoRegPair(hi[ideal_reg], lo[ideal_reg]); 2857 %} 2858 %} 2859 2860 //----------ATTRIBUTES--------------------------------------------------------- 2861 //----------Operand Attributes------------------------------------------------- 2862 op_attrib op_cost(0); // Required cost attribute 2863 2864 //----------Instruction Attributes--------------------------------------------- 2865 ins_attrib ins_cost(100); // Required cost attribute 2866 ins_attrib ins_size(8); // Required size attribute (in bits) 2867 ins_attrib ins_short_branch(0); // Required flag: is this instruction 2868 // a non-matching short branch variant 2869 // of some long branch? 2870 ins_attrib ins_alignment(1); // Required alignment attribute (must 2871 // be a power of 2) specifies the 2872 // alignment that some part of the 2873 // instruction (not necessarily the 2874 // start) requires. If > 1, a 2875 // compute_padding() function must be 2876 // provided for the instruction 2877 2878 //----------OPERANDS----------------------------------------------------------- 2879 // Operand definitions must precede instruction definitions for correct parsing 2880 // in the ADLC because operands constitute user defined types which are used in 2881 // instruction definitions. 2882 2883 //----------Simple Operands---------------------------------------------------- 2884 // Immediate Operands 2885 // Integer Immediate 2886 operand immI() 2887 %{ 2888 match(ConI); 2889 2890 op_cost(10); 2891 format %{ %} 2892 interface(CONST_INTER); 2893 %} 2894 2895 // Constant for test vs zero 2896 operand immI0() 2897 %{ 2898 predicate(n->get_int() == 0); 2899 match(ConI); 2900 2901 op_cost(0); 2902 format %{ %} 2903 interface(CONST_INTER); 2904 %} 2905 2906 // Constant for increment 2907 operand immI1() 2908 %{ 2909 predicate(n->get_int() == 1); 2910 match(ConI); 2911 2912 op_cost(0); 2913 format %{ %} 2914 interface(CONST_INTER); 2915 %} 2916 2917 // Constant for decrement 2918 operand immI_M1() 2919 %{ 2920 predicate(n->get_int() == -1); 2921 match(ConI); 2922 2923 op_cost(0); 2924 format %{ %} 2925 interface(CONST_INTER); 2926 %} 2927 2928 // Valid scale values for addressing modes 2929 operand immI2() 2930 %{ 2931 predicate(0 <= n->get_int() && (n->get_int() <= 3)); 2932 match(ConI); 2933 2934 format %{ %} 2935 interface(CONST_INTER); 2936 %} 2937 2938 operand immI8() 2939 %{ 2940 predicate((-0x80 <= n->get_int()) && (n->get_int() < 0x80)); 2941 match(ConI); 2942 2943 op_cost(5); 2944 format %{ %} 2945 interface(CONST_INTER); 2946 %} 2947 2948 operand immI16() 2949 %{ 2950 predicate((-32768 <= n->get_int()) && (n->get_int() <= 32767)); 2951 match(ConI); 2952 2953 op_cost(10); 2954 format %{ %} 2955 interface(CONST_INTER); 2956 %} 2957 2958 // Int Immediate non-negative 2959 operand immU31() 2960 %{ 2961 predicate(n->get_int() >= 0); 2962 match(ConI); 2963 2964 op_cost(0); 2965 format %{ %} 2966 interface(CONST_INTER); 2967 %} 2968 2969 // Constant for long shifts 2970 operand immI_32() 2971 %{ 2972 predicate( n->get_int() == 32 ); 2973 match(ConI); 2974 2975 op_cost(0); 2976 format %{ %} 2977 interface(CONST_INTER); 2978 %} 2979 2980 // Constant for long shifts 2981 operand immI_64() 2982 %{ 2983 predicate( n->get_int() == 64 ); 2984 match(ConI); 2985 2986 op_cost(0); 2987 format %{ %} 2988 interface(CONST_INTER); 2989 %} 2990 2991 // Pointer Immediate 2992 operand immP() 2993 %{ 2994 match(ConP); 2995 2996 op_cost(10); 2997 format %{ %} 2998 interface(CONST_INTER); 2999 %} 3000 3001 // NULL Pointer Immediate 3002 operand immP0() 3003 %{ 3004 predicate(n->get_ptr() == 0); 3005 match(ConP); 3006 3007 op_cost(5); 3008 format %{ %} 3009 interface(CONST_INTER); 3010 %} 3011 3012 // Pointer Immediate 3013 operand immN() %{ 3014 match(ConN); 3015 3016 op_cost(10); 3017 format %{ %} 3018 interface(CONST_INTER); 3019 %} 3020 3021 operand immNKlass() %{ 3022 match(ConNKlass); 3023 3024 op_cost(10); 3025 format %{ %} 3026 interface(CONST_INTER); 3027 %} 3028 3029 // NULL Pointer Immediate 3030 operand immN0() %{ 3031 predicate(n->get_narrowcon() == 0); 3032 match(ConN); 3033 3034 op_cost(5); 3035 format %{ %} 3036 interface(CONST_INTER); 3037 %} 3038 3039 operand immP31() 3040 %{ 3041 predicate(n->as_Type()->type()->reloc() == relocInfo::none 3042 && (n->get_ptr() >> 31) == 0); 3043 match(ConP); 3044 3045 op_cost(5); 3046 format %{ %} 3047 interface(CONST_INTER); 3048 %} 3049 3050 3051 // Long Immediate 3052 operand immL() 3053 %{ 3054 match(ConL); 3055 3056 op_cost(20); 3057 format %{ %} 3058 interface(CONST_INTER); 3059 %} 3060 3061 // Long Immediate 8-bit 3062 operand immL8() 3063 %{ 3064 predicate(-0x80L <= n->get_long() && n->get_long() < 0x80L); 3065 match(ConL); 3066 3067 op_cost(5); 3068 format %{ %} 3069 interface(CONST_INTER); 3070 %} 3071 3072 // Long Immediate 32-bit unsigned 3073 operand immUL32() 3074 %{ 3075 predicate(n->get_long() == (unsigned int) (n->get_long())); 3076 match(ConL); 3077 3078 op_cost(10); 3079 format %{ %} 3080 interface(CONST_INTER); 3081 %} 3082 3083 // Long Immediate 32-bit signed 3084 operand immL32() 3085 %{ 3086 predicate(n->get_long() == (int) (n->get_long())); 3087 match(ConL); 3088 3089 op_cost(15); 3090 format %{ %} 3091 interface(CONST_INTER); 3092 %} 3093 3094 // Long Immediate zero 3095 operand immL0() 3096 %{ 3097 predicate(n->get_long() == 0L); 3098 match(ConL); 3099 3100 op_cost(10); 3101 format %{ %} 3102 interface(CONST_INTER); 3103 %} 3104 3105 // Constant for increment 3106 operand immL1() 3107 %{ 3108 predicate(n->get_long() == 1); 3109 match(ConL); 3110 3111 format %{ %} 3112 interface(CONST_INTER); 3113 %} 3114 3115 // Constant for decrement 3116 operand immL_M1() 3117 %{ 3118 predicate(n->get_long() == -1); 3119 match(ConL); 3120 3121 format %{ %} 3122 interface(CONST_INTER); 3123 %} 3124 3125 // Long Immediate: the value 10 3126 operand immL10() 3127 %{ 3128 predicate(n->get_long() == 10); 3129 match(ConL); 3130 3131 format %{ %} 3132 interface(CONST_INTER); 3133 %} 3134 3135 // Long immediate from 0 to 127. 3136 // Used for a shorter form of long mul by 10. 3137 operand immL_127() 3138 %{ 3139 predicate(0 <= n->get_long() && n->get_long() < 0x80); 3140 match(ConL); 3141 3142 op_cost(10); 3143 format %{ %} 3144 interface(CONST_INTER); 3145 %} 3146 3147 // Long Immediate: low 32-bit mask 3148 operand immL_32bits() 3149 %{ 3150 predicate(n->get_long() == 0xFFFFFFFFL); 3151 match(ConL); 3152 op_cost(20); 3153 3154 format %{ %} 3155 interface(CONST_INTER); 3156 %} 3157 3158 // Float Immediate zero 3159 operand immF0() 3160 %{ 3161 predicate(jint_cast(n->getf()) == 0); 3162 match(ConF); 3163 3164 op_cost(5); 3165 format %{ %} 3166 interface(CONST_INTER); 3167 %} 3168 3169 // Float Immediate 3170 operand immF() 3171 %{ 3172 match(ConF); 3173 3174 op_cost(15); 3175 format %{ %} 3176 interface(CONST_INTER); 3177 %} 3178 3179 // Double Immediate zero 3180 operand immD0() 3181 %{ 3182 predicate(jlong_cast(n->getd()) == 0); 3183 match(ConD); 3184 3185 op_cost(5); 3186 format %{ %} 3187 interface(CONST_INTER); 3188 %} 3189 3190 // Double Immediate 3191 operand immD() 3192 %{ 3193 match(ConD); 3194 3195 op_cost(15); 3196 format %{ %} 3197 interface(CONST_INTER); 3198 %} 3199 3200 // Immediates for special shifts (sign extend) 3201 3202 // Constants for increment 3203 operand immI_16() 3204 %{ 3205 predicate(n->get_int() == 16); 3206 match(ConI); 3207 3208 format %{ %} 3209 interface(CONST_INTER); 3210 %} 3211 3212 operand immI_24() 3213 %{ 3214 predicate(n->get_int() == 24); 3215 match(ConI); 3216 3217 format %{ %} 3218 interface(CONST_INTER); 3219 %} 3220 3221 // Constant for byte-wide masking 3222 operand immI_255() 3223 %{ 3224 predicate(n->get_int() == 255); 3225 match(ConI); 3226 3227 format %{ %} 3228 interface(CONST_INTER); 3229 %} 3230 3231 // Constant for short-wide masking 3232 operand immI_65535() 3233 %{ 3234 predicate(n->get_int() == 65535); 3235 match(ConI); 3236 3237 format %{ %} 3238 interface(CONST_INTER); 3239 %} 3240 3241 // Constant for byte-wide masking 3242 operand immL_255() 3243 %{ 3244 predicate(n->get_long() == 255); 3245 match(ConL); 3246 3247 format %{ %} 3248 interface(CONST_INTER); 3249 %} 3250 3251 // Constant for short-wide masking 3252 operand immL_65535() 3253 %{ 3254 predicate(n->get_long() == 65535); 3255 match(ConL); 3256 3257 format %{ %} 3258 interface(CONST_INTER); 3259 %} 3260 3261 // Register Operands 3262 // Integer Register 3263 operand rRegI() 3264 %{ 3265 constraint(ALLOC_IN_RC(int_reg)); 3266 match(RegI); 3267 3268 match(rax_RegI); 3269 match(rbx_RegI); 3270 match(rcx_RegI); 3271 match(rdx_RegI); 3272 match(rdi_RegI); 3273 3274 format %{ %} 3275 interface(REG_INTER); 3276 %} 3277 3278 // Special Registers 3279 operand rax_RegI() 3280 %{ 3281 constraint(ALLOC_IN_RC(int_rax_reg)); 3282 match(RegI); 3283 match(rRegI); 3284 3285 format %{ "RAX" %} 3286 interface(REG_INTER); 3287 %} 3288 3289 // Special Registers 3290 operand rbx_RegI() 3291 %{ 3292 constraint(ALLOC_IN_RC(int_rbx_reg)); 3293 match(RegI); 3294 match(rRegI); 3295 3296 format %{ "RBX" %} 3297 interface(REG_INTER); 3298 %} 3299 3300 operand rcx_RegI() 3301 %{ 3302 constraint(ALLOC_IN_RC(int_rcx_reg)); 3303 match(RegI); 3304 match(rRegI); 3305 3306 format %{ "RCX" %} 3307 interface(REG_INTER); 3308 %} 3309 3310 operand rdx_RegI() 3311 %{ 3312 constraint(ALLOC_IN_RC(int_rdx_reg)); 3313 match(RegI); 3314 match(rRegI); 3315 3316 format %{ "RDX" %} 3317 interface(REG_INTER); 3318 %} 3319 3320 operand rdi_RegI() 3321 %{ 3322 constraint(ALLOC_IN_RC(int_rdi_reg)); 3323 match(RegI); 3324 match(rRegI); 3325 3326 format %{ "RDI" %} 3327 interface(REG_INTER); 3328 %} 3329 3330 operand no_rcx_RegI() 3331 %{ 3332 constraint(ALLOC_IN_RC(int_no_rcx_reg)); 3333 match(RegI); 3334 match(rax_RegI); 3335 match(rbx_RegI); 3336 match(rdx_RegI); 3337 match(rdi_RegI); 3338 3339 format %{ %} 3340 interface(REG_INTER); 3341 %} 3342 3343 operand no_rax_rdx_RegI() 3344 %{ 3345 constraint(ALLOC_IN_RC(int_no_rax_rdx_reg)); 3346 match(RegI); 3347 match(rbx_RegI); 3348 match(rcx_RegI); 3349 match(rdi_RegI); 3350 3351 format %{ %} 3352 interface(REG_INTER); 3353 %} 3354 3355 // Pointer Register 3356 operand any_RegP() 3357 %{ 3358 constraint(ALLOC_IN_RC(any_reg)); 3359 match(RegP); 3360 match(rax_RegP); 3361 match(rbx_RegP); 3362 match(rdi_RegP); 3363 match(rsi_RegP); 3364 match(rbp_RegP); 3365 match(r15_RegP); 3366 match(rRegP); 3367 3368 format %{ %} 3369 interface(REG_INTER); 3370 %} 3371 3372 operand rRegP() 3373 %{ 3374 constraint(ALLOC_IN_RC(ptr_reg)); 3375 match(RegP); 3376 match(rax_RegP); 3377 match(rbx_RegP); 3378 match(rdi_RegP); 3379 match(rsi_RegP); 3380 match(rbp_RegP); // See Q&A below about 3381 match(r15_RegP); // r15_RegP and rbp_RegP. 3382 3383 format %{ %} 3384 interface(REG_INTER); 3385 %} 3386 3387 operand rRegN() %{ 3388 constraint(ALLOC_IN_RC(int_reg)); 3389 match(RegN); 3390 3391 format %{ %} 3392 interface(REG_INTER); 3393 %} 3394 3395 // Question: Why is r15_RegP (the read-only TLS register) a match for rRegP? 3396 // Answer: Operand match rules govern the DFA as it processes instruction inputs. 3397 // It's fine for an instruction input that expects rRegP to match a r15_RegP. 3398 // The output of an instruction is controlled by the allocator, which respects 3399 // register class masks, not match rules. Unless an instruction mentions 3400 // r15_RegP or any_RegP explicitly as its output, r15 will not be considered 3401 // by the allocator as an input. 3402 // The same logic applies to rbp_RegP being a match for rRegP: If PreserveFramePointer==true, 3403 // the RBP is used as a proper frame pointer and is not included in ptr_reg. As a 3404 // result, RBP is not included in the output of the instruction either. 3405 3406 operand no_rax_RegP() 3407 %{ 3408 constraint(ALLOC_IN_RC(ptr_no_rax_reg)); 3409 match(RegP); 3410 match(rbx_RegP); 3411 match(rsi_RegP); 3412 match(rdi_RegP); 3413 3414 format %{ %} 3415 interface(REG_INTER); 3416 %} 3417 3418 // This operand is not allowed to use RBP even if 3419 // RBP is not used to hold the frame pointer. 3420 operand no_rbp_RegP() 3421 %{ 3422 constraint(ALLOC_IN_RC(ptr_reg_no_rbp)); 3423 match(RegP); 3424 match(rbx_RegP); 3425 match(rsi_RegP); 3426 match(rdi_RegP); 3427 3428 format %{ %} 3429 interface(REG_INTER); 3430 %} 3431 3432 operand no_rax_rbx_RegP() 3433 %{ 3434 constraint(ALLOC_IN_RC(ptr_no_rax_rbx_reg)); 3435 match(RegP); 3436 match(rsi_RegP); 3437 match(rdi_RegP); 3438 3439 format %{ %} 3440 interface(REG_INTER); 3441 %} 3442 3443 // Special Registers 3444 // Return a pointer value 3445 operand rax_RegP() 3446 %{ 3447 constraint(ALLOC_IN_RC(ptr_rax_reg)); 3448 match(RegP); 3449 match(rRegP); 3450 3451 format %{ %} 3452 interface(REG_INTER); 3453 %} 3454 3455 // Special Registers 3456 // Return a compressed pointer value 3457 operand rax_RegN() 3458 %{ 3459 constraint(ALLOC_IN_RC(int_rax_reg)); 3460 match(RegN); 3461 match(rRegN); 3462 3463 format %{ %} 3464 interface(REG_INTER); 3465 %} 3466 3467 // Used in AtomicAdd 3468 operand rbx_RegP() 3469 %{ 3470 constraint(ALLOC_IN_RC(ptr_rbx_reg)); 3471 match(RegP); 3472 match(rRegP); 3473 3474 format %{ %} 3475 interface(REG_INTER); 3476 %} 3477 3478 operand rsi_RegP() 3479 %{ 3480 constraint(ALLOC_IN_RC(ptr_rsi_reg)); 3481 match(RegP); 3482 match(rRegP); 3483 3484 format %{ %} 3485 interface(REG_INTER); 3486 %} 3487 3488 // Used in rep stosq 3489 operand rdi_RegP() 3490 %{ 3491 constraint(ALLOC_IN_RC(ptr_rdi_reg)); 3492 match(RegP); 3493 match(rRegP); 3494 3495 format %{ %} 3496 interface(REG_INTER); 3497 %} 3498 3499 operand r15_RegP() 3500 %{ 3501 constraint(ALLOC_IN_RC(ptr_r15_reg)); 3502 match(RegP); 3503 match(rRegP); 3504 3505 format %{ %} 3506 interface(REG_INTER); 3507 %} 3508 3509 operand rRegL() 3510 %{ 3511 constraint(ALLOC_IN_RC(long_reg)); 3512 match(RegL); 3513 match(rax_RegL); 3514 match(rdx_RegL); 3515 3516 format %{ %} 3517 interface(REG_INTER); 3518 %} 3519 3520 // Special Registers 3521 operand no_rax_rdx_RegL() 3522 %{ 3523 constraint(ALLOC_IN_RC(long_no_rax_rdx_reg)); 3524 match(RegL); 3525 match(rRegL); 3526 3527 format %{ %} 3528 interface(REG_INTER); 3529 %} 3530 3531 operand no_rax_RegL() 3532 %{ 3533 constraint(ALLOC_IN_RC(long_no_rax_rdx_reg)); 3534 match(RegL); 3535 match(rRegL); 3536 match(rdx_RegL); 3537 3538 format %{ %} 3539 interface(REG_INTER); 3540 %} 3541 3542 operand no_rcx_RegL() 3543 %{ 3544 constraint(ALLOC_IN_RC(long_no_rcx_reg)); 3545 match(RegL); 3546 match(rRegL); 3547 3548 format %{ %} 3549 interface(REG_INTER); 3550 %} 3551 3552 operand rax_RegL() 3553 %{ 3554 constraint(ALLOC_IN_RC(long_rax_reg)); 3555 match(RegL); 3556 match(rRegL); 3557 3558 format %{ "RAX" %} 3559 interface(REG_INTER); 3560 %} 3561 3562 operand rcx_RegL() 3563 %{ 3564 constraint(ALLOC_IN_RC(long_rcx_reg)); 3565 match(RegL); 3566 match(rRegL); 3567 3568 format %{ %} 3569 interface(REG_INTER); 3570 %} 3571 3572 operand rdx_RegL() 3573 %{ 3574 constraint(ALLOC_IN_RC(long_rdx_reg)); 3575 match(RegL); 3576 match(rRegL); 3577 3578 format %{ %} 3579 interface(REG_INTER); 3580 %} 3581 3582 // Flags register, used as output of compare instructions 3583 operand rFlagsReg() 3584 %{ 3585 constraint(ALLOC_IN_RC(int_flags)); 3586 match(RegFlags); 3587 3588 format %{ "RFLAGS" %} 3589 interface(REG_INTER); 3590 %} 3591 3592 // Flags register, used as output of FLOATING POINT compare instructions 3593 operand rFlagsRegU() 3594 %{ 3595 constraint(ALLOC_IN_RC(int_flags)); 3596 match(RegFlags); 3597 3598 format %{ "RFLAGS_U" %} 3599 interface(REG_INTER); 3600 %} 3601 3602 operand rFlagsRegUCF() %{ 3603 constraint(ALLOC_IN_RC(int_flags)); 3604 match(RegFlags); 3605 predicate(false); 3606 3607 format %{ "RFLAGS_U_CF" %} 3608 interface(REG_INTER); 3609 %} 3610 3611 // Float register operands 3612 operand regF() %{ 3613 constraint(ALLOC_IN_RC(float_reg)); 3614 match(RegF); 3615 3616 format %{ %} 3617 interface(REG_INTER); 3618 %} 3619 3620 // Double register operands 3621 operand regD() %{ 3622 constraint(ALLOC_IN_RC(double_reg)); 3623 match(RegD); 3624 3625 format %{ %} 3626 interface(REG_INTER); 3627 %} 3628 3629 // Vectors 3630 operand vecS() %{ 3631 constraint(ALLOC_IN_RC(vectors_reg)); 3632 match(VecS); 3633 3634 format %{ %} 3635 interface(REG_INTER); 3636 %} 3637 3638 operand vecD() %{ 3639 constraint(ALLOC_IN_RC(vectord_reg)); 3640 match(VecD); 3641 3642 format %{ %} 3643 interface(REG_INTER); 3644 %} 3645 3646 operand vecX() %{ 3647 constraint(ALLOC_IN_RC(vectorx_reg)); 3648 match(VecX); 3649 3650 format %{ %} 3651 interface(REG_INTER); 3652 %} 3653 3654 operand vecY() %{ 3655 constraint(ALLOC_IN_RC(vectory_reg)); 3656 match(VecY); 3657 3658 format %{ %} 3659 interface(REG_INTER); 3660 %} 3661 3662 //----------Memory Operands---------------------------------------------------- 3663 // Direct Memory Operand 3664 // operand direct(immP addr) 3665 // %{ 3666 // match(addr); 3667 3668 // format %{ "[$addr]" %} 3669 // interface(MEMORY_INTER) %{ 3670 // base(0xFFFFFFFF); 3671 // index(0x4); 3672 // scale(0x0); 3673 // disp($addr); 3674 // %} 3675 // %} 3676 3677 // Indirect Memory Operand 3678 operand indirect(any_RegP reg) 3679 %{ 3680 constraint(ALLOC_IN_RC(ptr_reg)); 3681 match(reg); 3682 3683 format %{ "[$reg]" %} 3684 interface(MEMORY_INTER) %{ 3685 base($reg); 3686 index(0x4); 3687 scale(0x0); 3688 disp(0x0); 3689 %} 3690 %} 3691 3692 // Indirect Memory Plus Short Offset Operand 3693 operand indOffset8(any_RegP reg, immL8 off) 3694 %{ 3695 constraint(ALLOC_IN_RC(ptr_reg)); 3696 match(AddP reg off); 3697 3698 format %{ "[$reg + $off (8-bit)]" %} 3699 interface(MEMORY_INTER) %{ 3700 base($reg); 3701 index(0x4); 3702 scale(0x0); 3703 disp($off); 3704 %} 3705 %} 3706 3707 // Indirect Memory Plus Long Offset Operand 3708 operand indOffset32(any_RegP reg, immL32 off) 3709 %{ 3710 constraint(ALLOC_IN_RC(ptr_reg)); 3711 match(AddP reg off); 3712 3713 format %{ "[$reg + $off (32-bit)]" %} 3714 interface(MEMORY_INTER) %{ 3715 base($reg); 3716 index(0x4); 3717 scale(0x0); 3718 disp($off); 3719 %} 3720 %} 3721 3722 // Indirect Memory Plus Index Register Plus Offset Operand 3723 operand indIndexOffset(any_RegP reg, rRegL lreg, immL32 off) 3724 %{ 3725 constraint(ALLOC_IN_RC(ptr_reg)); 3726 match(AddP (AddP reg lreg) off); 3727 3728 op_cost(10); 3729 format %{"[$reg + $off + $lreg]" %} 3730 interface(MEMORY_INTER) %{ 3731 base($reg); 3732 index($lreg); 3733 scale(0x0); 3734 disp($off); 3735 %} 3736 %} 3737 3738 // Indirect Memory Plus Index Register Plus Offset Operand 3739 operand indIndex(any_RegP reg, rRegL lreg) 3740 %{ 3741 constraint(ALLOC_IN_RC(ptr_reg)); 3742 match(AddP reg lreg); 3743 3744 op_cost(10); 3745 format %{"[$reg + $lreg]" %} 3746 interface(MEMORY_INTER) %{ 3747 base($reg); 3748 index($lreg); 3749 scale(0x0); 3750 disp(0x0); 3751 %} 3752 %} 3753 3754 // Indirect Memory Times Scale Plus Index Register 3755 operand indIndexScale(any_RegP reg, rRegL lreg, immI2 scale) 3756 %{ 3757 constraint(ALLOC_IN_RC(ptr_reg)); 3758 match(AddP reg (LShiftL lreg scale)); 3759 3760 op_cost(10); 3761 format %{"[$reg + $lreg << $scale]" %} 3762 interface(MEMORY_INTER) %{ 3763 base($reg); 3764 index($lreg); 3765 scale($scale); 3766 disp(0x0); 3767 %} 3768 %} 3769 3770 // Indirect Memory Times Scale Plus Index Register Plus Offset Operand 3771 operand indIndexScaleOffset(any_RegP reg, immL32 off, rRegL lreg, immI2 scale) 3772 %{ 3773 constraint(ALLOC_IN_RC(ptr_reg)); 3774 match(AddP (AddP reg (LShiftL lreg scale)) off); 3775 3776 op_cost(10); 3777 format %{"[$reg + $off + $lreg << $scale]" %} 3778 interface(MEMORY_INTER) %{ 3779 base($reg); 3780 index($lreg); 3781 scale($scale); 3782 disp($off); 3783 %} 3784 %} 3785 3786 // Indirect Memory Plus Positive Index Register Plus Offset Operand 3787 operand indPosIndexOffset(any_RegP reg, immL32 off, rRegI idx) 3788 %{ 3789 constraint(ALLOC_IN_RC(ptr_reg)); 3790 predicate(n->in(2)->in(3)->as_Type()->type()->is_long()->_lo >= 0); 3791 match(AddP (AddP reg (ConvI2L idx)) off); 3792 3793 op_cost(10); 3794 format %{"[$reg + $off + $idx]" %} 3795 interface(MEMORY_INTER) %{ 3796 base($reg); 3797 index($idx); 3798 scale(0x0); 3799 disp($off); 3800 %} 3801 %} 3802 3803 // Indirect Memory Times Scale Plus Positive Index Register Plus Offset Operand 3804 operand indPosIndexScaleOffset(any_RegP reg, immL32 off, rRegI idx, immI2 scale) 3805 %{ 3806 constraint(ALLOC_IN_RC(ptr_reg)); 3807 predicate(n->in(2)->in(3)->in(1)->as_Type()->type()->is_long()->_lo >= 0); 3808 match(AddP (AddP reg (LShiftL (ConvI2L idx) scale)) off); 3809 3810 op_cost(10); 3811 format %{"[$reg + $off + $idx << $scale]" %} 3812 interface(MEMORY_INTER) %{ 3813 base($reg); 3814 index($idx); 3815 scale($scale); 3816 disp($off); 3817 %} 3818 %} 3819 3820 // Indirect Narrow Oop Plus Offset Operand 3821 // Note: x86 architecture doesn't support "scale * index + offset" without a base 3822 // we can't free r12 even with Universe::narrow_oop_base() == NULL. 3823 operand indCompressedOopOffset(rRegN reg, immL32 off) %{ 3824 predicate(UseCompressedOops && (Universe::narrow_oop_shift() == Address::times_8)); 3825 constraint(ALLOC_IN_RC(ptr_reg)); 3826 match(AddP (DecodeN reg) off); 3827 3828 op_cost(10); 3829 format %{"[R12 + $reg << 3 + $off] (compressed oop addressing)" %} 3830 interface(MEMORY_INTER) %{ 3831 base(0xc); // R12 3832 index($reg); 3833 scale(0x3); 3834 disp($off); 3835 %} 3836 %} 3837 3838 // Indirect Memory Operand 3839 operand indirectNarrow(rRegN reg) 3840 %{ 3841 predicate(Universe::narrow_oop_shift() == 0); 3842 constraint(ALLOC_IN_RC(ptr_reg)); 3843 match(DecodeN reg); 3844 3845 format %{ "[$reg]" %} 3846 interface(MEMORY_INTER) %{ 3847 base($reg); 3848 index(0x4); 3849 scale(0x0); 3850 disp(0x0); 3851 %} 3852 %} 3853 3854 // Indirect Memory Plus Short Offset Operand 3855 operand indOffset8Narrow(rRegN reg, immL8 off) 3856 %{ 3857 predicate(Universe::narrow_oop_shift() == 0); 3858 constraint(ALLOC_IN_RC(ptr_reg)); 3859 match(AddP (DecodeN reg) off); 3860 3861 format %{ "[$reg + $off (8-bit)]" %} 3862 interface(MEMORY_INTER) %{ 3863 base($reg); 3864 index(0x4); 3865 scale(0x0); 3866 disp($off); 3867 %} 3868 %} 3869 3870 // Indirect Memory Plus Long Offset Operand 3871 operand indOffset32Narrow(rRegN reg, immL32 off) 3872 %{ 3873 predicate(Universe::narrow_oop_shift() == 0); 3874 constraint(ALLOC_IN_RC(ptr_reg)); 3875 match(AddP (DecodeN reg) off); 3876 3877 format %{ "[$reg + $off (32-bit)]" %} 3878 interface(MEMORY_INTER) %{ 3879 base($reg); 3880 index(0x4); 3881 scale(0x0); 3882 disp($off); 3883 %} 3884 %} 3885 3886 // Indirect Memory Plus Index Register Plus Offset Operand 3887 operand indIndexOffsetNarrow(rRegN reg, rRegL lreg, immL32 off) 3888 %{ 3889 predicate(Universe::narrow_oop_shift() == 0); 3890 constraint(ALLOC_IN_RC(ptr_reg)); 3891 match(AddP (AddP (DecodeN reg) lreg) off); 3892 3893 op_cost(10); 3894 format %{"[$reg + $off + $lreg]" %} 3895 interface(MEMORY_INTER) %{ 3896 base($reg); 3897 index($lreg); 3898 scale(0x0); 3899 disp($off); 3900 %} 3901 %} 3902 3903 // Indirect Memory Plus Index Register Plus Offset Operand 3904 operand indIndexNarrow(rRegN reg, rRegL lreg) 3905 %{ 3906 predicate(Universe::narrow_oop_shift() == 0); 3907 constraint(ALLOC_IN_RC(ptr_reg)); 3908 match(AddP (DecodeN reg) lreg); 3909 3910 op_cost(10); 3911 format %{"[$reg + $lreg]" %} 3912 interface(MEMORY_INTER) %{ 3913 base($reg); 3914 index($lreg); 3915 scale(0x0); 3916 disp(0x0); 3917 %} 3918 %} 3919 3920 // Indirect Memory Times Scale Plus Index Register 3921 operand indIndexScaleNarrow(rRegN reg, rRegL lreg, immI2 scale) 3922 %{ 3923 predicate(Universe::narrow_oop_shift() == 0); 3924 constraint(ALLOC_IN_RC(ptr_reg)); 3925 match(AddP (DecodeN reg) (LShiftL lreg scale)); 3926 3927 op_cost(10); 3928 format %{"[$reg + $lreg << $scale]" %} 3929 interface(MEMORY_INTER) %{ 3930 base($reg); 3931 index($lreg); 3932 scale($scale); 3933 disp(0x0); 3934 %} 3935 %} 3936 3937 // Indirect Memory Times Scale Plus Index Register Plus Offset Operand 3938 operand indIndexScaleOffsetNarrow(rRegN reg, immL32 off, rRegL lreg, immI2 scale) 3939 %{ 3940 predicate(Universe::narrow_oop_shift() == 0); 3941 constraint(ALLOC_IN_RC(ptr_reg)); 3942 match(AddP (AddP (DecodeN reg) (LShiftL lreg scale)) off); 3943 3944 op_cost(10); 3945 format %{"[$reg + $off + $lreg << $scale]" %} 3946 interface(MEMORY_INTER) %{ 3947 base($reg); 3948 index($lreg); 3949 scale($scale); 3950 disp($off); 3951 %} 3952 %} 3953 3954 // Indirect Memory Times Plus Positive Index Register Plus Offset Operand 3955 operand indPosIndexOffsetNarrow(rRegN reg, immL32 off, rRegI idx) 3956 %{ 3957 constraint(ALLOC_IN_RC(ptr_reg)); 3958 predicate(Universe::narrow_oop_shift() == 0 && n->in(2)->in(3)->as_Type()->type()->is_long()->_lo >= 0); 3959 match(AddP (AddP (DecodeN reg) (ConvI2L idx)) off); 3960 3961 op_cost(10); 3962 format %{"[$reg + $off + $idx]" %} 3963 interface(MEMORY_INTER) %{ 3964 base($reg); 3965 index($idx); 3966 scale(0x0); 3967 disp($off); 3968 %} 3969 %} 3970 3971 // Indirect Memory Times Scale Plus Positive Index Register Plus Offset Operand 3972 operand indPosIndexScaleOffsetNarrow(rRegN reg, immL32 off, rRegI idx, immI2 scale) 3973 %{ 3974 constraint(ALLOC_IN_RC(ptr_reg)); 3975 predicate(Universe::narrow_oop_shift() == 0 && n->in(2)->in(3)->in(1)->as_Type()->type()->is_long()->_lo >= 0); 3976 match(AddP (AddP (DecodeN reg) (LShiftL (ConvI2L idx) scale)) off); 3977 3978 op_cost(10); 3979 format %{"[$reg + $off + $idx << $scale]" %} 3980 interface(MEMORY_INTER) %{ 3981 base($reg); 3982 index($idx); 3983 scale($scale); 3984 disp($off); 3985 %} 3986 %} 3987 3988 //----------Special Memory Operands-------------------------------------------- 3989 // Stack Slot Operand - This operand is used for loading and storing temporary 3990 // values on the stack where a match requires a value to 3991 // flow through memory. 3992 operand stackSlotP(sRegP reg) 3993 %{ 3994 constraint(ALLOC_IN_RC(stack_slots)); 3995 // No match rule because this operand is only generated in matching 3996 3997 format %{ "[$reg]" %} 3998 interface(MEMORY_INTER) %{ 3999 base(0x4); // RSP 4000 index(0x4); // No Index 4001 scale(0x0); // No Scale 4002 disp($reg); // Stack Offset 4003 %} 4004 %} 4005 4006 operand stackSlotI(sRegI reg) 4007 %{ 4008 constraint(ALLOC_IN_RC(stack_slots)); 4009 // No match rule because this operand is only generated in matching 4010 4011 format %{ "[$reg]" %} 4012 interface(MEMORY_INTER) %{ 4013 base(0x4); // RSP 4014 index(0x4); // No Index 4015 scale(0x0); // No Scale 4016 disp($reg); // Stack Offset 4017 %} 4018 %} 4019 4020 operand stackSlotF(sRegF reg) 4021 %{ 4022 constraint(ALLOC_IN_RC(stack_slots)); 4023 // No match rule because this operand is only generated in matching 4024 4025 format %{ "[$reg]" %} 4026 interface(MEMORY_INTER) %{ 4027 base(0x4); // RSP 4028 index(0x4); // No Index 4029 scale(0x0); // No Scale 4030 disp($reg); // Stack Offset 4031 %} 4032 %} 4033 4034 operand stackSlotD(sRegD reg) 4035 %{ 4036 constraint(ALLOC_IN_RC(stack_slots)); 4037 // No match rule because this operand is only generated in matching 4038 4039 format %{ "[$reg]" %} 4040 interface(MEMORY_INTER) %{ 4041 base(0x4); // RSP 4042 index(0x4); // No Index 4043 scale(0x0); // No Scale 4044 disp($reg); // Stack Offset 4045 %} 4046 %} 4047 operand stackSlotL(sRegL reg) 4048 %{ 4049 constraint(ALLOC_IN_RC(stack_slots)); 4050 // No match rule because this operand is only generated in matching 4051 4052 format %{ "[$reg]" %} 4053 interface(MEMORY_INTER) %{ 4054 base(0x4); // RSP 4055 index(0x4); // No Index 4056 scale(0x0); // No Scale 4057 disp($reg); // Stack Offset 4058 %} 4059 %} 4060 4061 //----------Conditional Branch Operands---------------------------------------- 4062 // Comparison Op - This is the operation of the comparison, and is limited to 4063 // the following set of codes: 4064 // L (<), LE (<=), G (>), GE (>=), E (==), NE (!=) 4065 // 4066 // Other attributes of the comparison, such as unsignedness, are specified 4067 // by the comparison instruction that sets a condition code flags register. 4068 // That result is represented by a flags operand whose subtype is appropriate 4069 // to the unsignedness (etc.) of the comparison. 4070 // 4071 // Later, the instruction which matches both the Comparison Op (a Bool) and 4072 // the flags (produced by the Cmp) specifies the coding of the comparison op 4073 // by matching a specific subtype of Bool operand below, such as cmpOpU. 4074 4075 // Comparision Code 4076 operand cmpOp() 4077 %{ 4078 match(Bool); 4079 4080 format %{ "" %} 4081 interface(COND_INTER) %{ 4082 equal(0x4, "e"); 4083 not_equal(0x5, "ne"); 4084 less(0xC, "l"); 4085 greater_equal(0xD, "ge"); 4086 less_equal(0xE, "le"); 4087 greater(0xF, "g"); 4088 overflow(0x0, "o"); 4089 no_overflow(0x1, "no"); 4090 %} 4091 %} 4092 4093 // Comparison Code, unsigned compare. Used by FP also, with 4094 // C2 (unordered) turned into GT or LT already. The other bits 4095 // C0 and C3 are turned into Carry & Zero flags. 4096 operand cmpOpU() 4097 %{ 4098 match(Bool); 4099 4100 format %{ "" %} 4101 interface(COND_INTER) %{ 4102 equal(0x4, "e"); 4103 not_equal(0x5, "ne"); 4104 less(0x2, "b"); 4105 greater_equal(0x3, "nb"); 4106 less_equal(0x6, "be"); 4107 greater(0x7, "nbe"); 4108 overflow(0x0, "o"); 4109 no_overflow(0x1, "no"); 4110 %} 4111 %} 4112 4113 4114 // Floating comparisons that don't require any fixup for the unordered case 4115 operand cmpOpUCF() %{ 4116 match(Bool); 4117 predicate(n->as_Bool()->_test._test == BoolTest::lt || 4118 n->as_Bool()->_test._test == BoolTest::ge || 4119 n->as_Bool()->_test._test == BoolTest::le || 4120 n->as_Bool()->_test._test == BoolTest::gt); 4121 format %{ "" %} 4122 interface(COND_INTER) %{ 4123 equal(0x4, "e"); 4124 not_equal(0x5, "ne"); 4125 less(0x2, "b"); 4126 greater_equal(0x3, "nb"); 4127 less_equal(0x6, "be"); 4128 greater(0x7, "nbe"); 4129 overflow(0x0, "o"); 4130 no_overflow(0x1, "no"); 4131 %} 4132 %} 4133 4134 4135 // Floating comparisons that can be fixed up with extra conditional jumps 4136 operand cmpOpUCF2() %{ 4137 match(Bool); 4138 predicate(n->as_Bool()->_test._test == BoolTest::ne || 4139 n->as_Bool()->_test._test == BoolTest::eq); 4140 format %{ "" %} 4141 interface(COND_INTER) %{ 4142 equal(0x4, "e"); 4143 not_equal(0x5, "ne"); 4144 less(0x2, "b"); 4145 greater_equal(0x3, "nb"); 4146 less_equal(0x6, "be"); 4147 greater(0x7, "nbe"); 4148 overflow(0x0, "o"); 4149 no_overflow(0x1, "no"); 4150 %} 4151 %} 4152 4153 4154 //----------OPERAND CLASSES---------------------------------------------------- 4155 // Operand Classes are groups of operands that are used as to simplify 4156 // instruction definitions by not requiring the AD writer to specify separate 4157 // instructions for every form of operand when the instruction accepts 4158 // multiple operand types with the same basic encoding and format. The classic 4159 // case of this is memory operands. 4160 4161 opclass memory(indirect, indOffset8, indOffset32, indIndexOffset, indIndex, 4162 indIndexScale, indIndexScaleOffset, indPosIndexOffset, indPosIndexScaleOffset, 4163 indCompressedOopOffset, 4164 indirectNarrow, indOffset8Narrow, indOffset32Narrow, 4165 indIndexOffsetNarrow, indIndexNarrow, indIndexScaleNarrow, 4166 indIndexScaleOffsetNarrow, indPosIndexOffsetNarrow, indPosIndexScaleOffsetNarrow); 4167 4168 //----------PIPELINE----------------------------------------------------------- 4169 // Rules which define the behavior of the target architectures pipeline. 4170 pipeline %{ 4171 4172 //----------ATTRIBUTES--------------------------------------------------------- 4173 attributes %{ 4174 variable_size_instructions; // Fixed size instructions 4175 max_instructions_per_bundle = 3; // Up to 3 instructions per bundle 4176 instruction_unit_size = 1; // An instruction is 1 bytes long 4177 instruction_fetch_unit_size = 16; // The processor fetches one line 4178 instruction_fetch_units = 1; // of 16 bytes 4179 4180 // List of nop instructions 4181 nops( MachNop ); 4182 %} 4183 4184 //----------RESOURCES---------------------------------------------------------- 4185 // Resources are the functional units available to the machine 4186 4187 // Generic P2/P3 pipeline 4188 // 3 decoders, only D0 handles big operands; a "bundle" is the limit of 4189 // 3 instructions decoded per cycle. 4190 // 2 load/store ops per cycle, 1 branch, 1 FPU, 4191 // 3 ALU op, only ALU0 handles mul instructions. 4192 resources( D0, D1, D2, DECODE = D0 | D1 | D2, 4193 MS0, MS1, MS2, MEM = MS0 | MS1 | MS2, 4194 BR, FPU, 4195 ALU0, ALU1, ALU2, ALU = ALU0 | ALU1 | ALU2); 4196 4197 //----------PIPELINE DESCRIPTION----------------------------------------------- 4198 // Pipeline Description specifies the stages in the machine's pipeline 4199 4200 // Generic P2/P3 pipeline 4201 pipe_desc(S0, S1, S2, S3, S4, S5); 4202 4203 //----------PIPELINE CLASSES--------------------------------------------------- 4204 // Pipeline Classes describe the stages in which input and output are 4205 // referenced by the hardware pipeline. 4206 4207 // Naming convention: ialu or fpu 4208 // Then: _reg 4209 // Then: _reg if there is a 2nd register 4210 // Then: _long if it's a pair of instructions implementing a long 4211 // Then: _fat if it requires the big decoder 4212 // Or: _mem if it requires the big decoder and a memory unit. 4213 4214 // Integer ALU reg operation 4215 pipe_class ialu_reg(rRegI dst) 4216 %{ 4217 single_instruction; 4218 dst : S4(write); 4219 dst : S3(read); 4220 DECODE : S0; // any decoder 4221 ALU : S3; // any alu 4222 %} 4223 4224 // Long ALU reg operation 4225 pipe_class ialu_reg_long(rRegL dst) 4226 %{ 4227 instruction_count(2); 4228 dst : S4(write); 4229 dst : S3(read); 4230 DECODE : S0(2); // any 2 decoders 4231 ALU : S3(2); // both alus 4232 %} 4233 4234 // Integer ALU reg operation using big decoder 4235 pipe_class ialu_reg_fat(rRegI dst) 4236 %{ 4237 single_instruction; 4238 dst : S4(write); 4239 dst : S3(read); 4240 D0 : S0; // big decoder only 4241 ALU : S3; // any alu 4242 %} 4243 4244 // Long ALU reg operation using big decoder 4245 pipe_class ialu_reg_long_fat(rRegL dst) 4246 %{ 4247 instruction_count(2); 4248 dst : S4(write); 4249 dst : S3(read); 4250 D0 : S0(2); // big decoder only; twice 4251 ALU : S3(2); // any 2 alus 4252 %} 4253 4254 // Integer ALU reg-reg operation 4255 pipe_class ialu_reg_reg(rRegI dst, rRegI src) 4256 %{ 4257 single_instruction; 4258 dst : S4(write); 4259 src : S3(read); 4260 DECODE : S0; // any decoder 4261 ALU : S3; // any alu 4262 %} 4263 4264 // Long ALU reg-reg operation 4265 pipe_class ialu_reg_reg_long(rRegL dst, rRegL src) 4266 %{ 4267 instruction_count(2); 4268 dst : S4(write); 4269 src : S3(read); 4270 DECODE : S0(2); // any 2 decoders 4271 ALU : S3(2); // both alus 4272 %} 4273 4274 // Integer ALU reg-reg operation 4275 pipe_class ialu_reg_reg_fat(rRegI dst, memory src) 4276 %{ 4277 single_instruction; 4278 dst : S4(write); 4279 src : S3(read); 4280 D0 : S0; // big decoder only 4281 ALU : S3; // any alu 4282 %} 4283 4284 // Long ALU reg-reg operation 4285 pipe_class ialu_reg_reg_long_fat(rRegL dst, rRegL src) 4286 %{ 4287 instruction_count(2); 4288 dst : S4(write); 4289 src : S3(read); 4290 D0 : S0(2); // big decoder only; twice 4291 ALU : S3(2); // both alus 4292 %} 4293 4294 // Integer ALU reg-mem operation 4295 pipe_class ialu_reg_mem(rRegI dst, memory mem) 4296 %{ 4297 single_instruction; 4298 dst : S5(write); 4299 mem : S3(read); 4300 D0 : S0; // big decoder only 4301 ALU : S4; // any alu 4302 MEM : S3; // any mem 4303 %} 4304 4305 // Integer mem operation (prefetch) 4306 pipe_class ialu_mem(memory mem) 4307 %{ 4308 single_instruction; 4309 mem : S3(read); 4310 D0 : S0; // big decoder only 4311 MEM : S3; // any mem 4312 %} 4313 4314 // Integer Store to Memory 4315 pipe_class ialu_mem_reg(memory mem, rRegI src) 4316 %{ 4317 single_instruction; 4318 mem : S3(read); 4319 src : S5(read); 4320 D0 : S0; // big decoder only 4321 ALU : S4; // any alu 4322 MEM : S3; 4323 %} 4324 4325 // // Long Store to Memory 4326 // pipe_class ialu_mem_long_reg(memory mem, rRegL src) 4327 // %{ 4328 // instruction_count(2); 4329 // mem : S3(read); 4330 // src : S5(read); 4331 // D0 : S0(2); // big decoder only; twice 4332 // ALU : S4(2); // any 2 alus 4333 // MEM : S3(2); // Both mems 4334 // %} 4335 4336 // Integer Store to Memory 4337 pipe_class ialu_mem_imm(memory mem) 4338 %{ 4339 single_instruction; 4340 mem : S3(read); 4341 D0 : S0; // big decoder only 4342 ALU : S4; // any alu 4343 MEM : S3; 4344 %} 4345 4346 // Integer ALU0 reg-reg operation 4347 pipe_class ialu_reg_reg_alu0(rRegI dst, rRegI src) 4348 %{ 4349 single_instruction; 4350 dst : S4(write); 4351 src : S3(read); 4352 D0 : S0; // Big decoder only 4353 ALU0 : S3; // only alu0 4354 %} 4355 4356 // Integer ALU0 reg-mem operation 4357 pipe_class ialu_reg_mem_alu0(rRegI dst, memory mem) 4358 %{ 4359 single_instruction; 4360 dst : S5(write); 4361 mem : S3(read); 4362 D0 : S0; // big decoder only 4363 ALU0 : S4; // ALU0 only 4364 MEM : S3; // any mem 4365 %} 4366 4367 // Integer ALU reg-reg operation 4368 pipe_class ialu_cr_reg_reg(rFlagsReg cr, rRegI src1, rRegI src2) 4369 %{ 4370 single_instruction; 4371 cr : S4(write); 4372 src1 : S3(read); 4373 src2 : S3(read); 4374 DECODE : S0; // any decoder 4375 ALU : S3; // any alu 4376 %} 4377 4378 // Integer ALU reg-imm operation 4379 pipe_class ialu_cr_reg_imm(rFlagsReg cr, rRegI src1) 4380 %{ 4381 single_instruction; 4382 cr : S4(write); 4383 src1 : S3(read); 4384 DECODE : S0; // any decoder 4385 ALU : S3; // any alu 4386 %} 4387 4388 // Integer ALU reg-mem operation 4389 pipe_class ialu_cr_reg_mem(rFlagsReg cr, rRegI src1, memory src2) 4390 %{ 4391 single_instruction; 4392 cr : S4(write); 4393 src1 : S3(read); 4394 src2 : S3(read); 4395 D0 : S0; // big decoder only 4396 ALU : S4; // any alu 4397 MEM : S3; 4398 %} 4399 4400 // Conditional move reg-reg 4401 pipe_class pipe_cmplt( rRegI p, rRegI q, rRegI y) 4402 %{ 4403 instruction_count(4); 4404 y : S4(read); 4405 q : S3(read); 4406 p : S3(read); 4407 DECODE : S0(4); // any decoder 4408 %} 4409 4410 // Conditional move reg-reg 4411 pipe_class pipe_cmov_reg( rRegI dst, rRegI src, rFlagsReg cr) 4412 %{ 4413 single_instruction; 4414 dst : S4(write); 4415 src : S3(read); 4416 cr : S3(read); 4417 DECODE : S0; // any decoder 4418 %} 4419 4420 // Conditional move reg-mem 4421 pipe_class pipe_cmov_mem( rFlagsReg cr, rRegI dst, memory src) 4422 %{ 4423 single_instruction; 4424 dst : S4(write); 4425 src : S3(read); 4426 cr : S3(read); 4427 DECODE : S0; // any decoder 4428 MEM : S3; 4429 %} 4430 4431 // Conditional move reg-reg long 4432 pipe_class pipe_cmov_reg_long( rFlagsReg cr, rRegL dst, rRegL src) 4433 %{ 4434 single_instruction; 4435 dst : S4(write); 4436 src : S3(read); 4437 cr : S3(read); 4438 DECODE : S0(2); // any 2 decoders 4439 %} 4440 4441 // XXX 4442 // // Conditional move double reg-reg 4443 // pipe_class pipe_cmovD_reg( rFlagsReg cr, regDPR1 dst, regD src) 4444 // %{ 4445 // single_instruction; 4446 // dst : S4(write); 4447 // src : S3(read); 4448 // cr : S3(read); 4449 // DECODE : S0; // any decoder 4450 // %} 4451 4452 // Float reg-reg operation 4453 pipe_class fpu_reg(regD dst) 4454 %{ 4455 instruction_count(2); 4456 dst : S3(read); 4457 DECODE : S0(2); // any 2 decoders 4458 FPU : S3; 4459 %} 4460 4461 // Float reg-reg operation 4462 pipe_class fpu_reg_reg(regD dst, regD src) 4463 %{ 4464 instruction_count(2); 4465 dst : S4(write); 4466 src : S3(read); 4467 DECODE : S0(2); // any 2 decoders 4468 FPU : S3; 4469 %} 4470 4471 // Float reg-reg operation 4472 pipe_class fpu_reg_reg_reg(regD dst, regD src1, regD src2) 4473 %{ 4474 instruction_count(3); 4475 dst : S4(write); 4476 src1 : S3(read); 4477 src2 : S3(read); 4478 DECODE : S0(3); // any 3 decoders 4479 FPU : S3(2); 4480 %} 4481 4482 // Float reg-reg operation 4483 pipe_class fpu_reg_reg_reg_reg(regD dst, regD src1, regD src2, regD src3) 4484 %{ 4485 instruction_count(4); 4486 dst : S4(write); 4487 src1 : S3(read); 4488 src2 : S3(read); 4489 src3 : S3(read); 4490 DECODE : S0(4); // any 3 decoders 4491 FPU : S3(2); 4492 %} 4493 4494 // Float reg-reg operation 4495 pipe_class fpu_reg_mem_reg_reg(regD dst, memory src1, regD src2, regD src3) 4496 %{ 4497 instruction_count(4); 4498 dst : S4(write); 4499 src1 : S3(read); 4500 src2 : S3(read); 4501 src3 : S3(read); 4502 DECODE : S1(3); // any 3 decoders 4503 D0 : S0; // Big decoder only 4504 FPU : S3(2); 4505 MEM : S3; 4506 %} 4507 4508 // Float reg-mem operation 4509 pipe_class fpu_reg_mem(regD dst, memory mem) 4510 %{ 4511 instruction_count(2); 4512 dst : S5(write); 4513 mem : S3(read); 4514 D0 : S0; // big decoder only 4515 DECODE : S1; // any decoder for FPU POP 4516 FPU : S4; 4517 MEM : S3; // any mem 4518 %} 4519 4520 // Float reg-mem operation 4521 pipe_class fpu_reg_reg_mem(regD dst, regD src1, memory mem) 4522 %{ 4523 instruction_count(3); 4524 dst : S5(write); 4525 src1 : S3(read); 4526 mem : S3(read); 4527 D0 : S0; // big decoder only 4528 DECODE : S1(2); // any decoder for FPU POP 4529 FPU : S4; 4530 MEM : S3; // any mem 4531 %} 4532 4533 // Float mem-reg operation 4534 pipe_class fpu_mem_reg(memory mem, regD src) 4535 %{ 4536 instruction_count(2); 4537 src : S5(read); 4538 mem : S3(read); 4539 DECODE : S0; // any decoder for FPU PUSH 4540 D0 : S1; // big decoder only 4541 FPU : S4; 4542 MEM : S3; // any mem 4543 %} 4544 4545 pipe_class fpu_mem_reg_reg(memory mem, regD src1, regD src2) 4546 %{ 4547 instruction_count(3); 4548 src1 : S3(read); 4549 src2 : S3(read); 4550 mem : S3(read); 4551 DECODE : S0(2); // any decoder for FPU PUSH 4552 D0 : S1; // big decoder only 4553 FPU : S4; 4554 MEM : S3; // any mem 4555 %} 4556 4557 pipe_class fpu_mem_reg_mem(memory mem, regD src1, memory src2) 4558 %{ 4559 instruction_count(3); 4560 src1 : S3(read); 4561 src2 : S3(read); 4562 mem : S4(read); 4563 DECODE : S0; // any decoder for FPU PUSH 4564 D0 : S0(2); // big decoder only 4565 FPU : S4; 4566 MEM : S3(2); // any mem 4567 %} 4568 4569 pipe_class fpu_mem_mem(memory dst, memory src1) 4570 %{ 4571 instruction_count(2); 4572 src1 : S3(read); 4573 dst : S4(read); 4574 D0 : S0(2); // big decoder only 4575 MEM : S3(2); // any mem 4576 %} 4577 4578 pipe_class fpu_mem_mem_mem(memory dst, memory src1, memory src2) 4579 %{ 4580 instruction_count(3); 4581 src1 : S3(read); 4582 src2 : S3(read); 4583 dst : S4(read); 4584 D0 : S0(3); // big decoder only 4585 FPU : S4; 4586 MEM : S3(3); // any mem 4587 %} 4588 4589 pipe_class fpu_mem_reg_con(memory mem, regD src1) 4590 %{ 4591 instruction_count(3); 4592 src1 : S4(read); 4593 mem : S4(read); 4594 DECODE : S0; // any decoder for FPU PUSH 4595 D0 : S0(2); // big decoder only 4596 FPU : S4; 4597 MEM : S3(2); // any mem 4598 %} 4599 4600 // Float load constant 4601 pipe_class fpu_reg_con(regD dst) 4602 %{ 4603 instruction_count(2); 4604 dst : S5(write); 4605 D0 : S0; // big decoder only for the load 4606 DECODE : S1; // any decoder for FPU POP 4607 FPU : S4; 4608 MEM : S3; // any mem 4609 %} 4610 4611 // Float load constant 4612 pipe_class fpu_reg_reg_con(regD dst, regD src) 4613 %{ 4614 instruction_count(3); 4615 dst : S5(write); 4616 src : S3(read); 4617 D0 : S0; // big decoder only for the load 4618 DECODE : S1(2); // any decoder for FPU POP 4619 FPU : S4; 4620 MEM : S3; // any mem 4621 %} 4622 4623 // UnConditional branch 4624 pipe_class pipe_jmp(label labl) 4625 %{ 4626 single_instruction; 4627 BR : S3; 4628 %} 4629 4630 // Conditional branch 4631 pipe_class pipe_jcc(cmpOp cmp, rFlagsReg cr, label labl) 4632 %{ 4633 single_instruction; 4634 cr : S1(read); 4635 BR : S3; 4636 %} 4637 4638 // Allocation idiom 4639 pipe_class pipe_cmpxchg(rRegP dst, rRegP heap_ptr) 4640 %{ 4641 instruction_count(1); force_serialization; 4642 fixed_latency(6); 4643 heap_ptr : S3(read); 4644 DECODE : S0(3); 4645 D0 : S2; 4646 MEM : S3; 4647 ALU : S3(2); 4648 dst : S5(write); 4649 BR : S5; 4650 %} 4651 4652 // Generic big/slow expanded idiom 4653 pipe_class pipe_slow() 4654 %{ 4655 instruction_count(10); multiple_bundles; force_serialization; 4656 fixed_latency(100); 4657 D0 : S0(2); 4658 MEM : S3(2); 4659 %} 4660 4661 // The real do-nothing guy 4662 pipe_class empty() 4663 %{ 4664 instruction_count(0); 4665 %} 4666 4667 // Define the class for the Nop node 4668 define 4669 %{ 4670 MachNop = empty; 4671 %} 4672 4673 %} 4674 4675 //----------INSTRUCTIONS------------------------------------------------------- 4676 // 4677 // match -- States which machine-independent subtree may be replaced 4678 // by this instruction. 4679 // ins_cost -- The estimated cost of this instruction is used by instruction 4680 // selection to identify a minimum cost tree of machine 4681 // instructions that matches a tree of machine-independent 4682 // instructions. 4683 // format -- A string providing the disassembly for this instruction. 4684 // The value of an instruction's operand may be inserted 4685 // by referring to it with a '$' prefix. 4686 // opcode -- Three instruction opcodes may be provided. These are referred 4687 // to within an encode class as $primary, $secondary, and $tertiary 4688 // rrspectively. The primary opcode is commonly used to 4689 // indicate the type of machine instruction, while secondary 4690 // and tertiary are often used for prefix options or addressing 4691 // modes. 4692 // ins_encode -- A list of encode classes with parameters. The encode class 4693 // name must have been defined in an 'enc_class' specification 4694 // in the encode section of the architecture description. 4695 4696 4697 //----------Load/Store/Move Instructions--------------------------------------- 4698 //----------Load Instructions-------------------------------------------------- 4699 4700 // Load Byte (8 bit signed) 4701 instruct loadB(rRegI dst, memory mem) 4702 %{ 4703 match(Set dst (LoadB mem)); 4704 4705 ins_cost(125); 4706 format %{ "movsbl $dst, $mem\t# byte" %} 4707 4708 ins_encode %{ 4709 __ movsbl($dst$$Register, $mem$$Address); 4710 %} 4711 4712 ins_pipe(ialu_reg_mem); 4713 %} 4714 4715 // Load Byte (8 bit signed) into Long Register 4716 instruct loadB2L(rRegL dst, memory mem) 4717 %{ 4718 match(Set dst (ConvI2L (LoadB mem))); 4719 4720 ins_cost(125); 4721 format %{ "movsbq $dst, $mem\t# byte -> long" %} 4722 4723 ins_encode %{ 4724 __ movsbq($dst$$Register, $mem$$Address); 4725 %} 4726 4727 ins_pipe(ialu_reg_mem); 4728 %} 4729 4730 // Load Unsigned Byte (8 bit UNsigned) 4731 instruct loadUB(rRegI dst, memory mem) 4732 %{ 4733 match(Set dst (LoadUB mem)); 4734 4735 ins_cost(125); 4736 format %{ "movzbl $dst, $mem\t# ubyte" %} 4737 4738 ins_encode %{ 4739 __ movzbl($dst$$Register, $mem$$Address); 4740 %} 4741 4742 ins_pipe(ialu_reg_mem); 4743 %} 4744 4745 // Load Unsigned Byte (8 bit UNsigned) into Long Register 4746 instruct loadUB2L(rRegL dst, memory mem) 4747 %{ 4748 match(Set dst (ConvI2L (LoadUB mem))); 4749 4750 ins_cost(125); 4751 format %{ "movzbq $dst, $mem\t# ubyte -> long" %} 4752 4753 ins_encode %{ 4754 __ movzbq($dst$$Register, $mem$$Address); 4755 %} 4756 4757 ins_pipe(ialu_reg_mem); 4758 %} 4759 4760 // Load Unsigned Byte (8 bit UNsigned) with 32-bit mask into Long Register 4761 instruct loadUB2L_immI(rRegL dst, memory mem, immI mask, rFlagsReg cr) %{ 4762 match(Set dst (ConvI2L (AndI (LoadUB mem) mask))); 4763 effect(KILL cr); 4764 4765 format %{ "movzbq $dst, $mem\t# ubyte & 32-bit mask -> long\n\t" 4766 "andl $dst, right_n_bits($mask, 8)" %} 4767 ins_encode %{ 4768 Register Rdst = $dst$$Register; 4769 __ movzbq(Rdst, $mem$$Address); 4770 __ andl(Rdst, $mask$$constant & right_n_bits(8)); 4771 %} 4772 ins_pipe(ialu_reg_mem); 4773 %} 4774 4775 // Load Short (16 bit signed) 4776 instruct loadS(rRegI dst, memory mem) 4777 %{ 4778 match(Set dst (LoadS mem)); 4779 4780 ins_cost(125); 4781 format %{ "movswl $dst, $mem\t# short" %} 4782 4783 ins_encode %{ 4784 __ movswl($dst$$Register, $mem$$Address); 4785 %} 4786 4787 ins_pipe(ialu_reg_mem); 4788 %} 4789 4790 // Load Short (16 bit signed) to Byte (8 bit signed) 4791 instruct loadS2B(rRegI dst, memory mem, immI_24 twentyfour) %{ 4792 match(Set dst (RShiftI (LShiftI (LoadS mem) twentyfour) twentyfour)); 4793 4794 ins_cost(125); 4795 format %{ "movsbl $dst, $mem\t# short -> byte" %} 4796 ins_encode %{ 4797 __ movsbl($dst$$Register, $mem$$Address); 4798 %} 4799 ins_pipe(ialu_reg_mem); 4800 %} 4801 4802 // Load Short (16 bit signed) into Long Register 4803 instruct loadS2L(rRegL dst, memory mem) 4804 %{ 4805 match(Set dst (ConvI2L (LoadS mem))); 4806 4807 ins_cost(125); 4808 format %{ "movswq $dst, $mem\t# short -> long" %} 4809 4810 ins_encode %{ 4811 __ movswq($dst$$Register, $mem$$Address); 4812 %} 4813 4814 ins_pipe(ialu_reg_mem); 4815 %} 4816 4817 // Load Unsigned Short/Char (16 bit UNsigned) 4818 instruct loadUS(rRegI dst, memory mem) 4819 %{ 4820 match(Set dst (LoadUS mem)); 4821 4822 ins_cost(125); 4823 format %{ "movzwl $dst, $mem\t# ushort/char" %} 4824 4825 ins_encode %{ 4826 __ movzwl($dst$$Register, $mem$$Address); 4827 %} 4828 4829 ins_pipe(ialu_reg_mem); 4830 %} 4831 4832 // Load Unsigned Short/Char (16 bit UNsigned) to Byte (8 bit signed) 4833 instruct loadUS2B(rRegI dst, memory mem, immI_24 twentyfour) %{ 4834 match(Set dst (RShiftI (LShiftI (LoadUS mem) twentyfour) twentyfour)); 4835 4836 ins_cost(125); 4837 format %{ "movsbl $dst, $mem\t# ushort -> byte" %} 4838 ins_encode %{ 4839 __ movsbl($dst$$Register, $mem$$Address); 4840 %} 4841 ins_pipe(ialu_reg_mem); 4842 %} 4843 4844 // Load Unsigned Short/Char (16 bit UNsigned) into Long Register 4845 instruct loadUS2L(rRegL dst, memory mem) 4846 %{ 4847 match(Set dst (ConvI2L (LoadUS mem))); 4848 4849 ins_cost(125); 4850 format %{ "movzwq $dst, $mem\t# ushort/char -> long" %} 4851 4852 ins_encode %{ 4853 __ movzwq($dst$$Register, $mem$$Address); 4854 %} 4855 4856 ins_pipe(ialu_reg_mem); 4857 %} 4858 4859 // Load Unsigned Short/Char (16 bit UNsigned) with mask 0xFF into Long Register 4860 instruct loadUS2L_immI_255(rRegL dst, memory mem, immI_255 mask) %{ 4861 match(Set dst (ConvI2L (AndI (LoadUS mem) mask))); 4862 4863 format %{ "movzbq $dst, $mem\t# ushort/char & 0xFF -> long" %} 4864 ins_encode %{ 4865 __ movzbq($dst$$Register, $mem$$Address); 4866 %} 4867 ins_pipe(ialu_reg_mem); 4868 %} 4869 4870 // Load Unsigned Short/Char (16 bit UNsigned) with 32-bit mask into Long Register 4871 instruct loadUS2L_immI(rRegL dst, memory mem, immI mask, rFlagsReg cr) %{ 4872 match(Set dst (ConvI2L (AndI (LoadUS mem) mask))); 4873 effect(KILL cr); 4874 4875 format %{ "movzwq $dst, $mem\t# ushort/char & 32-bit mask -> long\n\t" 4876 "andl $dst, right_n_bits($mask, 16)" %} 4877 ins_encode %{ 4878 Register Rdst = $dst$$Register; 4879 __ movzwq(Rdst, $mem$$Address); 4880 __ andl(Rdst, $mask$$constant & right_n_bits(16)); 4881 %} 4882 ins_pipe(ialu_reg_mem); 4883 %} 4884 4885 // Load Integer 4886 instruct loadI(rRegI dst, memory mem) 4887 %{ 4888 match(Set dst (LoadI mem)); 4889 4890 ins_cost(125); 4891 format %{ "movl $dst, $mem\t# int" %} 4892 4893 ins_encode %{ 4894 __ movl($dst$$Register, $mem$$Address); 4895 %} 4896 4897 ins_pipe(ialu_reg_mem); 4898 %} 4899 4900 // Load Integer (32 bit signed) to Byte (8 bit signed) 4901 instruct loadI2B(rRegI dst, memory mem, immI_24 twentyfour) %{ 4902 match(Set dst (RShiftI (LShiftI (LoadI mem) twentyfour) twentyfour)); 4903 4904 ins_cost(125); 4905 format %{ "movsbl $dst, $mem\t# int -> byte" %} 4906 ins_encode %{ 4907 __ movsbl($dst$$Register, $mem$$Address); 4908 %} 4909 ins_pipe(ialu_reg_mem); 4910 %} 4911 4912 // Load Integer (32 bit signed) to Unsigned Byte (8 bit UNsigned) 4913 instruct loadI2UB(rRegI dst, memory mem, immI_255 mask) %{ 4914 match(Set dst (AndI (LoadI mem) mask)); 4915 4916 ins_cost(125); 4917 format %{ "movzbl $dst, $mem\t# int -> ubyte" %} 4918 ins_encode %{ 4919 __ movzbl($dst$$Register, $mem$$Address); 4920 %} 4921 ins_pipe(ialu_reg_mem); 4922 %} 4923 4924 // Load Integer (32 bit signed) to Short (16 bit signed) 4925 instruct loadI2S(rRegI dst, memory mem, immI_16 sixteen) %{ 4926 match(Set dst (RShiftI (LShiftI (LoadI mem) sixteen) sixteen)); 4927 4928 ins_cost(125); 4929 format %{ "movswl $dst, $mem\t# int -> short" %} 4930 ins_encode %{ 4931 __ movswl($dst$$Register, $mem$$Address); 4932 %} 4933 ins_pipe(ialu_reg_mem); 4934 %} 4935 4936 // Load Integer (32 bit signed) to Unsigned Short/Char (16 bit UNsigned) 4937 instruct loadI2US(rRegI dst, memory mem, immI_65535 mask) %{ 4938 match(Set dst (AndI (LoadI mem) mask)); 4939 4940 ins_cost(125); 4941 format %{ "movzwl $dst, $mem\t# int -> ushort/char" %} 4942 ins_encode %{ 4943 __ movzwl($dst$$Register, $mem$$Address); 4944 %} 4945 ins_pipe(ialu_reg_mem); 4946 %} 4947 4948 // Load Integer into Long Register 4949 instruct loadI2L(rRegL dst, memory mem) 4950 %{ 4951 match(Set dst (ConvI2L (LoadI mem))); 4952 4953 ins_cost(125); 4954 format %{ "movslq $dst, $mem\t# int -> long" %} 4955 4956 ins_encode %{ 4957 __ movslq($dst$$Register, $mem$$Address); 4958 %} 4959 4960 ins_pipe(ialu_reg_mem); 4961 %} 4962 4963 // Load Integer with mask 0xFF into Long Register 4964 instruct loadI2L_immI_255(rRegL dst, memory mem, immI_255 mask) %{ 4965 match(Set dst (ConvI2L (AndI (LoadI mem) mask))); 4966 4967 format %{ "movzbq $dst, $mem\t# int & 0xFF -> long" %} 4968 ins_encode %{ 4969 __ movzbq($dst$$Register, $mem$$Address); 4970 %} 4971 ins_pipe(ialu_reg_mem); 4972 %} 4973 4974 // Load Integer with mask 0xFFFF into Long Register 4975 instruct loadI2L_immI_65535(rRegL dst, memory mem, immI_65535 mask) %{ 4976 match(Set dst (ConvI2L (AndI (LoadI mem) mask))); 4977 4978 format %{ "movzwq $dst, $mem\t# int & 0xFFFF -> long" %} 4979 ins_encode %{ 4980 __ movzwq($dst$$Register, $mem$$Address); 4981 %} 4982 ins_pipe(ialu_reg_mem); 4983 %} 4984 4985 // Load Integer with a 31-bit mask into Long Register 4986 instruct loadI2L_immU31(rRegL dst, memory mem, immU31 mask, rFlagsReg cr) %{ 4987 match(Set dst (ConvI2L (AndI (LoadI mem) mask))); 4988 effect(KILL cr); 4989 4990 format %{ "movl $dst, $mem\t# int & 31-bit mask -> long\n\t" 4991 "andl $dst, $mask" %} 4992 ins_encode %{ 4993 Register Rdst = $dst$$Register; 4994 __ movl(Rdst, $mem$$Address); 4995 __ andl(Rdst, $mask$$constant); 4996 %} 4997 ins_pipe(ialu_reg_mem); 4998 %} 4999 5000 // Load Unsigned Integer into Long Register 5001 instruct loadUI2L(rRegL dst, memory mem, immL_32bits mask) 5002 %{ 5003 match(Set dst (AndL (ConvI2L (LoadI mem)) mask)); 5004 5005 ins_cost(125); 5006 format %{ "movl $dst, $mem\t# uint -> long" %} 5007 5008 ins_encode %{ 5009 __ movl($dst$$Register, $mem$$Address); 5010 %} 5011 5012 ins_pipe(ialu_reg_mem); 5013 %} 5014 5015 // Load Long 5016 instruct loadL(rRegL dst, memory mem) 5017 %{ 5018 match(Set dst (LoadL mem)); 5019 5020 ins_cost(125); 5021 format %{ "movq $dst, $mem\t# long" %} 5022 5023 ins_encode %{ 5024 __ movq($dst$$Register, $mem$$Address); 5025 %} 5026 5027 ins_pipe(ialu_reg_mem); // XXX 5028 %} 5029 5030 // Load Range 5031 instruct loadRange(rRegI dst, memory mem) 5032 %{ 5033 match(Set dst (LoadRange mem)); 5034 5035 ins_cost(125); // XXX 5036 format %{ "movl $dst, $mem\t# range" %} 5037 opcode(0x8B); 5038 ins_encode(REX_reg_mem(dst, mem), OpcP, reg_mem(dst, mem)); 5039 ins_pipe(ialu_reg_mem); 5040 %} 5041 5042 // Load Pointer 5043 instruct loadP(rRegP dst, memory mem) 5044 %{ 5045 match(Set dst (LoadP mem)); 5046 5047 ins_cost(125); // XXX 5048 format %{ "movq $dst, $mem\t# ptr" %} 5049 opcode(0x8B); 5050 ins_encode(REX_reg_mem_wide(dst, mem), OpcP, reg_mem(dst, mem)); 5051 ins_pipe(ialu_reg_mem); // XXX 5052 %} 5053 5054 // Load Compressed Pointer 5055 instruct loadN(rRegN dst, memory mem) 5056 %{ 5057 match(Set dst (LoadN mem)); 5058 5059 ins_cost(125); // XXX 5060 format %{ "movl $dst, $mem\t# compressed ptr" %} 5061 ins_encode %{ 5062 __ movl($dst$$Register, $mem$$Address); 5063 %} 5064 ins_pipe(ialu_reg_mem); // XXX 5065 %} 5066 5067 5068 // Load Klass Pointer 5069 instruct loadKlass(rRegP dst, memory mem) 5070 %{ 5071 match(Set dst (LoadKlass mem)); 5072 5073 ins_cost(125); // XXX 5074 format %{ "movq $dst, $mem\t# class" %} 5075 opcode(0x8B); 5076 ins_encode(REX_reg_mem_wide(dst, mem), OpcP, reg_mem(dst, mem)); 5077 ins_pipe(ialu_reg_mem); // XXX 5078 %} 5079 5080 // Load narrow Klass Pointer 5081 instruct loadNKlass(rRegN dst, memory mem) 5082 %{ 5083 match(Set dst (LoadNKlass mem)); 5084 5085 ins_cost(125); // XXX 5086 format %{ "movl $dst, $mem\t# compressed klass ptr" %} 5087 ins_encode %{ 5088 __ movl($dst$$Register, $mem$$Address); 5089 %} 5090 ins_pipe(ialu_reg_mem); // XXX 5091 %} 5092 5093 // Load Float 5094 instruct loadF(regF dst, memory mem) 5095 %{ 5096 match(Set dst (LoadF mem)); 5097 5098 ins_cost(145); // XXX 5099 format %{ "movss $dst, $mem\t# float" %} 5100 ins_encode %{ 5101 __ movflt($dst$$XMMRegister, $mem$$Address); 5102 %} 5103 ins_pipe(pipe_slow); // XXX 5104 %} 5105 5106 // Load Double 5107 instruct loadD_partial(regD dst, memory mem) 5108 %{ 5109 predicate(!UseXmmLoadAndClearUpper); 5110 match(Set dst (LoadD mem)); 5111 5112 ins_cost(145); // XXX 5113 format %{ "movlpd $dst, $mem\t# double" %} 5114 ins_encode %{ 5115 __ movdbl($dst$$XMMRegister, $mem$$Address); 5116 %} 5117 ins_pipe(pipe_slow); // XXX 5118 %} 5119 5120 instruct loadD(regD dst, memory mem) 5121 %{ 5122 predicate(UseXmmLoadAndClearUpper); 5123 match(Set dst (LoadD mem)); 5124 5125 ins_cost(145); // XXX 5126 format %{ "movsd $dst, $mem\t# double" %} 5127 ins_encode %{ 5128 __ movdbl($dst$$XMMRegister, $mem$$Address); 5129 %} 5130 ins_pipe(pipe_slow); // XXX 5131 %} 5132 5133 // Load Effective Address 5134 instruct leaP8(rRegP dst, indOffset8 mem) 5135 %{ 5136 match(Set dst mem); 5137 5138 ins_cost(110); // XXX 5139 format %{ "leaq $dst, $mem\t# ptr 8" %} 5140 opcode(0x8D); 5141 ins_encode(REX_reg_mem_wide(dst, mem), OpcP, reg_mem(dst, mem)); 5142 ins_pipe(ialu_reg_reg_fat); 5143 %} 5144 5145 instruct leaP32(rRegP dst, indOffset32 mem) 5146 %{ 5147 match(Set dst mem); 5148 5149 ins_cost(110); 5150 format %{ "leaq $dst, $mem\t# ptr 32" %} 5151 opcode(0x8D); 5152 ins_encode(REX_reg_mem_wide(dst, mem), OpcP, reg_mem(dst, mem)); 5153 ins_pipe(ialu_reg_reg_fat); 5154 %} 5155 5156 // instruct leaPIdx(rRegP dst, indIndex mem) 5157 // %{ 5158 // match(Set dst mem); 5159 5160 // ins_cost(110); 5161 // format %{ "leaq $dst, $mem\t# ptr idx" %} 5162 // opcode(0x8D); 5163 // ins_encode(REX_reg_mem_wide(dst, mem), OpcP, reg_mem(dst, mem)); 5164 // ins_pipe(ialu_reg_reg_fat); 5165 // %} 5166 5167 instruct leaPIdxOff(rRegP dst, indIndexOffset mem) 5168 %{ 5169 match(Set dst mem); 5170 5171 ins_cost(110); 5172 format %{ "leaq $dst, $mem\t# ptr idxoff" %} 5173 opcode(0x8D); 5174 ins_encode(REX_reg_mem_wide(dst, mem), OpcP, reg_mem(dst, mem)); 5175 ins_pipe(ialu_reg_reg_fat); 5176 %} 5177 5178 instruct leaPIdxScale(rRegP dst, indIndexScale mem) 5179 %{ 5180 match(Set dst mem); 5181 5182 ins_cost(110); 5183 format %{ "leaq $dst, $mem\t# ptr idxscale" %} 5184 opcode(0x8D); 5185 ins_encode(REX_reg_mem_wide(dst, mem), OpcP, reg_mem(dst, mem)); 5186 ins_pipe(ialu_reg_reg_fat); 5187 %} 5188 5189 instruct leaPIdxScaleOff(rRegP dst, indIndexScaleOffset mem) 5190 %{ 5191 match(Set dst mem); 5192 5193 ins_cost(110); 5194 format %{ "leaq $dst, $mem\t# ptr idxscaleoff" %} 5195 opcode(0x8D); 5196 ins_encode(REX_reg_mem_wide(dst, mem), OpcP, reg_mem(dst, mem)); 5197 ins_pipe(ialu_reg_reg_fat); 5198 %} 5199 5200 instruct leaPPosIdxOff(rRegP dst, indPosIndexOffset mem) 5201 %{ 5202 match(Set dst mem); 5203 5204 ins_cost(110); 5205 format %{ "leaq $dst, $mem\t# ptr posidxoff" %} 5206 opcode(0x8D); 5207 ins_encode(REX_reg_mem_wide(dst, mem), OpcP, reg_mem(dst, mem)); 5208 ins_pipe(ialu_reg_reg_fat); 5209 %} 5210 5211 instruct leaPPosIdxScaleOff(rRegP dst, indPosIndexScaleOffset mem) 5212 %{ 5213 match(Set dst mem); 5214 5215 ins_cost(110); 5216 format %{ "leaq $dst, $mem\t# ptr posidxscaleoff" %} 5217 opcode(0x8D); 5218 ins_encode(REX_reg_mem_wide(dst, mem), OpcP, reg_mem(dst, mem)); 5219 ins_pipe(ialu_reg_reg_fat); 5220 %} 5221 5222 // Load Effective Address which uses Narrow (32-bits) oop 5223 instruct leaPCompressedOopOffset(rRegP dst, indCompressedOopOffset mem) 5224 %{ 5225 predicate(UseCompressedOops && (Universe::narrow_oop_shift() != 0)); 5226 match(Set dst mem); 5227 5228 ins_cost(110); 5229 format %{ "leaq $dst, $mem\t# ptr compressedoopoff32" %} 5230 opcode(0x8D); 5231 ins_encode(REX_reg_mem_wide(dst, mem), OpcP, reg_mem(dst, mem)); 5232 ins_pipe(ialu_reg_reg_fat); 5233 %} 5234 5235 instruct leaP8Narrow(rRegP dst, indOffset8Narrow mem) 5236 %{ 5237 predicate(Universe::narrow_oop_shift() == 0); 5238 match(Set dst mem); 5239 5240 ins_cost(110); // XXX 5241 format %{ "leaq $dst, $mem\t# ptr off8narrow" %} 5242 opcode(0x8D); 5243 ins_encode(REX_reg_mem_wide(dst, mem), OpcP, reg_mem(dst, mem)); 5244 ins_pipe(ialu_reg_reg_fat); 5245 %} 5246 5247 instruct leaP32Narrow(rRegP dst, indOffset32Narrow mem) 5248 %{ 5249 predicate(Universe::narrow_oop_shift() == 0); 5250 match(Set dst mem); 5251 5252 ins_cost(110); 5253 format %{ "leaq $dst, $mem\t# ptr off32narrow" %} 5254 opcode(0x8D); 5255 ins_encode(REX_reg_mem_wide(dst, mem), OpcP, reg_mem(dst, mem)); 5256 ins_pipe(ialu_reg_reg_fat); 5257 %} 5258 5259 instruct leaPIdxOffNarrow(rRegP dst, indIndexOffsetNarrow mem) 5260 %{ 5261 predicate(Universe::narrow_oop_shift() == 0); 5262 match(Set dst mem); 5263 5264 ins_cost(110); 5265 format %{ "leaq $dst, $mem\t# ptr idxoffnarrow" %} 5266 opcode(0x8D); 5267 ins_encode(REX_reg_mem_wide(dst, mem), OpcP, reg_mem(dst, mem)); 5268 ins_pipe(ialu_reg_reg_fat); 5269 %} 5270 5271 instruct leaPIdxScaleNarrow(rRegP dst, indIndexScaleNarrow mem) 5272 %{ 5273 predicate(Universe::narrow_oop_shift() == 0); 5274 match(Set dst mem); 5275 5276 ins_cost(110); 5277 format %{ "leaq $dst, $mem\t# ptr idxscalenarrow" %} 5278 opcode(0x8D); 5279 ins_encode(REX_reg_mem_wide(dst, mem), OpcP, reg_mem(dst, mem)); 5280 ins_pipe(ialu_reg_reg_fat); 5281 %} 5282 5283 instruct leaPIdxScaleOffNarrow(rRegP dst, indIndexScaleOffsetNarrow mem) 5284 %{ 5285 predicate(Universe::narrow_oop_shift() == 0); 5286 match(Set dst mem); 5287 5288 ins_cost(110); 5289 format %{ "leaq $dst, $mem\t# ptr idxscaleoffnarrow" %} 5290 opcode(0x8D); 5291 ins_encode(REX_reg_mem_wide(dst, mem), OpcP, reg_mem(dst, mem)); 5292 ins_pipe(ialu_reg_reg_fat); 5293 %} 5294 5295 instruct leaPPosIdxOffNarrow(rRegP dst, indPosIndexOffsetNarrow mem) 5296 %{ 5297 predicate(Universe::narrow_oop_shift() == 0); 5298 match(Set dst mem); 5299 5300 ins_cost(110); 5301 format %{ "leaq $dst, $mem\t# ptr posidxoffnarrow" %} 5302 opcode(0x8D); 5303 ins_encode(REX_reg_mem_wide(dst, mem), OpcP, reg_mem(dst, mem)); 5304 ins_pipe(ialu_reg_reg_fat); 5305 %} 5306 5307 instruct leaPPosIdxScaleOffNarrow(rRegP dst, indPosIndexScaleOffsetNarrow mem) 5308 %{ 5309 predicate(Universe::narrow_oop_shift() == 0); 5310 match(Set dst mem); 5311 5312 ins_cost(110); 5313 format %{ "leaq $dst, $mem\t# ptr posidxscaleoffnarrow" %} 5314 opcode(0x8D); 5315 ins_encode(REX_reg_mem_wide(dst, mem), OpcP, reg_mem(dst, mem)); 5316 ins_pipe(ialu_reg_reg_fat); 5317 %} 5318 5319 instruct loadConI(rRegI dst, immI src) 5320 %{ 5321 match(Set dst src); 5322 5323 format %{ "movl $dst, $src\t# int" %} 5324 ins_encode(load_immI(dst, src)); 5325 ins_pipe(ialu_reg_fat); // XXX 5326 %} 5327 5328 instruct loadConI0(rRegI dst, immI0 src, rFlagsReg cr) 5329 %{ 5330 match(Set dst src); 5331 effect(KILL cr); 5332 5333 ins_cost(50); 5334 format %{ "xorl $dst, $dst\t# int" %} 5335 opcode(0x33); /* + rd */ 5336 ins_encode(REX_reg_reg(dst, dst), OpcP, reg_reg(dst, dst)); 5337 ins_pipe(ialu_reg); 5338 %} 5339 5340 instruct loadConL(rRegL dst, immL src) 5341 %{ 5342 match(Set dst src); 5343 5344 ins_cost(150); 5345 format %{ "movq $dst, $src\t# long" %} 5346 ins_encode(load_immL(dst, src)); 5347 ins_pipe(ialu_reg); 5348 %} 5349 5350 instruct loadConL0(rRegL dst, immL0 src, rFlagsReg cr) 5351 %{ 5352 match(Set dst src); 5353 effect(KILL cr); 5354 5355 ins_cost(50); 5356 format %{ "xorl $dst, $dst\t# long" %} 5357 opcode(0x33); /* + rd */ 5358 ins_encode(REX_reg_reg(dst, dst), OpcP, reg_reg(dst, dst)); 5359 ins_pipe(ialu_reg); // XXX 5360 %} 5361 5362 instruct loadConUL32(rRegL dst, immUL32 src) 5363 %{ 5364 match(Set dst src); 5365 5366 ins_cost(60); 5367 format %{ "movl $dst, $src\t# long (unsigned 32-bit)" %} 5368 ins_encode(load_immUL32(dst, src)); 5369 ins_pipe(ialu_reg); 5370 %} 5371 5372 instruct loadConL32(rRegL dst, immL32 src) 5373 %{ 5374 match(Set dst src); 5375 5376 ins_cost(70); 5377 format %{ "movq $dst, $src\t# long (32-bit)" %} 5378 ins_encode(load_immL32(dst, src)); 5379 ins_pipe(ialu_reg); 5380 %} 5381 5382 instruct loadConP(rRegP dst, immP con) %{ 5383 match(Set dst con); 5384 5385 format %{ "movq $dst, $con\t# ptr" %} 5386 ins_encode(load_immP(dst, con)); 5387 ins_pipe(ialu_reg_fat); // XXX 5388 %} 5389 5390 instruct loadConP0(rRegP dst, immP0 src, rFlagsReg cr) 5391 %{ 5392 match(Set dst src); 5393 effect(KILL cr); 5394 5395 ins_cost(50); 5396 format %{ "xorl $dst, $dst\t# ptr" %} 5397 opcode(0x33); /* + rd */ 5398 ins_encode(REX_reg_reg(dst, dst), OpcP, reg_reg(dst, dst)); 5399 ins_pipe(ialu_reg); 5400 %} 5401 5402 instruct loadConP31(rRegP dst, immP31 src, rFlagsReg cr) 5403 %{ 5404 match(Set dst src); 5405 effect(KILL cr); 5406 5407 ins_cost(60); 5408 format %{ "movl $dst, $src\t# ptr (positive 32-bit)" %} 5409 ins_encode(load_immP31(dst, src)); 5410 ins_pipe(ialu_reg); 5411 %} 5412 5413 instruct loadConF(regF dst, immF con) %{ 5414 match(Set dst con); 5415 ins_cost(125); 5416 format %{ "movss $dst, [$constantaddress]\t# load from constant table: float=$con" %} 5417 ins_encode %{ 5418 __ movflt($dst$$XMMRegister, $constantaddress($con)); 5419 %} 5420 ins_pipe(pipe_slow); 5421 %} 5422 5423 instruct loadConN0(rRegN dst, immN0 src, rFlagsReg cr) %{ 5424 match(Set dst src); 5425 effect(KILL cr); 5426 format %{ "xorq $dst, $src\t# compressed NULL ptr" %} 5427 ins_encode %{ 5428 __ xorq($dst$$Register, $dst$$Register); 5429 %} 5430 ins_pipe(ialu_reg); 5431 %} 5432 5433 instruct loadConN(rRegN dst, immN src) %{ 5434 match(Set dst src); 5435 5436 ins_cost(125); 5437 format %{ "movl $dst, $src\t# compressed ptr" %} 5438 ins_encode %{ 5439 address con = (address)$src$$constant; 5440 if (con == NULL) { 5441 ShouldNotReachHere(); 5442 } else { 5443 __ set_narrow_oop($dst$$Register, (jobject)$src$$constant); 5444 } 5445 %} 5446 ins_pipe(ialu_reg_fat); // XXX 5447 %} 5448 5449 instruct loadConNKlass(rRegN dst, immNKlass src) %{ 5450 match(Set dst src); 5451 5452 ins_cost(125); 5453 format %{ "movl $dst, $src\t# compressed klass ptr" %} 5454 ins_encode %{ 5455 address con = (address)$src$$constant; 5456 if (con == NULL) { 5457 ShouldNotReachHere(); 5458 } else { 5459 __ set_narrow_klass($dst$$Register, (Klass*)$src$$constant); 5460 } 5461 %} 5462 ins_pipe(ialu_reg_fat); // XXX 5463 %} 5464 5465 instruct loadConF0(regF dst, immF0 src) 5466 %{ 5467 match(Set dst src); 5468 ins_cost(100); 5469 5470 format %{ "xorps $dst, $dst\t# float 0.0" %} 5471 ins_encode %{ 5472 __ xorps($dst$$XMMRegister, $dst$$XMMRegister); 5473 %} 5474 ins_pipe(pipe_slow); 5475 %} 5476 5477 // Use the same format since predicate() can not be used here. 5478 instruct loadConD(regD dst, immD con) %{ 5479 match(Set dst con); 5480 ins_cost(125); 5481 format %{ "movsd $dst, [$constantaddress]\t# load from constant table: double=$con" %} 5482 ins_encode %{ 5483 __ movdbl($dst$$XMMRegister, $constantaddress($con)); 5484 %} 5485 ins_pipe(pipe_slow); 5486 %} 5487 5488 instruct loadConD0(regD dst, immD0 src) 5489 %{ 5490 match(Set dst src); 5491 ins_cost(100); 5492 5493 format %{ "xorpd $dst, $dst\t# double 0.0" %} 5494 ins_encode %{ 5495 __ xorpd ($dst$$XMMRegister, $dst$$XMMRegister); 5496 %} 5497 ins_pipe(pipe_slow); 5498 %} 5499 5500 instruct loadSSI(rRegI dst, stackSlotI src) 5501 %{ 5502 match(Set dst src); 5503 5504 ins_cost(125); 5505 format %{ "movl $dst, $src\t# int stk" %} 5506 opcode(0x8B); 5507 ins_encode(REX_reg_mem(dst, src), OpcP, reg_mem(dst, src)); 5508 ins_pipe(ialu_reg_mem); 5509 %} 5510 5511 instruct loadSSL(rRegL dst, stackSlotL src) 5512 %{ 5513 match(Set dst src); 5514 5515 ins_cost(125); 5516 format %{ "movq $dst, $src\t# long stk" %} 5517 opcode(0x8B); 5518 ins_encode(REX_reg_mem_wide(dst, src), OpcP, reg_mem(dst, src)); 5519 ins_pipe(ialu_reg_mem); 5520 %} 5521 5522 instruct loadSSP(rRegP dst, stackSlotP src) 5523 %{ 5524 match(Set dst src); 5525 5526 ins_cost(125); 5527 format %{ "movq $dst, $src\t# ptr stk" %} 5528 opcode(0x8B); 5529 ins_encode(REX_reg_mem_wide(dst, src), OpcP, reg_mem(dst, src)); 5530 ins_pipe(ialu_reg_mem); 5531 %} 5532 5533 instruct loadSSF(regF dst, stackSlotF src) 5534 %{ 5535 match(Set dst src); 5536 5537 ins_cost(125); 5538 format %{ "movss $dst, $src\t# float stk" %} 5539 ins_encode %{ 5540 __ movflt($dst$$XMMRegister, Address(rsp, $src$$disp)); 5541 %} 5542 ins_pipe(pipe_slow); // XXX 5543 %} 5544 5545 // Use the same format since predicate() can not be used here. 5546 instruct loadSSD(regD dst, stackSlotD src) 5547 %{ 5548 match(Set dst src); 5549 5550 ins_cost(125); 5551 format %{ "movsd $dst, $src\t# double stk" %} 5552 ins_encode %{ 5553 __ movdbl($dst$$XMMRegister, Address(rsp, $src$$disp)); 5554 %} 5555 ins_pipe(pipe_slow); // XXX 5556 %} 5557 5558 // Prefetch instructions for allocation. 5559 // Must be safe to execute with invalid address (cannot fault). 5560 5561 instruct prefetchAlloc( memory mem ) %{ 5562 predicate(AllocatePrefetchInstr==3); 5563 match(PrefetchAllocation mem); 5564 ins_cost(125); 5565 5566 format %{ "PREFETCHW $mem\t# Prefetch allocation into level 1 cache and mark modified" %} 5567 ins_encode %{ 5568 __ prefetchw($mem$$Address); 5569 %} 5570 ins_pipe(ialu_mem); 5571 %} 5572 5573 instruct prefetchAllocNTA( memory mem ) %{ 5574 predicate(AllocatePrefetchInstr==0); 5575 match(PrefetchAllocation mem); 5576 ins_cost(125); 5577 5578 format %{ "PREFETCHNTA $mem\t# Prefetch allocation to non-temporal cache for write" %} 5579 ins_encode %{ 5580 __ prefetchnta($mem$$Address); 5581 %} 5582 ins_pipe(ialu_mem); 5583 %} 5584 5585 instruct prefetchAllocT0( memory mem ) %{ 5586 predicate(AllocatePrefetchInstr==1); 5587 match(PrefetchAllocation mem); 5588 ins_cost(125); 5589 5590 format %{ "PREFETCHT0 $mem\t# Prefetch allocation to level 1 and 2 caches for write" %} 5591 ins_encode %{ 5592 __ prefetcht0($mem$$Address); 5593 %} 5594 ins_pipe(ialu_mem); 5595 %} 5596 5597 instruct prefetchAllocT2( memory mem ) %{ 5598 predicate(AllocatePrefetchInstr==2); 5599 match(PrefetchAllocation mem); 5600 ins_cost(125); 5601 5602 format %{ "PREFETCHT2 $mem\t# Prefetch allocation to level 2 cache for write" %} 5603 ins_encode %{ 5604 __ prefetcht2($mem$$Address); 5605 %} 5606 ins_pipe(ialu_mem); 5607 %} 5608 5609 //----------Store Instructions------------------------------------------------- 5610 5611 // Store Byte 5612 instruct storeB(memory mem, rRegI src) 5613 %{ 5614 match(Set mem (StoreB mem src)); 5615 5616 ins_cost(125); // XXX 5617 format %{ "movb $mem, $src\t# byte" %} 5618 opcode(0x88); 5619 ins_encode(REX_breg_mem(src, mem), OpcP, reg_mem(src, mem)); 5620 ins_pipe(ialu_mem_reg); 5621 %} 5622 5623 // Store Char/Short 5624 instruct storeC(memory mem, rRegI src) 5625 %{ 5626 match(Set mem (StoreC mem src)); 5627 5628 ins_cost(125); // XXX 5629 format %{ "movw $mem, $src\t# char/short" %} 5630 opcode(0x89); 5631 ins_encode(SizePrefix, REX_reg_mem(src, mem), OpcP, reg_mem(src, mem)); 5632 ins_pipe(ialu_mem_reg); 5633 %} 5634 5635 // Store Integer 5636 instruct storeI(memory mem, rRegI src) 5637 %{ 5638 match(Set mem (StoreI mem src)); 5639 5640 ins_cost(125); // XXX 5641 format %{ "movl $mem, $src\t# int" %} 5642 opcode(0x89); 5643 ins_encode(REX_reg_mem(src, mem), OpcP, reg_mem(src, mem)); 5644 ins_pipe(ialu_mem_reg); 5645 %} 5646 5647 // Store Long 5648 instruct storeL(memory mem, rRegL src) 5649 %{ 5650 match(Set mem (StoreL mem src)); 5651 5652 ins_cost(125); // XXX 5653 format %{ "movq $mem, $src\t# long" %} 5654 opcode(0x89); 5655 ins_encode(REX_reg_mem_wide(src, mem), OpcP, reg_mem(src, mem)); 5656 ins_pipe(ialu_mem_reg); // XXX 5657 %} 5658 5659 // Store Pointer 5660 instruct storeP(memory mem, any_RegP src) 5661 %{ 5662 match(Set mem (StoreP mem src)); 5663 5664 ins_cost(125); // XXX 5665 format %{ "movq $mem, $src\t# ptr" %} 5666 opcode(0x89); 5667 ins_encode(REX_reg_mem_wide(src, mem), OpcP, reg_mem(src, mem)); 5668 ins_pipe(ialu_mem_reg); 5669 %} 5670 5671 instruct storeImmP0(memory mem, immP0 zero) 5672 %{ 5673 predicate(UseCompressedOops && (Universe::narrow_oop_base() == NULL) && (Universe::narrow_klass_base() == NULL)); 5674 match(Set mem (StoreP mem zero)); 5675 5676 ins_cost(125); // XXX 5677 format %{ "movq $mem, R12\t# ptr (R12_heapbase==0)" %} 5678 ins_encode %{ 5679 __ movq($mem$$Address, r12); 5680 %} 5681 ins_pipe(ialu_mem_reg); 5682 %} 5683 5684 // Store NULL Pointer, mark word, or other simple pointer constant. 5685 instruct storeImmP(memory mem, immP31 src) 5686 %{ 5687 match(Set mem (StoreP mem src)); 5688 5689 ins_cost(150); // XXX 5690 format %{ "movq $mem, $src\t# ptr" %} 5691 opcode(0xC7); /* C7 /0 */ 5692 ins_encode(REX_mem_wide(mem), OpcP, RM_opc_mem(0x00, mem), Con32(src)); 5693 ins_pipe(ialu_mem_imm); 5694 %} 5695 5696 // Store Compressed Pointer 5697 instruct storeN(memory mem, rRegN src) 5698 %{ 5699 match(Set mem (StoreN mem src)); 5700 5701 ins_cost(125); // XXX 5702 format %{ "movl $mem, $src\t# compressed ptr" %} 5703 ins_encode %{ 5704 __ movl($mem$$Address, $src$$Register); 5705 %} 5706 ins_pipe(ialu_mem_reg); 5707 %} 5708 5709 instruct storeNKlass(memory mem, rRegN src) 5710 %{ 5711 match(Set mem (StoreNKlass mem src)); 5712 5713 ins_cost(125); // XXX 5714 format %{ "movl $mem, $src\t# compressed klass ptr" %} 5715 ins_encode %{ 5716 __ movl($mem$$Address, $src$$Register); 5717 %} 5718 ins_pipe(ialu_mem_reg); 5719 %} 5720 5721 instruct storeImmN0(memory mem, immN0 zero) 5722 %{ 5723 predicate(Universe::narrow_oop_base() == NULL && Universe::narrow_klass_base() == NULL); 5724 match(Set mem (StoreN mem zero)); 5725 5726 ins_cost(125); // XXX 5727 format %{ "movl $mem, R12\t# compressed ptr (R12_heapbase==0)" %} 5728 ins_encode %{ 5729 __ movl($mem$$Address, r12); 5730 %} 5731 ins_pipe(ialu_mem_reg); 5732 %} 5733 5734 instruct storeImmN(memory mem, immN src) 5735 %{ 5736 match(Set mem (StoreN mem src)); 5737 5738 ins_cost(150); // XXX 5739 format %{ "movl $mem, $src\t# compressed ptr" %} 5740 ins_encode %{ 5741 address con = (address)$src$$constant; 5742 if (con == NULL) { 5743 __ movl($mem$$Address, (int32_t)0); 5744 } else { 5745 __ set_narrow_oop($mem$$Address, (jobject)$src$$constant); 5746 } 5747 %} 5748 ins_pipe(ialu_mem_imm); 5749 %} 5750 5751 instruct storeImmNKlass(memory mem, immNKlass src) 5752 %{ 5753 match(Set mem (StoreNKlass mem src)); 5754 5755 ins_cost(150); // XXX 5756 format %{ "movl $mem, $src\t# compressed klass ptr" %} 5757 ins_encode %{ 5758 __ set_narrow_klass($mem$$Address, (Klass*)$src$$constant); 5759 %} 5760 ins_pipe(ialu_mem_imm); 5761 %} 5762 5763 // Store Integer Immediate 5764 instruct storeImmI0(memory mem, immI0 zero) 5765 %{ 5766 predicate(UseCompressedOops && (Universe::narrow_oop_base() == NULL) && (Universe::narrow_klass_base() == NULL)); 5767 match(Set mem (StoreI mem zero)); 5768 5769 ins_cost(125); // XXX 5770 format %{ "movl $mem, R12\t# int (R12_heapbase==0)" %} 5771 ins_encode %{ 5772 __ movl($mem$$Address, r12); 5773 %} 5774 ins_pipe(ialu_mem_reg); 5775 %} 5776 5777 instruct storeImmI(memory mem, immI src) 5778 %{ 5779 match(Set mem (StoreI mem src)); 5780 5781 ins_cost(150); 5782 format %{ "movl $mem, $src\t# int" %} 5783 opcode(0xC7); /* C7 /0 */ 5784 ins_encode(REX_mem(mem), OpcP, RM_opc_mem(0x00, mem), Con32(src)); 5785 ins_pipe(ialu_mem_imm); 5786 %} 5787 5788 // Store Long Immediate 5789 instruct storeImmL0(memory mem, immL0 zero) 5790 %{ 5791 predicate(UseCompressedOops && (Universe::narrow_oop_base() == NULL) && (Universe::narrow_klass_base() == NULL)); 5792 match(Set mem (StoreL mem zero)); 5793 5794 ins_cost(125); // XXX 5795 format %{ "movq $mem, R12\t# long (R12_heapbase==0)" %} 5796 ins_encode %{ 5797 __ movq($mem$$Address, r12); 5798 %} 5799 ins_pipe(ialu_mem_reg); 5800 %} 5801 5802 instruct storeImmL(memory mem, immL32 src) 5803 %{ 5804 match(Set mem (StoreL mem src)); 5805 5806 ins_cost(150); 5807 format %{ "movq $mem, $src\t# long" %} 5808 opcode(0xC7); /* C7 /0 */ 5809 ins_encode(REX_mem_wide(mem), OpcP, RM_opc_mem(0x00, mem), Con32(src)); 5810 ins_pipe(ialu_mem_imm); 5811 %} 5812 5813 // Store Short/Char Immediate 5814 instruct storeImmC0(memory mem, immI0 zero) 5815 %{ 5816 predicate(UseCompressedOops && (Universe::narrow_oop_base() == NULL) && (Universe::narrow_klass_base() == NULL)); 5817 match(Set mem (StoreC mem zero)); 5818 5819 ins_cost(125); // XXX 5820 format %{ "movw $mem, R12\t# short/char (R12_heapbase==0)" %} 5821 ins_encode %{ 5822 __ movw($mem$$Address, r12); 5823 %} 5824 ins_pipe(ialu_mem_reg); 5825 %} 5826 5827 instruct storeImmI16(memory mem, immI16 src) 5828 %{ 5829 predicate(UseStoreImmI16); 5830 match(Set mem (StoreC mem src)); 5831 5832 ins_cost(150); 5833 format %{ "movw $mem, $src\t# short/char" %} 5834 opcode(0xC7); /* C7 /0 Same as 32 store immediate with prefix */ 5835 ins_encode(SizePrefix, REX_mem(mem), OpcP, RM_opc_mem(0x00, mem),Con16(src)); 5836 ins_pipe(ialu_mem_imm); 5837 %} 5838 5839 // Store Byte Immediate 5840 instruct storeImmB0(memory mem, immI0 zero) 5841 %{ 5842 predicate(UseCompressedOops && (Universe::narrow_oop_base() == NULL) && (Universe::narrow_klass_base() == NULL)); 5843 match(Set mem (StoreB mem zero)); 5844 5845 ins_cost(125); // XXX 5846 format %{ "movb $mem, R12\t# short/char (R12_heapbase==0)" %} 5847 ins_encode %{ 5848 __ movb($mem$$Address, r12); 5849 %} 5850 ins_pipe(ialu_mem_reg); 5851 %} 5852 5853 instruct storeImmB(memory mem, immI8 src) 5854 %{ 5855 match(Set mem (StoreB mem src)); 5856 5857 ins_cost(150); // XXX 5858 format %{ "movb $mem, $src\t# byte" %} 5859 opcode(0xC6); /* C6 /0 */ 5860 ins_encode(REX_mem(mem), OpcP, RM_opc_mem(0x00, mem), Con8or32(src)); 5861 ins_pipe(ialu_mem_imm); 5862 %} 5863 5864 // Store CMS card-mark Immediate 5865 instruct storeImmCM0_reg(memory mem, immI0 zero) 5866 %{ 5867 predicate(UseCompressedOops && (Universe::narrow_oop_base() == NULL) && (Universe::narrow_klass_base() == NULL)); 5868 match(Set mem (StoreCM mem zero)); 5869 5870 ins_cost(125); // XXX 5871 format %{ "movb $mem, R12\t# CMS card-mark byte 0 (R12_heapbase==0)" %} 5872 ins_encode %{ 5873 __ movb($mem$$Address, r12); 5874 %} 5875 ins_pipe(ialu_mem_reg); 5876 %} 5877 5878 instruct storeImmCM0(memory mem, immI0 src) 5879 %{ 5880 match(Set mem (StoreCM mem src)); 5881 5882 ins_cost(150); // XXX 5883 format %{ "movb $mem, $src\t# CMS card-mark byte 0" %} 5884 opcode(0xC6); /* C6 /0 */ 5885 ins_encode(REX_mem(mem), OpcP, RM_opc_mem(0x00, mem), Con8or32(src)); 5886 ins_pipe(ialu_mem_imm); 5887 %} 5888 5889 // Store Float 5890 instruct storeF(memory mem, regF src) 5891 %{ 5892 match(Set mem (StoreF mem src)); 5893 5894 ins_cost(95); // XXX 5895 format %{ "movss $mem, $src\t# float" %} 5896 ins_encode %{ 5897 __ movflt($mem$$Address, $src$$XMMRegister); 5898 %} 5899 ins_pipe(pipe_slow); // XXX 5900 %} 5901 5902 // Store immediate Float value (it is faster than store from XMM register) 5903 instruct storeF0(memory mem, immF0 zero) 5904 %{ 5905 predicate(UseCompressedOops && (Universe::narrow_oop_base() == NULL) && (Universe::narrow_klass_base() == NULL)); 5906 match(Set mem (StoreF mem zero)); 5907 5908 ins_cost(25); // XXX 5909 format %{ "movl $mem, R12\t# float 0. (R12_heapbase==0)" %} 5910 ins_encode %{ 5911 __ movl($mem$$Address, r12); 5912 %} 5913 ins_pipe(ialu_mem_reg); 5914 %} 5915 5916 instruct storeF_imm(memory mem, immF src) 5917 %{ 5918 match(Set mem (StoreF mem src)); 5919 5920 ins_cost(50); 5921 format %{ "movl $mem, $src\t# float" %} 5922 opcode(0xC7); /* C7 /0 */ 5923 ins_encode(REX_mem(mem), OpcP, RM_opc_mem(0x00, mem), Con32F_as_bits(src)); 5924 ins_pipe(ialu_mem_imm); 5925 %} 5926 5927 // Store Double 5928 instruct storeD(memory mem, regD src) 5929 %{ 5930 match(Set mem (StoreD mem src)); 5931 5932 ins_cost(95); // XXX 5933 format %{ "movsd $mem, $src\t# double" %} 5934 ins_encode %{ 5935 __ movdbl($mem$$Address, $src$$XMMRegister); 5936 %} 5937 ins_pipe(pipe_slow); // XXX 5938 %} 5939 5940 // Store immediate double 0.0 (it is faster than store from XMM register) 5941 instruct storeD0_imm(memory mem, immD0 src) 5942 %{ 5943 predicate(!UseCompressedOops || (Universe::narrow_oop_base() != NULL)); 5944 match(Set mem (StoreD mem src)); 5945 5946 ins_cost(50); 5947 format %{ "movq $mem, $src\t# double 0." %} 5948 opcode(0xC7); /* C7 /0 */ 5949 ins_encode(REX_mem_wide(mem), OpcP, RM_opc_mem(0x00, mem), Con32F_as_bits(src)); 5950 ins_pipe(ialu_mem_imm); 5951 %} 5952 5953 instruct storeD0(memory mem, immD0 zero) 5954 %{ 5955 predicate(UseCompressedOops && (Universe::narrow_oop_base() == NULL) && (Universe::narrow_klass_base() == NULL)); 5956 match(Set mem (StoreD mem zero)); 5957 5958 ins_cost(25); // XXX 5959 format %{ "movq $mem, R12\t# double 0. (R12_heapbase==0)" %} 5960 ins_encode %{ 5961 __ movq($mem$$Address, r12); 5962 %} 5963 ins_pipe(ialu_mem_reg); 5964 %} 5965 5966 instruct storeSSI(stackSlotI dst, rRegI src) 5967 %{ 5968 match(Set dst src); 5969 5970 ins_cost(100); 5971 format %{ "movl $dst, $src\t# int stk" %} 5972 opcode(0x89); 5973 ins_encode(REX_reg_mem(src, dst), OpcP, reg_mem(src, dst)); 5974 ins_pipe( ialu_mem_reg ); 5975 %} 5976 5977 instruct storeSSL(stackSlotL dst, rRegL src) 5978 %{ 5979 match(Set dst src); 5980 5981 ins_cost(100); 5982 format %{ "movq $dst, $src\t# long stk" %} 5983 opcode(0x89); 5984 ins_encode(REX_reg_mem_wide(src, dst), OpcP, reg_mem(src, dst)); 5985 ins_pipe(ialu_mem_reg); 5986 %} 5987 5988 instruct storeSSP(stackSlotP dst, rRegP src) 5989 %{ 5990 match(Set dst src); 5991 5992 ins_cost(100); 5993 format %{ "movq $dst, $src\t# ptr stk" %} 5994 opcode(0x89); 5995 ins_encode(REX_reg_mem_wide(src, dst), OpcP, reg_mem(src, dst)); 5996 ins_pipe(ialu_mem_reg); 5997 %} 5998 5999 instruct storeSSF(stackSlotF dst, regF src) 6000 %{ 6001 match(Set dst src); 6002 6003 ins_cost(95); // XXX 6004 format %{ "movss $dst, $src\t# float stk" %} 6005 ins_encode %{ 6006 __ movflt(Address(rsp, $dst$$disp), $src$$XMMRegister); 6007 %} 6008 ins_pipe(pipe_slow); // XXX 6009 %} 6010 6011 instruct storeSSD(stackSlotD dst, regD src) 6012 %{ 6013 match(Set dst src); 6014 6015 ins_cost(95); // XXX 6016 format %{ "movsd $dst, $src\t# double stk" %} 6017 ins_encode %{ 6018 __ movdbl(Address(rsp, $dst$$disp), $src$$XMMRegister); 6019 %} 6020 ins_pipe(pipe_slow); // XXX 6021 %} 6022 6023 //----------BSWAP Instructions------------------------------------------------- 6024 instruct bytes_reverse_int(rRegI dst) %{ 6025 match(Set dst (ReverseBytesI dst)); 6026 6027 format %{ "bswapl $dst" %} 6028 opcode(0x0F, 0xC8); /*Opcode 0F /C8 */ 6029 ins_encode( REX_reg(dst), OpcP, opc2_reg(dst) ); 6030 ins_pipe( ialu_reg ); 6031 %} 6032 6033 instruct bytes_reverse_long(rRegL dst) %{ 6034 match(Set dst (ReverseBytesL dst)); 6035 6036 format %{ "bswapq $dst" %} 6037 opcode(0x0F, 0xC8); /* Opcode 0F /C8 */ 6038 ins_encode( REX_reg_wide(dst), OpcP, opc2_reg(dst) ); 6039 ins_pipe( ialu_reg); 6040 %} 6041 6042 instruct bytes_reverse_unsigned_short(rRegI dst, rFlagsReg cr) %{ 6043 match(Set dst (ReverseBytesUS dst)); 6044 effect(KILL cr); 6045 6046 format %{ "bswapl $dst\n\t" 6047 "shrl $dst,16\n\t" %} 6048 ins_encode %{ 6049 __ bswapl($dst$$Register); 6050 __ shrl($dst$$Register, 16); 6051 %} 6052 ins_pipe( ialu_reg ); 6053 %} 6054 6055 instruct bytes_reverse_short(rRegI dst, rFlagsReg cr) %{ 6056 match(Set dst (ReverseBytesS dst)); 6057 effect(KILL cr); 6058 6059 format %{ "bswapl $dst\n\t" 6060 "sar $dst,16\n\t" %} 6061 ins_encode %{ 6062 __ bswapl($dst$$Register); 6063 __ sarl($dst$$Register, 16); 6064 %} 6065 ins_pipe( ialu_reg ); 6066 %} 6067 6068 //---------- Zeros Count Instructions ------------------------------------------ 6069 6070 instruct countLeadingZerosI(rRegI dst, rRegI src, rFlagsReg cr) %{ 6071 predicate(UseCountLeadingZerosInstruction); 6072 match(Set dst (CountLeadingZerosI src)); 6073 effect(KILL cr); 6074 6075 format %{ "lzcntl $dst, $src\t# count leading zeros (int)" %} 6076 ins_encode %{ 6077 __ lzcntl($dst$$Register, $src$$Register); 6078 %} 6079 ins_pipe(ialu_reg); 6080 %} 6081 6082 instruct countLeadingZerosI_bsr(rRegI dst, rRegI src, rFlagsReg cr) %{ 6083 predicate(!UseCountLeadingZerosInstruction); 6084 match(Set dst (CountLeadingZerosI src)); 6085 effect(KILL cr); 6086 6087 format %{ "bsrl $dst, $src\t# count leading zeros (int)\n\t" 6088 "jnz skip\n\t" 6089 "movl $dst, -1\n" 6090 "skip:\n\t" 6091 "negl $dst\n\t" 6092 "addl $dst, 31" %} 6093 ins_encode %{ 6094 Register Rdst = $dst$$Register; 6095 Register Rsrc = $src$$Register; 6096 Label skip; 6097 __ bsrl(Rdst, Rsrc); 6098 __ jccb(Assembler::notZero, skip); 6099 __ movl(Rdst, -1); 6100 __ bind(skip); 6101 __ negl(Rdst); 6102 __ addl(Rdst, BitsPerInt - 1); 6103 %} 6104 ins_pipe(ialu_reg); 6105 %} 6106 6107 instruct countLeadingZerosL(rRegI dst, rRegL src, rFlagsReg cr) %{ 6108 predicate(UseCountLeadingZerosInstruction); 6109 match(Set dst (CountLeadingZerosL src)); 6110 effect(KILL cr); 6111 6112 format %{ "lzcntq $dst, $src\t# count leading zeros (long)" %} 6113 ins_encode %{ 6114 __ lzcntq($dst$$Register, $src$$Register); 6115 %} 6116 ins_pipe(ialu_reg); 6117 %} 6118 6119 instruct countLeadingZerosL_bsr(rRegI dst, rRegL src, rFlagsReg cr) %{ 6120 predicate(!UseCountLeadingZerosInstruction); 6121 match(Set dst (CountLeadingZerosL src)); 6122 effect(KILL cr); 6123 6124 format %{ "bsrq $dst, $src\t# count leading zeros (long)\n\t" 6125 "jnz skip\n\t" 6126 "movl $dst, -1\n" 6127 "skip:\n\t" 6128 "negl $dst\n\t" 6129 "addl $dst, 63" %} 6130 ins_encode %{ 6131 Register Rdst = $dst$$Register; 6132 Register Rsrc = $src$$Register; 6133 Label skip; 6134 __ bsrq(Rdst, Rsrc); 6135 __ jccb(Assembler::notZero, skip); 6136 __ movl(Rdst, -1); 6137 __ bind(skip); 6138 __ negl(Rdst); 6139 __ addl(Rdst, BitsPerLong - 1); 6140 %} 6141 ins_pipe(ialu_reg); 6142 %} 6143 6144 instruct countTrailingZerosI(rRegI dst, rRegI src, rFlagsReg cr) %{ 6145 predicate(UseCountTrailingZerosInstruction); 6146 match(Set dst (CountTrailingZerosI src)); 6147 effect(KILL cr); 6148 6149 format %{ "tzcntl $dst, $src\t# count trailing zeros (int)" %} 6150 ins_encode %{ 6151 __ tzcntl($dst$$Register, $src$$Register); 6152 %} 6153 ins_pipe(ialu_reg); 6154 %} 6155 6156 instruct countTrailingZerosI_bsf(rRegI dst, rRegI src, rFlagsReg cr) %{ 6157 predicate(!UseCountTrailingZerosInstruction); 6158 match(Set dst (CountTrailingZerosI src)); 6159 effect(KILL cr); 6160 6161 format %{ "bsfl $dst, $src\t# count trailing zeros (int)\n\t" 6162 "jnz done\n\t" 6163 "movl $dst, 32\n" 6164 "done:" %} 6165 ins_encode %{ 6166 Register Rdst = $dst$$Register; 6167 Label done; 6168 __ bsfl(Rdst, $src$$Register); 6169 __ jccb(Assembler::notZero, done); 6170 __ movl(Rdst, BitsPerInt); 6171 __ bind(done); 6172 %} 6173 ins_pipe(ialu_reg); 6174 %} 6175 6176 instruct countTrailingZerosL(rRegI dst, rRegL src, rFlagsReg cr) %{ 6177 predicate(UseCountTrailingZerosInstruction); 6178 match(Set dst (CountTrailingZerosL src)); 6179 effect(KILL cr); 6180 6181 format %{ "tzcntq $dst, $src\t# count trailing zeros (long)" %} 6182 ins_encode %{ 6183 __ tzcntq($dst$$Register, $src$$Register); 6184 %} 6185 ins_pipe(ialu_reg); 6186 %} 6187 6188 instruct countTrailingZerosL_bsf(rRegI dst, rRegL src, rFlagsReg cr) %{ 6189 predicate(!UseCountTrailingZerosInstruction); 6190 match(Set dst (CountTrailingZerosL src)); 6191 effect(KILL cr); 6192 6193 format %{ "bsfq $dst, $src\t# count trailing zeros (long)\n\t" 6194 "jnz done\n\t" 6195 "movl $dst, 64\n" 6196 "done:" %} 6197 ins_encode %{ 6198 Register Rdst = $dst$$Register; 6199 Label done; 6200 __ bsfq(Rdst, $src$$Register); 6201 __ jccb(Assembler::notZero, done); 6202 __ movl(Rdst, BitsPerLong); 6203 __ bind(done); 6204 %} 6205 ins_pipe(ialu_reg); 6206 %} 6207 6208 6209 //---------- Population Count Instructions ------------------------------------- 6210 6211 instruct popCountI(rRegI dst, rRegI src, rFlagsReg cr) %{ 6212 predicate(UsePopCountInstruction); 6213 match(Set dst (PopCountI src)); 6214 effect(KILL cr); 6215 6216 format %{ "popcnt $dst, $src" %} 6217 ins_encode %{ 6218 __ popcntl($dst$$Register, $src$$Register); 6219 %} 6220 ins_pipe(ialu_reg); 6221 %} 6222 6223 instruct popCountI_mem(rRegI dst, memory mem, rFlagsReg cr) %{ 6224 predicate(UsePopCountInstruction); 6225 match(Set dst (PopCountI (LoadI mem))); 6226 effect(KILL cr); 6227 6228 format %{ "popcnt $dst, $mem" %} 6229 ins_encode %{ 6230 __ popcntl($dst$$Register, $mem$$Address); 6231 %} 6232 ins_pipe(ialu_reg); 6233 %} 6234 6235 // Note: Long.bitCount(long) returns an int. 6236 instruct popCountL(rRegI dst, rRegL src, rFlagsReg cr) %{ 6237 predicate(UsePopCountInstruction); 6238 match(Set dst (PopCountL src)); 6239 effect(KILL cr); 6240 6241 format %{ "popcnt $dst, $src" %} 6242 ins_encode %{ 6243 __ popcntq($dst$$Register, $src$$Register); 6244 %} 6245 ins_pipe(ialu_reg); 6246 %} 6247 6248 // Note: Long.bitCount(long) returns an int. 6249 instruct popCountL_mem(rRegI dst, memory mem, rFlagsReg cr) %{ 6250 predicate(UsePopCountInstruction); 6251 match(Set dst (PopCountL (LoadL mem))); 6252 effect(KILL cr); 6253 6254 format %{ "popcnt $dst, $mem" %} 6255 ins_encode %{ 6256 __ popcntq($dst$$Register, $mem$$Address); 6257 %} 6258 ins_pipe(ialu_reg); 6259 %} 6260 6261 6262 //----------MemBar Instructions----------------------------------------------- 6263 // Memory barrier flavors 6264 6265 instruct membar_acquire() 6266 %{ 6267 match(MemBarAcquire); 6268 match(LoadFence); 6269 ins_cost(0); 6270 6271 size(0); 6272 format %{ "MEMBAR-acquire ! (empty encoding)" %} 6273 ins_encode(); 6274 ins_pipe(empty); 6275 %} 6276 6277 instruct membar_acquire_lock() 6278 %{ 6279 match(MemBarAcquireLock); 6280 ins_cost(0); 6281 6282 size(0); 6283 format %{ "MEMBAR-acquire (prior CMPXCHG in FastLock so empty encoding)" %} 6284 ins_encode(); 6285 ins_pipe(empty); 6286 %} 6287 6288 instruct membar_release() 6289 %{ 6290 match(MemBarRelease); 6291 match(StoreFence); 6292 ins_cost(0); 6293 6294 size(0); 6295 format %{ "MEMBAR-release ! (empty encoding)" %} 6296 ins_encode(); 6297 ins_pipe(empty); 6298 %} 6299 6300 instruct membar_release_lock() 6301 %{ 6302 match(MemBarReleaseLock); 6303 ins_cost(0); 6304 6305 size(0); 6306 format %{ "MEMBAR-release (a FastUnlock follows so empty encoding)" %} 6307 ins_encode(); 6308 ins_pipe(empty); 6309 %} 6310 6311 instruct membar_volatile(rFlagsReg cr) %{ 6312 match(MemBarVolatile); 6313 effect(KILL cr); 6314 ins_cost(400); 6315 6316 format %{ 6317 $$template 6318 if (os::is_MP()) { 6319 $$emit$$"lock addl [rsp + #0], 0\t! membar_volatile" 6320 } else { 6321 $$emit$$"MEMBAR-volatile ! (empty encoding)" 6322 } 6323 %} 6324 ins_encode %{ 6325 __ membar(Assembler::StoreLoad); 6326 %} 6327 ins_pipe(pipe_slow); 6328 %} 6329 6330 instruct unnecessary_membar_volatile() 6331 %{ 6332 match(MemBarVolatile); 6333 predicate(Matcher::post_store_load_barrier(n)); 6334 ins_cost(0); 6335 6336 size(0); 6337 format %{ "MEMBAR-volatile (unnecessary so empty encoding)" %} 6338 ins_encode(); 6339 ins_pipe(empty); 6340 %} 6341 6342 instruct membar_storestore() %{ 6343 match(MemBarStoreStore); 6344 ins_cost(0); 6345 6346 size(0); 6347 format %{ "MEMBAR-storestore (empty encoding)" %} 6348 ins_encode( ); 6349 ins_pipe(empty); 6350 %} 6351 6352 //----------Move Instructions-------------------------------------------------- 6353 6354 instruct castX2P(rRegP dst, rRegL src) 6355 %{ 6356 match(Set dst (CastX2P src)); 6357 6358 format %{ "movq $dst, $src\t# long->ptr" %} 6359 ins_encode %{ 6360 if ($dst$$reg != $src$$reg) { 6361 __ movptr($dst$$Register, $src$$Register); 6362 } 6363 %} 6364 ins_pipe(ialu_reg_reg); // XXX 6365 %} 6366 6367 instruct castP2X(rRegL dst, rRegP src) 6368 %{ 6369 match(Set dst (CastP2X src)); 6370 6371 format %{ "movq $dst, $src\t# ptr -> long" %} 6372 ins_encode %{ 6373 if ($dst$$reg != $src$$reg) { 6374 __ movptr($dst$$Register, $src$$Register); 6375 } 6376 %} 6377 ins_pipe(ialu_reg_reg); // XXX 6378 %} 6379 6380 // Convert oop into int for vectors alignment masking 6381 instruct convP2I(rRegI dst, rRegP src) 6382 %{ 6383 match(Set dst (ConvL2I (CastP2X src))); 6384 6385 format %{ "movl $dst, $src\t# ptr -> int" %} 6386 ins_encode %{ 6387 __ movl($dst$$Register, $src$$Register); 6388 %} 6389 ins_pipe(ialu_reg_reg); // XXX 6390 %} 6391 6392 // Convert compressed oop into int for vectors alignment masking 6393 // in case of 32bit oops (heap < 4Gb). 6394 instruct convN2I(rRegI dst, rRegN src) 6395 %{ 6396 predicate(Universe::narrow_oop_shift() == 0); 6397 match(Set dst (ConvL2I (CastP2X (DecodeN src)))); 6398 6399 format %{ "movl $dst, $src\t# compressed ptr -> int" %} 6400 ins_encode %{ 6401 __ movl($dst$$Register, $src$$Register); 6402 %} 6403 ins_pipe(ialu_reg_reg); // XXX 6404 %} 6405 6406 instruct shenandoahRB(rRegP dst, rRegP src, rFlagsReg cr) %{ 6407 match(Set dst (ShenandoahReadBarrier src)); 6408 effect(DEF dst, USE src); 6409 ins_cost(125); // XXX 6410 format %{ "shenandoah_rb $dst,$src" %} 6411 ins_encode %{ 6412 Register s = $src$$Register; 6413 Register d = $dst$$Register; 6414 __ movptr(d, Address(s, -8)); 6415 %} 6416 ins_pipe(ialu_reg_mem); 6417 %} 6418 6419 instruct shenandoahWB(rax_RegP dst, rdi_RegP src, rFlagsReg cr) %{ 6420 match(Set dst (ShenandoahWriteBarrier src)); 6421 effect(DEF dst, USE_KILL src, KILL cr); 6422 ins_cost(300); // XXX 6423 format %{ "shenandoah_wb $dst,$src" %} 6424 ins_encode %{ 6425 Label done; 6426 Register s = $src$$Register; 6427 Register d = $dst$$Register; 6428 assert(s == rdi, "need rdi"); 6429 assert(d == rax, "result in rax"); 6430 Address evacuation_in_progress = Address(r15_thread, in_bytes(JavaThread::evacuation_in_progress_offset())); 6431 __ movptr(d, Address(s, -8)); 6432 __ cmpb(evacuation_in_progress, 0); 6433 __ movptr(d, Address(s, -8)); 6434 __ jcc(Assembler::equal, done); 6435 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::x86::shenandoah_wb()))); 6436 __ bind(done); 6437 %} 6438 ins_pipe(pipe_slow); 6439 %} 6440 6441 // Convert oop pointer into compressed form 6442 instruct encodeHeapOop(rRegN dst, rRegP src, rFlagsReg cr) %{ 6443 predicate(n->bottom_type()->make_ptr()->ptr() != TypePtr::NotNull); 6444 match(Set dst (EncodeP src)); 6445 effect(KILL cr); 6446 format %{ "encode_heap_oop $dst,$src" %} 6447 ins_encode %{ 6448 Register s = $src$$Register; 6449 Register d = $dst$$Register; 6450 if (s != d) { 6451 __ movq(d, s); 6452 } 6453 __ encode_heap_oop(d); 6454 %} 6455 ins_pipe(ialu_reg_long); 6456 %} 6457 6458 instruct encodeHeapOop_not_null(rRegN dst, rRegP src, rFlagsReg cr) %{ 6459 predicate(n->bottom_type()->make_ptr()->ptr() == TypePtr::NotNull); 6460 match(Set dst (EncodeP src)); 6461 effect(KILL cr); 6462 format %{ "encode_heap_oop_not_null $dst,$src" %} 6463 ins_encode %{ 6464 __ encode_heap_oop_not_null($dst$$Register, $src$$Register); 6465 %} 6466 ins_pipe(ialu_reg_long); 6467 %} 6468 6469 instruct decodeHeapOop(rRegP dst, rRegN src, rFlagsReg cr) %{ 6470 predicate(n->bottom_type()->is_ptr()->ptr() != TypePtr::NotNull && 6471 n->bottom_type()->is_ptr()->ptr() != TypePtr::Constant); 6472 match(Set dst (DecodeN src)); 6473 effect(KILL cr); 6474 format %{ "decode_heap_oop $dst,$src" %} 6475 ins_encode %{ 6476 Register s = $src$$Register; 6477 Register d = $dst$$Register; 6478 if (s != d) { 6479 __ movq(d, s); 6480 } 6481 __ decode_heap_oop(d); 6482 %} 6483 ins_pipe(ialu_reg_long); 6484 %} 6485 6486 instruct decodeHeapOop_not_null(rRegP dst, rRegN src, rFlagsReg cr) %{ 6487 predicate(n->bottom_type()->is_ptr()->ptr() == TypePtr::NotNull || 6488 n->bottom_type()->is_ptr()->ptr() == TypePtr::Constant); 6489 match(Set dst (DecodeN src)); 6490 effect(KILL cr); 6491 format %{ "decode_heap_oop_not_null $dst,$src" %} 6492 ins_encode %{ 6493 Register s = $src$$Register; 6494 Register d = $dst$$Register; 6495 if (s != d) { 6496 __ decode_heap_oop_not_null(d, s); 6497 } else { 6498 __ decode_heap_oop_not_null(d); 6499 } 6500 %} 6501 ins_pipe(ialu_reg_long); 6502 %} 6503 6504 instruct encodeKlass_not_null(rRegN dst, rRegP src, rFlagsReg cr) %{ 6505 match(Set dst (EncodePKlass src)); 6506 effect(KILL cr); 6507 format %{ "encode_klass_not_null $dst,$src" %} 6508 ins_encode %{ 6509 __ encode_klass_not_null($dst$$Register, $src$$Register); 6510 %} 6511 ins_pipe(ialu_reg_long); 6512 %} 6513 6514 instruct decodeKlass_not_null(rRegP dst, rRegN src, rFlagsReg cr) %{ 6515 match(Set dst (DecodeNKlass src)); 6516 effect(KILL cr); 6517 format %{ "decode_klass_not_null $dst,$src" %} 6518 ins_encode %{ 6519 Register s = $src$$Register; 6520 Register d = $dst$$Register; 6521 if (s != d) { 6522 __ decode_klass_not_null(d, s); 6523 } else { 6524 __ decode_klass_not_null(d); 6525 } 6526 %} 6527 ins_pipe(ialu_reg_long); 6528 %} 6529 6530 6531 //----------Conditional Move--------------------------------------------------- 6532 // Jump 6533 // dummy instruction for generating temp registers 6534 instruct jumpXtnd_offset(rRegL switch_val, immI2 shift, rRegI dest) %{ 6535 match(Jump (LShiftL switch_val shift)); 6536 ins_cost(350); 6537 predicate(false); 6538 effect(TEMP dest); 6539 6540 format %{ "leaq $dest, [$constantaddress]\n\t" 6541 "jmp [$dest + $switch_val << $shift]\n\t" %} 6542 ins_encode %{ 6543 // We could use jump(ArrayAddress) except that the macro assembler needs to use r10 6544 // to do that and the compiler is using that register as one it can allocate. 6545 // So we build it all by hand. 6546 // Address index(noreg, switch_reg, (Address::ScaleFactor)$shift$$constant); 6547 // ArrayAddress dispatch(table, index); 6548 Address dispatch($dest$$Register, $switch_val$$Register, (Address::ScaleFactor) $shift$$constant); 6549 __ lea($dest$$Register, $constantaddress); 6550 __ jmp(dispatch); 6551 %} 6552 ins_pipe(pipe_jmp); 6553 %} 6554 6555 instruct jumpXtnd_addr(rRegL switch_val, immI2 shift, immL32 offset, rRegI dest) %{ 6556 match(Jump (AddL (LShiftL switch_val shift) offset)); 6557 ins_cost(350); 6558 effect(TEMP dest); 6559 6560 format %{ "leaq $dest, [$constantaddress]\n\t" 6561 "jmp [$dest + $switch_val << $shift + $offset]\n\t" %} 6562 ins_encode %{ 6563 // We could use jump(ArrayAddress) except that the macro assembler needs to use r10 6564 // to do that and the compiler is using that register as one it can allocate. 6565 // So we build it all by hand. 6566 // Address index(noreg, switch_reg, (Address::ScaleFactor) $shift$$constant, (int) $offset$$constant); 6567 // ArrayAddress dispatch(table, index); 6568 Address dispatch($dest$$Register, $switch_val$$Register, (Address::ScaleFactor) $shift$$constant, (int) $offset$$constant); 6569 __ lea($dest$$Register, $constantaddress); 6570 __ jmp(dispatch); 6571 %} 6572 ins_pipe(pipe_jmp); 6573 %} 6574 6575 instruct jumpXtnd(rRegL switch_val, rRegI dest) %{ 6576 match(Jump switch_val); 6577 ins_cost(350); 6578 effect(TEMP dest); 6579 6580 format %{ "leaq $dest, [$constantaddress]\n\t" 6581 "jmp [$dest + $switch_val]\n\t" %} 6582 ins_encode %{ 6583 // We could use jump(ArrayAddress) except that the macro assembler needs to use r10 6584 // to do that and the compiler is using that register as one it can allocate. 6585 // So we build it all by hand. 6586 // Address index(noreg, switch_reg, Address::times_1); 6587 // ArrayAddress dispatch(table, index); 6588 Address dispatch($dest$$Register, $switch_val$$Register, Address::times_1); 6589 __ lea($dest$$Register, $constantaddress); 6590 __ jmp(dispatch); 6591 %} 6592 ins_pipe(pipe_jmp); 6593 %} 6594 6595 // Conditional move 6596 instruct cmovI_reg(rRegI dst, rRegI src, rFlagsReg cr, cmpOp cop) 6597 %{ 6598 match(Set dst (CMoveI (Binary cop cr) (Binary dst src))); 6599 6600 ins_cost(200); // XXX 6601 format %{ "cmovl$cop $dst, $src\t# signed, int" %} 6602 opcode(0x0F, 0x40); 6603 ins_encode(REX_reg_reg(dst, src), enc_cmov(cop), reg_reg(dst, src)); 6604 ins_pipe(pipe_cmov_reg); 6605 %} 6606 6607 instruct cmovI_regU(cmpOpU cop, rFlagsRegU cr, rRegI dst, rRegI src) %{ 6608 match(Set dst (CMoveI (Binary cop cr) (Binary dst src))); 6609 6610 ins_cost(200); // XXX 6611 format %{ "cmovl$cop $dst, $src\t# unsigned, int" %} 6612 opcode(0x0F, 0x40); 6613 ins_encode(REX_reg_reg(dst, src), enc_cmov(cop), reg_reg(dst, src)); 6614 ins_pipe(pipe_cmov_reg); 6615 %} 6616 6617 instruct cmovI_regUCF(cmpOpUCF cop, rFlagsRegUCF cr, rRegI dst, rRegI src) %{ 6618 match(Set dst (CMoveI (Binary cop cr) (Binary dst src))); 6619 ins_cost(200); 6620 expand %{ 6621 cmovI_regU(cop, cr, dst, src); 6622 %} 6623 %} 6624 6625 // Conditional move 6626 instruct cmovI_mem(cmpOp cop, rFlagsReg cr, rRegI dst, memory src) %{ 6627 match(Set dst (CMoveI (Binary cop cr) (Binary dst (LoadI src)))); 6628 6629 ins_cost(250); // XXX 6630 format %{ "cmovl$cop $dst, $src\t# signed, int" %} 6631 opcode(0x0F, 0x40); 6632 ins_encode(REX_reg_mem(dst, src), enc_cmov(cop), reg_mem(dst, src)); 6633 ins_pipe(pipe_cmov_mem); 6634 %} 6635 6636 // Conditional move 6637 instruct cmovI_memU(cmpOpU cop, rFlagsRegU cr, rRegI dst, memory src) 6638 %{ 6639 match(Set dst (CMoveI (Binary cop cr) (Binary dst (LoadI src)))); 6640 6641 ins_cost(250); // XXX 6642 format %{ "cmovl$cop $dst, $src\t# unsigned, int" %} 6643 opcode(0x0F, 0x40); 6644 ins_encode(REX_reg_mem(dst, src), enc_cmov(cop), reg_mem(dst, src)); 6645 ins_pipe(pipe_cmov_mem); 6646 %} 6647 6648 instruct cmovI_memUCF(cmpOpUCF cop, rFlagsRegUCF cr, rRegI dst, memory src) %{ 6649 match(Set dst (CMoveI (Binary cop cr) (Binary dst (LoadI src)))); 6650 ins_cost(250); 6651 expand %{ 6652 cmovI_memU(cop, cr, dst, src); 6653 %} 6654 %} 6655 6656 // Conditional move 6657 instruct cmovN_reg(rRegN dst, rRegN src, rFlagsReg cr, cmpOp cop) 6658 %{ 6659 match(Set dst (CMoveN (Binary cop cr) (Binary dst src))); 6660 6661 ins_cost(200); // XXX 6662 format %{ "cmovl$cop $dst, $src\t# signed, compressed ptr" %} 6663 opcode(0x0F, 0x40); 6664 ins_encode(REX_reg_reg(dst, src), enc_cmov(cop), reg_reg(dst, src)); 6665 ins_pipe(pipe_cmov_reg); 6666 %} 6667 6668 // Conditional move 6669 instruct cmovN_regU(cmpOpU cop, rFlagsRegU cr, rRegN dst, rRegN src) 6670 %{ 6671 match(Set dst (CMoveN (Binary cop cr) (Binary dst src))); 6672 6673 ins_cost(200); // XXX 6674 format %{ "cmovl$cop $dst, $src\t# unsigned, compressed ptr" %} 6675 opcode(0x0F, 0x40); 6676 ins_encode(REX_reg_reg(dst, src), enc_cmov(cop), reg_reg(dst, src)); 6677 ins_pipe(pipe_cmov_reg); 6678 %} 6679 6680 instruct cmovN_regUCF(cmpOpUCF cop, rFlagsRegUCF cr, rRegN dst, rRegN src) %{ 6681 match(Set dst (CMoveN (Binary cop cr) (Binary dst src))); 6682 ins_cost(200); 6683 expand %{ 6684 cmovN_regU(cop, cr, dst, src); 6685 %} 6686 %} 6687 6688 // Conditional move 6689 instruct cmovP_reg(rRegP dst, rRegP src, rFlagsReg cr, cmpOp cop) 6690 %{ 6691 match(Set dst (CMoveP (Binary cop cr) (Binary dst src))); 6692 6693 ins_cost(200); // XXX 6694 format %{ "cmovq$cop $dst, $src\t# signed, ptr" %} 6695 opcode(0x0F, 0x40); 6696 ins_encode(REX_reg_reg_wide(dst, src), enc_cmov(cop), reg_reg(dst, src)); 6697 ins_pipe(pipe_cmov_reg); // XXX 6698 %} 6699 6700 // Conditional move 6701 instruct cmovP_regU(cmpOpU cop, rFlagsRegU cr, rRegP dst, rRegP src) 6702 %{ 6703 match(Set dst (CMoveP (Binary cop cr) (Binary dst src))); 6704 6705 ins_cost(200); // XXX 6706 format %{ "cmovq$cop $dst, $src\t# unsigned, ptr" %} 6707 opcode(0x0F, 0x40); 6708 ins_encode(REX_reg_reg_wide(dst, src), enc_cmov(cop), reg_reg(dst, src)); 6709 ins_pipe(pipe_cmov_reg); // XXX 6710 %} 6711 6712 instruct cmovP_regUCF(cmpOpUCF cop, rFlagsRegUCF cr, rRegP dst, rRegP src) %{ 6713 match(Set dst (CMoveP (Binary cop cr) (Binary dst src))); 6714 ins_cost(200); 6715 expand %{ 6716 cmovP_regU(cop, cr, dst, src); 6717 %} 6718 %} 6719 6720 // DISABLED: Requires the ADLC to emit a bottom_type call that 6721 // correctly meets the two pointer arguments; one is an incoming 6722 // register but the other is a memory operand. ALSO appears to 6723 // be buggy with implicit null checks. 6724 // 6725 //// Conditional move 6726 //instruct cmovP_mem(cmpOp cop, rFlagsReg cr, rRegP dst, memory src) 6727 //%{ 6728 // match(Set dst (CMoveP (Binary cop cr) (Binary dst (LoadP src)))); 6729 // ins_cost(250); 6730 // format %{ "CMOV$cop $dst,$src\t# ptr" %} 6731 // opcode(0x0F,0x40); 6732 // ins_encode( enc_cmov(cop), reg_mem( dst, src ) ); 6733 // ins_pipe( pipe_cmov_mem ); 6734 //%} 6735 // 6736 //// Conditional move 6737 //instruct cmovP_memU(cmpOpU cop, rFlagsRegU cr, rRegP dst, memory src) 6738 //%{ 6739 // match(Set dst (CMoveP (Binary cop cr) (Binary dst (LoadP src)))); 6740 // ins_cost(250); 6741 // format %{ "CMOV$cop $dst,$src\t# ptr" %} 6742 // opcode(0x0F,0x40); 6743 // ins_encode( enc_cmov(cop), reg_mem( dst, src ) ); 6744 // ins_pipe( pipe_cmov_mem ); 6745 //%} 6746 6747 instruct cmovL_reg(cmpOp cop, rFlagsReg cr, rRegL dst, rRegL src) 6748 %{ 6749 match(Set dst (CMoveL (Binary cop cr) (Binary dst src))); 6750 6751 ins_cost(200); // XXX 6752 format %{ "cmovq$cop $dst, $src\t# signed, long" %} 6753 opcode(0x0F, 0x40); 6754 ins_encode(REX_reg_reg_wide(dst, src), enc_cmov(cop), reg_reg(dst, src)); 6755 ins_pipe(pipe_cmov_reg); // XXX 6756 %} 6757 6758 instruct cmovL_mem(cmpOp cop, rFlagsReg cr, rRegL dst, memory src) 6759 %{ 6760 match(Set dst (CMoveL (Binary cop cr) (Binary dst (LoadL src)))); 6761 6762 ins_cost(200); // XXX 6763 format %{ "cmovq$cop $dst, $src\t# signed, long" %} 6764 opcode(0x0F, 0x40); 6765 ins_encode(REX_reg_mem_wide(dst, src), enc_cmov(cop), reg_mem(dst, src)); 6766 ins_pipe(pipe_cmov_mem); // XXX 6767 %} 6768 6769 instruct cmovL_regU(cmpOpU cop, rFlagsRegU cr, rRegL dst, rRegL src) 6770 %{ 6771 match(Set dst (CMoveL (Binary cop cr) (Binary dst src))); 6772 6773 ins_cost(200); // XXX 6774 format %{ "cmovq$cop $dst, $src\t# unsigned, long" %} 6775 opcode(0x0F, 0x40); 6776 ins_encode(REX_reg_reg_wide(dst, src), enc_cmov(cop), reg_reg(dst, src)); 6777 ins_pipe(pipe_cmov_reg); // XXX 6778 %} 6779 6780 instruct cmovL_regUCF(cmpOpUCF cop, rFlagsRegUCF cr, rRegL dst, rRegL src) %{ 6781 match(Set dst (CMoveL (Binary cop cr) (Binary dst src))); 6782 ins_cost(200); 6783 expand %{ 6784 cmovL_regU(cop, cr, dst, src); 6785 %} 6786 %} 6787 6788 instruct cmovL_memU(cmpOpU cop, rFlagsRegU cr, rRegL dst, memory src) 6789 %{ 6790 match(Set dst (CMoveL (Binary cop cr) (Binary dst (LoadL src)))); 6791 6792 ins_cost(200); // XXX 6793 format %{ "cmovq$cop $dst, $src\t# unsigned, long" %} 6794 opcode(0x0F, 0x40); 6795 ins_encode(REX_reg_mem_wide(dst, src), enc_cmov(cop), reg_mem(dst, src)); 6796 ins_pipe(pipe_cmov_mem); // XXX 6797 %} 6798 6799 instruct cmovL_memUCF(cmpOpUCF cop, rFlagsRegUCF cr, rRegL dst, memory src) %{ 6800 match(Set dst (CMoveL (Binary cop cr) (Binary dst (LoadL src)))); 6801 ins_cost(200); 6802 expand %{ 6803 cmovL_memU(cop, cr, dst, src); 6804 %} 6805 %} 6806 6807 instruct cmovF_reg(cmpOp cop, rFlagsReg cr, regF dst, regF src) 6808 %{ 6809 match(Set dst (CMoveF (Binary cop cr) (Binary dst src))); 6810 6811 ins_cost(200); // XXX 6812 format %{ "jn$cop skip\t# signed cmove float\n\t" 6813 "movss $dst, $src\n" 6814 "skip:" %} 6815 ins_encode %{ 6816 Label Lskip; 6817 // Invert sense of branch from sense of CMOV 6818 __ jccb((Assembler::Condition)($cop$$cmpcode^1), Lskip); 6819 __ movflt($dst$$XMMRegister, $src$$XMMRegister); 6820 __ bind(Lskip); 6821 %} 6822 ins_pipe(pipe_slow); 6823 %} 6824 6825 // instruct cmovF_mem(cmpOp cop, rFlagsReg cr, regF dst, memory src) 6826 // %{ 6827 // match(Set dst (CMoveF (Binary cop cr) (Binary dst (LoadL src)))); 6828 6829 // ins_cost(200); // XXX 6830 // format %{ "jn$cop skip\t# signed cmove float\n\t" 6831 // "movss $dst, $src\n" 6832 // "skip:" %} 6833 // ins_encode(enc_cmovf_mem_branch(cop, dst, src)); 6834 // ins_pipe(pipe_slow); 6835 // %} 6836 6837 instruct cmovF_regU(cmpOpU cop, rFlagsRegU cr, regF dst, regF src) 6838 %{ 6839 match(Set dst (CMoveF (Binary cop cr) (Binary dst src))); 6840 6841 ins_cost(200); // XXX 6842 format %{ "jn$cop skip\t# unsigned cmove float\n\t" 6843 "movss $dst, $src\n" 6844 "skip:" %} 6845 ins_encode %{ 6846 Label Lskip; 6847 // Invert sense of branch from sense of CMOV 6848 __ jccb((Assembler::Condition)($cop$$cmpcode^1), Lskip); 6849 __ movflt($dst$$XMMRegister, $src$$XMMRegister); 6850 __ bind(Lskip); 6851 %} 6852 ins_pipe(pipe_slow); 6853 %} 6854 6855 instruct cmovF_regUCF(cmpOpUCF cop, rFlagsRegUCF cr, regF dst, regF src) %{ 6856 match(Set dst (CMoveF (Binary cop cr) (Binary dst src))); 6857 ins_cost(200); 6858 expand %{ 6859 cmovF_regU(cop, cr, dst, src); 6860 %} 6861 %} 6862 6863 instruct cmovD_reg(cmpOp cop, rFlagsReg cr, regD dst, regD src) 6864 %{ 6865 match(Set dst (CMoveD (Binary cop cr) (Binary dst src))); 6866 6867 ins_cost(200); // XXX 6868 format %{ "jn$cop skip\t# signed cmove double\n\t" 6869 "movsd $dst, $src\n" 6870 "skip:" %} 6871 ins_encode %{ 6872 Label Lskip; 6873 // Invert sense of branch from sense of CMOV 6874 __ jccb((Assembler::Condition)($cop$$cmpcode^1), Lskip); 6875 __ movdbl($dst$$XMMRegister, $src$$XMMRegister); 6876 __ bind(Lskip); 6877 %} 6878 ins_pipe(pipe_slow); 6879 %} 6880 6881 instruct cmovD_regU(cmpOpU cop, rFlagsRegU cr, regD dst, regD src) 6882 %{ 6883 match(Set dst (CMoveD (Binary cop cr) (Binary dst src))); 6884 6885 ins_cost(200); // XXX 6886 format %{ "jn$cop skip\t# unsigned cmove double\n\t" 6887 "movsd $dst, $src\n" 6888 "skip:" %} 6889 ins_encode %{ 6890 Label Lskip; 6891 // Invert sense of branch from sense of CMOV 6892 __ jccb((Assembler::Condition)($cop$$cmpcode^1), Lskip); 6893 __ movdbl($dst$$XMMRegister, $src$$XMMRegister); 6894 __ bind(Lskip); 6895 %} 6896 ins_pipe(pipe_slow); 6897 %} 6898 6899 instruct cmovD_regUCF(cmpOpUCF cop, rFlagsRegUCF cr, regD dst, regD src) %{ 6900 match(Set dst (CMoveD (Binary cop cr) (Binary dst src))); 6901 ins_cost(200); 6902 expand %{ 6903 cmovD_regU(cop, cr, dst, src); 6904 %} 6905 %} 6906 6907 //----------Arithmetic Instructions-------------------------------------------- 6908 //----------Addition Instructions---------------------------------------------- 6909 6910 instruct addI_rReg(rRegI dst, rRegI src, rFlagsReg cr) 6911 %{ 6912 match(Set dst (AddI dst src)); 6913 effect(KILL cr); 6914 6915 format %{ "addl $dst, $src\t# int" %} 6916 opcode(0x03); 6917 ins_encode(REX_reg_reg(dst, src), OpcP, reg_reg(dst, src)); 6918 ins_pipe(ialu_reg_reg); 6919 %} 6920 6921 instruct addI_rReg_imm(rRegI dst, immI src, rFlagsReg cr) 6922 %{ 6923 match(Set dst (AddI dst src)); 6924 effect(KILL cr); 6925 6926 format %{ "addl $dst, $src\t# int" %} 6927 opcode(0x81, 0x00); /* /0 id */ 6928 ins_encode(OpcSErm(dst, src), Con8or32(src)); 6929 ins_pipe( ialu_reg ); 6930 %} 6931 6932 instruct addI_rReg_mem(rRegI dst, memory src, rFlagsReg cr) 6933 %{ 6934 match(Set dst (AddI dst (LoadI src))); 6935 effect(KILL cr); 6936 6937 ins_cost(125); // XXX 6938 format %{ "addl $dst, $src\t# int" %} 6939 opcode(0x03); 6940 ins_encode(REX_reg_mem(dst, src), OpcP, reg_mem(dst, src)); 6941 ins_pipe(ialu_reg_mem); 6942 %} 6943 6944 instruct addI_mem_rReg(memory dst, rRegI src, rFlagsReg cr) 6945 %{ 6946 match(Set dst (StoreI dst (AddI (LoadI dst) src))); 6947 effect(KILL cr); 6948 6949 ins_cost(150); // XXX 6950 format %{ "addl $dst, $src\t# int" %} 6951 opcode(0x01); /* Opcode 01 /r */ 6952 ins_encode(REX_reg_mem(src, dst), OpcP, reg_mem(src, dst)); 6953 ins_pipe(ialu_mem_reg); 6954 %} 6955 6956 instruct addI_mem_imm(memory dst, immI src, rFlagsReg cr) 6957 %{ 6958 match(Set dst (StoreI dst (AddI (LoadI dst) src))); 6959 effect(KILL cr); 6960 6961 ins_cost(125); // XXX 6962 format %{ "addl $dst, $src\t# int" %} 6963 opcode(0x81); /* Opcode 81 /0 id */ 6964 ins_encode(REX_mem(dst), OpcSE(src), RM_opc_mem(0x00, dst), Con8or32(src)); 6965 ins_pipe(ialu_mem_imm); 6966 %} 6967 6968 instruct incI_rReg(rRegI dst, immI1 src, rFlagsReg cr) 6969 %{ 6970 predicate(UseIncDec); 6971 match(Set dst (AddI dst src)); 6972 effect(KILL cr); 6973 6974 format %{ "incl $dst\t# int" %} 6975 opcode(0xFF, 0x00); // FF /0 6976 ins_encode(REX_reg(dst), OpcP, reg_opc(dst)); 6977 ins_pipe(ialu_reg); 6978 %} 6979 6980 instruct incI_mem(memory dst, immI1 src, rFlagsReg cr) 6981 %{ 6982 predicate(UseIncDec); 6983 match(Set dst (StoreI dst (AddI (LoadI dst) src))); 6984 effect(KILL cr); 6985 6986 ins_cost(125); // XXX 6987 format %{ "incl $dst\t# int" %} 6988 opcode(0xFF); /* Opcode FF /0 */ 6989 ins_encode(REX_mem(dst), OpcP, RM_opc_mem(0x00, dst)); 6990 ins_pipe(ialu_mem_imm); 6991 %} 6992 6993 // XXX why does that use AddI 6994 instruct decI_rReg(rRegI dst, immI_M1 src, rFlagsReg cr) 6995 %{ 6996 predicate(UseIncDec); 6997 match(Set dst (AddI dst src)); 6998 effect(KILL cr); 6999 7000 format %{ "decl $dst\t# int" %} 7001 opcode(0xFF, 0x01); // FF /1 7002 ins_encode(REX_reg(dst), OpcP, reg_opc(dst)); 7003 ins_pipe(ialu_reg); 7004 %} 7005 7006 // XXX why does that use AddI 7007 instruct decI_mem(memory dst, immI_M1 src, rFlagsReg cr) 7008 %{ 7009 predicate(UseIncDec); 7010 match(Set dst (StoreI dst (AddI (LoadI dst) src))); 7011 effect(KILL cr); 7012 7013 ins_cost(125); // XXX 7014 format %{ "decl $dst\t# int" %} 7015 opcode(0xFF); /* Opcode FF /1 */ 7016 ins_encode(REX_mem(dst), OpcP, RM_opc_mem(0x01, dst)); 7017 ins_pipe(ialu_mem_imm); 7018 %} 7019 7020 instruct leaI_rReg_immI(rRegI dst, rRegI src0, immI src1) 7021 %{ 7022 match(Set dst (AddI src0 src1)); 7023 7024 ins_cost(110); 7025 format %{ "addr32 leal $dst, [$src0 + $src1]\t# int" %} 7026 opcode(0x8D); /* 0x8D /r */ 7027 ins_encode(Opcode(0x67), REX_reg_reg(dst, src0), OpcP, reg_lea(dst, src0, src1)); // XXX 7028 ins_pipe(ialu_reg_reg); 7029 %} 7030 7031 instruct addL_rReg(rRegL dst, rRegL src, rFlagsReg cr) 7032 %{ 7033 match(Set dst (AddL dst src)); 7034 effect(KILL cr); 7035 7036 format %{ "addq $dst, $src\t# long" %} 7037 opcode(0x03); 7038 ins_encode(REX_reg_reg_wide(dst, src), OpcP, reg_reg(dst, src)); 7039 ins_pipe(ialu_reg_reg); 7040 %} 7041 7042 instruct addL_rReg_imm(rRegL dst, immL32 src, rFlagsReg cr) 7043 %{ 7044 match(Set dst (AddL dst src)); 7045 effect(KILL cr); 7046 7047 format %{ "addq $dst, $src\t# long" %} 7048 opcode(0x81, 0x00); /* /0 id */ 7049 ins_encode(OpcSErm_wide(dst, src), Con8or32(src)); 7050 ins_pipe( ialu_reg ); 7051 %} 7052 7053 instruct addL_rReg_mem(rRegL dst, memory src, rFlagsReg cr) 7054 %{ 7055 match(Set dst (AddL dst (LoadL src))); 7056 effect(KILL cr); 7057 7058 ins_cost(125); // XXX 7059 format %{ "addq $dst, $src\t# long" %} 7060 opcode(0x03); 7061 ins_encode(REX_reg_mem_wide(dst, src), OpcP, reg_mem(dst, src)); 7062 ins_pipe(ialu_reg_mem); 7063 %} 7064 7065 instruct addL_mem_rReg(memory dst, rRegL src, rFlagsReg cr) 7066 %{ 7067 match(Set dst (StoreL dst (AddL (LoadL dst) src))); 7068 effect(KILL cr); 7069 7070 ins_cost(150); // XXX 7071 format %{ "addq $dst, $src\t# long" %} 7072 opcode(0x01); /* Opcode 01 /r */ 7073 ins_encode(REX_reg_mem_wide(src, dst), OpcP, reg_mem(src, dst)); 7074 ins_pipe(ialu_mem_reg); 7075 %} 7076 7077 instruct addL_mem_imm(memory dst, immL32 src, rFlagsReg cr) 7078 %{ 7079 match(Set dst (StoreL dst (AddL (LoadL dst) src))); 7080 effect(KILL cr); 7081 7082 ins_cost(125); // XXX 7083 format %{ "addq $dst, $src\t# long" %} 7084 opcode(0x81); /* Opcode 81 /0 id */ 7085 ins_encode(REX_mem_wide(dst), 7086 OpcSE(src), RM_opc_mem(0x00, dst), Con8or32(src)); 7087 ins_pipe(ialu_mem_imm); 7088 %} 7089 7090 instruct incL_rReg(rRegI dst, immL1 src, rFlagsReg cr) 7091 %{ 7092 predicate(UseIncDec); 7093 match(Set dst (AddL dst src)); 7094 effect(KILL cr); 7095 7096 format %{ "incq $dst\t# long" %} 7097 opcode(0xFF, 0x00); // FF /0 7098 ins_encode(REX_reg_wide(dst), OpcP, reg_opc(dst)); 7099 ins_pipe(ialu_reg); 7100 %} 7101 7102 instruct incL_mem(memory dst, immL1 src, rFlagsReg cr) 7103 %{ 7104 predicate(UseIncDec); 7105 match(Set dst (StoreL dst (AddL (LoadL dst) src))); 7106 effect(KILL cr); 7107 7108 ins_cost(125); // XXX 7109 format %{ "incq $dst\t# long" %} 7110 opcode(0xFF); /* Opcode FF /0 */ 7111 ins_encode(REX_mem_wide(dst), OpcP, RM_opc_mem(0x00, dst)); 7112 ins_pipe(ialu_mem_imm); 7113 %} 7114 7115 // XXX why does that use AddL 7116 instruct decL_rReg(rRegL dst, immL_M1 src, rFlagsReg cr) 7117 %{ 7118 predicate(UseIncDec); 7119 match(Set dst (AddL dst src)); 7120 effect(KILL cr); 7121 7122 format %{ "decq $dst\t# long" %} 7123 opcode(0xFF, 0x01); // FF /1 7124 ins_encode(REX_reg_wide(dst), OpcP, reg_opc(dst)); 7125 ins_pipe(ialu_reg); 7126 %} 7127 7128 // XXX why does that use AddL 7129 instruct decL_mem(memory dst, immL_M1 src, rFlagsReg cr) 7130 %{ 7131 predicate(UseIncDec); 7132 match(Set dst (StoreL dst (AddL (LoadL dst) src))); 7133 effect(KILL cr); 7134 7135 ins_cost(125); // XXX 7136 format %{ "decq $dst\t# long" %} 7137 opcode(0xFF); /* Opcode FF /1 */ 7138 ins_encode(REX_mem_wide(dst), OpcP, RM_opc_mem(0x01, dst)); 7139 ins_pipe(ialu_mem_imm); 7140 %} 7141 7142 instruct leaL_rReg_immL(rRegL dst, rRegL src0, immL32 src1) 7143 %{ 7144 match(Set dst (AddL src0 src1)); 7145 7146 ins_cost(110); 7147 format %{ "leaq $dst, [$src0 + $src1]\t# long" %} 7148 opcode(0x8D); /* 0x8D /r */ 7149 ins_encode(REX_reg_reg_wide(dst, src0), OpcP, reg_lea(dst, src0, src1)); // XXX 7150 ins_pipe(ialu_reg_reg); 7151 %} 7152 7153 instruct addP_rReg(rRegP dst, rRegL src, rFlagsReg cr) 7154 %{ 7155 match(Set dst (AddP dst src)); 7156 effect(KILL cr); 7157 7158 format %{ "addq $dst, $src\t# ptr" %} 7159 opcode(0x03); 7160 ins_encode(REX_reg_reg_wide(dst, src), OpcP, reg_reg(dst, src)); 7161 ins_pipe(ialu_reg_reg); 7162 %} 7163 7164 instruct addP_rReg_imm(rRegP dst, immL32 src, rFlagsReg cr) 7165 %{ 7166 match(Set dst (AddP dst src)); 7167 effect(KILL cr); 7168 7169 format %{ "addq $dst, $src\t# ptr" %} 7170 opcode(0x81, 0x00); /* /0 id */ 7171 ins_encode(OpcSErm_wide(dst, src), Con8or32(src)); 7172 ins_pipe( ialu_reg ); 7173 %} 7174 7175 // XXX addP mem ops ???? 7176 7177 instruct leaP_rReg_imm(rRegP dst, rRegP src0, immL32 src1) 7178 %{ 7179 match(Set dst (AddP src0 src1)); 7180 7181 ins_cost(110); 7182 format %{ "leaq $dst, [$src0 + $src1]\t# ptr" %} 7183 opcode(0x8D); /* 0x8D /r */ 7184 ins_encode(REX_reg_reg_wide(dst, src0), OpcP, reg_lea(dst, src0, src1));// XXX 7185 ins_pipe(ialu_reg_reg); 7186 %} 7187 7188 instruct checkCastPP(rRegP dst) 7189 %{ 7190 match(Set dst (CheckCastPP dst)); 7191 7192 size(0); 7193 format %{ "# checkcastPP of $dst" %} 7194 ins_encode(/* empty encoding */); 7195 ins_pipe(empty); 7196 %} 7197 7198 instruct castPP(rRegP dst) 7199 %{ 7200 match(Set dst (CastPP dst)); 7201 7202 size(0); 7203 format %{ "# castPP of $dst" %} 7204 ins_encode(/* empty encoding */); 7205 ins_pipe(empty); 7206 %} 7207 7208 instruct castII(rRegI dst) 7209 %{ 7210 match(Set dst (CastII dst)); 7211 7212 size(0); 7213 format %{ "# castII of $dst" %} 7214 ins_encode(/* empty encoding */); 7215 ins_cost(0); 7216 ins_pipe(empty); 7217 %} 7218 7219 // LoadP-locked same as a regular LoadP when used with compare-swap 7220 instruct loadPLocked(rRegP dst, memory mem) 7221 %{ 7222 match(Set dst (LoadPLocked mem)); 7223 7224 ins_cost(125); // XXX 7225 format %{ "movq $dst, $mem\t# ptr locked" %} 7226 opcode(0x8B); 7227 ins_encode(REX_reg_mem_wide(dst, mem), OpcP, reg_mem(dst, mem)); 7228 ins_pipe(ialu_reg_mem); // XXX 7229 %} 7230 7231 // Conditional-store of the updated heap-top. 7232 // Used during allocation of the shared heap. 7233 // Sets flags (EQ) on success. Implemented with a CMPXCHG on Intel. 7234 7235 instruct storePConditional(memory heap_top_ptr, 7236 rax_RegP oldval, rRegP newval, 7237 rFlagsReg cr) 7238 %{ 7239 match(Set cr (StorePConditional heap_top_ptr (Binary oldval newval))); 7240 7241 format %{ "cmpxchgq $heap_top_ptr, $newval\t# (ptr) " 7242 "If rax == $heap_top_ptr then store $newval into $heap_top_ptr" %} 7243 opcode(0x0F, 0xB1); 7244 ins_encode(lock_prefix, 7245 REX_reg_mem_wide(newval, heap_top_ptr), 7246 OpcP, OpcS, 7247 reg_mem(newval, heap_top_ptr)); 7248 ins_pipe(pipe_cmpxchg); 7249 %} 7250 7251 // Conditional-store of an int value. 7252 // ZF flag is set on success, reset otherwise. Implemented with a CMPXCHG. 7253 instruct storeIConditional(memory mem, rax_RegI oldval, rRegI newval, rFlagsReg cr) 7254 %{ 7255 match(Set cr (StoreIConditional mem (Binary oldval newval))); 7256 effect(KILL oldval); 7257 7258 format %{ "cmpxchgl $mem, $newval\t# If rax == $mem then store $newval into $mem" %} 7259 opcode(0x0F, 0xB1); 7260 ins_encode(lock_prefix, 7261 REX_reg_mem(newval, mem), 7262 OpcP, OpcS, 7263 reg_mem(newval, mem)); 7264 ins_pipe(pipe_cmpxchg); 7265 %} 7266 7267 // Conditional-store of a long value. 7268 // ZF flag is set on success, reset otherwise. Implemented with a CMPXCHG. 7269 instruct storeLConditional(memory mem, rax_RegL oldval, rRegL newval, rFlagsReg cr) 7270 %{ 7271 match(Set cr (StoreLConditional mem (Binary oldval newval))); 7272 effect(KILL oldval); 7273 7274 format %{ "cmpxchgq $mem, $newval\t# If rax == $mem then store $newval into $mem" %} 7275 opcode(0x0F, 0xB1); 7276 ins_encode(lock_prefix, 7277 REX_reg_mem_wide(newval, mem), 7278 OpcP, OpcS, 7279 reg_mem(newval, mem)); 7280 ins_pipe(pipe_cmpxchg); 7281 %} 7282 7283 7284 // XXX No flag versions for CompareAndSwap{P,I,L} because matcher can't match them 7285 instruct compareAndSwapP(rRegI res, 7286 memory mem_ptr, 7287 rax_RegP oldval, rRegP newval, 7288 rFlagsReg cr) 7289 %{ 7290 predicate(VM_Version::supports_cx8()); 7291 match(Set res (CompareAndSwapP mem_ptr (Binary oldval newval))); 7292 effect(KILL cr, KILL oldval); 7293 7294 format %{ "cmpxchgq $mem_ptr,$newval\t# " 7295 "If rax == $mem_ptr then store $newval into $mem_ptr\n\t" 7296 "sete $res\n\t" 7297 "movzbl $res, $res" %} 7298 opcode(0x0F, 0xB1); 7299 ins_encode(lock_prefix, 7300 REX_reg_mem_wide(newval, mem_ptr), 7301 OpcP, OpcS, 7302 reg_mem(newval, mem_ptr), 7303 REX_breg(res), Opcode(0x0F), Opcode(0x94), reg(res), // sete 7304 REX_reg_breg(res, res), // movzbl 7305 Opcode(0xF), Opcode(0xB6), reg_reg(res, res)); 7306 ins_pipe( pipe_cmpxchg ); 7307 %} 7308 7309 instruct compareAndSwapL(rRegI res, 7310 memory mem_ptr, 7311 rax_RegL oldval, rRegL newval, 7312 rFlagsReg cr) 7313 %{ 7314 predicate(VM_Version::supports_cx8()); 7315 match(Set res (CompareAndSwapL mem_ptr (Binary oldval newval))); 7316 effect(KILL cr, KILL oldval); 7317 7318 format %{ "cmpxchgq $mem_ptr,$newval\t# " 7319 "If rax == $mem_ptr then store $newval into $mem_ptr\n\t" 7320 "sete $res\n\t" 7321 "movzbl $res, $res" %} 7322 opcode(0x0F, 0xB1); 7323 ins_encode(lock_prefix, 7324 REX_reg_mem_wide(newval, mem_ptr), 7325 OpcP, OpcS, 7326 reg_mem(newval, mem_ptr), 7327 REX_breg(res), Opcode(0x0F), Opcode(0x94), reg(res), // sete 7328 REX_reg_breg(res, res), // movzbl 7329 Opcode(0xF), Opcode(0xB6), reg_reg(res, res)); 7330 ins_pipe( pipe_cmpxchg ); 7331 %} 7332 7333 instruct compareAndSwapI(rRegI res, 7334 memory mem_ptr, 7335 rax_RegI oldval, rRegI newval, 7336 rFlagsReg cr) 7337 %{ 7338 match(Set res (CompareAndSwapI mem_ptr (Binary oldval newval))); 7339 effect(KILL cr, KILL oldval); 7340 7341 format %{ "cmpxchgl $mem_ptr,$newval\t# " 7342 "If rax == $mem_ptr then store $newval into $mem_ptr\n\t" 7343 "sete $res\n\t" 7344 "movzbl $res, $res" %} 7345 opcode(0x0F, 0xB1); 7346 ins_encode(lock_prefix, 7347 REX_reg_mem(newval, mem_ptr), 7348 OpcP, OpcS, 7349 reg_mem(newval, mem_ptr), 7350 REX_breg(res), Opcode(0x0F), Opcode(0x94), reg(res), // sete 7351 REX_reg_breg(res, res), // movzbl 7352 Opcode(0xF), Opcode(0xB6), reg_reg(res, res)); 7353 ins_pipe( pipe_cmpxchg ); 7354 %} 7355 7356 7357 instruct compareAndSwapN(rRegI res, 7358 memory mem_ptr, 7359 rax_RegN oldval, rRegN newval, 7360 rFlagsReg cr) %{ 7361 match(Set res (CompareAndSwapN mem_ptr (Binary oldval newval))); 7362 effect(KILL cr, KILL oldval); 7363 7364 format %{ "cmpxchgl $mem_ptr,$newval\t# " 7365 "If rax == $mem_ptr then store $newval into $mem_ptr\n\t" 7366 "sete $res\n\t" 7367 "movzbl $res, $res" %} 7368 opcode(0x0F, 0xB1); 7369 ins_encode(lock_prefix, 7370 REX_reg_mem(newval, mem_ptr), 7371 OpcP, OpcS, 7372 reg_mem(newval, mem_ptr), 7373 REX_breg(res), Opcode(0x0F), Opcode(0x94), reg(res), // sete 7374 REX_reg_breg(res, res), // movzbl 7375 Opcode(0xF), Opcode(0xB6), reg_reg(res, res)); 7376 ins_pipe( pipe_cmpxchg ); 7377 %} 7378 7379 instruct xaddI_no_res( memory mem, Universe dummy, immI add, rFlagsReg cr) %{ 7380 predicate(n->as_LoadStore()->result_not_used()); 7381 match(Set dummy (GetAndAddI mem add)); 7382 effect(KILL cr); 7383 format %{ "ADDL [$mem],$add" %} 7384 ins_encode %{ 7385 if (os::is_MP()) { __ lock(); } 7386 __ addl($mem$$Address, $add$$constant); 7387 %} 7388 ins_pipe( pipe_cmpxchg ); 7389 %} 7390 7391 instruct xaddI( memory mem, rRegI newval, rFlagsReg cr) %{ 7392 match(Set newval (GetAndAddI mem newval)); 7393 effect(KILL cr); 7394 format %{ "XADDL [$mem],$newval" %} 7395 ins_encode %{ 7396 if (os::is_MP()) { __ lock(); } 7397 __ xaddl($mem$$Address, $newval$$Register); 7398 %} 7399 ins_pipe( pipe_cmpxchg ); 7400 %} 7401 7402 instruct xaddL_no_res( memory mem, Universe dummy, immL32 add, rFlagsReg cr) %{ 7403 predicate(n->as_LoadStore()->result_not_used()); 7404 match(Set dummy (GetAndAddL mem add)); 7405 effect(KILL cr); 7406 format %{ "ADDQ [$mem],$add" %} 7407 ins_encode %{ 7408 if (os::is_MP()) { __ lock(); } 7409 __ addq($mem$$Address, $add$$constant); 7410 %} 7411 ins_pipe( pipe_cmpxchg ); 7412 %} 7413 7414 instruct xaddL( memory mem, rRegL newval, rFlagsReg cr) %{ 7415 match(Set newval (GetAndAddL mem newval)); 7416 effect(KILL cr); 7417 format %{ "XADDQ [$mem],$newval" %} 7418 ins_encode %{ 7419 if (os::is_MP()) { __ lock(); } 7420 __ xaddq($mem$$Address, $newval$$Register); 7421 %} 7422 ins_pipe( pipe_cmpxchg ); 7423 %} 7424 7425 instruct xchgI( memory mem, rRegI newval) %{ 7426 match(Set newval (GetAndSetI mem newval)); 7427 format %{ "XCHGL $newval,[$mem]" %} 7428 ins_encode %{ 7429 __ xchgl($newval$$Register, $mem$$Address); 7430 %} 7431 ins_pipe( pipe_cmpxchg ); 7432 %} 7433 7434 instruct xchgL( memory mem, rRegL newval) %{ 7435 match(Set newval (GetAndSetL mem newval)); 7436 format %{ "XCHGL $newval,[$mem]" %} 7437 ins_encode %{ 7438 __ xchgq($newval$$Register, $mem$$Address); 7439 %} 7440 ins_pipe( pipe_cmpxchg ); 7441 %} 7442 7443 instruct xchgP( memory mem, rRegP newval) %{ 7444 match(Set newval (GetAndSetP mem newval)); 7445 format %{ "XCHGQ $newval,[$mem]" %} 7446 ins_encode %{ 7447 __ xchgq($newval$$Register, $mem$$Address); 7448 %} 7449 ins_pipe( pipe_cmpxchg ); 7450 %} 7451 7452 instruct xchgN( memory mem, rRegN newval) %{ 7453 match(Set newval (GetAndSetN mem newval)); 7454 format %{ "XCHGL $newval,$mem]" %} 7455 ins_encode %{ 7456 __ xchgl($newval$$Register, $mem$$Address); 7457 %} 7458 ins_pipe( pipe_cmpxchg ); 7459 %} 7460 7461 //----------Subtraction Instructions------------------------------------------- 7462 7463 // Integer Subtraction Instructions 7464 instruct subI_rReg(rRegI dst, rRegI src, rFlagsReg cr) 7465 %{ 7466 match(Set dst (SubI dst src)); 7467 effect(KILL cr); 7468 7469 format %{ "subl $dst, $src\t# int" %} 7470 opcode(0x2B); 7471 ins_encode(REX_reg_reg(dst, src), OpcP, reg_reg(dst, src)); 7472 ins_pipe(ialu_reg_reg); 7473 %} 7474 7475 instruct subI_rReg_imm(rRegI dst, immI src, rFlagsReg cr) 7476 %{ 7477 match(Set dst (SubI dst src)); 7478 effect(KILL cr); 7479 7480 format %{ "subl $dst, $src\t# int" %} 7481 opcode(0x81, 0x05); /* Opcode 81 /5 */ 7482 ins_encode(OpcSErm(dst, src), Con8or32(src)); 7483 ins_pipe(ialu_reg); 7484 %} 7485 7486 instruct subI_rReg_mem(rRegI dst, memory src, rFlagsReg cr) 7487 %{ 7488 match(Set dst (SubI dst (LoadI src))); 7489 effect(KILL cr); 7490 7491 ins_cost(125); 7492 format %{ "subl $dst, $src\t# int" %} 7493 opcode(0x2B); 7494 ins_encode(REX_reg_mem(dst, src), OpcP, reg_mem(dst, src)); 7495 ins_pipe(ialu_reg_mem); 7496 %} 7497 7498 instruct subI_mem_rReg(memory dst, rRegI src, rFlagsReg cr) 7499 %{ 7500 match(Set dst (StoreI dst (SubI (LoadI dst) src))); 7501 effect(KILL cr); 7502 7503 ins_cost(150); 7504 format %{ "subl $dst, $src\t# int" %} 7505 opcode(0x29); /* Opcode 29 /r */ 7506 ins_encode(REX_reg_mem(src, dst), OpcP, reg_mem(src, dst)); 7507 ins_pipe(ialu_mem_reg); 7508 %} 7509 7510 instruct subI_mem_imm(memory dst, immI src, rFlagsReg cr) 7511 %{ 7512 match(Set dst (StoreI dst (SubI (LoadI dst) src))); 7513 effect(KILL cr); 7514 7515 ins_cost(125); // XXX 7516 format %{ "subl $dst, $src\t# int" %} 7517 opcode(0x81); /* Opcode 81 /5 id */ 7518 ins_encode(REX_mem(dst), OpcSE(src), RM_opc_mem(0x05, dst), Con8or32(src)); 7519 ins_pipe(ialu_mem_imm); 7520 %} 7521 7522 instruct subL_rReg(rRegL dst, rRegL src, rFlagsReg cr) 7523 %{ 7524 match(Set dst (SubL dst src)); 7525 effect(KILL cr); 7526 7527 format %{ "subq $dst, $src\t# long" %} 7528 opcode(0x2B); 7529 ins_encode(REX_reg_reg_wide(dst, src), OpcP, reg_reg(dst, src)); 7530 ins_pipe(ialu_reg_reg); 7531 %} 7532 7533 instruct subL_rReg_imm(rRegI dst, immL32 src, rFlagsReg cr) 7534 %{ 7535 match(Set dst (SubL dst src)); 7536 effect(KILL cr); 7537 7538 format %{ "subq $dst, $src\t# long" %} 7539 opcode(0x81, 0x05); /* Opcode 81 /5 */ 7540 ins_encode(OpcSErm_wide(dst, src), Con8or32(src)); 7541 ins_pipe(ialu_reg); 7542 %} 7543 7544 instruct subL_rReg_mem(rRegL dst, memory src, rFlagsReg cr) 7545 %{ 7546 match(Set dst (SubL dst (LoadL src))); 7547 effect(KILL cr); 7548 7549 ins_cost(125); 7550 format %{ "subq $dst, $src\t# long" %} 7551 opcode(0x2B); 7552 ins_encode(REX_reg_mem_wide(dst, src), OpcP, reg_mem(dst, src)); 7553 ins_pipe(ialu_reg_mem); 7554 %} 7555 7556 instruct subL_mem_rReg(memory dst, rRegL src, rFlagsReg cr) 7557 %{ 7558 match(Set dst (StoreL dst (SubL (LoadL dst) src))); 7559 effect(KILL cr); 7560 7561 ins_cost(150); 7562 format %{ "subq $dst, $src\t# long" %} 7563 opcode(0x29); /* Opcode 29 /r */ 7564 ins_encode(REX_reg_mem_wide(src, dst), OpcP, reg_mem(src, dst)); 7565 ins_pipe(ialu_mem_reg); 7566 %} 7567 7568 instruct subL_mem_imm(memory dst, immL32 src, rFlagsReg cr) 7569 %{ 7570 match(Set dst (StoreL dst (SubL (LoadL dst) src))); 7571 effect(KILL cr); 7572 7573 ins_cost(125); // XXX 7574 format %{ "subq $dst, $src\t# long" %} 7575 opcode(0x81); /* Opcode 81 /5 id */ 7576 ins_encode(REX_mem_wide(dst), 7577 OpcSE(src), RM_opc_mem(0x05, dst), Con8or32(src)); 7578 ins_pipe(ialu_mem_imm); 7579 %} 7580 7581 // Subtract from a pointer 7582 // XXX hmpf??? 7583 instruct subP_rReg(rRegP dst, rRegI src, immI0 zero, rFlagsReg cr) 7584 %{ 7585 match(Set dst (AddP dst (SubI zero src))); 7586 effect(KILL cr); 7587 7588 format %{ "subq $dst, $src\t# ptr - int" %} 7589 opcode(0x2B); 7590 ins_encode(REX_reg_reg_wide(dst, src), OpcP, reg_reg(dst, src)); 7591 ins_pipe(ialu_reg_reg); 7592 %} 7593 7594 instruct negI_rReg(rRegI dst, immI0 zero, rFlagsReg cr) 7595 %{ 7596 match(Set dst (SubI zero dst)); 7597 effect(KILL cr); 7598 7599 format %{ "negl $dst\t# int" %} 7600 opcode(0xF7, 0x03); // Opcode F7 /3 7601 ins_encode(REX_reg(dst), OpcP, reg_opc(dst)); 7602 ins_pipe(ialu_reg); 7603 %} 7604 7605 instruct negI_mem(memory dst, immI0 zero, rFlagsReg cr) 7606 %{ 7607 match(Set dst (StoreI dst (SubI zero (LoadI dst)))); 7608 effect(KILL cr); 7609 7610 format %{ "negl $dst\t# int" %} 7611 opcode(0xF7, 0x03); // Opcode F7 /3 7612 ins_encode(REX_mem(dst), OpcP, RM_opc_mem(secondary, dst)); 7613 ins_pipe(ialu_reg); 7614 %} 7615 7616 instruct negL_rReg(rRegL dst, immL0 zero, rFlagsReg cr) 7617 %{ 7618 match(Set dst (SubL zero dst)); 7619 effect(KILL cr); 7620 7621 format %{ "negq $dst\t# long" %} 7622 opcode(0xF7, 0x03); // Opcode F7 /3 7623 ins_encode(REX_reg_wide(dst), OpcP, reg_opc(dst)); 7624 ins_pipe(ialu_reg); 7625 %} 7626 7627 instruct negL_mem(memory dst, immL0 zero, rFlagsReg cr) 7628 %{ 7629 match(Set dst (StoreL dst (SubL zero (LoadL dst)))); 7630 effect(KILL cr); 7631 7632 format %{ "negq $dst\t# long" %} 7633 opcode(0xF7, 0x03); // Opcode F7 /3 7634 ins_encode(REX_mem_wide(dst), OpcP, RM_opc_mem(secondary, dst)); 7635 ins_pipe(ialu_reg); 7636 %} 7637 7638 //----------Multiplication/Division Instructions------------------------------- 7639 // Integer Multiplication Instructions 7640 // Multiply Register 7641 7642 instruct mulI_rReg(rRegI dst, rRegI src, rFlagsReg cr) 7643 %{ 7644 match(Set dst (MulI dst src)); 7645 effect(KILL cr); 7646 7647 ins_cost(300); 7648 format %{ "imull $dst, $src\t# int" %} 7649 opcode(0x0F, 0xAF); 7650 ins_encode(REX_reg_reg(dst, src), OpcP, OpcS, reg_reg(dst, src)); 7651 ins_pipe(ialu_reg_reg_alu0); 7652 %} 7653 7654 instruct mulI_rReg_imm(rRegI dst, rRegI src, immI imm, rFlagsReg cr) 7655 %{ 7656 match(Set dst (MulI src imm)); 7657 effect(KILL cr); 7658 7659 ins_cost(300); 7660 format %{ "imull $dst, $src, $imm\t# int" %} 7661 opcode(0x69); /* 69 /r id */ 7662 ins_encode(REX_reg_reg(dst, src), 7663 OpcSE(imm), reg_reg(dst, src), Con8or32(imm)); 7664 ins_pipe(ialu_reg_reg_alu0); 7665 %} 7666 7667 instruct mulI_mem(rRegI dst, memory src, rFlagsReg cr) 7668 %{ 7669 match(Set dst (MulI dst (LoadI src))); 7670 effect(KILL cr); 7671 7672 ins_cost(350); 7673 format %{ "imull $dst, $src\t# int" %} 7674 opcode(0x0F, 0xAF); 7675 ins_encode(REX_reg_mem(dst, src), OpcP, OpcS, reg_mem(dst, src)); 7676 ins_pipe(ialu_reg_mem_alu0); 7677 %} 7678 7679 instruct mulI_mem_imm(rRegI dst, memory src, immI imm, rFlagsReg cr) 7680 %{ 7681 match(Set dst (MulI (LoadI src) imm)); 7682 effect(KILL cr); 7683 7684 ins_cost(300); 7685 format %{ "imull $dst, $src, $imm\t# int" %} 7686 opcode(0x69); /* 69 /r id */ 7687 ins_encode(REX_reg_mem(dst, src), 7688 OpcSE(imm), reg_mem(dst, src), Con8or32(imm)); 7689 ins_pipe(ialu_reg_mem_alu0); 7690 %} 7691 7692 instruct mulL_rReg(rRegL dst, rRegL src, rFlagsReg cr) 7693 %{ 7694 match(Set dst (MulL dst src)); 7695 effect(KILL cr); 7696 7697 ins_cost(300); 7698 format %{ "imulq $dst, $src\t# long" %} 7699 opcode(0x0F, 0xAF); 7700 ins_encode(REX_reg_reg_wide(dst, src), OpcP, OpcS, reg_reg(dst, src)); 7701 ins_pipe(ialu_reg_reg_alu0); 7702 %} 7703 7704 instruct mulL_rReg_imm(rRegL dst, rRegL src, immL32 imm, rFlagsReg cr) 7705 %{ 7706 match(Set dst (MulL src imm)); 7707 effect(KILL cr); 7708 7709 ins_cost(300); 7710 format %{ "imulq $dst, $src, $imm\t# long" %} 7711 opcode(0x69); /* 69 /r id */ 7712 ins_encode(REX_reg_reg_wide(dst, src), 7713 OpcSE(imm), reg_reg(dst, src), Con8or32(imm)); 7714 ins_pipe(ialu_reg_reg_alu0); 7715 %} 7716 7717 instruct mulL_mem(rRegL dst, memory src, rFlagsReg cr) 7718 %{ 7719 match(Set dst (MulL dst (LoadL src))); 7720 effect(KILL cr); 7721 7722 ins_cost(350); 7723 format %{ "imulq $dst, $src\t# long" %} 7724 opcode(0x0F, 0xAF); 7725 ins_encode(REX_reg_mem_wide(dst, src), OpcP, OpcS, reg_mem(dst, src)); 7726 ins_pipe(ialu_reg_mem_alu0); 7727 %} 7728 7729 instruct mulL_mem_imm(rRegL dst, memory src, immL32 imm, rFlagsReg cr) 7730 %{ 7731 match(Set dst (MulL (LoadL src) imm)); 7732 effect(KILL cr); 7733 7734 ins_cost(300); 7735 format %{ "imulq $dst, $src, $imm\t# long" %} 7736 opcode(0x69); /* 69 /r id */ 7737 ins_encode(REX_reg_mem_wide(dst, src), 7738 OpcSE(imm), reg_mem(dst, src), Con8or32(imm)); 7739 ins_pipe(ialu_reg_mem_alu0); 7740 %} 7741 7742 instruct mulHiL_rReg(rdx_RegL dst, no_rax_RegL src, rax_RegL rax, rFlagsReg cr) 7743 %{ 7744 match(Set dst (MulHiL src rax)); 7745 effect(USE_KILL rax, KILL cr); 7746 7747 ins_cost(300); 7748 format %{ "imulq RDX:RAX, RAX, $src\t# mulhi" %} 7749 opcode(0xF7, 0x5); /* Opcode F7 /5 */ 7750 ins_encode(REX_reg_wide(src), OpcP, reg_opc(src)); 7751 ins_pipe(ialu_reg_reg_alu0); 7752 %} 7753 7754 instruct divI_rReg(rax_RegI rax, rdx_RegI rdx, no_rax_rdx_RegI div, 7755 rFlagsReg cr) 7756 %{ 7757 match(Set rax (DivI rax div)); 7758 effect(KILL rdx, KILL cr); 7759 7760 ins_cost(30*100+10*100); // XXX 7761 format %{ "cmpl rax, 0x80000000\t# idiv\n\t" 7762 "jne,s normal\n\t" 7763 "xorl rdx, rdx\n\t" 7764 "cmpl $div, -1\n\t" 7765 "je,s done\n" 7766 "normal: cdql\n\t" 7767 "idivl $div\n" 7768 "done:" %} 7769 opcode(0xF7, 0x7); /* Opcode F7 /7 */ 7770 ins_encode(cdql_enc(div), REX_reg(div), OpcP, reg_opc(div)); 7771 ins_pipe(ialu_reg_reg_alu0); 7772 %} 7773 7774 instruct divL_rReg(rax_RegL rax, rdx_RegL rdx, no_rax_rdx_RegL div, 7775 rFlagsReg cr) 7776 %{ 7777 match(Set rax (DivL rax div)); 7778 effect(KILL rdx, KILL cr); 7779 7780 ins_cost(30*100+10*100); // XXX 7781 format %{ "movq rdx, 0x8000000000000000\t# ldiv\n\t" 7782 "cmpq rax, rdx\n\t" 7783 "jne,s normal\n\t" 7784 "xorl rdx, rdx\n\t" 7785 "cmpq $div, -1\n\t" 7786 "je,s done\n" 7787 "normal: cdqq\n\t" 7788 "idivq $div\n" 7789 "done:" %} 7790 opcode(0xF7, 0x7); /* Opcode F7 /7 */ 7791 ins_encode(cdqq_enc(div), REX_reg_wide(div), OpcP, reg_opc(div)); 7792 ins_pipe(ialu_reg_reg_alu0); 7793 %} 7794 7795 // Integer DIVMOD with Register, both quotient and mod results 7796 instruct divModI_rReg_divmod(rax_RegI rax, rdx_RegI rdx, no_rax_rdx_RegI div, 7797 rFlagsReg cr) 7798 %{ 7799 match(DivModI rax div); 7800 effect(KILL cr); 7801 7802 ins_cost(30*100+10*100); // XXX 7803 format %{ "cmpl rax, 0x80000000\t# idiv\n\t" 7804 "jne,s normal\n\t" 7805 "xorl rdx, rdx\n\t" 7806 "cmpl $div, -1\n\t" 7807 "je,s done\n" 7808 "normal: cdql\n\t" 7809 "idivl $div\n" 7810 "done:" %} 7811 opcode(0xF7, 0x7); /* Opcode F7 /7 */ 7812 ins_encode(cdql_enc(div), REX_reg(div), OpcP, reg_opc(div)); 7813 ins_pipe(pipe_slow); 7814 %} 7815 7816 // Long DIVMOD with Register, both quotient and mod results 7817 instruct divModL_rReg_divmod(rax_RegL rax, rdx_RegL rdx, no_rax_rdx_RegL div, 7818 rFlagsReg cr) 7819 %{ 7820 match(DivModL rax div); 7821 effect(KILL cr); 7822 7823 ins_cost(30*100+10*100); // XXX 7824 format %{ "movq rdx, 0x8000000000000000\t# ldiv\n\t" 7825 "cmpq rax, rdx\n\t" 7826 "jne,s normal\n\t" 7827 "xorl rdx, rdx\n\t" 7828 "cmpq $div, -1\n\t" 7829 "je,s done\n" 7830 "normal: cdqq\n\t" 7831 "idivq $div\n" 7832 "done:" %} 7833 opcode(0xF7, 0x7); /* Opcode F7 /7 */ 7834 ins_encode(cdqq_enc(div), REX_reg_wide(div), OpcP, reg_opc(div)); 7835 ins_pipe(pipe_slow); 7836 %} 7837 7838 //----------- DivL-By-Constant-Expansions-------------------------------------- 7839 // DivI cases are handled by the compiler 7840 7841 // Magic constant, reciprocal of 10 7842 instruct loadConL_0x6666666666666667(rRegL dst) 7843 %{ 7844 effect(DEF dst); 7845 7846 format %{ "movq $dst, #0x666666666666667\t# Used in div-by-10" %} 7847 ins_encode(load_immL(dst, 0x6666666666666667)); 7848 ins_pipe(ialu_reg); 7849 %} 7850 7851 instruct mul_hi(rdx_RegL dst, no_rax_RegL src, rax_RegL rax, rFlagsReg cr) 7852 %{ 7853 effect(DEF dst, USE src, USE_KILL rax, KILL cr); 7854 7855 format %{ "imulq rdx:rax, rax, $src\t# Used in div-by-10" %} 7856 opcode(0xF7, 0x5); /* Opcode F7 /5 */ 7857 ins_encode(REX_reg_wide(src), OpcP, reg_opc(src)); 7858 ins_pipe(ialu_reg_reg_alu0); 7859 %} 7860 7861 instruct sarL_rReg_63(rRegL dst, rFlagsReg cr) 7862 %{ 7863 effect(USE_DEF dst, KILL cr); 7864 7865 format %{ "sarq $dst, #63\t# Used in div-by-10" %} 7866 opcode(0xC1, 0x7); /* C1 /7 ib */ 7867 ins_encode(reg_opc_imm_wide(dst, 0x3F)); 7868 ins_pipe(ialu_reg); 7869 %} 7870 7871 instruct sarL_rReg_2(rRegL dst, rFlagsReg cr) 7872 %{ 7873 effect(USE_DEF dst, KILL cr); 7874 7875 format %{ "sarq $dst, #2\t# Used in div-by-10" %} 7876 opcode(0xC1, 0x7); /* C1 /7 ib */ 7877 ins_encode(reg_opc_imm_wide(dst, 0x2)); 7878 ins_pipe(ialu_reg); 7879 %} 7880 7881 instruct divL_10(rdx_RegL dst, no_rax_RegL src, immL10 div) 7882 %{ 7883 match(Set dst (DivL src div)); 7884 7885 ins_cost((5+8)*100); 7886 expand %{ 7887 rax_RegL rax; // Killed temp 7888 rFlagsReg cr; // Killed 7889 loadConL_0x6666666666666667(rax); // movq rax, 0x6666666666666667 7890 mul_hi(dst, src, rax, cr); // mulq rdx:rax <= rax * $src 7891 sarL_rReg_63(src, cr); // sarq src, 63 7892 sarL_rReg_2(dst, cr); // sarq rdx, 2 7893 subL_rReg(dst, src, cr); // subl rdx, src 7894 %} 7895 %} 7896 7897 //----------------------------------------------------------------------------- 7898 7899 instruct modI_rReg(rdx_RegI rdx, rax_RegI rax, no_rax_rdx_RegI div, 7900 rFlagsReg cr) 7901 %{ 7902 match(Set rdx (ModI rax div)); 7903 effect(KILL rax, KILL cr); 7904 7905 ins_cost(300); // XXX 7906 format %{ "cmpl rax, 0x80000000\t# irem\n\t" 7907 "jne,s normal\n\t" 7908 "xorl rdx, rdx\n\t" 7909 "cmpl $div, -1\n\t" 7910 "je,s done\n" 7911 "normal: cdql\n\t" 7912 "idivl $div\n" 7913 "done:" %} 7914 opcode(0xF7, 0x7); /* Opcode F7 /7 */ 7915 ins_encode(cdql_enc(div), REX_reg(div), OpcP, reg_opc(div)); 7916 ins_pipe(ialu_reg_reg_alu0); 7917 %} 7918 7919 instruct modL_rReg(rdx_RegL rdx, rax_RegL rax, no_rax_rdx_RegL div, 7920 rFlagsReg cr) 7921 %{ 7922 match(Set rdx (ModL rax div)); 7923 effect(KILL rax, KILL cr); 7924 7925 ins_cost(300); // XXX 7926 format %{ "movq rdx, 0x8000000000000000\t# lrem\n\t" 7927 "cmpq rax, rdx\n\t" 7928 "jne,s normal\n\t" 7929 "xorl rdx, rdx\n\t" 7930 "cmpq $div, -1\n\t" 7931 "je,s done\n" 7932 "normal: cdqq\n\t" 7933 "idivq $div\n" 7934 "done:" %} 7935 opcode(0xF7, 0x7); /* Opcode F7 /7 */ 7936 ins_encode(cdqq_enc(div), REX_reg_wide(div), OpcP, reg_opc(div)); 7937 ins_pipe(ialu_reg_reg_alu0); 7938 %} 7939 7940 // Integer Shift Instructions 7941 // Shift Left by one 7942 instruct salI_rReg_1(rRegI dst, immI1 shift, rFlagsReg cr) 7943 %{ 7944 match(Set dst (LShiftI dst shift)); 7945 effect(KILL cr); 7946 7947 format %{ "sall $dst, $shift" %} 7948 opcode(0xD1, 0x4); /* D1 /4 */ 7949 ins_encode(REX_reg(dst), OpcP, reg_opc(dst)); 7950 ins_pipe(ialu_reg); 7951 %} 7952 7953 // Shift Left by one 7954 instruct salI_mem_1(memory dst, immI1 shift, rFlagsReg cr) 7955 %{ 7956 match(Set dst (StoreI dst (LShiftI (LoadI dst) shift))); 7957 effect(KILL cr); 7958 7959 format %{ "sall $dst, $shift\t" %} 7960 opcode(0xD1, 0x4); /* D1 /4 */ 7961 ins_encode(REX_mem(dst), OpcP, RM_opc_mem(secondary, dst)); 7962 ins_pipe(ialu_mem_imm); 7963 %} 7964 7965 // Shift Left by 8-bit immediate 7966 instruct salI_rReg_imm(rRegI dst, immI8 shift, rFlagsReg cr) 7967 %{ 7968 match(Set dst (LShiftI dst shift)); 7969 effect(KILL cr); 7970 7971 format %{ "sall $dst, $shift" %} 7972 opcode(0xC1, 0x4); /* C1 /4 ib */ 7973 ins_encode(reg_opc_imm(dst, shift)); 7974 ins_pipe(ialu_reg); 7975 %} 7976 7977 // Shift Left by 8-bit immediate 7978 instruct salI_mem_imm(memory dst, immI8 shift, rFlagsReg cr) 7979 %{ 7980 match(Set dst (StoreI dst (LShiftI (LoadI dst) shift))); 7981 effect(KILL cr); 7982 7983 format %{ "sall $dst, $shift" %} 7984 opcode(0xC1, 0x4); /* C1 /4 ib */ 7985 ins_encode(REX_mem(dst), OpcP, RM_opc_mem(secondary, dst), Con8or32(shift)); 7986 ins_pipe(ialu_mem_imm); 7987 %} 7988 7989 // Shift Left by variable 7990 instruct salI_rReg_CL(rRegI dst, rcx_RegI shift, rFlagsReg cr) 7991 %{ 7992 match(Set dst (LShiftI dst shift)); 7993 effect(KILL cr); 7994 7995 format %{ "sall $dst, $shift" %} 7996 opcode(0xD3, 0x4); /* D3 /4 */ 7997 ins_encode(REX_reg(dst), OpcP, reg_opc(dst)); 7998 ins_pipe(ialu_reg_reg); 7999 %} 8000 8001 // Shift Left by variable 8002 instruct salI_mem_CL(memory dst, rcx_RegI shift, rFlagsReg cr) 8003 %{ 8004 match(Set dst (StoreI dst (LShiftI (LoadI dst) shift))); 8005 effect(KILL cr); 8006 8007 format %{ "sall $dst, $shift" %} 8008 opcode(0xD3, 0x4); /* D3 /4 */ 8009 ins_encode(REX_mem(dst), OpcP, RM_opc_mem(secondary, dst)); 8010 ins_pipe(ialu_mem_reg); 8011 %} 8012 8013 // Arithmetic shift right by one 8014 instruct sarI_rReg_1(rRegI dst, immI1 shift, rFlagsReg cr) 8015 %{ 8016 match(Set dst (RShiftI dst shift)); 8017 effect(KILL cr); 8018 8019 format %{ "sarl $dst, $shift" %} 8020 opcode(0xD1, 0x7); /* D1 /7 */ 8021 ins_encode(REX_reg(dst), OpcP, reg_opc(dst)); 8022 ins_pipe(ialu_reg); 8023 %} 8024 8025 // Arithmetic shift right by one 8026 instruct sarI_mem_1(memory dst, immI1 shift, rFlagsReg cr) 8027 %{ 8028 match(Set dst (StoreI dst (RShiftI (LoadI dst) shift))); 8029 effect(KILL cr); 8030 8031 format %{ "sarl $dst, $shift" %} 8032 opcode(0xD1, 0x7); /* D1 /7 */ 8033 ins_encode(REX_mem(dst), OpcP, RM_opc_mem(secondary, dst)); 8034 ins_pipe(ialu_mem_imm); 8035 %} 8036 8037 // Arithmetic Shift Right by 8-bit immediate 8038 instruct sarI_rReg_imm(rRegI dst, immI8 shift, rFlagsReg cr) 8039 %{ 8040 match(Set dst (RShiftI dst shift)); 8041 effect(KILL cr); 8042 8043 format %{ "sarl $dst, $shift" %} 8044 opcode(0xC1, 0x7); /* C1 /7 ib */ 8045 ins_encode(reg_opc_imm(dst, shift)); 8046 ins_pipe(ialu_mem_imm); 8047 %} 8048 8049 // Arithmetic Shift Right by 8-bit immediate 8050 instruct sarI_mem_imm(memory dst, immI8 shift, rFlagsReg cr) 8051 %{ 8052 match(Set dst (StoreI dst (RShiftI (LoadI dst) shift))); 8053 effect(KILL cr); 8054 8055 format %{ "sarl $dst, $shift" %} 8056 opcode(0xC1, 0x7); /* C1 /7 ib */ 8057 ins_encode(REX_mem(dst), OpcP, RM_opc_mem(secondary, dst), Con8or32(shift)); 8058 ins_pipe(ialu_mem_imm); 8059 %} 8060 8061 // Arithmetic Shift Right by variable 8062 instruct sarI_rReg_CL(rRegI dst, rcx_RegI shift, rFlagsReg cr) 8063 %{ 8064 match(Set dst (RShiftI dst shift)); 8065 effect(KILL cr); 8066 8067 format %{ "sarl $dst, $shift" %} 8068 opcode(0xD3, 0x7); /* D3 /7 */ 8069 ins_encode(REX_reg(dst), OpcP, reg_opc(dst)); 8070 ins_pipe(ialu_reg_reg); 8071 %} 8072 8073 // Arithmetic Shift Right by variable 8074 instruct sarI_mem_CL(memory dst, rcx_RegI shift, rFlagsReg cr) 8075 %{ 8076 match(Set dst (StoreI dst (RShiftI (LoadI dst) shift))); 8077 effect(KILL cr); 8078 8079 format %{ "sarl $dst, $shift" %} 8080 opcode(0xD3, 0x7); /* D3 /7 */ 8081 ins_encode(REX_mem(dst), OpcP, RM_opc_mem(secondary, dst)); 8082 ins_pipe(ialu_mem_reg); 8083 %} 8084 8085 // Logical shift right by one 8086 instruct shrI_rReg_1(rRegI dst, immI1 shift, rFlagsReg cr) 8087 %{ 8088 match(Set dst (URShiftI dst shift)); 8089 effect(KILL cr); 8090 8091 format %{ "shrl $dst, $shift" %} 8092 opcode(0xD1, 0x5); /* D1 /5 */ 8093 ins_encode(REX_reg(dst), OpcP, reg_opc(dst)); 8094 ins_pipe(ialu_reg); 8095 %} 8096 8097 // Logical shift right by one 8098 instruct shrI_mem_1(memory dst, immI1 shift, rFlagsReg cr) 8099 %{ 8100 match(Set dst (StoreI dst (URShiftI (LoadI dst) shift))); 8101 effect(KILL cr); 8102 8103 format %{ "shrl $dst, $shift" %} 8104 opcode(0xD1, 0x5); /* D1 /5 */ 8105 ins_encode(REX_mem(dst), OpcP, RM_opc_mem(secondary, dst)); 8106 ins_pipe(ialu_mem_imm); 8107 %} 8108 8109 // Logical Shift Right by 8-bit immediate 8110 instruct shrI_rReg_imm(rRegI dst, immI8 shift, rFlagsReg cr) 8111 %{ 8112 match(Set dst (URShiftI dst shift)); 8113 effect(KILL cr); 8114 8115 format %{ "shrl $dst, $shift" %} 8116 opcode(0xC1, 0x5); /* C1 /5 ib */ 8117 ins_encode(reg_opc_imm(dst, shift)); 8118 ins_pipe(ialu_reg); 8119 %} 8120 8121 // Logical Shift Right by 8-bit immediate 8122 instruct shrI_mem_imm(memory dst, immI8 shift, rFlagsReg cr) 8123 %{ 8124 match(Set dst (StoreI dst (URShiftI (LoadI dst) shift))); 8125 effect(KILL cr); 8126 8127 format %{ "shrl $dst, $shift" %} 8128 opcode(0xC1, 0x5); /* C1 /5 ib */ 8129 ins_encode(REX_mem(dst), OpcP, RM_opc_mem(secondary, dst), Con8or32(shift)); 8130 ins_pipe(ialu_mem_imm); 8131 %} 8132 8133 // Logical Shift Right by variable 8134 instruct shrI_rReg_CL(rRegI dst, rcx_RegI shift, rFlagsReg cr) 8135 %{ 8136 match(Set dst (URShiftI dst shift)); 8137 effect(KILL cr); 8138 8139 format %{ "shrl $dst, $shift" %} 8140 opcode(0xD3, 0x5); /* D3 /5 */ 8141 ins_encode(REX_reg(dst), OpcP, reg_opc(dst)); 8142 ins_pipe(ialu_reg_reg); 8143 %} 8144 8145 // Logical Shift Right by variable 8146 instruct shrI_mem_CL(memory dst, rcx_RegI shift, rFlagsReg cr) 8147 %{ 8148 match(Set dst (StoreI dst (URShiftI (LoadI dst) shift))); 8149 effect(KILL cr); 8150 8151 format %{ "shrl $dst, $shift" %} 8152 opcode(0xD3, 0x5); /* D3 /5 */ 8153 ins_encode(REX_mem(dst), OpcP, RM_opc_mem(secondary, dst)); 8154 ins_pipe(ialu_mem_reg); 8155 %} 8156 8157 // Long Shift Instructions 8158 // Shift Left by one 8159 instruct salL_rReg_1(rRegL dst, immI1 shift, rFlagsReg cr) 8160 %{ 8161 match(Set dst (LShiftL dst shift)); 8162 effect(KILL cr); 8163 8164 format %{ "salq $dst, $shift" %} 8165 opcode(0xD1, 0x4); /* D1 /4 */ 8166 ins_encode(REX_reg_wide(dst), OpcP, reg_opc(dst)); 8167 ins_pipe(ialu_reg); 8168 %} 8169 8170 // Shift Left by one 8171 instruct salL_mem_1(memory dst, immI1 shift, rFlagsReg cr) 8172 %{ 8173 match(Set dst (StoreL dst (LShiftL (LoadL dst) shift))); 8174 effect(KILL cr); 8175 8176 format %{ "salq $dst, $shift" %} 8177 opcode(0xD1, 0x4); /* D1 /4 */ 8178 ins_encode(REX_mem_wide(dst), OpcP, RM_opc_mem(secondary, dst)); 8179 ins_pipe(ialu_mem_imm); 8180 %} 8181 8182 // Shift Left by 8-bit immediate 8183 instruct salL_rReg_imm(rRegL dst, immI8 shift, rFlagsReg cr) 8184 %{ 8185 match(Set dst (LShiftL dst shift)); 8186 effect(KILL cr); 8187 8188 format %{ "salq $dst, $shift" %} 8189 opcode(0xC1, 0x4); /* C1 /4 ib */ 8190 ins_encode(reg_opc_imm_wide(dst, shift)); 8191 ins_pipe(ialu_reg); 8192 %} 8193 8194 // Shift Left by 8-bit immediate 8195 instruct salL_mem_imm(memory dst, immI8 shift, rFlagsReg cr) 8196 %{ 8197 match(Set dst (StoreL dst (LShiftL (LoadL dst) shift))); 8198 effect(KILL cr); 8199 8200 format %{ "salq $dst, $shift" %} 8201 opcode(0xC1, 0x4); /* C1 /4 ib */ 8202 ins_encode(REX_mem_wide(dst), OpcP, 8203 RM_opc_mem(secondary, dst), Con8or32(shift)); 8204 ins_pipe(ialu_mem_imm); 8205 %} 8206 8207 // Shift Left by variable 8208 instruct salL_rReg_CL(rRegL dst, rcx_RegI shift, rFlagsReg cr) 8209 %{ 8210 match(Set dst (LShiftL dst shift)); 8211 effect(KILL cr); 8212 8213 format %{ "salq $dst, $shift" %} 8214 opcode(0xD3, 0x4); /* D3 /4 */ 8215 ins_encode(REX_reg_wide(dst), OpcP, reg_opc(dst)); 8216 ins_pipe(ialu_reg_reg); 8217 %} 8218 8219 // Shift Left by variable 8220 instruct salL_mem_CL(memory dst, rcx_RegI shift, rFlagsReg cr) 8221 %{ 8222 match(Set dst (StoreL dst (LShiftL (LoadL dst) shift))); 8223 effect(KILL cr); 8224 8225 format %{ "salq $dst, $shift" %} 8226 opcode(0xD3, 0x4); /* D3 /4 */ 8227 ins_encode(REX_mem_wide(dst), OpcP, RM_opc_mem(secondary, dst)); 8228 ins_pipe(ialu_mem_reg); 8229 %} 8230 8231 // Arithmetic shift right by one 8232 instruct sarL_rReg_1(rRegL dst, immI1 shift, rFlagsReg cr) 8233 %{ 8234 match(Set dst (RShiftL dst shift)); 8235 effect(KILL cr); 8236 8237 format %{ "sarq $dst, $shift" %} 8238 opcode(0xD1, 0x7); /* D1 /7 */ 8239 ins_encode(REX_reg_wide(dst), OpcP, reg_opc(dst)); 8240 ins_pipe(ialu_reg); 8241 %} 8242 8243 // Arithmetic shift right by one 8244 instruct sarL_mem_1(memory dst, immI1 shift, rFlagsReg cr) 8245 %{ 8246 match(Set dst (StoreL dst (RShiftL (LoadL dst) shift))); 8247 effect(KILL cr); 8248 8249 format %{ "sarq $dst, $shift" %} 8250 opcode(0xD1, 0x7); /* D1 /7 */ 8251 ins_encode(REX_mem_wide(dst), OpcP, RM_opc_mem(secondary, dst)); 8252 ins_pipe(ialu_mem_imm); 8253 %} 8254 8255 // Arithmetic Shift Right by 8-bit immediate 8256 instruct sarL_rReg_imm(rRegL dst, immI8 shift, rFlagsReg cr) 8257 %{ 8258 match(Set dst (RShiftL dst shift)); 8259 effect(KILL cr); 8260 8261 format %{ "sarq $dst, $shift" %} 8262 opcode(0xC1, 0x7); /* C1 /7 ib */ 8263 ins_encode(reg_opc_imm_wide(dst, shift)); 8264 ins_pipe(ialu_mem_imm); 8265 %} 8266 8267 // Arithmetic Shift Right by 8-bit immediate 8268 instruct sarL_mem_imm(memory dst, immI8 shift, rFlagsReg cr) 8269 %{ 8270 match(Set dst (StoreL dst (RShiftL (LoadL dst) shift))); 8271 effect(KILL cr); 8272 8273 format %{ "sarq $dst, $shift" %} 8274 opcode(0xC1, 0x7); /* C1 /7 ib */ 8275 ins_encode(REX_mem_wide(dst), OpcP, 8276 RM_opc_mem(secondary, dst), Con8or32(shift)); 8277 ins_pipe(ialu_mem_imm); 8278 %} 8279 8280 // Arithmetic Shift Right by variable 8281 instruct sarL_rReg_CL(rRegL dst, rcx_RegI shift, rFlagsReg cr) 8282 %{ 8283 match(Set dst (RShiftL dst shift)); 8284 effect(KILL cr); 8285 8286 format %{ "sarq $dst, $shift" %} 8287 opcode(0xD3, 0x7); /* D3 /7 */ 8288 ins_encode(REX_reg_wide(dst), OpcP, reg_opc(dst)); 8289 ins_pipe(ialu_reg_reg); 8290 %} 8291 8292 // Arithmetic Shift Right by variable 8293 instruct sarL_mem_CL(memory dst, rcx_RegI shift, rFlagsReg cr) 8294 %{ 8295 match(Set dst (StoreL dst (RShiftL (LoadL dst) shift))); 8296 effect(KILL cr); 8297 8298 format %{ "sarq $dst, $shift" %} 8299 opcode(0xD3, 0x7); /* D3 /7 */ 8300 ins_encode(REX_mem_wide(dst), OpcP, RM_opc_mem(secondary, dst)); 8301 ins_pipe(ialu_mem_reg); 8302 %} 8303 8304 // Logical shift right by one 8305 instruct shrL_rReg_1(rRegL dst, immI1 shift, rFlagsReg cr) 8306 %{ 8307 match(Set dst (URShiftL dst shift)); 8308 effect(KILL cr); 8309 8310 format %{ "shrq $dst, $shift" %} 8311 opcode(0xD1, 0x5); /* D1 /5 */ 8312 ins_encode(REX_reg_wide(dst), OpcP, reg_opc(dst )); 8313 ins_pipe(ialu_reg); 8314 %} 8315 8316 // Logical shift right by one 8317 instruct shrL_mem_1(memory dst, immI1 shift, rFlagsReg cr) 8318 %{ 8319 match(Set dst (StoreL dst (URShiftL (LoadL dst) shift))); 8320 effect(KILL cr); 8321 8322 format %{ "shrq $dst, $shift" %} 8323 opcode(0xD1, 0x5); /* D1 /5 */ 8324 ins_encode(REX_mem_wide(dst), OpcP, RM_opc_mem(secondary, dst)); 8325 ins_pipe(ialu_mem_imm); 8326 %} 8327 8328 // Logical Shift Right by 8-bit immediate 8329 instruct shrL_rReg_imm(rRegL dst, immI8 shift, rFlagsReg cr) 8330 %{ 8331 match(Set dst (URShiftL dst shift)); 8332 effect(KILL cr); 8333 8334 format %{ "shrq $dst, $shift" %} 8335 opcode(0xC1, 0x5); /* C1 /5 ib */ 8336 ins_encode(reg_opc_imm_wide(dst, shift)); 8337 ins_pipe(ialu_reg); 8338 %} 8339 8340 8341 // Logical Shift Right by 8-bit immediate 8342 instruct shrL_mem_imm(memory dst, immI8 shift, rFlagsReg cr) 8343 %{ 8344 match(Set dst (StoreL dst (URShiftL (LoadL dst) shift))); 8345 effect(KILL cr); 8346 8347 format %{ "shrq $dst, $shift" %} 8348 opcode(0xC1, 0x5); /* C1 /5 ib */ 8349 ins_encode(REX_mem_wide(dst), OpcP, 8350 RM_opc_mem(secondary, dst), Con8or32(shift)); 8351 ins_pipe(ialu_mem_imm); 8352 %} 8353 8354 // Logical Shift Right by variable 8355 instruct shrL_rReg_CL(rRegL dst, rcx_RegI shift, rFlagsReg cr) 8356 %{ 8357 match(Set dst (URShiftL dst shift)); 8358 effect(KILL cr); 8359 8360 format %{ "shrq $dst, $shift" %} 8361 opcode(0xD3, 0x5); /* D3 /5 */ 8362 ins_encode(REX_reg_wide(dst), OpcP, reg_opc(dst)); 8363 ins_pipe(ialu_reg_reg); 8364 %} 8365 8366 // Logical Shift Right by variable 8367 instruct shrL_mem_CL(memory dst, rcx_RegI shift, rFlagsReg cr) 8368 %{ 8369 match(Set dst (StoreL dst (URShiftL (LoadL dst) shift))); 8370 effect(KILL cr); 8371 8372 format %{ "shrq $dst, $shift" %} 8373 opcode(0xD3, 0x5); /* D3 /5 */ 8374 ins_encode(REX_mem_wide(dst), OpcP, RM_opc_mem(secondary, dst)); 8375 ins_pipe(ialu_mem_reg); 8376 %} 8377 8378 // Logical Shift Right by 24, followed by Arithmetic Shift Left by 24. 8379 // This idiom is used by the compiler for the i2b bytecode. 8380 instruct i2b(rRegI dst, rRegI src, immI_24 twentyfour) 8381 %{ 8382 match(Set dst (RShiftI (LShiftI src twentyfour) twentyfour)); 8383 8384 format %{ "movsbl $dst, $src\t# i2b" %} 8385 opcode(0x0F, 0xBE); 8386 ins_encode(REX_reg_breg(dst, src), OpcP, OpcS, reg_reg(dst, src)); 8387 ins_pipe(ialu_reg_reg); 8388 %} 8389 8390 // Logical Shift Right by 16, followed by Arithmetic Shift Left by 16. 8391 // This idiom is used by the compiler the i2s bytecode. 8392 instruct i2s(rRegI dst, rRegI src, immI_16 sixteen) 8393 %{ 8394 match(Set dst (RShiftI (LShiftI src sixteen) sixteen)); 8395 8396 format %{ "movswl $dst, $src\t# i2s" %} 8397 opcode(0x0F, 0xBF); 8398 ins_encode(REX_reg_reg(dst, src), OpcP, OpcS, reg_reg(dst, src)); 8399 ins_pipe(ialu_reg_reg); 8400 %} 8401 8402 // ROL/ROR instructions 8403 8404 // ROL expand 8405 instruct rolI_rReg_imm1(rRegI dst, rFlagsReg cr) %{ 8406 effect(KILL cr, USE_DEF dst); 8407 8408 format %{ "roll $dst" %} 8409 opcode(0xD1, 0x0); /* Opcode D1 /0 */ 8410 ins_encode(REX_reg(dst), OpcP, reg_opc(dst)); 8411 ins_pipe(ialu_reg); 8412 %} 8413 8414 instruct rolI_rReg_imm8(rRegI dst, immI8 shift, rFlagsReg cr) %{ 8415 effect(USE_DEF dst, USE shift, KILL cr); 8416 8417 format %{ "roll $dst, $shift" %} 8418 opcode(0xC1, 0x0); /* Opcode C1 /0 ib */ 8419 ins_encode( reg_opc_imm(dst, shift) ); 8420 ins_pipe(ialu_reg); 8421 %} 8422 8423 instruct rolI_rReg_CL(no_rcx_RegI dst, rcx_RegI shift, rFlagsReg cr) 8424 %{ 8425 effect(USE_DEF dst, USE shift, KILL cr); 8426 8427 format %{ "roll $dst, $shift" %} 8428 opcode(0xD3, 0x0); /* Opcode D3 /0 */ 8429 ins_encode(REX_reg(dst), OpcP, reg_opc(dst)); 8430 ins_pipe(ialu_reg_reg); 8431 %} 8432 // end of ROL expand 8433 8434 // Rotate Left by one 8435 instruct rolI_rReg_i1(rRegI dst, immI1 lshift, immI_M1 rshift, rFlagsReg cr) 8436 %{ 8437 match(Set dst (OrI (LShiftI dst lshift) (URShiftI dst rshift))); 8438 8439 expand %{ 8440 rolI_rReg_imm1(dst, cr); 8441 %} 8442 %} 8443 8444 // Rotate Left by 8-bit immediate 8445 instruct rolI_rReg_i8(rRegI dst, immI8 lshift, immI8 rshift, rFlagsReg cr) 8446 %{ 8447 predicate(0 == ((n->in(1)->in(2)->get_int() + n->in(2)->in(2)->get_int()) & 0x1f)); 8448 match(Set dst (OrI (LShiftI dst lshift) (URShiftI dst rshift))); 8449 8450 expand %{ 8451 rolI_rReg_imm8(dst, lshift, cr); 8452 %} 8453 %} 8454 8455 // Rotate Left by variable 8456 instruct rolI_rReg_Var_C0(no_rcx_RegI dst, rcx_RegI shift, immI0 zero, rFlagsReg cr) 8457 %{ 8458 match(Set dst (OrI (LShiftI dst shift) (URShiftI dst (SubI zero shift)))); 8459 8460 expand %{ 8461 rolI_rReg_CL(dst, shift, cr); 8462 %} 8463 %} 8464 8465 // Rotate Left by variable 8466 instruct rolI_rReg_Var_C32(no_rcx_RegI dst, rcx_RegI shift, immI_32 c32, rFlagsReg cr) 8467 %{ 8468 match(Set dst (OrI (LShiftI dst shift) (URShiftI dst (SubI c32 shift)))); 8469 8470 expand %{ 8471 rolI_rReg_CL(dst, shift, cr); 8472 %} 8473 %} 8474 8475 // ROR expand 8476 instruct rorI_rReg_imm1(rRegI dst, rFlagsReg cr) 8477 %{ 8478 effect(USE_DEF dst, KILL cr); 8479 8480 format %{ "rorl $dst" %} 8481 opcode(0xD1, 0x1); /* D1 /1 */ 8482 ins_encode(REX_reg(dst), OpcP, reg_opc(dst)); 8483 ins_pipe(ialu_reg); 8484 %} 8485 8486 instruct rorI_rReg_imm8(rRegI dst, immI8 shift, rFlagsReg cr) 8487 %{ 8488 effect(USE_DEF dst, USE shift, KILL cr); 8489 8490 format %{ "rorl $dst, $shift" %} 8491 opcode(0xC1, 0x1); /* C1 /1 ib */ 8492 ins_encode(reg_opc_imm(dst, shift)); 8493 ins_pipe(ialu_reg); 8494 %} 8495 8496 instruct rorI_rReg_CL(no_rcx_RegI dst, rcx_RegI shift, rFlagsReg cr) 8497 %{ 8498 effect(USE_DEF dst, USE shift, KILL cr); 8499 8500 format %{ "rorl $dst, $shift" %} 8501 opcode(0xD3, 0x1); /* D3 /1 */ 8502 ins_encode(REX_reg(dst), OpcP, reg_opc(dst)); 8503 ins_pipe(ialu_reg_reg); 8504 %} 8505 // end of ROR expand 8506 8507 // Rotate Right by one 8508 instruct rorI_rReg_i1(rRegI dst, immI1 rshift, immI_M1 lshift, rFlagsReg cr) 8509 %{ 8510 match(Set dst (OrI (URShiftI dst rshift) (LShiftI dst lshift))); 8511 8512 expand %{ 8513 rorI_rReg_imm1(dst, cr); 8514 %} 8515 %} 8516 8517 // Rotate Right by 8-bit immediate 8518 instruct rorI_rReg_i8(rRegI dst, immI8 rshift, immI8 lshift, rFlagsReg cr) 8519 %{ 8520 predicate(0 == ((n->in(1)->in(2)->get_int() + n->in(2)->in(2)->get_int()) & 0x1f)); 8521 match(Set dst (OrI (URShiftI dst rshift) (LShiftI dst lshift))); 8522 8523 expand %{ 8524 rorI_rReg_imm8(dst, rshift, cr); 8525 %} 8526 %} 8527 8528 // Rotate Right by variable 8529 instruct rorI_rReg_Var_C0(no_rcx_RegI dst, rcx_RegI shift, immI0 zero, rFlagsReg cr) 8530 %{ 8531 match(Set dst (OrI (URShiftI dst shift) (LShiftI dst (SubI zero shift)))); 8532 8533 expand %{ 8534 rorI_rReg_CL(dst, shift, cr); 8535 %} 8536 %} 8537 8538 // Rotate Right by variable 8539 instruct rorI_rReg_Var_C32(no_rcx_RegI dst, rcx_RegI shift, immI_32 c32, rFlagsReg cr) 8540 %{ 8541 match(Set dst (OrI (URShiftI dst shift) (LShiftI dst (SubI c32 shift)))); 8542 8543 expand %{ 8544 rorI_rReg_CL(dst, shift, cr); 8545 %} 8546 %} 8547 8548 // for long rotate 8549 // ROL expand 8550 instruct rolL_rReg_imm1(rRegL dst, rFlagsReg cr) %{ 8551 effect(USE_DEF dst, KILL cr); 8552 8553 format %{ "rolq $dst" %} 8554 opcode(0xD1, 0x0); /* Opcode D1 /0 */ 8555 ins_encode(REX_reg_wide(dst), OpcP, reg_opc(dst)); 8556 ins_pipe(ialu_reg); 8557 %} 8558 8559 instruct rolL_rReg_imm8(rRegL dst, immI8 shift, rFlagsReg cr) %{ 8560 effect(USE_DEF dst, USE shift, KILL cr); 8561 8562 format %{ "rolq $dst, $shift" %} 8563 opcode(0xC1, 0x0); /* Opcode C1 /0 ib */ 8564 ins_encode( reg_opc_imm_wide(dst, shift) ); 8565 ins_pipe(ialu_reg); 8566 %} 8567 8568 instruct rolL_rReg_CL(no_rcx_RegL dst, rcx_RegI shift, rFlagsReg cr) 8569 %{ 8570 effect(USE_DEF dst, USE shift, KILL cr); 8571 8572 format %{ "rolq $dst, $shift" %} 8573 opcode(0xD3, 0x0); /* Opcode D3 /0 */ 8574 ins_encode(REX_reg_wide(dst), OpcP, reg_opc(dst)); 8575 ins_pipe(ialu_reg_reg); 8576 %} 8577 // end of ROL expand 8578 8579 // Rotate Left by one 8580 instruct rolL_rReg_i1(rRegL dst, immI1 lshift, immI_M1 rshift, rFlagsReg cr) 8581 %{ 8582 match(Set dst (OrL (LShiftL dst lshift) (URShiftL dst rshift))); 8583 8584 expand %{ 8585 rolL_rReg_imm1(dst, cr); 8586 %} 8587 %} 8588 8589 // Rotate Left by 8-bit immediate 8590 instruct rolL_rReg_i8(rRegL dst, immI8 lshift, immI8 rshift, rFlagsReg cr) 8591 %{ 8592 predicate(0 == ((n->in(1)->in(2)->get_int() + n->in(2)->in(2)->get_int()) & 0x3f)); 8593 match(Set dst (OrL (LShiftL dst lshift) (URShiftL dst rshift))); 8594 8595 expand %{ 8596 rolL_rReg_imm8(dst, lshift, cr); 8597 %} 8598 %} 8599 8600 // Rotate Left by variable 8601 instruct rolL_rReg_Var_C0(no_rcx_RegL dst, rcx_RegI shift, immI0 zero, rFlagsReg cr) 8602 %{ 8603 match(Set dst (OrL (LShiftL dst shift) (URShiftL dst (SubI zero shift)))); 8604 8605 expand %{ 8606 rolL_rReg_CL(dst, shift, cr); 8607 %} 8608 %} 8609 8610 // Rotate Left by variable 8611 instruct rolL_rReg_Var_C64(no_rcx_RegL dst, rcx_RegI shift, immI_64 c64, rFlagsReg cr) 8612 %{ 8613 match(Set dst (OrL (LShiftL dst shift) (URShiftL dst (SubI c64 shift)))); 8614 8615 expand %{ 8616 rolL_rReg_CL(dst, shift, cr); 8617 %} 8618 %} 8619 8620 // ROR expand 8621 instruct rorL_rReg_imm1(rRegL dst, rFlagsReg cr) 8622 %{ 8623 effect(USE_DEF dst, KILL cr); 8624 8625 format %{ "rorq $dst" %} 8626 opcode(0xD1, 0x1); /* D1 /1 */ 8627 ins_encode(REX_reg_wide(dst), OpcP, reg_opc(dst)); 8628 ins_pipe(ialu_reg); 8629 %} 8630 8631 instruct rorL_rReg_imm8(rRegL dst, immI8 shift, rFlagsReg cr) 8632 %{ 8633 effect(USE_DEF dst, USE shift, KILL cr); 8634 8635 format %{ "rorq $dst, $shift" %} 8636 opcode(0xC1, 0x1); /* C1 /1 ib */ 8637 ins_encode(reg_opc_imm_wide(dst, shift)); 8638 ins_pipe(ialu_reg); 8639 %} 8640 8641 instruct rorL_rReg_CL(no_rcx_RegL dst, rcx_RegI shift, rFlagsReg cr) 8642 %{ 8643 effect(USE_DEF dst, USE shift, KILL cr); 8644 8645 format %{ "rorq $dst, $shift" %} 8646 opcode(0xD3, 0x1); /* D3 /1 */ 8647 ins_encode(REX_reg_wide(dst), OpcP, reg_opc(dst)); 8648 ins_pipe(ialu_reg_reg); 8649 %} 8650 // end of ROR expand 8651 8652 // Rotate Right by one 8653 instruct rorL_rReg_i1(rRegL dst, immI1 rshift, immI_M1 lshift, rFlagsReg cr) 8654 %{ 8655 match(Set dst (OrL (URShiftL dst rshift) (LShiftL dst lshift))); 8656 8657 expand %{ 8658 rorL_rReg_imm1(dst, cr); 8659 %} 8660 %} 8661 8662 // Rotate Right by 8-bit immediate 8663 instruct rorL_rReg_i8(rRegL dst, immI8 rshift, immI8 lshift, rFlagsReg cr) 8664 %{ 8665 predicate(0 == ((n->in(1)->in(2)->get_int() + n->in(2)->in(2)->get_int()) & 0x3f)); 8666 match(Set dst (OrL (URShiftL dst rshift) (LShiftL dst lshift))); 8667 8668 expand %{ 8669 rorL_rReg_imm8(dst, rshift, cr); 8670 %} 8671 %} 8672 8673 // Rotate Right by variable 8674 instruct rorL_rReg_Var_C0(no_rcx_RegL dst, rcx_RegI shift, immI0 zero, rFlagsReg cr) 8675 %{ 8676 match(Set dst (OrL (URShiftL dst shift) (LShiftL dst (SubI zero shift)))); 8677 8678 expand %{ 8679 rorL_rReg_CL(dst, shift, cr); 8680 %} 8681 %} 8682 8683 // Rotate Right by variable 8684 instruct rorL_rReg_Var_C64(no_rcx_RegL dst, rcx_RegI shift, immI_64 c64, rFlagsReg cr) 8685 %{ 8686 match(Set dst (OrL (URShiftL dst shift) (LShiftL dst (SubI c64 shift)))); 8687 8688 expand %{ 8689 rorL_rReg_CL(dst, shift, cr); 8690 %} 8691 %} 8692 8693 // Logical Instructions 8694 8695 // Integer Logical Instructions 8696 8697 // And Instructions 8698 // And Register with Register 8699 instruct andI_rReg(rRegI dst, rRegI src, rFlagsReg cr) 8700 %{ 8701 match(Set dst (AndI dst src)); 8702 effect(KILL cr); 8703 8704 format %{ "andl $dst, $src\t# int" %} 8705 opcode(0x23); 8706 ins_encode(REX_reg_reg(dst, src), OpcP, reg_reg(dst, src)); 8707 ins_pipe(ialu_reg_reg); 8708 %} 8709 8710 // And Register with Immediate 255 8711 instruct andI_rReg_imm255(rRegI dst, immI_255 src) 8712 %{ 8713 match(Set dst (AndI dst src)); 8714 8715 format %{ "movzbl $dst, $dst\t# int & 0xFF" %} 8716 opcode(0x0F, 0xB6); 8717 ins_encode(REX_reg_breg(dst, dst), OpcP, OpcS, reg_reg(dst, dst)); 8718 ins_pipe(ialu_reg); 8719 %} 8720 8721 // And Register with Immediate 255 and promote to long 8722 instruct andI2L_rReg_imm255(rRegL dst, rRegI src, immI_255 mask) 8723 %{ 8724 match(Set dst (ConvI2L (AndI src mask))); 8725 8726 format %{ "movzbl $dst, $src\t# int & 0xFF -> long" %} 8727 opcode(0x0F, 0xB6); 8728 ins_encode(REX_reg_breg(dst, src), OpcP, OpcS, reg_reg(dst, src)); 8729 ins_pipe(ialu_reg); 8730 %} 8731 8732 // And Register with Immediate 65535 8733 instruct andI_rReg_imm65535(rRegI dst, immI_65535 src) 8734 %{ 8735 match(Set dst (AndI dst src)); 8736 8737 format %{ "movzwl $dst, $dst\t# int & 0xFFFF" %} 8738 opcode(0x0F, 0xB7); 8739 ins_encode(REX_reg_reg(dst, dst), OpcP, OpcS, reg_reg(dst, dst)); 8740 ins_pipe(ialu_reg); 8741 %} 8742 8743 // And Register with Immediate 65535 and promote to long 8744 instruct andI2L_rReg_imm65535(rRegL dst, rRegI src, immI_65535 mask) 8745 %{ 8746 match(Set dst (ConvI2L (AndI src mask))); 8747 8748 format %{ "movzwl $dst, $src\t# int & 0xFFFF -> long" %} 8749 opcode(0x0F, 0xB7); 8750 ins_encode(REX_reg_reg(dst, src), OpcP, OpcS, reg_reg(dst, src)); 8751 ins_pipe(ialu_reg); 8752 %} 8753 8754 // And Register with Immediate 8755 instruct andI_rReg_imm(rRegI dst, immI src, rFlagsReg cr) 8756 %{ 8757 match(Set dst (AndI dst src)); 8758 effect(KILL cr); 8759 8760 format %{ "andl $dst, $src\t# int" %} 8761 opcode(0x81, 0x04); /* Opcode 81 /4 */ 8762 ins_encode(OpcSErm(dst, src), Con8or32(src)); 8763 ins_pipe(ialu_reg); 8764 %} 8765 8766 // And Register with Memory 8767 instruct andI_rReg_mem(rRegI dst, memory src, rFlagsReg cr) 8768 %{ 8769 match(Set dst (AndI dst (LoadI src))); 8770 effect(KILL cr); 8771 8772 ins_cost(125); 8773 format %{ "andl $dst, $src\t# int" %} 8774 opcode(0x23); 8775 ins_encode(REX_reg_mem(dst, src), OpcP, reg_mem(dst, src)); 8776 ins_pipe(ialu_reg_mem); 8777 %} 8778 8779 // And Memory with Register 8780 instruct andI_mem_rReg(memory dst, rRegI src, rFlagsReg cr) 8781 %{ 8782 match(Set dst (StoreI dst (AndI (LoadI dst) src))); 8783 effect(KILL cr); 8784 8785 ins_cost(150); 8786 format %{ "andl $dst, $src\t# int" %} 8787 opcode(0x21); /* Opcode 21 /r */ 8788 ins_encode(REX_reg_mem(src, dst), OpcP, reg_mem(src, dst)); 8789 ins_pipe(ialu_mem_reg); 8790 %} 8791 8792 // And Memory with Immediate 8793 instruct andI_mem_imm(memory dst, immI src, rFlagsReg cr) 8794 %{ 8795 match(Set dst (StoreI dst (AndI (LoadI dst) src))); 8796 effect(KILL cr); 8797 8798 ins_cost(125); 8799 format %{ "andl $dst, $src\t# int" %} 8800 opcode(0x81, 0x4); /* Opcode 81 /4 id */ 8801 ins_encode(REX_mem(dst), OpcSE(src), 8802 RM_opc_mem(secondary, dst), Con8or32(src)); 8803 ins_pipe(ialu_mem_imm); 8804 %} 8805 8806 // BMI1 instructions 8807 instruct andnI_rReg_rReg_mem(rRegI dst, rRegI src1, memory src2, immI_M1 minus_1, rFlagsReg cr) %{ 8808 match(Set dst (AndI (XorI src1 minus_1) (LoadI src2))); 8809 predicate(UseBMI1Instructions); 8810 effect(KILL cr); 8811 8812 ins_cost(125); 8813 format %{ "andnl $dst, $src1, $src2" %} 8814 8815 ins_encode %{ 8816 __ andnl($dst$$Register, $src1$$Register, $src2$$Address); 8817 %} 8818 ins_pipe(ialu_reg_mem); 8819 %} 8820 8821 instruct andnI_rReg_rReg_rReg(rRegI dst, rRegI src1, rRegI src2, immI_M1 minus_1, rFlagsReg cr) %{ 8822 match(Set dst (AndI (XorI src1 minus_1) src2)); 8823 predicate(UseBMI1Instructions); 8824 effect(KILL cr); 8825 8826 format %{ "andnl $dst, $src1, $src2" %} 8827 8828 ins_encode %{ 8829 __ andnl($dst$$Register, $src1$$Register, $src2$$Register); 8830 %} 8831 ins_pipe(ialu_reg); 8832 %} 8833 8834 instruct blsiI_rReg_rReg(rRegI dst, rRegI src, immI0 imm_zero, rFlagsReg cr) %{ 8835 match(Set dst (AndI (SubI imm_zero src) src)); 8836 predicate(UseBMI1Instructions); 8837 effect(KILL cr); 8838 8839 format %{ "blsil $dst, $src" %} 8840 8841 ins_encode %{ 8842 __ blsil($dst$$Register, $src$$Register); 8843 %} 8844 ins_pipe(ialu_reg); 8845 %} 8846 8847 instruct blsiI_rReg_mem(rRegI dst, memory src, immI0 imm_zero, rFlagsReg cr) %{ 8848 match(Set dst (AndI (SubI imm_zero (LoadI src) ) (LoadI src) )); 8849 predicate(UseBMI1Instructions); 8850 effect(KILL cr); 8851 8852 ins_cost(125); 8853 format %{ "blsil $dst, $src" %} 8854 8855 ins_encode %{ 8856 __ blsil($dst$$Register, $src$$Address); 8857 %} 8858 ins_pipe(ialu_reg_mem); 8859 %} 8860 8861 instruct blsmskI_rReg_mem(rRegI dst, memory src, immI_M1 minus_1, rFlagsReg cr) 8862 %{ 8863 match(Set dst (XorI (AddI (LoadI src) minus_1) (LoadI src) ) ); 8864 predicate(UseBMI1Instructions); 8865 effect(KILL cr); 8866 8867 ins_cost(125); 8868 format %{ "blsmskl $dst, $src" %} 8869 8870 ins_encode %{ 8871 __ blsmskl($dst$$Register, $src$$Address); 8872 %} 8873 ins_pipe(ialu_reg_mem); 8874 %} 8875 8876 instruct blsmskI_rReg_rReg(rRegI dst, rRegI src, immI_M1 minus_1, rFlagsReg cr) 8877 %{ 8878 match(Set dst (XorI (AddI src minus_1) src)); 8879 predicate(UseBMI1Instructions); 8880 effect(KILL cr); 8881 8882 format %{ "blsmskl $dst, $src" %} 8883 8884 ins_encode %{ 8885 __ blsmskl($dst$$Register, $src$$Register); 8886 %} 8887 8888 ins_pipe(ialu_reg); 8889 %} 8890 8891 instruct blsrI_rReg_rReg(rRegI dst, rRegI src, immI_M1 minus_1, rFlagsReg cr) 8892 %{ 8893 match(Set dst (AndI (AddI src minus_1) src) ); 8894 predicate(UseBMI1Instructions); 8895 effect(KILL cr); 8896 8897 format %{ "blsrl $dst, $src" %} 8898 8899 ins_encode %{ 8900 __ blsrl($dst$$Register, $src$$Register); 8901 %} 8902 8903 ins_pipe(ialu_reg_mem); 8904 %} 8905 8906 instruct blsrI_rReg_mem(rRegI dst, memory src, immI_M1 minus_1, rFlagsReg cr) 8907 %{ 8908 match(Set dst (AndI (AddI (LoadI src) minus_1) (LoadI src) ) ); 8909 predicate(UseBMI1Instructions); 8910 effect(KILL cr); 8911 8912 ins_cost(125); 8913 format %{ "blsrl $dst, $src" %} 8914 8915 ins_encode %{ 8916 __ blsrl($dst$$Register, $src$$Address); 8917 %} 8918 8919 ins_pipe(ialu_reg); 8920 %} 8921 8922 // Or Instructions 8923 // Or Register with Register 8924 instruct orI_rReg(rRegI dst, rRegI src, rFlagsReg cr) 8925 %{ 8926 match(Set dst (OrI dst src)); 8927 effect(KILL cr); 8928 8929 format %{ "orl $dst, $src\t# int" %} 8930 opcode(0x0B); 8931 ins_encode(REX_reg_reg(dst, src), OpcP, reg_reg(dst, src)); 8932 ins_pipe(ialu_reg_reg); 8933 %} 8934 8935 // Or Register with Immediate 8936 instruct orI_rReg_imm(rRegI dst, immI src, rFlagsReg cr) 8937 %{ 8938 match(Set dst (OrI dst src)); 8939 effect(KILL cr); 8940 8941 format %{ "orl $dst, $src\t# int" %} 8942 opcode(0x81, 0x01); /* Opcode 81 /1 id */ 8943 ins_encode(OpcSErm(dst, src), Con8or32(src)); 8944 ins_pipe(ialu_reg); 8945 %} 8946 8947 // Or Register with Memory 8948 instruct orI_rReg_mem(rRegI dst, memory src, rFlagsReg cr) 8949 %{ 8950 match(Set dst (OrI dst (LoadI src))); 8951 effect(KILL cr); 8952 8953 ins_cost(125); 8954 format %{ "orl $dst, $src\t# int" %} 8955 opcode(0x0B); 8956 ins_encode(REX_reg_mem(dst, src), OpcP, reg_mem(dst, src)); 8957 ins_pipe(ialu_reg_mem); 8958 %} 8959 8960 // Or Memory with Register 8961 instruct orI_mem_rReg(memory dst, rRegI src, rFlagsReg cr) 8962 %{ 8963 match(Set dst (StoreI dst (OrI (LoadI dst) src))); 8964 effect(KILL cr); 8965 8966 ins_cost(150); 8967 format %{ "orl $dst, $src\t# int" %} 8968 opcode(0x09); /* Opcode 09 /r */ 8969 ins_encode(REX_reg_mem(src, dst), OpcP, reg_mem(src, dst)); 8970 ins_pipe(ialu_mem_reg); 8971 %} 8972 8973 // Or Memory with Immediate 8974 instruct orI_mem_imm(memory dst, immI src, rFlagsReg cr) 8975 %{ 8976 match(Set dst (StoreI dst (OrI (LoadI dst) src))); 8977 effect(KILL cr); 8978 8979 ins_cost(125); 8980 format %{ "orl $dst, $src\t# int" %} 8981 opcode(0x81, 0x1); /* Opcode 81 /1 id */ 8982 ins_encode(REX_mem(dst), OpcSE(src), 8983 RM_opc_mem(secondary, dst), Con8or32(src)); 8984 ins_pipe(ialu_mem_imm); 8985 %} 8986 8987 // Xor Instructions 8988 // Xor Register with Register 8989 instruct xorI_rReg(rRegI dst, rRegI src, rFlagsReg cr) 8990 %{ 8991 match(Set dst (XorI dst src)); 8992 effect(KILL cr); 8993 8994 format %{ "xorl $dst, $src\t# int" %} 8995 opcode(0x33); 8996 ins_encode(REX_reg_reg(dst, src), OpcP, reg_reg(dst, src)); 8997 ins_pipe(ialu_reg_reg); 8998 %} 8999 9000 // Xor Register with Immediate -1 9001 instruct xorI_rReg_im1(rRegI dst, immI_M1 imm) %{ 9002 match(Set dst (XorI dst imm)); 9003 9004 format %{ "not $dst" %} 9005 ins_encode %{ 9006 __ notl($dst$$Register); 9007 %} 9008 ins_pipe(ialu_reg); 9009 %} 9010 9011 // Xor Register with Immediate 9012 instruct xorI_rReg_imm(rRegI dst, immI src, rFlagsReg cr) 9013 %{ 9014 match(Set dst (XorI dst src)); 9015 effect(KILL cr); 9016 9017 format %{ "xorl $dst, $src\t# int" %} 9018 opcode(0x81, 0x06); /* Opcode 81 /6 id */ 9019 ins_encode(OpcSErm(dst, src), Con8or32(src)); 9020 ins_pipe(ialu_reg); 9021 %} 9022 9023 // Xor Register with Memory 9024 instruct xorI_rReg_mem(rRegI dst, memory src, rFlagsReg cr) 9025 %{ 9026 match(Set dst (XorI dst (LoadI src))); 9027 effect(KILL cr); 9028 9029 ins_cost(125); 9030 format %{ "xorl $dst, $src\t# int" %} 9031 opcode(0x33); 9032 ins_encode(REX_reg_mem(dst, src), OpcP, reg_mem(dst, src)); 9033 ins_pipe(ialu_reg_mem); 9034 %} 9035 9036 // Xor Memory with Register 9037 instruct xorI_mem_rReg(memory dst, rRegI src, rFlagsReg cr) 9038 %{ 9039 match(Set dst (StoreI dst (XorI (LoadI dst) src))); 9040 effect(KILL cr); 9041 9042 ins_cost(150); 9043 format %{ "xorl $dst, $src\t# int" %} 9044 opcode(0x31); /* Opcode 31 /r */ 9045 ins_encode(REX_reg_mem(src, dst), OpcP, reg_mem(src, dst)); 9046 ins_pipe(ialu_mem_reg); 9047 %} 9048 9049 // Xor Memory with Immediate 9050 instruct xorI_mem_imm(memory dst, immI src, rFlagsReg cr) 9051 %{ 9052 match(Set dst (StoreI dst (XorI (LoadI dst) src))); 9053 effect(KILL cr); 9054 9055 ins_cost(125); 9056 format %{ "xorl $dst, $src\t# int" %} 9057 opcode(0x81, 0x6); /* Opcode 81 /6 id */ 9058 ins_encode(REX_mem(dst), OpcSE(src), 9059 RM_opc_mem(secondary, dst), Con8or32(src)); 9060 ins_pipe(ialu_mem_imm); 9061 %} 9062 9063 9064 // Long Logical Instructions 9065 9066 // And Instructions 9067 // And Register with Register 9068 instruct andL_rReg(rRegL dst, rRegL src, rFlagsReg cr) 9069 %{ 9070 match(Set dst (AndL dst src)); 9071 effect(KILL cr); 9072 9073 format %{ "andq $dst, $src\t# long" %} 9074 opcode(0x23); 9075 ins_encode(REX_reg_reg_wide(dst, src), OpcP, reg_reg(dst, src)); 9076 ins_pipe(ialu_reg_reg); 9077 %} 9078 9079 // And Register with Immediate 255 9080 instruct andL_rReg_imm255(rRegL dst, immL_255 src) 9081 %{ 9082 match(Set dst (AndL dst src)); 9083 9084 format %{ "movzbq $dst, $dst\t# long & 0xFF" %} 9085 opcode(0x0F, 0xB6); 9086 ins_encode(REX_reg_reg_wide(dst, dst), OpcP, OpcS, reg_reg(dst, dst)); 9087 ins_pipe(ialu_reg); 9088 %} 9089 9090 // And Register with Immediate 65535 9091 instruct andL_rReg_imm65535(rRegL dst, immL_65535 src) 9092 %{ 9093 match(Set dst (AndL dst src)); 9094 9095 format %{ "movzwq $dst, $dst\t# long & 0xFFFF" %} 9096 opcode(0x0F, 0xB7); 9097 ins_encode(REX_reg_reg_wide(dst, dst), OpcP, OpcS, reg_reg(dst, dst)); 9098 ins_pipe(ialu_reg); 9099 %} 9100 9101 // And Register with Immediate 9102 instruct andL_rReg_imm(rRegL dst, immL32 src, rFlagsReg cr) 9103 %{ 9104 match(Set dst (AndL dst src)); 9105 effect(KILL cr); 9106 9107 format %{ "andq $dst, $src\t# long" %} 9108 opcode(0x81, 0x04); /* Opcode 81 /4 */ 9109 ins_encode(OpcSErm_wide(dst, src), Con8or32(src)); 9110 ins_pipe(ialu_reg); 9111 %} 9112 9113 // And Register with Memory 9114 instruct andL_rReg_mem(rRegL dst, memory src, rFlagsReg cr) 9115 %{ 9116 match(Set dst (AndL dst (LoadL src))); 9117 effect(KILL cr); 9118 9119 ins_cost(125); 9120 format %{ "andq $dst, $src\t# long" %} 9121 opcode(0x23); 9122 ins_encode(REX_reg_mem_wide(dst, src), OpcP, reg_mem(dst, src)); 9123 ins_pipe(ialu_reg_mem); 9124 %} 9125 9126 // And Memory with Register 9127 instruct andL_mem_rReg(memory dst, rRegL src, rFlagsReg cr) 9128 %{ 9129 match(Set dst (StoreL dst (AndL (LoadL dst) src))); 9130 effect(KILL cr); 9131 9132 ins_cost(150); 9133 format %{ "andq $dst, $src\t# long" %} 9134 opcode(0x21); /* Opcode 21 /r */ 9135 ins_encode(REX_reg_mem_wide(src, dst), OpcP, reg_mem(src, dst)); 9136 ins_pipe(ialu_mem_reg); 9137 %} 9138 9139 // And Memory with Immediate 9140 instruct andL_mem_imm(memory dst, immL32 src, rFlagsReg cr) 9141 %{ 9142 match(Set dst (StoreL dst (AndL (LoadL dst) src))); 9143 effect(KILL cr); 9144 9145 ins_cost(125); 9146 format %{ "andq $dst, $src\t# long" %} 9147 opcode(0x81, 0x4); /* Opcode 81 /4 id */ 9148 ins_encode(REX_mem_wide(dst), OpcSE(src), 9149 RM_opc_mem(secondary, dst), Con8or32(src)); 9150 ins_pipe(ialu_mem_imm); 9151 %} 9152 9153 // BMI1 instructions 9154 instruct andnL_rReg_rReg_mem(rRegL dst, rRegL src1, memory src2, immL_M1 minus_1, rFlagsReg cr) %{ 9155 match(Set dst (AndL (XorL src1 minus_1) (LoadL src2))); 9156 predicate(UseBMI1Instructions); 9157 effect(KILL cr); 9158 9159 ins_cost(125); 9160 format %{ "andnq $dst, $src1, $src2" %} 9161 9162 ins_encode %{ 9163 __ andnq($dst$$Register, $src1$$Register, $src2$$Address); 9164 %} 9165 ins_pipe(ialu_reg_mem); 9166 %} 9167 9168 instruct andnL_rReg_rReg_rReg(rRegL dst, rRegL src1, rRegL src2, immL_M1 minus_1, rFlagsReg cr) %{ 9169 match(Set dst (AndL (XorL src1 minus_1) src2)); 9170 predicate(UseBMI1Instructions); 9171 effect(KILL cr); 9172 9173 format %{ "andnq $dst, $src1, $src2" %} 9174 9175 ins_encode %{ 9176 __ andnq($dst$$Register, $src1$$Register, $src2$$Register); 9177 %} 9178 ins_pipe(ialu_reg_mem); 9179 %} 9180 9181 instruct blsiL_rReg_rReg(rRegL dst, rRegL src, immL0 imm_zero, rFlagsReg cr) %{ 9182 match(Set dst (AndL (SubL imm_zero src) src)); 9183 predicate(UseBMI1Instructions); 9184 effect(KILL cr); 9185 9186 format %{ "blsiq $dst, $src" %} 9187 9188 ins_encode %{ 9189 __ blsiq($dst$$Register, $src$$Register); 9190 %} 9191 ins_pipe(ialu_reg); 9192 %} 9193 9194 instruct blsiL_rReg_mem(rRegL dst, memory src, immL0 imm_zero, rFlagsReg cr) %{ 9195 match(Set dst (AndL (SubL imm_zero (LoadL src) ) (LoadL src) )); 9196 predicate(UseBMI1Instructions); 9197 effect(KILL cr); 9198 9199 ins_cost(125); 9200 format %{ "blsiq $dst, $src" %} 9201 9202 ins_encode %{ 9203 __ blsiq($dst$$Register, $src$$Address); 9204 %} 9205 ins_pipe(ialu_reg_mem); 9206 %} 9207 9208 instruct blsmskL_rReg_mem(rRegL dst, memory src, immL_M1 minus_1, rFlagsReg cr) 9209 %{ 9210 match(Set dst (XorL (AddL (LoadL src) minus_1) (LoadL src) ) ); 9211 predicate(UseBMI1Instructions); 9212 effect(KILL cr); 9213 9214 ins_cost(125); 9215 format %{ "blsmskq $dst, $src" %} 9216 9217 ins_encode %{ 9218 __ blsmskq($dst$$Register, $src$$Address); 9219 %} 9220 ins_pipe(ialu_reg_mem); 9221 %} 9222 9223 instruct blsmskL_rReg_rReg(rRegL dst, rRegL src, immL_M1 minus_1, rFlagsReg cr) 9224 %{ 9225 match(Set dst (XorL (AddL src minus_1) src)); 9226 predicate(UseBMI1Instructions); 9227 effect(KILL cr); 9228 9229 format %{ "blsmskq $dst, $src" %} 9230 9231 ins_encode %{ 9232 __ blsmskq($dst$$Register, $src$$Register); 9233 %} 9234 9235 ins_pipe(ialu_reg); 9236 %} 9237 9238 instruct blsrL_rReg_rReg(rRegL dst, rRegL src, immL_M1 minus_1, rFlagsReg cr) 9239 %{ 9240 match(Set dst (AndL (AddL src minus_1) src) ); 9241 predicate(UseBMI1Instructions); 9242 effect(KILL cr); 9243 9244 format %{ "blsrq $dst, $src" %} 9245 9246 ins_encode %{ 9247 __ blsrq($dst$$Register, $src$$Register); 9248 %} 9249 9250 ins_pipe(ialu_reg); 9251 %} 9252 9253 instruct blsrL_rReg_mem(rRegL dst, memory src, immL_M1 minus_1, rFlagsReg cr) 9254 %{ 9255 match(Set dst (AndL (AddL (LoadL src) minus_1) (LoadL src)) ); 9256 predicate(UseBMI1Instructions); 9257 effect(KILL cr); 9258 9259 ins_cost(125); 9260 format %{ "blsrq $dst, $src" %} 9261 9262 ins_encode %{ 9263 __ blsrq($dst$$Register, $src$$Address); 9264 %} 9265 9266 ins_pipe(ialu_reg); 9267 %} 9268 9269 // Or Instructions 9270 // Or Register with Register 9271 instruct orL_rReg(rRegL dst, rRegL src, rFlagsReg cr) 9272 %{ 9273 match(Set dst (OrL dst src)); 9274 effect(KILL cr); 9275 9276 format %{ "orq $dst, $src\t# long" %} 9277 opcode(0x0B); 9278 ins_encode(REX_reg_reg_wide(dst, src), OpcP, reg_reg(dst, src)); 9279 ins_pipe(ialu_reg_reg); 9280 %} 9281 9282 // Use any_RegP to match R15 (TLS register) without spilling. 9283 instruct orL_rReg_castP2X(rRegL dst, any_RegP src, rFlagsReg cr) %{ 9284 match(Set dst (OrL dst (CastP2X src))); 9285 effect(KILL cr); 9286 9287 format %{ "orq $dst, $src\t# long" %} 9288 opcode(0x0B); 9289 ins_encode(REX_reg_reg_wide(dst, src), OpcP, reg_reg(dst, src)); 9290 ins_pipe(ialu_reg_reg); 9291 %} 9292 9293 9294 // Or Register with Immediate 9295 instruct orL_rReg_imm(rRegL dst, immL32 src, rFlagsReg cr) 9296 %{ 9297 match(Set dst (OrL dst src)); 9298 effect(KILL cr); 9299 9300 format %{ "orq $dst, $src\t# long" %} 9301 opcode(0x81, 0x01); /* Opcode 81 /1 id */ 9302 ins_encode(OpcSErm_wide(dst, src), Con8or32(src)); 9303 ins_pipe(ialu_reg); 9304 %} 9305 9306 // Or Register with Memory 9307 instruct orL_rReg_mem(rRegL dst, memory src, rFlagsReg cr) 9308 %{ 9309 match(Set dst (OrL dst (LoadL src))); 9310 effect(KILL cr); 9311 9312 ins_cost(125); 9313 format %{ "orq $dst, $src\t# long" %} 9314 opcode(0x0B); 9315 ins_encode(REX_reg_mem_wide(dst, src), OpcP, reg_mem(dst, src)); 9316 ins_pipe(ialu_reg_mem); 9317 %} 9318 9319 // Or Memory with Register 9320 instruct orL_mem_rReg(memory dst, rRegL src, rFlagsReg cr) 9321 %{ 9322 match(Set dst (StoreL dst (OrL (LoadL dst) src))); 9323 effect(KILL cr); 9324 9325 ins_cost(150); 9326 format %{ "orq $dst, $src\t# long" %} 9327 opcode(0x09); /* Opcode 09 /r */ 9328 ins_encode(REX_reg_mem_wide(src, dst), OpcP, reg_mem(src, dst)); 9329 ins_pipe(ialu_mem_reg); 9330 %} 9331 9332 // Or Memory with Immediate 9333 instruct orL_mem_imm(memory dst, immL32 src, rFlagsReg cr) 9334 %{ 9335 match(Set dst (StoreL dst (OrL (LoadL dst) src))); 9336 effect(KILL cr); 9337 9338 ins_cost(125); 9339 format %{ "orq $dst, $src\t# long" %} 9340 opcode(0x81, 0x1); /* Opcode 81 /1 id */ 9341 ins_encode(REX_mem_wide(dst), OpcSE(src), 9342 RM_opc_mem(secondary, dst), Con8or32(src)); 9343 ins_pipe(ialu_mem_imm); 9344 %} 9345 9346 // Xor Instructions 9347 // Xor Register with Register 9348 instruct xorL_rReg(rRegL dst, rRegL src, rFlagsReg cr) 9349 %{ 9350 match(Set dst (XorL dst src)); 9351 effect(KILL cr); 9352 9353 format %{ "xorq $dst, $src\t# long" %} 9354 opcode(0x33); 9355 ins_encode(REX_reg_reg_wide(dst, src), OpcP, reg_reg(dst, src)); 9356 ins_pipe(ialu_reg_reg); 9357 %} 9358 9359 // Xor Register with Immediate -1 9360 instruct xorL_rReg_im1(rRegL dst, immL_M1 imm) %{ 9361 match(Set dst (XorL dst imm)); 9362 9363 format %{ "notq $dst" %} 9364 ins_encode %{ 9365 __ notq($dst$$Register); 9366 %} 9367 ins_pipe(ialu_reg); 9368 %} 9369 9370 // Xor Register with Immediate 9371 instruct xorL_rReg_imm(rRegL dst, immL32 src, rFlagsReg cr) 9372 %{ 9373 match(Set dst (XorL dst src)); 9374 effect(KILL cr); 9375 9376 format %{ "xorq $dst, $src\t# long" %} 9377 opcode(0x81, 0x06); /* Opcode 81 /6 id */ 9378 ins_encode(OpcSErm_wide(dst, src), Con8or32(src)); 9379 ins_pipe(ialu_reg); 9380 %} 9381 9382 // Xor Register with Memory 9383 instruct xorL_rReg_mem(rRegL dst, memory src, rFlagsReg cr) 9384 %{ 9385 match(Set dst (XorL dst (LoadL src))); 9386 effect(KILL cr); 9387 9388 ins_cost(125); 9389 format %{ "xorq $dst, $src\t# long" %} 9390 opcode(0x33); 9391 ins_encode(REX_reg_mem_wide(dst, src), OpcP, reg_mem(dst, src)); 9392 ins_pipe(ialu_reg_mem); 9393 %} 9394 9395 // Xor Memory with Register 9396 instruct xorL_mem_rReg(memory dst, rRegL src, rFlagsReg cr) 9397 %{ 9398 match(Set dst (StoreL dst (XorL (LoadL dst) src))); 9399 effect(KILL cr); 9400 9401 ins_cost(150); 9402 format %{ "xorq $dst, $src\t# long" %} 9403 opcode(0x31); /* Opcode 31 /r */ 9404 ins_encode(REX_reg_mem_wide(src, dst), OpcP, reg_mem(src, dst)); 9405 ins_pipe(ialu_mem_reg); 9406 %} 9407 9408 // Xor Memory with Immediate 9409 instruct xorL_mem_imm(memory dst, immL32 src, rFlagsReg cr) 9410 %{ 9411 match(Set dst (StoreL dst (XorL (LoadL dst) src))); 9412 effect(KILL cr); 9413 9414 ins_cost(125); 9415 format %{ "xorq $dst, $src\t# long" %} 9416 opcode(0x81, 0x6); /* Opcode 81 /6 id */ 9417 ins_encode(REX_mem_wide(dst), OpcSE(src), 9418 RM_opc_mem(secondary, dst), Con8or32(src)); 9419 ins_pipe(ialu_mem_imm); 9420 %} 9421 9422 // Convert Int to Boolean 9423 instruct convI2B(rRegI dst, rRegI src, rFlagsReg cr) 9424 %{ 9425 match(Set dst (Conv2B src)); 9426 effect(KILL cr); 9427 9428 format %{ "testl $src, $src\t# ci2b\n\t" 9429 "setnz $dst\n\t" 9430 "movzbl $dst, $dst" %} 9431 ins_encode(REX_reg_reg(src, src), opc_reg_reg(0x85, src, src), // testl 9432 setNZ_reg(dst), 9433 REX_reg_breg(dst, dst), // movzbl 9434 Opcode(0x0F), Opcode(0xB6), reg_reg(dst, dst)); 9435 ins_pipe(pipe_slow); // XXX 9436 %} 9437 9438 // Convert Pointer to Boolean 9439 instruct convP2B(rRegI dst, rRegP src, rFlagsReg cr) 9440 %{ 9441 match(Set dst (Conv2B src)); 9442 effect(KILL cr); 9443 9444 format %{ "testq $src, $src\t# cp2b\n\t" 9445 "setnz $dst\n\t" 9446 "movzbl $dst, $dst" %} 9447 ins_encode(REX_reg_reg_wide(src, src), opc_reg_reg(0x85, src, src), // testq 9448 setNZ_reg(dst), 9449 REX_reg_breg(dst, dst), // movzbl 9450 Opcode(0x0F), Opcode(0xB6), reg_reg(dst, dst)); 9451 ins_pipe(pipe_slow); // XXX 9452 %} 9453 9454 instruct cmpLTMask(rRegI dst, rRegI p, rRegI q, rFlagsReg cr) 9455 %{ 9456 match(Set dst (CmpLTMask p q)); 9457 effect(KILL cr); 9458 9459 ins_cost(400); 9460 format %{ "cmpl $p, $q\t# cmpLTMask\n\t" 9461 "setlt $dst\n\t" 9462 "movzbl $dst, $dst\n\t" 9463 "negl $dst" %} 9464 ins_encode(REX_reg_reg(p, q), opc_reg_reg(0x3B, p, q), // cmpl 9465 setLT_reg(dst), 9466 REX_reg_breg(dst, dst), // movzbl 9467 Opcode(0x0F), Opcode(0xB6), reg_reg(dst, dst), 9468 neg_reg(dst)); 9469 ins_pipe(pipe_slow); 9470 %} 9471 9472 instruct cmpLTMask0(rRegI dst, immI0 zero, rFlagsReg cr) 9473 %{ 9474 match(Set dst (CmpLTMask dst zero)); 9475 effect(KILL cr); 9476 9477 ins_cost(100); 9478 format %{ "sarl $dst, #31\t# cmpLTMask0" %} 9479 ins_encode %{ 9480 __ sarl($dst$$Register, 31); 9481 %} 9482 ins_pipe(ialu_reg); 9483 %} 9484 9485 /* Better to save a register than avoid a branch */ 9486 instruct cadd_cmpLTMask(rRegI p, rRegI q, rRegI y, rFlagsReg cr) 9487 %{ 9488 match(Set p (AddI (AndI (CmpLTMask p q) y) (SubI p q))); 9489 effect(KILL cr); 9490 ins_cost(300); 9491 format %{ "subl $p,$q\t# cadd_cmpLTMask\n\t" 9492 "jge done\n\t" 9493 "addl $p,$y\n" 9494 "done: " %} 9495 ins_encode %{ 9496 Register Rp = $p$$Register; 9497 Register Rq = $q$$Register; 9498 Register Ry = $y$$Register; 9499 Label done; 9500 __ subl(Rp, Rq); 9501 __ jccb(Assembler::greaterEqual, done); 9502 __ addl(Rp, Ry); 9503 __ bind(done); 9504 %} 9505 ins_pipe(pipe_cmplt); 9506 %} 9507 9508 /* Better to save a register than avoid a branch */ 9509 instruct and_cmpLTMask(rRegI p, rRegI q, rRegI y, rFlagsReg cr) 9510 %{ 9511 match(Set y (AndI (CmpLTMask p q) y)); 9512 effect(KILL cr); 9513 9514 ins_cost(300); 9515 9516 format %{ "cmpl $p, $q\t# and_cmpLTMask\n\t" 9517 "jlt done\n\t" 9518 "xorl $y, $y\n" 9519 "done: " %} 9520 ins_encode %{ 9521 Register Rp = $p$$Register; 9522 Register Rq = $q$$Register; 9523 Register Ry = $y$$Register; 9524 Label done; 9525 __ cmpl(Rp, Rq); 9526 __ jccb(Assembler::less, done); 9527 __ xorl(Ry, Ry); 9528 __ bind(done); 9529 %} 9530 ins_pipe(pipe_cmplt); 9531 %} 9532 9533 9534 //---------- FP Instructions------------------------------------------------ 9535 9536 instruct cmpF_cc_reg(rFlagsRegU cr, regF src1, regF src2) 9537 %{ 9538 match(Set cr (CmpF src1 src2)); 9539 9540 ins_cost(145); 9541 format %{ "ucomiss $src1, $src2\n\t" 9542 "jnp,s exit\n\t" 9543 "pushfq\t# saw NaN, set CF\n\t" 9544 "andq [rsp], #0xffffff2b\n\t" 9545 "popfq\n" 9546 "exit:" %} 9547 ins_encode %{ 9548 __ ucomiss($src1$$XMMRegister, $src2$$XMMRegister); 9549 emit_cmpfp_fixup(_masm); 9550 %} 9551 ins_pipe(pipe_slow); 9552 %} 9553 9554 instruct cmpF_cc_reg_CF(rFlagsRegUCF cr, regF src1, regF src2) %{ 9555 match(Set cr (CmpF src1 src2)); 9556 9557 ins_cost(100); 9558 format %{ "ucomiss $src1, $src2" %} 9559 ins_encode %{ 9560 __ ucomiss($src1$$XMMRegister, $src2$$XMMRegister); 9561 %} 9562 ins_pipe(pipe_slow); 9563 %} 9564 9565 instruct cmpF_cc_mem(rFlagsRegU cr, regF src1, memory src2) 9566 %{ 9567 match(Set cr (CmpF src1 (LoadF src2))); 9568 9569 ins_cost(145); 9570 format %{ "ucomiss $src1, $src2\n\t" 9571 "jnp,s exit\n\t" 9572 "pushfq\t# saw NaN, set CF\n\t" 9573 "andq [rsp], #0xffffff2b\n\t" 9574 "popfq\n" 9575 "exit:" %} 9576 ins_encode %{ 9577 __ ucomiss($src1$$XMMRegister, $src2$$Address); 9578 emit_cmpfp_fixup(_masm); 9579 %} 9580 ins_pipe(pipe_slow); 9581 %} 9582 9583 instruct cmpF_cc_memCF(rFlagsRegUCF cr, regF src1, memory src2) %{ 9584 match(Set cr (CmpF src1 (LoadF src2))); 9585 9586 ins_cost(100); 9587 format %{ "ucomiss $src1, $src2" %} 9588 ins_encode %{ 9589 __ ucomiss($src1$$XMMRegister, $src2$$Address); 9590 %} 9591 ins_pipe(pipe_slow); 9592 %} 9593 9594 instruct cmpF_cc_imm(rFlagsRegU cr, regF src, immF con) %{ 9595 match(Set cr (CmpF src con)); 9596 9597 ins_cost(145); 9598 format %{ "ucomiss $src, [$constantaddress]\t# load from constant table: float=$con\n\t" 9599 "jnp,s exit\n\t" 9600 "pushfq\t# saw NaN, set CF\n\t" 9601 "andq [rsp], #0xffffff2b\n\t" 9602 "popfq\n" 9603 "exit:" %} 9604 ins_encode %{ 9605 __ ucomiss($src$$XMMRegister, $constantaddress($con)); 9606 emit_cmpfp_fixup(_masm); 9607 %} 9608 ins_pipe(pipe_slow); 9609 %} 9610 9611 instruct cmpF_cc_immCF(rFlagsRegUCF cr, regF src, immF con) %{ 9612 match(Set cr (CmpF src con)); 9613 ins_cost(100); 9614 format %{ "ucomiss $src, [$constantaddress]\t# load from constant table: float=$con" %} 9615 ins_encode %{ 9616 __ ucomiss($src$$XMMRegister, $constantaddress($con)); 9617 %} 9618 ins_pipe(pipe_slow); 9619 %} 9620 9621 instruct cmpD_cc_reg(rFlagsRegU cr, regD src1, regD src2) 9622 %{ 9623 match(Set cr (CmpD src1 src2)); 9624 9625 ins_cost(145); 9626 format %{ "ucomisd $src1, $src2\n\t" 9627 "jnp,s exit\n\t" 9628 "pushfq\t# saw NaN, set CF\n\t" 9629 "andq [rsp], #0xffffff2b\n\t" 9630 "popfq\n" 9631 "exit:" %} 9632 ins_encode %{ 9633 __ ucomisd($src1$$XMMRegister, $src2$$XMMRegister); 9634 emit_cmpfp_fixup(_masm); 9635 %} 9636 ins_pipe(pipe_slow); 9637 %} 9638 9639 instruct cmpD_cc_reg_CF(rFlagsRegUCF cr, regD src1, regD src2) %{ 9640 match(Set cr (CmpD src1 src2)); 9641 9642 ins_cost(100); 9643 format %{ "ucomisd $src1, $src2 test" %} 9644 ins_encode %{ 9645 __ ucomisd($src1$$XMMRegister, $src2$$XMMRegister); 9646 %} 9647 ins_pipe(pipe_slow); 9648 %} 9649 9650 instruct cmpD_cc_mem(rFlagsRegU cr, regD src1, memory src2) 9651 %{ 9652 match(Set cr (CmpD src1 (LoadD src2))); 9653 9654 ins_cost(145); 9655 format %{ "ucomisd $src1, $src2\n\t" 9656 "jnp,s exit\n\t" 9657 "pushfq\t# saw NaN, set CF\n\t" 9658 "andq [rsp], #0xffffff2b\n\t" 9659 "popfq\n" 9660 "exit:" %} 9661 ins_encode %{ 9662 __ ucomisd($src1$$XMMRegister, $src2$$Address); 9663 emit_cmpfp_fixup(_masm); 9664 %} 9665 ins_pipe(pipe_slow); 9666 %} 9667 9668 instruct cmpD_cc_memCF(rFlagsRegUCF cr, regD src1, memory src2) %{ 9669 match(Set cr (CmpD src1 (LoadD src2))); 9670 9671 ins_cost(100); 9672 format %{ "ucomisd $src1, $src2" %} 9673 ins_encode %{ 9674 __ ucomisd($src1$$XMMRegister, $src2$$Address); 9675 %} 9676 ins_pipe(pipe_slow); 9677 %} 9678 9679 instruct cmpD_cc_imm(rFlagsRegU cr, regD src, immD con) %{ 9680 match(Set cr (CmpD src con)); 9681 9682 ins_cost(145); 9683 format %{ "ucomisd $src, [$constantaddress]\t# load from constant table: double=$con\n\t" 9684 "jnp,s exit\n\t" 9685 "pushfq\t# saw NaN, set CF\n\t" 9686 "andq [rsp], #0xffffff2b\n\t" 9687 "popfq\n" 9688 "exit:" %} 9689 ins_encode %{ 9690 __ ucomisd($src$$XMMRegister, $constantaddress($con)); 9691 emit_cmpfp_fixup(_masm); 9692 %} 9693 ins_pipe(pipe_slow); 9694 %} 9695 9696 instruct cmpD_cc_immCF(rFlagsRegUCF cr, regD src, immD con) %{ 9697 match(Set cr (CmpD src con)); 9698 ins_cost(100); 9699 format %{ "ucomisd $src, [$constantaddress]\t# load from constant table: double=$con" %} 9700 ins_encode %{ 9701 __ ucomisd($src$$XMMRegister, $constantaddress($con)); 9702 %} 9703 ins_pipe(pipe_slow); 9704 %} 9705 9706 // Compare into -1,0,1 9707 instruct cmpF_reg(rRegI dst, regF src1, regF src2, rFlagsReg cr) 9708 %{ 9709 match(Set dst (CmpF3 src1 src2)); 9710 effect(KILL cr); 9711 9712 ins_cost(275); 9713 format %{ "ucomiss $src1, $src2\n\t" 9714 "movl $dst, #-1\n\t" 9715 "jp,s done\n\t" 9716 "jb,s done\n\t" 9717 "setne $dst\n\t" 9718 "movzbl $dst, $dst\n" 9719 "done:" %} 9720 ins_encode %{ 9721 __ ucomiss($src1$$XMMRegister, $src2$$XMMRegister); 9722 emit_cmpfp3(_masm, $dst$$Register); 9723 %} 9724 ins_pipe(pipe_slow); 9725 %} 9726 9727 // Compare into -1,0,1 9728 instruct cmpF_mem(rRegI dst, regF src1, memory src2, rFlagsReg cr) 9729 %{ 9730 match(Set dst (CmpF3 src1 (LoadF src2))); 9731 effect(KILL cr); 9732 9733 ins_cost(275); 9734 format %{ "ucomiss $src1, $src2\n\t" 9735 "movl $dst, #-1\n\t" 9736 "jp,s done\n\t" 9737 "jb,s done\n\t" 9738 "setne $dst\n\t" 9739 "movzbl $dst, $dst\n" 9740 "done:" %} 9741 ins_encode %{ 9742 __ ucomiss($src1$$XMMRegister, $src2$$Address); 9743 emit_cmpfp3(_masm, $dst$$Register); 9744 %} 9745 ins_pipe(pipe_slow); 9746 %} 9747 9748 // Compare into -1,0,1 9749 instruct cmpF_imm(rRegI dst, regF src, immF con, rFlagsReg cr) %{ 9750 match(Set dst (CmpF3 src con)); 9751 effect(KILL cr); 9752 9753 ins_cost(275); 9754 format %{ "ucomiss $src, [$constantaddress]\t# load from constant table: float=$con\n\t" 9755 "movl $dst, #-1\n\t" 9756 "jp,s done\n\t" 9757 "jb,s done\n\t" 9758 "setne $dst\n\t" 9759 "movzbl $dst, $dst\n" 9760 "done:" %} 9761 ins_encode %{ 9762 __ ucomiss($src$$XMMRegister, $constantaddress($con)); 9763 emit_cmpfp3(_masm, $dst$$Register); 9764 %} 9765 ins_pipe(pipe_slow); 9766 %} 9767 9768 // Compare into -1,0,1 9769 instruct cmpD_reg(rRegI dst, regD src1, regD src2, rFlagsReg cr) 9770 %{ 9771 match(Set dst (CmpD3 src1 src2)); 9772 effect(KILL cr); 9773 9774 ins_cost(275); 9775 format %{ "ucomisd $src1, $src2\n\t" 9776 "movl $dst, #-1\n\t" 9777 "jp,s done\n\t" 9778 "jb,s done\n\t" 9779 "setne $dst\n\t" 9780 "movzbl $dst, $dst\n" 9781 "done:" %} 9782 ins_encode %{ 9783 __ ucomisd($src1$$XMMRegister, $src2$$XMMRegister); 9784 emit_cmpfp3(_masm, $dst$$Register); 9785 %} 9786 ins_pipe(pipe_slow); 9787 %} 9788 9789 // Compare into -1,0,1 9790 instruct cmpD_mem(rRegI dst, regD src1, memory src2, rFlagsReg cr) 9791 %{ 9792 match(Set dst (CmpD3 src1 (LoadD src2))); 9793 effect(KILL cr); 9794 9795 ins_cost(275); 9796 format %{ "ucomisd $src1, $src2\n\t" 9797 "movl $dst, #-1\n\t" 9798 "jp,s done\n\t" 9799 "jb,s done\n\t" 9800 "setne $dst\n\t" 9801 "movzbl $dst, $dst\n" 9802 "done:" %} 9803 ins_encode %{ 9804 __ ucomisd($src1$$XMMRegister, $src2$$Address); 9805 emit_cmpfp3(_masm, $dst$$Register); 9806 %} 9807 ins_pipe(pipe_slow); 9808 %} 9809 9810 // Compare into -1,0,1 9811 instruct cmpD_imm(rRegI dst, regD src, immD con, rFlagsReg cr) %{ 9812 match(Set dst (CmpD3 src con)); 9813 effect(KILL cr); 9814 9815 ins_cost(275); 9816 format %{ "ucomisd $src, [$constantaddress]\t# load from constant table: double=$con\n\t" 9817 "movl $dst, #-1\n\t" 9818 "jp,s done\n\t" 9819 "jb,s done\n\t" 9820 "setne $dst\n\t" 9821 "movzbl $dst, $dst\n" 9822 "done:" %} 9823 ins_encode %{ 9824 __ ucomisd($src$$XMMRegister, $constantaddress($con)); 9825 emit_cmpfp3(_masm, $dst$$Register); 9826 %} 9827 ins_pipe(pipe_slow); 9828 %} 9829 9830 // -----------Trig and Trancendental Instructions------------------------------ 9831 instruct cosD_reg(regD dst) %{ 9832 match(Set dst (CosD dst)); 9833 9834 format %{ "dcos $dst\n\t" %} 9835 opcode(0xD9, 0xFF); 9836 ins_encode( Push_SrcXD(dst), OpcP, OpcS, Push_ResultXD(dst) ); 9837 ins_pipe( pipe_slow ); 9838 %} 9839 9840 instruct sinD_reg(regD dst) %{ 9841 match(Set dst (SinD dst)); 9842 9843 format %{ "dsin $dst\n\t" %} 9844 opcode(0xD9, 0xFE); 9845 ins_encode( Push_SrcXD(dst), OpcP, OpcS, Push_ResultXD(dst) ); 9846 ins_pipe( pipe_slow ); 9847 %} 9848 9849 instruct tanD_reg(regD dst) %{ 9850 match(Set dst (TanD dst)); 9851 9852 format %{ "dtan $dst\n\t" %} 9853 ins_encode( Push_SrcXD(dst), 9854 Opcode(0xD9), Opcode(0xF2), //fptan 9855 Opcode(0xDD), Opcode(0xD8), //fstp st 9856 Push_ResultXD(dst) ); 9857 ins_pipe( pipe_slow ); 9858 %} 9859 9860 instruct log10D_reg(regD dst) %{ 9861 // The source and result Double operands in XMM registers 9862 match(Set dst (Log10D dst)); 9863 // fldlg2 ; push log_10(2) on the FPU stack; full 80-bit number 9864 // fyl2x ; compute log_10(2) * log_2(x) 9865 format %{ "fldlg2\t\t\t#Log10\n\t" 9866 "fyl2x\t\t\t# Q=Log10*Log_2(x)\n\t" 9867 %} 9868 ins_encode(Opcode(0xD9), Opcode(0xEC), // fldlg2 9869 Push_SrcXD(dst), 9870 Opcode(0xD9), Opcode(0xF1), // fyl2x 9871 Push_ResultXD(dst)); 9872 9873 ins_pipe( pipe_slow ); 9874 %} 9875 9876 instruct logD_reg(regD dst) %{ 9877 // The source and result Double operands in XMM registers 9878 match(Set dst (LogD dst)); 9879 // fldln2 ; push log_e(2) on the FPU stack; full 80-bit number 9880 // fyl2x ; compute log_e(2) * log_2(x) 9881 format %{ "fldln2\t\t\t#Log_e\n\t" 9882 "fyl2x\t\t\t# Q=Log_e*Log_2(x)\n\t" 9883 %} 9884 ins_encode( Opcode(0xD9), Opcode(0xED), // fldln2 9885 Push_SrcXD(dst), 9886 Opcode(0xD9), Opcode(0xF1), // fyl2x 9887 Push_ResultXD(dst)); 9888 ins_pipe( pipe_slow ); 9889 %} 9890 9891 instruct powD_reg(regD dst, regD src0, regD src1, rax_RegI rax, rdx_RegI rdx, rcx_RegI rcx, rFlagsReg cr) %{ 9892 match(Set dst (PowD src0 src1)); // Raise src0 to the src1'th power 9893 effect(KILL rax, KILL rdx, KILL rcx, KILL cr); 9894 format %{ "fast_pow $src0 $src1 -> $dst // KILL $rax, $rcx, $rdx" %} 9895 ins_encode %{ 9896 __ subptr(rsp, 8); 9897 __ movdbl(Address(rsp, 0), $src1$$XMMRegister); 9898 __ fld_d(Address(rsp, 0)); 9899 __ movdbl(Address(rsp, 0), $src0$$XMMRegister); 9900 __ fld_d(Address(rsp, 0)); 9901 __ fast_pow(); 9902 __ fstp_d(Address(rsp, 0)); 9903 __ movdbl($dst$$XMMRegister, Address(rsp, 0)); 9904 __ addptr(rsp, 8); 9905 %} 9906 ins_pipe( pipe_slow ); 9907 %} 9908 9909 instruct expD_reg(regD dst, regD src, rax_RegI rax, rdx_RegI rdx, rcx_RegI rcx, rFlagsReg cr) %{ 9910 match(Set dst (ExpD src)); 9911 effect(KILL rax, KILL rcx, KILL rdx, KILL cr); 9912 format %{ "fast_exp $dst -> $src // KILL $rax, $rcx, $rdx" %} 9913 ins_encode %{ 9914 __ subptr(rsp, 8); 9915 __ movdbl(Address(rsp, 0), $src$$XMMRegister); 9916 __ fld_d(Address(rsp, 0)); 9917 __ fast_exp(); 9918 __ fstp_d(Address(rsp, 0)); 9919 __ movdbl($dst$$XMMRegister, Address(rsp, 0)); 9920 __ addptr(rsp, 8); 9921 %} 9922 ins_pipe( pipe_slow ); 9923 %} 9924 9925 //----------Arithmetic Conversion Instructions--------------------------------- 9926 9927 instruct roundFloat_nop(regF dst) 9928 %{ 9929 match(Set dst (RoundFloat dst)); 9930 9931 ins_cost(0); 9932 ins_encode(); 9933 ins_pipe(empty); 9934 %} 9935 9936 instruct roundDouble_nop(regD dst) 9937 %{ 9938 match(Set dst (RoundDouble dst)); 9939 9940 ins_cost(0); 9941 ins_encode(); 9942 ins_pipe(empty); 9943 %} 9944 9945 instruct convF2D_reg_reg(regD dst, regF src) 9946 %{ 9947 match(Set dst (ConvF2D src)); 9948 9949 format %{ "cvtss2sd $dst, $src" %} 9950 ins_encode %{ 9951 __ cvtss2sd ($dst$$XMMRegister, $src$$XMMRegister); 9952 %} 9953 ins_pipe(pipe_slow); // XXX 9954 %} 9955 9956 instruct convF2D_reg_mem(regD dst, memory src) 9957 %{ 9958 match(Set dst (ConvF2D (LoadF src))); 9959 9960 format %{ "cvtss2sd $dst, $src" %} 9961 ins_encode %{ 9962 __ cvtss2sd ($dst$$XMMRegister, $src$$Address); 9963 %} 9964 ins_pipe(pipe_slow); // XXX 9965 %} 9966 9967 instruct convD2F_reg_reg(regF dst, regD src) 9968 %{ 9969 match(Set dst (ConvD2F src)); 9970 9971 format %{ "cvtsd2ss $dst, $src" %} 9972 ins_encode %{ 9973 __ cvtsd2ss ($dst$$XMMRegister, $src$$XMMRegister); 9974 %} 9975 ins_pipe(pipe_slow); // XXX 9976 %} 9977 9978 instruct convD2F_reg_mem(regF dst, memory src) 9979 %{ 9980 match(Set dst (ConvD2F (LoadD src))); 9981 9982 format %{ "cvtsd2ss $dst, $src" %} 9983 ins_encode %{ 9984 __ cvtsd2ss ($dst$$XMMRegister, $src$$Address); 9985 %} 9986 ins_pipe(pipe_slow); // XXX 9987 %} 9988 9989 // XXX do mem variants 9990 instruct convF2I_reg_reg(rRegI dst, regF src, rFlagsReg cr) 9991 %{ 9992 match(Set dst (ConvF2I src)); 9993 effect(KILL cr); 9994 9995 format %{ "cvttss2sil $dst, $src\t# f2i\n\t" 9996 "cmpl $dst, #0x80000000\n\t" 9997 "jne,s done\n\t" 9998 "subq rsp, #8\n\t" 9999 "movss [rsp], $src\n\t" 10000 "call f2i_fixup\n\t" 10001 "popq $dst\n" 10002 "done: "%} 10003 ins_encode %{ 10004 Label done; 10005 __ cvttss2sil($dst$$Register, $src$$XMMRegister); 10006 __ cmpl($dst$$Register, 0x80000000); 10007 __ jccb(Assembler::notEqual, done); 10008 __ subptr(rsp, 8); 10009 __ movflt(Address(rsp, 0), $src$$XMMRegister); 10010 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::x86::f2i_fixup()))); 10011 __ pop($dst$$Register); 10012 __ bind(done); 10013 %} 10014 ins_pipe(pipe_slow); 10015 %} 10016 10017 instruct convF2L_reg_reg(rRegL dst, regF src, rFlagsReg cr) 10018 %{ 10019 match(Set dst (ConvF2L src)); 10020 effect(KILL cr); 10021 10022 format %{ "cvttss2siq $dst, $src\t# f2l\n\t" 10023 "cmpq $dst, [0x8000000000000000]\n\t" 10024 "jne,s done\n\t" 10025 "subq rsp, #8\n\t" 10026 "movss [rsp], $src\n\t" 10027 "call f2l_fixup\n\t" 10028 "popq $dst\n" 10029 "done: "%} 10030 ins_encode %{ 10031 Label done; 10032 __ cvttss2siq($dst$$Register, $src$$XMMRegister); 10033 __ cmp64($dst$$Register, 10034 ExternalAddress((address) StubRoutines::x86::double_sign_flip())); 10035 __ jccb(Assembler::notEqual, done); 10036 __ subptr(rsp, 8); 10037 __ movflt(Address(rsp, 0), $src$$XMMRegister); 10038 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::x86::f2l_fixup()))); 10039 __ pop($dst$$Register); 10040 __ bind(done); 10041 %} 10042 ins_pipe(pipe_slow); 10043 %} 10044 10045 instruct convD2I_reg_reg(rRegI dst, regD src, rFlagsReg cr) 10046 %{ 10047 match(Set dst (ConvD2I src)); 10048 effect(KILL cr); 10049 10050 format %{ "cvttsd2sil $dst, $src\t# d2i\n\t" 10051 "cmpl $dst, #0x80000000\n\t" 10052 "jne,s done\n\t" 10053 "subq rsp, #8\n\t" 10054 "movsd [rsp], $src\n\t" 10055 "call d2i_fixup\n\t" 10056 "popq $dst\n" 10057 "done: "%} 10058 ins_encode %{ 10059 Label done; 10060 __ cvttsd2sil($dst$$Register, $src$$XMMRegister); 10061 __ cmpl($dst$$Register, 0x80000000); 10062 __ jccb(Assembler::notEqual, done); 10063 __ subptr(rsp, 8); 10064 __ movdbl(Address(rsp, 0), $src$$XMMRegister); 10065 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::x86::d2i_fixup()))); 10066 __ pop($dst$$Register); 10067 __ bind(done); 10068 %} 10069 ins_pipe(pipe_slow); 10070 %} 10071 10072 instruct convD2L_reg_reg(rRegL dst, regD src, rFlagsReg cr) 10073 %{ 10074 match(Set dst (ConvD2L src)); 10075 effect(KILL cr); 10076 10077 format %{ "cvttsd2siq $dst, $src\t# d2l\n\t" 10078 "cmpq $dst, [0x8000000000000000]\n\t" 10079 "jne,s done\n\t" 10080 "subq rsp, #8\n\t" 10081 "movsd [rsp], $src\n\t" 10082 "call d2l_fixup\n\t" 10083 "popq $dst\n" 10084 "done: "%} 10085 ins_encode %{ 10086 Label done; 10087 __ cvttsd2siq($dst$$Register, $src$$XMMRegister); 10088 __ cmp64($dst$$Register, 10089 ExternalAddress((address) StubRoutines::x86::double_sign_flip())); 10090 __ jccb(Assembler::notEqual, done); 10091 __ subptr(rsp, 8); 10092 __ movdbl(Address(rsp, 0), $src$$XMMRegister); 10093 __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::x86::d2l_fixup()))); 10094 __ pop($dst$$Register); 10095 __ bind(done); 10096 %} 10097 ins_pipe(pipe_slow); 10098 %} 10099 10100 instruct convI2F_reg_reg(regF dst, rRegI src) 10101 %{ 10102 predicate(!UseXmmI2F); 10103 match(Set dst (ConvI2F src)); 10104 10105 format %{ "cvtsi2ssl $dst, $src\t# i2f" %} 10106 ins_encode %{ 10107 __ cvtsi2ssl ($dst$$XMMRegister, $src$$Register); 10108 %} 10109 ins_pipe(pipe_slow); // XXX 10110 %} 10111 10112 instruct convI2F_reg_mem(regF dst, memory src) 10113 %{ 10114 match(Set dst (ConvI2F (LoadI src))); 10115 10116 format %{ "cvtsi2ssl $dst, $src\t# i2f" %} 10117 ins_encode %{ 10118 __ cvtsi2ssl ($dst$$XMMRegister, $src$$Address); 10119 %} 10120 ins_pipe(pipe_slow); // XXX 10121 %} 10122 10123 instruct convI2D_reg_reg(regD dst, rRegI src) 10124 %{ 10125 predicate(!UseXmmI2D); 10126 match(Set dst (ConvI2D src)); 10127 10128 format %{ "cvtsi2sdl $dst, $src\t# i2d" %} 10129 ins_encode %{ 10130 __ cvtsi2sdl ($dst$$XMMRegister, $src$$Register); 10131 %} 10132 ins_pipe(pipe_slow); // XXX 10133 %} 10134 10135 instruct convI2D_reg_mem(regD dst, memory src) 10136 %{ 10137 match(Set dst (ConvI2D (LoadI src))); 10138 10139 format %{ "cvtsi2sdl $dst, $src\t# i2d" %} 10140 ins_encode %{ 10141 __ cvtsi2sdl ($dst$$XMMRegister, $src$$Address); 10142 %} 10143 ins_pipe(pipe_slow); // XXX 10144 %} 10145 10146 instruct convXI2F_reg(regF dst, rRegI src) 10147 %{ 10148 predicate(UseXmmI2F); 10149 match(Set dst (ConvI2F src)); 10150 10151 format %{ "movdl $dst, $src\n\t" 10152 "cvtdq2psl $dst, $dst\t# i2f" %} 10153 ins_encode %{ 10154 __ movdl($dst$$XMMRegister, $src$$Register); 10155 __ cvtdq2ps($dst$$XMMRegister, $dst$$XMMRegister); 10156 %} 10157 ins_pipe(pipe_slow); // XXX 10158 %} 10159 10160 instruct convXI2D_reg(regD dst, rRegI src) 10161 %{ 10162 predicate(UseXmmI2D); 10163 match(Set dst (ConvI2D src)); 10164 10165 format %{ "movdl $dst, $src\n\t" 10166 "cvtdq2pdl $dst, $dst\t# i2d" %} 10167 ins_encode %{ 10168 __ movdl($dst$$XMMRegister, $src$$Register); 10169 __ cvtdq2pd($dst$$XMMRegister, $dst$$XMMRegister); 10170 %} 10171 ins_pipe(pipe_slow); // XXX 10172 %} 10173 10174 instruct convL2F_reg_reg(regF dst, rRegL src) 10175 %{ 10176 match(Set dst (ConvL2F src)); 10177 10178 format %{ "cvtsi2ssq $dst, $src\t# l2f" %} 10179 ins_encode %{ 10180 __ cvtsi2ssq ($dst$$XMMRegister, $src$$Register); 10181 %} 10182 ins_pipe(pipe_slow); // XXX 10183 %} 10184 10185 instruct convL2F_reg_mem(regF dst, memory src) 10186 %{ 10187 match(Set dst (ConvL2F (LoadL src))); 10188 10189 format %{ "cvtsi2ssq $dst, $src\t# l2f" %} 10190 ins_encode %{ 10191 __ cvtsi2ssq ($dst$$XMMRegister, $src$$Address); 10192 %} 10193 ins_pipe(pipe_slow); // XXX 10194 %} 10195 10196 instruct convL2D_reg_reg(regD dst, rRegL src) 10197 %{ 10198 match(Set dst (ConvL2D src)); 10199 10200 format %{ "cvtsi2sdq $dst, $src\t# l2d" %} 10201 ins_encode %{ 10202 __ cvtsi2sdq ($dst$$XMMRegister, $src$$Register); 10203 %} 10204 ins_pipe(pipe_slow); // XXX 10205 %} 10206 10207 instruct convL2D_reg_mem(regD dst, memory src) 10208 %{ 10209 match(Set dst (ConvL2D (LoadL src))); 10210 10211 format %{ "cvtsi2sdq $dst, $src\t# l2d" %} 10212 ins_encode %{ 10213 __ cvtsi2sdq ($dst$$XMMRegister, $src$$Address); 10214 %} 10215 ins_pipe(pipe_slow); // XXX 10216 %} 10217 10218 instruct convI2L_reg_reg(rRegL dst, rRegI src) 10219 %{ 10220 match(Set dst (ConvI2L src)); 10221 10222 ins_cost(125); 10223 format %{ "movslq $dst, $src\t# i2l" %} 10224 ins_encode %{ 10225 __ movslq($dst$$Register, $src$$Register); 10226 %} 10227 ins_pipe(ialu_reg_reg); 10228 %} 10229 10230 // instruct convI2L_reg_reg_foo(rRegL dst, rRegI src) 10231 // %{ 10232 // match(Set dst (ConvI2L src)); 10233 // // predicate(_kids[0]->_leaf->as_Type()->type()->is_int()->_lo >= 0 && 10234 // // _kids[0]->_leaf->as_Type()->type()->is_int()->_hi >= 0); 10235 // predicate(((const TypeNode*) n)->type()->is_long()->_hi == 10236 // (unsigned int) ((const TypeNode*) n)->type()->is_long()->_hi && 10237 // ((const TypeNode*) n)->type()->is_long()->_lo == 10238 // (unsigned int) ((const TypeNode*) n)->type()->is_long()->_lo); 10239 10240 // format %{ "movl $dst, $src\t# unsigned i2l" %} 10241 // ins_encode(enc_copy(dst, src)); 10242 // // opcode(0x63); // needs REX.W 10243 // // ins_encode(REX_reg_reg_wide(dst, src), OpcP, reg_reg(dst,src)); 10244 // ins_pipe(ialu_reg_reg); 10245 // %} 10246 10247 // Zero-extend convert int to long 10248 instruct convI2L_reg_reg_zex(rRegL dst, rRegI src, immL_32bits mask) 10249 %{ 10250 match(Set dst (AndL (ConvI2L src) mask)); 10251 10252 format %{ "movl $dst, $src\t# i2l zero-extend\n\t" %} 10253 ins_encode %{ 10254 if ($dst$$reg != $src$$reg) { 10255 __ movl($dst$$Register, $src$$Register); 10256 } 10257 %} 10258 ins_pipe(ialu_reg_reg); 10259 %} 10260 10261 // Zero-extend convert int to long 10262 instruct convI2L_reg_mem_zex(rRegL dst, memory src, immL_32bits mask) 10263 %{ 10264 match(Set dst (AndL (ConvI2L (LoadI src)) mask)); 10265 10266 format %{ "movl $dst, $src\t# i2l zero-extend\n\t" %} 10267 ins_encode %{ 10268 __ movl($dst$$Register, $src$$Address); 10269 %} 10270 ins_pipe(ialu_reg_mem); 10271 %} 10272 10273 instruct zerox_long_reg_reg(rRegL dst, rRegL src, immL_32bits mask) 10274 %{ 10275 match(Set dst (AndL src mask)); 10276 10277 format %{ "movl $dst, $src\t# zero-extend long" %} 10278 ins_encode %{ 10279 __ movl($dst$$Register, $src$$Register); 10280 %} 10281 ins_pipe(ialu_reg_reg); 10282 %} 10283 10284 instruct convL2I_reg_reg(rRegI dst, rRegL src) 10285 %{ 10286 match(Set dst (ConvL2I src)); 10287 10288 format %{ "movl $dst, $src\t# l2i" %} 10289 ins_encode %{ 10290 __ movl($dst$$Register, $src$$Register); 10291 %} 10292 ins_pipe(ialu_reg_reg); 10293 %} 10294 10295 10296 instruct MoveF2I_stack_reg(rRegI dst, stackSlotF src) %{ 10297 match(Set dst (MoveF2I src)); 10298 effect(DEF dst, USE src); 10299 10300 ins_cost(125); 10301 format %{ "movl $dst, $src\t# MoveF2I_stack_reg" %} 10302 ins_encode %{ 10303 __ movl($dst$$Register, Address(rsp, $src$$disp)); 10304 %} 10305 ins_pipe(ialu_reg_mem); 10306 %} 10307 10308 instruct MoveI2F_stack_reg(regF dst, stackSlotI src) %{ 10309 match(Set dst (MoveI2F src)); 10310 effect(DEF dst, USE src); 10311 10312 ins_cost(125); 10313 format %{ "movss $dst, $src\t# MoveI2F_stack_reg" %} 10314 ins_encode %{ 10315 __ movflt($dst$$XMMRegister, Address(rsp, $src$$disp)); 10316 %} 10317 ins_pipe(pipe_slow); 10318 %} 10319 10320 instruct MoveD2L_stack_reg(rRegL dst, stackSlotD src) %{ 10321 match(Set dst (MoveD2L src)); 10322 effect(DEF dst, USE src); 10323 10324 ins_cost(125); 10325 format %{ "movq $dst, $src\t# MoveD2L_stack_reg" %} 10326 ins_encode %{ 10327 __ movq($dst$$Register, Address(rsp, $src$$disp)); 10328 %} 10329 ins_pipe(ialu_reg_mem); 10330 %} 10331 10332 instruct MoveL2D_stack_reg_partial(regD dst, stackSlotL src) %{ 10333 predicate(!UseXmmLoadAndClearUpper); 10334 match(Set dst (MoveL2D src)); 10335 effect(DEF dst, USE src); 10336 10337 ins_cost(125); 10338 format %{ "movlpd $dst, $src\t# MoveL2D_stack_reg" %} 10339 ins_encode %{ 10340 __ movdbl($dst$$XMMRegister, Address(rsp, $src$$disp)); 10341 %} 10342 ins_pipe(pipe_slow); 10343 %} 10344 10345 instruct MoveL2D_stack_reg(regD dst, stackSlotL src) %{ 10346 predicate(UseXmmLoadAndClearUpper); 10347 match(Set dst (MoveL2D src)); 10348 effect(DEF dst, USE src); 10349 10350 ins_cost(125); 10351 format %{ "movsd $dst, $src\t# MoveL2D_stack_reg" %} 10352 ins_encode %{ 10353 __ movdbl($dst$$XMMRegister, Address(rsp, $src$$disp)); 10354 %} 10355 ins_pipe(pipe_slow); 10356 %} 10357 10358 10359 instruct MoveF2I_reg_stack(stackSlotI dst, regF src) %{ 10360 match(Set dst (MoveF2I src)); 10361 effect(DEF dst, USE src); 10362 10363 ins_cost(95); // XXX 10364 format %{ "movss $dst, $src\t# MoveF2I_reg_stack" %} 10365 ins_encode %{ 10366 __ movflt(Address(rsp, $dst$$disp), $src$$XMMRegister); 10367 %} 10368 ins_pipe(pipe_slow); 10369 %} 10370 10371 instruct MoveI2F_reg_stack(stackSlotF dst, rRegI src) %{ 10372 match(Set dst (MoveI2F src)); 10373 effect(DEF dst, USE src); 10374 10375 ins_cost(100); 10376 format %{ "movl $dst, $src\t# MoveI2F_reg_stack" %} 10377 ins_encode %{ 10378 __ movl(Address(rsp, $dst$$disp), $src$$Register); 10379 %} 10380 ins_pipe( ialu_mem_reg ); 10381 %} 10382 10383 instruct MoveD2L_reg_stack(stackSlotL dst, regD src) %{ 10384 match(Set dst (MoveD2L src)); 10385 effect(DEF dst, USE src); 10386 10387 ins_cost(95); // XXX 10388 format %{ "movsd $dst, $src\t# MoveL2D_reg_stack" %} 10389 ins_encode %{ 10390 __ movdbl(Address(rsp, $dst$$disp), $src$$XMMRegister); 10391 %} 10392 ins_pipe(pipe_slow); 10393 %} 10394 10395 instruct MoveL2D_reg_stack(stackSlotD dst, rRegL src) %{ 10396 match(Set dst (MoveL2D src)); 10397 effect(DEF dst, USE src); 10398 10399 ins_cost(100); 10400 format %{ "movq $dst, $src\t# MoveL2D_reg_stack" %} 10401 ins_encode %{ 10402 __ movq(Address(rsp, $dst$$disp), $src$$Register); 10403 %} 10404 ins_pipe(ialu_mem_reg); 10405 %} 10406 10407 instruct MoveF2I_reg_reg(rRegI dst, regF src) %{ 10408 match(Set dst (MoveF2I src)); 10409 effect(DEF dst, USE src); 10410 ins_cost(85); 10411 format %{ "movd $dst,$src\t# MoveF2I" %} 10412 ins_encode %{ 10413 __ movdl($dst$$Register, $src$$XMMRegister); 10414 %} 10415 ins_pipe( pipe_slow ); 10416 %} 10417 10418 instruct MoveD2L_reg_reg(rRegL dst, regD src) %{ 10419 match(Set dst (MoveD2L src)); 10420 effect(DEF dst, USE src); 10421 ins_cost(85); 10422 format %{ "movd $dst,$src\t# MoveD2L" %} 10423 ins_encode %{ 10424 __ movdq($dst$$Register, $src$$XMMRegister); 10425 %} 10426 ins_pipe( pipe_slow ); 10427 %} 10428 10429 instruct MoveI2F_reg_reg(regF dst, rRegI src) %{ 10430 match(Set dst (MoveI2F src)); 10431 effect(DEF dst, USE src); 10432 ins_cost(100); 10433 format %{ "movd $dst,$src\t# MoveI2F" %} 10434 ins_encode %{ 10435 __ movdl($dst$$XMMRegister, $src$$Register); 10436 %} 10437 ins_pipe( pipe_slow ); 10438 %} 10439 10440 instruct MoveL2D_reg_reg(regD dst, rRegL src) %{ 10441 match(Set dst (MoveL2D src)); 10442 effect(DEF dst, USE src); 10443 ins_cost(100); 10444 format %{ "movd $dst,$src\t# MoveL2D" %} 10445 ins_encode %{ 10446 __ movdq($dst$$XMMRegister, $src$$Register); 10447 %} 10448 ins_pipe( pipe_slow ); 10449 %} 10450 10451 10452 // ======================================================================= 10453 // fast clearing of an array 10454 instruct rep_stos(rcx_RegL cnt, rdi_RegP base, rax_RegI zero, Universe dummy, 10455 rFlagsReg cr) 10456 %{ 10457 predicate(!UseFastStosb); 10458 match(Set dummy (ClearArray cnt base)); 10459 effect(USE_KILL cnt, USE_KILL base, KILL zero, KILL cr); 10460 10461 format %{ "xorq rax, rax\t# ClearArray:\n\t" 10462 "rep stosq\t# Store rax to *rdi++ while rcx--" %} 10463 ins_encode %{ 10464 __ clear_mem($base$$Register, $cnt$$Register, $zero$$Register); 10465 %} 10466 ins_pipe(pipe_slow); 10467 %} 10468 10469 instruct rep_fast_stosb(rcx_RegL cnt, rdi_RegP base, rax_RegI zero, Universe dummy, 10470 rFlagsReg cr) 10471 %{ 10472 predicate(UseFastStosb); 10473 match(Set dummy (ClearArray cnt base)); 10474 effect(USE_KILL cnt, USE_KILL base, KILL zero, KILL cr); 10475 format %{ "xorq rax, rax\t# ClearArray:\n\t" 10476 "shlq rcx,3\t# Convert doublewords to bytes\n\t" 10477 "rep stosb\t# Store rax to *rdi++ while rcx--" %} 10478 ins_encode %{ 10479 __ clear_mem($base$$Register, $cnt$$Register, $zero$$Register); 10480 %} 10481 ins_pipe( pipe_slow ); 10482 %} 10483 10484 instruct string_compare(rdi_RegP str1, rcx_RegI cnt1, rsi_RegP str2, rdx_RegI cnt2, 10485 rax_RegI result, regD tmp1, rFlagsReg cr) 10486 %{ 10487 match(Set result (StrComp (Binary str1 cnt1) (Binary str2 cnt2))); 10488 effect(TEMP tmp1, USE_KILL str1, USE_KILL str2, USE_KILL cnt1, USE_KILL cnt2, KILL cr); 10489 10490 format %{ "String Compare $str1,$cnt1,$str2,$cnt2 -> $result // KILL $tmp1" %} 10491 ins_encode %{ 10492 __ string_compare($str1$$Register, $str2$$Register, 10493 $cnt1$$Register, $cnt2$$Register, $result$$Register, 10494 $tmp1$$XMMRegister); 10495 %} 10496 ins_pipe( pipe_slow ); 10497 %} 10498 10499 // fast search of substring with known size. 10500 instruct string_indexof_con(rdi_RegP str1, rdx_RegI cnt1, rsi_RegP str2, immI int_cnt2, 10501 rbx_RegI result, regD vec, rax_RegI cnt2, rcx_RegI tmp, rFlagsReg cr) 10502 %{ 10503 predicate(UseSSE42Intrinsics); 10504 match(Set result (StrIndexOf (Binary str1 cnt1) (Binary str2 int_cnt2))); 10505 effect(TEMP vec, USE_KILL str1, USE_KILL str2, USE_KILL cnt1, KILL cnt2, KILL tmp, KILL cr); 10506 10507 format %{ "String IndexOf $str1,$cnt1,$str2,$int_cnt2 -> $result // KILL $vec, $cnt1, $cnt2, $tmp" %} 10508 ins_encode %{ 10509 int icnt2 = (int)$int_cnt2$$constant; 10510 if (icnt2 >= 8) { 10511 // IndexOf for constant substrings with size >= 8 elements 10512 // which don't need to be loaded through stack. 10513 __ string_indexofC8($str1$$Register, $str2$$Register, 10514 $cnt1$$Register, $cnt2$$Register, 10515 icnt2, $result$$Register, 10516 $vec$$XMMRegister, $tmp$$Register); 10517 } else { 10518 // Small strings are loaded through stack if they cross page boundary. 10519 __ string_indexof($str1$$Register, $str2$$Register, 10520 $cnt1$$Register, $cnt2$$Register, 10521 icnt2, $result$$Register, 10522 $vec$$XMMRegister, $tmp$$Register); 10523 } 10524 %} 10525 ins_pipe( pipe_slow ); 10526 %} 10527 10528 instruct string_indexof(rdi_RegP str1, rdx_RegI cnt1, rsi_RegP str2, rax_RegI cnt2, 10529 rbx_RegI result, regD vec, rcx_RegI tmp, rFlagsReg cr) 10530 %{ 10531 predicate(UseSSE42Intrinsics); 10532 match(Set result (StrIndexOf (Binary str1 cnt1) (Binary str2 cnt2))); 10533 effect(TEMP vec, USE_KILL str1, USE_KILL str2, USE_KILL cnt1, USE_KILL cnt2, KILL tmp, KILL cr); 10534 10535 format %{ "String IndexOf $str1,$cnt1,$str2,$cnt2 -> $result // KILL all" %} 10536 ins_encode %{ 10537 __ string_indexof($str1$$Register, $str2$$Register, 10538 $cnt1$$Register, $cnt2$$Register, 10539 (-1), $result$$Register, 10540 $vec$$XMMRegister, $tmp$$Register); 10541 %} 10542 ins_pipe( pipe_slow ); 10543 %} 10544 10545 // fast string equals 10546 instruct string_equals(rdi_RegP str1, rsi_RegP str2, rcx_RegI cnt, rax_RegI result, 10547 regD tmp1, regD tmp2, rbx_RegI tmp3, rFlagsReg cr) 10548 %{ 10549 match(Set result (StrEquals (Binary str1 str2) cnt)); 10550 effect(TEMP tmp1, TEMP tmp2, USE_KILL str1, USE_KILL str2, USE_KILL cnt, KILL tmp3, KILL cr); 10551 10552 format %{ "String Equals $str1,$str2,$cnt -> $result // KILL $tmp1, $tmp2, $tmp3" %} 10553 ins_encode %{ 10554 __ char_arrays_equals(false, $str1$$Register, $str2$$Register, 10555 $cnt$$Register, $result$$Register, $tmp3$$Register, 10556 $tmp1$$XMMRegister, $tmp2$$XMMRegister); 10557 %} 10558 ins_pipe( pipe_slow ); 10559 %} 10560 10561 // fast array equals 10562 instruct array_equals(rdi_RegP ary1, rsi_RegP ary2, rax_RegI result, 10563 regD tmp1, regD tmp2, rcx_RegI tmp3, rbx_RegI tmp4, rFlagsReg cr) 10564 %{ 10565 match(Set result (AryEq ary1 ary2)); 10566 effect(TEMP tmp1, TEMP tmp2, USE_KILL ary1, USE_KILL ary2, KILL tmp3, KILL tmp4, KILL cr); 10567 //ins_cost(300); 10568 10569 format %{ "Array Equals $ary1,$ary2 -> $result // KILL $tmp1, $tmp2, $tmp3, $tmp4" %} 10570 ins_encode %{ 10571 __ char_arrays_equals(true, $ary1$$Register, $ary2$$Register, 10572 $tmp3$$Register, $result$$Register, $tmp4$$Register, 10573 $tmp1$$XMMRegister, $tmp2$$XMMRegister); 10574 %} 10575 ins_pipe( pipe_slow ); 10576 %} 10577 10578 // encode char[] to byte[] in ISO_8859_1 10579 instruct encode_iso_array(rsi_RegP src, rdi_RegP dst, rdx_RegI len, 10580 regD tmp1, regD tmp2, regD tmp3, regD tmp4, 10581 rcx_RegI tmp5, rax_RegI result, rFlagsReg cr) %{ 10582 match(Set result (EncodeISOArray src (Binary dst len))); 10583 effect(TEMP tmp1, TEMP tmp2, TEMP tmp3, TEMP tmp4, USE_KILL src, USE_KILL dst, USE_KILL len, KILL tmp5, KILL cr); 10584 10585 format %{ "Encode array $src,$dst,$len -> $result // KILL RCX, RDX, $tmp1, $tmp2, $tmp3, $tmp4, RSI, RDI " %} 10586 ins_encode %{ 10587 __ encode_iso_array($src$$Register, $dst$$Register, $len$$Register, 10588 $tmp1$$XMMRegister, $tmp2$$XMMRegister, $tmp3$$XMMRegister, 10589 $tmp4$$XMMRegister, $tmp5$$Register, $result$$Register); 10590 %} 10591 ins_pipe( pipe_slow ); 10592 %} 10593 10594 //----------Overflow Math Instructions----------------------------------------- 10595 10596 instruct overflowAddI_rReg(rFlagsReg cr, rax_RegI op1, rRegI op2) 10597 %{ 10598 match(Set cr (OverflowAddI op1 op2)); 10599 effect(DEF cr, USE_KILL op1, USE op2); 10600 10601 format %{ "addl $op1, $op2\t# overflow check int" %} 10602 10603 ins_encode %{ 10604 __ addl($op1$$Register, $op2$$Register); 10605 %} 10606 ins_pipe(ialu_reg_reg); 10607 %} 10608 10609 instruct overflowAddI_rReg_imm(rFlagsReg cr, rax_RegI op1, immI op2) 10610 %{ 10611 match(Set cr (OverflowAddI op1 op2)); 10612 effect(DEF cr, USE_KILL op1, USE op2); 10613 10614 format %{ "addl $op1, $op2\t# overflow check int" %} 10615 10616 ins_encode %{ 10617 __ addl($op1$$Register, $op2$$constant); 10618 %} 10619 ins_pipe(ialu_reg_reg); 10620 %} 10621 10622 instruct overflowAddL_rReg(rFlagsReg cr, rax_RegL op1, rRegL op2) 10623 %{ 10624 match(Set cr (OverflowAddL op1 op2)); 10625 effect(DEF cr, USE_KILL op1, USE op2); 10626 10627 format %{ "addq $op1, $op2\t# overflow check long" %} 10628 ins_encode %{ 10629 __ addq($op1$$Register, $op2$$Register); 10630 %} 10631 ins_pipe(ialu_reg_reg); 10632 %} 10633 10634 instruct overflowAddL_rReg_imm(rFlagsReg cr, rax_RegL op1, immL32 op2) 10635 %{ 10636 match(Set cr (OverflowAddL op1 op2)); 10637 effect(DEF cr, USE_KILL op1, USE op2); 10638 10639 format %{ "addq $op1, $op2\t# overflow check long" %} 10640 ins_encode %{ 10641 __ addq($op1$$Register, $op2$$constant); 10642 %} 10643 ins_pipe(ialu_reg_reg); 10644 %} 10645 10646 instruct overflowSubI_rReg(rFlagsReg cr, rRegI op1, rRegI op2) 10647 %{ 10648 match(Set cr (OverflowSubI op1 op2)); 10649 10650 format %{ "cmpl $op1, $op2\t# overflow check int" %} 10651 ins_encode %{ 10652 __ cmpl($op1$$Register, $op2$$Register); 10653 %} 10654 ins_pipe(ialu_reg_reg); 10655 %} 10656 10657 instruct overflowSubI_rReg_imm(rFlagsReg cr, rRegI op1, immI op2) 10658 %{ 10659 match(Set cr (OverflowSubI op1 op2)); 10660 10661 format %{ "cmpl $op1, $op2\t# overflow check int" %} 10662 ins_encode %{ 10663 __ cmpl($op1$$Register, $op2$$constant); 10664 %} 10665 ins_pipe(ialu_reg_reg); 10666 %} 10667 10668 instruct overflowSubL_rReg(rFlagsReg cr, rRegL op1, rRegL op2) 10669 %{ 10670 match(Set cr (OverflowSubL op1 op2)); 10671 10672 format %{ "cmpq $op1, $op2\t# overflow check long" %} 10673 ins_encode %{ 10674 __ cmpq($op1$$Register, $op2$$Register); 10675 %} 10676 ins_pipe(ialu_reg_reg); 10677 %} 10678 10679 instruct overflowSubL_rReg_imm(rFlagsReg cr, rRegL op1, immL32 op2) 10680 %{ 10681 match(Set cr (OverflowSubL op1 op2)); 10682 10683 format %{ "cmpq $op1, $op2\t# overflow check long" %} 10684 ins_encode %{ 10685 __ cmpq($op1$$Register, $op2$$constant); 10686 %} 10687 ins_pipe(ialu_reg_reg); 10688 %} 10689 10690 instruct overflowNegI_rReg(rFlagsReg cr, immI0 zero, rax_RegI op2) 10691 %{ 10692 match(Set cr (OverflowSubI zero op2)); 10693 effect(DEF cr, USE_KILL op2); 10694 10695 format %{ "negl $op2\t# overflow check int" %} 10696 ins_encode %{ 10697 __ negl($op2$$Register); 10698 %} 10699 ins_pipe(ialu_reg_reg); 10700 %} 10701 10702 instruct overflowNegL_rReg(rFlagsReg cr, immL0 zero, rax_RegL op2) 10703 %{ 10704 match(Set cr (OverflowSubL zero op2)); 10705 effect(DEF cr, USE_KILL op2); 10706 10707 format %{ "negq $op2\t# overflow check long" %} 10708 ins_encode %{ 10709 __ negq($op2$$Register); 10710 %} 10711 ins_pipe(ialu_reg_reg); 10712 %} 10713 10714 instruct overflowMulI_rReg(rFlagsReg cr, rax_RegI op1, rRegI op2) 10715 %{ 10716 match(Set cr (OverflowMulI op1 op2)); 10717 effect(DEF cr, USE_KILL op1, USE op2); 10718 10719 format %{ "imull $op1, $op2\t# overflow check int" %} 10720 ins_encode %{ 10721 __ imull($op1$$Register, $op2$$Register); 10722 %} 10723 ins_pipe(ialu_reg_reg_alu0); 10724 %} 10725 10726 instruct overflowMulI_rReg_imm(rFlagsReg cr, rRegI op1, immI op2, rRegI tmp) 10727 %{ 10728 match(Set cr (OverflowMulI op1 op2)); 10729 effect(DEF cr, TEMP tmp, USE op1, USE op2); 10730 10731 format %{ "imull $tmp, $op1, $op2\t# overflow check int" %} 10732 ins_encode %{ 10733 __ imull($tmp$$Register, $op1$$Register, $op2$$constant); 10734 %} 10735 ins_pipe(ialu_reg_reg_alu0); 10736 %} 10737 10738 instruct overflowMulL_rReg(rFlagsReg cr, rax_RegL op1, rRegL op2) 10739 %{ 10740 match(Set cr (OverflowMulL op1 op2)); 10741 effect(DEF cr, USE_KILL op1, USE op2); 10742 10743 format %{ "imulq $op1, $op2\t# overflow check long" %} 10744 ins_encode %{ 10745 __ imulq($op1$$Register, $op2$$Register); 10746 %} 10747 ins_pipe(ialu_reg_reg_alu0); 10748 %} 10749 10750 instruct overflowMulL_rReg_imm(rFlagsReg cr, rRegL op1, immL32 op2, rRegL tmp) 10751 %{ 10752 match(Set cr (OverflowMulL op1 op2)); 10753 effect(DEF cr, TEMP tmp, USE op1, USE op2); 10754 10755 format %{ "imulq $tmp, $op1, $op2\t# overflow check long" %} 10756 ins_encode %{ 10757 __ imulq($tmp$$Register, $op1$$Register, $op2$$constant); 10758 %} 10759 ins_pipe(ialu_reg_reg_alu0); 10760 %} 10761 10762 10763 //----------Control Flow Instructions------------------------------------------ 10764 // Signed compare Instructions 10765 10766 // XXX more variants!! 10767 instruct compI_rReg(rFlagsReg cr, rRegI op1, rRegI op2) 10768 %{ 10769 match(Set cr (CmpI op1 op2)); 10770 effect(DEF cr, USE op1, USE op2); 10771 10772 format %{ "cmpl $op1, $op2" %} 10773 opcode(0x3B); /* Opcode 3B /r */ 10774 ins_encode(REX_reg_reg(op1, op2), OpcP, reg_reg(op1, op2)); 10775 ins_pipe(ialu_cr_reg_reg); 10776 %} 10777 10778 instruct compI_rReg_imm(rFlagsReg cr, rRegI op1, immI op2) 10779 %{ 10780 match(Set cr (CmpI op1 op2)); 10781 10782 format %{ "cmpl $op1, $op2" %} 10783 opcode(0x81, 0x07); /* Opcode 81 /7 */ 10784 ins_encode(OpcSErm(op1, op2), Con8or32(op2)); 10785 ins_pipe(ialu_cr_reg_imm); 10786 %} 10787 10788 instruct compI_rReg_mem(rFlagsReg cr, rRegI op1, memory op2) 10789 %{ 10790 match(Set cr (CmpI op1 (LoadI op2))); 10791 10792 ins_cost(500); // XXX 10793 format %{ "cmpl $op1, $op2" %} 10794 opcode(0x3B); /* Opcode 3B /r */ 10795 ins_encode(REX_reg_mem(op1, op2), OpcP, reg_mem(op1, op2)); 10796 ins_pipe(ialu_cr_reg_mem); 10797 %} 10798 10799 instruct testI_reg(rFlagsReg cr, rRegI src, immI0 zero) 10800 %{ 10801 match(Set cr (CmpI src zero)); 10802 10803 format %{ "testl $src, $src" %} 10804 opcode(0x85); 10805 ins_encode(REX_reg_reg(src, src), OpcP, reg_reg(src, src)); 10806 ins_pipe(ialu_cr_reg_imm); 10807 %} 10808 10809 instruct testI_reg_imm(rFlagsReg cr, rRegI src, immI con, immI0 zero) 10810 %{ 10811 match(Set cr (CmpI (AndI src con) zero)); 10812 10813 format %{ "testl $src, $con" %} 10814 opcode(0xF7, 0x00); 10815 ins_encode(REX_reg(src), OpcP, reg_opc(src), Con32(con)); 10816 ins_pipe(ialu_cr_reg_imm); 10817 %} 10818 10819 instruct testI_reg_mem(rFlagsReg cr, rRegI src, memory mem, immI0 zero) 10820 %{ 10821 match(Set cr (CmpI (AndI src (LoadI mem)) zero)); 10822 10823 format %{ "testl $src, $mem" %} 10824 opcode(0x85); 10825 ins_encode(REX_reg_mem(src, mem), OpcP, reg_mem(src, mem)); 10826 ins_pipe(ialu_cr_reg_mem); 10827 %} 10828 10829 // Unsigned compare Instructions; really, same as signed except they 10830 // produce an rFlagsRegU instead of rFlagsReg. 10831 instruct compU_rReg(rFlagsRegU cr, rRegI op1, rRegI op2) 10832 %{ 10833 match(Set cr (CmpU op1 op2)); 10834 10835 format %{ "cmpl $op1, $op2\t# unsigned" %} 10836 opcode(0x3B); /* Opcode 3B /r */ 10837 ins_encode(REX_reg_reg(op1, op2), OpcP, reg_reg(op1, op2)); 10838 ins_pipe(ialu_cr_reg_reg); 10839 %} 10840 10841 instruct compU_rReg_imm(rFlagsRegU cr, rRegI op1, immI op2) 10842 %{ 10843 match(Set cr (CmpU op1 op2)); 10844 10845 format %{ "cmpl $op1, $op2\t# unsigned" %} 10846 opcode(0x81,0x07); /* Opcode 81 /7 */ 10847 ins_encode(OpcSErm(op1, op2), Con8or32(op2)); 10848 ins_pipe(ialu_cr_reg_imm); 10849 %} 10850 10851 instruct compU_rReg_mem(rFlagsRegU cr, rRegI op1, memory op2) 10852 %{ 10853 match(Set cr (CmpU op1 (LoadI op2))); 10854 10855 ins_cost(500); // XXX 10856 format %{ "cmpl $op1, $op2\t# unsigned" %} 10857 opcode(0x3B); /* Opcode 3B /r */ 10858 ins_encode(REX_reg_mem(op1, op2), OpcP, reg_mem(op1, op2)); 10859 ins_pipe(ialu_cr_reg_mem); 10860 %} 10861 10862 // // // Cisc-spilled version of cmpU_rReg 10863 // //instruct compU_mem_rReg(rFlagsRegU cr, memory op1, rRegI op2) 10864 // //%{ 10865 // // match(Set cr (CmpU (LoadI op1) op2)); 10866 // // 10867 // // format %{ "CMPu $op1,$op2" %} 10868 // // ins_cost(500); 10869 // // opcode(0x39); /* Opcode 39 /r */ 10870 // // ins_encode( OpcP, reg_mem( op1, op2) ); 10871 // //%} 10872 10873 instruct testU_reg(rFlagsRegU cr, rRegI src, immI0 zero) 10874 %{ 10875 match(Set cr (CmpU src zero)); 10876 10877 format %{ "testl $src, $src\t# unsigned" %} 10878 opcode(0x85); 10879 ins_encode(REX_reg_reg(src, src), OpcP, reg_reg(src, src)); 10880 ins_pipe(ialu_cr_reg_imm); 10881 %} 10882 10883 instruct compP_rReg(rFlagsRegU cr, rRegP op1, rRegP op2) 10884 %{ 10885 match(Set cr (CmpP op1 op2)); 10886 10887 format %{ "cmpq $op1, $op2\t# ptr" %} 10888 opcode(0x3B); /* Opcode 3B /r */ 10889 ins_encode(REX_reg_reg_wide(op1, op2), OpcP, reg_reg(op1, op2)); 10890 ins_pipe(ialu_cr_reg_reg); 10891 %} 10892 10893 instruct compP_rReg_mem(rFlagsRegU cr, rRegP op1, memory op2) 10894 %{ 10895 match(Set cr (CmpP op1 (LoadP op2))); 10896 10897 ins_cost(500); // XXX 10898 format %{ "cmpq $op1, $op2\t# ptr" %} 10899 opcode(0x3B); /* Opcode 3B /r */ 10900 ins_encode(REX_reg_mem_wide(op1, op2), OpcP, reg_mem(op1, op2)); 10901 ins_pipe(ialu_cr_reg_mem); 10902 %} 10903 10904 // // // Cisc-spilled version of cmpP_rReg 10905 // //instruct compP_mem_rReg(rFlagsRegU cr, memory op1, rRegP op2) 10906 // //%{ 10907 // // match(Set cr (CmpP (LoadP op1) op2)); 10908 // // 10909 // // format %{ "CMPu $op1,$op2" %} 10910 // // ins_cost(500); 10911 // // opcode(0x39); /* Opcode 39 /r */ 10912 // // ins_encode( OpcP, reg_mem( op1, op2) ); 10913 // //%} 10914 10915 // XXX this is generalized by compP_rReg_mem??? 10916 // Compare raw pointer (used in out-of-heap check). 10917 // Only works because non-oop pointers must be raw pointers 10918 // and raw pointers have no anti-dependencies. 10919 instruct compP_mem_rReg(rFlagsRegU cr, rRegP op1, memory op2) 10920 %{ 10921 predicate(n->in(2)->in(2)->bottom_type()->reloc() == relocInfo::none); 10922 match(Set cr (CmpP op1 (LoadP op2))); 10923 10924 format %{ "cmpq $op1, $op2\t# raw ptr" %} 10925 opcode(0x3B); /* Opcode 3B /r */ 10926 ins_encode(REX_reg_mem_wide(op1, op2), OpcP, reg_mem(op1, op2)); 10927 ins_pipe(ialu_cr_reg_mem); 10928 %} 10929 10930 // This will generate a signed flags result. This should be OK since 10931 // any compare to a zero should be eq/neq. 10932 instruct testP_reg(rFlagsReg cr, rRegP src, immP0 zero) 10933 %{ 10934 match(Set cr (CmpP src zero)); 10935 10936 format %{ "testq $src, $src\t# ptr" %} 10937 opcode(0x85); 10938 ins_encode(REX_reg_reg_wide(src, src), OpcP, reg_reg(src, src)); 10939 ins_pipe(ialu_cr_reg_imm); 10940 %} 10941 10942 // This will generate a signed flags result. This should be OK since 10943 // any compare to a zero should be eq/neq. 10944 instruct testP_mem(rFlagsReg cr, memory op, immP0 zero) 10945 %{ 10946 predicate(!UseCompressedOops || (Universe::narrow_oop_base() != NULL)); 10947 match(Set cr (CmpP (LoadP op) zero)); 10948 10949 ins_cost(500); // XXX 10950 format %{ "testq $op, 0xffffffffffffffff\t# ptr" %} 10951 opcode(0xF7); /* Opcode F7 /0 */ 10952 ins_encode(REX_mem_wide(op), 10953 OpcP, RM_opc_mem(0x00, op), Con_d32(0xFFFFFFFF)); 10954 ins_pipe(ialu_cr_reg_imm); 10955 %} 10956 10957 instruct testP_mem_reg0(rFlagsReg cr, memory mem, immP0 zero) 10958 %{ 10959 predicate(UseCompressedOops && (Universe::narrow_oop_base() == NULL) && (Universe::narrow_klass_base() == NULL)); 10960 match(Set cr (CmpP (LoadP mem) zero)); 10961 10962 format %{ "cmpq R12, $mem\t# ptr (R12_heapbase==0)" %} 10963 ins_encode %{ 10964 __ cmpq(r12, $mem$$Address); 10965 %} 10966 ins_pipe(ialu_cr_reg_mem); 10967 %} 10968 10969 instruct compN_rReg(rFlagsRegU cr, rRegN op1, rRegN op2) 10970 %{ 10971 match(Set cr (CmpN op1 op2)); 10972 10973 format %{ "cmpl $op1, $op2\t# compressed ptr" %} 10974 ins_encode %{ __ cmpl($op1$$Register, $op2$$Register); %} 10975 ins_pipe(ialu_cr_reg_reg); 10976 %} 10977 10978 instruct compN_rReg_mem(rFlagsRegU cr, rRegN src, memory mem) 10979 %{ 10980 match(Set cr (CmpN src (LoadN mem))); 10981 10982 format %{ "cmpl $src, $mem\t# compressed ptr" %} 10983 ins_encode %{ 10984 __ cmpl($src$$Register, $mem$$Address); 10985 %} 10986 ins_pipe(ialu_cr_reg_mem); 10987 %} 10988 10989 instruct compN_rReg_imm(rFlagsRegU cr, rRegN op1, immN op2) %{ 10990 match(Set cr (CmpN op1 op2)); 10991 10992 format %{ "cmpl $op1, $op2\t# compressed ptr" %} 10993 ins_encode %{ 10994 __ cmp_narrow_oop($op1$$Register, (jobject)$op2$$constant); 10995 %} 10996 ins_pipe(ialu_cr_reg_imm); 10997 %} 10998 10999 instruct compN_mem_imm(rFlagsRegU cr, memory mem, immN src) 11000 %{ 11001 match(Set cr (CmpN src (LoadN mem))); 11002 11003 format %{ "cmpl $mem, $src\t# compressed ptr" %} 11004 ins_encode %{ 11005 __ cmp_narrow_oop($mem$$Address, (jobject)$src$$constant); 11006 %} 11007 ins_pipe(ialu_cr_reg_mem); 11008 %} 11009 11010 instruct compN_rReg_imm_klass(rFlagsRegU cr, rRegN op1, immNKlass op2) %{ 11011 match(Set cr (CmpN op1 op2)); 11012 11013 format %{ "cmpl $op1, $op2\t# compressed klass ptr" %} 11014 ins_encode %{ 11015 __ cmp_narrow_klass($op1$$Register, (Klass*)$op2$$constant); 11016 %} 11017 ins_pipe(ialu_cr_reg_imm); 11018 %} 11019 11020 instruct compN_mem_imm_klass(rFlagsRegU cr, memory mem, immNKlass src) 11021 %{ 11022 match(Set cr (CmpN src (LoadNKlass mem))); 11023 11024 format %{ "cmpl $mem, $src\t# compressed klass ptr" %} 11025 ins_encode %{ 11026 __ cmp_narrow_klass($mem$$Address, (Klass*)$src$$constant); 11027 %} 11028 ins_pipe(ialu_cr_reg_mem); 11029 %} 11030 11031 instruct testN_reg(rFlagsReg cr, rRegN src, immN0 zero) %{ 11032 match(Set cr (CmpN src zero)); 11033 11034 format %{ "testl $src, $src\t# compressed ptr" %} 11035 ins_encode %{ __ testl($src$$Register, $src$$Register); %} 11036 ins_pipe(ialu_cr_reg_imm); 11037 %} 11038 11039 instruct testN_mem(rFlagsReg cr, memory mem, immN0 zero) 11040 %{ 11041 predicate(Universe::narrow_oop_base() != NULL); 11042 match(Set cr (CmpN (LoadN mem) zero)); 11043 11044 ins_cost(500); // XXX 11045 format %{ "testl $mem, 0xffffffff\t# compressed ptr" %} 11046 ins_encode %{ 11047 __ cmpl($mem$$Address, (int)0xFFFFFFFF); 11048 %} 11049 ins_pipe(ialu_cr_reg_mem); 11050 %} 11051 11052 instruct testN_mem_reg0(rFlagsReg cr, memory mem, immN0 zero) 11053 %{ 11054 predicate(Universe::narrow_oop_base() == NULL && (Universe::narrow_klass_base() == NULL)); 11055 match(Set cr (CmpN (LoadN mem) zero)); 11056 11057 format %{ "cmpl R12, $mem\t# compressed ptr (R12_heapbase==0)" %} 11058 ins_encode %{ 11059 __ cmpl(r12, $mem$$Address); 11060 %} 11061 ins_pipe(ialu_cr_reg_mem); 11062 %} 11063 11064 // Yanked all unsigned pointer compare operations. 11065 // Pointer compares are done with CmpP which is already unsigned. 11066 11067 instruct compL_rReg(rFlagsReg cr, rRegL op1, rRegL op2) 11068 %{ 11069 match(Set cr (CmpL op1 op2)); 11070 11071 format %{ "cmpq $op1, $op2" %} 11072 opcode(0x3B); /* Opcode 3B /r */ 11073 ins_encode(REX_reg_reg_wide(op1, op2), OpcP, reg_reg(op1, op2)); 11074 ins_pipe(ialu_cr_reg_reg); 11075 %} 11076 11077 instruct compL_rReg_imm(rFlagsReg cr, rRegL op1, immL32 op2) 11078 %{ 11079 match(Set cr (CmpL op1 op2)); 11080 11081 format %{ "cmpq $op1, $op2" %} 11082 opcode(0x81, 0x07); /* Opcode 81 /7 */ 11083 ins_encode(OpcSErm_wide(op1, op2), Con8or32(op2)); 11084 ins_pipe(ialu_cr_reg_imm); 11085 %} 11086 11087 instruct compL_rReg_mem(rFlagsReg cr, rRegL op1, memory op2) 11088 %{ 11089 match(Set cr (CmpL op1 (LoadL op2))); 11090 11091 format %{ "cmpq $op1, $op2" %} 11092 opcode(0x3B); /* Opcode 3B /r */ 11093 ins_encode(REX_reg_mem_wide(op1, op2), OpcP, reg_mem(op1, op2)); 11094 ins_pipe(ialu_cr_reg_mem); 11095 %} 11096 11097 instruct testL_reg(rFlagsReg cr, rRegL src, immL0 zero) 11098 %{ 11099 match(Set cr (CmpL src zero)); 11100 11101 format %{ "testq $src, $src" %} 11102 opcode(0x85); 11103 ins_encode(REX_reg_reg_wide(src, src), OpcP, reg_reg(src, src)); 11104 ins_pipe(ialu_cr_reg_imm); 11105 %} 11106 11107 instruct testL_reg_imm(rFlagsReg cr, rRegL src, immL32 con, immL0 zero) 11108 %{ 11109 match(Set cr (CmpL (AndL src con) zero)); 11110 11111 format %{ "testq $src, $con\t# long" %} 11112 opcode(0xF7, 0x00); 11113 ins_encode(REX_reg_wide(src), OpcP, reg_opc(src), Con32(con)); 11114 ins_pipe(ialu_cr_reg_imm); 11115 %} 11116 11117 instruct testL_reg_mem(rFlagsReg cr, rRegL src, memory mem, immL0 zero) 11118 %{ 11119 match(Set cr (CmpL (AndL src (LoadL mem)) zero)); 11120 11121 format %{ "testq $src, $mem" %} 11122 opcode(0x85); 11123 ins_encode(REX_reg_mem_wide(src, mem), OpcP, reg_mem(src, mem)); 11124 ins_pipe(ialu_cr_reg_mem); 11125 %} 11126 11127 // Manifest a CmpL result in an integer register. Very painful. 11128 // This is the test to avoid. 11129 instruct cmpL3_reg_reg(rRegI dst, rRegL src1, rRegL src2, rFlagsReg flags) 11130 %{ 11131 match(Set dst (CmpL3 src1 src2)); 11132 effect(KILL flags); 11133 11134 ins_cost(275); // XXX 11135 format %{ "cmpq $src1, $src2\t# CmpL3\n\t" 11136 "movl $dst, -1\n\t" 11137 "jl,s done\n\t" 11138 "setne $dst\n\t" 11139 "movzbl $dst, $dst\n\t" 11140 "done:" %} 11141 ins_encode(cmpl3_flag(src1, src2, dst)); 11142 ins_pipe(pipe_slow); 11143 %} 11144 11145 //----------Max and Min-------------------------------------------------------- 11146 // Min Instructions 11147 11148 instruct cmovI_reg_g(rRegI dst, rRegI src, rFlagsReg cr) 11149 %{ 11150 effect(USE_DEF dst, USE src, USE cr); 11151 11152 format %{ "cmovlgt $dst, $src\t# min" %} 11153 opcode(0x0F, 0x4F); 11154 ins_encode(REX_reg_reg(dst, src), OpcP, OpcS, reg_reg(dst, src)); 11155 ins_pipe(pipe_cmov_reg); 11156 %} 11157 11158 11159 instruct minI_rReg(rRegI dst, rRegI src) 11160 %{ 11161 match(Set dst (MinI dst src)); 11162 11163 ins_cost(200); 11164 expand %{ 11165 rFlagsReg cr; 11166 compI_rReg(cr, dst, src); 11167 cmovI_reg_g(dst, src, cr); 11168 %} 11169 %} 11170 11171 instruct cmovI_reg_l(rRegI dst, rRegI src, rFlagsReg cr) 11172 %{ 11173 effect(USE_DEF dst, USE src, USE cr); 11174 11175 format %{ "cmovllt $dst, $src\t# max" %} 11176 opcode(0x0F, 0x4C); 11177 ins_encode(REX_reg_reg(dst, src), OpcP, OpcS, reg_reg(dst, src)); 11178 ins_pipe(pipe_cmov_reg); 11179 %} 11180 11181 11182 instruct maxI_rReg(rRegI dst, rRegI src) 11183 %{ 11184 match(Set dst (MaxI dst src)); 11185 11186 ins_cost(200); 11187 expand %{ 11188 rFlagsReg cr; 11189 compI_rReg(cr, dst, src); 11190 cmovI_reg_l(dst, src, cr); 11191 %} 11192 %} 11193 11194 // ============================================================================ 11195 // Branch Instructions 11196 11197 // Jump Direct - Label defines a relative address from JMP+1 11198 instruct jmpDir(label labl) 11199 %{ 11200 match(Goto); 11201 effect(USE labl); 11202 11203 ins_cost(300); 11204 format %{ "jmp $labl" %} 11205 size(5); 11206 ins_encode %{ 11207 Label* L = $labl$$label; 11208 __ jmp(*L, false); // Always long jump 11209 %} 11210 ins_pipe(pipe_jmp); 11211 %} 11212 11213 // Jump Direct Conditional - Label defines a relative address from Jcc+1 11214 instruct jmpCon(cmpOp cop, rFlagsReg cr, label labl) 11215 %{ 11216 match(If cop cr); 11217 effect(USE labl); 11218 11219 ins_cost(300); 11220 format %{ "j$cop $labl" %} 11221 size(6); 11222 ins_encode %{ 11223 Label* L = $labl$$label; 11224 __ jcc((Assembler::Condition)($cop$$cmpcode), *L, false); // Always long jump 11225 %} 11226 ins_pipe(pipe_jcc); 11227 %} 11228 11229 // Jump Direct Conditional - Label defines a relative address from Jcc+1 11230 instruct jmpLoopEnd(cmpOp cop, rFlagsReg cr, label labl) 11231 %{ 11232 match(CountedLoopEnd cop cr); 11233 effect(USE labl); 11234 11235 ins_cost(300); 11236 format %{ "j$cop $labl\t# loop end" %} 11237 size(6); 11238 ins_encode %{ 11239 Label* L = $labl$$label; 11240 __ jcc((Assembler::Condition)($cop$$cmpcode), *L, false); // Always long jump 11241 %} 11242 ins_pipe(pipe_jcc); 11243 %} 11244 11245 // Jump Direct Conditional - Label defines a relative address from Jcc+1 11246 instruct jmpLoopEndU(cmpOpU cop, rFlagsRegU cmp, label labl) %{ 11247 match(CountedLoopEnd cop cmp); 11248 effect(USE labl); 11249 11250 ins_cost(300); 11251 format %{ "j$cop,u $labl\t# loop end" %} 11252 size(6); 11253 ins_encode %{ 11254 Label* L = $labl$$label; 11255 __ jcc((Assembler::Condition)($cop$$cmpcode), *L, false); // Always long jump 11256 %} 11257 ins_pipe(pipe_jcc); 11258 %} 11259 11260 instruct jmpLoopEndUCF(cmpOpUCF cop, rFlagsRegUCF cmp, label labl) %{ 11261 match(CountedLoopEnd cop cmp); 11262 effect(USE labl); 11263 11264 ins_cost(200); 11265 format %{ "j$cop,u $labl\t# loop end" %} 11266 size(6); 11267 ins_encode %{ 11268 Label* L = $labl$$label; 11269 __ jcc((Assembler::Condition)($cop$$cmpcode), *L, false); // Always long jump 11270 %} 11271 ins_pipe(pipe_jcc); 11272 %} 11273 11274 // Jump Direct Conditional - using unsigned comparison 11275 instruct jmpConU(cmpOpU cop, rFlagsRegU cmp, label labl) %{ 11276 match(If cop cmp); 11277 effect(USE labl); 11278 11279 ins_cost(300); 11280 format %{ "j$cop,u $labl" %} 11281 size(6); 11282 ins_encode %{ 11283 Label* L = $labl$$label; 11284 __ jcc((Assembler::Condition)($cop$$cmpcode), *L, false); // Always long jump 11285 %} 11286 ins_pipe(pipe_jcc); 11287 %} 11288 11289 instruct jmpConUCF(cmpOpUCF cop, rFlagsRegUCF cmp, label labl) %{ 11290 match(If cop cmp); 11291 effect(USE labl); 11292 11293 ins_cost(200); 11294 format %{ "j$cop,u $labl" %} 11295 size(6); 11296 ins_encode %{ 11297 Label* L = $labl$$label; 11298 __ jcc((Assembler::Condition)($cop$$cmpcode), *L, false); // Always long jump 11299 %} 11300 ins_pipe(pipe_jcc); 11301 %} 11302 11303 instruct jmpConUCF2(cmpOpUCF2 cop, rFlagsRegUCF cmp, label labl) %{ 11304 match(If cop cmp); 11305 effect(USE labl); 11306 11307 ins_cost(200); 11308 format %{ $$template 11309 if ($cop$$cmpcode == Assembler::notEqual) { 11310 $$emit$$"jp,u $labl\n\t" 11311 $$emit$$"j$cop,u $labl" 11312 } else { 11313 $$emit$$"jp,u done\n\t" 11314 $$emit$$"j$cop,u $labl\n\t" 11315 $$emit$$"done:" 11316 } 11317 %} 11318 ins_encode %{ 11319 Label* l = $labl$$label; 11320 if ($cop$$cmpcode == Assembler::notEqual) { 11321 __ jcc(Assembler::parity, *l, false); 11322 __ jcc(Assembler::notEqual, *l, false); 11323 } else if ($cop$$cmpcode == Assembler::equal) { 11324 Label done; 11325 __ jccb(Assembler::parity, done); 11326 __ jcc(Assembler::equal, *l, false); 11327 __ bind(done); 11328 } else { 11329 ShouldNotReachHere(); 11330 } 11331 %} 11332 ins_pipe(pipe_jcc); 11333 %} 11334 11335 // ============================================================================ 11336 // The 2nd slow-half of a subtype check. Scan the subklass's 2ndary 11337 // superklass array for an instance of the superklass. Set a hidden 11338 // internal cache on a hit (cache is checked with exposed code in 11339 // gen_subtype_check()). Return NZ for a miss or zero for a hit. The 11340 // encoding ALSO sets flags. 11341 11342 instruct partialSubtypeCheck(rdi_RegP result, 11343 rsi_RegP sub, rax_RegP super, rcx_RegI rcx, 11344 rFlagsReg cr) 11345 %{ 11346 match(Set result (PartialSubtypeCheck sub super)); 11347 effect(KILL rcx, KILL cr); 11348 11349 ins_cost(1100); // slightly larger than the next version 11350 format %{ "movq rdi, [$sub + in_bytes(Klass::secondary_supers_offset())]\n\t" 11351 "movl rcx, [rdi + Array<Klass*>::length_offset_in_bytes()]\t# length to scan\n\t" 11352 "addq rdi, Array<Klass*>::base_offset_in_bytes()\t# Skip to start of data; set NZ in case count is zero\n\t" 11353 "repne scasq\t# Scan *rdi++ for a match with rax while rcx--\n\t" 11354 "jne,s miss\t\t# Missed: rdi not-zero\n\t" 11355 "movq [$sub + in_bytes(Klass::secondary_super_cache_offset())], $super\t# Hit: update cache\n\t" 11356 "xorq $result, $result\t\t Hit: rdi zero\n\t" 11357 "miss:\t" %} 11358 11359 opcode(0x1); // Force a XOR of RDI 11360 ins_encode(enc_PartialSubtypeCheck()); 11361 ins_pipe(pipe_slow); 11362 %} 11363 11364 instruct partialSubtypeCheck_vs_Zero(rFlagsReg cr, 11365 rsi_RegP sub, rax_RegP super, rcx_RegI rcx, 11366 immP0 zero, 11367 rdi_RegP result) 11368 %{ 11369 match(Set cr (CmpP (PartialSubtypeCheck sub super) zero)); 11370 effect(KILL rcx, KILL result); 11371 11372 ins_cost(1000); 11373 format %{ "movq rdi, [$sub + in_bytes(Klass::secondary_supers_offset())]\n\t" 11374 "movl rcx, [rdi + Array<Klass*>::length_offset_in_bytes()]\t# length to scan\n\t" 11375 "addq rdi, Array<Klass*>::base_offset_in_bytes()\t# Skip to start of data; set NZ in case count is zero\n\t" 11376 "repne scasq\t# Scan *rdi++ for a match with rax while cx-- != 0\n\t" 11377 "jne,s miss\t\t# Missed: flags nz\n\t" 11378 "movq [$sub + in_bytes(Klass::secondary_super_cache_offset())], $super\t# Hit: update cache\n\t" 11379 "miss:\t" %} 11380 11381 opcode(0x0); // No need to XOR RDI 11382 ins_encode(enc_PartialSubtypeCheck()); 11383 ins_pipe(pipe_slow); 11384 %} 11385 11386 // ============================================================================ 11387 // Branch Instructions -- short offset versions 11388 // 11389 // These instructions are used to replace jumps of a long offset (the default 11390 // match) with jumps of a shorter offset. These instructions are all tagged 11391 // with the ins_short_branch attribute, which causes the ADLC to suppress the 11392 // match rules in general matching. Instead, the ADLC generates a conversion 11393 // method in the MachNode which can be used to do in-place replacement of the 11394 // long variant with the shorter variant. The compiler will determine if a 11395 // branch can be taken by the is_short_branch_offset() predicate in the machine 11396 // specific code section of the file. 11397 11398 // Jump Direct - Label defines a relative address from JMP+1 11399 instruct jmpDir_short(label labl) %{ 11400 match(Goto); 11401 effect(USE labl); 11402 11403 ins_cost(300); 11404 format %{ "jmp,s $labl" %} 11405 size(2); 11406 ins_encode %{ 11407 Label* L = $labl$$label; 11408 __ jmpb(*L); 11409 %} 11410 ins_pipe(pipe_jmp); 11411 ins_short_branch(1); 11412 %} 11413 11414 // Jump Direct Conditional - Label defines a relative address from Jcc+1 11415 instruct jmpCon_short(cmpOp cop, rFlagsReg cr, label labl) %{ 11416 match(If cop cr); 11417 effect(USE labl); 11418 11419 ins_cost(300); 11420 format %{ "j$cop,s $labl" %} 11421 size(2); 11422 ins_encode %{ 11423 Label* L = $labl$$label; 11424 __ jccb((Assembler::Condition)($cop$$cmpcode), *L); 11425 %} 11426 ins_pipe(pipe_jcc); 11427 ins_short_branch(1); 11428 %} 11429 11430 // Jump Direct Conditional - Label defines a relative address from Jcc+1 11431 instruct jmpLoopEnd_short(cmpOp cop, rFlagsReg cr, label labl) %{ 11432 match(CountedLoopEnd cop cr); 11433 effect(USE labl); 11434 11435 ins_cost(300); 11436 format %{ "j$cop,s $labl\t# loop end" %} 11437 size(2); 11438 ins_encode %{ 11439 Label* L = $labl$$label; 11440 __ jccb((Assembler::Condition)($cop$$cmpcode), *L); 11441 %} 11442 ins_pipe(pipe_jcc); 11443 ins_short_branch(1); 11444 %} 11445 11446 // Jump Direct Conditional - Label defines a relative address from Jcc+1 11447 instruct jmpLoopEndU_short(cmpOpU cop, rFlagsRegU cmp, label labl) %{ 11448 match(CountedLoopEnd cop cmp); 11449 effect(USE labl); 11450 11451 ins_cost(300); 11452 format %{ "j$cop,us $labl\t# loop end" %} 11453 size(2); 11454 ins_encode %{ 11455 Label* L = $labl$$label; 11456 __ jccb((Assembler::Condition)($cop$$cmpcode), *L); 11457 %} 11458 ins_pipe(pipe_jcc); 11459 ins_short_branch(1); 11460 %} 11461 11462 instruct jmpLoopEndUCF_short(cmpOpUCF cop, rFlagsRegUCF cmp, label labl) %{ 11463 match(CountedLoopEnd cop cmp); 11464 effect(USE labl); 11465 11466 ins_cost(300); 11467 format %{ "j$cop,us $labl\t# loop end" %} 11468 size(2); 11469 ins_encode %{ 11470 Label* L = $labl$$label; 11471 __ jccb((Assembler::Condition)($cop$$cmpcode), *L); 11472 %} 11473 ins_pipe(pipe_jcc); 11474 ins_short_branch(1); 11475 %} 11476 11477 // Jump Direct Conditional - using unsigned comparison 11478 instruct jmpConU_short(cmpOpU cop, rFlagsRegU cmp, label labl) %{ 11479 match(If cop cmp); 11480 effect(USE labl); 11481 11482 ins_cost(300); 11483 format %{ "j$cop,us $labl" %} 11484 size(2); 11485 ins_encode %{ 11486 Label* L = $labl$$label; 11487 __ jccb((Assembler::Condition)($cop$$cmpcode), *L); 11488 %} 11489 ins_pipe(pipe_jcc); 11490 ins_short_branch(1); 11491 %} 11492 11493 instruct jmpConUCF_short(cmpOpUCF cop, rFlagsRegUCF cmp, label labl) %{ 11494 match(If cop cmp); 11495 effect(USE labl); 11496 11497 ins_cost(300); 11498 format %{ "j$cop,us $labl" %} 11499 size(2); 11500 ins_encode %{ 11501 Label* L = $labl$$label; 11502 __ jccb((Assembler::Condition)($cop$$cmpcode), *L); 11503 %} 11504 ins_pipe(pipe_jcc); 11505 ins_short_branch(1); 11506 %} 11507 11508 instruct jmpConUCF2_short(cmpOpUCF2 cop, rFlagsRegUCF cmp, label labl) %{ 11509 match(If cop cmp); 11510 effect(USE labl); 11511 11512 ins_cost(300); 11513 format %{ $$template 11514 if ($cop$$cmpcode == Assembler::notEqual) { 11515 $$emit$$"jp,u,s $labl\n\t" 11516 $$emit$$"j$cop,u,s $labl" 11517 } else { 11518 $$emit$$"jp,u,s done\n\t" 11519 $$emit$$"j$cop,u,s $labl\n\t" 11520 $$emit$$"done:" 11521 } 11522 %} 11523 size(4); 11524 ins_encode %{ 11525 Label* l = $labl$$label; 11526 if ($cop$$cmpcode == Assembler::notEqual) { 11527 __ jccb(Assembler::parity, *l); 11528 __ jccb(Assembler::notEqual, *l); 11529 } else if ($cop$$cmpcode == Assembler::equal) { 11530 Label done; 11531 __ jccb(Assembler::parity, done); 11532 __ jccb(Assembler::equal, *l); 11533 __ bind(done); 11534 } else { 11535 ShouldNotReachHere(); 11536 } 11537 %} 11538 ins_pipe(pipe_jcc); 11539 ins_short_branch(1); 11540 %} 11541 11542 // ============================================================================ 11543 // inlined locking and unlocking 11544 11545 instruct cmpFastLockRTM(rFlagsReg cr, rRegP object, rbx_RegP box, rax_RegI tmp, rdx_RegI scr, rRegI cx1, rRegI cx2) %{ 11546 predicate(Compile::current()->use_rtm()); 11547 match(Set cr (FastLock object box)); 11548 effect(TEMP tmp, TEMP scr, TEMP cx1, TEMP cx2, USE_KILL box); 11549 ins_cost(300); 11550 format %{ "fastlock $object,$box\t! kills $box,$tmp,$scr,$cx1,$cx2" %} 11551 ins_encode %{ 11552 __ fast_lock($object$$Register, $box$$Register, $tmp$$Register, 11553 $scr$$Register, $cx1$$Register, $cx2$$Register, 11554 _counters, _rtm_counters, _stack_rtm_counters, 11555 ((Method*)(ra_->C->method()->constant_encoding()))->method_data(), 11556 true, ra_->C->profile_rtm()); 11557 %} 11558 ins_pipe(pipe_slow); 11559 %} 11560 11561 instruct cmpFastLock(rFlagsReg cr, rRegP object, rbx_RegP box, rax_RegI tmp, rRegP scr) %{ 11562 predicate(!Compile::current()->use_rtm()); 11563 match(Set cr (FastLock object box)); 11564 effect(TEMP tmp, TEMP scr, USE_KILL box); 11565 ins_cost(300); 11566 format %{ "fastlock $object,$box\t! kills $box,$tmp,$scr" %} 11567 ins_encode %{ 11568 __ fast_lock($object$$Register, $box$$Register, $tmp$$Register, 11569 $scr$$Register, noreg, noreg, _counters, NULL, NULL, NULL, false, false); 11570 %} 11571 ins_pipe(pipe_slow); 11572 %} 11573 11574 instruct cmpFastUnlock(rFlagsReg cr, rRegP object, rax_RegP box, rRegP tmp) %{ 11575 match(Set cr (FastUnlock object box)); 11576 effect(TEMP tmp, USE_KILL box); 11577 ins_cost(300); 11578 format %{ "fastunlock $object,$box\t! kills $box,$tmp" %} 11579 ins_encode %{ 11580 __ fast_unlock($object$$Register, $box$$Register, $tmp$$Register, ra_->C->use_rtm()); 11581 %} 11582 ins_pipe(pipe_slow); 11583 %} 11584 11585 11586 // ============================================================================ 11587 // Safepoint Instructions 11588 instruct safePoint_poll(rFlagsReg cr) 11589 %{ 11590 predicate(!Assembler::is_polling_page_far()); 11591 match(SafePoint); 11592 effect(KILL cr); 11593 11594 format %{ "testl rax, [rip + #offset_to_poll_page]\t" 11595 "# Safepoint: poll for GC" %} 11596 ins_cost(125); 11597 ins_encode %{ 11598 AddressLiteral addr(os::get_polling_page(), relocInfo::poll_type); 11599 __ testl(rax, addr); 11600 %} 11601 ins_pipe(ialu_reg_mem); 11602 %} 11603 11604 instruct safePoint_poll_far(rFlagsReg cr, rRegP poll) 11605 %{ 11606 predicate(Assembler::is_polling_page_far()); 11607 match(SafePoint poll); 11608 effect(KILL cr, USE poll); 11609 11610 format %{ "testl rax, [$poll]\t" 11611 "# Safepoint: poll for GC" %} 11612 ins_cost(125); 11613 ins_encode %{ 11614 __ relocate(relocInfo::poll_type); 11615 __ testl(rax, Address($poll$$Register, 0)); 11616 %} 11617 ins_pipe(ialu_reg_mem); 11618 %} 11619 11620 // ============================================================================ 11621 // Procedure Call/Return Instructions 11622 // Call Java Static Instruction 11623 // Note: If this code changes, the corresponding ret_addr_offset() and 11624 // compute_padding() functions will have to be adjusted. 11625 instruct CallStaticJavaDirect(method meth) %{ 11626 match(CallStaticJava); 11627 effect(USE meth); 11628 11629 ins_cost(300); 11630 format %{ "call,static " %} 11631 opcode(0xE8); /* E8 cd */ 11632 ins_encode(clear_avx, Java_Static_Call(meth), call_epilog); 11633 ins_pipe(pipe_slow); 11634 ins_alignment(4); 11635 %} 11636 11637 // Call Java Dynamic Instruction 11638 // Note: If this code changes, the corresponding ret_addr_offset() and 11639 // compute_padding() functions will have to be adjusted. 11640 instruct CallDynamicJavaDirect(method meth) 11641 %{ 11642 match(CallDynamicJava); 11643 effect(USE meth); 11644 11645 ins_cost(300); 11646 format %{ "movq rax, #Universe::non_oop_word()\n\t" 11647 "call,dynamic " %} 11648 ins_encode(clear_avx, Java_Dynamic_Call(meth), call_epilog); 11649 ins_pipe(pipe_slow); 11650 ins_alignment(4); 11651 %} 11652 11653 // Call Runtime Instruction 11654 instruct CallRuntimeDirect(method meth) 11655 %{ 11656 match(CallRuntime); 11657 effect(USE meth); 11658 11659 ins_cost(300); 11660 format %{ "call,runtime " %} 11661 ins_encode(clear_avx, Java_To_Runtime(meth)); 11662 ins_pipe(pipe_slow); 11663 %} 11664 11665 // Call runtime without safepoint 11666 instruct CallLeafDirect(method meth) 11667 %{ 11668 match(CallLeaf); 11669 effect(USE meth); 11670 11671 ins_cost(300); 11672 format %{ "call_leaf,runtime " %} 11673 ins_encode(clear_avx, Java_To_Runtime(meth)); 11674 ins_pipe(pipe_slow); 11675 %} 11676 11677 // Call runtime without safepoint 11678 instruct CallLeafNoFPDirect(method meth) 11679 %{ 11680 match(CallLeafNoFP); 11681 effect(USE meth); 11682 11683 ins_cost(300); 11684 format %{ "call_leaf_nofp,runtime " %} 11685 ins_encode(Java_To_Runtime(meth)); 11686 ins_pipe(pipe_slow); 11687 %} 11688 11689 // Return Instruction 11690 // Remove the return address & jump to it. 11691 // Notice: We always emit a nop after a ret to make sure there is room 11692 // for safepoint patching 11693 instruct Ret() 11694 %{ 11695 match(Return); 11696 11697 format %{ "ret" %} 11698 opcode(0xC3); 11699 ins_encode(OpcP); 11700 ins_pipe(pipe_jmp); 11701 %} 11702 11703 // Tail Call; Jump from runtime stub to Java code. 11704 // Also known as an 'interprocedural jump'. 11705 // Target of jump will eventually return to caller. 11706 // TailJump below removes the return address. 11707 instruct TailCalljmpInd(no_rbp_RegP jump_target, rbx_RegP method_oop) 11708 %{ 11709 match(TailCall jump_target method_oop); 11710 11711 ins_cost(300); 11712 format %{ "jmp $jump_target\t# rbx holds method oop" %} 11713 opcode(0xFF, 0x4); /* Opcode FF /4 */ 11714 ins_encode(REX_reg(jump_target), OpcP, reg_opc(jump_target)); 11715 ins_pipe(pipe_jmp); 11716 %} 11717 11718 // Tail Jump; remove the return address; jump to target. 11719 // TailCall above leaves the return address around. 11720 instruct tailjmpInd(no_rbp_RegP jump_target, rax_RegP ex_oop) 11721 %{ 11722 match(TailJump jump_target ex_oop); 11723 11724 ins_cost(300); 11725 format %{ "popq rdx\t# pop return address\n\t" 11726 "jmp $jump_target" %} 11727 opcode(0xFF, 0x4); /* Opcode FF /4 */ 11728 ins_encode(Opcode(0x5a), // popq rdx 11729 REX_reg(jump_target), OpcP, reg_opc(jump_target)); 11730 ins_pipe(pipe_jmp); 11731 %} 11732 11733 // Create exception oop: created by stack-crawling runtime code. 11734 // Created exception is now available to this handler, and is setup 11735 // just prior to jumping to this handler. No code emitted. 11736 instruct CreateException(rax_RegP ex_oop) 11737 %{ 11738 match(Set ex_oop (CreateEx)); 11739 11740 size(0); 11741 // use the following format syntax 11742 format %{ "# exception oop is in rax; no code emitted" %} 11743 ins_encode(); 11744 ins_pipe(empty); 11745 %} 11746 11747 // Rethrow exception: 11748 // The exception oop will come in the first argument position. 11749 // Then JUMP (not call) to the rethrow stub code. 11750 instruct RethrowException() 11751 %{ 11752 match(Rethrow); 11753 11754 // use the following format syntax 11755 format %{ "jmp rethrow_stub" %} 11756 ins_encode(enc_rethrow); 11757 ins_pipe(pipe_jmp); 11758 %} 11759 11760 11761 // ============================================================================ 11762 // This name is KNOWN by the ADLC and cannot be changed. 11763 // The ADLC forces a 'TypeRawPtr::BOTTOM' output type 11764 // for this guy. 11765 instruct tlsLoadP(r15_RegP dst) %{ 11766 match(Set dst (ThreadLocal)); 11767 effect(DEF dst); 11768 11769 size(0); 11770 format %{ "# TLS is in R15" %} 11771 ins_encode( /*empty encoding*/ ); 11772 ins_pipe(ialu_reg_reg); 11773 %} 11774 11775 11776 //----------PEEPHOLE RULES----------------------------------------------------- 11777 // These must follow all instruction definitions as they use the names 11778 // defined in the instructions definitions. 11779 // 11780 // peepmatch ( root_instr_name [preceding_instruction]* ); 11781 // 11782 // peepconstraint %{ 11783 // (instruction_number.operand_name relational_op instruction_number.operand_name 11784 // [, ...] ); 11785 // // instruction numbers are zero-based using left to right order in peepmatch 11786 // 11787 // peepreplace ( instr_name ( [instruction_number.operand_name]* ) ); 11788 // // provide an instruction_number.operand_name for each operand that appears 11789 // // in the replacement instruction's match rule 11790 // 11791 // ---------VM FLAGS--------------------------------------------------------- 11792 // 11793 // All peephole optimizations can be turned off using -XX:-OptoPeephole 11794 // 11795 // Each peephole rule is given an identifying number starting with zero and 11796 // increasing by one in the order seen by the parser. An individual peephole 11797 // can be enabled, and all others disabled, by using -XX:OptoPeepholeAt=# 11798 // on the command-line. 11799 // 11800 // ---------CURRENT LIMITATIONS---------------------------------------------- 11801 // 11802 // Only match adjacent instructions in same basic block 11803 // Only equality constraints 11804 // Only constraints between operands, not (0.dest_reg == RAX_enc) 11805 // Only one replacement instruction 11806 // 11807 // ---------EXAMPLE---------------------------------------------------------- 11808 // 11809 // // pertinent parts of existing instructions in architecture description 11810 // instruct movI(rRegI dst, rRegI src) 11811 // %{ 11812 // match(Set dst (CopyI src)); 11813 // %} 11814 // 11815 // instruct incI_rReg(rRegI dst, immI1 src, rFlagsReg cr) 11816 // %{ 11817 // match(Set dst (AddI dst src)); 11818 // effect(KILL cr); 11819 // %} 11820 // 11821 // // Change (inc mov) to lea 11822 // peephole %{ 11823 // // increment preceeded by register-register move 11824 // peepmatch ( incI_rReg movI ); 11825 // // require that the destination register of the increment 11826 // // match the destination register of the move 11827 // peepconstraint ( 0.dst == 1.dst ); 11828 // // construct a replacement instruction that sets 11829 // // the destination to ( move's source register + one ) 11830 // peepreplace ( leaI_rReg_immI( 0.dst 1.src 0.src ) ); 11831 // %} 11832 // 11833 11834 // Implementation no longer uses movX instructions since 11835 // machine-independent system no longer uses CopyX nodes. 11836 // 11837 // peephole 11838 // %{ 11839 // peepmatch (incI_rReg movI); 11840 // peepconstraint (0.dst == 1.dst); 11841 // peepreplace (leaI_rReg_immI(0.dst 1.src 0.src)); 11842 // %} 11843 11844 // peephole 11845 // %{ 11846 // peepmatch (decI_rReg movI); 11847 // peepconstraint (0.dst == 1.dst); 11848 // peepreplace (leaI_rReg_immI(0.dst 1.src 0.src)); 11849 // %} 11850 11851 // peephole 11852 // %{ 11853 // peepmatch (addI_rReg_imm movI); 11854 // peepconstraint (0.dst == 1.dst); 11855 // peepreplace (leaI_rReg_immI(0.dst 1.src 0.src)); 11856 // %} 11857 11858 // peephole 11859 // %{ 11860 // peepmatch (incL_rReg movL); 11861 // peepconstraint (0.dst == 1.dst); 11862 // peepreplace (leaL_rReg_immL(0.dst 1.src 0.src)); 11863 // %} 11864 11865 // peephole 11866 // %{ 11867 // peepmatch (decL_rReg movL); 11868 // peepconstraint (0.dst == 1.dst); 11869 // peepreplace (leaL_rReg_immL(0.dst 1.src 0.src)); 11870 // %} 11871 11872 // peephole 11873 // %{ 11874 // peepmatch (addL_rReg_imm movL); 11875 // peepconstraint (0.dst == 1.dst); 11876 // peepreplace (leaL_rReg_immL(0.dst 1.src 0.src)); 11877 // %} 11878 11879 // peephole 11880 // %{ 11881 // peepmatch (addP_rReg_imm movP); 11882 // peepconstraint (0.dst == 1.dst); 11883 // peepreplace (leaP_rReg_imm(0.dst 1.src 0.src)); 11884 // %} 11885 11886 // // Change load of spilled value to only a spill 11887 // instruct storeI(memory mem, rRegI src) 11888 // %{ 11889 // match(Set mem (StoreI mem src)); 11890 // %} 11891 // 11892 // instruct loadI(rRegI dst, memory mem) 11893 // %{ 11894 // match(Set dst (LoadI mem)); 11895 // %} 11896 // 11897 11898 peephole 11899 %{ 11900 peepmatch (loadI storeI); 11901 peepconstraint (1.src == 0.dst, 1.mem == 0.mem); 11902 peepreplace (storeI(1.mem 1.mem 1.src)); 11903 %} 11904 11905 peephole 11906 %{ 11907 peepmatch (loadL storeL); 11908 peepconstraint (1.src == 0.dst, 1.mem == 0.mem); 11909 peepreplace (storeL(1.mem 1.mem 1.src)); 11910 %} 11911 11912 //----------SMARTSPILL RULES--------------------------------------------------- 11913 // These must follow all instruction definitions as they use the names 11914 // defined in the instructions definitions.