genCall (PrimTarget (MO_Cmpxchg _width))
        [dst] [addr, old, new] = runStmtsDecls $ do
    addrVar <- exprToVarW addr
    oldVar <- exprToVarW old
    newVar <- exprToVarW new
    let targetTy = getVarType oldVar
        ptrExpr = Cast LM_Inttoptr addrVar (pLift targetTy)
    ptrVar <- doExprW (pLift targetTy) ptrExpr
    dstVar <- getCmmRegW (CmmLocal dst)
    retVar <- doExprW (LMStructU [targetTy,i1])
              $ CmpXChg ptrVar oldVar newVar SyncSeqCst SyncSeqCst
    retVar' <- doExprW targetTy $ ExtractV retVar 0
    statement $ Store retVar' dstVar
genCall (PrimTarget (MO_Cmpxchg _width))
        [dst] [addr, old, new] = runStmtsDecls $ do
    addrVar <- exprToVarW addr
    oldVar <- exprToVarW old
    newVar <- exprToVarW new
    let targetTy = getVarType oldVar
        ptrExpr = Cast LM_Inttoptr addrVar (pLift targetTy)
    ptrVar <- doExprW (pLift targetTy) ptrExpr
    dstVar <- getCmmRegW (CmmLocal dst)
    retVar <- doExprW (LMStructU [targetTy,i1])
              $ CmpXChg ptrVar oldVar newVar SyncSeqCst SyncSeqCst
    retVar' <- doExprW targetTy $ ExtractV retVar 0
    statement $ Store retVar' dstVar
genCall (PrimTarget (MO_Cmpxchg _width))
        [dst] [addr, old, new] = runStmtsDecls $ do
    addrVar <- exprToVarW addr
    oldVar <- exprToVarW old
    newVar <- exprToVarW new
    let targetTy = getVarType oldVar
        ptrExpr = Cast LM_Inttoptr addrVar (pLift targetTy)
    ptrVar <- doExprW (pLift targetTy) ptrExpr
    dstVar <- getCmmRegW (CmmLocal dst)
    retVar <- doExprW (LMStructU [targetTy,i1])
              $ CmpXChg ptrVar oldVar newVar SyncSeqCst SyncSeqCst
    retVar' <- doExprW targetTy $ ExtractV retVar 0
    statement $ Store retVar' dstVar