From 8832500ce59d52f5ab5774189780ac729340d5bb Mon Sep 17 00:00:00 2001 From: John Hodge Date: Tue, 29 Oct 2019 20:38:38 +0800 Subject: Codegen C - More inline assembly hackery --- src/trans/codegen_c.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'src') 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. -- cgit v1.2.3