1 // 2 // Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. 3 // Copyright 2012, 2014 SAP AG. All rights reserved. 4 // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 // 6 // This code is free software; you can redistribute it and/or modify it 7 // under the terms of the GNU General Public License version 2 only, as 8 // published by the Free Software Foundation. 9 // 10 // This code is distributed in the hope that it will be useful, but WITHOUT 11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 // version 2 for more details (a copy is included in the LICENSE file that 14 // accompanied this code). 15 // 16 // You should have received a copy of the GNU General Public License version 17 // 2 along with this work; if not, write to the Free Software Foundation, 18 // Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19 // 20 // Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 // or visit www.oracle.com if you need additional information or have any 22 // questions. 23 // 24 // 25 26 // 27 // PPC64 Architecture Description File 28 // 29 30 //----------REGISTER DEFINITION BLOCK------------------------------------------ 31 // This information is used by the matcher and the register allocator to 32 // describe individual registers and classes of registers within the target 33 // architecture. 34 register %{ 35 //----------Architecture Description Register Definitions---------------------- 36 // General Registers 37 // "reg_def" name (register save type, C convention save type, 38 // ideal register type, encoding); 39 // 40 // Register Save Types: 41 // 42 // NS = No-Save: The register allocator assumes that these registers 43 // can be used without saving upon entry to the method, & 44 // that they do not need to be saved at call sites. 45 // 46 // SOC = Save-On-Call: The register allocator assumes that these registers 47 // can be used without saving upon entry to the method, 48 // but that they must be saved at call sites. 49 // These are called "volatiles" on ppc. 50 // 51 // SOE = Save-On-Entry: The register allocator assumes that these registers 52 // must be saved before using them upon entry to the 53 // method, but they do not need to be saved at call 54 // sites. 55 // These are called "nonvolatiles" on ppc. 56 // 57 // AS = Always-Save: The register allocator assumes that these registers 58 // must be saved before using them upon entry to the 59 // method, & that they must be saved at call sites. 60 // 61 // Ideal Register Type is used to determine how to save & restore a 62 // register. Op_RegI will get spilled with LoadI/StoreI, Op_RegP will get 63 // spilled with LoadP/StoreP. If the register supports both, use Op_RegI. 64 // 65 // The encoding number is the actual bit-pattern placed into the opcodes. 66 // 67 // PPC64 register definitions, based on the 64-bit PowerPC ELF ABI 68 // Supplement Version 1.7 as of 2003-10-29. 69 // 70 // For each 64-bit register we must define two registers: the register 71 // itself, e.g. R3, and a corresponding virtual other (32-bit-)'half', 72 // e.g. R3_H, which is needed by the allocator, but is not used 73 // for stores, loads, etc. 74 75 // ---------------------------- 76 // Integer/Long Registers 77 // ---------------------------- 78 79 // PPC64 has 32 64-bit integer registers. 80 81 // types: v = volatile, nv = non-volatile, s = system 82 reg_def R0 ( SOC, SOC, Op_RegI, 0, R0->as_VMReg() ); // v used in prologs 83 reg_def R0_H ( SOC, SOC, Op_RegI, 99, R0->as_VMReg()->next() ); 84 reg_def R1 ( NS, NS, Op_RegI, 1, R1->as_VMReg() ); // s SP 85 reg_def R1_H ( NS, NS, Op_RegI, 99, R1->as_VMReg()->next() ); 86 reg_def R2 ( SOC, SOC, Op_RegI, 2, R2->as_VMReg() ); // v TOC 87 reg_def R2_H ( SOC, SOC, Op_RegI, 99, R2->as_VMReg()->next() ); 88 reg_def R3 ( SOC, SOC, Op_RegI, 3, R3->as_VMReg() ); // v iarg1 & iret 89 reg_def R3_H ( SOC, SOC, Op_RegI, 99, R3->as_VMReg()->next() ); 90 reg_def R4 ( SOC, SOC, Op_RegI, 4, R4->as_VMReg() ); // iarg2 91 reg_def R4_H ( SOC, SOC, Op_RegI, 99, R4->as_VMReg()->next() ); 92 reg_def R5 ( SOC, SOC, Op_RegI, 5, R5->as_VMReg() ); // v iarg3 93 reg_def R5_H ( SOC, SOC, Op_RegI, 99, R5->as_VMReg()->next() ); 94 reg_def R6 ( SOC, SOC, Op_RegI, 6, R6->as_VMReg() ); // v iarg4 95 reg_def R6_H ( SOC, SOC, Op_RegI, 99, R6->as_VMReg()->next() ); 96 reg_def R7 ( SOC, SOC, Op_RegI, 7, R7->as_VMReg() ); // v iarg5 97 reg_def R7_H ( SOC, SOC, Op_RegI, 99, R7->as_VMReg()->next() ); 98 reg_def R8 ( SOC, SOC, Op_RegI, 8, R8->as_VMReg() ); // v iarg6 99 reg_def R8_H ( SOC, SOC, Op_RegI, 99, R8->as_VMReg()->next() ); 100 reg_def R9 ( SOC, SOC, Op_RegI, 9, R9->as_VMReg() ); // v iarg7 101 reg_def R9_H ( SOC, SOC, Op_RegI, 99, R9->as_VMReg()->next() ); 102 reg_def R10 ( SOC, SOC, Op_RegI, 10, R10->as_VMReg() ); // v iarg8 103 reg_def R10_H( SOC, SOC, Op_RegI, 99, R10->as_VMReg()->next()); 104 reg_def R11 ( SOC, SOC, Op_RegI, 11, R11->as_VMReg() ); // v ENV / scratch 105 reg_def R11_H( SOC, SOC, Op_RegI, 99, R11->as_VMReg()->next()); 106 reg_def R12 ( SOC, SOC, Op_RegI, 12, R12->as_VMReg() ); // v scratch 107 reg_def R12_H( SOC, SOC, Op_RegI, 99, R12->as_VMReg()->next()); 108 reg_def R13 ( NS, NS, Op_RegI, 13, R13->as_VMReg() ); // s system thread id 109 reg_def R13_H( NS, NS, Op_RegI, 99, R13->as_VMReg()->next()); 110 reg_def R14 ( SOC, SOE, Op_RegI, 14, R14->as_VMReg() ); // nv 111 reg_def R14_H( SOC, SOE, Op_RegI, 99, R14->as_VMReg()->next()); 112 reg_def R15 ( SOC, SOE, Op_RegI, 15, R15->as_VMReg() ); // nv 113 reg_def R15_H( SOC, SOE, Op_RegI, 99, R15->as_VMReg()->next()); 114 reg_def R16 ( SOC, SOE, Op_RegI, 16, R16->as_VMReg() ); // nv 115 reg_def R16_H( SOC, SOE, Op_RegI, 99, R16->as_VMReg()->next()); 116 reg_def R17 ( SOC, SOE, Op_RegI, 17, R17->as_VMReg() ); // nv 117 reg_def R17_H( SOC, SOE, Op_RegI, 99, R17->as_VMReg()->next()); 118 reg_def R18 ( SOC, SOE, Op_RegI, 18, R18->as_VMReg() ); // nv 119 reg_def R18_H( SOC, SOE, Op_RegI, 99, R18->as_VMReg()->next()); 120 reg_def R19 ( SOC, SOE, Op_RegI, 19, R19->as_VMReg() ); // nv 121 reg_def R19_H( SOC, SOE, Op_RegI, 99, R19->as_VMReg()->next()); 122 reg_def R20 ( SOC, SOE, Op_RegI, 20, R20->as_VMReg() ); // nv 123 reg_def R20_H( SOC, SOE, Op_RegI, 99, R20->as_VMReg()->next()); 124 reg_def R21 ( SOC, SOE, Op_RegI, 21, R21->as_VMReg() ); // nv 125 reg_def R21_H( SOC, SOE, Op_RegI, 99, R21->as_VMReg()->next()); 126 reg_def R22 ( SOC, SOE, Op_RegI, 22, R22->as_VMReg() ); // nv 127 reg_def R22_H( SOC, SOE, Op_RegI, 99, R22->as_VMReg()->next()); 128 reg_def R23 ( SOC, SOE, Op_RegI, 23, R23->as_VMReg() ); // nv 129 reg_def R23_H( SOC, SOE, Op_RegI, 99, R23->as_VMReg()->next()); 130 reg_def R24 ( SOC, SOE, Op_RegI, 24, R24->as_VMReg() ); // nv 131 reg_def R24_H( SOC, SOE, Op_RegI, 99, R24->as_VMReg()->next()); 132 reg_def R25 ( SOC, SOE, Op_RegI, 25, R25->as_VMReg() ); // nv 133 reg_def R25_H( SOC, SOE, Op_RegI, 99, R25->as_VMReg()->next()); 134 reg_def R26 ( SOC, SOE, Op_RegI, 26, R26->as_VMReg() ); // nv 135 reg_def R26_H( SOC, SOE, Op_RegI, 99, R26->as_VMReg()->next()); 136 reg_def R27 ( SOC, SOE, Op_RegI, 27, R27->as_VMReg() ); // nv 137 reg_def R27_H( SOC, SOE, Op_RegI, 99, R27->as_VMReg()->next()); 138 reg_def R28 ( SOC, SOE, Op_RegI, 28, R28->as_VMReg() ); // nv 139 reg_def R28_H( SOC, SOE, Op_RegI, 99, R28->as_VMReg()->next()); 140 reg_def R29 ( SOC, SOE, Op_RegI, 29, R29->as_VMReg() ); // nv 141 reg_def R29_H( SOC, SOE, Op_RegI, 99, R29->as_VMReg()->next()); 142 reg_def R30 ( SOC, SOE, Op_RegI, 30, R30->as_VMReg() ); // nv 143 reg_def R30_H( SOC, SOE, Op_RegI, 99, R30->as_VMReg()->next()); 144 reg_def R31 ( SOC, SOE, Op_RegI, 31, R31->as_VMReg() ); // nv 145 reg_def R31_H( SOC, SOE, Op_RegI, 99, R31->as_VMReg()->next()); 146 147 148 // ---------------------------- 149 // Float/Double Registers 150 // ---------------------------- 151 152 // Double Registers 153 // The rules of ADL require that double registers be defined in pairs. 154 // Each pair must be two 32-bit values, but not necessarily a pair of 155 // single float registers. In each pair, ADLC-assigned register numbers 156 // must be adjacent, with the lower number even. Finally, when the 157 // CPU stores such a register pair to memory, the word associated with 158 // the lower ADLC-assigned number must be stored to the lower address. 159 160 // PPC64 has 32 64-bit floating-point registers. Each can store a single 161 // or double precision floating-point value. 162 163 // types: v = volatile, nv = non-volatile, s = system 164 reg_def F0 ( SOC, SOC, Op_RegF, 0, F0->as_VMReg() ); // v scratch 165 reg_def F0_H ( SOC, SOC, Op_RegF, 99, F0->as_VMReg()->next() ); 166 reg_def F1 ( SOC, SOC, Op_RegF, 1, F1->as_VMReg() ); // v farg1 & fret 167 reg_def F1_H ( SOC, SOC, Op_RegF, 99, F1->as_VMReg()->next() ); 168 reg_def F2 ( SOC, SOC, Op_RegF, 2, F2->as_VMReg() ); // v farg2 169 reg_def F2_H ( SOC, SOC, Op_RegF, 99, F2->as_VMReg()->next() ); 170 reg_def F3 ( SOC, SOC, Op_RegF, 3, F3->as_VMReg() ); // v farg3 171 reg_def F3_H ( SOC, SOC, Op_RegF, 99, F3->as_VMReg()->next() ); 172 reg_def F4 ( SOC, SOC, Op_RegF, 4, F4->as_VMReg() ); // v farg4 173 reg_def F4_H ( SOC, SOC, Op_RegF, 99, F4->as_VMReg()->next() ); 174 reg_def F5 ( SOC, SOC, Op_RegF, 5, F5->as_VMReg() ); // v farg5 175 reg_def F5_H ( SOC, SOC, Op_RegF, 99, F5->as_VMReg()->next() ); 176 reg_def F6 ( SOC, SOC, Op_RegF, 6, F6->as_VMReg() ); // v farg6 177 reg_def F6_H ( SOC, SOC, Op_RegF, 99, F6->as_VMReg()->next() ); 178 reg_def F7 ( SOC, SOC, Op_RegF, 7, F7->as_VMReg() ); // v farg7 179 reg_def F7_H ( SOC, SOC, Op_RegF, 99, F7->as_VMReg()->next() ); 180 reg_def F8 ( SOC, SOC, Op_RegF, 8, F8->as_VMReg() ); // v farg8 181 reg_def F8_H ( SOC, SOC, Op_RegF, 99, F8->as_VMReg()->next() ); 182 reg_def F9 ( SOC, SOC, Op_RegF, 9, F9->as_VMReg() ); // v farg9 183 reg_def F9_H ( SOC, SOC, Op_RegF, 99, F9->as_VMReg()->next() ); 184 reg_def F10 ( SOC, SOC, Op_RegF, 10, F10->as_VMReg() ); // v farg10 185 reg_def F10_H( SOC, SOC, Op_RegF, 99, F10->as_VMReg()->next()); 186 reg_def F11 ( SOC, SOC, Op_RegF, 11, F11->as_VMReg() ); // v farg11 187 reg_def F11_H( SOC, SOC, Op_RegF, 99, F11->as_VMReg()->next()); 188 reg_def F12 ( SOC, SOC, Op_RegF, 12, F12->as_VMReg() ); // v farg12 189 reg_def F12_H( SOC, SOC, Op_RegF, 99, F12->as_VMReg()->next()); 190 reg_def F13 ( SOC, SOC, Op_RegF, 13, F13->as_VMReg() ); // v farg13 191 reg_def F13_H( SOC, SOC, Op_RegF, 99, F13->as_VMReg()->next()); 192 reg_def F14 ( SOC, SOE, Op_RegF, 14, F14->as_VMReg() ); // nv 193 reg_def F14_H( SOC, SOE, Op_RegF, 99, F14->as_VMReg()->next()); 194 reg_def F15 ( SOC, SOE, Op_RegF, 15, F15->as_VMReg() ); // nv 195 reg_def F15_H( SOC, SOE, Op_RegF, 99, F15->as_VMReg()->next()); 196 reg_def F16 ( SOC, SOE, Op_RegF, 16, F16->as_VMReg() ); // nv 197 reg_def F16_H( SOC, SOE, Op_RegF, 99, F16->as_VMReg()->next()); 198 reg_def F17 ( SOC, SOE, Op_RegF, 17, F17->as_VMReg() ); // nv 199 reg_def F17_H( SOC, SOE, Op_RegF, 99, F17->as_VMReg()->next()); 200 reg_def F18 ( SOC, SOE, Op_RegF, 18, F18->as_VMReg() ); // nv 201 reg_def F18_H( SOC, SOE, Op_RegF, 99, F18->as_VMReg()->next()); 202 reg_def F19 ( SOC, SOE, Op_RegF, 19, F19->as_VMReg() ); // nv 203 reg_def F19_H( SOC, SOE, Op_RegF, 99, F19->as_VMReg()->next()); 204 reg_def F20 ( SOC, SOE, Op_RegF, 20, F20->as_VMReg() ); // nv 205 reg_def F20_H( SOC, SOE, Op_RegF, 99, F20->as_VMReg()->next()); 206 reg_def F21 ( SOC, SOE, Op_RegF, 21, F21->as_VMReg() ); // nv 207 reg_def F21_H( SOC, SOE, Op_RegF, 99, F21->as_VMReg()->next()); 208 reg_def F22 ( SOC, SOE, Op_RegF, 22, F22->as_VMReg() ); // nv 209 reg_def F22_H( SOC, SOE, Op_RegF, 99, F22->as_VMReg()->next()); 210 reg_def F23 ( SOC, SOE, Op_RegF, 23, F23->as_VMReg() ); // nv 211 reg_def F23_H( SOC, SOE, Op_RegF, 99, F23->as_VMReg()->next()); 212 reg_def F24 ( SOC, SOE, Op_RegF, 24, F24->as_VMReg() ); // nv 213 reg_def F24_H( SOC, SOE, Op_RegF, 99, F24->as_VMReg()->next()); 214 reg_def F25 ( SOC, SOE, Op_RegF, 25, F25->as_VMReg() ); // nv 215 reg_def F25_H( SOC, SOE, Op_RegF, 99, F25->as_VMReg()->next()); 216 reg_def F26 ( SOC, SOE, Op_RegF, 26, F26->as_VMReg() ); // nv 217 reg_def F26_H( SOC, SOE, Op_RegF, 99, F26->as_VMReg()->next()); 218 reg_def F27 ( SOC, SOE, Op_RegF, 27, F27->as_VMReg() ); // nv 219 reg_def F27_H( SOC, SOE, Op_RegF, 99, F27->as_VMReg()->next()); 220 reg_def F28 ( SOC, SOE, Op_RegF, 28, F28->as_VMReg() ); // nv 221 reg_def F28_H( SOC, SOE, Op_RegF, 99, F28->as_VMReg()->next()); 222 reg_def F29 ( SOC, SOE, Op_RegF, 29, F29->as_VMReg() ); // nv 223 reg_def F29_H( SOC, SOE, Op_RegF, 99, F29->as_VMReg()->next()); 224 reg_def F30 ( SOC, SOE, Op_RegF, 30, F30->as_VMReg() ); // nv 225 reg_def F30_H( SOC, SOE, Op_RegF, 99, F30->as_VMReg()->next()); 226 reg_def F31 ( SOC, SOE, Op_RegF, 31, F31->as_VMReg() ); // nv 227 reg_def F31_H( SOC, SOE, Op_RegF, 99, F31->as_VMReg()->next()); 228 229 // ---------------------------- 230 // Special Registers 231 // ---------------------------- 232 233 // Condition Codes Flag Registers 234 235 // PPC64 has 8 condition code "registers" which are all contained 236 // in the CR register. 237 238 // types: v = volatile, nv = non-volatile, s = system 239 reg_def CCR0(SOC, SOC, Op_RegFlags, 0, CCR0->as_VMReg()); // v 240 reg_def CCR1(SOC, SOC, Op_RegFlags, 1, CCR1->as_VMReg()); // v 241 reg_def CCR2(SOC, SOC, Op_RegFlags, 2, CCR2->as_VMReg()); // nv 242 reg_def CCR3(SOC, SOC, Op_RegFlags, 3, CCR3->as_VMReg()); // nv 243 reg_def CCR4(SOC, SOC, Op_RegFlags, 4, CCR4->as_VMReg()); // nv 244 reg_def CCR5(SOC, SOC, Op_RegFlags, 5, CCR5->as_VMReg()); // v 245 reg_def CCR6(SOC, SOC, Op_RegFlags, 6, CCR6->as_VMReg()); // v 246 reg_def CCR7(SOC, SOC, Op_RegFlags, 7, CCR7->as_VMReg()); // v 247 248 // Special registers of PPC64 249 250 reg_def SR_XER( SOC, SOC, Op_RegP, 0, SR_XER->as_VMReg()); // v 251 reg_def SR_LR( SOC, SOC, Op_RegP, 1, SR_LR->as_VMReg()); // v 252 reg_def SR_CTR( SOC, SOC, Op_RegP, 2, SR_CTR->as_VMReg()); // v 253 reg_def SR_VRSAVE( SOC, SOC, Op_RegP, 3, SR_VRSAVE->as_VMReg()); // v 254 reg_def SR_SPEFSCR(SOC, SOC, Op_RegP, 4, SR_SPEFSCR->as_VMReg()); // v 255 reg_def SR_PPR( SOC, SOC, Op_RegP, 5, SR_PPR->as_VMReg()); // v 256 257 258 // ---------------------------- 259 // Specify priority of register selection within phases of register 260 // allocation. Highest priority is first. A useful heuristic is to 261 // give registers a low priority when they are required by machine 262 // instructions, like EAX and EDX on I486, and choose no-save registers 263 // before save-on-call, & save-on-call before save-on-entry. Registers 264 // which participate in fixed calling sequences should come last. 265 // Registers which are used as pairs must fall on an even boundary. 266 267 // It's worth about 1% on SPEC geomean to get this right. 268 269 // Chunk0, chunk1, and chunk2 form the MachRegisterNumbers enumeration 270 // in adGlobals_ppc64.hpp which defines the <register>_num values, e.g. 271 // R3_num. Therefore, R3_num may not be (and in reality is not) 272 // the same as R3->encoding()! Furthermore, we cannot make any 273 // assumptions on ordering, e.g. R3_num may be less than R2_num. 274 // Additionally, the function 275 // static enum RC rc_class(OptoReg::Name reg ) 276 // maps a given <register>_num value to its chunk type (except for flags) 277 // and its current implementation relies on chunk0 and chunk1 having a 278 // size of 64 each. 279 280 // If you change this allocation class, please have a look at the 281 // default values for the parameters RoundRobinIntegerRegIntervalStart 282 // and RoundRobinFloatRegIntervalStart 283 284 alloc_class chunk0 ( 285 // Chunk0 contains *all* 64 integer registers halves. 286 287 // "non-volatile" registers 288 R14, R14_H, 289 R15, R15_H, 290 R17, R17_H, 291 R18, R18_H, 292 R19, R19_H, 293 R20, R20_H, 294 R21, R21_H, 295 R22, R22_H, 296 R23, R23_H, 297 R24, R24_H, 298 R25, R25_H, 299 R26, R26_H, 300 R27, R27_H, 301 R28, R28_H, 302 R29, R29_H, 303 R30, R30_H, 304 R31, R31_H, 305 306 // scratch/special registers 307 R11, R11_H, 308 R12, R12_H, 309 310 // argument registers 311 R10, R10_H, 312 R9, R9_H, 313 R8, R8_H, 314 R7, R7_H, 315 R6, R6_H, 316 R5, R5_H, 317 R4, R4_H, 318 R3, R3_H, 319 320 // special registers, not available for allocation 321 R16, R16_H, // R16_thread 322 R13, R13_H, // system thread id 323 R2, R2_H, // may be used for TOC 324 R1, R1_H, // SP 325 R0, R0_H // R0 (scratch) 326 ); 327 328 // If you change this allocation class, please have a look at the 329 // default values for the parameters RoundRobinIntegerRegIntervalStart 330 // and RoundRobinFloatRegIntervalStart 331 332 alloc_class chunk1 ( 333 // Chunk1 contains *all* 64 floating-point registers halves. 334 335 // scratch register 336 F0, F0_H, 337 338 // argument registers 339 F13, F13_H, 340 F12, F12_H, 341 F11, F11_H, 342 F10, F10_H, 343 F9, F9_H, 344 F8, F8_H, 345 F7, F7_H, 346 F6, F6_H, 347 F5, F5_H, 348 F4, F4_H, 349 F3, F3_H, 350 F2, F2_H, 351 F1, F1_H, 352 353 // non-volatile registers 354 F14, F14_H, 355 F15, F15_H, 356 F16, F16_H, 357 F17, F17_H, 358 F18, F18_H, 359 F19, F19_H, 360 F20, F20_H, 361 F21, F21_H, 362 F22, F22_H, 363 F23, F23_H, 364 F24, F24_H, 365 F25, F25_H, 366 F26, F26_H, 367 F27, F27_H, 368 F28, F28_H, 369 F29, F29_H, 370 F30, F30_H, 371 F31, F31_H 372 ); 373 374 alloc_class chunk2 ( 375 // Chunk2 contains *all* 8 condition code registers. 376 377 CCR0, 378 CCR1, 379 CCR2, 380 CCR3, 381 CCR4, 382 CCR5, 383 CCR6, 384 CCR7 385 ); 386 387 alloc_class chunk3 ( 388 // special registers 389 // These registers are not allocated, but used for nodes generated by postalloc expand. 390 SR_XER, 391 SR_LR, 392 SR_CTR, 393 SR_VRSAVE, 394 SR_SPEFSCR, 395 SR_PPR 396 ); 397 398 //-------Architecture Description Register Classes----------------------- 399 400 // Several register classes are automatically defined based upon 401 // information in this architecture description. 402 403 // 1) reg_class inline_cache_reg ( as defined in frame section ) 404 // 2) reg_class compiler_method_oop_reg ( as defined in frame section ) 405 // 2) reg_class interpreter_method_oop_reg ( as defined in frame section ) 406 // 3) reg_class stack_slots( /* one chunk of stack-based "registers" */ ) 407 // 408 409 // ---------------------------- 410 // 32 Bit Register Classes 411 // ---------------------------- 412 413 // We specify registers twice, once as read/write, and once read-only. 414 // We use the read-only registers for source operands. With this, we 415 // can include preset read only registers in this class, as a hard-coded 416 // '0'-register. (We used to simulate this on ppc.) 417 418 // 32 bit registers that can be read and written i.e. these registers 419 // can be dest (or src) of normal instructions. 420 reg_class bits32_reg_rw( 421 /*R0*/ // R0 422 /*R1*/ // SP 423 R2, // TOC 424 R3, 425 R4, 426 R5, 427 R6, 428 R7, 429 R8, 430 R9, 431 R10, 432 R11, 433 R12, 434 /*R13*/ // system thread id 435 R14, 436 R15, 437 /*R16*/ // R16_thread 438 R17, 439 R18, 440 R19, 441 R20, 442 R21, 443 R22, 444 R23, 445 R24, 446 R25, 447 R26, 448 R27, 449 R28, 450 /*R29*/ // global TOC 451 /*R30*/ // Narrow Oop Base 452 R31 453 ); 454 455 // 32 bit registers that can only be read i.e. these registers can 456 // only be src of all instructions. 457 reg_class bits32_reg_ro( 458 /*R0*/ // R0 459 /*R1*/ // SP 460 R2 // TOC 461 R3, 462 R4, 463 R5, 464 R6, 465 R7, 466 R8, 467 R9, 468 R10, 469 R11, 470 R12, 471 /*R13*/ // system thread id 472 R14, 473 R15, 474 /*R16*/ // R16_thread 475 R17, 476 R18, 477 R19, 478 R20, 479 R21, 480 R22, 481 R23, 482 R24, 483 R25, 484 R26, 485 R27, 486 R28, 487 /*R29*/ 488 /*R30*/ // Narrow Oop Base 489 R31 490 ); 491 492 // Complement-required-in-pipeline operands for narrow oops. 493 reg_class bits32_reg_ro_not_complement ( 494 /*R0*/ // R0 495 R1, // SP 496 R2, // TOC 497 R3, 498 R4, 499 R5, 500 R6, 501 R7, 502 R8, 503 R9, 504 R10, 505 R11, 506 R12, 507 /*R13,*/ // system thread id 508 R14, 509 R15, 510 R16, // R16_thread 511 R17, 512 R18, 513 R19, 514 R20, 515 R21, 516 R22, 517 /*R23, 518 R24, 519 R25, 520 R26, 521 R27, 522 R28,*/ 523 /*R29,*/ // TODO: let allocator handle TOC!! 524 /*R30,*/ 525 R31 526 ); 527 528 // Complement-required-in-pipeline operands for narrow oops. 529 // See 64-bit declaration. 530 reg_class bits32_reg_ro_complement ( 531 R23, 532 R24, 533 R25, 534 R26, 535 R27, 536 R28 537 ); 538 539 reg_class rscratch1_bits32_reg(R11); 540 reg_class rscratch2_bits32_reg(R12); 541 reg_class rarg1_bits32_reg(R3); 542 reg_class rarg2_bits32_reg(R4); 543 reg_class rarg3_bits32_reg(R5); 544 reg_class rarg4_bits32_reg(R6); 545 546 // ---------------------------- 547 // 64 Bit Register Classes 548 // ---------------------------- 549 // 64-bit build means 64-bit pointers means hi/lo pairs 550 551 reg_class rscratch1_bits64_reg(R11_H, R11); 552 reg_class rscratch2_bits64_reg(R12_H, R12); 553 reg_class rarg1_bits64_reg(R3_H, R3); 554 reg_class rarg2_bits64_reg(R4_H, R4); 555 reg_class rarg3_bits64_reg(R5_H, R5); 556 reg_class rarg4_bits64_reg(R6_H, R6); 557 // Thread register, 'written' by tlsLoadP, see there. 558 reg_class thread_bits64_reg(R16_H, R16); 559 560 reg_class r19_bits64_reg(R19_H, R19); 561 562 // 64 bit registers that can be read and written i.e. these registers 563 // can be dest (or src) of normal instructions. 564 reg_class bits64_reg_rw( 565 /*R0_H, R0*/ // R0 566 /*R1_H, R1*/ // SP 567 R2_H, R2, // TOC 568 R3_H, R3, 569 R4_H, R4, 570 R5_H, R5, 571 R6_H, R6, 572 R7_H, R7, 573 R8_H, R8, 574 R9_H, R9, 575 R10_H, R10, 576 R11_H, R11, 577 R12_H, R12, 578 /*R13_H, R13*/ // system thread id 579 R14_H, R14, 580 R15_H, R15, 581 /*R16_H, R16*/ // R16_thread 582 R17_H, R17, 583 R18_H, R18, 584 R19_H, R19, 585 R20_H, R20, 586 R21_H, R21, 587 R22_H, R22, 588 R23_H, R23, 589 R24_H, R24, 590 R25_H, R25, 591 R26_H, R26, 592 R27_H, R27, 593 R28_H, R28, 594 /*R29_H, R29*/ 595 /*R30_H, R30*/ 596 R31_H, R31 597 ); 598 599 // 64 bit registers used excluding r2, r11 and r12 600 // Used to hold the TOC to avoid collisions with expanded LeafCall which uses 601 // r2, r11 and r12 internally. 602 reg_class bits64_reg_leaf_call( 603 /*R0_H, R0*/ // R0 604 /*R1_H, R1*/ // SP 605 /*R2_H, R2*/ // TOC 606 R3_H, R3, 607 R4_H, R4, 608 R5_H, R5, 609 R6_H, R6, 610 R7_H, R7, 611 R8_H, R8, 612 R9_H, R9, 613 R10_H, R10, 614 /*R11_H, R11*/ 615 /*R12_H, R12*/ 616 /*R13_H, R13*/ // system thread id 617 R14_H, R14, 618 R15_H, R15, 619 /*R16_H, R16*/ // R16_thread 620 R17_H, R17, 621 R18_H, R18, 622 R19_H, R19, 623 R20_H, R20, 624 R21_H, R21, 625 R22_H, R22, 626 R23_H, R23, 627 R24_H, R24, 628 R25_H, R25, 629 R26_H, R26, 630 R27_H, R27, 631 R28_H, R28, 632 /*R29_H, R29*/ 633 /*R30_H, R30*/ 634 R31_H, R31 635 ); 636 637 // Used to hold the TOC to avoid collisions with expanded DynamicCall 638 // which uses r19 as inline cache internally and expanded LeafCall which uses 639 // r2, r11 and r12 internally. 640 reg_class bits64_constant_table_base( 641 /*R0_H, R0*/ // R0 642 /*R1_H, R1*/ // SP 643 /*R2_H, R2*/ // TOC 644 R3_H, R3, 645 R4_H, R4, 646 R5_H, R5, 647 R6_H, R6, 648 R7_H, R7, 649 R8_H, R8, 650 R9_H, R9, 651 R10_H, R10, 652 /*R11_H, R11*/ 653 /*R12_H, R12*/ 654 /*R13_H, R13*/ // system thread id 655 R14_H, R14, 656 R15_H, R15, 657 /*R16_H, R16*/ // R16_thread 658 R17_H, R17, 659 R18_H, R18, 660 /*R19_H, R19*/ 661 R20_H, R20, 662 R21_H, R21, 663 R22_H, R22, 664 R23_H, R23, 665 R24_H, R24, 666 R25_H, R25, 667 R26_H, R26, 668 R27_H, R27, 669 R28_H, R28, 670 /*R29_H, R29*/ 671 /*R30_H, R30*/ 672 R31_H, R31 673 ); 674 675 // 64 bit registers that can only be read i.e. these registers can 676 // only be src of all instructions. 677 reg_class bits64_reg_ro( 678 /*R0_H, R0*/ // R0 679 R1_H, R1, 680 R2_H, R2, // TOC 681 R3_H, R3, 682 R4_H, R4, 683 R5_H, R5, 684 R6_H, R6, 685 R7_H, R7, 686 R8_H, R8, 687 R9_H, R9, 688 R10_H, R10, 689 R11_H, R11, 690 R12_H, R12, 691 /*R13_H, R13*/ // system thread id 692 R14_H, R14, 693 R15_H, R15, 694 R16_H, R16, // R16_thread 695 R17_H, R17, 696 R18_H, R18, 697 R19_H, R19, 698 R20_H, R20, 699 R21_H, R21, 700 R22_H, R22, 701 R23_H, R23, 702 R24_H, R24, 703 R25_H, R25, 704 R26_H, R26, 705 R27_H, R27, 706 R28_H, R28, 707 /*R29_H, R29*/ // TODO: let allocator handle TOC!! 708 /*R30_H, R30,*/ 709 R31_H, R31 710 ); 711 712 // Complement-required-in-pipeline operands. 713 reg_class bits64_reg_ro_not_complement ( 714 /*R0_H, R0*/ // R0 715 R1_H, R1, // SP 716 R2_H, R2, // TOC 717 R3_H, R3, 718 R4_H, R4, 719 R5_H, R5, 720 R6_H, R6, 721 R7_H, R7, 722 R8_H, R8, 723 R9_H, R9, 724 R10_H, R10, 725 R11_H, R11, 726 R12_H, R12, 727 /*R13_H, R13*/ // system thread id 728 R14_H, R14, 729 R15_H, R15, 730 R16_H, R16, // R16_thread 731 R17_H, R17, 732 R18_H, R18, 733 R19_H, R19, 734 R20_H, R20, 735 R21_H, R21, 736 R22_H, R22, 737 /*R23_H, R23, 738 R24_H, R24, 739 R25_H, R25, 740 R26_H, R26, 741 R27_H, R27, 742 R28_H, R28,*/ 743 /*R29_H, R29*/ // TODO: let allocator handle TOC!! 744 /*R30_H, R30,*/ 745 R31_H, R31 746 ); 747 748 // Complement-required-in-pipeline operands. 749 // This register mask is used for the trap instructions that implement 750 // the null checks on AIX. The trap instruction first computes the 751 // complement of the value it shall trap on. Because of this, the 752 // instruction can not be scheduled in the same cycle as an other 753 // instruction reading the normal value of the same register. So we 754 // force the value to check into 'bits64_reg_ro_not_complement' 755 // and then copy it to 'bits64_reg_ro_complement' for the trap. 756 reg_class bits64_reg_ro_complement ( 757 R23_H, R23, 758 R24_H, R24, 759 R25_H, R25, 760 R26_H, R26, 761 R27_H, R27, 762 R28_H, R28 763 ); 764 765 766 // ---------------------------- 767 // Special Class for Condition Code Flags Register 768 769 reg_class int_flags( 770 /*CCR0*/ // scratch 771 /*CCR1*/ // scratch 772 /*CCR2*/ // nv! 773 /*CCR3*/ // nv! 774 /*CCR4*/ // nv! 775 CCR5, 776 CCR6, 777 CCR7 778 ); 779 780 reg_class int_flags_CR0(CCR0); 781 reg_class int_flags_CR1(CCR1); 782 reg_class int_flags_CR6(CCR6); 783 reg_class ctr_reg(SR_CTR); 784 785 // ---------------------------- 786 // Float Register Classes 787 // ---------------------------- 788 789 reg_class flt_reg( 790 /*F0*/ // scratch 791 F1, 792 F2, 793 F3, 794 F4, 795 F5, 796 F6, 797 F7, 798 F8, 799 F9, 800 F10, 801 F11, 802 F12, 803 F13, 804 F14, // nv! 805 F15, // nv! 806 F16, // nv! 807 F17, // nv! 808 F18, // nv! 809 F19, // nv! 810 F20, // nv! 811 F21, // nv! 812 F22, // nv! 813 F23, // nv! 814 F24, // nv! 815 F25, // nv! 816 F26, // nv! 817 F27, // nv! 818 F28, // nv! 819 F29, // nv! 820 F30, // nv! 821 F31 // nv! 822 ); 823 824 // Double precision float registers have virtual `high halves' that 825 // are needed by the allocator. 826 reg_class dbl_reg( 827 /*F0, F0_H*/ // scratch 828 F1, F1_H, 829 F2, F2_H, 830 F3, F3_H, 831 F4, F4_H, 832 F5, F5_H, 833 F6, F6_H, 834 F7, F7_H, 835 F8, F8_H, 836 F9, F9_H, 837 F10, F10_H, 838 F11, F11_H, 839 F12, F12_H, 840 F13, F13_H, 841 F14, F14_H, // nv! 842 F15, F15_H, // nv! 843 F16, F16_H, // nv! 844 F17, F17_H, // nv! 845 F18, F18_H, // nv! 846 F19, F19_H, // nv! 847 F20, F20_H, // nv! 848 F21, F21_H, // nv! 849 F22, F22_H, // nv! 850 F23, F23_H, // nv! 851 F24, F24_H, // nv! 852 F25, F25_H, // nv! 853 F26, F26_H, // nv! 854 F27, F27_H, // nv! 855 F28, F28_H, // nv! 856 F29, F29_H, // nv! 857 F30, F30_H, // nv! 858 F31, F31_H // nv! 859 ); 860 861 %} 862 863 //----------DEFINITION BLOCK--------------------------------------------------- 864 // Define name --> value mappings to inform the ADLC of an integer valued name 865 // Current support includes integer values in the range [0, 0x7FFFFFFF] 866 // Format: 867 // int_def <name> ( <int_value>, <expression>); 868 // Generated Code in ad_<arch>.hpp 869 // #define <name> (<expression>) 870 // // value == <int_value> 871 // Generated code in ad_<arch>.cpp adlc_verification() 872 // assert( <name> == <int_value>, "Expect (<expression>) to equal <int_value>"); 873 // 874 definitions %{ 875 // The default cost (of an ALU instruction). 876 int_def DEFAULT_COST_LOW ( 30, 30); 877 int_def DEFAULT_COST ( 100, 100); 878 int_def HUGE_COST (1000000, 1000000); 879 880 // Memory refs 881 int_def MEMORY_REF_COST_LOW ( 200, DEFAULT_COST * 2); 882 int_def MEMORY_REF_COST ( 300, DEFAULT_COST * 3); 883 884 // Branches are even more expensive. 885 int_def BRANCH_COST ( 900, DEFAULT_COST * 9); 886 int_def CALL_COST ( 1300, DEFAULT_COST * 13); 887 %} 888 889 890 //----------SOURCE BLOCK------------------------------------------------------- 891 // This is a block of C++ code which provides values, functions, and 892 // definitions necessary in the rest of the architecture description. 893 source_hpp %{ 894 // Returns true if Node n is followed by a MemBar node that 895 // will do an acquire. If so, this node must not do the acquire 896 // operation. 897 bool followed_by_acquire(const Node *n); 898 %} 899 900 source %{ 901 902 // Optimize load-acquire. 903 // 904 // Check if acquire is unnecessary due to following operation that does 905 // acquire anyways. 906 // Walk the pattern: 907 // 908 // n: Load.acq 909 // | 910 // MemBarAcquire 911 // | | 912 // Proj(ctrl) Proj(mem) 913 // | | 914 // MemBarRelease/Volatile 915 // 916 bool followed_by_acquire(const Node *load) { 917 assert(load->is_Load(), "So far implemented only for loads."); 918 919 // Find MemBarAcquire. 920 const Node *mba = NULL; 921 for (DUIterator_Fast imax, i = load->fast_outs(imax); i < imax; i++) { 922 const Node *out = load->fast_out(i); 923 if (out->Opcode() == Op_MemBarAcquire) { 924 if (out->in(0) == load) continue; // Skip control edge, membar should be found via precedence edge. 925 mba = out; 926 break; 927 } 928 } 929 if (!mba) return false; 930 931 // Find following MemBar node. 932 // 933 // The following node must be reachable by control AND memory 934 // edge to assure no other operations are in between the two nodes. 935 // 936 // So first get the Proj node, mem_proj, to use it to iterate forward. 937 Node *mem_proj = NULL; 938 for (DUIterator_Fast imax, i = mba->fast_outs(imax); i < imax; i++) { 939 mem_proj = mba->fast_out(i); // Throw out-of-bounds if proj not found 940 assert(mem_proj->is_Proj(), "only projections here"); 941 ProjNode *proj = mem_proj->as_Proj(); 942 if (proj->_con == TypeFunc::Memory && 943 !Compile::current()->node_arena()->contains(mem_proj)) // Unmatched old-space only 944 break; 945 } 946 assert(mem_proj->as_Proj()->_con == TypeFunc::Memory, "Graph broken"); 947 948 // Search MemBar behind Proj. If there are other memory operations 949 // behind the Proj we lost. 950 for (DUIterator_Fast jmax, j = mem_proj->fast_outs(jmax); j < jmax; j++) { 951 Node *x = mem_proj->fast_out(j); 952 // Proj might have an edge to a store or load node which precedes the membar. 953 if (x->is_Mem()) return false; 954 955 // On PPC64 release and volatile are implemented by an instruction 956 // that also has acquire semantics. I.e. there is no need for an 957 // acquire before these. 958 int xop = x->Opcode(); 959 if (xop == Op_MemBarRelease || xop == Op_MemBarVolatile) { 960 // Make sure we're not missing Call/Phi/MergeMem by checking 961 // control edges. The control edge must directly lead back 962 // to the MemBarAcquire 963 Node *ctrl_proj = x->in(0); 964 if (ctrl_proj->is_Proj() && ctrl_proj->in(0) == mba) { 965 return true; 966 } 967 } 968 } 969 970 return false; 971 } 972 973 #define __ _masm. 974 975 // Tertiary op of a LoadP or StoreP encoding. 976 #define REGP_OP true 977 978 // **************************************************************************** 979 980 // REQUIRED FUNCTIONALITY 981 982 // !!!!! Special hack to get all type of calls to specify the byte offset 983 // from the start of the call to the point where the return address 984 // will point. 985 986 // PPC port: Removed use of lazy constant construct. 987 988 int MachCallStaticJavaNode::ret_addr_offset() { 989 // It's only a single branch-and-link instruction. 990 return 4; 991 } 992 993 int MachCallDynamicJavaNode::ret_addr_offset() { 994 // Offset is 4 with postalloc expanded calls (bl is one instruction). We use 995 // postalloc expanded calls if we use inline caches and do not update method data. 996 if (UseInlineCaches) 997 return 4; 998 999 int vtable_index = this->_vtable_index; 1000 if (vtable_index < 0) { 1001 // Must be invalid_vtable_index, not nonvirtual_vtable_index. 1002 assert(vtable_index == Method::invalid_vtable_index, "correct sentinel value"); 1003 return 12; 1004 } else { 1005 assert(!UseInlineCaches, "expect vtable calls only if not using ICs"); 1006 return 24; 1007 } 1008 } 1009 1010 int MachCallRuntimeNode::ret_addr_offset() { 1011 #if defined(ABI_ELFv2) 1012 return 28; 1013 #else 1014 return 40; 1015 #endif 1016 } 1017 1018 //============================================================================= 1019 1020 // condition code conversions 1021 1022 static int cc_to_boint(int cc) { 1023 return Assembler::bcondCRbiIs0 | (cc & 8); 1024 } 1025 1026 static int cc_to_inverse_boint(int cc) { 1027 return Assembler::bcondCRbiIs0 | (8-(cc & 8)); 1028 } 1029 1030 static int cc_to_biint(int cc, int flags_reg) { 1031 return (flags_reg << 2) | (cc & 3); 1032 } 1033 1034 //============================================================================= 1035 1036 // Compute padding required for nodes which need alignment. The padding 1037 // is the number of bytes (not instructions) which will be inserted before 1038 // the instruction. The padding must match the size of a NOP instruction. 1039 1040 int string_indexOf_imm1_charNode::compute_padding(int current_offset) const { 1041 return (3*4-current_offset)&31; 1042 } 1043 1044 int string_indexOf_imm1Node::compute_padding(int current_offset) const { 1045 return (2*4-current_offset)&31; 1046 } 1047 1048 int string_indexOf_immNode::compute_padding(int current_offset) const { 1049 return (3*4-current_offset)&31; 1050 } 1051 1052 int string_indexOfNode::compute_padding(int current_offset) const { 1053 return (1*4-current_offset)&31; 1054 } 1055 1056 int string_compareNode::compute_padding(int current_offset) const { 1057 return (4*4-current_offset)&31; 1058 } 1059 1060 int string_equals_immNode::compute_padding(int current_offset) const { 1061 if (opnd_array(3)->constant() < 16) return 0; // Don't insert nops for short version (loop completely unrolled). 1062 return (2*4-current_offset)&31; 1063 } 1064 1065 int string_equalsNode::compute_padding(int current_offset) const { 1066 return (7*4-current_offset)&31; 1067 } 1068 1069 int inlineCallClearArrayNode::compute_padding(int current_offset) const { 1070 return (2*4-current_offset)&31; 1071 } 1072 1073 //============================================================================= 1074 1075 // Indicate if the safepoint node needs the polling page as an input. 1076 bool SafePointNode::needs_polling_address_input() { 1077 // The address is loaded from thread by a seperate node. 1078 return true; 1079 } 1080 1081 //============================================================================= 1082 1083 // Emit an interrupt that is caught by the debugger (for debugging compiler). 1084 void emit_break(CodeBuffer &cbuf) { 1085 MacroAssembler _masm(&cbuf); 1086 __ illtrap(); 1087 } 1088 1089 #ifndef PRODUCT 1090 void MachBreakpointNode::format(PhaseRegAlloc *ra_, outputStream *st) const { 1091 st->print("BREAKPOINT"); 1092 } 1093 #endif 1094 1095 void MachBreakpointNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const { 1096 emit_break(cbuf); 1097 } 1098 1099 uint MachBreakpointNode::size(PhaseRegAlloc *ra_) const { 1100 return MachNode::size(ra_); 1101 } 1102 1103 //============================================================================= 1104 1105 void emit_nop(CodeBuffer &cbuf) { 1106 MacroAssembler _masm(&cbuf); 1107 __ nop(); 1108 } 1109 1110 static inline void emit_long(CodeBuffer &cbuf, int value) { 1111 *((int*)(cbuf.insts_end())) = value; 1112 cbuf.set_insts_end(cbuf.insts_end() + BytesPerInstWord); 1113 } 1114 1115 //============================================================================= 1116 1117 // Emit a trampoline stub for a call to a target which is too far away. 1118 // 1119 // code sequences: 1120 // 1121 // call-site: 1122 // branch-and-link to <destination> or <trampoline stub> 1123 // 1124 // Related trampoline stub for this call-site in the stub section: 1125 // load the call target from the constant pool 1126 // branch via CTR (LR/link still points to the call-site above) 1127 1128 const uint trampoline_stub_size = 6 * BytesPerInstWord; 1129 1130 void emit_trampoline_stub(MacroAssembler &_masm, int destination_toc_offset, int insts_call_instruction_offset) { 1131 // Start the stub. 1132 address stub = __ start_a_stub(Compile::MAX_stubs_size/2); 1133 if (stub == NULL) { 1134 Compile::current()->env()->record_out_of_memory_failure(); 1135 return; 1136 } 1137 1138 // For java_to_interp stubs we use R11_scratch1 as scratch register 1139 // and in call trampoline stubs we use R12_scratch2. This way we 1140 // can distinguish them (see is_NativeCallTrampolineStub_at()). 1141 Register reg_scratch = R12_scratch2; 1142 1143 // Create a trampoline stub relocation which relates this trampoline stub 1144 // with the call instruction at insts_call_instruction_offset in the 1145 // instructions code-section. 1146 __ relocate(trampoline_stub_Relocation::spec(__ code()->insts()->start() + insts_call_instruction_offset)); 1147 const int stub_start_offset = __ offset(); 1148 1149 // Now, create the trampoline stub's code: 1150 // - load the TOC 1151 // - load the call target from the constant pool 1152 // - call 1153 __ calculate_address_from_global_toc(reg_scratch, __ method_toc()); 1154 __ ld_largeoffset_unchecked(reg_scratch, destination_toc_offset, reg_scratch, false); 1155 __ mtctr(reg_scratch); 1156 __ bctr(); 1157 1158 const address stub_start_addr = __ addr_at(stub_start_offset); 1159 1160 // FIXME: Assert that the trampoline stub can be identified and patched. 1161 1162 // Assert that the encoded destination_toc_offset can be identified and that it is correct. 1163 assert(destination_toc_offset == NativeCallTrampolineStub_at(stub_start_addr)->destination_toc_offset(), 1164 "encoded offset into the constant pool must match"); 1165 // Trampoline_stub_size should be good. 1166 assert((uint)(__ offset() - stub_start_offset) <= trampoline_stub_size, "should be good size"); 1167 assert(is_NativeCallTrampolineStub_at(stub_start_addr), "doesn't look like a trampoline"); 1168 1169 // End the stub. 1170 __ end_a_stub(); 1171 } 1172 1173 // Size of trampoline stub, this doesn't need to be accurate but it must 1174 // be larger or equal to the real size of the stub. 1175 // Used for optimization in Compile::Shorten_branches. 1176 uint size_call_trampoline() { 1177 return trampoline_stub_size; 1178 } 1179 1180 // Number of relocation entries needed by trampoline stub. 1181 // Used for optimization in Compile::Shorten_branches. 1182 uint reloc_call_trampoline() { 1183 return 5; 1184 } 1185 1186 //============================================================================= 1187 1188 // Emit an inline branch-and-link call and a related trampoline stub. 1189 // 1190 // code sequences: 1191 // 1192 // call-site: 1193 // branch-and-link to <destination> or <trampoline stub> 1194 // 1195 // Related trampoline stub for this call-site in the stub section: 1196 // load the call target from the constant pool 1197 // branch via CTR (LR/link still points to the call-site above) 1198 // 1199 1200 typedef struct { 1201 int insts_call_instruction_offset; 1202 int ret_addr_offset; 1203 } EmitCallOffsets; 1204 1205 // Emit a branch-and-link instruction that branches to a trampoline. 1206 // - Remember the offset of the branch-and-link instruction. 1207 // - Add a relocation at the branch-and-link instruction. 1208 // - Emit a branch-and-link. 1209 // - Remember the return pc offset. 1210 EmitCallOffsets emit_call_with_trampoline_stub(MacroAssembler &_masm, address entry_point, relocInfo::relocType rtype) { 1211 EmitCallOffsets offsets = { -1, -1 }; 1212 const int start_offset = __ offset(); 1213 offsets.insts_call_instruction_offset = __ offset(); 1214 1215 // No entry point given, use the current pc. 1216 if (entry_point == NULL) entry_point = __ pc(); 1217 1218 if (!Compile::current()->in_scratch_emit_size()) { 1219 // Put the entry point as a constant into the constant pool. 1220 const address entry_point_toc_addr = __ address_constant(entry_point, RelocationHolder::none); 1221 const int entry_point_toc_offset = __ offset_to_method_toc(entry_point_toc_addr); 1222 1223 // Emit the trampoline stub which will be related to the branch-and-link below. 1224 emit_trampoline_stub(_masm, entry_point_toc_offset, offsets.insts_call_instruction_offset); 1225 __ relocate(rtype); 1226 } 1227 1228 // Note: At this point we do not have the address of the trampoline 1229 // stub, and the entry point might be too far away for bl, so __ pc() 1230 // serves as dummy and the bl will be patched later. 1231 __ bl((address) __ pc()); 1232 1233 offsets.ret_addr_offset = __ offset() - start_offset; 1234 1235 return offsets; 1236 } 1237 1238 //============================================================================= 1239 1240 // Factory for creating loadConL* nodes for large/small constant pool. 1241 1242 static inline jlong replicate_immF(float con) { 1243 // Replicate float con 2 times and pack into vector. 1244 int val = *((int*)&con); 1245 jlong lval = val; 1246 lval = (lval << 32) | (lval & 0xFFFFFFFFl); 1247 return lval; 1248 } 1249 1250 //============================================================================= 1251 1252 const RegMask& MachConstantBaseNode::_out_RegMask = BITS64_CONSTANT_TABLE_BASE_mask(); 1253 int Compile::ConstantTable::calculate_table_base_offset() const { 1254 return 0; // absolute addressing, no offset 1255 } 1256 1257 bool MachConstantBaseNode::requires_postalloc_expand() const { return true; } 1258 void MachConstantBaseNode::postalloc_expand(GrowableArray <Node *> *nodes, PhaseRegAlloc *ra_) { 1259 Compile *C = ra_->C; 1260 1261 iRegPdstOper *op_dst = new (C) iRegPdstOper(); 1262 MachNode *m1 = new (C) loadToc_hiNode(); 1263 MachNode *m2 = new (C) loadToc_loNode(); 1264 1265 m1->add_req(NULL); 1266 m2->add_req(NULL, m1); 1267 m1->_opnds[0] = op_dst; 1268 m2->_opnds[0] = op_dst; 1269 m2->_opnds[1] = op_dst; 1270 ra_->set_pair(m1->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); 1271 ra_->set_pair(m2->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); 1272 nodes->push(m1); 1273 nodes->push(m2); 1274 } 1275 1276 void MachConstantBaseNode::emit(CodeBuffer& cbuf, PhaseRegAlloc* ra_) const { 1277 // Is postalloc expanded. 1278 ShouldNotReachHere(); 1279 } 1280 1281 uint MachConstantBaseNode::size(PhaseRegAlloc* ra_) const { 1282 return 0; 1283 } 1284 1285 #ifndef PRODUCT 1286 void MachConstantBaseNode::format(PhaseRegAlloc* ra_, outputStream* st) const { 1287 st->print("-- \t// MachConstantBaseNode (empty encoding)"); 1288 } 1289 #endif 1290 1291 //============================================================================= 1292 1293 #ifndef PRODUCT 1294 void MachPrologNode::format(PhaseRegAlloc *ra_, outputStream *st) const { 1295 Compile* C = ra_->C; 1296 const long framesize = C->frame_slots() << LogBytesPerInt; 1297 1298 st->print("PROLOG\n\t"); 1299 if (C->need_stack_bang(framesize)) { 1300 st->print("stack_overflow_check\n\t"); 1301 } 1302 1303 if (!false /* TODO: PPC port C->is_frameless_method()*/) { 1304 st->print("save return pc\n\t"); 1305 st->print("push frame %d\n\t", -framesize); 1306 } 1307 } 1308 #endif 1309 1310 // Macro used instead of the common __ to emulate the pipes of PPC. 1311 // Instead of e.g. __ ld(...) one hase to write ___(ld) ld(...) This enables the 1312 // micro scheduler to cope with "hand written" assembler like in the prolog. Though 1313 // still no scheduling of this code is possible, the micro scheduler is aware of the 1314 // code and can update its internal data. The following mechanism is used to achieve this: 1315 // The micro scheduler calls size() of each compound node during scheduling. size() does a 1316 // dummy emit and only during this dummy emit C->hb_scheduling() is not NULL. 1317 #if 0 // TODO: PPC port 1318 #define ___(op) if (UsePower6SchedulerPPC64 && C->hb_scheduling()) \ 1319 C->hb_scheduling()->_pdScheduling->PdEmulatePipe(ppc64Opcode_##op); \ 1320 _masm. 1321 #define ___stop if (UsePower6SchedulerPPC64 && C->hb_scheduling()) \ 1322 C->hb_scheduling()->_pdScheduling->PdEmulatePipe(archOpcode_none) 1323 #define ___advance if (UsePower6SchedulerPPC64 && C->hb_scheduling()) \ 1324 C->hb_scheduling()->_pdScheduling->advance_offset 1325 #else 1326 #define ___(op) if (UsePower6SchedulerPPC64) \ 1327 Unimplemented(); \ 1328 _masm. 1329 #define ___stop if (UsePower6SchedulerPPC64) \ 1330 Unimplemented() 1331 #define ___advance if (UsePower6SchedulerPPC64) \ 1332 Unimplemented() 1333 #endif 1334 1335 void MachPrologNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const { 1336 Compile* C = ra_->C; 1337 MacroAssembler _masm(&cbuf); 1338 1339 const long framesize = C->frame_size_in_bytes(); 1340 assert(framesize % (2 * wordSize) == 0, "must preserve 2*wordSize alignment"); 1341 1342 const bool method_is_frameless = false /* TODO: PPC port C->is_frameless_method()*/; 1343 1344 const Register return_pc = R20; // Must match return_addr() in frame section. 1345 const Register callers_sp = R21; 1346 const Register push_frame_temp = R22; 1347 const Register toc_temp = R23; 1348 assert_different_registers(R11, return_pc, callers_sp, push_frame_temp, toc_temp); 1349 1350 if (method_is_frameless) { 1351 // Add nop at beginning of all frameless methods to prevent any 1352 // oop instructions from getting overwritten by make_not_entrant 1353 // (patching attempt would fail). 1354 ___(nop) nop(); 1355 } else { 1356 // Get return pc. 1357 ___(mflr) mflr(return_pc); 1358 } 1359 1360 // Calls to C2R adapters often do not accept exceptional returns. 1361 // We require that their callers must bang for them. But be 1362 // careful, because some VM calls (such as call site linkage) can 1363 // use several kilobytes of stack. But the stack safety zone should 1364 // account for that. See bugs 4446381, 4468289, 4497237. 1365 1366 int bangsize = C->bang_size_in_bytes(); 1367 assert(bangsize >= framesize || bangsize <= 0, "stack bang size incorrect"); 1368 if (C->need_stack_bang(bangsize) && UseStackBanging) { 1369 // Unfortunately we cannot use the function provided in 1370 // assembler.cpp as we have to emulate the pipes. So I had to 1371 // insert the code of generate_stack_overflow_check(), see 1372 // assembler.cpp for some illuminative comments. 1373 const int page_size = os::vm_page_size(); 1374 int bang_end = (StackShadowPages+1) * page_size; 1375 1376 // This is how far the previous frame's stack banging extended. 1377 const int bang_end_safe = bang_end; 1378 1379 if (bangsize > page_size) { 1380 bang_end += bangsize; 1381 } 1382 1383 int bang_offset = bang_end_safe; 1384 1385 while (bang_offset <= bang_end) { 1386 // Need at least one stack bang at end of shadow zone. 1387 1388 // Again I had to copy code, this time from assembler_ppc64.cpp, 1389 // bang_stack_with_offset - see there for comments. 1390 1391 // Stack grows down, caller passes positive offset. 1392 assert(bang_offset > 0, "must bang with positive offset"); 1393 1394 long stdoffset = -bang_offset; 1395 1396 if (Assembler::is_simm(stdoffset, 16)) { 1397 // Signed 16 bit offset, a simple std is ok. 1398 if (UseLoadInstructionsForStackBangingPPC64) { 1399 ___(ld) ld(R0, (int)(signed short)stdoffset, R1_SP); 1400 } else { 1401 ___(std) std(R0, (int)(signed short)stdoffset, R1_SP); 1402 } 1403 } else if (Assembler::is_simm(stdoffset, 31)) { 1404 // Use largeoffset calculations for addis & ld/std. 1405 const int hi = MacroAssembler::largeoffset_si16_si16_hi(stdoffset); 1406 const int lo = MacroAssembler::largeoffset_si16_si16_lo(stdoffset); 1407 1408 Register tmp = R11; 1409 ___(addis) addis(tmp, R1_SP, hi); 1410 if (UseLoadInstructionsForStackBangingPPC64) { 1411 ___(ld) ld(R0, lo, tmp); 1412 } else { 1413 ___(std) std(R0, lo, tmp); 1414 } 1415 } else { 1416 ShouldNotReachHere(); 1417 } 1418 1419 bang_offset += page_size; 1420 } 1421 // R11 trashed 1422 } // C->need_stack_bang(framesize) && UseStackBanging 1423 1424 unsigned int bytes = (unsigned int)framesize; 1425 long offset = Assembler::align_addr(bytes, frame::alignment_in_bytes); 1426 ciMethod *currMethod = C->method(); 1427 1428 // Optimized version for most common case. 1429 if (UsePower6SchedulerPPC64 && 1430 !method_is_frameless && Assembler::is_simm((int)(-offset), 16) && 1431 !(false /* ConstantsALot TODO: PPC port*/)) { 1432 ___(or) mr(callers_sp, R1_SP); 1433 ___(std) std(return_pc, _abi(lr), R1_SP); 1434 ___(stdu) stdu(R1_SP, -offset, R1_SP); 1435 return; 1436 } 1437 1438 if (!method_is_frameless) { 1439 // Get callers sp. 1440 ___(or) mr(callers_sp, R1_SP); 1441 1442 // Push method's frame, modifies SP. 1443 assert(Assembler::is_uimm(framesize, 32U), "wrong type"); 1444 // The ABI is already accounted for in 'framesize' via the 1445 // 'out_preserve' area. 1446 Register tmp = push_frame_temp; 1447 // Had to insert code of push_frame((unsigned int)framesize, push_frame_temp). 1448 if (Assembler::is_simm(-offset, 16)) { 1449 ___(stdu) stdu(R1_SP, -offset, R1_SP); 1450 } else { 1451 long x = -offset; 1452 // Had to insert load_const(tmp, -offset). 1453 ___(addis) lis( tmp, (int)((signed short)(((x >> 32) & 0xffff0000) >> 16))); 1454 ___(ori) ori( tmp, tmp, ((x >> 32) & 0x0000ffff)); 1455 ___(rldicr) sldi(tmp, tmp, 32); 1456 ___(oris) oris(tmp, tmp, (x & 0xffff0000) >> 16); 1457 ___(ori) ori( tmp, tmp, (x & 0x0000ffff)); 1458 1459 ___(stdux) stdux(R1_SP, R1_SP, tmp); 1460 } 1461 } 1462 #if 0 // TODO: PPC port 1463 // For testing large constant pools, emit a lot of constants to constant pool. 1464 // "Randomize" const_size. 1465 if (ConstantsALot) { 1466 const int num_consts = const_size(); 1467 for (int i = 0; i < num_consts; i++) { 1468 __ long_constant(0xB0B5B00BBABE); 1469 } 1470 } 1471 #endif 1472 if (!method_is_frameless) { 1473 // Save return pc. 1474 ___(std) std(return_pc, _abi(lr), callers_sp); 1475 } 1476 } 1477 #undef ___ 1478 #undef ___stop 1479 #undef ___advance 1480 1481 uint MachPrologNode::size(PhaseRegAlloc *ra_) const { 1482 // Variable size. determine dynamically. 1483 return MachNode::size(ra_); 1484 } 1485 1486 int MachPrologNode::reloc() const { 1487 // Return number of relocatable values contained in this instruction. 1488 return 1; // 1 reloc entry for load_const(toc). 1489 } 1490 1491 //============================================================================= 1492 1493 #ifndef PRODUCT 1494 void MachEpilogNode::format(PhaseRegAlloc *ra_, outputStream *st) const { 1495 Compile* C = ra_->C; 1496 1497 st->print("EPILOG\n\t"); 1498 st->print("restore return pc\n\t"); 1499 st->print("pop frame\n\t"); 1500 1501 if (do_polling() && C->is_method_compilation()) { 1502 st->print("touch polling page\n\t"); 1503 } 1504 } 1505 #endif 1506 1507 void MachEpilogNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const { 1508 Compile* C = ra_->C; 1509 MacroAssembler _masm(&cbuf); 1510 1511 const long framesize = ((long)C->frame_slots()) << LogBytesPerInt; 1512 assert(framesize >= 0, "negative frame-size?"); 1513 1514 const bool method_needs_polling = do_polling() && C->is_method_compilation(); 1515 const bool method_is_frameless = false /* TODO: PPC port C->is_frameless_method()*/; 1516 const Register return_pc = R11; 1517 const Register polling_page = R12; 1518 1519 if (!method_is_frameless) { 1520 // Restore return pc relative to callers' sp. 1521 __ ld(return_pc, ((int)framesize) + _abi(lr), R1_SP); 1522 } 1523 1524 if (method_needs_polling) { 1525 if (LoadPollAddressFromThread) { 1526 // TODO: PPC port __ ld(polling_page, in_bytes(JavaThread::poll_address_offset()), R16_thread); 1527 Unimplemented(); 1528 } else { 1529 __ load_const_optimized(polling_page, (long)(address) os::get_polling_page()); // TODO: PPC port: get_standard_polling_page() 1530 } 1531 } 1532 1533 if (!method_is_frameless) { 1534 // Move return pc to LR. 1535 __ mtlr(return_pc); 1536 // Pop frame (fixed frame-size). 1537 __ addi(R1_SP, R1_SP, (int)framesize); 1538 } 1539 1540 if (method_needs_polling) { 1541 // We need to mark the code position where the load from the safepoint 1542 // polling page was emitted as relocInfo::poll_return_type here. 1543 __ relocate(relocInfo::poll_return_type); 1544 __ load_from_polling_page(polling_page); 1545 } 1546 } 1547 1548 uint MachEpilogNode::size(PhaseRegAlloc *ra_) const { 1549 // Variable size. Determine dynamically. 1550 return MachNode::size(ra_); 1551 } 1552 1553 int MachEpilogNode::reloc() const { 1554 // Return number of relocatable values contained in this instruction. 1555 return 1; // 1 for load_from_polling_page. 1556 } 1557 1558 const Pipeline * MachEpilogNode::pipeline() const { 1559 return MachNode::pipeline_class(); 1560 } 1561 1562 // This method seems to be obsolete. It is declared in machnode.hpp 1563 // and defined in all *.ad files, but it is never called. Should we 1564 // get rid of it? 1565 int MachEpilogNode::safepoint_offset() const { 1566 assert(do_polling(), "no return for this epilog node"); 1567 return 0; 1568 } 1569 1570 #if 0 // TODO: PPC port 1571 void MachLoadPollAddrLateNode::emit(CodeBuffer& cbuf, PhaseRegAlloc* ra_) const { 1572 MacroAssembler _masm(&cbuf); 1573 if (LoadPollAddressFromThread) { 1574 _masm.ld(R11, in_bytes(JavaThread::poll_address_offset()), R16_thread); 1575 } else { 1576 _masm.nop(); 1577 } 1578 } 1579 1580 uint MachLoadPollAddrLateNode::size(PhaseRegAlloc* ra_) const { 1581 if (LoadPollAddressFromThread) { 1582 return 4; 1583 } else { 1584 return 4; 1585 } 1586 } 1587 1588 #ifndef PRODUCT 1589 void MachLoadPollAddrLateNode::format(PhaseRegAlloc* ra_, outputStream* st) const { 1590 st->print_cr(" LD R11, PollAddressOffset, R16_thread \t// LoadPollAddressFromThread"); 1591 } 1592 #endif 1593 1594 const RegMask &MachLoadPollAddrLateNode::out_RegMask() const { 1595 return RSCRATCH1_BITS64_REG_mask(); 1596 } 1597 #endif // PPC port 1598 1599 // ============================================================================= 1600 1601 // Figure out which register class each belongs in: rc_int, rc_float or 1602 // rc_stack. 1603 enum RC { rc_bad, rc_int, rc_float, rc_stack }; 1604 1605 static enum RC rc_class(OptoReg::Name reg) { 1606 // Return the register class for the given register. The given register 1607 // reg is a <register>_num value, which is an index into the MachRegisterNumbers 1608 // enumeration in adGlobals_ppc64.hpp. 1609 1610 if (reg == OptoReg::Bad) return rc_bad; 1611 1612 // We have 64 integer register halves, starting at index 0. 1613 if (reg < 64) return rc_int; 1614 1615 // We have 64 floating-point register halves, starting at index 64. 1616 if (reg < 64+64) return rc_float; 1617 1618 // Between float regs & stack are the flags regs. 1619 assert(OptoReg::is_stack(reg), "blow up if spilling flags"); 1620 1621 return rc_stack; 1622 } 1623 1624 static int ld_st_helper(CodeBuffer *cbuf, const char *op_str, uint opcode, int reg, int offset, 1625 bool do_print, Compile* C, outputStream *st) { 1626 1627 assert(opcode == Assembler::LD_OPCODE || 1628 opcode == Assembler::STD_OPCODE || 1629 opcode == Assembler::LWZ_OPCODE || 1630 opcode == Assembler::STW_OPCODE || 1631 opcode == Assembler::LFD_OPCODE || 1632 opcode == Assembler::STFD_OPCODE || 1633 opcode == Assembler::LFS_OPCODE || 1634 opcode == Assembler::STFS_OPCODE, 1635 "opcode not supported"); 1636 1637 if (cbuf) { 1638 int d = 1639 (Assembler::LD_OPCODE == opcode || Assembler::STD_OPCODE == opcode) ? 1640 Assembler::ds(offset+0 /* TODO: PPC port C->frame_slots_sp_bias_in_bytes()*/) 1641 : Assembler::d1(offset+0 /* TODO: PPC port C->frame_slots_sp_bias_in_bytes()*/); // Makes no difference in opt build. 1642 emit_long(*cbuf, opcode | Assembler::rt(Matcher::_regEncode[reg]) | d | Assembler::ra(R1_SP)); 1643 } 1644 #ifndef PRODUCT 1645 else if (do_print) { 1646 st->print("%-7s %s, [R1_SP + #%d+%d] \t// spill copy", 1647 op_str, 1648 Matcher::regName[reg], 1649 offset, 0 /* TODO: PPC port C->frame_slots_sp_bias_in_bytes()*/); 1650 } 1651 #endif 1652 return 4; // size 1653 } 1654 1655 uint MachSpillCopyNode::implementation(CodeBuffer *cbuf, PhaseRegAlloc *ra_, bool do_size, outputStream *st) const { 1656 Compile* C = ra_->C; 1657 1658 // Get registers to move. 1659 OptoReg::Name src_hi = ra_->get_reg_second(in(1)); 1660 OptoReg::Name src_lo = ra_->get_reg_first(in(1)); 1661 OptoReg::Name dst_hi = ra_->get_reg_second(this); 1662 OptoReg::Name dst_lo = ra_->get_reg_first(this); 1663 1664 enum RC src_hi_rc = rc_class(src_hi); 1665 enum RC src_lo_rc = rc_class(src_lo); 1666 enum RC dst_hi_rc = rc_class(dst_hi); 1667 enum RC dst_lo_rc = rc_class(dst_lo); 1668 1669 assert(src_lo != OptoReg::Bad && dst_lo != OptoReg::Bad, "must move at least 1 register"); 1670 if (src_hi != OptoReg::Bad) 1671 assert((src_lo&1)==0 && src_lo+1==src_hi && 1672 (dst_lo&1)==0 && dst_lo+1==dst_hi, 1673 "expected aligned-adjacent pairs"); 1674 // Generate spill code! 1675 int size = 0; 1676 1677 if (src_lo == dst_lo && src_hi == dst_hi) 1678 return size; // Self copy, no move. 1679 1680 // -------------------------------------- 1681 // Memory->Memory Spill. Use R0 to hold the value. 1682 if (src_lo_rc == rc_stack && dst_lo_rc == rc_stack) { 1683 int src_offset = ra_->reg2offset(src_lo); 1684 int dst_offset = ra_->reg2offset(dst_lo); 1685 if (src_hi != OptoReg::Bad) { 1686 assert(src_hi_rc==rc_stack && dst_hi_rc==rc_stack, 1687 "expected same type of move for high parts"); 1688 size += ld_st_helper(cbuf, "LD ", Assembler::LD_OPCODE, R0_num, src_offset, !do_size, C, st); 1689 if (!cbuf && !do_size) st->print("\n\t"); 1690 size += ld_st_helper(cbuf, "STD ", Assembler::STD_OPCODE, R0_num, dst_offset, !do_size, C, st); 1691 } else { 1692 size += ld_st_helper(cbuf, "LWZ ", Assembler::LWZ_OPCODE, R0_num, src_offset, !do_size, C, st); 1693 if (!cbuf && !do_size) st->print("\n\t"); 1694 size += ld_st_helper(cbuf, "STW ", Assembler::STW_OPCODE, R0_num, dst_offset, !do_size, C, st); 1695 } 1696 return size; 1697 } 1698 1699 // -------------------------------------- 1700 // Check for float->int copy; requires a trip through memory. 1701 if (src_lo_rc == rc_float && dst_lo_rc == rc_int) { 1702 Unimplemented(); 1703 } 1704 1705 // -------------------------------------- 1706 // Check for integer reg-reg copy. 1707 if (src_lo_rc == rc_int && dst_lo_rc == rc_int) { 1708 Register Rsrc = as_Register(Matcher::_regEncode[src_lo]); 1709 Register Rdst = as_Register(Matcher::_regEncode[dst_lo]); 1710 size = (Rsrc != Rdst) ? 4 : 0; 1711 1712 if (cbuf) { 1713 MacroAssembler _masm(cbuf); 1714 if (size) { 1715 __ mr(Rdst, Rsrc); 1716 } 1717 } 1718 #ifndef PRODUCT 1719 else if (!do_size) { 1720 if (size) { 1721 st->print("%-7s %s, %s \t// spill copy", "MR", Matcher::regName[dst_lo], Matcher::regName[src_lo]); 1722 } else { 1723 st->print("%-7s %s, %s \t// spill copy", "MR-NOP", Matcher::regName[dst_lo], Matcher::regName[src_lo]); 1724 } 1725 } 1726 #endif 1727 return size; 1728 } 1729 1730 // Check for integer store. 1731 if (src_lo_rc == rc_int && dst_lo_rc == rc_stack) { 1732 int dst_offset = ra_->reg2offset(dst_lo); 1733 if (src_hi != OptoReg::Bad) { 1734 assert(src_hi_rc==rc_int && dst_hi_rc==rc_stack, 1735 "expected same type of move for high parts"); 1736 size += ld_st_helper(cbuf, "STD ", Assembler::STD_OPCODE, src_lo, dst_offset, !do_size, C, st); 1737 } else { 1738 size += ld_st_helper(cbuf, "STW ", Assembler::STW_OPCODE, src_lo, dst_offset, !do_size, C, st); 1739 } 1740 return size; 1741 } 1742 1743 // Check for integer load. 1744 if (dst_lo_rc == rc_int && src_lo_rc == rc_stack) { 1745 int src_offset = ra_->reg2offset(src_lo); 1746 if (src_hi != OptoReg::Bad) { 1747 assert(dst_hi_rc==rc_int && src_hi_rc==rc_stack, 1748 "expected same type of move for high parts"); 1749 size += ld_st_helper(cbuf, "LD ", Assembler::LD_OPCODE, dst_lo, src_offset, !do_size, C, st); 1750 } else { 1751 size += ld_st_helper(cbuf, "LWZ ", Assembler::LWZ_OPCODE, dst_lo, src_offset, !do_size, C, st); 1752 } 1753 return size; 1754 } 1755 1756 // Check for float reg-reg copy. 1757 if (src_lo_rc == rc_float && dst_lo_rc == rc_float) { 1758 if (cbuf) { 1759 MacroAssembler _masm(cbuf); 1760 FloatRegister Rsrc = as_FloatRegister(Matcher::_regEncode[src_lo]); 1761 FloatRegister Rdst = as_FloatRegister(Matcher::_regEncode[dst_lo]); 1762 __ fmr(Rdst, Rsrc); 1763 } 1764 #ifndef PRODUCT 1765 else if (!do_size) { 1766 st->print("%-7s %s, %s \t// spill copy", "FMR", Matcher::regName[dst_lo], Matcher::regName[src_lo]); 1767 } 1768 #endif 1769 return 4; 1770 } 1771 1772 // Check for float store. 1773 if (src_lo_rc == rc_float && dst_lo_rc == rc_stack) { 1774 int dst_offset = ra_->reg2offset(dst_lo); 1775 if (src_hi != OptoReg::Bad) { 1776 assert(src_hi_rc==rc_float && dst_hi_rc==rc_stack, 1777 "expected same type of move for high parts"); 1778 size += ld_st_helper(cbuf, "STFD", Assembler::STFD_OPCODE, src_lo, dst_offset, !do_size, C, st); 1779 } else { 1780 size += ld_st_helper(cbuf, "STFS", Assembler::STFS_OPCODE, src_lo, dst_offset, !do_size, C, st); 1781 } 1782 return size; 1783 } 1784 1785 // Check for float load. 1786 if (dst_lo_rc == rc_float && src_lo_rc == rc_stack) { 1787 int src_offset = ra_->reg2offset(src_lo); 1788 if (src_hi != OptoReg::Bad) { 1789 assert(dst_hi_rc==rc_float && src_hi_rc==rc_stack, 1790 "expected same type of move for high parts"); 1791 size += ld_st_helper(cbuf, "LFD ", Assembler::LFD_OPCODE, dst_lo, src_offset, !do_size, C, st); 1792 } else { 1793 size += ld_st_helper(cbuf, "LFS ", Assembler::LFS_OPCODE, dst_lo, src_offset, !do_size, C, st); 1794 } 1795 return size; 1796 } 1797 1798 // -------------------------------------------------------------------- 1799 // Check for hi bits still needing moving. Only happens for misaligned 1800 // arguments to native calls. 1801 if (src_hi == dst_hi) 1802 return size; // Self copy; no move. 1803 1804 assert(src_hi_rc != rc_bad && dst_hi_rc != rc_bad, "src_hi & dst_hi cannot be Bad"); 1805 ShouldNotReachHere(); // Unimplemented 1806 return 0; 1807 } 1808 1809 #ifndef PRODUCT 1810 void MachSpillCopyNode::format(PhaseRegAlloc *ra_, outputStream *st) const { 1811 if (!ra_) 1812 st->print("N%d = SpillCopy(N%d)", _idx, in(1)->_idx); 1813 else 1814 implementation(NULL, ra_, false, st); 1815 } 1816 #endif 1817 1818 void MachSpillCopyNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const { 1819 implementation(&cbuf, ra_, false, NULL); 1820 } 1821 1822 uint MachSpillCopyNode::size(PhaseRegAlloc *ra_) const { 1823 return implementation(NULL, ra_, true, NULL); 1824 } 1825 1826 #if 0 // TODO: PPC port 1827 ArchOpcode MachSpillCopyNode_archOpcode(MachSpillCopyNode *n, PhaseRegAlloc *ra_) { 1828 #ifndef PRODUCT 1829 if (ra_->node_regs_max_index() == 0) return archOpcode_undefined; 1830 #endif 1831 assert(ra_->node_regs_max_index() != 0, ""); 1832 1833 // Get registers to move. 1834 OptoReg::Name src_hi = ra_->get_reg_second(n->in(1)); 1835 OptoReg::Name src_lo = ra_->get_reg_first(n->in(1)); 1836 OptoReg::Name dst_hi = ra_->get_reg_second(n); 1837 OptoReg::Name dst_lo = ra_->get_reg_first(n); 1838 1839 enum RC src_lo_rc = rc_class(src_lo); 1840 enum RC dst_lo_rc = rc_class(dst_lo); 1841 1842 if (src_lo == dst_lo && src_hi == dst_hi) 1843 return ppc64Opcode_none; // Self copy, no move. 1844 1845 // -------------------------------------- 1846 // Memory->Memory Spill. Use R0 to hold the value. 1847 if (src_lo_rc == rc_stack && dst_lo_rc == rc_stack) { 1848 return ppc64Opcode_compound; 1849 } 1850 1851 // -------------------------------------- 1852 // Check for float->int copy; requires a trip through memory. 1853 if (src_lo_rc == rc_float && dst_lo_rc == rc_int) { 1854 Unimplemented(); 1855 } 1856 1857 // -------------------------------------- 1858 // Check for integer reg-reg copy. 1859 if (src_lo_rc == rc_int && dst_lo_rc == rc_int) { 1860 Register Rsrc = as_Register(Matcher::_regEncode[src_lo]); 1861 Register Rdst = as_Register(Matcher::_regEncode[dst_lo]); 1862 if (Rsrc == Rdst) { 1863 return ppc64Opcode_none; 1864 } else { 1865 return ppc64Opcode_or; 1866 } 1867 } 1868 1869 // Check for integer store. 1870 if (src_lo_rc == rc_int && dst_lo_rc == rc_stack) { 1871 if (src_hi != OptoReg::Bad) { 1872 return ppc64Opcode_std; 1873 } else { 1874 return ppc64Opcode_stw; 1875 } 1876 } 1877 1878 // Check for integer load. 1879 if (dst_lo_rc == rc_int && src_lo_rc == rc_stack) { 1880 if (src_hi != OptoReg::Bad) { 1881 return ppc64Opcode_ld; 1882 } else { 1883 return ppc64Opcode_lwz; 1884 } 1885 } 1886 1887 // Check for float reg-reg copy. 1888 if (src_lo_rc == rc_float && dst_lo_rc == rc_float) { 1889 return ppc64Opcode_fmr; 1890 } 1891 1892 // Check for float store. 1893 if (src_lo_rc == rc_float && dst_lo_rc == rc_stack) { 1894 if (src_hi != OptoReg::Bad) { 1895 return ppc64Opcode_stfd; 1896 } else { 1897 return ppc64Opcode_stfs; 1898 } 1899 } 1900 1901 // Check for float load. 1902 if (dst_lo_rc == rc_float && src_lo_rc == rc_stack) { 1903 if (src_hi != OptoReg::Bad) { 1904 return ppc64Opcode_lfd; 1905 } else { 1906 return ppc64Opcode_lfs; 1907 } 1908 } 1909 1910 // -------------------------------------------------------------------- 1911 // Check for hi bits still needing moving. Only happens for misaligned 1912 // arguments to native calls. 1913 if (src_hi == dst_hi) 1914 return ppc64Opcode_none; // Self copy; no move. 1915 1916 ShouldNotReachHere(); 1917 return ppc64Opcode_undefined; 1918 } 1919 #endif // PPC port 1920 1921 #ifndef PRODUCT 1922 void MachNopNode::format(PhaseRegAlloc *ra_, outputStream *st) const { 1923 st->print("NOP \t// %d nops to pad for loops.", _count); 1924 } 1925 #endif 1926 1927 void MachNopNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *) const { 1928 MacroAssembler _masm(&cbuf); 1929 // _count contains the number of nops needed for padding. 1930 for (int i = 0; i < _count; i++) { 1931 __ nop(); 1932 } 1933 } 1934 1935 uint MachNopNode::size(PhaseRegAlloc *ra_) const { 1936 return _count * 4; 1937 } 1938 1939 #ifndef PRODUCT 1940 void BoxLockNode::format(PhaseRegAlloc *ra_, outputStream *st) const { 1941 int offset = ra_->reg2offset(in_RegMask(0).find_first_elem()); 1942 int reg = ra_->get_reg_first(this); 1943 st->print("ADDI %s, SP, %d \t// box node", Matcher::regName[reg], offset); 1944 } 1945 #endif 1946 1947 void BoxLockNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const { 1948 MacroAssembler _masm(&cbuf); 1949 1950 int offset = ra_->reg2offset(in_RegMask(0).find_first_elem()); 1951 int reg = ra_->get_encode(this); 1952 1953 if (Assembler::is_simm(offset, 16)) { 1954 __ addi(as_Register(reg), R1, offset); 1955 } else { 1956 ShouldNotReachHere(); 1957 } 1958 } 1959 1960 uint BoxLockNode::size(PhaseRegAlloc *ra_) const { 1961 // BoxLockNode is not a MachNode, so we can't just call MachNode::size(ra_). 1962 return 4; 1963 } 1964 1965 #ifndef PRODUCT 1966 void MachUEPNode::format(PhaseRegAlloc *ra_, outputStream *st) const { 1967 st->print_cr("---- MachUEPNode ----"); 1968 st->print_cr("..."); 1969 } 1970 #endif 1971 1972 void MachUEPNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const { 1973 // This is the unverified entry point. 1974 MacroAssembler _masm(&cbuf); 1975 1976 // Inline_cache contains a klass. 1977 Register ic_klass = as_Register(Matcher::inline_cache_reg_encode()); 1978 Register receiver_klass = R0; // tmp 1979 1980 assert_different_registers(ic_klass, receiver_klass, R11_scratch1, R3_ARG1); 1981 assert(R11_scratch1 == R11, "need prologue scratch register"); 1982 1983 // Check for NULL argument if we don't have implicit null checks. 1984 if (!ImplicitNullChecks || !os::zero_page_read_protected()) { 1985 if (TrapBasedNullChecks) { 1986 __ trap_null_check(R3_ARG1); 1987 } else { 1988 Label valid; 1989 __ cmpdi(CCR0, R3_ARG1, 0); 1990 __ bne_predict_taken(CCR0, valid); 1991 // We have a null argument, branch to ic_miss_stub. 1992 __ b64_patchable((address)SharedRuntime::get_ic_miss_stub(), 1993 relocInfo::runtime_call_type); 1994 __ bind(valid); 1995 } 1996 } 1997 // Assume argument is not NULL, load klass from receiver. 1998 __ load_klass(receiver_klass, R3_ARG1); 1999 2000 if (TrapBasedICMissChecks) { 2001 __ trap_ic_miss_check(receiver_klass, ic_klass); 2002 } else { 2003 Label valid; 2004 __ cmpd(CCR0, receiver_klass, ic_klass); 2005 __ beq_predict_taken(CCR0, valid); 2006 // We have an unexpected klass, branch to ic_miss_stub. 2007 __ b64_patchable((address)SharedRuntime::get_ic_miss_stub(), 2008 relocInfo::runtime_call_type); 2009 __ bind(valid); 2010 } 2011 2012 // Argument is valid and klass is as expected, continue. 2013 } 2014 2015 #if 0 // TODO: PPC port 2016 // Optimize UEP code on z (save a load_const() call in main path). 2017 int MachUEPNode::ep_offset() { 2018 return 0; 2019 } 2020 #endif 2021 2022 uint MachUEPNode::size(PhaseRegAlloc *ra_) const { 2023 // Variable size. Determine dynamically. 2024 return MachNode::size(ra_); 2025 } 2026 2027 //============================================================================= 2028 2029 uint size_exception_handler() { 2030 // The exception_handler is a b64_patchable. 2031 return MacroAssembler::b64_patchable_size; 2032 } 2033 2034 uint size_deopt_handler() { 2035 // The deopt_handler is a bl64_patchable. 2036 return MacroAssembler::bl64_patchable_size; 2037 } 2038 2039 int emit_exception_handler(CodeBuffer &cbuf) { 2040 MacroAssembler _masm(&cbuf); 2041 2042 address base = __ start_a_stub(size_exception_handler()); 2043 if (base == NULL) return 0; // CodeBuffer::expand failed 2044 2045 int offset = __ offset(); 2046 __ b64_patchable((address)OptoRuntime::exception_blob()->content_begin(), 2047 relocInfo::runtime_call_type); 2048 assert(__ offset() - offset == (int)size_exception_handler(), "must be fixed size"); 2049 __ end_a_stub(); 2050 2051 return offset; 2052 } 2053 2054 // The deopt_handler is like the exception handler, but it calls to 2055 // the deoptimization blob instead of jumping to the exception blob. 2056 int emit_deopt_handler(CodeBuffer& cbuf) { 2057 MacroAssembler _masm(&cbuf); 2058 2059 address base = __ start_a_stub(size_deopt_handler()); 2060 if (base == NULL) return 0; // CodeBuffer::expand failed 2061 2062 int offset = __ offset(); 2063 __ bl64_patchable((address)SharedRuntime::deopt_blob()->unpack(), 2064 relocInfo::runtime_call_type); 2065 assert(__ offset() - offset == (int) size_deopt_handler(), "must be fixed size"); 2066 __ end_a_stub(); 2067 2068 return offset; 2069 } 2070 2071 //============================================================================= 2072 2073 // Use a frame slots bias for frameless methods if accessing the stack. 2074 static int frame_slots_bias(int reg_enc, PhaseRegAlloc* ra_) { 2075 if (as_Register(reg_enc) == R1_SP) { 2076 return 0; // TODO: PPC port ra_->C->frame_slots_sp_bias_in_bytes(); 2077 } 2078 return 0; 2079 } 2080 2081 const bool Matcher::match_rule_supported(int opcode) { 2082 if (!has_match_rule(opcode)) 2083 return false; 2084 2085 switch (opcode) { 2086 case Op_SqrtD: 2087 return VM_Version::has_fsqrt(); 2088 case Op_CountLeadingZerosI: 2089 case Op_CountLeadingZerosL: 2090 case Op_CountTrailingZerosI: 2091 case Op_CountTrailingZerosL: 2092 if (!UseCountLeadingZerosInstructionsPPC64) 2093 return false; 2094 break; 2095 2096 case Op_PopCountI: 2097 case Op_PopCountL: 2098 return (UsePopCountInstruction && VM_Version::has_popcntw()); 2099 2100 case Op_StrComp: 2101 return SpecialStringCompareTo; 2102 case Op_StrEquals: 2103 return SpecialStringEquals; 2104 case Op_StrIndexOf: 2105 return SpecialStringIndexOf; 2106 } 2107 2108 return true; // Per default match rules are supported. 2109 } 2110 2111 int Matcher::regnum_to_fpu_offset(int regnum) { 2112 // No user for this method? 2113 Unimplemented(); 2114 return 999; 2115 } 2116 2117 const bool Matcher::convL2FSupported(void) { 2118 // fcfids can do the conversion (>= Power7). 2119 // fcfid + frsp showed rounding problem when result should be 0x3f800001. 2120 return VM_Version::has_fcfids(); // False means that conversion is done by runtime call. 2121 } 2122 2123 // Vector width in bytes. 2124 const int Matcher::vector_width_in_bytes(BasicType bt) { 2125 assert(MaxVectorSize == 8, ""); 2126 return 8; 2127 } 2128 2129 // Vector ideal reg. 2130 const int Matcher::vector_ideal_reg(int size) { 2131 assert(MaxVectorSize == 8 && size == 8, ""); 2132 return Op_RegL; 2133 } 2134 2135 const int Matcher::vector_shift_count_ideal_reg(int size) { 2136 fatal("vector shift is not supported"); 2137 return Node::NotAMachineReg; 2138 } 2139 2140 // Limits on vector size (number of elements) loaded into vector. 2141 const int Matcher::max_vector_size(const BasicType bt) { 2142 assert(is_java_primitive(bt), "only primitive type vectors"); 2143 return vector_width_in_bytes(bt)/type2aelembytes(bt); 2144 } 2145 2146 const int Matcher::min_vector_size(const BasicType bt) { 2147 return max_vector_size(bt); // Same as max. 2148 } 2149 2150 // PPC doesn't support misaligned vectors store/load. 2151 const bool Matcher::misaligned_vectors_ok() { 2152 return false; 2153 } 2154 2155 // PPC AES support not yet implemented 2156 const bool Matcher::pass_original_key_for_aes() { 2157 return false; 2158 } 2159 2160 // RETURNS: whether this branch offset is short enough that a short 2161 // branch can be used. 2162 // 2163 // If the platform does not provide any short branch variants, then 2164 // this method should return `false' for offset 0. 2165 // 2166 // `Compile::Fill_buffer' will decide on basis of this information 2167 // whether to do the pass `Compile::Shorten_branches' at all. 2168 // 2169 // And `Compile::Shorten_branches' will decide on basis of this 2170 // information whether to replace particular branch sites by short 2171 // ones. 2172 bool Matcher::is_short_branch_offset(int rule, int br_size, int offset) { 2173 // Is the offset within the range of a ppc64 pc relative branch? 2174 bool b; 2175 2176 const int safety_zone = 3 * BytesPerInstWord; 2177 b = Assembler::is_simm((offset<0 ? offset-safety_zone : offset+safety_zone), 2178 29 - 16 + 1 + 2); 2179 return b; 2180 } 2181 2182 const bool Matcher::isSimpleConstant64(jlong value) { 2183 // Probably always true, even if a temp register is required. 2184 return true; 2185 } 2186 /* TODO: PPC port 2187 // Make a new machine dependent decode node (with its operands). 2188 MachTypeNode *Matcher::make_decode_node(Compile *C) { 2189 assert(Universe::narrow_oop_base() == NULL && Universe::narrow_oop_shift() == 0, 2190 "This method is only implemented for unscaled cOops mode so far"); 2191 MachTypeNode *decode = new (C) decodeN_unscaledNode(); 2192 decode->set_opnd_array(0, new (C) iRegPdstOper()); 2193 decode->set_opnd_array(1, new (C) iRegNsrcOper()); 2194 return decode; 2195 } 2196 */ 2197 // Threshold size for cleararray. 2198 const int Matcher::init_array_short_size = 8 * BytesPerLong; 2199 2200 // false => size gets scaled to BytesPerLong, ok. 2201 const bool Matcher::init_array_count_is_in_bytes = false; 2202 2203 // Use conditional move (CMOVL) on Power7. 2204 const int Matcher::long_cmove_cost() { return 0; } // this only makes long cmoves more expensive than int cmoves 2205 2206 // Suppress CMOVF. Conditional move available (sort of) on PPC64 only from P7 onwards. Not exploited yet. 2207 // fsel doesn't accept a condition register as input, so this would be slightly different. 2208 const int Matcher::float_cmove_cost() { return ConditionalMoveLimit; } 2209 2210 // Power6 requires postalloc expand (see block.cpp for description of postalloc expand). 2211 const bool Matcher::require_postalloc_expand = true; 2212 2213 // Should the Matcher clone shifts on addressing modes, expecting them to 2214 // be subsumed into complex addressing expressions or compute them into 2215 // registers? True for Intel but false for most RISCs. 2216 const bool Matcher::clone_shift_expressions = false; 2217 2218 // Do we need to mask the count passed to shift instructions or does 2219 // the cpu only look at the lower 5/6 bits anyway? 2220 // Off, as masks are generated in expand rules where required. 2221 // Constant shift counts are handled in Ideal phase. 2222 const bool Matcher::need_masked_shift_count = false; 2223 2224 // This affects two different things: 2225 // - how Decode nodes are matched 2226 // - how ImplicitNullCheck opportunities are recognized 2227 // If true, the matcher will try to remove all Decodes and match them 2228 // (as operands) into nodes. NullChecks are not prepared to deal with 2229 // Decodes by final_graph_reshaping(). 2230 // If false, final_graph_reshaping() forces the decode behind the Cmp 2231 // for a NullCheck. The matcher matches the Decode node into a register. 2232 // Implicit_null_check optimization moves the Decode along with the 2233 // memory operation back up before the NullCheck. 2234 bool Matcher::narrow_oop_use_complex_address() { 2235 // TODO: PPC port if (MatchDecodeNodes) return true; 2236 return false; 2237 } 2238 2239 bool Matcher::narrow_klass_use_complex_address() { 2240 NOT_LP64(ShouldNotCallThis()); 2241 assert(UseCompressedClassPointers, "only for compressed klass code"); 2242 // TODO: PPC port if (MatchDecodeNodes) return true; 2243 return false; 2244 } 2245 2246 // Is it better to copy float constants, or load them directly from memory? 2247 // Intel can load a float constant from a direct address, requiring no 2248 // extra registers. Most RISCs will have to materialize an address into a 2249 // register first, so they would do better to copy the constant from stack. 2250 const bool Matcher::rematerialize_float_constants = false; 2251 2252 // If CPU can load and store mis-aligned doubles directly then no fixup is 2253 // needed. Else we split the double into 2 integer pieces and move it 2254 // piece-by-piece. Only happens when passing doubles into C code as the 2255 // Java calling convention forces doubles to be aligned. 2256 const bool Matcher::misaligned_doubles_ok = true; 2257 2258 void Matcher::pd_implicit_null_fixup(MachNode *node, uint idx) { 2259 Unimplemented(); 2260 } 2261 2262 // Advertise here if the CPU requires explicit rounding operations 2263 // to implement the UseStrictFP mode. 2264 const bool Matcher::strict_fp_requires_explicit_rounding = false; 2265 2266 // Do floats take an entire double register or just half? 2267 // 2268 // A float occupies a ppc64 double register. For the allocator, a 2269 // ppc64 double register appears as a pair of float registers. 2270 bool Matcher::float_in_double() { return true; } 2271 2272 // Do ints take an entire long register or just half? 2273 // The relevant question is how the int is callee-saved: 2274 // the whole long is written but de-opt'ing will have to extract 2275 // the relevant 32 bits. 2276 const bool Matcher::int_in_long = true; 2277 2278 // Constants for c2c and c calling conventions. 2279 2280 const MachRegisterNumbers iarg_reg[8] = { 2281 R3_num, R4_num, R5_num, R6_num, 2282 R7_num, R8_num, R9_num, R10_num 2283 }; 2284 2285 const MachRegisterNumbers farg_reg[13] = { 2286 F1_num, F2_num, F3_num, F4_num, 2287 F5_num, F6_num, F7_num, F8_num, 2288 F9_num, F10_num, F11_num, F12_num, 2289 F13_num 2290 }; 2291 2292 const int num_iarg_registers = sizeof(iarg_reg) / sizeof(iarg_reg[0]); 2293 2294 const int num_farg_registers = sizeof(farg_reg) / sizeof(farg_reg[0]); 2295 2296 // Return whether or not this register is ever used as an argument. This 2297 // function is used on startup to build the trampoline stubs in generateOptoStub. 2298 // Registers not mentioned will be killed by the VM call in the trampoline, and 2299 // arguments in those registers not be available to the callee. 2300 bool Matcher::can_be_java_arg(int reg) { 2301 // We return true for all registers contained in iarg_reg[] and 2302 // farg_reg[] and their virtual halves. 2303 // We must include the virtual halves in order to get STDs and LDs 2304 // instead of STWs and LWs in the trampoline stubs. 2305 2306 if ( reg == R3_num || reg == R3_H_num 2307 || reg == R4_num || reg == R4_H_num 2308 || reg == R5_num || reg == R5_H_num 2309 || reg == R6_num || reg == R6_H_num 2310 || reg == R7_num || reg == R7_H_num 2311 || reg == R8_num || reg == R8_H_num 2312 || reg == R9_num || reg == R9_H_num 2313 || reg == R10_num || reg == R10_H_num) 2314 return true; 2315 2316 if ( reg == F1_num || reg == F1_H_num 2317 || reg == F2_num || reg == F2_H_num 2318 || reg == F3_num || reg == F3_H_num 2319 || reg == F4_num || reg == F4_H_num 2320 || reg == F5_num || reg == F5_H_num 2321 || reg == F6_num || reg == F6_H_num 2322 || reg == F7_num || reg == F7_H_num 2323 || reg == F8_num || reg == F8_H_num 2324 || reg == F9_num || reg == F9_H_num 2325 || reg == F10_num || reg == F10_H_num 2326 || reg == F11_num || reg == F11_H_num 2327 || reg == F12_num || reg == F12_H_num 2328 || reg == F13_num || reg == F13_H_num) 2329 return true; 2330 2331 return false; 2332 } 2333 2334 bool Matcher::is_spillable_arg(int reg) { 2335 return can_be_java_arg(reg); 2336 } 2337 2338 bool Matcher::use_asm_for_ldiv_by_con(jlong divisor) { 2339 return false; 2340 } 2341 2342 // Register for DIVI projection of divmodI. 2343 RegMask Matcher::divI_proj_mask() { 2344 ShouldNotReachHere(); 2345 return RegMask(); 2346 } 2347 2348 // Register for MODI projection of divmodI. 2349 RegMask Matcher::modI_proj_mask() { 2350 ShouldNotReachHere(); 2351 return RegMask(); 2352 } 2353 2354 // Register for DIVL projection of divmodL. 2355 RegMask Matcher::divL_proj_mask() { 2356 ShouldNotReachHere(); 2357 return RegMask(); 2358 } 2359 2360 // Register for MODL projection of divmodL. 2361 RegMask Matcher::modL_proj_mask() { 2362 ShouldNotReachHere(); 2363 return RegMask(); 2364 } 2365 2366 const RegMask Matcher::method_handle_invoke_SP_save_mask() { 2367 return RegMask(); 2368 } 2369 2370 %} 2371 2372 //----------ENCODING BLOCK----------------------------------------------------- 2373 // This block specifies the encoding classes used by the compiler to output 2374 // byte streams. Encoding classes are parameterized macros used by 2375 // Machine Instruction Nodes in order to generate the bit encoding of the 2376 // instruction. Operands specify their base encoding interface with the 2377 // interface keyword. There are currently supported four interfaces, 2378 // REG_INTER, CONST_INTER, MEMORY_INTER, & COND_INTER. REG_INTER causes an 2379 // operand to generate a function which returns its register number when 2380 // queried. CONST_INTER causes an operand to generate a function which 2381 // returns the value of the constant when queried. MEMORY_INTER causes an 2382 // operand to generate four functions which return the Base Register, the 2383 // Index Register, the Scale Value, and the Offset Value of the operand when 2384 // queried. COND_INTER causes an operand to generate six functions which 2385 // return the encoding code (ie - encoding bits for the instruction) 2386 // associated with each basic boolean condition for a conditional instruction. 2387 // 2388 // Instructions specify two basic values for encoding. Again, a function 2389 // is available to check if the constant displacement is an oop. They use the 2390 // ins_encode keyword to specify their encoding classes (which must be 2391 // a sequence of enc_class names, and their parameters, specified in 2392 // the encoding block), and they use the 2393 // opcode keyword to specify, in order, their primary, secondary, and 2394 // tertiary opcode. Only the opcode sections which a particular instruction 2395 // needs for encoding need to be specified. 2396 encode %{ 2397 enc_class enc_unimplemented %{ 2398 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 2399 MacroAssembler _masm(&cbuf); 2400 __ unimplemented("Unimplemented mach node encoding in AD file.", 13); 2401 %} 2402 2403 enc_class enc_untested %{ 2404 #ifdef ASSERT 2405 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 2406 MacroAssembler _masm(&cbuf); 2407 __ untested("Untested mach node encoding in AD file."); 2408 #else 2409 // TODO: PPC port $archOpcode(ppc64Opcode_none); 2410 #endif 2411 %} 2412 2413 enc_class enc_lbz(iRegIdst dst, memory mem) %{ 2414 // TODO: PPC port $archOpcode(ppc64Opcode_lbz); 2415 MacroAssembler _masm(&cbuf); 2416 int Idisp = $mem$$disp + frame_slots_bias($mem$$base, ra_); 2417 __ lbz($dst$$Register, Idisp, $mem$$base$$Register); 2418 %} 2419 2420 // Load acquire. 2421 enc_class enc_lbz_ac(iRegIdst dst, memory mem) %{ 2422 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 2423 MacroAssembler _masm(&cbuf); 2424 int Idisp = $mem$$disp + frame_slots_bias($mem$$base, ra_); 2425 __ lbz($dst$$Register, Idisp, $mem$$base$$Register); 2426 __ twi_0($dst$$Register); 2427 __ isync(); 2428 %} 2429 2430 enc_class enc_lhz(iRegIdst dst, memory mem) %{ 2431 // TODO: PPC port $archOpcode(ppc64Opcode_lhz); 2432 2433 MacroAssembler _masm(&cbuf); 2434 int Idisp = $mem$$disp + frame_slots_bias($mem$$base, ra_); 2435 __ lhz($dst$$Register, Idisp, $mem$$base$$Register); 2436 %} 2437 2438 // Load acquire. 2439 enc_class enc_lhz_ac(iRegIdst dst, memory mem) %{ 2440 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 2441 2442 MacroAssembler _masm(&cbuf); 2443 int Idisp = $mem$$disp + frame_slots_bias($mem$$base, ra_); 2444 __ lhz($dst$$Register, Idisp, $mem$$base$$Register); 2445 __ twi_0($dst$$Register); 2446 __ isync(); 2447 %} 2448 2449 enc_class enc_lwz(iRegIdst dst, memory mem) %{ 2450 // TODO: PPC port $archOpcode(ppc64Opcode_lwz); 2451 2452 MacroAssembler _masm(&cbuf); 2453 int Idisp = $mem$$disp + frame_slots_bias($mem$$base, ra_); 2454 __ lwz($dst$$Register, Idisp, $mem$$base$$Register); 2455 %} 2456 2457 // Load acquire. 2458 enc_class enc_lwz_ac(iRegIdst dst, memory mem) %{ 2459 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 2460 2461 MacroAssembler _masm(&cbuf); 2462 int Idisp = $mem$$disp + frame_slots_bias($mem$$base, ra_); 2463 __ lwz($dst$$Register, Idisp, $mem$$base$$Register); 2464 __ twi_0($dst$$Register); 2465 __ isync(); 2466 %} 2467 2468 enc_class enc_ld(iRegLdst dst, memoryAlg4 mem) %{ 2469 // TODO: PPC port $archOpcode(ppc64Opcode_ld); 2470 MacroAssembler _masm(&cbuf); 2471 int Idisp = $mem$$disp + frame_slots_bias($mem$$base, ra_); 2472 // Operand 'ds' requires 4-alignment. 2473 assert((Idisp & 0x3) == 0, "unaligned offset"); 2474 __ ld($dst$$Register, Idisp, $mem$$base$$Register); 2475 %} 2476 2477 // Load acquire. 2478 enc_class enc_ld_ac(iRegLdst dst, memoryAlg4 mem) %{ 2479 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 2480 MacroAssembler _masm(&cbuf); 2481 int Idisp = $mem$$disp + frame_slots_bias($mem$$base, ra_); 2482 // Operand 'ds' requires 4-alignment. 2483 assert((Idisp & 0x3) == 0, "unaligned offset"); 2484 __ ld($dst$$Register, Idisp, $mem$$base$$Register); 2485 __ twi_0($dst$$Register); 2486 __ isync(); 2487 %} 2488 2489 enc_class enc_lfd(RegF dst, memory mem) %{ 2490 // TODO: PPC port $archOpcode(ppc64Opcode_lfd); 2491 MacroAssembler _masm(&cbuf); 2492 int Idisp = $mem$$disp + frame_slots_bias($mem$$base, ra_); 2493 __ lfd($dst$$FloatRegister, Idisp, $mem$$base$$Register); 2494 %} 2495 2496 enc_class enc_load_long_constL(iRegLdst dst, immL src, iRegLdst toc) %{ 2497 // TODO: PPC port $archOpcode(ppc64Opcode_ld); 2498 2499 MacroAssembler _masm(&cbuf); 2500 int toc_offset = 0; 2501 2502 if (!ra_->C->in_scratch_emit_size()) { 2503 address const_toc_addr; 2504 // Create a non-oop constant, no relocation needed. 2505 // If it is an IC, it has a virtual_call_Relocation. 2506 const_toc_addr = __ long_constant((jlong)$src$$constant); 2507 2508 // Get the constant's TOC offset. 2509 toc_offset = __ offset_to_method_toc(const_toc_addr); 2510 2511 // Keep the current instruction offset in mind. 2512 ((loadConLNode*)this)->_cbuf_insts_offset = __ offset(); 2513 } 2514 2515 __ ld($dst$$Register, toc_offset, $toc$$Register); 2516 %} 2517 2518 enc_class enc_load_long_constL_hi(iRegLdst dst, iRegLdst toc, immL src) %{ 2519 // TODO: PPC port $archOpcode(ppc64Opcode_addis); 2520 2521 MacroAssembler _masm(&cbuf); 2522 2523 if (!ra_->C->in_scratch_emit_size()) { 2524 address const_toc_addr; 2525 // Create a non-oop constant, no relocation needed. 2526 // If it is an IC, it has a virtual_call_Relocation. 2527 const_toc_addr = __ long_constant((jlong)$src$$constant); 2528 2529 // Get the constant's TOC offset. 2530 const int toc_offset = __ offset_to_method_toc(const_toc_addr); 2531 // Store the toc offset of the constant. 2532 ((loadConL_hiNode*)this)->_const_toc_offset = toc_offset; 2533 2534 // Also keep the current instruction offset in mind. 2535 ((loadConL_hiNode*)this)->_cbuf_insts_offset = __ offset(); 2536 } 2537 2538 __ addis($dst$$Register, $toc$$Register, MacroAssembler::largeoffset_si16_si16_hi(_const_toc_offset)); 2539 %} 2540 2541 %} // encode 2542 2543 source %{ 2544 2545 typedef struct { 2546 loadConL_hiNode *_large_hi; 2547 loadConL_loNode *_large_lo; 2548 loadConLNode *_small; 2549 MachNode *_last; 2550 } loadConLNodesTuple; 2551 2552 loadConLNodesTuple loadConLNodesTuple_create(Compile *C, PhaseRegAlloc *ra_, Node *toc, immLOper *immSrc, 2553 OptoReg::Name reg_second, OptoReg::Name reg_first) { 2554 loadConLNodesTuple nodes; 2555 2556 const bool large_constant_pool = true; // TODO: PPC port C->cfg()->_consts_size > 4000; 2557 if (large_constant_pool) { 2558 // Create new nodes. 2559 loadConL_hiNode *m1 = new (C) loadConL_hiNode(); 2560 loadConL_loNode *m2 = new (C) loadConL_loNode(); 2561 2562 // inputs for new nodes 2563 m1->add_req(NULL, toc); 2564 m2->add_req(NULL, m1); 2565 2566 // operands for new nodes 2567 m1->_opnds[0] = new (C) iRegLdstOper(); // dst 2568 m1->_opnds[1] = immSrc; // src 2569 m1->_opnds[2] = new (C) iRegPdstOper(); // toc 2570 m2->_opnds[0] = new (C) iRegLdstOper(); // dst 2571 m2->_opnds[1] = immSrc; // src 2572 m2->_opnds[2] = new (C) iRegLdstOper(); // base 2573 2574 // Initialize ins_attrib TOC fields. 2575 m1->_const_toc_offset = -1; 2576 m2->_const_toc_offset_hi_node = m1; 2577 2578 // Initialize ins_attrib instruction offset. 2579 m1->_cbuf_insts_offset = -1; 2580 2581 // register allocation for new nodes 2582 ra_->set_pair(m1->_idx, reg_second, reg_first); 2583 ra_->set_pair(m2->_idx, reg_second, reg_first); 2584 2585 // Create result. 2586 nodes._large_hi = m1; 2587 nodes._large_lo = m2; 2588 nodes._small = NULL; 2589 nodes._last = nodes._large_lo; 2590 assert(m2->bottom_type()->isa_long(), "must be long"); 2591 } else { 2592 loadConLNode *m2 = new (C) loadConLNode(); 2593 2594 // inputs for new nodes 2595 m2->add_req(NULL, toc); 2596 2597 // operands for new nodes 2598 m2->_opnds[0] = new (C) iRegLdstOper(); // dst 2599 m2->_opnds[1] = immSrc; // src 2600 m2->_opnds[2] = new (C) iRegPdstOper(); // toc 2601 2602 // Initialize ins_attrib instruction offset. 2603 m2->_cbuf_insts_offset = -1; 2604 2605 // register allocation for new nodes 2606 ra_->set_pair(m2->_idx, reg_second, reg_first); 2607 2608 // Create result. 2609 nodes._large_hi = NULL; 2610 nodes._large_lo = NULL; 2611 nodes._small = m2; 2612 nodes._last = nodes._small; 2613 assert(m2->bottom_type()->isa_long(), "must be long"); 2614 } 2615 2616 return nodes; 2617 } 2618 2619 %} // source 2620 2621 encode %{ 2622 // Postalloc expand emitter for loading a long constant from the method's TOC. 2623 // Enc_class needed as consttanttablebase is not supported by postalloc 2624 // expand. 2625 enc_class postalloc_expand_load_long_constant(iRegLdst dst, immL src, iRegLdst toc) %{ 2626 // Create new nodes. 2627 loadConLNodesTuple loadConLNodes = 2628 loadConLNodesTuple_create(C, ra_, n_toc, op_src, 2629 ra_->get_reg_second(this), ra_->get_reg_first(this)); 2630 2631 // Push new nodes. 2632 if (loadConLNodes._large_hi) nodes->push(loadConLNodes._large_hi); 2633 if (loadConLNodes._last) nodes->push(loadConLNodes._last); 2634 2635 // some asserts 2636 assert(nodes->length() >= 1, "must have created at least 1 node"); 2637 assert(loadConLNodes._last->bottom_type()->isa_long(), "must be long"); 2638 %} 2639 2640 enc_class enc_load_long_constP(iRegLdst dst, immP src, iRegLdst toc) %{ 2641 // TODO: PPC port $archOpcode(ppc64Opcode_ld); 2642 2643 MacroAssembler _masm(&cbuf); 2644 int toc_offset = 0; 2645 2646 if (!ra_->C->in_scratch_emit_size()) { 2647 intptr_t val = $src$$constant; 2648 relocInfo::relocType constant_reloc = $src->constant_reloc(); // src 2649 address const_toc_addr; 2650 if (constant_reloc == relocInfo::oop_type) { 2651 // Create an oop constant and a corresponding relocation. 2652 AddressLiteral a = __ allocate_oop_address((jobject)val); 2653 const_toc_addr = __ address_constant((address)a.value(), RelocationHolder::none); 2654 __ relocate(a.rspec()); 2655 } else if (constant_reloc == relocInfo::metadata_type) { 2656 AddressLiteral a = __ allocate_metadata_address((Metadata *)val); 2657 const_toc_addr = __ address_constant((address)a.value(), RelocationHolder::none); 2658 __ relocate(a.rspec()); 2659 } else { 2660 // Create a non-oop constant, no relocation needed. 2661 const_toc_addr = __ long_constant((jlong)$src$$constant); 2662 } 2663 2664 // Get the constant's TOC offset. 2665 toc_offset = __ offset_to_method_toc(const_toc_addr); 2666 } 2667 2668 __ ld($dst$$Register, toc_offset, $toc$$Register); 2669 %} 2670 2671 enc_class enc_load_long_constP_hi(iRegLdst dst, immP src, iRegLdst toc) %{ 2672 // TODO: PPC port $archOpcode(ppc64Opcode_addis); 2673 2674 MacroAssembler _masm(&cbuf); 2675 if (!ra_->C->in_scratch_emit_size()) { 2676 intptr_t val = $src$$constant; 2677 relocInfo::relocType constant_reloc = $src->constant_reloc(); // src 2678 address const_toc_addr; 2679 if (constant_reloc == relocInfo::oop_type) { 2680 // Create an oop constant and a corresponding relocation. 2681 AddressLiteral a = __ allocate_oop_address((jobject)val); 2682 const_toc_addr = __ address_constant((address)a.value(), RelocationHolder::none); 2683 __ relocate(a.rspec()); 2684 } else if (constant_reloc == relocInfo::metadata_type) { 2685 AddressLiteral a = __ allocate_metadata_address((Metadata *)val); 2686 const_toc_addr = __ address_constant((address)a.value(), RelocationHolder::none); 2687 __ relocate(a.rspec()); 2688 } else { // non-oop pointers, e.g. card mark base, heap top 2689 // Create a non-oop constant, no relocation needed. 2690 const_toc_addr = __ long_constant((jlong)$src$$constant); 2691 } 2692 2693 // Get the constant's TOC offset. 2694 const int toc_offset = __ offset_to_method_toc(const_toc_addr); 2695 // Store the toc offset of the constant. 2696 ((loadConP_hiNode*)this)->_const_toc_offset = toc_offset; 2697 } 2698 2699 __ addis($dst$$Register, $toc$$Register, MacroAssembler::largeoffset_si16_si16_hi(_const_toc_offset)); 2700 %} 2701 2702 // Postalloc expand emitter for loading a ptr constant from the method's TOC. 2703 // Enc_class needed as consttanttablebase is not supported by postalloc 2704 // expand. 2705 enc_class postalloc_expand_load_ptr_constant(iRegPdst dst, immP src, iRegLdst toc) %{ 2706 const bool large_constant_pool = true; // TODO: PPC port C->cfg()->_consts_size > 4000; 2707 if (large_constant_pool) { 2708 // Create new nodes. 2709 loadConP_hiNode *m1 = new (C) loadConP_hiNode(); 2710 loadConP_loNode *m2 = new (C) loadConP_loNode(); 2711 2712 // inputs for new nodes 2713 m1->add_req(NULL, n_toc); 2714 m2->add_req(NULL, m1); 2715 2716 // operands for new nodes 2717 m1->_opnds[0] = new (C) iRegPdstOper(); // dst 2718 m1->_opnds[1] = op_src; // src 2719 m1->_opnds[2] = new (C) iRegPdstOper(); // toc 2720 m2->_opnds[0] = new (C) iRegPdstOper(); // dst 2721 m2->_opnds[1] = op_src; // src 2722 m2->_opnds[2] = new (C) iRegLdstOper(); // base 2723 2724 // Initialize ins_attrib TOC fields. 2725 m1->_const_toc_offset = -1; 2726 m2->_const_toc_offset_hi_node = m1; 2727 2728 // Register allocation for new nodes. 2729 ra_->set_pair(m1->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); 2730 ra_->set_pair(m2->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); 2731 2732 nodes->push(m1); 2733 nodes->push(m2); 2734 assert(m2->bottom_type()->isa_ptr(), "must be ptr"); 2735 } else { 2736 loadConPNode *m2 = new (C) loadConPNode(); 2737 2738 // inputs for new nodes 2739 m2->add_req(NULL, n_toc); 2740 2741 // operands for new nodes 2742 m2->_opnds[0] = new (C) iRegPdstOper(); // dst 2743 m2->_opnds[1] = op_src; // src 2744 m2->_opnds[2] = new (C) iRegPdstOper(); // toc 2745 2746 // Register allocation for new nodes. 2747 ra_->set_pair(m2->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); 2748 2749 nodes->push(m2); 2750 assert(m2->bottom_type()->isa_ptr(), "must be ptr"); 2751 } 2752 %} 2753 2754 // Enc_class needed as consttanttablebase is not supported by postalloc 2755 // expand. 2756 enc_class postalloc_expand_load_float_constant(regF dst, immF src, iRegLdst toc) %{ 2757 bool large_constant_pool = true; // TODO: PPC port C->cfg()->_consts_size > 4000; 2758 2759 MachNode *m2; 2760 if (large_constant_pool) { 2761 m2 = new (C) loadConFCompNode(); 2762 } else { 2763 m2 = new (C) loadConFNode(); 2764 } 2765 // inputs for new nodes 2766 m2->add_req(NULL, n_toc); 2767 2768 // operands for new nodes 2769 m2->_opnds[0] = op_dst; 2770 m2->_opnds[1] = op_src; 2771 m2->_opnds[2] = new (C) iRegPdstOper(); // constanttablebase 2772 2773 // register allocation for new nodes 2774 ra_->set_pair(m2->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); 2775 nodes->push(m2); 2776 %} 2777 2778 // Enc_class needed as consttanttablebase is not supported by postalloc 2779 // expand. 2780 enc_class postalloc_expand_load_double_constant(regD dst, immD src, iRegLdst toc) %{ 2781 bool large_constant_pool = true; // TODO: PPC port C->cfg()->_consts_size > 4000; 2782 2783 MachNode *m2; 2784 if (large_constant_pool) { 2785 m2 = new (C) loadConDCompNode(); 2786 } else { 2787 m2 = new (C) loadConDNode(); 2788 } 2789 // inputs for new nodes 2790 m2->add_req(NULL, n_toc); 2791 2792 // operands for new nodes 2793 m2->_opnds[0] = op_dst; 2794 m2->_opnds[1] = op_src; 2795 m2->_opnds[2] = new (C) iRegPdstOper(); // constanttablebase 2796 2797 // register allocation for new nodes 2798 ra_->set_pair(m2->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); 2799 nodes->push(m2); 2800 %} 2801 2802 enc_class enc_stw(iRegIsrc src, memory mem) %{ 2803 // TODO: PPC port $archOpcode(ppc64Opcode_stw); 2804 MacroAssembler _masm(&cbuf); 2805 int Idisp = $mem$$disp + frame_slots_bias($mem$$base, ra_); 2806 __ stw($src$$Register, Idisp, $mem$$base$$Register); 2807 %} 2808 2809 enc_class enc_std(iRegIsrc src, memoryAlg4 mem) %{ 2810 // TODO: PPC port $archOpcode(ppc64Opcode_std); 2811 MacroAssembler _masm(&cbuf); 2812 int Idisp = $mem$$disp + frame_slots_bias($mem$$base, ra_); 2813 // Operand 'ds' requires 4-alignment. 2814 assert((Idisp & 0x3) == 0, "unaligned offset"); 2815 __ std($src$$Register, Idisp, $mem$$base$$Register); 2816 %} 2817 2818 enc_class enc_stfs(RegF src, memory mem) %{ 2819 // TODO: PPC port $archOpcode(ppc64Opcode_stfs); 2820 MacroAssembler _masm(&cbuf); 2821 int Idisp = $mem$$disp + frame_slots_bias($mem$$base, ra_); 2822 __ stfs($src$$FloatRegister, Idisp, $mem$$base$$Register); 2823 %} 2824 2825 enc_class enc_stfd(RegF src, memory mem) %{ 2826 // TODO: PPC port $archOpcode(ppc64Opcode_stfd); 2827 MacroAssembler _masm(&cbuf); 2828 int Idisp = $mem$$disp + frame_slots_bias($mem$$base, ra_); 2829 __ stfd($src$$FloatRegister, Idisp, $mem$$base$$Register); 2830 %} 2831 2832 // Use release_store for card-marking to ensure that previous 2833 // oop-stores are visible before the card-mark change. 2834 enc_class enc_cms_card_mark(memory mem, iRegLdst releaseFieldAddr) %{ 2835 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 2836 // FIXME: Implement this as a cmove and use a fixed condition code 2837 // register which is written on every transition to compiled code, 2838 // e.g. in call-stub and when returning from runtime stubs. 2839 // 2840 // Proposed code sequence for the cmove implementation: 2841 // 2842 // Label skip_release; 2843 // __ beq(CCRfixed, skip_release); 2844 // __ release(); 2845 // __ bind(skip_release); 2846 // __ stb(card mark); 2847 2848 MacroAssembler _masm(&cbuf); 2849 Label skip_storestore; 2850 2851 #if 0 // TODO: PPC port 2852 // Check CMSCollectorCardTableModRefBSExt::_requires_release and do the 2853 // StoreStore barrier conditionally. 2854 __ lwz(R0, 0, $releaseFieldAddr$$Register); 2855 __ cmpwi(CCR0, R0, 0); 2856 __ beq_predict_taken(CCR0, skip_storestore); 2857 #endif 2858 __ li(R0, 0); 2859 __ membar(Assembler::StoreStore); 2860 #if 0 // TODO: PPC port 2861 __ bind(skip_storestore); 2862 #endif 2863 2864 // Do the store. 2865 if ($mem$$index == 0) { 2866 __ stb(R0, $mem$$disp, $mem$$base$$Register); 2867 } else { 2868 assert(0 == $mem$$disp, "no displacement possible with indexed load/stores on ppc"); 2869 __ stbx(R0, $mem$$base$$Register, $mem$$index$$Register); 2870 } 2871 %} 2872 2873 enc_class postalloc_expand_encode_oop(iRegNdst dst, iRegPdst src, flagsReg crx) %{ 2874 2875 if (VM_Version::has_isel()) { 2876 // use isel instruction with Power 7 2877 cmpP_reg_imm16Node *n_compare = new (C) cmpP_reg_imm16Node(); 2878 encodeP_subNode *n_sub_base = new (C) encodeP_subNode(); 2879 encodeP_shiftNode *n_shift = new (C) encodeP_shiftNode(); 2880 cond_set_0_oopNode *n_cond_set = new (C) cond_set_0_oopNode(); 2881 2882 n_compare->add_req(n_region, n_src); 2883 n_compare->_opnds[0] = op_crx; 2884 n_compare->_opnds[1] = op_src; 2885 n_compare->_opnds[2] = new (C) immL16Oper(0); 2886 2887 n_sub_base->add_req(n_region, n_src); 2888 n_sub_base->_opnds[0] = op_dst; 2889 n_sub_base->_opnds[1] = op_src; 2890 n_sub_base->_bottom_type = _bottom_type; 2891 2892 n_shift->add_req(n_region, n_sub_base); 2893 n_shift->_opnds[0] = op_dst; 2894 n_shift->_opnds[1] = op_dst; 2895 n_shift->_bottom_type = _bottom_type; 2896 2897 n_cond_set->add_req(n_region, n_compare, n_shift); 2898 n_cond_set->_opnds[0] = op_dst; 2899 n_cond_set->_opnds[1] = op_crx; 2900 n_cond_set->_opnds[2] = op_dst; 2901 n_cond_set->_bottom_type = _bottom_type; 2902 2903 ra_->set_pair(n_compare->_idx, ra_->get_reg_second(n_crx), ra_->get_reg_first(n_crx)); 2904 ra_->set_pair(n_sub_base->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); 2905 ra_->set_pair(n_shift->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); 2906 ra_->set_pair(n_cond_set->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); 2907 2908 nodes->push(n_compare); 2909 nodes->push(n_sub_base); 2910 nodes->push(n_shift); 2911 nodes->push(n_cond_set); 2912 2913 } else { 2914 // before Power 7 2915 moveRegNode *n_move = new (C) moveRegNode(); 2916 cmpP_reg_imm16Node *n_compare = new (C) cmpP_reg_imm16Node(); 2917 encodeP_shiftNode *n_shift = new (C) encodeP_shiftNode(); 2918 cond_sub_baseNode *n_sub_base = new (C) cond_sub_baseNode(); 2919 2920 n_move->add_req(n_region, n_src); 2921 n_move->_opnds[0] = op_dst; 2922 n_move->_opnds[1] = op_src; 2923 ra_->set_oop(n_move, true); // Until here, 'n_move' still produces an oop. 2924 2925 n_compare->add_req(n_region, n_src); 2926 n_compare->add_prec(n_move); 2927 2928 n_compare->_opnds[0] = op_crx; 2929 n_compare->_opnds[1] = op_src; 2930 n_compare->_opnds[2] = new (C) immL16Oper(0); 2931 2932 n_sub_base->add_req(n_region, n_compare, n_src); 2933 n_sub_base->_opnds[0] = op_dst; 2934 n_sub_base->_opnds[1] = op_crx; 2935 n_sub_base->_opnds[2] = op_src; 2936 n_sub_base->_bottom_type = _bottom_type; 2937 2938 n_shift->add_req(n_region, n_sub_base); 2939 n_shift->_opnds[0] = op_dst; 2940 n_shift->_opnds[1] = op_dst; 2941 n_shift->_bottom_type = _bottom_type; 2942 2943 ra_->set_pair(n_shift->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); 2944 ra_->set_pair(n_compare->_idx, ra_->get_reg_second(n_crx), ra_->get_reg_first(n_crx)); 2945 ra_->set_pair(n_sub_base->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); 2946 ra_->set_pair(n_move->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); 2947 2948 nodes->push(n_move); 2949 nodes->push(n_compare); 2950 nodes->push(n_sub_base); 2951 nodes->push(n_shift); 2952 } 2953 2954 assert(!(ra_->is_oop(this)), "sanity"); // This is not supposed to be GC'ed. 2955 %} 2956 2957 enc_class postalloc_expand_encode_oop_not_null(iRegNdst dst, iRegPdst src) %{ 2958 2959 encodeP_subNode *n1 = new (C) encodeP_subNode(); 2960 n1->add_req(n_region, n_src); 2961 n1->_opnds[0] = op_dst; 2962 n1->_opnds[1] = op_src; 2963 n1->_bottom_type = _bottom_type; 2964 2965 encodeP_shiftNode *n2 = new (C) encodeP_shiftNode(); 2966 n2->add_req(n_region, n1); 2967 n2->_opnds[0] = op_dst; 2968 n2->_opnds[1] = op_dst; 2969 n2->_bottom_type = _bottom_type; 2970 ra_->set_pair(n1->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); 2971 ra_->set_pair(n2->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); 2972 2973 nodes->push(n1); 2974 nodes->push(n2); 2975 assert(!(ra_->is_oop(this)), "sanity"); // This is not supposed to be GC'ed. 2976 %} 2977 2978 enc_class postalloc_expand_decode_oop(iRegPdst dst, iRegNsrc src, flagsReg crx) %{ 2979 decodeN_shiftNode *n_shift = new (C) decodeN_shiftNode(); 2980 cmpN_reg_imm0Node *n_compare = new (C) cmpN_reg_imm0Node(); 2981 2982 n_compare->add_req(n_region, n_src); 2983 n_compare->_opnds[0] = op_crx; 2984 n_compare->_opnds[1] = op_src; 2985 n_compare->_opnds[2] = new (C) immN_0Oper(TypeNarrowOop::NULL_PTR); 2986 2987 n_shift->add_req(n_region, n_src); 2988 n_shift->_opnds[0] = op_dst; 2989 n_shift->_opnds[1] = op_src; 2990 n_shift->_bottom_type = _bottom_type; 2991 2992 if (VM_Version::has_isel()) { 2993 // use isel instruction with Power 7 2994 2995 decodeN_addNode *n_add_base = new (C) decodeN_addNode(); 2996 n_add_base->add_req(n_region, n_shift); 2997 n_add_base->_opnds[0] = op_dst; 2998 n_add_base->_opnds[1] = op_dst; 2999 n_add_base->_bottom_type = _bottom_type; 3000 3001 cond_set_0_ptrNode *n_cond_set = new (C) cond_set_0_ptrNode(); 3002 n_cond_set->add_req(n_region, n_compare, n_add_base); 3003 n_cond_set->_opnds[0] = op_dst; 3004 n_cond_set->_opnds[1] = op_crx; 3005 n_cond_set->_opnds[2] = op_dst; 3006 n_cond_set->_bottom_type = _bottom_type; 3007 3008 assert(ra_->is_oop(this) == true, "A decodeN node must produce an oop!"); 3009 ra_->set_oop(n_cond_set, true); 3010 3011 ra_->set_pair(n_shift->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); 3012 ra_->set_pair(n_compare->_idx, ra_->get_reg_second(n_crx), ra_->get_reg_first(n_crx)); 3013 ra_->set_pair(n_add_base->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); 3014 ra_->set_pair(n_cond_set->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); 3015 3016 nodes->push(n_compare); 3017 nodes->push(n_shift); 3018 nodes->push(n_add_base); 3019 nodes->push(n_cond_set); 3020 3021 } else { 3022 // before Power 7 3023 cond_add_baseNode *n_add_base = new (C) cond_add_baseNode(); 3024 3025 n_add_base->add_req(n_region, n_compare, n_shift); 3026 n_add_base->_opnds[0] = op_dst; 3027 n_add_base->_opnds[1] = op_crx; 3028 n_add_base->_opnds[2] = op_dst; 3029 n_add_base->_bottom_type = _bottom_type; 3030 3031 assert(ra_->is_oop(this) == true, "A decodeN node must produce an oop!"); 3032 ra_->set_oop(n_add_base, true); 3033 3034 ra_->set_pair(n_shift->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); 3035 ra_->set_pair(n_compare->_idx, ra_->get_reg_second(n_crx), ra_->get_reg_first(n_crx)); 3036 ra_->set_pair(n_add_base->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); 3037 3038 nodes->push(n_compare); 3039 nodes->push(n_shift); 3040 nodes->push(n_add_base); 3041 } 3042 %} 3043 3044 enc_class postalloc_expand_decode_oop_not_null(iRegPdst dst, iRegNsrc src) %{ 3045 decodeN_shiftNode *n1 = new (C) decodeN_shiftNode(); 3046 n1->add_req(n_region, n_src); 3047 n1->_opnds[0] = op_dst; 3048 n1->_opnds[1] = op_src; 3049 n1->_bottom_type = _bottom_type; 3050 3051 decodeN_addNode *n2 = new (C) decodeN_addNode(); 3052 n2->add_req(n_region, n1); 3053 n2->_opnds[0] = op_dst; 3054 n2->_opnds[1] = op_dst; 3055 n2->_bottom_type = _bottom_type; 3056 ra_->set_pair(n1->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); 3057 ra_->set_pair(n2->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); 3058 3059 assert(ra_->is_oop(this) == true, "A decodeN node must produce an oop!"); 3060 ra_->set_oop(n2, true); 3061 3062 nodes->push(n1); 3063 nodes->push(n2); 3064 %} 3065 3066 enc_class enc_cmove_reg(iRegIdst dst, flagsReg crx, iRegIsrc src, cmpOp cmp) %{ 3067 // TODO: PPC port $archOpcode(ppc64Opcode_cmove); 3068 3069 MacroAssembler _masm(&cbuf); 3070 int cc = $cmp$$cmpcode; 3071 int flags_reg = $crx$$reg; 3072 Label done; 3073 assert((Assembler::bcondCRbiIs1 & ~Assembler::bcondCRbiIs0) == 8, "check encoding"); 3074 // Branch if not (cmp crx). 3075 __ bc(cc_to_inverse_boint(cc), cc_to_biint(cc, flags_reg), done); 3076 __ mr($dst$$Register, $src$$Register); 3077 // TODO PPC port __ endgroup_if_needed(_size == 12); 3078 __ bind(done); 3079 %} 3080 3081 enc_class enc_cmove_imm(iRegIdst dst, flagsReg crx, immI16 src, cmpOp cmp) %{ 3082 // TODO: PPC port $archOpcode(ppc64Opcode_cmove); 3083 3084 MacroAssembler _masm(&cbuf); 3085 Label done; 3086 assert((Assembler::bcondCRbiIs1 & ~Assembler::bcondCRbiIs0) == 8, "check encoding"); 3087 // Branch if not (cmp crx). 3088 __ bc(cc_to_inverse_boint($cmp$$cmpcode), cc_to_biint($cmp$$cmpcode, $crx$$reg), done); 3089 __ li($dst$$Register, $src$$constant); 3090 // TODO PPC port __ endgroup_if_needed(_size == 12); 3091 __ bind(done); 3092 %} 3093 3094 // New atomics. 3095 enc_class enc_GetAndAddI(iRegIdst res, iRegPdst mem_ptr, iRegIsrc src) %{ 3096 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 3097 3098 MacroAssembler _masm(&cbuf); 3099 Register Rtmp = R0; 3100 Register Rres = $res$$Register; 3101 Register Rsrc = $src$$Register; 3102 Register Rptr = $mem_ptr$$Register; 3103 bool RegCollision = (Rres == Rsrc) || (Rres == Rptr); 3104 Register Rold = RegCollision ? Rtmp : Rres; 3105 3106 Label Lretry; 3107 __ bind(Lretry); 3108 __ lwarx(Rold, Rptr, MacroAssembler::cmpxchgx_hint_atomic_update()); 3109 __ add(Rtmp, Rsrc, Rold); 3110 __ stwcx_(Rtmp, Rptr); 3111 if (UseStaticBranchPredictionInCompareAndSwapPPC64) { 3112 __ bne_predict_not_taken(CCR0, Lretry); 3113 } else { 3114 __ bne( CCR0, Lretry); 3115 } 3116 if (RegCollision) __ subf(Rres, Rsrc, Rtmp); 3117 __ fence(); 3118 %} 3119 3120 enc_class enc_GetAndAddL(iRegLdst res, iRegPdst mem_ptr, iRegLsrc src) %{ 3121 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 3122 3123 MacroAssembler _masm(&cbuf); 3124 Register Rtmp = R0; 3125 Register Rres = $res$$Register; 3126 Register Rsrc = $src$$Register; 3127 Register Rptr = $mem_ptr$$Register; 3128 bool RegCollision = (Rres == Rsrc) || (Rres == Rptr); 3129 Register Rold = RegCollision ? Rtmp : Rres; 3130 3131 Label Lretry; 3132 __ bind(Lretry); 3133 __ ldarx(Rold, Rptr, MacroAssembler::cmpxchgx_hint_atomic_update()); 3134 __ add(Rtmp, Rsrc, Rold); 3135 __ stdcx_(Rtmp, Rptr); 3136 if (UseStaticBranchPredictionInCompareAndSwapPPC64) { 3137 __ bne_predict_not_taken(CCR0, Lretry); 3138 } else { 3139 __ bne( CCR0, Lretry); 3140 } 3141 if (RegCollision) __ subf(Rres, Rsrc, Rtmp); 3142 __ fence(); 3143 %} 3144 3145 enc_class enc_GetAndSetI(iRegIdst res, iRegPdst mem_ptr, iRegIsrc src) %{ 3146 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 3147 3148 MacroAssembler _masm(&cbuf); 3149 Register Rtmp = R0; 3150 Register Rres = $res$$Register; 3151 Register Rsrc = $src$$Register; 3152 Register Rptr = $mem_ptr$$Register; 3153 bool RegCollision = (Rres == Rsrc) || (Rres == Rptr); 3154 Register Rold = RegCollision ? Rtmp : Rres; 3155 3156 Label Lretry; 3157 __ bind(Lretry); 3158 __ lwarx(Rold, Rptr, MacroAssembler::cmpxchgx_hint_atomic_update()); 3159 __ stwcx_(Rsrc, Rptr); 3160 if (UseStaticBranchPredictionInCompareAndSwapPPC64) { 3161 __ bne_predict_not_taken(CCR0, Lretry); 3162 } else { 3163 __ bne( CCR0, Lretry); 3164 } 3165 if (RegCollision) __ mr(Rres, Rtmp); 3166 __ fence(); 3167 %} 3168 3169 enc_class enc_GetAndSetL(iRegLdst res, iRegPdst mem_ptr, iRegLsrc src) %{ 3170 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 3171 3172 MacroAssembler _masm(&cbuf); 3173 Register Rtmp = R0; 3174 Register Rres = $res$$Register; 3175 Register Rsrc = $src$$Register; 3176 Register Rptr = $mem_ptr$$Register; 3177 bool RegCollision = (Rres == Rsrc) || (Rres == Rptr); 3178 Register Rold = RegCollision ? Rtmp : Rres; 3179 3180 Label Lretry; 3181 __ bind(Lretry); 3182 __ ldarx(Rold, Rptr, MacroAssembler::cmpxchgx_hint_atomic_update()); 3183 __ stdcx_(Rsrc, Rptr); 3184 if (UseStaticBranchPredictionInCompareAndSwapPPC64) { 3185 __ bne_predict_not_taken(CCR0, Lretry); 3186 } else { 3187 __ bne( CCR0, Lretry); 3188 } 3189 if (RegCollision) __ mr(Rres, Rtmp); 3190 __ fence(); 3191 %} 3192 3193 // This enc_class is needed so that scheduler gets proper 3194 // input mapping for latency computation. 3195 enc_class enc_andc(iRegIdst dst, iRegIsrc src1, iRegIsrc src2) %{ 3196 // TODO: PPC port $archOpcode(ppc64Opcode_andc); 3197 MacroAssembler _masm(&cbuf); 3198 __ andc($dst$$Register, $src1$$Register, $src2$$Register); 3199 %} 3200 3201 enc_class enc_convI2B_regI__cmove(iRegIdst dst, iRegIsrc src, flagsReg crx, immI16 zero, immI16 notzero) %{ 3202 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 3203 3204 MacroAssembler _masm(&cbuf); 3205 3206 Label done; 3207 __ cmpwi($crx$$CondRegister, $src$$Register, 0); 3208 __ li($dst$$Register, $zero$$constant); 3209 __ beq($crx$$CondRegister, done); 3210 __ li($dst$$Register, $notzero$$constant); 3211 __ bind(done); 3212 %} 3213 3214 enc_class enc_convP2B_regP__cmove(iRegIdst dst, iRegPsrc src, flagsReg crx, immI16 zero, immI16 notzero) %{ 3215 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 3216 3217 MacroAssembler _masm(&cbuf); 3218 3219 Label done; 3220 __ cmpdi($crx$$CondRegister, $src$$Register, 0); 3221 __ li($dst$$Register, $zero$$constant); 3222 __ beq($crx$$CondRegister, done); 3223 __ li($dst$$Register, $notzero$$constant); 3224 __ bind(done); 3225 %} 3226 3227 enc_class enc_cmove_bso_stackSlotL(iRegLdst dst, flagsReg crx, stackSlotL mem ) %{ 3228 // TODO: PPC port $archOpcode(ppc64Opcode_cmove); 3229 3230 MacroAssembler _masm(&cbuf); 3231 int Idisp = $mem$$disp + frame_slots_bias($mem$$base, ra_); 3232 Label done; 3233 __ bso($crx$$CondRegister, done); 3234 __ ld($dst$$Register, Idisp, $mem$$base$$Register); 3235 // TODO PPC port __ endgroup_if_needed(_size == 12); 3236 __ bind(done); 3237 %} 3238 3239 enc_class enc_bc(flagsReg crx, cmpOp cmp, Label lbl) %{ 3240 // TODO: PPC port $archOpcode(ppc64Opcode_bc); 3241 3242 MacroAssembler _masm(&cbuf); 3243 Label d; // dummy 3244 __ bind(d); 3245 Label* p = ($lbl$$label); 3246 // `p' is `NULL' when this encoding class is used only to 3247 // determine the size of the encoded instruction. 3248 Label& l = (NULL == p)? d : *(p); 3249 int cc = $cmp$$cmpcode; 3250 int flags_reg = $crx$$reg; 3251 assert((Assembler::bcondCRbiIs1 & ~Assembler::bcondCRbiIs0) == 8, "check encoding"); 3252 int bhint = Assembler::bhintNoHint; 3253 3254 if (UseStaticBranchPredictionForUncommonPathsPPC64) { 3255 if (_prob <= PROB_NEVER) { 3256 bhint = Assembler::bhintIsNotTaken; 3257 } else if (_prob >= PROB_ALWAYS) { 3258 bhint = Assembler::bhintIsTaken; 3259 } 3260 } 3261 3262 __ bc(Assembler::add_bhint_to_boint(bhint, cc_to_boint(cc)), 3263 cc_to_biint(cc, flags_reg), 3264 l); 3265 %} 3266 3267 enc_class enc_bc_far(flagsReg crx, cmpOp cmp, Label lbl) %{ 3268 // The scheduler doesn't know about branch shortening, so we set the opcode 3269 // to ppc64Opcode_bc in order to hide this detail from the scheduler. 3270 // TODO: PPC port $archOpcode(ppc64Opcode_bc); 3271 3272 MacroAssembler _masm(&cbuf); 3273 Label d; // dummy 3274 __ bind(d); 3275 Label* p = ($lbl$$label); 3276 // `p' is `NULL' when this encoding class is used only to 3277 // determine the size of the encoded instruction. 3278 Label& l = (NULL == p)? d : *(p); 3279 int cc = $cmp$$cmpcode; 3280 int flags_reg = $crx$$reg; 3281 int bhint = Assembler::bhintNoHint; 3282 3283 if (UseStaticBranchPredictionForUncommonPathsPPC64) { 3284 if (_prob <= PROB_NEVER) { 3285 bhint = Assembler::bhintIsNotTaken; 3286 } else if (_prob >= PROB_ALWAYS) { 3287 bhint = Assembler::bhintIsTaken; 3288 } 3289 } 3290 3291 // Tell the conditional far branch to optimize itself when being relocated. 3292 __ bc_far(Assembler::add_bhint_to_boint(bhint, cc_to_boint(cc)), 3293 cc_to_biint(cc, flags_reg), 3294 l, 3295 MacroAssembler::bc_far_optimize_on_relocate); 3296 %} 3297 3298 // Branch used with Power6 scheduling (can be shortened without changing the node). 3299 enc_class enc_bc_short_far(flagsReg crx, cmpOp cmp, Label lbl) %{ 3300 // The scheduler doesn't know about branch shortening, so we set the opcode 3301 // to ppc64Opcode_bc in order to hide this detail from the scheduler. 3302 // TODO: PPC port $archOpcode(ppc64Opcode_bc); 3303 3304 MacroAssembler _masm(&cbuf); 3305 Label d; // dummy 3306 __ bind(d); 3307 Label* p = ($lbl$$label); 3308 // `p' is `NULL' when this encoding class is used only to 3309 // determine the size of the encoded instruction. 3310 Label& l = (NULL == p)? d : *(p); 3311 int cc = $cmp$$cmpcode; 3312 int flags_reg = $crx$$reg; 3313 int bhint = Assembler::bhintNoHint; 3314 3315 if (UseStaticBranchPredictionForUncommonPathsPPC64) { 3316 if (_prob <= PROB_NEVER) { 3317 bhint = Assembler::bhintIsNotTaken; 3318 } else if (_prob >= PROB_ALWAYS) { 3319 bhint = Assembler::bhintIsTaken; 3320 } 3321 } 3322 3323 #if 0 // TODO: PPC port 3324 if (_size == 8) { 3325 // Tell the conditional far branch to optimize itself when being relocated. 3326 __ bc_far(Assembler::add_bhint_to_boint(bhint, cc_to_boint(cc)), 3327 cc_to_biint(cc, flags_reg), 3328 l, 3329 MacroAssembler::bc_far_optimize_on_relocate); 3330 } else { 3331 __ bc (Assembler::add_bhint_to_boint(bhint, cc_to_boint(cc)), 3332 cc_to_biint(cc, flags_reg), 3333 l); 3334 } 3335 #endif 3336 Unimplemented(); 3337 %} 3338 3339 // Postalloc expand emitter for loading a replicatef float constant from 3340 // the method's TOC. 3341 // Enc_class needed as consttanttablebase is not supported by postalloc 3342 // expand. 3343 enc_class postalloc_expand_load_replF_constant(iRegLdst dst, immF src, iRegLdst toc) %{ 3344 // Create new nodes. 3345 3346 // Make an operand with the bit pattern to load as float. 3347 immLOper *op_repl = new (C) immLOper((jlong)replicate_immF(op_src->constantF())); 3348 3349 loadConLNodesTuple loadConLNodes = 3350 loadConLNodesTuple_create(C, ra_, n_toc, op_repl, 3351 ra_->get_reg_second(this), ra_->get_reg_first(this)); 3352 3353 // Push new nodes. 3354 if (loadConLNodes._large_hi) nodes->push(loadConLNodes._large_hi); 3355 if (loadConLNodes._last) nodes->push(loadConLNodes._last); 3356 3357 assert(nodes->length() >= 1, "must have created at least 1 node"); 3358 assert(loadConLNodes._last->bottom_type()->isa_long(), "must be long"); 3359 %} 3360 3361 // This enc_class is needed so that scheduler gets proper 3362 // input mapping for latency computation. 3363 enc_class enc_poll(immI dst, iRegLdst poll) %{ 3364 // TODO: PPC port $archOpcode(ppc64Opcode_ld); 3365 // Fake operand dst needed for PPC scheduler. 3366 assert($dst$$constant == 0x0, "dst must be 0x0"); 3367 3368 MacroAssembler _masm(&cbuf); 3369 // Mark the code position where the load from the safepoint 3370 // polling page was emitted as relocInfo::poll_type. 3371 __ relocate(relocInfo::poll_type); 3372 __ load_from_polling_page($poll$$Register); 3373 %} 3374 3375 // A Java static call or a runtime call. 3376 // 3377 // Branch-and-link relative to a trampoline. 3378 // The trampoline loads the target address and does a long branch to there. 3379 // In case we call java, the trampoline branches to a interpreter_stub 3380 // which loads the inline cache and the real call target from the constant pool. 3381 // 3382 // This basically looks like this: 3383 // 3384 // >>>> consts -+ -+ 3385 // | |- offset1 3386 // [call target1] | <-+ 3387 // [IC cache] |- offset2 3388 // [call target2] <--+ 3389 // 3390 // <<<< consts 3391 // >>>> insts 3392 // 3393 // bl offset16 -+ -+ ??? // How many bits available? 3394 // | | 3395 // <<<< insts | | 3396 // >>>> stubs | | 3397 // | |- trampoline_stub_Reloc 3398 // trampoline stub: | <-+ 3399 // r2 = toc | 3400 // r2 = [r2 + offset1] | // Load call target1 from const section 3401 // mtctr r2 | 3402 // bctr |- static_stub_Reloc 3403 // comp_to_interp_stub: <---+ 3404 // r1 = toc 3405 // ICreg = [r1 + IC_offset] // Load IC from const section 3406 // r1 = [r1 + offset2] // Load call target2 from const section 3407 // mtctr r1 3408 // bctr 3409 // 3410 // <<<< stubs 3411 // 3412 // The call instruction in the code either 3413 // - Branches directly to a compiled method if the offset is encodable in instruction. 3414 // - Branches to the trampoline stub if the offset to the compiled method is not encodable. 3415 // - Branches to the compiled_to_interp stub if the target is interpreted. 3416 // 3417 // Further there are three relocations from the loads to the constants in 3418 // the constant section. 3419 // 3420 // Usage of r1 and r2 in the stubs allows to distinguish them. 3421 enc_class enc_java_static_call(method meth) %{ 3422 // TODO: PPC port $archOpcode(ppc64Opcode_bl); 3423 3424 MacroAssembler _masm(&cbuf); 3425 address entry_point = (address)$meth$$method; 3426 3427 if (!_method) { 3428 // A call to a runtime wrapper, e.g. new, new_typeArray_Java, uncommon_trap. 3429 emit_call_with_trampoline_stub(_masm, entry_point, relocInfo::runtime_call_type); 3430 } else { 3431 // Remember the offset not the address. 3432 const int start_offset = __ offset(); 3433 // The trampoline stub. 3434 if (!Compile::current()->in_scratch_emit_size()) { 3435 // No entry point given, use the current pc. 3436 // Make sure branch fits into 3437 if (entry_point == 0) entry_point = __ pc(); 3438 3439 // Put the entry point as a constant into the constant pool. 3440 const address entry_point_toc_addr = __ address_constant(entry_point, RelocationHolder::none); 3441 const int entry_point_toc_offset = __ offset_to_method_toc(entry_point_toc_addr); 3442 3443 // Emit the trampoline stub which will be related to the branch-and-link below. 3444 emit_trampoline_stub(_masm, entry_point_toc_offset, start_offset); 3445 __ relocate(_optimized_virtual ? 3446 relocInfo::opt_virtual_call_type : relocInfo::static_call_type); 3447 } 3448 3449 // The real call. 3450 // Note: At this point we do not have the address of the trampoline 3451 // stub, and the entry point might be too far away for bl, so __ pc() 3452 // serves as dummy and the bl will be patched later. 3453 cbuf.set_insts_mark(); 3454 __ bl(__ pc()); // Emits a relocation. 3455 3456 // The stub for call to interpreter. 3457 CompiledStaticCall::emit_to_interp_stub(cbuf); 3458 } 3459 %} 3460 3461 // Emit a method handle call. 3462 // 3463 // Method handle calls from compiled to compiled are going thru a 3464 // c2i -> i2c adapter, extending the frame for their arguments. The 3465 // caller however, returns directly to the compiled callee, that has 3466 // to cope with the extended frame. We restore the original frame by 3467 // loading the callers sp and adding the calculated framesize. 3468 enc_class enc_java_handle_call(method meth) %{ 3469 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 3470 3471 MacroAssembler _masm(&cbuf); 3472 address entry_point = (address)$meth$$method; 3473 3474 // Remember the offset not the address. 3475 const int start_offset = __ offset(); 3476 // The trampoline stub. 3477 if (!ra_->C->in_scratch_emit_size()) { 3478 // No entry point given, use the current pc. 3479 // Make sure branch fits into 3480 if (entry_point == 0) entry_point = __ pc(); 3481 3482 // Put the entry point as a constant into the constant pool. 3483 const address entry_point_toc_addr = __ address_constant(entry_point, RelocationHolder::none); 3484 const int entry_point_toc_offset = __ offset_to_method_toc(entry_point_toc_addr); 3485 3486 // Emit the trampoline stub which will be related to the branch-and-link below. 3487 emit_trampoline_stub(_masm, entry_point_toc_offset, start_offset); 3488 assert(_optimized_virtual, "methodHandle call should be a virtual call"); 3489 __ relocate(relocInfo::opt_virtual_call_type); 3490 } 3491 3492 // The real call. 3493 // Note: At this point we do not have the address of the trampoline 3494 // stub, and the entry point might be too far away for bl, so __ pc() 3495 // serves as dummy and the bl will be patched later. 3496 cbuf.set_insts_mark(); 3497 __ bl(__ pc()); // Emits a relocation. 3498 3499 assert(_method, "execute next statement conditionally"); 3500 // The stub for call to interpreter. 3501 CompiledStaticCall::emit_to_interp_stub(cbuf); 3502 3503 // Restore original sp. 3504 __ ld(R11_scratch1, 0, R1_SP); // Load caller sp. 3505 const long framesize = ra_->C->frame_slots() << LogBytesPerInt; 3506 unsigned int bytes = (unsigned int)framesize; 3507 long offset = Assembler::align_addr(bytes, frame::alignment_in_bytes); 3508 if (Assembler::is_simm(-offset, 16)) { 3509 __ addi(R1_SP, R11_scratch1, -offset); 3510 } else { 3511 __ load_const_optimized(R12_scratch2, -offset); 3512 __ add(R1_SP, R11_scratch1, R12_scratch2); 3513 } 3514 #ifdef ASSERT 3515 __ ld(R12_scratch2, 0, R1_SP); // Load from unextended_sp. 3516 __ cmpd(CCR0, R11_scratch1, R12_scratch2); 3517 __ asm_assert_eq("backlink changed", 0x8000); 3518 #endif 3519 // If fails should store backlink before unextending. 3520 3521 if (ra_->C->env()->failing()) { 3522 return; 3523 } 3524 %} 3525 3526 // Second node of expanded dynamic call - the call. 3527 enc_class enc_java_dynamic_call_sched(method meth) %{ 3528 // TODO: PPC port $archOpcode(ppc64Opcode_bl); 3529 3530 MacroAssembler _masm(&cbuf); 3531 3532 if (!ra_->C->in_scratch_emit_size()) { 3533 // Create a call trampoline stub for the given method. 3534 const address entry_point = !($meth$$method) ? 0 : (address)$meth$$method; 3535 const address entry_point_const = __ address_constant(entry_point, RelocationHolder::none); 3536 const int entry_point_const_toc_offset = __ offset_to_method_toc(entry_point_const); 3537 emit_trampoline_stub(_masm, entry_point_const_toc_offset, __ offset()); 3538 3539 if (ra_->C->env()->failing()) 3540 return; 3541 3542 // Build relocation at call site with ic position as data. 3543 assert((_load_ic_hi_node != NULL && _load_ic_node == NULL) || 3544 (_load_ic_hi_node == NULL && _load_ic_node != NULL), 3545 "must have one, but can't have both"); 3546 assert((_load_ic_hi_node != NULL && _load_ic_hi_node->_cbuf_insts_offset != -1) || 3547 (_load_ic_node != NULL && _load_ic_node->_cbuf_insts_offset != -1), 3548 "must contain instruction offset"); 3549 const int virtual_call_oop_addr_offset = _load_ic_hi_node != NULL 3550 ? _load_ic_hi_node->_cbuf_insts_offset 3551 : _load_ic_node->_cbuf_insts_offset; 3552 const address virtual_call_oop_addr = __ addr_at(virtual_call_oop_addr_offset); 3553 assert(MacroAssembler::is_load_const_from_method_toc_at(virtual_call_oop_addr), 3554 "should be load from TOC"); 3555 3556 __ relocate(virtual_call_Relocation::spec(virtual_call_oop_addr)); 3557 } 3558 3559 // At this point I do not have the address of the trampoline stub, 3560 // and the entry point might be too far away for bl. Pc() serves 3561 // as dummy and bl will be patched later. 3562 __ bl((address) __ pc()); 3563 %} 3564 3565 // postalloc expand emitter for virtual calls. 3566 enc_class postalloc_expand_java_dynamic_call_sched(method meth, iRegLdst toc) %{ 3567 3568 // Create the nodes for loading the IC from the TOC. 3569 loadConLNodesTuple loadConLNodes_IC = 3570 loadConLNodesTuple_create(C, ra_, n_toc, new (C) immLOper((jlong)Universe::non_oop_word()), 3571 OptoReg::Name(R19_H_num), OptoReg::Name(R19_num)); 3572 3573 // Create the call node. 3574 CallDynamicJavaDirectSchedNode *call = new (C) CallDynamicJavaDirectSchedNode(); 3575 call->_method_handle_invoke = _method_handle_invoke; 3576 call->_vtable_index = _vtable_index; 3577 call->_method = _method; 3578 call->_bci = _bci; 3579 call->_optimized_virtual = _optimized_virtual; 3580 call->_tf = _tf; 3581 call->_entry_point = _entry_point; 3582 call->_cnt = _cnt; 3583 call->_argsize = _argsize; 3584 call->_oop_map = _oop_map; 3585 call->_jvms = _jvms; 3586 call->_jvmadj = _jvmadj; 3587 call->_in_rms = _in_rms; 3588 call->_nesting = _nesting; 3589 3590 // New call needs all inputs of old call. 3591 // Req... 3592 for (uint i = 0; i < req(); ++i) { 3593 // The expanded node does not need toc any more. 3594 // Add the inline cache constant here instead. This expresses the 3595 // register of the inline cache must be live at the call. 3596 // Else we would have to adapt JVMState by -1. 3597 if (i == mach_constant_base_node_input()) { 3598 call->add_req(loadConLNodes_IC._last); 3599 } else { 3600 call->add_req(in(i)); 3601 } 3602 } 3603 // ...as well as prec 3604 for (uint i = req(); i < len(); ++i) { 3605 call->add_prec(in(i)); 3606 } 3607 3608 // Remember nodes loading the inline cache into r19. 3609 call->_load_ic_hi_node = loadConLNodes_IC._large_hi; 3610 call->_load_ic_node = loadConLNodes_IC._small; 3611 3612 // Operands for new nodes. 3613 call->_opnds[0] = _opnds[0]; 3614 call->_opnds[1] = _opnds[1]; 3615 3616 // Only the inline cache is associated with a register. 3617 assert(Matcher::inline_cache_reg() == OptoReg::Name(R19_num), "ic reg should be R19"); 3618 3619 // Push new nodes. 3620 if (loadConLNodes_IC._large_hi) nodes->push(loadConLNodes_IC._large_hi); 3621 if (loadConLNodes_IC._last) nodes->push(loadConLNodes_IC._last); 3622 nodes->push(call); 3623 %} 3624 3625 // Compound version of call dynamic 3626 enc_class enc_java_dynamic_call(method meth, iRegLdst toc) %{ 3627 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 3628 MacroAssembler _masm(&cbuf); 3629 int start_offset = __ offset(); 3630 3631 Register Rtoc = (ra_) ? $constanttablebase : R2_TOC; 3632 #if 0 3633 if (_vtable_index < 0) { 3634 // Must be invalid_vtable_index, not nonvirtual_vtable_index. 3635 assert(_vtable_index == Method::invalid_vtable_index, "correct sentinel value"); 3636 Register ic_reg = as_Register(Matcher::inline_cache_reg_encode()); 3637 AddressLiteral meta = __ allocate_metadata_address((Metadata *)Universe::non_oop_word()); 3638 3639 address virtual_call_meta_addr = __ pc(); 3640 __ load_const_from_method_toc(ic_reg, meta, Rtoc); 3641 // CALL to fixup routine. Fixup routine uses ScopeDesc info 3642 // to determine who we intended to call. 3643 __ relocate(virtual_call_Relocation::spec(virtual_call_meta_addr)); 3644 emit_call_with_trampoline_stub(_masm, (address)$meth$$method, relocInfo::none); 3645 assert(((MachCallDynamicJavaNode*)this)->ret_addr_offset() == __ offset() - start_offset, 3646 "Fix constant in ret_addr_offset()"); 3647 } else { 3648 assert(!UseInlineCaches, "expect vtable calls only if not using ICs"); 3649 // Go thru the vtable. Get receiver klass. Receiver already 3650 // checked for non-null. If we'll go thru a C2I adapter, the 3651 // interpreter expects method in R19_method. 3652 3653 __ load_klass(R11_scratch1, R3); 3654 3655 int entry_offset = InstanceKlass::vtable_start_offset() + _vtable_index * vtableEntry::size(); 3656 int v_off = entry_offset * wordSize + vtableEntry::method_offset_in_bytes(); 3657 __ li(R19_method, v_off); 3658 __ ldx(R19_method/*method oop*/, R19_method/*method offset*/, R11_scratch1/*class*/); 3659 // NOTE: for vtable dispatches, the vtable entry will never be 3660 // null. However it may very well end up in handle_wrong_method 3661 // if the method is abstract for the particular class. 3662 __ ld(R11_scratch1, in_bytes(Method::from_compiled_offset()), R19_method); 3663 // Call target. Either compiled code or C2I adapter. 3664 __ mtctr(R11_scratch1); 3665 __ bctrl(); 3666 if (((MachCallDynamicJavaNode*)this)->ret_addr_offset() != __ offset() - start_offset) { 3667 tty->print(" %d, %d\n", ((MachCallDynamicJavaNode*)this)->ret_addr_offset(),__ offset() - start_offset); 3668 } 3669 assert(((MachCallDynamicJavaNode*)this)->ret_addr_offset() == __ offset() - start_offset, 3670 "Fix constant in ret_addr_offset()"); 3671 } 3672 #endif 3673 guarantee(0, "Fix handling of toc edge: messes up derived/base pairs."); 3674 Unimplemented(); // ret_addr_offset not yet fixed. Depends on compressed oops (load klass!). 3675 %} 3676 3677 // a runtime call 3678 enc_class enc_java_to_runtime_call (method meth) %{ 3679 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 3680 3681 MacroAssembler _masm(&cbuf); 3682 const address start_pc = __ pc(); 3683 3684 #if defined(ABI_ELFv2) 3685 address entry= !($meth$$method) ? NULL : (address)$meth$$method; 3686 __ call_c(entry, relocInfo::runtime_call_type); 3687 #else 3688 // The function we're going to call. 3689 FunctionDescriptor fdtemp; 3690 const FunctionDescriptor* fd = !($meth$$method) ? &fdtemp : (FunctionDescriptor*)$meth$$method; 3691 3692 Register Rtoc = R12_scratch2; 3693 // Calculate the method's TOC. 3694 __ calculate_address_from_global_toc(Rtoc, __ method_toc()); 3695 // Put entry, env, toc into the constant pool, this needs up to 3 constant 3696 // pool entries; call_c_using_toc will optimize the call. 3697 __ call_c_using_toc(fd, relocInfo::runtime_call_type, Rtoc); 3698 #endif 3699 3700 // Check the ret_addr_offset. 3701 assert(((MachCallRuntimeNode*)this)->ret_addr_offset() == __ last_calls_return_pc() - start_pc, 3702 "Fix constant in ret_addr_offset()"); 3703 %} 3704 3705 // Move to ctr for leaf call. 3706 // This enc_class is needed so that scheduler gets proper 3707 // input mapping for latency computation. 3708 enc_class enc_leaf_call_mtctr(iRegLsrc src) %{ 3709 // TODO: PPC port $archOpcode(ppc64Opcode_mtctr); 3710 MacroAssembler _masm(&cbuf); 3711 __ mtctr($src$$Register); 3712 %} 3713 3714 // Postalloc expand emitter for runtime leaf calls. 3715 enc_class postalloc_expand_java_to_runtime_call(method meth, iRegLdst toc) %{ 3716 loadConLNodesTuple loadConLNodes_Entry; 3717 #if defined(ABI_ELFv2) 3718 jlong entry_address = (jlong) this->entry_point(); 3719 assert(entry_address, "need address here"); 3720 loadConLNodes_Entry = loadConLNodesTuple_create(C, ra_, n_toc, new (C) immLOper(entry_address), 3721 OptoReg::Name(R12_H_num), OptoReg::Name(R12_num)); 3722 #else 3723 // Get the struct that describes the function we are about to call. 3724 FunctionDescriptor* fd = (FunctionDescriptor*) this->entry_point(); 3725 assert(fd, "need fd here"); 3726 jlong entry_address = (jlong) fd->entry(); 3727 // new nodes 3728 loadConLNodesTuple loadConLNodes_Env; 3729 loadConLNodesTuple loadConLNodes_Toc; 3730 3731 // Create nodes and operands for loading the entry point. 3732 loadConLNodes_Entry = loadConLNodesTuple_create(C, ra_, n_toc, new (C) immLOper(entry_address), 3733 OptoReg::Name(R12_H_num), OptoReg::Name(R12_num)); 3734 3735 3736 // Create nodes and operands for loading the env pointer. 3737 if (fd->env() != NULL) { 3738 loadConLNodes_Env = loadConLNodesTuple_create(C, ra_, n_toc, new (C) immLOper((jlong) fd->env()), 3739 OptoReg::Name(R11_H_num), OptoReg::Name(R11_num)); 3740 } else { 3741 loadConLNodes_Env._large_hi = NULL; 3742 loadConLNodes_Env._large_lo = NULL; 3743 loadConLNodes_Env._small = NULL; 3744 loadConLNodes_Env._last = new (C) loadConL16Node(); 3745 loadConLNodes_Env._last->_opnds[0] = new (C) iRegLdstOper(); 3746 loadConLNodes_Env._last->_opnds[1] = new (C) immL16Oper(0); 3747 ra_->set_pair(loadConLNodes_Env._last->_idx, OptoReg::Name(R11_H_num), OptoReg::Name(R11_num)); 3748 } 3749 3750 // Create nodes and operands for loading the Toc point. 3751 loadConLNodes_Toc = loadConLNodesTuple_create(C, ra_, n_toc, new (C) immLOper((jlong) fd->toc()), 3752 OptoReg::Name(R2_H_num), OptoReg::Name(R2_num)); 3753 #endif // ABI_ELFv2 3754 // mtctr node 3755 MachNode *mtctr = new (C) CallLeafDirect_mtctrNode(); 3756 3757 assert(loadConLNodes_Entry._last != NULL, "entry must exist"); 3758 mtctr->add_req(0, loadConLNodes_Entry._last); 3759 3760 mtctr->_opnds[0] = new (C) iRegLdstOper(); 3761 mtctr->_opnds[1] = new (C) iRegLdstOper(); 3762 3763 // call node 3764 MachCallLeafNode *call = new (C) CallLeafDirectNode(); 3765 3766 call->_opnds[0] = _opnds[0]; 3767 call->_opnds[1] = new (C) methodOper((intptr_t) entry_address); // May get set later. 3768 3769 // Make the new call node look like the old one. 3770 call->_name = _name; 3771 call->_tf = _tf; 3772 call->_entry_point = _entry_point; 3773 call->_cnt = _cnt; 3774 call->_argsize = _argsize; 3775 call->_oop_map = _oop_map; 3776 guarantee(!_jvms, "You must clone the jvms and adapt the offsets by fix_jvms()."); 3777 call->_jvms = NULL; 3778 call->_jvmadj = _jvmadj; 3779 call->_in_rms = _in_rms; 3780 call->_nesting = _nesting; 3781 3782 3783 // New call needs all inputs of old call. 3784 // Req... 3785 for (uint i = 0; i < req(); ++i) { 3786 if (i != mach_constant_base_node_input()) { 3787 call->add_req(in(i)); 3788 } 3789 } 3790 3791 // These must be reqired edges, as the registers are live up to 3792 // the call. Else the constants are handled as kills. 3793 call->add_req(mtctr); 3794 #if !defined(ABI_ELFv2) 3795 call->add_req(loadConLNodes_Env._last); 3796 call->add_req(loadConLNodes_Toc._last); 3797 #endif 3798 3799 // ...as well as prec 3800 for (uint i = req(); i < len(); ++i) { 3801 call->add_prec(in(i)); 3802 } 3803 3804 // registers 3805 ra_->set1(mtctr->_idx, OptoReg::Name(SR_CTR_num)); 3806 3807 // Insert the new nodes. 3808 if (loadConLNodes_Entry._large_hi) nodes->push(loadConLNodes_Entry._large_hi); 3809 if (loadConLNodes_Entry._last) nodes->push(loadConLNodes_Entry._last); 3810 #if !defined(ABI_ELFv2) 3811 if (loadConLNodes_Env._large_hi) nodes->push(loadConLNodes_Env._large_hi); 3812 if (loadConLNodes_Env._last) nodes->push(loadConLNodes_Env._last); 3813 if (loadConLNodes_Toc._large_hi) nodes->push(loadConLNodes_Toc._large_hi); 3814 if (loadConLNodes_Toc._last) nodes->push(loadConLNodes_Toc._last); 3815 #endif 3816 nodes->push(mtctr); 3817 nodes->push(call); 3818 %} 3819 %} 3820 3821 //----------FRAME-------------------------------------------------------------- 3822 // Definition of frame structure and management information. 3823 3824 frame %{ 3825 // What direction does stack grow in (assumed to be same for native & Java). 3826 stack_direction(TOWARDS_LOW); 3827 3828 // These two registers define part of the calling convention between 3829 // compiled code and the interpreter. 3830 3831 // Inline Cache Register or method for I2C. 3832 inline_cache_reg(R19); // R19_method 3833 3834 // Method Oop Register when calling interpreter. 3835 interpreter_method_oop_reg(R19); // R19_method 3836 3837 // Optional: name the operand used by cisc-spilling to access 3838 // [stack_pointer + offset]. 3839 cisc_spilling_operand_name(indOffset); 3840 3841 // Number of stack slots consumed by a Monitor enter. 3842 sync_stack_slots((frame::jit_monitor_size / VMRegImpl::stack_slot_size)); 3843 3844 // Compiled code's Frame Pointer. 3845 frame_pointer(R1); // R1_SP 3846 3847 // Interpreter stores its frame pointer in a register which is 3848 // stored to the stack by I2CAdaptors. I2CAdaptors convert from 3849 // interpreted java to compiled java. 3850 // 3851 // R14_state holds pointer to caller's cInterpreter. 3852 interpreter_frame_pointer(R14); // R14_state 3853 3854 stack_alignment(frame::alignment_in_bytes); 3855 3856 in_preserve_stack_slots((frame::jit_in_preserve_size / VMRegImpl::stack_slot_size)); 3857 3858 // Number of outgoing stack slots killed above the 3859 // out_preserve_stack_slots for calls to C. Supports the var-args 3860 // backing area for register parms. 3861 // 3862 varargs_C_out_slots_killed(((frame::abi_reg_args_size - frame::jit_out_preserve_size) / VMRegImpl::stack_slot_size)); 3863 3864 // The after-PROLOG location of the return address. Location of 3865 // return address specifies a type (REG or STACK) and a number 3866 // representing the register number (i.e. - use a register name) or 3867 // stack slot. 3868 // 3869 // A: Link register is stored in stack slot ... 3870 // M: ... but it's in the caller's frame according to PPC-64 ABI. 3871 // J: Therefore, we make sure that the link register is also in R11_scratch1 3872 // at the end of the prolog. 3873 // B: We use R20, now. 3874 //return_addr(REG R20); 3875 3876 // G: After reading the comments made by all the luminaries on their 3877 // failure to tell the compiler where the return address really is, 3878 // I hardly dare to try myself. However, I'm convinced it's in slot 3879 // 4 what apparently works and saves us some spills. 3880 return_addr(STACK 4); 3881 3882 // This is the body of the function 3883 // 3884 // void Matcher::calling_convention(OptoRegPair* sig, // array of ideal regs 3885 // uint length, // length of array 3886 // bool is_outgoing) 3887 // 3888 // The `sig' array is to be updated. sig[j] represents the location 3889 // of the j-th argument, either a register or a stack slot. 3890 3891 // Comment taken from i486.ad: 3892 // Body of function which returns an integer array locating 3893 // arguments either in registers or in stack slots. Passed an array 3894 // of ideal registers called "sig" and a "length" count. Stack-slot 3895 // offsets are based on outgoing arguments, i.e. a CALLER setting up 3896 // arguments for a CALLEE. Incoming stack arguments are 3897 // automatically biased by the preserve_stack_slots field above. 3898 calling_convention %{ 3899 // No difference between ingoing/outgoing. Just pass false. 3900 SharedRuntime::java_calling_convention(sig_bt, regs, length, false); 3901 %} 3902 3903 // Comment taken from i486.ad: 3904 // Body of function which returns an integer array locating 3905 // arguments either in registers or in stack slots. Passed an array 3906 // of ideal registers called "sig" and a "length" count. Stack-slot 3907 // offsets are based on outgoing arguments, i.e. a CALLER setting up 3908 // arguments for a CALLEE. Incoming stack arguments are 3909 // automatically biased by the preserve_stack_slots field above. 3910 c_calling_convention %{ 3911 // This is obviously always outgoing. 3912 // C argument in register AND stack slot. 3913 (void) SharedRuntime::c_calling_convention(sig_bt, regs, /*regs2=*/NULL, length); 3914 %} 3915 3916 // Location of native (C/C++) and interpreter return values. This 3917 // is specified to be the same as Java. In the 32-bit VM, long 3918 // values are actually returned from native calls in O0:O1 and 3919 // returned to the interpreter in I0:I1. The copying to and from 3920 // the register pairs is done by the appropriate call and epilog 3921 // opcodes. This simplifies the register allocator. 3922 c_return_value %{ 3923 assert((ideal_reg >= Op_RegI && ideal_reg <= Op_RegL) || 3924 (ideal_reg == Op_RegN && Universe::narrow_oop_base() == NULL && Universe::narrow_oop_shift() == 0), 3925 "only return normal values"); 3926 // enum names from opcodes.hpp: Op_Node Op_Set Op_RegN Op_RegI Op_RegP Op_RegF Op_RegD Op_RegL 3927 static int typeToRegLo[Op_RegL+1] = { 0, 0, R3_num, R3_num, R3_num, F1_num, F1_num, R3_num }; 3928 static int typeToRegHi[Op_RegL+1] = { 0, 0, OptoReg::Bad, R3_H_num, R3_H_num, OptoReg::Bad, F1_H_num, R3_H_num }; 3929 return OptoRegPair(typeToRegHi[ideal_reg], typeToRegLo[ideal_reg]); 3930 %} 3931 3932 // Location of compiled Java return values. Same as C 3933 return_value %{ 3934 assert((ideal_reg >= Op_RegI && ideal_reg <= Op_RegL) || 3935 (ideal_reg == Op_RegN && Universe::narrow_oop_base() == NULL && Universe::narrow_oop_shift() == 0), 3936 "only return normal values"); 3937 // enum names from opcodes.hpp: Op_Node Op_Set Op_RegN Op_RegI Op_RegP Op_RegF Op_RegD Op_RegL 3938 static int typeToRegLo[Op_RegL+1] = { 0, 0, R3_num, R3_num, R3_num, F1_num, F1_num, R3_num }; 3939 static int typeToRegHi[Op_RegL+1] = { 0, 0, OptoReg::Bad, R3_H_num, R3_H_num, OptoReg::Bad, F1_H_num, R3_H_num }; 3940 return OptoRegPair(typeToRegHi[ideal_reg], typeToRegLo[ideal_reg]); 3941 %} 3942 %} 3943 3944 3945 //----------ATTRIBUTES--------------------------------------------------------- 3946 3947 //----------Operand Attributes------------------------------------------------- 3948 op_attrib op_cost(1); // Required cost attribute. 3949 3950 //----------Instruction Attributes--------------------------------------------- 3951 3952 // Cost attribute. required. 3953 ins_attrib ins_cost(DEFAULT_COST); 3954 3955 // Is this instruction a non-matching short branch variant of some 3956 // long branch? Not required. 3957 ins_attrib ins_short_branch(0); 3958 3959 ins_attrib ins_is_TrapBasedCheckNode(true); 3960 3961 // Number of constants. 3962 // This instruction uses the given number of constants 3963 // (optional attribute). 3964 // This is needed to determine in time whether the constant pool will 3965 // exceed 4000 entries. Before postalloc_expand the overall number of constants 3966 // is determined. It's also used to compute the constant pool size 3967 // in Output(). 3968 ins_attrib ins_num_consts(0); 3969 3970 // Required alignment attribute (must be a power of 2) specifies the 3971 // alignment that some part of the instruction (not necessarily the 3972 // start) requires. If > 1, a compute_padding() function must be 3973 // provided for the instruction. 3974 ins_attrib ins_alignment(1); 3975 3976 // Enforce/prohibit rematerializations. 3977 // - If an instruction is attributed with 'ins_cannot_rematerialize(true)' 3978 // then rematerialization of that instruction is prohibited and the 3979 // instruction's value will be spilled if necessary. 3980 // Causes that MachNode::rematerialize() returns false. 3981 // - If an instruction is attributed with 'ins_should_rematerialize(true)' 3982 // then rematerialization should be enforced and a copy of the instruction 3983 // should be inserted if possible; rematerialization is not guaranteed. 3984 // Note: this may result in rematerializations in front of every use. 3985 // Causes that MachNode::rematerialize() can return true. 3986 // (optional attribute) 3987 ins_attrib ins_cannot_rematerialize(false); 3988 ins_attrib ins_should_rematerialize(false); 3989 3990 // Instruction has variable size depending on alignment. 3991 ins_attrib ins_variable_size_depending_on_alignment(false); 3992 3993 // Instruction is a nop. 3994 ins_attrib ins_is_nop(false); 3995 3996 // Instruction is mapped to a MachIfFastLock node (instead of MachFastLock). 3997 ins_attrib ins_use_mach_if_fast_lock_node(false); 3998 3999 // Field for the toc offset of a constant. 4000 // 4001 // This is needed if the toc offset is not encodable as an immediate in 4002 // the PPC load instruction. If so, the upper (hi) bits of the offset are 4003 // added to the toc, and from this a load with immediate is performed. 4004 // With postalloc expand, we get two nodes that require the same offset 4005 // but which don't know about each other. The offset is only known 4006 // when the constant is added to the constant pool during emitting. 4007 // It is generated in the 'hi'-node adding the upper bits, and saved 4008 // in this node. The 'lo'-node has a link to the 'hi'-node and reads 4009 // the offset from there when it gets encoded. 4010 ins_attrib ins_field_const_toc_offset(0); 4011 ins_attrib ins_field_const_toc_offset_hi_node(0); 4012 4013 // A field that can hold the instructions offset in the code buffer. 4014 // Set in the nodes emitter. 4015 ins_attrib ins_field_cbuf_insts_offset(-1); 4016 4017 // Fields for referencing a call's load-IC-node. 4018 // If the toc offset can not be encoded as an immediate in a load, we 4019 // use two nodes. 4020 ins_attrib ins_field_load_ic_hi_node(0); 4021 ins_attrib ins_field_load_ic_node(0); 4022 4023 //----------OPERANDS----------------------------------------------------------- 4024 // Operand definitions must precede instruction definitions for correct 4025 // parsing in the ADLC because operands constitute user defined types 4026 // which are used in instruction definitions. 4027 // 4028 // Formats are generated automatically for constants and base registers. 4029 4030 //----------Simple Operands---------------------------------------------------- 4031 // Immediate Operands 4032 4033 // Integer Immediate: 32-bit 4034 operand immI() %{ 4035 match(ConI); 4036 op_cost(40); 4037 format %{ %} 4038 interface(CONST_INTER); 4039 %} 4040 4041 operand immI8() %{ 4042 predicate(Assembler::is_simm(n->get_int(), 8)); 4043 op_cost(0); 4044 match(ConI); 4045 format %{ %} 4046 interface(CONST_INTER); 4047 %} 4048 4049 // Integer Immediate: 16-bit 4050 operand immI16() %{ 4051 predicate(Assembler::is_simm(n->get_int(), 16)); 4052 op_cost(0); 4053 match(ConI); 4054 format %{ %} 4055 interface(CONST_INTER); 4056 %} 4057 4058 // Integer Immediate: 32-bit, where lowest 16 bits are 0x0000. 4059 operand immIhi16() %{ 4060 predicate(((n->get_int() & 0xffff0000) != 0) && ((n->get_int() & 0xffff) == 0)); 4061 match(ConI); 4062 op_cost(0); 4063 format %{ %} 4064 interface(CONST_INTER); 4065 %} 4066 4067 operand immInegpow2() %{ 4068 predicate(is_power_of_2_long((jlong) (julong) (juint) (-(n->get_int())))); 4069 match(ConI); 4070 op_cost(0); 4071 format %{ %} 4072 interface(CONST_INTER); 4073 %} 4074 4075 operand immIpow2minus1() %{ 4076 predicate(is_power_of_2_long((((jlong) (n->get_int()))+1))); 4077 match(ConI); 4078 op_cost(0); 4079 format %{ %} 4080 interface(CONST_INTER); 4081 %} 4082 4083 operand immIpowerOf2() %{ 4084 predicate(is_power_of_2_long((((jlong) (julong) (juint) (n->get_int()))))); 4085 match(ConI); 4086 op_cost(0); 4087 format %{ %} 4088 interface(CONST_INTER); 4089 %} 4090 4091 // Unsigned Integer Immediate: the values 0-31 4092 operand uimmI5() %{ 4093 predicate(Assembler::is_uimm(n->get_int(), 5)); 4094 match(ConI); 4095 op_cost(0); 4096 format %{ %} 4097 interface(CONST_INTER); 4098 %} 4099 4100 // Unsigned Integer Immediate: 6-bit 4101 operand uimmI6() %{ 4102 predicate(Assembler::is_uimm(n->get_int(), 6)); 4103 match(ConI); 4104 op_cost(0); 4105 format %{ %} 4106 interface(CONST_INTER); 4107 %} 4108 4109 // Unsigned Integer Immediate: 6-bit int, greater than 32 4110 operand uimmI6_ge32() %{ 4111 predicate(Assembler::is_uimm(n->get_int(), 6) && n->get_int() >= 32); 4112 match(ConI); 4113 op_cost(0); 4114 format %{ %} 4115 interface(CONST_INTER); 4116 %} 4117 4118 // Unsigned Integer Immediate: 15-bit 4119 operand uimmI15() %{ 4120 predicate(Assembler::is_uimm(n->get_int(), 15)); 4121 match(ConI); 4122 op_cost(0); 4123 format %{ %} 4124 interface(CONST_INTER); 4125 %} 4126 4127 // Unsigned Integer Immediate: 16-bit 4128 operand uimmI16() %{ 4129 predicate(Assembler::is_uimm(n->get_int(), 16)); 4130 match(ConI); 4131 op_cost(0); 4132 format %{ %} 4133 interface(CONST_INTER); 4134 %} 4135 4136 // constant 'int 0'. 4137 operand immI_0() %{ 4138 predicate(n->get_int() == 0); 4139 match(ConI); 4140 op_cost(0); 4141 format %{ %} 4142 interface(CONST_INTER); 4143 %} 4144 4145 // constant 'int 1'. 4146 operand immI_1() %{ 4147 predicate(n->get_int() == 1); 4148 match(ConI); 4149 op_cost(0); 4150 format %{ %} 4151 interface(CONST_INTER); 4152 %} 4153 4154 // constant 'int -1'. 4155 operand immI_minus1() %{ 4156 predicate(n->get_int() == -1); 4157 match(ConI); 4158 op_cost(0); 4159 format %{ %} 4160 interface(CONST_INTER); 4161 %} 4162 4163 // int value 16. 4164 operand immI_16() %{ 4165 predicate(n->get_int() == 16); 4166 match(ConI); 4167 op_cost(0); 4168 format %{ %} 4169 interface(CONST_INTER); 4170 %} 4171 4172 // int value 24. 4173 operand immI_24() %{ 4174 predicate(n->get_int() == 24); 4175 match(ConI); 4176 op_cost(0); 4177 format %{ %} 4178 interface(CONST_INTER); 4179 %} 4180 4181 // Compressed oops constants 4182 // Pointer Immediate 4183 operand immN() %{ 4184 match(ConN); 4185 4186 op_cost(10); 4187 format %{ %} 4188 interface(CONST_INTER); 4189 %} 4190 4191 // NULL Pointer Immediate 4192 operand immN_0() %{ 4193 predicate(n->get_narrowcon() == 0); 4194 match(ConN); 4195 4196 op_cost(0); 4197 format %{ %} 4198 interface(CONST_INTER); 4199 %} 4200 4201 // Compressed klass constants 4202 operand immNKlass() %{ 4203 match(ConNKlass); 4204 4205 op_cost(0); 4206 format %{ %} 4207 interface(CONST_INTER); 4208 %} 4209 4210 // This operand can be used to avoid matching of an instruct 4211 // with chain rule. 4212 operand immNKlass_NM() %{ 4213 match(ConNKlass); 4214 predicate(false); 4215 op_cost(0); 4216 format %{ %} 4217 interface(CONST_INTER); 4218 %} 4219 4220 // Pointer Immediate: 64-bit 4221 operand immP() %{ 4222 match(ConP); 4223 op_cost(0); 4224 format %{ %} 4225 interface(CONST_INTER); 4226 %} 4227 4228 // Operand to avoid match of loadConP. 4229 // This operand can be used to avoid matching of an instruct 4230 // with chain rule. 4231 operand immP_NM() %{ 4232 match(ConP); 4233 predicate(false); 4234 op_cost(0); 4235 format %{ %} 4236 interface(CONST_INTER); 4237 %} 4238 4239 // costant 'pointer 0'. 4240 operand immP_0() %{ 4241 predicate(n->get_ptr() == 0); 4242 match(ConP); 4243 op_cost(0); 4244 format %{ %} 4245 interface(CONST_INTER); 4246 %} 4247 4248 // pointer 0x0 or 0x1 4249 operand immP_0or1() %{ 4250 predicate((n->get_ptr() == 0) || (n->get_ptr() == 1)); 4251 match(ConP); 4252 op_cost(0); 4253 format %{ %} 4254 interface(CONST_INTER); 4255 %} 4256 4257 operand immL() %{ 4258 match(ConL); 4259 op_cost(40); 4260 format %{ %} 4261 interface(CONST_INTER); 4262 %} 4263 4264 // Long Immediate: 16-bit 4265 operand immL16() %{ 4266 predicate(Assembler::is_simm(n->get_long(), 16)); 4267 match(ConL); 4268 op_cost(0); 4269 format %{ %} 4270 interface(CONST_INTER); 4271 %} 4272 4273 // Long Immediate: 16-bit, 4-aligned 4274 operand immL16Alg4() %{ 4275 predicate(Assembler::is_simm(n->get_long(), 16) && ((n->get_long() & 0x3) == 0)); 4276 match(ConL); 4277 op_cost(0); 4278 format %{ %} 4279 interface(CONST_INTER); 4280 %} 4281 4282 // Long Immediate: 32-bit, where lowest 16 bits are 0x0000. 4283 operand immL32hi16() %{ 4284 predicate(Assembler::is_simm(n->get_long(), 32) && ((n->get_long() & 0xffffL) == 0L)); 4285 match(ConL); 4286 op_cost(0); 4287 format %{ %} 4288 interface(CONST_INTER); 4289 %} 4290 4291 // Long Immediate: 32-bit 4292 operand immL32() %{ 4293 predicate(Assembler::is_simm(n->get_long(), 32)); 4294 match(ConL); 4295 op_cost(0); 4296 format %{ %} 4297 interface(CONST_INTER); 4298 %} 4299 4300 // Long Immediate: 64-bit, where highest 16 bits are not 0x0000. 4301 operand immLhighest16() %{ 4302 predicate((n->get_long() & 0xffff000000000000L) != 0L && (n->get_long() & 0x0000ffffffffffffL) == 0L); 4303 match(ConL); 4304 op_cost(0); 4305 format %{ %} 4306 interface(CONST_INTER); 4307 %} 4308 4309 operand immLnegpow2() %{ 4310 predicate(is_power_of_2_long((jlong)-(n->get_long()))); 4311 match(ConL); 4312 op_cost(0); 4313 format %{ %} 4314 interface(CONST_INTER); 4315 %} 4316 4317 operand immLpow2minus1() %{ 4318 predicate(is_power_of_2_long((((jlong) (n->get_long()))+1)) && 4319 (n->get_long() != (jlong)0xffffffffffffffffL)); 4320 match(ConL); 4321 op_cost(0); 4322 format %{ %} 4323 interface(CONST_INTER); 4324 %} 4325 4326 // constant 'long 0'. 4327 operand immL_0() %{ 4328 predicate(n->get_long() == 0L); 4329 match(ConL); 4330 op_cost(0); 4331 format %{ %} 4332 interface(CONST_INTER); 4333 %} 4334 4335 // constat ' long -1'. 4336 operand immL_minus1() %{ 4337 predicate(n->get_long() == -1L); 4338 match(ConL); 4339 op_cost(0); 4340 format %{ %} 4341 interface(CONST_INTER); 4342 %} 4343 4344 // Long Immediate: low 32-bit mask 4345 operand immL_32bits() %{ 4346 predicate(n->get_long() == 0xFFFFFFFFL); 4347 match(ConL); 4348 op_cost(0); 4349 format %{ %} 4350 interface(CONST_INTER); 4351 %} 4352 4353 // Unsigned Long Immediate: 16-bit 4354 operand uimmL16() %{ 4355 predicate(Assembler::is_uimm(n->get_long(), 16)); 4356 match(ConL); 4357 op_cost(0); 4358 format %{ %} 4359 interface(CONST_INTER); 4360 %} 4361 4362 // Float Immediate 4363 operand immF() %{ 4364 match(ConF); 4365 op_cost(40); 4366 format %{ %} 4367 interface(CONST_INTER); 4368 %} 4369 4370 // constant 'float +0.0'. 4371 operand immF_0() %{ 4372 predicate((n->getf() == 0) && 4373 (fpclassify(n->getf()) == FP_ZERO) && (signbit(n->getf()) == 0)); 4374 match(ConF); 4375 op_cost(0); 4376 format %{ %} 4377 interface(CONST_INTER); 4378 %} 4379 4380 // Double Immediate 4381 operand immD() %{ 4382 match(ConD); 4383 op_cost(40); 4384 format %{ %} 4385 interface(CONST_INTER); 4386 %} 4387 4388 // Integer Register Operands 4389 // Integer Destination Register 4390 // See definition of reg_class bits32_reg_rw. 4391 operand iRegIdst() %{ 4392 constraint(ALLOC_IN_RC(bits32_reg_rw)); 4393 match(RegI); 4394 match(rscratch1RegI); 4395 match(rscratch2RegI); 4396 match(rarg1RegI); 4397 match(rarg2RegI); 4398 match(rarg3RegI); 4399 match(rarg4RegI); 4400 format %{ %} 4401 interface(REG_INTER); 4402 %} 4403 4404 // Integer Source Register 4405 // See definition of reg_class bits32_reg_ro. 4406 operand iRegIsrc() %{ 4407 constraint(ALLOC_IN_RC(bits32_reg_ro)); 4408 match(RegI); 4409 match(rscratch1RegI); 4410 match(rscratch2RegI); 4411 match(rarg1RegI); 4412 match(rarg2RegI); 4413 match(rarg3RegI); 4414 match(rarg4RegI); 4415 format %{ %} 4416 interface(REG_INTER); 4417 %} 4418 4419 operand rscratch1RegI() %{ 4420 constraint(ALLOC_IN_RC(rscratch1_bits32_reg)); 4421 match(iRegIdst); 4422 format %{ %} 4423 interface(REG_INTER); 4424 %} 4425 4426 operand rscratch2RegI() %{ 4427 constraint(ALLOC_IN_RC(rscratch2_bits32_reg)); 4428 match(iRegIdst); 4429 format %{ %} 4430 interface(REG_INTER); 4431 %} 4432 4433 operand rarg1RegI() %{ 4434 constraint(ALLOC_IN_RC(rarg1_bits32_reg)); 4435 match(iRegIdst); 4436 format %{ %} 4437 interface(REG_INTER); 4438 %} 4439 4440 operand rarg2RegI() %{ 4441 constraint(ALLOC_IN_RC(rarg2_bits32_reg)); 4442 match(iRegIdst); 4443 format %{ %} 4444 interface(REG_INTER); 4445 %} 4446 4447 operand rarg3RegI() %{ 4448 constraint(ALLOC_IN_RC(rarg3_bits32_reg)); 4449 match(iRegIdst); 4450 format %{ %} 4451 interface(REG_INTER); 4452 %} 4453 4454 operand rarg4RegI() %{ 4455 constraint(ALLOC_IN_RC(rarg4_bits32_reg)); 4456 match(iRegIdst); 4457 format %{ %} 4458 interface(REG_INTER); 4459 %} 4460 4461 operand rarg1RegL() %{ 4462 constraint(ALLOC_IN_RC(rarg1_bits64_reg)); 4463 match(iRegLdst); 4464 format %{ %} 4465 interface(REG_INTER); 4466 %} 4467 4468 operand rarg2RegL() %{ 4469 constraint(ALLOC_IN_RC(rarg2_bits64_reg)); 4470 match(iRegLdst); 4471 format %{ %} 4472 interface(REG_INTER); 4473 %} 4474 4475 operand rarg3RegL() %{ 4476 constraint(ALLOC_IN_RC(rarg3_bits64_reg)); 4477 match(iRegLdst); 4478 format %{ %} 4479 interface(REG_INTER); 4480 %} 4481 4482 operand rarg4RegL() %{ 4483 constraint(ALLOC_IN_RC(rarg4_bits64_reg)); 4484 match(iRegLdst); 4485 format %{ %} 4486 interface(REG_INTER); 4487 %} 4488 4489 // Pointer Destination Register 4490 // See definition of reg_class bits64_reg_rw. 4491 operand iRegPdst() %{ 4492 constraint(ALLOC_IN_RC(bits64_reg_rw)); 4493 match(RegP); 4494 match(rscratch1RegP); 4495 match(rscratch2RegP); 4496 match(rarg1RegP); 4497 match(rarg2RegP); 4498 match(rarg3RegP); 4499 match(rarg4RegP); 4500 format %{ %} 4501 interface(REG_INTER); 4502 %} 4503 4504 // Pointer Destination Register 4505 // Operand not using r11 and r12 (killed in epilog). 4506 operand iRegPdstNoScratch() %{ 4507 constraint(ALLOC_IN_RC(bits64_reg_leaf_call)); 4508 match(RegP); 4509 match(rarg1RegP); 4510 match(rarg2RegP); 4511 match(rarg3RegP); 4512 match(rarg4RegP); 4513 format %{ %} 4514 interface(REG_INTER); 4515 %} 4516 4517 // Pointer Source Register 4518 // See definition of reg_class bits64_reg_ro. 4519 operand iRegPsrc() %{ 4520 constraint(ALLOC_IN_RC(bits64_reg_ro)); 4521 match(RegP); 4522 match(iRegPdst); 4523 match(rscratch1RegP); 4524 match(rscratch2RegP); 4525 match(rarg1RegP); 4526 match(rarg2RegP); 4527 match(rarg3RegP); 4528 match(rarg4RegP); 4529 match(threadRegP); 4530 format %{ %} 4531 interface(REG_INTER); 4532 %} 4533 4534 // Thread operand. 4535 operand threadRegP() %{ 4536 constraint(ALLOC_IN_RC(thread_bits64_reg)); 4537 match(iRegPdst); 4538 format %{ "R16" %} 4539 interface(REG_INTER); 4540 %} 4541 4542 operand rscratch1RegP() %{ 4543 constraint(ALLOC_IN_RC(rscratch1_bits64_reg)); 4544 match(iRegPdst); 4545 format %{ "R11" %} 4546 interface(REG_INTER); 4547 %} 4548 4549 operand rscratch2RegP() %{ 4550 constraint(ALLOC_IN_RC(rscratch2_bits64_reg)); 4551 match(iRegPdst); 4552 format %{ %} 4553 interface(REG_INTER); 4554 %} 4555 4556 operand rarg1RegP() %{ 4557 constraint(ALLOC_IN_RC(rarg1_bits64_reg)); 4558 match(iRegPdst); 4559 format %{ %} 4560 interface(REG_INTER); 4561 %} 4562 4563 operand rarg2RegP() %{ 4564 constraint(ALLOC_IN_RC(rarg2_bits64_reg)); 4565 match(iRegPdst); 4566 format %{ %} 4567 interface(REG_INTER); 4568 %} 4569 4570 operand rarg3RegP() %{ 4571 constraint(ALLOC_IN_RC(rarg3_bits64_reg)); 4572 match(iRegPdst); 4573 format %{ %} 4574 interface(REG_INTER); 4575 %} 4576 4577 operand rarg4RegP() %{ 4578 constraint(ALLOC_IN_RC(rarg4_bits64_reg)); 4579 match(iRegPdst); 4580 format %{ %} 4581 interface(REG_INTER); 4582 %} 4583 4584 operand iRegNsrc() %{ 4585 constraint(ALLOC_IN_RC(bits32_reg_ro)); 4586 match(RegN); 4587 match(iRegNdst); 4588 4589 format %{ %} 4590 interface(REG_INTER); 4591 %} 4592 4593 operand iRegNdst() %{ 4594 constraint(ALLOC_IN_RC(bits32_reg_rw)); 4595 match(RegN); 4596 4597 format %{ %} 4598 interface(REG_INTER); 4599 %} 4600 4601 // Long Destination Register 4602 // See definition of reg_class bits64_reg_rw. 4603 operand iRegLdst() %{ 4604 constraint(ALLOC_IN_RC(bits64_reg_rw)); 4605 match(RegL); 4606 match(rscratch1RegL); 4607 match(rscratch2RegL); 4608 format %{ %} 4609 interface(REG_INTER); 4610 %} 4611 4612 // Long Source Register 4613 // See definition of reg_class bits64_reg_ro. 4614 operand iRegLsrc() %{ 4615 constraint(ALLOC_IN_RC(bits64_reg_ro)); 4616 match(RegL); 4617 match(iRegLdst); 4618 match(rscratch1RegL); 4619 match(rscratch2RegL); 4620 format %{ %} 4621 interface(REG_INTER); 4622 %} 4623 4624 // Special operand for ConvL2I. 4625 operand iRegL2Isrc(iRegLsrc reg) %{ 4626 constraint(ALLOC_IN_RC(bits64_reg_ro)); 4627 match(ConvL2I reg); 4628 format %{ "ConvL2I($reg)" %} 4629 interface(REG_INTER) 4630 %} 4631 4632 operand rscratch1RegL() %{ 4633 constraint(ALLOC_IN_RC(rscratch1_bits64_reg)); 4634 match(RegL); 4635 format %{ %} 4636 interface(REG_INTER); 4637 %} 4638 4639 operand rscratch2RegL() %{ 4640 constraint(ALLOC_IN_RC(rscratch2_bits64_reg)); 4641 match(RegL); 4642 format %{ %} 4643 interface(REG_INTER); 4644 %} 4645 4646 // Condition Code Flag Registers 4647 operand flagsReg() %{ 4648 constraint(ALLOC_IN_RC(int_flags)); 4649 match(RegFlags); 4650 format %{ %} 4651 interface(REG_INTER); 4652 %} 4653 4654 // Condition Code Flag Register CR0 4655 operand flagsRegCR0() %{ 4656 constraint(ALLOC_IN_RC(int_flags_CR0)); 4657 match(RegFlags); 4658 format %{ "CR0" %} 4659 interface(REG_INTER); 4660 %} 4661 4662 operand flagsRegCR1() %{ 4663 constraint(ALLOC_IN_RC(int_flags_CR1)); 4664 match(RegFlags); 4665 format %{ "CR1" %} 4666 interface(REG_INTER); 4667 %} 4668 4669 operand flagsRegCR6() %{ 4670 constraint(ALLOC_IN_RC(int_flags_CR6)); 4671 match(RegFlags); 4672 format %{ "CR6" %} 4673 interface(REG_INTER); 4674 %} 4675 4676 operand regCTR() %{ 4677 constraint(ALLOC_IN_RC(ctr_reg)); 4678 // RegFlags should work. Introducing a RegSpecial type would cause a 4679 // lot of changes. 4680 match(RegFlags); 4681 format %{"SR_CTR" %} 4682 interface(REG_INTER); 4683 %} 4684 4685 operand regD() %{ 4686 constraint(ALLOC_IN_RC(dbl_reg)); 4687 match(RegD); 4688 format %{ %} 4689 interface(REG_INTER); 4690 %} 4691 4692 operand regF() %{ 4693 constraint(ALLOC_IN_RC(flt_reg)); 4694 match(RegF); 4695 format %{ %} 4696 interface(REG_INTER); 4697 %} 4698 4699 // Special Registers 4700 4701 // Method Register 4702 operand inline_cache_regP(iRegPdst reg) %{ 4703 constraint(ALLOC_IN_RC(r19_bits64_reg)); // inline_cache_reg 4704 match(reg); 4705 format %{ %} 4706 interface(REG_INTER); 4707 %} 4708 4709 operand compiler_method_oop_regP(iRegPdst reg) %{ 4710 constraint(ALLOC_IN_RC(rscratch1_bits64_reg)); // compiler_method_oop_reg 4711 match(reg); 4712 format %{ %} 4713 interface(REG_INTER); 4714 %} 4715 4716 operand interpreter_method_oop_regP(iRegPdst reg) %{ 4717 constraint(ALLOC_IN_RC(r19_bits64_reg)); // interpreter_method_oop_reg 4718 match(reg); 4719 format %{ %} 4720 interface(REG_INTER); 4721 %} 4722 4723 // Operands to remove register moves in unscaled mode. 4724 // Match read/write registers with an EncodeP node if neither shift nor add are required. 4725 operand iRegP2N(iRegPsrc reg) %{ 4726 predicate(false /* TODO: PPC port MatchDecodeNodes*/&& Universe::narrow_oop_shift() == 0); 4727 constraint(ALLOC_IN_RC(bits64_reg_ro)); 4728 match(EncodeP reg); 4729 format %{ "$reg" %} 4730 interface(REG_INTER) 4731 %} 4732 4733 operand iRegN2P(iRegNsrc reg) %{ 4734 predicate(false /* TODO: PPC port MatchDecodeNodes*/); 4735 constraint(ALLOC_IN_RC(bits32_reg_ro)); 4736 match(DecodeN reg); 4737 match(DecodeNKlass reg); 4738 format %{ "$reg" %} 4739 interface(REG_INTER) 4740 %} 4741 4742 //----------Complex Operands--------------------------------------------------- 4743 // Indirect Memory Reference 4744 operand indirect(iRegPsrc reg) %{ 4745 constraint(ALLOC_IN_RC(bits64_reg_ro)); 4746 match(reg); 4747 op_cost(100); 4748 format %{ "[$reg]" %} 4749 interface(MEMORY_INTER) %{ 4750 base($reg); 4751 index(0x0); 4752 scale(0x0); 4753 disp(0x0); 4754 %} 4755 %} 4756 4757 // Indirect with Offset 4758 operand indOffset16(iRegPsrc reg, immL16 offset) %{ 4759 constraint(ALLOC_IN_RC(bits64_reg_ro)); 4760 match(AddP reg offset); 4761 op_cost(100); 4762 format %{ "[$reg + $offset]" %} 4763 interface(MEMORY_INTER) %{ 4764 base($reg); 4765 index(0x0); 4766 scale(0x0); 4767 disp($offset); 4768 %} 4769 %} 4770 4771 // Indirect with 4-aligned Offset 4772 operand indOffset16Alg4(iRegPsrc reg, immL16Alg4 offset) %{ 4773 constraint(ALLOC_IN_RC(bits64_reg_ro)); 4774 match(AddP reg offset); 4775 op_cost(100); 4776 format %{ "[$reg + $offset]" %} 4777 interface(MEMORY_INTER) %{ 4778 base($reg); 4779 index(0x0); 4780 scale(0x0); 4781 disp($offset); 4782 %} 4783 %} 4784 4785 //----------Complex Operands for Compressed OOPs------------------------------- 4786 // Compressed OOPs with narrow_oop_shift == 0. 4787 4788 // Indirect Memory Reference, compressed OOP 4789 operand indirectNarrow(iRegNsrc reg) %{ 4790 predicate(false /* TODO: PPC port MatchDecodeNodes*/); 4791 constraint(ALLOC_IN_RC(bits64_reg_ro)); 4792 match(DecodeN reg); 4793 match(DecodeNKlass reg); 4794 op_cost(100); 4795 format %{ "[$reg]" %} 4796 interface(MEMORY_INTER) %{ 4797 base($reg); 4798 index(0x0); 4799 scale(0x0); 4800 disp(0x0); 4801 %} 4802 %} 4803 4804 // Indirect with Offset, compressed OOP 4805 operand indOffset16Narrow(iRegNsrc reg, immL16 offset) %{ 4806 predicate(false /* TODO: PPC port MatchDecodeNodes*/); 4807 constraint(ALLOC_IN_RC(bits64_reg_ro)); 4808 match(AddP (DecodeN reg) offset); 4809 match(AddP (DecodeNKlass reg) offset); 4810 op_cost(100); 4811 format %{ "[$reg + $offset]" %} 4812 interface(MEMORY_INTER) %{ 4813 base($reg); 4814 index(0x0); 4815 scale(0x0); 4816 disp($offset); 4817 %} 4818 %} 4819 4820 // Indirect with 4-aligned Offset, compressed OOP 4821 operand indOffset16NarrowAlg4(iRegNsrc reg, immL16Alg4 offset) %{ 4822 predicate(false /* TODO: PPC port MatchDecodeNodes*/); 4823 constraint(ALLOC_IN_RC(bits64_reg_ro)); 4824 match(AddP (DecodeN reg) offset); 4825 match(AddP (DecodeNKlass reg) offset); 4826 op_cost(100); 4827 format %{ "[$reg + $offset]" %} 4828 interface(MEMORY_INTER) %{ 4829 base($reg); 4830 index(0x0); 4831 scale(0x0); 4832 disp($offset); 4833 %} 4834 %} 4835 4836 //----------Special Memory Operands-------------------------------------------- 4837 // Stack Slot Operand 4838 // 4839 // This operand is used for loading and storing temporary values on 4840 // the stack where a match requires a value to flow through memory. 4841 operand stackSlotI(sRegI reg) %{ 4842 constraint(ALLOC_IN_RC(stack_slots)); 4843 op_cost(100); 4844 //match(RegI); 4845 format %{ "[sp+$reg]" %} 4846 interface(MEMORY_INTER) %{ 4847 base(0x1); // R1_SP 4848 index(0x0); 4849 scale(0x0); 4850 disp($reg); // Stack Offset 4851 %} 4852 %} 4853 4854 operand stackSlotL(sRegL reg) %{ 4855 constraint(ALLOC_IN_RC(stack_slots)); 4856 op_cost(100); 4857 //match(RegL); 4858 format %{ "[sp+$reg]" %} 4859 interface(MEMORY_INTER) %{ 4860 base(0x1); // R1_SP 4861 index(0x0); 4862 scale(0x0); 4863 disp($reg); // Stack Offset 4864 %} 4865 %} 4866 4867 operand stackSlotP(sRegP reg) %{ 4868 constraint(ALLOC_IN_RC(stack_slots)); 4869 op_cost(100); 4870 //match(RegP); 4871 format %{ "[sp+$reg]" %} 4872 interface(MEMORY_INTER) %{ 4873 base(0x1); // R1_SP 4874 index(0x0); 4875 scale(0x0); 4876 disp($reg); // Stack Offset 4877 %} 4878 %} 4879 4880 operand stackSlotF(sRegF reg) %{ 4881 constraint(ALLOC_IN_RC(stack_slots)); 4882 op_cost(100); 4883 //match(RegF); 4884 format %{ "[sp+$reg]" %} 4885 interface(MEMORY_INTER) %{ 4886 base(0x1); // R1_SP 4887 index(0x0); 4888 scale(0x0); 4889 disp($reg); // Stack Offset 4890 %} 4891 %} 4892 4893 operand stackSlotD(sRegD reg) %{ 4894 constraint(ALLOC_IN_RC(stack_slots)); 4895 op_cost(100); 4896 //match(RegD); 4897 format %{ "[sp+$reg]" %} 4898 interface(MEMORY_INTER) %{ 4899 base(0x1); // R1_SP 4900 index(0x0); 4901 scale(0x0); 4902 disp($reg); // Stack Offset 4903 %} 4904 %} 4905 4906 // Operands for expressing Control Flow 4907 // NOTE: Label is a predefined operand which should not be redefined in 4908 // the AD file. It is generically handled within the ADLC. 4909 4910 //----------Conditional Branch Operands---------------------------------------- 4911 // Comparison Op 4912 // 4913 // This is the operation of the comparison, and is limited to the 4914 // following set of codes: L (<), LE (<=), G (>), GE (>=), E (==), NE 4915 // (!=). 4916 // 4917 // Other attributes of the comparison, such as unsignedness, are specified 4918 // by the comparison instruction that sets a condition code flags register. 4919 // That result is represented by a flags operand whose subtype is appropriate 4920 // to the unsignedness (etc.) of the comparison. 4921 // 4922 // Later, the instruction which matches both the Comparison Op (a Bool) and 4923 // the flags (produced by the Cmp) specifies the coding of the comparison op 4924 // by matching a specific subtype of Bool operand below. 4925 4926 // When used for floating point comparisons: unordered same as less. 4927 operand cmpOp() %{ 4928 match(Bool); 4929 format %{ "" %} 4930 interface(COND_INTER) %{ 4931 // BO only encodes bit 4 of bcondCRbiIsX, as bits 1-3 are always '100'. 4932 // BO & BI 4933 equal(0xA); // 10 10: bcondCRbiIs1 & Condition::equal 4934 not_equal(0x2); // 00 10: bcondCRbiIs0 & Condition::equal 4935 less(0x8); // 10 00: bcondCRbiIs1 & Condition::less 4936 greater_equal(0x0); // 00 00: bcondCRbiIs0 & Condition::less 4937 less_equal(0x1); // 00 01: bcondCRbiIs0 & Condition::greater 4938 greater(0x9); // 10 01: bcondCRbiIs1 & Condition::greater 4939 overflow(0xB); // 10 11: bcondCRbiIs1 & Condition::summary_overflow 4940 no_overflow(0x3); // 00 11: bcondCRbiIs0 & Condition::summary_overflow 4941 %} 4942 %} 4943 4944 //----------OPERAND CLASSES---------------------------------------------------- 4945 // Operand Classes are groups of operands that are used to simplify 4946 // instruction definitions by not requiring the AD writer to specify 4947 // seperate instructions for every form of operand when the 4948 // instruction accepts multiple operand types with the same basic 4949 // encoding and format. The classic case of this is memory operands. 4950 // Indirect is not included since its use is limited to Compare & Swap. 4951 4952 opclass memory(indirect, indOffset16 /*, indIndex, tlsReference*/, indirectNarrow, indOffset16Narrow); 4953 // Memory operand where offsets are 4-aligned. Required for ld, std. 4954 opclass memoryAlg4(indirect, indOffset16Alg4, indirectNarrow, indOffset16NarrowAlg4); 4955 opclass indirectMemory(indirect, indirectNarrow); 4956 4957 // Special opclass for I and ConvL2I. 4958 opclass iRegIsrc_iRegL2Isrc(iRegIsrc, iRegL2Isrc); 4959 4960 // Operand classes to match encode and decode. iRegN_P2N is only used 4961 // for storeN. I have never seen an encode node elsewhere. 4962 opclass iRegN_P2N(iRegNsrc, iRegP2N); 4963 opclass iRegP_N2P(iRegPsrc, iRegN2P); 4964 4965 //----------PIPELINE----------------------------------------------------------- 4966 4967 pipeline %{ 4968 4969 // See J.M.Tendler et al. "Power4 system microarchitecture", IBM 4970 // J. Res. & Dev., No. 1, Jan. 2002. 4971 4972 //----------ATTRIBUTES--------------------------------------------------------- 4973 attributes %{ 4974 4975 // Power4 instructions are of fixed length. 4976 fixed_size_instructions; 4977 4978 // TODO: if `bundle' means number of instructions fetched 4979 // per cycle, this is 8. If `bundle' means Power4 `group', that is 4980 // max instructions issued per cycle, this is 5. 4981 max_instructions_per_bundle = 8; 4982 4983 // A Power4 instruction is 4 bytes long. 4984 instruction_unit_size = 4; 4985 4986 // The Power4 processor fetches 64 bytes... 4987 instruction_fetch_unit_size = 64; 4988 4989 // ...in one line 4990 instruction_fetch_units = 1 4991 4992 // Unused, list one so that array generated by adlc is not empty. 4993 // Aix compiler chokes if _nop_count = 0. 4994 nops(fxNop); 4995 %} 4996 4997 //----------RESOURCES---------------------------------------------------------- 4998 // Resources are the functional units available to the machine 4999 resources( 5000 PPC_BR, // branch unit 5001 PPC_CR, // condition unit 5002 PPC_FX1, // integer arithmetic unit 1 5003 PPC_FX2, // integer arithmetic unit 2 5004 PPC_LDST1, // load/store unit 1 5005 PPC_LDST2, // load/store unit 2 5006 PPC_FP1, // float arithmetic unit 1 5007 PPC_FP2, // float arithmetic unit 2 5008 PPC_LDST = PPC_LDST1 | PPC_LDST2, 5009 PPC_FX = PPC_FX1 | PPC_FX2, 5010 PPC_FP = PPC_FP1 | PPC_FP2 5011 ); 5012 5013 //----------PIPELINE DESCRIPTION----------------------------------------------- 5014 // Pipeline Description specifies the stages in the machine's pipeline 5015 pipe_desc( 5016 // Power4 longest pipeline path 5017 PPC_IF, // instruction fetch 5018 PPC_IC, 5019 //PPC_BP, // branch prediction 5020 PPC_D0, // decode 5021 PPC_D1, // decode 5022 PPC_D2, // decode 5023 PPC_D3, // decode 5024 PPC_Xfer1, 5025 PPC_GD, // group definition 5026 PPC_MP, // map 5027 PPC_ISS, // issue 5028 PPC_RF, // resource fetch 5029 PPC_EX1, // execute (all units) 5030 PPC_EX2, // execute (FP, LDST) 5031 PPC_EX3, // execute (FP, LDST) 5032 PPC_EX4, // execute (FP) 5033 PPC_EX5, // execute (FP) 5034 PPC_EX6, // execute (FP) 5035 PPC_WB, // write back 5036 PPC_Xfer2, 5037 PPC_CP 5038 ); 5039 5040 //----------PIPELINE CLASSES--------------------------------------------------- 5041 // Pipeline Classes describe the stages in which input and output are 5042 // referenced by the hardware pipeline. 5043 5044 // Simple pipeline classes. 5045 5046 // Default pipeline class. 5047 pipe_class pipe_class_default() %{ 5048 single_instruction; 5049 fixed_latency(2); 5050 %} 5051 5052 // Pipeline class for empty instructions. 5053 pipe_class pipe_class_empty() %{ 5054 single_instruction; 5055 fixed_latency(0); 5056 %} 5057 5058 // Pipeline class for compares. 5059 pipe_class pipe_class_compare() %{ 5060 single_instruction; 5061 fixed_latency(16); 5062 %} 5063 5064 // Pipeline class for traps. 5065 pipe_class pipe_class_trap() %{ 5066 single_instruction; 5067 fixed_latency(100); 5068 %} 5069 5070 // Pipeline class for memory operations. 5071 pipe_class pipe_class_memory() %{ 5072 single_instruction; 5073 fixed_latency(16); 5074 %} 5075 5076 // Pipeline class for call. 5077 pipe_class pipe_class_call() %{ 5078 single_instruction; 5079 fixed_latency(100); 5080 %} 5081 5082 // Define the class for the Nop node. 5083 define %{ 5084 MachNop = pipe_class_default; 5085 %} 5086 5087 %} 5088 5089 //----------INSTRUCTIONS------------------------------------------------------- 5090 5091 // Naming of instructions: 5092 // opA_operB / opA_operB_operC: 5093 // Operation 'op' with one or two source operands 'oper'. Result 5094 // type is A, source operand types are B and C. 5095 // Iff A == B == C, B and C are left out. 5096 // 5097 // The instructions are ordered according to the following scheme: 5098 // - loads 5099 // - load constants 5100 // - prefetch 5101 // - store 5102 // - encode/decode 5103 // - membar 5104 // - conditional moves 5105 // - compare & swap 5106 // - arithmetic and logic operations 5107 // * int: Add, Sub, Mul, Div, Mod 5108 // * int: lShift, arShift, urShift, rot 5109 // * float: Add, Sub, Mul, Div 5110 // * and, or, xor ... 5111 // - register moves: float <-> int, reg <-> stack, repl 5112 // - cast (high level type cast, XtoP, castPP, castII, not_null etc. 5113 // - conv (low level type cast requiring bit changes (sign extend etc) 5114 // - compares, range & zero checks. 5115 // - branches 5116 // - complex operations, intrinsics, min, max, replicate 5117 // - lock 5118 // - Calls 5119 // 5120 // If there are similar instructions with different types they are sorted: 5121 // int before float 5122 // small before big 5123 // signed before unsigned 5124 // e.g., loadS before loadUS before loadI before loadF. 5125 5126 5127 //----------Load/Store Instructions-------------------------------------------- 5128 5129 //----------Load Instructions-------------------------------------------------- 5130 5131 // Converts byte to int. 5132 // As convB2I_reg, but without match rule. The match rule of convB2I_reg 5133 // reuses the 'amount' operand, but adlc expects that operand specification 5134 // and operands in match rule are equivalent. 5135 instruct convB2I_reg_2(iRegIdst dst, iRegIsrc src) %{ 5136 effect(DEF dst, USE src); 5137 format %{ "EXTSB $dst, $src \t// byte->int" %} 5138 size(4); 5139 ins_encode %{ 5140 // TODO: PPC port $archOpcode(ppc64Opcode_extsb); 5141 __ extsb($dst$$Register, $src$$Register); 5142 %} 5143 ins_pipe(pipe_class_default); 5144 %} 5145 5146 instruct loadUB_indirect(iRegIdst dst, indirectMemory mem) %{ 5147 // match-rule, false predicate 5148 match(Set dst (LoadB mem)); 5149 predicate(false); 5150 5151 format %{ "LBZ $dst, $mem" %} 5152 size(4); 5153 ins_encode( enc_lbz(dst, mem) ); 5154 ins_pipe(pipe_class_memory); 5155 %} 5156 5157 instruct loadUB_indirect_ac(iRegIdst dst, indirectMemory mem) %{ 5158 // match-rule, false predicate 5159 match(Set dst (LoadB mem)); 5160 predicate(false); 5161 5162 format %{ "LBZ $dst, $mem\n\t" 5163 "TWI $dst\n\t" 5164 "ISYNC" %} 5165 size(12); 5166 ins_encode( enc_lbz_ac(dst, mem) ); 5167 ins_pipe(pipe_class_memory); 5168 %} 5169 5170 // Load Byte (8bit signed). LoadB = LoadUB + ConvUB2B. 5171 instruct loadB_indirect_Ex(iRegIdst dst, indirectMemory mem) %{ 5172 match(Set dst (LoadB mem)); 5173 predicate(n->as_Load()->is_unordered() || followed_by_acquire(n)); 5174 ins_cost(MEMORY_REF_COST + DEFAULT_COST); 5175 expand %{ 5176 iRegIdst tmp; 5177 loadUB_indirect(tmp, mem); 5178 convB2I_reg_2(dst, tmp); 5179 %} 5180 %} 5181 5182 instruct loadB_indirect_ac_Ex(iRegIdst dst, indirectMemory mem) %{ 5183 match(Set dst (LoadB mem)); 5184 ins_cost(3*MEMORY_REF_COST + DEFAULT_COST); 5185 expand %{ 5186 iRegIdst tmp; 5187 loadUB_indirect_ac(tmp, mem); 5188 convB2I_reg_2(dst, tmp); 5189 %} 5190 %} 5191 5192 instruct loadUB_indOffset16(iRegIdst dst, indOffset16 mem) %{ 5193 // match-rule, false predicate 5194 match(Set dst (LoadB mem)); 5195 predicate(false); 5196 5197 format %{ "LBZ $dst, $mem" %} 5198 size(4); 5199 ins_encode( enc_lbz(dst, mem) ); 5200 ins_pipe(pipe_class_memory); 5201 %} 5202 5203 instruct loadUB_indOffset16_ac(iRegIdst dst, indOffset16 mem) %{ 5204 // match-rule, false predicate 5205 match(Set dst (LoadB mem)); 5206 predicate(false); 5207 5208 format %{ "LBZ $dst, $mem\n\t" 5209 "TWI $dst\n\t" 5210 "ISYNC" %} 5211 size(12); 5212 ins_encode( enc_lbz_ac(dst, mem) ); 5213 ins_pipe(pipe_class_memory); 5214 %} 5215 5216 // Load Byte (8bit signed). LoadB = LoadUB + ConvUB2B. 5217 instruct loadB_indOffset16_Ex(iRegIdst dst, indOffset16 mem) %{ 5218 match(Set dst (LoadB mem)); 5219 predicate(n->as_Load()->is_unordered() || followed_by_acquire(n)); 5220 ins_cost(MEMORY_REF_COST + DEFAULT_COST); 5221 5222 expand %{ 5223 iRegIdst tmp; 5224 loadUB_indOffset16(tmp, mem); 5225 convB2I_reg_2(dst, tmp); 5226 %} 5227 %} 5228 5229 instruct loadB_indOffset16_ac_Ex(iRegIdst dst, indOffset16 mem) %{ 5230 match(Set dst (LoadB mem)); 5231 ins_cost(3*MEMORY_REF_COST + DEFAULT_COST); 5232 5233 expand %{ 5234 iRegIdst tmp; 5235 loadUB_indOffset16_ac(tmp, mem); 5236 convB2I_reg_2(dst, tmp); 5237 %} 5238 %} 5239 5240 // Load Unsigned Byte (8bit UNsigned) into an int reg. 5241 instruct loadUB(iRegIdst dst, memory mem) %{ 5242 predicate(n->as_Load()->is_unordered() || followed_by_acquire(n)); 5243 match(Set dst (LoadUB mem)); 5244 ins_cost(MEMORY_REF_COST); 5245 5246 format %{ "LBZ $dst, $mem \t// byte, zero-extend to int" %} 5247 size(4); 5248 ins_encode( enc_lbz(dst, mem) ); 5249 ins_pipe(pipe_class_memory); 5250 %} 5251 5252 // Load Unsigned Byte (8bit UNsigned) acquire. 5253 instruct loadUB_ac(iRegIdst dst, memory mem) %{ 5254 match(Set dst (LoadUB mem)); 5255 ins_cost(3*MEMORY_REF_COST); 5256 5257 format %{ "LBZ $dst, $mem \t// byte, zero-extend to int, acquire\n\t" 5258 "TWI $dst\n\t" 5259 "ISYNC" %} 5260 size(12); 5261 ins_encode( enc_lbz_ac(dst, mem) ); 5262 ins_pipe(pipe_class_memory); 5263 %} 5264 5265 // Load Unsigned Byte (8bit UNsigned) into a Long Register. 5266 instruct loadUB2L(iRegLdst dst, memory mem) %{ 5267 match(Set dst (ConvI2L (LoadUB mem))); 5268 predicate(_kids[0]->_leaf->as_Load()->is_unordered() || followed_by_acquire(_kids[0]->_leaf)); 5269 ins_cost(MEMORY_REF_COST); 5270 5271 format %{ "LBZ $dst, $mem \t// byte, zero-extend to long" %} 5272 size(4); 5273 ins_encode( enc_lbz(dst, mem) ); 5274 ins_pipe(pipe_class_memory); 5275 %} 5276 5277 instruct loadUB2L_ac(iRegLdst dst, memory mem) %{ 5278 match(Set dst (ConvI2L (LoadUB mem))); 5279 ins_cost(3*MEMORY_REF_COST); 5280 5281 format %{ "LBZ $dst, $mem \t// byte, zero-extend to long, acquire\n\t" 5282 "TWI $dst\n\t" 5283 "ISYNC" %} 5284 size(12); 5285 ins_encode( enc_lbz_ac(dst, mem) ); 5286 ins_pipe(pipe_class_memory); 5287 %} 5288 5289 // Load Short (16bit signed) 5290 instruct loadS(iRegIdst dst, memory mem) %{ 5291 match(Set dst (LoadS mem)); 5292 predicate(n->as_Load()->is_unordered() || followed_by_acquire(n)); 5293 ins_cost(MEMORY_REF_COST); 5294 5295 format %{ "LHA $dst, $mem" %} 5296 size(4); 5297 ins_encode %{ 5298 // TODO: PPC port $archOpcode(ppc64Opcode_lha); 5299 int Idisp = $mem$$disp + frame_slots_bias($mem$$base, ra_); 5300 __ lha($dst$$Register, Idisp, $mem$$base$$Register); 5301 %} 5302 ins_pipe(pipe_class_memory); 5303 %} 5304 5305 // Load Short (16bit signed) acquire. 5306 instruct loadS_ac(iRegIdst dst, memory mem) %{ 5307 match(Set dst (LoadS mem)); 5308 ins_cost(3*MEMORY_REF_COST); 5309 5310 format %{ "LHA $dst, $mem\t acquire\n\t" 5311 "TWI $dst\n\t" 5312 "ISYNC" %} 5313 size(12); 5314 ins_encode %{ 5315 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 5316 int Idisp = $mem$$disp + frame_slots_bias($mem$$base, ra_); 5317 __ lha($dst$$Register, Idisp, $mem$$base$$Register); 5318 __ twi_0($dst$$Register); 5319 __ isync(); 5320 %} 5321 ins_pipe(pipe_class_memory); 5322 %} 5323 5324 // Load Char (16bit unsigned) 5325 instruct loadUS(iRegIdst dst, memory mem) %{ 5326 match(Set dst (LoadUS mem)); 5327 predicate(n->as_Load()->is_unordered() || followed_by_acquire(n)); 5328 ins_cost(MEMORY_REF_COST); 5329 5330 format %{ "LHZ $dst, $mem" %} 5331 size(4); 5332 ins_encode( enc_lhz(dst, mem) ); 5333 ins_pipe(pipe_class_memory); 5334 %} 5335 5336 // Load Char (16bit unsigned) acquire. 5337 instruct loadUS_ac(iRegIdst dst, memory mem) %{ 5338 match(Set dst (LoadUS mem)); 5339 ins_cost(3*MEMORY_REF_COST); 5340 5341 format %{ "LHZ $dst, $mem \t// acquire\n\t" 5342 "TWI $dst\n\t" 5343 "ISYNC" %} 5344 size(12); 5345 ins_encode( enc_lhz_ac(dst, mem) ); 5346 ins_pipe(pipe_class_memory); 5347 %} 5348 5349 // Load Unsigned Short/Char (16bit UNsigned) into a Long Register. 5350 instruct loadUS2L(iRegLdst dst, memory mem) %{ 5351 match(Set dst (ConvI2L (LoadUS mem))); 5352 predicate(_kids[0]->_leaf->as_Load()->is_unordered() || followed_by_acquire(_kids[0]->_leaf)); 5353 ins_cost(MEMORY_REF_COST); 5354 5355 format %{ "LHZ $dst, $mem \t// short, zero-extend to long" %} 5356 size(4); 5357 ins_encode( enc_lhz(dst, mem) ); 5358 ins_pipe(pipe_class_memory); 5359 %} 5360 5361 // Load Unsigned Short/Char (16bit UNsigned) into a Long Register acquire. 5362 instruct loadUS2L_ac(iRegLdst dst, memory mem) %{ 5363 match(Set dst (ConvI2L (LoadUS mem))); 5364 ins_cost(3*MEMORY_REF_COST); 5365 5366 format %{ "LHZ $dst, $mem \t// short, zero-extend to long, acquire\n\t" 5367 "TWI $dst\n\t" 5368 "ISYNC" %} 5369 size(12); 5370 ins_encode( enc_lhz_ac(dst, mem) ); 5371 ins_pipe(pipe_class_memory); 5372 %} 5373 5374 // Load Integer. 5375 instruct loadI(iRegIdst dst, memory mem) %{ 5376 match(Set dst (LoadI mem)); 5377 predicate(n->as_Load()->is_unordered() || followed_by_acquire(n)); 5378 ins_cost(MEMORY_REF_COST); 5379 5380 format %{ "LWZ $dst, $mem" %} 5381 size(4); 5382 ins_encode( enc_lwz(dst, mem) ); 5383 ins_pipe(pipe_class_memory); 5384 %} 5385 5386 // Load Integer acquire. 5387 instruct loadI_ac(iRegIdst dst, memory mem) %{ 5388 match(Set dst (LoadI mem)); 5389 ins_cost(3*MEMORY_REF_COST); 5390 5391 format %{ "LWZ $dst, $mem \t// load acquire\n\t" 5392 "TWI $dst\n\t" 5393 "ISYNC" %} 5394 size(12); 5395 ins_encode( enc_lwz_ac(dst, mem) ); 5396 ins_pipe(pipe_class_memory); 5397 %} 5398 5399 // Match loading integer and casting it to unsigned int in 5400 // long register. 5401 // LoadI + ConvI2L + AndL 0xffffffff. 5402 instruct loadUI2L(iRegLdst dst, memory mem, immL_32bits mask) %{ 5403 match(Set dst (AndL (ConvI2L (LoadI mem)) mask)); 5404 predicate(_kids[0]->_kids[0]->_leaf->as_Load()->is_unordered()); 5405 ins_cost(MEMORY_REF_COST); 5406 5407 format %{ "LWZ $dst, $mem \t// zero-extend to long" %} 5408 size(4); 5409 ins_encode( enc_lwz(dst, mem) ); 5410 ins_pipe(pipe_class_memory); 5411 %} 5412 5413 // Match loading integer and casting it to long. 5414 instruct loadI2L(iRegLdst dst, memory mem) %{ 5415 match(Set dst (ConvI2L (LoadI mem))); 5416 predicate(_kids[0]->_leaf->as_Load()->is_unordered()); 5417 ins_cost(MEMORY_REF_COST); 5418 5419 format %{ "LWA $dst, $mem \t// loadI2L" %} 5420 size(4); 5421 ins_encode %{ 5422 // TODO: PPC port $archOpcode(ppc64Opcode_lwa); 5423 int Idisp = $mem$$disp + frame_slots_bias($mem$$base, ra_); 5424 __ lwa($dst$$Register, Idisp, $mem$$base$$Register); 5425 %} 5426 ins_pipe(pipe_class_memory); 5427 %} 5428 5429 // Match loading integer and casting it to long - acquire. 5430 instruct loadI2L_ac(iRegLdst dst, memory mem) %{ 5431 match(Set dst (ConvI2L (LoadI mem))); 5432 ins_cost(3*MEMORY_REF_COST); 5433 5434 format %{ "LWA $dst, $mem \t// loadI2L acquire" 5435 "TWI $dst\n\t" 5436 "ISYNC" %} 5437 size(12); 5438 ins_encode %{ 5439 // TODO: PPC port $archOpcode(ppc64Opcode_lwa); 5440 int Idisp = $mem$$disp + frame_slots_bias($mem$$base, ra_); 5441 __ lwa($dst$$Register, Idisp, $mem$$base$$Register); 5442 __ twi_0($dst$$Register); 5443 __ isync(); 5444 %} 5445 ins_pipe(pipe_class_memory); 5446 %} 5447 5448 // Load Long - aligned 5449 instruct loadL(iRegLdst dst, memoryAlg4 mem) %{ 5450 match(Set dst (LoadL mem)); 5451 predicate(n->as_Load()->is_unordered() || followed_by_acquire(n)); 5452 ins_cost(MEMORY_REF_COST); 5453 5454 format %{ "LD $dst, $mem \t// long" %} 5455 size(4); 5456 ins_encode( enc_ld(dst, mem) ); 5457 ins_pipe(pipe_class_memory); 5458 %} 5459 5460 // Load Long - aligned acquire. 5461 instruct loadL_ac(iRegLdst dst, memoryAlg4 mem) %{ 5462 match(Set dst (LoadL mem)); 5463 ins_cost(3*MEMORY_REF_COST); 5464 5465 format %{ "LD $dst, $mem \t// long acquire\n\t" 5466 "TWI $dst\n\t" 5467 "ISYNC" %} 5468 size(12); 5469 ins_encode( enc_ld_ac(dst, mem) ); 5470 ins_pipe(pipe_class_memory); 5471 %} 5472 5473 // Load Long - UNaligned 5474 instruct loadL_unaligned(iRegLdst dst, memoryAlg4 mem) %{ 5475 match(Set dst (LoadL_unaligned mem)); 5476 // predicate(...) // Unaligned_ac is not needed (and wouldn't make sense). 5477 ins_cost(MEMORY_REF_COST); 5478 5479 format %{ "LD $dst, $mem \t// unaligned long" %} 5480 size(4); 5481 ins_encode( enc_ld(dst, mem) ); 5482 ins_pipe(pipe_class_memory); 5483 %} 5484 5485 // Load nodes for superwords 5486 5487 // Load Aligned Packed Byte 5488 instruct loadV8(iRegLdst dst, memoryAlg4 mem) %{ 5489 predicate(n->as_LoadVector()->memory_size() == 8); 5490 match(Set dst (LoadVector mem)); 5491 ins_cost(MEMORY_REF_COST); 5492 5493 format %{ "LD $dst, $mem \t// load 8-byte Vector" %} 5494 size(4); 5495 ins_encode( enc_ld(dst, mem) ); 5496 ins_pipe(pipe_class_memory); 5497 %} 5498 5499 // Load Range, range = array length (=jint) 5500 instruct loadRange(iRegIdst dst, memory mem) %{ 5501 match(Set dst (LoadRange mem)); 5502 ins_cost(MEMORY_REF_COST); 5503 5504 format %{ "LWZ $dst, $mem \t// range" %} 5505 size(4); 5506 ins_encode( enc_lwz(dst, mem) ); 5507 ins_pipe(pipe_class_memory); 5508 %} 5509 5510 // Load Compressed Pointer 5511 instruct loadN(iRegNdst dst, memory mem) %{ 5512 match(Set dst (LoadN mem)); 5513 predicate(n->as_Load()->is_unordered() || followed_by_acquire(n)); 5514 ins_cost(MEMORY_REF_COST); 5515 5516 format %{ "LWZ $dst, $mem \t// load compressed ptr" %} 5517 size(4); 5518 ins_encode( enc_lwz(dst, mem) ); 5519 ins_pipe(pipe_class_memory); 5520 %} 5521 5522 // Load Compressed Pointer acquire. 5523 instruct loadN_ac(iRegNdst dst, memory mem) %{ 5524 match(Set dst (LoadN mem)); 5525 ins_cost(3*MEMORY_REF_COST); 5526 5527 format %{ "LWZ $dst, $mem \t// load acquire compressed ptr\n\t" 5528 "TWI $dst\n\t" 5529 "ISYNC" %} 5530 size(12); 5531 ins_encode( enc_lwz_ac(dst, mem) ); 5532 ins_pipe(pipe_class_memory); 5533 %} 5534 5535 // Load Compressed Pointer and decode it if narrow_oop_shift == 0. 5536 instruct loadN2P_unscaled(iRegPdst dst, memory mem) %{ 5537 match(Set dst (DecodeN (LoadN mem))); 5538 predicate(_kids[0]->_leaf->as_Load()->is_unordered() && Universe::narrow_oop_shift() == 0); 5539 ins_cost(MEMORY_REF_COST); 5540 5541 format %{ "LWZ $dst, $mem \t// DecodeN (unscaled)" %} 5542 size(4); 5543 ins_encode( enc_lwz(dst, mem) ); 5544 ins_pipe(pipe_class_memory); 5545 %} 5546 5547 // Load Pointer 5548 instruct loadP(iRegPdst dst, memoryAlg4 mem) %{ 5549 match(Set dst (LoadP mem)); 5550 predicate(n->as_Load()->is_unordered() || followed_by_acquire(n)); 5551 ins_cost(MEMORY_REF_COST); 5552 5553 format %{ "LD $dst, $mem \t// ptr" %} 5554 size(4); 5555 ins_encode( enc_ld(dst, mem) ); 5556 ins_pipe(pipe_class_memory); 5557 %} 5558 5559 // Load Pointer acquire. 5560 instruct loadP_ac(iRegPdst dst, memoryAlg4 mem) %{ 5561 match(Set dst (LoadP mem)); 5562 ins_cost(3*MEMORY_REF_COST); 5563 5564 format %{ "LD $dst, $mem \t// ptr acquire\n\t" 5565 "TWI $dst\n\t" 5566 "ISYNC" %} 5567 size(12); 5568 ins_encode( enc_ld_ac(dst, mem) ); 5569 ins_pipe(pipe_class_memory); 5570 %} 5571 5572 // LoadP + CastP2L 5573 instruct loadP2X(iRegLdst dst, memoryAlg4 mem) %{ 5574 match(Set dst (CastP2X (LoadP mem))); 5575 predicate(_kids[0]->_leaf->as_Load()->is_unordered()); 5576 ins_cost(MEMORY_REF_COST); 5577 5578 format %{ "LD $dst, $mem \t// ptr + p2x" %} 5579 size(4); 5580 ins_encode( enc_ld(dst, mem) ); 5581 ins_pipe(pipe_class_memory); 5582 %} 5583 5584 // Load compressed klass pointer. 5585 instruct loadNKlass(iRegNdst dst, memory mem) %{ 5586 match(Set dst (LoadNKlass mem)); 5587 ins_cost(MEMORY_REF_COST); 5588 5589 format %{ "LWZ $dst, $mem \t// compressed klass ptr" %} 5590 size(4); 5591 ins_encode( enc_lwz(dst, mem) ); 5592 ins_pipe(pipe_class_memory); 5593 %} 5594 5595 //// Load compressed klass and decode it if narrow_klass_shift == 0. 5596 //// TODO: will narrow_klass_shift ever be 0? 5597 //instruct decodeNKlass2Klass(iRegPdst dst, memory mem) %{ 5598 // match(Set dst (DecodeNKlass (LoadNKlass mem))); 5599 // predicate(false /* TODO: PPC port Universe::narrow_klass_shift() == 0*); 5600 // ins_cost(MEMORY_REF_COST); 5601 // 5602 // format %{ "LWZ $dst, $mem \t// DecodeNKlass (unscaled)" %} 5603 // size(4); 5604 // ins_encode( enc_lwz(dst, mem) ); 5605 // ins_pipe(pipe_class_memory); 5606 //%} 5607 5608 // Load Klass Pointer 5609 instruct loadKlass(iRegPdst dst, memoryAlg4 mem) %{ 5610 match(Set dst (LoadKlass mem)); 5611 ins_cost(MEMORY_REF_COST); 5612 5613 format %{ "LD $dst, $mem \t// klass ptr" %} 5614 size(4); 5615 ins_encode( enc_ld(dst, mem) ); 5616 ins_pipe(pipe_class_memory); 5617 %} 5618 5619 // Load Float 5620 instruct loadF(regF dst, memory mem) %{ 5621 match(Set dst (LoadF mem)); 5622 predicate(n->as_Load()->is_unordered() || followed_by_acquire(n)); 5623 ins_cost(MEMORY_REF_COST); 5624 5625 format %{ "LFS $dst, $mem" %} 5626 size(4); 5627 ins_encode %{ 5628 // TODO: PPC port $archOpcode(ppc64Opcode_lfs); 5629 int Idisp = $mem$$disp + frame_slots_bias($mem$$base, ra_); 5630 __ lfs($dst$$FloatRegister, Idisp, $mem$$base$$Register); 5631 %} 5632 ins_pipe(pipe_class_memory); 5633 %} 5634 5635 // Load Float acquire. 5636 instruct loadF_ac(regF dst, memory mem) %{ 5637 match(Set dst (LoadF mem)); 5638 ins_cost(3*MEMORY_REF_COST); 5639 5640 format %{ "LFS $dst, $mem \t// acquire\n\t" 5641 "FCMPU cr0, $dst, $dst\n\t" 5642 "BNE cr0, next\n" 5643 "next:\n\t" 5644 "ISYNC" %} 5645 size(16); 5646 ins_encode %{ 5647 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 5648 int Idisp = $mem$$disp + frame_slots_bias($mem$$base, ra_); 5649 Label next; 5650 __ lfs($dst$$FloatRegister, Idisp, $mem$$base$$Register); 5651 __ fcmpu(CCR0, $dst$$FloatRegister, $dst$$FloatRegister); 5652 __ bne(CCR0, next); 5653 __ bind(next); 5654 __ isync(); 5655 %} 5656 ins_pipe(pipe_class_memory); 5657 %} 5658 5659 // Load Double - aligned 5660 instruct loadD(regD dst, memory mem) %{ 5661 match(Set dst (LoadD mem)); 5662 predicate(n->as_Load()->is_unordered() || followed_by_acquire(n)); 5663 ins_cost(MEMORY_REF_COST); 5664 5665 format %{ "LFD $dst, $mem" %} 5666 size(4); 5667 ins_encode( enc_lfd(dst, mem) ); 5668 ins_pipe(pipe_class_memory); 5669 %} 5670 5671 // Load Double - aligned acquire. 5672 instruct loadD_ac(regD dst, memory mem) %{ 5673 match(Set dst (LoadD mem)); 5674 ins_cost(3*MEMORY_REF_COST); 5675 5676 format %{ "LFD $dst, $mem \t// acquire\n\t" 5677 "FCMPU cr0, $dst, $dst\n\t" 5678 "BNE cr0, next\n" 5679 "next:\n\t" 5680 "ISYNC" %} 5681 size(16); 5682 ins_encode %{ 5683 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 5684 int Idisp = $mem$$disp + frame_slots_bias($mem$$base, ra_); 5685 Label next; 5686 __ lfd($dst$$FloatRegister, Idisp, $mem$$base$$Register); 5687 __ fcmpu(CCR0, $dst$$FloatRegister, $dst$$FloatRegister); 5688 __ bne(CCR0, next); 5689 __ bind(next); 5690 __ isync(); 5691 %} 5692 ins_pipe(pipe_class_memory); 5693 %} 5694 5695 // Load Double - UNaligned 5696 instruct loadD_unaligned(regD dst, memory mem) %{ 5697 match(Set dst (LoadD_unaligned mem)); 5698 // predicate(...) // Unaligned_ac is not needed (and wouldn't make sense). 5699 ins_cost(MEMORY_REF_COST); 5700 5701 format %{ "LFD $dst, $mem" %} 5702 size(4); 5703 ins_encode( enc_lfd(dst, mem) ); 5704 ins_pipe(pipe_class_memory); 5705 %} 5706 5707 //----------Constants-------------------------------------------------------- 5708 5709 // Load MachConstantTableBase: add hi offset to global toc. 5710 // TODO: Handle hidden register r29 in bundler! 5711 instruct loadToc_hi(iRegLdst dst) %{ 5712 effect(DEF dst); 5713 ins_cost(DEFAULT_COST); 5714 5715 format %{ "ADDIS $dst, R29, DISP.hi \t// load TOC hi" %} 5716 size(4); 5717 ins_encode %{ 5718 // TODO: PPC port $archOpcode(ppc64Opcode_addis); 5719 __ calculate_address_from_global_toc_hi16only($dst$$Register, __ method_toc()); 5720 %} 5721 ins_pipe(pipe_class_default); 5722 %} 5723 5724 // Load MachConstantTableBase: add lo offset to global toc. 5725 instruct loadToc_lo(iRegLdst dst, iRegLdst src) %{ 5726 effect(DEF dst, USE src); 5727 ins_cost(DEFAULT_COST); 5728 5729 format %{ "ADDI $dst, $src, DISP.lo \t// load TOC lo" %} 5730 size(4); 5731 ins_encode %{ 5732 // TODO: PPC port $archOpcode(ppc64Opcode_ori); 5733 __ calculate_address_from_global_toc_lo16only($dst$$Register, __ method_toc()); 5734 %} 5735 ins_pipe(pipe_class_default); 5736 %} 5737 5738 // Load 16-bit integer constant 0xssss???? 5739 instruct loadConI16(iRegIdst dst, immI16 src) %{ 5740 match(Set dst src); 5741 5742 format %{ "LI $dst, $src" %} 5743 size(4); 5744 ins_encode %{ 5745 // TODO: PPC port $archOpcode(ppc64Opcode_addi); 5746 __ li($dst$$Register, (int)((short)($src$$constant & 0xFFFF))); 5747 %} 5748 ins_pipe(pipe_class_default); 5749 %} 5750 5751 // Load integer constant 0x????0000 5752 instruct loadConIhi16(iRegIdst dst, immIhi16 src) %{ 5753 match(Set dst src); 5754 ins_cost(DEFAULT_COST); 5755 5756 format %{ "LIS $dst, $src.hi" %} 5757 size(4); 5758 ins_encode %{ 5759 // TODO: PPC port $archOpcode(ppc64Opcode_addis); 5760 // Lis sign extends 16-bit src then shifts it 16 bit to the left. 5761 __ lis($dst$$Register, (int)((short)(($src$$constant & 0xFFFF0000) >> 16))); 5762 %} 5763 ins_pipe(pipe_class_default); 5764 %} 5765 5766 // Part 2 of loading 32 bit constant: hi16 is is src1 (properly shifted 5767 // and sign extended), this adds the low 16 bits. 5768 instruct loadConI32_lo16(iRegIdst dst, iRegIsrc src1, immI16 src2) %{ 5769 // no match-rule, false predicate 5770 effect(DEF dst, USE src1, USE src2); 5771 predicate(false); 5772 5773 format %{ "ORI $dst, $src1.hi, $src2.lo" %} 5774 size(4); 5775 ins_encode %{ 5776 // TODO: PPC port $archOpcode(ppc64Opcode_ori); 5777 __ ori($dst$$Register, $src1$$Register, ($src2$$constant) & 0xFFFF); 5778 %} 5779 ins_pipe(pipe_class_default); 5780 %} 5781 5782 instruct loadConI_Ex(iRegIdst dst, immI src) %{ 5783 match(Set dst src); 5784 ins_cost(DEFAULT_COST*2); 5785 5786 expand %{ 5787 // Would like to use $src$$constant. 5788 immI16 srcLo %{ _opnds[1]->constant() %} 5789 // srcHi can be 0000 if srcLo sign-extends to a negative number. 5790 immIhi16 srcHi %{ _opnds[1]->constant() %} 5791 iRegIdst tmpI; 5792 loadConIhi16(tmpI, srcHi); 5793 loadConI32_lo16(dst, tmpI, srcLo); 5794 %} 5795 %} 5796 5797 // No constant pool entries required. 5798 instruct loadConL16(iRegLdst dst, immL16 src) %{ 5799 match(Set dst src); 5800 5801 format %{ "LI $dst, $src \t// long" %} 5802 size(4); 5803 ins_encode %{ 5804 // TODO: PPC port $archOpcode(ppc64Opcode_addi); 5805 __ li($dst$$Register, (int)((short) ($src$$constant & 0xFFFF))); 5806 %} 5807 ins_pipe(pipe_class_default); 5808 %} 5809 5810 // Load long constant 0xssssssss????0000 5811 instruct loadConL32hi16(iRegLdst dst, immL32hi16 src) %{ 5812 match(Set dst src); 5813 ins_cost(DEFAULT_COST); 5814 5815 format %{ "LIS $dst, $src.hi \t// long" %} 5816 size(4); 5817 ins_encode %{ 5818 // TODO: PPC port $archOpcode(ppc64Opcode_addis); 5819 __ lis($dst$$Register, (int)((short)(($src$$constant & 0xFFFF0000) >> 16))); 5820 %} 5821 ins_pipe(pipe_class_default); 5822 %} 5823 5824 // To load a 32 bit constant: merge lower 16 bits into already loaded 5825 // high 16 bits. 5826 instruct loadConL32_lo16(iRegLdst dst, iRegLsrc src1, immL16 src2) %{ 5827 // no match-rule, false predicate 5828 effect(DEF dst, USE src1, USE src2); 5829 predicate(false); 5830 5831 format %{ "ORI $dst, $src1, $src2.lo" %} 5832 size(4); 5833 ins_encode %{ 5834 // TODO: PPC port $archOpcode(ppc64Opcode_ori); 5835 __ ori($dst$$Register, $src1$$Register, ($src2$$constant) & 0xFFFF); 5836 %} 5837 ins_pipe(pipe_class_default); 5838 %} 5839 5840 // Load 32-bit long constant 5841 instruct loadConL32_Ex(iRegLdst dst, immL32 src) %{ 5842 match(Set dst src); 5843 ins_cost(DEFAULT_COST*2); 5844 5845 expand %{ 5846 // Would like to use $src$$constant. 5847 immL16 srcLo %{ _opnds[1]->constant() /*& 0x0000FFFFL */%} 5848 // srcHi can be 0000 if srcLo sign-extends to a negative number. 5849 immL32hi16 srcHi %{ _opnds[1]->constant() /*& 0xFFFF0000L */%} 5850 iRegLdst tmpL; 5851 loadConL32hi16(tmpL, srcHi); 5852 loadConL32_lo16(dst, tmpL, srcLo); 5853 %} 5854 %} 5855 5856 // Load long constant 0x????000000000000. 5857 instruct loadConLhighest16_Ex(iRegLdst dst, immLhighest16 src) %{ 5858 match(Set dst src); 5859 ins_cost(DEFAULT_COST); 5860 5861 expand %{ 5862 immL32hi16 srcHi %{ _opnds[1]->constant() >> 32 /*& 0xFFFF0000L */%} 5863 immI shift32 %{ 32 %} 5864 iRegLdst tmpL; 5865 loadConL32hi16(tmpL, srcHi); 5866 lshiftL_regL_immI(dst, tmpL, shift32); 5867 %} 5868 %} 5869 5870 // Expand node for constant pool load: small offset. 5871 instruct loadConL(iRegLdst dst, immL src, iRegLdst toc) %{ 5872 effect(DEF dst, USE src, USE toc); 5873 ins_cost(MEMORY_REF_COST); 5874 5875 ins_num_consts(1); 5876 // Needed so that CallDynamicJavaDirect can compute the address of this 5877 // instruction for relocation. 5878 ins_field_cbuf_insts_offset(int); 5879 5880 format %{ "LD $dst, offset, $toc \t// load long $src from TOC" %} 5881 size(4); 5882 ins_encode( enc_load_long_constL(dst, src, toc) ); 5883 ins_pipe(pipe_class_memory); 5884 %} 5885 5886 // Expand node for constant pool load: large offset. 5887 instruct loadConL_hi(iRegLdst dst, immL src, iRegLdst toc) %{ 5888 effect(DEF dst, USE src, USE toc); 5889 predicate(false); 5890 5891 ins_num_consts(1); 5892 ins_field_const_toc_offset(int); 5893 // Needed so that CallDynamicJavaDirect can compute the address of this 5894 // instruction for relocation. 5895 ins_field_cbuf_insts_offset(int); 5896 5897 format %{ "ADDIS $dst, $toc, offset \t// load long $src from TOC (hi)" %} 5898 size(4); 5899 ins_encode( enc_load_long_constL_hi(dst, toc, src) ); 5900 ins_pipe(pipe_class_default); 5901 %} 5902 5903 // Expand node for constant pool load: large offset. 5904 // No constant pool entries required. 5905 instruct loadConL_lo(iRegLdst dst, immL src, iRegLdst base) %{ 5906 effect(DEF dst, USE src, USE base); 5907 predicate(false); 5908 5909 ins_field_const_toc_offset_hi_node(loadConL_hiNode*); 5910 5911 format %{ "LD $dst, offset, $base \t// load long $src from TOC (lo)" %} 5912 size(4); 5913 ins_encode %{ 5914 // TODO: PPC port $archOpcode(ppc64Opcode_ld); 5915 int offset = ra_->C->in_scratch_emit_size() ? 0 : _const_toc_offset_hi_node->_const_toc_offset; 5916 __ ld($dst$$Register, MacroAssembler::largeoffset_si16_si16_lo(offset), $base$$Register); 5917 %} 5918 ins_pipe(pipe_class_memory); 5919 %} 5920 5921 // Load long constant from constant table. Expand in case of 5922 // offset > 16 bit is needed. 5923 // Adlc adds toc node MachConstantTableBase. 5924 instruct loadConL_Ex(iRegLdst dst, immL src) %{ 5925 match(Set dst src); 5926 ins_cost(MEMORY_REF_COST); 5927 5928 format %{ "LD $dst, offset, $constanttablebase\t// load long $src from table, postalloc expanded" %} 5929 // We can not inline the enc_class for the expand as that does not support constanttablebase. 5930 postalloc_expand( postalloc_expand_load_long_constant(dst, src, constanttablebase) ); 5931 %} 5932 5933 // Load NULL as compressed oop. 5934 instruct loadConN0(iRegNdst dst, immN_0 src) %{ 5935 match(Set dst src); 5936 ins_cost(DEFAULT_COST); 5937 5938 format %{ "LI $dst, $src \t// compressed ptr" %} 5939 size(4); 5940 ins_encode %{ 5941 // TODO: PPC port $archOpcode(ppc64Opcode_addi); 5942 __ li($dst$$Register, 0); 5943 %} 5944 ins_pipe(pipe_class_default); 5945 %} 5946 5947 // Load hi part of compressed oop constant. 5948 instruct loadConN_hi(iRegNdst dst, immN src) %{ 5949 effect(DEF dst, USE src); 5950 ins_cost(DEFAULT_COST); 5951 5952 format %{ "LIS $dst, $src \t// narrow oop hi" %} 5953 size(4); 5954 ins_encode %{ 5955 // TODO: PPC port $archOpcode(ppc64Opcode_addis); 5956 __ lis($dst$$Register, (int)(short)(($src$$constant >> 16) & 0xffff)); 5957 %} 5958 ins_pipe(pipe_class_default); 5959 %} 5960 5961 // Add lo part of compressed oop constant to already loaded hi part. 5962 instruct loadConN_lo(iRegNdst dst, iRegNsrc src1, immN src2) %{ 5963 effect(DEF dst, USE src1, USE src2); 5964 ins_cost(DEFAULT_COST); 5965 5966 format %{ "ORI $dst, $src1, $src2 \t// narrow oop lo" %} 5967 size(4); 5968 ins_encode %{ 5969 // TODO: PPC port $archOpcode(ppc64Opcode_addi); 5970 assert(__ oop_recorder() != NULL, "this assembler needs an OopRecorder"); 5971 int oop_index = __ oop_recorder()->find_index((jobject)$src2$$constant); 5972 RelocationHolder rspec = oop_Relocation::spec(oop_index); 5973 __ relocate(rspec, 1); 5974 __ ori($dst$$Register, $src1$$Register, $src2$$constant & 0xffff); 5975 %} 5976 ins_pipe(pipe_class_default); 5977 %} 5978 5979 // Needed to postalloc expand loadConN: ConN is loaded as ConI 5980 // leaving the upper 32 bits with sign-extension bits. 5981 // This clears these bits: dst = src & 0xFFFFFFFF. 5982 // TODO: Eventually call this maskN_regN_FFFFFFFF. 5983 instruct clearMs32b(iRegNdst dst, iRegNsrc src) %{ 5984 effect(DEF dst, USE src); 5985 predicate(false); 5986 5987 format %{ "MASK $dst, $src, 0xFFFFFFFF" %} // mask 5988 size(4); 5989 ins_encode %{ 5990 // TODO: PPC port $archOpcode(ppc64Opcode_rldicl); 5991 __ clrldi($dst$$Register, $src$$Register, 0x20); 5992 %} 5993 ins_pipe(pipe_class_default); 5994 %} 5995 5996 // Loading ConN must be postalloc expanded so that edges between 5997 // the nodes are safe. They may not interfere with a safepoint. 5998 // GL TODO: This needs three instructions: better put this into the constant pool. 5999 instruct loadConN_Ex(iRegNdst dst, immN src) %{ 6000 match(Set dst src); 6001 ins_cost(DEFAULT_COST*2); 6002 6003 format %{ "LoadN $dst, $src \t// postalloc expanded" %} // mask 6004 postalloc_expand %{ 6005 MachNode *m1 = new (C) loadConN_hiNode(); 6006 MachNode *m2 = new (C) loadConN_loNode(); 6007 MachNode *m3 = new (C) clearMs32bNode(); 6008 m1->add_req(NULL); 6009 m2->add_req(NULL, m1); 6010 m3->add_req(NULL, m2); 6011 m1->_opnds[0] = op_dst; 6012 m1->_opnds[1] = op_src; 6013 m2->_opnds[0] = op_dst; 6014 m2->_opnds[1] = op_dst; 6015 m2->_opnds[2] = op_src; 6016 m3->_opnds[0] = op_dst; 6017 m3->_opnds[1] = op_dst; 6018 ra_->set_pair(m1->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); 6019 ra_->set_pair(m2->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); 6020 ra_->set_pair(m3->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); 6021 nodes->push(m1); 6022 nodes->push(m2); 6023 nodes->push(m3); 6024 %} 6025 %} 6026 6027 instruct loadConNKlass_hi(iRegNdst dst, immNKlass src) %{ 6028 effect(DEF dst, USE src); 6029 ins_cost(DEFAULT_COST); 6030 6031 format %{ "LIS $dst, $src \t// narrow oop hi" %} 6032 size(4); 6033 ins_encode %{ 6034 // TODO: PPC port $archOpcode(ppc64Opcode_addis); 6035 intptr_t Csrc = Klass::encode_klass((Klass *)$src$$constant); 6036 __ lis($dst$$Register, (int)(short)((Csrc >> 16) & 0xffff)); 6037 %} 6038 ins_pipe(pipe_class_default); 6039 %} 6040 6041 // This needs a match rule so that build_oop_map knows this is 6042 // not a narrow oop. 6043 instruct loadConNKlass_lo(iRegNdst dst, immNKlass_NM src1, iRegNsrc src2) %{ 6044 match(Set dst src1); 6045 effect(TEMP src2); 6046 ins_cost(DEFAULT_COST); 6047 6048 format %{ "ADDI $dst, $src1, $src2 \t// narrow oop lo" %} 6049 size(4); 6050 ins_encode %{ 6051 // TODO: PPC port $archOpcode(ppc64Opcode_addi); 6052 intptr_t Csrc = Klass::encode_klass((Klass *)$src1$$constant); 6053 assert(__ oop_recorder() != NULL, "this assembler needs an OopRecorder"); 6054 int klass_index = __ oop_recorder()->find_index((Klass *)$src1$$constant); 6055 RelocationHolder rspec = metadata_Relocation::spec(klass_index); 6056 6057 __ relocate(rspec, 1); 6058 __ ori($dst$$Register, $src2$$Register, Csrc & 0xffff); 6059 %} 6060 ins_pipe(pipe_class_default); 6061 %} 6062 6063 // Loading ConNKlass must be postalloc expanded so that edges between 6064 // the nodes are safe. They may not interfere with a safepoint. 6065 instruct loadConNKlass_Ex(iRegNdst dst, immNKlass src) %{ 6066 match(Set dst src); 6067 ins_cost(DEFAULT_COST*2); 6068 6069 format %{ "LoadN $dst, $src \t// postalloc expanded" %} // mask 6070 postalloc_expand %{ 6071 // Load high bits into register. Sign extended. 6072 MachNode *m1 = new (C) loadConNKlass_hiNode(); 6073 m1->add_req(NULL); 6074 m1->_opnds[0] = op_dst; 6075 m1->_opnds[1] = op_src; 6076 ra_->set_pair(m1->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); 6077 nodes->push(m1); 6078 6079 MachNode *m2 = m1; 6080 if (!Assembler::is_uimm((jlong)Klass::encode_klass((Klass *)op_src->constant()), 31)) { 6081 // Value might be 1-extended. Mask out these bits. 6082 m2 = new (C) clearMs32bNode(); 6083 m2->add_req(NULL, m1); 6084 m2->_opnds[0] = op_dst; 6085 m2->_opnds[1] = op_dst; 6086 ra_->set_pair(m2->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); 6087 nodes->push(m2); 6088 } 6089 6090 MachNode *m3 = new (C) loadConNKlass_loNode(); 6091 m3->add_req(NULL, m2); 6092 m3->_opnds[0] = op_dst; 6093 m3->_opnds[1] = op_src; 6094 m3->_opnds[2] = op_dst; 6095 ra_->set_pair(m3->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); 6096 nodes->push(m3); 6097 %} 6098 %} 6099 6100 // 0x1 is used in object initialization (initial object header). 6101 // No constant pool entries required. 6102 instruct loadConP0or1(iRegPdst dst, immP_0or1 src) %{ 6103 match(Set dst src); 6104 6105 format %{ "LI $dst, $src \t// ptr" %} 6106 size(4); 6107 ins_encode %{ 6108 // TODO: PPC port $archOpcode(ppc64Opcode_addi); 6109 __ li($dst$$Register, (int)((short)($src$$constant & 0xFFFF))); 6110 %} 6111 ins_pipe(pipe_class_default); 6112 %} 6113 6114 // Expand node for constant pool load: small offset. 6115 // The match rule is needed to generate the correct bottom_type(), 6116 // however this node should never match. The use of predicate is not 6117 // possible since ADLC forbids predicates for chain rules. The higher 6118 // costs do not prevent matching in this case. For that reason the 6119 // operand immP_NM with predicate(false) is used. 6120 instruct loadConP(iRegPdst dst, immP_NM src, iRegLdst toc) %{ 6121 match(Set dst src); 6122 effect(TEMP toc); 6123 6124 ins_num_consts(1); 6125 6126 format %{ "LD $dst, offset, $toc \t// load ptr $src from TOC" %} 6127 size(4); 6128 ins_encode( enc_load_long_constP(dst, src, toc) ); 6129 ins_pipe(pipe_class_memory); 6130 %} 6131 6132 // Expand node for constant pool load: large offset. 6133 instruct loadConP_hi(iRegPdst dst, immP_NM src, iRegLdst toc) %{ 6134 effect(DEF dst, USE src, USE toc); 6135 predicate(false); 6136 6137 ins_num_consts(1); 6138 ins_field_const_toc_offset(int); 6139 6140 format %{ "ADDIS $dst, $toc, offset \t// load ptr $src from TOC (hi)" %} 6141 size(4); 6142 ins_encode( enc_load_long_constP_hi(dst, src, toc) ); 6143 ins_pipe(pipe_class_default); 6144 %} 6145 6146 // Expand node for constant pool load: large offset. 6147 instruct loadConP_lo(iRegPdst dst, immP_NM src, iRegLdst base) %{ 6148 match(Set dst src); 6149 effect(TEMP base); 6150 6151 ins_field_const_toc_offset_hi_node(loadConP_hiNode*); 6152 6153 format %{ "LD $dst, offset, $base \t// load ptr $src from TOC (lo)" %} 6154 size(4); 6155 ins_encode %{ 6156 // TODO: PPC port $archOpcode(ppc64Opcode_ld); 6157 int offset = ra_->C->in_scratch_emit_size() ? 0 : _const_toc_offset_hi_node->_const_toc_offset; 6158 __ ld($dst$$Register, MacroAssembler::largeoffset_si16_si16_lo(offset), $base$$Register); 6159 %} 6160 ins_pipe(pipe_class_memory); 6161 %} 6162 6163 // Load pointer constant from constant table. Expand in case an 6164 // offset > 16 bit is needed. 6165 // Adlc adds toc node MachConstantTableBase. 6166 instruct loadConP_Ex(iRegPdst dst, immP src) %{ 6167 match(Set dst src); 6168 ins_cost(MEMORY_REF_COST); 6169 6170 // This rule does not use "expand" because then 6171 // the result type is not known to be an Oop. An ADLC 6172 // enhancement will be needed to make that work - not worth it! 6173 6174 // If this instruction rematerializes, it prolongs the live range 6175 // of the toc node, causing illegal graphs. 6176 // assert(edge_from_to(_reg_node[reg_lo],def)) fails in verify_good_schedule(). 6177 ins_cannot_rematerialize(true); 6178 6179 format %{ "LD $dst, offset, $constanttablebase \t// load ptr $src from table, postalloc expanded" %} 6180 postalloc_expand( postalloc_expand_load_ptr_constant(dst, src, constanttablebase) ); 6181 %} 6182 6183 // Expand node for constant pool load: small offset. 6184 instruct loadConF(regF dst, immF src, iRegLdst toc) %{ 6185 effect(DEF dst, USE src, USE toc); 6186 ins_cost(MEMORY_REF_COST); 6187 6188 ins_num_consts(1); 6189 6190 format %{ "LFS $dst, offset, $toc \t// load float $src from TOC" %} 6191 size(4); 6192 ins_encode %{ 6193 // TODO: PPC port $archOpcode(ppc64Opcode_lfs); 6194 address float_address = __ float_constant($src$$constant); 6195 __ lfs($dst$$FloatRegister, __ offset_to_method_toc(float_address), $toc$$Register); 6196 %} 6197 ins_pipe(pipe_class_memory); 6198 %} 6199 6200 // Expand node for constant pool load: large offset. 6201 instruct loadConFComp(regF dst, immF src, iRegLdst toc) %{ 6202 effect(DEF dst, USE src, USE toc); 6203 ins_cost(MEMORY_REF_COST); 6204 6205 ins_num_consts(1); 6206 6207 format %{ "ADDIS $toc, $toc, offset_hi\n\t" 6208 "LFS $dst, offset_lo, $toc \t// load float $src from TOC (hi/lo)\n\t" 6209 "ADDIS $toc, $toc, -offset_hi"%} 6210 size(12); 6211 ins_encode %{ 6212 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 6213 FloatRegister Rdst = $dst$$FloatRegister; 6214 Register Rtoc = $toc$$Register; 6215 address float_address = __ float_constant($src$$constant); 6216 int offset = __ offset_to_method_toc(float_address); 6217 int hi = (offset + (1<<15))>>16; 6218 int lo = offset - hi * (1<<16); 6219 6220 __ addis(Rtoc, Rtoc, hi); 6221 __ lfs(Rdst, lo, Rtoc); 6222 __ addis(Rtoc, Rtoc, -hi); 6223 %} 6224 ins_pipe(pipe_class_memory); 6225 %} 6226 6227 // Adlc adds toc node MachConstantTableBase. 6228 instruct loadConF_Ex(regF dst, immF src) %{ 6229 match(Set dst src); 6230 ins_cost(MEMORY_REF_COST); 6231 6232 // See loadConP. 6233 ins_cannot_rematerialize(true); 6234 6235 format %{ "LFS $dst, offset, $constanttablebase \t// load $src from table, postalloc expanded" %} 6236 postalloc_expand( postalloc_expand_load_float_constant(dst, src, constanttablebase) ); 6237 %} 6238 6239 // Expand node for constant pool load: small offset. 6240 instruct loadConD(regD dst, immD src, iRegLdst toc) %{ 6241 effect(DEF dst, USE src, USE toc); 6242 ins_cost(MEMORY_REF_COST); 6243 6244 ins_num_consts(1); 6245 6246 format %{ "LFD $dst, offset, $toc \t// load double $src from TOC" %} 6247 size(4); 6248 ins_encode %{ 6249 // TODO: PPC port $archOpcode(ppc64Opcode_lfd); 6250 int offset = __ offset_to_method_toc(__ double_constant($src$$constant)); 6251 __ lfd($dst$$FloatRegister, offset, $toc$$Register); 6252 %} 6253 ins_pipe(pipe_class_memory); 6254 %} 6255 6256 // Expand node for constant pool load: large offset. 6257 instruct loadConDComp(regD dst, immD src, iRegLdst toc) %{ 6258 effect(DEF dst, USE src, USE toc); 6259 ins_cost(MEMORY_REF_COST); 6260 6261 ins_num_consts(1); 6262 6263 format %{ "ADDIS $toc, $toc, offset_hi\n\t" 6264 "LFD $dst, offset_lo, $toc \t// load double $src from TOC (hi/lo)\n\t" 6265 "ADDIS $toc, $toc, -offset_hi" %} 6266 size(12); 6267 ins_encode %{ 6268 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 6269 FloatRegister Rdst = $dst$$FloatRegister; 6270 Register Rtoc = $toc$$Register; 6271 address float_address = __ double_constant($src$$constant); 6272 int offset = __ offset_to_method_toc(float_address); 6273 int hi = (offset + (1<<15))>>16; 6274 int lo = offset - hi * (1<<16); 6275 6276 __ addis(Rtoc, Rtoc, hi); 6277 __ lfd(Rdst, lo, Rtoc); 6278 __ addis(Rtoc, Rtoc, -hi); 6279 %} 6280 ins_pipe(pipe_class_memory); 6281 %} 6282 6283 // Adlc adds toc node MachConstantTableBase. 6284 instruct loadConD_Ex(regD dst, immD src) %{ 6285 match(Set dst src); 6286 ins_cost(MEMORY_REF_COST); 6287 6288 // See loadConP. 6289 ins_cannot_rematerialize(true); 6290 6291 format %{ "ConD $dst, offset, $constanttablebase \t// load $src from table, postalloc expanded" %} 6292 postalloc_expand( postalloc_expand_load_double_constant(dst, src, constanttablebase) ); 6293 %} 6294 6295 // Prefetch instructions. 6296 // Must be safe to execute with invalid address (cannot fault). 6297 6298 instruct prefetchr(indirectMemory mem, iRegLsrc src) %{ 6299 match(PrefetchRead (AddP mem src)); 6300 ins_cost(MEMORY_REF_COST); 6301 6302 format %{ "PREFETCH $mem, 0, $src \t// Prefetch read-many" %} 6303 size(4); 6304 ins_encode %{ 6305 // TODO: PPC port $archOpcode(ppc64Opcode_dcbt); 6306 __ dcbt($src$$Register, $mem$$base$$Register); 6307 %} 6308 ins_pipe(pipe_class_memory); 6309 %} 6310 6311 instruct prefetchr_no_offset(indirectMemory mem) %{ 6312 match(PrefetchRead mem); 6313 ins_cost(MEMORY_REF_COST); 6314 6315 format %{ "PREFETCH $mem" %} 6316 size(4); 6317 ins_encode %{ 6318 // TODO: PPC port $archOpcode(ppc64Opcode_dcbt); 6319 __ dcbt($mem$$base$$Register); 6320 %} 6321 ins_pipe(pipe_class_memory); 6322 %} 6323 6324 instruct prefetchw(indirectMemory mem, iRegLsrc src) %{ 6325 match(PrefetchWrite (AddP mem src)); 6326 ins_cost(MEMORY_REF_COST); 6327 6328 format %{ "PREFETCH $mem, 2, $src \t// Prefetch write-many (and read)" %} 6329 size(4); 6330 ins_encode %{ 6331 // TODO: PPC port $archOpcode(ppc64Opcode_dcbtst); 6332 __ dcbtst($src$$Register, $mem$$base$$Register); 6333 %} 6334 ins_pipe(pipe_class_memory); 6335 %} 6336 6337 instruct prefetchw_no_offset(indirectMemory mem) %{ 6338 match(PrefetchWrite mem); 6339 ins_cost(MEMORY_REF_COST); 6340 6341 format %{ "PREFETCH $mem" %} 6342 size(4); 6343 ins_encode %{ 6344 // TODO: PPC port $archOpcode(ppc64Opcode_dcbtst); 6345 __ dcbtst($mem$$base$$Register); 6346 %} 6347 ins_pipe(pipe_class_memory); 6348 %} 6349 6350 // Special prefetch versions which use the dcbz instruction. 6351 instruct prefetch_alloc_zero(indirectMemory mem, iRegLsrc src) %{ 6352 match(PrefetchAllocation (AddP mem src)); 6353 predicate(AllocatePrefetchStyle == 3); 6354 ins_cost(MEMORY_REF_COST); 6355 6356 format %{ "PREFETCH $mem, 2, $src \t// Prefetch write-many with zero" %} 6357 size(4); 6358 ins_encode %{ 6359 // TODO: PPC port $archOpcode(ppc64Opcode_dcbtst); 6360 __ dcbz($src$$Register, $mem$$base$$Register); 6361 %} 6362 ins_pipe(pipe_class_memory); 6363 %} 6364 6365 instruct prefetch_alloc_zero_no_offset(indirectMemory mem) %{ 6366 match(PrefetchAllocation mem); 6367 predicate(AllocatePrefetchStyle == 3); 6368 ins_cost(MEMORY_REF_COST); 6369 6370 format %{ "PREFETCH $mem, 2 \t// Prefetch write-many with zero" %} 6371 size(4); 6372 ins_encode %{ 6373 // TODO: PPC port $archOpcode(ppc64Opcode_dcbtst); 6374 __ dcbz($mem$$base$$Register); 6375 %} 6376 ins_pipe(pipe_class_memory); 6377 %} 6378 6379 instruct prefetch_alloc(indirectMemory mem, iRegLsrc src) %{ 6380 match(PrefetchAllocation (AddP mem src)); 6381 predicate(AllocatePrefetchStyle != 3); 6382 ins_cost(MEMORY_REF_COST); 6383 6384 format %{ "PREFETCH $mem, 2, $src \t// Prefetch write-many" %} 6385 size(4); 6386 ins_encode %{ 6387 // TODO: PPC port $archOpcode(ppc64Opcode_dcbtst); 6388 __ dcbtst($src$$Register, $mem$$base$$Register); 6389 %} 6390 ins_pipe(pipe_class_memory); 6391 %} 6392 6393 instruct prefetch_alloc_no_offset(indirectMemory mem) %{ 6394 match(PrefetchAllocation mem); 6395 predicate(AllocatePrefetchStyle != 3); 6396 ins_cost(MEMORY_REF_COST); 6397 6398 format %{ "PREFETCH $mem, 2 \t// Prefetch write-many" %} 6399 size(4); 6400 ins_encode %{ 6401 // TODO: PPC port $archOpcode(ppc64Opcode_dcbtst); 6402 __ dcbtst($mem$$base$$Register); 6403 %} 6404 ins_pipe(pipe_class_memory); 6405 %} 6406 6407 //----------Store Instructions------------------------------------------------- 6408 6409 // Store Byte 6410 instruct storeB(memory mem, iRegIsrc src) %{ 6411 match(Set mem (StoreB mem src)); 6412 ins_cost(MEMORY_REF_COST); 6413 6414 format %{ "STB $src, $mem \t// byte" %} 6415 size(4); 6416 ins_encode %{ 6417 // TODO: PPC port $archOpcode(ppc64Opcode_stb); 6418 int Idisp = $mem$$disp + frame_slots_bias($mem$$base, ra_); 6419 __ stb($src$$Register, Idisp, $mem$$base$$Register); 6420 %} 6421 ins_pipe(pipe_class_memory); 6422 %} 6423 6424 // Store Char/Short 6425 instruct storeC(memory mem, iRegIsrc src) %{ 6426 match(Set mem (StoreC mem src)); 6427 ins_cost(MEMORY_REF_COST); 6428 6429 format %{ "STH $src, $mem \t// short" %} 6430 size(4); 6431 ins_encode %{ 6432 // TODO: PPC port $archOpcode(ppc64Opcode_sth); 6433 int Idisp = $mem$$disp + frame_slots_bias($mem$$base, ra_); 6434 __ sth($src$$Register, Idisp, $mem$$base$$Register); 6435 %} 6436 ins_pipe(pipe_class_memory); 6437 %} 6438 6439 // Store Integer 6440 instruct storeI(memory mem, iRegIsrc src) %{ 6441 match(Set mem (StoreI mem src)); 6442 ins_cost(MEMORY_REF_COST); 6443 6444 format %{ "STW $src, $mem" %} 6445 size(4); 6446 ins_encode( enc_stw(src, mem) ); 6447 ins_pipe(pipe_class_memory); 6448 %} 6449 6450 // ConvL2I + StoreI. 6451 instruct storeI_convL2I(memory mem, iRegLsrc src) %{ 6452 match(Set mem (StoreI mem (ConvL2I src))); 6453 ins_cost(MEMORY_REF_COST); 6454 6455 format %{ "STW l2i($src), $mem" %} 6456 size(4); 6457 ins_encode( enc_stw(src, mem) ); 6458 ins_pipe(pipe_class_memory); 6459 %} 6460 6461 // Store Long 6462 instruct storeL(memoryAlg4 mem, iRegLsrc src) %{ 6463 match(Set mem (StoreL mem src)); 6464 ins_cost(MEMORY_REF_COST); 6465 6466 format %{ "STD $src, $mem \t// long" %} 6467 size(4); 6468 ins_encode( enc_std(src, mem) ); 6469 ins_pipe(pipe_class_memory); 6470 %} 6471 6472 // Store super word nodes. 6473 6474 // Store Aligned Packed Byte long register to memory 6475 instruct storeA8B(memoryAlg4 mem, iRegLsrc src) %{ 6476 predicate(n->as_StoreVector()->memory_size() == 8); 6477 match(Set mem (StoreVector mem src)); 6478 ins_cost(MEMORY_REF_COST); 6479 6480 format %{ "STD $mem, $src \t// packed8B" %} 6481 size(4); 6482 ins_encode( enc_std(src, mem) ); 6483 ins_pipe(pipe_class_memory); 6484 %} 6485 6486 // Store Compressed Oop 6487 instruct storeN(memory dst, iRegN_P2N src) %{ 6488 match(Set dst (StoreN dst src)); 6489 ins_cost(MEMORY_REF_COST); 6490 6491 format %{ "STW $src, $dst \t// compressed oop" %} 6492 size(4); 6493 ins_encode( enc_stw(src, dst) ); 6494 ins_pipe(pipe_class_memory); 6495 %} 6496 6497 // Store Compressed KLass 6498 instruct storeNKlass(memory dst, iRegN_P2N src) %{ 6499 match(Set dst (StoreNKlass dst src)); 6500 ins_cost(MEMORY_REF_COST); 6501 6502 format %{ "STW $src, $dst \t// compressed klass" %} 6503 size(4); 6504 ins_encode( enc_stw(src, dst) ); 6505 ins_pipe(pipe_class_memory); 6506 %} 6507 6508 // Store Pointer 6509 instruct storeP(memoryAlg4 dst, iRegPsrc src) %{ 6510 match(Set dst (StoreP dst src)); 6511 ins_cost(MEMORY_REF_COST); 6512 6513 format %{ "STD $src, $dst \t// ptr" %} 6514 size(4); 6515 ins_encode( enc_std(src, dst) ); 6516 ins_pipe(pipe_class_memory); 6517 %} 6518 6519 // Store Float 6520 instruct storeF(memory mem, regF src) %{ 6521 match(Set mem (StoreF mem src)); 6522 ins_cost(MEMORY_REF_COST); 6523 6524 format %{ "STFS $src, $mem" %} 6525 size(4); 6526 ins_encode( enc_stfs(src, mem) ); 6527 ins_pipe(pipe_class_memory); 6528 %} 6529 6530 // Store Double 6531 instruct storeD(memory mem, regD src) %{ 6532 match(Set mem (StoreD mem src)); 6533 ins_cost(MEMORY_REF_COST); 6534 6535 format %{ "STFD $src, $mem" %} 6536 size(4); 6537 ins_encode( enc_stfd(src, mem) ); 6538 ins_pipe(pipe_class_memory); 6539 %} 6540 6541 //----------Store Instructions With Zeros-------------------------------------- 6542 6543 // Card-mark for CMS garbage collection. 6544 // This cardmark does an optimization so that it must not always 6545 // do a releasing store. For this, it gets the address of 6546 // CMSCollectorCardTableModRefBSExt::_requires_release as input. 6547 // (Using releaseFieldAddr in the match rule is a hack.) 6548 instruct storeCM_CMS(memory mem, iRegLdst releaseFieldAddr) %{ 6549 match(Set mem (StoreCM mem releaseFieldAddr)); 6550 predicate(false); 6551 ins_cost(MEMORY_REF_COST); 6552 6553 // See loadConP. 6554 ins_cannot_rematerialize(true); 6555 6556 format %{ "STB #0, $mem \t// CMS card-mark byte (must be 0!), checking requires_release in [$releaseFieldAddr]" %} 6557 ins_encode( enc_cms_card_mark(mem, releaseFieldAddr) ); 6558 ins_pipe(pipe_class_memory); 6559 %} 6560 6561 // Card-mark for CMS garbage collection. 6562 // This cardmark does an optimization so that it must not always 6563 // do a releasing store. For this, it needs the constant address of 6564 // CMSCollectorCardTableModRefBSExt::_requires_release. 6565 // This constant address is split off here by expand so we can use 6566 // adlc / matcher functionality to load it from the constant section. 6567 instruct storeCM_CMS_ExEx(memory mem, immI_0 zero) %{ 6568 match(Set mem (StoreCM mem zero)); 6569 predicate(UseConcMarkSweepGC); 6570 6571 expand %{ 6572 immL baseImm %{ 0 /* TODO: PPC port (jlong)CMSCollectorCardTableModRefBSExt::requires_release_address() */ %} 6573 iRegLdst releaseFieldAddress; 6574 loadConL_Ex(releaseFieldAddress, baseImm); 6575 storeCM_CMS(mem, releaseFieldAddress); 6576 %} 6577 %} 6578 6579 instruct storeCM_G1(memory mem, immI_0 zero) %{ 6580 match(Set mem (StoreCM mem zero)); 6581 predicate(UseG1GC); 6582 ins_cost(MEMORY_REF_COST); 6583 6584 ins_cannot_rematerialize(true); 6585 6586 format %{ "STB #0, $mem \t// CMS card-mark byte store (G1)" %} 6587 size(8); 6588 ins_encode %{ 6589 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 6590 __ li(R0, 0); 6591 //__ release(); // G1: oops are allowed to get visible after dirty marking 6592 guarantee($mem$$base$$Register != R1_SP, "use frame_slots_bias"); 6593 __ stb(R0, $mem$$disp, $mem$$base$$Register); 6594 %} 6595 ins_pipe(pipe_class_memory); 6596 %} 6597 6598 // Convert oop pointer into compressed form. 6599 6600 // Nodes for postalloc expand. 6601 6602 // Shift node for expand. 6603 instruct encodeP_shift(iRegNdst dst, iRegNsrc src) %{ 6604 // The match rule is needed to make it a 'MachTypeNode'! 6605 match(Set dst (EncodeP src)); 6606 predicate(false); 6607 6608 format %{ "SRDI $dst, $src, 3 \t// encode" %} 6609 size(4); 6610 ins_encode %{ 6611 // TODO: PPC port $archOpcode(ppc64Opcode_rldicl); 6612 __ srdi($dst$$Register, $src$$Register, Universe::narrow_oop_shift() & 0x3f); 6613 %} 6614 ins_pipe(pipe_class_default); 6615 %} 6616 6617 // Add node for expand. 6618 instruct encodeP_sub(iRegPdst dst, iRegPdst src) %{ 6619 // The match rule is needed to make it a 'MachTypeNode'! 6620 match(Set dst (EncodeP src)); 6621 predicate(false); 6622 6623 format %{ "SUB $dst, $src, oop_base \t// encode" %} 6624 size(4); 6625 ins_encode %{ 6626 // TODO: PPC port $archOpcode(ppc64Opcode_subf); 6627 __ subf($dst$$Register, R30, $src$$Register); 6628 %} 6629 ins_pipe(pipe_class_default); 6630 %} 6631 6632 // Conditional sub base. 6633 instruct cond_sub_base(iRegNdst dst, flagsReg crx, iRegPsrc src1) %{ 6634 // The match rule is needed to make it a 'MachTypeNode'! 6635 match(Set dst (EncodeP (Binary crx src1))); 6636 predicate(false); 6637 6638 ins_variable_size_depending_on_alignment(true); 6639 6640 format %{ "BEQ $crx, done\n\t" 6641 "SUB $dst, $src1, R30 \t// encode: subtract base if != NULL\n" 6642 "done:" %} 6643 size(false /* TODO: PPC PORT (InsertEndGroupPPC64 && Compile::current()->do_hb_scheduling())*/ ? 12 : 8); 6644 ins_encode %{ 6645 // TODO: PPC port $archOpcode(ppc64Opcode_cmove); 6646 Label done; 6647 __ beq($crx$$CondRegister, done); 6648 __ subf($dst$$Register, R30, $src1$$Register); 6649 // TODO PPC port __ endgroup_if_needed(_size == 12); 6650 __ bind(done); 6651 %} 6652 ins_pipe(pipe_class_default); 6653 %} 6654 6655 // Power 7 can use isel instruction 6656 instruct cond_set_0_oop(iRegNdst dst, flagsReg crx, iRegPsrc src1) %{ 6657 // The match rule is needed to make it a 'MachTypeNode'! 6658 match(Set dst (EncodeP (Binary crx src1))); 6659 predicate(false); 6660 6661 format %{ "CMOVE $dst, $crx eq, 0, $src1 \t// encode: preserve 0" %} 6662 size(4); 6663 ins_encode %{ 6664 // This is a Power7 instruction for which no machine description exists. 6665 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 6666 __ isel_0($dst$$Register, $crx$$CondRegister, Assembler::equal, $src1$$Register); 6667 %} 6668 ins_pipe(pipe_class_default); 6669 %} 6670 6671 // base != 0 6672 // 32G aligned narrow oop base. 6673 instruct encodeP_32GAligned(iRegNdst dst, iRegPsrc src) %{ 6674 match(Set dst (EncodeP src)); 6675 predicate(false /* TODO: PPC port Universe::narrow_oop_base_disjoint()*/); 6676 6677 format %{ "EXTRDI $dst, $src, #32, #3 \t// encode with 32G aligned base" %} 6678 size(4); 6679 ins_encode %{ 6680 // TODO: PPC port $archOpcode(ppc64Opcode_rldicl); 6681 __ rldicl($dst$$Register, $src$$Register, 64-Universe::narrow_oop_shift(), 32); 6682 %} 6683 ins_pipe(pipe_class_default); 6684 %} 6685 6686 // shift != 0, base != 0 6687 instruct encodeP_Ex(iRegNdst dst, flagsReg crx, iRegPsrc src) %{ 6688 match(Set dst (EncodeP src)); 6689 effect(TEMP crx); 6690 predicate(n->bottom_type()->make_ptr()->ptr() != TypePtr::NotNull && 6691 Universe::narrow_oop_shift() != 0 && 6692 true /* TODO: PPC port Universe::narrow_oop_base_overlaps()*/); 6693 6694 format %{ "EncodeP $dst, $crx, $src \t// postalloc expanded" %} 6695 postalloc_expand( postalloc_expand_encode_oop(dst, src, crx)); 6696 %} 6697 6698 // shift != 0, base != 0 6699 instruct encodeP_not_null_Ex(iRegNdst dst, iRegPsrc src) %{ 6700 match(Set dst (EncodeP src)); 6701 predicate(n->bottom_type()->make_ptr()->ptr() == TypePtr::NotNull && 6702 Universe::narrow_oop_shift() != 0 && 6703 true /* TODO: PPC port Universe::narrow_oop_base_overlaps()*/); 6704 6705 format %{ "EncodeP $dst, $src\t// $src != Null, postalloc expanded" %} 6706 postalloc_expand( postalloc_expand_encode_oop_not_null(dst, src) ); 6707 %} 6708 6709 // shift != 0, base == 0 6710 // TODO: This is the same as encodeP_shift. Merge! 6711 instruct encodeP_not_null_base_null(iRegNdst dst, iRegPsrc src) %{ 6712 match(Set dst (EncodeP src)); 6713 predicate(Universe::narrow_oop_shift() != 0 && 6714 Universe::narrow_oop_base() ==0); 6715 6716 format %{ "SRDI $dst, $src, #3 \t// encodeP, $src != NULL" %} 6717 size(4); 6718 ins_encode %{ 6719 // TODO: PPC port $archOpcode(ppc64Opcode_rldicl); 6720 __ srdi($dst$$Register, $src$$Register, Universe::narrow_oop_shift() & 0x3f); 6721 %} 6722 ins_pipe(pipe_class_default); 6723 %} 6724 6725 // Compressed OOPs with narrow_oop_shift == 0. 6726 // shift == 0, base == 0 6727 instruct encodeP_narrow_oop_shift_0(iRegNdst dst, iRegPsrc src) %{ 6728 match(Set dst (EncodeP src)); 6729 predicate(Universe::narrow_oop_shift() == 0); 6730 6731 format %{ "MR $dst, $src \t// Ptr->Narrow" %} 6732 // variable size, 0 or 4. 6733 ins_encode %{ 6734 // TODO: PPC port $archOpcode(ppc64Opcode_or); 6735 __ mr_if_needed($dst$$Register, $src$$Register); 6736 %} 6737 ins_pipe(pipe_class_default); 6738 %} 6739 6740 // Decode nodes. 6741 6742 // Shift node for expand. 6743 instruct decodeN_shift(iRegPdst dst, iRegPsrc src) %{ 6744 // The match rule is needed to make it a 'MachTypeNode'! 6745 match(Set dst (DecodeN src)); 6746 predicate(false); 6747 6748 format %{ "SLDI $dst, $src, #3 \t// DecodeN" %} 6749 size(4); 6750 ins_encode %{ 6751 // TODO: PPC port $archOpcode(ppc64Opcode_rldicr); 6752 __ sldi($dst$$Register, $src$$Register, Universe::narrow_oop_shift()); 6753 %} 6754 ins_pipe(pipe_class_default); 6755 %} 6756 6757 // Add node for expand. 6758 instruct decodeN_add(iRegPdst dst, iRegPdst src) %{ 6759 // The match rule is needed to make it a 'MachTypeNode'! 6760 match(Set dst (DecodeN src)); 6761 predicate(false); 6762 6763 format %{ "ADD $dst, $src, R30 \t// DecodeN, add oop base" %} 6764 size(4); 6765 ins_encode %{ 6766 // TODO: PPC port $archOpcode(ppc64Opcode_add); 6767 __ add($dst$$Register, $src$$Register, R30); 6768 %} 6769 ins_pipe(pipe_class_default); 6770 %} 6771 6772 // conditianal add base for expand 6773 instruct cond_add_base(iRegPdst dst, flagsReg crx, iRegPsrc src1) %{ 6774 // The match rule is needed to make it a 'MachTypeNode'! 6775 // NOTICE that the rule is nonsense - we just have to make sure that: 6776 // - _matrule->_rChild->_opType == "DecodeN" (see InstructForm::captures_bottom_type() in formssel.cpp) 6777 // - we have to match 'crx' to avoid an "illegal USE of non-input: flagsReg crx" error in ADLC. 6778 match(Set dst (DecodeN (Binary crx src1))); 6779 predicate(false); 6780 6781 ins_variable_size_depending_on_alignment(true); 6782 6783 format %{ "BEQ $crx, done\n\t" 6784 "ADD $dst, $src1, R30 \t// DecodeN: add oop base if $src1 != NULL\n" 6785 "done:" %} 6786 size(false /* TODO: PPC PORT (InsertEndGroupPPC64 && Compile::current()->do_hb_scheduling()) */? 12 : 8); 6787 ins_encode %{ 6788 // TODO: PPC port $archOpcode(ppc64Opcode_cmove); 6789 Label done; 6790 __ beq($crx$$CondRegister, done); 6791 __ add($dst$$Register, $src1$$Register, R30); 6792 // TODO PPC port __ endgroup_if_needed(_size == 12); 6793 __ bind(done); 6794 %} 6795 ins_pipe(pipe_class_default); 6796 %} 6797 6798 instruct cond_set_0_ptr(iRegPdst dst, flagsReg crx, iRegPsrc src1) %{ 6799 // The match rule is needed to make it a 'MachTypeNode'! 6800 // NOTICE that the rule is nonsense - we just have to make sure that: 6801 // - _matrule->_rChild->_opType == "DecodeN" (see InstructForm::captures_bottom_type() in formssel.cpp) 6802 // - we have to match 'crx' to avoid an "illegal USE of non-input: flagsReg crx" error in ADLC. 6803 match(Set dst (DecodeN (Binary crx src1))); 6804 predicate(false); 6805 6806 format %{ "CMOVE $dst, $crx eq, 0, $src1 \t// decode: preserve 0" %} 6807 size(4); 6808 ins_encode %{ 6809 // This is a Power7 instruction for which no machine description exists. 6810 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 6811 __ isel_0($dst$$Register, $crx$$CondRegister, Assembler::equal, $src1$$Register); 6812 %} 6813 ins_pipe(pipe_class_default); 6814 %} 6815 6816 // shift != 0, base != 0 6817 instruct decodeN_Ex(iRegPdst dst, iRegNsrc src, flagsReg crx) %{ 6818 match(Set dst (DecodeN src)); 6819 predicate((n->bottom_type()->is_oopptr()->ptr() != TypePtr::NotNull && 6820 n->bottom_type()->is_oopptr()->ptr() != TypePtr::Constant) && 6821 Universe::narrow_oop_shift() != 0 && 6822 Universe::narrow_oop_base() != 0); 6823 effect(TEMP crx); 6824 6825 format %{ "DecodeN $dst, $src \t// Kills $crx, postalloc expanded" %} 6826 postalloc_expand( postalloc_expand_decode_oop(dst, src, crx) ); 6827 %} 6828 6829 // shift != 0, base == 0 6830 instruct decodeN_nullBase(iRegPdst dst, iRegNsrc src) %{ 6831 match(Set dst (DecodeN src)); 6832 predicate(Universe::narrow_oop_shift() != 0 && 6833 Universe::narrow_oop_base() == 0); 6834 6835 format %{ "SLDI $dst, $src, #3 \t// DecodeN (zerobased)" %} 6836 size(4); 6837 ins_encode %{ 6838 // TODO: PPC port $archOpcode(ppc64Opcode_rldicr); 6839 __ sldi($dst$$Register, $src$$Register, Universe::narrow_oop_shift()); 6840 %} 6841 ins_pipe(pipe_class_default); 6842 %} 6843 6844 // src != 0, shift != 0, base != 0 6845 instruct decodeN_notNull_addBase_Ex(iRegPdst dst, iRegNsrc src) %{ 6846 match(Set dst (DecodeN src)); 6847 predicate((n->bottom_type()->is_oopptr()->ptr() == TypePtr::NotNull || 6848 n->bottom_type()->is_oopptr()->ptr() == TypePtr::Constant) && 6849 Universe::narrow_oop_shift() != 0 && 6850 Universe::narrow_oop_base() != 0); 6851 6852 format %{ "DecodeN $dst, $src \t// $src != NULL, postalloc expanded" %} 6853 postalloc_expand( postalloc_expand_decode_oop_not_null(dst, src)); 6854 %} 6855 6856 // Compressed OOPs with narrow_oop_shift == 0. 6857 instruct decodeN_unscaled(iRegPdst dst, iRegNsrc src) %{ 6858 match(Set dst (DecodeN src)); 6859 predicate(Universe::narrow_oop_shift() == 0); 6860 ins_cost(DEFAULT_COST); 6861 6862 format %{ "MR $dst, $src \t// DecodeN (unscaled)" %} 6863 // variable size, 0 or 4. 6864 ins_encode %{ 6865 // TODO: PPC port $archOpcode(ppc64Opcode_or); 6866 __ mr_if_needed($dst$$Register, $src$$Register); 6867 %} 6868 ins_pipe(pipe_class_default); 6869 %} 6870 6871 // Convert compressed oop into int for vectors alignment masking. 6872 instruct decodeN2I_unscaled(iRegIdst dst, iRegNsrc src) %{ 6873 match(Set dst (ConvL2I (CastP2X (DecodeN src)))); 6874 predicate(Universe::narrow_oop_shift() == 0); 6875 ins_cost(DEFAULT_COST); 6876 6877 format %{ "MR $dst, $src \t// (int)DecodeN (unscaled)" %} 6878 // variable size, 0 or 4. 6879 ins_encode %{ 6880 // TODO: PPC port $archOpcode(ppc64Opcode_or); 6881 __ mr_if_needed($dst$$Register, $src$$Register); 6882 %} 6883 ins_pipe(pipe_class_default); 6884 %} 6885 6886 // Convert klass pointer into compressed form. 6887 6888 // Nodes for postalloc expand. 6889 6890 // Shift node for expand. 6891 instruct encodePKlass_shift(iRegNdst dst, iRegNsrc src) %{ 6892 // The match rule is needed to make it a 'MachTypeNode'! 6893 match(Set dst (EncodePKlass src)); 6894 predicate(false); 6895 6896 format %{ "SRDI $dst, $src, 3 \t// encode" %} 6897 size(4); 6898 ins_encode %{ 6899 // TODO: PPC port $archOpcode(ppc64Opcode_rldicl); 6900 __ srdi($dst$$Register, $src$$Register, Universe::narrow_klass_shift()); 6901 %} 6902 ins_pipe(pipe_class_default); 6903 %} 6904 6905 // Add node for expand. 6906 instruct encodePKlass_sub_base(iRegPdst dst, iRegLsrc base, iRegPdst src) %{ 6907 // The match rule is needed to make it a 'MachTypeNode'! 6908 match(Set dst (EncodePKlass (Binary base src))); 6909 predicate(false); 6910 6911 format %{ "SUB $dst, $base, $src \t// encode" %} 6912 size(4); 6913 ins_encode %{ 6914 // TODO: PPC port $archOpcode(ppc64Opcode_subf); 6915 __ subf($dst$$Register, $base$$Register, $src$$Register); 6916 %} 6917 ins_pipe(pipe_class_default); 6918 %} 6919 6920 // base != 0 6921 // 32G aligned narrow oop base. 6922 instruct encodePKlass_32GAligned(iRegNdst dst, iRegPsrc src) %{ 6923 match(Set dst (EncodePKlass src)); 6924 predicate(false /* TODO: PPC port Universe::narrow_klass_base_disjoint()*/); 6925 6926 format %{ "EXTRDI $dst, $src, #32, #3 \t// encode with 32G aligned base" %} 6927 size(4); 6928 ins_encode %{ 6929 // TODO: PPC port $archOpcode(ppc64Opcode_rldicl); 6930 __ rldicl($dst$$Register, $src$$Register, 64-Universe::narrow_oop_shift(), 32); 6931 %} 6932 ins_pipe(pipe_class_default); 6933 %} 6934 6935 // shift != 0, base != 0 6936 instruct encodePKlass_not_null_Ex(iRegNdst dst, iRegLsrc base, iRegPsrc src) %{ 6937 match(Set dst (EncodePKlass (Binary base src))); 6938 predicate(false); 6939 6940 format %{ "EncodePKlass $dst, $src\t// $src != Null, postalloc expanded" %} 6941 postalloc_expand %{ 6942 encodePKlass_sub_baseNode *n1 = new (C) encodePKlass_sub_baseNode(); 6943 n1->add_req(n_region, n_base, n_src); 6944 n1->_opnds[0] = op_dst; 6945 n1->_opnds[1] = op_base; 6946 n1->_opnds[2] = op_src; 6947 n1->_bottom_type = _bottom_type; 6948 6949 encodePKlass_shiftNode *n2 = new (C) encodePKlass_shiftNode(); 6950 n2->add_req(n_region, n1); 6951 n2->_opnds[0] = op_dst; 6952 n2->_opnds[1] = op_dst; 6953 n2->_bottom_type = _bottom_type; 6954 ra_->set_pair(n1->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); 6955 ra_->set_pair(n2->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); 6956 6957 nodes->push(n1); 6958 nodes->push(n2); 6959 %} 6960 %} 6961 6962 // shift != 0, base != 0 6963 instruct encodePKlass_not_null_ExEx(iRegNdst dst, iRegPsrc src) %{ 6964 match(Set dst (EncodePKlass src)); 6965 //predicate(Universe::narrow_klass_shift() != 0 && 6966 // true /* TODO: PPC port Universe::narrow_klass_base_overlaps()*/); 6967 6968 //format %{ "EncodePKlass $dst, $src\t// $src != Null, postalloc expanded" %} 6969 ins_cost(DEFAULT_COST*2); // Don't count constant. 6970 expand %{ 6971 immL baseImm %{ (jlong)(intptr_t)Universe::narrow_klass_base() %} 6972 iRegLdst base; 6973 loadConL_Ex(base, baseImm); 6974 encodePKlass_not_null_Ex(dst, base, src); 6975 %} 6976 %} 6977 6978 // Decode nodes. 6979 6980 // Shift node for expand. 6981 instruct decodeNKlass_shift(iRegPdst dst, iRegPsrc src) %{ 6982 // The match rule is needed to make it a 'MachTypeNode'! 6983 match(Set dst (DecodeNKlass src)); 6984 predicate(false); 6985 6986 format %{ "SLDI $dst, $src, #3 \t// DecodeNKlass" %} 6987 size(4); 6988 ins_encode %{ 6989 // TODO: PPC port $archOpcode(ppc64Opcode_rldicr); 6990 __ sldi($dst$$Register, $src$$Register, Universe::narrow_klass_shift()); 6991 %} 6992 ins_pipe(pipe_class_default); 6993 %} 6994 6995 // Add node for expand. 6996 6997 instruct decodeNKlass_add_base(iRegPdst dst, iRegLsrc base, iRegPdst src) %{ 6998 // The match rule is needed to make it a 'MachTypeNode'! 6999 match(Set dst (DecodeNKlass (Binary base src))); 7000 predicate(false); 7001 7002 format %{ "ADD $dst, $base, $src \t// DecodeNKlass, add klass base" %} 7003 size(4); 7004 ins_encode %{ 7005 // TODO: PPC port $archOpcode(ppc64Opcode_add); 7006 __ add($dst$$Register, $base$$Register, $src$$Register); 7007 %} 7008 ins_pipe(pipe_class_default); 7009 %} 7010 7011 // src != 0, shift != 0, base != 0 7012 instruct decodeNKlass_notNull_addBase_Ex(iRegPdst dst, iRegLsrc base, iRegNsrc src) %{ 7013 match(Set dst (DecodeNKlass (Binary base src))); 7014 //effect(kill src); // We need a register for the immediate result after shifting. 7015 predicate(false); 7016 7017 format %{ "DecodeNKlass $dst = $base + ($src << 3) \t// $src != NULL, postalloc expanded" %} 7018 postalloc_expand %{ 7019 decodeNKlass_add_baseNode *n1 = new (C) decodeNKlass_add_baseNode(); 7020 n1->add_req(n_region, n_base, n_src); 7021 n1->_opnds[0] = op_dst; 7022 n1->_opnds[1] = op_base; 7023 n1->_opnds[2] = op_src; 7024 n1->_bottom_type = _bottom_type; 7025 7026 decodeNKlass_shiftNode *n2 = new (C) decodeNKlass_shiftNode(); 7027 n2->add_req(n_region, n2); 7028 n2->_opnds[0] = op_dst; 7029 n2->_opnds[1] = op_dst; 7030 n2->_bottom_type = _bottom_type; 7031 7032 ra_->set_pair(n1->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); 7033 ra_->set_pair(n2->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); 7034 7035 nodes->push(n1); 7036 nodes->push(n2); 7037 %} 7038 %} 7039 7040 // src != 0, shift != 0, base != 0 7041 instruct decodeNKlass_notNull_addBase_ExEx(iRegPdst dst, iRegNsrc src) %{ 7042 match(Set dst (DecodeNKlass src)); 7043 // predicate(Universe::narrow_klass_shift() != 0 && 7044 // Universe::narrow_klass_base() != 0); 7045 7046 //format %{ "DecodeNKlass $dst, $src \t// $src != NULL, expanded" %} 7047 7048 ins_cost(DEFAULT_COST*2); // Don't count constant. 7049 expand %{ 7050 // We add first, then we shift. Like this, we can get along with one register less. 7051 // But we have to load the base pre-shifted. 7052 immL baseImm %{ (jlong)((intptr_t)Universe::narrow_klass_base() >> Universe::narrow_klass_shift()) %} 7053 iRegLdst base; 7054 loadConL_Ex(base, baseImm); 7055 decodeNKlass_notNull_addBase_Ex(dst, base, src); 7056 %} 7057 %} 7058 7059 //----------MemBar Instructions----------------------------------------------- 7060 // Memory barrier flavors 7061 7062 instruct membar_acquire() %{ 7063 match(LoadFence); 7064 ins_cost(4*MEMORY_REF_COST); 7065 7066 format %{ "MEMBAR-acquire" %} 7067 size(4); 7068 ins_encode %{ 7069 // TODO: PPC port $archOpcode(ppc64Opcode_lwsync); 7070 __ acquire(); 7071 %} 7072 ins_pipe(pipe_class_default); 7073 %} 7074 7075 instruct unnecessary_membar_acquire() %{ 7076 match(MemBarAcquire); 7077 ins_cost(0); 7078 7079 format %{ " -- \t// redundant MEMBAR-acquire - empty" %} 7080 size(0); 7081 ins_encode( /*empty*/ ); 7082 ins_pipe(pipe_class_default); 7083 %} 7084 7085 instruct membar_acquire_lock() %{ 7086 match(MemBarAcquireLock); 7087 ins_cost(0); 7088 7089 format %{ " -- \t// redundant MEMBAR-acquire - empty (acquire as part of CAS in prior FastLock)" %} 7090 size(0); 7091 ins_encode( /*empty*/ ); 7092 ins_pipe(pipe_class_default); 7093 %} 7094 7095 instruct membar_release() %{ 7096 match(MemBarRelease); 7097 match(StoreFence); 7098 ins_cost(4*MEMORY_REF_COST); 7099 7100 format %{ "MEMBAR-release" %} 7101 size(4); 7102 ins_encode %{ 7103 // TODO: PPC port $archOpcode(ppc64Opcode_lwsync); 7104 __ release(); 7105 %} 7106 ins_pipe(pipe_class_default); 7107 %} 7108 7109 instruct membar_storestore() %{ 7110 match(MemBarStoreStore); 7111 ins_cost(4*MEMORY_REF_COST); 7112 7113 format %{ "MEMBAR-store-store" %} 7114 size(4); 7115 ins_encode %{ 7116 // TODO: PPC port $archOpcode(ppc64Opcode_lwsync); 7117 __ membar(Assembler::StoreStore); 7118 %} 7119 ins_pipe(pipe_class_default); 7120 %} 7121 7122 instruct membar_release_lock() %{ 7123 match(MemBarReleaseLock); 7124 ins_cost(0); 7125 7126 format %{ " -- \t// redundant MEMBAR-release - empty (release in FastUnlock)" %} 7127 size(0); 7128 ins_encode( /*empty*/ ); 7129 ins_pipe(pipe_class_default); 7130 %} 7131 7132 instruct membar_volatile() %{ 7133 match(MemBarVolatile); 7134 ins_cost(4*MEMORY_REF_COST); 7135 7136 format %{ "MEMBAR-volatile" %} 7137 size(4); 7138 ins_encode %{ 7139 // TODO: PPC port $archOpcode(ppc64Opcode_sync); 7140 __ fence(); 7141 %} 7142 ins_pipe(pipe_class_default); 7143 %} 7144 7145 // This optimization is wrong on PPC. The following pattern is not supported: 7146 // MemBarVolatile 7147 // ^ ^ 7148 // | | 7149 // CtrlProj MemProj 7150 // ^ ^ 7151 // | | 7152 // | Load 7153 // | 7154 // MemBarVolatile 7155 // 7156 // The first MemBarVolatile could get optimized out! According to 7157 // Vladimir, this pattern can not occur on Oracle platforms. 7158 // However, it does occur on PPC64 (because of membars in 7159 // inline_unsafe_load_store). 7160 // 7161 // Add this node again if we found a good solution for inline_unsafe_load_store(). 7162 // Don't forget to look at the implementation of post_store_load_barrier again, 7163 // we did other fixes in that method. 7164 //instruct unnecessary_membar_volatile() %{ 7165 // match(MemBarVolatile); 7166 // predicate(Matcher::post_store_load_barrier(n)); 7167 // ins_cost(0); 7168 // 7169 // format %{ " -- \t// redundant MEMBAR-volatile - empty" %} 7170 // size(0); 7171 // ins_encode( /*empty*/ ); 7172 // ins_pipe(pipe_class_default); 7173 //%} 7174 7175 instruct membar_CPUOrder() %{ 7176 match(MemBarCPUOrder); 7177 ins_cost(0); 7178 7179 format %{ " -- \t// MEMBAR-CPUOrder - empty: PPC64 processors are self-consistent." %} 7180 size(0); 7181 ins_encode( /*empty*/ ); 7182 ins_pipe(pipe_class_default); 7183 %} 7184 7185 //----------Conditional Move--------------------------------------------------- 7186 7187 // Cmove using isel. 7188 instruct cmovI_reg_isel(cmpOp cmp, flagsReg crx, iRegIdst dst, iRegIsrc src) %{ 7189 match(Set dst (CMoveI (Binary cmp crx) (Binary dst src))); 7190 predicate(VM_Version::has_isel()); 7191 ins_cost(DEFAULT_COST); 7192 7193 format %{ "CMOVE $cmp, $crx, $dst, $src\n\t" %} 7194 size(4); 7195 ins_encode %{ 7196 // This is a Power7 instruction for which no machine description 7197 // exists. Anyways, the scheduler should be off on Power7. 7198 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 7199 int cc = $cmp$$cmpcode; 7200 __ isel($dst$$Register, $crx$$CondRegister, 7201 (Assembler::Condition)(cc & 3), /*invert*/((~cc) & 8), $src$$Register); 7202 %} 7203 ins_pipe(pipe_class_default); 7204 %} 7205 7206 instruct cmovI_reg(cmpOp cmp, flagsReg crx, iRegIdst dst, iRegIsrc src) %{ 7207 match(Set dst (CMoveI (Binary cmp crx) (Binary dst src))); 7208 predicate(!VM_Version::has_isel()); 7209 ins_cost(DEFAULT_COST+BRANCH_COST); 7210 7211 ins_variable_size_depending_on_alignment(true); 7212 7213 format %{ "CMOVE $cmp, $crx, $dst, $src\n\t" %} 7214 // Worst case is branch + move + stop, no stop without scheduler 7215 size(false /* TODO: PPC PORT Compile::current()->do_hb_scheduling()*/ ? 12 : 8); 7216 ins_encode( enc_cmove_reg(dst, crx, src, cmp) ); 7217 ins_pipe(pipe_class_default); 7218 %} 7219 7220 instruct cmovI_imm(cmpOp cmp, flagsReg crx, iRegIdst dst, immI16 src) %{ 7221 match(Set dst (CMoveI (Binary cmp crx) (Binary dst src))); 7222 ins_cost(DEFAULT_COST+BRANCH_COST); 7223 7224 ins_variable_size_depending_on_alignment(true); 7225 7226 format %{ "CMOVE $cmp, $crx, $dst, $src\n\t" %} 7227 // Worst case is branch + move + stop, no stop without scheduler 7228 size(false /* TODO: PPC PORT Compile::current()->do_hb_scheduling()*/ ? 12 : 8); 7229 ins_encode( enc_cmove_imm(dst, crx, src, cmp) ); 7230 ins_pipe(pipe_class_default); 7231 %} 7232 7233 // Cmove using isel. 7234 instruct cmovL_reg_isel(cmpOp cmp, flagsReg crx, iRegLdst dst, iRegLsrc src) %{ 7235 match(Set dst (CMoveL (Binary cmp crx) (Binary dst src))); 7236 predicate(VM_Version::has_isel()); 7237 ins_cost(DEFAULT_COST); 7238 7239 format %{ "CMOVE $cmp, $crx, $dst, $src\n\t" %} 7240 size(4); 7241 ins_encode %{ 7242 // This is a Power7 instruction for which no machine description 7243 // exists. Anyways, the scheduler should be off on Power7. 7244 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 7245 int cc = $cmp$$cmpcode; 7246 __ isel($dst$$Register, $crx$$CondRegister, 7247 (Assembler::Condition)(cc & 3), /*invert*/((~cc) & 8), $src$$Register); 7248 %} 7249 ins_pipe(pipe_class_default); 7250 %} 7251 7252 instruct cmovL_reg(cmpOp cmp, flagsReg crx, iRegLdst dst, iRegLsrc src) %{ 7253 match(Set dst (CMoveL (Binary cmp crx) (Binary dst src))); 7254 predicate(!VM_Version::has_isel()); 7255 ins_cost(DEFAULT_COST+BRANCH_COST); 7256 7257 ins_variable_size_depending_on_alignment(true); 7258 7259 format %{ "CMOVE $cmp, $crx, $dst, $src\n\t" %} 7260 // Worst case is branch + move + stop, no stop without scheduler. 7261 size(false /* TODO: PPC PORT Compile::current()->do_hb_scheduling()*/ ? 12 : 8); 7262 ins_encode( enc_cmove_reg(dst, crx, src, cmp) ); 7263 ins_pipe(pipe_class_default); 7264 %} 7265 7266 instruct cmovL_imm(cmpOp cmp, flagsReg crx, iRegLdst dst, immL16 src) %{ 7267 match(Set dst (CMoveL (Binary cmp crx) (Binary dst src))); 7268 ins_cost(DEFAULT_COST+BRANCH_COST); 7269 7270 ins_variable_size_depending_on_alignment(true); 7271 7272 format %{ "CMOVE $cmp, $crx, $dst, $src\n\t" %} 7273 // Worst case is branch + move + stop, no stop without scheduler. 7274 size(false /* TODO: PPC PORT Compile::current()->do_hb_scheduling()*/ ? 12 : 8); 7275 ins_encode( enc_cmove_imm(dst, crx, src, cmp) ); 7276 ins_pipe(pipe_class_default); 7277 %} 7278 7279 // Cmove using isel. 7280 instruct cmovN_reg_isel(cmpOp cmp, flagsReg crx, iRegNdst dst, iRegNsrc src) %{ 7281 match(Set dst (CMoveN (Binary cmp crx) (Binary dst src))); 7282 predicate(VM_Version::has_isel()); 7283 ins_cost(DEFAULT_COST); 7284 7285 format %{ "CMOVE $cmp, $crx, $dst, $src\n\t" %} 7286 size(4); 7287 ins_encode %{ 7288 // This is a Power7 instruction for which no machine description 7289 // exists. Anyways, the scheduler should be off on Power7. 7290 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 7291 int cc = $cmp$$cmpcode; 7292 __ isel($dst$$Register, $crx$$CondRegister, 7293 (Assembler::Condition)(cc & 3), /*invert*/((~cc) & 8), $src$$Register); 7294 %} 7295 ins_pipe(pipe_class_default); 7296 %} 7297 7298 // Conditional move for RegN. Only cmov(reg, reg). 7299 instruct cmovN_reg(cmpOp cmp, flagsReg crx, iRegNdst dst, iRegNsrc src) %{ 7300 match(Set dst (CMoveN (Binary cmp crx) (Binary dst src))); 7301 predicate(!VM_Version::has_isel()); 7302 ins_cost(DEFAULT_COST+BRANCH_COST); 7303 7304 ins_variable_size_depending_on_alignment(true); 7305 7306 format %{ "CMOVE $cmp, $crx, $dst, $src\n\t" %} 7307 // Worst case is branch + move + stop, no stop without scheduler. 7308 size(false /* TODO: PPC PORT Compile::current()->do_hb_scheduling()*/ ? 12 : 8); 7309 ins_encode( enc_cmove_reg(dst, crx, src, cmp) ); 7310 ins_pipe(pipe_class_default); 7311 %} 7312 7313 instruct cmovN_imm(cmpOp cmp, flagsReg crx, iRegNdst dst, immN_0 src) %{ 7314 match(Set dst (CMoveN (Binary cmp crx) (Binary dst src))); 7315 ins_cost(DEFAULT_COST+BRANCH_COST); 7316 7317 ins_variable_size_depending_on_alignment(true); 7318 7319 format %{ "CMOVE $cmp, $crx, $dst, $src\n\t" %} 7320 // Worst case is branch + move + stop, no stop without scheduler. 7321 size(false /* TODO: PPC PORT Compile::current()->do_hb_scheduling()*/ ? 12 : 8); 7322 ins_encode( enc_cmove_imm(dst, crx, src, cmp) ); 7323 ins_pipe(pipe_class_default); 7324 %} 7325 7326 // Cmove using isel. 7327 instruct cmovP_reg_isel(cmpOp cmp, flagsReg crx, iRegPdst dst, iRegPsrc src) %{ 7328 match(Set dst (CMoveP (Binary cmp crx) (Binary dst src))); 7329 predicate(VM_Version::has_isel()); 7330 ins_cost(DEFAULT_COST); 7331 7332 format %{ "CMOVE $cmp, $crx, $dst, $src\n\t" %} 7333 size(4); 7334 ins_encode %{ 7335 // This is a Power7 instruction for which no machine description 7336 // exists. Anyways, the scheduler should be off on Power7. 7337 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 7338 int cc = $cmp$$cmpcode; 7339 __ isel($dst$$Register, $crx$$CondRegister, 7340 (Assembler::Condition)(cc & 3), /*invert*/((~cc) & 8), $src$$Register); 7341 %} 7342 ins_pipe(pipe_class_default); 7343 %} 7344 7345 instruct cmovP_reg(cmpOp cmp, flagsReg crx, iRegPdst dst, iRegP_N2P src) %{ 7346 match(Set dst (CMoveP (Binary cmp crx) (Binary dst src))); 7347 predicate(!VM_Version::has_isel()); 7348 ins_cost(DEFAULT_COST+BRANCH_COST); 7349 7350 ins_variable_size_depending_on_alignment(true); 7351 7352 format %{ "CMOVE $cmp, $crx, $dst, $src\n\t" %} 7353 // Worst case is branch + move + stop, no stop without scheduler. 7354 size(false /* TODO: PPC PORT Compile::current()->do_hb_scheduling()*/ ? 12 : 8); 7355 ins_encode( enc_cmove_reg(dst, crx, src, cmp) ); 7356 ins_pipe(pipe_class_default); 7357 %} 7358 7359 instruct cmovP_imm(cmpOp cmp, flagsReg crx, iRegPdst dst, immP_0 src) %{ 7360 match(Set dst (CMoveP (Binary cmp crx) (Binary dst src))); 7361 ins_cost(DEFAULT_COST+BRANCH_COST); 7362 7363 ins_variable_size_depending_on_alignment(true); 7364 7365 format %{ "CMOVE $cmp, $crx, $dst, $src\n\t" %} 7366 // Worst case is branch + move + stop, no stop without scheduler. 7367 size(false /* TODO: PPC PORT Compile::current()->do_hb_scheduling()*/ ? 12 : 8); 7368 ins_encode( enc_cmove_imm(dst, crx, src, cmp) ); 7369 ins_pipe(pipe_class_default); 7370 %} 7371 7372 instruct cmovF_reg(cmpOp cmp, flagsReg crx, regF dst, regF src) %{ 7373 match(Set dst (CMoveF (Binary cmp crx) (Binary dst src))); 7374 ins_cost(DEFAULT_COST+BRANCH_COST); 7375 7376 ins_variable_size_depending_on_alignment(true); 7377 7378 format %{ "CMOVEF $cmp, $crx, $dst, $src\n\t" %} 7379 // Worst case is branch + move + stop, no stop without scheduler. 7380 size(false /* TODO: PPC PORT (InsertEndGroupPPC64 && Compile::current()->do_hb_scheduling())*/ ? 12 : 8); 7381 ins_encode %{ 7382 // TODO: PPC port $archOpcode(ppc64Opcode_cmovef); 7383 Label done; 7384 assert((Assembler::bcondCRbiIs1 & ~Assembler::bcondCRbiIs0) == 8, "check encoding"); 7385 // Branch if not (cmp crx). 7386 __ bc(cc_to_inverse_boint($cmp$$cmpcode), cc_to_biint($cmp$$cmpcode, $crx$$reg), done); 7387 __ fmr($dst$$FloatRegister, $src$$FloatRegister); 7388 // TODO PPC port __ endgroup_if_needed(_size == 12); 7389 __ bind(done); 7390 %} 7391 ins_pipe(pipe_class_default); 7392 %} 7393 7394 instruct cmovD_reg(cmpOp cmp, flagsReg crx, regD dst, regD src) %{ 7395 match(Set dst (CMoveD (Binary cmp crx) (Binary dst src))); 7396 ins_cost(DEFAULT_COST+BRANCH_COST); 7397 7398 ins_variable_size_depending_on_alignment(true); 7399 7400 format %{ "CMOVEF $cmp, $crx, $dst, $src\n\t" %} 7401 // Worst case is branch + move + stop, no stop without scheduler. 7402 size(false /* TODO: PPC PORT (InsertEndGroupPPC64 && Compile::current()->do_hb_scheduling())*/ ? 12 : 8); 7403 ins_encode %{ 7404 // TODO: PPC port $archOpcode(ppc64Opcode_cmovef); 7405 Label done; 7406 assert((Assembler::bcondCRbiIs1 & ~Assembler::bcondCRbiIs0) == 8, "check encoding"); 7407 // Branch if not (cmp crx). 7408 __ bc(cc_to_inverse_boint($cmp$$cmpcode), cc_to_biint($cmp$$cmpcode, $crx$$reg), done); 7409 __ fmr($dst$$FloatRegister, $src$$FloatRegister); 7410 // TODO PPC port __ endgroup_if_needed(_size == 12); 7411 __ bind(done); 7412 %} 7413 ins_pipe(pipe_class_default); 7414 %} 7415 7416 //----------Conditional_store-------------------------------------------------- 7417 // Conditional-store of the updated heap-top. 7418 // Used during allocation of the shared heap. 7419 // Sets flags (EQ) on success. Implemented with a CASA on Sparc. 7420 7421 // As compareAndSwapL, but return flag register instead of boolean value in 7422 // int register. 7423 // Used by sun/misc/AtomicLongCSImpl.java. 7424 // Mem_ptr must be a memory operand, else this node does not get 7425 // Flag_needs_anti_dependence_check set by adlc. If this is not set this node 7426 // can be rematerialized which leads to errors. 7427 instruct storeLConditional_regP_regL_regL(flagsReg crx, indirect mem_ptr, iRegLsrc oldVal, iRegLsrc newVal) %{ 7428 match(Set crx (StoreLConditional mem_ptr (Binary oldVal newVal))); 7429 format %{ "CMPXCHGD if ($crx = ($oldVal == *$mem_ptr)) *mem_ptr = $newVal; as bool" %} 7430 ins_encode %{ 7431 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 7432 __ cmpxchgd($crx$$CondRegister, R0, $oldVal$$Register, $newVal$$Register, $mem_ptr$$Register, 7433 MacroAssembler::MemBarNone, MacroAssembler::cmpxchgx_hint_atomic_update(), 7434 noreg, NULL, true); 7435 %} 7436 ins_pipe(pipe_class_default); 7437 %} 7438 7439 // As compareAndSwapP, but return flag register instead of boolean value in 7440 // int register. 7441 // This instruction is matched if UseTLAB is off. 7442 // Mem_ptr must be a memory operand, else this node does not get 7443 // Flag_needs_anti_dependence_check set by adlc. If this is not set this node 7444 // can be rematerialized which leads to errors. 7445 instruct storePConditional_regP_regP_regP(flagsReg crx, indirect mem_ptr, iRegPsrc oldVal, iRegPsrc newVal) %{ 7446 match(Set crx (StorePConditional mem_ptr (Binary oldVal newVal))); 7447 format %{ "CMPXCHGD if ($crx = ($oldVal == *$mem_ptr)) *mem_ptr = $newVal; as bool" %} 7448 ins_encode %{ 7449 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 7450 __ cmpxchgd($crx$$CondRegister, R0, $oldVal$$Register, $newVal$$Register, $mem_ptr$$Register, 7451 MacroAssembler::MemBarNone, MacroAssembler::cmpxchgx_hint_atomic_update(), 7452 noreg, NULL, true); 7453 %} 7454 ins_pipe(pipe_class_default); 7455 %} 7456 7457 // Implement LoadPLocked. Must be ordered against changes of the memory location 7458 // by storePConditional. 7459 // Don't know whether this is ever used. 7460 instruct loadPLocked(iRegPdst dst, memory mem) %{ 7461 match(Set dst (LoadPLocked mem)); 7462 ins_cost(MEMORY_REF_COST); 7463 7464 format %{ "LD $dst, $mem \t// loadPLocked\n\t" 7465 "TWI $dst\n\t" 7466 "ISYNC" %} 7467 size(12); 7468 ins_encode( enc_ld_ac(dst, mem) ); 7469 ins_pipe(pipe_class_memory); 7470 %} 7471 7472 //----------Compare-And-Swap--------------------------------------------------- 7473 7474 // CompareAndSwap{P,I,L} have more than one output, therefore "CmpI 7475 // (CompareAndSwap ...)" or "If (CmpI (CompareAndSwap ..))" cannot be 7476 // matched. 7477 7478 instruct compareAndSwapI_regP_regI_regI(iRegIdst res, iRegPdst mem_ptr, iRegIsrc src1, iRegIsrc src2) %{ 7479 match(Set res (CompareAndSwapI mem_ptr (Binary src1 src2))); 7480 format %{ "CMPXCHGW $res, $mem_ptr, $src1, $src2; as bool" %} 7481 // Variable size: instruction count smaller if regs are disjoint. 7482 ins_encode %{ 7483 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 7484 // CmpxchgX sets CCR0 to cmpX(src1, src2) and Rres to 'true'/'false'. 7485 __ cmpxchgw(CCR0, R0, $src1$$Register, $src2$$Register, $mem_ptr$$Register, 7486 MacroAssembler::MemBarFenceAfter, MacroAssembler::cmpxchgx_hint_atomic_update(), 7487 $res$$Register, true); 7488 %} 7489 ins_pipe(pipe_class_default); 7490 %} 7491 7492 instruct compareAndSwapN_regP_regN_regN(iRegIdst res, iRegPdst mem_ptr, iRegNsrc src1, iRegNsrc src2) %{ 7493 match(Set res (CompareAndSwapN mem_ptr (Binary src1 src2))); 7494 format %{ "CMPXCHGW $res, $mem_ptr, $src1, $src2; as bool" %} 7495 // Variable size: instruction count smaller if regs are disjoint. 7496 ins_encode %{ 7497 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 7498 // CmpxchgX sets CCR0 to cmpX(src1, src2) and Rres to 'true'/'false'. 7499 __ cmpxchgw(CCR0, R0, $src1$$Register, $src2$$Register, $mem_ptr$$Register, 7500 MacroAssembler::MemBarFenceAfter, MacroAssembler::cmpxchgx_hint_atomic_update(), 7501 $res$$Register, true); 7502 %} 7503 ins_pipe(pipe_class_default); 7504 %} 7505 7506 instruct compareAndSwapL_regP_regL_regL(iRegIdst res, iRegPdst mem_ptr, iRegLsrc src1, iRegLsrc src2) %{ 7507 match(Set res (CompareAndSwapL mem_ptr (Binary src1 src2))); 7508 format %{ "CMPXCHGD $res, $mem_ptr, $src1, $src2; as bool" %} 7509 // Variable size: instruction count smaller if regs are disjoint. 7510 ins_encode %{ 7511 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 7512 // CmpxchgX sets CCR0 to cmpX(src1, src2) and Rres to 'true'/'false'. 7513 __ cmpxchgd(CCR0, R0, $src1$$Register, $src2$$Register, $mem_ptr$$Register, 7514 MacroAssembler::MemBarFenceAfter, MacroAssembler::cmpxchgx_hint_atomic_update(), 7515 $res$$Register, NULL, true); 7516 %} 7517 ins_pipe(pipe_class_default); 7518 %} 7519 7520 instruct compareAndSwapP_regP_regP_regP(iRegIdst res, iRegPdst mem_ptr, iRegPsrc src1, iRegPsrc src2) %{ 7521 match(Set res (CompareAndSwapP mem_ptr (Binary src1 src2))); 7522 format %{ "CMPXCHGD $res, $mem_ptr, $src1, $src2; as bool; ptr" %} 7523 // Variable size: instruction count smaller if regs are disjoint. 7524 ins_encode %{ 7525 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 7526 // CmpxchgX sets CCR0 to cmpX(src1, src2) and Rres to 'true'/'false'. 7527 __ cmpxchgd(CCR0, R0, $src1$$Register, $src2$$Register, $mem_ptr$$Register, 7528 MacroAssembler::MemBarFenceAfter, MacroAssembler::cmpxchgx_hint_atomic_update(), 7529 $res$$Register, NULL, true); 7530 %} 7531 ins_pipe(pipe_class_default); 7532 %} 7533 7534 instruct getAndAddI(iRegIdst res, iRegPdst mem_ptr, iRegIsrc src) %{ 7535 match(Set res (GetAndAddI mem_ptr src)); 7536 format %{ "GetAndAddI $res, $mem_ptr, $src" %} 7537 // Variable size: instruction count smaller if regs are disjoint. 7538 ins_encode( enc_GetAndAddI(res, mem_ptr, src) ); 7539 ins_pipe(pipe_class_default); 7540 %} 7541 7542 instruct getAndAddL(iRegLdst res, iRegPdst mem_ptr, iRegLsrc src) %{ 7543 match(Set res (GetAndAddL mem_ptr src)); 7544 format %{ "GetAndAddL $res, $mem_ptr, $src" %} 7545 // Variable size: instruction count smaller if regs are disjoint. 7546 ins_encode( enc_GetAndAddL(res, mem_ptr, src) ); 7547 ins_pipe(pipe_class_default); 7548 %} 7549 7550 instruct getAndSetI(iRegIdst res, iRegPdst mem_ptr, iRegIsrc src) %{ 7551 match(Set res (GetAndSetI mem_ptr src)); 7552 format %{ "GetAndSetI $res, $mem_ptr, $src" %} 7553 // Variable size: instruction count smaller if regs are disjoint. 7554 ins_encode( enc_GetAndSetI(res, mem_ptr, src) ); 7555 ins_pipe(pipe_class_default); 7556 %} 7557 7558 instruct getAndSetL(iRegLdst res, iRegPdst mem_ptr, iRegLsrc src) %{ 7559 match(Set res (GetAndSetL mem_ptr src)); 7560 format %{ "GetAndSetL $res, $mem_ptr, $src" %} 7561 // Variable size: instruction count smaller if regs are disjoint. 7562 ins_encode( enc_GetAndSetL(res, mem_ptr, src) ); 7563 ins_pipe(pipe_class_default); 7564 %} 7565 7566 instruct getAndSetP(iRegPdst res, iRegPdst mem_ptr, iRegPsrc src) %{ 7567 match(Set res (GetAndSetP mem_ptr src)); 7568 format %{ "GetAndSetP $res, $mem_ptr, $src" %} 7569 // Variable size: instruction count smaller if regs are disjoint. 7570 ins_encode( enc_GetAndSetL(res, mem_ptr, src) ); 7571 ins_pipe(pipe_class_default); 7572 %} 7573 7574 instruct getAndSetN(iRegNdst res, iRegPdst mem_ptr, iRegNsrc src) %{ 7575 match(Set res (GetAndSetN mem_ptr src)); 7576 format %{ "GetAndSetN $res, $mem_ptr, $src" %} 7577 // Variable size: instruction count smaller if regs are disjoint. 7578 ins_encode( enc_GetAndSetI(res, mem_ptr, src) ); 7579 ins_pipe(pipe_class_default); 7580 %} 7581 7582 //----------Arithmetic Instructions-------------------------------------------- 7583 // Addition Instructions 7584 7585 // Register Addition 7586 instruct addI_reg_reg(iRegIdst dst, iRegIsrc_iRegL2Isrc src1, iRegIsrc_iRegL2Isrc src2) %{ 7587 match(Set dst (AddI src1 src2)); 7588 format %{ "ADD $dst, $src1, $src2" %} 7589 size(4); 7590 ins_encode %{ 7591 // TODO: PPC port $archOpcode(ppc64Opcode_add); 7592 __ add($dst$$Register, $src1$$Register, $src2$$Register); 7593 %} 7594 ins_pipe(pipe_class_default); 7595 %} 7596 7597 // Expand does not work with above instruct. (??) 7598 instruct addI_reg_reg_2(iRegIdst dst, iRegIsrc src1, iRegIsrc src2) %{ 7599 // no match-rule 7600 effect(DEF dst, USE src1, USE src2); 7601 format %{ "ADD $dst, $src1, $src2" %} 7602 size(4); 7603 ins_encode %{ 7604 // TODO: PPC port $archOpcode(ppc64Opcode_add); 7605 __ add($dst$$Register, $src1$$Register, $src2$$Register); 7606 %} 7607 ins_pipe(pipe_class_default); 7608 %} 7609 7610 instruct tree_addI_addI_addI_reg_reg_Ex(iRegIdst dst, iRegIsrc src1, iRegIsrc src2, iRegIsrc src3, iRegIsrc src4) %{ 7611 match(Set dst (AddI (AddI (AddI src1 src2) src3) src4)); 7612 ins_cost(DEFAULT_COST*3); 7613 7614 expand %{ 7615 // FIXME: we should do this in the ideal world. 7616 iRegIdst tmp1; 7617 iRegIdst tmp2; 7618 addI_reg_reg(tmp1, src1, src2); 7619 addI_reg_reg_2(tmp2, src3, src4); // Adlc complains about addI_reg_reg. 7620 addI_reg_reg(dst, tmp1, tmp2); 7621 %} 7622 %} 7623 7624 // Immediate Addition 7625 instruct addI_reg_imm16(iRegIdst dst, iRegIsrc src1, immI16 src2) %{ 7626 match(Set dst (AddI src1 src2)); 7627 format %{ "ADDI $dst, $src1, $src2" %} 7628 size(4); 7629 ins_encode %{ 7630 // TODO: PPC port $archOpcode(ppc64Opcode_addi); 7631 __ addi($dst$$Register, $src1$$Register, $src2$$constant); 7632 %} 7633 ins_pipe(pipe_class_default); 7634 %} 7635 7636 // Immediate Addition with 16-bit shifted operand 7637 instruct addI_reg_immhi16(iRegIdst dst, iRegIsrc src1, immIhi16 src2) %{ 7638 match(Set dst (AddI src1 src2)); 7639 format %{ "ADDIS $dst, $src1, $src2" %} 7640 size(4); 7641 ins_encode %{ 7642 // TODO: PPC port $archOpcode(ppc64Opcode_addis); 7643 __ addis($dst$$Register, $src1$$Register, ($src2$$constant)>>16); 7644 %} 7645 ins_pipe(pipe_class_default); 7646 %} 7647 7648 // Long Addition 7649 instruct addL_reg_reg(iRegLdst dst, iRegLsrc src1, iRegLsrc src2) %{ 7650 match(Set dst (AddL src1 src2)); 7651 format %{ "ADD $dst, $src1, $src2 \t// long" %} 7652 size(4); 7653 ins_encode %{ 7654 // TODO: PPC port $archOpcode(ppc64Opcode_add); 7655 __ add($dst$$Register, $src1$$Register, $src2$$Register); 7656 %} 7657 ins_pipe(pipe_class_default); 7658 %} 7659 7660 // Expand does not work with above instruct. (??) 7661 instruct addL_reg_reg_2(iRegLdst dst, iRegLsrc src1, iRegLsrc src2) %{ 7662 // no match-rule 7663 effect(DEF dst, USE src1, USE src2); 7664 format %{ "ADD $dst, $src1, $src2 \t// long" %} 7665 size(4); 7666 ins_encode %{ 7667 // TODO: PPC port $archOpcode(ppc64Opcode_add); 7668 __ add($dst$$Register, $src1$$Register, $src2$$Register); 7669 %} 7670 ins_pipe(pipe_class_default); 7671 %} 7672 7673 instruct tree_addL_addL_addL_reg_reg_Ex(iRegLdst dst, iRegLsrc src1, iRegLsrc src2, iRegLsrc src3, iRegLsrc src4) %{ 7674 match(Set dst (AddL (AddL (AddL src1 src2) src3) src4)); 7675 ins_cost(DEFAULT_COST*3); 7676 7677 expand %{ 7678 // FIXME: we should do this in the ideal world. 7679 iRegLdst tmp1; 7680 iRegLdst tmp2; 7681 addL_reg_reg(tmp1, src1, src2); 7682 addL_reg_reg_2(tmp2, src3, src4); // Adlc complains about orI_reg_reg. 7683 addL_reg_reg(dst, tmp1, tmp2); 7684 %} 7685 %} 7686 7687 // AddL + ConvL2I. 7688 instruct addI_regL_regL(iRegIdst dst, iRegLsrc src1, iRegLsrc src2) %{ 7689 match(Set dst (ConvL2I (AddL src1 src2))); 7690 7691 format %{ "ADD $dst, $src1, $src2 \t// long + l2i" %} 7692 size(4); 7693 ins_encode %{ 7694 // TODO: PPC port $archOpcode(ppc64Opcode_add); 7695 __ add($dst$$Register, $src1$$Register, $src2$$Register); 7696 %} 7697 ins_pipe(pipe_class_default); 7698 %} 7699 7700 // No constant pool entries required. 7701 instruct addL_reg_imm16(iRegLdst dst, iRegLsrc src1, immL16 src2) %{ 7702 match(Set dst (AddL src1 src2)); 7703 7704 format %{ "ADDI $dst, $src1, $src2" %} 7705 size(4); 7706 ins_encode %{ 7707 // TODO: PPC port $archOpcode(ppc64Opcode_addi); 7708 __ addi($dst$$Register, $src1$$Register, $src2$$constant); 7709 %} 7710 ins_pipe(pipe_class_default); 7711 %} 7712 7713 // Long Immediate Addition with 16-bit shifted operand. 7714 // No constant pool entries required. 7715 instruct addL_reg_immhi16(iRegLdst dst, iRegLsrc src1, immL32hi16 src2) %{ 7716 match(Set dst (AddL src1 src2)); 7717 7718 format %{ "ADDIS $dst, $src1, $src2" %} 7719 size(4); 7720 ins_encode %{ 7721 // TODO: PPC port $archOpcode(ppc64Opcode_addis); 7722 __ addis($dst$$Register, $src1$$Register, ($src2$$constant)>>16); 7723 %} 7724 ins_pipe(pipe_class_default); 7725 %} 7726 7727 // Pointer Register Addition 7728 instruct addP_reg_reg(iRegPdst dst, iRegP_N2P src1, iRegLsrc src2) %{ 7729 match(Set dst (AddP src1 src2)); 7730 format %{ "ADD $dst, $src1, $src2" %} 7731 size(4); 7732 ins_encode %{ 7733 // TODO: PPC port $archOpcode(ppc64Opcode_add); 7734 __ add($dst$$Register, $src1$$Register, $src2$$Register); 7735 %} 7736 ins_pipe(pipe_class_default); 7737 %} 7738 7739 // Pointer Immediate Addition 7740 // No constant pool entries required. 7741 instruct addP_reg_imm16(iRegPdst dst, iRegP_N2P src1, immL16 src2) %{ 7742 match(Set dst (AddP src1 src2)); 7743 7744 format %{ "ADDI $dst, $src1, $src2" %} 7745 size(4); 7746 ins_encode %{ 7747 // TODO: PPC port $archOpcode(ppc64Opcode_addi); 7748 __ addi($dst$$Register, $src1$$Register, $src2$$constant); 7749 %} 7750 ins_pipe(pipe_class_default); 7751 %} 7752 7753 // Pointer Immediate Addition with 16-bit shifted operand. 7754 // No constant pool entries required. 7755 instruct addP_reg_immhi16(iRegPdst dst, iRegP_N2P src1, immL32hi16 src2) %{ 7756 match(Set dst (AddP src1 src2)); 7757 7758 format %{ "ADDIS $dst, $src1, $src2" %} 7759 size(4); 7760 ins_encode %{ 7761 // TODO: PPC port $archOpcode(ppc64Opcode_addis); 7762 __ addis($dst$$Register, $src1$$Register, ($src2$$constant)>>16); 7763 %} 7764 ins_pipe(pipe_class_default); 7765 %} 7766 7767 //--------------------- 7768 // Subtraction Instructions 7769 7770 // Register Subtraction 7771 instruct subI_reg_reg(iRegIdst dst, iRegIsrc src1, iRegIsrc src2) %{ 7772 match(Set dst (SubI src1 src2)); 7773 format %{ "SUBF $dst, $src2, $src1" %} 7774 size(4); 7775 ins_encode %{ 7776 // TODO: PPC port $archOpcode(ppc64Opcode_subf); 7777 __ subf($dst$$Register, $src2$$Register, $src1$$Register); 7778 %} 7779 ins_pipe(pipe_class_default); 7780 %} 7781 7782 // Immediate Subtraction 7783 // The compiler converts "x-c0" into "x+ -c0" (see SubINode::Ideal), 7784 // so this rule seems to be unused. 7785 instruct subI_reg_imm16(iRegIdst dst, iRegIsrc src1, immI16 src2) %{ 7786 match(Set dst (SubI src1 src2)); 7787 format %{ "SUBI $dst, $src1, $src2" %} 7788 size(4); 7789 ins_encode %{ 7790 // TODO: PPC port $archOpcode(ppc64Opcode_addi); 7791 __ addi($dst$$Register, $src1$$Register, ($src2$$constant) * (-1)); 7792 %} 7793 ins_pipe(pipe_class_default); 7794 %} 7795 7796 // SubI from constant (using subfic). 7797 instruct subI_imm16_reg(iRegIdst dst, immI16 src1, iRegIsrc src2) %{ 7798 match(Set dst (SubI src1 src2)); 7799 format %{ "SUBI $dst, $src1, $src2" %} 7800 7801 size(4); 7802 ins_encode %{ 7803 // TODO: PPC port $archOpcode(ppc64Opcode_subfic); 7804 __ subfic($dst$$Register, $src2$$Register, $src1$$constant); 7805 %} 7806 ins_pipe(pipe_class_default); 7807 %} 7808 7809 // Turn the sign-bit of an integer into a 32-bit mask, 0x0...0 for 7810 // positive integers and 0xF...F for negative ones. 7811 instruct signmask32I_regI(iRegIdst dst, iRegIsrc src) %{ 7812 // no match-rule, false predicate 7813 effect(DEF dst, USE src); 7814 predicate(false); 7815 7816 format %{ "SRAWI $dst, $src, #31" %} 7817 size(4); 7818 ins_encode %{ 7819 // TODO: PPC port $archOpcode(ppc64Opcode_srawi); 7820 __ srawi($dst$$Register, $src$$Register, 0x1f); 7821 %} 7822 ins_pipe(pipe_class_default); 7823 %} 7824 7825 instruct absI_reg_Ex(iRegIdst dst, iRegIsrc src) %{ 7826 match(Set dst (AbsI src)); 7827 ins_cost(DEFAULT_COST*3); 7828 7829 expand %{ 7830 iRegIdst tmp1; 7831 iRegIdst tmp2; 7832 signmask32I_regI(tmp1, src); 7833 xorI_reg_reg(tmp2, tmp1, src); 7834 subI_reg_reg(dst, tmp2, tmp1); 7835 %} 7836 %} 7837 7838 instruct negI_regI(iRegIdst dst, immI_0 zero, iRegIsrc src2) %{ 7839 match(Set dst (SubI zero src2)); 7840 format %{ "NEG $dst, $src2" %} 7841 size(4); 7842 ins_encode %{ 7843 // TODO: PPC port $archOpcode(ppc64Opcode_neg); 7844 __ neg($dst$$Register, $src2$$Register); 7845 %} 7846 ins_pipe(pipe_class_default); 7847 %} 7848 7849 // Long subtraction 7850 instruct subL_reg_reg(iRegLdst dst, iRegLsrc src1, iRegLsrc src2) %{ 7851 match(Set dst (SubL src1 src2)); 7852 format %{ "SUBF $dst, $src2, $src1 \t// long" %} 7853 size(4); 7854 ins_encode %{ 7855 // TODO: PPC port $archOpcode(ppc64Opcode_subf); 7856 __ subf($dst$$Register, $src2$$Register, $src1$$Register); 7857 %} 7858 ins_pipe(pipe_class_default); 7859 %} 7860 7861 // SubL + convL2I. 7862 instruct subI_regL_regL(iRegIdst dst, iRegLsrc src1, iRegLsrc src2) %{ 7863 match(Set dst (ConvL2I (SubL src1 src2))); 7864 7865 format %{ "SUBF $dst, $src2, $src1 \t// long + l2i" %} 7866 size(4); 7867 ins_encode %{ 7868 // TODO: PPC port $archOpcode(ppc64Opcode_subf); 7869 __ subf($dst$$Register, $src2$$Register, $src1$$Register); 7870 %} 7871 ins_pipe(pipe_class_default); 7872 %} 7873 7874 // Immediate Subtraction 7875 // The compiler converts "x-c0" into "x+ -c0" (see SubLNode::Ideal), 7876 // so this rule seems to be unused. 7877 // No constant pool entries required. 7878 instruct subL_reg_imm16(iRegLdst dst, iRegLsrc src1, immL16 src2) %{ 7879 match(Set dst (SubL src1 src2)); 7880 7881 format %{ "SUBI $dst, $src1, $src2 \t// long" %} 7882 size(4); 7883 ins_encode %{ 7884 // TODO: PPC port $archOpcode(ppc64Opcode_addi); 7885 __ addi($dst$$Register, $src1$$Register, ($src2$$constant) * (-1)); 7886 %} 7887 ins_pipe(pipe_class_default); 7888 %} 7889 7890 // Turn the sign-bit of a long into a 64-bit mask, 0x0...0 for 7891 // positive longs and 0xF...F for negative ones. 7892 instruct signmask64I_regI(iRegIdst dst, iRegIsrc src) %{ 7893 // no match-rule, false predicate 7894 effect(DEF dst, USE src); 7895 predicate(false); 7896 7897 format %{ "SRADI $dst, $src, #63" %} 7898 size(4); 7899 ins_encode %{ 7900 // TODO: PPC port $archOpcode(ppc64Opcode_sradi); 7901 __ sradi($dst$$Register, $src$$Register, 0x3f); 7902 %} 7903 ins_pipe(pipe_class_default); 7904 %} 7905 7906 // Long negation 7907 instruct negL_reg_reg(iRegLdst dst, immL_0 zero, iRegLsrc src2) %{ 7908 match(Set dst (SubL zero src2)); 7909 format %{ "NEG $dst, $src2 \t// long" %} 7910 size(4); 7911 ins_encode %{ 7912 // TODO: PPC port $archOpcode(ppc64Opcode_neg); 7913 __ neg($dst$$Register, $src2$$Register); 7914 %} 7915 ins_pipe(pipe_class_default); 7916 %} 7917 7918 // NegL + ConvL2I. 7919 instruct negI_con0_regL(iRegIdst dst, immL_0 zero, iRegLsrc src2) %{ 7920 match(Set dst (ConvL2I (SubL zero src2))); 7921 7922 format %{ "NEG $dst, $src2 \t// long + l2i" %} 7923 size(4); 7924 ins_encode %{ 7925 // TODO: PPC port $archOpcode(ppc64Opcode_neg); 7926 __ neg($dst$$Register, $src2$$Register); 7927 %} 7928 ins_pipe(pipe_class_default); 7929 %} 7930 7931 // Multiplication Instructions 7932 // Integer Multiplication 7933 7934 // Register Multiplication 7935 instruct mulI_reg_reg(iRegIdst dst, iRegIsrc src1, iRegIsrc src2) %{ 7936 match(Set dst (MulI src1 src2)); 7937 ins_cost(DEFAULT_COST); 7938 7939 format %{ "MULLW $dst, $src1, $src2" %} 7940 size(4); 7941 ins_encode %{ 7942 // TODO: PPC port $archOpcode(ppc64Opcode_mullw); 7943 __ mullw($dst$$Register, $src1$$Register, $src2$$Register); 7944 %} 7945 ins_pipe(pipe_class_default); 7946 %} 7947 7948 // Immediate Multiplication 7949 instruct mulI_reg_imm16(iRegIdst dst, iRegIsrc src1, immI16 src2) %{ 7950 match(Set dst (MulI src1 src2)); 7951 ins_cost(DEFAULT_COST); 7952 7953 format %{ "MULLI $dst, $src1, $src2" %} 7954 size(4); 7955 ins_encode %{ 7956 // TODO: PPC port $archOpcode(ppc64Opcode_mulli); 7957 __ mulli($dst$$Register, $src1$$Register, $src2$$constant); 7958 %} 7959 ins_pipe(pipe_class_default); 7960 %} 7961 7962 instruct mulL_reg_reg(iRegLdst dst, iRegLsrc src1, iRegLsrc src2) %{ 7963 match(Set dst (MulL src1 src2)); 7964 ins_cost(DEFAULT_COST); 7965 7966 format %{ "MULLD $dst $src1, $src2 \t// long" %} 7967 size(4); 7968 ins_encode %{ 7969 // TODO: PPC port $archOpcode(ppc64Opcode_mulld); 7970 __ mulld($dst$$Register, $src1$$Register, $src2$$Register); 7971 %} 7972 ins_pipe(pipe_class_default); 7973 %} 7974 7975 // Multiply high for optimized long division by constant. 7976 instruct mulHighL_reg_reg(iRegLdst dst, iRegLsrc src1, iRegLsrc src2) %{ 7977 match(Set dst (MulHiL src1 src2)); 7978 ins_cost(DEFAULT_COST); 7979 7980 format %{ "MULHD $dst $src1, $src2 \t// long" %} 7981 size(4); 7982 ins_encode %{ 7983 // TODO: PPC port $archOpcode(ppc64Opcode_mulhd); 7984 __ mulhd($dst$$Register, $src1$$Register, $src2$$Register); 7985 %} 7986 ins_pipe(pipe_class_default); 7987 %} 7988 7989 // Immediate Multiplication 7990 instruct mulL_reg_imm16(iRegLdst dst, iRegLsrc src1, immL16 src2) %{ 7991 match(Set dst (MulL src1 src2)); 7992 ins_cost(DEFAULT_COST); 7993 7994 format %{ "MULLI $dst, $src1, $src2" %} 7995 size(4); 7996 ins_encode %{ 7997 // TODO: PPC port $archOpcode(ppc64Opcode_mulli); 7998 __ mulli($dst$$Register, $src1$$Register, $src2$$constant); 7999 %} 8000 ins_pipe(pipe_class_default); 8001 %} 8002 8003 // Integer Division with Immediate -1: Negate. 8004 instruct divI_reg_immIvalueMinus1(iRegIdst dst, iRegIsrc src1, immI_minus1 src2) %{ 8005 match(Set dst (DivI src1 src2)); 8006 ins_cost(DEFAULT_COST); 8007 8008 format %{ "NEG $dst, $src1 \t// /-1" %} 8009 size(4); 8010 ins_encode %{ 8011 // TODO: PPC port $archOpcode(ppc64Opcode_neg); 8012 __ neg($dst$$Register, $src1$$Register); 8013 %} 8014 ins_pipe(pipe_class_default); 8015 %} 8016 8017 // Integer Division with constant, but not -1. 8018 // We should be able to improve this by checking the type of src2. 8019 // It might well be that src2 is known to be positive. 8020 instruct divI_reg_regnotMinus1(iRegIdst dst, iRegIsrc src1, iRegIsrc src2) %{ 8021 match(Set dst (DivI src1 src2)); 8022 predicate(n->in(2)->find_int_con(-1) != -1); // src2 is a constant, but not -1 8023 ins_cost(2*DEFAULT_COST); 8024 8025 format %{ "DIVW $dst, $src1, $src2 \t// /not-1" %} 8026 size(4); 8027 ins_encode %{ 8028 // TODO: PPC port $archOpcode(ppc64Opcode_divw); 8029 __ divw($dst$$Register, $src1$$Register, $src2$$Register); 8030 %} 8031 ins_pipe(pipe_class_default); 8032 %} 8033 8034 instruct cmovI_bne_negI_reg(iRegIdst dst, flagsReg crx, iRegIsrc src1) %{ 8035 effect(USE_DEF dst, USE src1, USE crx); 8036 predicate(false); 8037 8038 ins_variable_size_depending_on_alignment(true); 8039 8040 format %{ "CMOVE $dst, neg($src1), $crx" %} 8041 // Worst case is branch + move + stop, no stop without scheduler. 8042 size(false /* TODO: PPC PORT (InsertEndGroupPPC64 && Compile::current()->do_hb_scheduling())*/ ? 12 : 8); 8043 ins_encode %{ 8044 // TODO: PPC port $archOpcode(ppc64Opcode_cmove); 8045 Label done; 8046 __ bne($crx$$CondRegister, done); 8047 __ neg($dst$$Register, $src1$$Register); 8048 // TODO PPC port __ endgroup_if_needed(_size == 12); 8049 __ bind(done); 8050 %} 8051 ins_pipe(pipe_class_default); 8052 %} 8053 8054 // Integer Division with Registers not containing constants. 8055 instruct divI_reg_reg_Ex(iRegIdst dst, iRegIsrc src1, iRegIsrc src2) %{ 8056 match(Set dst (DivI src1 src2)); 8057 ins_cost(10*DEFAULT_COST); 8058 8059 expand %{ 8060 immI16 imm %{ (int)-1 %} 8061 flagsReg tmp1; 8062 cmpI_reg_imm16(tmp1, src2, imm); // check src2 == -1 8063 divI_reg_regnotMinus1(dst, src1, src2); // dst = src1 / src2 8064 cmovI_bne_negI_reg(dst, tmp1, src1); // cmove dst = neg(src1) if src2 == -1 8065 %} 8066 %} 8067 8068 // Long Division with Immediate -1: Negate. 8069 instruct divL_reg_immLvalueMinus1(iRegLdst dst, iRegLsrc src1, immL_minus1 src2) %{ 8070 match(Set dst (DivL src1 src2)); 8071 ins_cost(DEFAULT_COST); 8072 8073 format %{ "NEG $dst, $src1 \t// /-1, long" %} 8074 size(4); 8075 ins_encode %{ 8076 // TODO: PPC port $archOpcode(ppc64Opcode_neg); 8077 __ neg($dst$$Register, $src1$$Register); 8078 %} 8079 ins_pipe(pipe_class_default); 8080 %} 8081 8082 // Long Division with constant, but not -1. 8083 instruct divL_reg_regnotMinus1(iRegLdst dst, iRegLsrc src1, iRegLsrc src2) %{ 8084 match(Set dst (DivL src1 src2)); 8085 predicate(n->in(2)->find_long_con(-1L) != -1L); // Src2 is a constant, but not -1. 8086 ins_cost(2*DEFAULT_COST); 8087 8088 format %{ "DIVD $dst, $src1, $src2 \t// /not-1, long" %} 8089 size(4); 8090 ins_encode %{ 8091 // TODO: PPC port $archOpcode(ppc64Opcode_divd); 8092 __ divd($dst$$Register, $src1$$Register, $src2$$Register); 8093 %} 8094 ins_pipe(pipe_class_default); 8095 %} 8096 8097 instruct cmovL_bne_negL_reg(iRegLdst dst, flagsReg crx, iRegLsrc src1) %{ 8098 effect(USE_DEF dst, USE src1, USE crx); 8099 predicate(false); 8100 8101 ins_variable_size_depending_on_alignment(true); 8102 8103 format %{ "CMOVE $dst, neg($src1), $crx" %} 8104 // Worst case is branch + move + stop, no stop without scheduler. 8105 size(false /* TODO: PPC PORT (InsertEndGroupPPC64 && Compile::current()->do_hb_scheduling())*/ ? 12 : 8); 8106 ins_encode %{ 8107 // TODO: PPC port $archOpcode(ppc64Opcode_cmove); 8108 Label done; 8109 __ bne($crx$$CondRegister, done); 8110 __ neg($dst$$Register, $src1$$Register); 8111 // TODO PPC port __ endgroup_if_needed(_size == 12); 8112 __ bind(done); 8113 %} 8114 ins_pipe(pipe_class_default); 8115 %} 8116 8117 // Long Division with Registers not containing constants. 8118 instruct divL_reg_reg_Ex(iRegLdst dst, iRegLsrc src1, iRegLsrc src2) %{ 8119 match(Set dst (DivL src1 src2)); 8120 ins_cost(10*DEFAULT_COST); 8121 8122 expand %{ 8123 immL16 imm %{ (int)-1 %} 8124 flagsReg tmp1; 8125 cmpL_reg_imm16(tmp1, src2, imm); // check src2 == -1 8126 divL_reg_regnotMinus1(dst, src1, src2); // dst = src1 / src2 8127 cmovL_bne_negL_reg(dst, tmp1, src1); // cmove dst = neg(src1) if src2 == -1 8128 %} 8129 %} 8130 8131 // Integer Remainder with registers. 8132 instruct modI_reg_reg_Ex(iRegIdst dst, iRegIsrc src1, iRegIsrc src2) %{ 8133 match(Set dst (ModI src1 src2)); 8134 ins_cost(10*DEFAULT_COST); 8135 8136 expand %{ 8137 immI16 imm %{ (int)-1 %} 8138 flagsReg tmp1; 8139 iRegIdst tmp2; 8140 iRegIdst tmp3; 8141 cmpI_reg_imm16(tmp1, src2, imm); // check src2 == -1 8142 divI_reg_regnotMinus1(tmp2, src1, src2); // tmp2 = src1 / src2 8143 cmovI_bne_negI_reg(tmp2, tmp1, src1); // cmove tmp2 = neg(src1) if src2 == -1 8144 mulI_reg_reg(tmp3, src2, tmp2); // tmp3 = src2 * tmp2 8145 subI_reg_reg(dst, src1, tmp3); // dst = src1 - tmp3 8146 %} 8147 %} 8148 8149 // Long Remainder with registers 8150 instruct modL_reg_reg_Ex(iRegLdst dst, iRegLsrc src1, iRegLsrc src2, flagsRegCR0 cr0) %{ 8151 match(Set dst (ModL src1 src2)); 8152 ins_cost(10*DEFAULT_COST); 8153 8154 expand %{ 8155 immL16 imm %{ (int)-1 %} 8156 flagsReg tmp1; 8157 iRegLdst tmp2; 8158 iRegLdst tmp3; 8159 cmpL_reg_imm16(tmp1, src2, imm); // check src2 == -1 8160 divL_reg_regnotMinus1(tmp2, src1, src2); // tmp2 = src1 / src2 8161 cmovL_bne_negL_reg(tmp2, tmp1, src1); // cmove tmp2 = neg(src1) if src2 == -1 8162 mulL_reg_reg(tmp3, src2, tmp2); // tmp3 = src2 * tmp2 8163 subL_reg_reg(dst, src1, tmp3); // dst = src1 - tmp3 8164 %} 8165 %} 8166 8167 // Integer Shift Instructions 8168 8169 // Register Shift Left 8170 8171 // Clear all but the lowest #mask bits. 8172 // Used to normalize shift amounts in registers. 8173 instruct maskI_reg_imm(iRegIdst dst, iRegIsrc src, uimmI6 mask) %{ 8174 // no match-rule, false predicate 8175 effect(DEF dst, USE src, USE mask); 8176 predicate(false); 8177 8178 format %{ "MASK $dst, $src, $mask \t// clear $mask upper bits" %} 8179 size(4); 8180 ins_encode %{ 8181 // TODO: PPC port $archOpcode(ppc64Opcode_rldicl); 8182 __ clrldi($dst$$Register, $src$$Register, $mask$$constant); 8183 %} 8184 ins_pipe(pipe_class_default); 8185 %} 8186 8187 instruct lShiftI_reg_reg(iRegIdst dst, iRegIsrc src1, iRegIsrc src2) %{ 8188 // no match-rule, false predicate 8189 effect(DEF dst, USE src1, USE src2); 8190 predicate(false); 8191 8192 format %{ "SLW $dst, $src1, $src2" %} 8193 size(4); 8194 ins_encode %{ 8195 // TODO: PPC port $archOpcode(ppc64Opcode_slw); 8196 __ slw($dst$$Register, $src1$$Register, $src2$$Register); 8197 %} 8198 ins_pipe(pipe_class_default); 8199 %} 8200 8201 instruct lShiftI_reg_reg_Ex(iRegIdst dst, iRegIsrc src1, iRegIsrc src2) %{ 8202 match(Set dst (LShiftI src1 src2)); 8203 ins_cost(DEFAULT_COST*2); 8204 expand %{ 8205 uimmI6 mask %{ 0x3b /* clear 59 bits, keep 5 */ %} 8206 iRegIdst tmpI; 8207 maskI_reg_imm(tmpI, src2, mask); 8208 lShiftI_reg_reg(dst, src1, tmpI); 8209 %} 8210 %} 8211 8212 // Register Shift Left Immediate 8213 instruct lShiftI_reg_imm(iRegIdst dst, iRegIsrc src1, immI src2) %{ 8214 match(Set dst (LShiftI src1 src2)); 8215 8216 format %{ "SLWI $dst, $src1, ($src2 & 0x1f)" %} 8217 size(4); 8218 ins_encode %{ 8219 // TODO: PPC port $archOpcode(ppc64Opcode_rlwinm); 8220 __ slwi($dst$$Register, $src1$$Register, ($src2$$constant) & 0x1f); 8221 %} 8222 ins_pipe(pipe_class_default); 8223 %} 8224 8225 // AndI with negpow2-constant + LShiftI 8226 instruct lShiftI_andI_immInegpow2_imm5(iRegIdst dst, iRegIsrc src1, immInegpow2 src2, uimmI5 src3) %{ 8227 match(Set dst (LShiftI (AndI src1 src2) src3)); 8228 predicate(UseRotateAndMaskInstructionsPPC64); 8229 8230 format %{ "RLWINM $dst, lShiftI(AndI($src1, $src2), $src3)" %} 8231 size(4); 8232 ins_encode %{ 8233 // TODO: PPC port $archOpcode(ppc64Opcode_rlwinm); // FIXME: assert that rlwinm is equal to addi 8234 long src2 = $src2$$constant; 8235 long src3 = $src3$$constant; 8236 long maskbits = src3 + log2_long((jlong) (julong) (juint) -src2); 8237 if (maskbits >= 32) { 8238 __ li($dst$$Register, 0); // addi 8239 } else { 8240 __ rlwinm($dst$$Register, $src1$$Register, src3 & 0x1f, 0, (31-maskbits) & 0x1f); 8241 } 8242 %} 8243 ins_pipe(pipe_class_default); 8244 %} 8245 8246 // RShiftI + AndI with negpow2-constant + LShiftI 8247 instruct lShiftI_andI_immInegpow2_rShiftI_imm5(iRegIdst dst, iRegIsrc src1, immInegpow2 src2, uimmI5 src3) %{ 8248 match(Set dst (LShiftI (AndI (RShiftI src1 src3) src2) src3)); 8249 predicate(UseRotateAndMaskInstructionsPPC64); 8250 8251 format %{ "RLWINM $dst, lShiftI(AndI(RShiftI($src1, $src3), $src2), $src3)" %} 8252 size(4); 8253 ins_encode %{ 8254 // TODO: PPC port $archOpcode(ppc64Opcode_rlwinm); // FIXME: assert that rlwinm is equal to addi 8255 long src2 = $src2$$constant; 8256 long src3 = $src3$$constant; 8257 long maskbits = src3 + log2_long((jlong) (julong) (juint) -src2); 8258 if (maskbits >= 32) { 8259 __ li($dst$$Register, 0); // addi 8260 } else { 8261 __ rlwinm($dst$$Register, $src1$$Register, 0, 0, (31-maskbits) & 0x1f); 8262 } 8263 %} 8264 ins_pipe(pipe_class_default); 8265 %} 8266 8267 instruct lShiftL_regL_regI(iRegLdst dst, iRegLsrc src1, iRegIsrc src2) %{ 8268 // no match-rule, false predicate 8269 effect(DEF dst, USE src1, USE src2); 8270 predicate(false); 8271 8272 format %{ "SLD $dst, $src1, $src2" %} 8273 size(4); 8274 ins_encode %{ 8275 // TODO: PPC port $archOpcode(ppc64Opcode_sld); 8276 __ sld($dst$$Register, $src1$$Register, $src2$$Register); 8277 %} 8278 ins_pipe(pipe_class_default); 8279 %} 8280 8281 // Register Shift Left 8282 instruct lShiftL_regL_regI_Ex(iRegLdst dst, iRegLsrc src1, iRegIsrc src2) %{ 8283 match(Set dst (LShiftL src1 src2)); 8284 ins_cost(DEFAULT_COST*2); 8285 expand %{ 8286 uimmI6 mask %{ 0x3a /* clear 58 bits, keep 6 */ %} 8287 iRegIdst tmpI; 8288 maskI_reg_imm(tmpI, src2, mask); 8289 lShiftL_regL_regI(dst, src1, tmpI); 8290 %} 8291 %} 8292 8293 // Register Shift Left Immediate 8294 instruct lshiftL_regL_immI(iRegLdst dst, iRegLsrc src1, immI src2) %{ 8295 match(Set dst (LShiftL src1 src2)); 8296 format %{ "SLDI $dst, $src1, ($src2 & 0x3f)" %} 8297 size(4); 8298 ins_encode %{ 8299 // TODO: PPC port $archOpcode(ppc64Opcode_rldicr); 8300 __ sldi($dst$$Register, $src1$$Register, ($src2$$constant) & 0x3f); 8301 %} 8302 ins_pipe(pipe_class_default); 8303 %} 8304 8305 // If we shift more than 32 bits, we need not convert I2L. 8306 instruct lShiftL_regI_immGE32(iRegLdst dst, iRegIsrc src1, uimmI6_ge32 src2) %{ 8307 match(Set dst (LShiftL (ConvI2L src1) src2)); 8308 ins_cost(DEFAULT_COST); 8309 8310 size(4); 8311 format %{ "SLDI $dst, i2l($src1), $src2" %} 8312 ins_encode %{ 8313 // TODO: PPC port $archOpcode(ppc64Opcode_rldicr); 8314 __ sldi($dst$$Register, $src1$$Register, ($src2$$constant) & 0x3f); 8315 %} 8316 ins_pipe(pipe_class_default); 8317 %} 8318 8319 // Shift a postivie int to the left. 8320 // Clrlsldi clears the upper 32 bits and shifts. 8321 instruct scaledPositiveI2L_lShiftL_convI2L_reg_imm6(iRegLdst dst, iRegIsrc src1, uimmI6 src2) %{ 8322 match(Set dst (LShiftL (ConvI2L src1) src2)); 8323 predicate(((ConvI2LNode*)(_kids[0]->_leaf))->type()->is_long()->is_positive_int()); 8324 8325 format %{ "SLDI $dst, i2l(positive_int($src1)), $src2" %} 8326 size(4); 8327 ins_encode %{ 8328 // TODO: PPC port $archOpcode(ppc64Opcode_rldic); 8329 __ clrlsldi($dst$$Register, $src1$$Register, 0x20, $src2$$constant); 8330 %} 8331 ins_pipe(pipe_class_default); 8332 %} 8333 8334 instruct arShiftI_reg_reg(iRegIdst dst, iRegIsrc src1, iRegIsrc src2) %{ 8335 // no match-rule, false predicate 8336 effect(DEF dst, USE src1, USE src2); 8337 predicate(false); 8338 8339 format %{ "SRAW $dst, $src1, $src2" %} 8340 size(4); 8341 ins_encode %{ 8342 // TODO: PPC port $archOpcode(ppc64Opcode_sraw); 8343 __ sraw($dst$$Register, $src1$$Register, $src2$$Register); 8344 %} 8345 ins_pipe(pipe_class_default); 8346 %} 8347 8348 // Register Arithmetic Shift Right 8349 instruct arShiftI_reg_reg_Ex(iRegIdst dst, iRegIsrc src1, iRegIsrc src2) %{ 8350 match(Set dst (RShiftI src1 src2)); 8351 ins_cost(DEFAULT_COST*2); 8352 expand %{ 8353 uimmI6 mask %{ 0x3b /* clear 59 bits, keep 5 */ %} 8354 iRegIdst tmpI; 8355 maskI_reg_imm(tmpI, src2, mask); 8356 arShiftI_reg_reg(dst, src1, tmpI); 8357 %} 8358 %} 8359 8360 // Register Arithmetic Shift Right Immediate 8361 instruct arShiftI_reg_imm(iRegIdst dst, iRegIsrc src1, immI src2) %{ 8362 match(Set dst (RShiftI src1 src2)); 8363 8364 format %{ "SRAWI $dst, $src1, ($src2 & 0x1f)" %} 8365 size(4); 8366 ins_encode %{ 8367 // TODO: PPC port $archOpcode(ppc64Opcode_srawi); 8368 __ srawi($dst$$Register, $src1$$Register, ($src2$$constant) & 0x1f); 8369 %} 8370 ins_pipe(pipe_class_default); 8371 %} 8372 8373 instruct arShiftL_regL_regI(iRegLdst dst, iRegLsrc src1, iRegIsrc src2) %{ 8374 // no match-rule, false predicate 8375 effect(DEF dst, USE src1, USE src2); 8376 predicate(false); 8377 8378 format %{ "SRAD $dst, $src1, $src2" %} 8379 size(4); 8380 ins_encode %{ 8381 // TODO: PPC port $archOpcode(ppc64Opcode_srad); 8382 __ srad($dst$$Register, $src1$$Register, $src2$$Register); 8383 %} 8384 ins_pipe(pipe_class_default); 8385 %} 8386 8387 // Register Shift Right Arithmetic Long 8388 instruct arShiftL_regL_regI_Ex(iRegLdst dst, iRegLsrc src1, iRegIsrc src2) %{ 8389 match(Set dst (RShiftL src1 src2)); 8390 ins_cost(DEFAULT_COST*2); 8391 8392 expand %{ 8393 uimmI6 mask %{ 0x3a /* clear 58 bits, keep 6 */ %} 8394 iRegIdst tmpI; 8395 maskI_reg_imm(tmpI, src2, mask); 8396 arShiftL_regL_regI(dst, src1, tmpI); 8397 %} 8398 %} 8399 8400 // Register Shift Right Immediate 8401 instruct arShiftL_regL_immI(iRegLdst dst, iRegLsrc src1, immI src2) %{ 8402 match(Set dst (RShiftL src1 src2)); 8403 8404 format %{ "SRADI $dst, $src1, ($src2 & 0x3f)" %} 8405 size(4); 8406 ins_encode %{ 8407 // TODO: PPC port $archOpcode(ppc64Opcode_sradi); 8408 __ sradi($dst$$Register, $src1$$Register, ($src2$$constant) & 0x3f); 8409 %} 8410 ins_pipe(pipe_class_default); 8411 %} 8412 8413 // RShiftL + ConvL2I 8414 instruct convL2I_arShiftL_regL_immI(iRegIdst dst, iRegLsrc src1, immI src2) %{ 8415 match(Set dst (ConvL2I (RShiftL src1 src2))); 8416 8417 format %{ "SRADI $dst, $src1, ($src2 & 0x3f) \t// long + l2i" %} 8418 size(4); 8419 ins_encode %{ 8420 // TODO: PPC port $archOpcode(ppc64Opcode_sradi); 8421 __ sradi($dst$$Register, $src1$$Register, ($src2$$constant) & 0x3f); 8422 %} 8423 ins_pipe(pipe_class_default); 8424 %} 8425 8426 instruct urShiftI_reg_reg(iRegIdst dst, iRegIsrc src1, iRegIsrc src2) %{ 8427 // no match-rule, false predicate 8428 effect(DEF dst, USE src1, USE src2); 8429 predicate(false); 8430 8431 format %{ "SRW $dst, $src1, $src2" %} 8432 size(4); 8433 ins_encode %{ 8434 // TODO: PPC port $archOpcode(ppc64Opcode_srw); 8435 __ srw($dst$$Register, $src1$$Register, $src2$$Register); 8436 %} 8437 ins_pipe(pipe_class_default); 8438 %} 8439 8440 // Register Shift Right 8441 instruct urShiftI_reg_reg_Ex(iRegIdst dst, iRegIsrc src1, iRegIsrc src2) %{ 8442 match(Set dst (URShiftI src1 src2)); 8443 ins_cost(DEFAULT_COST*2); 8444 8445 expand %{ 8446 uimmI6 mask %{ 0x3b /* clear 59 bits, keep 5 */ %} 8447 iRegIdst tmpI; 8448 maskI_reg_imm(tmpI, src2, mask); 8449 urShiftI_reg_reg(dst, src1, tmpI); 8450 %} 8451 %} 8452 8453 // Register Shift Right Immediate 8454 instruct urShiftI_reg_imm(iRegIdst dst, iRegIsrc src1, immI src2) %{ 8455 match(Set dst (URShiftI src1 src2)); 8456 8457 format %{ "SRWI $dst, $src1, ($src2 & 0x1f)" %} 8458 size(4); 8459 ins_encode %{ 8460 // TODO: PPC port $archOpcode(ppc64Opcode_rlwinm); 8461 __ srwi($dst$$Register, $src1$$Register, ($src2$$constant) & 0x1f); 8462 %} 8463 ins_pipe(pipe_class_default); 8464 %} 8465 8466 instruct urShiftL_regL_regI(iRegLdst dst, iRegLsrc src1, iRegIsrc src2) %{ 8467 // no match-rule, false predicate 8468 effect(DEF dst, USE src1, USE src2); 8469 predicate(false); 8470 8471 format %{ "SRD $dst, $src1, $src2" %} 8472 size(4); 8473 ins_encode %{ 8474 // TODO: PPC port $archOpcode(ppc64Opcode_srd); 8475 __ srd($dst$$Register, $src1$$Register, $src2$$Register); 8476 %} 8477 ins_pipe(pipe_class_default); 8478 %} 8479 8480 // Register Shift Right 8481 instruct urShiftL_regL_regI_Ex(iRegLdst dst, iRegLsrc src1, iRegIsrc src2) %{ 8482 match(Set dst (URShiftL src1 src2)); 8483 ins_cost(DEFAULT_COST*2); 8484 8485 expand %{ 8486 uimmI6 mask %{ 0x3a /* clear 58 bits, keep 6 */ %} 8487 iRegIdst tmpI; 8488 maskI_reg_imm(tmpI, src2, mask); 8489 urShiftL_regL_regI(dst, src1, tmpI); 8490 %} 8491 %} 8492 8493 // Register Shift Right Immediate 8494 instruct urShiftL_regL_immI(iRegLdst dst, iRegLsrc src1, immI src2) %{ 8495 match(Set dst (URShiftL src1 src2)); 8496 8497 format %{ "SRDI $dst, $src1, ($src2 & 0x3f)" %} 8498 size(4); 8499 ins_encode %{ 8500 // TODO: PPC port $archOpcode(ppc64Opcode_rldicl); 8501 __ srdi($dst$$Register, $src1$$Register, ($src2$$constant) & 0x3f); 8502 %} 8503 ins_pipe(pipe_class_default); 8504 %} 8505 8506 // URShiftL + ConvL2I. 8507 instruct convL2I_urShiftL_regL_immI(iRegIdst dst, iRegLsrc src1, immI src2) %{ 8508 match(Set dst (ConvL2I (URShiftL src1 src2))); 8509 8510 format %{ "SRDI $dst, $src1, ($src2 & 0x3f) \t// long + l2i" %} 8511 size(4); 8512 ins_encode %{ 8513 // TODO: PPC port $archOpcode(ppc64Opcode_rldicl); 8514 __ srdi($dst$$Register, $src1$$Register, ($src2$$constant) & 0x3f); 8515 %} 8516 ins_pipe(pipe_class_default); 8517 %} 8518 8519 // Register Shift Right Immediate with a CastP2X 8520 instruct shrP_convP2X_reg_imm6(iRegLdst dst, iRegP_N2P src1, uimmI6 src2) %{ 8521 match(Set dst (URShiftL (CastP2X src1) src2)); 8522 8523 format %{ "SRDI $dst, $src1, $src2 \t// Cast ptr $src1 to long and shift" %} 8524 size(4); 8525 ins_encode %{ 8526 // TODO: PPC port $archOpcode(ppc64Opcode_rldicl); 8527 __ srdi($dst$$Register, $src1$$Register, ($src2$$constant) & 0x3f); 8528 %} 8529 ins_pipe(pipe_class_default); 8530 %} 8531 8532 instruct sxtI_reg(iRegIdst dst, iRegIsrc src) %{ 8533 match(Set dst (ConvL2I (ConvI2L src))); 8534 8535 format %{ "EXTSW $dst, $src \t// int->int" %} 8536 size(4); 8537 ins_encode %{ 8538 // TODO: PPC port $archOpcode(ppc64Opcode_extsw); 8539 __ extsw($dst$$Register, $src$$Register); 8540 %} 8541 ins_pipe(pipe_class_default); 8542 %} 8543 8544 //----------Rotate Instructions------------------------------------------------ 8545 8546 // Rotate Left by 8-bit immediate 8547 instruct rotlI_reg_immi8(iRegIdst dst, iRegIsrc src, immI8 lshift, immI8 rshift) %{ 8548 match(Set dst (OrI (LShiftI src lshift) (URShiftI src rshift))); 8549 predicate(0 == ((n->in(1)->in(2)->get_int() + n->in(2)->in(2)->get_int()) & 0x1f)); 8550 8551 format %{ "ROTLWI $dst, $src, $lshift" %} 8552 size(4); 8553 ins_encode %{ 8554 // TODO: PPC port $archOpcode(ppc64Opcode_rlwinm); 8555 __ rotlwi($dst$$Register, $src$$Register, $lshift$$constant); 8556 %} 8557 ins_pipe(pipe_class_default); 8558 %} 8559 8560 // Rotate Right by 8-bit immediate 8561 instruct rotrI_reg_immi8(iRegIdst dst, iRegIsrc src, immI8 rshift, immI8 lshift) %{ 8562 match(Set dst (OrI (URShiftI src rshift) (LShiftI src lshift))); 8563 predicate(0 == ((n->in(1)->in(2)->get_int() + n->in(2)->in(2)->get_int()) & 0x1f)); 8564 8565 format %{ "ROTRWI $dst, $rshift" %} 8566 size(4); 8567 ins_encode %{ 8568 // TODO: PPC port $archOpcode(ppc64Opcode_rlwinm); 8569 __ rotrwi($dst$$Register, $src$$Register, $rshift$$constant); 8570 %} 8571 ins_pipe(pipe_class_default); 8572 %} 8573 8574 //----------Floating Point Arithmetic Instructions----------------------------- 8575 8576 // Add float single precision 8577 instruct addF_reg_reg(regF dst, regF src1, regF src2) %{ 8578 match(Set dst (AddF src1 src2)); 8579 8580 format %{ "FADDS $dst, $src1, $src2" %} 8581 size(4); 8582 ins_encode %{ 8583 // TODO: PPC port $archOpcode(ppc64Opcode_fadds); 8584 __ fadds($dst$$FloatRegister, $src1$$FloatRegister, $src2$$FloatRegister); 8585 %} 8586 ins_pipe(pipe_class_default); 8587 %} 8588 8589 // Add float double precision 8590 instruct addD_reg_reg(regD dst, regD src1, regD src2) %{ 8591 match(Set dst (AddD src1 src2)); 8592 8593 format %{ "FADD $dst, $src1, $src2" %} 8594 size(4); 8595 ins_encode %{ 8596 // TODO: PPC port $archOpcode(ppc64Opcode_fadd); 8597 __ fadd($dst$$FloatRegister, $src1$$FloatRegister, $src2$$FloatRegister); 8598 %} 8599 ins_pipe(pipe_class_default); 8600 %} 8601 8602 // Sub float single precision 8603 instruct subF_reg_reg(regF dst, regF src1, regF src2) %{ 8604 match(Set dst (SubF src1 src2)); 8605 8606 format %{ "FSUBS $dst, $src1, $src2" %} 8607 size(4); 8608 ins_encode %{ 8609 // TODO: PPC port $archOpcode(ppc64Opcode_fsubs); 8610 __ fsubs($dst$$FloatRegister, $src1$$FloatRegister, $src2$$FloatRegister); 8611 %} 8612 ins_pipe(pipe_class_default); 8613 %} 8614 8615 // Sub float double precision 8616 instruct subD_reg_reg(regD dst, regD src1, regD src2) %{ 8617 match(Set dst (SubD src1 src2)); 8618 format %{ "FSUB $dst, $src1, $src2" %} 8619 size(4); 8620 ins_encode %{ 8621 // TODO: PPC port $archOpcode(ppc64Opcode_fsub); 8622 __ fsub($dst$$FloatRegister, $src1$$FloatRegister, $src2$$FloatRegister); 8623 %} 8624 ins_pipe(pipe_class_default); 8625 %} 8626 8627 // Mul float single precision 8628 instruct mulF_reg_reg(regF dst, regF src1, regF src2) %{ 8629 match(Set dst (MulF src1 src2)); 8630 format %{ "FMULS $dst, $src1, $src2" %} 8631 size(4); 8632 ins_encode %{ 8633 // TODO: PPC port $archOpcode(ppc64Opcode_fmuls); 8634 __ fmuls($dst$$FloatRegister, $src1$$FloatRegister, $src2$$FloatRegister); 8635 %} 8636 ins_pipe(pipe_class_default); 8637 %} 8638 8639 // Mul float double precision 8640 instruct mulD_reg_reg(regD dst, regD src1, regD src2) %{ 8641 match(Set dst (MulD src1 src2)); 8642 format %{ "FMUL $dst, $src1, $src2" %} 8643 size(4); 8644 ins_encode %{ 8645 // TODO: PPC port $archOpcode(ppc64Opcode_fmul); 8646 __ fmul($dst$$FloatRegister, $src1$$FloatRegister, $src2$$FloatRegister); 8647 %} 8648 ins_pipe(pipe_class_default); 8649 %} 8650 8651 // Div float single precision 8652 instruct divF_reg_reg(regF dst, regF src1, regF src2) %{ 8653 match(Set dst (DivF src1 src2)); 8654 format %{ "FDIVS $dst, $src1, $src2" %} 8655 size(4); 8656 ins_encode %{ 8657 // TODO: PPC port $archOpcode(ppc64Opcode_fdivs); 8658 __ fdivs($dst$$FloatRegister, $src1$$FloatRegister, $src2$$FloatRegister); 8659 %} 8660 ins_pipe(pipe_class_default); 8661 %} 8662 8663 // Div float double precision 8664 instruct divD_reg_reg(regD dst, regD src1, regD src2) %{ 8665 match(Set dst (DivD src1 src2)); 8666 format %{ "FDIV $dst, $src1, $src2" %} 8667 size(4); 8668 ins_encode %{ 8669 // TODO: PPC port $archOpcode(ppc64Opcode_fdiv); 8670 __ fdiv($dst$$FloatRegister, $src1$$FloatRegister, $src2$$FloatRegister); 8671 %} 8672 ins_pipe(pipe_class_default); 8673 %} 8674 8675 // Absolute float single precision 8676 instruct absF_reg(regF dst, regF src) %{ 8677 match(Set dst (AbsF src)); 8678 format %{ "FABS $dst, $src \t// float" %} 8679 size(4); 8680 ins_encode %{ 8681 // TODO: PPC port $archOpcode(ppc64Opcode_fabs); 8682 __ fabs($dst$$FloatRegister, $src$$FloatRegister); 8683 %} 8684 ins_pipe(pipe_class_default); 8685 %} 8686 8687 // Absolute float double precision 8688 instruct absD_reg(regD dst, regD src) %{ 8689 match(Set dst (AbsD src)); 8690 format %{ "FABS $dst, $src \t// double" %} 8691 size(4); 8692 ins_encode %{ 8693 // TODO: PPC port $archOpcode(ppc64Opcode_fabs); 8694 __ fabs($dst$$FloatRegister, $src$$FloatRegister); 8695 %} 8696 ins_pipe(pipe_class_default); 8697 %} 8698 8699 instruct negF_reg(regF dst, regF src) %{ 8700 match(Set dst (NegF src)); 8701 format %{ "FNEG $dst, $src \t// float" %} 8702 size(4); 8703 ins_encode %{ 8704 // TODO: PPC port $archOpcode(ppc64Opcode_fneg); 8705 __ fneg($dst$$FloatRegister, $src$$FloatRegister); 8706 %} 8707 ins_pipe(pipe_class_default); 8708 %} 8709 8710 instruct negD_reg(regD dst, regD src) %{ 8711 match(Set dst (NegD src)); 8712 format %{ "FNEG $dst, $src \t// double" %} 8713 size(4); 8714 ins_encode %{ 8715 // TODO: PPC port $archOpcode(ppc64Opcode_fneg); 8716 __ fneg($dst$$FloatRegister, $src$$FloatRegister); 8717 %} 8718 ins_pipe(pipe_class_default); 8719 %} 8720 8721 // AbsF + NegF. 8722 instruct negF_absF_reg(regF dst, regF src) %{ 8723 match(Set dst (NegF (AbsF src))); 8724 format %{ "FNABS $dst, $src \t// float" %} 8725 size(4); 8726 ins_encode %{ 8727 // TODO: PPC port $archOpcode(ppc64Opcode_fnabs); 8728 __ fnabs($dst$$FloatRegister, $src$$FloatRegister); 8729 %} 8730 ins_pipe(pipe_class_default); 8731 %} 8732 8733 // AbsD + NegD. 8734 instruct negD_absD_reg(regD dst, regD src) %{ 8735 match(Set dst (NegD (AbsD src))); 8736 format %{ "FNABS $dst, $src \t// double" %} 8737 size(4); 8738 ins_encode %{ 8739 // TODO: PPC port $archOpcode(ppc64Opcode_fnabs); 8740 __ fnabs($dst$$FloatRegister, $src$$FloatRegister); 8741 %} 8742 ins_pipe(pipe_class_default); 8743 %} 8744 8745 // VM_Version::has_fsqrt() decides if this node will be used. 8746 // Sqrt float double precision 8747 instruct sqrtD_reg(regD dst, regD src) %{ 8748 match(Set dst (SqrtD src)); 8749 format %{ "FSQRT $dst, $src" %} 8750 size(4); 8751 ins_encode %{ 8752 // TODO: PPC port $archOpcode(ppc64Opcode_fsqrt); 8753 __ fsqrt($dst$$FloatRegister, $src$$FloatRegister); 8754 %} 8755 ins_pipe(pipe_class_default); 8756 %} 8757 8758 // Single-precision sqrt. 8759 instruct sqrtF_reg(regF dst, regF src) %{ 8760 match(Set dst (ConvD2F (SqrtD (ConvF2D src)))); 8761 ins_cost(DEFAULT_COST); 8762 8763 format %{ "FSQRTS $dst, $src" %} 8764 size(4); 8765 ins_encode %{ 8766 // TODO: PPC port $archOpcode(ppc64Opcode_fsqrts); 8767 __ fsqrts($dst$$FloatRegister, $src$$FloatRegister); 8768 %} 8769 ins_pipe(pipe_class_default); 8770 %} 8771 8772 instruct roundDouble_nop(regD dst) %{ 8773 match(Set dst (RoundDouble dst)); 8774 ins_cost(0); 8775 8776 format %{ " -- \t// RoundDouble not needed - empty" %} 8777 size(0); 8778 // PPC results are already "rounded" (i.e., normal-format IEEE). 8779 ins_encode( /*empty*/ ); 8780 ins_pipe(pipe_class_default); 8781 %} 8782 8783 instruct roundFloat_nop(regF dst) %{ 8784 match(Set dst (RoundFloat dst)); 8785 ins_cost(0); 8786 8787 format %{ " -- \t// RoundFloat not needed - empty" %} 8788 size(0); 8789 // PPC results are already "rounded" (i.e., normal-format IEEE). 8790 ins_encode( /*empty*/ ); 8791 ins_pipe(pipe_class_default); 8792 %} 8793 8794 //----------Logical Instructions----------------------------------------------- 8795 8796 // And Instructions 8797 8798 // Register And 8799 instruct andI_reg_reg(iRegIdst dst, iRegIsrc src1, iRegIsrc src2) %{ 8800 match(Set dst (AndI src1 src2)); 8801 format %{ "AND $dst, $src1, $src2" %} 8802 size(4); 8803 ins_encode %{ 8804 // TODO: PPC port $archOpcode(ppc64Opcode_and); 8805 __ andr($dst$$Register, $src1$$Register, $src2$$Register); 8806 %} 8807 ins_pipe(pipe_class_default); 8808 %} 8809 8810 // Immediate And 8811 instruct andI_reg_uimm16(iRegIdst dst, iRegIsrc src1, uimmI16 src2, flagsRegCR0 cr0) %{ 8812 match(Set dst (AndI src1 src2)); 8813 effect(KILL cr0); 8814 8815 format %{ "ANDI $dst, $src1, $src2" %} 8816 size(4); 8817 ins_encode %{ 8818 // TODO: PPC port $archOpcode(ppc64Opcode_andi_); 8819 // FIXME: avoid andi_ ? 8820 __ andi_($dst$$Register, $src1$$Register, $src2$$constant); 8821 %} 8822 ins_pipe(pipe_class_default); 8823 %} 8824 8825 // Immediate And where the immediate is a negative power of 2. 8826 instruct andI_reg_immInegpow2(iRegIdst dst, iRegIsrc src1, immInegpow2 src2) %{ 8827 match(Set dst (AndI src1 src2)); 8828 format %{ "ANDWI $dst, $src1, $src2" %} 8829 size(4); 8830 ins_encode %{ 8831 // TODO: PPC port $archOpcode(ppc64Opcode_rldicr); 8832 __ clrrdi($dst$$Register, $src1$$Register, log2_long((jlong)(julong)(juint)-($src2$$constant))); 8833 %} 8834 ins_pipe(pipe_class_default); 8835 %} 8836 8837 instruct andI_reg_immIpow2minus1(iRegIdst dst, iRegIsrc src1, immIpow2minus1 src2) %{ 8838 match(Set dst (AndI src1 src2)); 8839 format %{ "ANDWI $dst, $src1, $src2" %} 8840 size(4); 8841 ins_encode %{ 8842 // TODO: PPC port $archOpcode(ppc64Opcode_rldicl); 8843 __ clrldi($dst$$Register, $src1$$Register, 64-log2_long((((jlong) $src2$$constant)+1))); 8844 %} 8845 ins_pipe(pipe_class_default); 8846 %} 8847 8848 instruct andI_reg_immIpowerOf2(iRegIdst dst, iRegIsrc src1, immIpowerOf2 src2) %{ 8849 match(Set dst (AndI src1 src2)); 8850 predicate(UseRotateAndMaskInstructionsPPC64); 8851 format %{ "ANDWI $dst, $src1, $src2" %} 8852 size(4); 8853 ins_encode %{ 8854 // TODO: PPC port $archOpcode(ppc64Opcode_rlwinm); 8855 __ rlwinm($dst$$Register, $src1$$Register, 0, 8856 (31-log2_long((jlong) $src2$$constant)) & 0x1f, (31-log2_long((jlong) $src2$$constant)) & 0x1f); 8857 %} 8858 ins_pipe(pipe_class_default); 8859 %} 8860 8861 // Register And Long 8862 instruct andL_reg_reg(iRegLdst dst, iRegLsrc src1, iRegLsrc src2) %{ 8863 match(Set dst (AndL src1 src2)); 8864 ins_cost(DEFAULT_COST); 8865 8866 format %{ "AND $dst, $src1, $src2 \t// long" %} 8867 size(4); 8868 ins_encode %{ 8869 // TODO: PPC port $archOpcode(ppc64Opcode_and); 8870 __ andr($dst$$Register, $src1$$Register, $src2$$Register); 8871 %} 8872 ins_pipe(pipe_class_default); 8873 %} 8874 8875 // Immediate And long 8876 instruct andL_reg_uimm16(iRegLdst dst, iRegLsrc src1, uimmL16 src2, flagsRegCR0 cr0) %{ 8877 match(Set dst (AndL src1 src2)); 8878 effect(KILL cr0); 8879 ins_cost(DEFAULT_COST); 8880 8881 format %{ "ANDI $dst, $src1, $src2 \t// long" %} 8882 size(4); 8883 ins_encode %{ 8884 // TODO: PPC port $archOpcode(ppc64Opcode_andi_); 8885 // FIXME: avoid andi_ ? 8886 __ andi_($dst$$Register, $src1$$Register, $src2$$constant); 8887 %} 8888 ins_pipe(pipe_class_default); 8889 %} 8890 8891 // Immediate And Long where the immediate is a negative power of 2. 8892 instruct andL_reg_immLnegpow2(iRegLdst dst, iRegLsrc src1, immLnegpow2 src2) %{ 8893 match(Set dst (AndL src1 src2)); 8894 format %{ "ANDDI $dst, $src1, $src2" %} 8895 size(4); 8896 ins_encode %{ 8897 // TODO: PPC port $archOpcode(ppc64Opcode_rldicr); 8898 __ clrrdi($dst$$Register, $src1$$Register, log2_long((jlong)-$src2$$constant)); 8899 %} 8900 ins_pipe(pipe_class_default); 8901 %} 8902 8903 instruct andL_reg_immLpow2minus1(iRegLdst dst, iRegLsrc src1, immLpow2minus1 src2) %{ 8904 match(Set dst (AndL src1 src2)); 8905 format %{ "ANDDI $dst, $src1, $src2" %} 8906 size(4); 8907 ins_encode %{ 8908 // TODO: PPC port $archOpcode(ppc64Opcode_rldicl); 8909 __ clrldi($dst$$Register, $src1$$Register, 64-log2_long((((jlong) $src2$$constant)+1))); 8910 %} 8911 ins_pipe(pipe_class_default); 8912 %} 8913 8914 // AndL + ConvL2I. 8915 instruct convL2I_andL_reg_immLpow2minus1(iRegIdst dst, iRegLsrc src1, immLpow2minus1 src2) %{ 8916 match(Set dst (ConvL2I (AndL src1 src2))); 8917 ins_cost(DEFAULT_COST); 8918 8919 format %{ "ANDDI $dst, $src1, $src2 \t// long + l2i" %} 8920 size(4); 8921 ins_encode %{ 8922 // TODO: PPC port $archOpcode(ppc64Opcode_rldicl); 8923 __ clrldi($dst$$Register, $src1$$Register, 64-log2_long((((jlong) $src2$$constant)+1))); 8924 %} 8925 ins_pipe(pipe_class_default); 8926 %} 8927 8928 // Or Instructions 8929 8930 // Register Or 8931 instruct orI_reg_reg(iRegIdst dst, iRegIsrc src1, iRegIsrc src2) %{ 8932 match(Set dst (OrI src1 src2)); 8933 format %{ "OR $dst, $src1, $src2" %} 8934 size(4); 8935 ins_encode %{ 8936 // TODO: PPC port $archOpcode(ppc64Opcode_or); 8937 __ or_unchecked($dst$$Register, $src1$$Register, $src2$$Register); 8938 %} 8939 ins_pipe(pipe_class_default); 8940 %} 8941 8942 // Expand does not work with above instruct. (??) 8943 instruct orI_reg_reg_2(iRegIdst dst, iRegIsrc src1, iRegIsrc src2) %{ 8944 // no match-rule 8945 effect(DEF dst, USE src1, USE src2); 8946 format %{ "OR $dst, $src1, $src2" %} 8947 size(4); 8948 ins_encode %{ 8949 // TODO: PPC port $archOpcode(ppc64Opcode_or); 8950 __ or_unchecked($dst$$Register, $src1$$Register, $src2$$Register); 8951 %} 8952 ins_pipe(pipe_class_default); 8953 %} 8954 8955 instruct tree_orI_orI_orI_reg_reg_Ex(iRegIdst dst, iRegIsrc src1, iRegIsrc src2, iRegIsrc src3, iRegIsrc src4) %{ 8956 match(Set dst (OrI (OrI (OrI src1 src2) src3) src4)); 8957 ins_cost(DEFAULT_COST*3); 8958 8959 expand %{ 8960 // FIXME: we should do this in the ideal world. 8961 iRegIdst tmp1; 8962 iRegIdst tmp2; 8963 orI_reg_reg(tmp1, src1, src2); 8964 orI_reg_reg_2(tmp2, src3, src4); // Adlc complains about orI_reg_reg. 8965 orI_reg_reg(dst, tmp1, tmp2); 8966 %} 8967 %} 8968 8969 // Immediate Or 8970 instruct orI_reg_uimm16(iRegIdst dst, iRegIsrc src1, uimmI16 src2) %{ 8971 match(Set dst (OrI src1 src2)); 8972 format %{ "ORI $dst, $src1, $src2" %} 8973 size(4); 8974 ins_encode %{ 8975 // TODO: PPC port $archOpcode(ppc64Opcode_ori); 8976 __ ori($dst$$Register, $src1$$Register, ($src2$$constant) & 0xFFFF); 8977 %} 8978 ins_pipe(pipe_class_default); 8979 %} 8980 8981 // Register Or Long 8982 instruct orL_reg_reg(iRegLdst dst, iRegLsrc src1, iRegLsrc src2) %{ 8983 match(Set dst (OrL src1 src2)); 8984 ins_cost(DEFAULT_COST); 8985 8986 size(4); 8987 format %{ "OR $dst, $src1, $src2 \t// long" %} 8988 ins_encode %{ 8989 // TODO: PPC port $archOpcode(ppc64Opcode_or); 8990 __ or_unchecked($dst$$Register, $src1$$Register, $src2$$Register); 8991 %} 8992 ins_pipe(pipe_class_default); 8993 %} 8994 8995 // OrL + ConvL2I. 8996 instruct orI_regL_regL(iRegIdst dst, iRegLsrc src1, iRegLsrc src2) %{ 8997 match(Set dst (ConvL2I (OrL src1 src2))); 8998 ins_cost(DEFAULT_COST); 8999 9000 format %{ "OR $dst, $src1, $src2 \t// long + l2i" %} 9001 size(4); 9002 ins_encode %{ 9003 // TODO: PPC port $archOpcode(ppc64Opcode_or); 9004 __ or_unchecked($dst$$Register, $src1$$Register, $src2$$Register); 9005 %} 9006 ins_pipe(pipe_class_default); 9007 %} 9008 9009 // Immediate Or long 9010 instruct orL_reg_uimm16(iRegLdst dst, iRegLsrc src1, uimmL16 con) %{ 9011 match(Set dst (OrL src1 con)); 9012 ins_cost(DEFAULT_COST); 9013 9014 format %{ "ORI $dst, $src1, $con \t// long" %} 9015 size(4); 9016 ins_encode %{ 9017 // TODO: PPC port $archOpcode(ppc64Opcode_ori); 9018 __ ori($dst$$Register, $src1$$Register, ($con$$constant) & 0xFFFF); 9019 %} 9020 ins_pipe(pipe_class_default); 9021 %} 9022 9023 // Xor Instructions 9024 9025 // Register Xor 9026 instruct xorI_reg_reg(iRegIdst dst, iRegIsrc src1, iRegIsrc src2) %{ 9027 match(Set dst (XorI src1 src2)); 9028 format %{ "XOR $dst, $src1, $src2" %} 9029 size(4); 9030 ins_encode %{ 9031 // TODO: PPC port $archOpcode(ppc64Opcode_xor); 9032 __ xorr($dst$$Register, $src1$$Register, $src2$$Register); 9033 %} 9034 ins_pipe(pipe_class_default); 9035 %} 9036 9037 // Expand does not work with above instruct. (??) 9038 instruct xorI_reg_reg_2(iRegIdst dst, iRegIsrc src1, iRegIsrc src2) %{ 9039 // no match-rule 9040 effect(DEF dst, USE src1, USE src2); 9041 format %{ "XOR $dst, $src1, $src2" %} 9042 size(4); 9043 ins_encode %{ 9044 // TODO: PPC port $archOpcode(ppc64Opcode_xor); 9045 __ xorr($dst$$Register, $src1$$Register, $src2$$Register); 9046 %} 9047 ins_pipe(pipe_class_default); 9048 %} 9049 9050 instruct tree_xorI_xorI_xorI_reg_reg_Ex(iRegIdst dst, iRegIsrc src1, iRegIsrc src2, iRegIsrc src3, iRegIsrc src4) %{ 9051 match(Set dst (XorI (XorI (XorI src1 src2) src3) src4)); 9052 ins_cost(DEFAULT_COST*3); 9053 9054 expand %{ 9055 // FIXME: we should do this in the ideal world. 9056 iRegIdst tmp1; 9057 iRegIdst tmp2; 9058 xorI_reg_reg(tmp1, src1, src2); 9059 xorI_reg_reg_2(tmp2, src3, src4); // Adlc complains about xorI_reg_reg. 9060 xorI_reg_reg(dst, tmp1, tmp2); 9061 %} 9062 %} 9063 9064 // Immediate Xor 9065 instruct xorI_reg_uimm16(iRegIdst dst, iRegIsrc src1, uimmI16 src2) %{ 9066 match(Set dst (XorI src1 src2)); 9067 format %{ "XORI $dst, $src1, $src2" %} 9068 size(4); 9069 ins_encode %{ 9070 // TODO: PPC port $archOpcode(ppc64Opcode_xori); 9071 __ xori($dst$$Register, $src1$$Register, $src2$$constant); 9072 %} 9073 ins_pipe(pipe_class_default); 9074 %} 9075 9076 // Register Xor Long 9077 instruct xorL_reg_reg(iRegLdst dst, iRegLsrc src1, iRegLsrc src2) %{ 9078 match(Set dst (XorL src1 src2)); 9079 ins_cost(DEFAULT_COST); 9080 9081 format %{ "XOR $dst, $src1, $src2 \t// long" %} 9082 size(4); 9083 ins_encode %{ 9084 // TODO: PPC port $archOpcode(ppc64Opcode_xor); 9085 __ xorr($dst$$Register, $src1$$Register, $src2$$Register); 9086 %} 9087 ins_pipe(pipe_class_default); 9088 %} 9089 9090 // XorL + ConvL2I. 9091 instruct xorI_regL_regL(iRegIdst dst, iRegLsrc src1, iRegLsrc src2) %{ 9092 match(Set dst (ConvL2I (XorL src1 src2))); 9093 ins_cost(DEFAULT_COST); 9094 9095 format %{ "XOR $dst, $src1, $src2 \t// long + l2i" %} 9096 size(4); 9097 ins_encode %{ 9098 // TODO: PPC port $archOpcode(ppc64Opcode_xor); 9099 __ xorr($dst$$Register, $src1$$Register, $src2$$Register); 9100 %} 9101 ins_pipe(pipe_class_default); 9102 %} 9103 9104 // Immediate Xor Long 9105 instruct xorL_reg_uimm16(iRegLdst dst, iRegLsrc src1, uimmL16 src2) %{ 9106 match(Set dst (XorL src1 src2)); 9107 ins_cost(DEFAULT_COST); 9108 9109 format %{ "XORI $dst, $src1, $src2 \t// long" %} 9110 size(4); 9111 ins_encode %{ 9112 // TODO: PPC port $archOpcode(ppc64Opcode_xori); 9113 __ xori($dst$$Register, $src1$$Register, $src2$$constant); 9114 %} 9115 ins_pipe(pipe_class_default); 9116 %} 9117 9118 instruct notI_reg(iRegIdst dst, iRegIsrc src1, immI_minus1 src2) %{ 9119 match(Set dst (XorI src1 src2)); 9120 ins_cost(DEFAULT_COST); 9121 9122 format %{ "NOT $dst, $src1 ($src2)" %} 9123 size(4); 9124 ins_encode %{ 9125 // TODO: PPC port $archOpcode(ppc64Opcode_nor); 9126 __ nor($dst$$Register, $src1$$Register, $src1$$Register); 9127 %} 9128 ins_pipe(pipe_class_default); 9129 %} 9130 9131 instruct notL_reg(iRegLdst dst, iRegLsrc src1, immL_minus1 src2) %{ 9132 match(Set dst (XorL src1 src2)); 9133 ins_cost(DEFAULT_COST); 9134 9135 format %{ "NOT $dst, $src1 ($src2) \t// long" %} 9136 size(4); 9137 ins_encode %{ 9138 // TODO: PPC port $archOpcode(ppc64Opcode_nor); 9139 __ nor($dst$$Register, $src1$$Register, $src1$$Register); 9140 %} 9141 ins_pipe(pipe_class_default); 9142 %} 9143 9144 // And-complement 9145 instruct andcI_reg_reg(iRegIdst dst, iRegIsrc src1, immI_minus1 src2, iRegIsrc src3) %{ 9146 match(Set dst (AndI (XorI src1 src2) src3)); 9147 ins_cost(DEFAULT_COST); 9148 9149 format %{ "ANDW $dst, xori($src1, $src2), $src3" %} 9150 size(4); 9151 ins_encode( enc_andc(dst, src3, src1) ); 9152 ins_pipe(pipe_class_default); 9153 %} 9154 9155 // And-complement 9156 instruct andcL_reg_reg(iRegLdst dst, iRegLsrc src1, iRegLsrc src2) %{ 9157 // no match-rule, false predicate 9158 effect(DEF dst, USE src1, USE src2); 9159 predicate(false); 9160 9161 format %{ "ANDC $dst, $src1, $src2" %} 9162 size(4); 9163 ins_encode %{ 9164 // TODO: PPC port $archOpcode(ppc64Opcode_andc); 9165 __ andc($dst$$Register, $src1$$Register, $src2$$Register); 9166 %} 9167 ins_pipe(pipe_class_default); 9168 %} 9169 9170 //----------Moves between int/long and float/double---------------------------- 9171 // 9172 // The following rules move values from int/long registers/stack-locations 9173 // to float/double registers/stack-locations and vice versa, without doing any 9174 // conversions. These rules are used to implement the bit-conversion methods 9175 // of java.lang.Float etc., e.g. 9176 // int floatToIntBits(float value) 9177 // float intBitsToFloat(int bits) 9178 // 9179 // Notes on the implementation on ppc64: 9180 // We only provide rules which move between a register and a stack-location, 9181 // because we always have to go through memory when moving between a float 9182 // register and an integer register. 9183 9184 //---------- Chain stack slots between similar types -------- 9185 9186 // These are needed so that the rules below can match. 9187 9188 // Load integer from stack slot 9189 instruct stkI_to_regI(iRegIdst dst, stackSlotI src) %{ 9190 match(Set dst src); 9191 ins_cost(MEMORY_REF_COST); 9192 9193 format %{ "LWZ $dst, $src" %} 9194 size(4); 9195 ins_encode( enc_lwz(dst, src) ); 9196 ins_pipe(pipe_class_memory); 9197 %} 9198 9199 // Store integer to stack slot 9200 instruct regI_to_stkI(stackSlotI dst, iRegIsrc src) %{ 9201 match(Set dst src); 9202 ins_cost(MEMORY_REF_COST); 9203 9204 format %{ "STW $src, $dst \t// stk" %} 9205 size(4); 9206 ins_encode( enc_stw(src, dst) ); // rs=rt 9207 ins_pipe(pipe_class_memory); 9208 %} 9209 9210 // Load long from stack slot 9211 instruct stkL_to_regL(iRegLdst dst, stackSlotL src) %{ 9212 match(Set dst src); 9213 ins_cost(MEMORY_REF_COST); 9214 9215 format %{ "LD $dst, $src \t// long" %} 9216 size(4); 9217 ins_encode( enc_ld(dst, src) ); 9218 ins_pipe(pipe_class_memory); 9219 %} 9220 9221 // Store long to stack slot 9222 instruct regL_to_stkL(stackSlotL dst, iRegLsrc src) %{ 9223 match(Set dst src); 9224 ins_cost(MEMORY_REF_COST); 9225 9226 format %{ "STD $src, $dst \t// long" %} 9227 size(4); 9228 ins_encode( enc_std(src, dst) ); // rs=rt 9229 ins_pipe(pipe_class_memory); 9230 %} 9231 9232 //----------Moves between int and float 9233 9234 // Move float value from float stack-location to integer register. 9235 instruct moveF2I_stack_reg(iRegIdst dst, stackSlotF src) %{ 9236 match(Set dst (MoveF2I src)); 9237 ins_cost(MEMORY_REF_COST); 9238 9239 format %{ "LWZ $dst, $src \t// MoveF2I" %} 9240 size(4); 9241 ins_encode( enc_lwz(dst, src) ); 9242 ins_pipe(pipe_class_memory); 9243 %} 9244 9245 // Move float value from float register to integer stack-location. 9246 instruct moveF2I_reg_stack(stackSlotI dst, regF src) %{ 9247 match(Set dst (MoveF2I src)); 9248 ins_cost(MEMORY_REF_COST); 9249 9250 format %{ "STFS $src, $dst \t// MoveF2I" %} 9251 size(4); 9252 ins_encode( enc_stfs(src, dst) ); 9253 ins_pipe(pipe_class_memory); 9254 %} 9255 9256 // Move integer value from integer stack-location to float register. 9257 instruct moveI2F_stack_reg(regF dst, stackSlotI src) %{ 9258 match(Set dst (MoveI2F src)); 9259 ins_cost(MEMORY_REF_COST); 9260 9261 format %{ "LFS $dst, $src \t// MoveI2F" %} 9262 size(4); 9263 ins_encode %{ 9264 // TODO: PPC port $archOpcode(ppc64Opcode_lfs); 9265 int Idisp = $src$$disp + frame_slots_bias($src$$base, ra_); 9266 __ lfs($dst$$FloatRegister, Idisp, $src$$base$$Register); 9267 %} 9268 ins_pipe(pipe_class_memory); 9269 %} 9270 9271 // Move integer value from integer register to float stack-location. 9272 instruct moveI2F_reg_stack(stackSlotF dst, iRegIsrc src) %{ 9273 match(Set dst (MoveI2F src)); 9274 ins_cost(MEMORY_REF_COST); 9275 9276 format %{ "STW $src, $dst \t// MoveI2F" %} 9277 size(4); 9278 ins_encode( enc_stw(src, dst) ); 9279 ins_pipe(pipe_class_memory); 9280 %} 9281 9282 //----------Moves between long and float 9283 9284 instruct moveF2L_reg_stack(stackSlotL dst, regF src) %{ 9285 // no match-rule, false predicate 9286 effect(DEF dst, USE src); 9287 predicate(false); 9288 9289 format %{ "storeD $src, $dst \t// STACK" %} 9290 size(4); 9291 ins_encode( enc_stfd(src, dst) ); 9292 ins_pipe(pipe_class_default); 9293 %} 9294 9295 //----------Moves between long and double 9296 9297 // Move double value from double stack-location to long register. 9298 instruct moveD2L_stack_reg(iRegLdst dst, stackSlotD src) %{ 9299 match(Set dst (MoveD2L src)); 9300 ins_cost(MEMORY_REF_COST); 9301 size(4); 9302 format %{ "LD $dst, $src \t// MoveD2L" %} 9303 ins_encode( enc_ld(dst, src) ); 9304 ins_pipe(pipe_class_memory); 9305 %} 9306 9307 // Move double value from double register to long stack-location. 9308 instruct moveD2L_reg_stack(stackSlotL dst, regD src) %{ 9309 match(Set dst (MoveD2L src)); 9310 effect(DEF dst, USE src); 9311 ins_cost(MEMORY_REF_COST); 9312 9313 format %{ "STFD $src, $dst \t// MoveD2L" %} 9314 size(4); 9315 ins_encode( enc_stfd(src, dst) ); 9316 ins_pipe(pipe_class_memory); 9317 %} 9318 9319 // Move long value from long stack-location to double register. 9320 instruct moveL2D_stack_reg(regD dst, stackSlotL src) %{ 9321 match(Set dst (MoveL2D src)); 9322 ins_cost(MEMORY_REF_COST); 9323 9324 format %{ "LFD $dst, $src \t// MoveL2D" %} 9325 size(4); 9326 ins_encode( enc_lfd(dst, src) ); 9327 ins_pipe(pipe_class_memory); 9328 %} 9329 9330 // Move long value from long register to double stack-location. 9331 instruct moveL2D_reg_stack(stackSlotD dst, iRegLsrc src) %{ 9332 match(Set dst (MoveL2D src)); 9333 ins_cost(MEMORY_REF_COST); 9334 9335 format %{ "STD $src, $dst \t// MoveL2D" %} 9336 size(4); 9337 ins_encode( enc_std(src, dst) ); 9338 ins_pipe(pipe_class_memory); 9339 %} 9340 9341 //----------Register Move Instructions----------------------------------------- 9342 9343 // Replicate for Superword 9344 9345 instruct moveReg(iRegLdst dst, iRegIsrc src) %{ 9346 predicate(false); 9347 effect(DEF dst, USE src); 9348 9349 format %{ "MR $dst, $src \t// replicate " %} 9350 // variable size, 0 or 4. 9351 ins_encode %{ 9352 // TODO: PPC port $archOpcode(ppc64Opcode_or); 9353 __ mr_if_needed($dst$$Register, $src$$Register); 9354 %} 9355 ins_pipe(pipe_class_default); 9356 %} 9357 9358 //----------Cast instructions (Java-level type cast)--------------------------- 9359 9360 // Cast Long to Pointer for unsafe natives. 9361 instruct castX2P(iRegPdst dst, iRegLsrc src) %{ 9362 match(Set dst (CastX2P src)); 9363 9364 format %{ "MR $dst, $src \t// Long->Ptr" %} 9365 // variable size, 0 or 4. 9366 ins_encode %{ 9367 // TODO: PPC port $archOpcode(ppc64Opcode_or); 9368 __ mr_if_needed($dst$$Register, $src$$Register); 9369 %} 9370 ins_pipe(pipe_class_default); 9371 %} 9372 9373 // Cast Pointer to Long for unsafe natives. 9374 instruct castP2X(iRegLdst dst, iRegP_N2P src) %{ 9375 match(Set dst (CastP2X src)); 9376 9377 format %{ "MR $dst, $src \t// Ptr->Long" %} 9378 // variable size, 0 or 4. 9379 ins_encode %{ 9380 // TODO: PPC port $archOpcode(ppc64Opcode_or); 9381 __ mr_if_needed($dst$$Register, $src$$Register); 9382 %} 9383 ins_pipe(pipe_class_default); 9384 %} 9385 9386 instruct castPP(iRegPdst dst) %{ 9387 match(Set dst (CastPP dst)); 9388 format %{ " -- \t// castPP of $dst" %} 9389 size(0); 9390 ins_encode( /*empty*/ ); 9391 ins_pipe(pipe_class_default); 9392 %} 9393 9394 instruct castII(iRegIdst dst) %{ 9395 match(Set dst (CastII dst)); 9396 format %{ " -- \t// castII of $dst" %} 9397 size(0); 9398 ins_encode( /*empty*/ ); 9399 ins_pipe(pipe_class_default); 9400 %} 9401 9402 instruct checkCastPP(iRegPdst dst) %{ 9403 match(Set dst (CheckCastPP dst)); 9404 format %{ " -- \t// checkcastPP of $dst" %} 9405 size(0); 9406 ins_encode( /*empty*/ ); 9407 ins_pipe(pipe_class_default); 9408 %} 9409 9410 //----------Convert instructions----------------------------------------------- 9411 9412 // Convert to boolean. 9413 9414 // int_to_bool(src) : { 1 if src != 0 9415 // { 0 else 9416 // 9417 // strategy: 9418 // 1) Count leading zeros of 32 bit-value src, 9419 // this returns 32 (0b10.0000) iff src == 0 and <32 otherwise. 9420 // 2) Shift 5 bits to the right, result is 0b1 iff src == 0, 0b0 otherwise. 9421 // 3) Xori the result to get 0b1 if src != 0 and 0b0 if src == 0. 9422 9423 // convI2Bool 9424 instruct convI2Bool_reg__cntlz_Ex(iRegIdst dst, iRegIsrc src) %{ 9425 match(Set dst (Conv2B src)); 9426 predicate(UseCountLeadingZerosInstructionsPPC64); 9427 ins_cost(DEFAULT_COST); 9428 9429 expand %{ 9430 immI shiftAmount %{ 0x5 %} 9431 uimmI16 mask %{ 0x1 %} 9432 iRegIdst tmp1; 9433 iRegIdst tmp2; 9434 countLeadingZerosI(tmp1, src); 9435 urShiftI_reg_imm(tmp2, tmp1, shiftAmount); 9436 xorI_reg_uimm16(dst, tmp2, mask); 9437 %} 9438 %} 9439 9440 instruct convI2Bool_reg__cmove(iRegIdst dst, iRegIsrc src, flagsReg crx) %{ 9441 match(Set dst (Conv2B src)); 9442 effect(TEMP crx); 9443 predicate(!UseCountLeadingZerosInstructionsPPC64); 9444 ins_cost(DEFAULT_COST); 9445 9446 format %{ "CMPWI $crx, $src, #0 \t// convI2B" 9447 "LI $dst, #0\n\t" 9448 "BEQ $crx, done\n\t" 9449 "LI $dst, #1\n" 9450 "done:" %} 9451 size(16); 9452 ins_encode( enc_convI2B_regI__cmove(dst, src, crx, 0x0, 0x1) ); 9453 ins_pipe(pipe_class_compare); 9454 %} 9455 9456 // ConvI2B + XorI 9457 instruct xorI_convI2Bool_reg_immIvalue1__cntlz_Ex(iRegIdst dst, iRegIsrc src, immI_1 mask) %{ 9458 match(Set dst (XorI (Conv2B src) mask)); 9459 predicate(UseCountLeadingZerosInstructionsPPC64); 9460 ins_cost(DEFAULT_COST); 9461 9462 expand %{ 9463 immI shiftAmount %{ 0x5 %} 9464 iRegIdst tmp1; 9465 countLeadingZerosI(tmp1, src); 9466 urShiftI_reg_imm(dst, tmp1, shiftAmount); 9467 %} 9468 %} 9469 9470 instruct xorI_convI2Bool_reg_immIvalue1__cmove(iRegIdst dst, iRegIsrc src, flagsReg crx, immI_1 mask) %{ 9471 match(Set dst (XorI (Conv2B src) mask)); 9472 effect(TEMP crx); 9473 predicate(!UseCountLeadingZerosInstructionsPPC64); 9474 ins_cost(DEFAULT_COST); 9475 9476 format %{ "CMPWI $crx, $src, #0 \t// Xor(convI2B($src), $mask)" 9477 "LI $dst, #1\n\t" 9478 "BEQ $crx, done\n\t" 9479 "LI $dst, #0\n" 9480 "done:" %} 9481 size(16); 9482 ins_encode( enc_convI2B_regI__cmove(dst, src, crx, 0x1, 0x0) ); 9483 ins_pipe(pipe_class_compare); 9484 %} 9485 9486 // AndI 0b0..010..0 + ConvI2B 9487 instruct convI2Bool_andI_reg_immIpowerOf2(iRegIdst dst, iRegIsrc src, immIpowerOf2 mask) %{ 9488 match(Set dst (Conv2B (AndI src mask))); 9489 predicate(UseRotateAndMaskInstructionsPPC64); 9490 ins_cost(DEFAULT_COST); 9491 9492 format %{ "RLWINM $dst, $src, $mask \t// convI2B(AndI($src, $mask))" %} 9493 size(4); 9494 ins_encode %{ 9495 // TODO: PPC port $archOpcode(ppc64Opcode_rlwinm); 9496 __ rlwinm($dst$$Register, $src$$Register, (32-log2_long((jlong)$mask$$constant)) & 0x1f, 31, 31); 9497 %} 9498 ins_pipe(pipe_class_default); 9499 %} 9500 9501 // Convert pointer to boolean. 9502 // 9503 // ptr_to_bool(src) : { 1 if src != 0 9504 // { 0 else 9505 // 9506 // strategy: 9507 // 1) Count leading zeros of 64 bit-value src, 9508 // this returns 64 (0b100.0000) iff src == 0 and <64 otherwise. 9509 // 2) Shift 6 bits to the right, result is 0b1 iff src == 0, 0b0 otherwise. 9510 // 3) Xori the result to get 0b1 if src != 0 and 0b0 if src == 0. 9511 9512 // ConvP2B 9513 instruct convP2Bool_reg__cntlz_Ex(iRegIdst dst, iRegP_N2P src) %{ 9514 match(Set dst (Conv2B src)); 9515 predicate(UseCountLeadingZerosInstructionsPPC64); 9516 ins_cost(DEFAULT_COST); 9517 9518 expand %{ 9519 immI shiftAmount %{ 0x6 %} 9520 uimmI16 mask %{ 0x1 %} 9521 iRegIdst tmp1; 9522 iRegIdst tmp2; 9523 countLeadingZerosP(tmp1, src); 9524 urShiftI_reg_imm(tmp2, tmp1, shiftAmount); 9525 xorI_reg_uimm16(dst, tmp2, mask); 9526 %} 9527 %} 9528 9529 instruct convP2Bool_reg__cmove(iRegIdst dst, iRegP_N2P src, flagsReg crx) %{ 9530 match(Set dst (Conv2B src)); 9531 effect(TEMP crx); 9532 predicate(!UseCountLeadingZerosInstructionsPPC64); 9533 ins_cost(DEFAULT_COST); 9534 9535 format %{ "CMPDI $crx, $src, #0 \t// convP2B" 9536 "LI $dst, #0\n\t" 9537 "BEQ $crx, done\n\t" 9538 "LI $dst, #1\n" 9539 "done:" %} 9540 size(16); 9541 ins_encode( enc_convP2B_regP__cmove(dst, src, crx, 0x0, 0x1) ); 9542 ins_pipe(pipe_class_compare); 9543 %} 9544 9545 // ConvP2B + XorI 9546 instruct xorI_convP2Bool_reg__cntlz_Ex(iRegIdst dst, iRegP_N2P src, immI_1 mask) %{ 9547 match(Set dst (XorI (Conv2B src) mask)); 9548 predicate(UseCountLeadingZerosInstructionsPPC64); 9549 ins_cost(DEFAULT_COST); 9550 9551 expand %{ 9552 immI shiftAmount %{ 0x6 %} 9553 iRegIdst tmp1; 9554 countLeadingZerosP(tmp1, src); 9555 urShiftI_reg_imm(dst, tmp1, shiftAmount); 9556 %} 9557 %} 9558 9559 instruct xorI_convP2Bool_reg_immIvalue1__cmove(iRegIdst dst, iRegP_N2P src, flagsReg crx, immI_1 mask) %{ 9560 match(Set dst (XorI (Conv2B src) mask)); 9561 effect(TEMP crx); 9562 predicate(!UseCountLeadingZerosInstructionsPPC64); 9563 ins_cost(DEFAULT_COST); 9564 9565 format %{ "CMPDI $crx, $src, #0 \t// XorI(convP2B($src), $mask)" 9566 "LI $dst, #1\n\t" 9567 "BEQ $crx, done\n\t" 9568 "LI $dst, #0\n" 9569 "done:" %} 9570 size(16); 9571 ins_encode( enc_convP2B_regP__cmove(dst, src, crx, 0x1, 0x0) ); 9572 ins_pipe(pipe_class_compare); 9573 %} 9574 9575 // if src1 < src2, return -1 else return 0 9576 instruct cmpLTMask_reg_reg_Ex(iRegIdst dst, iRegIsrc src1, iRegIsrc src2) %{ 9577 match(Set dst (CmpLTMask src1 src2)); 9578 ins_cost(DEFAULT_COST*4); 9579 9580 expand %{ 9581 iRegIdst src1s; 9582 iRegIdst src2s; 9583 iRegIdst diff; 9584 sxtI_reg(src1s, src1); // ensure proper sign extention 9585 sxtI_reg(src2s, src2); // ensure proper sign extention 9586 subI_reg_reg(diff, src1s, src2s); 9587 // Need to consider >=33 bit result, therefore we need signmaskL. 9588 signmask64I_regI(dst, diff); 9589 %} 9590 %} 9591 9592 instruct cmpLTMask_reg_immI0(iRegIdst dst, iRegIsrc src1, immI_0 src2) %{ 9593 match(Set dst (CmpLTMask src1 src2)); // if src1 < src2, return -1 else return 0 9594 format %{ "SRAWI $dst, $src1, $src2 \t// CmpLTMask" %} 9595 size(4); 9596 ins_encode %{ 9597 // TODO: PPC port $archOpcode(ppc64Opcode_srawi); 9598 __ srawi($dst$$Register, $src1$$Register, 0x1f); 9599 %} 9600 ins_pipe(pipe_class_default); 9601 %} 9602 9603 //----------Arithmetic Conversion Instructions--------------------------------- 9604 9605 // Convert to Byte -- nop 9606 // Convert to Short -- nop 9607 9608 // Convert to Int 9609 9610 instruct convB2I_reg(iRegIdst dst, iRegIsrc src, immI_24 amount) %{ 9611 match(Set dst (RShiftI (LShiftI src amount) amount)); 9612 format %{ "EXTSB $dst, $src \t// byte->int" %} 9613 size(4); 9614 ins_encode %{ 9615 // TODO: PPC port $archOpcode(ppc64Opcode_extsb); 9616 __ extsb($dst$$Register, $src$$Register); 9617 %} 9618 ins_pipe(pipe_class_default); 9619 %} 9620 9621 // LShiftI 16 + RShiftI 16 converts short to int. 9622 instruct convS2I_reg(iRegIdst dst, iRegIsrc src, immI_16 amount) %{ 9623 match(Set dst (RShiftI (LShiftI src amount) amount)); 9624 format %{ "EXTSH $dst, $src \t// short->int" %} 9625 size(4); 9626 ins_encode %{ 9627 // TODO: PPC port $archOpcode(ppc64Opcode_extsh); 9628 __ extsh($dst$$Register, $src$$Register); 9629 %} 9630 ins_pipe(pipe_class_default); 9631 %} 9632 9633 // ConvL2I + ConvI2L: Sign extend int in long register. 9634 instruct sxtI_L2L_reg(iRegLdst dst, iRegLsrc src) %{ 9635 match(Set dst (ConvI2L (ConvL2I src))); 9636 9637 format %{ "EXTSW $dst, $src \t// long->long" %} 9638 size(4); 9639 ins_encode %{ 9640 // TODO: PPC port $archOpcode(ppc64Opcode_extsw); 9641 __ extsw($dst$$Register, $src$$Register); 9642 %} 9643 ins_pipe(pipe_class_default); 9644 %} 9645 9646 instruct convL2I_reg(iRegIdst dst, iRegLsrc src) %{ 9647 match(Set dst (ConvL2I src)); 9648 format %{ "MR $dst, $src \t// long->int" %} 9649 // variable size, 0 or 4 9650 ins_encode %{ 9651 // TODO: PPC port $archOpcode(ppc64Opcode_or); 9652 __ mr_if_needed($dst$$Register, $src$$Register); 9653 %} 9654 ins_pipe(pipe_class_default); 9655 %} 9656 9657 instruct convD2IRaw_regD(regD dst, regD src) %{ 9658 // no match-rule, false predicate 9659 effect(DEF dst, USE src); 9660 predicate(false); 9661 9662 format %{ "FCTIWZ $dst, $src \t// convD2I, $src != NaN" %} 9663 size(4); 9664 ins_encode %{ 9665 // TODO: PPC port $archOpcode(ppc64Opcode_fctiwz);; 9666 __ fctiwz($dst$$FloatRegister, $src$$FloatRegister); 9667 %} 9668 ins_pipe(pipe_class_default); 9669 %} 9670 9671 instruct cmovI_bso_stackSlotL(iRegIdst dst, flagsReg crx, stackSlotL src) %{ 9672 // no match-rule, false predicate 9673 effect(DEF dst, USE crx, USE src); 9674 predicate(false); 9675 9676 ins_variable_size_depending_on_alignment(true); 9677 9678 format %{ "cmovI $crx, $dst, $src" %} 9679 // Worst case is branch + move + stop, no stop without scheduler. 9680 size(false /* TODO: PPC PORT(InsertEndGroupPPC64 && Compile::current()->do_hb_scheduling())*/ ? 12 : 8); 9681 ins_encode( enc_cmove_bso_stackSlotL(dst, crx, src) ); 9682 ins_pipe(pipe_class_default); 9683 %} 9684 9685 instruct cmovI_bso_stackSlotL_conLvalue0_Ex(iRegIdst dst, flagsReg crx, stackSlotL mem) %{ 9686 // no match-rule, false predicate 9687 effect(DEF dst, USE crx, USE mem); 9688 predicate(false); 9689 9690 format %{ "CmovI $dst, $crx, $mem \t// postalloc expanded" %} 9691 postalloc_expand %{ 9692 // 9693 // replaces 9694 // 9695 // region dst crx mem 9696 // \ | | / 9697 // dst=cmovI_bso_stackSlotL_conLvalue0 9698 // 9699 // with 9700 // 9701 // region dst 9702 // \ / 9703 // dst=loadConI16(0) 9704 // | 9705 // ^ region dst crx mem 9706 // | \ | | / 9707 // dst=cmovI_bso_stackSlotL 9708 // 9709 9710 // Create new nodes. 9711 MachNode *m1 = new (C) loadConI16Node(); 9712 MachNode *m2 = new (C) cmovI_bso_stackSlotLNode(); 9713 9714 // inputs for new nodes 9715 m1->add_req(n_region); 9716 m2->add_req(n_region, n_crx, n_mem); 9717 9718 // precedences for new nodes 9719 m2->add_prec(m1); 9720 9721 // operands for new nodes 9722 m1->_opnds[0] = op_dst; 9723 m1->_opnds[1] = new (C) immI16Oper(0); 9724 9725 m2->_opnds[0] = op_dst; 9726 m2->_opnds[1] = op_crx; 9727 m2->_opnds[2] = op_mem; 9728 9729 // registers for new nodes 9730 ra_->set_pair(m1->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); // dst 9731 ra_->set_pair(m2->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); // dst 9732 9733 // Insert new nodes. 9734 nodes->push(m1); 9735 nodes->push(m2); 9736 %} 9737 %} 9738 9739 // Double to Int conversion, NaN is mapped to 0. 9740 instruct convD2I_reg_ExEx(iRegIdst dst, regD src) %{ 9741 match(Set dst (ConvD2I src)); 9742 ins_cost(DEFAULT_COST); 9743 9744 expand %{ 9745 regD tmpD; 9746 stackSlotL tmpS; 9747 flagsReg crx; 9748 cmpDUnordered_reg_reg(crx, src, src); // Check whether src is NaN. 9749 convD2IRaw_regD(tmpD, src); // Convert float to int (speculated). 9750 moveD2L_reg_stack(tmpS, tmpD); // Store float to stack (speculated). 9751 cmovI_bso_stackSlotL_conLvalue0_Ex(dst, crx, tmpS); // Cmove based on NaN check. 9752 %} 9753 %} 9754 9755 instruct convF2IRaw_regF(regF dst, regF src) %{ 9756 // no match-rule, false predicate 9757 effect(DEF dst, USE src); 9758 predicate(false); 9759 9760 format %{ "FCTIWZ $dst, $src \t// convF2I, $src != NaN" %} 9761 size(4); 9762 ins_encode %{ 9763 // TODO: PPC port $archOpcode(ppc64Opcode_fctiwz); 9764 __ fctiwz($dst$$FloatRegister, $src$$FloatRegister); 9765 %} 9766 ins_pipe(pipe_class_default); 9767 %} 9768 9769 // Float to Int conversion, NaN is mapped to 0. 9770 instruct convF2I_regF_ExEx(iRegIdst dst, regF src) %{ 9771 match(Set dst (ConvF2I src)); 9772 ins_cost(DEFAULT_COST); 9773 9774 expand %{ 9775 regF tmpF; 9776 stackSlotL tmpS; 9777 flagsReg crx; 9778 cmpFUnordered_reg_reg(crx, src, src); // Check whether src is NaN. 9779 convF2IRaw_regF(tmpF, src); // Convert float to int (speculated). 9780 moveF2L_reg_stack(tmpS, tmpF); // Store float to stack (speculated). 9781 cmovI_bso_stackSlotL_conLvalue0_Ex(dst, crx, tmpS); // Cmove based on NaN check. 9782 %} 9783 %} 9784 9785 // Convert to Long 9786 9787 instruct convI2L_reg(iRegLdst dst, iRegIsrc src) %{ 9788 match(Set dst (ConvI2L src)); 9789 format %{ "EXTSW $dst, $src \t// int->long" %} 9790 size(4); 9791 ins_encode %{ 9792 // TODO: PPC port $archOpcode(ppc64Opcode_extsw); 9793 __ extsw($dst$$Register, $src$$Register); 9794 %} 9795 ins_pipe(pipe_class_default); 9796 %} 9797 9798 // Zero-extend: convert unsigned int to long (convUI2L). 9799 instruct zeroExtendL_regI(iRegLdst dst, iRegIsrc src, immL_32bits mask) %{ 9800 match(Set dst (AndL (ConvI2L src) mask)); 9801 ins_cost(DEFAULT_COST); 9802 9803 format %{ "CLRLDI $dst, $src, #32 \t// zero-extend int to long" %} 9804 size(4); 9805 ins_encode %{ 9806 // TODO: PPC port $archOpcode(ppc64Opcode_rldicl); 9807 __ clrldi($dst$$Register, $src$$Register, 32); 9808 %} 9809 ins_pipe(pipe_class_default); 9810 %} 9811 9812 // Zero-extend: convert unsigned int to long in long register. 9813 instruct zeroExtendL_regL(iRegLdst dst, iRegLsrc src, immL_32bits mask) %{ 9814 match(Set dst (AndL src mask)); 9815 ins_cost(DEFAULT_COST); 9816 9817 format %{ "CLRLDI $dst, $src, #32 \t// zero-extend int to long" %} 9818 size(4); 9819 ins_encode %{ 9820 // TODO: PPC port $archOpcode(ppc64Opcode_rldicl); 9821 __ clrldi($dst$$Register, $src$$Register, 32); 9822 %} 9823 ins_pipe(pipe_class_default); 9824 %} 9825 9826 instruct convF2LRaw_regF(regF dst, regF src) %{ 9827 // no match-rule, false predicate 9828 effect(DEF dst, USE src); 9829 predicate(false); 9830 9831 format %{ "FCTIDZ $dst, $src \t// convF2L, $src != NaN" %} 9832 size(4); 9833 ins_encode %{ 9834 // TODO: PPC port $archOpcode(ppc64Opcode_fctiwz); 9835 __ fctidz($dst$$FloatRegister, $src$$FloatRegister); 9836 %} 9837 ins_pipe(pipe_class_default); 9838 %} 9839 9840 instruct cmovL_bso_stackSlotL(iRegLdst dst, flagsReg crx, stackSlotL src) %{ 9841 // no match-rule, false predicate 9842 effect(DEF dst, USE crx, USE src); 9843 predicate(false); 9844 9845 ins_variable_size_depending_on_alignment(true); 9846 9847 format %{ "cmovL $crx, $dst, $src" %} 9848 // Worst case is branch + move + stop, no stop without scheduler. 9849 size(false /* TODO: PPC PORT Compile::current()->do_hb_scheduling()*/ ? 12 : 8); 9850 ins_encode( enc_cmove_bso_stackSlotL(dst, crx, src) ); 9851 ins_pipe(pipe_class_default); 9852 %} 9853 9854 instruct cmovL_bso_stackSlotL_conLvalue0_Ex(iRegLdst dst, flagsReg crx, stackSlotL mem) %{ 9855 // no match-rule, false predicate 9856 effect(DEF dst, USE crx, USE mem); 9857 predicate(false); 9858 9859 format %{ "CmovL $dst, $crx, $mem \t// postalloc expanded" %} 9860 postalloc_expand %{ 9861 // 9862 // replaces 9863 // 9864 // region dst crx mem 9865 // \ | | / 9866 // dst=cmovL_bso_stackSlotL_conLvalue0 9867 // 9868 // with 9869 // 9870 // region dst 9871 // \ / 9872 // dst=loadConL16(0) 9873 // | 9874 // ^ region dst crx mem 9875 // | \ | | / 9876 // dst=cmovL_bso_stackSlotL 9877 // 9878 9879 // Create new nodes. 9880 MachNode *m1 = new (C) loadConL16Node(); 9881 MachNode *m2 = new (C) cmovL_bso_stackSlotLNode(); 9882 9883 // inputs for new nodes 9884 m1->add_req(n_region); 9885 m2->add_req(n_region, n_crx, n_mem); 9886 m2->add_prec(m1); 9887 9888 // operands for new nodes 9889 m1->_opnds[0] = op_dst; 9890 m1->_opnds[1] = new (C) immL16Oper(0); 9891 m2->_opnds[0] = op_dst; 9892 m2->_opnds[1] = op_crx; 9893 m2->_opnds[2] = op_mem; 9894 9895 // registers for new nodes 9896 ra_->set_pair(m1->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); // dst 9897 ra_->set_pair(m2->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); // dst 9898 9899 // Insert new nodes. 9900 nodes->push(m1); 9901 nodes->push(m2); 9902 %} 9903 %} 9904 9905 // Float to Long conversion, NaN is mapped to 0. 9906 instruct convF2L_reg_ExEx(iRegLdst dst, regF src) %{ 9907 match(Set dst (ConvF2L src)); 9908 ins_cost(DEFAULT_COST); 9909 9910 expand %{ 9911 regF tmpF; 9912 stackSlotL tmpS; 9913 flagsReg crx; 9914 cmpFUnordered_reg_reg(crx, src, src); // Check whether src is NaN. 9915 convF2LRaw_regF(tmpF, src); // Convert float to long (speculated). 9916 moveF2L_reg_stack(tmpS, tmpF); // Store float to stack (speculated). 9917 cmovL_bso_stackSlotL_conLvalue0_Ex(dst, crx, tmpS); // Cmove based on NaN check. 9918 %} 9919 %} 9920 9921 instruct convD2LRaw_regD(regD dst, regD src) %{ 9922 // no match-rule, false predicate 9923 effect(DEF dst, USE src); 9924 predicate(false); 9925 9926 format %{ "FCTIDZ $dst, $src \t// convD2L $src != NaN" %} 9927 size(4); 9928 ins_encode %{ 9929 // TODO: PPC port $archOpcode(ppc64Opcode_fctiwz); 9930 __ fctidz($dst$$FloatRegister, $src$$FloatRegister); 9931 %} 9932 ins_pipe(pipe_class_default); 9933 %} 9934 9935 // Double to Long conversion, NaN is mapped to 0. 9936 instruct convD2L_reg_ExEx(iRegLdst dst, regD src) %{ 9937 match(Set dst (ConvD2L src)); 9938 ins_cost(DEFAULT_COST); 9939 9940 expand %{ 9941 regD tmpD; 9942 stackSlotL tmpS; 9943 flagsReg crx; 9944 cmpDUnordered_reg_reg(crx, src, src); // Check whether src is NaN. 9945 convD2LRaw_regD(tmpD, src); // Convert float to long (speculated). 9946 moveD2L_reg_stack(tmpS, tmpD); // Store float to stack (speculated). 9947 cmovL_bso_stackSlotL_conLvalue0_Ex(dst, crx, tmpS); // Cmove based on NaN check. 9948 %} 9949 %} 9950 9951 // Convert to Float 9952 9953 // Placed here as needed in expand. 9954 instruct convL2DRaw_regD(regD dst, regD src) %{ 9955 // no match-rule, false predicate 9956 effect(DEF dst, USE src); 9957 predicate(false); 9958 9959 format %{ "FCFID $dst, $src \t// convL2D" %} 9960 size(4); 9961 ins_encode %{ 9962 // TODO: PPC port $archOpcode(ppc64Opcode_fcfid); 9963 __ fcfid($dst$$FloatRegister, $src$$FloatRegister); 9964 %} 9965 ins_pipe(pipe_class_default); 9966 %} 9967 9968 // Placed here as needed in expand. 9969 instruct convD2F_reg(regF dst, regD src) %{ 9970 match(Set dst (ConvD2F src)); 9971 format %{ "FRSP $dst, $src \t// convD2F" %} 9972 size(4); 9973 ins_encode %{ 9974 // TODO: PPC port $archOpcode(ppc64Opcode_frsp); 9975 __ frsp($dst$$FloatRegister, $src$$FloatRegister); 9976 %} 9977 ins_pipe(pipe_class_default); 9978 %} 9979 9980 // Integer to Float conversion. 9981 instruct convI2F_ireg_Ex(regF dst, iRegIsrc src) %{ 9982 match(Set dst (ConvI2F src)); 9983 predicate(!VM_Version::has_fcfids()); 9984 ins_cost(DEFAULT_COST); 9985 9986 expand %{ 9987 iRegLdst tmpL; 9988 stackSlotL tmpS; 9989 regD tmpD; 9990 regD tmpD2; 9991 convI2L_reg(tmpL, src); // Sign-extension int to long. 9992 regL_to_stkL(tmpS, tmpL); // Store long to stack. 9993 moveL2D_stack_reg(tmpD, tmpS); // Load long into double register. 9994 convL2DRaw_regD(tmpD2, tmpD); // Convert to double. 9995 convD2F_reg(dst, tmpD2); // Convert double to float. 9996 %} 9997 %} 9998 9999 instruct convL2FRaw_regF(regF dst, regD src) %{ 10000 // no match-rule, false predicate 10001 effect(DEF dst, USE src); 10002 predicate(false); 10003 10004 format %{ "FCFIDS $dst, $src \t// convL2F" %} 10005 size(4); 10006 ins_encode %{ 10007 // TODO: PPC port $archOpcode(ppc64Opcode_fcfid); 10008 __ fcfids($dst$$FloatRegister, $src$$FloatRegister); 10009 %} 10010 ins_pipe(pipe_class_default); 10011 %} 10012 10013 // Integer to Float conversion. Special version for Power7. 10014 instruct convI2F_ireg_fcfids_Ex(regF dst, iRegIsrc src) %{ 10015 match(Set dst (ConvI2F src)); 10016 predicate(VM_Version::has_fcfids()); 10017 ins_cost(DEFAULT_COST); 10018 10019 expand %{ 10020 iRegLdst tmpL; 10021 stackSlotL tmpS; 10022 regD tmpD; 10023 convI2L_reg(tmpL, src); // Sign-extension int to long. 10024 regL_to_stkL(tmpS, tmpL); // Store long to stack. 10025 moveL2D_stack_reg(tmpD, tmpS); // Load long into double register. 10026 convL2FRaw_regF(dst, tmpD); // Convert to float. 10027 %} 10028 %} 10029 10030 // L2F to avoid runtime call. 10031 instruct convL2F_ireg_fcfids_Ex(regF dst, iRegLsrc src) %{ 10032 match(Set dst (ConvL2F src)); 10033 predicate(VM_Version::has_fcfids()); 10034 ins_cost(DEFAULT_COST); 10035 10036 expand %{ 10037 stackSlotL tmpS; 10038 regD tmpD; 10039 regL_to_stkL(tmpS, src); // Store long to stack. 10040 moveL2D_stack_reg(tmpD, tmpS); // Load long into double register. 10041 convL2FRaw_regF(dst, tmpD); // Convert to float. 10042 %} 10043 %} 10044 10045 // Moved up as used in expand. 10046 //instruct convD2F_reg(regF dst, regD src) %{%} 10047 10048 // Convert to Double 10049 10050 // Integer to Double conversion. 10051 instruct convI2D_reg_Ex(regD dst, iRegIsrc src) %{ 10052 match(Set dst (ConvI2D src)); 10053 ins_cost(DEFAULT_COST); 10054 10055 expand %{ 10056 iRegLdst tmpL; 10057 stackSlotL tmpS; 10058 regD tmpD; 10059 convI2L_reg(tmpL, src); // Sign-extension int to long. 10060 regL_to_stkL(tmpS, tmpL); // Store long to stack. 10061 moveL2D_stack_reg(tmpD, tmpS); // Load long into double register. 10062 convL2DRaw_regD(dst, tmpD); // Convert to double. 10063 %} 10064 %} 10065 10066 // Long to Double conversion 10067 instruct convL2D_reg_Ex(regD dst, stackSlotL src) %{ 10068 match(Set dst (ConvL2D src)); 10069 ins_cost(DEFAULT_COST + MEMORY_REF_COST); 10070 10071 expand %{ 10072 regD tmpD; 10073 moveL2D_stack_reg(tmpD, src); 10074 convL2DRaw_regD(dst, tmpD); 10075 %} 10076 %} 10077 10078 instruct convF2D_reg(regD dst, regF src) %{ 10079 match(Set dst (ConvF2D src)); 10080 format %{ "FMR $dst, $src \t// float->double" %} 10081 // variable size, 0 or 4 10082 ins_encode %{ 10083 // TODO: PPC port $archOpcode(ppc64Opcode_fmr); 10084 __ fmr_if_needed($dst$$FloatRegister, $src$$FloatRegister); 10085 %} 10086 ins_pipe(pipe_class_default); 10087 %} 10088 10089 //----------Control Flow Instructions------------------------------------------ 10090 // Compare Instructions 10091 10092 // Compare Integers 10093 instruct cmpI_reg_reg(flagsReg crx, iRegIsrc src1, iRegIsrc src2) %{ 10094 match(Set crx (CmpI src1 src2)); 10095 size(4); 10096 format %{ "CMPW $crx, $src1, $src2" %} 10097 ins_encode %{ 10098 // TODO: PPC port $archOpcode(ppc64Opcode_cmp); 10099 __ cmpw($crx$$CondRegister, $src1$$Register, $src2$$Register); 10100 %} 10101 ins_pipe(pipe_class_compare); 10102 %} 10103 10104 instruct cmpI_reg_imm16(flagsReg crx, iRegIsrc src1, immI16 src2) %{ 10105 match(Set crx (CmpI src1 src2)); 10106 format %{ "CMPWI $crx, $src1, $src2" %} 10107 size(4); 10108 ins_encode %{ 10109 // TODO: PPC port $archOpcode(ppc64Opcode_cmpi); 10110 __ cmpwi($crx$$CondRegister, $src1$$Register, $src2$$constant); 10111 %} 10112 ins_pipe(pipe_class_compare); 10113 %} 10114 10115 // (src1 & src2) == 0? 10116 instruct testI_reg_imm(flagsRegCR0 cr0, iRegIsrc src1, uimmI16 src2, immI_0 zero) %{ 10117 match(Set cr0 (CmpI (AndI src1 src2) zero)); 10118 // r0 is killed 10119 format %{ "ANDI R0, $src1, $src2 \t// BTST int" %} 10120 size(4); 10121 ins_encode %{ 10122 // TODO: PPC port $archOpcode(ppc64Opcode_andi_); 10123 // FIXME: avoid andi_ ? 10124 __ andi_(R0, $src1$$Register, $src2$$constant); 10125 %} 10126 ins_pipe(pipe_class_compare); 10127 %} 10128 10129 instruct cmpL_reg_reg(flagsReg crx, iRegLsrc src1, iRegLsrc src2) %{ 10130 match(Set crx (CmpL src1 src2)); 10131 format %{ "CMPD $crx, $src1, $src2" %} 10132 size(4); 10133 ins_encode %{ 10134 // TODO: PPC port $archOpcode(ppc64Opcode_cmp); 10135 __ cmpd($crx$$CondRegister, $src1$$Register, $src2$$Register); 10136 %} 10137 ins_pipe(pipe_class_compare); 10138 %} 10139 10140 instruct cmpL_reg_imm16(flagsReg crx, iRegLsrc src1, immL16 src2) %{ 10141 match(Set crx (CmpL src1 src2)); 10142 format %{ "CMPDI $crx, $src1, $src2" %} 10143 size(4); 10144 ins_encode %{ 10145 // TODO: PPC port $archOpcode(ppc64Opcode_cmpi); 10146 __ cmpdi($crx$$CondRegister, $src1$$Register, $src2$$constant); 10147 %} 10148 ins_pipe(pipe_class_compare); 10149 %} 10150 10151 instruct testL_reg_reg(flagsRegCR0 cr0, iRegLsrc src1, iRegLsrc src2, immL_0 zero) %{ 10152 match(Set cr0 (CmpL (AndL src1 src2) zero)); 10153 // r0 is killed 10154 format %{ "AND R0, $src1, $src2 \t// BTST long" %} 10155 size(4); 10156 ins_encode %{ 10157 // TODO: PPC port $archOpcode(ppc64Opcode_and_); 10158 __ and_(R0, $src1$$Register, $src2$$Register); 10159 %} 10160 ins_pipe(pipe_class_compare); 10161 %} 10162 10163 instruct testL_reg_imm(flagsRegCR0 cr0, iRegLsrc src1, uimmL16 src2, immL_0 zero) %{ 10164 match(Set cr0 (CmpL (AndL src1 src2) zero)); 10165 // r0 is killed 10166 format %{ "ANDI R0, $src1, $src2 \t// BTST long" %} 10167 size(4); 10168 ins_encode %{ 10169 // TODO: PPC port $archOpcode(ppc64Opcode_andi_); 10170 // FIXME: avoid andi_ ? 10171 __ andi_(R0, $src1$$Register, $src2$$constant); 10172 %} 10173 ins_pipe(pipe_class_compare); 10174 %} 10175 10176 instruct cmovI_conIvalueMinus1_conIvalue1(iRegIdst dst, flagsReg crx) %{ 10177 // no match-rule, false predicate 10178 effect(DEF dst, USE crx); 10179 predicate(false); 10180 10181 ins_variable_size_depending_on_alignment(true); 10182 10183 format %{ "cmovI $crx, $dst, -1, 0, +1" %} 10184 // Worst case is branch + move + branch + move + stop, no stop without scheduler. 10185 size(false /* TODO: PPC PORTInsertEndGroupPPC64 && Compile::current()->do_hb_scheduling())*/ ? 20 : 16); 10186 ins_encode %{ 10187 // TODO: PPC port $archOpcode(ppc64Opcode_cmove); 10188 Label done; 10189 // li(Rdst, 0); // equal -> 0 10190 __ beq($crx$$CondRegister, done); 10191 __ li($dst$$Register, 1); // greater -> +1 10192 __ bgt($crx$$CondRegister, done); 10193 __ li($dst$$Register, -1); // unordered or less -> -1 10194 // TODO: PPC port__ endgroup_if_needed(_size == 20); 10195 __ bind(done); 10196 %} 10197 ins_pipe(pipe_class_compare); 10198 %} 10199 10200 instruct cmovI_conIvalueMinus1_conIvalue0_conIvalue1_Ex(iRegIdst dst, flagsReg crx) %{ 10201 // no match-rule, false predicate 10202 effect(DEF dst, USE crx); 10203 predicate(false); 10204 10205 format %{ "CmovI $crx, $dst, -1, 0, +1 \t// postalloc expanded" %} 10206 postalloc_expand %{ 10207 // 10208 // replaces 10209 // 10210 // region crx 10211 // \ | 10212 // dst=cmovI_conIvalueMinus1_conIvalue0_conIvalue1 10213 // 10214 // with 10215 // 10216 // region 10217 // \ 10218 // dst=loadConI16(0) 10219 // | 10220 // ^ region crx 10221 // | \ | 10222 // dst=cmovI_conIvalueMinus1_conIvalue1 10223 // 10224 10225 // Create new nodes. 10226 MachNode *m1 = new (C) loadConI16Node(); 10227 MachNode *m2 = new (C) cmovI_conIvalueMinus1_conIvalue1Node(); 10228 10229 // inputs for new nodes 10230 m1->add_req(n_region); 10231 m2->add_req(n_region, n_crx); 10232 m2->add_prec(m1); 10233 10234 // operands for new nodes 10235 m1->_opnds[0] = op_dst; 10236 m1->_opnds[1] = new (C) immI16Oper(0); 10237 m2->_opnds[0] = op_dst; 10238 m2->_opnds[1] = op_crx; 10239 10240 // registers for new nodes 10241 ra_->set_pair(m1->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); // dst 10242 ra_->set_pair(m2->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); // dst 10243 10244 // Insert new nodes. 10245 nodes->push(m1); 10246 nodes->push(m2); 10247 %} 10248 %} 10249 10250 // Manifest a CmpL3 result in an integer register. Very painful. 10251 // This is the test to avoid. 10252 // (src1 < src2) ? -1 : ((src1 > src2) ? 1 : 0) 10253 instruct cmpL3_reg_reg_ExEx(iRegIdst dst, iRegLsrc src1, iRegLsrc src2) %{ 10254 match(Set dst (CmpL3 src1 src2)); 10255 ins_cost(DEFAULT_COST*5+BRANCH_COST); 10256 10257 expand %{ 10258 flagsReg tmp1; 10259 cmpL_reg_reg(tmp1, src1, src2); 10260 cmovI_conIvalueMinus1_conIvalue0_conIvalue1_Ex(dst, tmp1); 10261 %} 10262 %} 10263 10264 // Implicit range checks. 10265 // A range check in the ideal world has one of the following shapes: 10266 // - (If le (CmpU length index)), (IfTrue throw exception) 10267 // - (If lt (CmpU index length)), (IfFalse throw exception) 10268 // 10269 // Match range check 'If le (CmpU length index)'. 10270 instruct rangeCheck_iReg_uimm15(cmpOp cmp, iRegIsrc src_length, uimmI15 index, label labl) %{ 10271 match(If cmp (CmpU src_length index)); 10272 effect(USE labl); 10273 predicate(TrapBasedRangeChecks && 10274 _kids[0]->_leaf->as_Bool()->_test._test == BoolTest::le && 10275 PROB_UNLIKELY(_leaf->as_If()->_prob) >= PROB_ALWAYS && 10276 (Matcher::branches_to_uncommon_trap(_leaf))); 10277 10278 ins_is_TrapBasedCheckNode(true); 10279 10280 format %{ "TWI $index $cmp $src_length \t// RangeCheck => trap $labl" %} 10281 size(4); 10282 ins_encode %{ 10283 // TODO: PPC port $archOpcode(ppc64Opcode_twi); 10284 if ($cmp$$cmpcode == 0x1 /* less_equal */) { 10285 __ trap_range_check_le($src_length$$Register, $index$$constant); 10286 } else { 10287 // Both successors are uncommon traps, probability is 0. 10288 // Node got flipped during fixup flow. 10289 assert($cmp$$cmpcode == 0x9, "must be greater"); 10290 __ trap_range_check_g($src_length$$Register, $index$$constant); 10291 } 10292 %} 10293 ins_pipe(pipe_class_trap); 10294 %} 10295 10296 // Match range check 'If lt (CmpU index length)'. 10297 instruct rangeCheck_iReg_iReg(cmpOp cmp, iRegIsrc src_index, iRegIsrc src_length, label labl) %{ 10298 match(If cmp (CmpU src_index src_length)); 10299 effect(USE labl); 10300 predicate(TrapBasedRangeChecks && 10301 _kids[0]->_leaf->as_Bool()->_test._test == BoolTest::lt && 10302 _leaf->as_If()->_prob >= PROB_ALWAYS && 10303 (Matcher::branches_to_uncommon_trap(_leaf))); 10304 10305 ins_is_TrapBasedCheckNode(true); 10306 10307 format %{ "TW $src_index $cmp $src_length \t// RangeCheck => trap $labl" %} 10308 size(4); 10309 ins_encode %{ 10310 // TODO: PPC port $archOpcode(ppc64Opcode_tw); 10311 if ($cmp$$cmpcode == 0x0 /* greater_equal */) { 10312 __ trap_range_check_ge($src_index$$Register, $src_length$$Register); 10313 } else { 10314 // Both successors are uncommon traps, probability is 0. 10315 // Node got flipped during fixup flow. 10316 assert($cmp$$cmpcode == 0x8, "must be less"); 10317 __ trap_range_check_l($src_index$$Register, $src_length$$Register); 10318 } 10319 %} 10320 ins_pipe(pipe_class_trap); 10321 %} 10322 10323 // Match range check 'If lt (CmpU index length)'. 10324 instruct rangeCheck_uimm15_iReg(cmpOp cmp, iRegIsrc src_index, uimmI15 length, label labl) %{ 10325 match(If cmp (CmpU src_index length)); 10326 effect(USE labl); 10327 predicate(TrapBasedRangeChecks && 10328 _kids[0]->_leaf->as_Bool()->_test._test == BoolTest::lt && 10329 _leaf->as_If()->_prob >= PROB_ALWAYS && 10330 (Matcher::branches_to_uncommon_trap(_leaf))); 10331 10332 ins_is_TrapBasedCheckNode(true); 10333 10334 format %{ "TWI $src_index $cmp $length \t// RangeCheck => trap $labl" %} 10335 size(4); 10336 ins_encode %{ 10337 // TODO: PPC port $archOpcode(ppc64Opcode_twi); 10338 if ($cmp$$cmpcode == 0x0 /* greater_equal */) { 10339 __ trap_range_check_ge($src_index$$Register, $length$$constant); 10340 } else { 10341 // Both successors are uncommon traps, probability is 0. 10342 // Node got flipped during fixup flow. 10343 assert($cmp$$cmpcode == 0x8, "must be less"); 10344 __ trap_range_check_l($src_index$$Register, $length$$constant); 10345 } 10346 %} 10347 ins_pipe(pipe_class_trap); 10348 %} 10349 10350 instruct compU_reg_reg(flagsReg crx, iRegIsrc src1, iRegIsrc src2) %{ 10351 match(Set crx (CmpU src1 src2)); 10352 format %{ "CMPLW $crx, $src1, $src2 \t// unsigned" %} 10353 size(4); 10354 ins_encode %{ 10355 // TODO: PPC port $archOpcode(ppc64Opcode_cmpl); 10356 __ cmplw($crx$$CondRegister, $src1$$Register, $src2$$Register); 10357 %} 10358 ins_pipe(pipe_class_compare); 10359 %} 10360 10361 instruct compU_reg_uimm16(flagsReg crx, iRegIsrc src1, uimmI16 src2) %{ 10362 match(Set crx (CmpU src1 src2)); 10363 size(4); 10364 format %{ "CMPLWI $crx, $src1, $src2" %} 10365 ins_encode %{ 10366 // TODO: PPC port $archOpcode(ppc64Opcode_cmpli); 10367 __ cmplwi($crx$$CondRegister, $src1$$Register, $src2$$constant); 10368 %} 10369 ins_pipe(pipe_class_compare); 10370 %} 10371 10372 // Implicit zero checks (more implicit null checks). 10373 // No constant pool entries required. 10374 instruct zeroCheckN_iReg_imm0(cmpOp cmp, iRegNsrc value, immN_0 zero, label labl) %{ 10375 match(If cmp (CmpN value zero)); 10376 effect(USE labl); 10377 predicate(TrapBasedNullChecks && 10378 _kids[0]->_leaf->as_Bool()->_test._test == BoolTest::ne && 10379 _leaf->as_If()->_prob >= PROB_LIKELY_MAG(4) && 10380 Matcher::branches_to_uncommon_trap(_leaf)); 10381 ins_cost(1); 10382 10383 ins_is_TrapBasedCheckNode(true); 10384 10385 format %{ "TDI $value $cmp $zero \t// ZeroCheckN => trap $labl" %} 10386 size(4); 10387 ins_encode %{ 10388 // TODO: PPC port $archOpcode(ppc64Opcode_tdi); 10389 if ($cmp$$cmpcode == 0xA) { 10390 __ trap_null_check($value$$Register); 10391 } else { 10392 // Both successors are uncommon traps, probability is 0. 10393 // Node got flipped during fixup flow. 10394 assert($cmp$$cmpcode == 0x2 , "must be equal(0xA) or notEqual(0x2)"); 10395 __ trap_null_check($value$$Register, Assembler::traptoGreaterThanUnsigned); 10396 } 10397 %} 10398 ins_pipe(pipe_class_trap); 10399 %} 10400 10401 // Compare narrow oops. 10402 instruct cmpN_reg_reg(flagsReg crx, iRegNsrc src1, iRegNsrc src2) %{ 10403 match(Set crx (CmpN src1 src2)); 10404 10405 size(4); 10406 ins_cost(DEFAULT_COST); 10407 format %{ "CMPLW $crx, $src1, $src2 \t// compressed ptr" %} 10408 ins_encode %{ 10409 // TODO: PPC port $archOpcode(ppc64Opcode_cmpl); 10410 __ cmplw($crx$$CondRegister, $src1$$Register, $src2$$Register); 10411 %} 10412 ins_pipe(pipe_class_compare); 10413 %} 10414 10415 instruct cmpN_reg_imm0(flagsReg crx, iRegNsrc src1, immN_0 src2) %{ 10416 match(Set crx (CmpN src1 src2)); 10417 // Make this more expensive than zeroCheckN_iReg_imm0. 10418 ins_cost(DEFAULT_COST); 10419 10420 format %{ "CMPLWI $crx, $src1, $src2 \t// compressed ptr" %} 10421 size(4); 10422 ins_encode %{ 10423 // TODO: PPC port $archOpcode(ppc64Opcode_cmpli); 10424 __ cmplwi($crx$$CondRegister, $src1$$Register, $src2$$constant); 10425 %} 10426 ins_pipe(pipe_class_compare); 10427 %} 10428 10429 // Implicit zero checks (more implicit null checks). 10430 // No constant pool entries required. 10431 instruct zeroCheckP_reg_imm0(cmpOp cmp, iRegP_N2P value, immP_0 zero, label labl) %{ 10432 match(If cmp (CmpP value zero)); 10433 effect(USE labl); 10434 predicate(TrapBasedNullChecks && 10435 _kids[0]->_leaf->as_Bool()->_test._test == BoolTest::ne && 10436 _leaf->as_If()->_prob >= PROB_LIKELY_MAG(4) && 10437 Matcher::branches_to_uncommon_trap(_leaf)); 10438 10439 ins_is_TrapBasedCheckNode(true); 10440 10441 format %{ "TDI $value $cmp $zero \t// ZeroCheckP => trap $labl" %} 10442 size(4); 10443 ins_encode %{ 10444 // TODO: PPC port $archOpcode(ppc64Opcode_tdi); 10445 if ($cmp$$cmpcode == 0xA) { 10446 __ trap_null_check($value$$Register); 10447 } else { 10448 // Both successors are uncommon traps, probability is 0. 10449 // Node got flipped during fixup flow. 10450 assert($cmp$$cmpcode == 0x2 , "must be equal(0xA) or notEqual(0x2)"); 10451 __ trap_null_check($value$$Register, Assembler::traptoGreaterThanUnsigned); 10452 } 10453 %} 10454 ins_pipe(pipe_class_trap); 10455 %} 10456 10457 // Compare Pointers 10458 instruct cmpP_reg_reg(flagsReg crx, iRegP_N2P src1, iRegP_N2P src2) %{ 10459 match(Set crx (CmpP src1 src2)); 10460 format %{ "CMPLD $crx, $src1, $src2 \t// ptr" %} 10461 size(4); 10462 ins_encode %{ 10463 // TODO: PPC port $archOpcode(ppc64Opcode_cmpl); 10464 __ cmpld($crx$$CondRegister, $src1$$Register, $src2$$Register); 10465 %} 10466 ins_pipe(pipe_class_compare); 10467 %} 10468 10469 // Used in postalloc expand. 10470 instruct cmpP_reg_imm16(flagsReg crx, iRegPsrc src1, immL16 src2) %{ 10471 // This match rule prevents reordering of node before a safepoint. 10472 // This only makes sense if this instructions is used exclusively 10473 // for the expansion of EncodeP! 10474 match(Set crx (CmpP src1 src2)); 10475 predicate(false); 10476 10477 format %{ "CMPDI $crx, $src1, $src2" %} 10478 size(4); 10479 ins_encode %{ 10480 // TODO: PPC port $archOpcode(ppc64Opcode_cmpi); 10481 __ cmpdi($crx$$CondRegister, $src1$$Register, $src2$$constant); 10482 %} 10483 ins_pipe(pipe_class_compare); 10484 %} 10485 10486 //----------Float Compares---------------------------------------------------- 10487 10488 instruct cmpFUnordered_reg_reg(flagsReg crx, regF src1, regF src2) %{ 10489 // no match-rule, false predicate 10490 effect(DEF crx, USE src1, USE src2); 10491 predicate(false); 10492 10493 format %{ "cmpFUrd $crx, $src1, $src2" %} 10494 size(4); 10495 ins_encode %{ 10496 // TODO: PPC port $archOpcode(ppc64Opcode_fcmpu); 10497 __ fcmpu($crx$$CondRegister, $src1$$FloatRegister, $src2$$FloatRegister); 10498 %} 10499 ins_pipe(pipe_class_default); 10500 %} 10501 10502 instruct cmov_bns_less(flagsReg crx) %{ 10503 // no match-rule, false predicate 10504 effect(DEF crx); 10505 predicate(false); 10506 10507 ins_variable_size_depending_on_alignment(true); 10508 10509 format %{ "cmov $crx" %} 10510 // Worst case is branch + move + stop, no stop without scheduler. 10511 size(false /* TODO: PPC PORT(InsertEndGroupPPC64 && Compile::current()->do_hb_scheduling())*/ ? 16 : 12); 10512 ins_encode %{ 10513 // TODO: PPC port $archOpcode(ppc64Opcode_cmovecr); 10514 Label done; 10515 __ bns($crx$$CondRegister, done); // not unordered -> keep crx 10516 __ li(R0, 0); 10517 __ cmpwi($crx$$CondRegister, R0, 1); // unordered -> set crx to 'less' 10518 // TODO PPC port __ endgroup_if_needed(_size == 16); 10519 __ bind(done); 10520 %} 10521 ins_pipe(pipe_class_default); 10522 %} 10523 10524 // Compare floating, generate condition code. 10525 instruct cmpF_reg_reg_Ex(flagsReg crx, regF src1, regF src2) %{ 10526 // FIXME: should we match 'If cmp (CmpF src1 src2))' ?? 10527 // 10528 // The following code sequence occurs a lot in mpegaudio: 10529 // 10530 // block BXX: 10531 // 0: instruct cmpFUnordered_reg_reg (cmpF_reg_reg-0): 10532 // cmpFUrd CCR6, F11, F9 10533 // 4: instruct cmov_bns_less (cmpF_reg_reg-1): 10534 // cmov CCR6 10535 // 8: instruct branchConSched: 10536 // B_FARle CCR6, B56 P=0.500000 C=-1.000000 10537 match(Set crx (CmpF src1 src2)); 10538 ins_cost(DEFAULT_COST+BRANCH_COST); 10539 10540 format %{ "CmpF $crx, $src1, $src2 \t// postalloc expanded" %} 10541 postalloc_expand %{ 10542 // 10543 // replaces 10544 // 10545 // region src1 src2 10546 // \ | | 10547 // crx=cmpF_reg_reg 10548 // 10549 // with 10550 // 10551 // region src1 src2 10552 // \ | | 10553 // crx=cmpFUnordered_reg_reg 10554 // | 10555 // ^ region 10556 // | \ 10557 // crx=cmov_bns_less 10558 // 10559 10560 // Create new nodes. 10561 MachNode *m1 = new (C) cmpFUnordered_reg_regNode(); 10562 MachNode *m2 = new (C) cmov_bns_lessNode(); 10563 10564 // inputs for new nodes 10565 m1->add_req(n_region, n_src1, n_src2); 10566 m2->add_req(n_region); 10567 m2->add_prec(m1); 10568 10569 // operands for new nodes 10570 m1->_opnds[0] = op_crx; 10571 m1->_opnds[1] = op_src1; 10572 m1->_opnds[2] = op_src2; 10573 m2->_opnds[0] = op_crx; 10574 10575 // registers for new nodes 10576 ra_->set_pair(m1->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); // crx 10577 ra_->set_pair(m2->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); // crx 10578 10579 // Insert new nodes. 10580 nodes->push(m1); 10581 nodes->push(m2); 10582 %} 10583 %} 10584 10585 // Compare float, generate -1,0,1 10586 instruct cmpF3_reg_reg_ExEx(iRegIdst dst, regF src1, regF src2) %{ 10587 match(Set dst (CmpF3 src1 src2)); 10588 ins_cost(DEFAULT_COST*5+BRANCH_COST); 10589 10590 expand %{ 10591 flagsReg tmp1; 10592 cmpFUnordered_reg_reg(tmp1, src1, src2); 10593 cmovI_conIvalueMinus1_conIvalue0_conIvalue1_Ex(dst, tmp1); 10594 %} 10595 %} 10596 10597 instruct cmpDUnordered_reg_reg(flagsReg crx, regD src1, regD src2) %{ 10598 // no match-rule, false predicate 10599 effect(DEF crx, USE src1, USE src2); 10600 predicate(false); 10601 10602 format %{ "cmpFUrd $crx, $src1, $src2" %} 10603 size(4); 10604 ins_encode %{ 10605 // TODO: PPC port $archOpcode(ppc64Opcode_fcmpu); 10606 __ fcmpu($crx$$CondRegister, $src1$$FloatRegister, $src2$$FloatRegister); 10607 %} 10608 ins_pipe(pipe_class_default); 10609 %} 10610 10611 instruct cmpD_reg_reg_Ex(flagsReg crx, regD src1, regD src2) %{ 10612 match(Set crx (CmpD src1 src2)); 10613 ins_cost(DEFAULT_COST+BRANCH_COST); 10614 10615 format %{ "CmpD $crx, $src1, $src2 \t// postalloc expanded" %} 10616 postalloc_expand %{ 10617 // 10618 // replaces 10619 // 10620 // region src1 src2 10621 // \ | | 10622 // crx=cmpD_reg_reg 10623 // 10624 // with 10625 // 10626 // region src1 src2 10627 // \ | | 10628 // crx=cmpDUnordered_reg_reg 10629 // | 10630 // ^ region 10631 // | \ 10632 // crx=cmov_bns_less 10633 // 10634 10635 // create new nodes 10636 MachNode *m1 = new (C) cmpDUnordered_reg_regNode(); 10637 MachNode *m2 = new (C) cmov_bns_lessNode(); 10638 10639 // inputs for new nodes 10640 m1->add_req(n_region, n_src1, n_src2); 10641 m2->add_req(n_region); 10642 m2->add_prec(m1); 10643 10644 // operands for new nodes 10645 m1->_opnds[0] = op_crx; 10646 m1->_opnds[1] = op_src1; 10647 m1->_opnds[2] = op_src2; 10648 m2->_opnds[0] = op_crx; 10649 10650 // registers for new nodes 10651 ra_->set_pair(m1->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); // crx 10652 ra_->set_pair(m2->_idx, ra_->get_reg_second(this), ra_->get_reg_first(this)); // crx 10653 10654 // Insert new nodes. 10655 nodes->push(m1); 10656 nodes->push(m2); 10657 %} 10658 %} 10659 10660 // Compare double, generate -1,0,1 10661 instruct cmpD3_reg_reg_ExEx(iRegIdst dst, regD src1, regD src2) %{ 10662 match(Set dst (CmpD3 src1 src2)); 10663 ins_cost(DEFAULT_COST*5+BRANCH_COST); 10664 10665 expand %{ 10666 flagsReg tmp1; 10667 cmpDUnordered_reg_reg(tmp1, src1, src2); 10668 cmovI_conIvalueMinus1_conIvalue0_conIvalue1_Ex(dst, tmp1); 10669 %} 10670 %} 10671 10672 //----------Branches--------------------------------------------------------- 10673 // Jump 10674 10675 // Direct Branch. 10676 instruct branch(label labl) %{ 10677 match(Goto); 10678 effect(USE labl); 10679 ins_cost(BRANCH_COST); 10680 10681 format %{ "B $labl" %} 10682 size(4); 10683 ins_encode %{ 10684 // TODO: PPC port $archOpcode(ppc64Opcode_b); 10685 Label d; // dummy 10686 __ bind(d); 10687 Label* p = $labl$$label; 10688 // `p' is `NULL' when this encoding class is used only to 10689 // determine the size of the encoded instruction. 10690 Label& l = (NULL == p)? d : *(p); 10691 __ b(l); 10692 %} 10693 ins_pipe(pipe_class_default); 10694 %} 10695 10696 // Conditional Near Branch 10697 instruct branchCon(cmpOp cmp, flagsReg crx, label lbl) %{ 10698 // Same match rule as `branchConFar'. 10699 match(If cmp crx); 10700 effect(USE lbl); 10701 ins_cost(BRANCH_COST); 10702 10703 // If set to 1 this indicates that the current instruction is a 10704 // short variant of a long branch. This avoids using this 10705 // instruction in first-pass matching. It will then only be used in 10706 // the `Shorten_branches' pass. 10707 ins_short_branch(1); 10708 10709 format %{ "B$cmp $crx, $lbl" %} 10710 size(4); 10711 ins_encode( enc_bc(crx, cmp, lbl) ); 10712 ins_pipe(pipe_class_default); 10713 %} 10714 10715 // This is for cases when the ppc64 `bc' instruction does not 10716 // reach far enough. So we emit a far branch here, which is more 10717 // expensive. 10718 // 10719 // Conditional Far Branch 10720 instruct branchConFar(cmpOp cmp, flagsReg crx, label lbl) %{ 10721 // Same match rule as `branchCon'. 10722 match(If cmp crx); 10723 effect(USE crx, USE lbl); 10724 predicate(!false /* TODO: PPC port HB_Schedule*/); 10725 // Higher cost than `branchCon'. 10726 ins_cost(5*BRANCH_COST); 10727 10728 // This is not a short variant of a branch, but the long variant. 10729 ins_short_branch(0); 10730 10731 format %{ "B_FAR$cmp $crx, $lbl" %} 10732 size(8); 10733 ins_encode( enc_bc_far(crx, cmp, lbl) ); 10734 ins_pipe(pipe_class_default); 10735 %} 10736 10737 // Conditional Branch used with Power6 scheduler (can be far or short). 10738 instruct branchConSched(cmpOp cmp, flagsReg crx, label lbl) %{ 10739 // Same match rule as `branchCon'. 10740 match(If cmp crx); 10741 effect(USE crx, USE lbl); 10742 predicate(false /* TODO: PPC port HB_Schedule*/); 10743 // Higher cost than `branchCon'. 10744 ins_cost(5*BRANCH_COST); 10745 10746 // Actually size doesn't depend on alignment but on shortening. 10747 ins_variable_size_depending_on_alignment(true); 10748 // long variant. 10749 ins_short_branch(0); 10750 10751 format %{ "B_FAR$cmp $crx, $lbl" %} 10752 size(8); // worst case 10753 ins_encode( enc_bc_short_far(crx, cmp, lbl) ); 10754 ins_pipe(pipe_class_default); 10755 %} 10756 10757 instruct branchLoopEnd(cmpOp cmp, flagsReg crx, label labl) %{ 10758 match(CountedLoopEnd cmp crx); 10759 effect(USE labl); 10760 ins_cost(BRANCH_COST); 10761 10762 // short variant. 10763 ins_short_branch(1); 10764 10765 format %{ "B$cmp $crx, $labl \t// counted loop end" %} 10766 size(4); 10767 ins_encode( enc_bc(crx, cmp, labl) ); 10768 ins_pipe(pipe_class_default); 10769 %} 10770 10771 instruct branchLoopEndFar(cmpOp cmp, flagsReg crx, label labl) %{ 10772 match(CountedLoopEnd cmp crx); 10773 effect(USE labl); 10774 predicate(!false /* TODO: PPC port HB_Schedule */); 10775 ins_cost(BRANCH_COST); 10776 10777 // Long variant. 10778 ins_short_branch(0); 10779 10780 format %{ "B_FAR$cmp $crx, $labl \t// counted loop end" %} 10781 size(8); 10782 ins_encode( enc_bc_far(crx, cmp, labl) ); 10783 ins_pipe(pipe_class_default); 10784 %} 10785 10786 // Conditional Branch used with Power6 scheduler (can be far or short). 10787 instruct branchLoopEndSched(cmpOp cmp, flagsReg crx, label labl) %{ 10788 match(CountedLoopEnd cmp crx); 10789 effect(USE labl); 10790 predicate(false /* TODO: PPC port HB_Schedule */); 10791 // Higher cost than `branchCon'. 10792 ins_cost(5*BRANCH_COST); 10793 10794 // Actually size doesn't depend on alignment but on shortening. 10795 ins_variable_size_depending_on_alignment(true); 10796 // Long variant. 10797 ins_short_branch(0); 10798 10799 format %{ "B_FAR$cmp $crx, $labl \t// counted loop end" %} 10800 size(8); // worst case 10801 ins_encode( enc_bc_short_far(crx, cmp, labl) ); 10802 ins_pipe(pipe_class_default); 10803 %} 10804 10805 // ============================================================================ 10806 // Java runtime operations, intrinsics and other complex operations. 10807 10808 // The 2nd slow-half of a subtype check. Scan the subklass's 2ndary superklass 10809 // array for an instance of the superklass. Set a hidden internal cache on a 10810 // hit (cache is checked with exposed code in gen_subtype_check()). Return 10811 // not zero for a miss or zero for a hit. The encoding ALSO sets flags. 10812 // 10813 // GL TODO: Improve this. 10814 // - result should not be a TEMP 10815 // - Add match rule as on sparc avoiding additional Cmp. 10816 instruct partialSubtypeCheck(iRegPdst result, iRegP_N2P subklass, iRegP_N2P superklass, 10817 iRegPdst tmp_klass, iRegPdst tmp_arrayptr) %{ 10818 match(Set result (PartialSubtypeCheck subklass superklass)); 10819 effect(TEMP result, TEMP tmp_klass, TEMP tmp_arrayptr); 10820 ins_cost(DEFAULT_COST*10); 10821 10822 format %{ "PartialSubtypeCheck $result = ($subklass instanceOf $superklass) tmp: $tmp_klass, $tmp_arrayptr" %} 10823 ins_encode %{ 10824 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 10825 __ check_klass_subtype_slow_path($subklass$$Register, $superklass$$Register, $tmp_arrayptr$$Register, 10826 $tmp_klass$$Register, NULL, $result$$Register); 10827 %} 10828 ins_pipe(pipe_class_default); 10829 %} 10830 10831 // inlined locking and unlocking 10832 10833 instruct cmpFastLock(flagsReg crx, iRegPdst oop, iRegPdst box, iRegPdst tmp1, iRegPdst tmp2, iRegPdst tmp3) %{ 10834 match(Set crx (FastLock oop box)); 10835 effect(TEMP tmp1, TEMP tmp2, TEMP tmp3); 10836 // TODO PPC port predicate(!UseNewFastLockPPC64 || UseBiasedLocking); 10837 10838 format %{ "FASTLOCK $oop, $box, $tmp1, $tmp2, $tmp3" %} 10839 ins_encode %{ 10840 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 10841 __ compiler_fast_lock_object($crx$$CondRegister, $oop$$Register, $box$$Register, 10842 $tmp3$$Register, $tmp1$$Register, $tmp2$$Register); 10843 // If locking was successfull, crx should indicate 'EQ'. 10844 // The compiler generates a branch to the runtime call to 10845 // _complete_monitor_locking_Java for the case where crx is 'NE'. 10846 %} 10847 ins_pipe(pipe_class_compare); 10848 %} 10849 10850 instruct cmpFastUnlock(flagsReg crx, iRegPdst oop, iRegPdst box, iRegPdst tmp1, iRegPdst tmp2, iRegPdst tmp3) %{ 10851 match(Set crx (FastUnlock oop box)); 10852 effect(TEMP tmp1, TEMP tmp2, TEMP tmp3); 10853 10854 format %{ "FASTUNLOCK $oop, $box, $tmp1, $tmp2" %} 10855 ins_encode %{ 10856 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 10857 __ compiler_fast_unlock_object($crx$$CondRegister, $oop$$Register, $box$$Register, 10858 $tmp3$$Register, $tmp1$$Register, $tmp2$$Register); 10859 // If unlocking was successfull, crx should indicate 'EQ'. 10860 // The compiler generates a branch to the runtime call to 10861 // _complete_monitor_unlocking_Java for the case where crx is 'NE'. 10862 %} 10863 ins_pipe(pipe_class_compare); 10864 %} 10865 10866 // Align address. 10867 instruct align_addr(iRegPdst dst, iRegPsrc src, immLnegpow2 mask) %{ 10868 match(Set dst (CastX2P (AndL (CastP2X src) mask))); 10869 10870 format %{ "ANDDI $dst, $src, $mask \t// next aligned address" %} 10871 size(4); 10872 ins_encode %{ 10873 // TODO: PPC port $archOpcode(ppc64Opcode_rldicr); 10874 __ clrrdi($dst$$Register, $src$$Register, log2_long((jlong)-$mask$$constant)); 10875 %} 10876 ins_pipe(pipe_class_default); 10877 %} 10878 10879 // Array size computation. 10880 instruct array_size(iRegLdst dst, iRegPsrc end, iRegPsrc start) %{ 10881 match(Set dst (SubL (CastP2X end) (CastP2X start))); 10882 10883 format %{ "SUB $dst, $end, $start \t// array size in bytes" %} 10884 size(4); 10885 ins_encode %{ 10886 // TODO: PPC port $archOpcode(ppc64Opcode_subf); 10887 __ subf($dst$$Register, $start$$Register, $end$$Register); 10888 %} 10889 ins_pipe(pipe_class_default); 10890 %} 10891 10892 // Clear-array with dynamic array-size. 10893 instruct inlineCallClearArray(rarg1RegL cnt, rarg2RegP base, Universe dummy, regCTR ctr) %{ 10894 match(Set dummy (ClearArray cnt base)); 10895 effect(USE_KILL cnt, USE_KILL base, KILL ctr); 10896 ins_cost(MEMORY_REF_COST); 10897 10898 ins_alignment(8); // 'compute_padding()' gets called, up to this number-1 nops will get inserted. 10899 10900 format %{ "ClearArray $cnt, $base" %} 10901 ins_encode %{ 10902 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 10903 __ clear_memory_doubleword($base$$Register, $cnt$$Register); // kills cnt, base, R0 10904 %} 10905 ins_pipe(pipe_class_default); 10906 %} 10907 10908 // String_IndexOf for needle of length 1. 10909 // 10910 // Match needle into immediate operands: no loadConP node needed. Saves one 10911 // register and two instructions over string_indexOf_imm1Node. 10912 // 10913 // Assumes register result differs from all input registers. 10914 // 10915 // Preserves registers haystack, haycnt 10916 // Kills registers tmp1, tmp2 10917 // Defines registers result 10918 // 10919 // Use dst register classes if register gets killed, as it is the case for tmp registers! 10920 // 10921 // Unfortunately this does not match too often. In many situations the AddP is used 10922 // by several nodes, even several StrIndexOf nodes, breaking the match tree. 10923 instruct string_indexOf_imm1_char(iRegIdst result, iRegPsrc haystack, iRegIsrc haycnt, 10924 immP needleImm, immL offsetImm, immI_1 needlecntImm, 10925 iRegIdst tmp1, iRegIdst tmp2, 10926 flagsRegCR0 cr0, flagsRegCR1 cr1) %{ 10927 predicate(SpecialStringIndexOf); // type check implicit by parameter type, See Matcher::match_rule_supported 10928 match(Set result (StrIndexOf (Binary haystack haycnt) (Binary (AddP needleImm offsetImm) needlecntImm))); 10929 10930 effect(TEMP result, TEMP tmp1, TEMP tmp2, KILL cr0, KILL cr1); 10931 10932 ins_cost(150); 10933 format %{ "String IndexOf CSCL1 $haystack[0..$haycnt], $needleImm+$offsetImm[0..$needlecntImm]" 10934 "-> $result \t// KILL $haycnt, $tmp1, $tmp2, $cr0, $cr1" %} 10935 10936 ins_alignment(8); // 'compute_padding()' gets called, up to this number-1 nops will get inserted 10937 ins_encode %{ 10938 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 10939 immPOper *needleOper = (immPOper *)$needleImm; 10940 const TypeOopPtr *t = needleOper->type()->isa_oopptr(); 10941 ciTypeArray* needle_values = t->const_oop()->as_type_array(); // Pointer to live char * 10942 10943 __ string_indexof_1($result$$Register, 10944 $haystack$$Register, $haycnt$$Register, 10945 R0, needle_values->char_at(0), 10946 $tmp1$$Register, $tmp2$$Register); 10947 %} 10948 ins_pipe(pipe_class_compare); 10949 %} 10950 10951 // String_IndexOf for needle of length 1. 10952 // 10953 // Special case requires less registers and emits less instructions. 10954 // 10955 // Assumes register result differs from all input registers. 10956 // 10957 // Preserves registers haystack, haycnt 10958 // Kills registers tmp1, tmp2, needle 10959 // Defines registers result 10960 // 10961 // Use dst register classes if register gets killed, as it is the case for tmp registers! 10962 instruct string_indexOf_imm1(iRegIdst result, iRegPsrc haystack, iRegIsrc haycnt, 10963 rscratch2RegP needle, immI_1 needlecntImm, 10964 iRegIdst tmp1, iRegIdst tmp2, 10965 flagsRegCR0 cr0, flagsRegCR1 cr1) %{ 10966 match(Set result (StrIndexOf (Binary haystack haycnt) (Binary needle needlecntImm))); 10967 effect(USE_KILL needle, /* TDEF needle, */ TEMP result, 10968 TEMP tmp1, TEMP tmp2); 10969 // Required for EA: check if it is still a type_array. 10970 predicate(SpecialStringIndexOf && n->in(3)->in(1)->bottom_type()->is_aryptr()->const_oop() && 10971 n->in(3)->in(1)->bottom_type()->is_aryptr()->const_oop()->is_type_array()); 10972 ins_cost(180); 10973 10974 ins_alignment(8); // 'compute_padding()' gets called, up to this number-1 nops will get inserted. 10975 10976 format %{ "String IndexOf SCL1 $haystack[0..$haycnt], $needle[0..$needlecntImm]" 10977 " -> $result \t// KILL $haycnt, $needle, $tmp1, $tmp2, $cr0, $cr1" %} 10978 ins_encode %{ 10979 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 10980 Node *ndl = in(operand_index($needle)); // The node that defines needle. 10981 ciTypeArray* needle_values = ndl->bottom_type()->is_aryptr()->const_oop()->as_type_array(); 10982 guarantee(needle_values, "sanity"); 10983 if (needle_values != NULL) { 10984 __ string_indexof_1($result$$Register, 10985 $haystack$$Register, $haycnt$$Register, 10986 R0, needle_values->char_at(0), 10987 $tmp1$$Register, $tmp2$$Register); 10988 } else { 10989 __ string_indexof_1($result$$Register, 10990 $haystack$$Register, $haycnt$$Register, 10991 $needle$$Register, 0, 10992 $tmp1$$Register, $tmp2$$Register); 10993 } 10994 %} 10995 ins_pipe(pipe_class_compare); 10996 %} 10997 10998 // String_IndexOf. 10999 // 11000 // Length of needle as immediate. This saves instruction loading constant needle 11001 // length. 11002 // @@@ TODO Specify rules for length < 8 or so, and roll out comparison of needle 11003 // completely or do it in vector instruction. This should save registers for 11004 // needlecnt and needle. 11005 // 11006 // Assumes register result differs from all input registers. 11007 // Overwrites haycnt, needlecnt. 11008 // Use dst register classes if register gets killed, as it is the case for tmp registers! 11009 instruct string_indexOf_imm(iRegIdst result, iRegPsrc haystack, rscratch1RegI haycnt, 11010 iRegPsrc needle, uimmI15 needlecntImm, 11011 iRegIdst tmp1, iRegIdst tmp2, iRegIdst tmp3, iRegIdst tmp4, iRegIdst tmp5, 11012 flagsRegCR0 cr0, flagsRegCR1 cr1, flagsRegCR6 cr6) %{ 11013 match(Set result (StrIndexOf (Binary haystack haycnt) (Binary needle needlecntImm))); 11014 effect(USE_KILL haycnt, /* better: TDEF haycnt, */ TEMP result, 11015 TEMP tmp1, TEMP tmp2, TEMP tmp3, TEMP tmp4, TEMP tmp5, KILL cr0, KILL cr1, KILL cr6); 11016 // Required for EA: check if it is still a type_array. 11017 predicate(SpecialStringIndexOf && n->in(3)->in(1)->bottom_type()->is_aryptr()->const_oop() && 11018 n->in(3)->in(1)->bottom_type()->is_aryptr()->const_oop()->is_type_array()); 11019 ins_cost(250); 11020 11021 ins_alignment(8); // 'compute_padding()' gets called, up to this number-1 nops will get inserted. 11022 11023 format %{ "String IndexOf SCL $haystack[0..$haycnt], $needle[0..$needlecntImm]" 11024 " -> $result \t// KILL $haycnt, $tmp1, $tmp2, $tmp3, $tmp4, $tmp5, $cr0, $cr1" %} 11025 ins_encode %{ 11026 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 11027 Node *ndl = in(operand_index($needle)); // The node that defines needle. 11028 ciTypeArray* needle_values = ndl->bottom_type()->is_aryptr()->const_oop()->as_type_array(); 11029 11030 __ string_indexof($result$$Register, 11031 $haystack$$Register, $haycnt$$Register, 11032 $needle$$Register, needle_values, $tmp5$$Register, $needlecntImm$$constant, 11033 $tmp1$$Register, $tmp2$$Register, $tmp3$$Register, $tmp4$$Register); 11034 %} 11035 ins_pipe(pipe_class_compare); 11036 %} 11037 11038 // StrIndexOf node. 11039 // 11040 // Assumes register result differs from all input registers. 11041 // Overwrites haycnt, needlecnt. 11042 // Use dst register classes if register gets killed, as it is the case for tmp registers! 11043 instruct string_indexOf(iRegIdst result, iRegPsrc haystack, rscratch1RegI haycnt, iRegPsrc needle, rscratch2RegI needlecnt, 11044 iRegLdst tmp1, iRegLdst tmp2, iRegLdst tmp3, iRegLdst tmp4, 11045 flagsRegCR0 cr0, flagsRegCR1 cr1, flagsRegCR6 cr6) %{ 11046 match(Set result (StrIndexOf (Binary haystack haycnt) (Binary needle needlecnt))); 11047 effect(USE_KILL haycnt, USE_KILL needlecnt, /*better: TDEF haycnt, TDEF needlecnt,*/ 11048 TEMP result, 11049 TEMP tmp1, TEMP tmp2, TEMP tmp3, TEMP tmp4, KILL cr0, KILL cr1, KILL cr6); 11050 predicate(SpecialStringIndexOf); // See Matcher::match_rule_supported. 11051 ins_cost(300); 11052 11053 ins_alignment(8); // 'compute_padding()' gets called, up to this number-1 nops will get inserted. 11054 11055 format %{ "String IndexOf $haystack[0..$haycnt], $needle[0..$needlecnt]" 11056 " -> $result \t// KILL $haycnt, $needlecnt, $tmp1, $tmp2, $tmp3, $tmp4, $cr0, $cr1" %} 11057 ins_encode %{ 11058 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 11059 __ string_indexof($result$$Register, 11060 $haystack$$Register, $haycnt$$Register, 11061 $needle$$Register, NULL, $needlecnt$$Register, 0, // needlecnt not constant. 11062 $tmp1$$Register, $tmp2$$Register, $tmp3$$Register, $tmp4$$Register); 11063 %} 11064 ins_pipe(pipe_class_compare); 11065 %} 11066 11067 // String equals with immediate. 11068 instruct string_equals_imm(iRegPsrc str1, iRegPsrc str2, uimmI15 cntImm, iRegIdst result, 11069 iRegPdst tmp1, iRegPdst tmp2, 11070 flagsRegCR0 cr0, flagsRegCR6 cr6, regCTR ctr) %{ 11071 match(Set result (StrEquals (Binary str1 str2) cntImm)); 11072 effect(TEMP result, TEMP tmp1, TEMP tmp2, 11073 KILL cr0, KILL cr6, KILL ctr); 11074 predicate(SpecialStringEquals); // See Matcher::match_rule_supported. 11075 ins_cost(250); 11076 11077 ins_alignment(8); // 'compute_padding()' gets called, up to this number-1 nops will get inserted. 11078 11079 format %{ "String Equals SCL [0..$cntImm]($str1),[0..$cntImm]($str2)" 11080 " -> $result \t// KILL $cr0, $cr6, $ctr, TEMP $result, $tmp1, $tmp2" %} 11081 ins_encode %{ 11082 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 11083 __ char_arrays_equalsImm($str1$$Register, $str2$$Register, $cntImm$$constant, 11084 $result$$Register, $tmp1$$Register, $tmp2$$Register); 11085 %} 11086 ins_pipe(pipe_class_compare); 11087 %} 11088 11089 // String equals. 11090 // Use dst register classes if register gets killed, as it is the case for TEMP operands! 11091 instruct string_equals(iRegPsrc str1, iRegPsrc str2, iRegIsrc cnt, iRegIdst result, 11092 iRegPdst tmp1, iRegPdst tmp2, iRegPdst tmp3, iRegPdst tmp4, iRegPdst tmp5, 11093 flagsRegCR0 cr0, flagsRegCR1 cr1, flagsRegCR6 cr6, regCTR ctr) %{ 11094 match(Set result (StrEquals (Binary str1 str2) cnt)); 11095 effect(TEMP result, TEMP tmp1, TEMP tmp2, TEMP tmp3, TEMP tmp4, TEMP tmp5, 11096 KILL cr0, KILL cr1, KILL cr6, KILL ctr); 11097 predicate(SpecialStringEquals); // See Matcher::match_rule_supported. 11098 ins_cost(300); 11099 11100 ins_alignment(8); // 'compute_padding()' gets called, up to this number-1 nops will get inserted. 11101 11102 format %{ "String Equals [0..$cnt]($str1),[0..$cnt]($str2) -> $result" 11103 " \t// KILL $cr0, $cr1, $cr6, $ctr, TEMP $result, $tmp1, $tmp2, $tmp3, $tmp4, $tmp5" %} 11104 ins_encode %{ 11105 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 11106 __ char_arrays_equals($str1$$Register, $str2$$Register, $cnt$$Register, $result$$Register, 11107 $tmp1$$Register, $tmp2$$Register, $tmp3$$Register, $tmp4$$Register, $tmp5$$Register); 11108 %} 11109 ins_pipe(pipe_class_compare); 11110 %} 11111 11112 // String compare. 11113 // Char[] pointers are passed in. 11114 // Use dst register classes if register gets killed, as it is the case for TEMP operands! 11115 instruct string_compare(rarg1RegP str1, rarg2RegP str2, rarg3RegI cnt1, rarg4RegI cnt2, iRegIdst result, 11116 iRegPdst tmp, flagsRegCR0 cr0, regCTR ctr) %{ 11117 match(Set result (StrComp (Binary str1 cnt1) (Binary str2 cnt2))); 11118 effect(USE_KILL cnt1, USE_KILL cnt2, USE_KILL str1, USE_KILL str2, TEMP result, TEMP tmp, KILL cr0, KILL ctr); 11119 ins_cost(300); 11120 11121 ins_alignment(8); // 'compute_padding()' gets called, up to this number-1 nops will get inserted. 11122 11123 format %{ "String Compare $str1[0..$cnt1], $str2[0..$cnt2] -> $result" 11124 " \t// TEMP $tmp, $result KILLs $str1, $cnt1, $str2, $cnt2, $cr0, $ctr" %} 11125 ins_encode %{ 11126 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 11127 __ string_compare($str1$$Register, $str2$$Register, $cnt1$$Register, $cnt2$$Register, 11128 $result$$Register, $tmp$$Register); 11129 %} 11130 ins_pipe(pipe_class_compare); 11131 %} 11132 11133 //---------- Min/Max Instructions --------------------------------------------- 11134 11135 instruct minI_reg_reg_Ex(iRegIdst dst, iRegIsrc src1, iRegIsrc src2) %{ 11136 match(Set dst (MinI src1 src2)); 11137 ins_cost(DEFAULT_COST*6); 11138 11139 expand %{ 11140 iRegIdst src1s; 11141 iRegIdst src2s; 11142 iRegIdst diff; 11143 iRegIdst sm; 11144 iRegIdst doz; // difference or zero 11145 sxtI_reg(src1s, src1); // Ensure proper sign extention. 11146 sxtI_reg(src2s, src2); // Ensure proper sign extention. 11147 subI_reg_reg(diff, src2s, src1s); 11148 // Need to consider >=33 bit result, therefore we need signmaskL. 11149 signmask64I_regI(sm, diff); 11150 andI_reg_reg(doz, diff, sm); // <=0 11151 addI_reg_reg(dst, doz, src1s); 11152 %} 11153 %} 11154 11155 instruct maxI_reg_reg_Ex(iRegIdst dst, iRegIsrc src1, iRegIsrc src2) %{ 11156 match(Set dst (MaxI src1 src2)); 11157 ins_cost(DEFAULT_COST*6); 11158 11159 expand %{ 11160 immI_minus1 m1 %{ -1 %} 11161 iRegIdst src1s; 11162 iRegIdst src2s; 11163 iRegIdst diff; 11164 iRegIdst sm; 11165 iRegIdst doz; // difference or zero 11166 sxtI_reg(src1s, src1); // Ensure proper sign extention. 11167 sxtI_reg(src2s, src2); // Ensure proper sign extention. 11168 subI_reg_reg(diff, src2s, src1s); 11169 // Need to consider >=33 bit result, therefore we need signmaskL. 11170 signmask64I_regI(sm, diff); 11171 andcI_reg_reg(doz, sm, m1, diff); // >=0 11172 addI_reg_reg(dst, doz, src1s); 11173 %} 11174 %} 11175 11176 //---------- Population Count Instructions ------------------------------------ 11177 11178 // Popcnt for Power7. 11179 instruct popCountI(iRegIdst dst, iRegIsrc src) %{ 11180 match(Set dst (PopCountI src)); 11181 predicate(UsePopCountInstruction && VM_Version::has_popcntw()); 11182 ins_cost(DEFAULT_COST); 11183 11184 format %{ "POPCNTW $dst, $src" %} 11185 size(4); 11186 ins_encode %{ 11187 // TODO: PPC port $archOpcode(ppc64Opcode_popcntb); 11188 __ popcntw($dst$$Register, $src$$Register); 11189 %} 11190 ins_pipe(pipe_class_default); 11191 %} 11192 11193 // Popcnt for Power7. 11194 instruct popCountL(iRegIdst dst, iRegLsrc src) %{ 11195 predicate(UsePopCountInstruction && VM_Version::has_popcntw()); 11196 match(Set dst (PopCountL src)); 11197 ins_cost(DEFAULT_COST); 11198 11199 format %{ "POPCNTD $dst, $src" %} 11200 size(4); 11201 ins_encode %{ 11202 // TODO: PPC port $archOpcode(ppc64Opcode_popcntb); 11203 __ popcntd($dst$$Register, $src$$Register); 11204 %} 11205 ins_pipe(pipe_class_default); 11206 %} 11207 11208 instruct countLeadingZerosI(iRegIdst dst, iRegIsrc src) %{ 11209 match(Set dst (CountLeadingZerosI src)); 11210 predicate(UseCountLeadingZerosInstructionsPPC64); // See Matcher::match_rule_supported. 11211 ins_cost(DEFAULT_COST); 11212 11213 format %{ "CNTLZW $dst, $src" %} 11214 size(4); 11215 ins_encode %{ 11216 // TODO: PPC port $archOpcode(ppc64Opcode_cntlzw); 11217 __ cntlzw($dst$$Register, $src$$Register); 11218 %} 11219 ins_pipe(pipe_class_default); 11220 %} 11221 11222 instruct countLeadingZerosL(iRegIdst dst, iRegLsrc src) %{ 11223 match(Set dst (CountLeadingZerosL src)); 11224 predicate(UseCountLeadingZerosInstructionsPPC64); // See Matcher::match_rule_supported. 11225 ins_cost(DEFAULT_COST); 11226 11227 format %{ "CNTLZD $dst, $src" %} 11228 size(4); 11229 ins_encode %{ 11230 // TODO: PPC port $archOpcode(ppc64Opcode_cntlzd); 11231 __ cntlzd($dst$$Register, $src$$Register); 11232 %} 11233 ins_pipe(pipe_class_default); 11234 %} 11235 11236 instruct countLeadingZerosP(iRegIdst dst, iRegPsrc src) %{ 11237 // no match-rule, false predicate 11238 effect(DEF dst, USE src); 11239 predicate(false); 11240 11241 format %{ "CNTLZD $dst, $src" %} 11242 size(4); 11243 ins_encode %{ 11244 // TODO: PPC port $archOpcode(ppc64Opcode_cntlzd); 11245 __ cntlzd($dst$$Register, $src$$Register); 11246 %} 11247 ins_pipe(pipe_class_default); 11248 %} 11249 11250 instruct countTrailingZerosI_Ex(iRegIdst dst, iRegIsrc src) %{ 11251 match(Set dst (CountTrailingZerosI src)); 11252 predicate(UseCountLeadingZerosInstructionsPPC64); 11253 ins_cost(DEFAULT_COST); 11254 11255 expand %{ 11256 immI16 imm1 %{ (int)-1 %} 11257 immI16 imm2 %{ (int)32 %} 11258 immI_minus1 m1 %{ -1 %} 11259 iRegIdst tmpI1; 11260 iRegIdst tmpI2; 11261 iRegIdst tmpI3; 11262 addI_reg_imm16(tmpI1, src, imm1); 11263 andcI_reg_reg(tmpI2, src, m1, tmpI1); 11264 countLeadingZerosI(tmpI3, tmpI2); 11265 subI_imm16_reg(dst, imm2, tmpI3); 11266 %} 11267 %} 11268 11269 instruct countTrailingZerosL_Ex(iRegIdst dst, iRegLsrc src) %{ 11270 match(Set dst (CountTrailingZerosL src)); 11271 predicate(UseCountLeadingZerosInstructionsPPC64); 11272 ins_cost(DEFAULT_COST); 11273 11274 expand %{ 11275 immL16 imm1 %{ (long)-1 %} 11276 immI16 imm2 %{ (int)64 %} 11277 iRegLdst tmpL1; 11278 iRegLdst tmpL2; 11279 iRegIdst tmpL3; 11280 addL_reg_imm16(tmpL1, src, imm1); 11281 andcL_reg_reg(tmpL2, tmpL1, src); 11282 countLeadingZerosL(tmpL3, tmpL2); 11283 subI_imm16_reg(dst, imm2, tmpL3); 11284 %} 11285 %} 11286 11287 // Expand nodes for byte_reverse_int. 11288 instruct insrwi_a(iRegIdst dst, iRegIsrc src, immI16 pos, immI16 shift) %{ 11289 effect(DEF dst, USE src, USE pos, USE shift); 11290 predicate(false); 11291 11292 format %{ "INSRWI $dst, $src, $pos, $shift" %} 11293 size(4); 11294 ins_encode %{ 11295 // TODO: PPC port $archOpcode(ppc64Opcode_rlwimi); 11296 __ insrwi($dst$$Register, $src$$Register, $shift$$constant, $pos$$constant); 11297 %} 11298 ins_pipe(pipe_class_default); 11299 %} 11300 11301 // As insrwi_a, but with USE_DEF. 11302 instruct insrwi(iRegIdst dst, iRegIsrc src, immI16 pos, immI16 shift) %{ 11303 effect(USE_DEF dst, USE src, USE pos, USE shift); 11304 predicate(false); 11305 11306 format %{ "INSRWI $dst, $src, $pos, $shift" %} 11307 size(4); 11308 ins_encode %{ 11309 // TODO: PPC port $archOpcode(ppc64Opcode_rlwimi); 11310 __ insrwi($dst$$Register, $src$$Register, $shift$$constant, $pos$$constant); 11311 %} 11312 ins_pipe(pipe_class_default); 11313 %} 11314 11315 // Just slightly faster than java implementation. 11316 instruct bytes_reverse_int_Ex(iRegIdst dst, iRegIsrc src) %{ 11317 match(Set dst (ReverseBytesI src)); 11318 predicate(UseCountLeadingZerosInstructionsPPC64); 11319 ins_cost(DEFAULT_COST); 11320 11321 expand %{ 11322 immI16 imm24 %{ (int) 24 %} 11323 immI16 imm16 %{ (int) 16 %} 11324 immI16 imm8 %{ (int) 8 %} 11325 immI16 imm4 %{ (int) 4 %} 11326 immI16 imm0 %{ (int) 0 %} 11327 iRegLdst tmpI1; 11328 iRegLdst tmpI2; 11329 iRegLdst tmpI3; 11330 11331 urShiftI_reg_imm(tmpI1, src, imm24); 11332 insrwi_a(dst, tmpI1, imm24, imm8); 11333 urShiftI_reg_imm(tmpI2, src, imm16); 11334 insrwi(dst, tmpI2, imm8, imm16); 11335 urShiftI_reg_imm(tmpI3, src, imm8); 11336 insrwi(dst, tmpI3, imm8, imm8); 11337 insrwi(dst, src, imm0, imm8); 11338 %} 11339 %} 11340 11341 //---------- Replicate Vector Instructions ------------------------------------ 11342 11343 // Insrdi does replicate if src == dst. 11344 instruct repl32(iRegLdst dst) %{ 11345 predicate(false); 11346 effect(USE_DEF dst); 11347 11348 format %{ "INSRDI $dst, #0, $dst, #32 \t// replicate" %} 11349 size(4); 11350 ins_encode %{ 11351 // TODO: PPC port $archOpcode(ppc64Opcode_rldimi); 11352 __ insrdi($dst$$Register, $dst$$Register, 32, 0); 11353 %} 11354 ins_pipe(pipe_class_default); 11355 %} 11356 11357 // Insrdi does replicate if src == dst. 11358 instruct repl48(iRegLdst dst) %{ 11359 predicate(false); 11360 effect(USE_DEF dst); 11361 11362 format %{ "INSRDI $dst, #0, $dst, #48 \t// replicate" %} 11363 size(4); 11364 ins_encode %{ 11365 // TODO: PPC port $archOpcode(ppc64Opcode_rldimi); 11366 __ insrdi($dst$$Register, $dst$$Register, 48, 0); 11367 %} 11368 ins_pipe(pipe_class_default); 11369 %} 11370 11371 // Insrdi does replicate if src == dst. 11372 instruct repl56(iRegLdst dst) %{ 11373 predicate(false); 11374 effect(USE_DEF dst); 11375 11376 format %{ "INSRDI $dst, #0, $dst, #56 \t// replicate" %} 11377 size(4); 11378 ins_encode %{ 11379 // TODO: PPC port $archOpcode(ppc64Opcode_rldimi); 11380 __ insrdi($dst$$Register, $dst$$Register, 56, 0); 11381 %} 11382 ins_pipe(pipe_class_default); 11383 %} 11384 11385 instruct repl8B_reg_Ex(iRegLdst dst, iRegIsrc src) %{ 11386 match(Set dst (ReplicateB src)); 11387 predicate(n->as_Vector()->length() == 8); 11388 expand %{ 11389 moveReg(dst, src); 11390 repl56(dst); 11391 repl48(dst); 11392 repl32(dst); 11393 %} 11394 %} 11395 11396 instruct repl8B_immI0(iRegLdst dst, immI_0 zero) %{ 11397 match(Set dst (ReplicateB zero)); 11398 predicate(n->as_Vector()->length() == 8); 11399 format %{ "LI $dst, #0 \t// replicate8B" %} 11400 size(4); 11401 ins_encode %{ 11402 // TODO: PPC port $archOpcode(ppc64Opcode_addi); 11403 __ li($dst$$Register, (int)((short)($zero$$constant & 0xFFFF))); 11404 %} 11405 ins_pipe(pipe_class_default); 11406 %} 11407 11408 instruct repl8B_immIminus1(iRegLdst dst, immI_minus1 src) %{ 11409 match(Set dst (ReplicateB src)); 11410 predicate(n->as_Vector()->length() == 8); 11411 format %{ "LI $dst, #-1 \t// replicate8B" %} 11412 size(4); 11413 ins_encode %{ 11414 // TODO: PPC port $archOpcode(ppc64Opcode_addi); 11415 __ li($dst$$Register, (int)((short)($src$$constant & 0xFFFF))); 11416 %} 11417 ins_pipe(pipe_class_default); 11418 %} 11419 11420 instruct repl4S_reg_Ex(iRegLdst dst, iRegIsrc src) %{ 11421 match(Set dst (ReplicateS src)); 11422 predicate(n->as_Vector()->length() == 4); 11423 expand %{ 11424 moveReg(dst, src); 11425 repl48(dst); 11426 repl32(dst); 11427 %} 11428 %} 11429 11430 instruct repl4S_immI0(iRegLdst dst, immI_0 zero) %{ 11431 match(Set dst (ReplicateS zero)); 11432 predicate(n->as_Vector()->length() == 4); 11433 format %{ "LI $dst, #0 \t// replicate4C" %} 11434 size(4); 11435 ins_encode %{ 11436 // TODO: PPC port $archOpcode(ppc64Opcode_addi); 11437 __ li($dst$$Register, (int)((short)($zero$$constant & 0xFFFF))); 11438 %} 11439 ins_pipe(pipe_class_default); 11440 %} 11441 11442 instruct repl4S_immIminus1(iRegLdst dst, immI_minus1 src) %{ 11443 match(Set dst (ReplicateS src)); 11444 predicate(n->as_Vector()->length() == 4); 11445 format %{ "LI $dst, -1 \t// replicate4C" %} 11446 size(4); 11447 ins_encode %{ 11448 // TODO: PPC port $archOpcode(ppc64Opcode_addi); 11449 __ li($dst$$Register, (int)((short)($src$$constant & 0xFFFF))); 11450 %} 11451 ins_pipe(pipe_class_default); 11452 %} 11453 11454 instruct repl2I_reg_Ex(iRegLdst dst, iRegIsrc src) %{ 11455 match(Set dst (ReplicateI src)); 11456 predicate(n->as_Vector()->length() == 2); 11457 ins_cost(2 * DEFAULT_COST); 11458 expand %{ 11459 moveReg(dst, src); 11460 repl32(dst); 11461 %} 11462 %} 11463 11464 instruct repl2I_immI0(iRegLdst dst, immI_0 zero) %{ 11465 match(Set dst (ReplicateI zero)); 11466 predicate(n->as_Vector()->length() == 2); 11467 format %{ "LI $dst, #0 \t// replicate4C" %} 11468 size(4); 11469 ins_encode %{ 11470 // TODO: PPC port $archOpcode(ppc64Opcode_addi); 11471 __ li($dst$$Register, (int)((short)($zero$$constant & 0xFFFF))); 11472 %} 11473 ins_pipe(pipe_class_default); 11474 %} 11475 11476 instruct repl2I_immIminus1(iRegLdst dst, immI_minus1 src) %{ 11477 match(Set dst (ReplicateI src)); 11478 predicate(n->as_Vector()->length() == 2); 11479 format %{ "LI $dst, -1 \t// replicate4C" %} 11480 size(4); 11481 ins_encode %{ 11482 // TODO: PPC port $archOpcode(ppc64Opcode_addi); 11483 __ li($dst$$Register, (int)((short)($src$$constant & 0xFFFF))); 11484 %} 11485 ins_pipe(pipe_class_default); 11486 %} 11487 11488 // Move float to int register via stack, replicate. 11489 instruct repl2F_reg_Ex(iRegLdst dst, regF src) %{ 11490 match(Set dst (ReplicateF src)); 11491 predicate(n->as_Vector()->length() == 2); 11492 ins_cost(2 * MEMORY_REF_COST + DEFAULT_COST); 11493 expand %{ 11494 stackSlotL tmpS; 11495 iRegIdst tmpI; 11496 moveF2I_reg_stack(tmpS, src); // Move float to stack. 11497 moveF2I_stack_reg(tmpI, tmpS); // Move stack to int reg. 11498 moveReg(dst, tmpI); // Move int to long reg. 11499 repl32(dst); // Replicate bitpattern. 11500 %} 11501 %} 11502 11503 // Replicate scalar constant to packed float values in Double register 11504 instruct repl2F_immF_Ex(iRegLdst dst, immF src) %{ 11505 match(Set dst (ReplicateF src)); 11506 predicate(n->as_Vector()->length() == 2); 11507 ins_cost(5 * DEFAULT_COST); 11508 11509 format %{ "LD $dst, offset, $constanttablebase\t// load replicated float $src $src from table, postalloc expanded" %} 11510 postalloc_expand( postalloc_expand_load_replF_constant(dst, src, constanttablebase) ); 11511 %} 11512 11513 // Replicate scalar zero constant to packed float values in Double register 11514 instruct repl2F_immF0(iRegLdst dst, immF_0 zero) %{ 11515 match(Set dst (ReplicateF zero)); 11516 predicate(n->as_Vector()->length() == 2); 11517 11518 format %{ "LI $dst, #0 \t// replicate2F" %} 11519 ins_encode %{ 11520 // TODO: PPC port $archOpcode(ppc64Opcode_addi); 11521 __ li($dst$$Register, 0x0); 11522 %} 11523 ins_pipe(pipe_class_default); 11524 %} 11525 11526 // ============================================================================ 11527 // Safepoint Instruction 11528 11529 instruct safePoint_poll(iRegPdst poll) %{ 11530 match(SafePoint poll); 11531 predicate(LoadPollAddressFromThread); 11532 11533 // It caused problems to add the effect that r0 is killed, but this 11534 // effect no longer needs to be mentioned, since r0 is not contained 11535 // in a reg_class. 11536 11537 format %{ "LD R0, #0, $poll \t// Safepoint poll for GC" %} 11538 size(4); 11539 ins_encode( enc_poll(0x0, poll) ); 11540 ins_pipe(pipe_class_default); 11541 %} 11542 11543 // Safepoint without per-thread support. Load address of page to poll 11544 // as constant. 11545 // Rscratch2RegP is R12. 11546 // LoadConPollAddr node is added in pd_post_matching_hook(). It must be 11547 // a seperate node so that the oop map is at the right location. 11548 instruct safePoint_poll_conPollAddr(rscratch2RegP poll) %{ 11549 match(SafePoint poll); 11550 predicate(!LoadPollAddressFromThread); 11551 11552 // It caused problems to add the effect that r0 is killed, but this 11553 // effect no longer needs to be mentioned, since r0 is not contained 11554 // in a reg_class. 11555 11556 format %{ "LD R12, addr of polling page\n\t" 11557 "LD R0, #0, R12 \t// Safepoint poll for GC" %} 11558 ins_encode( enc_poll(0x0, poll) ); 11559 ins_pipe(pipe_class_default); 11560 %} 11561 11562 // ============================================================================ 11563 // Call Instructions 11564 11565 // Call Java Static Instruction 11566 11567 // Schedulable version of call static node. 11568 instruct CallStaticJavaDirect(method meth) %{ 11569 match(CallStaticJava); 11570 effect(USE meth); 11571 predicate(!((CallStaticJavaNode*)n)->is_method_handle_invoke()); 11572 ins_cost(CALL_COST); 11573 11574 ins_num_consts(3 /* up to 3 patchable constants: inline cache, 2 call targets. */); 11575 11576 format %{ "CALL,static $meth \t// ==> " %} 11577 size(4); 11578 ins_encode( enc_java_static_call(meth) ); 11579 ins_pipe(pipe_class_call); 11580 %} 11581 11582 // Schedulable version of call static node. 11583 instruct CallStaticJavaDirectHandle(method meth) %{ 11584 match(CallStaticJava); 11585 effect(USE meth); 11586 predicate(((CallStaticJavaNode*)n)->is_method_handle_invoke()); 11587 ins_cost(CALL_COST); 11588 11589 ins_num_consts(3 /* up to 3 patchable constants: inline cache, 2 call targets. */); 11590 11591 format %{ "CALL,static $meth \t// ==> " %} 11592 ins_encode( enc_java_handle_call(meth) ); 11593 ins_pipe(pipe_class_call); 11594 %} 11595 11596 // Call Java Dynamic Instruction 11597 11598 // Used by postalloc expand of CallDynamicJavaDirectSchedEx (actual call). 11599 // Loading of IC was postalloc expanded. The nodes loading the IC are reachable 11600 // via fields ins_field_load_ic_hi_node and ins_field_load_ic_node. 11601 // The call destination must still be placed in the constant pool. 11602 instruct CallDynamicJavaDirectSched(method meth) %{ 11603 match(CallDynamicJava); // To get all the data fields we need ... 11604 effect(USE meth); 11605 predicate(false); // ... but never match. 11606 11607 ins_field_load_ic_hi_node(loadConL_hiNode*); 11608 ins_field_load_ic_node(loadConLNode*); 11609 ins_num_consts(1 /* 1 patchable constant: call destination */); 11610 11611 format %{ "BL \t// dynamic $meth ==> " %} 11612 size(4); 11613 ins_encode( enc_java_dynamic_call_sched(meth) ); 11614 ins_pipe(pipe_class_call); 11615 %} 11616 11617 // Schedulable (i.e. postalloc expanded) version of call dynamic java. 11618 // We use postalloc expanded calls if we use inline caches 11619 // and do not update method data. 11620 // 11621 // This instruction has two constants: inline cache (IC) and call destination. 11622 // Loading the inline cache will be postalloc expanded, thus leaving a call with 11623 // one constant. 11624 instruct CallDynamicJavaDirectSched_Ex(method meth) %{ 11625 match(CallDynamicJava); 11626 effect(USE meth); 11627 predicate(UseInlineCaches); 11628 ins_cost(CALL_COST); 11629 11630 ins_num_consts(2 /* 2 patchable constants: inline cache, call destination. */); 11631 11632 format %{ "CALL,dynamic $meth \t// postalloc expanded" %} 11633 postalloc_expand( postalloc_expand_java_dynamic_call_sched(meth, constanttablebase) ); 11634 %} 11635 11636 // Compound version of call dynamic java 11637 // We use postalloc expanded calls if we use inline caches 11638 // and do not update method data. 11639 instruct CallDynamicJavaDirect(method meth) %{ 11640 match(CallDynamicJava); 11641 effect(USE meth); 11642 predicate(!UseInlineCaches); 11643 ins_cost(CALL_COST); 11644 11645 // Enc_java_to_runtime_call needs up to 4 constants (method data oop). 11646 ins_num_consts(4); 11647 11648 format %{ "CALL,dynamic $meth \t// ==> " %} 11649 ins_encode( enc_java_dynamic_call(meth, constanttablebase) ); 11650 ins_pipe(pipe_class_call); 11651 %} 11652 11653 // Call Runtime Instruction 11654 11655 instruct CallRuntimeDirect(method meth) %{ 11656 match(CallRuntime); 11657 effect(USE meth); 11658 ins_cost(CALL_COST); 11659 11660 // Enc_java_to_runtime_call needs up to 3 constants: call target, 11661 // env for callee, C-toc. 11662 ins_num_consts(3); 11663 11664 format %{ "CALL,runtime" %} 11665 ins_encode( enc_java_to_runtime_call(meth) ); 11666 ins_pipe(pipe_class_call); 11667 %} 11668 11669 // Call Leaf 11670 11671 // Used by postalloc expand of CallLeafDirect_Ex (mtctr). 11672 instruct CallLeafDirect_mtctr(iRegLdst dst, iRegLsrc src) %{ 11673 effect(DEF dst, USE src); 11674 11675 ins_num_consts(1); 11676 11677 format %{ "MTCTR $src" %} 11678 size(4); 11679 ins_encode( enc_leaf_call_mtctr(src) ); 11680 ins_pipe(pipe_class_default); 11681 %} 11682 11683 // Used by postalloc expand of CallLeafDirect_Ex (actual call). 11684 instruct CallLeafDirect(method meth) %{ 11685 match(CallLeaf); // To get the data all the data fields we need ... 11686 effect(USE meth); 11687 predicate(false); // but never match. 11688 11689 format %{ "BCTRL \t// leaf call $meth ==> " %} 11690 size(4); 11691 ins_encode %{ 11692 // TODO: PPC port $archOpcode(ppc64Opcode_bctrl); 11693 __ bctrl(); 11694 %} 11695 ins_pipe(pipe_class_call); 11696 %} 11697 11698 // postalloc expand of CallLeafDirect. 11699 // Load adress to call from TOC, then bl to it. 11700 instruct CallLeafDirect_Ex(method meth) %{ 11701 match(CallLeaf); 11702 effect(USE meth); 11703 ins_cost(CALL_COST); 11704 11705 // Postalloc_expand_java_to_runtime_call needs up to 3 constants: call target, 11706 // env for callee, C-toc. 11707 ins_num_consts(3); 11708 11709 format %{ "CALL,runtime leaf $meth \t// postalloc expanded" %} 11710 postalloc_expand( postalloc_expand_java_to_runtime_call(meth, constanttablebase) ); 11711 %} 11712 11713 // Call runtime without safepoint - same as CallLeaf. 11714 // postalloc expand of CallLeafNoFPDirect. 11715 // Load adress to call from TOC, then bl to it. 11716 instruct CallLeafNoFPDirect_Ex(method meth) %{ 11717 match(CallLeafNoFP); 11718 effect(USE meth); 11719 ins_cost(CALL_COST); 11720 11721 // Enc_java_to_runtime_call needs up to 3 constants: call target, 11722 // env for callee, C-toc. 11723 ins_num_consts(3); 11724 11725 format %{ "CALL,runtime leaf nofp $meth \t// postalloc expanded" %} 11726 postalloc_expand( postalloc_expand_java_to_runtime_call(meth, constanttablebase) ); 11727 %} 11728 11729 // Tail Call; Jump from runtime stub to Java code. 11730 // Also known as an 'interprocedural jump'. 11731 // Target of jump will eventually return to caller. 11732 // TailJump below removes the return address. 11733 instruct TailCalljmpInd(iRegPdstNoScratch jump_target, inline_cache_regP method_oop) %{ 11734 match(TailCall jump_target method_oop); 11735 ins_cost(CALL_COST); 11736 11737 format %{ "MTCTR $jump_target \t// $method_oop holds method oop\n\t" 11738 "BCTR \t// tail call" %} 11739 size(8); 11740 ins_encode %{ 11741 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 11742 __ mtctr($jump_target$$Register); 11743 __ bctr(); 11744 %} 11745 ins_pipe(pipe_class_call); 11746 %} 11747 11748 // Return Instruction 11749 instruct Ret() %{ 11750 match(Return); 11751 format %{ "BLR \t// branch to link register" %} 11752 size(4); 11753 ins_encode %{ 11754 // TODO: PPC port $archOpcode(ppc64Opcode_blr); 11755 // LR is restored in MachEpilogNode. Just do the RET here. 11756 __ blr(); 11757 %} 11758 ins_pipe(pipe_class_default); 11759 %} 11760 11761 // Tail Jump; remove the return address; jump to target. 11762 // TailCall above leaves the return address around. 11763 // TailJump is used in only one place, the rethrow_Java stub (fancy_jump=2). 11764 // ex_oop (Exception Oop) is needed in %o0 at the jump. As there would be a 11765 // "restore" before this instruction (in Epilogue), we need to materialize it 11766 // in %i0. 11767 instruct tailjmpInd(iRegPdstNoScratch jump_target, rarg1RegP ex_oop) %{ 11768 match(TailJump jump_target ex_oop); 11769 ins_cost(CALL_COST); 11770 11771 format %{ "LD R4_ARG2 = LR\n\t" 11772 "MTCTR $jump_target\n\t" 11773 "BCTR \t// TailJump, exception oop: $ex_oop" %} 11774 size(12); 11775 ins_encode %{ 11776 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 11777 __ ld(R4_ARG2/* issuing pc */, _abi(lr), R1_SP); 11778 __ mtctr($jump_target$$Register); 11779 __ bctr(); 11780 %} 11781 ins_pipe(pipe_class_call); 11782 %} 11783 11784 // Create exception oop: created by stack-crawling runtime code. 11785 // Created exception is now available to this handler, and is setup 11786 // just prior to jumping to this handler. No code emitted. 11787 instruct CreateException(rarg1RegP ex_oop) %{ 11788 match(Set ex_oop (CreateEx)); 11789 ins_cost(0); 11790 11791 format %{ " -- \t// exception oop; no code emitted" %} 11792 size(0); 11793 ins_encode( /*empty*/ ); 11794 ins_pipe(pipe_class_default); 11795 %} 11796 11797 // Rethrow exception: The exception oop will come in the first 11798 // argument position. Then JUMP (not call) to the rethrow stub code. 11799 instruct RethrowException() %{ 11800 match(Rethrow); 11801 ins_cost(CALL_COST); 11802 11803 format %{ "Jmp rethrow_stub" %} 11804 ins_encode %{ 11805 // TODO: PPC port $archOpcode(ppc64Opcode_compound); 11806 cbuf.set_insts_mark(); 11807 __ b64_patchable((address)OptoRuntime::rethrow_stub(), relocInfo::runtime_call_type); 11808 %} 11809 ins_pipe(pipe_class_call); 11810 %} 11811 11812 // Die now. 11813 instruct ShouldNotReachHere() %{ 11814 match(Halt); 11815 ins_cost(CALL_COST); 11816 11817 format %{ "ShouldNotReachHere" %} 11818 size(4); 11819 ins_encode %{ 11820 // TODO: PPC port $archOpcode(ppc64Opcode_tdi); 11821 __ trap_should_not_reach_here(); 11822 %} 11823 ins_pipe(pipe_class_default); 11824 %} 11825 11826 // This name is KNOWN by the ADLC and cannot be changed. The ADLC 11827 // forces a 'TypeRawPtr::BOTTOM' output type for this guy. 11828 // Get a DEF on threadRegP, no costs, no encoding, use 11829 // 'ins_should_rematerialize(true)' to avoid spilling. 11830 instruct tlsLoadP(threadRegP dst) %{ 11831 match(Set dst (ThreadLocal)); 11832 ins_cost(0); 11833 11834 ins_should_rematerialize(true); 11835 11836 format %{ " -- \t// $dst=Thread::current(), empty" %} 11837 size(0); 11838 ins_encode( /*empty*/ ); 11839 ins_pipe(pipe_class_empty); 11840 %} 11841 11842 //---Some PPC specific nodes--------------------------------------------------- 11843 11844 // Stop a group. 11845 instruct endGroup() %{ 11846 ins_cost(0); 11847 11848 ins_is_nop(true); 11849 11850 format %{ "End Bundle (ori r1, r1, 0)" %} 11851 size(4); 11852 ins_encode %{ 11853 // TODO: PPC port $archOpcode(ppc64Opcode_endgroup); 11854 __ endgroup(); 11855 %} 11856 ins_pipe(pipe_class_default); 11857 %} 11858 11859 // Nop instructions 11860 11861 instruct fxNop() %{ 11862 ins_cost(0); 11863 11864 ins_is_nop(true); 11865 11866 format %{ "fxNop" %} 11867 size(4); 11868 ins_encode %{ 11869 // TODO: PPC port $archOpcode(ppc64Opcode_fmr); 11870 __ nop(); 11871 %} 11872 ins_pipe(pipe_class_default); 11873 %} 11874 11875 instruct fpNop0() %{ 11876 ins_cost(0); 11877 11878 ins_is_nop(true); 11879 11880 format %{ "fpNop0" %} 11881 size(4); 11882 ins_encode %{ 11883 // TODO: PPC port $archOpcode(ppc64Opcode_fmr); 11884 __ fpnop0(); 11885 %} 11886 ins_pipe(pipe_class_default); 11887 %} 11888 11889 instruct fpNop1() %{ 11890 ins_cost(0); 11891 11892 ins_is_nop(true); 11893 11894 format %{ "fpNop1" %} 11895 size(4); 11896 ins_encode %{ 11897 // TODO: PPC port $archOpcode(ppc64Opcode_fmr); 11898 __ fpnop1(); 11899 %} 11900 ins_pipe(pipe_class_default); 11901 %} 11902 11903 instruct brNop0() %{ 11904 ins_cost(0); 11905 size(4); 11906 format %{ "brNop0" %} 11907 ins_encode %{ 11908 // TODO: PPC port $archOpcode(ppc64Opcode_mcrf); 11909 __ brnop0(); 11910 %} 11911 ins_is_nop(true); 11912 ins_pipe(pipe_class_default); 11913 %} 11914 11915 instruct brNop1() %{ 11916 ins_cost(0); 11917 11918 ins_is_nop(true); 11919 11920 format %{ "brNop1" %} 11921 size(4); 11922 ins_encode %{ 11923 // TODO: PPC port $archOpcode(ppc64Opcode_mcrf); 11924 __ brnop1(); 11925 %} 11926 ins_pipe(pipe_class_default); 11927 %} 11928 11929 instruct brNop2() %{ 11930 ins_cost(0); 11931 11932 ins_is_nop(true); 11933 11934 format %{ "brNop2" %} 11935 size(4); 11936 ins_encode %{ 11937 // TODO: PPC port $archOpcode(ppc64Opcode_mcrf); 11938 __ brnop2(); 11939 %} 11940 ins_pipe(pipe_class_default); 11941 %} 11942 11943 //----------PEEPHOLE RULES----------------------------------------------------- 11944 // These must follow all instruction definitions as they use the names 11945 // defined in the instructions definitions. 11946 // 11947 // peepmatch ( root_instr_name [preceeding_instruction]* ); 11948 // 11949 // peepconstraint %{ 11950 // (instruction_number.operand_name relational_op instruction_number.operand_name 11951 // [, ...] ); 11952 // // instruction numbers are zero-based using left to right order in peepmatch 11953 // 11954 // peepreplace ( instr_name ( [instruction_number.operand_name]* ) ); 11955 // // provide an instruction_number.operand_name for each operand that appears 11956 // // in the replacement instruction's match rule 11957 // 11958 // ---------VM FLAGS--------------------------------------------------------- 11959 // 11960 // All peephole optimizations can be turned off using -XX:-OptoPeephole 11961 // 11962 // Each peephole rule is given an identifying number starting with zero and 11963 // increasing by one in the order seen by the parser. An individual peephole 11964 // can be enabled, and all others disabled, by using -XX:OptoPeepholeAt=# 11965 // on the command-line. 11966 // 11967 // ---------CURRENT LIMITATIONS---------------------------------------------- 11968 // 11969 // Only match adjacent instructions in same basic block 11970 // Only equality constraints 11971 // Only constraints between operands, not (0.dest_reg == EAX_enc) 11972 // Only one replacement instruction 11973 // 11974 // ---------EXAMPLE---------------------------------------------------------- 11975 // 11976 // // pertinent parts of existing instructions in architecture description 11977 // instruct movI(eRegI dst, eRegI src) %{ 11978 // match(Set dst (CopyI src)); 11979 // %} 11980 // 11981 // instruct incI_eReg(eRegI dst, immI1 src, eFlagsReg cr) %{ 11982 // match(Set dst (AddI dst src)); 11983 // effect(KILL cr); 11984 // %} 11985 // 11986 // // Change (inc mov) to lea 11987 // peephole %{ 11988 // // increment preceeded by register-register move 11989 // peepmatch ( incI_eReg movI ); 11990 // // require that the destination register of the increment 11991 // // match the destination register of the move 11992 // peepconstraint ( 0.dst == 1.dst ); 11993 // // construct a replacement instruction that sets 11994 // // the destination to ( move's source register + one ) 11995 // peepreplace ( leaI_eReg_immI( 0.dst 1.src 0.src ) ); 11996 // %} 11997 // 11998 // Implementation no longer uses movX instructions since 11999 // machine-independent system no longer uses CopyX nodes. 12000 // 12001 // peephole %{ 12002 // peepmatch ( incI_eReg movI ); 12003 // peepconstraint ( 0.dst == 1.dst ); 12004 // peepreplace ( leaI_eReg_immI( 0.dst 1.src 0.src ) ); 12005 // %} 12006 // 12007 // peephole %{ 12008 // peepmatch ( decI_eReg movI ); 12009 // peepconstraint ( 0.dst == 1.dst ); 12010 // peepreplace ( leaI_eReg_immI( 0.dst 1.src 0.src ) ); 12011 // %} 12012 // 12013 // peephole %{ 12014 // peepmatch ( addI_eReg_imm movI ); 12015 // peepconstraint ( 0.dst == 1.dst ); 12016 // peepreplace ( leaI_eReg_immI( 0.dst 1.src 0.src ) ); 12017 // %} 12018 // 12019 // peephole %{ 12020 // peepmatch ( addP_eReg_imm movP ); 12021 // peepconstraint ( 0.dst == 1.dst ); 12022 // peepreplace ( leaP_eReg_immI( 0.dst 1.src 0.src ) ); 12023 // %} 12024 12025 // // Change load of spilled value to only a spill 12026 // instruct storeI(memory mem, eRegI src) %{ 12027 // match(Set mem (StoreI mem src)); 12028 // %} 12029 // 12030 // instruct loadI(eRegI dst, memory mem) %{ 12031 // match(Set dst (LoadI mem)); 12032 // %} 12033 // 12034 peephole %{ 12035 peepmatch ( loadI storeI ); 12036 peepconstraint ( 1.src == 0.dst, 1.mem == 0.mem ); 12037 peepreplace ( storeI( 1.mem 1.mem 1.src ) ); 12038 %} 12039 12040 peephole %{ 12041 peepmatch ( loadL storeL ); 12042 peepconstraint ( 1.src == 0.dst, 1.mem == 0.mem ); 12043 peepreplace ( storeL( 1.mem 1.mem 1.src ) ); 12044 %} 12045 12046 peephole %{ 12047 peepmatch ( loadP storeP ); 12048 peepconstraint ( 1.src == 0.dst, 1.dst == 0.mem ); 12049 peepreplace ( storeP( 1.dst 1.dst 1.src ) ); 12050 %} 12051 12052 //----------SMARTSPILL RULES--------------------------------------------------- 12053 // These must follow all instruction definitions as they use the names 12054 // defined in the instructions definitions.