src/cpu/sparc/vm/sparc.ad

changeset 1063
7bb995fbd3c0
parent 1014
0fbdb4381b99
parent 1059
337400e7a5dd
child 1082
bd441136a5ce
equal deleted inserted replaced
1015:ce2272390558 1063:7bb995fbd3c0
187 187
188 // These definitions specify the actual bit encodings of the sparc 188 // These definitions specify the actual bit encodings of the sparc
189 // double fp register numbers. FloatRegisterImpl in register_sparc.hpp 189 // double fp register numbers. FloatRegisterImpl in register_sparc.hpp
190 // wants 0-63, so we have to convert every time we want to use fp regs 190 // wants 0-63, so we have to convert every time we want to use fp regs
191 // with the macroassembler, using reg_to_DoubleFloatRegister_object(). 191 // with the macroassembler, using reg_to_DoubleFloatRegister_object().
192 // 255 is a flag meaning 'dont go here'. 192 // 255 is a flag meaning "don't go here".
193 // I believe we can't handle callee-save doubles D32 and up until 193 // I believe we can't handle callee-save doubles D32 and up until
194 // the place in the sparc stack crawler that asserts on the 255 is 194 // the place in the sparc stack crawler that asserts on the 255 is
195 // fixed up. 195 // fixed up.
196 reg_def R_D32x(SOC, SOC, Op_RegD,255, F32->as_VMReg()); 196 reg_def R_D32x(SOC, SOC, Op_RegD,255, F32->as_VMReg());
197 reg_def R_D32 (SOC, SOC, Op_RegD, 1, F32->as_VMReg()->next()); 197 reg_def R_D32 (SOC, SOC, Op_RegD, 1, F32->as_VMReg()->next());
460 // Must be visible to the DFA in dfa_sparc.cpp 460 // Must be visible to the DFA in dfa_sparc.cpp
461 extern bool can_branch_register( Node *bol, Node *cmp ); 461 extern bool can_branch_register( Node *bol, Node *cmp );
462 462
463 // Macros to extract hi & lo halves from a long pair. 463 // Macros to extract hi & lo halves from a long pair.
464 // G0 is not part of any long pair, so assert on that. 464 // G0 is not part of any long pair, so assert on that.
465 // Prevents accidently using G1 instead of G0. 465 // Prevents accidentally using G1 instead of G0.
466 #define LONG_HI_REG(x) (x) 466 #define LONG_HI_REG(x) (x)
467 #define LONG_LO_REG(x) (x) 467 #define LONG_LO_REG(x) (x)
468 468
469 %} 469 %}
470 470
1429 return size; // Self copy; no move 1429 return size; // Self copy; no move
1430 assert( src_second_rc != rc_bad && dst_second_rc != rc_bad, "src_second & dst_second cannot be Bad" ); 1430 assert( src_second_rc != rc_bad && dst_second_rc != rc_bad, "src_second & dst_second cannot be Bad" );
1431 1431
1432 #ifndef _LP64 1432 #ifndef _LP64
1433 // In the LP64 build, all registers can be moved as aligned/adjacent 1433 // In the LP64 build, all registers can be moved as aligned/adjacent
1434 // pairs, so there's never any need to move the high bits seperately. 1434 // pairs, so there's never any need to move the high bits separately.
1435 // The 32-bit builds have to deal with the 32-bit ABI which can force 1435 // The 32-bit builds have to deal with the 32-bit ABI which can force
1436 // all sorts of silly alignment problems. 1436 // all sorts of silly alignment problems.
1437 1437
1438 // Check for integer reg-reg copy. Hi bits are stuck up in the top 1438 // Check for integer reg-reg copy. Hi bits are stuck up in the top
1439 // 32-bits of a 64-bit register, but are needed in low bits of another 1439 // 32-bits of a 64-bit register, but are needed in low bits of another
1622 Label L; 1622 Label L;
1623 Register G5_ic_reg = reg_to_register_object(Matcher::inline_cache_reg_encode()); 1623 Register G5_ic_reg = reg_to_register_object(Matcher::inline_cache_reg_encode());
1624 Register temp_reg = G3; 1624 Register temp_reg = G3;
1625 assert( G5_ic_reg != temp_reg, "conflicting registers" ); 1625 assert( G5_ic_reg != temp_reg, "conflicting registers" );
1626 1626
1627 // Load klass from reciever 1627 // Load klass from receiver
1628 __ load_klass(O0, temp_reg); 1628 __ load_klass(O0, temp_reg);
1629 // Compare against expected klass 1629 // Compare against expected klass
1630 __ cmp(temp_reg, G5_ic_reg); 1630 __ cmp(temp_reg, G5_ic_reg);
1631 // Branch to miss code, checks xcc or icc depending 1631 // Branch to miss code, checks xcc or icc depending
1632 __ trap(Assembler::notEqual, Assembler::ptr_cc, G0, ST_RESERVED_FOR_USER_0+2); 1632 __ trap(Assembler::notEqual, Assembler::ptr_cc, G0, ST_RESERVED_FOR_USER_0+2);
4147 %} 4147 %}
4148 %} 4148 %}
4149 4149
4150 //----------OPERAND CLASSES---------------------------------------------------- 4150 //----------OPERAND CLASSES----------------------------------------------------
4151 // Operand Classes are groups of operands that are used to simplify 4151 // Operand Classes are groups of operands that are used to simplify
4152 // instruction definitions by not requiring the AD writer to specify seperate 4152 // instruction definitions by not requiring the AD writer to specify separate
4153 // instructions for every form of operand when the instruction accepts 4153 // instructions for every form of operand when the instruction accepts
4154 // multiple operand types with the same basic encoding and format. The classic 4154 // multiple operand types with the same basic encoding and format. The classic
4155 // case of this is memory operands. 4155 // case of this is memory operands.
4156 // Indirect is not included since its use is limited to Compare & Swap 4156 // Indirect is not included since its use is limited to Compare & Swap
4157 opclass memory( indirect, indOffset13, indIndex ); 4157 opclass memory( indirect, indOffset13, indIndex );
5284 instruct loadB(iRegI dst, memory mem) %{ 5284 instruct loadB(iRegI dst, memory mem) %{
5285 match(Set dst (LoadB mem)); 5285 match(Set dst (LoadB mem));
5286 ins_cost(MEMORY_REF_COST); 5286 ins_cost(MEMORY_REF_COST);
5287 5287
5288 size(4); 5288 size(4);
5289 format %{ "LDSB $mem,$dst" %} 5289 format %{ "LDSB $mem,$dst\t! byte" %}
5290 opcode(Assembler::ldsb_op3); 5290 opcode(Assembler::ldsb_op3);
5291 ins_encode(simple_form3_mem_reg( mem, dst ) ); 5291 ins_encode(simple_form3_mem_reg( mem, dst ) );
5292 ins_pipe(iload_mask_mem); 5292 ins_pipe(iload_mask_mem);
5293 %} 5293 %}
5294 5294
5295 // Load Byte (8bit UNsigned) into an int reg 5295 // Load Byte (8bit signed) into a Long Register
5296 instruct loadUB(iRegI dst, memory mem, immI_255 bytemask) %{ 5296 instruct loadB2L(iRegL dst, memory mem) %{
5297 match(Set dst (AndI (LoadB mem) bytemask)); 5297 match(Set dst (ConvI2L (LoadB mem)));
5298 ins_cost(MEMORY_REF_COST); 5298 ins_cost(MEMORY_REF_COST);
5299 5299
5300 size(4); 5300 size(4);
5301 format %{ "LDUB $mem,$dst" %} 5301 format %{ "LDSB $mem,$dst\t! byte -> long" %}
5302 opcode(Assembler::ldsb_op3);
5303 ins_encode(simple_form3_mem_reg( mem, dst ) );
5304 ins_pipe(iload_mask_mem);
5305 %}
5306
5307 // Load Unsigned Byte (8bit UNsigned) into an int reg
5308 instruct loadUB(iRegI dst, memory mem) %{
5309 match(Set dst (LoadUB mem));
5310 ins_cost(MEMORY_REF_COST);
5311
5312 size(4);
5313 format %{ "LDUB $mem,$dst\t! ubyte" %}
5302 opcode(Assembler::ldub_op3); 5314 opcode(Assembler::ldub_op3);
5303 ins_encode(simple_form3_mem_reg( mem, dst ) ); 5315 ins_encode(simple_form3_mem_reg( mem, dst ) );
5304 ins_pipe(iload_mask_mem); 5316 ins_pipe(iload_mask_mem);
5305 %} 5317 %}
5306 5318
5307 // Load Byte (8bit UNsigned) into a Long Register 5319 // Load Unsigned Byte (8bit UNsigned) into a Long Register
5308 instruct loadUBL(iRegL dst, memory mem, immL_FF bytemask) %{ 5320 instruct loadUB2L(iRegL dst, memory mem) %{
5309 match(Set dst (AndL (ConvI2L (LoadB mem)) bytemask)); 5321 match(Set dst (ConvI2L (LoadUB mem)));
5310 ins_cost(MEMORY_REF_COST); 5322 ins_cost(MEMORY_REF_COST);
5311 5323
5312 size(4); 5324 size(4);
5313 format %{ "LDUB $mem,$dst" %} 5325 format %{ "LDUB $mem,$dst\t! ubyte -> long" %}
5314 opcode(Assembler::ldub_op3); 5326 opcode(Assembler::ldub_op3);
5315 ins_encode(simple_form3_mem_reg( mem, dst ) ); 5327 ins_encode(simple_form3_mem_reg( mem, dst ) );
5316 ins_pipe(iload_mask_mem); 5328 ins_pipe(iload_mask_mem);
5317 %} 5329 %}
5318 5330
5319 // Load Unsigned Short/Char (16bit UNsigned) into a Long Register 5331 // Load Short (16bit signed)
5320 instruct loadUS2L(iRegL dst, memory mem, immL_FFFF bytemask) %{ 5332 instruct loadS(iRegI dst, memory mem) %{
5321 match(Set dst (AndL (ConvI2L (LoadUS mem)) bytemask)); 5333 match(Set dst (LoadS mem));
5322 ins_cost(MEMORY_REF_COST); 5334 ins_cost(MEMORY_REF_COST);
5323 5335
5324 size(4); 5336 size(4);
5325 format %{ "LDUH $mem,$dst" %} 5337 format %{ "LDSH $mem,$dst\t! short" %}
5338 opcode(Assembler::ldsh_op3);
5339 ins_encode(simple_form3_mem_reg( mem, dst ) );
5340 ins_pipe(iload_mask_mem);
5341 %}
5342
5343 // Load Short (16bit signed) into a Long Register
5344 instruct loadS2L(iRegL dst, memory mem) %{
5345 match(Set dst (ConvI2L (LoadS mem)));
5346 ins_cost(MEMORY_REF_COST);
5347
5348 size(4);
5349 format %{ "LDSH $mem,$dst\t! short -> long" %}
5350 opcode(Assembler::ldsh_op3);
5351 ins_encode(simple_form3_mem_reg( mem, dst ) );
5352 ins_pipe(iload_mask_mem);
5353 %}
5354
5355 // Load Unsigned Short/Char (16bit UNsigned)
5356 instruct loadUS(iRegI dst, memory mem) %{
5357 match(Set dst (LoadUS mem));
5358 ins_cost(MEMORY_REF_COST);
5359
5360 size(4);
5361 format %{ "LDUH $mem,$dst\t! ushort/char" %}
5326 opcode(Assembler::lduh_op3); 5362 opcode(Assembler::lduh_op3);
5327 ins_encode(simple_form3_mem_reg( mem, dst ) ); 5363 ins_encode(simple_form3_mem_reg( mem, dst ) );
5328 ins_pipe(iload_mask_mem); 5364 ins_pipe(iload_mask_mem);
5329 %} 5365 %}
5330 5366
5331 // Load Unsigned Short/Char (16bit unsigned) 5367 // Load Unsigned Short/Char (16bit UNsigned) into a Long Register
5332 instruct loadUS(iRegI dst, memory mem) %{ 5368 instruct loadUS2L(iRegL dst, memory mem) %{
5333 match(Set dst (LoadUS mem)); 5369 match(Set dst (ConvI2L (LoadUS mem)));
5334 ins_cost(MEMORY_REF_COST); 5370 ins_cost(MEMORY_REF_COST);
5335 5371
5336 size(4); 5372 size(4);
5337 format %{ "LDUH $mem,$dst" %} 5373 format %{ "LDUH $mem,$dst\t! ushort/char -> long" %}
5338 opcode(Assembler::lduh_op3); 5374 opcode(Assembler::lduh_op3);
5339 ins_encode(simple_form3_mem_reg( mem, dst ) ); 5375 ins_encode(simple_form3_mem_reg( mem, dst ) );
5340 ins_pipe(iload_mask_mem); 5376 ins_pipe(iload_mask_mem);
5341 %} 5377 %}
5342 5378
5343 // Load Integer 5379 // Load Integer
5344 instruct loadI(iRegI dst, memory mem) %{ 5380 instruct loadI(iRegI dst, memory mem) %{
5345 match(Set dst (LoadI mem)); 5381 match(Set dst (LoadI mem));
5346 ins_cost(MEMORY_REF_COST); 5382 ins_cost(MEMORY_REF_COST);
5347 size(4); 5383
5348 5384 size(4);
5349 format %{ "LDUW $mem,$dst" %} 5385 format %{ "LDUW $mem,$dst\t! int" %}
5386 opcode(Assembler::lduw_op3);
5387 ins_encode(simple_form3_mem_reg( mem, dst ) );
5388 ins_pipe(iload_mem);
5389 %}
5390
5391 // Load Integer into a Long Register
5392 instruct loadI2L(iRegL dst, memory mem) %{
5393 match(Set dst (ConvI2L (LoadI mem)));
5394 ins_cost(MEMORY_REF_COST);
5395
5396 size(4);
5397 format %{ "LDSW $mem,$dst\t! int -> long" %}
5398 opcode(Assembler::ldsw_op3);
5399 ins_encode(simple_form3_mem_reg( mem, dst ) );
5400 ins_pipe(iload_mem);
5401 %}
5402
5403 // Load Unsigned Integer into a Long Register
5404 instruct loadUI2L(iRegL dst, memory mem) %{
5405 match(Set dst (LoadUI2L mem));
5406 ins_cost(MEMORY_REF_COST);
5407
5408 size(4);
5409 format %{ "LDUW $mem,$dst\t! uint -> long" %}
5350 opcode(Assembler::lduw_op3); 5410 opcode(Assembler::lduw_op3);
5351 ins_encode(simple_form3_mem_reg( mem, dst ) ); 5411 ins_encode(simple_form3_mem_reg( mem, dst ) );
5352 ins_pipe(iload_mem); 5412 ins_pipe(iload_mem);
5353 %} 5413 %}
5354 5414
5355 // Load Long - aligned 5415 // Load Long - aligned
5356 instruct loadL(iRegL dst, memory mem ) %{ 5416 instruct loadL(iRegL dst, memory mem ) %{
5357 match(Set dst (LoadL mem)); 5417 match(Set dst (LoadL mem));
5358 ins_cost(MEMORY_REF_COST); 5418 ins_cost(MEMORY_REF_COST);
5419
5359 size(4); 5420 size(4);
5360 format %{ "LDX $mem,$dst\t! long" %} 5421 format %{ "LDX $mem,$dst\t! long" %}
5361 opcode(Assembler::ldx_op3); 5422 opcode(Assembler::ldx_op3);
5362 ins_encode(simple_form3_mem_reg( mem, dst ) ); 5423 ins_encode(simple_form3_mem_reg( mem, dst ) );
5363 ins_pipe(iload_mem); 5424 ins_pipe(iload_mem);
5469 ins_cost(MEMORY_REF_COST); 5530 ins_cost(MEMORY_REF_COST);
5470 size(4); 5531 size(4);
5471 5532
5472 format %{ "LDUW $mem,$dst\t! compressed ptr" %} 5533 format %{ "LDUW $mem,$dst\t! compressed ptr" %}
5473 ins_encode %{ 5534 ins_encode %{
5474 Register base = as_Register($mem$$base); 5535 Register index = $mem$$index$$Register;
5475 Register index = as_Register($mem$$index);
5476 Register dst = $dst$$Register;
5477 if (index != G0) { 5536 if (index != G0) {
5478 __ lduw(base, index, dst); 5537 __ lduw($mem$$base$$Register, index, $dst$$Register);
5479 } else { 5538 } else {
5480 __ lduw(base, $mem$$disp, dst); 5539 __ lduw($mem$$base$$Register, $mem$$disp, $dst$$Register);
5481 } 5540 }
5482 %} 5541 %}
5483 ins_pipe(iload_mem); 5542 ins_pipe(iload_mem);
5484 %} 5543 %}
5485 5544
5517 } else { 5576 } else {
5518 __ lduw(base, $mem$$disp, dst); 5577 __ lduw(base, $mem$$disp, dst);
5519 } 5578 }
5520 %} 5579 %}
5521 ins_pipe(iload_mem); 5580 ins_pipe(iload_mem);
5522 %}
5523
5524 // Load Short (16bit signed)
5525 instruct loadS(iRegI dst, memory mem) %{
5526 match(Set dst (LoadS mem));
5527 ins_cost(MEMORY_REF_COST);
5528
5529 size(4);
5530 format %{ "LDSH $mem,$dst" %}
5531 opcode(Assembler::ldsh_op3);
5532 ins_encode(simple_form3_mem_reg( mem, dst ) );
5533 ins_pipe(iload_mask_mem);
5534 %} 5581 %}
5535 5582
5536 // Load Double 5583 // Load Double
5537 instruct loadD(regD dst, memory mem) %{ 5584 instruct loadD(regD dst, memory mem) %{
5538 match(Set dst (LoadD mem)); 5585 match(Set dst (LoadD mem));
6845 "SRLX $dst,#32,$dst\t\t! Extract only hi word of result" %} 6892 "SRLX $dst,#32,$dst\t\t! Extract only hi word of result" %}
6846 ins_encode( enc_mul_hi(dst,src1,src2)); 6893 ins_encode( enc_mul_hi(dst,src1,src2));
6847 ins_pipe(sdiv_reg_reg); 6894 ins_pipe(sdiv_reg_reg);
6848 %} 6895 %}
6849 6896
6850 // Magic constant, reciprical of 10 6897 // Magic constant, reciprocal of 10
6851 instruct loadConI_x66666667(iRegIsafe dst) %{ 6898 instruct loadConI_x66666667(iRegIsafe dst) %{
6852 effect( DEF dst ); 6899 effect( DEF dst );
6853 6900
6854 size(8); 6901 size(8);
6855 format %{ "SET 0x66666667,$dst\t! Used in div-by-10" %} 6902 format %{ "SET 0x66666667,$dst\t! Used in div-by-10" %}
6856 ins_encode( Set32(0x66666667, dst) ); 6903 ins_encode( Set32(0x66666667, dst) );
6857 ins_pipe(ialu_hi_lo_reg); 6904 ins_pipe(ialu_hi_lo_reg);
6858 %} 6905 %}
6859 6906
6860 // Register Shift Right Arithmatic Long by 32-63 6907 // Register Shift Right Arithmetic Long by 32-63
6861 instruct sra_31( iRegI dst, iRegI src ) %{ 6908 instruct sra_31( iRegI dst, iRegI src ) %{
6862 effect( DEF dst, USE src ); 6909 effect( DEF dst, USE src );
6863 format %{ "SRA $src,31,$dst\t! Used in div-by-10" %} 6910 format %{ "SRA $src,31,$dst\t! Used in div-by-10" %}
6864 ins_encode( form3_rs1_rd_copysign_hi(src,dst) ); 6911 ins_encode( form3_rs1_rd_copysign_hi(src,dst) );
6865 ins_pipe(ialu_reg_reg); 6912 ins_pipe(ialu_reg_reg);
9046 9093
9047 //----------PEEPHOLE RULES----------------------------------------------------- 9094 //----------PEEPHOLE RULES-----------------------------------------------------
9048 // These must follow all instruction definitions as they use the names 9095 // These must follow all instruction definitions as they use the names
9049 // defined in the instructions definitions. 9096 // defined in the instructions definitions.
9050 // 9097 //
9051 // peepmatch ( root_instr_name [preceeding_instruction]* ); 9098 // peepmatch ( root_instr_name [preceding_instruction]* );
9052 // 9099 //
9053 // peepconstraint %{ 9100 // peepconstraint %{
9054 // (instruction_number.operand_name relational_op instruction_number.operand_name 9101 // (instruction_number.operand_name relational_op instruction_number.operand_name
9055 // [, ...] ); 9102 // [, ...] );
9056 // // instruction numbers are zero-based using left to right order in peepmatch 9103 // // instruction numbers are zero-based using left to right order in peepmatch

mercurial