comparison src/cpu/sparc/vm/sparc.ad @ 6795:7eca5de9e0b6

7023898: Intrinsify AtomicLongFieldUpdater.getAndIncrement() Summary: use shorter instruction sequences for atomic add and atomic exchange when possible. Reviewed-by: kvn, jrose
author roland
date Thu, 20 Sep 2012 16:49:17 +0200
parents da91efe96a93
children 859c45fb8cea
comparison
equal deleted inserted replaced
6794:8ae8f9dd7099 6795:7eca5de9e0b6
1835 case Op_CountTrailingZerosI: 1835 case Op_CountTrailingZerosI:
1836 case Op_CountTrailingZerosL: 1836 case Op_CountTrailingZerosL:
1837 case Op_PopCountI: 1837 case Op_PopCountI:
1838 case Op_PopCountL: 1838 case Op_PopCountL:
1839 if (!UsePopCountInstruction) 1839 if (!UsePopCountInstruction)
1840 return false;
1841 case Op_CompareAndSwapL:
1842 #ifdef _LP64
1843 case Op_CompareAndSwapP:
1844 #endif
1845 if (!VM_Version::supports_cx8())
1840 return false; 1846 return false;
1841 break; 1847 break;
1842 } 1848 }
1843 1849
1844 return true; // Per default match rules are supported. 1850 return true; // Per default match rules are supported.
7197 %} 7203 %}
7198 7204
7199 // No flag versions for CompareAndSwap{P,I,L} because matcher can't match them 7205 // No flag versions for CompareAndSwap{P,I,L} because matcher can't match them
7200 7206
7201 instruct compareAndSwapL_bool(iRegP mem_ptr, iRegL oldval, iRegL newval, iRegI res, o7RegI tmp1, flagsReg ccr ) %{ 7207 instruct compareAndSwapL_bool(iRegP mem_ptr, iRegL oldval, iRegL newval, iRegI res, o7RegI tmp1, flagsReg ccr ) %{
7208 predicate(VM_Version::supports_cx8());
7202 match(Set res (CompareAndSwapL mem_ptr (Binary oldval newval))); 7209 match(Set res (CompareAndSwapL mem_ptr (Binary oldval newval)));
7203 effect( USE mem_ptr, KILL ccr, KILL tmp1); 7210 effect( USE mem_ptr, KILL ccr, KILL tmp1);
7204 format %{ 7211 format %{
7205 "MOV $newval,O7\n\t" 7212 "MOV $newval,O7\n\t"
7206 "CASXA [$mem_ptr],$oldval,O7\t! If $oldval==[$mem_ptr] Then store O7 into [$mem_ptr], set O7=[$mem_ptr] in any case\n\t" 7213 "CASXA [$mem_ptr],$oldval,O7\t! If $oldval==[$mem_ptr] Then store O7 into [$mem_ptr], set O7=[$mem_ptr] in any case\n\t"
7228 enc_iflags_ne_to_boolean(res) ); 7235 enc_iflags_ne_to_boolean(res) );
7229 ins_pipe( long_memory_op ); 7236 ins_pipe( long_memory_op );
7230 %} 7237 %}
7231 7238
7232 instruct compareAndSwapP_bool(iRegP mem_ptr, iRegP oldval, iRegP newval, iRegI res, o7RegI tmp1, flagsReg ccr ) %{ 7239 instruct compareAndSwapP_bool(iRegP mem_ptr, iRegP oldval, iRegP newval, iRegI res, o7RegI tmp1, flagsReg ccr ) %{
7240 #ifdef _LP64
7241 predicate(VM_Version::supports_cx8());
7242 #endif
7233 match(Set res (CompareAndSwapP mem_ptr (Binary oldval newval))); 7243 match(Set res (CompareAndSwapP mem_ptr (Binary oldval newval)));
7234 effect( USE mem_ptr, KILL ccr, KILL tmp1); 7244 effect( USE mem_ptr, KILL ccr, KILL tmp1);
7235 format %{ 7245 format %{
7236 "MOV $newval,O7\n\t" 7246 "MOV $newval,O7\n\t"
7237 "CASA_PTR [$mem_ptr],$oldval,O7\t! If $oldval==[$mem_ptr] Then store O7 into [$mem_ptr], set O7=[$mem_ptr] in any case\n\t" 7247 "CASA_PTR [$mem_ptr],$oldval,O7\t! If $oldval==[$mem_ptr] Then store O7 into [$mem_ptr], set O7=[$mem_ptr] in any case\n\t"
7259 "MOV 1,$res\n\t" 7269 "MOV 1,$res\n\t"
7260 "MOVne icc,R_G0,$res" 7270 "MOVne icc,R_G0,$res"
7261 %} 7271 %}
7262 ins_encode( enc_casi(mem_ptr, oldval, newval), 7272 ins_encode( enc_casi(mem_ptr, oldval, newval),
7263 enc_iflags_ne_to_boolean(res) ); 7273 enc_iflags_ne_to_boolean(res) );
7274 ins_pipe( long_memory_op );
7275 %}
7276
7277 instruct xchgI( memory mem, iRegI newval) %{
7278 match(Set newval (GetAndSetI mem newval));
7279 format %{ "SWAP [$mem],$newval" %}
7280 size(4);
7281 ins_encode %{
7282 __ swap($mem$$Address, $newval$$Register);
7283 %}
7284 ins_pipe( long_memory_op );
7285 %}
7286
7287 #ifndef _LP64
7288 instruct xchgP( memory mem, iRegP newval) %{
7289 match(Set newval (GetAndSetP mem newval));
7290 format %{ "SWAP [$mem],$newval" %}
7291 size(4);
7292 ins_encode %{
7293 __ swap($mem$$Address, $newval$$Register);
7294 %}
7295 ins_pipe( long_memory_op );
7296 %}
7297 #endif
7298
7299 instruct xchgN( memory mem, iRegN newval) %{
7300 match(Set newval (GetAndSetN mem newval));
7301 format %{ "SWAP [$mem],$newval" %}
7302 size(4);
7303 ins_encode %{
7304 __ swap($mem$$Address, $newval$$Register);
7305 %}
7264 ins_pipe( long_memory_op ); 7306 ins_pipe( long_memory_op );
7265 %} 7307 %}
7266 7308
7267 //--------------------- 7309 //---------------------
7268 // Subtraction Instructions 7310 // Subtraction Instructions