annotate src/cpu/x86/vm/x86_64.ad @ 3142:9b8ce46870df

7145346: VerifyStackAtCalls is broken Summary: Replace call_epilog() encoding with macroassembler use. Moved duplicated code to x86.ad. Fixed return_addr() definition. Reviewed-by: never
author kvn
date Thu, 16 Feb 2012 17:12:49 -0800
parents fd8114661503
children 61b82be3b1ff
rev   line source
duke@0 1 //
kvn@3142 2 // Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
duke@0 3 // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@0 4 //
duke@0 5 // This code is free software; you can redistribute it and/or modify it
duke@0 6 // under the terms of the GNU General Public License version 2 only, as
duke@0 7 // published by the Free Software Foundation.
duke@0 8 //
duke@0 9 // This code is distributed in the hope that it will be useful, but WITHOUT
duke@0 10 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@0 11 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@0 12 // version 2 for more details (a copy is included in the LICENSE file that
duke@0 13 // accompanied this code).
duke@0 14 //
duke@0 15 // You should have received a copy of the GNU General Public License version
duke@0 16 // 2 along with this work; if not, write to the Free Software Foundation,
duke@0 17 // Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@0 18 //
trims@1472 19 // Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1472 20 // or visit www.oracle.com if you need additional information or have any
trims@1472 21 // questions.
duke@0 22 //
duke@0 23 //
duke@0 24
duke@0 25 // AMD64 Architecture Description File
duke@0 26
duke@0 27 //----------REGISTER DEFINITION BLOCK------------------------------------------
duke@0 28 // This information is used by the matcher and the register allocator to
duke@0 29 // describe individual registers and classes of registers within the target
duke@0 30 // archtecture.
duke@0 31
duke@0 32 register %{
duke@0 33 //----------Architecture Description Register Definitions----------------------
duke@0 34 // General Registers
duke@0 35 // "reg_def" name ( register save type, C convention save type,
duke@0 36 // ideal register type, encoding );
duke@0 37 // Register Save Types:
duke@0 38 //
duke@0 39 // NS = No-Save: The register allocator assumes that these registers
duke@0 40 // can be used without saving upon entry to the method, &
duke@0 41 // that they do not need to be saved at call sites.
duke@0 42 //
duke@0 43 // SOC = Save-On-Call: The register allocator assumes that these registers
duke@0 44 // can be used without saving upon entry to the method,
duke@0 45 // but that they must be saved at call sites.
duke@0 46 //
duke@0 47 // SOE = Save-On-Entry: The register allocator assumes that these registers
duke@0 48 // must be saved before using them upon entry to the
duke@0 49 // method, but they do not need to be saved at call
duke@0 50 // sites.
duke@0 51 //
duke@0 52 // AS = Always-Save: The register allocator assumes that these registers
duke@0 53 // must be saved before using them upon entry to the
duke@0 54 // method, & that they must be saved at call sites.
duke@0 55 //
duke@0 56 // Ideal Register Type is used to determine how to save & restore a
duke@0 57 // register. Op_RegI will get spilled with LoadI/StoreI, Op_RegP will get
duke@0 58 // spilled with LoadP/StoreP. If the register supports both, use Op_RegI.
duke@0 59 //
duke@0 60 // The encoding number is the actual bit-pattern placed into the opcodes.
duke@0 61
duke@0 62 // General Registers
duke@0 63 // R8-R15 must be encoded with REX. (RSP, RBP, RSI, RDI need REX when
duke@0 64 // used as byte registers)
duke@0 65
duke@0 66 // Previously set RBX, RSI, and RDI as save-on-entry for java code
duke@0 67 // Turn off SOE in java-code due to frequent use of uncommon-traps.
duke@0 68 // Now that allocator is better, turn on RSI and RDI as SOE registers.
duke@0 69
duke@0 70 reg_def RAX (SOC, SOC, Op_RegI, 0, rax->as_VMReg());
duke@0 71 reg_def RAX_H(SOC, SOC, Op_RegI, 0, rax->as_VMReg()->next());
duke@0 72
duke@0 73 reg_def RCX (SOC, SOC, Op_RegI, 1, rcx->as_VMReg());
duke@0 74 reg_def RCX_H(SOC, SOC, Op_RegI, 1, rcx->as_VMReg()->next());
duke@0 75
duke@0 76 reg_def RDX (SOC, SOC, Op_RegI, 2, rdx->as_VMReg());
duke@0 77 reg_def RDX_H(SOC, SOC, Op_RegI, 2, rdx->as_VMReg()->next());
duke@0 78
duke@0 79 reg_def RBX (SOC, SOE, Op_RegI, 3, rbx->as_VMReg());
duke@0 80 reg_def RBX_H(SOC, SOE, Op_RegI, 3, rbx->as_VMReg()->next());
duke@0 81
duke@0 82 reg_def RSP (NS, NS, Op_RegI, 4, rsp->as_VMReg());
duke@0 83 reg_def RSP_H(NS, NS, Op_RegI, 4, rsp->as_VMReg()->next());
duke@0 84
duke@0 85 // now that adapter frames are gone RBP is always saved and restored by the prolog/epilog code
duke@0 86 reg_def RBP (NS, SOE, Op_RegI, 5, rbp->as_VMReg());
duke@0 87 reg_def RBP_H(NS, SOE, Op_RegI, 5, rbp->as_VMReg()->next());
duke@0 88
duke@0 89 #ifdef _WIN64
duke@0 90
duke@0 91 reg_def RSI (SOC, SOE, Op_RegI, 6, rsi->as_VMReg());
duke@0 92 reg_def RSI_H(SOC, SOE, Op_RegI, 6, rsi->as_VMReg()->next());
duke@0 93
duke@0 94 reg_def RDI (SOC, SOE, Op_RegI, 7, rdi->as_VMReg());
duke@0 95 reg_def RDI_H(SOC, SOE, Op_RegI, 7, rdi->as_VMReg()->next());
duke@0 96
duke@0 97 #else
duke@0 98
duke@0 99 reg_def RSI (SOC, SOC, Op_RegI, 6, rsi->as_VMReg());
duke@0 100 reg_def RSI_H(SOC, SOC, Op_RegI, 6, rsi->as_VMReg()->next());
duke@0 101
duke@0 102 reg_def RDI (SOC, SOC, Op_RegI, 7, rdi->as_VMReg());
duke@0 103 reg_def RDI_H(SOC, SOC, Op_RegI, 7, rdi->as_VMReg()->next());
duke@0 104
duke@0 105 #endif
duke@0 106
duke@0 107 reg_def R8 (SOC, SOC, Op_RegI, 8, r8->as_VMReg());
duke@0 108 reg_def R8_H (SOC, SOC, Op_RegI, 8, r8->as_VMReg()->next());
duke@0 109
duke@0 110 reg_def R9 (SOC, SOC, Op_RegI, 9, r9->as_VMReg());
duke@0 111 reg_def R9_H (SOC, SOC, Op_RegI, 9, r9->as_VMReg()->next());
duke@0 112
duke@0 113 reg_def R10 (SOC, SOC, Op_RegI, 10, r10->as_VMReg());
duke@0 114 reg_def R10_H(SOC, SOC, Op_RegI, 10, r10->as_VMReg()->next());
duke@0 115
duke@0 116 reg_def R11 (SOC, SOC, Op_RegI, 11, r11->as_VMReg());
duke@0 117 reg_def R11_H(SOC, SOC, Op_RegI, 11, r11->as_VMReg()->next());
duke@0 118
duke@0 119 reg_def R12 (SOC, SOE, Op_RegI, 12, r12->as_VMReg());
duke@0 120 reg_def R12_H(SOC, SOE, Op_RegI, 12, r12->as_VMReg()->next());
duke@0 121
duke@0 122 reg_def R13 (SOC, SOE, Op_RegI, 13, r13->as_VMReg());
duke@0 123 reg_def R13_H(SOC, SOE, Op_RegI, 13, r13->as_VMReg()->next());
duke@0 124
duke@0 125 reg_def R14 (SOC, SOE, Op_RegI, 14, r14->as_VMReg());
duke@0 126 reg_def R14_H(SOC, SOE, Op_RegI, 14, r14->as_VMReg()->next());
duke@0 127
duke@0 128 reg_def R15 (SOC, SOE, Op_RegI, 15, r15->as_VMReg());
duke@0 129 reg_def R15_H(SOC, SOE, Op_RegI, 15, r15->as_VMReg()->next());
duke@0 130
duke@0 131
duke@0 132 // Floating Point Registers
duke@0 133
duke@0 134 // XMM registers. 128-bit registers or 4 words each, labeled (a)-d.
duke@0 135 // Word a in each register holds a Float, words ab hold a Double. We
duke@0 136 // currently do not use the SIMD capabilities, so registers cd are
duke@0 137 // unused at the moment.
duke@0 138 // XMM8-XMM15 must be encoded with REX.
duke@0 139 // Linux ABI: No register preserved across function calls
duke@0 140 // XMM0-XMM7 might hold parameters
duke@0 141 // Windows ABI: XMM6-XMM15 preserved across function calls
duke@0 142 // XMM0-XMM3 might hold parameters
duke@0 143
duke@0 144 reg_def XMM0 (SOC, SOC, Op_RegF, 0, xmm0->as_VMReg());
duke@0 145 reg_def XMM0_H (SOC, SOC, Op_RegF, 0, xmm0->as_VMReg()->next());
duke@0 146
duke@0 147 reg_def XMM1 (SOC, SOC, Op_RegF, 1, xmm1->as_VMReg());
duke@0 148 reg_def XMM1_H (SOC, SOC, Op_RegF, 1, xmm1->as_VMReg()->next());
duke@0 149
duke@0 150 reg_def XMM2 (SOC, SOC, Op_RegF, 2, xmm2->as_VMReg());
duke@0 151 reg_def XMM2_H (SOC, SOC, Op_RegF, 2, xmm2->as_VMReg()->next());
duke@0 152
duke@0 153 reg_def XMM3 (SOC, SOC, Op_RegF, 3, xmm3->as_VMReg());
duke@0 154 reg_def XMM3_H (SOC, SOC, Op_RegF, 3, xmm3->as_VMReg()->next());
duke@0 155
duke@0 156 reg_def XMM4 (SOC, SOC, Op_RegF, 4, xmm4->as_VMReg());
duke@0 157 reg_def XMM4_H (SOC, SOC, Op_RegF, 4, xmm4->as_VMReg()->next());
duke@0 158
duke@0 159 reg_def XMM5 (SOC, SOC, Op_RegF, 5, xmm5->as_VMReg());
duke@0 160 reg_def XMM5_H (SOC, SOC, Op_RegF, 5, xmm5->as_VMReg()->next());
duke@0 161
duke@0 162 #ifdef _WIN64
duke@0 163
duke@0 164 reg_def XMM6 (SOC, SOE, Op_RegF, 6, xmm6->as_VMReg());
duke@0 165 reg_def XMM6_H (SOC, SOE, Op_RegF, 6, xmm6->as_VMReg()->next());
duke@0 166
duke@0 167 reg_def XMM7 (SOC, SOE, Op_RegF, 7, xmm7->as_VMReg());
duke@0 168 reg_def XMM7_H (SOC, SOE, Op_RegF, 7, xmm7->as_VMReg()->next());
duke@0 169
duke@0 170 reg_def XMM8 (SOC, SOE, Op_RegF, 8, xmm8->as_VMReg());
duke@0 171 reg_def XMM8_H (SOC, SOE, Op_RegF, 8, xmm8->as_VMReg()->next());
duke@0 172
duke@0 173 reg_def XMM9 (SOC, SOE, Op_RegF, 9, xmm9->as_VMReg());
duke@0 174 reg_def XMM9_H (SOC, SOE, Op_RegF, 9, xmm9->as_VMReg()->next());
duke@0 175
duke@0 176 reg_def XMM10 (SOC, SOE, Op_RegF, 10, xmm10->as_VMReg());
duke@0 177 reg_def XMM10_H(SOC, SOE, Op_RegF, 10, xmm10->as_VMReg()->next());
duke@0 178
duke@0 179 reg_def XMM11 (SOC, SOE, Op_RegF, 11, xmm11->as_VMReg());
duke@0 180 reg_def XMM11_H(SOC, SOE, Op_RegF, 11, xmm11->as_VMReg()->next());
duke@0 181
duke@0 182 reg_def XMM12 (SOC, SOE, Op_RegF, 12, xmm12->as_VMReg());
duke@0 183 reg_def XMM12_H(SOC, SOE, Op_RegF, 12, xmm12->as_VMReg()->next());
duke@0 184
duke@0 185 reg_def XMM13 (SOC, SOE, Op_RegF, 13, xmm13->as_VMReg());
duke@0 186 reg_def XMM13_H(SOC, SOE, Op_RegF, 13, xmm13->as_VMReg()->next());
duke@0 187
duke@0 188 reg_def XMM14 (SOC, SOE, Op_RegF, 14, xmm14->as_VMReg());
duke@0 189 reg_def XMM14_H(SOC, SOE, Op_RegF, 14, xmm14->as_VMReg()->next());
duke@0 190
duke@0 191 reg_def XMM15 (SOC, SOE, Op_RegF, 15, xmm15->as_VMReg());
duke@0 192 reg_def XMM15_H(SOC, SOE, Op_RegF, 15, xmm15->as_VMReg()->next());
duke@0 193
duke@0 194 #else
duke@0 195
duke@0 196 reg_def XMM6 (SOC, SOC, Op_RegF, 6, xmm6->as_VMReg());
duke@0 197 reg_def XMM6_H (SOC, SOC, Op_RegF, 6, xmm6->as_VMReg()->next());
duke@0 198
duke@0 199 reg_def XMM7 (SOC, SOC, Op_RegF, 7, xmm7->as_VMReg());
duke@0 200 reg_def XMM7_H (SOC, SOC, Op_RegF, 7, xmm7->as_VMReg()->next());
duke@0 201
duke@0 202 reg_def XMM8 (SOC, SOC, Op_RegF, 8, xmm8->as_VMReg());
duke@0 203 reg_def XMM8_H (SOC, SOC, Op_RegF, 8, xmm8->as_VMReg()->next());
duke@0 204
duke@0 205 reg_def XMM9 (SOC, SOC, Op_RegF, 9, xmm9->as_VMReg());
duke@0 206 reg_def XMM9_H (SOC, SOC, Op_RegF, 9, xmm9->as_VMReg()->next());
duke@0 207
duke@0 208 reg_def XMM10 (SOC, SOC, Op_RegF, 10, xmm10->as_VMReg());
duke@0 209 reg_def XMM10_H(SOC, SOC, Op_RegF, 10, xmm10->as_VMReg()->next());
duke@0 210
duke@0 211 reg_def XMM11 (SOC, SOC, Op_RegF, 11, xmm11->as_VMReg());
duke@0 212 reg_def XMM11_H(SOC, SOC, Op_RegF, 11, xmm11->as_VMReg()->next());
duke@0 213
duke@0 214 reg_def XMM12 (SOC, SOC, Op_RegF, 12, xmm12->as_VMReg());
duke@0 215 reg_def XMM12_H(SOC, SOC, Op_RegF, 12, xmm12->as_VMReg()->next());
duke@0 216
duke@0 217 reg_def XMM13 (SOC, SOC, Op_RegF, 13, xmm13->as_VMReg());
duke@0 218 reg_def XMM13_H(SOC, SOC, Op_RegF, 13, xmm13->as_VMReg()->next());
duke@0 219
duke@0 220 reg_def XMM14 (SOC, SOC, Op_RegF, 14, xmm14->as_VMReg());
duke@0 221 reg_def XMM14_H(SOC, SOC, Op_RegF, 14, xmm14->as_VMReg()->next());
duke@0 222
duke@0 223 reg_def XMM15 (SOC, SOC, Op_RegF, 15, xmm15->as_VMReg());
duke@0 224 reg_def XMM15_H(SOC, SOC, Op_RegF, 15, xmm15->as_VMReg()->next());
duke@0 225
duke@0 226 #endif // _WIN64
duke@0 227
duke@0 228 reg_def RFLAGS(SOC, SOC, 0, 16, VMRegImpl::Bad());
duke@0 229
duke@0 230 // Specify priority of register selection within phases of register
duke@0 231 // allocation. Highest priority is first. A useful heuristic is to
duke@0 232 // give registers a low priority when they are required by machine
duke@0 233 // instructions, like EAX and EDX on I486, and choose no-save registers
duke@0 234 // before save-on-call, & save-on-call before save-on-entry. Registers
duke@0 235 // which participate in fixed calling sequences should come last.
duke@0 236 // Registers which are used as pairs must fall on an even boundary.
duke@0 237
duke@0 238 alloc_class chunk0(R10, R10_H,
duke@0 239 R11, R11_H,
duke@0 240 R8, R8_H,
duke@0 241 R9, R9_H,
duke@0 242 R12, R12_H,
duke@0 243 RCX, RCX_H,
duke@0 244 RBX, RBX_H,
duke@0 245 RDI, RDI_H,
duke@0 246 RDX, RDX_H,
duke@0 247 RSI, RSI_H,
duke@0 248 RAX, RAX_H,
duke@0 249 RBP, RBP_H,
duke@0 250 R13, R13_H,
duke@0 251 R14, R14_H,
duke@0 252 R15, R15_H,
duke@0 253 RSP, RSP_H);
duke@0 254
duke@0 255 // XXX probably use 8-15 first on Linux
duke@0 256 alloc_class chunk1(XMM0, XMM0_H,
duke@0 257 XMM1, XMM1_H,
duke@0 258 XMM2, XMM2_H,
duke@0 259 XMM3, XMM3_H,
duke@0 260 XMM4, XMM4_H,
duke@0 261 XMM5, XMM5_H,
duke@0 262 XMM6, XMM6_H,
duke@0 263 XMM7, XMM7_H,
duke@0 264 XMM8, XMM8_H,
duke@0 265 XMM9, XMM9_H,
duke@0 266 XMM10, XMM10_H,
duke@0 267 XMM11, XMM11_H,
duke@0 268 XMM12, XMM12_H,
duke@0 269 XMM13, XMM13_H,
duke@0 270 XMM14, XMM14_H,
duke@0 271 XMM15, XMM15_H);
duke@0 272
duke@0 273 alloc_class chunk2(RFLAGS);
duke@0 274
duke@0 275
duke@0 276 //----------Architecture Description Register Classes--------------------------
duke@0 277 // Several register classes are automatically defined based upon information in
duke@0 278 // this architecture description.
duke@0 279 // 1) reg_class inline_cache_reg ( /* as def'd in frame section */ )
duke@0 280 // 2) reg_class compiler_method_oop_reg ( /* as def'd in frame section */ )
duke@0 281 // 2) reg_class interpreter_method_oop_reg ( /* as def'd in frame section */ )
duke@0 282 // 3) reg_class stack_slots( /* one chunk of stack-based "registers" */ )
duke@0 283 //
duke@0 284
duke@0 285 // Class for all pointer registers (including RSP)
duke@0 286 reg_class any_reg(RAX, RAX_H,
duke@0 287 RDX, RDX_H,
duke@0 288 RBP, RBP_H,
duke@0 289 RDI, RDI_H,
duke@0 290 RSI, RSI_H,
duke@0 291 RCX, RCX_H,
duke@0 292 RBX, RBX_H,
duke@0 293 RSP, RSP_H,
duke@0 294 R8, R8_H,
duke@0 295 R9, R9_H,
duke@0 296 R10, R10_H,
duke@0 297 R11, R11_H,
duke@0 298 R12, R12_H,
duke@0 299 R13, R13_H,
duke@0 300 R14, R14_H,
duke@0 301 R15, R15_H);
duke@0 302
duke@0 303 // Class for all pointer registers except RSP
duke@0 304 reg_class ptr_reg(RAX, RAX_H,
duke@0 305 RDX, RDX_H,
duke@0 306 RBP, RBP_H,
duke@0 307 RDI, RDI_H,
duke@0 308 RSI, RSI_H,
duke@0 309 RCX, RCX_H,
duke@0 310 RBX, RBX_H,
duke@0 311 R8, R8_H,
duke@0 312 R9, R9_H,
duke@0 313 R10, R10_H,
duke@0 314 R11, R11_H,
duke@0 315 R13, R13_H,
duke@0 316 R14, R14_H);
duke@0 317
duke@0 318 // Class for all pointer registers except RAX and RSP
duke@0 319 reg_class ptr_no_rax_reg(RDX, RDX_H,
duke@0 320 RBP, RBP_H,
duke@0 321 RDI, RDI_H,
duke@0 322 RSI, RSI_H,
duke@0 323 RCX, RCX_H,
duke@0 324 RBX, RBX_H,
duke@0 325 R8, R8_H,
duke@0 326 R9, R9_H,
duke@0 327 R10, R10_H,
duke@0 328 R11, R11_H,
duke@0 329 R13, R13_H,
duke@0 330 R14, R14_H);
duke@0 331
duke@0 332 reg_class ptr_no_rbp_reg(RDX, RDX_H,
duke@0 333 RAX, RAX_H,
duke@0 334 RDI, RDI_H,
duke@0 335 RSI, RSI_H,
duke@0 336 RCX, RCX_H,
duke@0 337 RBX, RBX_H,
duke@0 338 R8, R8_H,
duke@0 339 R9, R9_H,
duke@0 340 R10, R10_H,
duke@0 341 R11, R11_H,
duke@0 342 R13, R13_H,
duke@0 343 R14, R14_H);
duke@0 344
duke@0 345 // Class for all pointer registers except RAX, RBX and RSP
duke@0 346 reg_class ptr_no_rax_rbx_reg(RDX, RDX_H,
duke@0 347 RBP, RBP_H,
duke@0 348 RDI, RDI_H,
duke@0 349 RSI, RSI_H,
duke@0 350 RCX, RCX_H,
duke@0 351 R8, R8_H,
duke@0 352 R9, R9_H,
duke@0 353 R10, R10_H,
duke@0 354 R11, R11_H,
duke@0 355 R13, R13_H,
duke@0 356 R14, R14_H);
duke@0 357
duke@0 358 // Singleton class for RAX pointer register
duke@0 359 reg_class ptr_rax_reg(RAX, RAX_H);
duke@0 360
duke@0 361 // Singleton class for RBX pointer register
duke@0 362 reg_class ptr_rbx_reg(RBX, RBX_H);
duke@0 363
duke@0 364 // Singleton class for RSI pointer register
duke@0 365 reg_class ptr_rsi_reg(RSI, RSI_H);
duke@0 366
duke@0 367 // Singleton class for RDI pointer register
duke@0 368 reg_class ptr_rdi_reg(RDI, RDI_H);
duke@0 369
duke@0 370 // Singleton class for RBP pointer register
duke@0 371 reg_class ptr_rbp_reg(RBP, RBP_H);
duke@0 372
duke@0 373 // Singleton class for stack pointer
duke@0 374 reg_class ptr_rsp_reg(RSP, RSP_H);
duke@0 375
duke@0 376 // Singleton class for TLS pointer
duke@0 377 reg_class ptr_r15_reg(R15, R15_H);
duke@0 378
duke@0 379 // Class for all long registers (except RSP)
duke@0 380 reg_class long_reg(RAX, RAX_H,
duke@0 381 RDX, RDX_H,
duke@0 382 RBP, RBP_H,
duke@0 383 RDI, RDI_H,
duke@0 384 RSI, RSI_H,
duke@0 385 RCX, RCX_H,
duke@0 386 RBX, RBX_H,
duke@0 387 R8, R8_H,
duke@0 388 R9, R9_H,
duke@0 389 R10, R10_H,
duke@0 390 R11, R11_H,
duke@0 391 R13, R13_H,
duke@0 392 R14, R14_H);
duke@0 393
duke@0 394 // Class for all long registers except RAX, RDX (and RSP)
duke@0 395 reg_class long_no_rax_rdx_reg(RBP, RBP_H,
duke@0 396 RDI, RDI_H,
duke@0 397 RSI, RSI_H,
duke@0 398 RCX, RCX_H,
duke@0 399 RBX, RBX_H,
duke@0 400 R8, R8_H,
duke@0 401 R9, R9_H,
duke@0 402 R10, R10_H,
duke@0 403 R11, R11_H,
duke@0 404 R13, R13_H,
duke@0 405 R14, R14_H);
duke@0 406
duke@0 407 // Class for all long registers except RCX (and RSP)
duke@0 408 reg_class long_no_rcx_reg(RBP, RBP_H,
duke@0 409 RDI, RDI_H,
duke@0 410 RSI, RSI_H,
duke@0 411 RAX, RAX_H,
duke@0 412 RDX, RDX_H,
duke@0 413 RBX, RBX_H,
duke@0 414 R8, R8_H,
duke@0 415 R9, R9_H,
duke@0 416 R10, R10_H,
duke@0 417 R11, R11_H,
duke@0 418 R13, R13_H,
duke@0 419 R14, R14_H);
duke@0 420
duke@0 421 // Class for all long registers except RAX (and RSP)
duke@0 422 reg_class long_no_rax_reg(RBP, RBP_H,
duke@0 423 RDX, RDX_H,
duke@0 424 RDI, RDI_H,
duke@0 425 RSI, RSI_H,
duke@0 426 RCX, RCX_H,
duke@0 427 RBX, RBX_H,
duke@0 428 R8, R8_H,
duke@0 429 R9, R9_H,
duke@0 430 R10, R10_H,
duke@0 431 R11, R11_H,
duke@0 432 R13, R13_H,
duke@0 433 R14, R14_H);
duke@0 434
duke@0 435 // Singleton class for RAX long register
duke@0 436 reg_class long_rax_reg(RAX, RAX_H);
duke@0 437
duke@0 438 // Singleton class for RCX long register
duke@0 439 reg_class long_rcx_reg(RCX, RCX_H);
duke@0 440
duke@0 441 // Singleton class for RDX long register
duke@0 442 reg_class long_rdx_reg(RDX, RDX_H);
duke@0 443
duke@0 444 // Class for all int registers (except RSP)
duke@0 445 reg_class int_reg(RAX,
duke@0 446 RDX,
duke@0 447 RBP,
duke@0 448 RDI,
duke@0 449 RSI,
duke@0 450 RCX,
duke@0 451 RBX,
duke@0 452 R8,
duke@0 453 R9,
duke@0 454 R10,
duke@0 455 R11,
duke@0 456 R13,
duke@0 457 R14);
duke@0 458
duke@0 459 // Class for all int registers except RCX (and RSP)
duke@0 460 reg_class int_no_rcx_reg(RAX,
duke@0 461 RDX,
duke@0 462 RBP,
duke@0 463 RDI,
duke@0 464 RSI,
duke@0 465 RBX,
duke@0 466 R8,
duke@0 467 R9,
duke@0 468 R10,
duke@0 469 R11,
duke@0 470 R13,
duke@0 471 R14);
duke@0 472
duke@0 473 // Class for all int registers except RAX, RDX (and RSP)
duke@0 474 reg_class int_no_rax_rdx_reg(RBP,
never@304 475 RDI,
duke@0 476 RSI,
duke@0 477 RCX,
duke@0 478 RBX,
duke@0 479 R8,
duke@0 480 R9,
duke@0 481 R10,
duke@0 482 R11,
duke@0 483 R13,
duke@0 484 R14);
duke@0 485
duke@0 486 // Singleton class for RAX int register
duke@0 487 reg_class int_rax_reg(RAX);
duke@0 488
duke@0 489 // Singleton class for RBX int register
duke@0 490 reg_class int_rbx_reg(RBX);
duke@0 491
duke@0 492 // Singleton class for RCX int register
duke@0 493 reg_class int_rcx_reg(RCX);
duke@0 494
duke@0 495 // Singleton class for RCX int register
duke@0 496 reg_class int_rdx_reg(RDX);
duke@0 497
duke@0 498 // Singleton class for RCX int register
duke@0 499 reg_class int_rdi_reg(RDI);
duke@0 500
duke@0 501 // Singleton class for instruction pointer
duke@0 502 // reg_class ip_reg(RIP);
duke@0 503
duke@0 504 // Singleton class for condition codes
duke@0 505 reg_class int_flags(RFLAGS);
duke@0 506
duke@0 507 // Class for all float registers
duke@0 508 reg_class float_reg(XMM0,
duke@0 509 XMM1,
duke@0 510 XMM2,
duke@0 511 XMM3,
duke@0 512 XMM4,
duke@0 513 XMM5,
duke@0 514 XMM6,
duke@0 515 XMM7,
duke@0 516 XMM8,
duke@0 517 XMM9,
duke@0 518 XMM10,
duke@0 519 XMM11,
duke@0 520 XMM12,
duke@0 521 XMM13,
duke@0 522 XMM14,
duke@0 523 XMM15);
duke@0 524
duke@0 525 // Class for all double registers
duke@0 526 reg_class double_reg(XMM0, XMM0_H,
duke@0 527 XMM1, XMM1_H,
duke@0 528 XMM2, XMM2_H,
duke@0 529 XMM3, XMM3_H,
duke@0 530 XMM4, XMM4_H,
duke@0 531 XMM5, XMM5_H,
duke@0 532 XMM6, XMM6_H,
duke@0 533 XMM7, XMM7_H,
duke@0 534 XMM8, XMM8_H,
duke@0 535 XMM9, XMM9_H,
duke@0 536 XMM10, XMM10_H,
duke@0 537 XMM11, XMM11_H,
duke@0 538 XMM12, XMM12_H,
duke@0 539 XMM13, XMM13_H,
duke@0 540 XMM14, XMM14_H,
duke@0 541 XMM15, XMM15_H);
duke@0 542 %}
duke@0 543
duke@0 544
duke@0 545 //----------SOURCE BLOCK-------------------------------------------------------
duke@0 546 // This is a block of C++ code which provides values, functions, and
duke@0 547 // definitions necessary in the rest of the architecture description
duke@0 548 source %{
never@304 549 #define RELOC_IMM64 Assembler::imm_operand
duke@0 550 #define RELOC_DISP32 Assembler::disp32_operand
duke@0 551
duke@0 552 #define __ _masm.
duke@0 553
twisti@1137 554 static int preserve_SP_size() {
kvn@2953 555 return 3; // rex.w, op, rm(reg/reg)
twisti@1137 556 }
twisti@1137 557
duke@0 558 // !!!!! Special hack to get all types of calls to specify the byte offset
duke@0 559 // from the start of the call to the point where the return address
duke@0 560 // will point.
duke@0 561 int MachCallStaticJavaNode::ret_addr_offset()
duke@0 562 {
twisti@1137 563 int offset = 5; // 5 bytes from start of call to where return address points
twisti@1137 564 if (_method_handle_invoke)
twisti@1137 565 offset += preserve_SP_size();
twisti@1137 566 return offset;
duke@0 567 }
duke@0 568
duke@0 569 int MachCallDynamicJavaNode::ret_addr_offset()
duke@0 570 {
duke@0 571 return 15; // 15 bytes from start of call to where return address points
duke@0 572 }
duke@0 573
duke@0 574 // In os_cpu .ad file
duke@0 575 // int MachCallRuntimeNode::ret_addr_offset()
duke@0 576
iveresov@2251 577 // Indicate if the safepoint node needs the polling page as an input,
iveresov@2251 578 // it does if the polling page is more than disp32 away.
duke@0 579 bool SafePointNode::needs_polling_address_input()
duke@0 580 {
iveresov@2251 581 return Assembler::is_polling_page_far();
duke@0 582 }
duke@0 583
duke@0 584 //
duke@0 585 // Compute padding required for nodes which need alignment
duke@0 586 //
duke@0 587
duke@0 588 // The address of the call instruction needs to be 4-byte aligned to
duke@0 589 // ensure that it does not span a cache line so that it can be patched.
duke@0 590 int CallStaticJavaDirectNode::compute_padding(int current_offset) const
duke@0 591 {
duke@0 592 current_offset += 1; // skip call opcode byte
duke@0 593 return round_to(current_offset, alignment_required()) - current_offset;
duke@0 594 }
duke@0 595
duke@0 596 // The address of the call instruction needs to be 4-byte aligned to
duke@0 597 // ensure that it does not span a cache line so that it can be patched.
twisti@1137 598 int CallStaticJavaHandleNode::compute_padding(int current_offset) const
twisti@1137 599 {
twisti@1137 600 current_offset += preserve_SP_size(); // skip mov rbp, rsp
twisti@1137 601 current_offset += 1; // skip call opcode byte
twisti@1137 602 return round_to(current_offset, alignment_required()) - current_offset;
twisti@1137 603 }
twisti@1137 604
twisti@1137 605 // The address of the call instruction needs to be 4-byte aligned to
twisti@1137 606 // ensure that it does not span a cache line so that it can be patched.
duke@0 607 int CallDynamicJavaDirectNode::compute_padding(int current_offset) const
duke@0 608 {
duke@0 609 current_offset += 11; // skip movq instruction + call opcode byte
duke@0 610 return round_to(current_offset, alignment_required()) - current_offset;
duke@0 611 }
duke@0 612
duke@0 613 // EMIT_RM()
twisti@1668 614 void emit_rm(CodeBuffer &cbuf, int f1, int f2, int f3) {
duke@0 615 unsigned char c = (unsigned char) ((f1 << 6) | (f2 << 3) | f3);
twisti@1668 616 cbuf.insts()->emit_int8(c);
duke@0 617 }
duke@0 618
duke@0 619 // EMIT_CC()
twisti@1668 620 void emit_cc(CodeBuffer &cbuf, int f1, int f2) {
duke@0 621 unsigned char c = (unsigned char) (f1 | f2);
twisti@1668 622 cbuf.insts()->emit_int8(c);
duke@0 623 }
duke@0 624
duke@0 625 // EMIT_OPCODE()
twisti@1668 626 void emit_opcode(CodeBuffer &cbuf, int code) {
twisti@1668 627 cbuf.insts()->emit_int8((unsigned char) code);
duke@0 628 }
duke@0 629
duke@0 630 // EMIT_OPCODE() w/ relocation information
duke@0 631 void emit_opcode(CodeBuffer &cbuf,
duke@0 632 int code, relocInfo::relocType reloc, int offset, int format)
duke@0 633 {
twisti@1668 634 cbuf.relocate(cbuf.insts_mark() + offset, reloc, format);
duke@0 635 emit_opcode(cbuf, code);
duke@0 636 }
duke@0 637
duke@0 638 // EMIT_D8()
twisti@1668 639 void emit_d8(CodeBuffer &cbuf, int d8) {
twisti@1668 640 cbuf.insts()->emit_int8((unsigned char) d8);
duke@0 641 }
duke@0 642
duke@0 643 // EMIT_D16()
twisti@1668 644 void emit_d16(CodeBuffer &cbuf, int d16) {
twisti@1668 645 cbuf.insts()->emit_int16(d16);
duke@0 646 }
duke@0 647
duke@0 648 // EMIT_D32()
twisti@1668 649 void emit_d32(CodeBuffer &cbuf, int d32) {
twisti@1668 650 cbuf.insts()->emit_int32(d32);
duke@0 651 }
duke@0 652
duke@0 653 // EMIT_D64()
twisti@1668 654 void emit_d64(CodeBuffer &cbuf, int64_t d64) {
twisti@1668 655 cbuf.insts()->emit_int64(d64);
duke@0 656 }
duke@0 657
duke@0 658 // emit 32 bit value and construct relocation entry from relocInfo::relocType
duke@0 659 void emit_d32_reloc(CodeBuffer& cbuf,
duke@0 660 int d32,
duke@0 661 relocInfo::relocType reloc,
duke@0 662 int format)
duke@0 663 {
duke@0 664 assert(reloc != relocInfo::external_word_type, "use 2-arg emit_d32_reloc");
twisti@1668 665 cbuf.relocate(cbuf.insts_mark(), reloc, format);
twisti@1668 666 cbuf.insts()->emit_int32(d32);
duke@0 667 }
duke@0 668
duke@0 669 // emit 32 bit value and construct relocation entry from RelocationHolder
twisti@1668 670 void emit_d32_reloc(CodeBuffer& cbuf, int d32, RelocationHolder const& rspec, int format) {
duke@0 671 #ifdef ASSERT
duke@0 672 if (rspec.reloc()->type() == relocInfo::oop_type &&
duke@0 673 d32 != 0 && d32 != (intptr_t) Universe::non_oop_word()) {
jrose@989 674 assert(oop((intptr_t)d32)->is_oop() && (ScavengeRootsInCode || !oop((intptr_t)d32)->is_scavengable()), "cannot embed scavengable oops in code");
duke@0 675 }
duke@0 676 #endif
twisti@1668 677 cbuf.relocate(cbuf.insts_mark(), rspec, format);
twisti@1668 678 cbuf.insts()->emit_int32(d32);
duke@0 679 }
duke@0 680
duke@0 681 void emit_d32_reloc(CodeBuffer& cbuf, address addr) {
twisti@1668 682 address next_ip = cbuf.insts_end() + 4;
duke@0 683 emit_d32_reloc(cbuf, (int) (addr - next_ip),
duke@0 684 external_word_Relocation::spec(addr),
duke@0 685 RELOC_DISP32);
duke@0 686 }
duke@0 687
duke@0 688
duke@0 689 // emit 64 bit value and construct relocation entry from relocInfo::relocType
twisti@1668 690 void emit_d64_reloc(CodeBuffer& cbuf, int64_t d64, relocInfo::relocType reloc, int format) {
twisti@1668 691 cbuf.relocate(cbuf.insts_mark(), reloc, format);
twisti@1668 692 cbuf.insts()->emit_int64(d64);
duke@0 693 }
duke@0 694
duke@0 695 // emit 64 bit value and construct relocation entry from RelocationHolder
twisti@1668 696 void emit_d64_reloc(CodeBuffer& cbuf, int64_t d64, RelocationHolder const& rspec, int format) {
duke@0 697 #ifdef ASSERT
duke@0 698 if (rspec.reloc()->type() == relocInfo::oop_type &&
duke@0 699 d64 != 0 && d64 != (int64_t) Universe::non_oop_word()) {
jrose@989 700 assert(oop(d64)->is_oop() && (ScavengeRootsInCode || !oop(d64)->is_scavengable()),
jrose@989 701 "cannot embed scavengable oops in code");
duke@0 702 }
duke@0 703 #endif
twisti@1668 704 cbuf.relocate(cbuf.insts_mark(), rspec, format);
twisti@1668 705 cbuf.insts()->emit_int64(d64);
duke@0 706 }
duke@0 707
duke@0 708 // Access stack slot for load or store
duke@0 709 void store_to_stackslot(CodeBuffer &cbuf, int opcode, int rm_field, int disp)
duke@0 710 {
duke@0 711 emit_opcode(cbuf, opcode); // (e.g., FILD [RSP+src])
duke@0 712 if (-0x80 <= disp && disp < 0x80) {
duke@0 713 emit_rm(cbuf, 0x01, rm_field, RSP_enc); // R/M byte
duke@0 714 emit_rm(cbuf, 0x00, RSP_enc, RSP_enc); // SIB byte
duke@0 715 emit_d8(cbuf, disp); // Displacement // R/M byte
duke@0 716 } else {
duke@0 717 emit_rm(cbuf, 0x02, rm_field, RSP_enc); // R/M byte
duke@0 718 emit_rm(cbuf, 0x00, RSP_enc, RSP_enc); // SIB byte
duke@0 719 emit_d32(cbuf, disp); // Displacement // R/M byte
duke@0 720 }
duke@0 721 }
duke@0 722
duke@0 723 // rRegI ereg, memory mem) %{ // emit_reg_mem
duke@0 724 void encode_RegMem(CodeBuffer &cbuf,
duke@0 725 int reg,
duke@0 726 int base, int index, int scale, int disp, bool disp_is_oop)
duke@0 727 {
duke@0 728 assert(!disp_is_oop, "cannot have disp");
duke@0 729 int regenc = reg & 7;
duke@0 730 int baseenc = base & 7;
duke@0 731 int indexenc = index & 7;
duke@0 732
duke@0 733 // There is no index & no scale, use form without SIB byte
duke@0 734 if (index == 0x4 && scale == 0 && base != RSP_enc && base != R12_enc) {
duke@0 735 // If no displacement, mode is 0x0; unless base is [RBP] or [R13]
duke@0 736 if (disp == 0 && base != RBP_enc && base != R13_enc) {
duke@0 737 emit_rm(cbuf, 0x0, regenc, baseenc); // *
duke@0 738 } else if (-0x80 <= disp && disp < 0x80 && !disp_is_oop) {
duke@0 739 // If 8-bit displacement, mode 0x1
duke@0 740 emit_rm(cbuf, 0x1, regenc, baseenc); // *
duke@0 741 emit_d8(cbuf, disp);
duke@0 742 } else {
duke@0 743 // If 32-bit displacement
duke@0 744 if (base == -1) { // Special flag for absolute address
duke@0 745 emit_rm(cbuf, 0x0, regenc, 0x5); // *
duke@0 746 if (disp_is_oop) {
duke@0 747 emit_d32_reloc(cbuf, disp, relocInfo::oop_type, RELOC_DISP32);
duke@0 748 } else {
duke@0 749 emit_d32(cbuf, disp);
duke@0 750 }
duke@0 751 } else {
duke@0 752 // Normal base + offset
duke@0 753 emit_rm(cbuf, 0x2, regenc, baseenc); // *
duke@0 754 if (disp_is_oop) {
duke@0 755 emit_d32_reloc(cbuf, disp, relocInfo::oop_type, RELOC_DISP32);
duke@0 756 } else {
duke@0 757 emit_d32(cbuf, disp);
duke@0 758 }
duke@0 759 }
duke@0 760 }
duke@0 761 } else {
duke@0 762 // Else, encode with the SIB byte
duke@0 763 // If no displacement, mode is 0x0; unless base is [RBP] or [R13]
duke@0 764 if (disp == 0 && base != RBP_enc && base != R13_enc) {
duke@0 765 // If no displacement
duke@0 766 emit_rm(cbuf, 0x0, regenc, 0x4); // *
duke@0 767 emit_rm(cbuf, scale, indexenc, baseenc);
duke@0 768 } else {
duke@0 769 if (-0x80 <= disp && disp < 0x80 && !disp_is_oop) {
duke@0 770 // If 8-bit displacement, mode 0x1
duke@0 771 emit_rm(cbuf, 0x1, regenc, 0x4); // *
duke@0 772 emit_rm(cbuf, scale, indexenc, baseenc);
duke@0 773 emit_d8(cbuf, disp);
duke@0 774 } else {
duke@0 775 // If 32-bit displacement
duke@0 776 if (base == 0x04 ) {
duke@0 777 emit_rm(cbuf, 0x2, regenc, 0x4);
duke@0 778 emit_rm(cbuf, scale, indexenc, 0x04); // XXX is this valid???
duke@0 779 } else {
duke@0 780 emit_rm(cbuf, 0x2, regenc, 0x4);
duke@0 781 emit_rm(cbuf, scale, indexenc, baseenc); // *
duke@0 782 }
duke@0 783 if (disp_is_oop) {
duke@0 784 emit_d32_reloc(cbuf, disp, relocInfo::oop_type, RELOC_DISP32);
duke@0 785 } else {
duke@0 786 emit_d32(cbuf, disp);
duke@0 787 }
duke@0 788 }
duke@0 789 }
duke@0 790 }
duke@0 791 }
duke@0 792
never@2545 793 // This could be in MacroAssembler but it's fairly C2 specific
never@2545 794 void emit_cmpfp_fixup(MacroAssembler& _masm) {
never@2545 795 Label exit;
never@2545 796 __ jccb(Assembler::noParity, exit);
never@2545 797 __ pushf();
kvn@2953 798 //
kvn@2953 799 // comiss/ucomiss instructions set ZF,PF,CF flags and
kvn@2953 800 // zero OF,AF,SF for NaN values.
kvn@2953 801 // Fixup flags by zeroing ZF,PF so that compare of NaN
kvn@2953 802 // values returns 'less than' result (CF is set).
kvn@2953 803 // Leave the rest of flags unchanged.
kvn@2953 804 //
kvn@2953 805 // 7 6 5 4 3 2 1 0
kvn@2953 806 // |S|Z|r|A|r|P|r|C| (r - reserved bit)
kvn@2953 807 // 0 0 1 0 1 0 1 1 (0x2B)
kvn@2953 808 //
never@2545 809 __ andq(Address(rsp, 0), 0xffffff2b);
never@2545 810 __ popf();
never@2545 811 __ bind(exit);
kvn@2953 812 }
kvn@2953 813
kvn@2953 814 void emit_cmpfp3(MacroAssembler& _masm, Register dst) {
kvn@2953 815 Label done;
kvn@2953 816 __ movl(dst, -1);
kvn@2953 817 __ jcc(Assembler::parity, done);
kvn@2953 818 __ jcc(Assembler::below, done);
kvn@2953 819 __ setb(Assembler::notEqual, dst);
kvn@2953 820 __ movzbl(dst, dst);
kvn@2953 821 __ bind(done);
never@2545 822 }
never@2545 823
duke@0 824
duke@0 825 //=============================================================================
twisti@1915 826 const RegMask& MachConstantBaseNode::_out_RegMask = RegMask::Empty;
twisti@1915 827
twisti@2875 828 int Compile::ConstantTable::calculate_table_base_offset() const {
twisti@2875 829 return 0; // absolute addressing, no offset
twisti@2875 830 }
twisti@2875 831
twisti@1915 832 void MachConstantBaseNode::emit(CodeBuffer& cbuf, PhaseRegAlloc* ra_) const {
twisti@1915 833 // Empty encoding
twisti@1915 834 }
twisti@1915 835
twisti@1915 836 uint MachConstantBaseNode::size(PhaseRegAlloc* ra_) const {
twisti@1915 837 return 0;
twisti@1915 838 }
twisti@1915 839
twisti@1915 840 #ifndef PRODUCT
twisti@1915 841 void MachConstantBaseNode::format(PhaseRegAlloc* ra_, outputStream* st) const {
twisti@1915 842 st->print("# MachConstantBaseNode (empty encoding)");
twisti@1915 843 }
twisti@1915 844 #endif
twisti@1915 845
twisti@1915 846
twisti@1915 847 //=============================================================================
duke@0 848 #ifndef PRODUCT
kvn@3139 849 void MachPrologNode::format(PhaseRegAlloc* ra_, outputStream* st) const {
duke@0 850 Compile* C = ra_->C;
duke@0 851
duke@0 852 int framesize = C->frame_slots() << LogBytesPerInt;
duke@0 853 assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned");
kvn@3139 854 // Remove wordSize for return addr which is already pushed.
kvn@3139 855 framesize -= wordSize;
kvn@3139 856
duke@0 857 if (C->need_stack_bang(framesize)) {
kvn@3139 858 framesize -= wordSize;
kvn@3139 859 st->print("# stack bang");
kvn@3139 860 st->print("\n\t");
kvn@3139 861 st->print("pushq rbp\t# Save rbp");
kvn@3139 862 if (framesize) {
kvn@3139 863 st->print("\n\t");
kvn@3139 864 st->print("subq rsp, #%d\t# Create frame",framesize);
kvn@3139 865 }
kvn@3139 866 } else {
kvn@3139 867 st->print("subq rsp, #%d\t# Create frame",framesize);
kvn@3139 868 st->print("\n\t");
kvn@3139 869 framesize -= wordSize;
kvn@3139 870 st->print("movq [rsp + #%d], rbp\t# Save rbp",framesize);
duke@0 871 }
duke@0 872
duke@0 873 if (VerifyStackAtCalls) {
kvn@3139 874 st->print("\n\t");
kvn@3139 875 framesize -= wordSize;
kvn@3139 876 st->print("movq [rsp + #%d], 0xbadb100d\t# Majik cookie for stack depth check",framesize);
kvn@3139 877 #ifdef ASSERT
kvn@3139 878 st->print("\n\t");
kvn@3139 879 st->print("# stack alignment check");
kvn@3139 880 #endif
duke@0 881 }
kvn@3139 882 st->cr();
duke@0 883 }
duke@0 884 #endif
duke@0 885
kvn@3139 886 void MachPrologNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {
duke@0 887 Compile* C = ra_->C;
kvn@3139 888 MacroAssembler _masm(&cbuf);
duke@0 889
duke@0 890 int framesize = C->frame_slots() << LogBytesPerInt;
kvn@3139 891
kvn@3139 892 __ verified_entry(framesize, C->need_stack_bang(framesize), false);
duke@0 893
twisti@1668 894 C->set_frame_complete(cbuf.insts_size());
duke@0 895
twisti@2875 896 if (C->has_mach_constant_base_node()) {
twisti@2875 897 // NOTE: We set the table base offset here because users might be
twisti@2875 898 // emitted before MachConstantBaseNode.
twisti@2875 899 Compile::ConstantTable& constant_table = C->constant_table();
twisti@2875 900 constant_table.set_table_base_offset(constant_table.calculate_table_base_offset());
twisti@2875 901 }
duke@0 902 }
duke@0 903
duke@0 904 uint MachPrologNode::size(PhaseRegAlloc* ra_) const
duke@0 905 {
duke@0 906 return MachNode::size(ra_); // too many variables; just compute it
duke@0 907 // the hard way
duke@0 908 }
duke@0 909
duke@0 910 int MachPrologNode::reloc() const
duke@0 911 {
duke@0 912 return 0; // a large enough number
duke@0 913 }
duke@0 914
duke@0 915 //=============================================================================
duke@0 916 #ifndef PRODUCT
duke@0 917 void MachEpilogNode::format(PhaseRegAlloc* ra_, outputStream* st) const
duke@0 918 {
duke@0 919 Compile* C = ra_->C;
duke@0 920 int framesize = C->frame_slots() << LogBytesPerInt;
duke@0 921 assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned");
duke@0 922 // Remove word for return adr already pushed
duke@0 923 // and RBP
duke@0 924 framesize -= 2*wordSize;
duke@0 925
duke@0 926 if (framesize) {
iveresov@2251 927 st->print_cr("addq rsp, %d\t# Destroy frame", framesize);
duke@0 928 st->print("\t");
duke@0 929 }
duke@0 930
iveresov@2251 931 st->print_cr("popq rbp");
duke@0 932 if (do_polling() && C->is_method_compilation()) {
duke@0 933 st->print("\t");
iveresov@2251 934 if (Assembler::is_polling_page_far()) {
iveresov@2251 935 st->print_cr("movq rscratch1, #polling_page_address\n\t"
iveresov@2251 936 "testl rax, [rscratch1]\t"
iveresov@2251 937 "# Safepoint: poll for GC");
iveresov@2251 938 } else {
iveresov@2251 939 st->print_cr("testl rax, [rip + #offset_to_poll_page]\t"
iveresov@2251 940 "# Safepoint: poll for GC");
iveresov@2251 941 }
duke@0 942 }
duke@0 943 }
duke@0 944 #endif
duke@0 945
duke@0 946 void MachEpilogNode::emit(CodeBuffer& cbuf, PhaseRegAlloc* ra_) const
duke@0 947 {
duke@0 948 Compile* C = ra_->C;
duke@0 949 int framesize = C->frame_slots() << LogBytesPerInt;
duke@0 950 assert((framesize & (StackAlignmentInBytes-1)) == 0, "frame size not aligned");
duke@0 951 // Remove word for return adr already pushed
duke@0 952 // and RBP
duke@0 953 framesize -= 2*wordSize;
duke@0 954
duke@0 955 // Note that VerifyStackAtCalls' Majik cookie does not change the frame size popped here
duke@0 956
duke@0 957 if (framesize) {
duke@0 958 emit_opcode(cbuf, Assembler::REX_W);
duke@0 959 if (framesize < 0x80) {
duke@0 960 emit_opcode(cbuf, 0x83); // addq rsp, #framesize
duke@0 961 emit_rm(cbuf, 0x3, 0x00, RSP_enc);
duke@0 962 emit_d8(cbuf, framesize);
duke@0 963 } else {
duke@0 964 emit_opcode(cbuf, 0x81); // addq rsp, #framesize
duke@0 965 emit_rm(cbuf, 0x3, 0x00, RSP_enc);
duke@0 966 emit_d32(cbuf, framesize);
duke@0 967 }
duke@0 968 }
duke@0 969
duke@0 970 // popq rbp
duke@0 971 emit_opcode(cbuf, 0x58 | RBP_enc);
duke@0 972
duke@0 973 if (do_polling() && C->is_method_compilation()) {
iveresov@2251 974 MacroAssembler _masm(&cbuf);
iveresov@2251 975 AddressLiteral polling_page(os::get_polling_page(), relocInfo::poll_return_type);
iveresov@2251 976 if (Assembler::is_polling_page_far()) {
iveresov@2251 977 __ lea(rscratch1, polling_page);
iveresov@2251 978 __ relocate(relocInfo::poll_return_type);
iveresov@2251 979 __ testl(rax, Address(rscratch1, 0));
iveresov@2251 980 } else {
iveresov@2251 981 __ testl(rax, polling_page);
iveresov@2251 982 }
duke@0 983 }
duke@0 984 }
duke@0 985
duke@0 986 uint MachEpilogNode::size(PhaseRegAlloc* ra_) const
duke@0 987 {
iveresov@2251 988 return MachNode::size(ra_); // too many variables; just compute it
iveresov@2251 989 // the hard way
duke@0 990 }
duke@0 991
duke@0 992 int MachEpilogNode::reloc() const
duke@0 993 {
duke@0 994 return 2; // a large enough number
duke@0 995 }
duke@0 996
duke@0 997 const Pipeline* MachEpilogNode::pipeline() const
duke@0 998 {
duke@0 999 return MachNode::pipeline_class();
duke@0 1000 }
duke@0 1001
duke@0 1002 int MachEpilogNode::safepoint_offset() const
duke@0 1003 {
duke@0 1004 return 0;
duke@0 1005 }
duke@0 1006
duke@0 1007 //=============================================================================
duke@0 1008
duke@0 1009 enum RC {
duke@0 1010 rc_bad,
duke@0 1011 rc_int,
duke@0 1012 rc_float,
duke@0 1013 rc_stack
duke@0 1014 };
duke@0 1015
duke@0 1016 static enum RC rc_class(OptoReg::Name reg)
duke@0 1017 {
duke@0 1018 if( !OptoReg::is_valid(reg) ) return rc_bad;
duke@0 1019
duke@0 1020 if (OptoReg::is_stack(reg)) return rc_stack;
duke@0 1021
duke@0 1022 VMReg r = OptoReg::as_VMReg(reg);
duke@0 1023
duke@0 1024 if (r->is_Register()) return rc_int;
duke@0 1025
duke@0 1026 assert(r->is_XMMRegister(), "must be");
duke@0 1027 return rc_float;
duke@0 1028 }
duke@0 1029
duke@0 1030 uint MachSpillCopyNode::implementation(CodeBuffer* cbuf,
duke@0 1031 PhaseRegAlloc* ra_,
duke@0 1032 bool do_size,
duke@0 1033 outputStream* st) const
duke@0 1034 {
duke@0 1035
duke@0 1036 // Get registers to move
duke@0 1037 OptoReg::Name src_second = ra_->get_reg_second(in(1));
duke@0 1038 OptoReg::Name src_first = ra_->get_reg_first(in(1));
duke@0 1039 OptoReg::Name dst_second = ra_->get_reg_second(this);
duke@0 1040 OptoReg::Name dst_first = ra_->get_reg_first(this);
duke@0 1041
duke@0 1042 enum RC src_second_rc = rc_class(src_second);
duke@0 1043 enum RC src_first_rc = rc_class(src_first);
duke@0 1044 enum RC dst_second_rc = rc_class(dst_second);
duke@0 1045 enum RC dst_first_rc = rc_class(dst_first);
duke@0 1046
duke@0 1047 assert(OptoReg::is_valid(src_first) && OptoReg::is_valid(dst_first),
duke@0 1048 "must move at least 1 register" );
duke@0 1049
duke@0 1050 if (src_first == dst_first && src_second == dst_second) {
duke@0 1051 // Self copy, no move
duke@0 1052 return 0;
duke@0 1053 } else if (src_first_rc == rc_stack) {
duke@0 1054 // mem ->
duke@0 1055 if (dst_first_rc == rc_stack) {
duke@0 1056 // mem -> mem
duke@0 1057 assert(src_second != dst_first, "overlap");
duke@0 1058 if ((src_first & 1) == 0 && src_first + 1 == src_second &&
duke@0 1059 (dst_first & 1) == 0 && dst_first + 1 == dst_second) {
duke@0 1060 // 64-bit
duke@0 1061 int src_offset = ra_->reg2offset(src_first);
duke@0 1062 int dst_offset = ra_->reg2offset(dst_first);
duke@0 1063 if (cbuf) {
duke@0 1064 emit_opcode(*cbuf, 0xFF);
duke@0 1065 encode_RegMem(*cbuf, RSI_enc, RSP_enc, 0x4, 0, src_offset, false);
duke@0 1066
duke@0 1067 emit_opcode(*cbuf, 0x8F);
duke@0 1068 encode_RegMem(*cbuf, RAX_enc, RSP_enc, 0x4, 0, dst_offset, false);
duke@0 1069
duke@0 1070 #ifndef PRODUCT
duke@0 1071 } else if (!do_size) {
duke@0 1072 st->print("pushq [rsp + #%d]\t# 64-bit mem-mem spill\n\t"
duke@0 1073 "popq [rsp + #%d]",
duke@0 1074 src_offset,
duke@0 1075 dst_offset);
duke@0 1076 #endif
duke@0 1077 }
duke@0 1078 return
duke@0 1079 3 + ((src_offset == 0) ? 0 : (src_offset < 0x80 ? 1 : 4)) +
duke@0 1080 3 + ((dst_offset == 0) ? 0 : (dst_offset < 0x80 ? 1 : 4));
duke@0 1081 } else {
duke@0 1082 // 32-bit
duke@0 1083 assert(!((src_first & 1) == 0 && src_first + 1 == src_second), "no transform");
duke@0 1084 assert(!((dst_first & 1) == 0 && dst_first + 1 == dst_second), "no transform");
duke@0 1085 // No pushl/popl, so:
duke@0 1086 int src_offset = ra_->reg2offset(src_first);
duke@0 1087 int dst_offset = ra_->reg2offset(dst_first);
duke@0 1088 if (cbuf) {
duke@0 1089 emit_opcode(*cbuf, Assembler::REX_W);
duke@0 1090 emit_opcode(*cbuf, 0x89);
duke@0 1091 emit_opcode(*cbuf, 0x44);
duke@0 1092 emit_opcode(*cbuf, 0x24);
duke@0 1093 emit_opcode(*cbuf, 0xF8);
duke@0 1094
duke@0 1095 emit_opcode(*cbuf, 0x8B);
duke@0 1096 encode_RegMem(*cbuf,
duke@0 1097 RAX_enc,
duke@0 1098 RSP_enc, 0x4, 0, src_offset,
duke@0 1099 false);
duke@0 1100
duke@0 1101 emit_opcode(*cbuf, 0x89);
duke@0 1102 encode_RegMem(*cbuf,
duke@0 1103 RAX_enc,
duke@0 1104 RSP_enc, 0x4, 0, dst_offset,
duke@0 1105 false);
duke@0 1106
duke@0 1107 emit_opcode(*cbuf, Assembler::REX_W);
duke@0 1108 emit_opcode(*cbuf, 0x8B);
duke@0 1109 emit_opcode(*cbuf, 0x44);
duke@0 1110 emit_opcode(*cbuf, 0x24);
duke@0 1111 emit_opcode(*cbuf, 0xF8);
duke@0 1112
duke@0 1113 #ifndef PRODUCT
duke@0 1114 } else if (!do_size) {
duke@0 1115 st->print("movq [rsp - #8], rax\t# 32-bit mem-mem spill\n\t"
duke@0 1116 "movl rax, [rsp + #%d]\n\t"
duke@0 1117 "movl [rsp + #%d], rax\n\t"
duke@0 1118 "movq rax, [rsp - #8]",
duke@0 1119 src_offset,
duke@0 1120 dst_offset);
duke@0 1121 #endif
duke@0 1122 }
duke@0 1123 return
duke@0 1124 5 + // movq
duke@0 1125 3 + ((src_offset == 0) ? 0 : (src_offset < 0x80 ? 1 : 4)) + // movl
duke@0 1126 3 + ((dst_offset == 0) ? 0 : (dst_offset < 0x80 ? 1 : 4)) + // movl
duke@0 1127 5; // movq
duke@0 1128 }
duke@0 1129 } else if (dst_first_rc == rc_int) {
duke@0 1130 // mem -> gpr
duke@0 1131 if ((src_first & 1) == 0 && src_first + 1 == src_second &&
duke@0 1132 (dst_first & 1) == 0 && dst_first + 1 == dst_second) {
duke@0 1133 // 64-bit
duke@0 1134 int offset = ra_->reg2offset(src_first);
duke@0 1135 if (cbuf) {
duke@0 1136 if (Matcher::_regEncode[dst_first] < 8) {
duke@0 1137 emit_opcode(*cbuf, Assembler::REX_W);
duke@0 1138 } else {
duke@0 1139 emit_opcode(*cbuf, Assembler::REX_WR);
duke@0 1140 }
duke@0 1141 emit_opcode(*cbuf, 0x8B);
duke@0 1142 encode_RegMem(*cbuf,
duke@0 1143 Matcher::_regEncode[dst_first],
duke@0 1144 RSP_enc, 0x4, 0, offset,
duke@0 1145 false);
duke@0 1146 #ifndef PRODUCT
duke@0 1147 } else if (!do_size) {
duke@0 1148 st->print("movq %s, [rsp + #%d]\t# spill",
duke@0 1149 Matcher::regName[dst_first],
duke@0 1150 offset);
duke@0 1151 #endif
duke@0 1152 }
duke@0 1153 return
duke@0 1154 ((offset == 0) ? 0 : (offset < 0x80 ? 1 : 4)) + 4; // REX
duke@0 1155 } else {
duke@0 1156 // 32-bit
duke@0 1157 assert(!((src_first & 1) == 0 && src_first + 1 == src_second), "no transform");
duke@0 1158 assert(!((dst_first & 1) == 0 && dst_first + 1 == dst_second), "no transform");
duke@0 1159 int offset = ra_->reg2offset(src_first);
duke@0 1160 if (cbuf) {
duke@0 1161 if (Matcher::_regEncode[dst_first] >= 8) {
duke@0 1162 emit_opcode(*cbuf, Assembler::REX_R);
duke@0 1163 }
duke@0 1164 emit_opcode(*cbuf, 0x8B);
duke@0 1165 encode_RegMem(*cbuf,
duke@0 1166 Matcher::_regEncode[dst_first],
duke@0 1167 RSP_enc, 0x4, 0, offset,
duke@0 1168 false);
duke@0 1169 #ifndef PRODUCT
duke@0 1170 } else if (!do_size) {
duke@0 1171 st->print("movl %s, [rsp + #%d]\t# spill",
duke@0 1172 Matcher::regName[dst_first],
duke@0 1173 offset);
duke@0 1174 #endif
duke@0 1175 }
duke@0 1176 return
duke@0 1177 ((offset == 0) ? 0 : (offset < 0x80 ? 1 : 4)) +
duke@0 1178 ((Matcher::_regEncode[dst_first] < 8)
duke@0 1179 ? 3
duke@0 1180 : 4); // REX
duke@0 1181 }
duke@0 1182 } else if (dst_first_rc == rc_float) {
duke@0 1183 // mem-> xmm
duke@0 1184 if ((src_first & 1) == 0 && src_first + 1 == src_second &&
duke@0 1185 (dst_first & 1) == 0 && dst_first + 1 == dst_second) {
duke@0 1186 // 64-bit
duke@0 1187 int offset = ra_->reg2offset(src_first);
duke@0 1188 if (cbuf) {
kvn@2953 1189 MacroAssembler _masm(cbuf);
kvn@2953 1190 __ movdbl( as_XMMRegister(Matcher::_regEncode[dst_first]), Address(rsp, offset));
duke@0 1191 #ifndef PRODUCT
duke@0 1192 } else if (!do_size) {
duke@0 1193 st->print("%s %s, [rsp + #%d]\t# spill",
duke@0 1194 UseXmmLoadAndClearUpper ? "movsd " : "movlpd",
duke@0 1195 Matcher::regName[dst_first],
duke@0 1196 offset);
duke@0 1197 #endif
duke@0 1198 }
duke@0 1199 return
duke@0 1200 ((offset == 0) ? 0 : (offset < 0x80 ? 1 : 4)) +
kvn@2953 1201 ((Matcher::_regEncode[dst_first] >= 8)
kvn@2953 1202 ? 6
kvn@2953 1203 : (5 + ((UseAVX>0)?1:0))); // REX
duke@0 1204 } else {
duke@0 1205 // 32-bit
duke@0 1206 assert(!((src_first & 1) == 0 && src_first + 1 == src_second), "no transform");
duke@0 1207 assert(!((dst_first & 1) == 0 && dst_first + 1 == dst_second), "no transform");
duke@0 1208 int offset = ra_->reg2offset(src_first);
duke@0 1209 if (cbuf) {
kvn@2953 1210 MacroAssembler _masm(cbuf);
kvn@2953 1211 __ movflt( as_XMMRegister(Matcher::_regEncode[dst_first]), Address(rsp, offset));
duke@0 1212 #ifndef PRODUCT
duke@0 1213 } else if (!do_size) {
duke@0 1214 st->print("movss %s, [rsp + #%d]\t# spill",
duke@0 1215 Matcher::regName[dst_first],
duke@0 1216 offset);
duke@0 1217 #endif
duke@0 1218 }
duke@0 1219 return
duke@0 1220 ((offset == 0) ? 0 : (offset < 0x80 ? 1 : 4)) +
kvn@2953 1221 ((Matcher::_regEncode[dst_first] >= 8)
kvn@2953 1222 ? 6
kvn@2953 1223 : (5 + ((UseAVX>0)?1:0))); // REX
duke@0 1224 }
duke@0 1225 }
duke@0 1226 } else if (src_first_rc == rc_int) {
duke@0 1227 // gpr ->
duke@0 1228 if (dst_first_rc == rc_stack) {
duke@0 1229 // gpr -> mem
duke@0 1230 if ((src_first & 1) == 0 && src_first + 1 == src_second &&
duke@0 1231 (dst_first & 1) == 0 && dst_first + 1 == dst_second) {
duke@0 1232 // 64-bit
duke@0 1233 int offset = ra_->reg2offset(dst_first);
duke@0 1234 if (cbuf) {
duke@0 1235 if (Matcher::_regEncode[src_first] < 8) {
duke@0 1236 emit_opcode(*cbuf, Assembler::REX_W);
duke@0 1237 } else {
duke@0 1238 emit_opcode(*cbuf, Assembler::REX_WR);
duke@0 1239 }
duke@0 1240 emit_opcode(*cbuf, 0x89);
duke@0 1241 encode_RegMem(*cbuf,
duke@0 1242 Matcher::_regEncode[src_first],
duke@0 1243 RSP_enc, 0x4, 0, offset,
duke@0 1244 false);
duke@0 1245 #ifndef PRODUCT
duke@0 1246 } else if (!do_size) {
duke@0 1247 st->print("movq [rsp + #%d], %s\t# spill",
duke@0 1248 offset,
duke@0 1249 Matcher::regName[src_first]);
duke@0 1250 #endif
duke@0 1251 }
duke@0 1252 return ((offset == 0) ? 0 : (offset < 0x80 ? 1 : 4)) + 4; // REX
duke@0 1253 } else {
duke@0 1254 // 32-bit
duke@0 1255 assert(!((src_first & 1) == 0 && src_first + 1 == src_second), "no transform");
duke@0 1256 assert(!((dst_first & 1) == 0 && dst_first + 1 == dst_second), "no transform");
duke@0 1257 int offset = ra_->reg2offset(dst_first);
duke@0 1258 if (cbuf) {
duke@0 1259 if (Matcher::_regEncode[src_first] >= 8) {
duke@0 1260 emit_opcode(*cbuf, Assembler::REX_R);
duke@0 1261 }
duke@0 1262 emit_opcode(*cbuf, 0x89);
duke@0 1263 encode_RegMem(*cbuf,
duke@0 1264 Matcher::_regEncode[src_first],
duke@0 1265 RSP_enc, 0x4, 0, offset,
duke@0 1266 false);
duke@0 1267 #ifndef PRODUCT
duke@0 1268 } else if (!do_size) {
duke@0 1269 st->print("movl [rsp + #%d], %s\t# spill",
duke@0 1270 offset,
duke@0 1271 Matcher::regName[src_first]);
duke@0 1272 #endif
duke@0 1273 }
duke@0 1274 return
duke@0 1275 ((offset == 0) ? 0 : (offset < 0x80 ? 1 : 4)) +
duke@0 1276 ((Matcher::_regEncode[src_first] < 8)
duke@0 1277 ? 3
duke@0 1278 : 4); // REX
duke@0 1279 }
duke@0 1280 } else if (dst_first_rc == rc_int) {
duke@0 1281 // gpr -> gpr
duke@0 1282 if ((src_first & 1) == 0 && src_first + 1 == src_second &&
duke@0 1283 (dst_first & 1) == 0 && dst_first + 1 == dst_second) {
duke@0 1284 // 64-bit
duke@0 1285 if (cbuf) {
duke@0 1286 if (Matcher::_regEncode[dst_first] < 8) {
duke@0 1287 if (Matcher::_regEncode[src_first] < 8) {
duke@0 1288 emit_opcode(*cbuf, Assembler::REX_W);
duke@0 1289 } else {
duke@0 1290 emit_opcode(*cbuf, Assembler::REX_WB);
duke@0 1291 }
duke@0 1292 } else {
duke@0 1293 if (Matcher::_regEncode[src_first] < 8) {
duke@0 1294 emit_opcode(*cbuf, Assembler::REX_WR);
duke@0 1295 } else {
duke@0 1296 emit_opcode(*cbuf, Assembler::REX_WRB);
duke@0 1297 }
duke@0 1298 }
duke@0 1299 emit_opcode(*cbuf, 0x8B);
duke@0 1300 emit_rm(*cbuf, 0x3,
duke@0 1301 Matcher::_regEncode[dst_first] & 7,
duke@0 1302 Matcher::_regEncode[src_first] & 7);
duke@0 1303 #ifndef PRODUCT
duke@0 1304 } else if (!do_size) {
duke@0 1305 st->print("movq %s, %s\t# spill",
duke@0 1306 Matcher::regName[dst_first],
duke@0 1307 Matcher::regName[src_first]);
duke@0 1308 #endif
duke@0 1309 }
duke@0 1310 return 3; // REX
duke@0 1311 } else {
duke@0 1312 // 32-bit
duke@0 1313 assert(!((src_first & 1) == 0 && src_first + 1 == src_second), "no transform");
duke@0 1314 assert(!((dst_first & 1) == 0 && dst_first + 1 == dst_second), "no transform");
duke@0 1315 if (cbuf) {
duke@0 1316 if (Matcher::_regEncode[dst_first] < 8) {
duke@0 1317 if (Matcher::_regEncode[src_first] >= 8) {
duke@0 1318 emit_opcode(*cbuf, Assembler::REX_B);
duke@0 1319 }
duke@0 1320 } else {
duke@0 1321 if (Matcher::_regEncode[src_first] < 8) {
duke@0 1322 emit_opcode(*cbuf, Assembler::REX_R);
duke@0 1323 } else {
duke@0 1324 emit_opcode(*cbuf, Assembler::REX_RB);
duke@0 1325 }
duke@0 1326 }
duke@0 1327 emit_opcode(*cbuf, 0x8B);
duke@0 1328 emit_rm(*cbuf, 0x3,
duke@0 1329 Matcher::_regEncode[dst_first] & 7,
duke@0 1330 Matcher::_regEncode[src_first] & 7);
duke@0 1331 #ifndef PRODUCT
duke@0 1332 } else if (!do_size) {
duke@0 1333 st->print("movl %s, %s\t# spill",
duke@0 1334 Matcher::regName[dst_first],
duke@0 1335 Matcher::regName[src_first]);
duke@0 1336 #endif
duke@0 1337 }
duke@0 1338 return
duke@0 1339 (Matcher::_regEncode[src_first] < 8 && Matcher::_regEncode[dst_first] < 8)
duke@0 1340 ? 2
duke@0 1341 : 3; // REX
duke@0 1342 }
duke@0 1343 } else if (dst_first_rc == rc_float) {
duke@0 1344 // gpr -> xmm
duke@0 1345 if ((src_first & 1) == 0 && src_first + 1 == src_second &&
duke@0 1346 (dst_first & 1) == 0 && dst_first + 1 == dst_second) {
duke@0 1347 // 64-bit
duke@0 1348 if (cbuf) {
kvn@2953 1349 MacroAssembler _masm(cbuf);
kvn@2953 1350 __ movdq( as_XMMRegister(Matcher::_regEncode[dst_first]), as_Register(Matcher::_regEncode[src_first]));
duke@0 1351 #ifndef PRODUCT
duke@0 1352 } else if (!do_size) {
duke@0 1353 st->print("movdq %s, %s\t# spill",
duke@0 1354 Matcher::regName[dst_first],
duke@0 1355 Matcher::regName[src_first]);
duke@0 1356 #endif
duke@0 1357 }
duke@0 1358 return 5; // REX
duke@0 1359 } else {
duke@0 1360 // 32-bit
duke@0 1361 assert(!((src_first & 1) == 0 && src_first + 1 == src_second), "no transform");
duke@0 1362 assert(!((dst_first & 1) == 0 && dst_first + 1 == dst_second), "no transform");
duke@0 1363 if (cbuf) {
kvn@2953 1364 MacroAssembler _masm(cbuf);
kvn@2953 1365 __ movdl( as_XMMRegister(Matcher::_regEncode[dst_first]), as_Register(Matcher::_regEncode[src_first]));
duke@0 1366 #ifndef PRODUCT
duke@0 1367 } else if (!do_size) {
duke@0 1368 st->print("movdl %s, %s\t# spill",
duke@0 1369 Matcher::regName[dst_first],
duke@0 1370 Matcher::regName[src_first]);
duke@0 1371 #endif
duke@0 1372 }
duke@0 1373 return
kvn@2953 1374 (Matcher::_regEncode[src_first] >= 8 || Matcher::_regEncode[dst_first] >= 8)
kvn@2953 1375 ? 5
kvn@2953 1376 : (4 + ((UseAVX>0)?1:0)); // REX
duke@0 1377 }
duke@0 1378 }
duke@0 1379 } else if (src_first_rc == rc_float) {
duke@0 1380 // xmm ->
duke@0 1381 if (dst_first_rc == rc_stack) {
duke@0 1382 // xmm -> mem
duke@0 1383 if ((src_first & 1) == 0 && src_first + 1 == src_second &&
duke@0 1384 (dst_first & 1) == 0 && dst_first + 1 == dst_second) {
duke@0 1385 // 64-bit
duke@0 1386 int offset = ra_->reg2offset(dst_first);
duke@0 1387 if (cbuf) {
kvn@2953 1388 MacroAssembler _masm(cbuf);
kvn@2953 1389 __ movdbl( Address(rsp, offset), as_XMMRegister(Matcher::_regEncode[src_first]));
duke@0 1390 #ifndef PRODUCT
duke@0 1391 } else if (!do_size) {
duke@0 1392 st->print("movsd [rsp + #%d], %s\t# spill",
duke@0 1393 offset,
duke@0 1394 Matcher::regName[src_first]);
duke@0 1395 #endif
duke@0 1396 }
duke@0 1397 return
duke@0 1398 ((offset == 0) ? 0 : (offset < 0x80 ? 1 : 4)) +
kvn@2953 1399 ((Matcher::_regEncode[src_first] >= 8)
kvn@2953 1400 ? 6
kvn@2953 1401 : (5 + ((UseAVX>0)?1:0))); // REX
duke@0 1402 } else {
duke@0 1403 // 32-bit
duke@0 1404 assert(!((src_first & 1) == 0 && src_first + 1 == src_second), "no transform");
duke@0 1405 assert(!((dst_first & 1) == 0 && dst_first + 1 == dst_second), "no transform");
duke@0 1406 int offset = ra_->reg2offset(dst_first);
duke@0 1407 if (cbuf) {
kvn@2953 1408 MacroAssembler _masm(cbuf);
kvn@2953 1409 __ movflt(Address(rsp, offset), as_XMMRegister(Matcher::_regEncode[src_first]));
duke@0 1410 #ifndef PRODUCT
duke@0 1411 } else if (!do_size) {
duke@0 1412 st->print("movss [rsp + #%d], %s\t# spill",
duke@0 1413 offset,
duke@0 1414 Matcher::regName[src_first]);
duke@0 1415 #endif
duke@0 1416 }
duke@0 1417 return
duke@0 1418 ((offset == 0) ? 0 : (offset < 0x80 ? 1 : 4)) +
kvn@2953 1419 ((Matcher::_regEncode[src_first] >=8)
kvn@2953 1420 ? 6
kvn@2953 1421 : (5 + ((UseAVX>0)?1:0))); // REX
duke@0 1422 }
duke@0 1423 } else if (dst_first_rc == rc_int) {
duke@0 1424 // xmm -> gpr
duke@0 1425 if ((src_first & 1) == 0 && src_first + 1 == src_second &&
duke@0 1426 (dst_first & 1) == 0 && dst_first + 1 == dst_second) {
duke@0 1427 // 64-bit
duke@0 1428 if (cbuf) {
kvn@2953 1429 MacroAssembler _masm(cbuf);
kvn@2953 1430 __ movdq( as_Register(Matcher::_regEncode[dst_first]), as_XMMRegister(Matcher::_regEncode[src_first]));
duke@0 1431 #ifndef PRODUCT
duke@0 1432 } else if (!do_size) {
duke@0 1433 st->print("movdq %s, %s\t# spill",
duke@0 1434 Matcher::regName[dst_first],
duke@0 1435 Matcher::regName[src_first]);
duke@0 1436 #endif
duke@0 1437 }
duke@0 1438 return 5; // REX
duke@0 1439 } else {
duke@0 1440 // 32-bit
duke@0 1441 assert(!((src_first & 1) == 0 && src_first + 1 == src_second), "no transform");
duke@0 1442 assert(!((dst_first & 1) == 0 && dst_first + 1 == dst_second), "no transform");
duke@0 1443 if (cbuf) {
kvn@2953 1444 MacroAssembler _masm(cbuf);
kvn@2953 1445 __ movdl( as_Register(Matcher::_regEncode[dst_first]), as_XMMRegister(Matcher::_regEncode[src_first]));
duke@0 1446 #ifndef PRODUCT
duke@0 1447 } else if (!do_size) {
duke@0 1448 st->print("movdl %s, %s\t# spill",
duke@0 1449 Matcher::regName[dst_first],
duke@0 1450 Matcher::regName[src_first]);
duke@0 1451 #endif
duke@0 1452 }
duke@0 1453 return
kvn@2953 1454 (Matcher::_regEncode[src_first] >= 8 || Matcher::_regEncode[dst_first] >= 8)
kvn@2953 1455 ? 5
kvn@2953 1456 : (4 + ((UseAVX>0)?1:0)); // REX
duke@0 1457 }
duke@0 1458 } else if (dst_first_rc == rc_float) {
duke@0 1459 // xmm -> xmm
duke@0 1460 if ((src_first & 1) == 0 && src_first + 1 == src_second &&
duke@0 1461 (dst_first & 1) == 0 && dst_first + 1 == dst_second) {
duke@0 1462 // 64-bit
duke@0 1463 if (cbuf) {
kvn@2953 1464 MacroAssembler _masm(cbuf);
kvn@2953 1465 __ movdbl( as_XMMRegister(Matcher::_regEncode[dst_first]), as_XMMRegister(Matcher::_regEncode[src_first]));
duke@0 1466 #ifndef PRODUCT
duke@0 1467 } else if (!do_size) {
duke@0 1468 st->print("%s %s, %s\t# spill",
duke@0 1469 UseXmmRegToRegMoveAll ? "movapd" : "movsd ",
duke@0 1470 Matcher::regName[dst_first],
duke@0 1471 Matcher::regName[src_first]);
duke@0 1472 #endif
duke@0 1473 }
duke@0 1474 return
kvn@2953 1475 (Matcher::_regEncode[src_first] >= 8 || Matcher::_regEncode[dst_first] >= 8)
kvn@2953 1476 ? 5
kvn@2953 1477 : (4 + ((UseAVX>0)?1:0)); // REX
duke@0 1478 } else {
duke@0 1479 // 32-bit
duke@0 1480 assert(!((src_first & 1) == 0 && src_first + 1 == src_second), "no transform");
duke@0 1481 assert(!((dst_first & 1) == 0 && dst_first + 1 == dst_second), "no transform");
duke@0 1482 if (cbuf) {
kvn@2953 1483 MacroAssembler _masm(cbuf);
kvn@2953 1484 __ movflt( as_XMMRegister(Matcher::_regEncode[dst_first]), as_XMMRegister(Matcher::_regEncode[src_first]));
duke@0 1485 #ifndef PRODUCT
duke@0 1486 } else if (!do_size) {
duke@0 1487 st->print("%s %s, %s\t# spill",
duke@0 1488 UseXmmRegToRegMoveAll ? "movaps" : "movss ",
duke@0 1489 Matcher::regName[dst_first],
duke@0 1490 Matcher::regName[src_first]);
duke@0 1491 #endif
duke@0 1492 }
kvn@2953 1493 return ((UseAVX>0) ? 5:
kvn@2953 1494 ((Matcher::_regEncode[src_first] >= 8 || Matcher::_regEncode[dst_first] >= 8)
kvn@2953 1495 ? (UseXmmRegToRegMoveAll ? 4 : 5)
kvn@2953 1496 : (UseXmmRegToRegMoveAll ? 3 : 4))); // REX
duke@0 1497 }
duke@0 1498 }
duke@0 1499 }
duke@0 1500
duke@0 1501 assert(0," foo ");
duke@0 1502 Unimplemented();
duke@0 1503
duke@0 1504 return 0;
duke@0 1505 }
duke@0 1506
duke@0 1507 #ifndef PRODUCT
duke@0 1508 void MachSpillCopyNode::format(PhaseRegAlloc *ra_, outputStream* st) const
duke@0 1509 {
duke@0 1510 implementation(NULL, ra_, false, st);
duke@0 1511 }
duke@0 1512 #endif
duke@0 1513
duke@0 1514 void MachSpillCopyNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const
duke@0 1515 {
duke@0 1516 implementation(&cbuf, ra_, false, NULL);
duke@0 1517 }
duke@0 1518
duke@0 1519 uint MachSpillCopyNode::size(PhaseRegAlloc *ra_) const
duke@0 1520 {
duke@0 1521 return implementation(NULL, ra_, true, NULL);
duke@0 1522 }
duke@0 1523
duke@0 1524 //=============================================================================
duke@0 1525 #ifndef PRODUCT
duke@0 1526 void BoxLockNode::format(PhaseRegAlloc* ra_, outputStream* st) const
duke@0 1527 {
duke@0 1528 int offset = ra_->reg2offset(in_RegMask(0).find_first_elem());
duke@0 1529 int reg = ra_->get_reg_first(this);
duke@0 1530 st->print("leaq %s, [rsp + #%d]\t# box lock",
duke@0 1531 Matcher::regName[reg], offset);
duke@0 1532 }
duke@0 1533 #endif
duke@0 1534
duke@0 1535 void BoxLockNode::emit(CodeBuffer& cbuf, PhaseRegAlloc* ra_) const
duke@0 1536 {
duke@0 1537 int offset = ra_->reg2offset(in_RegMask(0).find_first_elem());
duke@0 1538 int reg = ra_->get_encode(this);
duke@0 1539 if (offset >= 0x80) {
duke@0 1540 emit_opcode(cbuf, reg < 8 ? Assembler::REX_W : Assembler::REX_WR);
duke@0 1541 emit_opcode(cbuf, 0x8D); // LEA reg,[SP+offset]
duke@0 1542 emit_rm(cbuf, 0x2, reg & 7, 0x04);
duke@0 1543 emit_rm(cbuf, 0x0, 0x04, RSP_enc);
duke@0 1544 emit_d32(cbuf, offset);
duke@0 1545 } else {
duke@0 1546 emit_opcode(cbuf, reg < 8 ? Assembler::REX_W : Assembler::REX_WR);
duke@0 1547 emit_opcode(cbuf, 0x8D); // LEA reg,[SP+offset]
duke@0 1548 emit_rm(cbuf, 0x1, reg & 7, 0x04);
duke@0 1549 emit_rm(cbuf, 0x0, 0x04, RSP_enc);
duke@0 1550 emit_d8(cbuf, offset);
duke@0 1551 }
duke@0 1552 }
duke@0 1553
duke@0 1554 uint BoxLockNode::size(PhaseRegAlloc *ra_) const
duke@0 1555 {
duke@0 1556 int offset = ra_->reg2offset(in_RegMask(0).find_first_elem());
duke@0 1557 return (offset < 0x80) ? 5 : 8; // REX
duke@0 1558 }
duke@0 1559
duke@0 1560 //=============================================================================
duke@0 1561
duke@0 1562 // emit call stub, compiled java to interpreter
duke@0 1563 void emit_java_to_interp(CodeBuffer& cbuf)
duke@0 1564 {
duke@0 1565 // Stub is fixed up when the corresponding call is converted from
duke@0 1566 // calling compiled code to calling interpreted code.
duke@0 1567 // movq rbx, 0
duke@0 1568 // jmp -5 # to self
duke@0 1569
twisti@1668 1570 address mark = cbuf.insts_mark(); // get mark within main instrs section
twisti@1668 1571
twisti@1668 1572 // Note that the code buffer's insts_mark is always relative to insts.
duke@0 1573 // That's why we must use the macroassembler to generate a stub.
duke@0 1574 MacroAssembler _masm(&cbuf);
duke@0 1575
duke@0 1576 address base =
duke@0 1577 __ start_a_stub(Compile::MAX_stubs_size);
duke@0 1578 if (base == NULL) return; // CodeBuffer::expand failed
duke@0 1579 // static stub relocation stores the instruction address of the call
duke@0 1580 __ relocate(static_stub_Relocation::spec(mark), RELOC_IMM64);
duke@0 1581 // static stub relocation also tags the methodOop in the code-stream.
duke@0 1582 __ movoop(rbx, (jobject) NULL); // method is zapped till fixup time
never@304 1583 // This is recognized as unresolved by relocs/nativeinst/ic code
duke@0 1584 __ jump(RuntimeAddress(__ pc()));
duke@0 1585
twisti@1668 1586 // Update current stubs pointer and restore insts_end.
duke@0 1587 __ end_a_stub();
duke@0 1588 }
duke@0 1589
duke@0 1590 // size of call stub, compiled java to interpretor
duke@0 1591 uint size_java_to_interp()
duke@0 1592 {
duke@0 1593 return 15; // movq (1+1+8); jmp (1+4)
duke@0 1594 }
duke@0 1595
duke@0 1596 // relocation entries for call stub, compiled java to interpretor
duke@0 1597 uint reloc_java_to_interp()
duke@0 1598 {
duke@0 1599 return 4; // 3 in emit_java_to_interp + 1 in Java_Static_Call
duke@0 1600 }
duke@0 1601
duke@0 1602 //=============================================================================
duke@0 1603 #ifndef PRODUCT
duke@0 1604 void MachUEPNode::format(PhaseRegAlloc* ra_, outputStream* st) const
duke@0 1605 {
coleenp@113 1606 if (UseCompressedOops) {
kvn@1491 1607 st->print_cr("movl rscratch1, [j_rarg0 + oopDesc::klass_offset_in_bytes()]\t# compressed klass");
kvn@642 1608 if (Universe::narrow_oop_shift() != 0) {
kvn@1491 1609 st->print_cr("\tdecode_heap_oop_not_null rscratch1, rscratch1");
kvn@1491 1610 }
kvn@1491 1611 st->print_cr("\tcmpq rax, rscratch1\t # Inline cache check");
coleenp@113 1612 } else {
kvn@1491 1613 st->print_cr("\tcmpq rax, [j_rarg0 + oopDesc::klass_offset_in_bytes()]\t"
kvn@1491 1614 "# Inline cache check");
coleenp@113 1615 }
duke@0 1616 st->print_cr("\tjne SharedRuntime::_ic_miss_stub");
kvn@1491 1617 st->print_cr("\tnop\t# nops to align entry point");
duke@0 1618 }
duke@0 1619 #endif
duke@0 1620
duke@0 1621 void MachUEPNode::emit(CodeBuffer& cbuf, PhaseRegAlloc* ra_) const
duke@0 1622 {
duke@0 1623 MacroAssembler masm(&cbuf);
twisti@1668 1624 uint insts_size = cbuf.insts_size();
coleenp@113 1625 if (UseCompressedOops) {
coleenp@113 1626 masm.load_klass(rscratch1, j_rarg0);
never@304 1627 masm.cmpptr(rax, rscratch1);
coleenp@113 1628 } else {
never@304 1629 masm.cmpptr(rax, Address(j_rarg0, oopDesc::klass_offset_in_bytes()));
coleenp@113 1630 }
duke@0 1631
duke@0 1632 masm.jump_cc(Assembler::notEqual, RuntimeAddress(SharedRuntime::get_ic_miss_stub()));
duke@0 1633
duke@0 1634 /* WARNING these NOPs are critical so that verified entry point is properly
kvn@1491 1635 4 bytes aligned for patching by NativeJump::patch_verified_entry() */
twisti@1668 1636 int nops_cnt = 4 - ((cbuf.insts_size() - insts_size) & 0x3);
kvn@1491 1637 if (OptoBreakpoint) {
duke@0 1638 // Leave space for int3
kvn@1491 1639 nops_cnt -= 1;
duke@0 1640 }
kvn@1491 1641 nops_cnt &= 0x3; // Do not add nops if code is aligned.
kvn@1491 1642 if (nops_cnt > 0)
kvn@1491 1643 masm.nop(nops_cnt);
duke@0 1644 }
duke@0 1645
duke@0 1646 uint MachUEPNode::size(PhaseRegAlloc* ra_) const
duke@0 1647 {
kvn@1491 1648 return MachNode::size(ra_); // too many variables; just compute it
kvn@1491 1649 // the hard way
duke@0 1650 }
duke@0 1651
duke@0 1652
duke@0 1653 //=============================================================================
duke@0 1654 uint size_exception_handler()
duke@0 1655 {
duke@0 1656 // NativeCall instruction size is the same as NativeJump.
duke@0 1657 // Note that this value is also credited (in output.cpp) to
duke@0 1658 // the size of the code section.
duke@0 1659 return NativeJump::instruction_size;
duke@0 1660 }
duke@0 1661
duke@0 1662 // Emit exception handler code.
duke@0 1663 int emit_exception_handler(CodeBuffer& cbuf)
duke@0 1664 {
duke@0 1665
twisti@1668 1666 // Note that the code buffer's insts_mark is always relative to insts.
duke@0 1667 // That's why we must use the macroassembler to generate a handler.
duke@0 1668 MacroAssembler _masm(&cbuf);
duke@0 1669 address base =
duke@0 1670 __ start_a_stub(size_exception_handler());
duke@0 1671 if (base == NULL) return 0; // CodeBuffer::expand failed
duke@0 1672 int offset = __ offset();
twisti@1668 1673 __ jump(RuntimeAddress(OptoRuntime::exception_blob()->entry_point()));
duke@0 1674 assert(__ offset() - offset <= (int) size_exception_handler(), "overflow");
duke@0 1675 __ end_a_stub();
duke@0 1676 return offset;
duke@0 1677 }
duke@0 1678
duke@0 1679 uint size_deopt_handler()
duke@0 1680 {
duke@0 1681 // three 5 byte instructions
duke@0 1682 return 15;
duke@0 1683 }
duke@0 1684
duke@0 1685 // Emit deopt handler code.
duke@0 1686 int emit_deopt_handler(CodeBuffer& cbuf)
duke@0 1687 {
duke@0 1688
twisti@1668 1689 // Note that the code buffer's insts_mark is always relative to insts.
duke@0 1690 // That's why we must use the macroassembler to generate a handler.
duke@0 1691 MacroAssembler _masm(&cbuf);
duke@0 1692 address base =
duke@0 1693 __ start_a_stub(size_deopt_handler());
duke@0 1694 if (base == NULL) return 0; // CodeBuffer::expand failed
duke@0 1695 int offset = __ offset();
duke@0 1696 address the_pc = (address) __ pc();
duke@0 1697 Label next;
duke@0 1698 // push a "the_pc" on the stack without destroying any registers
duke@0 1699 // as they all may be live.
duke@0 1700
duke@0 1701 // push address of "next"
duke@0 1702 __ call(next, relocInfo::none); // reloc none is fine since it is a disp32
duke@0 1703 __ bind(next);
duke@0 1704 // adjust it so it matches "the_pc"
never@304 1705 __ subptr(Address(rsp, 0), __ offset() - offset);
duke@0 1706 __ jump(RuntimeAddress(SharedRuntime::deopt_blob()->unpack()));
duke@0 1707 assert(__ offset() - offset <= (int) size_deopt_handler(), "overflow");
duke@0 1708 __ end_a_stub();
duke@0 1709 return offset;
duke@0 1710 }
duke@0 1711
duke@0 1712
twisti@775 1713 const bool Matcher::match_rule_supported(int opcode) {
twisti@775 1714 if (!has_match_rule(opcode))
twisti@775 1715 return false;
twisti@775 1716
twisti@775 1717 return true; // Per default match rules are supported.
twisti@775 1718 }
twisti@775 1719
duke@0 1720 int Matcher::regnum_to_fpu_offset(int regnum)
duke@0 1721 {
duke@0 1722 return regnum - 32; // The FP registers are in the second chunk
duke@0 1723 }
duke@0 1724
duke@0 1725 // This is UltraSparc specific, true just means we have fast l2f conversion
duke@0 1726 const bool Matcher::convL2FSupported(void) {
duke@0 1727 return true;
duke@0 1728 }
duke@0 1729
duke@0 1730 // Vector width in bytes
duke@0 1731 const uint Matcher::vector_width_in_bytes(void) {
duke@0 1732 return 8;
duke@0 1733 }
duke@0 1734
duke@0 1735 // Vector ideal reg
duke@0 1736 const uint Matcher::vector_ideal_reg(void) {
duke@0 1737 return Op_RegD;
duke@0 1738 }
duke@0 1739
duke@0 1740 // Is this branch offset short enough that a short branch can be used?
duke@0 1741 //
duke@0 1742 // NOTE: If the platform does not provide any short branch variants, then
duke@0 1743 // this method should return false for offset 0.
kvn@2614 1744 bool Matcher::is_short_branch_offset(int rule, int br_size, int offset) {
kvn@2614 1745 // The passed offset is relative to address of the branch.
kvn@2614 1746 // On 86 a branch displacement is calculated relative to address
kvn@2614 1747 // of a next instruction.
kvn@2614 1748 offset -= br_size;
kvn@2614 1749
never@415 1750 // the short version of jmpConUCF2 contains multiple branches,
never@415 1751 // making the reach slightly less
never@415 1752 if (rule == jmpConUCF2_rule)
never@415 1753 return (-126 <= offset && offset <= 125);
never@415 1754 return (-128 <= offset && offset <= 127);
duke@0 1755 }
duke@0 1756
duke@0 1757 const bool Matcher::isSimpleConstant64(jlong value) {
duke@0 1758 // Will one (StoreL ConL) be cheaper than two (StoreI ConI)?.
duke@0 1759 //return value == (int) value; // Cf. storeImmL and immL32.
duke@0 1760
duke@0 1761 // Probably always true, even if a temp register is required.
duke@0 1762 return true;
duke@0 1763 }
duke@0 1764
duke@0 1765 // The ecx parameter to rep stosq for the ClearArray node is in words.
duke@0 1766 const bool Matcher::init_array_count_is_in_bytes = false;
duke@0 1767
duke@0 1768 // Threshold size for cleararray.
duke@0 1769 const int Matcher::init_array_short_size = 8 * BytesPerLong;
duke@0 1770
kvn@2808 1771 // No additional cost for CMOVL.
kvn@2808 1772 const int Matcher::long_cmove_cost() { return 0; }
kvn@2808 1773
kvn@2808 1774 // No CMOVF/CMOVD with SSE2
kvn@2808 1775 const int Matcher::float_cmove_cost() { return ConditionalMoveLimit; }
kvn@2808 1776
duke@0 1777 // Should the Matcher clone shifts on addressing modes, expecting them
duke@0 1778 // to be subsumed into complex addressing expressions or compute them
duke@0 1779 // into registers? True for Intel but false for most RISCs
duke@0 1780 const bool Matcher::clone_shift_expressions = true;
duke@0 1781
roland@2248 1782 // Do we need to mask the count passed to shift instructions or does
roland@2248 1783 // the cpu only look at the lower 5/6 bits anyway?
roland@2248 1784 const bool Matcher::need_masked_shift_count = false;
roland@2248 1785
kvn@1495 1786 bool Matcher::narrow_oop_use_complex_address() {
kvn@1495 1787 assert(UseCompressedOops, "only for compressed oops code");
kvn@1495 1788 return (LogMinObjAlignmentInBytes <= 3);
kvn@1495 1789 }
kvn@1495 1790
duke@0 1791 // Is it better to copy float constants, or load them directly from
duke@0 1792 // memory? Intel can load a float constant from a direct address,
duke@0 1793 // requiring no extra registers. Most RISCs will have to materialize
duke@0 1794 // an address into a register first, so they would do better to copy
duke@0 1795 // the constant from stack.
duke@0 1796 const bool Matcher::rematerialize_float_constants = true; // XXX
duke@0 1797
duke@0 1798 // If CPU can load and store mis-aligned doubles directly then no
duke@0 1799 // fixup is needed. Else we split the double into 2 integer pieces
duke@0 1800 // and move it piece-by-piece. Only happens when passing doubles into
duke@0 1801 // C code as the Java calling convention forces doubles to be aligned.
duke@0 1802 const bool Matcher::misaligned_doubles_ok = true;
duke@0 1803
duke@0 1804 // No-op on amd64
duke@0 1805 void Matcher::pd_implicit_null_fixup(MachNode *node, uint idx) {}
duke@0 1806
duke@0 1807 // Advertise here if the CPU requires explicit rounding operations to
duke@0 1808 // implement the UseStrictFP mode.
duke@0 1809 const bool Matcher::strict_fp_requires_explicit_rounding = true;
duke@0 1810
kvn@1274 1811 // Are floats conerted to double when stored to stack during deoptimization?
kvn@1274 1812 // On x64 it is stored without convertion so we can use normal access.
kvn@1274 1813 bool Matcher::float_in_double() { return false; }
kvn@1274 1814
duke@0 1815 // Do ints take an entire long register or just half?
duke@0 1816 const bool Matcher::int_in_long = true;
duke@0 1817
duke@0 1818 // Return whether or not this register is ever used as an argument.
duke@0 1819 // This function is used on startup to build the trampoline stubs in
duke@0 1820 // generateOptoStub. Registers not mentioned will be killed by the VM
duke@0 1821 // call in the trampoline, and arguments in those registers not be
duke@0 1822 // available to the callee.
duke@0 1823 bool Matcher::can_be_java_arg(int reg)
duke@0 1824 {
duke@0 1825 return
duke@0 1826 reg == RDI_num || reg == RDI_H_num ||
duke@0 1827 reg == RSI_num || reg == RSI_H_num ||
duke@0 1828 reg == RDX_num || reg == RDX_H_num ||
duke@0 1829 reg == RCX_num || reg == RCX_H_num ||
duke@0 1830 reg == R8_num || reg == R8_H_num ||
duke@0 1831 reg == R9_num || reg == R9_H_num ||
coleenp@113 1832 reg == R12_num || reg == R12_H_num ||
duke@0 1833 reg == XMM0_num || reg == XMM0_H_num ||
duke@0 1834 reg == XMM1_num || reg == XMM1_H_num ||
duke@0 1835 reg == XMM2_num || reg == XMM2_H_num ||
duke@0 1836 reg == XMM3_num || reg == XMM3_H_num ||
duke@0 1837 reg == XMM4_num || reg == XMM4_H_num ||
duke@0 1838 reg == XMM5_num || reg == XMM5_H_num ||
duke@0 1839 reg == XMM6_num || reg == XMM6_H_num ||
duke@0 1840 reg == XMM7_num || reg == XMM7_H_num;
duke@0 1841 }
duke@0 1842
duke@0 1843 bool Matcher::is_spillable_arg(int reg)
duke@0 1844 {
duke@0 1845 return can_be_java_arg(reg);
duke@0 1846 }
duke@0 1847
kvn@1834 1848 bool Matcher::use_asm_for_ldiv_by_con( jlong divisor ) {
kvn@1834 1849 // In 64 bit mode a code which use multiply when
kvn@1834 1850 // devisor is constant is faster than hardware
kvn@1834 1851 // DIV instruction (it uses MulHiL).
kvn@1834 1852 return false;
kvn@1834 1853 }
kvn@1834 1854
duke@0 1855 // Register for DIVI projection of divmodI
duke@0 1856 RegMask Matcher::divI_proj_mask() {
roland@2882 1857 return INT_RAX_REG_mask();
duke@0 1858 }
duke@0 1859
duke@0 1860 // Register for MODI projection of divmodI
duke@0 1861 RegMask Matcher::modI_proj_mask() {
roland@2882 1862 return INT_RDX_REG_mask();
duke@0 1863 }
duke@0 1864
duke@0 1865 // Register for DIVL projection of divmodL
duke@0 1866 RegMask Matcher::divL_proj_mask() {
roland@2882 1867 return LONG_RAX_REG_mask();
duke@0 1868 }
duke@0 1869
duke@0 1870 // Register for MODL projection of divmodL
duke@0 1871 RegMask Matcher::modL_proj_mask() {
roland@2882 1872 return LONG_RDX_REG_mask();
duke@0 1873 }
duke@0 1874
twisti@1137 1875 const RegMask Matcher::method_handle_invoke_SP_save_mask() {
roland@2882 1876 return PTR_RBP_REG_mask();
twisti@1137 1877 }
twisti@1137 1878
coleenp@113 1879 static Address build_address(int b, int i, int s, int d) {
coleenp@113 1880 Register index = as_Register(i);
coleenp@113 1881 Address::ScaleFactor scale = (Address::ScaleFactor)s;
coleenp@113 1882 if (index == rsp) {
coleenp@113 1883 index = noreg;
coleenp@113 1884 scale = Address::no_scale;
coleenp@113 1885 }
coleenp@113 1886 Address addr(as_Register(b), index, scale, d);
coleenp@113 1887 return addr;
coleenp@113 1888 }
coleenp@113 1889
duke@0 1890 %}
duke@0 1891
duke@0 1892 //----------ENCODING BLOCK-----------------------------------------------------
duke@0 1893 // This block specifies the encoding classes used by the compiler to
duke@0 1894 // output byte streams. Encoding classes are parameterized macros
duke@0 1895 // used by Machine Instruction Nodes in order to generate the bit
duke@0 1896 // encoding of the instruction. Operands specify their base encoding
duke@0 1897 // interface with the interface keyword. There are currently
duke@0 1898 // supported four interfaces, REG_INTER, CONST_INTER, MEMORY_INTER, &
duke@0 1899 // COND_INTER. REG_INTER causes an operand to generate a function
duke@0 1900 // which returns its register number when queried. CONST_INTER causes
duke@0 1901 // an operand to generate a function which returns the value of the
duke@0 1902 // constant when queried. MEMORY_INTER causes an operand to generate
duke@0 1903 // four functions which return the Base Register, the Index Register,
duke@0 1904 // the Scale Value, and the Offset Value of the operand when queried.
duke@0 1905 // COND_INTER causes an operand to generate six functions which return
duke@0 1906 // the encoding code (ie - encoding bits for the instruction)
duke@0 1907 // associated with each basic boolean condition for a conditional
duke@0 1908 // instruction.
duke@0 1909 //
duke@0 1910 // Instructions specify two basic values for encoding. Again, a
duke@0 1911 // function is available to check if the constant displacement is an
duke@0 1912 // oop. They use the ins_encode keyword to specify their encoding
duke@0 1913 // classes (which must be a sequence of enc_class names, and their
duke@0 1914 // parameters, specified in the encoding block), and they use the
duke@0 1915 // opcode keyword to specify, in order, their primary, secondary, and
duke@0 1916 // tertiary opcode. Only the opcode sections which a particular
duke@0 1917 // instruction needs for encoding need to be specified.
duke@0 1918 encode %{
duke@0 1919 // Build emit functions for each basic byte or larger field in the
duke@0 1920 // intel encoding scheme (opcode, rm, sib, immediate), and call them
duke@0 1921 // from C++ code in the enc_class source block. Emit functions will
duke@0 1922 // live in the main source block for now. In future, we can
duke@0 1923 // generalize this by adding a syntax that specifies the sizes of
duke@0 1924 // fields in an order, so that the adlc can build the emit functions
duke@0 1925 // automagically
duke@0 1926
duke@0 1927 // Emit primary opcode
duke@0 1928 enc_class OpcP
duke@0 1929 %{
duke@0 1930 emit_opcode(cbuf, $primary);
duke@0 1931 %}
duke@0 1932
duke@0 1933 // Emit secondary opcode
duke@0 1934 enc_class OpcS
duke@0 1935 %{
duke@0 1936 emit_opcode(cbuf, $secondary);
duke@0 1937 %}
duke@0 1938
duke@0 1939 // Emit tertiary opcode
duke@0 1940 enc_class OpcT
duke@0 1941 %{
duke@0 1942 emit_opcode(cbuf, $tertiary);
duke@0 1943 %}
duke@0 1944
duke@0 1945 // Emit opcode directly
duke@0 1946 enc_class Opcode(immI d8)
duke@0 1947 %{
duke@0 1948 emit_opcode(cbuf, $d8$$constant);
duke@0 1949 %}
duke@0 1950
duke@0 1951 // Emit size prefix
duke@0 1952 enc_class SizePrefix
duke@0 1953 %{
duke@0 1954 emit_opcode(cbuf, 0x66);
duke@0 1955 %}
duke@0 1956
duke@0 1957 enc_class reg(rRegI reg)
duke@0 1958 %{
duke@0 1959 emit_rm(cbuf, 0x3, 0, $reg$$reg & 7);
duke@0 1960 %}
duke@0 1961
duke@0 1962 enc_class reg_reg(rRegI dst, rRegI src)
duke@0 1963 %{
duke@0 1964 emit_rm(cbuf, 0x3, $dst$$reg & 7, $src$$reg & 7);
duke@0 1965 %}
duke@0 1966
duke@0 1967 enc_class opc_reg_reg(immI opcode, rRegI dst, rRegI src)
duke@0 1968 %{
duke@0 1969 emit_opcode(cbuf, $opcode$$constant);
duke@0 1970 emit_rm(cbuf, 0x3, $dst$$reg & 7, $src$$reg & 7);
duke@0 1971 %}
duke@0 1972
duke@0 1973 enc_class cdql_enc(no_rax_rdx_RegI div)
duke@0 1974 %{
duke@0 1975 // Full implementation of Java idiv and irem; checks for
duke@0 1976 // special case as described in JVM spec., p.243 & p.271.
duke@0 1977 //
duke@0 1978 // normal case special case
duke@0 1979 //
duke@0 1980 // input : rax: dividend min_int
duke@0 1981 // reg: divisor -1
duke@0 1982 //
duke@0 1983 // output: rax: quotient (= rax idiv reg) min_int
duke@0 1984 // rdx: remainder (= rax irem reg) 0
duke@0 1985 //
duke@0 1986 // Code sequnce:
duke@0 1987 //
duke@0 1988 // 0: 3d 00 00 00 80 cmp $0x80000000,%eax
duke@0 1989 // 5: 75 07/08 jne e <normal>
duke@0 1990 // 7: 33 d2 xor %edx,%edx
duke@0 1991 // [div >= 8 -> offset + 1]
duke@0 1992 // [REX_B]
duke@0 1993 // 9: 83 f9 ff cmp $0xffffffffffffffff,$div
duke@0 1994 // c: 74 03/04 je 11 <done>
duke@0 1995 // 000000000000000e <normal>:
duke@0 1996 // e: 99 cltd
duke@0 1997 // [div >= 8 -> offset + 1]
duke@0 1998 // [REX_B]
duke@0 1999 // f: f7 f9 idiv $div
duke@0 2000 // 0000000000000011 <done>:
duke@0 2001
duke@0 2002 // cmp $0x80000000,%eax
duke@0 2003 emit_opcode(cbuf, 0x3d);
duke@0 2004 emit_d8(cbuf, 0x00);
duke@0 2005 emit_d8(cbuf, 0x00);
duke@0 2006 emit_d8(cbuf, 0x00);
duke@0 2007 emit_d8(cbuf, 0x80);
duke@0 2008
duke@0 2009 // jne e <normal>
duke@0 2010 emit_opcode(cbuf, 0x75);
duke@0 2011 emit_d8(cbuf, $div$$reg < 8 ? 0x07 : 0x08);
duke@0 2012
duke@0 2013 // xor %edx,%edx
duke@0 2014 emit_opcode(cbuf, 0x33);
duke@0 2015 emit_d8(cbuf, 0xD2);
duke@0 2016
duke@0 2017 // cmp $0xffffffffffffffff,%ecx
duke@0 2018 if ($div$$reg >= 8) {
duke@0 2019 emit_opcode(cbuf, Assembler::REX_B);
duke@0 2020 }
duke@0 2021 emit_opcode(cbuf, 0x83);
duke@0 2022 emit_rm(cbuf, 0x3, 0x7, $div$$reg & 7);
duke@0 2023 emit_d8(cbuf, 0xFF);
duke@0 2024
duke@0 2025 // je 11 <done>
duke@0 2026 emit_opcode(cbuf, 0x74);
duke@0 2027 emit_d8(cbuf, $div$$reg < 8 ? 0x03 : 0x04);
duke@0 2028
duke@0 2029 // <normal>
duke@0 2030 // cltd
duke@0 2031 emit_opcode(cbuf, 0x99);
duke@0 2032
duke@0 2033 // idivl (note: must be emitted by the user of this rule)
duke@0 2034 // <done>
duke@0 2035 %}
duke@0 2036
duke@0 2037 enc_class cdqq_enc(no_rax_rdx_RegL div)
duke@0 2038 %{
duke@0 2039 // Full implementation of Java ldiv and lrem; checks for
duke@0 2040 // special case as described in JVM spec., p.243 & p.271.
duke@0 2041 //
duke@0 2042 // normal case special case
duke@0 2043 //
duke@0 2044 // input : rax: dividend min_long
duke@0 2045 // reg: divisor -1
duke@0 2046 //
duke@0 2047 // output: rax: quotient (= rax idiv reg) min_long
duke@0 2048 // rdx: remainder (= rax irem reg) 0
duke@0 2049 //
duke@0 2050 // Code sequnce:
duke@0 2051 //
duke@0 2052 // 0: 48 ba 00 00 00 00 00 mov $0x8000000000000000,%rdx
duke@0 2053 // 7: 00 00 80
duke@0 2054 // a: 48 39 d0 cmp %rdx,%rax
duke@0 2055 // d: 75 08 jne 17 <normal>
duke@0 2056 // f: 33 d2 xor %edx,%edx
duke@0 2057 // 11: 48 83 f9 ff cmp $0xffffffffffffffff,$div
duke@0 2058 // 15: 74 05 je 1c <done>
duke@0 2059 // 0000000000000017 <normal>:
duke@0 2060 // 17: 48 99 cqto
duke@0 2061 // 19: 48 f7 f9 idiv $div
duke@0 2062 // 000000000000001c <done>:
duke@0 2063
duke@0 2064 // mov $0x8000000000000000,%rdx
duke@0 2065 emit_opcode(cbuf, Assembler::REX_W);
duke@0 2066 emit_opcode(cbuf, 0xBA);
duke@0 2067 emit_d8(cbuf, 0x00);
duke@0 2068 emit_d8(cbuf, 0x00);
duke@0 2069 emit_d8(cbuf, 0x00);
duke@0 2070 emit_d8(cbuf, 0x00);
duke@0 2071 emit_d8(cbuf, 0x00);
duke@0 2072 emit_d8(cbuf, 0x00);
duke@0 2073 emit_d8(cbuf, 0x00);
duke@0 2074 emit_d8(cbuf, 0x80);
duke@0 2075
duke@0 2076 // cmp %rdx,%rax
duke@0 2077 emit_opcode(cbuf, Assembler::REX_W);
duke@0 2078 emit_opcode(cbuf, 0x39);
duke@0 2079 emit_d8(cbuf, 0xD0);
duke@0 2080
duke@0 2081 // jne 17 <normal>
duke@0 2082 emit_opcode(cbuf, 0x75);
duke@0 2083 emit_d8(cbuf, 0x08);
duke@0 2084
duke@0 2085 // xor %edx,%edx
duke@0 2086 emit_opcode(cbuf, 0x33);
duke@0 2087 emit_d8(cbuf, 0xD2);
duke@0 2088
duke@0 2089 // cmp $0xffffffffffffffff,$div
duke@0 2090 emit_opcode(cbuf, $div$$reg < 8 ? Assembler::REX_W : Assembler::REX_WB);
duke@0 2091 emit_opcode(cbuf, 0x83);
duke@0 2092 emit_rm(cbuf, 0x3, 0x7, $div$$reg & 7);
duke@0 2093 emit_d8(cbuf, 0xFF);
duke@0 2094
duke@0 2095 // je 1e <done>
duke@0 2096 emit_opcode(cbuf, 0x74);
duke@0 2097 emit_d8(cbuf, 0x05);
duke@0 2098
duke@0 2099 // <normal>
duke@0 2100 // cqto
duke@0 2101 emit_opcode(cbuf, Assembler::REX_W);
duke@0 2102 emit_opcode(cbuf, 0x99);
duke@0 2103
duke@0 2104 // idivq (note: must be emitted by the user of this rule)
duke@0 2105 // <done>
duke@0 2106 %}
duke@0 2107
duke@0 2108 // Opcde enc_class for 8/32 bit immediate instructions with sign-extension
duke@0 2109 enc_class OpcSE(immI imm)
duke@0 2110 %{
duke@0 2111 // Emit primary opcode and set sign-extend bit
duke@0 2112 // Check for 8-bit immediate, and set sign extend bit in opcode
duke@0 2113 if (-0x80 <= $imm$$constant && $imm$$constant < 0x80) {
duke@0 2114 emit_opcode(cbuf, $primary | 0x02);
duke@0 2115 } else {
duke@0 2116 // 32-bit immediate
duke@0 2117 emit_opcode(cbuf, $primary);
duke@0 2118 }
duke@0 2119 %}
duke@0 2120
duke@0 2121 enc_class OpcSErm(rRegI dst, immI imm)
duke@0 2122 %{
duke@0 2123 // OpcSEr/m
duke@0 2124 int dstenc = $dst$$reg;
duke@0 2125 if (dstenc >= 8) {
duke@0 2126 emit_opcode(cbuf, Assembler::REX_B);
duke@0 2127 dstenc -= 8;
duke@0 2128 }
duke@0 2129 // Emit primary opcode and set sign-extend bit
duke@0 2130 // Check for 8-bit immediate, and set sign extend bit in opcode
duke@0 2131 if (-0x80 <= $imm$$constant && $imm$$constant < 0x80) {
duke@0 2132 emit_opcode(cbuf, $primary | 0x02);
duke@0 2133 } else {
duke@0 2134 // 32-bit immediate
duke@0 2135 emit_opcode(cbuf, $primary);
duke@0 2136 }
duke@0 2137 // Emit r/m byte with secondary opcode, after primary opcode.
duke@0 2138 emit_rm(cbuf, 0x3, $secondary, dstenc);
duke@0 2139 %}
duke@0 2140
duke@0 2141 enc_class OpcSErm_wide(rRegL dst, immI imm)
duke@0 2142 %{
duke@0 2143 // OpcSEr/m
duke@0 2144 int dstenc = $dst$$reg;
duke@0 2145 if (dstenc < 8) {
duke@0 2146 emit_opcode(cbuf, Assembler::REX_W);
duke@0 2147 } else {
duke@0 2148 emit_opcode(cbuf, Assembler::REX_WB);
duke@0 2149 dstenc -= 8;
duke@0 2150 }
duke@0 2151 // Emit primary opcode and set sign-extend bit
duke@0 2152 // Check for 8-bit immediate, and set sign extend bit in opcode
duke@0 2153 if (-0x80 <= $imm$$constant && $imm$$constant < 0x80) {
duke@0 2154 emit_opcode(cbuf, $primary | 0x02);
duke@0 2155 } else {
duke@0 2156 // 32-bit immediate
duke@0 2157 emit_opcode(cbuf, $primary);
duke@0 2158 }
duke@0 2159 // Emit r/m byte with secondary opcode, after primary opcode.
duke@0 2160 emit_rm(cbuf, 0x3, $secondary, dstenc);
duke@0 2161 %}
duke@0 2162
duke@0 2163 enc_class Con8or32(immI imm)
duke@0 2164 %{
duke@0 2165 // Check for 8-bit immediate, and set sign extend bit in opcode
duke@0 2166 if (-0x80 <= $imm$$constant && $imm$$constant < 0x80) {
duke@0 2167 $$$emit8$imm$$constant;
duke@0 2168 } else {
duke@0 2169 // 32-bit immediate
duke@0 2170 $$$emit32$imm$$constant;
duke@0 2171 }
duke@0 2172 %}
duke@0 2173
duke@0 2174 enc_class opc2_reg(rRegI dst)
duke@0 2175 %{
duke@0 2176 // BSWAP
duke@0 2177 emit_cc(cbuf, $secondary, $dst$$reg);
duke@0 2178 %}
duke@0 2179
duke@0 2180 enc_class opc3_reg(rRegI dst)
duke@0 2181 %{
duke@0 2182 // BSWAP
duke@0 2183 emit_cc(cbuf, $tertiary, $dst$$reg);
duke@0 2184 %}
duke@0 2185
duke@0 2186 enc_class reg_opc(rRegI div)
duke@0 2187 %{
duke@0 2188 // INC, DEC, IDIV, IMOD, JMP indirect, ...
duke@0 2189 emit_rm(cbuf, 0x3, $secondary, $div$$reg & 7);
duke@0 2190 %}
duke@0 2191
duke@0 2192 enc_class enc_cmov(cmpOp cop)
duke@0 2193 %{
duke@0 2194 // CMOV
duke@0 2195 $$$emit8$primary;
duke@0 2196 emit_cc(cbuf, $secondary, $cop$$cmpcode);
duke@0 2197 %}
duke@0 2198
duke@0 2199 enc_class enc_PartialSubtypeCheck()
duke@0 2200 %{
duke@0 2201 Register Rrdi = as_Register(RDI_enc); // result register
duke@0 2202 Register Rrax = as_Register(RAX_enc); // super class
duke@0 2203 Register Rrcx = as_Register(RCX_enc); // killed
duke@0 2204 Register Rrsi = as_Register(RSI_enc); // sub class
jrose@644 2205 Label miss;
jrose@644 2206 const bool set_cond_codes = true;
duke@0 2207
duke@0 2208 MacroAssembler _masm(&cbuf);
jrose@644 2209 __ check_klass_subtype_slow_path(Rrsi, Rrax, Rrcx, Rrdi,
jrose@644 2210 NULL, &miss,
jrose@644 2211 /*set_cond_codes:*/ true);
duke@0 2212 if ($primary) {
never@304 2213 __ xorptr(Rrdi, Rrdi);
duke@0 2214 }
duke@0 2215 __ bind(miss);
duke@0 2216 %}
duke@0 2217
duke@0 2218 enc_class Java_To_Interpreter(method meth)
duke@0 2219 %{
duke@0 2220 // CALL Java_To_Interpreter
duke@0 2221 // This is the instruction starting address for relocation info.
twisti@1668 2222 cbuf.set_insts_mark();
duke@0 2223 $$$emit8$primary;
duke@0 2224 // CALL directly to the runtime
duke@0 2225 emit_d32_reloc(cbuf,
twisti@1668 2226 (int) ($meth$$method - ((intptr_t) cbuf.insts_end()) - 4),
duke@0 2227 runtime_call_Relocation::spec(),
duke@0 2228 RELOC_DISP32);
duke@0 2229 %}
duke@0 2230
duke@0 2231 enc_class Java_Static_Call(method meth)
duke@0 2232 %{
duke@0 2233 // JAVA STATIC CALL
duke@0 2234 // CALL to fixup routine. Fixup routine uses ScopeDesc info to
duke@0 2235 // determine who we intended to call.
twisti@1668 2236 cbuf.set_insts_mark();
duke@0 2237 $$$emit8$primary;
duke@0 2238
duke@0 2239 if (!_method) {
duke@0 2240 emit_d32_reloc(cbuf,
twisti@1668 2241 (int) ($meth$$method - ((intptr_t) cbuf.insts_end()) - 4),
duke@0 2242 runtime_call_Relocation::spec(),
duke@0 2243 RELOC_DISP32);
duke@0 2244 } else if (_optimized_virtual) {
duke@0 2245 emit_d32_reloc(cbuf,
twisti@1668 2246 (int) ($meth$$method - ((intptr_t) cbuf.insts_end()) - 4),
duke@0 2247 opt_virtual_call_Relocation::spec(),
duke@0 2248 RELOC_DISP32);
duke@0 2249 } else {
duke@0 2250 emit_d32_reloc(cbuf,
twisti@1668 2251 (int) ($meth$$method - ((intptr_t) cbuf.insts_end()) - 4),
duke@0 2252 static_call_Relocation::spec(),
duke@0 2253 RELOC_DISP32);
duke@0 2254 }
duke@0 2255 if (_method) {
duke@0 2256 // Emit stub for static call
duke@0 2257 emit_java_to_interp(cbuf);
duke@0 2258 }
duke@0 2259 %}
duke@0 2260
duke@0 2261 enc_class Java_Dynamic_Call(method meth)
duke@0 2262 %{
duke@0 2263 // JAVA DYNAMIC CALL
duke@0 2264 // !!!!!
duke@0 2265 // Generate "movq rax, -1", placeholder instruction to load oop-info
duke@0 2266 // emit_call_dynamic_prologue( cbuf );
twisti@1668 2267 cbuf.set_insts_mark();
duke@0 2268
duke@0 2269 // movq rax, -1
duke@0 2270 emit_opcode(cbuf, Assembler::REX_W);
duke@0 2271 emit_opcode(cbuf, 0xB8 | RAX_enc);
duke@0 2272 emit_d64_reloc(cbuf,
duke@0 2273 (int64_t) Universe::non_oop_word(),
duke@0 2274 oop_Relocation::spec_for_immediate(), RELOC_IMM64);
twisti@1668 2275 address virtual_call_oop_addr = cbuf.insts_mark();
duke@0 2276 // CALL to fixup routine. Fixup routine uses ScopeDesc info to determine
duke@0 2277 // who we intended to call.
twisti@1668 2278 cbuf.set_insts_mark();
duke@0 2279 $$$emit8$primary;
duke@0 2280 emit_d32_reloc(cbuf,
twisti@1668 2281 (int) ($meth$$method - ((intptr_t) cbuf.insts_end()) - 4),
duke@0 2282 virtual_call_Relocation::spec(virtual_call_oop_addr),
duke@0 2283 RELOC_DISP32);
duke@0 2284 %}
duke@0 2285
duke@0 2286 enc_class Java_Compiled_Call(method meth)
duke@0 2287 %{
duke@0 2288 // JAVA COMPILED CALL
duke@0 2289 int disp = in_bytes(methodOopDesc:: from_compiled_offset());
duke@0 2290
duke@0 2291 // XXX XXX offset is 128 is 1.5 NON-PRODUCT !!!
duke@0 2292 // assert(-0x80 <= disp && disp < 0x80, "compiled_code_offset isn't small");
duke@0 2293
duke@0 2294 // callq *disp(%rax)
twisti@1668 2295 cbuf.set_insts_mark();
duke@0 2296 $$$emit8$primary;
duke@0 2297 if (disp < 0x80) {
duke@0 2298 emit_rm(cbuf, 0x01, $secondary, RAX_enc); // R/M byte
duke@0 2299 emit_d8(cbuf, disp); // Displacement
duke@0 2300 } else {
duke@0 2301 emit_rm(cbuf, 0x02, $secondary, RAX_enc); // R/M byte
duke@0 2302 emit_d32(cbuf, disp); // Displacement
duke@0 2303 }
duke@0 2304 %}
duke@0 2305
duke@0 2306 enc_class reg_opc_imm(rRegI dst, immI8 shift)
duke@0 2307 %{
duke@0 2308 // SAL, SAR, SHR
duke@0 2309 int dstenc = $dst$$reg;
duke@0 2310 if (dstenc >= 8) {
duke@0 2311 emit_opcode(cbuf, Assembler::REX_B);
duke@0 2312 dstenc -= 8;
duke@0 2313 }
duke@0 2314 $$$emit8$primary;
duke@0 2315 emit_rm(cbuf, 0x3, $secondary, dstenc);
duke@0 2316 $$$emit8$shift$$constant;
duke@0 2317 %}
duke@0 2318
duke@0 2319 enc_class reg_opc_imm_wide(rRegL dst, immI8 shift)
duke@0 2320 %{
duke@0 2321 // SAL, SAR, SHR
duke@0 2322 int dstenc = $dst$$reg;
duke@0 2323 if (dstenc < 8) {
duke@0 2324 emit_opcode(cbuf, Assembler::REX_W);
duke@0 2325 } else {
duke@0 2326 emit_opcode(cbuf, Assembler::REX_WB);
duke@0 2327 dstenc -= 8;
duke@0 2328 }
duke@0 2329 $$$emit8$primary;
duke@0 2330 emit_rm(cbuf, 0x3, $secondary, dstenc);
duke@0 2331 $$$emit8$shift$$constant;
duke@0 2332 %}
duke@0 2333
duke@0 2334 enc_class load_immI(rRegI dst, immI src)
duke@0 2335 %{
duke@0 2336 int dstenc = $dst$$reg;
duke@0 2337 if (dstenc >= 8) {
duke@0 2338 emit_opcode(cbuf, Assembler::REX_B);
duke@0 2339 dstenc -= 8;
duke@0 2340 }
duke@0 2341 emit_opcode(cbuf, 0xB8 | dstenc);
duke@0 2342 $$$emit32$src$$constant;
duke@0 2343 %}
duke@0 2344
duke@0 2345 enc_class load_immL(rRegL dst, immL src)
duke@0 2346 %{
duke@0 2347 int dstenc = $dst$$reg;
duke@0 2348 if (dstenc < 8) {
duke@0 2349 emit_opcode(cbuf, Assembler::REX_W);
duke@0 2350 } else {
duke@0 2351 emit_opcode(cbuf, Assembler::REX_WB);
duke@0 2352 dstenc -= 8;
duke@0 2353 }
duke@0 2354 emit_opcode(cbuf, 0xB8 | dstenc);
duke@0 2355 emit_d64(cbuf, $src$$constant);
duke@0 2356 %}
duke@0 2357
duke@0 2358 enc_class load_immUL32(rRegL dst, immUL32 src)
duke@0 2359 %{
duke@0 2360 // same as load_immI, but this time we care about zeroes in the high word
duke@0 2361 int dstenc = $dst$$reg;
duke@0 2362 if (dstenc >= 8) {
duke@0 2363 emit_opcode(cbuf, Assembler::REX_B);
duke@0 2364 dstenc -= 8;
duke@0 2365 }
duke@0 2366 emit_opcode(cbuf, 0xB8 | dstenc);
duke@0 2367 $$$emit32$src$$constant;
duke@0 2368 %}
duke@0 2369
duke@0 2370 enc_class load_immL32(rRegL dst, immL32 src)
duke@0 2371 %{
duke@0 2372 int dstenc = $dst$$reg;
duke@0 2373 if (dstenc < 8) {
duke@0 2374 emit_opcode(cbuf, Assembler::REX_W);
duke@0 2375 } else {
duke@0 2376 emit_opcode(cbuf, Assembler::REX_WB);
duke@0 2377 dstenc -= 8;
duke@0 2378 }
duke@0 2379 emit_opcode(cbuf, 0xC7);
duke@0 2380 emit_rm(cbuf, 0x03, 0x00, dstenc);
duke@0 2381 $$$emit32$src$$constant;
duke@0 2382 %}
duke@0 2383
duke@0 2384 enc_class load_immP31(rRegP dst, immP32 src)
duke@0 2385 %{
duke@0 2386 // same as load_immI, but this time we care about zeroes in the high word
duke@0 2387 int dstenc = $dst$$reg;
duke@0 2388 if (dstenc >= 8) {
duke@0 2389 emit_opcode(cbuf, Assembler::REX_B);
duke@0 2390 dstenc -= 8;
duke@0 2391 }
duke@0 2392 emit_opcode(cbuf, 0xB8 | dstenc);
duke@0 2393 $$$emit32$src$$constant;
duke@0 2394 %}
duke@0 2395
duke@0 2396 enc_class load_immP(rRegP dst, immP src)
duke@0 2397 %{
duke@0 2398 int dstenc = $dst$$reg;
duke@0 2399 if (dstenc < 8) {
duke@0 2400 emit_opcode(cbuf, Assembler::REX_W);
duke@0 2401 } else {
duke@0 2402 emit_opcode(cbuf, Assembler::REX_WB);
duke@0 2403 dstenc -= 8;
duke@0 2404 }
duke@0 2405 emit_opcode(cbuf, 0xB8 | dstenc);
duke@0 2406 // This next line should be generated from ADLC
duke@0 2407 if ($src->constant_is_oop()) {
duke@0 2408 emit_d64_reloc(cbuf, $src$$constant, relocInfo::oop_type, RELOC_IMM64);
duke@0 2409 } else {
duke@0 2410 emit_d64(cbuf, $src$$constant);
duke@0 2411 }
duke@0 2412 %}
duke@0 2413
duke@0 2414 enc_class Con32(immI src)
duke@0 2415 %{
duke@0 2416 // Output immediate
duke@0 2417 $$$emit32$src$$constant;
duke@0 2418 %}
duke@0 2419
duke@0 2420 enc_class Con64(immL src)
duke@0 2421 %{
duke@0 2422 // Output immediate
duke@0 2423 emit_d64($src$$constant);
duke@0 2424 %}
duke@0 2425
duke@0 2426 enc_class Con32F_as_bits(immF src)
duke@0 2427 %{
duke@0 2428 // Output Float immediate bits
duke@0 2429 jfloat jf = $src$$constant;
duke@0 2430 jint jf_as_bits = jint_cast(jf);
duke@0 2431 emit_d32(cbuf, jf_as_bits);
duke@0 2432 %}
duke@0 2433
duke@0 2434 enc_class Con16(immI src)
duke@0 2435 %{
duke@0 2436 // Output immediate
duke@0 2437 $$$emit16$src$$constant;
duke@0 2438 %}
duke@0 2439
duke@0 2440 // How is this different from Con32??? XXX
duke@0 2441 enc_class Con_d32(immI src)
duke@0 2442 %{
duke@0 2443 emit_d32(cbuf,$src$$constant);
duke@0 2444 %}
duke@0 2445
duke@0 2446 enc_class conmemref (rRegP t1) %{ // Con32(storeImmI)
duke@0 2447 // Output immediate memory reference
duke@0 2448 emit_rm(cbuf, 0x00, $t1$$reg, 0x05 );
duke@0 2449 emit_d32(cbuf, 0x00);
duke@0 2450 %}
duke@0 2451
duke@0 2452 enc_class lock_prefix()
duke@0 2453 %{
duke@0 2454 if (os::is_MP()) {
duke@0 2455 emit_opcode(cbuf, 0xF0); // lock
duke@0 2456 }
duke@0 2457 %}
duke@0 2458
duke@0 2459 enc_class REX_mem(memory mem)
duke@0 2460 %{
duke@0 2461 if ($mem$$base >= 8) {
duke@0 2462 if ($mem$$index < 8) {
duke@0 2463 emit_opcode(cbuf, Assembler::REX_B);
duke@0 2464 } else {
duke@0 2465 emit_opcode(cbuf, Assembler::REX_XB);
duke@0 2466 }
duke@0 2467 } else {
duke@0 2468 if ($mem$$index >= 8) {
duke@0 2469 emit_opcode(cbuf, Assembler::REX_X);
duke@0 2470 }
duke@0 2471 }
duke@0 2472 %}
duke@0 2473
duke@0 2474 enc_class REX_mem_wide(memory mem)
duke@0 2475 %{
duke@0 2476 if ($mem$$base >= 8) {
duke@0 2477 if ($mem$$index < 8) {
duke@0 2478 emit_opcode(cbuf, Assembler::REX_WB);
duke@0 2479 } else {
duke@0 2480 emit_opcode(cbuf, Assembler::REX_WXB);
duke@0 2481 }
duke@0 2482 } else {
duke@0 2483 if ($mem$$index < 8) {
duke@0 2484 emit_opcode(cbuf, Assembler::REX_W);
duke@0 2485 } else {
duke@0 2486 emit_opcode(cbuf, Assembler::REX_WX);
duke@0 2487 }
duke@0 2488 }
duke@0 2489 %}
duke@0 2490
duke@0 2491 // for byte regs
duke@0 2492 enc_class REX_breg(rRegI reg)
duke@0 2493 %{
duke@0 2494 if ($reg$$reg >= 4) {
duke@0 2495 emit_opcode(cbuf, $reg$$reg < 8 ? Assembler::REX : Assembler::REX_B);
duke@0 2496 }
duke@0 2497 %}
duke@0 2498
duke@0 2499 // for byte regs
duke@0 2500 enc_class REX_reg_breg(rRegI dst, rRegI src)
duke@0 2501 %{
duke@0 2502 if ($dst$$reg < 8) {
duke@0 2503 if ($src$$reg >= 4) {
duke@0 2504 emit_opcode(cbuf, $src$$reg < 8 ? Assembler::REX : Assembler::REX_B);
duke@0 2505 }
duke@0 2506 } else {
duke@0 2507 if ($src$$reg < 8) {
duke@0 2508 emit_opcode(cbuf, Assembler::REX_R);
duke@0 2509 } else {
duke@0 2510 emit_opcode(cbuf, Assembler::REX_RB);
duke@0 2511 }
duke@0 2512 }
duke@0 2513 %}
duke@0 2514
duke@0 2515 // for byte regs
duke@0 2516 enc_class REX_breg_mem(rRegI reg, memory mem)
duke@0 2517 %{
duke@0 2518 if ($reg$$reg < 8) {
duke@0 2519 if ($mem$$base < 8) {
duke@0 2520 if ($mem$$index >= 8) {
duke@0 2521 emit_opcode(cbuf, Assembler::REX_X);
duke@0 2522 } else if ($reg$$reg >= 4) {
duke@0 2523 emit_opcode(cbuf, Assembler::REX);
duke@0 2524 }
duke@0 2525 } else {
duke@0 2526 if ($mem$$index < 8) {
duke@0 2527 emit_opcode(cbuf, Assembler::REX_B);
duke@0 2528 } else {
duke@0 2529 emit_opcode(cbuf, Assembler::REX_XB);
duke@0 2530 }
duke@0 2531 }
duke@0 2532 } else {
duke@0 2533 if ($mem$$base < 8) {
duke@0 2534 if ($mem$$index < 8) {
duke@0 2535 emit_opcode(cbuf, Assembler::REX_R);
duke@0 2536 } else {
duke@0 2537 emit_opcode(cbuf, Assembler::REX_RX);
duke@0 2538 }
duke@0 2539 } else {
duke@0 2540 if ($mem$$index < 8) {
duke@0 2541 emit_opcode(cbuf, Assembler::REX_RB);
duke@0 2542 } else {
duke@0 2543 emit_opcode(cbuf, Assembler::REX_RXB);
duke@0 2544 }
duke@0 2545 }
duke@0 2546 }
duke@0 2547 %}
duke@0 2548
duke@0 2549 enc_class REX_reg(rRegI reg)
duke@0 2550 %{
duke@0 2551 if ($reg$$reg >= 8) {
duke@0 2552 emit_opcode(cbuf, Assembler::REX_B);
duke@0 2553 }
duke@0 2554 %}
duke@0 2555
duke@0 2556 enc_class REX_reg_wide(rRegI reg)
duke@0 2557 %{
duke@0 2558 if ($reg$$reg < 8) {
duke@0 2559 emit_opcode(cbuf, Assembler::REX_W);
duke@0 2560 } else {
duke@0 2561 emit_opcode(cbuf, Assembler::REX_WB);
duke@0 2562 }
duke@0 2563 %}
duke@0 2564
duke@0 2565 enc_class REX_reg_reg(rRegI dst, rRegI src)
duke@0 2566 %{
duke@0 2567 if ($dst$$reg < 8) {
duke@0 2568 if ($src$$reg >= 8) {
duke@0 2569 emit_opcode(cbuf, Assembler::REX_B);
duke@0 2570 }
duke@0 2571 } else {
duke@0 2572 if ($src$$reg < 8) {
duke@0 2573 emit_opcode(cbuf, Assembler::REX_R);
duke@0 2574 } else {
duke@0 2575 emit_opcode(cbuf, Assembler::REX_RB);
duke@0 2576 }
duke@0 2577 }
duke@0 2578 %}
duke@0 2579
duke@0 2580 enc_class REX_reg_reg_wide(rRegI dst, rRegI src)
duke@0 2581 %{
duke@0 2582 if ($dst$$reg < 8) {
duke@0 2583 if ($src$$reg < 8) {
duke@0 2584 emit_opcode(cbuf, Assembler::REX_W);
duke@0 2585 } else {
duke@0 2586 emit_opcode(cbuf, Assembler::REX_WB);
duke@0 2587 }
duke@0 2588 } else {
duke@0 2589 if ($src$$reg < 8) {
duke@0 2590 emit_opcode(cbuf, Assembler::REX_WR);
duke@0 2591 } else {
duke@0 2592 emit_opcode(cbuf, Assembler::REX_WRB);
duke@0 2593 }
duke@0 2594 }
duke@0 2595 %}
duke@0 2596
duke@0 2597 enc_class REX_reg_mem(rRegI reg, memory mem)
duke@0 2598 %{
duke@0 2599 if ($reg$$reg < 8) {
duke@0 2600 if ($mem$$base < 8) {
duke@0 2601 if ($mem$$index >= 8) {
duke@0 2602 emit_opcode(cbuf, Assembler::REX_X);
duke@0 2603 }
duke@0 2604 } else {
duke@0 2605 if ($mem$$index < 8) {
duke@0 2606 emit_opcode(cbuf, Assembler::REX_B);
duke@0 2607 } else {
duke@0 2608 emit_opcode(cbuf, Assembler::REX_XB);
duke@0 2609 }
duke@0 2610 }
duke@0 2611 } else {
duke@0 2612 if ($mem$$base < 8) {
duke@0 2613 if ($mem$$index < 8) {
duke@0 2614 emit_opcode(cbuf, Assembler::REX_R);
duke@0 2615 } else {
duke@0 2616 emit_opcode(cbuf, Assembler::REX_RX);
duke@0 2617 }
duke@0 2618 } else {
duke@0 2619 if ($mem$$index < 8) {
duke@0 2620 emit_opcode(cbuf, Assembler::REX_RB);
duke@0 2621 } else {
duke@0 2622 emit_opcode(cbuf, Assembler::REX_RXB);
duke@0 2623 }
duke@0 2624 }
duke@0 2625 }
duke@0 2626 %}
duke@0 2627
duke@0 2628 enc_class REX_reg_mem_wide(rRegL reg, memory mem)
duke@0 2629 %{
duke@0 2630 if ($reg$$reg < 8) {
duke@0 2631 if ($mem$$base < 8) {
duke@0 2632 if ($mem$$index < 8) {
duke@0 2633 emit_opcode(cbuf, Assembler::REX_W);
duke@0 2634 } else {
duke@0 2635 emit_opcode(cbuf, Assembler::REX_WX);
duke@0 2636 }
duke@0 2637 } else {
duke@0 2638 if ($mem$$index < 8) {
duke@0 2639 emit_opcode(cbuf, Assembler::REX_WB);
duke@0 2640 } else {
duke@0 2641 emit_opcode(cbuf, Assembler::REX_WXB);
duke@0 2642 }
duke@0 2643 }
duke@0 2644 } else {
duke@0 2645 if ($mem$$base < 8) {
duke@0 2646 if ($mem$$index < 8) {
duke@0 2647 emit_opcode(cbuf, Assembler::REX_WR);
duke@0 2648 } else {
duke@0 2649 emit_opcode(cbuf, Assembler::REX_WRX);
duke@0 2650 }
duke@0 2651 } else {
duke@0 2652 if ($mem$$index < 8) {
duke@0 2653 emit_opcode(cbuf, Assembler::REX_WRB);
duke@0 2654 } else {
duke@0 2655 emit_opcode(cbuf, Assembler::REX_WRXB);
duke@0 2656 }
duke@0 2657 }
duke@0 2658 }
duke@0 2659 %}
duke@0 2660
duke@0 2661 enc_class reg_mem(rRegI ereg, memory mem)
duke@0 2662 %{
duke@0 2663 // High registers handle in encode_RegMem
duke@0 2664 int reg = $ereg$$reg;
duke@0 2665 int base = $mem$$base;
duke@0 2666 int index = $mem$$index;
duke@0 2667 int scale = $mem$$scale;
duke@0 2668 int disp = $mem$$disp;
duke@0 2669 bool disp_is_oop = $mem->disp_is_oop();
duke@0 2670
duke@0 2671 encode_RegMem(cbuf, reg, base, index, scale, disp, disp_is_oop);
duke@0 2672 %}
duke@0 2673
duke@0 2674 enc_class RM_opc_mem(immI rm_opcode, memory mem)
duke@0 2675 %{
duke@0 2676 int rm_byte_opcode = $rm_opcode$$constant;
duke@0 2677
duke@0 2678 // High registers handle in encode_RegMem
duke@0 2679 int base = $mem$$base;
duke@0 2680 int index = $mem$$index;
duke@0 2681 int scale = $mem$$scale;
duke@0 2682 int displace = $mem$$disp;
duke@0 2683
duke@0 2684 bool disp_is_oop = $mem->disp_is_oop(); // disp-as-oop when
duke@0 2685 // working with static
duke@0 2686 // globals
duke@0 2687 encode_RegMem(cbuf, rm_byte_opcode, base, index, scale, displace,
duke@0 2688 disp_is_oop);
duke@0 2689 %}
duke@0 2690
duke@0 2691 enc_class reg_lea(rRegI dst, rRegI src0, immI src1)
duke@0 2692 %{
duke@0 2693 int reg_encoding = $dst$$reg;
duke@0 2694 int base = $src0$$reg; // 0xFFFFFFFF indicates no base
duke@0 2695 int index = 0x04; // 0x04 indicates no index
duke@0 2696 int scale = 0x00; // 0x00 indicates no scale
duke@0 2697 int displace = $src1$$constant; // 0x00 indicates no displacement
duke@0 2698 bool disp_is_oop = false;
duke@0 2699 encode_RegMem(cbuf, reg_encoding, base, index, scale, displace,
duke@0 2700 disp_is_oop);
duke@0 2701 %}
duke@0 2702
duke@0 2703 enc_class neg_reg(rRegI dst)
duke@0 2704 %{
duke@0 2705 int dstenc = $dst$$reg;
duke@0 2706 if (dstenc >= 8) {
duke@0 2707 emit_opcode(cbuf, Assembler::REX_B);
duke@0 2708 dstenc -= 8;
duke@0 2709 }
duke@0 2710 // NEG $dst
duke@0 2711 emit_opcode(cbuf, 0xF7);
duke@0 2712 emit_rm(cbuf, 0x3, 0x03, dstenc);
duke@0 2713 %}
duke@0 2714
duke@0 2715 enc_class neg_reg_wide(rRegI dst)
duke@0 2716 %{
duke@0 2717 int dstenc = $dst$$reg;
duke@0 2718 if (dstenc < 8) {
duke@0 2719 emit_opcode(cbuf, Assembler::REX_W);
duke@0 2720 } else {
duke@0 2721 emit_opcode(cbuf, Assembler::REX_WB);
duke@0 2722 dstenc -= 8;
duke@0 2723 }
duke@0 2724 // NEG $dst
duke@0 2725 emit_opcode(cbuf, 0xF7);
duke@0 2726 emit_rm(cbuf, 0x3, 0x03, dstenc);
duke@0 2727 %}
duke@0 2728
duke@0 2729 enc_class setLT_reg(rRegI dst)
duke@0 2730 %{
duke@0 2731 int dstenc = $dst$$reg;
duke@0 2732 if (dstenc >= 8) {
duke@0 2733 emit_opcode(cbuf, Assembler::REX_B);
duke@0 2734 dstenc -= 8;
duke@0 2735 } else if (dstenc >= 4) {
duke@0 2736 emit_opcode(cbuf, Assembler::REX);
duke@0 2737 }
duke@0 2738 // SETLT $dst
duke@0 2739 emit_opcode(cbuf, 0x0F);
duke@0 2740 emit_opcode(cbuf, 0x9C);
duke@0 2741 emit_rm(cbuf, 0x3, 0x0, dstenc);
duke@0 2742 %}
duke@0 2743
duke@0 2744 enc_class setNZ_reg(rRegI dst)
duke@0 2745 %{
duke@0 2746 int dstenc = $dst$$reg;
duke@0 2747 if (dstenc >= 8) {
duke@0 2748 emit_opcode(cbuf, Assembler::REX_B);
duke@0 2749 dstenc -= 8;
duke@0 2750 } else if (dstenc >= 4) {
duke@0 2751 emit_opcode(cbuf, Assembler::REX);
duke@0 2752 }
duke@0 2753 // SETNZ $dst
duke@0 2754 emit_opcode(cbuf, 0x0F);
duke@0 2755 emit_opcode(cbuf, 0x95);
duke@0 2756 emit_rm(cbuf, 0x3, 0x0, dstenc);
duke@0 2757 %}
duke@0 2758
duke@0 2759
duke@0 2760 // Compare the lonogs and set -1, 0, or 1 into dst
duke@0 2761 enc_class cmpl3_flag(rRegL src1, rRegL src2, rRegI dst)
duke@0 2762 %{
duke@0 2763 int src1enc = $src1$$reg;
duke@0 2764 int src2enc = $src2$$reg;
duke@0 2765 int dstenc = $dst$$reg;
duke@0 2766
duke@0 2767 // cmpq $src1, $src2
duke@0 2768 if (src1enc < 8) {
duke@0 2769 if (src2enc < 8) {
duke@0 2770 emit_opcode(cbuf, Assembler::REX_W);
duke@0 2771 } else {
duke@0 2772 emit_opcode(cbuf, Assembler::REX_WB);
duke@0 2773 }
duke@0 2774 } else {
duke@0 2775 if (src2enc < 8) {
duke@0 2776 emit_opcode(cbuf, Assembler::REX_WR);
duke@0 2777 } else {
duke@0 2778 emit_opcode(cbuf, Assembler::REX_WRB);
duke@0 2779 }
duke@0 2780 }
duke@0 2781 emit_opcode(cbuf, 0x3B);
duke@0 2782 emit_rm(cbuf, 0x3, src1enc & 7, src2enc & 7);
duke@0 2783
duke@0 2784 // movl $dst, -1
duke@0 2785 if (dstenc >= 8) {
duke@0 2786 emit_opcode(cbuf, Assembler::REX_B);
duke@0 2787 }
duke@0 2788 emit_opcode(cbuf, 0xB8 | (dstenc & 7));
duke@0 2789 emit_d32(cbuf, -1);
duke@0 2790
duke@0 2791 // jl,s done
duke@0 2792 emit_opcode(cbuf, 0x7C);
duke@0 2793 emit_d8(cbuf, dstenc < 4 ? 0x06 : 0x08);
duke@0 2794
duke@0 2795 // setne $dst
duke@0 2796 if (dstenc >= 4) {
duke@0 2797 emit_opcode(cbuf, dstenc < 8 ? Assembler::REX : Assembler::REX_B);
duke@0 2798 }
duke@0 2799 emit_opcode(cbuf, 0x0F);
duke@0 2800 emit_opcode(cbuf, 0x95);
duke@0 2801 emit_opcode(cbuf, 0xC0 | (dstenc & 7));
duke@0 2802
duke@0 2803 // movzbl $dst, $dst
duke@0 2804 if (dstenc >= 4) {
duke@0 2805 emit_opcode(cbuf, dstenc < 8 ? Assembler::REX : Assembler::REX_RB);
duke@0 2806 }
duke@0 2807 emit_opcode(cbuf, 0x0F);
duke@0 2808 emit_opcode(cbuf, 0xB6);
duke@0 2809 emit_rm(cbuf, 0x3, dstenc & 7, dstenc & 7);
duke@0 2810 %}
duke@0 2811
duke@0 2812 enc_class Push_ResultXD(regD dst) %{
kvn@2953 2813 MacroAssembler _masm(&cbuf);
kvn@2953 2814 __ fstp_d(Address(rsp, 0));
kvn@2953 2815 __ movdbl($dst$$XMMRegister, Address(rsp, 0));
kvn@2953 2816 __ addptr(rsp, 8);
duke@0 2817 %}
duke@0 2818
duke@0 2819 enc_class Push_SrcXD(regD src) %{
duke@0 2820 MacroAssembler _masm(&cbuf);
kvn@2953 2821 __ subptr(rsp, 8);
kvn@2953 2822 __ movdbl(Address(rsp, 0), $src$$XMMRegister);
kvn@2953 2823 __ fld_d(Address(rsp, 0));
kvn@2953 2824 %}
kvn@2953 2825
duke@0 2826
duke@0 2827 // obj: object to lock
duke@0 2828 // box: box address (header location) -- killed
duke@0 2829 // tmp: rax -- killed
duke@0 2830 // scr: rbx -- killed
duke@0 2831 //
duke@0 2832 // What follows is a direct transliteration of fast_lock() and fast_unlock()
duke@0 2833 // from i486.ad. See that file for comments.
duke@0 2834 // TODO: where possible switch from movq (r, 0) to movl(r,0) and
duke@0 2835 // use the shorter encoding. (Movl clears the high-order 32-bits).
duke@0 2836
duke@0 2837
duke@0 2838 enc_class Fast_Lock(rRegP obj, rRegP box, rax_RegI tmp, rRegP scr)
duke@0 2839 %{
duke@0 2840 Register objReg = as_Register((int)$obj$$reg);
duke@0 2841 Register boxReg = as_Register((int)$box$$reg);
duke@0 2842 Register tmpReg = as_Register($tmp$$reg);
duke@0 2843 Register scrReg = as_Register($scr$$reg);
duke@0 2844 MacroAssembler masm(&cbuf);
duke@0 2845
duke@0 2846 // Verify uniqueness of register assignments -- necessary but not sufficient
duke@0 2847 assert (objReg != boxReg && objReg != tmpReg &&
duke@0 2848 objReg != scrReg && tmpReg != scrReg, "invariant") ;
duke@0 2849
duke@0 2850 if (_counters != NULL) {
duke@0 2851 masm.atomic_incl(ExternalAddress((address) _counters->total_entry_count_addr()));
duke@0 2852 }
duke@0 2853 if (EmitSync & 1) {
never@304 2854 // Without cast to int32_t a movptr will destroy r10 which is typically obj
iveresov@2251 2855 masm.movptr (Address(boxReg, 0), (int32_t)intptr_t(markOopDesc::unused_mark())) ;
iveresov@2251 2856 masm.cmpptr(rsp, (int32_t)NULL_WORD) ;
duke@0 2857 } else
duke@0 2858 if (EmitSync & 2) {
duke@0 2859 Label DONE_LABEL;
duke@0 2860 if (UseBiasedLocking) {
duke@0 2861 // Note: tmpReg maps to the swap_reg argument and scrReg to the tmp_reg argument.
duke@0 2862 masm.biased_locking_enter(boxReg, objReg, tmpReg, scrReg, false, DONE_LABEL, NULL, _counters);
duke@0 2863 }
never@304 2864 // QQQ was movl...
never@304 2865 masm.movptr(tmpReg, 0x1);
never@304 2866 masm.orptr(tmpReg, Address(objReg, 0));
never@304 2867 masm.movptr(Address(boxReg, 0), tmpReg);
duke@0 2868 if (os::is_MP()) {
duke@0 2869 masm.lock();
duke@0 2870 }
never@304 2871 masm.cmpxchgptr(boxReg, Address(objReg, 0)); // Updates tmpReg
duke@0 2872 masm.jcc(Assembler::equal, DONE_LABEL);
duke@0 2873
duke@0 2874 // Recursive locking
never@304 2875 masm.subptr(tmpReg, rsp);
never@304 2876 masm.andptr(tmpReg, 7 - os::vm_page_size());
never@304 2877 masm.movptr(Address(boxReg, 0), tmpReg);
duke@0 2878
duke@0 2879 masm.bind(DONE_LABEL);
duke@0 2880 masm.nop(); // avoid branch to branch
duke@0 2881 } else {
duke@0 2882 Label DONE_LABEL, IsInflated, Egress;
duke@0 2883
iveresov@2251 2884 masm.movptr(tmpReg, Address(objReg, 0)) ;
never@304 2885 masm.testl (tmpReg, 0x02) ; // inflated vs stack-locked|neutral|biased
iveresov@2251 2886 masm.jcc (Assembler::notZero, IsInflated) ;
iveresov@2251 2887
duke@0 2888 // it's stack-locked, biased or neutral
duke@0 2889 // TODO: optimize markword triage order to reduce the number of
duke@0 2890 // conditional branches in the most common cases.
duke@0 2891 // Beware -- there's a subtle invariant that fetch of the markword
duke@0 2892 // at [FETCH], below, will never observe a biased encoding (*101b).
duke@0 2893 // If this invariant is not held we'll suffer exclusion (safety) failure.
duke@0 2894
kvn@420 2895 if (UseBiasedLocking && !UseOptoBiasInlining) {
duke@0 2896 masm.biased_locking_enter(boxReg, objReg, tmpReg, scrReg, true, DONE_LABEL, NULL, _counters);
never@304 2897 masm.movptr(tmpReg, Address(objReg, 0)) ; // [FETCH]
duke@0 2898 }
duke@0 2899
never@304 2900 // was q will it destroy high?
iveresov@2251 2901 masm.orl (tmpReg, 1) ;
iveresov@2251 2902 masm.movptr(Address(boxReg, 0), tmpReg) ;
iveresov@2251 2903 if (os::is_MP()) { masm.lock(); }
never@304 2904 masm.cmpxchgptr(boxReg, Address(objReg, 0)); // Updates tmpReg
duke@0 2905 if (_counters != NULL) {
duke@0 2906 masm.cond_inc32(Assembler::equal,
duke@0 2907 ExternalAddress((address) _counters->fast_path_entry_count_addr()));
duke@0 2908 }
duke@0 2909 masm.jcc (Assembler::equal, DONE_LABEL);
duke@0 2910
duke@0 2911 // Recursive locking
never@304 2912 masm.subptr(tmpReg, rsp);
never@304 2913 masm.andptr(tmpReg, 7 - os::vm_page_size());
never@304 2914 masm.movptr(Address(boxReg, 0), tmpReg);
duke@0 2915 if (_counters != NULL) {
duke@0 2916 masm.cond_inc32(Assembler::equal,
duke@0 2917 ExternalAddress((address) _counters->fast_path_entry_count_addr()));
duke@0 2918 }
duke@0 2919 masm.jmp (DONE_LABEL) ;
duke@0 2920
duke@0 2921 masm.bind (IsInflated) ;
duke@0 2922 // It's inflated
duke@0 2923
duke@0 2924 // TODO: someday avoid the ST-before-CAS penalty by
duke@0 2925 // relocating (deferring) the following ST.
duke@0 2926 // We should also think about trying a CAS without having
duke@0 2927 // fetched _owner. If the CAS is successful we may
duke@0 2928 // avoid an RTO->RTS upgrade on the $line.
never@304 2929 // Without cast to int32_t a movptr will destroy r10 which is typically obj
iveresov@2251 2930 masm.movptr(Address(boxReg, 0), (int32_t)intptr_t(markOopDesc::unused_mark())) ;
iveresov@2251 2931
iveresov@2251 2932 masm.mov (boxReg, tmpReg) ;
iveresov@2251 2933 masm.movptr (tmpReg, Address(tmpReg, ObjectMonitor::owner_offset_in_bytes()-2)) ;
iveresov@2251 2934 masm.testptr(tmpReg, tmpReg) ;
iveresov@2251 2935 masm.jcc (Assembler::notZero, DONE_LABEL) ;
duke@0 2936
duke@0 2937 // It's inflated and appears unlocked
iveresov@2251 2938 if (os::is_MP()) { masm.lock(); }
iveresov@2251 2939 masm.cmpxchgptr(r15_thread, Address(boxReg, ObjectMonitor::owner_offset_in_bytes()-2)) ;
duke@0 2940 // Intentional fall-through into DONE_LABEL ...
duke@0 2941
duke@0 2942 masm.bind (DONE_LABEL) ;
duke@0 2943 masm.nop () ; // avoid jmp to jmp
duke@0 2944 }
duke@0 2945 %}
duke@0 2946
duke@0 2947 // obj: object to unlock
duke@0 2948 // box: box address (displaced header location), killed
duke@0 2949 // RBX: killed tmp; cannot be obj nor box
duke@0 2950 enc_class Fast_Unlock(rRegP obj, rax_RegP box, rRegP tmp)
duke@0 2951 %{
duke@0 2952
duke@0 2953 Register objReg = as_Register($obj$$reg);
duke@0 2954 Register boxReg = as_Register($box$$reg);
duke@0 2955 Register tmpReg = as_Register($tmp$$reg);
duke@0 2956 MacroAssembler masm(&cbuf);
duke@0 2957
iveresov@2251 2958 if (EmitSync & 4) {
iveresov@2251 2959 masm.cmpptr(rsp, 0) ;
duke@0 2960 } else
duke@0 2961 if (EmitSync & 8) {
duke@0 2962 Label DONE_LABEL;
duke@0 2963 if (UseBiasedLocking) {
duke@0 2964 masm.biased_locking_exit(objReg, tmpReg, DONE_LABEL);
duke@0 2965 }
duke@0 2966
duke@0 2967 // Check whether the displaced header is 0
duke@0 2968 //(=> recursive unlock)
never@304 2969 masm.movptr(tmpReg, Address(boxReg, 0));
never@304 2970 masm.testptr(tmpReg, tmpReg);
duke@0 2971 masm.jcc(Assembler::zero, DONE_LABEL);
duke@0 2972
duke@0 2973 // If not recursive lock, reset the header to displaced header
duke@0 2974 if (os::is_MP()) {
duke@0 2975 masm.lock();
duke@0 2976 }
never@304 2977 masm.cmpxchgptr(tmpReg, Address(objReg, 0)); // Uses RAX which is box
duke@0 2978 masm.bind(DONE_LABEL);
duke@0 2979 masm.nop(); // avoid branch to branch
duke@0 2980 } else {
duke@0 2981 Label DONE_LABEL, Stacked, CheckSucc ;
duke@0 2982
kvn@420 2983 if (UseBiasedLocking && !UseOptoBiasInlining) {
duke@0 2984 masm.biased_locking_exit(objReg, tmpReg, DONE_LABEL);
duke@0 2985 }
iveresov@2251 2986
iveresov@2251 2987 masm.movptr(tmpReg, Address(objReg, 0)) ;
iveresov@2251 2988 masm.cmpptr(Address(boxReg, 0), (int32_t)NULL_WORD) ;
iveresov@2251 2989 masm.jcc (Assembler::zero, DONE_LABEL) ;
iveresov@2251 2990 masm.testl (tmpReg, 0x02) ;
iveresov@2251 2991 masm.jcc (Assembler::zero, Stacked) ;
iveresov@2251 2992
duke@0 2993 // It's inflated
iveresov@2251 2994 masm.movptr(boxReg, Address (tmpReg, ObjectMonitor::owner_offset_in_bytes()-2)) ;
iveresov@2251 2995 masm.xorptr(boxReg, r15_thread) ;
iveresov@2251 2996 masm.orptr (boxReg, Address (tmpReg, ObjectMonitor::recursions_offset_in_bytes()-2)) ;
iveresov@2251 2997 masm.jcc (Assembler::notZero, DONE_LABEL) ;
iveresov@2251 2998 masm.movptr(boxReg, Address (tmpReg, ObjectMonitor::cxq_offset_in_bytes()-2)) ;
iveresov@2251 2999 masm.orptr (boxReg, Address (tmpReg, ObjectMonitor::EntryList_offset_in_bytes()-2)) ;
iveresov@2251 3000 masm.jcc (Assembler::notZero, CheckSucc) ;
iveresov@2251 3001 masm.movptr(Address (tmpReg, ObjectMonitor::owner_offset_in_bytes()-2), (int32_t)NULL_WORD) ;
iveresov@2251 3002 masm.jmp (DONE_LABEL) ;
iveresov@2251 3003
iveresov@2251 3004 if ((EmitSync & 65536) == 0) {
duke@0 3005 Label LSuccess, LGoSlowPath ;
duke@0 3006 masm.bind (CheckSucc) ;
never@304 3007 masm.cmpptr(Address (tmpReg, ObjectMonitor::succ_offset_in_bytes()-2), (int32_t)NULL_WORD) ;
duke@0 3008 masm.jcc (Assembler::zero, LGoSlowPath) ;
duke@0 3009
duke@0 3010 // I'd much rather use lock:andl m->_owner, 0 as it's faster than the
duke@0 3011 // the explicit ST;MEMBAR combination, but masm doesn't currently support
duke@0 3012 // "ANDQ M,IMM". Don't use MFENCE here. lock:add to TOS, xchg, etc
duke@0 3013 // are all faster when the write buffer is populated.
never@304 3014 masm.movptr (Address (tmpReg, ObjectMonitor::owner_offset_in_bytes()-2), (int32_t)NULL_WORD) ;
duke@0 3015 if (os::is_MP()) {
never@304 3016 masm.lock () ; masm.addl (Address(rsp, 0), 0) ;
duke@0 3017 }
never@304 3018 masm.cmpptr(Address (tmpReg, ObjectMonitor::succ_offset_in_bytes()-2), (int32_t)NULL_WORD) ;
duke@0 3019 masm.jcc (Assembler::notZero, LSuccess) ;
duke@0 3020
never@304 3021 masm.movptr (boxReg, (int32_t)NULL_WORD) ; // box is really EAX
duke@0 3022 if (os::is_MP()) { masm.lock(); }
never@304 3023 masm.cmpxchgptr(r15_thread, Address(tmpReg, ObjectMonitor::owner_offset_in_bytes()-2));
duke@0 3024 masm.jcc (Assembler::notEqual, LSuccess) ;
duke@0 3025 // Intentional fall-through into slow-path
duke@0 3026
duke@0 3027 masm.bind (LGoSlowPath) ;
duke@0 3028 masm.orl (boxReg, 1) ; // set ICC.ZF=0 to indicate failure
duke@0 3029 masm.jmp (DONE_LABEL) ;
duke@0 3030
duke@0 3031 masm.bind (LSuccess) ;
duke@0 3032 masm.testl (boxReg, 0) ; // set ICC.ZF=1 to indicate success
duke@0 3033 masm.jmp (DONE_LABEL) ;
duke@0 3034 }
duke@0 3035
iveresov@2251 3036 masm.bind (Stacked) ;
never@304 3037 masm.movptr(tmpReg, Address (boxReg, 0)) ; // re-fetch
iveresov@2251 3038 if (os::is_MP()) { masm.lock(); }
never@304 3039 masm.cmpxchgptr(tmpReg, Address(objReg, 0)); // Uses RAX which is box
duke@0 3040
duke@0 3041 if (EmitSync & 65536) {
duke@0 3042 masm.bind (CheckSucc) ;
duke@0 3043 }
duke@0 3044 masm.bind(DONE_LABEL);
duke@0 3045 if (EmitSync & 32768) {
duke@0 3046 masm.nop(); // avoid branch to branch
duke@0 3047 }
duke@0 3048 }
duke@0 3049 %}
duke@0 3050
rasbold@169 3051
duke@0 3052 enc_class enc_rethrow()
duke@0 3053 %{
twisti@1668 3054 cbuf.set_insts_mark();
duke@0 3055 emit_opcode(cbuf, 0xE9); // jmp entry
duke@0 3056 emit_d32_reloc(cbuf,
twisti@1668 3057 (int) (OptoRuntime::rethrow_stub() - cbuf.insts_end() - 4),
duke@0 3058 runtime_call_Relocation::spec(),
duke@0 3059 RELOC_DISP32);
duke@0 3060 %}
duke@0 3061
duke@0 3062 %}
duke@0 3063
duke@0 3064
coleenp@113 3065
duke@0 3066 //----------FRAME--------------------------------------------------------------
duke@0 3067 // Definition of frame structure and management information.
duke@0 3068 //
duke@0 3069 // S T A C K L A Y O U T Allocators stack-slot number
duke@0 3070 // | (to get allocators register number
duke@0 3071 // G Owned by | | v add OptoReg::stack0())
duke@0 3072 // r CALLER | |
duke@0 3073 // o | +--------+ pad to even-align allocators stack-slot
duke@0 3074 // w V | pad0 | numbers; owned by CALLER
duke@0 3075 // t -----------+--------+----> Matcher::_in_arg_limit, unaligned
duke@0 3076 // h ^ | in | 5
duke@0 3077 // | | args | 4 Holes in incoming args owned by SELF
duke@0 3078 // | | | | 3
duke@0 3079 // | | +--------+
duke@0 3080 // V | | old out| Empty on Intel, window on Sparc
duke@0 3081 // | old |preserve| Must be even aligned.
duke@0 3082 // | SP-+--------+----> Matcher::_old_SP, even aligned
duke@0 3083 // | | in | 3 area for Intel ret address
duke@0 3084 // Owned by |preserve| Empty on Sparc.
duke@0 3085 // SELF +--------+
duke@0 3086 // | | pad2 | 2 pad to align old SP
duke@0 3087 // | +--------+ 1
duke@0 3088 // | | locks | 0
duke@0 3089 // | +--------+----> OptoReg::stack0(), even aligned
duke@0 3090 // | | pad1 | 11 pad to align new SP
duke@0 3091 // | +--------+
duke@0 3092 // | | | 10
duke@0 3093 // | | spills | 9 spills
duke@0 3094 // V | | 8 (pad0 slot for callee)
duke@0 3095 // -----------+--------+----> Matcher::_out_arg_limit, unaligned
duke@0 3096 // ^ | out | 7
duke@0 3097 // | | args | 6 Holes in outgoing args owned by CALLEE
duke@0 3098 // Owned by +--------+
duke@0 3099 // CALLEE | new out| 6 Empty on Intel, window on Sparc
duke@0 3100 // | new |preserve| Must be even-aligned.
duke@0 3101 // | SP-+--------+----> Matcher::_new_SP, even aligned
duke@0 3102 // | | |
duke@0 3103 //
duke@0 3104 // Note 1: Only region 8-11 is determined by the allocator. Region 0-5 is
duke@0 3105 // known from SELF's arguments and the Java calling convention.
duke@0 3106 // Region 6-7 is determined per call site.
duke@0 3107 // Note 2: If the calling convention leaves holes in the incoming argument
duke@0 3108 // area, those holes are owned by SELF. Holes in the outgoing area
duke@0 3109 // are owned by the CALLEE. Holes should not be nessecary in the
duke@0 3110 // incoming area, as the Java calling convention is completely under
duke@0 3111 // the control of the AD file. Doubles can be sorted and packed to
duke@0 3112 // avoid holes. Holes in the outgoing arguments may be nessecary for
duke@0 3113 // varargs C calling conventions.
duke@0 3114 // Note 3: Region 0-3 is even aligned, with pad2 as needed. Region 3-5 is
duke@0 3115 // even aligned with pad0 as needed.
duke@0 3116 // Region 6 is even aligned. Region 6-7 is NOT even aligned;
duke@0 3117 // region 6-11 is even aligned; it may be padded out more so that
duke@0 3118 // the region from SP to FP meets the minimum stack alignment.
duke@0 3119 // Note 4: For I2C adapters, the incoming FP may not meet the minimum stack
duke@0 3120 // alignment. Region 11, pad1, may be dynamically extended so that
duke@0 3121 // SP meets the minimum alignment.
duke@0 3122
duke@0 3123 frame
duke@0 3124 %{
duke@0 3125 // What direction does stack grow in (assumed to be same for C & Java)
duke@0 3126 stack_direction(TOWARDS_LOW);
duke@0 3127
duke@0 3128 // These three registers define part of the calling convention
duke@0 3129 // between compiled code and the interpreter.
duke@0 3130 inline_cache_reg(RAX); // Inline Cache Register
duke@0 3131 interpreter_method_oop_reg(RBX); // Method Oop Register when
duke@0 3132 // calling interpreter
duke@0 3133
duke@0 3134 // Optional: name the operand used by cisc-spilling to access
duke@0 3135 // [stack_pointer + offset]
duke@0 3136 cisc_spilling_operand_name(indOffset32);
duke@0 3137
duke@0 3138 // Number of stack slots consumed by locking an object
duke@0 3139 sync_stack_slots(2);
duke@0 3140
duke@0 3141 // Compiled code's Frame Pointer
duke@0 3142 frame_pointer(RSP);
duke@0 3143
duke@0 3144 // Interpreter stores its frame pointer in a register which is
duke@0 3145 // stored to the stack by I2CAdaptors.
duke@0 3146 // I2CAdaptors convert from interpreted java to compiled java.
duke@0 3147 interpreter_frame_pointer(RBP);
duke@0 3148
duke@0 3149 // Stack alignment requirement
duke@0 3150 stack_alignment(StackAlignmentInBytes); // Alignment size in bytes (128-bit -> 16 bytes)
duke@0 3151
duke@0 3152 // Number of stack slots between incoming argument block and the start of
duke@0 3153 // a new frame. The PROLOG must add this many slots to the stack. The
duke@0 3154 // EPILOG must remove this many slots. amd64 needs two slots for
duke@0 3155 // return address.
duke@0 3156 in_preserve_stack_slots(4 + 2 * VerifyStackAtCalls);
duke@0 3157
duke@0 3158 // Number of outgoing stack slots killed above the out_preserve_stack_slots
duke@0 3159 // for calls to C. Supports the var-args backing area for register parms.
duke@0 3160 varargs_C_out_slots_killed(frame::arg_reg_save_area_bytes/BytesPerInt);
duke@0 3161
duke@0 3162 // The after-PROLOG location of the return address. Location of
duke@0 3163 // return address specifies a type (REG or STACK) and a number
duke@0 3164 // representing the register number (i.e. - use a register name) or
duke@0 3165 // stack slot.
duke@0 3166 // Ret Addr is on stack in slot 0 if no locks or verification or alignment.
duke@0 3167 // Otherwise, it is above the locks and verification slot and alignment word
duke@0 3168 return_addr(STACK - 2 +
kvn@3142 3169 round_to((Compile::current()->in_preserve_stack_slots() +
kvn@3142 3170 Compile::current()->fixed_slots()),
kvn@3142 3171 stack_alignment_in_slots()));
duke@0 3172
duke@0 3173 // Body of function which returns an integer array locating
duke@0 3174 // arguments either in registers or in stack slots. Passed an array
duke@0 3175 // of ideal registers called "sig" and a "length" count. Stack-slot
duke@0 3176 // offsets are based on outgoing arguments, i.e. a CALLER setting up
duke@0 3177 // arguments for a CALLEE. Incoming stack arguments are
duke@0 3178 // automatically biased by the preserve_stack_slots field above.
duke@0 3179
duke@0 3180 calling_convention
duke@0 3181 %{
duke@0 3182 // No difference between ingoing/outgoing just pass false
duke@0 3183 SharedRuntime::java_calling_convention(sig_bt, regs, length, false);
duke@0 3184 %}
duke@0 3185
duke@0 3186 c_calling_convention
duke@0 3187 %{
duke@0 3188 // This is obviously always outgoing
duke@0 3189 (void) SharedRuntime::c_calling_convention(sig_bt, regs, length);
duke@0 3190 %}
duke@0 3191
duke@0 3192 // Location of compiled Java return values. Same as C for now.
duke@0 3193 return_value
duke@0 3194 %{
duke@0 3195 assert(ideal_reg >= Op_RegI && ideal_reg <= Op_RegL,
duke@0 3196 "only return normal values");
duke@0 3197
duke@0 3198 static const int lo[Op_RegL + 1] = {
duke@0 3199 0,
duke@0 3200 0,
coleenp@113 3201 RAX_num, // Op_RegN
duke@0 3202 RAX_num, // Op_RegI
duke@0 3203 RAX_num, // Op_RegP
duke@0 3204 XMM0_num, // Op_RegF
duke@0 3205 XMM0_num, // Op_RegD
duke@0 3206 RAX_num // Op_RegL
duke@0 3207 };
duke@0 3208 static const int hi[Op_RegL + 1] = {
duke@0 3209 0,
duke@0 3210 0,
coleenp@113 3211 OptoReg::Bad, // Op_RegN
duke@0 3212 OptoReg::Bad, // Op_RegI
duke@0 3213 RAX_H_num, // Op_RegP
duke@0 3214 OptoReg::Bad, // Op_RegF
duke@0 3215 XMM0_H_num, // Op_RegD
duke@0 3216 RAX_H_num // Op_RegL
duke@0 3217 };
coleenp@113 3218 assert(ARRAY_SIZE(hi) == _last_machine_leaf - 1, "missing type");
duke@0 3219 return OptoRegPair(hi[ideal_reg], lo[ideal_reg]);
duke@0 3220 %}
duke@0 3221 %}
duke@0 3222
duke@0 3223 //----------ATTRIBUTES---------------------------------------------------------
duke@0 3224 //----------Operand Attributes-------------------------------------------------
duke@0 3225 op_attrib op_cost(0); // Required cost attribute
duke@0 3226
duke@0 3227 //----------Instruction Attributes---------------------------------------------
duke@0 3228 ins_attrib ins_cost(100); // Required cost attribute
duke@0 3229 ins_attrib ins_size(8); // Required size attribute (in bits)
duke@0 3230 ins_attrib ins_short_branch(0); // Required flag: is this instruction
duke@0 3231 // a non-matching short branch variant
duke@0 3232 // of some long branch?
duke@0 3233 ins_attrib ins_alignment(1); // Required alignment attribute (must
duke@0 3234 // be a power of 2) specifies the
duke@0 3235 // alignment that some part of the
duke@0 3236 // instruction (not necessarily the
duke@0 3237 // start) requires. If > 1, a
duke@0 3238 // compute_padding() function must be
duke@0 3239 // provided for the instruction
duke@0 3240
duke@0 3241 //----------OPERANDS-----------------------------------------------------------
duke@0 3242 // Operand definitions must precede instruction definitions for correct parsing
duke@0 3243 // in the ADLC because operands constitute user defined types which are used in
duke@0 3244 // instruction definitions.
duke@0 3245
duke@0 3246 //----------Simple Operands----------------------------------------------------
duke@0 3247 // Immediate Operands
duke@0 3248 // Integer Immediate
duke@0 3249 operand immI()
duke@0 3250 %{
duke@0 3251 match(ConI);
duke@0 3252
duke@0 3253 op_cost(10);
duke@0 3254 format %{ %}
duke@0 3255 interface(CONST_INTER);
duke@0 3256 %}
duke@0 3257
duke@0 3258 // Constant for test vs zero
duke@0 3259 operand immI0()
duke@0 3260 %{
duke@0 3261 predicate(n->get_int() == 0);
duke@0 3262 match(ConI);
duke@0 3263
duke@0 3264 op_cost(0);
duke@0 3265 format %{ %}
duke@0 3266 interface(CONST_INTER);
duke@0 3267 %}
duke@0 3268
duke@0 3269 // Constant for increment
duke@0 3270 operand immI1()
duke@0 3271 %{
duke@0 3272 predicate(n->get_int() == 1);
duke@0 3273 match(ConI);
duke@0 3274
duke@0 3275 op_cost(0);
duke@0 3276 format %{ %}
duke@0 3277 interface(CONST_INTER);
duke@0 3278 %}
duke@0 3279
duke@0 3280 // Constant for decrement
duke@0 3281 operand immI_M1()
duke@0 3282 %{
duke@0 3283 predicate(n->get_int() == -1);
duke@0 3284 match(ConI);
duke@0 3285
duke@0 3286 op_cost(0);
duke@0 3287 format %{ %}
duke@0 3288 interface(CONST_INTER);
duke@0 3289 %}
duke@0 3290
duke@0 3291 // Valid scale values for addressing modes
duke@0 3292 operand immI2()
duke@0 3293 %{
duke@0 3294 predicate(0 <= n->get_int() && (n->get_int() <= 3));
duke@0 3295 match(ConI);
duke@0 3296
duke@0 3297 format %{ %}
duke@0 3298 interface(CONST_INTER);
duke@0 3299 %}
duke@0 3300
duke@0 3301 operand immI8()
duke@0 3302 %{
duke@0 3303 predicate((-0x80 <= n->get_int()) && (n->get_int() < 0x80));
duke@0 3304 match(ConI);
duke@0 3305
duke@0 3306 op_cost(5);
duke@0 3307 format %{ %}
duke@0 3308 interface(CONST_INTER);
duke@0 3309 %}
duke@0 3310
duke@0 3311 operand immI16()
duke@0 3312 %{
duke@0 3313 predicate((-32768 <= n->get_int()) && (n->get_int() <= 32767));
duke@0 3314 match(ConI);
duke@0 3315
duke@0 3316 op_cost(10);
duke@0 3317 format %{ %}
duke@0 3318 interface(CONST_INTER);
duke@0 3319 %}
duke@0 3320
duke@0 3321 // Constant for long shifts
duke@0 3322 operand immI_32()
duke@0 3323 %{
duke@0 3324 predicate( n->get_int() == 32 );
duke@0 3325 match(ConI);
duke@0 3326
duke@0 3327 op_cost(0);
duke@0 3328 format %{ %}
duke@0 3329 interface(CONST_INTER);
duke@0 3330 %}
duke@0 3331
duke@0 3332 // Constant for long shifts
duke@0 3333 operand immI_64()
duke@0 3334 %{
duke@0 3335 predicate( n->get_int() == 64 );
duke@0 3336 match(ConI);
duke@0 3337
duke@0 3338 op_cost(0);
duke@0 3339 format %{ %}
duke@0 3340 interface(CONST_INTER);
duke@0 3341 %}
duke@0 3342
duke@0 3343 // Pointer Immediate
duke@0 3344 operand immP()
duke@0 3345 %{
duke@0 3346 match(ConP);
duke@0 3347
duke@0 3348 op_cost(10);
duke@0 3349 format %{ %}
duke@0 3350 interface(CONST_INTER);
duke@0 3351 %}
duke@0 3352
duke@0 3353 // NULL Pointer Immediate
duke@0 3354 operand immP0()
duke@0 3355 %{
duke@0 3356 predicate(n->get_ptr() == 0);
duke@0 3357 match(ConP);
duke@0 3358
duke@0 3359 op_cost(5);
duke@0 3360 format %{ %}
duke@0 3361 interface(CONST_INTER);
duke@0 3362 %}
duke@0 3363
iveresov@2251 3364 operand immP_poll() %{
iveresov@2251 3365 predicate(n->get_ptr() != 0 && n->get_ptr() == (intptr_t)os::get_polling_page());
iveresov@2251 3366 match(ConP);
iveresov@2251 3367
iveresov@2251 3368 // formats are generated automatically for constants and base registers
iveresov@2251 3369 format %{ %}
iveresov@2251 3370 interface(CONST_INTER);
iveresov@2251 3371 %}
iveresov@2251 3372
coleenp@113 3373 // Pointer Immediate
coleenp@113 3374 operand immN() %{
coleenp@113 3375 match(ConN);
coleenp@113 3376
coleenp@113 3377 op_cost(10);
coleenp@113 3378 format %{ %}
coleenp@113 3379 interface(CONST_INTER);
coleenp@113 3380 %}
coleenp@113 3381
coleenp@113 3382 // NULL Pointer Immediate
coleenp@113 3383 operand immN0() %{
coleenp@113 3384 predicate(n->get_narrowcon() == 0);
coleenp@113 3385 match(ConN);
coleenp@113 3386
coleenp@113 3387 op_cost(5);
coleenp@113 3388 format %{ %}
coleenp@113 3389 interface(CONST_INTER);
coleenp@113 3390 %}
coleenp@113 3391
duke@0 3392 operand immP31()
duke@0 3393 %{
duke@0 3394 predicate(!n->as_Type()->type()->isa_oopptr()
duke@0 3395 && (n->get_ptr() >> 31) == 0);
duke@0 3396 match(ConP);
duke@0 3397
duke@0 3398 op_cost(5);
duke@0 3399 format %{ %}
duke@0 3400 interface(CONST_INTER);
duke@0 3401 %}
duke@0 3402
coleenp@113 3403
duke@0 3404 // Long Immediate
duke@0 3405 operand immL()
duke@0 3406 %{
duke@0 3407 match(ConL);
duke@0 3408
duke@0 3409 op_cost(20);
duke@0 3410 format %{ %}
duke@0 3411 interface(CONST_INTER);
duke@0 3412 %}
duke@0 3413
duke@0 3414 // Long Immediate 8-bit
duke@0 3415 operand immL8()
duke@0 3416 %{
duke@0 3417 predicate(-0x80L <= n->get_long() && n->get_long() < 0x80L);
duke@0 3418 match(ConL);
duke@0 3419
duke@0 3420 op_cost(5);
duke@0 3421 format %{ %}
duke@0 3422 interface(CONST_INTER);
duke@0 3423 %}
duke@0 3424
duke@0 3425 // Long Immediate 32-bit unsigned
duke@0 3426 operand immUL32()
duke@0 3427 %{
duke@0 3428 predicate(n->get_long() == (unsigned int) (n->get_long()));
duke@0 3429 match(ConL);
duke@0 3430
duke@0 3431 op_cost(10);
duke@0 3432 format %{ %}
duke@0 3433 interface(CONST_INTER);
duke@0 3434 %}
duke@0 3435
duke@0 3436 // Long Immediate 32-bit signed
duke@0 3437 operand immL32()
duke@0 3438 %{
duke@0 3439 predicate(n->get_long() == (int) (n->get_long()));
duke@0 3440 match(ConL);
duke@0 3441
duke@0 3442 op_cost(15);
duke@0 3443 format %{ %}
duke@0 3444 interface(CONST_INTER);
duke@0 3445 %}
duke@0 3446
duke@0 3447 // Long Immediate zero
duke@0 3448 operand immL0()
duke@0 3449 %{
duke@0 3450 predicate(n->get_long() == 0L);
duke@0 3451 match(ConL);
duke@0 3452
duke@0 3453 op_cost(10);
duke@0 3454 format %{ %}
duke@0 3455 interface(CONST_INTER);
duke@0 3456 %}
duke@0 3457
duke@0 3458 // Constant for increment
duke@0 3459 operand immL1()
duke@0 3460 %{
duke@0 3461 predicate(n->get_long() == 1);
duke@0 3462 match(ConL);
duke@0 3463
duke@0 3464 format %{ %}
duke@0 3465 interface(CONST_INTER);
duke@0 3466 %}
duke@0 3467
duke@0 3468 // Constant for decrement
duke@0 3469 operand immL_M1()
duke@0 3470 %{
duke@0 3471 predicate(n->get_long() == -1);
duke@0 3472 match(ConL);
duke@0 3473
duke@0 3474 format %{ %}
duke@0 3475 interface(CONST_INTER);
duke@0 3476 %}
duke@0 3477
duke@0 3478 // Long Immediate: the value 10
duke@0 3479 operand immL10()
duke@0 3480 %{
duke@0 3481 predicate(n->get_long() == 10);
duke@0 3482 match(ConL);
duke@0 3483
duke@0 3484 format %{ %}
duke@0 3485 interface(CONST_INTER);
duke@0 3486 %}
duke@0 3487
duke@0 3488 // Long immediate from 0 to 127.
duke@0 3489 // Used for a shorter form of long mul by 10.
duke@0 3490 operand immL_127()
duke@0 3491 %{
duke@0 3492 predicate(0 <= n->get_long() && n->get_long() < 0x80);
duke@0 3493 match(ConL);
duke@0 3494
duke@0 3495 op_cost(10);
duke@0 3496 format %{ %}
duke@0 3497 interface(CONST_INTER);
duke@0 3498 %}
duke@0 3499
duke@0 3500 // Long Immediate: low 32-bit mask
duke@0 3501 operand immL_32bits()
duke@0 3502 %{
duke@0 3503 predicate(n->get_long() == 0xFFFFFFFFL);
duke@0 3504 match(ConL);
duke@0 3505 op_cost(20);
duke@0 3506
duke@0 3507 format %{ %}
duke@0 3508 interface(CONST_INTER);
duke@0 3509 %}
duke@0 3510
duke@0 3511 // Float Immediate zero
duke@0 3512 operand immF0()
duke@0 3513 %{
duke@0 3514 predicate(jint_cast(n->getf()) == 0);
duke@0 3515 match(ConF);
duke@0 3516
duke@0 3517 op_cost(5);
duke@0 3518 format %{ %}
duke@0 3519 interface(CONST_INTER);
duke@0 3520 %}
duke@0 3521
duke@0 3522 // Float Immediate
duke@0 3523 operand immF()
duke@0 3524 %{
duke@0 3525 match(ConF);
duke@0 3526
duke@0 3527 op_cost(15);
duke@0 3528 format %{ %}
duke@0 3529 interface(CONST_INTER);
duke@0 3530 %}
duke@0 3531
duke@0 3532 // Double Immediate zero
duke@0 3533 operand immD0()
duke@0 3534 %{
duke@0 3535 predicate(jlong_cast(n->getd()) == 0);
duke@0 3536 match(ConD);
duke@0 3537
duke@0 3538 op_cost(5);
duke@0 3539 format %{ %}
duke@0 3540 interface(CONST_INTER);
duke@0 3541 %}
duke@0 3542
duke@0 3543 // Double Immediate
duke@0 3544 operand immD()
duke@0 3545 %{
duke@0 3546 match(ConD);
duke@0 3547
duke@0 3548 op_cost(15);
duke@0 3549 format %{ %}
duke@0 3550 interface(CONST_INTER);
duke@0 3551 %}
duke@0 3552
duke@0 3553 // Immediates for special shifts (sign extend)
duke@0 3554
duke@0 3555 // Constants for increment
duke@0 3556 operand immI_16()
duke@0 3557 %{
duke@0 3558 predicate(n->get_int() == 16);
duke@0 3559 match(ConI);
duke@0 3560
duke@0 3561 format %{ %}
duke@0 3562 interface(CONST_INTER);
duke@0 3563 %}
duke@0 3564
duke@0 3565 operand immI_24()
duke@0 3566 %{
duke@0 3567 predicate(n->get_int() == 24);
duke@0 3568 match(ConI);
duke@0 3569
duke@0 3570 format %{ %}
duke@0 3571 interface(CONST_INTER);
duke@0 3572 %}
duke@0 3573
duke@0 3574 // Constant for byte-wide masking
duke@0 3575 operand immI_255()
duke@0 3576 %{
duke@0 3577 predicate(n->get_int() == 255);
duke@0 3578 match(ConI);
duke@0 3579
duke@0 3580 format %{ %}
duke@0 3581 interface(CONST_INTER);
duke@0 3582 %}
duke@0 3583
duke@0 3584 // Constant for short-wide masking
duke@0 3585 operand immI_65535()
duke@0 3586 %{
duke@0 3587 predicate(n->get_int() == 65535);
duke@0 3588 match(ConI);
duke@0 3589
duke@0 3590 format %{ %}
duke@0 3591 interface(CONST_INTER);
duke@0 3592 %}
duke@0 3593
duke@0 3594 // Constant for byte-wide masking
duke@0 3595 operand immL_255()
duke@0 3596 %{
duke@0 3597 predicate(n->get_long() == 255);
duke@0 3598 match(ConL);
duke@0 3599
duke@0 3600 format %{ %}
duke@0 3601 interface(CONST_INTER);
duke@0 3602 %}
duke@0 3603
duke@0 3604 // Constant for short-wide masking
duke@0 3605 operand immL_65535()
duke@0 3606 %{
duke@0 3607 predicate(n->get_long() == 65535);
duke@0 3608 match(ConL);
duke@0 3609
duke@0 3610 format %{ %}
duke@0 3611 interface(CONST_INTER);
duke@0 3612 %}
duke@0 3613
duke@0 3614 // Register Operands
duke@0 3615 // Integer Register
duke@0 3616 operand rRegI()
duke@0 3617 %{
duke@0 3618 constraint(ALLOC_IN_RC(int_reg));
duke@0 3619 match(RegI);
duke@0 3620
duke@0 3621 match(rax_RegI);
duke@0 3622 match(rbx_RegI);
duke@0 3623 match(rcx_RegI);
duke@0 3624 match(rdx_RegI);
duke@0 3625 match(rdi_RegI);
duke@0 3626
duke@0 3627 format %{ %}
duke@0 3628 interface(REG_INTER);
duke@0 3629 %}
duke@0 3630
duke@0 3631 // Special Registers
duke@0 3632 operand rax_RegI()
duke@0 3633 %{
duke@0 3634 constraint(ALLOC_IN_RC(int_rax_reg));
duke@0 3635 match(RegI);
duke@0 3636 match(rRegI);
duke@0 3637
duke@0 3638 format %{ "RAX" %}
duke@0 3639 interface(REG_INTER);
duke@0 3640 %}
duke@0 3641
duke@0 3642 // Special Registers
duke@0 3643 operand rbx_RegI()
duke@0 3644 %{
duke@0 3645 constraint(ALLOC_IN_RC(int_rbx_reg));
duke@0 3646 match(RegI);
duke@0 3647 match(rRegI);
duke@0 3648
duke@0 3649 format %{ "RBX" %}
duke@0 3650 interface(REG_INTER);
duke@0 3651 %}
duke@0 3652
duke@0 3653 operand rcx_RegI()
duke@0 3654 %{
duke@0 3655 constraint(ALLOC_IN_RC(int_rcx_reg));
duke@0 3656 match(RegI);
duke@0 3657 match(rRegI);
duke@0 3658
duke@0 3659 format %{ "RCX" %}
duke@0 3660 interface(REG_INTER);
duke@0 3661 %}
duke@0 3662
duke@0 3663 operand rdx_RegI()
duke@0 3664 %{
duke@0 3665 constraint(ALLOC_IN_RC(int_rdx_reg));
duke@0 3666 match(RegI);
duke@0 3667 match(rRegI);
duke@0 3668
duke@0 3669 format %{ "RDX" %}
duke@0 3670 interface(REG_INTER);
duke@0 3671 %}
duke@0 3672
duke@0 3673 operand rdi_RegI()
duke@0 3674 %{
duke@0 3675 constraint(ALLOC_IN_RC(int_rdi_reg));
duke@0 3676 match(RegI);
duke@0 3677 match(rRegI);
duke@0 3678
duke@0 3679 format %{ "RDI" %}
duke@0 3680 interface(REG_INTER);
duke@0 3681 %}
duke@0 3682
duke@0 3683 operand no_rcx_RegI()
duke@0 3684 %{
duke@0 3685 constraint(ALLOC_IN_RC(int_no_rcx_reg));
duke@0 3686 match(RegI);
duke@0 3687 match(rax_RegI);
duke@0 3688 match(rbx_RegI);
duke@0 3689 match(rdx_RegI);
duke@0 3690 match(rdi_RegI);
duke@0 3691
duke@0 3692 format %{ %}
duke@0 3693 interface(REG_INTER);
duke@0 3694 %}
duke@0 3695
duke@0 3696 operand no_rax_rdx_RegI()
duke@0 3697 %{
duke@0 3698 constraint(ALLOC_IN_RC(int_no_rax_rdx_reg));
duke@0 3699 match(RegI);
duke@0 3700 match(rbx_RegI);
duke@0 3701 match(rcx_RegI);
duke@0 3702 match(rdi_RegI);
duke@0 3703
duke@0 3704 format %{ %}
duke@0 3705 interface(REG_INTER);
duke@0 3706 %}
duke@0 3707
duke@0 3708 // Pointer Register
duke@0 3709 operand any_RegP()
duke@0 3710 %{
duke@0 3711 constraint(ALLOC_IN_RC(any_reg));
duke@0 3712 match(RegP);
duke@0 3713 match(rax_RegP);
duke@0 3714 match(rbx_RegP);
duke@0 3715 match(rdi_RegP);
duke@0 3716 match(rsi_RegP);
duke@0 3717 match(rbp_RegP);
duke@0 3718 match(r15_RegP);
duke@0 3719 match(rRegP);
duke@0 3720
duke@0 3721 format %{ %}
duke@0 3722 interface(REG_INTER);
duke@0 3723 %}
duke@0 3724
duke@0 3725 operand rRegP()
duke@0 3726 %{
duke@0 3727 constraint(ALLOC_IN_RC(ptr_reg));
duke@0 3728 match(RegP);
duke@0 3729 match(rax_RegP);
duke@0 3730 match(rbx_RegP);
duke@0 3731 match(rdi_RegP);
duke@0 3732 match(rsi_RegP);
duke@0 3733 match(rbp_RegP);
duke@0 3734 match(r15_RegP); // See Q&A below about r15_RegP.
duke@0 3735
duke@0 3736 format %{ %}
duke@0 3737 interface(REG_INTER);
duke@0 3738 %}
duke@0 3739
coleenp@113 3740 operand rRegN() %{
coleenp@113 3741 constraint(ALLOC_IN_RC(int_reg));
coleenp@113 3742 match(RegN);
coleenp@113 3743
coleenp@113 3744 format %{ %}
coleenp@113 3745 interface(REG_INTER);
coleenp@113 3746 %}
coleenp@113 3747
duke@0 3748 // Question: Why is r15_RegP (the read-only TLS register) a match for rRegP?
duke@0 3749 // Answer: Operand match rules govern the DFA as it processes instruction inputs.
duke@0 3750 // It's fine for an instruction input which expects rRegP to match a r15_RegP.
duke@0 3751 // The output of an instruction is controlled by the allocator, which respects
duke@0 3752 // register class masks, not match rules. Unless an instruction mentions
duke@0 3753 // r15_RegP or any_RegP explicitly as its output, r15 will not be considered
duke@0 3754 // by the allocator as an input.
duke@0 3755
duke@0 3756 operand no_rax_RegP()
duke@0 3757 %{
duke@0 3758 constraint(ALLOC_IN_RC(ptr_no_rax_reg));
duke@0 3759 match(RegP);
duke@0 3760 match(rbx_RegP);
duke@0 3761 match(rsi_RegP);
duke@0 3762 match(rdi_RegP);
duke@0 3763
duke@0 3764 format %{ %}
duke@0 3765 interface(REG_INTER);
duke@0 3766 %}
duke@0 3767
duke@0 3768 operand no_rbp_RegP()
duke@0 3769 %{
duke@0 3770 constraint(ALLOC_IN_RC(ptr_no_rbp_reg));
duke@0 3771 match(RegP);
duke@0 3772 match(rbx_RegP);
duke@0 3773 match(rsi_RegP);
duke@0 3774 match(rdi_RegP);
duke@0 3775
duke@0 3776 format %{ %}
duke@0 3777 interface(REG_INTER);
duke@0 3778 %}
duke@0 3779
duke@0 3780 operand no_rax_rbx_RegP()
duke@0 3781 %{
duke@0 3782 constraint(ALLOC_IN_RC(ptr_no_rax_rbx_reg));
duke@0 3783 match(RegP);
duke@0 3784 match(rsi_RegP);
duke@0 3785 match(rdi_RegP);
duke@0 3786
duke@0 3787 format %{ %}
duke@0 3788 interface(REG_INTER);
duke@0 3789 %}
duke@0 3790
duke@0 3791 // Special Registers
duke@0 3792 // Return a pointer value
duke@0 3793 operand rax_RegP()
duke@0 3794 %{
duke@0 3795 constraint(ALLOC_IN_RC(ptr_rax_reg));
duke@0 3796 match(RegP);
duke@0 3797 match(rRegP);
duke@0 3798
duke@0 3799 format %{ %}
duke@0 3800 interface(REG_INTER);
duke@0 3801 %}
duke@0 3802
coleenp@113 3803 // Special Registers
coleenp@113 3804 // Return a compressed pointer value
coleenp@113 3805 operand rax_RegN()
coleenp@113 3806 %{
coleenp@113 3807 constraint(ALLOC_IN_RC(int_rax_reg));
coleenp@113 3808 match(RegN);
coleenp@113 3809 match(rRegN);
coleenp@113 3810
coleenp@113 3811 format %{ %}
coleenp@113 3812 interface(REG_INTER);
coleenp@113 3813 %}
coleenp@113 3814
duke@0 3815 // Used in AtomicAdd
duke@0 3816 operand rbx_RegP()
duke@0 3817 %{
duke@0 3818 constraint(ALLOC_IN_RC(ptr_rbx_reg));
duke@0 3819 match(RegP);
duke@0 3820 match(rRegP);
duke@0 3821
duke@0 3822 format %{ %}
duke@0 3823 interface(REG_INTER);
duke@0 3824 %}
duke@0 3825
duke@0 3826 operand rsi_RegP()
duke@0 3827 %{
duke@0 3828 constraint(ALLOC_IN_RC(ptr_rsi_reg));
duke@0 3829 match(RegP);
duke@0 3830 match(rRegP);
duke@0 3831
duke@0 3832 format %{ %}
duke@0 3833 interface(REG_INTER);
duke@0 3834 %}
duke@0 3835
duke@0 3836 // Used in rep stosq
duke@0 3837 operand rdi_RegP()
duke@0 3838 %{
duke@0 3839 constraint(ALLOC_IN_RC(ptr_rdi_reg));
duke@0 3840 match(RegP);
duke@0 3841 match(rRegP);
duke@0 3842
duke@0 3843 format %{ %}
duke@0 3844 interface(REG_INTER);
duke@0 3845 %}
duke@0 3846
duke@0 3847 operand rbp_RegP()
duke@0 3848 %{
duke@0 3849 constraint(ALLOC_IN_RC(ptr_rbp_reg));
duke@0 3850 match(RegP);
duke@0 3851 match(rRegP);
duke@0 3852
duke@0 3853 format %{ %}
duke@0 3854 interface(REG_INTER);
duke@0 3855 %}
duke@0 3856
duke@0 3857 operand r15_RegP()
duke@0 3858 %{
duke@0 3859 constraint(ALLOC_IN_RC(ptr_r15_reg));
duke@0 3860 match(RegP);
duke@0 3861 match(rRegP);
duke@0 3862
duke@0 3863 format %{ %}
duke@0 3864 interface(REG_INTER);
duke@0 3865 %}
duke@0 3866
duke@0 3867 operand rRegL()
duke@0 3868 %{
duke@0 3869 constraint(ALLOC_IN_RC(long_reg));
duke@0 3870 match(RegL);
duke@0 3871 match(rax_RegL);
duke@0 3872 match(rdx_RegL);
duke@0 3873
duke@0 3874 format %{ %}
duke@0 3875 interface(REG_INTER);
duke@0 3876 %}
duke@0 3877
duke@0 3878 // Special Registers
duke@0 3879 operand no_rax_rdx_RegL()
duke@0 3880 %{
duke@0 3881 constraint(ALLOC_IN_RC(long_no_rax_rdx_reg));
duke@0 3882 match(RegL);
duke@0 3883 match(rRegL);