diff options
author | John Hodge <tpg@mutabah.net> | 2019-10-29 20:38:38 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2019-10-29 20:38:38 +0800 |
commit | 8832500ce59d52f5ab5774189780ac729340d5bb (patch) | |
tree | 4ce46a2a7bf8890e33d078dd60e5646ab6256ffd /src | |
parent | a1a03108029fa6bd092bc8f141acbc4cdb210e01 (diff) | |
download | mrust-8832500ce59d52f5ab5774189780ac729340d5bb.tar.gz |
Codegen C - More inline assembly hackery
Diffstat (limited to 'src')
-rw-r--r-- | src/trans/codegen_c.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/trans/codegen_c.cpp b/src/trans/codegen_c.cpp index 5f22f081..631db28b 100644 --- a/src/trans/codegen_c.cpp +++ b/src/trans/codegen_c.cpp @@ -4096,6 +4096,43 @@ namespace { m_of << " }\n"; return ; } + // parking_lot src/elision.rs + else if( matches_template("xacquire; lock; cmpxchgl $2, $1", /*input=*/{"r", "{rax}"}, /*output=*/{"={rax}", "+*m"}) ) + { + m_of << indent << "InterlockedCompareExchangeAcquire("; + emit_lvalue(e.outputs[1].second); m_of << ","; + emit_lvalue(e.inputs[0].second); m_of << ","; + emit_lvalue(e.inputs[1].second); + m_of << ");\n"; + return ; + } + else if( matches_template("xrelease; lock; cmpxchgl $2, $1", /*input=*/{"r", "{rax}"}, /*output=*/{"={rax}", "+*m"}) ) + { + m_of << indent << "InterlockedCompareExchangeRelease("; + emit_lvalue(e.outputs[1].second); m_of << ","; + emit_lvalue(e.inputs[0].second); m_of << ","; + emit_lvalue(e.inputs[1].second); + m_of << ");\n"; + return ; + } + else if( matches_template("xacquire; lock; cmpxchgq $2, $1", /*input=*/{"r", "{rax}"}, /*output=*/{"={rax}", "+*m"}) ) + { + m_of << indent << "InterlockedCompareExchange64Acquire("; + emit_lvalue(e.outputs[1].second); m_of << ","; + emit_lvalue(e.inputs[0].second); m_of << ","; + emit_lvalue(e.inputs[1].second); + m_of << ");\n"; + return ; + } + else if( matches_template("xrelease; lock; cmpxchgq $2, $1", /*input=*/{"r", "{rax}"}, /*output=*/{"={rax}", "+*m"}) ) + { + m_of << indent << "InterlockedCompareExchange64Release("; + emit_lvalue(e.outputs[1].second); m_of << ","; + emit_lvalue(e.inputs[0].second); m_of << ","; + emit_lvalue(e.inputs[1].second); + m_of << ");\n"; + return ; + } else { // No hard-coded translations. |